40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
'use client';
|
|||
|
|
|
||
|
|
import * as React from 'react';
|
||
|
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
||
|
|
import { Check, Minus } from 'lucide-react';
|
||
|
|
import { cn } from '@imphnen-frontend-service/utils';
|
||
|
|
|
||
|
|
function Checkbox({
|
||
|
|
className,
|
||
|
|
...props
|
||
|
|
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
||
|
|
return (
|
||
|
|
<CheckboxPrimitive.Root
|
||
|
|
data-slot="checkbox"
|
||
|
|
className={cn(
|
||
|
|
'peer size-4 shrink-0 rounded-sm border border-neutral-300 bg-background shadow-sm',
|
||
|
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
||
|
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
||
|
|
'data-[state=checked]:bg-primary-500 data-[state=checked]:text-white data-[state=checked]:border-primary-500',
|
||
|
|
'data-[state=indeterminate]:bg-primary-500 data-[state=indeterminate]:text-white data-[state=indeterminate]:border-primary-500',
|
||
|
|
className
|
||
|
|
)}
|
||
|
|
{...props}
|
||
|
|
>
|
||
|
|
<CheckboxPrimitive.Indicator
|
||
|
|
data-slot="checkbox-indicator"
|
||
|
|
className="flex items-center justify-center text-current"
|
||
|
|
>
|
||
|
|
{props.checked === 'indeterminate' ? (
|
||
|
|
<Minus className="size-3.5" />
|
||
|
|
) : (
|
||
|
|
<Check className="size-3.5" />
|
||
|
|
)}
|
||
|
|
</CheckboxPrimitive.Indicator>
|
||
|
|
</CheckboxPrimitive.Root>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
export { Checkbox };
|