/* ───────────────────────────────────────────────────────────────────────── PixelRadioGroup — grouped radios with pixel dot indicator. ───────────────────────────────────────────────────────────────────────── */ import React, { forwardRef } from 'react'; import { Tone, Surface, Option, cn, toneMap, surfaceClasses, useEffectiveSurface, } from '../common'; /** Public prop bag for {@link PixelRadioGroup}. */ export interface PixelRadioGroupProps { /** Legend rendered above the group. */ label: string; /** Currently-selected option value. */ value: string; /** Radio items. */ options: Option[]; /** Fires with the new value when the user picks a radio. */ onChange: (next: string) => void; /** Disables every radio in the group. */ disabled?: boolean; /** Visual tone for the selected radio. Default: `'cyan'`. */ tone?: Tone; /** Surface variant. Inherits from `PxlKitSurfaceProvider` when omitted. */ surface?: Surface; /** Form-serialization name. */ name?: string; /** Marks the field as required for native form validation. */ required?: boolean; } export const PixelRadioGroup = forwardRef(function PixelRadioGroup( { label, value, options, onChange, disabled = false, tone = 'cyan', surface: surfaceProp, name, required, }, ref, ) { const surface = useEffectiveSurface(surfaceProp); const s = surfaceClasses(surface); return (
{name && } {label} {options.map((opt) => { const isActive = value === opt.value; return ( ); })}
); });