Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | 1x 1x 1x 1x 1x 13x 13x 1x 1x 1x 1x 13x 13x 9x 4x 1x 1x 5x 2x 1x 1x | import {filterKeys} from './helpers.js'
export const ACTIONABLE_ONLY_PROPS = [
'href',
'iconPlacement',
'target',
'actionable',
'linkFactory',
'rel',
'pressed',
'defaultPressed'
]
export const STANDARD_ONLY_PROPS = ['closeIcon', 'onClose', 'closeLabel']
export const SIZES = {
XLARGE: 'xl',
LARGE: 'l',
MEDIUM: 'm',
SMALL: 's',
XSMALL: 'xs'
}
export const COLORS = {
PRIMARY: 'primary',
ACCENT: 'accent',
SUCCESS: 'success',
ALERT: 'alert',
ERROR: 'error',
NEUTRAL: 'neutral',
SURFACE: 'surface'
}
export const getColor = ({isActionable, color}) => {
Iif (color !== undefined && Object.values(COLORS).includes(color)) {
return color
}
return isActionable ? COLORS.PRIMARY : COLORS.NEUTRAL
}
export const ICON_PLACEMENTS = {
LEFT: 'left',
RIGHT: 'right'
}
export const LINK_TYPES = {
NOFOLLOW: 'nofollow',
NOOPENER: 'noopener',
NOREFERRER: 'noreferrer',
PREV: 'prev',
NEXT: 'next',
TAG: 'tag'
}
export const DESIGNS = {
SOLID: 'solid',
TINTED: 'tinted',
OUTLINE: 'outline',
DASHED: 'dashed'
}
export const getDesign = ({isActionable, design}) => {
Iif (design !== undefined && Object.values(DESIGNS).includes(design)) {
return design
}
return isActionable ? DESIGNS.SOLID : DESIGNS.TINTED
}
/**
* Removes all actionable tag props from the react props
* @return {Object}
*/
export const getStandardProps = props => filterKeys(props, ACTIONABLE_ONLY_PROPS)
/**
* Removes all standard tag props from the react props
* @return {Object}
*/
export const getActionableProps = props => filterKeys(props, STANDARD_ONLY_PROPS)
export const isFunction = fn => typeof fn === 'function'
export const onHandler = ({disabled, readOnly}, handler, {...args} = {}) => {
return event => {
if (!(disabled || readOnly)) {
event.stopPropagation()
isFunction(handler) && handler(event, {...args})
}
}
}
|