@react-aria/radio 3.10.1 → 3.10.3

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,21 +1,7 @@
1
- import {mergeProps as $4vDl6$mergeProps, filterDOMProps as $4vDl6$filterDOMProps, useFormReset as $4vDl6$useFormReset, useId as $4vDl6$useId} from "@react-aria/utils";
2
- import {useFocusable as $4vDl6$useFocusable, getFocusableTreeWalker as $4vDl6$getFocusableTreeWalker} from "@react-aria/focus";
3
- import {useFormValidation as $4vDl6$useFormValidation} from "@react-aria/form";
4
- import {usePress as $4vDl6$usePress, useFocusWithin as $4vDl6$useFocusWithin} from "@react-aria/interactions";
5
- import {useField as $4vDl6$useField} from "@react-aria/label";
6
- import {useLocale as $4vDl6$useLocale} from "@react-aria/i18n";
1
+ import {useRadio as $0d5c49892c1215da$export$37b0961d2f4751e2} from "./useRadio.mjs";
2
+ import {useRadioGroup as $430f30ed08ec25fa$export$62b9571f283ff5c2} from "./useRadioGroup.mjs";
7
3
 
8
4
  /*
9
- * Copyright 2020 Adobe. All rights reserved.
10
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License. You may obtain a copy
12
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software distributed under
15
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
- * OF ANY KIND, either express or implied. See the License for the specific language
17
- * governing permissions and limitations under the License.
18
- */ /*
19
5
  * Copyright 2020 Adobe. All rights reserved.
20
6
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
21
7
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -26,204 +12,6 @@ import {useLocale as $4vDl6$useLocale} from "@react-aria/i18n";
26
12
  * OF ANY KIND, either express or implied. See the License for the specific language
27
13
  * governing permissions and limitations under the License.
28
14
  */
29
- /*
30
- * Copyright 2020 Adobe. All rights reserved.
31
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
32
- * you may not use this file except in compliance with the License. You may obtain a copy
33
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
34
- *
35
- * Unless required by applicable law or agreed to in writing, software distributed under
36
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
37
- * OF ANY KIND, either express or implied. See the License for the specific language
38
- * governing permissions and limitations under the License.
39
- */ const $884aeceb3d67f00f$export$37b65e5b5444d35c = new WeakMap();
40
-
41
-
42
-
43
-
44
-
45
- function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
46
- let { value: value, children: children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby } = props;
47
- const isDisabled = props.isDisabled || state.isDisabled;
48
- let hasChildren = children != null;
49
- let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
50
- if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
51
- let checked = state.selectedValue === value;
52
- let onChange = (e)=>{
53
- e.stopPropagation();
54
- state.setSelectedValue(value);
55
- };
56
- let { pressProps: pressProps, isPressed: isPressed } = (0, $4vDl6$usePress)({
57
- isDisabled: isDisabled
58
- });
59
- // iOS does not toggle radios if you drag off and back onto the label, so handle it ourselves.
60
- let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $4vDl6$usePress)({
61
- isDisabled: isDisabled,
62
- onPress () {
63
- state.setSelectedValue(value);
64
- }
65
- });
66
- let { focusableProps: focusableProps } = (0, $4vDl6$useFocusable)((0, $4vDl6$mergeProps)(props, {
67
- onFocus: ()=>state.setLastFocusedValue(value)
68
- }), ref);
69
- let interactions = (0, $4vDl6$mergeProps)(pressProps, focusableProps);
70
- let domProps = (0, $4vDl6$filterDOMProps)(props, {
71
- labelable: true
72
- });
73
- let tabIndex = -1;
74
- if (state.selectedValue != null) {
75
- if (state.selectedValue === value) tabIndex = 0;
76
- } else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
77
- if (isDisabled) tabIndex = undefined;
78
- let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $884aeceb3d67f00f$export$37b65e5b5444d35c).get(state);
79
- (0, $4vDl6$useFormReset)(ref, state.selectedValue, state.setSelectedValue);
80
- (0, $4vDl6$useFormValidation)({
81
- validationBehavior: validationBehavior
82
- }, state, ref);
83
- return {
84
- labelProps: (0, $4vDl6$mergeProps)(labelProps, {
85
- onClick: (e)=>e.preventDefault()
86
- }),
87
- inputProps: (0, $4vDl6$mergeProps)(domProps, {
88
- ...interactions,
89
- type: "radio",
90
- name: name,
91
- tabIndex: tabIndex,
92
- disabled: isDisabled,
93
- required: state.isRequired && validationBehavior === "native",
94
- checked: checked,
95
- value: value,
96
- onChange: onChange,
97
- "aria-describedby": [
98
- props["aria-describedby"],
99
- state.isInvalid ? errorMessageId : null,
100
- descriptionId
101
- ].filter(Boolean).join(" ") || undefined
102
- }),
103
- isDisabled: isDisabled,
104
- isSelected: checked,
105
- isPressed: isPressed || isLabelPressed
106
- };
107
- }
108
-
109
-
110
- /*
111
- * Copyright 2020 Adobe. All rights reserved.
112
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
113
- * you may not use this file except in compliance with the License. You may obtain a copy
114
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
115
- *
116
- * Unless required by applicable law or agreed to in writing, software distributed under
117
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
118
- * OF ANY KIND, either express or implied. See the License for the specific language
119
- * governing permissions and limitations under the License.
120
- */
121
-
122
-
123
-
124
-
125
-
126
- function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
127
- let { name: name, isReadOnly: isReadOnly, isRequired: isRequired, isDisabled: isDisabled, orientation: orientation = "vertical", validationBehavior: validationBehavior = "aria" } = props;
128
- let { direction: direction } = (0, $4vDl6$useLocale)();
129
- let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
130
- let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $4vDl6$useField)({
131
- ...props,
132
- // Radio group is not an HTML input element so it
133
- // shouldn't be labeled by a <label> element.
134
- labelElementType: "span",
135
- isInvalid: state.isInvalid,
136
- errorMessage: props.errorMessage || validationErrors
137
- });
138
- let domProps = (0, $4vDl6$filterDOMProps)(props, {
139
- labelable: true
140
- });
141
- // When the radio group loses focus, reset the focusable radio to null if
142
- // there is no selection. This allows tabbing into the group from either
143
- // direction to go to the first or last radio.
144
- let { focusWithinProps: focusWithinProps } = (0, $4vDl6$useFocusWithin)({
145
- onBlurWithin (e) {
146
- var _props_onBlur;
147
- (_props_onBlur = props.onBlur) === null || _props_onBlur === void 0 ? void 0 : _props_onBlur.call(props, e);
148
- if (!state.selectedValue) state.setLastFocusedValue(null);
149
- },
150
- onFocusWithin: props.onFocus,
151
- onFocusWithinChange: props.onFocusChange
152
- });
153
- let onKeyDown = (e)=>{
154
- let nextDir;
155
- switch(e.key){
156
- case "ArrowRight":
157
- if (direction === "rtl" && orientation !== "vertical") nextDir = "prev";
158
- else nextDir = "next";
159
- break;
160
- case "ArrowLeft":
161
- if (direction === "rtl" && orientation !== "vertical") nextDir = "next";
162
- else nextDir = "prev";
163
- break;
164
- case "ArrowDown":
165
- nextDir = "next";
166
- break;
167
- case "ArrowUp":
168
- nextDir = "prev";
169
- break;
170
- default:
171
- return;
172
- }
173
- e.preventDefault();
174
- let walker = (0, $4vDl6$getFocusableTreeWalker)(e.currentTarget, {
175
- from: e.target
176
- });
177
- let nextElem;
178
- if (nextDir === "next") {
179
- nextElem = walker.nextNode();
180
- if (!nextElem) {
181
- walker.currentNode = e.currentTarget;
182
- nextElem = walker.firstChild();
183
- }
184
- } else {
185
- nextElem = walker.previousNode();
186
- if (!nextElem) {
187
- walker.currentNode = e.currentTarget;
188
- nextElem = walker.lastChild();
189
- }
190
- }
191
- if (nextElem) {
192
- // Call focus on nextElem so that keyboard navigation scrolls the radio into view
193
- nextElem.focus();
194
- state.setSelectedValue(nextElem.value);
195
- }
196
- };
197
- let groupName = (0, $4vDl6$useId)(name);
198
- (0, $884aeceb3d67f00f$export$37b65e5b5444d35c).set(state, {
199
- name: groupName,
200
- descriptionId: descriptionProps.id,
201
- errorMessageId: errorMessageProps.id,
202
- validationBehavior: validationBehavior
203
- });
204
- return {
205
- radioGroupProps: (0, $4vDl6$mergeProps)(domProps, {
206
- // https://www.w3.org/TR/wai-aria-1.2/#radiogroup
207
- role: "radiogroup",
208
- onKeyDown: onKeyDown,
209
- "aria-invalid": state.isInvalid || undefined,
210
- "aria-errormessage": props["aria-errormessage"],
211
- "aria-readonly": isReadOnly || undefined,
212
- "aria-required": isRequired || undefined,
213
- "aria-disabled": isDisabled || undefined,
214
- "aria-orientation": orientation,
215
- ...fieldProps,
216
- ...focusWithinProps
217
- }),
218
- labelProps: labelProps,
219
- descriptionProps: descriptionProps,
220
- errorMessageProps: errorMessageProps,
221
- isInvalid: isInvalid,
222
- validationErrors: validationErrors,
223
- validationDetails: validationDetails
224
- };
225
- }
226
-
227
15
 
228
16
 
229
17
 
package/dist/main.js CHANGED
@@ -1,28 +1,14 @@
1
- var $fMEGB$reactariautils = require("@react-aria/utils");
2
- var $fMEGB$reactariafocus = require("@react-aria/focus");
3
- var $fMEGB$reactariaform = require("@react-aria/form");
4
- var $fMEGB$reactariainteractions = require("@react-aria/interactions");
5
- var $fMEGB$reactarialabel = require("@react-aria/label");
6
- var $fMEGB$reactariai18n = require("@react-aria/i18n");
1
+ var $e184702b1b7f1863$exports = require("./useRadio.main.js");
2
+ var $dfcade00a56a6317$exports = require("./useRadioGroup.main.js");
7
3
 
8
4
 
9
5
  function $parcel$export(e, n, v, s) {
10
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
11
7
  }
12
8
 
13
- $parcel$export(module.exports, "useRadio", () => $e184702b1b7f1863$export$37b0961d2f4751e2);
14
- $parcel$export(module.exports, "useRadioGroup", () => $dfcade00a56a6317$export$62b9571f283ff5c2);
9
+ $parcel$export(module.exports, "useRadio", () => $e184702b1b7f1863$exports.useRadio);
10
+ $parcel$export(module.exports, "useRadioGroup", () => $dfcade00a56a6317$exports.useRadioGroup);
15
11
  /*
16
- * Copyright 2020 Adobe. All rights reserved.
17
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
- * you may not use this file except in compliance with the License. You may obtain a copy
19
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
- *
21
- * Unless required by applicable law or agreed to in writing, software distributed under
22
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
- * OF ANY KIND, either express or implied. See the License for the specific language
24
- * governing permissions and limitations under the License.
25
- */ /*
26
12
  * Copyright 2020 Adobe. All rights reserved.
27
13
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
28
14
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -33,204 +19,6 @@ $parcel$export(module.exports, "useRadioGroup", () => $dfcade00a56a6317$export$6
33
19
  * OF ANY KIND, either express or implied. See the License for the specific language
34
20
  * governing permissions and limitations under the License.
35
21
  */
36
- /*
37
- * Copyright 2020 Adobe. All rights reserved.
38
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
39
- * you may not use this file except in compliance with the License. You may obtain a copy
40
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
41
- *
42
- * Unless required by applicable law or agreed to in writing, software distributed under
43
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
44
- * OF ANY KIND, either express or implied. See the License for the specific language
45
- * governing permissions and limitations under the License.
46
- */ const $eeb149278aae5c67$export$37b65e5b5444d35c = new WeakMap();
47
-
48
-
49
-
50
-
51
-
52
- function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
53
- let { value: value, children: children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby } = props;
54
- const isDisabled = props.isDisabled || state.isDisabled;
55
- let hasChildren = children != null;
56
- let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
57
- if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
58
- let checked = state.selectedValue === value;
59
- let onChange = (e)=>{
60
- e.stopPropagation();
61
- state.setSelectedValue(value);
62
- };
63
- let { pressProps: pressProps, isPressed: isPressed } = (0, $fMEGB$reactariainteractions.usePress)({
64
- isDisabled: isDisabled
65
- });
66
- // iOS does not toggle radios if you drag off and back onto the label, so handle it ourselves.
67
- let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $fMEGB$reactariainteractions.usePress)({
68
- isDisabled: isDisabled,
69
- onPress () {
70
- state.setSelectedValue(value);
71
- }
72
- });
73
- let { focusableProps: focusableProps } = (0, $fMEGB$reactariafocus.useFocusable)((0, $fMEGB$reactariautils.mergeProps)(props, {
74
- onFocus: ()=>state.setLastFocusedValue(value)
75
- }), ref);
76
- let interactions = (0, $fMEGB$reactariautils.mergeProps)(pressProps, focusableProps);
77
- let domProps = (0, $fMEGB$reactariautils.filterDOMProps)(props, {
78
- labelable: true
79
- });
80
- let tabIndex = -1;
81
- if (state.selectedValue != null) {
82
- if (state.selectedValue === value) tabIndex = 0;
83
- } else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
84
- if (isDisabled) tabIndex = undefined;
85
- let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $eeb149278aae5c67$export$37b65e5b5444d35c).get(state);
86
- (0, $fMEGB$reactariautils.useFormReset)(ref, state.selectedValue, state.setSelectedValue);
87
- (0, $fMEGB$reactariaform.useFormValidation)({
88
- validationBehavior: validationBehavior
89
- }, state, ref);
90
- return {
91
- labelProps: (0, $fMEGB$reactariautils.mergeProps)(labelProps, {
92
- onClick: (e)=>e.preventDefault()
93
- }),
94
- inputProps: (0, $fMEGB$reactariautils.mergeProps)(domProps, {
95
- ...interactions,
96
- type: "radio",
97
- name: name,
98
- tabIndex: tabIndex,
99
- disabled: isDisabled,
100
- required: state.isRequired && validationBehavior === "native",
101
- checked: checked,
102
- value: value,
103
- onChange: onChange,
104
- "aria-describedby": [
105
- props["aria-describedby"],
106
- state.isInvalid ? errorMessageId : null,
107
- descriptionId
108
- ].filter(Boolean).join(" ") || undefined
109
- }),
110
- isDisabled: isDisabled,
111
- isSelected: checked,
112
- isPressed: isPressed || isLabelPressed
113
- };
114
- }
115
-
116
-
117
- /*
118
- * Copyright 2020 Adobe. All rights reserved.
119
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
120
- * you may not use this file except in compliance with the License. You may obtain a copy
121
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
122
- *
123
- * Unless required by applicable law or agreed to in writing, software distributed under
124
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
125
- * OF ANY KIND, either express or implied. See the License for the specific language
126
- * governing permissions and limitations under the License.
127
- */
128
-
129
-
130
-
131
-
132
-
133
- function $dfcade00a56a6317$export$62b9571f283ff5c2(props, state) {
134
- let { name: name, isReadOnly: isReadOnly, isRequired: isRequired, isDisabled: isDisabled, orientation: orientation = "vertical", validationBehavior: validationBehavior = "aria" } = props;
135
- let { direction: direction } = (0, $fMEGB$reactariai18n.useLocale)();
136
- let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
137
- let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $fMEGB$reactarialabel.useField)({
138
- ...props,
139
- // Radio group is not an HTML input element so it
140
- // shouldn't be labeled by a <label> element.
141
- labelElementType: "span",
142
- isInvalid: state.isInvalid,
143
- errorMessage: props.errorMessage || validationErrors
144
- });
145
- let domProps = (0, $fMEGB$reactariautils.filterDOMProps)(props, {
146
- labelable: true
147
- });
148
- // When the radio group loses focus, reset the focusable radio to null if
149
- // there is no selection. This allows tabbing into the group from either
150
- // direction to go to the first or last radio.
151
- let { focusWithinProps: focusWithinProps } = (0, $fMEGB$reactariainteractions.useFocusWithin)({
152
- onBlurWithin (e) {
153
- var _props_onBlur;
154
- (_props_onBlur = props.onBlur) === null || _props_onBlur === void 0 ? void 0 : _props_onBlur.call(props, e);
155
- if (!state.selectedValue) state.setLastFocusedValue(null);
156
- },
157
- onFocusWithin: props.onFocus,
158
- onFocusWithinChange: props.onFocusChange
159
- });
160
- let onKeyDown = (e)=>{
161
- let nextDir;
162
- switch(e.key){
163
- case "ArrowRight":
164
- if (direction === "rtl" && orientation !== "vertical") nextDir = "prev";
165
- else nextDir = "next";
166
- break;
167
- case "ArrowLeft":
168
- if (direction === "rtl" && orientation !== "vertical") nextDir = "next";
169
- else nextDir = "prev";
170
- break;
171
- case "ArrowDown":
172
- nextDir = "next";
173
- break;
174
- case "ArrowUp":
175
- nextDir = "prev";
176
- break;
177
- default:
178
- return;
179
- }
180
- e.preventDefault();
181
- let walker = (0, $fMEGB$reactariafocus.getFocusableTreeWalker)(e.currentTarget, {
182
- from: e.target
183
- });
184
- let nextElem;
185
- if (nextDir === "next") {
186
- nextElem = walker.nextNode();
187
- if (!nextElem) {
188
- walker.currentNode = e.currentTarget;
189
- nextElem = walker.firstChild();
190
- }
191
- } else {
192
- nextElem = walker.previousNode();
193
- if (!nextElem) {
194
- walker.currentNode = e.currentTarget;
195
- nextElem = walker.lastChild();
196
- }
197
- }
198
- if (nextElem) {
199
- // Call focus on nextElem so that keyboard navigation scrolls the radio into view
200
- nextElem.focus();
201
- state.setSelectedValue(nextElem.value);
202
- }
203
- };
204
- let groupName = (0, $fMEGB$reactariautils.useId)(name);
205
- (0, $eeb149278aae5c67$export$37b65e5b5444d35c).set(state, {
206
- name: groupName,
207
- descriptionId: descriptionProps.id,
208
- errorMessageId: errorMessageProps.id,
209
- validationBehavior: validationBehavior
210
- });
211
- return {
212
- radioGroupProps: (0, $fMEGB$reactariautils.mergeProps)(domProps, {
213
- // https://www.w3.org/TR/wai-aria-1.2/#radiogroup
214
- role: "radiogroup",
215
- onKeyDown: onKeyDown,
216
- "aria-invalid": state.isInvalid || undefined,
217
- "aria-errormessage": props["aria-errormessage"],
218
- "aria-readonly": isReadOnly || undefined,
219
- "aria-required": isRequired || undefined,
220
- "aria-disabled": isDisabled || undefined,
221
- "aria-orientation": orientation,
222
- ...fieldProps,
223
- ...focusWithinProps
224
- }),
225
- labelProps: labelProps,
226
- descriptionProps: descriptionProps,
227
- errorMessageProps: errorMessageProps,
228
- isInvalid: isInvalid,
229
- validationErrors: validationErrors,
230
- validationDetails: validationDetails
231
- };
232
- }
233
-
234
22
 
235
23
 
236
24
 
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAWM,MAAM,4CAAiB,IAAI;;;;;;ADoB3B,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAgC;IACtG,IAAI,SACF,KAAK,YACL,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,EAClC,GAAG;IAEJ,MAAM,aAAa,MAAM,UAAU,IAAI,MAAM,UAAU;IAEvD,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,IAAI,CAAC;IAGf,IAAI,UAAU,MAAM,aAAa,KAAK;IAEtC,IAAI,WAAW,CAAC;QACd,EAAE,eAAe;QACjB,MAAM,gBAAgB,CAAC;IACzB;IAEA,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;oBACrC;IACF;IAEA,8FAA8F;IAC9F,IAAI,EAAC,YAAY,UAAU,EAAE,WAAW,cAAc,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;oBACjE;QACA;YACE,MAAM,gBAAgB,CAAC;QACzB;IACF;IAEA,IAAI,k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,YAAY,QAAQ;YACtB,WAAW,OAAO,QAAQ;YAC1B,IAAI,CAAC,UAAU;gBACb,OAAO,WAAW,GAAG,EAAE,aAAa;gBACpC,WAAW,OAAO,UAAU;YAC9B;QACF,OAAO;YACL,WAAW,OAAO,YAAY;YAC9B,IAAI,CAAC,UAAU;gBACb,OAAO,WAAW,GAAG,EAAE,aAAa;gBACpC,WAAW,OAAO,SAAS;YAC7B;QACF;QACA,IAAI,UAAU;YACZ,iFAAiF;YACjF,SAAS,KAAK;YACd,MAAM,gBAAgB,CAAC,SAAS,KAAK;QACvC;IACF;IAEA,IAAI,YAAY,CAAA,GAAA,2BAAI,EAAE;IACtB,CAAA,GAAA,yCAAa,EAAE,GAAG,CAAC,OAAO;QACxB,MAAM;QACN,eAAe,iBAAiB,EAAE;QAClC,gBAAgB,kBAAkB,EAAE;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/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, LabelHTMLAttributes, RefObject} from 'react';\nimport {radioGroupData} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {useFormValidation} from '@react-aria/form';\nimport {usePress} from '@react-aria/interactions';\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>): 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 // iOS does not toggle radios if you drag off and back onto the label, so handle it ourselves.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n isDisabled,\n onPress() {\n state.setSelectedValue(value);\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, descriptionId, errorMessageId, validationBehavior} = radioGroupData.get(state)!;\n useFormReset(ref, state.selectedValue, 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 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","/*\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 descriptionId: string | undefined,\n errorMessageId: string | undefined,\n validationBehavior: 'aria' | 'native'\n}\n\nexport const radioGroupData = new WeakMap<RadioGroupState, RadioGroupData>();\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, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, 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 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, {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 radioGroupData.set(state, {\n name: groupName,\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":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/radio/src/index.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"],"names":[],"version":3,"file":"main.js.map"}