{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checkbox-15",
  "type": "registry:component",
  "title": "Checkbox 15",
  "description": "Checkbox 15. A checkbox component for selecting options.",
  "dependencies": [
    "@base-ui/react",
    "lucide-react"
  ],
  "registryDependencies": [
    "label"
  ],
  "files": [
    {
      "path": "components/watermelon/checkbox-15.tsx",
      "type": "registry:component",
      "content": "'use client'\n\nimport { useMemo, useState } from 'react'\n\nimport { CheckIcon, MinusIcon } from 'lucide-react'\n\nimport { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox'\n\nimport { Label } from '@/components/base-ui/label'\nimport { cn } from '@/lib/utils'\n\nconst items = ['Module 1', 'Module 2', 'Module 3'] as const\n\ntype Item = (typeof items)[number]\ntype CheckboxRootProps = CheckboxPrimitive.Root.Props\n\nconst Checkbox = ({\n  checked,\n  className,\n  indeterminate = false,\n  ...props\n}: CheckboxRootProps) => {\n  return (\n    <CheckboxPrimitive.Root\n      data-slot='checkbox'\n      checked={checked}\n      indeterminate={indeterminate}\n      className={cn(\n        'peer relative flex size-4 shrink-0 items-center justify-center rounded-[5px] border border-input bg-background outline-none transition-colors focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30 data-checked:border-sky-600 data-checked:bg-sky-600 data-checked:text-white data-indeterminate:border-input data-indeterminate:bg-background data-indeterminate:text-muted-foreground dark:data-checked:border-sky-500 dark:data-checked:bg-sky-500 dark:data-indeterminate:border-input dark:data-indeterminate:bg-input/30 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40',\n        className\n      )}\n      {...props}\n    >\n      <CheckboxPrimitive.Indicator\n        data-slot='checkbox-indicator'\n        className='grid place-content-center text-current transition-none'\n      >\n        {indeterminate ? (\n          <MinusIcon className='size-2.5' />\n        ) : checked ? (\n          <CheckIcon className='size-3.5' />\n        ) : null}\n      </CheckboxPrimitive.Indicator>\n    </CheckboxPrimitive.Root>\n  )\n}\n\nconst Checkbox15 = () => {\n  const [selectedItems, setSelectedItems] = useState<Item[]>([\n    'Module 1',\n    'Module 2'\n  ])\n\n  const allChildrenSelected = useMemo(\n    () => selectedItems.length === items.length,\n    [selectedItems]\n  )\n  const isParentIndeterminate = useMemo(\n    () => selectedItems.length > 0 && selectedItems.length < items.length,\n    [selectedItems]\n  )\n\n  const handleParentCheckedChange = (checked: boolean) => {\n    if (checked) {\n      setSelectedItems([...items])\n    } else {\n      setSelectedItems([])\n    }\n  }\n\n  const handleChildCheckedChange = (item: Item, checked: boolean) => {\n    setSelectedItems((previousSelectedItems) =>\n      checked\n        ? previousSelectedItems.includes(item)\n          ? previousSelectedItems\n          : [...previousSelectedItems, item]\n        : previousSelectedItems.filter((selectedItem) => selectedItem !== item)\n    )\n  }\n\n  return (\n    <div className='flex flex-col gap-4'>\n      <div className='flex items-center gap-2'>\n        <Checkbox\n          id='parent'\n          checked={allChildrenSelected}\n          indeterminate={isParentIndeterminate}\n          onCheckedChange={handleParentCheckedChange}\n        />\n        <Label htmlFor='parent' className='text-sm font-medium'>\n          Select all modules\n        </Label>\n      </div>\n      <div className='flex flex-col gap-2 pl-6'>\n        {items.map((item) => (\n          <div key={item} className='flex items-center gap-2'>\n            <Checkbox\n              id={item}\n              checked={selectedItems.includes(item)}\n              onCheckedChange={(checked) =>\n                handleChildCheckedChange(item, checked)\n              }\n            />\n            <Label htmlFor={item} className='text-sm'>\n              {item}\n            </Label>\n          </div>\n        ))}\n      </div>\n    </div>\n  )\n}\n\nexport default Checkbox15\n"
    }
  ]
}
