{"version":3,"file":"RadioGroup.mjs","names":[],"sources":["../../../src/radio-group/RadioGroup.tsx"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport type React from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { FieldsetBase, type FieldsetProps } from '../fieldset/Fieldset';\n\ntype RadioGroupProps = FieldsetProps & {\n  /** Shared native name for the radios in the group */\n  name: string;\n  /** The value of the selected radio. Pass `null` when no radio is selected. Leave undefined for uncontrolled usage */\n  value?: string | null;\n  /** Called with the newly selected radio's value when the selection changes */\n  onChange?: (\n    value: string,\n    event: React.ChangeEvent<HTMLInputElement>,\n  ) => void;\n  /** Whether the radios are stacked vertically or laid out in a wrapping row */\n  orientation?: 'horizontal' | 'vertical';\n};\n\n/**\n * Groups atomic `Radio` components under a shared name and accessible legend.\n *\n * @remarks\n * Pass `value` and `onChange` to control the selection from the group; each\n * `Radio` is then checked when its `value` matches the group's `value`, and\n * its own `isChecked` is ignored. Without `value`, selection state remains on\n * each `Radio` (for example via `isDefaultChecked`), and `onChange` can still\n * be used to observe changes. Radios inherit `name`, disabled, required,\n * help, and validation semantics from the group.\n */\nconst RadioGroup = ({\n  name,\n  value,\n  onChange,\n  orientation = 'vertical',\n  isDisabled = false,\n  isRequired = false,\n  htmlAttributes,\n  ...props\n}: CommonProps<'fieldset', RadioGroupProps>) => (\n  <FieldsetBase\n    {...props}\n    orientation={orientation}\n    isDisabled={isDisabled}\n    isRequired={isRequired}\n    fieldGroup={{\n      controlType: 'radio',\n      name,\n      onChange:\n        onChange === undefined\n          ? undefined\n          : (event) => onChange(event.target.value, event),\n      value,\n    }}\n    htmlAttributes={{\n      ...htmlAttributes,\n      'aria-required': isRequired || undefined,\n      role: 'radiogroup',\n    }}\n  />\n);\n\nRadioGroup.displayName = 'RadioGroup';\n\nexport { RadioGroup };\n"],"mappings":";;;;;;CAoDE;CACA;CACA;CACA;CACA;CACA;CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAPF,MAAM,cAAc,SAUlB;CAVkB,IAAA,EAClB,MACA,OACA,UACA,cAAc,YACd,aAAa,OACb,aAAa,OACb,mBAAA,MACG,QAAA,yBAAA,MAAA,SAAA;CAEH,OAAA,oBAAC,cAAA,eAAA,eAAA,CAAA,GACK,KAAA,GAAA,CAAA,GAAA;EACS;EACD;EACA;EACZ,YAAY;GACV,aAAa;GACb;GACA,UACE,aAAa,KAAA,IACT,KAAA,KACC,UAAU,SAAS,MAAM,OAAO,OAAO,KAAK;GACnD;EACF;EACA,gBAAA,eAAA,eAAA,CAAA,GACK,cAAA,GAAA,CAAA,GAAA;GACH,iBAAiB,cAAc,KAAA;GAC/B,MAAM;EACR,CAAA;CACD,CAAA,CAAA;;AAGH,WAAW,cAAc"}