map • Lines: 1{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA8ED,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,EAClD,MAAM,KAAK,EACX,MAAM,YAAY,IAAI,MACtB,MAAM,QAAQ;IAEhB,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,CAAA;QACrB,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,eAAgB,MAAM,YAAY,IAAI;0BACxF;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 {\n FocusEvents,\n HelpTextProps,\n InputBase,\n InputDOMProps,\n LabelableProps,\n Orientation,\n Validation,\n ValidationState,\n ValueBase\n} from '@react-types/shared';\nimport {FormValidationState, useFormValidationState} from '../form/useFormValidationState';\nimport {useControlledState} from '../utils/useControlledState';\nimport {useMemo, useState} from 'react';\n\nexport interface RadioGroupProps\n extends\n ValueBase<string | null, string>,\n InputBase,\n Pick<InputDOMProps, 'name'>,\n Validation<string>,\n LabelableProps,\n HelpTextProps,\n FocusEvents {\n /**\n * The axis the Radio Button(s) should align with.\n *\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 *\n * @private\n * @deprecated\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 *\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(\n props.value,\n props.defaultValue ?? null,\n props.onChange\n );\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"}