import type { CheckboxProps as AriaCheckboxProps } from 'react-aria-components'; import { Checkbox as AriaCheckbox, composeRenderProps } from 'react-aria-components'; import { tv } from 'tailwind-variants'; const checkbox = tv({ base: 'inline-flex items-center gap-2 text-sm font-medium leading-7', variants: { isDisabled: { true: 'text-dabeeo-gray-be', }, }, }); const box = tv({ base: 'w-4 h-4 box-border shrink-0 flex items-center justify-center text-white border border-dabeeo-gray-be transition', variants: { isSelected: { true: 'bg-primary border-primary', }, isDisabled: { true: 'text-dabeeo-gray-99 bg-dabeeo-gray-eb border-dabeeo-gray-be cursor-not-allowed', }, isFocusVisible: { true: 'ring-2 ring-offset-2 ring-primary', }, }, compoundVariants: [], }); export const Checkbox = (props: AriaCheckboxProps) => { const { className, children, ...restProps } = props; return ( checkbox({ ...renderProps, className }))} {...restProps} > {composeRenderProps(children, (children, { isSelected, isIndeterminate, ...renderProps }) => ( <>
{isIndeterminate ? ( ) : isSelected ? ( ) : null}
{children} ))}
); };