@react-aria/radio 3.1.4 → 3.1.8
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/main.js +150 -217
- package/dist/main.js.map +1 -1
- package/dist/module.js +142 -199
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +1 -11
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/useRadio.ts +1 -18
package/dist/main.js
CHANGED
|
@@ -1,238 +1,171 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} = require("@react-aria/interactions");
|
|
13
|
-
|
|
14
|
-
var {
|
|
15
|
-
useFocusable,
|
|
16
|
-
getFocusableTreeWalker
|
|
17
|
-
} = require("@react-aria/focus");
|
|
18
|
-
|
|
19
|
-
var {
|
|
20
|
-
filterDOMProps,
|
|
21
|
-
mergeProps,
|
|
22
|
-
useId
|
|
23
|
-
} = require("@react-aria/utils");
|
|
24
|
-
|
|
25
|
-
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
|
|
26
|
-
|
|
27
|
-
function $parcel$interopDefault(a) {
|
|
28
|
-
return a && a.__esModule ? a.default : a;
|
|
29
|
-
}
|
|
1
|
+
var $jfuDl$reactariautils = require("@react-aria/utils");
|
|
2
|
+
var $jfuDl$reactariafocus = require("@react-aria/focus");
|
|
3
|
+
var $jfuDl$reactariainteractions = require("@react-aria/interactions");
|
|
4
|
+
var $jfuDl$reactarialabel = require("@react-aria/label");
|
|
5
|
+
var $jfuDl$reactariai18n = require("@react-aria/i18n");
|
|
6
|
+
|
|
7
|
+
function $parcel$exportWildcard(dest, source) {
|
|
8
|
+
Object.keys(source).forEach(function(key) {
|
|
9
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
30
12
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
38
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
39
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
40
|
-
* governing permissions and limitations under the License.
|
|
41
|
-
*/
|
|
42
|
-
const $d9900fa75ce48f638bc47fd54695f66$export$radioGroupNames = new WeakMap();
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Provides the behavior and accessibility implementation for an individual
|
|
46
|
-
* radio button in a radio group.
|
|
47
|
-
* @param props - Props for the radio.
|
|
48
|
-
* @param state - State for the radio group, as returned by `useRadioGroupState`.
|
|
49
|
-
* @param ref - Ref to the HTML input element.
|
|
50
|
-
*/
|
|
51
|
-
function useRadio(props, state, ref) {
|
|
52
|
-
let {
|
|
53
|
-
value,
|
|
54
|
-
isRequired,
|
|
55
|
-
children,
|
|
56
|
-
'aria-label': ariaLabel,
|
|
57
|
-
'aria-labelledby': ariaLabelledby
|
|
58
|
-
} = props;
|
|
59
|
-
const isDisabled = props.isDisabled || state.isDisabled; // Individual radios cannot be readonly
|
|
60
|
-
|
|
61
|
-
const isReadOnly = state.isReadOnly;
|
|
62
|
-
let hasChildren = children != null;
|
|
63
|
-
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
64
|
-
|
|
65
|
-
if (!hasChildren && !hasAriaLabel) {
|
|
66
|
-
console.warn('If you do not provide children, you must specify an aria-label for accessibility');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
let checked = state.selectedValue === value;
|
|
70
|
-
|
|
71
|
-
let onChange = e => {
|
|
72
|
-
e.stopPropagation();
|
|
73
|
-
state.setSelectedValue(value);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
let {
|
|
77
|
-
pressProps
|
|
78
|
-
} = usePress({
|
|
79
|
-
isDisabled
|
|
80
|
-
});
|
|
81
|
-
let {
|
|
82
|
-
focusableProps
|
|
83
|
-
} = useFocusable(mergeProps(props, {
|
|
84
|
-
onFocus: () => state.setLastFocusedValue(value)
|
|
85
|
-
}), ref);
|
|
86
|
-
let interactions = mergeProps(pressProps, focusableProps);
|
|
87
|
-
let domProps = filterDOMProps(props, {
|
|
88
|
-
labelable: true
|
|
13
|
+
Object.defineProperty(dest, key, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return source[key];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
89
19
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
inputProps: mergeProps(domProps, _babelRuntimeHelpersExtends({}, interactions, {
|
|
98
|
-
type: 'radio',
|
|
99
|
-
name: $d9900fa75ce48f638bc47fd54695f66$export$radioGroupNames.get(state),
|
|
100
|
-
tabIndex,
|
|
101
|
-
disabled: isDisabled,
|
|
102
|
-
'aria-readonly': isReadOnly || undefined,
|
|
103
|
-
required: isRequired,
|
|
104
|
-
checked,
|
|
105
|
-
value,
|
|
106
|
-
onChange
|
|
107
|
-
}))
|
|
108
|
-
};
|
|
20
|
+
|
|
21
|
+
return dest;
|
|
22
|
+
}
|
|
23
|
+
function $parcel$export(e, n, v, s) {
|
|
24
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
109
25
|
}
|
|
26
|
+
var $338761e45a036ef1$exports = {};
|
|
110
27
|
|
|
111
|
-
exports
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Provides the behavior and accessibility implementation for a radio group component.
|
|
115
|
-
* Radio groups allow users to select a single item from a list of mutually exclusive options.
|
|
116
|
-
* @param props - Props for the radio group.
|
|
117
|
-
* @param state - State for the radio group, as returned by `useRadioGroupState`.
|
|
118
|
-
*/
|
|
119
|
-
function useRadioGroup(props, state) {
|
|
120
|
-
let {
|
|
121
|
-
name,
|
|
122
|
-
validationState,
|
|
123
|
-
isReadOnly,
|
|
124
|
-
isRequired,
|
|
125
|
-
isDisabled,
|
|
126
|
-
orientation = 'vertical'
|
|
127
|
-
} = props;
|
|
128
|
-
let {
|
|
129
|
-
direction
|
|
130
|
-
} = useLocale();
|
|
131
|
-
let {
|
|
132
|
-
labelProps,
|
|
133
|
-
fieldProps
|
|
134
|
-
} = useLabel(_babelRuntimeHelpersExtends({}, props, {
|
|
135
|
-
// Radio group is not an HTML input element so it
|
|
136
|
-
// shouldn't be labeled by a <label> element.
|
|
137
|
-
labelElementType: 'span'
|
|
138
|
-
}));
|
|
139
|
-
let domProps = filterDOMProps(props, {
|
|
140
|
-
labelable: true
|
|
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
|
-
|
|
145
|
-
let {
|
|
146
|
-
focusWithinProps
|
|
147
|
-
} = useFocusWithin({
|
|
148
|
-
onBlurWithin() {
|
|
149
|
-
if (!state.selectedValue) {
|
|
150
|
-
state.setLastFocusedValue(null);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
28
|
+
$parcel$export($338761e45a036ef1$exports, "useRadio", () => $338761e45a036ef1$export$37b0961d2f4751e2);
|
|
153
29
|
|
|
154
|
-
|
|
30
|
+
const $a1e0bad4e707cb8d$export$3b7b268d09480394 = new WeakMap();
|
|
155
31
|
|
|
156
|
-
let onKeyDown = e => {
|
|
157
|
-
let nextDir;
|
|
158
32
|
|
|
159
|
-
switch (e.key) {
|
|
160
|
-
case 'ArrowRight':
|
|
161
|
-
if (direction === 'rtl' && orientation !== 'vertical') {
|
|
162
|
-
nextDir = 'prev';
|
|
163
|
-
} else {
|
|
164
|
-
nextDir = 'next';
|
|
165
|
-
}
|
|
166
33
|
|
|
167
|
-
break;
|
|
168
34
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
35
|
+
function $338761e45a036ef1$export$37b0961d2f4751e2(props, state, ref) {
|
|
36
|
+
let { value: value , children: children , 'aria-label': ariaLabel , 'aria-labelledby': ariaLabelledby } = props;
|
|
37
|
+
const isDisabled = props.isDisabled || state.isDisabled;
|
|
38
|
+
let hasChildren = children != null;
|
|
39
|
+
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
40
|
+
if (!hasChildren && !hasAriaLabel) console.warn('If you do not provide children, you must specify an aria-label for accessibility');
|
|
41
|
+
let checked = state.selectedValue === value;
|
|
42
|
+
let onChange = (e)=>{
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
state.setSelectedValue(value);
|
|
45
|
+
};
|
|
46
|
+
let { pressProps: pressProps } = $jfuDl$reactariainteractions.usePress({
|
|
47
|
+
isDisabled: isDisabled
|
|
48
|
+
});
|
|
49
|
+
let { focusableProps: focusableProps } = $jfuDl$reactariafocus.useFocusable($jfuDl$reactariautils.mergeProps(props, {
|
|
50
|
+
onFocus: ()=>state.setLastFocusedValue(value)
|
|
51
|
+
}), ref);
|
|
52
|
+
let interactions = $jfuDl$reactariautils.mergeProps(pressProps, focusableProps);
|
|
53
|
+
let domProps = $jfuDl$reactariautils.filterDOMProps(props, {
|
|
54
|
+
labelable: true
|
|
55
|
+
});
|
|
56
|
+
let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;
|
|
57
|
+
if (isDisabled) tabIndex = undefined;
|
|
58
|
+
return {
|
|
59
|
+
inputProps: $jfuDl$reactariautils.mergeProps(domProps, {
|
|
60
|
+
...interactions,
|
|
61
|
+
type: 'radio',
|
|
62
|
+
name: $a1e0bad4e707cb8d$export$3b7b268d09480394.get(state),
|
|
63
|
+
tabIndex: tabIndex,
|
|
64
|
+
disabled: isDisabled,
|
|
65
|
+
checked: checked,
|
|
66
|
+
value: value,
|
|
67
|
+
onChange: onChange
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
}
|
|
175
71
|
|
|
176
|
-
break;
|
|
177
72
|
|
|
178
|
-
|
|
179
|
-
nextDir = 'next';
|
|
180
|
-
break;
|
|
73
|
+
var $dab8d6446eaa2014$exports = {};
|
|
181
74
|
|
|
182
|
-
|
|
183
|
-
nextDir = 'prev';
|
|
184
|
-
break;
|
|
75
|
+
$parcel$export($dab8d6446eaa2014$exports, "useRadioGroup", () => $dab8d6446eaa2014$export$62b9571f283ff5c2);
|
|
185
76
|
|
|
186
|
-
default:
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
77
|
|
|
190
|
-
e.preventDefault();
|
|
191
|
-
let walker = getFocusableTreeWalker(e.currentTarget, {
|
|
192
|
-
from: e.target
|
|
193
|
-
});
|
|
194
|
-
let nextElem;
|
|
195
78
|
|
|
196
|
-
if (nextDir === 'next') {
|
|
197
|
-
nextElem = walker.nextNode();
|
|
198
79
|
|
|
199
|
-
if (!nextElem) {
|
|
200
|
-
walker.currentNode = e.currentTarget;
|
|
201
|
-
nextElem = walker.firstChild();
|
|
202
|
-
}
|
|
203
|
-
} else {
|
|
204
|
-
nextElem = walker.previousNode();
|
|
205
80
|
|
|
206
|
-
if (!nextElem) {
|
|
207
|
-
walker.currentNode = e.currentTarget;
|
|
208
|
-
nextElem = walker.lastChild();
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
81
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
82
|
+
function $dab8d6446eaa2014$export$62b9571f283ff5c2(props, state) {
|
|
83
|
+
let { name: name , validationState: validationState , isReadOnly: isReadOnly , isRequired: isRequired , isDisabled: isDisabled , orientation: orientation = 'vertical' } = props;
|
|
84
|
+
let { direction: direction } = $jfuDl$reactariai18n.useLocale();
|
|
85
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = $jfuDl$reactarialabel.useLabel({
|
|
86
|
+
...props,
|
|
87
|
+
// Radio group is not an HTML input element so it
|
|
88
|
+
// shouldn't be labeled by a <label> element.
|
|
89
|
+
labelElementType: 'span'
|
|
90
|
+
});
|
|
91
|
+
let domProps = $jfuDl$reactariautils.filterDOMProps(props, {
|
|
92
|
+
labelable: true
|
|
93
|
+
});
|
|
94
|
+
// When the radio group loses focus, reset the focusable radio to null if
|
|
95
|
+
// there is no selection. This allows tabbing into the group from either
|
|
96
|
+
// direction to go to the first or last radio.
|
|
97
|
+
let { focusWithinProps: focusWithinProps } = $jfuDl$reactariainteractions.useFocusWithin({
|
|
98
|
+
onBlurWithin () {
|
|
99
|
+
if (!state.selectedValue) state.setLastFocusedValue(null);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
let onKeyDown = (e)=>{
|
|
103
|
+
let nextDir;
|
|
104
|
+
switch(e.key){
|
|
105
|
+
case 'ArrowRight':
|
|
106
|
+
if (direction === 'rtl' && orientation !== 'vertical') nextDir = 'prev';
|
|
107
|
+
else nextDir = 'next';
|
|
108
|
+
break;
|
|
109
|
+
case 'ArrowLeft':
|
|
110
|
+
if (direction === 'rtl' && orientation !== 'vertical') nextDir = 'next';
|
|
111
|
+
else nextDir = 'prev';
|
|
112
|
+
break;
|
|
113
|
+
case 'ArrowDown':
|
|
114
|
+
nextDir = 'next';
|
|
115
|
+
break;
|
|
116
|
+
case 'ArrowUp':
|
|
117
|
+
nextDir = 'prev';
|
|
118
|
+
break;
|
|
119
|
+
default:
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
let walker = $jfuDl$reactariafocus.getFocusableTreeWalker(e.currentTarget, {
|
|
124
|
+
from: e.target
|
|
125
|
+
});
|
|
126
|
+
let nextElem;
|
|
127
|
+
if (nextDir === 'next') {
|
|
128
|
+
nextElem = walker.nextNode();
|
|
129
|
+
if (!nextElem) {
|
|
130
|
+
walker.currentNode = e.currentTarget;
|
|
131
|
+
nextElem = walker.firstChild();
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
nextElem = walker.previousNode();
|
|
135
|
+
if (!nextElem) {
|
|
136
|
+
walker.currentNode = e.currentTarget;
|
|
137
|
+
nextElem = walker.lastChild();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (nextElem) {
|
|
141
|
+
// Call focus on nextElem so that keyboard navigation scrolls the radio into view
|
|
142
|
+
nextElem.focus();
|
|
143
|
+
state.setSelectedValue(nextElem.value);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
let groupName = $jfuDl$reactariautils.useId(name);
|
|
147
|
+
$a1e0bad4e707cb8d$export$3b7b268d09480394.set(state, groupName);
|
|
148
|
+
return {
|
|
149
|
+
radioGroupProps: $jfuDl$reactariautils.mergeProps(domProps, {
|
|
150
|
+
// https://www.w3.org/TR/wai-aria-1.2/#radiogroup
|
|
151
|
+
role: 'radiogroup',
|
|
152
|
+
onKeyDown: onKeyDown,
|
|
153
|
+
'aria-invalid': validationState === 'invalid' || undefined,
|
|
154
|
+
'aria-errormessage': props['aria-errormessage'],
|
|
155
|
+
'aria-readonly': isReadOnly || undefined,
|
|
156
|
+
'aria-required': isRequired || undefined,
|
|
157
|
+
'aria-disabled': isDisabled || undefined,
|
|
158
|
+
'aria-orientation': orientation,
|
|
159
|
+
...fieldProps,
|
|
160
|
+
...focusWithinProps
|
|
161
|
+
}),
|
|
162
|
+
labelProps: labelProps
|
|
163
|
+
};
|
|
235
164
|
}
|
|
236
165
|
|
|
237
|
-
|
|
166
|
+
|
|
167
|
+
$parcel$exportWildcard(module.exports, $338761e45a036ef1$exports);
|
|
168
|
+
$parcel$exportWildcard(module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ages/@react-aria/radio/src/useRadio.ts","./packages/@react-aria/radio/src/useRadioGroup.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\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>();\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 {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\ninterface RadioAriaProps extends AriaRadioProps {\n /**\n * Whether the Radio is required. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required).\n */\n isRequired?: boolean,\n /**\n * Whether the Radio can be interacted with but cannot have its selection state changed.\n */\n isReadOnly?: boolean\n}\n\ninterface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLElement>\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: RadioAriaProps, state: RadioGroupState, ref: RefObject<HTMLElement>): RadioAria {\n let {\n value,\n isRequired,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby\n } = props;\n\n const isDisabled = props.isDisabled || state.isDisabled;\n \n // Individual radios cannot be readonly\n const isReadOnly = state.isReadOnly;\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 'aria-readonly': isReadOnly || undefined,\n required: isRequired,\n checked,\n value,\n onChange\n })\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 {AriaRadioGroupProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes} from 'react';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: HTMLAttributes<HTMLElement>,\n /** Props for the radio group's visible label (if any). */\n labelProps: HTMLAttributes<HTMLElement>\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} = useLabel({\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\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 };\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","radioGroupNames","WeakMap","useRadio","props","state","ref","value","isRequired","children","ariaLabel","ariaLabelledby","isDisabled","isReadOnly","hasChildren","hasAriaLabel","console","warn","checked","selectedValue","onChange","e","stopPropagation","setSelectedValue","pressProps","usePress","focusableProps","useFocusable","mergeProps","onFocus","setLastFocusedValue","interactions","domProps","filterDOMProps","labelable","tabIndex","lastFocusedValue","undefined","inputProps","type","name","get","disabled","required","useRadioGroup","validationState","orientation","direction","useLocale","labelProps","fieldProps","useLabel","labelElementType","focusWithinProps","useFocusWithin","onBlurWithin","onKeyDown","nextDir","key","preventDefault","walker","getFocusableTreeWalker","currentTarget","from","target","nextElem","nextNode","currentNode","firstChild","previousNode","lastChild","focus","groupName","useId","set","radioGroupProps","role"],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEcO,KAAK,CAAC,yCAAe,GAAG,GAAG,CAAC,OAAO;;;;;SDkB1B,yCAAQ,CAAC,KAAqB,EAAE,KAAsB,EAAE,GAA2B,EAAa,CAAC;IAC/G,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,CAAC,UAAU;IAEvD,GAAG,CAAC,WAAW,GAAG,QAAQ,IAAI,IAAI;IAClC,GAAG,CAAC,YAAY,GAAG,SAAS,IAAI,IAAI,IAAI,cAAc,IAAI,IAAI;IAC9D,EAAE,GAAG,WAAW,KAAK,YAAY,EAC/B,OAAO,CAAC,IAAI,CAAC,CAAkF;IAGjG,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,aAAa,KAAK,KAAK;IAE3C,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAK,CAAC;QACrB,CAAC,CAAC,eAAe;QACjB,KAAK,CAAC,gBAAgB,CAAC,KAAK;IAC9B,CAAC;IAED,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,qCAAQ,CAAC,CAAC;oBAC3B,UAAU;IACZ,CAAC;IAED,GAAG,CAAC,CAAC,iBAAA,cA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AAa;gBACpC,QAAQ,GAAG,MAAM,CAAC,UAAU;YAC9B,CAAC;QACH,CAAC,MAAM,CAAC;YACN,QAAQ,GAAG,MAAM,CAAC,YAAY;YAC9B,EAAE,GAAG,QAAQ,EAAE,CAAC;gBACd,MAAM,CAAC,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,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;IACZ,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 */\n\nexport * from './useRadio';\nexport * 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 {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\ninterface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLElement>\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<HTMLElement>): 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 })\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>();\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 {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes} from 'react';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: HTMLAttributes<HTMLElement>,\n /** Props for the radio group's visible label (if any). */\n labelProps: HTMLAttributes<HTMLElement>\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} = useLabel({\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\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 };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,211 +1,154 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { usePress, useFocusWithin } from "@react-aria/interactions";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
const $a7d0e5df3871fb1bfdb437cffdabab2a$export$radioGroupNames = new WeakMap();
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Provides the behavior and accessibility implementation for an individual
|
|
23
|
-
* radio button in a radio group.
|
|
24
|
-
* @param props - Props for the radio.
|
|
25
|
-
* @param state - State for the radio group, as returned by `useRadioGroupState`.
|
|
26
|
-
* @param ref - Ref to the HTML input element.
|
|
27
|
-
*/
|
|
28
|
-
export function useRadio(props, state, ref) {
|
|
29
|
-
let {
|
|
30
|
-
value,
|
|
31
|
-
isRequired,
|
|
32
|
-
children,
|
|
33
|
-
'aria-label': ariaLabel,
|
|
34
|
-
'aria-labelledby': ariaLabelledby
|
|
35
|
-
} = props;
|
|
36
|
-
const isDisabled = props.isDisabled || state.isDisabled; // Individual radios cannot be readonly
|
|
37
|
-
|
|
38
|
-
const isReadOnly = state.isReadOnly;
|
|
39
|
-
let hasChildren = children != null;
|
|
40
|
-
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
41
|
-
|
|
42
|
-
if (!hasChildren && !hasAriaLabel) {
|
|
43
|
-
console.warn('If you do not provide children, you must specify an aria-label for accessibility');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
let checked = state.selectedValue === value;
|
|
47
|
-
|
|
48
|
-
let onChange = e => {
|
|
49
|
-
e.stopPropagation();
|
|
50
|
-
state.setSelectedValue(value);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
let {
|
|
54
|
-
pressProps
|
|
55
|
-
} = usePress({
|
|
56
|
-
isDisabled
|
|
57
|
-
});
|
|
58
|
-
let {
|
|
59
|
-
focusableProps
|
|
60
|
-
} = useFocusable(mergeProps(props, {
|
|
61
|
-
onFocus: () => state.setLastFocusedValue(value)
|
|
62
|
-
}), ref);
|
|
63
|
-
let interactions = mergeProps(pressProps, focusableProps);
|
|
64
|
-
let domProps = filterDOMProps(props, {
|
|
65
|
-
labelable: true
|
|
66
|
-
});
|
|
67
|
-
let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;
|
|
68
|
-
|
|
69
|
-
if (isDisabled) {
|
|
70
|
-
tabIndex = undefined;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
inputProps: mergeProps(domProps, _babelRuntimeHelpersEsmExtends({}, interactions, {
|
|
75
|
-
type: 'radio',
|
|
76
|
-
name: $a7d0e5df3871fb1bfdb437cffdabab2a$export$radioGroupNames.get(state),
|
|
77
|
-
tabIndex,
|
|
78
|
-
disabled: isDisabled,
|
|
79
|
-
'aria-readonly': isReadOnly || undefined,
|
|
80
|
-
required: isRequired,
|
|
81
|
-
checked,
|
|
82
|
-
value,
|
|
83
|
-
onChange
|
|
84
|
-
}))
|
|
85
|
-
};
|
|
1
|
+
import {mergeProps as $2aKPr$mergeProps, filterDOMProps as $2aKPr$filterDOMProps, useId as $2aKPr$useId} from "@react-aria/utils";
|
|
2
|
+
import {useFocusable as $2aKPr$useFocusable, getFocusableTreeWalker as $2aKPr$getFocusableTreeWalker} from "@react-aria/focus";
|
|
3
|
+
import {usePress as $2aKPr$usePress, useFocusWithin as $2aKPr$useFocusWithin} from "@react-aria/interactions";
|
|
4
|
+
import {useLabel as $2aKPr$useLabel} from "@react-aria/label";
|
|
5
|
+
import {useLocale as $2aKPr$useLocale} from "@react-aria/i18n";
|
|
6
|
+
|
|
7
|
+
function $parcel$export(e, n, v, s) {
|
|
8
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
86
9
|
}
|
|
10
|
+
var $2cd2cc131ce1e951$exports = {};
|
|
87
11
|
|
|
88
|
-
|
|
89
|
-
* Provides the behavior and accessibility implementation for a radio group component.
|
|
90
|
-
* Radio groups allow users to select a single item from a list of mutually exclusive options.
|
|
91
|
-
* @param props - Props for the radio group.
|
|
92
|
-
* @param state - State for the radio group, as returned by `useRadioGroupState`.
|
|
93
|
-
*/
|
|
94
|
-
export function useRadioGroup(props, state) {
|
|
95
|
-
let {
|
|
96
|
-
name,
|
|
97
|
-
validationState,
|
|
98
|
-
isReadOnly,
|
|
99
|
-
isRequired,
|
|
100
|
-
isDisabled,
|
|
101
|
-
orientation = 'vertical'
|
|
102
|
-
} = props;
|
|
103
|
-
let {
|
|
104
|
-
direction
|
|
105
|
-
} = useLocale();
|
|
106
|
-
let {
|
|
107
|
-
labelProps,
|
|
108
|
-
fieldProps
|
|
109
|
-
} = useLabel(_babelRuntimeHelpersEsmExtends({}, 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
|
-
let domProps = filterDOMProps(props, {
|
|
115
|
-
labelable: true
|
|
116
|
-
}); // When the radio group loses focus, reset the focusable radio to null if
|
|
117
|
-
// there is no selection. This allows tabbing into the group from either
|
|
118
|
-
// direction to go to the first or last radio.
|
|
119
|
-
|
|
120
|
-
let {
|
|
121
|
-
focusWithinProps
|
|
122
|
-
} = useFocusWithin({
|
|
123
|
-
onBlurWithin() {
|
|
124
|
-
if (!state.selectedValue) {
|
|
125
|
-
state.setLastFocusedValue(null);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
let onKeyDown = e => {
|
|
132
|
-
let nextDir;
|
|
133
|
-
|
|
134
|
-
switch (e.key) {
|
|
135
|
-
case 'ArrowRight':
|
|
136
|
-
if (direction === 'rtl' && orientation !== 'vertical') {
|
|
137
|
-
nextDir = 'prev';
|
|
138
|
-
} else {
|
|
139
|
-
nextDir = 'next';
|
|
140
|
-
}
|
|
12
|
+
$parcel$export($2cd2cc131ce1e951$exports, "useRadio", () => $2cd2cc131ce1e951$export$37b0961d2f4751e2);
|
|
141
13
|
|
|
142
|
-
|
|
14
|
+
const $a249568f27a21ba9$export$3b7b268d09480394 = new WeakMap();
|
|
143
15
|
|
|
144
|
-
case 'ArrowLeft':
|
|
145
|
-
if (direction === 'rtl' && orientation !== 'vertical') {
|
|
146
|
-
nextDir = 'next';
|
|
147
|
-
} else {
|
|
148
|
-
nextDir = 'prev';
|
|
149
|
-
}
|
|
150
16
|
|
|
151
|
-
break;
|
|
152
17
|
|
|
153
|
-
case 'ArrowDown':
|
|
154
|
-
nextDir = 'next';
|
|
155
|
-
break;
|
|
156
18
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
19
|
+
function $2cd2cc131ce1e951$export$37b0961d2f4751e2(props, state, ref) {
|
|
20
|
+
let { value: value , children: children , 'aria-label': ariaLabel , 'aria-labelledby': ariaLabelledby } = props;
|
|
21
|
+
const isDisabled = props.isDisabled || state.isDisabled;
|
|
22
|
+
let hasChildren = children != null;
|
|
23
|
+
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
24
|
+
if (!hasChildren && !hasAriaLabel) console.warn('If you do not provide children, you must specify an aria-label for accessibility');
|
|
25
|
+
let checked = state.selectedValue === value;
|
|
26
|
+
let onChange = (e)=>{
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
state.setSelectedValue(value);
|
|
29
|
+
};
|
|
30
|
+
let { pressProps: pressProps } = $2aKPr$usePress({
|
|
31
|
+
isDisabled: isDisabled
|
|
32
|
+
});
|
|
33
|
+
let { focusableProps: focusableProps } = $2aKPr$useFocusable($2aKPr$mergeProps(props, {
|
|
34
|
+
onFocus: ()=>state.setLastFocusedValue(value)
|
|
35
|
+
}), ref);
|
|
36
|
+
let interactions = $2aKPr$mergeProps(pressProps, focusableProps);
|
|
37
|
+
let domProps = $2aKPr$filterDOMProps(props, {
|
|
38
|
+
labelable: true
|
|
39
|
+
});
|
|
40
|
+
let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;
|
|
41
|
+
if (isDisabled) tabIndex = undefined;
|
|
42
|
+
return {
|
|
43
|
+
inputProps: $2aKPr$mergeProps(domProps, {
|
|
44
|
+
...interactions,
|
|
45
|
+
type: 'radio',
|
|
46
|
+
name: $a249568f27a21ba9$export$3b7b268d09480394.get(state),
|
|
47
|
+
tabIndex: tabIndex,
|
|
48
|
+
disabled: isDisabled,
|
|
49
|
+
checked: checked,
|
|
50
|
+
value: value,
|
|
51
|
+
onChange: onChange
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
var $b5bb90da5b40a472$exports = {};
|
|
58
|
+
|
|
59
|
+
$parcel$export($b5bb90da5b40a472$exports, "useRadioGroup", () => $b5bb90da5b40a472$export$62b9571f283ff5c2);
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
160
63
|
|
|
161
|
-
default:
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
64
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
65
|
+
|
|
66
|
+
function $b5bb90da5b40a472$export$62b9571f283ff5c2(props, state) {
|
|
67
|
+
let { name: name , validationState: validationState , isReadOnly: isReadOnly , isRequired: isRequired , isDisabled: isDisabled , orientation: orientation = 'vertical' } = props;
|
|
68
|
+
let { direction: direction } = $2aKPr$useLocale();
|
|
69
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = $2aKPr$useLabel({
|
|
70
|
+
...props,
|
|
71
|
+
// Radio group is not an HTML input element so it
|
|
72
|
+
// shouldn't be labeled by a <label> element.
|
|
73
|
+
labelElementType: 'span'
|
|
74
|
+
});
|
|
75
|
+
let domProps = $2aKPr$filterDOMProps(props, {
|
|
76
|
+
labelable: true
|
|
77
|
+
});
|
|
78
|
+
// When the radio group loses focus, reset the focusable radio to null if
|
|
79
|
+
// there is no selection. This allows tabbing into the group from either
|
|
80
|
+
// direction to go to the first or last radio.
|
|
81
|
+
let { focusWithinProps: focusWithinProps } = $2aKPr$useFocusWithin({
|
|
82
|
+
onBlurWithin () {
|
|
83
|
+
if (!state.selectedValue) state.setLastFocusedValue(null);
|
|
84
|
+
}
|
|
168
85
|
});
|
|
169
|
-
let
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
86
|
+
let onKeyDown = (e)=>{
|
|
87
|
+
let nextDir;
|
|
88
|
+
switch(e.key){
|
|
89
|
+
case 'ArrowRight':
|
|
90
|
+
if (direction === 'rtl' && orientation !== 'vertical') nextDir = 'prev';
|
|
91
|
+
else nextDir = 'next';
|
|
92
|
+
break;
|
|
93
|
+
case 'ArrowLeft':
|
|
94
|
+
if (direction === 'rtl' && orientation !== 'vertical') nextDir = 'next';
|
|
95
|
+
else nextDir = 'prev';
|
|
96
|
+
break;
|
|
97
|
+
case 'ArrowDown':
|
|
98
|
+
nextDir = 'next';
|
|
99
|
+
break;
|
|
100
|
+
case 'ArrowUp':
|
|
101
|
+
nextDir = 'prev';
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
let walker = $2aKPr$getFocusableTreeWalker(e.currentTarget, {
|
|
108
|
+
from: e.target
|
|
109
|
+
});
|
|
110
|
+
let nextElem;
|
|
111
|
+
if (nextDir === 'next') {
|
|
112
|
+
nextElem = walker.nextNode();
|
|
113
|
+
if (!nextElem) {
|
|
114
|
+
walker.currentNode = e.currentTarget;
|
|
115
|
+
nextElem = walker.firstChild();
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
nextElem = walker.previousNode();
|
|
119
|
+
if (!nextElem) {
|
|
120
|
+
walker.currentNode = e.currentTarget;
|
|
121
|
+
nextElem = walker.lastChild();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (nextElem) {
|
|
125
|
+
// Call focus on nextElem so that keyboard navigation scrolls the radio into view
|
|
126
|
+
nextElem.focus();
|
|
127
|
+
state.setSelectedValue(nextElem.value);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
let groupName = $2aKPr$useId(name);
|
|
131
|
+
$a249568f27a21ba9$export$3b7b268d09480394.set(state, groupName);
|
|
132
|
+
return {
|
|
133
|
+
radioGroupProps: $2aKPr$mergeProps(domProps, {
|
|
134
|
+
// https://www.w3.org/TR/wai-aria-1.2/#radiogroup
|
|
135
|
+
role: 'radiogroup',
|
|
136
|
+
onKeyDown: onKeyDown,
|
|
137
|
+
'aria-invalid': validationState === 'invalid' || undefined,
|
|
138
|
+
'aria-errormessage': props['aria-errormessage'],
|
|
139
|
+
'aria-readonly': isReadOnly || undefined,
|
|
140
|
+
'aria-required': isRequired || undefined,
|
|
141
|
+
'aria-disabled': isDisabled || undefined,
|
|
142
|
+
'aria-orientation': orientation,
|
|
143
|
+
...fieldProps,
|
|
144
|
+
...focusWithinProps
|
|
145
|
+
}),
|
|
146
|
+
labelProps: labelProps
|
|
147
|
+
};
|
|
210
148
|
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
export {$2cd2cc131ce1e951$export$37b0961d2f4751e2 as useRadio, $b5bb90da5b40a472$export$62b9571f283ff5c2 as useRadioGroup};
|
|
211
154
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;;AAcO,MAAMA,wDAAe,GAAG,IAAIC,OAAJ,EAAxB;;ACsBP;;;;;;;OAOO,SAASC,QAAT,CAAkBC,KAAlB,EAAyCC,KAAzC,EAAiEC,GAAjE,EAAyG;AAC9G,MAAI;AACFC,IAAAA,KADE;AAEFC,IAAAA,UAFE;AAGFC,IAAAA,QAHE;AAIF,kBAAcC,SAJZ;AAKF,uBAAmBC;AALjB,MAMAP,KANJ;AAQA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,CAAC1D,KAAhC;AACD;AACF,GA/CD;;AAiDA,MAAIiE,SAAS,GAAGC,KAAK,CAACjC,IAAD,CAArB;AACA,2DAAgBkC,GAAhB,CAAoBrE,KAApB,EAA2BmE,SAA3B;AAEA,SAAO;AACLG,IAAAA,eAAe,EAAE/C,UAAU,CAACI,QAAD;AACzB;AACA4C,MAAAA,IAAI,EAAE,YAFmB;AAGzBpB,MAAAA,SAHyB;AAIzB,sBAAgBX,eAAe,KAAK,SAApB,IAAiCR,SAJxB;AAKzB,2BAAqBjC,KAAK,CAAC,mBAAD,CALD;AAMzB,uBAAiBS,UAAU,IAAIwB,SANN;AAOzB,uBAAiB7B,UAAU,IAAI6B,SAPN;AAQzB,uBAAiBzB,UAAU,IAAIyB,SARN;AASzB,0BAAoBS;AATK,OAUtBI,UAVsB,EAWtBG,gBAXsB,EADtB;AAcLJ,IAAAA;AAdK,GAAP;AAgBD","sources":["./packages/@react-aria/radio/src/utils.ts","./packages/@react-aria/radio/src/useRadio.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 */\n\nimport {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = 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 {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\ninterface RadioAriaProps extends AriaRadioProps {\n /**\n * Whether the Radio is required. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required).\n */\n isRequired?: boolean,\n /**\n * Whether the Radio can be interacted with but cannot have its selection state changed.\n */\n isReadOnly?: boolean\n}\n\ninterface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLElement>\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: RadioAriaProps, state: RadioGroupState, ref: RefObject<HTMLElement>): RadioAria {\n let {\n value,\n isRequired,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby\n } = props;\n\n const isDisabled = props.isDisabled || state.isDisabled;\n \n // Individual radios cannot be readonly\n const isReadOnly = state.isReadOnly;\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 'aria-readonly': isReadOnly || undefined,\n required: isRequired,\n checked,\n value,\n onChange\n })\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 {AriaRadioGroupProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes} from 'react';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: HTMLAttributes<HTMLElement>,\n /** Props for the radio group's visible label (if any). */\n labelProps: HTMLAttributes<HTMLElement>\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} = useLabel({\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\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 };\n}\n"],"names":["radioGroupNames","WeakMap","useRadio","props","state","ref","value","isRequired","children","ariaLabel","ariaLabelledby","isDisabled","isReadOnly","hasChildren","hasAriaLabel","console","warn","checked","selectedValue","onChange","e","stopPropagation","setSelectedValue","pressProps","usePress","focusableProps","useFocusable","mergeProps","onFocus","setLastFocusedValue","interactions","domProps","filterDOMProps","labelable","tabIndex","lastFocusedValue","undefined","inputProps","type","name","get","disabled","required","useRadioGroup","validationState","orientation","direction","useLocale","labelProps","fieldProps","useLabel","labelElementType","focusWithinProps","useFocusWithin","onBlurWithin","onKeyDown","nextDir","key","preventDefault","walker","getFocusableTreeWalker","currentTarget","from","target","nextElem","nextNode","currentNode","firstChild","previousNode","lastChild","focus","groupName","useId","set","radioGroupProps","role"],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AEcO,KAAK,CAAC,yCAAe,GAAG,GAAG,CAAC,OAAO;;;;;SDkB1B,yCAAQ,CAAC,KAAqB,EAAE,KAAsB,EAAE,GAA2B,EAAa,CAAC;IAC/G,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,CAAC,UAAU;IAEvD,GAAG,CAAC,WAAW,GAAG,QAAQ,IAAI,IAAI;IAClC,GAAG,CAAC,YAAY,GAAG,SAAS,IAAI,IAAI,IAAI,cAAc,IAAI,IAAI;IAC9D,EAAE,GAAG,WAAW,KAAK,YAAY,EAC/B,OAAO,CAAC,IAAI,CAAC,CAAkF;IAGjG,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,aAAa,KAAK,KAAK;IAE3C,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAK,CAAC;QACrB,CAAC,CAAC,eAAe;QACjB,KAAK,CAAC,gBAAgB,CAAC,KAAK;IAC9B,CAAC;IAED,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,eAAQ,CAAC,C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QAAQ,EAAE,CAAC;gBACd,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC,aAAa;gBACpC,QAAQ,GAAG,MAAM,CAAC,UAAU;YAC9B,CAAC;QACH,CAAC,MAAM,CAAC;YACN,QAAQ,GAAG,MAAM,CAAC,YAAY;YAC9B,EAAE,GAAG,QAAQ,EAAE,CAAC;gBACd,MAAM,CAAC,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;IACZ,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 */\n\nexport * from './useRadio';\nexport * 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 {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\ninterface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLElement>\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<HTMLElement>): 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 })\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>();\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 {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes} from 'react';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: HTMLAttributes<HTMLElement>,\n /** Props for the radio group's visible label (if any). */\n labelProps: HTMLAttributes<HTMLElement>\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} = useLabel({\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\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 };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { AriaRadioProps, AriaRadioGroupProps } from "@react-types/radio";
|
|
2
2
|
import { InputHTMLAttributes, RefObject, HTMLAttributes } from "react";
|
|
3
3
|
import { RadioGroupState } from "@react-stately/radio";
|
|
4
|
-
interface RadioAriaProps extends AriaRadioProps {
|
|
5
|
-
/**
|
|
6
|
-
* Whether the Radio is required. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required).
|
|
7
|
-
*/
|
|
8
|
-
isRequired?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Whether the Radio can be interacted with but cannot have its selection state changed.
|
|
11
|
-
*/
|
|
12
|
-
isReadOnly?: boolean;
|
|
13
|
-
}
|
|
14
4
|
interface RadioAria {
|
|
15
5
|
/** Props for the input element. */
|
|
16
6
|
inputProps: InputHTMLAttributes<HTMLElement>;
|
|
@@ -22,7 +12,7 @@ interface RadioAria {
|
|
|
22
12
|
* @param state - State for the radio group, as returned by `useRadioGroupState`.
|
|
23
13
|
* @param ref - Ref to the HTML input element.
|
|
24
14
|
*/
|
|
25
|
-
export function useRadio(props:
|
|
15
|
+
export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<HTMLElement>): RadioAria;
|
|
26
16
|
interface RadioGroupAria {
|
|
27
17
|
/** Props for the radio group wrapper element. */
|
|
28
18
|
radioGroupProps: HTMLAttributes<HTMLElement>;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;ACoBA;IACE,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,WAAW,CAAC,CAAA;CAC7C;AAED;;;;;;GAMG;AACH,yBAAyB,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,SAAS,CAiD9G;AC3DD;IACE,iDAAiD;IACjD,eAAe,EAAE,eAAe,WAAW,CAAC,CAAC;IAC7C,0DAA0D;IAC1D,UAAU,EAAE,eAAe,WAAW,CAAC,CAAA;CACxC;AAED;;;;;GAKG;AACH,8BAA8B,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,eAAe,GAAG,cAAc,CAmGhG","sources":["packages/@react-aria/radio/src/packages/@react-aria/radio/src/utils.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/useRadioGroup.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useRadio';\nexport * from './useRadioGroup';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/radio",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.8",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-aria/focus": "^3.
|
|
22
|
-
"@react-aria/i18n": "^3.3.
|
|
23
|
-
"@react-aria/interactions": "^3.
|
|
24
|
-
"@react-aria/label": "^3.
|
|
25
|
-
"@react-aria/utils": "^3.
|
|
26
|
-
"@react-stately/radio": "^3.3.
|
|
27
|
-
"@react-types/radio": "^3.1.
|
|
21
|
+
"@react-aria/focus": "^3.5.2",
|
|
22
|
+
"@react-aria/i18n": "^3.3.6",
|
|
23
|
+
"@react-aria/interactions": "^3.8.1",
|
|
24
|
+
"@react-aria/label": "^3.2.3",
|
|
25
|
+
"@react-aria/utils": "^3.11.2",
|
|
26
|
+
"@react-stately/radio": "^3.3.4",
|
|
27
|
+
"@react-types/radio": "^3.1.4"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
|
|
36
36
|
}
|
package/src/useRadio.ts
CHANGED
|
@@ -18,17 +18,6 @@ import {RadioGroupState} from '@react-stately/radio';
|
|
|
18
18
|
import {useFocusable} from '@react-aria/focus';
|
|
19
19
|
import {usePress} from '@react-aria/interactions';
|
|
20
20
|
|
|
21
|
-
interface RadioAriaProps extends AriaRadioProps {
|
|
22
|
-
/**
|
|
23
|
-
* Whether the Radio is required. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required).
|
|
24
|
-
*/
|
|
25
|
-
isRequired?: boolean,
|
|
26
|
-
/**
|
|
27
|
-
* Whether the Radio can be interacted with but cannot have its selection state changed.
|
|
28
|
-
*/
|
|
29
|
-
isReadOnly?: boolean
|
|
30
|
-
}
|
|
31
|
-
|
|
32
21
|
interface RadioAria {
|
|
33
22
|
/** Props for the input element. */
|
|
34
23
|
inputProps: InputHTMLAttributes<HTMLElement>
|
|
@@ -41,19 +30,15 @@ interface RadioAria {
|
|
|
41
30
|
* @param state - State for the radio group, as returned by `useRadioGroupState`.
|
|
42
31
|
* @param ref - Ref to the HTML input element.
|
|
43
32
|
*/
|
|
44
|
-
export function useRadio(props:
|
|
33
|
+
export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<HTMLElement>): RadioAria {
|
|
45
34
|
let {
|
|
46
35
|
value,
|
|
47
|
-
isRequired,
|
|
48
36
|
children,
|
|
49
37
|
'aria-label': ariaLabel,
|
|
50
38
|
'aria-labelledby': ariaLabelledby
|
|
51
39
|
} = props;
|
|
52
40
|
|
|
53
41
|
const isDisabled = props.isDisabled || state.isDisabled;
|
|
54
|
-
|
|
55
|
-
// Individual radios cannot be readonly
|
|
56
|
-
const isReadOnly = state.isReadOnly;
|
|
57
42
|
|
|
58
43
|
let hasChildren = children != null;
|
|
59
44
|
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
@@ -89,8 +74,6 @@ export function useRadio(props: RadioAriaProps, state: RadioGroupState, ref: Ref
|
|
|
89
74
|
name: radioGroupNames.get(state),
|
|
90
75
|
tabIndex,
|
|
91
76
|
disabled: isDisabled,
|
|
92
|
-
'aria-readonly': isReadOnly || undefined,
|
|
93
|
-
required: isRequired,
|
|
94
77
|
checked,
|
|
95
78
|
value,
|
|
96
79
|
onChange
|