import React, { useState } from 'react'; import { v4 as uuidv4 } from 'uuid'; import styles from './styles.module.scss'; import colorVariables from '../../variables/colors.json'; type CheckboxPropsBase = { checked: boolean, id?: string, color?: string disabled?: boolean, onChange?: (event: React.ChangeEvent) => void, label?: React.ReactNode, }; type NativeCheckboxProps = React.HTMLProps; // Allow passing native checkbox props, but Omit those that we define in CheckboxPropsBase so they don't conflict type CheckboxProps = Omit & CheckboxPropsBase; const Checkbox: React.FunctionComponent = ({ id, color, checked, disabled=false, onChange, label="", ...props}) => { const [idProp] = useState(id || `checkbox-${uuidv4()}`); return (
e.stopPropagation()} >
); } Checkbox.defaultProps = { id: undefined, checked: false, disabled: false, color: colorVariables.midnight, }; export default Checkbox;