@react-aria/radio 3.4.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +197 -0
- package/dist/main.js +86 -46
- package/dist/main.js.map +1 -1
- package/dist/module.js +86 -46
- package/dist/module.js.map +1 -1
- package/package.json +16 -11
package/dist/import.mjs
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import {mergeProps as $4vDl6$mergeProps, filterDOMProps as $4vDl6$filterDOMProps, useId as $4vDl6$useId} from "@react-aria/utils";
|
|
2
|
+
import {useFocusable as $4vDl6$useFocusable, getFocusableTreeWalker as $4vDl6$getFocusableTreeWalker} from "@react-aria/focus";
|
|
3
|
+
import {usePress as $4vDl6$usePress, useFocusWithin as $4vDl6$useFocusWithin} from "@react-aria/interactions";
|
|
4
|
+
import {useField as $4vDl6$useField} from "@react-aria/label";
|
|
5
|
+
import {useLocale as $4vDl6$useLocale} from "@react-aria/i18n";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/ /*
|
|
18
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
/*
|
|
29
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
30
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
31
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
32
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
+
*
|
|
34
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
35
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
36
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
37
|
+
* governing permissions and limitations under the License.
|
|
38
|
+
*/ const $884aeceb3d67f00f$export$3b7b268d09480394 = new WeakMap();
|
|
39
|
+
const $884aeceb3d67f00f$export$8e8b214e06dd397d = new WeakMap();
|
|
40
|
+
const $884aeceb3d67f00f$export$61c8d3f0151e21b2 = new WeakMap();
|
|
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 } = (0, $4vDl6$usePress)({
|
|
57
|
+
isDisabled: isDisabled
|
|
58
|
+
});
|
|
59
|
+
let { focusableProps: focusableProps } = (0, $4vDl6$useFocusable)((0, $4vDl6$mergeProps)(props, {
|
|
60
|
+
onFocus: ()=>state.setLastFocusedValue(value)
|
|
61
|
+
}), ref);
|
|
62
|
+
let interactions = (0, $4vDl6$mergeProps)(pressProps, focusableProps);
|
|
63
|
+
let domProps = (0, $4vDl6$filterDOMProps)(props, {
|
|
64
|
+
labelable: true
|
|
65
|
+
});
|
|
66
|
+
let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;
|
|
67
|
+
if (isDisabled) tabIndex = undefined;
|
|
68
|
+
return {
|
|
69
|
+
inputProps: (0, $4vDl6$mergeProps)(domProps, {
|
|
70
|
+
...interactions,
|
|
71
|
+
type: "radio",
|
|
72
|
+
name: (0, $884aeceb3d67f00f$export$3b7b268d09480394).get(state),
|
|
73
|
+
tabIndex: tabIndex,
|
|
74
|
+
disabled: isDisabled,
|
|
75
|
+
checked: checked,
|
|
76
|
+
value: value,
|
|
77
|
+
onChange: onChange,
|
|
78
|
+
"aria-describedby": [
|
|
79
|
+
state.validationState === "invalid" ? (0, $884aeceb3d67f00f$export$61c8d3f0151e21b2).get(state) : null,
|
|
80
|
+
(0, $884aeceb3d67f00f$export$8e8b214e06dd397d).get(state)
|
|
81
|
+
].filter(Boolean).join(" ") || undefined
|
|
82
|
+
}),
|
|
83
|
+
isDisabled: isDisabled,
|
|
84
|
+
isSelected: checked
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
91
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
92
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
93
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
94
|
+
*
|
|
95
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
96
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
97
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
98
|
+
* governing permissions and limitations under the License.
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
106
|
+
let { name: name , validationState: validationState , isReadOnly: isReadOnly , isRequired: isRequired , isDisabled: isDisabled , orientation: orientation = "vertical" } = props;
|
|
107
|
+
let { direction: direction } = (0, $4vDl6$useLocale)();
|
|
108
|
+
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $4vDl6$useField)({
|
|
109
|
+
...props,
|
|
110
|
+
// Radio group is not an HTML input element so it
|
|
111
|
+
// shouldn't be labeled by a <label> element.
|
|
112
|
+
labelElementType: "span"
|
|
113
|
+
});
|
|
114
|
+
(0, $884aeceb3d67f00f$export$8e8b214e06dd397d).set(state, descriptionProps.id);
|
|
115
|
+
(0, $884aeceb3d67f00f$export$61c8d3f0151e21b2).set(state, errorMessageProps.id);
|
|
116
|
+
let domProps = (0, $4vDl6$filterDOMProps)(props, {
|
|
117
|
+
labelable: true
|
|
118
|
+
});
|
|
119
|
+
// When the radio group loses focus, reset the focusable radio to null if
|
|
120
|
+
// there is no selection. This allows tabbing into the group from either
|
|
121
|
+
// direction to go to the first or last radio.
|
|
122
|
+
let { focusWithinProps: focusWithinProps } = (0, $4vDl6$useFocusWithin)({
|
|
123
|
+
onBlurWithin () {
|
|
124
|
+
if (!state.selectedValue) state.setLastFocusedValue(null);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
let onKeyDown = (e)=>{
|
|
128
|
+
let nextDir;
|
|
129
|
+
switch(e.key){
|
|
130
|
+
case "ArrowRight":
|
|
131
|
+
if (direction === "rtl" && orientation !== "vertical") nextDir = "prev";
|
|
132
|
+
else nextDir = "next";
|
|
133
|
+
break;
|
|
134
|
+
case "ArrowLeft":
|
|
135
|
+
if (direction === "rtl" && orientation !== "vertical") nextDir = "next";
|
|
136
|
+
else nextDir = "prev";
|
|
137
|
+
break;
|
|
138
|
+
case "ArrowDown":
|
|
139
|
+
nextDir = "next";
|
|
140
|
+
break;
|
|
141
|
+
case "ArrowUp":
|
|
142
|
+
nextDir = "prev";
|
|
143
|
+
break;
|
|
144
|
+
default:
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
let walker = (0, $4vDl6$getFocusableTreeWalker)(e.currentTarget, {
|
|
149
|
+
from: e.target
|
|
150
|
+
});
|
|
151
|
+
let nextElem;
|
|
152
|
+
if (nextDir === "next") {
|
|
153
|
+
nextElem = walker.nextNode();
|
|
154
|
+
if (!nextElem) {
|
|
155
|
+
walker.currentNode = e.currentTarget;
|
|
156
|
+
nextElem = walker.firstChild();
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
nextElem = walker.previousNode();
|
|
160
|
+
if (!nextElem) {
|
|
161
|
+
walker.currentNode = e.currentTarget;
|
|
162
|
+
nextElem = walker.lastChild();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (nextElem) {
|
|
166
|
+
// Call focus on nextElem so that keyboard navigation scrolls the radio into view
|
|
167
|
+
nextElem.focus();
|
|
168
|
+
state.setSelectedValue(nextElem.value);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
let groupName = (0, $4vDl6$useId)(name);
|
|
172
|
+
(0, $884aeceb3d67f00f$export$3b7b268d09480394).set(state, groupName);
|
|
173
|
+
return {
|
|
174
|
+
radioGroupProps: (0, $4vDl6$mergeProps)(domProps, {
|
|
175
|
+
// https://www.w3.org/TR/wai-aria-1.2/#radiogroup
|
|
176
|
+
role: "radiogroup",
|
|
177
|
+
onKeyDown: onKeyDown,
|
|
178
|
+
"aria-invalid": validationState === "invalid" || undefined,
|
|
179
|
+
"aria-errormessage": props["aria-errormessage"],
|
|
180
|
+
"aria-readonly": isReadOnly || undefined,
|
|
181
|
+
"aria-required": isRequired || undefined,
|
|
182
|
+
"aria-disabled": isDisabled || undefined,
|
|
183
|
+
"aria-orientation": orientation,
|
|
184
|
+
...fieldProps,
|
|
185
|
+
...focusWithinProps
|
|
186
|
+
}),
|
|
187
|
+
labelProps: labelProps,
|
|
188
|
+
descriptionProps: descriptionProps,
|
|
189
|
+
errorMessageProps: errorMessageProps
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
export {$0d5c49892c1215da$export$37b0961d2f4751e2 as useRadio, $430f30ed08ec25fa$export$62b9571f283ff5c2 as useRadioGroup};
|
|
197
|
+
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -10,8 +10,38 @@ function $parcel$export(e, n, v, s) {
|
|
|
10
10
|
|
|
11
11
|
$parcel$export(module.exports, "useRadio", () => $e184702b1b7f1863$export$37b0961d2f4751e2);
|
|
12
12
|
$parcel$export(module.exports, "useRadioGroup", () => $dfcade00a56a6317$export$62b9571f283ff5c2);
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
15
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
17
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
20
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
21
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
22
|
+
* governing permissions and limitations under the License.
|
|
23
|
+
*/ /*
|
|
24
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
25
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
26
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
27
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
30
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
31
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
32
|
+
* governing permissions and limitations under the License.
|
|
33
|
+
*/
|
|
34
|
+
/*
|
|
35
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
36
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
37
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
38
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
39
|
+
*
|
|
40
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
41
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
42
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
43
|
+
* governing permissions and limitations under the License.
|
|
44
|
+
*/ const $eeb149278aae5c67$export$3b7b268d09480394 = new WeakMap();
|
|
15
45
|
const $eeb149278aae5c67$export$8e8b214e06dd397d = new WeakMap();
|
|
16
46
|
const $eeb149278aae5c67$export$61c8d3f0151e21b2 = new WeakMap();
|
|
17
47
|
|
|
@@ -19,42 +49,42 @@ const $eeb149278aae5c67$export$61c8d3f0151e21b2 = new WeakMap();
|
|
|
19
49
|
|
|
20
50
|
|
|
21
51
|
function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
|
|
22
|
-
let { value: value , children: children ,
|
|
52
|
+
let { value: value , children: children , "aria-label": ariaLabel , "aria-labelledby": ariaLabelledby } = props;
|
|
23
53
|
const isDisabled = props.isDisabled || state.isDisabled;
|
|
24
54
|
let hasChildren = children != null;
|
|
25
55
|
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
26
|
-
if (!hasChildren && !hasAriaLabel) console.warn(
|
|
56
|
+
if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
|
|
27
57
|
let checked = state.selectedValue === value;
|
|
28
58
|
let onChange = (e)=>{
|
|
29
59
|
e.stopPropagation();
|
|
30
60
|
state.setSelectedValue(value);
|
|
31
61
|
};
|
|
32
|
-
let { pressProps: pressProps } = $fMEGB$reactariainteractions.usePress({
|
|
62
|
+
let { pressProps: pressProps } = (0, $fMEGB$reactariainteractions.usePress)({
|
|
33
63
|
isDisabled: isDisabled
|
|
34
64
|
});
|
|
35
|
-
let { focusableProps: focusableProps } = $fMEGB$reactariafocus.useFocusable($fMEGB$reactariautils.mergeProps(props, {
|
|
65
|
+
let { focusableProps: focusableProps } = (0, $fMEGB$reactariafocus.useFocusable)((0, $fMEGB$reactariautils.mergeProps)(props, {
|
|
36
66
|
onFocus: ()=>state.setLastFocusedValue(value)
|
|
37
67
|
}), ref);
|
|
38
|
-
let interactions = $fMEGB$reactariautils.mergeProps(pressProps, focusableProps);
|
|
39
|
-
let domProps = $fMEGB$reactariautils.filterDOMProps(props, {
|
|
68
|
+
let interactions = (0, $fMEGB$reactariautils.mergeProps)(pressProps, focusableProps);
|
|
69
|
+
let domProps = (0, $fMEGB$reactariautils.filterDOMProps)(props, {
|
|
40
70
|
labelable: true
|
|
41
71
|
});
|
|
42
72
|
let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;
|
|
43
73
|
if (isDisabled) tabIndex = undefined;
|
|
44
74
|
return {
|
|
45
|
-
inputProps: $fMEGB$reactariautils.mergeProps(domProps, {
|
|
75
|
+
inputProps: (0, $fMEGB$reactariautils.mergeProps)(domProps, {
|
|
46
76
|
...interactions,
|
|
47
|
-
type:
|
|
48
|
-
name: $eeb149278aae5c67$export$3b7b268d09480394.get(state),
|
|
77
|
+
type: "radio",
|
|
78
|
+
name: (0, $eeb149278aae5c67$export$3b7b268d09480394).get(state),
|
|
49
79
|
tabIndex: tabIndex,
|
|
50
80
|
disabled: isDisabled,
|
|
51
81
|
checked: checked,
|
|
52
82
|
value: value,
|
|
53
83
|
onChange: onChange,
|
|
54
|
-
|
|
55
|
-
state.validationState ===
|
|
56
|
-
$eeb149278aae5c67$export$8e8b214e06dd397d.get(state)
|
|
57
|
-
].filter(Boolean).join(
|
|
84
|
+
"aria-describedby": [
|
|
85
|
+
state.validationState === "invalid" ? (0, $eeb149278aae5c67$export$61c8d3f0151e21b2).get(state) : null,
|
|
86
|
+
(0, $eeb149278aae5c67$export$8e8b214e06dd397d).get(state)
|
|
87
|
+
].filter(Boolean).join(" ") || undefined
|
|
58
88
|
}),
|
|
59
89
|
isDisabled: isDisabled,
|
|
60
90
|
isSelected: checked
|
|
@@ -62,30 +92,40 @@ function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
62
92
|
}
|
|
63
93
|
|
|
64
94
|
|
|
65
|
-
|
|
95
|
+
/*
|
|
96
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
97
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
98
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
99
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
100
|
+
*
|
|
101
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
102
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
103
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
104
|
+
* governing permissions and limitations under the License.
|
|
105
|
+
*/
|
|
66
106
|
|
|
67
107
|
|
|
68
108
|
|
|
69
109
|
|
|
70
110
|
|
|
71
111
|
function $dfcade00a56a6317$export$62b9571f283ff5c2(props, state) {
|
|
72
|
-
let { name: name , validationState: validationState , isReadOnly: isReadOnly , isRequired: isRequired , isDisabled: isDisabled , orientation: orientation =
|
|
73
|
-
let { direction: direction } = $fMEGB$reactariai18n.useLocale();
|
|
74
|
-
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $fMEGB$reactarialabel.useField({
|
|
112
|
+
let { name: name , validationState: validationState , isReadOnly: isReadOnly , isRequired: isRequired , isDisabled: isDisabled , orientation: orientation = "vertical" } = props;
|
|
113
|
+
let { direction: direction } = (0, $fMEGB$reactariai18n.useLocale)();
|
|
114
|
+
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $fMEGB$reactarialabel.useField)({
|
|
75
115
|
...props,
|
|
76
116
|
// Radio group is not an HTML input element so it
|
|
77
117
|
// shouldn't be labeled by a <label> element.
|
|
78
|
-
labelElementType:
|
|
118
|
+
labelElementType: "span"
|
|
79
119
|
});
|
|
80
|
-
$eeb149278aae5c67$export$8e8b214e06dd397d.set(state, descriptionProps.id);
|
|
81
|
-
$eeb149278aae5c67$export$61c8d3f0151e21b2.set(state, errorMessageProps.id);
|
|
82
|
-
let domProps = $fMEGB$reactariautils.filterDOMProps(props, {
|
|
120
|
+
(0, $eeb149278aae5c67$export$8e8b214e06dd397d).set(state, descriptionProps.id);
|
|
121
|
+
(0, $eeb149278aae5c67$export$61c8d3f0151e21b2).set(state, errorMessageProps.id);
|
|
122
|
+
let domProps = (0, $fMEGB$reactariautils.filterDOMProps)(props, {
|
|
83
123
|
labelable: true
|
|
84
124
|
});
|
|
85
125
|
// When the radio group loses focus, reset the focusable radio to null if
|
|
86
126
|
// there is no selection. This allows tabbing into the group from either
|
|
87
127
|
// direction to go to the first or last radio.
|
|
88
|
-
let { focusWithinProps: focusWithinProps } = $fMEGB$reactariainteractions.useFocusWithin({
|
|
128
|
+
let { focusWithinProps: focusWithinProps } = (0, $fMEGB$reactariainteractions.useFocusWithin)({
|
|
89
129
|
onBlurWithin () {
|
|
90
130
|
if (!state.selectedValue) state.setLastFocusedValue(null);
|
|
91
131
|
}
|
|
@@ -93,29 +133,29 @@ function $dfcade00a56a6317$export$62b9571f283ff5c2(props, state) {
|
|
|
93
133
|
let onKeyDown = (e)=>{
|
|
94
134
|
let nextDir;
|
|
95
135
|
switch(e.key){
|
|
96
|
-
case
|
|
97
|
-
if (direction ===
|
|
98
|
-
else nextDir =
|
|
136
|
+
case "ArrowRight":
|
|
137
|
+
if (direction === "rtl" && orientation !== "vertical") nextDir = "prev";
|
|
138
|
+
else nextDir = "next";
|
|
99
139
|
break;
|
|
100
|
-
case
|
|
101
|
-
if (direction ===
|
|
102
|
-
else nextDir =
|
|
140
|
+
case "ArrowLeft":
|
|
141
|
+
if (direction === "rtl" && orientation !== "vertical") nextDir = "next";
|
|
142
|
+
else nextDir = "prev";
|
|
103
143
|
break;
|
|
104
|
-
case
|
|
105
|
-
nextDir =
|
|
144
|
+
case "ArrowDown":
|
|
145
|
+
nextDir = "next";
|
|
106
146
|
break;
|
|
107
|
-
case
|
|
108
|
-
nextDir =
|
|
147
|
+
case "ArrowUp":
|
|
148
|
+
nextDir = "prev";
|
|
109
149
|
break;
|
|
110
150
|
default:
|
|
111
151
|
return;
|
|
112
152
|
}
|
|
113
153
|
e.preventDefault();
|
|
114
|
-
let walker = $fMEGB$reactariafocus.getFocusableTreeWalker(e.currentTarget, {
|
|
154
|
+
let walker = (0, $fMEGB$reactariafocus.getFocusableTreeWalker)(e.currentTarget, {
|
|
115
155
|
from: e.target
|
|
116
156
|
});
|
|
117
157
|
let nextElem;
|
|
118
|
-
if (nextDir ===
|
|
158
|
+
if (nextDir === "next") {
|
|
119
159
|
nextElem = walker.nextNode();
|
|
120
160
|
if (!nextElem) {
|
|
121
161
|
walker.currentNode = e.currentTarget;
|
|
@@ -134,19 +174,19 @@ function $dfcade00a56a6317$export$62b9571f283ff5c2(props, state) {
|
|
|
134
174
|
state.setSelectedValue(nextElem.value);
|
|
135
175
|
}
|
|
136
176
|
};
|
|
137
|
-
let groupName = $fMEGB$reactariautils.useId(name);
|
|
138
|
-
$eeb149278aae5c67$export$3b7b268d09480394.set(state, groupName);
|
|
177
|
+
let groupName = (0, $fMEGB$reactariautils.useId)(name);
|
|
178
|
+
(0, $eeb149278aae5c67$export$3b7b268d09480394).set(state, groupName);
|
|
139
179
|
return {
|
|
140
|
-
radioGroupProps: $fMEGB$reactariautils.mergeProps(domProps, {
|
|
180
|
+
radioGroupProps: (0, $fMEGB$reactariautils.mergeProps)(domProps, {
|
|
141
181
|
// https://www.w3.org/TR/wai-aria-1.2/#radiogroup
|
|
142
|
-
role:
|
|
182
|
+
role: "radiogroup",
|
|
143
183
|
onKeyDown: onKeyDown,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
184
|
+
"aria-invalid": validationState === "invalid" || undefined,
|
|
185
|
+
"aria-errormessage": props["aria-errormessage"],
|
|
186
|
+
"aria-readonly": isReadOnly || undefined,
|
|
187
|
+
"aria-required": isRequired || undefined,
|
|
188
|
+
"aria-disabled": isDisabled || undefined,
|
|
189
|
+
"aria-orientation": orientation,
|
|
150
190
|
...fieldProps,
|
|
151
191
|
...focusWithinProps
|
|
152
192
|
}),
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AEcO,KAAK,CAAC,yCAAe,GAAG,GAAG,CAAC,OAAO;AACnC,KAAK,CAAC,yCAAwB,GAAG,GAAG,CAAC,OAAO;AAC5C,KAAK,CAAC,yCAAyB,GAAG,GAAG,CAAC,OAAO;;;;;SDoBpC,yCAAQ,CAAC,KAAqB,EAAE,KAAsB,EAAE,GAAgC,EAAa,CAAC;IACpH,GAAG,CAAC,CAAC,QACH,KAAK,aACL,QAAQ,GACR,CAAY,aAAE,SAAS,GACvB,CAAiB,kBAAE,cAAc,EACnC,CAAC,GAAG,KAAK;IAET,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK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E,QAAQ,EAAE,CAAC;YACb,EAAiF,AAAjF,+EAAiF;YACjF,QAAQ,CAAC,KAAK;YACd,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK;QACvC,CAAC;IACH,CAAC;IAED,GAAG,CAAC,SAAS,GAAG,2BAAK,CAAC,IAAI;IAC1B,yCAAe,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS;IAEpC,MAAM,CAAC,CAAC;QACN,eAAe,EAAE,gCAAU,CAAC,QAAQ,EAAE,CAAC;YACrC,EAAiD,AAAjD,+CAAiD;YACjD,IAAI,EAAE,CAAY;uBAClB,SAAS;YACT,CAAc,eAAE,eAAe,KAAK,CAAS,YAAI,SAAS;YAC1D,CAAmB,oBAAE,KAAK,CAAC,CAAmB;YAC9C,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAkB,mBAAE,WAAW;eAC5B,UAAU;eACV,gBAAgB;QACrB,CAAC;oBACD,UAAU;0BACV,gBAAgB;2BAChB,iBAAiB;IACnB,CAAC;AACH,CAAC;;","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 {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the radio is disabled. */\n isDisabled: boolean,\n /** Whether the radio is currently selected. */\n isSelected: boolean\n}\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} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(mergeProps(props, {\n onFocus: () => state.setLastFocusedValue(value)\n }), ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange,\n 'aria-describedby': [\n state.validationState === 'invalid' ? radioGroupErrorMessageIds.get(state) : null,\n radioGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\nexport const radioGroupDescriptionIds = new WeakMap<RadioGroupState, string>();\nexport const radioGroupErrorMessageIds = new WeakMap<RadioGroupState, string>();\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaRadioGroupProps} from '@react-types/radio';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: DOMAttributes,\n /** Props for the radio group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the radio group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the radio group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a radio group component.\n * Radio groups allow users to select a single item from a list of mutually exclusive options.\n * @param props - Props for the radio group.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n */\nexport function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria {\n let {\n name,\n validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Radio group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n radioGroupDescriptionIds.set(state, descriptionProps.id);\n radioGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // When the radio group loses focus, reset the focusable radio to null if\n // there is no selection. This allows tabbing into the group from either\n // direction to go to the first or last radio.\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\n });\n\n let onKeyDown = (e) => {\n let nextDir;\n switch (e.key) {\n case 'ArrowRight':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'prev';\n } else {\n nextDir = 'next';\n }\n break;\n case 'ArrowLeft':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'next';\n } else {\n nextDir = 'prev';\n }\n break;\n case 'ArrowDown':\n nextDir = 'next';\n break;\n case 'ArrowUp':\n nextDir = 'prev';\n break;\n default:\n return;\n }\n e.preventDefault();\n let walker = getFocusableTreeWalker(e.currentTarget, {from: e.target});\n let nextElem;\n if (nextDir === 'next') {\n nextElem = walker.nextNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.firstChild();\n }\n } else {\n nextElem = walker.previousNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.lastChild();\n }\n }\n if (nextElem) {\n // Call focus on nextElem so that keyboard navigation scrolls the radio into view\n nextElem.focus();\n state.setSelectedValue(nextElem.value);\n }\n };\n\n let groupName = useId(name);\n radioGroupNames.set(state, groupName);\n\n return {\n radioGroupProps: mergeProps(domProps, {\n // https://www.w3.org/TR/wai-aria-1.2/#radiogroup\n role: 'radiogroup',\n onKeyDown,\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n 'aria-disabled': isDisabled || undefined,\n 'aria-orientation': orientation,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;ACZA;;;;;;;;;;CAUC,GAED,AAEO,MAAM,4CAAkB,IAAI;AAC5B,MAAM,4CAA2B,IAAI;AACrC,MAAM,4CAA4B,IAAI;;;;;ADoBtC,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAgC,EAAa;IACnH,IAAI,SACF,MAAK,YACL,SAAQ,EACR,cAAc,UAAS,EACvB,mBAAmB,eAAc,EAClC,GAAG;IAEJ,MAAM,aAAa,MAAM,UAAU,IAAI,MAAM,UAAU;I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Q;YAC1B,IAAI,CAAC,UAAU;gBACb,OAAO,WAAW,GAAG,EAAE,aAAa;gBACpC,WAAW,OAAO,UAAU;YAC9B,CAAC;QACH,OAAO;YACL,WAAW,OAAO,YAAY;YAC9B,IAAI,CAAC,UAAU;gBACb,OAAO,WAAW,GAAG,EAAE,aAAa;gBACpC,WAAW,OAAO,SAAS;YAC7B,CAAC;QACH,CAAC;QACD,IAAI,UAAU;YACZ,iFAAiF;YACjF,SAAS,KAAK;YACd,MAAM,gBAAgB,CAAC,SAAS,KAAK;QACvC,CAAC;IACH;IAEA,IAAI,YAAY,CAAA,GAAA,2BAAI,EAAE;IACtB,CAAA,GAAA,yCAAc,EAAE,GAAG,CAAC,OAAO;IAE3B,OAAO;QACL,iBAAiB,CAAA,GAAA,gCAAU,AAAD,EAAE,UAAU;YACpC,iDAAiD;YACjD,MAAM;uBACN;YACA,gBAAgB,oBAAoB,aAAa;YACjD,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,oBAAoB;YACpB,GAAG,UAAU;YACb,GAAG,gBAAgB;QACrB;oBACA;0BACA;2BACA;IACF;AACF;","sources":["packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/utils.ts","packages/@react-aria/radio/src/useRadioGroup.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the radio is disabled. */\n isDisabled: boolean,\n /** Whether the radio is currently selected. */\n isSelected: boolean\n}\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} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(mergeProps(props, {\n onFocus: () => state.setLastFocusedValue(value)\n }), ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange,\n 'aria-describedby': [\n state.validationState === 'invalid' ? radioGroupErrorMessageIds.get(state) : null,\n radioGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\nexport const radioGroupDescriptionIds = new WeakMap<RadioGroupState, string>();\nexport const radioGroupErrorMessageIds = new WeakMap<RadioGroupState, string>();\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaRadioGroupProps} from '@react-types/radio';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: DOMAttributes,\n /** Props for the radio group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the radio group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the radio group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a radio group component.\n * Radio groups allow users to select a single item from a list of mutually exclusive options.\n * @param props - Props for the radio group.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n */\nexport function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria {\n let {\n name,\n validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Radio group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n radioGroupDescriptionIds.set(state, descriptionProps.id);\n radioGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // When the radio group loses focus, reset the focusable radio to null if\n // there is no selection. This allows tabbing into the group from either\n // direction to go to the first or last radio.\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\n });\n\n let onKeyDown = (e) => {\n let nextDir;\n switch (e.key) {\n case 'ArrowRight':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'prev';\n } else {\n nextDir = 'next';\n }\n break;\n case 'ArrowLeft':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'next';\n } else {\n nextDir = 'prev';\n }\n break;\n case 'ArrowDown':\n nextDir = 'next';\n break;\n case 'ArrowUp':\n nextDir = 'prev';\n break;\n default:\n return;\n }\n e.preventDefault();\n let walker = getFocusableTreeWalker(e.currentTarget, {from: e.target});\n let nextElem;\n if (nextDir === 'next') {\n nextElem = walker.nextNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.firstChild();\n }\n } else {\n nextElem = walker.previousNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.lastChild();\n }\n }\n if (nextElem) {\n // Call focus on nextElem so that keyboard navigation scrolls the radio into view\n nextElem.focus();\n state.setSelectedValue(nextElem.value);\n }\n };\n\n let groupName = useId(name);\n radioGroupNames.set(state, groupName);\n\n return {\n radioGroupProps: mergeProps(domProps, {\n // https://www.w3.org/TR/wai-aria-1.2/#radiogroup\n role: 'radiogroup',\n onKeyDown,\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n 'aria-disabled': isDisabled || undefined,\n 'aria-orientation': orientation,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -4,8 +4,38 @@ import {usePress as $4vDl6$usePress, useFocusWithin as $4vDl6$useFocusWithin} fr
|
|
|
4
4
|
import {useField as $4vDl6$useField} from "@react-aria/label";
|
|
5
5
|
import {useLocale as $4vDl6$useLocale} from "@react-aria/i18n";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/ /*
|
|
18
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
/*
|
|
29
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
30
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
31
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
32
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
+
*
|
|
34
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
35
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
36
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
37
|
+
* governing permissions and limitations under the License.
|
|
38
|
+
*/ const $884aeceb3d67f00f$export$3b7b268d09480394 = new WeakMap();
|
|
9
39
|
const $884aeceb3d67f00f$export$8e8b214e06dd397d = new WeakMap();
|
|
10
40
|
const $884aeceb3d67f00f$export$61c8d3f0151e21b2 = new WeakMap();
|
|
11
41
|
|
|
@@ -13,42 +43,42 @@ const $884aeceb3d67f00f$export$61c8d3f0151e21b2 = new WeakMap();
|
|
|
13
43
|
|
|
14
44
|
|
|
15
45
|
function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
16
|
-
let { value: value , children: children ,
|
|
46
|
+
let { value: value , children: children , "aria-label": ariaLabel , "aria-labelledby": ariaLabelledby } = props;
|
|
17
47
|
const isDisabled = props.isDisabled || state.isDisabled;
|
|
18
48
|
let hasChildren = children != null;
|
|
19
49
|
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
20
|
-
if (!hasChildren && !hasAriaLabel) console.warn(
|
|
50
|
+
if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
|
|
21
51
|
let checked = state.selectedValue === value;
|
|
22
52
|
let onChange = (e)=>{
|
|
23
53
|
e.stopPropagation();
|
|
24
54
|
state.setSelectedValue(value);
|
|
25
55
|
};
|
|
26
|
-
let { pressProps: pressProps } = $4vDl6$usePress({
|
|
56
|
+
let { pressProps: pressProps } = (0, $4vDl6$usePress)({
|
|
27
57
|
isDisabled: isDisabled
|
|
28
58
|
});
|
|
29
|
-
let { focusableProps: focusableProps } = $4vDl6$useFocusable($4vDl6$mergeProps(props, {
|
|
59
|
+
let { focusableProps: focusableProps } = (0, $4vDl6$useFocusable)((0, $4vDl6$mergeProps)(props, {
|
|
30
60
|
onFocus: ()=>state.setLastFocusedValue(value)
|
|
31
61
|
}), ref);
|
|
32
|
-
let interactions = $4vDl6$mergeProps(pressProps, focusableProps);
|
|
33
|
-
let domProps = $4vDl6$filterDOMProps(props, {
|
|
62
|
+
let interactions = (0, $4vDl6$mergeProps)(pressProps, focusableProps);
|
|
63
|
+
let domProps = (0, $4vDl6$filterDOMProps)(props, {
|
|
34
64
|
labelable: true
|
|
35
65
|
});
|
|
36
66
|
let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;
|
|
37
67
|
if (isDisabled) tabIndex = undefined;
|
|
38
68
|
return {
|
|
39
|
-
inputProps: $4vDl6$mergeProps(domProps, {
|
|
69
|
+
inputProps: (0, $4vDl6$mergeProps)(domProps, {
|
|
40
70
|
...interactions,
|
|
41
|
-
type:
|
|
42
|
-
name: $884aeceb3d67f00f$export$3b7b268d09480394.get(state),
|
|
71
|
+
type: "radio",
|
|
72
|
+
name: (0, $884aeceb3d67f00f$export$3b7b268d09480394).get(state),
|
|
43
73
|
tabIndex: tabIndex,
|
|
44
74
|
disabled: isDisabled,
|
|
45
75
|
checked: checked,
|
|
46
76
|
value: value,
|
|
47
77
|
onChange: onChange,
|
|
48
|
-
|
|
49
|
-
state.validationState ===
|
|
50
|
-
$884aeceb3d67f00f$export$8e8b214e06dd397d.get(state)
|
|
51
|
-
].filter(Boolean).join(
|
|
78
|
+
"aria-describedby": [
|
|
79
|
+
state.validationState === "invalid" ? (0, $884aeceb3d67f00f$export$61c8d3f0151e21b2).get(state) : null,
|
|
80
|
+
(0, $884aeceb3d67f00f$export$8e8b214e06dd397d).get(state)
|
|
81
|
+
].filter(Boolean).join(" ") || undefined
|
|
52
82
|
}),
|
|
53
83
|
isDisabled: isDisabled,
|
|
54
84
|
isSelected: checked
|
|
@@ -56,30 +86,40 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
56
86
|
}
|
|
57
87
|
|
|
58
88
|
|
|
59
|
-
|
|
89
|
+
/*
|
|
90
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
91
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
92
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
93
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
94
|
+
*
|
|
95
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
96
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
97
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
98
|
+
* governing permissions and limitations under the License.
|
|
99
|
+
*/
|
|
60
100
|
|
|
61
101
|
|
|
62
102
|
|
|
63
103
|
|
|
64
104
|
|
|
65
105
|
function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
66
|
-
let { name: name , validationState: validationState , isReadOnly: isReadOnly , isRequired: isRequired , isDisabled: isDisabled , orientation: orientation =
|
|
67
|
-
let { direction: direction } = $4vDl6$useLocale();
|
|
68
|
-
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $4vDl6$useField({
|
|
106
|
+
let { name: name , validationState: validationState , isReadOnly: isReadOnly , isRequired: isRequired , isDisabled: isDisabled , orientation: orientation = "vertical" } = props;
|
|
107
|
+
let { direction: direction } = (0, $4vDl6$useLocale)();
|
|
108
|
+
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $4vDl6$useField)({
|
|
69
109
|
...props,
|
|
70
110
|
// Radio group is not an HTML input element so it
|
|
71
111
|
// shouldn't be labeled by a <label> element.
|
|
72
|
-
labelElementType:
|
|
112
|
+
labelElementType: "span"
|
|
73
113
|
});
|
|
74
|
-
$884aeceb3d67f00f$export$8e8b214e06dd397d.set(state, descriptionProps.id);
|
|
75
|
-
$884aeceb3d67f00f$export$61c8d3f0151e21b2.set(state, errorMessageProps.id);
|
|
76
|
-
let domProps = $4vDl6$filterDOMProps(props, {
|
|
114
|
+
(0, $884aeceb3d67f00f$export$8e8b214e06dd397d).set(state, descriptionProps.id);
|
|
115
|
+
(0, $884aeceb3d67f00f$export$61c8d3f0151e21b2).set(state, errorMessageProps.id);
|
|
116
|
+
let domProps = (0, $4vDl6$filterDOMProps)(props, {
|
|
77
117
|
labelable: true
|
|
78
118
|
});
|
|
79
119
|
// When the radio group loses focus, reset the focusable radio to null if
|
|
80
120
|
// there is no selection. This allows tabbing into the group from either
|
|
81
121
|
// direction to go to the first or last radio.
|
|
82
|
-
let { focusWithinProps: focusWithinProps } = $4vDl6$useFocusWithin({
|
|
122
|
+
let { focusWithinProps: focusWithinProps } = (0, $4vDl6$useFocusWithin)({
|
|
83
123
|
onBlurWithin () {
|
|
84
124
|
if (!state.selectedValue) state.setLastFocusedValue(null);
|
|
85
125
|
}
|
|
@@ -87,29 +127,29 @@ function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
|
87
127
|
let onKeyDown = (e)=>{
|
|
88
128
|
let nextDir;
|
|
89
129
|
switch(e.key){
|
|
90
|
-
case
|
|
91
|
-
if (direction ===
|
|
92
|
-
else nextDir =
|
|
130
|
+
case "ArrowRight":
|
|
131
|
+
if (direction === "rtl" && orientation !== "vertical") nextDir = "prev";
|
|
132
|
+
else nextDir = "next";
|
|
93
133
|
break;
|
|
94
|
-
case
|
|
95
|
-
if (direction ===
|
|
96
|
-
else nextDir =
|
|
134
|
+
case "ArrowLeft":
|
|
135
|
+
if (direction === "rtl" && orientation !== "vertical") nextDir = "next";
|
|
136
|
+
else nextDir = "prev";
|
|
97
137
|
break;
|
|
98
|
-
case
|
|
99
|
-
nextDir =
|
|
138
|
+
case "ArrowDown":
|
|
139
|
+
nextDir = "next";
|
|
100
140
|
break;
|
|
101
|
-
case
|
|
102
|
-
nextDir =
|
|
141
|
+
case "ArrowUp":
|
|
142
|
+
nextDir = "prev";
|
|
103
143
|
break;
|
|
104
144
|
default:
|
|
105
145
|
return;
|
|
106
146
|
}
|
|
107
147
|
e.preventDefault();
|
|
108
|
-
let walker = $4vDl6$getFocusableTreeWalker(e.currentTarget, {
|
|
148
|
+
let walker = (0, $4vDl6$getFocusableTreeWalker)(e.currentTarget, {
|
|
109
149
|
from: e.target
|
|
110
150
|
});
|
|
111
151
|
let nextElem;
|
|
112
|
-
if (nextDir ===
|
|
152
|
+
if (nextDir === "next") {
|
|
113
153
|
nextElem = walker.nextNode();
|
|
114
154
|
if (!nextElem) {
|
|
115
155
|
walker.currentNode = e.currentTarget;
|
|
@@ -128,19 +168,19 @@ function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
|
128
168
|
state.setSelectedValue(nextElem.value);
|
|
129
169
|
}
|
|
130
170
|
};
|
|
131
|
-
let groupName = $4vDl6$useId(name);
|
|
132
|
-
$884aeceb3d67f00f$export$3b7b268d09480394.set(state, groupName);
|
|
171
|
+
let groupName = (0, $4vDl6$useId)(name);
|
|
172
|
+
(0, $884aeceb3d67f00f$export$3b7b268d09480394).set(state, groupName);
|
|
133
173
|
return {
|
|
134
|
-
radioGroupProps: $4vDl6$mergeProps(domProps, {
|
|
174
|
+
radioGroupProps: (0, $4vDl6$mergeProps)(domProps, {
|
|
135
175
|
// https://www.w3.org/TR/wai-aria-1.2/#radiogroup
|
|
136
|
-
role:
|
|
176
|
+
role: "radiogroup",
|
|
137
177
|
onKeyDown: onKeyDown,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
178
|
+
"aria-invalid": validationState === "invalid" || undefined,
|
|
179
|
+
"aria-errormessage": props["aria-errormessage"],
|
|
180
|
+
"aria-readonly": isReadOnly || undefined,
|
|
181
|
+
"aria-required": isRequired || undefined,
|
|
182
|
+
"aria-disabled": isDisabled || undefined,
|
|
183
|
+
"aria-orientation": orientation,
|
|
144
184
|
...fieldProps,
|
|
145
185
|
...focusWithinProps
|
|
146
186
|
}),
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AEcO,KAAK,CAAC,yCAAe,GAAG,GAAG,CAAC,OAAO;AACnC,KAAK,CAAC,yCAAwB,GAAG,GAAG,CAAC,OAAO;AAC5C,KAAK,CAAC,yCAAyB,GAAG,GAAG,CAAC,OAAO;;;;;SDoBpC,yCAAQ,CAAC,KAAqB,EAAE,KAAsB,EAAE,GAAgC,EAAa,CAAC;IACpH,GAAG,CAAC,CAAC,QACH,KAAK,aACL,QAAQ,GACR,CAAY,aAAE,SAAS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WAAW,GAAG,CAAC,CAAC,aAAa;gBACpC,QAAQ,GAAG,MAAM,CAAC,SAAS;YAC7B,CAAC;QACH,CAAC;QACD,EAAE,EAAE,QAAQ,EAAE,CAAC;YACb,EAAiF,AAAjF,+EAAiF;YACjF,QAAQ,CAAC,KAAK;YACd,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK;QACvC,CAAC;IACH,CAAC;IAED,GAAG,CAAC,SAAS,GAAG,YAAK,CAAC,IAAI;IAC1B,yCAAe,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS;IAEpC,MAAM,CAAC,CAAC;QACN,eAAe,EAAE,iBAAU,CAAC,QAAQ,EAAE,CAAC;YACrC,EAAiD,AAAjD,+CAAiD;YACjD,IAAI,EAAE,CAAY;uBAClB,SAAS;YACT,CAAc,eAAE,eAAe,KAAK,CAAS,YAAI,SAAS;YAC1D,CAAmB,oBAAE,KAAK,CAAC,CAAmB;YAC9C,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAkB,mBAAE,WAAW;eAC5B,UAAU;eACV,gBAAgB;QACrB,CAAC;oBACD,UAAU;0BACV,gBAAgB;2BAChB,iBAAiB;IACnB,CAAC;AACH,CAAC;;","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 {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the radio is disabled. */\n isDisabled: boolean,\n /** Whether the radio is currently selected. */\n isSelected: boolean\n}\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} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(mergeProps(props, {\n onFocus: () => state.setLastFocusedValue(value)\n }), ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange,\n 'aria-describedby': [\n state.validationState === 'invalid' ? radioGroupErrorMessageIds.get(state) : null,\n radioGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\nexport const radioGroupDescriptionIds = new WeakMap<RadioGroupState, string>();\nexport const radioGroupErrorMessageIds = new WeakMap<RadioGroupState, string>();\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaRadioGroupProps} from '@react-types/radio';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: DOMAttributes,\n /** Props for the radio group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the radio group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the radio group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a radio group component.\n * Radio groups allow users to select a single item from a list of mutually exclusive options.\n * @param props - Props for the radio group.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n */\nexport function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria {\n let {\n name,\n validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Radio group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n radioGroupDescriptionIds.set(state, descriptionProps.id);\n radioGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // When the radio group loses focus, reset the focusable radio to null if\n // there is no selection. This allows tabbing into the group from either\n // direction to go to the first or last radio.\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\n });\n\n let onKeyDown = (e) => {\n let nextDir;\n switch (e.key) {\n case 'ArrowRight':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'prev';\n } else {\n nextDir = 'next';\n }\n break;\n case 'ArrowLeft':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'next';\n } else {\n nextDir = 'prev';\n }\n break;\n case 'ArrowDown':\n nextDir = 'next';\n break;\n case 'ArrowUp':\n nextDir = 'prev';\n break;\n default:\n return;\n }\n e.preventDefault();\n let walker = getFocusableTreeWalker(e.currentTarget, {from: e.target});\n let nextElem;\n if (nextDir === 'next') {\n nextElem = walker.nextNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.firstChild();\n }\n } else {\n nextElem = walker.previousNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.lastChild();\n }\n }\n if (nextElem) {\n // Call focus on nextElem so that keyboard navigation scrolls the radio into view\n nextElem.focus();\n state.setSelectedValue(nextElem.value);\n }\n };\n\n let groupName = useId(name);\n radioGroupNames.set(state, groupName);\n\n return {\n radioGroupProps: mergeProps(domProps, {\n // https://www.w3.org/TR/wai-aria-1.2/#radiogroup\n role: 'radiogroup',\n onKeyDown,\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n 'aria-disabled': isDisabled || undefined,\n 'aria-orientation': orientation,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;ACZA;;;;;;;;;;CAUC,GAED,AAEO,MAAM,4CAAkB,IAAI;AAC5B,MAAM,4CAA2B,IAAI;AACrC,MAAM,4CAA4B,IAAI;;;;;ADoBtC,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAgC,EAAa;IACnH,IAAI,SACF,MAAK,YACL,SAAQ,E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,EAAE;YAAC,MAAM,EAAE,MAAM;QAAA;QACpE,IAAI;QACJ,IAAI,YAAY,QAAQ;YACtB,WAAW,OAAO,QAAQ;YAC1B,IAAI,CAAC,UAAU;gBACb,OAAO,WAAW,GAAG,EAAE,aAAa;gBACpC,WAAW,OAAO,UAAU;YAC9B,CAAC;QACH,OAAO;YACL,WAAW,OAAO,YAAY;YAC9B,IAAI,CAAC,UAAU;gBACb,OAAO,WAAW,GAAG,EAAE,aAAa;gBACpC,WAAW,OAAO,SAAS;YAC7B,CAAC;QACH,CAAC;QACD,IAAI,UAAU;YACZ,iFAAiF;YACjF,SAAS,KAAK;YACd,MAAM,gBAAgB,CAAC,SAAS,KAAK;QACvC,CAAC;IACH;IAEA,IAAI,YAAY,CAAA,GAAA,YAAI,EAAE;IACtB,CAAA,GAAA,yCAAc,EAAE,GAAG,CAAC,OAAO;IAE3B,OAAO;QACL,iBAAiB,CAAA,GAAA,iBAAU,AAAD,EAAE,UAAU;YACpC,iDAAiD;YACjD,MAAM;uBACN;YACA,gBAAgB,oBAAoB,aAAa;YACjD,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,oBAAoB;YACpB,GAAG,UAAU;YACb,GAAG,gBAAgB;QACrB;oBACA;0BACA;2BACA;IACF;AACF;","sources":["packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/utils.ts","packages/@react-aria/radio/src/useRadioGroup.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the radio is disabled. */\n isDisabled: boolean,\n /** Whether the radio is currently selected. */\n isSelected: boolean\n}\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} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(mergeProps(props, {\n onFocus: () => state.setLastFocusedValue(value)\n }), ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange,\n 'aria-describedby': [\n state.validationState === 'invalid' ? radioGroupErrorMessageIds.get(state) : null,\n radioGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\nexport const radioGroupDescriptionIds = new WeakMap<RadioGroupState, string>();\nexport const radioGroupErrorMessageIds = new WeakMap<RadioGroupState, string>();\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaRadioGroupProps} from '@react-types/radio';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupDescriptionIds, radioGroupErrorMessageIds, radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: DOMAttributes,\n /** Props for the radio group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the radio group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the radio group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a radio group component.\n * Radio groups allow users to select a single item from a list of mutually exclusive options.\n * @param props - Props for the radio group.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n */\nexport function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria {\n let {\n name,\n validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Radio group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n radioGroupDescriptionIds.set(state, descriptionProps.id);\n radioGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // When the radio group loses focus, reset the focusable radio to null if\n // there is no selection. This allows tabbing into the group from either\n // direction to go to the first or last radio.\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\n });\n\n let onKeyDown = (e) => {\n let nextDir;\n switch (e.key) {\n case 'ArrowRight':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'prev';\n } else {\n nextDir = 'next';\n }\n break;\n case 'ArrowLeft':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'next';\n } else {\n nextDir = 'prev';\n }\n break;\n case 'ArrowDown':\n nextDir = 'next';\n break;\n case 'ArrowUp':\n nextDir = 'prev';\n break;\n default:\n return;\n }\n e.preventDefault();\n let walker = getFocusableTreeWalker(e.currentTarget, {from: e.target});\n let nextElem;\n if (nextDir === 'next') {\n nextElem = walker.nextNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.firstChild();\n }\n } else {\n nextElem = walker.previousNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.lastChild();\n }\n }\n if (nextElem) {\n // Call focus on nextElem so that keyboard navigation scrolls the radio into view\n nextElem.focus();\n state.setSelectedValue(nextElem.value);\n }\n };\n\n let groupName = useId(name);\n radioGroupNames.set(state, groupName);\n\n return {\n radioGroupProps: mergeProps(domProps, {\n // https://www.w3.org/TR/wai-aria-1.2/#radiogroup\n role: 'radiogroup',\n onKeyDown,\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n 'aria-disabled': isDisabled || undefined,\n 'aria-orientation': orientation,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/radio",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
8
13
|
"types": "dist/types.d.ts",
|
|
9
14
|
"source": "src/index.ts",
|
|
10
15
|
"files": [
|
|
@@ -17,15 +22,15 @@
|
|
|
17
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
18
23
|
},
|
|
19
24
|
"dependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@react-aria/
|
|
22
|
-
"@react-aria/
|
|
23
|
-
"@react-aria/
|
|
24
|
-
"@react-aria/
|
|
25
|
-
"@react-
|
|
26
|
-
"@react-
|
|
27
|
-
"@react-types/
|
|
28
|
-
"@
|
|
25
|
+
"@react-aria/focus": "^3.11.0",
|
|
26
|
+
"@react-aria/i18n": "^3.7.0",
|
|
27
|
+
"@react-aria/interactions": "^3.14.0",
|
|
28
|
+
"@react-aria/label": "^3.5.0",
|
|
29
|
+
"@react-aria/utils": "^3.15.0",
|
|
30
|
+
"@react-stately/radio": "^3.7.0",
|
|
31
|
+
"@react-types/radio": "^3.4.0",
|
|
32
|
+
"@react-types/shared": "^3.17.0",
|
|
33
|
+
"@swc/helpers": "^0.4.14"
|
|
29
34
|
},
|
|
30
35
|
"peerDependencies": {
|
|
31
36
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
@@ -33,5 +38,5 @@
|
|
|
33
38
|
"publishConfig": {
|
|
34
39
|
"access": "public"
|
|
35
40
|
},
|
|
36
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
|
|
37
42
|
}
|