{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "radio-cards",
  "title": "Radio cards",
  "description": "One of a few options, each a card with a title, a description and room for a price or an icon. Picked, the card fades to grey and its empty circle gives way to a check that wipes in, while the old pick fades back.",
  "dependencies": [
    "@ui-sdk/react",
    "@ui-sdk/core"
  ],
  "registryDependencies": [
    "https://kinoui.com/r/checkbox.json",
    "https://kinoui.com/r/choice.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/radio-cards.tsx",
      "content": "'use client'\n\nimport { CheckboxMark } from '@/registry/components/kino/checkbox'\nimport {\n  ChoiceCardContext,\n  choiceCardBoxClassName,\n  choiceCardCheckedClassName,\n  choiceCardClassName,\n  choiceCardDescriptionClassName,\n  choiceCardMarkClassName,\n  choiceCardTitleClassName,\n  choicePressHandlers,\n} from '@/registry/lib/choice'\nimport {\n  Radio as RadioPrimitive,\n  RadioGroup as RadioGroupPrimitive,\n} from '@ui-sdk/react/radio'\nimport { type ComponentProps, type ReactNode, use, useId } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * One of a few options, each a card: a plan, a shipping method. The card is\n * a label around its radio, so a press anywhere on it picks it. Picked, the\n * card fades to grey and its radio gives way to a check that wipes in, as\n * Checkbox cards do; the old pick fades back to its card and empty circle.\n */\n\nfunction RadioCards<T extends string = string>({\n  className,\n  ...props\n}: Omit<ComponentProps<typeof RadioGroupPrimitive<T>>, 'className'> & {\n  className?: string\n}) {\n  return (\n    <RadioGroupPrimitive<T>\n      className={cn(\n        // Columns at least 14rem wide, as many as fit, so the cards wrap from a phone to a wide page.\n        'relative isolate grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3',\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\ntype RadioProps = ComponentProps<typeof RadioPrimitive>\n\n/** One option's card. Its props go to its radio, the `RadioCardIndicator` inside it, and `className` to the card. */\nfunction RadioCard({\n  className,\n  children,\n  ...props\n}: Omit<RadioProps, 'className' | 'children'> & {\n  className?: string\n  children?: ReactNode\n}) {\n  const id = useId()\n  return (\n    <label\n      data-slot='radio-card'\n      data-choice-card=''\n      className={cn(choiceCardClassName, className)}\n    >\n      <ChoiceCardContext\n        value={{ title: `${id}-title`, description: `${id}-description`, control: props }}\n      >\n        {children}\n      </ChoiceCardContext>\n    </label>\n  )\n}\n\n/** The card's radio, named by the card's title and described by its description: an empty circle, and once picked a check that wipes in. */\nfunction RadioCardIndicator({ className }: { className?: string }) {\n  const { title, description, control } = use(ChoiceCardContext)\n  const { onKeyDown, onKeyUp, onBlur, ...props } = control as RadioProps\n  return (\n    <RadioPrimitive\n      aria-labelledby={title}\n      aria-describedby={description}\n      className={cn(\n        choiceCardBoxClassName,\n        choiceCardCheckedClassName,\n        'group/checkbox relative inline-flex rounded-full',\n        className,\n      )}\n      {...choicePressHandlers({ onKeyDown, onKeyUp, onBlur })}\n      {...props}\n    >\n      <CheckboxMark className={choiceCardMarkClassName} />\n    </RadioPrimitive>\n  )\n}\n\nfunction RadioCardTitle({ className, ...props }: ComponentProps<'div'>) {\n  const { title } = use(ChoiceCardContext)\n  return (\n    <div\n      data-slot='radio-card-title'\n      id={title}\n      className={cn(choiceCardTitleClassName, className)}\n      {...props}\n    />\n  )\n}\n\nfunction RadioCardDescription({ className, ...props }: ComponentProps<'div'>) {\n  const { description } = use(ChoiceCardContext)\n  return (\n    <div\n      data-slot='radio-card-description'\n      id={description}\n      className={cn(choiceCardDescriptionClassName, className)}\n      {...props}\n    />\n  )\n}\n\nexport { RadioCard, RadioCardDescription, RadioCardIndicator, RadioCards, RadioCardTitle }\n",
      "type": "registry:component",
      "target": "@components/kino/radio-cards.tsx"
    }
  ],
  "type": "registry:component"
}