{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport { useControlledState as $cKWHA$useControlledState } from \"@react-stately/utils\";\nimport { useMemo as $cKWHA$useMemo, useState as $cKWHA$useState } from \"react\";\n\nfunction $parcel$export(e, n, v, s) {\n  Object.defineProperty(e, n, {\n    get: v,\n    set: s,\n    enumerable: true,\n    configurable: true\n  });\n}\n\nvar $abdd678977242949$exports = {};\n$parcel$export($abdd678977242949$exports, \"useRadioGroupState\", function () {\n  return $abdd678977242949$export$bca9d026f8e704eb;\n});\nvar $abdd678977242949$var$instance = Math.round(Math.random() * 10000000000);\nvar $abdd678977242949$var$i = 0;\n\nfunction $abdd678977242949$export$bca9d026f8e704eb(props) {\n  var name = $cKWHA$useMemo(function () {\n    return props.name || \"radio-group-\" + $abdd678977242949$var$instance + \"-\" + ++$abdd678977242949$var$i;\n  }, [props.name]);\n\n  var _$cKWHA$useControlled = $cKWHA$useControlledState(props.value, props.defaultValue, props.onChange),\n      _$cKWHA$useControlled2 = _slicedToArray(_$cKWHA$useControlled, 2),\n      selectedValue = _$cKWHA$useControlled2[0],\n      setSelected = _$cKWHA$useControlled2[1];\n\n  var _$cKWHA$useState = $cKWHA$useState(null),\n      _$cKWHA$useState2 = _slicedToArray(_$cKWHA$useState, 2),\n      lastFocusedValue = _$cKWHA$useState2[0],\n      setLastFocusedValue = _$cKWHA$useState2[1];\n\n  var setSelectedValue = function setSelectedValue(value) {\n    if (!props.isReadOnly && !props.isDisabled) setSelected(value);\n  };\n\n  return {\n    name: name,\n    selectedValue: selectedValue,\n    setSelectedValue: setSelectedValue,\n    lastFocusedValue: lastFocusedValue,\n    setLastFocusedValue: setLastFocusedValue,\n    isDisabled: props.isDisabled || false,\n    isReadOnly: props.isReadOnly || false\n  };\n}\n\nexport { $abdd678977242949$export$bca9d026f8e704eb as useRadioGroupState };","map":{"version":3,"sources":["packages/@react-stately/radio/src/useRadioGroupState.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA2CA,IAAI,8BAAQ,GAAG,IAAI,CAAC,KAAL,CAAW,IAAI,CAAC,MAAL,KAAgB,WAA3B,CAAf;AACA,IAAI,uBAAC,GAAG,CAAR;;SAMgB,yC,CAAmB,K,EAA0C;AAE3E,MAAI,IAAI,GAAG,cAAO,CAAA;AAAA,WAAO,KAAK,CAAC,IAAN,qBAA6B,8BAA7B,SAAuC,EAAI,uBAAlD;AAAA,GAAA,EAAuD,CAAC,KAAK,CAAC,IAAP,CAAvD,CAAlB;;AACA,8BAAmC,yBAAkB,CAAC,KAAK,CAAC,KAAP,EAAc,KAAK,CAAC,YAApB,EAAkC,KAAK,CAAC,QAAxC,CAArD;AAAA;AAAA,MAAK,aAAL;AAAA,MAAoB,WAApB;;AACA,yBAA8C,eAAQ,CAAC,IAAD,CAAtD;AAAA;AAAA,MAAK,gBAAL;AAAA,MAAuB,mBAAvB;;AAEA,MAAI,gBAAgB,GAAA,SAAhB,gBAAgB,CAAI,KAAJ,EAAc;AAChC,QAAE,CAAG,KAAK,CAAC,UAAT,IAAmB,CAAK,KAAK,CAAC,UAAhC,EACE,WAAW,CAAC,KAAD,CAAX;AAEH,GAJD;;AAMA,SAAO;UACL,IADK;mBAEL,aAFK;sBAGL,gBAHK;sBAIL,gBAJK;yBAKL,mBALK;AAML,IAAA,UAAU,EAAE,KAAK,CAAC,UAAN,IAAoB,KAN3B;AAOL,IAAA,UAAU,EAAE,KAAK,CAAC,UAAN,IAAoB;AAP3B,GAAP;AASD","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 {RadioGroupProps} from '@react-types/radio';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useState} from 'react';\n\nexport interface RadioGroupState {\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  /** The currently selected value. */\n  readonly selectedValue: string | null,\n\n  /** Sets the selected value. */\n  setSelectedValue(value: string): 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): 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, props.onChange);\n  let [lastFocusedValue, setLastFocusedValue] = useState(null);\n\n  let setSelectedValue = (value) => {\n    if (!props.isReadOnly && !props.isDisabled) {\n      setSelected(value);\n    }\n  };\n\n  return {\n    name,\n    selectedValue,\n    setSelectedValue,\n    lastFocusedValue,\n    setLastFocusedValue,\n    isDisabled: props.isDisabled || false,\n    isReadOnly: props.isReadOnly || false\n  };\n}\n"]},"metadata":{},"sourceType":"module"}