{"version":3,"sources":["../src/form/radio-button/radio-group.tsx"],"sourcesContent":["import {\n  type ChangeEventHandler,\n  createContext,\n  forwardRef,\n  type InputHTMLAttributes,\n  type ReactNode,\n  useContext,\n} from \"react\";\nimport { FieldsetDescription } from \"../fieldset/fieldset-description\";\nimport { Fieldset, type FieldsetProps } from \"../fieldset\";\nimport { FieldsetLegend } from \"../fieldset/fieldset-legend\";\n\nexport interface RadioGroupProps extends Omit<FieldsetProps, \"onChange\"> {\n  children: ReactNode;\n  /** Will be passed to all Radio buttons within the radio group */\n  name?: InputHTMLAttributes<HTMLInputElement>[\"name\"];\n  /** If you want the group to be controlled, you can pass the selected value here */\n  value?: InputHTMLAttributes<HTMLInputElement>[\"value\"];\n  /** Will be passed to all Radio buttons within the radio group */\n  onChange?: ChangeEventHandler<HTMLInputElement> | undefined;\n}\n\ntype RadioGroupContextProps = Pick<RadioGroupProps, \"name\" | \"value\" | \"onChange\" | \"size\">;\n\nconst RadioGroupContext = createContext<RadioGroupContextProps>({\n  name: undefined,\n  onChange: () => undefined,\n  size: undefined,\n});\n\nexport const useRadioGroupContext = () => useContext(RadioGroupContext);\n\nexport const RadioGroup = forwardRef<HTMLFieldSetElement, RadioGroupProps>(function RadioGroup(\n  { name, value, onChange, children, size, ...rest },\n  ref,\n) {\n  return (\n    <RadioGroupContext.Provider value={{ name, value, onChange, size }}>\n      <Fieldset size={size} {...rest} ref={ref}>\n        {children}\n      </Fieldset>\n    </RadioGroupContext.Provider>\n  );\n}) as RadioGroupType;\n\ntype RadioGroupType = ReturnType<typeof forwardRef<HTMLFieldSetElement, RadioGroupProps>> & {\n  Description: typeof FieldsetDescription;\n  Legend: typeof FieldsetLegend;\n};\n\nRadioGroup.Description = FieldsetDescription;\nRadioGroup.Legend = FieldsetLegend;\n\nRadioGroup.displayName = \"RadioGroup\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EAGA;AAAA,OACK;AA+BD;AAdN,IAAM,oBAAoB,cAAsC;AAAA,EAC9D,MAAM;AAAA,EACN,UAAU,MAAM;AAAA,EAChB,MAAM;AACR,CAAC;AAEM,IAAM,uBAAuB,MAAM,WAAW,iBAAiB;AAE/D,IAAM,aAAa,WAAiD,SAASA,YAClF,IACA,KACA;AAFA,eAAE,QAAM,OAAO,UAAU,UAAU,KAjCrC,IAiCE,IAA4C,iBAA5C,IAA4C,CAA1C,QAAM,SAAO,YAAU,YAAU;AAGnC,SACE,oBAAC,kBAAkB,UAAlB,EAA2B,OAAO,EAAE,MAAM,OAAO,UAAU,KAAK,GAC/D,8BAAC,yCAAS,QAAgB,OAAzB,EAA+B,KAC7B,WACH,GACF;AAEJ,CAAC;AAOD,WAAW,cAAc;AACzB,WAAW,SAAS;AAEpB,WAAW,cAAc;","names":["RadioGroup"]}