'use client' import { Label, RadioGroup as GuiRadioGroup, Text, VisuallyHidden } from '@hanzo/gui'; import * as React from 'react'; // ─── Size mappings ────────────────────────────────────────────────── const SIZE = { xs: { rootGap: 6, control: 12, indicator: 6, label: 12 }, sm: { rootGap: 6, control: 14, indicator: 6, label: 12 }, md: { rootGap: 8, control: 16, indicator: 8, label: 14 }, lg: { rootGap: 10, control: 20, indicator: 10, label: 16 }, } as const; type RadioSize = keyof typeof SIZE; const INK = 'var(--color-text-primary)' as never; const RESTING_BORDER = 'var(--color-input-border)' as never; const OUTLINE = 'var(--color-gray-500)' as never; // ─── Size context ─────────────────────────────────────────────────── const RadioSizeContext = React.createContext('md'); // ─── RadioGroup ───────────────────────────────────────────────────── export interface RadioGroupProps extends Omit, 'defaultValue' | 'dir'> { name?: string; required?: boolean; disabled?: boolean; readOnly?: boolean; orientation?: 'horizontal' | 'vertical'; loop?: boolean; defaultValue?: string; value?: string | null; onValueChange?: (details: { value: string | null }) => void; size?: RadioSize; } const RadioGroupBase = React.forwardRef( function RadioGroup(props, ref) { const { children, name, required, disabled = false, readOnly = false, orientation = 'vertical', // `loop` was a Radix-only knob; gui's roving focus always wraps. loop: _loop = true, defaultValue, value, onValueChange, size = 'md', ...rest } = props; const handleValueChange = React.useCallback( (nextValue: string) => { if (readOnly) return; onValueChange?.({ value: nextValue }); }, [ readOnly, onValueChange ], ); return ( { /* gui's RadioGroup — role=radiogroup / role=radio and roving focus from its headless core, real Pressables on native. */ } { children } ); }, ); export const RadioGroup = RadioGroupBase; const NOOP = () => { /* noop */ }; // ─── Radio ────────────────────────────────────────────────────────── export interface RadioProps extends Omit, 'onChange'> { rootRef?: React.Ref; inputProps?: React.InputHTMLAttributes; value: string; disabled?: boolean; } const RadioBase = React.forwardRef( function Radio(props, ref) { const { children, inputProps, rootRef, value, disabled, ...rest } = props; const size = React.useContext(RadioSizeContext); const s = SIZE[size]; return ( ); }, ); export const Radio = RadioBase;