{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checkbox-group",
  "title": "Checkbox Group",
  "description": "Checkbox Group from the Get IT Done design system.",
  "dependencies": [
    "lucide-react@^0.379.0"
  ],
  "registryDependencies": [
    "https://zero-design.itdone.de/r/recipes.json",
    "https://zero-design.itdone.de/r/utils.json",
    "https://zero-design.itdone.de/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/ui/checkbox-group.tsx",
      "content": "'use client';\n\nimport { Check } from 'lucide-react';\nimport * as React from 'react';\n\nimport { transitionBase } from '@/lib/recipes';\nimport { cn } from '@/lib/utils';\n\ntype GroupSize = 'sm' | 'md';\ntype GroupMode = 'single' | 'multiple';\n\ninterface GroupContextValue {\n  mode: GroupMode;\n  size: GroupSize;\n  name: string;\n  disabled: boolean;\n  selected: string[];\n  toggle: (value: string) => void;\n}\n\nconst GroupContext = React.createContext<GroupContextValue | null>(null);\n\nexport interface CheckboxGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n  // `multiple` renders checkboxes (any number selected), `single` renders radios (at most one).\n  type?: GroupMode;\n  // Selected item values. In `single` mode the array holds at most one entry.\n  value?: string[];\n  defaultValue?: string[];\n  onValueChange?: (value: string[]) => void;\n  size?: GroupSize;\n  disabled?: boolean;\n  // Form field name shared by every item.\n  name?: string;\n  // Stack the items (default) or lay them out in a responsive grid.\n  layout?: 'stack' | 'grid';\n}\n\n// Selectable cards (Figma \"Checkbox group\"): a labelled group of native checkboxes or radios drawn as cards.\nconst CheckboxGroup = React.forwardRef<HTMLDivElement, CheckboxGroupProps>(\n  (\n    {\n      className,\n      type = 'multiple',\n      value,\n      defaultValue = [],\n      onValueChange,\n      size = 'md',\n      disabled = false,\n      name,\n      layout = 'stack',\n      ...props\n    },\n    ref,\n  ) => {\n    const autoName = React.useId();\n    const [inner, setInner] = React.useState<string[]>(defaultValue);\n    const selected = value ?? inner;\n\n    const toggle = React.useCallback(\n      (item: string) => {\n        let next: string[];\n        if (type === 'single') next = [item];\n        else next = selected.includes(item) ? selected.filter((entry) => entry !== item) : [...selected, item];\n        setInner(next);\n        onValueChange?.(next);\n      },\n      [onValueChange, selected, type],\n    );\n\n    const context = React.useMemo<GroupContextValue>(\n      () => ({ mode: type, size, name: name ?? autoName, disabled, selected, toggle }),\n      [type, size, name, autoName, disabled, selected, toggle],\n    );\n\n    return (\n      <GroupContext.Provider value={context}>\n        <div\n          ref={ref}\n          role={type === 'single' ? 'radiogroup' : 'group'}\n          aria-disabled={disabled || undefined}\n          className={cn(layout === 'grid' ? 'grid grid-cols-1 gap-3 sm:grid-cols-2' : 'flex flex-col gap-3', className)}\n          {...props}\n        />\n      </GroupContext.Provider>\n    );\n  },\n);\nCheckboxGroup.displayName = 'CheckboxGroup';\n\nexport interface CheckboxGroupItemProps\n  extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'title' | 'onChange'> {\n  value: string;\n  title: React.ReactNode;\n  // Muted text right after the title on the same line (Figma \"Text and subtext\"), for example \"$10/month\".\n  price?: React.ReactNode;\n  description?: React.ReactNode;\n  // Leading visual: an icon, an Avatar or a payment logo.\n  media?: React.ReactNode;\n  // `plain` shows the media as is, `featured` puts it in a soft round badge, `framed` in a bordered tile (payment icons).\n  mediaVariant?: 'plain' | 'featured' | 'framed';\n  // `auto` shows a checkbox or radio indicator matching the group type, `none` relies on the card border (icon cards).\n  indicator?: 'auto' | 'none';\n  // Where the indicator sits. Defaults to `start` for plain radio and checkbox rows and `end` when there is media.\n  indicatorPosition?: 'start' | 'end';\n  // Figma \"Icon card\": a header with media, title and indicator above a body with price, description and badge.\n  card?: boolean;\n  // Small label in the body of a card, for example a limited-offer badge.\n  badge?: React.ReactNode;\n  // Error border (Figma State=Error).\n  invalid?: boolean;\n  disabled?: boolean;\n}\n\nconst CheckboxGroupItem = React.forwardRef<HTMLInputElement, CheckboxGroupItemProps>(\n  (\n    {\n      className,\n      value,\n      title,\n      price,\n      description,\n      media,\n      mediaVariant = 'plain',\n      indicator = 'auto',\n      indicatorPosition,\n      card = false,\n      badge,\n      invalid = false,\n      disabled,\n      ...props\n    },\n    ref,\n  ) => {\n    const context = React.useContext(GroupContext);\n    if (!context) throw new Error('CheckboxGroupItem must be rendered inside CheckboxGroup');\n    const checked = context.selected.includes(value);\n    const isDisabled = disabled || context.disabled;\n    const radio = context.mode === 'single';\n    const small = context.size === 'sm';\n    const position = indicatorPosition ?? (media || card ? 'end' : 'start');\n\n    const indicatorNode =\n      indicator === 'auto' ? (\n        <span\n          aria-hidden=\"true\"\n          data-indicator=\"\"\n          className={cn(\n            'inline-flex shrink-0 items-center justify-center border border-solid',\n            small ? 'h-checkbox-sm w-checkbox-sm' : 'h-checkbox-md w-checkbox-md',\n            radio ? 'rounded-full' : 'rounded-checkbox',\n            checked\n              ? 'border-border-brand bg-checkbox-background-checked text-icon-on-brand'\n              : 'border-checkbox-border-default bg-background',\n            !card && position === 'start' && 'mt-micro',\n          )}\n        >\n          {checked ? (\n            radio ? (\n              <span className=\"h-2 w-2 rounded-full bg-icon-on-brand\" />\n            ) : (\n              <Check className=\"h-3 w-3 [stroke-width:var(--size-icon-stroke-check,3)]\" />\n            )\n          ) : null}\n        </span>\n      ) : null;\n\n    const mediaNode = media ? (\n      <span\n        aria-hidden=\"true\"\n        className={cn(\n          'inline-flex shrink-0 items-center justify-center text-icon-default',\n          mediaVariant === 'featured' && 'h-10 w-10 rounded-full bg-background-brand-subtle-hover',\n          mediaVariant === 'framed' && 'h-10 w-14 rounded-item border border-solid border-border-default bg-background',\n        )}\n      >\n        {media}\n      </span>\n    ) : null;\n\n    const titleClass = cn('typography-label', checked && !card ? 'text-general-brand-on-container' : 'text-foreground');\n    const subtleClass = cn('typography-label', checked && !card ? 'text-general-brand-on-container' : 'text-text-subtle');\n\n    const textBlock = (\n      <span className=\"flex min-w-0 flex-1 flex-col\">\n        <span className=\"flex flex-wrap gap-1\">\n          <span className={titleClass}>{title}</span>\n          {price ? <span className={subtleClass}>{price}</span> : null}\n        </span>\n        {description ? <span className={subtleClass}>{description}</span> : null}\n      </span>\n    );\n\n    return (\n      <label\n        className={cn('relative block', isDisabled ? 'cursor-not-allowed' : 'cursor-pointer', className)}\n        {...props}\n      >\n        <input\n          ref={ref}\n          type={radio ? 'radio' : 'checkbox'}\n          name={context.name}\n          value={value}\n          checked={checked}\n          disabled={isDisabled}\n          onChange={() => context.toggle(value)}\n          className=\"peer sr-only\"\n        />\n        <span\n          data-state={checked ? 'checked' : 'unchecked'}\n          data-disabled={isDisabled || undefined}\n          data-invalid={invalid || undefined}\n          data-card={card || undefined}\n          className={cn(\n            'flex rounded-card border border-solid border-border-default bg-background',\n            card ? 'flex-col' : cn('items-start gap-2', small ? 'p-3' : 'p-4'),\n            transitionBase,\n            'motion-reduce:transition-none',\n            'hover:border-border-bold',\n            'peer-focus-visible:border-border-focus peer-focus-visible:ring-[3px] peer-focus-visible:ring-ring/30',\n            'data-[state=checked]:border-2 data-[state=checked]:border-border-brand',\n            !card && 'data-[state=checked]:bg-background-brand-subtle',\n            'data-[invalid=true]:border-border-destructive',\n            'data-[disabled=true]:opacity-disabled',\n          )}\n        >\n          {card ? (\n            <>\n              <span\n                data-card-header=\"\"\n                className={cn(\n                  'flex items-center gap-4 rounded-t-card border-b border-solid border-border-default py-4 pl-4 pr-5',\n                  checked && 'bg-background-brand-subtle',\n                )}\n              >\n                {mediaNode}\n                <span className={cn(titleClass, 'flex-1')}>{title}</span>\n                {indicatorNode}\n              </span>\n              <span data-card-body=\"\" className=\"flex items-start gap-1 p-4\">\n                <span className=\"flex min-w-0 flex-1 flex-col gap-1\">\n                  {price ? <span className=\"typography-label text-foreground\">{price}</span> : null}\n                  {description ? <span className={subtleClass}>{description}</span> : null}\n                </span>\n                {badge}\n              </span>\n            </>\n          ) : (\n            <>\n              {position === 'start' ? indicatorNode : null}\n              {mediaNode}\n              {textBlock}\n              {position === 'end' ? indicatorNode : null}\n            </>\n          )}\n        </span>\n      </label>\n    );\n  },\n);\nCheckboxGroupItem.displayName = 'CheckboxGroupItem';\n\nexport { CheckboxGroup, CheckboxGroupItem };\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}