@react-aria/radio 3.12.0 → 3.12.2

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.
@@ -1 +1 @@
1
- {"mappings":";;;;ACqBA;IACE,2CAA2C;IAC3C,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,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,GAAG,IAAI,CAAC,GAAG,SAAS,CAmG1H;ACtHD,+BAAgC,SAAQ,gBAAgB;IACtD,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,CAwHhG;AClJD,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":";;;;ACqBA;IACE,2CAA2C;IAC3C,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,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,GAAG,IAAI,CAAC,GAAG,SAAS,CA2G1H;AC9HD,+BAAgC,SAAQ,gBAAgB;IACtD,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,CAwHhG;AClJD,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,5 +1,6 @@
1
1
  var $eeb149278aae5c67$exports = require("./utils.main.js");
2
2
  var $gWC9A$reactariautils = require("@react-aria/utils");
3
+ var $gWC9A$react = require("react");
3
4
  var $gWC9A$reactariainteractions = require("@react-aria/interactions");
4
5
  var $gWC9A$reactariaform = require("@react-aria/form");
5
6
 
@@ -23,6 +24,7 @@ $parcel$export(module.exports, "useRadio", () => $e184702b1b7f1863$export$37b096
23
24
 
24
25
 
25
26
 
27
+
26
28
  function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
27
29
  let { value: value, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressChange: onPressChange, onPress: onPress, onPressUp: onPressUp, onClick: onClick } = props;
28
30
  const isDisabled = props.isDisabled || state.isDisabled;
@@ -77,9 +79,12 @@ function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
77
79
  validationBehavior: validationBehavior
78
80
  }, state, ref);
79
81
  return {
80
- labelProps: (0, $gWC9A$reactariautils.mergeProps)(labelProps, {
81
- onClick: (e)=>e.preventDefault()
82
- }),
82
+ labelProps: (0, $gWC9A$reactariautils.mergeProps)(labelProps, (0, $gWC9A$react.useMemo)(()=>({
83
+ onClick: (e)=>e.preventDefault(),
84
+ // Prevent label from being focused when mouse down on it.
85
+ // Note, this does not prevent the input from being focused in the `click` event.
86
+ onMouseDown: (e)=>e.preventDefault()
87
+ }), [])),
83
88
  inputProps: (0, $gWC9A$reactariautils.mergeProps)(domProps, {
84
89
  ...interactions,
85
90
  type: 'radio',
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA+BM,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAuC;IAC7G,IAAI,SACF,KAAK,YACL,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,gBACjC,YAAY,cACZ,UAAU,iBACV,aAAa,WACb,OAAO,aACP,SAAS,WACT,OAAO,EACR,GAAG;IAEJ,MAAM,aAAa,MAAM,UAAU,IAAI,MAAM,UAAU;IAEvD,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,gBAAgB,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAC5D,QAAQ,IAAI,CAAC;IAGf,IAAI,UAAU,MAAM,aAAa,KAAK;IAEtC,IAAI,WAAW,CAAC;QACd,EAAE,eAAe;QACjB,MAAM,gBAAgB,CAAC;IACzB;IAEA,uFAAuF;IACvF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAA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,MAAM;kBACN;kBACA;sBACA;YACA,UAAU;YACV,UAAU,MAAM,UAAU,IAAI,uBAAuB;qBACrD;mBACA;sBACA;YACA,oBAAoB;gBAClB,KAAK,CAAC,mBAAmB;gBACzB,MAAM,SAAS,GAAG,iBAAiB;gBACnC;aACD,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ;QACjC;oBACA;QACA,YAAY;QACZ,WAAW,aAAa;IAC1B;AACF","sources":["packages/@react-aria/radio/src/useRadio.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 {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\nimport {radioGroupData} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {RefObject} from '@react-types/shared';\nimport {useFocusable, usePress} from '@react-aria/interactions';\nimport {useFormValidation} from '@react-aria/form';\n\nexport interface RadioAria {\n /** Props for the label wrapper element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\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 | null>): RadioAria {\n let {\n value,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick\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 && process.env.NODE_ENV !== 'production') {\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 // Handle press state for keyboard interactions and cases where labelProps is not used.\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick,\n isDisabled\n });\n\n // Handle press state on the label.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPressUp,\n onClick,\n isDisabled,\n onPress(e) {\n onPress?.(e);\n state.setSelectedValue(value);\n ref.current?.focus();\n }\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: number | undefined = -1;\n if (state.selectedValue != null) {\n if (state.selectedValue === value) {\n tabIndex = 0;\n }\n } else if (state.lastFocusedValue === value || state.lastFocusedValue == null) {\n tabIndex = 0;\n }\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n let {name, form, descriptionId, errorMessageId, validationBehavior} = radioGroupData.get(state)!;\n useFormReset(ref, state.defaultSelectedValue, state.setSelectedValue);\n useFormValidation({validationBehavior}, state, ref);\n\n return {\n labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}),\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name,\n form,\n tabIndex,\n disabled: isDisabled,\n required: state.isRequired && validationBehavior === 'native',\n checked,\n value,\n onChange,\n 'aria-describedby': [\n props['aria-describedby'],\n state.isInvalid ? errorMessageId : null,\n descriptionId\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked,\n isPressed: isPressed || isLabelPressed\n };\n}\n"],"names":[],"version":3,"file":"useRadio.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+BM,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAuC;IAC7G,IAAI,SACF,KAAK,YACL,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,gBACjC,YAAY,cACZ,UAAU,iBACV,aAAa,WACb,OAAO,aACP,SAAS,WACT,OAAO,EACR,GAAG;IAEJ,MAAM,aAAa,MAAM,UAAU,IAAI,MAAM,UAAU;IAEvD,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,gBAAgB,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAC5D,QAAQ,IAAI,CAAC;IAGf,IAAI,UAAU,MAAM,aAAa,KAAK;IAEtC,IAAI,WAAW,CAAC;QACd,EAAE,eAAe;QACjB,MAAM,gBAAgB,CAAC;IACzB;IAEA,uFAAuF;IACvF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;sBACrC;oBACA;uBACA;iBACA;mBACA;iBACA;oBACA;IACF;IAEA,mCAAmC;IACnC,IAAI,EAAC,YAAY,UAAU,EAAE,WAAW,cAAc,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;sBACjE;oBACA;uBACA;mBACA;iBACA;oBACA;QACA,SAAQ,CAAC;gBAGP;YAFA,oBAAA,8BAAA,QAAU;YACV,MAAM,gBAAgB,CAAC;aACvB,eAAA,IAAI,OAAO,cAAX,mCAAA,aAAa,KAAK;QACpB;IACF;IAEA,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A;QACA,YAAY;QACZ,WAAW,aAAa;IAC1B;AACF","sources":["packages/@react-aria/radio/src/useRadio.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 {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, LabelHTMLAttributes, useMemo} from 'react';\nimport {radioGroupData} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {RefObject} from '@react-types/shared';\nimport {useFocusable, usePress} from '@react-aria/interactions';\nimport {useFormValidation} from '@react-aria/form';\n\nexport interface RadioAria {\n /** Props for the label wrapper element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\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 | null>): RadioAria {\n let {\n value,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick\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 && process.env.NODE_ENV !== 'production') {\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 // Handle press state for keyboard interactions and cases where labelProps is not used.\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick,\n isDisabled\n });\n\n // Handle press state on the label.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPressUp,\n onClick,\n isDisabled,\n onPress(e) {\n onPress?.(e);\n state.setSelectedValue(value);\n ref.current?.focus();\n }\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: number | undefined = -1;\n if (state.selectedValue != null) {\n if (state.selectedValue === value) {\n tabIndex = 0;\n }\n } else if (state.lastFocusedValue === value || state.lastFocusedValue == null) {\n tabIndex = 0;\n }\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n let {name, form, descriptionId, errorMessageId, validationBehavior} = radioGroupData.get(state)!;\n useFormReset(ref, state.defaultSelectedValue, state.setSelectedValue);\n useFormValidation({validationBehavior}, state, ref);\n\n return {\n labelProps: mergeProps(\n labelProps,\n useMemo(() => ({\n onClick: e => e.preventDefault(),\n\n // Prevent label from being focused when mouse down on it.\n // Note, this does not prevent the input from being focused in the `click` event.\n onMouseDown: e => e.preventDefault()\n }), [])),\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name,\n form,\n tabIndex,\n disabled: isDisabled,\n required: state.isRequired && validationBehavior === 'native',\n checked,\n value,\n onChange,\n 'aria-describedby': [\n props['aria-describedby'],\n state.isInvalid ? errorMessageId : null,\n descriptionId\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked,\n isPressed: isPressed || isLabelPressed\n };\n}\n"],"names":[],"version":3,"file":"useRadio.main.js.map"}
package/dist/useRadio.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import {radioGroupData as $884aeceb3d67f00f$export$37b65e5b5444d35c} from "./utils.mjs";
2
2
  import {mergeProps as $5jJ3f$mergeProps, filterDOMProps as $5jJ3f$filterDOMProps, useFormReset as $5jJ3f$useFormReset} from "@react-aria/utils";
3
+ import {useMemo as $5jJ3f$useMemo} from "react";
3
4
  import {usePress as $5jJ3f$usePress, useFocusable as $5jJ3f$useFocusable} from "@react-aria/interactions";
4
5
  import {useFormValidation as $5jJ3f$useFormValidation} from "@react-aria/form";
5
6
 
@@ -17,6 +18,7 @@ import {useFormValidation as $5jJ3f$useFormValidation} from "@react-aria/form";
17
18
 
18
19
 
19
20
 
21
+
20
22
  function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
21
23
  let { value: value, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressChange: onPressChange, onPress: onPress, onPressUp: onPressUp, onClick: onClick } = props;
22
24
  const isDisabled = props.isDisabled || state.isDisabled;
@@ -71,9 +73,12 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
71
73
  validationBehavior: validationBehavior
72
74
  }, state, ref);
73
75
  return {
74
- labelProps: (0, $5jJ3f$mergeProps)(labelProps, {
75
- onClick: (e)=>e.preventDefault()
76
- }),
76
+ labelProps: (0, $5jJ3f$mergeProps)(labelProps, (0, $5jJ3f$useMemo)(()=>({
77
+ onClick: (e)=>e.preventDefault(),
78
+ // Prevent label from being focused when mouse down on it.
79
+ // Note, this does not prevent the input from being focused in the `click` event.
80
+ onMouseDown: (e)=>e.preventDefault()
81
+ }), [])),
77
82
  inputProps: (0, $5jJ3f$mergeProps)(domProps, {
78
83
  ...interactions,
79
84
  type: 'radio',
@@ -1,5 +1,6 @@
1
1
  import {radioGroupData as $884aeceb3d67f00f$export$37b65e5b5444d35c} from "./utils.module.js";
2
2
  import {mergeProps as $5jJ3f$mergeProps, filterDOMProps as $5jJ3f$filterDOMProps, useFormReset as $5jJ3f$useFormReset} from "@react-aria/utils";
3
+ import {useMemo as $5jJ3f$useMemo} from "react";
3
4
  import {usePress as $5jJ3f$usePress, useFocusable as $5jJ3f$useFocusable} from "@react-aria/interactions";
4
5
  import {useFormValidation as $5jJ3f$useFormValidation} from "@react-aria/form";
5
6
 
@@ -17,6 +18,7 @@ import {useFormValidation as $5jJ3f$useFormValidation} from "@react-aria/form";
17
18
 
18
19
 
19
20
 
21
+
20
22
  function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
21
23
  let { value: value, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressChange: onPressChange, onPress: onPress, onPressUp: onPressUp, onClick: onClick } = props;
22
24
  const isDisabled = props.isDisabled || state.isDisabled;
@@ -71,9 +73,12 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
71
73
  validationBehavior: validationBehavior
72
74
  }, state, ref);
73
75
  return {
74
- labelProps: (0, $5jJ3f$mergeProps)(labelProps, {
75
- onClick: (e)=>e.preventDefault()
76
- }),
76
+ labelProps: (0, $5jJ3f$mergeProps)(labelProps, (0, $5jJ3f$useMemo)(()=>({
77
+ onClick: (e)=>e.preventDefault(),
78
+ // Prevent label from being focused when mouse down on it.
79
+ // Note, this does not prevent the input from being focused in the `click` event.
80
+ onMouseDown: (e)=>e.preventDefault()
81
+ }), [])),
77
82
  inputProps: (0, $5jJ3f$mergeProps)(domProps, {
78
83
  ...interactions,
79
84
  type: 'radio',
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AA+BM,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAuC;IAC7G,IAAI,SACF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IACb,OACK,IAAI,MAAM,gBAAgB,KAAK,SAAS,MAAM,gBAAgB,IAAI,MACvE,WAAW;IAEb,IAAI,YACF,WAAW;IAGb,IAAI,QAAC,IAAI,QAAE,IAAI,iBAAE,aAAa,kBAAE,cAAc,sBAAE,kBAAkB,EAAC,GAAG,CAAA,GAAA,yCAAa,EAAE,GAAG,CAAC;IACzF,CAAA,GAAA,mBAAW,EAAE,KAAK,MAAM,oBAAoB,EAAE,MAAM,gBAAgB;IACpE,CAAA,GAAA,wBAAgB,EAAE;4BAAC;IAAkB,GAAG,OAAO;IAE/C,OAAO;QACL,YAAY,CAAA,GAAA,iBAAS,EAAE,YAAY;YAAC,SAAS,CAAA,IAAK,EAAE,cAAc;QAAE;QACpE,YAAY,CAAA,GAAA,iBAAS,EAAE,UAAU;YAC/B,GAAG,YAAY;YACf,MAAM;kBACN;kBACA;sBACA;YACA,UAAU;YACV,UAAU,MAAM,UAAU,IAAI,uBAAuB;qBACrD;mBACA;sBACA;YACA,oBAAoB;gBAClB,KAAK,CAAC,mBAAmB;gBACzB,MAAM,SAAS,GAAG,iBAAiB;gBACnC;aACD,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ;QACjC;oBACA;QACA,YAAY;QACZ,WAAW,aAAa;IAC1B;AACF","sources":["packages/@react-aria/radio/src/useRadio.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 {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\nimport {radioGroupData} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {RefObject} from '@react-types/shared';\nimport {useFocusable, usePress} from '@react-aria/interactions';\nimport {useFormValidation} from '@react-aria/form';\n\nexport interface RadioAria {\n /** Props for the label wrapper element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\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 | null>): RadioAria {\n let {\n value,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick\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 && process.env.NODE_ENV !== 'production') {\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 // Handle press state for keyboard interactions and cases where labelProps is not used.\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick,\n isDisabled\n });\n\n // Handle press state on the label.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPressUp,\n onClick,\n isDisabled,\n onPress(e) {\n onPress?.(e);\n state.setSelectedValue(value);\n ref.current?.focus();\n }\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: number | undefined = -1;\n if (state.selectedValue != null) {\n if (state.selectedValue === value) {\n tabIndex = 0;\n }\n } else if (state.lastFocusedValue === value || state.lastFocusedValue == null) {\n tabIndex = 0;\n }\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n let {name, form, descriptionId, errorMessageId, validationBehavior} = radioGroupData.get(state)!;\n useFormReset(ref, state.defaultSelectedValue, state.setSelectedValue);\n useFormValidation({validationBehavior}, state, ref);\n\n return {\n labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}),\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name,\n form,\n tabIndex,\n disabled: isDisabled,\n required: state.isRequired && validationBehavior === 'native',\n checked,\n value,\n onChange,\n 'aria-describedby': [\n props['aria-describedby'],\n state.isInvalid ? errorMessageId : null,\n descriptionId\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked,\n isPressed: isPressed || isLabelPressed\n };\n}\n"],"names":[],"version":3,"file":"useRadio.module.js.map"}
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+BM,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAuC;IAC7G,IAAI,SACF,KAAK,YACL,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,gBACjC,YAAY,cACZ,UAAU,iBACV,aAAa,WACb,OAAO,aACP,SAAS,WACT,OAAO,EACR,GAAG;IAEJ,MAAM,aAAa,MAAM,UAAU,IAAI,MAAM,UAAU;IAEvD,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,gBAAgB,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAC5D,QAAQ,IAAI,CAAC;IAGf,IAAI,UA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AO;QACL,YAAY,CAAA,GAAA,iBAAS,EACnB,YACA,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;gBACb,SAAS,CAAA,IAAK,EAAE,cAAc;gBAE9B,0DAA0D;gBAC1D,iFAAiF;gBACjF,aAAa,CAAA,IAAK,EAAE,cAAc;YACpC,CAAA,GAAI,EAAE;QACR,YAAY,CAAA,GAAA,iBAAS,EAAE,UAAU;YAC/B,GAAG,YAAY;YACf,MAAM;kBACN;kBACA;sBACA;YACA,UAAU;YACV,UAAU,MAAM,UAAU,IAAI,uBAAuB;qBACrD;mBACA;sBACA;YACA,oBAAoB;gBAClB,KAAK,CAAC,mBAAmB;gBACzB,MAAM,SAAS,GAAG,iBAAiB;gBACnC;aACD,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ;QACjC;oBACA;QACA,YAAY;QACZ,WAAW,aAAa;IAC1B;AACF","sources":["packages/@react-aria/radio/src/useRadio.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 {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, LabelHTMLAttributes, useMemo} from 'react';\nimport {radioGroupData} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {RefObject} from '@react-types/shared';\nimport {useFocusable, usePress} from '@react-aria/interactions';\nimport {useFormValidation} from '@react-aria/form';\n\nexport interface RadioAria {\n /** Props for the label wrapper element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\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 | null>): RadioAria {\n let {\n value,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick\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 && process.env.NODE_ENV !== 'production') {\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 // Handle press state for keyboard interactions and cases where labelProps is not used.\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick,\n isDisabled\n });\n\n // Handle press state on the label.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPressUp,\n onClick,\n isDisabled,\n onPress(e) {\n onPress?.(e);\n state.setSelectedValue(value);\n ref.current?.focus();\n }\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: number | undefined = -1;\n if (state.selectedValue != null) {\n if (state.selectedValue === value) {\n tabIndex = 0;\n }\n } else if (state.lastFocusedValue === value || state.lastFocusedValue == null) {\n tabIndex = 0;\n }\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n let {name, form, descriptionId, errorMessageId, validationBehavior} = radioGroupData.get(state)!;\n useFormReset(ref, state.defaultSelectedValue, state.setSelectedValue);\n useFormValidation({validationBehavior}, state, ref);\n\n return {\n labelProps: mergeProps(\n labelProps,\n useMemo(() => ({\n onClick: e => e.preventDefault(),\n\n // Prevent label from being focused when mouse down on it.\n // Note, this does not prevent the input from being focused in the `click` event.\n onMouseDown: e => e.preventDefault()\n }), [])),\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name,\n form,\n tabIndex,\n disabled: isDisabled,\n required: state.isRequired && validationBehavior === 'native',\n checked,\n value,\n onChange,\n 'aria-describedby': [\n props['aria-describedby'],\n state.isInvalid ? errorMessageId : null,\n descriptionId\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked,\n isPressed: isPressed || isLabelPressed\n };\n}\n"],"names":[],"version":3,"file":"useRadio.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/radio",
3
- "version": "3.12.0",
3
+ "version": "3.12.2",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -26,15 +26,15 @@
26
26
  "url": "https://github.com/adobe/react-spectrum"
27
27
  },
28
28
  "dependencies": {
29
- "@react-aria/focus": "^3.21.0",
30
- "@react-aria/form": "^3.1.0",
31
- "@react-aria/i18n": "^3.12.11",
32
- "@react-aria/interactions": "^3.25.4",
33
- "@react-aria/label": "^3.7.20",
34
- "@react-aria/utils": "^3.30.0",
35
- "@react-stately/radio": "^3.11.0",
36
- "@react-types/radio": "^3.9.0",
37
- "@react-types/shared": "^3.31.0",
29
+ "@react-aria/focus": "^3.21.2",
30
+ "@react-aria/form": "^3.1.2",
31
+ "@react-aria/i18n": "^3.12.13",
32
+ "@react-aria/interactions": "^3.25.6",
33
+ "@react-aria/label": "^3.7.22",
34
+ "@react-aria/utils": "^3.31.0",
35
+ "@react-stately/radio": "^3.11.2",
36
+ "@react-types/radio": "^3.9.2",
37
+ "@react-types/shared": "^3.32.1",
38
38
  "@swc/helpers": "^0.5.0"
39
39
  },
40
40
  "peerDependencies": {
@@ -44,5 +44,5 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "8b9348ff255e018b2dd9b27e2a45507cadfa1d35"
47
+ "gitHead": "0bda51183baa23306342af32a82012ea0fe0f2dc"
48
48
  }
package/src/useRadio.ts CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  import {AriaRadioProps} from '@react-types/radio';
14
14
  import {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';
15
- import {InputHTMLAttributes, LabelHTMLAttributes} from 'react';
15
+ import {InputHTMLAttributes, LabelHTMLAttributes, useMemo} from 'react';
16
16
  import {radioGroupData} from './utils';
17
17
  import {RadioGroupState} from '@react-stately/radio';
18
18
  import {RefObject} from '@react-types/shared';
@@ -116,7 +116,15 @@ export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: Ref
116
116
  useFormValidation({validationBehavior}, state, ref);
117
117
 
118
118
  return {
119
- labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}),
119
+ labelProps: mergeProps(
120
+ labelProps,
121
+ useMemo(() => ({
122
+ onClick: e => e.preventDefault(),
123
+
124
+ // Prevent label from being focused when mouse down on it.
125
+ // Note, this does not prevent the input from being focused in the `click` event.
126
+ onMouseDown: e => e.preventDefault()
127
+ }), [])),
120
128
  inputProps: mergeProps(domProps, {
121
129
  ...interactions,
122
130
  type: 'radio',