{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "radio-group",
  "type": "registry:ui",
  "title": "Radio Group",
  "description": "Radio group selection for Tile UI.",
  "devDependencies": [
    "sass"
  ],
  "registryDependencies": [
    "@tile-ui/core",
    "@tile-ui/styles"
  ],
  "files": [
    {
      "path": "packages/react/src/components/radio-group/radio-group.tsx",
      "type": "registry:ui",
      "target": "components/ui/radio-group/radio-group.tsx",
      "content": "import React, { createContext, useContext, useId, useState } from 'react';\nimport { getRadioState, radioGroupStyleKeys } from '../lib/core';\nimport type { RadioGroupBaseProps, RadioGroupItemBaseProps } from '../lib/core';\nimport styles from './radio-group.module.scss';\n\ninterface RadioGroupContextValue {\n\tvalue: string;\n\tname: string;\n\tdisabled: boolean;\n\tselect: (value: string) => void;\n}\n\nconst RadioGroupContext = createContext<RadioGroupContextValue | null>(null);\n\nfunction useRadioGroupContext(): RadioGroupContextValue {\n\tconst context = useContext(RadioGroupContext);\n\tif (!context) {\n\t\tthrow new Error('RadioGroup sub-components must be used within <RadioGroup>.');\n\t}\n\treturn context;\n}\n\nexport interface RadioGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'value' | 'defaultValue'>, RadioGroupBaseProps {}\n\nconst RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>(\n\t({ className = '', value, defaultValue = '', onValueChange, orientation = 'vertical', name = '', disabled = false, children, ...props }, ref) => {\n\t\tconst [internalValue, setInternalValue] = useState(defaultValue);\n\t\tconst currentValue = value !== undefined ? value : internalValue;\n\n\t\tfunction select(next: string) {\n\t\t\tif (disabled) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (value === undefined) {\n\t\t\t\tsetInternalValue(next);\n\t\t\t}\n\t\t\tonValueChange?.(next);\n\t\t}\n\n\t\treturn (\n\t\t\t<RadioGroupContext.Provider value={{ value: currentValue, name, disabled, select }}>\n\t\t\t\t<div\n\t\t\t\t\tref={ref}\n\t\t\t\t\trole=\"radiogroup\"\n\t\t\t\t\taria-orientation={orientation}\n\t\t\t\t\tdata-orientation={orientation}\n\t\t\t\t\tclassName={`${styles[radioGroupStyleKeys.root]} ${className}`}\n\t\t\t\t\t{...props}>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</RadioGroupContext.Provider>\n\t\t);\n\t},\n);\nRadioGroup.displayName = 'RadioGroup';\n\nexport interface RadioGroupItemProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'checked'>, RadioGroupItemBaseProps {\n\tvalue: string;\n}\n\nconst RadioGroupItem = React.forwardRef<HTMLInputElement, RadioGroupItemProps>(({ className = '', value, disabled = false, onChange, children, ...props }, ref) => {\n\tconst context = useRadioGroupContext();\n\tconst checked = context.value === value;\n\tconst state = getRadioState(checked);\n\tconst inputId = useId();\n\n\tfunction handleChange(event: React.ChangeEvent<HTMLInputElement>) {\n\t\tcontext.select(value);\n\t\tonChange?.(event);\n\t}\n\n\treturn (\n\t\t<label htmlFor={inputId} className={`${styles[radioGroupStyleKeys.label]} ${className}`}>\n\t\t\t<input\n\t\t\t\t{...props}\n\t\t\t\tref={ref}\n\t\t\t\tid={inputId}\n\t\t\t\ttype=\"radio\"\n\t\t\t\tname={context.name}\n\t\t\t\tvalue={value}\n\t\t\t\tchecked={checked}\n\t\t\t\tdisabled={disabled || context.disabled}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tclassName={styles[radioGroupStyleKeys.input]}\n\t\t\t/>\n\t\t\t<span aria-hidden data-state={state} className={styles[radioGroupStyleKeys.item]}>\n\t\t\t\t<span className={styles[radioGroupStyleKeys.indicator]}>\n\t\t\t\t\t<span className={styles[radioGroupStyleKeys.dot]} />\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t\t{children}\n\t\t</label>\n\t);\n});\nRadioGroupItem.displayName = 'RadioGroupItem';\n\nexport { RadioGroup, RadioGroupItem };\nexport default RadioGroup;\n"
    },
    {
      "path": "packages/styles/scss/components/radio-group.module.scss",
      "type": "registry:file",
      "target": "components/ui/radio-group/radio-group.module.scss",
      "content": "@use '../../../styles/variables/colors' as *;\n\n.root {\n\tdisplay: grid;\n\tgap: $spacing-3;\n\n\t&[data-orientation='horizontal'] {\n\t\tgrid-auto-flow: column;\n\t\tgrid-auto-columns: max-content;\n\t}\n}\n\n.label {\n\tposition: relative;\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tcursor: pointer;\n}\n\n.input {\n\tposition: absolute;\n\tinset: 0;\n\twidth: 100%;\n\theight: 100%;\n\tmargin: 0;\n\topacity: 0;\n\tcursor: pointer;\n\n\t&:focus-visible + .item {\n\t\tborder-color: var(--tile-radio-focus-border, #{$ring});\n\t\tbox-shadow: var(--tile-radio-focus-shadow, 0 0 0 3px color-mix(in srgb, #{$ring} 50%, transparent));\n\t\toutline: var(--tile-radio-focus-outline, none);\n\t\toutline-offset: var(--tile-radio-focus-offset, 0px);\n\t}\n\n\t&:disabled {\n\t\tcursor: not-allowed;\n\t}\n\n\t&:disabled + .item {\n\t\tcursor: not-allowed;\n\t\topacity: 0.5;\n\t}\n}\n\n.item {\n\tdisplay: inline-flex;\n\twidth: 1rem;\n\theight: 1rem;\n\tflex-shrink: 0;\n\talign-items: center;\n\tjustify-content: center;\n\tborder: var(--tile-radio-border-width, 1px) solid var(--tile-radio-border, #{$input});\n\tborder-radius: $radius-full;\n\tbackground-color: var(--tile-radio-background, #{$background});\n\tcolor: var(--tile-radio-color, #{$primary});\n\tbox-shadow: var(--tile-radio-shadow, none);\n\ttransition:\n\t\tborder-color $transition-fast,\n\t\tbox-shadow $transition-fast,\n\t\tcolor $transition-fast;\n\toutline: none;\n\n\t&[data-state='checked'] {\n\t\tborder-color: var(--tile-radio-checked-border, #{$primary});\n\t\tbackground-color: var(--tile-radio-checked-background, #{$background});\n\t\tcolor: var(--tile-radio-checked-color, #{$primary});\n\t\tbox-shadow: var(--tile-radio-checked-shadow, none);\n\t}\n}\n\n.input:focus-visible + .item[data-state='checked'] {\n\tbox-shadow: var(--tile-radio-focus-shadow, 0 0 0 3px color-mix(in srgb, #{$ring} 50%, transparent));\n}\n\n.indicator {\n\tdisplay: flex;\n\twidth: 100%;\n\theight: 100%;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n.dot {\n\twidth: 0.5rem;\n\theight: 0.5rem;\n\tborder-radius: $radius-full;\n\tbackground-color: currentColor;\n}\n"
    },
    {
      "path": "packages/react/src/components/radio-group/index.ts",
      "type": "registry:ui",
      "target": "components/ui/radio-group/index.ts",
      "content": "export { RadioGroup, RadioGroupItem, type RadioGroupProps, type RadioGroupItemProps } from './radio-group';\n"
    }
  ]
}
