{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAyDD,IAAI,iCAAW,KAAK,KAAK,CAAC,KAAK,MAAM,KAAK;AAC1C,IAAI,0BAAI;AAMD,SAAS,0CAAmB,KAAsB;IACvD,mGAAmG;IACnG,IAAI,OAAO,CAAA,GAAA,oBAAM,EAAE,IAAM,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,+BAAS,CAAC,EAAE,EAAE,yBAAG,EAAE;QAAC,MAAM,IAAI;KAAC;IACrF,IAAI,CAAC,eAAe,YAAY,GAAG,CAAA,GAAA,4CAAiB,EAAE,MAAM,KAAK,EAAE,MAAM,YAAY,IAAI,MAAM,MAAM,QAAQ;IAC7G,IAAI,CAAC,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC9B,IAAI,CAAC,kBAAkB,oBAAoB,GAAG,CAAA,GAAA,qBAAO,EAAiB;IAEtE,IAAI,aAAa,CAAA,GAAA,gDAAqB,EAAE;QACtC,GAAG,KAAK;QACR,OAAO;IACT;IAEA,IAAI,mBAAmB,CAAC;QACtB,IAAI,CAAC,MAAM,UAAU,IAAI,CAAC,MAAM,UAAU,EAAE;YAC1C,YAAY;YACZ,WAAW,gBAAgB;QAC7B;IACF;IAEA,IAAI,YAAY,WAAW,iBAAiB,CAAC,SAAS;IAEtD,OAAO;QACL,GAAG,UAAU;cACb;QACA,eAAe;QACf,sBAAsB,MAAM,KAAK,KAAK,YAAY,eAAe,MAAM,YAAY,IAAI;0BACvF;0BACA;6BACA;QACA,YAAY,MAAM,UAAU,IAAI;QAChC,YAAY,MAAM,UAAU,IAAI;QAChC,YAAY,MAAM,UAAU,IAAI;QAChC,iBAAiB,MAAM,eAAe,IAAK,CAAA,YAAY,YAAY,IAAG;mBACtE;IACF;AACF","sources":["packages/react-stately/src/radio/useRadioGroupState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusEvents, HelpTextProps, InputBase, InputDOMProps, LabelableProps, Orientation, Validation, ValidationState, ValueBase} from '@react-types/shared';\nimport {FormValidationState, useFormValidationState} from '../form/useFormValidationState';\nimport {useControlledState} from '../utils/useControlledState';\nimport {useMemo, useState} from 'react';\n\nexport interface RadioGroupProps extends ValueBase<string|null, string>, InputBase, Pick<InputDOMProps, 'name'>, Validation<string>, LabelableProps, HelpTextProps, FocusEvents {\n  /**\n   * The axis the Radio Button(s) should align with.\n   * @default 'vertical'\n   */\n  orientation?: Orientation\n}\n\nexport interface RadioGroupState extends FormValidationState {\n  /**\n   * The name for the group, used for native form submission.\n   * @deprecated\n   * @private\n   */\n  readonly name: string,\n\n  /** Whether the radio group is disabled. */\n  readonly isDisabled: boolean,\n\n  /** Whether the radio group is read only. */\n  readonly isReadOnly: boolean,\n\n  /** Whether the radio group is required. */\n  readonly isRequired: boolean,\n\n  /**\n   * Whether the radio group is valid or invalid.\n   * @deprecated Use `isInvalid` instead.\n   */\n  readonly validationState: ValidationState | null,\n\n  /** Whether the radio group is invalid. */\n  readonly isInvalid: boolean,\n\n  /** The currently selected value. */\n  readonly selectedValue: string | null,\n\n  /** The default selected value. */\n  readonly defaultSelectedValue: string | null,\n\n  /** Sets the selected value. */\n  setSelectedValue(value: string | null): void,\n\n  /** The value of the last focused radio. */\n  readonly lastFocusedValue: string | null,\n\n  /** Sets the last focused value. */\n  setLastFocusedValue(value: string | null): void\n}\n\nlet instance = Math.round(Math.random() * 10000000000);\nlet i = 0;\n\n/**\n * Provides state management for a radio group component. Provides a name for the group,\n * and manages selection and focus state.\n */\nexport function useRadioGroupState(props: RadioGroupProps): RadioGroupState  {\n  // Preserved here for backward compatibility. React Aria now generates the name instead of stately.\n  let name = useMemo(() => props.name || `radio-group-${instance}-${++i}`, [props.name]);\n  let [selectedValue, setSelected] = useControlledState(props.value, props.defaultValue ?? null, props.onChange);\n  let [initialValue] = useState(selectedValue);\n  let [lastFocusedValue, setLastFocusedValue] = useState<string | null>(null);\n\n  let validation = useFormValidationState({\n    ...props,\n    value: selectedValue\n  });\n\n  let setSelectedValue = (value) => {\n    if (!props.isReadOnly && !props.isDisabled) {\n      setSelected(value);\n      validation.commitValidation();\n    }\n  };\n\n  let isInvalid = validation.displayValidation.isInvalid;\n\n  return {\n    ...validation,\n    name,\n    selectedValue: selectedValue,\n    defaultSelectedValue: props.value !== undefined ? initialValue : props.defaultValue ?? null,\n    setSelectedValue,\n    lastFocusedValue,\n    setLastFocusedValue,\n    isDisabled: props.isDisabled || false,\n    isReadOnly: props.isReadOnly || false,\n    isRequired: props.isRequired || false,\n    validationState: props.validationState || (isInvalid ? 'invalid' : null),\n    isInvalid\n  };\n}\n"],"names":[],"version":3,"file":"useRadioGroupState.cjs.map"}