import cx from "classnames"; import React from "react"; const CLASS_ROOT = "checkbox"; export type CheckboxSize = "default" | "large"; export interface CheckboxProps extends Omit, "size"> { /** Html id attribute */ id: string; /** Checked state. */ isChecked?: boolean; /** Disabled state. */ isDisabled?: boolean; /** Invalid state */ isInvalid?: boolean; /** Checkbox is displayed as Toggle */ isToggle?: boolean; /** Html name attribute. Id is used when not set.*/ name?: string; /** Size of element. */ size?: CheckboxSize; className?: string; } const defaultProps = { size: "default" as CheckboxSize, }; const Checkbox: React.FC = ({ id, isChecked, isDisabled, isInvalid, isToggle, name, size = defaultProps.size, className, ...other }) => { const classes = cx(CLASS_ROOT, className, { [`${CLASS_ROOT}--${size}`]: size !== defaultProps.size, "is-invalid": isInvalid, }); const inputName = name || id; const CheckboxInput = () => ( <>
); return isToggle ? (
) : ( ); }; Checkbox.displayName = "Checkbox"; export { Checkbox };