@react-aria/radio 3.11.4 → 3.12.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/types.d.ts.map +1 -1
- package/dist/useRadio.main.js +17 -4
- package/dist/useRadio.main.js.map +1 -1
- package/dist/useRadio.mjs +17 -4
- package/dist/useRadio.module.js +17 -4
- package/dist/useRadio.module.js.map +1 -1
- package/dist/useRadioGroup.main.js +4 -2
- package/dist/useRadioGroup.main.js.map +1 -1
- package/dist/useRadioGroup.mjs +5 -3
- package/dist/useRadioGroup.module.js +5 -3
- package/dist/useRadioGroup.module.js.map +1 -1
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.module.js.map +1 -1
- package/package.json +11 -11
- package/src/useRadio.ts +23 -4
- package/src/useRadioGroup.ts +7 -2
- package/src/utils.ts +2 -1
package/dist/types.d.ts.map
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/useRadio.main.js
CHANGED
|
@@ -24,7 +24,7 @@ $parcel$export(module.exports, "useRadio", () => $e184702b1b7f1863$export$37b096
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
|
|
27
|
-
let { value: value, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby } = props;
|
|
27
|
+
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
28
|
const isDisabled = props.isDisabled || state.isDisabled;
|
|
29
29
|
let hasChildren = children != null;
|
|
30
30
|
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
@@ -36,13 +36,25 @@ function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
36
36
|
};
|
|
37
37
|
// Handle press state for keyboard interactions and cases where labelProps is not used.
|
|
38
38
|
let { pressProps: pressProps, isPressed: isPressed } = (0, $gWC9A$reactariainteractions.usePress)({
|
|
39
|
+
onPressStart: onPressStart,
|
|
40
|
+
onPressEnd: onPressEnd,
|
|
41
|
+
onPressChange: onPressChange,
|
|
42
|
+
onPress: onPress,
|
|
43
|
+
onPressUp: onPressUp,
|
|
44
|
+
onClick: onClick,
|
|
39
45
|
isDisabled: isDisabled
|
|
40
46
|
});
|
|
41
47
|
// Handle press state on the label.
|
|
42
48
|
let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $gWC9A$reactariainteractions.usePress)({
|
|
49
|
+
onPressStart: onPressStart,
|
|
50
|
+
onPressEnd: onPressEnd,
|
|
51
|
+
onPressChange: onPressChange,
|
|
52
|
+
onPressUp: onPressUp,
|
|
53
|
+
onClick: onClick,
|
|
43
54
|
isDisabled: isDisabled,
|
|
44
|
-
onPress () {
|
|
55
|
+
onPress (e) {
|
|
45
56
|
var _ref_current;
|
|
57
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(e);
|
|
46
58
|
state.setSelectedValue(value);
|
|
47
59
|
(_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
|
|
48
60
|
}
|
|
@@ -59,8 +71,8 @@ function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
59
71
|
if (state.selectedValue === value) tabIndex = 0;
|
|
60
72
|
} else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
|
|
61
73
|
if (isDisabled) tabIndex = undefined;
|
|
62
|
-
let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $eeb149278aae5c67$exports.radioGroupData).get(state);
|
|
63
|
-
(0, $gWC9A$reactariautils.useFormReset)(ref, state.
|
|
74
|
+
let { name: name, form: form, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $eeb149278aae5c67$exports.radioGroupData).get(state);
|
|
75
|
+
(0, $gWC9A$reactariautils.useFormReset)(ref, state.defaultSelectedValue, state.setSelectedValue);
|
|
64
76
|
(0, $gWC9A$reactariaform.useFormValidation)({
|
|
65
77
|
validationBehavior: validationBehavior
|
|
66
78
|
}, state, ref);
|
|
@@ -72,6 +84,7 @@ function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
72
84
|
...interactions,
|
|
73
85
|
type: 'radio',
|
|
74
86
|
name: name,
|
|
87
|
+
form: form,
|
|
75
88
|
tabIndex: tabIndex,
|
|
76
89
|
disabled: isDisabled,
|
|
77
90
|
required: state.isRequired && validationBehavior === 'native',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA+BM,SA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,MAAM,mBAAmB,CAAC;IAC3C,IAAI;IACJ,IAAI,eAAe,CAAA,GAAA,gCAAS,EAAE,YAAY;IAC1C,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,WAA+B;IACnC,IAAI,MAAM,aAAa,IAAI,MACzB;QAAA,IAAI,MAAM,aAAa,KAAK,OAC1B,WAAW;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,wCAAa,EAAE,GAAG,CAAC;IACzF,CAAA,GAAA,kCAAW,EAAE,KAAK,MAAM,oBAAoB,EAAE,MAAM,gBAAgB;IACpE,CAAA,GAAA,sCAAgB,EAAE;4BAAC;IAAkB,GAAG,OAAO;IAE/C,OAAO;QACL,YAAY,CAAA,GAAA,gCAAS,EAAE,YAAY;YAAC,SAAS,CAAA,IAAK,EAAE,cAAc;QAAE;QACpE,YAAY,CAAA,GAAA,gCAAS,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.main.js.map"}
|
package/dist/useRadio.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import {useFormValidation as $5jJ3f$useFormValidation} from "@react-aria/form";
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
21
|
-
let { value: value, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby } = props;
|
|
21
|
+
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
22
|
const isDisabled = props.isDisabled || state.isDisabled;
|
|
23
23
|
let hasChildren = children != null;
|
|
24
24
|
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
@@ -30,13 +30,25 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
30
30
|
};
|
|
31
31
|
// Handle press state for keyboard interactions and cases where labelProps is not used.
|
|
32
32
|
let { pressProps: pressProps, isPressed: isPressed } = (0, $5jJ3f$usePress)({
|
|
33
|
+
onPressStart: onPressStart,
|
|
34
|
+
onPressEnd: onPressEnd,
|
|
35
|
+
onPressChange: onPressChange,
|
|
36
|
+
onPress: onPress,
|
|
37
|
+
onPressUp: onPressUp,
|
|
38
|
+
onClick: onClick,
|
|
33
39
|
isDisabled: isDisabled
|
|
34
40
|
});
|
|
35
41
|
// Handle press state on the label.
|
|
36
42
|
let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $5jJ3f$usePress)({
|
|
43
|
+
onPressStart: onPressStart,
|
|
44
|
+
onPressEnd: onPressEnd,
|
|
45
|
+
onPressChange: onPressChange,
|
|
46
|
+
onPressUp: onPressUp,
|
|
47
|
+
onClick: onClick,
|
|
37
48
|
isDisabled: isDisabled,
|
|
38
|
-
onPress () {
|
|
49
|
+
onPress (e) {
|
|
39
50
|
var _ref_current;
|
|
51
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(e);
|
|
40
52
|
state.setSelectedValue(value);
|
|
41
53
|
(_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
|
|
42
54
|
}
|
|
@@ -53,8 +65,8 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
53
65
|
if (state.selectedValue === value) tabIndex = 0;
|
|
54
66
|
} else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
|
|
55
67
|
if (isDisabled) tabIndex = undefined;
|
|
56
|
-
let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $884aeceb3d67f00f$export$37b65e5b5444d35c).get(state);
|
|
57
|
-
(0, $5jJ3f$useFormReset)(ref, state.
|
|
68
|
+
let { name: name, form: form, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $884aeceb3d67f00f$export$37b65e5b5444d35c).get(state);
|
|
69
|
+
(0, $5jJ3f$useFormReset)(ref, state.defaultSelectedValue, state.setSelectedValue);
|
|
58
70
|
(0, $5jJ3f$useFormValidation)({
|
|
59
71
|
validationBehavior: validationBehavior
|
|
60
72
|
}, state, ref);
|
|
@@ -66,6 +78,7 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
66
78
|
...interactions,
|
|
67
79
|
type: 'radio',
|
|
68
80
|
name: name,
|
|
81
|
+
form: form,
|
|
69
82
|
tabIndex: tabIndex,
|
|
70
83
|
disabled: isDisabled,
|
|
71
84
|
required: state.isRequired && validationBehavior === 'native',
|
package/dist/useRadio.module.js
CHANGED
|
@@ -18,7 +18,7 @@ import {useFormValidation as $5jJ3f$useFormValidation} from "@react-aria/form";
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
21
|
-
let { value: value, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby } = props;
|
|
21
|
+
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
22
|
const isDisabled = props.isDisabled || state.isDisabled;
|
|
23
23
|
let hasChildren = children != null;
|
|
24
24
|
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
@@ -30,13 +30,25 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
30
30
|
};
|
|
31
31
|
// Handle press state for keyboard interactions and cases where labelProps is not used.
|
|
32
32
|
let { pressProps: pressProps, isPressed: isPressed } = (0, $5jJ3f$usePress)({
|
|
33
|
+
onPressStart: onPressStart,
|
|
34
|
+
onPressEnd: onPressEnd,
|
|
35
|
+
onPressChange: onPressChange,
|
|
36
|
+
onPress: onPress,
|
|
37
|
+
onPressUp: onPressUp,
|
|
38
|
+
onClick: onClick,
|
|
33
39
|
isDisabled: isDisabled
|
|
34
40
|
});
|
|
35
41
|
// Handle press state on the label.
|
|
36
42
|
let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $5jJ3f$usePress)({
|
|
43
|
+
onPressStart: onPressStart,
|
|
44
|
+
onPressEnd: onPressEnd,
|
|
45
|
+
onPressChange: onPressChange,
|
|
46
|
+
onPressUp: onPressUp,
|
|
47
|
+
onClick: onClick,
|
|
37
48
|
isDisabled: isDisabled,
|
|
38
|
-
onPress () {
|
|
49
|
+
onPress (e) {
|
|
39
50
|
var _ref_current;
|
|
51
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(e);
|
|
40
52
|
state.setSelectedValue(value);
|
|
41
53
|
(_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
|
|
42
54
|
}
|
|
@@ -53,8 +65,8 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
53
65
|
if (state.selectedValue === value) tabIndex = 0;
|
|
54
66
|
} else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
|
|
55
67
|
if (isDisabled) tabIndex = undefined;
|
|
56
|
-
let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $884aeceb3d67f00f$export$37b65e5b5444d35c).get(state);
|
|
57
|
-
(0, $5jJ3f$useFormReset)(ref, state.
|
|
68
|
+
let { name: name, form: form, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $884aeceb3d67f00f$export$37b65e5b5444d35c).get(state);
|
|
69
|
+
(0, $5jJ3f$useFormReset)(ref, state.defaultSelectedValue, state.setSelectedValue);
|
|
58
70
|
(0, $5jJ3f$useFormValidation)({
|
|
59
71
|
validationBehavior: validationBehavior
|
|
60
72
|
}, state, ref);
|
|
@@ -66,6 +78,7 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
66
78
|
...interactions,
|
|
67
79
|
type: 'radio',
|
|
68
80
|
name: name,
|
|
81
|
+
form: form,
|
|
69
82
|
tabIndex: tabIndex,
|
|
70
83
|
disabled: isDisabled,
|
|
71
84
|
required: state.isRequired && validationBehavior === 'native',
|
|
@@ -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,
|
|
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,IAA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,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"}
|
|
@@ -28,7 +28,7 @@ $parcel$export(module.exports, "useRadioGroup", () => $dfcade00a56a6317$export$6
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
function $dfcade00a56a6317$export$62b9571f283ff5c2(props, state) {
|
|
31
|
-
let { name: name, isReadOnly: isReadOnly, isRequired: isRequired, isDisabled: isDisabled, orientation: orientation = 'vertical', validationBehavior: validationBehavior = 'aria' } = props;
|
|
31
|
+
let { name: name, form: form, isReadOnly: isReadOnly, isRequired: isRequired, isDisabled: isDisabled, orientation: orientation = 'vertical', validationBehavior: validationBehavior = 'aria' } = props;
|
|
32
32
|
let { direction: direction } = (0, $bNSfM$reactariai18n.useLocale)();
|
|
33
33
|
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
34
34
|
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $bNSfM$reactarialabel.useField)({
|
|
@@ -76,7 +76,8 @@ function $dfcade00a56a6317$export$62b9571f283ff5c2(props, state) {
|
|
|
76
76
|
}
|
|
77
77
|
e.preventDefault();
|
|
78
78
|
let walker = (0, $bNSfM$reactariafocus.getFocusableTreeWalker)(e.currentTarget, {
|
|
79
|
-
from: e.target
|
|
79
|
+
from: e.target,
|
|
80
|
+
accept: (node)=>node instanceof (0, $bNSfM$reactariautils.getOwnerWindow)(node).HTMLInputElement && node.type === 'radio'
|
|
80
81
|
});
|
|
81
82
|
let nextElem;
|
|
82
83
|
if (nextDir === 'next') {
|
|
@@ -101,6 +102,7 @@ function $dfcade00a56a6317$export$62b9571f283ff5c2(props, state) {
|
|
|
101
102
|
let groupName = (0, $bNSfM$reactariautils.useId)(name);
|
|
102
103
|
(0, $eeb149278aae5c67$exports.radioGroupData).set(state, {
|
|
103
104
|
name: groupName,
|
|
105
|
+
form: form,
|
|
104
106
|
descriptionId: descriptionProps.id,
|
|
105
107
|
errorMessageId: errorMessageProps.id,
|
|
106
108
|
validationBehavior: validationBehavior
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA6BM,SAAS,0CAAc,KAA0B,EAAE,KAAsB;IAC9E,IAAI,QACF,IAAI,cACJ,UAAU,cACV,UAAU,cACV,UAAU,eACV,cAAc,gCACd,qBAAqB,QACtB,GAAG;IACJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAE1B,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,MAAM,iBAAiB;IAC9E,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,CAAA,GAAA,8BAAO,EAAE;QAC3E,GAAG,KAAK;QACR,iDAAiD;QACjD,6CAA6C;QAC7C,kBAAkB;QAClB,WAAW,MAAM,SAAS;QAC1B,cAAc,MAAM,YAAY,IAAI;IACtC;IAEA,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,yEAAyE;IACzE,wEAAwE;IACxE,8CAA8C;IAC9C,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,2CAAa,EAAE;QACtC,cAAa,CAAC;gBACZ;aAAA,gBAAA,MAAM,MAAM,cAAZ,oCAAA,mBAAA,OAAe;YACf,IAAI,CAAC,MAAM,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AE;4BACpC;IACF;IAEA,OAAO;QACL,iBAAiB,CAAA,GAAA,gCAAS,EAAE,UAAU;YACpC,iDAAiD;YACjD,MAAM;uBACN;YACA,gBAAgB,MAAM,SAAS,IAAI;YACnC,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;mBACA;0BACA;2BACA;IACF;AACF","sources":["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 */\n\nimport {AriaRadioGroupProps} from '@react-types/radio';\nimport {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, getOwnerWindow, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupData} 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 extends ValidationResult {\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 form,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical',\n validationBehavior = 'aria'\n } = props;\n let {direction} = useLocale();\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\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 isInvalid: state.isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\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(e) {\n props.onBlur?.(e);\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n },\n onFocusWithin: props.onFocus,\n onFocusWithinChange: props.onFocusChange\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, {\n from: e.target,\n accept: (node) => node instanceof getOwnerWindow(node).HTMLInputElement && node.type === 'radio'\n });\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 radioGroupData.set(state, {\n name: groupName,\n form,\n descriptionId: descriptionProps.id,\n errorMessageId: errorMessageProps.id,\n validationBehavior\n });\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': state.isInvalid || 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 isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useRadioGroup.main.js.map"}
|
package/dist/useRadioGroup.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {radioGroupData as $884aeceb3d67f00f$export$37b65e5b5444d35c} from "./utils.mjs";
|
|
2
|
-
import {filterDOMProps as $czmJy$filterDOMProps, useId as $czmJy$useId, mergeProps as $czmJy$mergeProps} from "@react-aria/utils";
|
|
2
|
+
import {filterDOMProps as $czmJy$filterDOMProps, getOwnerWindow as $czmJy$getOwnerWindow, useId as $czmJy$useId, mergeProps as $czmJy$mergeProps} from "@react-aria/utils";
|
|
3
3
|
import {getFocusableTreeWalker as $czmJy$getFocusableTreeWalker} from "@react-aria/focus";
|
|
4
4
|
import {useField as $czmJy$useField} from "@react-aria/label";
|
|
5
5
|
import {useFocusWithin as $czmJy$useFocusWithin} from "@react-aria/interactions";
|
|
@@ -22,7 +22,7 @@ import {useLocale as $czmJy$useLocale} from "@react-aria/i18n";
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
25
|
-
let { name: name, isReadOnly: isReadOnly, isRequired: isRequired, isDisabled: isDisabled, orientation: orientation = 'vertical', validationBehavior: validationBehavior = 'aria' } = props;
|
|
25
|
+
let { name: name, form: form, isReadOnly: isReadOnly, isRequired: isRequired, isDisabled: isDisabled, orientation: orientation = 'vertical', validationBehavior: validationBehavior = 'aria' } = props;
|
|
26
26
|
let { direction: direction } = (0, $czmJy$useLocale)();
|
|
27
27
|
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
28
28
|
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $czmJy$useField)({
|
|
@@ -70,7 +70,8 @@ function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
|
70
70
|
}
|
|
71
71
|
e.preventDefault();
|
|
72
72
|
let walker = (0, $czmJy$getFocusableTreeWalker)(e.currentTarget, {
|
|
73
|
-
from: e.target
|
|
73
|
+
from: e.target,
|
|
74
|
+
accept: (node)=>node instanceof (0, $czmJy$getOwnerWindow)(node).HTMLInputElement && node.type === 'radio'
|
|
74
75
|
});
|
|
75
76
|
let nextElem;
|
|
76
77
|
if (nextDir === 'next') {
|
|
@@ -95,6 +96,7 @@ function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
|
95
96
|
let groupName = (0, $czmJy$useId)(name);
|
|
96
97
|
(0, $884aeceb3d67f00f$export$37b65e5b5444d35c).set(state, {
|
|
97
98
|
name: groupName,
|
|
99
|
+
form: form,
|
|
98
100
|
descriptionId: descriptionProps.id,
|
|
99
101
|
errorMessageId: errorMessageProps.id,
|
|
100
102
|
validationBehavior: validationBehavior
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {radioGroupData as $884aeceb3d67f00f$export$37b65e5b5444d35c} from "./utils.module.js";
|
|
2
|
-
import {filterDOMProps as $czmJy$filterDOMProps, useId as $czmJy$useId, mergeProps as $czmJy$mergeProps} from "@react-aria/utils";
|
|
2
|
+
import {filterDOMProps as $czmJy$filterDOMProps, getOwnerWindow as $czmJy$getOwnerWindow, useId as $czmJy$useId, mergeProps as $czmJy$mergeProps} from "@react-aria/utils";
|
|
3
3
|
import {getFocusableTreeWalker as $czmJy$getFocusableTreeWalker} from "@react-aria/focus";
|
|
4
4
|
import {useField as $czmJy$useField} from "@react-aria/label";
|
|
5
5
|
import {useFocusWithin as $czmJy$useFocusWithin} from "@react-aria/interactions";
|
|
@@ -22,7 +22,7 @@ import {useLocale as $czmJy$useLocale} from "@react-aria/i18n";
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
25
|
-
let { name: name, isReadOnly: isReadOnly, isRequired: isRequired, isDisabled: isDisabled, orientation: orientation = 'vertical', validationBehavior: validationBehavior = 'aria' } = props;
|
|
25
|
+
let { name: name, form: form, isReadOnly: isReadOnly, isRequired: isRequired, isDisabled: isDisabled, orientation: orientation = 'vertical', validationBehavior: validationBehavior = 'aria' } = props;
|
|
26
26
|
let { direction: direction } = (0, $czmJy$useLocale)();
|
|
27
27
|
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
28
28
|
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $czmJy$useField)({
|
|
@@ -70,7 +70,8 @@ function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
|
70
70
|
}
|
|
71
71
|
e.preventDefault();
|
|
72
72
|
let walker = (0, $czmJy$getFocusableTreeWalker)(e.currentTarget, {
|
|
73
|
-
from: e.target
|
|
73
|
+
from: e.target,
|
|
74
|
+
accept: (node)=>node instanceof (0, $czmJy$getOwnerWindow)(node).HTMLInputElement && node.type === 'radio'
|
|
74
75
|
});
|
|
75
76
|
let nextElem;
|
|
76
77
|
if (nextDir === 'next') {
|
|
@@ -95,6 +96,7 @@ function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
|
95
96
|
let groupName = (0, $czmJy$useId)(name);
|
|
96
97
|
(0, $884aeceb3d67f00f$export$37b65e5b5444d35c).set(state, {
|
|
97
98
|
name: groupName,
|
|
99
|
+
form: form,
|
|
98
100
|
descriptionId: descriptionProps.id,
|
|
99
101
|
errorMessageId: errorMessageProps.id,
|
|
100
102
|
validationBehavior: validationBehavior
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA6BM,SAAS,0CAAc,KAA0B,EAAE,KAAsB;IAC9E,IAAI,QACF,IAAI,cACJ,UAAU,cACV,UAAU,cACV,UAAU,eACV,cAAc,gCACd,qBAAqB,QACtB,GAAG;IACJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAE1B,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,MAAM,iBAAiB;IAC9E,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC3E,GAAG,KAAK;QACR,iDAAiD;QACjD,6CAA6C;QAC7C,kBAAkB;QAClB,WAAW,MAAM,SAAS;QAC1B,cAAc,MAAM,YAAY,IAAI;IACtC;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,yEAAyE;IACzE,wEAAwE;IACxE,8CAA8C;IAC9C,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QACtC,cAAa,CAAC;gBACZ;aAAA,gBAAA,MAAM,MAAM,cAAZ,oCAAA,mBAAA,OAAe;YACf,IAAI,CAAC,MAAM,aAAa,EACtB,MAAM,mBAAmB,CAAC;QAE9B;QACA,eAAe,MAAM,OAAO;QAC5B,qBAAqB,MAAM,aAAa;IAC1C;IAEA,IAAI,Y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AM,SAAS,IAAI;YACnC,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;mBACA;0BACA;2BACA;IACF;AACF","sources":["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 */\n\nimport {AriaRadioGroupProps} from '@react-types/radio';\nimport {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, getOwnerWindow, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupData} 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 extends ValidationResult {\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 form,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical',\n validationBehavior = 'aria'\n } = props;\n let {direction} = useLocale();\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\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 isInvalid: state.isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\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(e) {\n props.onBlur?.(e);\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n },\n onFocusWithin: props.onFocus,\n onFocusWithinChange: props.onFocusChange\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, {\n from: e.target,\n accept: (node) => node instanceof getOwnerWindow(node).HTMLInputElement && node.type === 'radio'\n });\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 radioGroupData.set(state, {\n name: groupName,\n form,\n descriptionId: descriptionProps.id,\n errorMessageId: errorMessageProps.id,\n validationBehavior\n });\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': state.isInvalid || 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 isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useRadioGroup.module.js.map"}
|
package/dist/utils.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAYM,MAAM,4CAA2D,IAAI","sources":["packages/@react-aria/radio/src/utils.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 {RadioGroupState} from '@react-stately/radio';\n\ninterface RadioGroupData {\n name: string,\n form: string | undefined,\n descriptionId: string | undefined,\n errorMessageId: string | undefined,\n validationBehavior: 'aria' | 'native'\n}\n\nexport const radioGroupData: WeakMap<RadioGroupState, RadioGroupData> = new WeakMap<RadioGroupState, RadioGroupData>();\n"],"names":[],"version":3,"file":"utils.main.js.map"}
|
package/dist/utils.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAYM,MAAM,4CAA2D,IAAI","sources":["packages/@react-aria/radio/src/utils.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 {RadioGroupState} from '@react-stately/radio';\n\ninterface RadioGroupData {\n name: string,\n form: string | undefined,\n descriptionId: string | undefined,\n errorMessageId: string | undefined,\n validationBehavior: 'aria' | 'native'\n}\n\nexport const radioGroupData: WeakMap<RadioGroupState, RadioGroupData> = new WeakMap<RadioGroupState, RadioGroupData>();\n"],"names":[],"version":3,"file":"utils.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/radio",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.0",
|
|
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.
|
|
30
|
-
"@react-aria/form": "^3.0
|
|
31
|
-
"@react-aria/i18n": "^3.12.
|
|
32
|
-
"@react-aria/interactions": "^3.25.
|
|
33
|
-
"@react-aria/label": "^3.7.
|
|
34
|
-
"@react-aria/utils": "^3.
|
|
35
|
-
"@react-stately/radio": "^3.
|
|
36
|
-
"@react-types/radio": "^3.
|
|
37
|
-
"@react-types/shared": "^3.
|
|
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",
|
|
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": "
|
|
47
|
+
"gitHead": "8b9348ff255e018b2dd9b27e2a45507cadfa1d35"
|
|
48
48
|
}
|
package/src/useRadio.ts
CHANGED
|
@@ -44,7 +44,13 @@ export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: Ref
|
|
|
44
44
|
value,
|
|
45
45
|
children,
|
|
46
46
|
'aria-label': ariaLabel,
|
|
47
|
-
'aria-labelledby': ariaLabelledby
|
|
47
|
+
'aria-labelledby': ariaLabelledby,
|
|
48
|
+
onPressStart,
|
|
49
|
+
onPressEnd,
|
|
50
|
+
onPressChange,
|
|
51
|
+
onPress,
|
|
52
|
+
onPressUp,
|
|
53
|
+
onClick
|
|
48
54
|
} = props;
|
|
49
55
|
|
|
50
56
|
const isDisabled = props.isDisabled || state.isDisabled;
|
|
@@ -64,13 +70,25 @@ export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: Ref
|
|
|
64
70
|
|
|
65
71
|
// Handle press state for keyboard interactions and cases where labelProps is not used.
|
|
66
72
|
let {pressProps, isPressed} = usePress({
|
|
73
|
+
onPressStart,
|
|
74
|
+
onPressEnd,
|
|
75
|
+
onPressChange,
|
|
76
|
+
onPress,
|
|
77
|
+
onPressUp,
|
|
78
|
+
onClick,
|
|
67
79
|
isDisabled
|
|
68
80
|
});
|
|
69
81
|
|
|
70
82
|
// Handle press state on the label.
|
|
71
83
|
let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({
|
|
84
|
+
onPressStart,
|
|
85
|
+
onPressEnd,
|
|
86
|
+
onPressChange,
|
|
87
|
+
onPressUp,
|
|
88
|
+
onClick,
|
|
72
89
|
isDisabled,
|
|
73
|
-
onPress() {
|
|
90
|
+
onPress(e) {
|
|
91
|
+
onPress?.(e);
|
|
74
92
|
state.setSelectedValue(value);
|
|
75
93
|
ref.current?.focus();
|
|
76
94
|
}
|
|
@@ -93,8 +111,8 @@ export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: Ref
|
|
|
93
111
|
tabIndex = undefined;
|
|
94
112
|
}
|
|
95
113
|
|
|
96
|
-
let {name, descriptionId, errorMessageId, validationBehavior} = radioGroupData.get(state)!;
|
|
97
|
-
useFormReset(ref, state.
|
|
114
|
+
let {name, form, descriptionId, errorMessageId, validationBehavior} = radioGroupData.get(state)!;
|
|
115
|
+
useFormReset(ref, state.defaultSelectedValue, state.setSelectedValue);
|
|
98
116
|
useFormValidation({validationBehavior}, state, ref);
|
|
99
117
|
|
|
100
118
|
return {
|
|
@@ -103,6 +121,7 @@ export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: Ref
|
|
|
103
121
|
...interactions,
|
|
104
122
|
type: 'radio',
|
|
105
123
|
name,
|
|
124
|
+
form,
|
|
106
125
|
tabIndex,
|
|
107
126
|
disabled: isDisabled,
|
|
108
127
|
required: state.isRequired && validationBehavior === 'native',
|
package/src/useRadioGroup.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import {AriaRadioGroupProps} from '@react-types/radio';
|
|
14
14
|
import {DOMAttributes, ValidationResult} from '@react-types/shared';
|
|
15
|
-
import {filterDOMProps, mergeProps, useId} from '@react-aria/utils';
|
|
15
|
+
import {filterDOMProps, getOwnerWindow, mergeProps, useId} from '@react-aria/utils';
|
|
16
16
|
import {getFocusableTreeWalker} from '@react-aria/focus';
|
|
17
17
|
import {radioGroupData} from './utils';
|
|
18
18
|
import {RadioGroupState} from '@react-stately/radio';
|
|
@@ -40,6 +40,7 @@ export interface RadioGroupAria extends ValidationResult {
|
|
|
40
40
|
export function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria {
|
|
41
41
|
let {
|
|
42
42
|
name,
|
|
43
|
+
form,
|
|
43
44
|
isReadOnly,
|
|
44
45
|
isRequired,
|
|
45
46
|
isDisabled,
|
|
@@ -101,7 +102,10 @@ export function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState
|
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
104
|
e.preventDefault();
|
|
104
|
-
let walker = getFocusableTreeWalker(e.currentTarget, {
|
|
105
|
+
let walker = getFocusableTreeWalker(e.currentTarget, {
|
|
106
|
+
from: e.target,
|
|
107
|
+
accept: (node) => node instanceof getOwnerWindow(node).HTMLInputElement && node.type === 'radio'
|
|
108
|
+
});
|
|
105
109
|
let nextElem;
|
|
106
110
|
if (nextDir === 'next') {
|
|
107
111
|
nextElem = walker.nextNode();
|
|
@@ -126,6 +130,7 @@ export function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState
|
|
|
126
130
|
let groupName = useId(name);
|
|
127
131
|
radioGroupData.set(state, {
|
|
128
132
|
name: groupName,
|
|
133
|
+
form,
|
|
129
134
|
descriptionId: descriptionProps.id,
|
|
130
135
|
errorMessageId: errorMessageProps.id,
|
|
131
136
|
validationBehavior
|
package/src/utils.ts
CHANGED
|
@@ -14,9 +14,10 @@ import {RadioGroupState} from '@react-stately/radio';
|
|
|
14
14
|
|
|
15
15
|
interface RadioGroupData {
|
|
16
16
|
name: string,
|
|
17
|
+
form: string | undefined,
|
|
17
18
|
descriptionId: string | undefined,
|
|
18
19
|
errorMessageId: string | undefined,
|
|
19
20
|
validationBehavior: 'aria' | 'native'
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
export const radioGroupData = new WeakMap<RadioGroupState, RadioGroupData>();
|
|
23
|
+
export const radioGroupData: WeakMap<RadioGroupState, RadioGroupData> = new WeakMap<RadioGroupState, RadioGroupData>();
|