| 1 |
import classNames from 'classnames'; |
| 2 |
|
| 3 |
export const CheckboxInput = ({ |
| 4 |
label, |
| 5 |
slug, |
| 6 |
description, |
| 7 |
checked, |
| 8 |
onChange, |
| 9 |
locked = false, |
| 10 |
}) => { |
| 11 |
return ( |
| 12 |
<label |
| 13 |
className={classNames('flex items-center px-4 py-3.5', { |
| 14 |
'cursor-not-allowed': locked, |
| 15 |
'focus-within:text-design-main hover:text-design-main': !locked, |
| 16 |
})} |
| 17 |
htmlFor={slug}> |
| 18 |
<span className="relative mr-3 inline-block h-5 w-5 align-middle rtl:ml-3 rtl:mr-0"> |
| 19 |
<input |
| 20 |
id={slug} |
| 21 |
className="m-0 h-5 w-5 rounded-sm" |
| 22 |
style={{ |
| 23 |
'--ext-design-main': locked ? '#BBBBBB' : undefined, |
| 24 |
}} |
| 25 |
disabled={locked} |
| 26 |
type="checkbox" |
| 27 |
onChange={locked ? undefined : onChange} |
| 28 |
checked={locked ? true : checked} |
| 29 |
/> |
| 30 |
<svg |
| 31 |
className={classNames('absolute inset-0 block h-5 w-5', { |
| 32 |
'text-white': checked, |
| 33 |
'text-transparent': !checked, |
| 34 |
})} |
| 35 |
viewBox="1 0 20 20" |
| 36 |
fill="none" |
| 37 |
xmlns="http://www.w3.org/2000/svg" |
| 38 |
role="presentation"> |
| 39 |
<path |
| 40 |
d="M8.72912 13.7449L5.77536 10.7911L4.76953 11.7899L8.72912 15.7495L17.2291 7.24948L16.2304 6.25073L8.72912 13.7449Z" |
| 41 |
fill="currentColor" |
| 42 |
/> |
| 43 |
</svg> |
| 44 |
</span> |
| 45 |
<span className="flex grow flex-col overflow-hidden"> |
| 46 |
<span className="truncate text-base font-medium leading-tight"> |
| 47 |
{label} |
| 48 |
</span> |
| 49 |
{description ? ( |
| 50 |
<span className="block pt-1">{description}</span> |
| 51 |
) : ( |
| 52 |
<span /> |
| 53 |
)} |
| 54 |
</span> |
| 55 |
</label> |
| 56 |
); |
| 57 |
}; |
| 58 |
|