import * as React from 'react'; import * as CheckControlBase from '@tesseract-design/web-base-checkcontrol'; export type ToggleTickBoxProps = Omit, 'type' | 'style'> & { /** * Should the component occupy the whole width of its parent? */ block?: boolean, /** * Does the component need to conserve space? */ compact?: boolean, /** * Complementary content of the component. */ subtext?: React.ReactNode, /** * Does the component have indeterminate check state? */ indeterminate?: boolean, } /** * Component for performing an action upon activation (e.g. when clicked). * * This component functions as a regular button. */ export const ToggleTickBox = React.forwardRef( ( { children, block = false, compact = false, subtext, indeterminate = false, className: _className, as: _as, ...etcProps }: ToggleTickBoxProps, ref, ) => { const styleProps = React.useMemo(() => ({ block, compact, appearance: CheckControlBase.CheckControlAppearance.TICK_BOX, type: CheckControlBase.CheckControlType.CHECKBOX, uncheckedLabel: false, }), [block, compact]); const defaultRef = React.useRef(null); const theRef = (ref ?? defaultRef) as React.MutableRefObject; React.useEffect(() => { if (!(indeterminate && theRef.current)) { return; } theRef.current.indeterminate = indeterminate; }, [theRef, indeterminate]); return (
); }, ); ToggleTickBox.displayName = 'ActionButton';