import React, { CSSProperties, HTMLAttributes } from 'react' import classNames from 'classnames' import _ from 'lodash' import { CheckboxGroupContext } from './util' import Checkbox, { CheckboxProps } from './checkbox' interface CheckboxGroupProps extends Omit, 'onChange'> { value?: V[] onChange?: (value: V[]) => void name?: string className?: string style?: CSSProperties options?: CheckboxProps[] } function CheckboxGroup({ value = [], onChange = _.noop, name, className, options = [], children, ...rest }: CheckboxGroupProps) { const handleChange = (cValue: V): void => { if (value?.includes(cValue)) { onChange(_.without(value, cValue)) } else { onChange([...value, cValue]) } } const isOptions = options.length > 0 return (
{isOptions ? options.map((option, index) => ) : children}
) } export default CheckboxGroup export type { CheckboxGroupProps }