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 | 1x 5x 5x 5x 1x | import isEqual from 'lodash.isequal'
import PropTypes from 'prop-types'
import Injector from '@s-ui/react-primitive-injector'
const ExtendedChildren = ({value, children, onSelect, checkbox, ...props}) => {
const {value: valueChild} = children.props
const selected = Array.isArray(value)
? value.some(innerValue => isEqual(valueChild, innerValue))
: isEqual(value, valueChild)
return (
<Injector
{...{
...props,
selected,
onSelect,
checkbox
}}
>
{children}
</Injector>
)
}
ExtendedChildren.propTypes = {
/** selected value */
value: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
/** checkbox contained in all DropdownOption **/
checkbox: PropTypes.bool,
/** each single node to be included in the list (MoleculeDropdownOption) */
children: PropTypes.node,
/** callback on select option **/
onSelect: PropTypes.func
}
export default ExtendedChildren
|