@react-aria/radio 3.6.1 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/import.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import {mergeProps as $4vDl6$mergeProps, filterDOMProps as $4vDl6$filterDOMProps, useId as $4vDl6$useId} from "@react-aria/utils";
1
+ import {mergeProps as $4vDl6$mergeProps, filterDOMProps as $4vDl6$filterDOMProps, useFormReset as $4vDl6$useFormReset, useId as $4vDl6$useId} from "@react-aria/utils";
2
2
  import {useFocusable as $4vDl6$useFocusable, getFocusableTreeWalker as $4vDl6$getFocusableTreeWalker} from "@react-aria/focus";
3
3
  import {usePress as $4vDl6$usePress, useFocusWithin as $4vDl6$useFocusWithin} from "@react-aria/interactions";
4
4
  import {useField as $4vDl6$useField} from "@react-aria/label";
@@ -65,6 +65,7 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
65
65
  });
66
66
  let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;
67
67
  if (isDisabled) tabIndex = undefined;
68
+ (0, $4vDl6$useFormReset)(ref, state.selectedValue, state.setSelectedValue);
68
69
  return {
69
70
  inputProps: (0, $4vDl6$mergeProps)(domProps, {
70
71
  ...interactions,
@@ -76,6 +77,7 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
76
77
  value: value,
77
78
  onChange: onChange,
78
79
  "aria-describedby": [
80
+ props["aria-describedby"],
79
81
  state.validationState === "invalid" ? (0, $884aeceb3d67f00f$export$61c8d3f0151e21b2).get(state) : null,
80
82
  (0, $884aeceb3d67f00f$export$8e8b214e06dd397d).get(state)
81
83
  ].filter(Boolean).join(" ") || undefined
package/dist/main.js CHANGED
@@ -71,6 +71,7 @@ function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
71
71
  });
72
72
  let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;
73
73
  if (isDisabled) tabIndex = undefined;
74
+ (0, $fMEGB$reactariautils.useFormReset)(ref, state.selectedValue, state.setSelectedValue);
74
75
  return {
75
76
  inputProps: (0, $fMEGB$reactariautils.mergeProps)(domProps, {
76
77
  ...interactions,
@@ -82,6 +83,7 @@ function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
82
83
  value: value,
83
84
  onChange: onChange,
84
85
  "aria-describedby": [
86
+ props["aria-describedby"],
85
87
  state.validationState === "invalid" ? (0, $eeb149278aae5c67$export$61c8d3f0151e21b2).get(state) : null,
86
88
  (0, $eeb149278aae5c67$export$8e8b214e06dd397d).get(state)
87
89
  ].filter(Boolean).join(" ") || undefined
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;ACZA;;;;;;;;;;CAUC,GAED,AAEO,MAAM,4CAAkB,IAAI;AAC5B,MAAM,4CAA2B,IAAI;AACrC,MAAM,4CAA4B,IAAI;;;;;ADsBtC,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAgC,EAAa;IACnH,IAAI,SACF,MAAK,YACL,SAAQ,EACR,cAAc,UAAS,EACvB,mBAAmB,eAAc,EAClC,GAAG;IAEJ,MAAM,aAAa,MAAM,UAAU,IAAI,MAAM,UAAU;IAEvD,IAAI,cAAc,YAAY,IAAI;IAClC,IAAI,eAAe,aAAa,IAAI,IAAI,kBAAkB,IAAI;IAC9D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,IAAI,CAAC;IAGf,IAAI,UAAU,MAAM,aAAa,KAAK;IAEtC,IAAI,WAAW,CAAC,IAAM;QACpB,EAAE,eAAe;QACjB,MAAM,gBAAgB,CAAC;IACzB;IAEA,IAAI,cAAC,WAAU,aAAE,UAAS,EAAC,GAAG,CAAA,GAAA,qCAAQ,AAAD,EAAE;oBACrC;IACF;IAEA,IAAI,kBAAC,eAAc,EAAC,GAAG,CAAA,GA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GAAA,2BAAI,EAAE;IACtB,CAAA,GAAA,yCAAc,EAAE,GAAG,CAAC,OAAO;IAE3B,OAAO;QACL,iBAAiB,CAAA,GAAA,gCAAU,AAAD,EAAE,UAAU;YACpC,iDAAiD;YACjD,MAAM;uBACN;YACA,gBAAgB,oBAAoB,aAAa;YACjD,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,oBAAoB;YACpB,GAAG,UAAU;YACb,GAAG,gBAAgB;QACrB;oBACA;0BACA;2BACA;IACF;AACF;","sources":["packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/utils.ts","packages/@react-aria/radio/src/useRadioGroup.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 */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {Orientation} from '@react-types/shared';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n","/*\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 {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the radio is disabled. */\n isDisabled: boolean,\n /** Whether the radio is currently selected. */\n isSelected: boolean,\n /** Whether the radio is in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an individual\n * radio button in a radio group.\n * @param props - Props for the radio.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n * @param ref - Ref to the HTML input element.\n */\nexport function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<HTMLInputElement>): RadioAria {\n let {\n value,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby\n } = props;\n\n const isDisabled = props.isDisabled || state.isDisabled;\n\n let hasChildren = children != null;\n let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;\n if (!hasChildren && !hasAriaLabel) {\n console.warn('If you do not provide children, you must specify an aria-label for accessibility');\n }\n\n let checked = state.selectedValue === value;\n\n let onChange = (e) => {\n e.stopPropagation();\n state.setSelectedValue(value);\n };\n\n let {pressProps, isPressed} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(mergeProps(props, {\n onFocus: () => state.setLastFocusedValue(value)\n }), ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange,\n 'aria-describedby': [\n state.validationState === 'invalid' ? radioGroupErrorMessageIds.get(state) : null,\n radioGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked,\n isPressed\n };\n}\n","/*\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 {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\nexport const radioGroupDescriptionIds = new WeakMap<RadioGroupState, string>();\nexport const radioGroupErrorMessageIds = new WeakMap<RadioGroupState, string>();\n","/*\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 {AriaRadioGroupProps} from '@react-types/radio';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: DOMAttributes,\n /** Props for the radio group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the radio group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the radio group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a radio group component.\n * Radio groups allow users to select a single item from a list of mutually exclusive options.\n * @param props - Props for the radio group.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n */\nexport function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria {\n let {\n name,\n validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Radio group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n radioGroupDescriptionIds.set(state, descriptionProps.id);\n radioGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // When the radio group loses focus, reset the focusable radio to null if\n // there is no selection. This allows tabbing into the group from either\n // direction to go to the first or last radio.\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\n });\n\n let onKeyDown = (e) => {\n let nextDir;\n switch (e.key) {\n case 'ArrowRight':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'prev';\n } else {\n nextDir = 'next';\n }\n break;\n case 'ArrowLeft':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'next';\n } else {\n nextDir = 'prev';\n }\n break;\n case 'ArrowDown':\n nextDir = 'next';\n break;\n case 'ArrowUp':\n nextDir = 'prev';\n break;\n default:\n return;\n }\n e.preventDefault();\n let walker = getFocusableTreeWalker(e.currentTarget, {from: e.target});\n let nextElem;\n if (nextDir === 'next') {\n nextElem = walker.nextNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.firstChild();\n }\n } else {\n nextElem = walker.previousNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.lastChild();\n }\n }\n if (nextElem) {\n // Call focus on nextElem so that keyboard navigation scrolls the radio into view\n nextElem.focus();\n state.setSelectedValue(nextElem.value);\n }\n };\n\n let groupName = useId(name);\n radioGroupNames.set(state, groupName);\n\n return {\n radioGroupProps: mergeProps(domProps, {\n // https://www.w3.org/TR/wai-aria-1.2/#radiogroup\n role: 'radiogroup',\n onKeyDown,\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n 'aria-disabled': isDisabled || undefined,\n 'aria-orientation': orientation,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAIM,MAAM,4CAAkB,IAAI;AAC5B,MAAM,4CAA2B,IAAI;AACrC,MAAM,4CAA4B,IAAI;;;;;ADsBtC,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAgC;IACtG,IAAI,SACF,MAAK,YACL,SAAQ,EACR,cAAc,UAAS,EACvB,mBAAmB,eAAc,EAClC,GAAG;IAEJ,MAAM,aAAa,MAAM,cAAc,MAAM;IAE7C,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,KAAK;IAGf,IAAI,UAAU,MAAM,kBAAkB;IAEtC,IAAI,WAAW,CAAC;QACd,EAAE;QACF,MAAM,iBAAiB;IACzB;IAEA,IAAI,cAAC,WAAU,aAAE,UAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;oBACrC;IACF;IAEA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,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,oBAAoB;YACpB,GAAG,UAAU;YACb,GAAG,gBAAgB;QACrB;oBACA;0BACA;2BACA;IACF;AACF;","sources":["packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/utils.ts","packages/@react-aria/radio/src/useRadioGroup.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 */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {Orientation} from '@react-types/shared';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n","/*\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 {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the radio is disabled. */\n isDisabled: boolean,\n /** Whether the radio is currently selected. */\n isSelected: boolean,\n /** Whether the radio is in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an individual\n * radio button in a radio group.\n * @param props - Props for the radio.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n * @param ref - Ref to the HTML input element.\n */\nexport function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<HTMLInputElement>): RadioAria {\n let {\n value,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby\n } = props;\n\n const isDisabled = props.isDisabled || state.isDisabled;\n\n let hasChildren = children != null;\n let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;\n if (!hasChildren && !hasAriaLabel) {\n console.warn('If you do not provide children, you must specify an aria-label for accessibility');\n }\n\n let checked = state.selectedValue === value;\n\n let onChange = (e) => {\n e.stopPropagation();\n state.setSelectedValue(value);\n };\n\n let {pressProps, isPressed} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(mergeProps(props, {\n onFocus: () => state.setLastFocusedValue(value)\n }), ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n useFormReset(ref, state.selectedValue, state.setSelectedValue);\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange,\n 'aria-describedby': [\n props['aria-describedby'],\n state.validationState === 'invalid' ? radioGroupErrorMessageIds.get(state) : null,\n radioGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked,\n isPressed\n };\n}\n","/*\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 {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\nexport const radioGroupDescriptionIds = new WeakMap<RadioGroupState, string>();\nexport const radioGroupErrorMessageIds = new WeakMap<RadioGroupState, string>();\n","/*\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 {AriaRadioGroupProps} from '@react-types/radio';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: DOMAttributes,\n /** Props for the radio group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the radio group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the radio group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a radio group component.\n * Radio groups allow users to select a single item from a list of mutually exclusive options.\n * @param props - Props for the radio group.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n */\nexport function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria {\n let {\n name,\n validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Radio group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n radioGroupDescriptionIds.set(state, descriptionProps.id);\n radioGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // When the radio group loses focus, reset the focusable radio to null if\n // there is no selection. This allows tabbing into the group from either\n // direction to go to the first or last radio.\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\n });\n\n let onKeyDown = (e) => {\n let nextDir;\n switch (e.key) {\n case 'ArrowRight':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'prev';\n } else {\n nextDir = 'next';\n }\n break;\n case 'ArrowLeft':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'next';\n } else {\n nextDir = 'prev';\n }\n break;\n case 'ArrowDown':\n nextDir = 'next';\n break;\n case 'ArrowUp':\n nextDir = 'prev';\n break;\n default:\n return;\n }\n e.preventDefault();\n let walker = getFocusableTreeWalker(e.currentTarget, {from: e.target});\n let nextElem;\n if (nextDir === 'next') {\n nextElem = walker.nextNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.firstChild();\n }\n } else {\n nextElem = walker.previousNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.lastChild();\n }\n }\n if (nextElem) {\n // Call focus on nextElem so that keyboard navigation scrolls the radio into view\n nextElem.focus();\n state.setSelectedValue(nextElem.value);\n }\n };\n\n let groupName = useId(name);\n radioGroupNames.set(state, groupName);\n\n return {\n radioGroupProps: mergeProps(domProps, {\n // https://www.w3.org/TR/wai-aria-1.2/#radiogroup\n role: 'radiogroup',\n onKeyDown,\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n 'aria-disabled': isDisabled || undefined,\n 'aria-orientation': orientation,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import {mergeProps as $4vDl6$mergeProps, filterDOMProps as $4vDl6$filterDOMProps, useId as $4vDl6$useId} from "@react-aria/utils";
1
+ import {mergeProps as $4vDl6$mergeProps, filterDOMProps as $4vDl6$filterDOMProps, useFormReset as $4vDl6$useFormReset, useId as $4vDl6$useId} from "@react-aria/utils";
2
2
  import {useFocusable as $4vDl6$useFocusable, getFocusableTreeWalker as $4vDl6$getFocusableTreeWalker} from "@react-aria/focus";
3
3
  import {usePress as $4vDl6$usePress, useFocusWithin as $4vDl6$useFocusWithin} from "@react-aria/interactions";
4
4
  import {useField as $4vDl6$useField} from "@react-aria/label";
@@ -65,6 +65,7 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
65
65
  });
66
66
  let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;
67
67
  if (isDisabled) tabIndex = undefined;
68
+ (0, $4vDl6$useFormReset)(ref, state.selectedValue, state.setSelectedValue);
68
69
  return {
69
70
  inputProps: (0, $4vDl6$mergeProps)(domProps, {
70
71
  ...interactions,
@@ -76,6 +77,7 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
76
77
  value: value,
77
78
  onChange: onChange,
78
79
  "aria-describedby": [
80
+ props["aria-describedby"],
79
81
  state.validationState === "invalid" ? (0, $884aeceb3d67f00f$export$61c8d3f0151e21b2).get(state) : null,
80
82
  (0, $884aeceb3d67f00f$export$8e8b214e06dd397d).get(state)
81
83
  ].filter(Boolean).join(" ") || undefined
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;ACZA;;;;;;;;;;CAUC,GAED,AAEO,MAAM,4CAAkB,IAAI;AAC5B,MAAM,4CAA2B,IAAI;AACrC,MAAM,4CAA4B,IAAI;;;;;ADsBtC,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAgC,EAAa;IACnH,IAAI,SACF,MAAK,YACL,SAAQ,EACR,cAAc,UAAS,EACvB,mBAAmB,eAAc,EAClC,GAAG;IAEJ,MAAM,aAAa,MAAM,UAAU,IAAI,MAAM,UAAU;IAEvD,IAAI,cAAc,YAAY,IAAI;IAClC,IAAI,eAAe,aAAa,IAAI,IAAI,kBAAkB,IAAI;IAC9D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,IAAI,CAAC;IAGf,IAAI,UAAU,MAAM,aAAa,KAAK;IAEtC,IAAI,WAAW,CAAC,IAAM;QACpB,EAAE,eAAe;QACjB,MAAM,gBAAgB,CAAC;IACzB;IAEA,IAAI,cAAC,WAAU,aAAE,UAAS,EAAC,GAAG,CAAA,GAAA,eAAQ,AAAD,EAAE;oBACrC;IACF;IAEA,IAAI,kBAAC,eAAc,EAAC,GAAG,CAAA,GAAA,mBAAY,AAAD,EAAE,CAAA,GAAA,iBAAU,AAAD,EAAE,OAAO;QACpD,SAAS,IAAM,MAAM,mBAAmB,CAAC;IAC3C,IAAI;IACJ,IAAI,eAAe,CAAA,GAAA,iBAAS,EAAE,YAAY;IAC1C,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW,IAAI;IAAA;IACrD,IAAI,WAAW,MAAM,gBAAgB,KAAK,SAAS,MAAM,gBAAgB,IAAI,IAAI,GAA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,GAAG,UAAU;YACb,GAAG,gBAAgB;QACrB;oBACA;0BACA;2BACA;IACF;AACF;","sources":["packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/utils.ts","packages/@react-aria/radio/src/useRadioGroup.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 */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {Orientation} from '@react-types/shared';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n","/*\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 {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the radio is disabled. */\n isDisabled: boolean,\n /** Whether the radio is currently selected. */\n isSelected: boolean,\n /** Whether the radio is in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an individual\n * radio button in a radio group.\n * @param props - Props for the radio.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n * @param ref - Ref to the HTML input element.\n */\nexport function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<HTMLInputElement>): RadioAria {\n let {\n value,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby\n } = props;\n\n const isDisabled = props.isDisabled || state.isDisabled;\n\n let hasChildren = children != null;\n let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;\n if (!hasChildren && !hasAriaLabel) {\n console.warn('If you do not provide children, you must specify an aria-label for accessibility');\n }\n\n let checked = state.selectedValue === value;\n\n let onChange = (e) => {\n e.stopPropagation();\n state.setSelectedValue(value);\n };\n\n let {pressProps, isPressed} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(mergeProps(props, {\n onFocus: () => state.setLastFocusedValue(value)\n }), ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange,\n 'aria-describedby': [\n state.validationState === 'invalid' ? radioGroupErrorMessageIds.get(state) : null,\n radioGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked,\n isPressed\n };\n}\n","/*\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 {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\nexport const radioGroupDescriptionIds = new WeakMap<RadioGroupState, string>();\nexport const radioGroupErrorMessageIds = new WeakMap<RadioGroupState, string>();\n","/*\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 {AriaRadioGroupProps} from '@react-types/radio';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: DOMAttributes,\n /** Props for the radio group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the radio group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the radio group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a radio group component.\n * Radio groups allow users to select a single item from a list of mutually exclusive options.\n * @param props - Props for the radio group.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n */\nexport function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria {\n let {\n name,\n validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Radio group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n radioGroupDescriptionIds.set(state, descriptionProps.id);\n radioGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // When the radio group loses focus, reset the focusable radio to null if\n // there is no selection. This allows tabbing into the group from either\n // direction to go to the first or last radio.\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\n });\n\n let onKeyDown = (e) => {\n let nextDir;\n switch (e.key) {\n case 'ArrowRight':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'prev';\n } else {\n nextDir = 'next';\n }\n break;\n case 'ArrowLeft':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'next';\n } else {\n nextDir = 'prev';\n }\n break;\n case 'ArrowDown':\n nextDir = 'next';\n break;\n case 'ArrowUp':\n nextDir = 'prev';\n break;\n default:\n return;\n }\n e.preventDefault();\n let walker = getFocusableTreeWalker(e.currentTarget, {from: e.target});\n let nextElem;\n if (nextDir === 'next') {\n nextElem = walker.nextNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.firstChild();\n }\n } else {\n nextElem = walker.previousNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.lastChild();\n }\n }\n if (nextElem) {\n // Call focus on nextElem so that keyboard navigation scrolls the radio into view\n nextElem.focus();\n state.setSelectedValue(nextElem.value);\n }\n };\n\n let groupName = useId(name);\n radioGroupNames.set(state, groupName);\n\n return {\n radioGroupProps: mergeProps(domProps, {\n // https://www.w3.org/TR/wai-aria-1.2/#radiogroup\n role: 'radiogroup',\n onKeyDown,\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n 'aria-disabled': isDisabled || undefined,\n 'aria-orientation': orientation,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAIM,MAAM,4CAAkB,IAAI;AAC5B,MAAM,4CAA2B,IAAI;AACrC,MAAM,4CAA4B,IAAI;;;;;ADsBtC,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAgC;IACtG,IAAI,SACF,MAAK,YACL,SAAQ,EACR,cAAc,UAAS,EACvB,mBAAmB,eAAc,EAClC,GAAG;IAEJ,MAAM,aAAa,MAAM,cAAc,MAAM;IAE7C,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,KAAK;IAGf,IAAI,UAAU,MAAM,kBAAkB;IAEtC,IAAI,WAAW,CAAC;QACd,EAAE;QACF,MAAM,iBAAiB;IACzB;IAEA,IAAI,cAAC,WAAU,aAAE,UAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;oBACrC;IACF;IAEA,IAAI,kBAAC,eAAc,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE,CAAA,GAAA,iBAAS,EAAE,OAAO;QACpD,SAAS,IAAM,MAAM,oBAAoB;IAC3C,IAAI;IACJ,IAAI,eAAe,CAAA,GAAA,iBAAS,EAAE,YAAY;IAC1C,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,WAAW,MAAM,qBAAqB,SAAS,MAAM,oBAAoB,OAAO,IAAI;IACx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;QACf,IAAI;QACJ,OAAQ,EAAE;YACR,KAAK;gBACH,IAAI,cAAc,SAAS,gBAAgB,YACzC,UAAU;qBAEV,UAAU;gBAEZ;YACF,KAAK;gBACH,IAAI,cAAc,SAAS,gBAAgB,YACzC,UAAU;qBAEV,UAAU;gBAEZ;YACF,KAAK;gBACH,UAAU;gBACV;YACF,KAAK;gBACH,UAAU;gBACV;YACF;gBACE;QACJ;QACA,EAAE;QACF,IAAI,SAAS,CAAA,GAAA,6BAAqB,EAAE,EAAE,eAAe;YAAC,MAAM,EAAE;QAAM;QACpE,IAAI;QACJ,IAAI,YAAY,QAAQ;YACtB,WAAW,OAAO;YAClB,IAAI,CAAC,UAAU;gBACb,OAAO,cAAc,EAAE;gBACvB,WAAW,OAAO;YACpB;QACF,OAAO;YACL,WAAW,OAAO;YAClB,IAAI,CAAC,UAAU;gBACb,OAAO,cAAc,EAAE;gBACvB,WAAW,OAAO;YACpB;QACF;QACA,IAAI,UAAU;YACZ,iFAAiF;YACjF,SAAS;YACT,MAAM,iBAAiB,SAAS;QAClC;IACF;IAEA,IAAI,YAAY,CAAA,GAAA,YAAI,EAAE;IACtB,CAAA,GAAA,yCAAc,EAAE,IAAI,OAAO;IAE3B,OAAO;QACL,iBAAiB,CAAA,GAAA,iBAAS,EAAE,UAAU;YACpC,iDAAiD;YACjD,MAAM;uBACN;YACA,gBAAgB,oBAAoB,aAAa;YACjD,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,oBAAoB;YACpB,GAAG,UAAU;YACb,GAAG,gBAAgB;QACrB;oBACA;0BACA;2BACA;IACF;AACF;","sources":["packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/utils.ts","packages/@react-aria/radio/src/useRadioGroup.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 */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {Orientation} from '@react-types/shared';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n","/*\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 {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the radio is disabled. */\n isDisabled: boolean,\n /** Whether the radio is currently selected. */\n isSelected: boolean,\n /** Whether the radio is in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an individual\n * radio button in a radio group.\n * @param props - Props for the radio.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n * @param ref - Ref to the HTML input element.\n */\nexport function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<HTMLInputElement>): RadioAria {\n let {\n value,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby\n } = props;\n\n const isDisabled = props.isDisabled || state.isDisabled;\n\n let hasChildren = children != null;\n let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;\n if (!hasChildren && !hasAriaLabel) {\n console.warn('If you do not provide children, you must specify an aria-label for accessibility');\n }\n\n let checked = state.selectedValue === value;\n\n let onChange = (e) => {\n e.stopPropagation();\n state.setSelectedValue(value);\n };\n\n let {pressProps, isPressed} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(mergeProps(props, {\n onFocus: () => state.setLastFocusedValue(value)\n }), ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n useFormReset(ref, state.selectedValue, state.setSelectedValue);\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange,\n 'aria-describedby': [\n props['aria-describedby'],\n state.validationState === 'invalid' ? radioGroupErrorMessageIds.get(state) : null,\n radioGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked,\n isPressed\n };\n}\n","/*\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 {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\nexport const radioGroupDescriptionIds = new WeakMap<RadioGroupState, string>();\nexport const radioGroupErrorMessageIds = new WeakMap<RadioGroupState, string>();\n","/*\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 {AriaRadioGroupProps} from '@react-types/radio';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: DOMAttributes,\n /** Props for the radio group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the radio group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the radio group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a radio group component.\n * Radio groups allow users to select a single item from a list of mutually exclusive options.\n * @param props - Props for the radio group.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n */\nexport function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria {\n let {\n name,\n validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Radio group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n radioGroupDescriptionIds.set(state, descriptionProps.id);\n radioGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // When the radio group loses focus, reset the focusable radio to null if\n // there is no selection. This allows tabbing into the group from either\n // direction to go to the first or last radio.\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\n });\n\n let onKeyDown = (e) => {\n let nextDir;\n switch (e.key) {\n case 'ArrowRight':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'prev';\n } else {\n nextDir = 'next';\n }\n break;\n case 'ArrowLeft':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'next';\n } else {\n nextDir = 'prev';\n }\n break;\n case 'ArrowDown':\n nextDir = 'next';\n break;\n case 'ArrowUp':\n nextDir = 'prev';\n break;\n default:\n return;\n }\n e.preventDefault();\n let walker = getFocusableTreeWalker(e.currentTarget, {from: e.target});\n let nextElem;\n if (nextDir === 'next') {\n nextElem = walker.nextNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.firstChild();\n }\n } else {\n nextElem = walker.previousNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.lastChild();\n }\n }\n if (nextElem) {\n // Call focus on nextElem so that keyboard navigation scrolls the radio into view\n nextElem.focus();\n state.setSelectedValue(nextElem.value);\n }\n };\n\n let groupName = useId(name);\n radioGroupNames.set(state, groupName);\n\n return {\n radioGroupProps: mergeProps(domProps, {\n // https://www.w3.org/TR/wai-aria-1.2/#radiogroup\n role: 'radiogroup',\n onKeyDown,\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n 'aria-disabled': isDisabled || undefined,\n 'aria-orientation': orientation,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;ACoBA;IACE,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,qCAAqC;IACrC,UAAU,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,UAAU,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;GAMG;AACH,yBAAyB,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,SAAS,CAwDnH;ACxED;IACE,iDAAiD;IACjD,eAAe,EAAE,aAAa,CAAC;IAC/B,0DAA0D;IAC1D,UAAU,EAAE,aAAa,CAAC;IAC1B,6DAA6D;IAC7D,gBAAgB,EAAE,aAAa,CAAC;IAChC,+DAA+D;IAC/D,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAED;;;;;GAKG;AACH,8BAA8B,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,eAAe,GAAG,cAAc,CAuGhG;ACjID,YAAY,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAC5E,YAAY,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/radio/src/packages/@react-aria/radio/src/utils.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/useRadioGroup.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\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 */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {Orientation} from '@react-types/shared';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;ACoBA;IACE,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,qCAAqC;IACrC,UAAU,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,UAAU,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;GAMG;AACH,yBAAyB,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,SAAS,CA2DnH;AC3ED;IACE,iDAAiD;IACjD,eAAe,EAAE,aAAa,CAAC;IAC/B,0DAA0D;IAC1D,UAAU,EAAE,aAAa,CAAC;IAC1B,6DAA6D;IAC7D,gBAAgB,EAAE,aAAa,CAAC;IAChC,+DAA+D;IAC/D,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAED;;;;;GAKG;AACH,8BAA8B,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,eAAe,GAAG,cAAc,CAuGhG;ACjID,YAAY,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAC5E,YAAY,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/radio/src/packages/@react-aria/radio/src/utils.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/useRadioGroup.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\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 */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {Orientation} from '@react-types/shared';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/radio",
3
- "version": "3.6.1",
3
+ "version": "3.7.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,15 +22,15 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/focus": "^3.12.1",
26
- "@react-aria/i18n": "^3.7.2",
27
- "@react-aria/interactions": "^3.15.1",
28
- "@react-aria/label": "^3.5.2",
29
- "@react-aria/utils": "^3.17.0",
30
- "@react-stately/radio": "^3.8.1",
31
- "@react-types/radio": "^3.4.2",
32
- "@react-types/shared": "^3.18.1",
33
- "@swc/helpers": "^0.4.14"
25
+ "@react-aria/focus": "^3.14.0",
26
+ "@react-aria/i18n": "^3.8.1",
27
+ "@react-aria/interactions": "^3.17.0",
28
+ "@react-aria/label": "^3.6.1",
29
+ "@react-aria/utils": "^3.19.0",
30
+ "@react-stately/radio": "^3.8.3",
31
+ "@react-types/radio": "^3.5.0",
32
+ "@react-types/shared": "^3.19.0",
33
+ "@swc/helpers": "^0.5.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "5911ed21de4b76d66f6254c02302519e02d50e16"
41
+ "gitHead": "d4dfe4bb842a914f10045ee63fc6b92f034c5b30"
42
42
  }
package/src/useRadio.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
 
13
13
  import {AriaRadioProps} from '@react-types/radio';
14
- import {filterDOMProps, mergeProps} from '@react-aria/utils';
14
+ import {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';
15
15
  import {InputHTMLAttributes, RefObject} from 'react';
16
16
  import {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';
17
17
  import {RadioGroupState} from '@react-stately/radio';
@@ -73,6 +73,8 @@ export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: Ref
73
73
  tabIndex = undefined;
74
74
  }
75
75
 
76
+ useFormReset(ref, state.selectedValue, state.setSelectedValue);
77
+
76
78
  return {
77
79
  inputProps: mergeProps(domProps, {
78
80
  ...interactions,
@@ -84,6 +86,7 @@ export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: Ref
84
86
  value,
85
87
  onChange,
86
88
  'aria-describedby': [
89
+ props['aria-describedby'],
87
90
  state.validationState === 'invalid' ? radioGroupErrorMessageIds.get(state) : null,
88
91
  radioGroupDescriptionIds.get(state)
89
92
  ].filter(Boolean).join(' ') || undefined