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 | 1x 1x 1x 1x 1x 1x 1x 1x 18x 1x 1x 1x 28x 28x 28x 1x 14x | import {Children, createContext, useContext} from 'react'
import cx from 'classnames'
import {inputSizes} from '@s-ui/react-atom-input'
import {atomTagSizes} from '@s-ui/react-atom-tag'
import {moleculeDropdownListSizes} from '@s-ui/react-molecule-dropdown-list'
export const BASE_CLASS = `sui-MoleculeSelect`
export const CLASS_FOCUS = `${BASE_CLASS}--focus`
export const CLASS_DISABLED = `is-disabled`
export const SELECT_STATES = {
ERROR: 'error',
SUCCESS: 'success',
ALERT: 'alert'
}
export const SELECT_INPUT_SIZES = {...inputSizes}
export const SELECT_TAG_SIZES = {...atomTagSizes}
export const SELECT_DROPDOWN_LIST_SIZES = {...moleculeDropdownListSizes}
export const DropdownContext = createContext()
export const useDropdown = () => useContext(DropdownContext)
export const ENABLED_KEYS = ['Enter', 'ArrowDown', 'ArrowUp']
export const SELECTION_KEYS = [' ', 'Enter']
export const getOptionData = children => {
const optionsData = {}
Children.forEach(children, child => {
const {children, value} = child.props
optionsData[value] = children
})
return optionsData
}
export const getClassName = ({state, errorState, disabled, className, isBorderless}) =>
cx(
BASE_CLASS,
errorState && `${BASE_CLASS}--${SELECT_STATES.ERROR}`,
errorState === false && `${BASE_CLASS}--${SELECT_STATES.SUCCESS}`,
state && `${BASE_CLASS}--${state}`,
isBorderless && `${BASE_CLASS}--isBorderless`,
{
[CLASS_DISABLED]: disabled
},
className
)
|