2023-12-15 17:34:50 +03:00
|
|
|
import clsx from 'clsx';
|
2023-12-25 16:53:27 +03:00
|
|
|
import { motion } from 'framer-motion';
|
|
|
|
|
|
|
|
import { animateDropdownItem } from '@/utils/animations';
|
2023-12-15 17:34:50 +03:00
|
|
|
|
2023-09-02 01:11:27 +03:00
|
|
|
import Checkbox from './Checkbox';
|
|
|
|
|
|
|
|
interface DropdownCheckboxProps {
|
2023-09-07 16:30:43 +03:00
|
|
|
value: boolean
|
2023-09-02 01:11:27 +03:00
|
|
|
label?: string
|
2023-12-18 19:42:27 +03:00
|
|
|
title?: string
|
2023-09-02 01:11:27 +03:00
|
|
|
disabled?: boolean
|
2023-09-07 16:30:43 +03:00
|
|
|
setValue?: (newValue: boolean) => void
|
2023-09-02 01:11:27 +03:00
|
|
|
}
|
|
|
|
|
2023-12-18 19:42:27 +03:00
|
|
|
function DropdownCheckbox({ title, setValue, disabled, ...restProps }: DropdownCheckboxProps) {
|
2023-09-02 01:11:27 +03:00
|
|
|
return (
|
2023-12-25 16:53:27 +03:00
|
|
|
<motion.div
|
|
|
|
variants={animateDropdownItem}
|
2023-12-18 19:42:27 +03:00
|
|
|
title={title}
|
2023-12-15 17:34:50 +03:00
|
|
|
className={clsx(
|
|
|
|
'px-3 py-1',
|
|
|
|
'text-left overflow-ellipsis whitespace-nowrap',
|
|
|
|
'disabled:clr-text-controls',
|
|
|
|
!!setValue && !disabled && 'clr-hover'
|
|
|
|
)}
|
2023-12-05 01:22:44 +03:00
|
|
|
>
|
2023-12-18 12:25:39 +03:00
|
|
|
<Checkbox
|
2023-12-05 01:22:44 +03:00
|
|
|
disabled={disabled}
|
|
|
|
setValue={setValue}
|
|
|
|
{...restProps}
|
|
|
|
/>
|
2023-12-25 16:53:27 +03:00
|
|
|
</motion.div>);
|
2023-09-02 01:11:27 +03:00
|
|
|
}
|
|
|
|
|
2023-12-15 17:34:50 +03:00
|
|
|
export default DropdownCheckbox;
|