@react-aria/radio 3.1.6 → 3.1.9
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 -212
- package/dist/main.js.map +1 -1
- package/dist/module.js +142 -194
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/main.js
CHANGED
|
@@ -1,233 +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 $fMEGB$reactariautils = require("@react-aria/utils");
|
|
2
|
+
var $fMEGB$reactariafocus = require("@react-aria/focus");
|
|
3
|
+
var $fMEGB$reactariainteractions = require("@react-aria/interactions");
|
|
4
|
+
var $fMEGB$reactarialabel = require("@react-aria/label");
|
|
5
|
+
var $fMEGB$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
|
-
children,
|
|
55
|
-
'aria-label': ariaLabel,
|
|
56
|
-
'aria-labelledby': ariaLabelledby
|
|
57
|
-
} = props;
|
|
58
|
-
const isDisabled = props.isDisabled || state.isDisabled;
|
|
59
|
-
let hasChildren = children != null;
|
|
60
|
-
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
61
|
-
|
|
62
|
-
if (!hasChildren && !hasAriaLabel) {
|
|
63
|
-
console.warn('If you do not provide children, you must specify an aria-label for accessibility');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let checked = state.selectedValue === value;
|
|
67
|
-
|
|
68
|
-
let onChange = e => {
|
|
69
|
-
e.stopPropagation();
|
|
70
|
-
state.setSelectedValue(value);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
let {
|
|
74
|
-
pressProps
|
|
75
|
-
} = usePress({
|
|
76
|
-
isDisabled
|
|
77
|
-
});
|
|
78
|
-
let {
|
|
79
|
-
focusableProps
|
|
80
|
-
} = useFocusable(mergeProps(props, {
|
|
81
|
-
onFocus: () => state.setLastFocusedValue(value)
|
|
82
|
-
}), ref);
|
|
83
|
-
let interactions = mergeProps(pressProps, focusableProps);
|
|
84
|
-
let domProps = filterDOMProps(props, {
|
|
85
|
-
labelable: true
|
|
13
|
+
Object.defineProperty(dest, key, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return source[key];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
86
19
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
inputProps: mergeProps(domProps, _babelRuntimeHelpersExtends({}, interactions, {
|
|
95
|
-
type: 'radio',
|
|
96
|
-
name: $d9900fa75ce48f638bc47fd54695f66$export$radioGroupNames.get(state),
|
|
97
|
-
tabIndex,
|
|
98
|
-
disabled: isDisabled,
|
|
99
|
-
checked,
|
|
100
|
-
value,
|
|
101
|
-
onChange
|
|
102
|
-
}))
|
|
103
|
-
};
|
|
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});
|
|
104
25
|
}
|
|
26
|
+
var $e184702b1b7f1863$exports = {};
|
|
105
27
|
|
|
106
|
-
exports
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Provides the behavior and accessibility implementation for a radio group component.
|
|
110
|
-
* Radio groups allow users to select a single item from a list of mutually exclusive options.
|
|
111
|
-
* @param props - Props for the radio group.
|
|
112
|
-
* @param state - State for the radio group, as returned by `useRadioGroupState`.
|
|
113
|
-
*/
|
|
114
|
-
function useRadioGroup(props, state) {
|
|
115
|
-
let {
|
|
116
|
-
name,
|
|
117
|
-
validationState,
|
|
118
|
-
isReadOnly,
|
|
119
|
-
isRequired,
|
|
120
|
-
isDisabled,
|
|
121
|
-
orientation = 'vertical'
|
|
122
|
-
} = props;
|
|
123
|
-
let {
|
|
124
|
-
direction
|
|
125
|
-
} = useLocale();
|
|
126
|
-
let {
|
|
127
|
-
labelProps,
|
|
128
|
-
fieldProps
|
|
129
|
-
} = useLabel(_babelRuntimeHelpersExtends({}, props, {
|
|
130
|
-
// Radio group is not an HTML input element so it
|
|
131
|
-
// shouldn't be labeled by a <label> element.
|
|
132
|
-
labelElementType: 'span'
|
|
133
|
-
}));
|
|
134
|
-
let domProps = filterDOMProps(props, {
|
|
135
|
-
labelable: true
|
|
136
|
-
}); // When the radio group loses focus, reset the focusable radio to null if
|
|
137
|
-
// there is no selection. This allows tabbing into the group from either
|
|
138
|
-
// direction to go to the first or last radio.
|
|
139
|
-
|
|
140
|
-
let {
|
|
141
|
-
focusWithinProps
|
|
142
|
-
} = useFocusWithin({
|
|
143
|
-
onBlurWithin() {
|
|
144
|
-
if (!state.selectedValue) {
|
|
145
|
-
state.setLastFocusedValue(null);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
28
|
+
$parcel$export($e184702b1b7f1863$exports, "useRadio", () => $e184702b1b7f1863$export$37b0961d2f4751e2);
|
|
148
29
|
|
|
149
|
-
|
|
30
|
+
const $eeb149278aae5c67$export$3b7b268d09480394 = new WeakMap();
|
|
150
31
|
|
|
151
|
-
let onKeyDown = e => {
|
|
152
|
-
let nextDir;
|
|
153
32
|
|
|
154
|
-
switch (e.key) {
|
|
155
|
-
case 'ArrowRight':
|
|
156
|
-
if (direction === 'rtl' && orientation !== 'vertical') {
|
|
157
|
-
nextDir = 'prev';
|
|
158
|
-
} else {
|
|
159
|
-
nextDir = 'next';
|
|
160
|
-
}
|
|
161
33
|
|
|
162
|
-
break;
|
|
163
34
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
35
|
+
function $e184702b1b7f1863$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 } = $fMEGB$reactariainteractions.usePress({
|
|
47
|
+
isDisabled: isDisabled
|
|
48
|
+
});
|
|
49
|
+
let { focusableProps: focusableProps } = $fMEGB$reactariafocus.useFocusable($fMEGB$reactariautils.mergeProps(props, {
|
|
50
|
+
onFocus: ()=>state.setLastFocusedValue(value)
|
|
51
|
+
}), ref);
|
|
52
|
+
let interactions = $fMEGB$reactariautils.mergeProps(pressProps, focusableProps);
|
|
53
|
+
let domProps = $fMEGB$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: $fMEGB$reactariautils.mergeProps(domProps, {
|
|
60
|
+
...interactions,
|
|
61
|
+
type: 'radio',
|
|
62
|
+
name: $eeb149278aae5c67$export$3b7b268d09480394.get(state),
|
|
63
|
+
tabIndex: tabIndex,
|
|
64
|
+
disabled: isDisabled,
|
|
65
|
+
checked: checked,
|
|
66
|
+
value: value,
|
|
67
|
+
onChange: onChange
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
}
|
|
170
71
|
|
|
171
|
-
break;
|
|
172
72
|
|
|
173
|
-
|
|
174
|
-
nextDir = 'next';
|
|
175
|
-
break;
|
|
73
|
+
var $dfcade00a56a6317$exports = {};
|
|
176
74
|
|
|
177
|
-
|
|
178
|
-
nextDir = 'prev';
|
|
179
|
-
break;
|
|
75
|
+
$parcel$export($dfcade00a56a6317$exports, "useRadioGroup", () => $dfcade00a56a6317$export$62b9571f283ff5c2);
|
|
180
76
|
|
|
181
|
-
default:
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
77
|
|
|
185
|
-
e.preventDefault();
|
|
186
|
-
let walker = getFocusableTreeWalker(e.currentTarget, {
|
|
187
|
-
from: e.target
|
|
188
|
-
});
|
|
189
|
-
let nextElem;
|
|
190
78
|
|
|
191
|
-
if (nextDir === 'next') {
|
|
192
|
-
nextElem = walker.nextNode();
|
|
193
79
|
|
|
194
|
-
if (!nextElem) {
|
|
195
|
-
walker.currentNode = e.currentTarget;
|
|
196
|
-
nextElem = walker.firstChild();
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
nextElem = walker.previousNode();
|
|
200
80
|
|
|
201
|
-
if (!nextElem) {
|
|
202
|
-
walker.currentNode = e.currentTarget;
|
|
203
|
-
nextElem = walker.lastChild();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
81
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
82
|
+
function $dfcade00a56a6317$export$62b9571f283ff5c2(props, state) {
|
|
83
|
+
let { name: name , validationState: validationState , isReadOnly: isReadOnly , isRequired: isRequired , isDisabled: isDisabled , orientation: orientation = 'vertical' } = props;
|
|
84
|
+
let { direction: direction } = $fMEGB$reactariai18n.useLocale();
|
|
85
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = $fMEGB$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 = $fMEGB$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 } = $fMEGB$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 = $fMEGB$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 = $fMEGB$reactariautils.useId(name);
|
|
147
|
+
$eeb149278aae5c67$export$3b7b268d09480394.set(state, groupName);
|
|
148
|
+
return {
|
|
149
|
+
radioGroupProps: $fMEGB$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
|
+
};
|
|
230
164
|
}
|
|
231
165
|
|
|
232
|
-
|
|
166
|
+
|
|
167
|
+
$parcel$exportWildcard(module.exports, $e184702b1b7f1863$exports);
|
|
168
|
+
$parcel$exportWildcard(module.exports, $dfcade00a56a6317$exports);
|
|
169
|
+
|
|
170
|
+
|
|
233
171
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT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CAACJ,QAAL,EAAe;AACbL,QAAAA,MAAM,CAACO,WAAP,GAAqB/C,CAAC,CAAC0C,aAAvB;AACAG,QAAAA,QAAQ,GAAGL,MAAM,CAACU,SAAP,EAAX;AACD;AACF;;AACD,QAAIL,QAAJ,EAAc;AACZ;AACAA,MAAAA,QAAQ,CAACM,KAAT;AACAjE,MAAAA,KAAK,CAACgB,gBAAN,CAAuB2C,QAAQ,CAACzD,KAAhC;AACD;AACF,GA/CD;;AAiDA,MAAIgE,SAAS,GAAGC,KAAK,CAAClC,IAAD,CAArB;AACA,0DAAgBmC,GAAhB,CAAoBpE,KAApB,EAA2BkE,SAA3B;AAEA,SAAO;AACLG,IAAAA,eAAe,EAAEhD,UAAU,CAACI,QAAD;AACzB;AACA6C,MAAAA,IAAI,EAAE,YAFmB;AAGzBpB,MAAAA,SAHyB;AAIzB,sBAAgBb,eAAe,KAAK,SAApB,IAAiCP,SAJxB;AAKzB,2BAAqB/B,KAAK,CAAC,mBAAD,CALD;AAMzB,uBAAiBuC,UAAU,IAAIR,SANN;AAOzB,uBAAiBS,UAAU,IAAIT,SAPN;AAQzB,uBAAiBxB,UAAU,IAAIwB,SARN;AASzB,0BAAoBU;AATK,OAUtBI,UAVsB,EAWtBG,gBAXsB,EADtB;AAcLJ,IAAAA;AAdK,GAAP;AAgBD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/radio/src/utils.ts","./packages/@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 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 {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","children","ariaLabel","ariaLabelledby","isDisabled","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","useRadioGroup","validationState","isReadOnly","isRequired","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,cAA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AjD,+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,206 +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
|
-
children,
|
|
32
|
-
'aria-label': ariaLabel,
|
|
33
|
-
'aria-labelledby': ariaLabelledby
|
|
34
|
-
} = props;
|
|
35
|
-
const isDisabled = props.isDisabled || state.isDisabled;
|
|
36
|
-
let hasChildren = children != null;
|
|
37
|
-
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
38
|
-
|
|
39
|
-
if (!hasChildren && !hasAriaLabel) {
|
|
40
|
-
console.warn('If you do not provide children, you must specify an aria-label for accessibility');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let checked = state.selectedValue === value;
|
|
44
|
-
|
|
45
|
-
let onChange = e => {
|
|
46
|
-
e.stopPropagation();
|
|
47
|
-
state.setSelectedValue(value);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
let {
|
|
51
|
-
pressProps
|
|
52
|
-
} = usePress({
|
|
53
|
-
isDisabled
|
|
54
|
-
});
|
|
55
|
-
let {
|
|
56
|
-
focusableProps
|
|
57
|
-
} = useFocusable(mergeProps(props, {
|
|
58
|
-
onFocus: () => state.setLastFocusedValue(value)
|
|
59
|
-
}), ref);
|
|
60
|
-
let interactions = mergeProps(pressProps, focusableProps);
|
|
61
|
-
let domProps = filterDOMProps(props, {
|
|
62
|
-
labelable: true
|
|
63
|
-
});
|
|
64
|
-
let tabIndex = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;
|
|
65
|
-
|
|
66
|
-
if (isDisabled) {
|
|
67
|
-
tabIndex = undefined;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
inputProps: mergeProps(domProps, _babelRuntimeHelpersEsmExtends({}, interactions, {
|
|
72
|
-
type: 'radio',
|
|
73
|
-
name: $a7d0e5df3871fb1bfdb437cffdabab2a$export$radioGroupNames.get(state),
|
|
74
|
-
tabIndex,
|
|
75
|
-
disabled: isDisabled,
|
|
76
|
-
checked,
|
|
77
|
-
value,
|
|
78
|
-
onChange
|
|
79
|
-
}))
|
|
80
|
-
};
|
|
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 {useLabel as $4vDl6$useLabel} from "@react-aria/label";
|
|
5
|
+
import {useLocale as $4vDl6$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});
|
|
81
9
|
}
|
|
10
|
+
var $0d5c49892c1215da$exports = {};
|
|
82
11
|
|
|
83
|
-
|
|
84
|
-
* Provides the behavior and accessibility implementation for a radio group component.
|
|
85
|
-
* Radio groups allow users to select a single item from a list of mutually exclusive options.
|
|
86
|
-
* @param props - Props for the radio group.
|
|
87
|
-
* @param state - State for the radio group, as returned by `useRadioGroupState`.
|
|
88
|
-
*/
|
|
89
|
-
export function useRadioGroup(props, state) {
|
|
90
|
-
let {
|
|
91
|
-
name,
|
|
92
|
-
validationState,
|
|
93
|
-
isReadOnly,
|
|
94
|
-
isRequired,
|
|
95
|
-
isDisabled,
|
|
96
|
-
orientation = 'vertical'
|
|
97
|
-
} = props;
|
|
98
|
-
let {
|
|
99
|
-
direction
|
|
100
|
-
} = useLocale();
|
|
101
|
-
let {
|
|
102
|
-
labelProps,
|
|
103
|
-
fieldProps
|
|
104
|
-
} = useLabel(_babelRuntimeHelpersEsmExtends({}, props, {
|
|
105
|
-
// Radio group is not an HTML input element so it
|
|
106
|
-
// shouldn't be labeled by a <label> element.
|
|
107
|
-
labelElementType: 'span'
|
|
108
|
-
}));
|
|
109
|
-
let domProps = filterDOMProps(props, {
|
|
110
|
-
labelable: true
|
|
111
|
-
}); // When the radio group loses focus, reset the focusable radio to null if
|
|
112
|
-
// there is no selection. This allows tabbing into the group from either
|
|
113
|
-
// direction to go to the first or last radio.
|
|
114
|
-
|
|
115
|
-
let {
|
|
116
|
-
focusWithinProps
|
|
117
|
-
} = useFocusWithin({
|
|
118
|
-
onBlurWithin() {
|
|
119
|
-
if (!state.selectedValue) {
|
|
120
|
-
state.setLastFocusedValue(null);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
let onKeyDown = e => {
|
|
127
|
-
let nextDir;
|
|
128
|
-
|
|
129
|
-
switch (e.key) {
|
|
130
|
-
case 'ArrowRight':
|
|
131
|
-
if (direction === 'rtl' && orientation !== 'vertical') {
|
|
132
|
-
nextDir = 'prev';
|
|
133
|
-
} else {
|
|
134
|
-
nextDir = 'next';
|
|
135
|
-
}
|
|
12
|
+
$parcel$export($0d5c49892c1215da$exports, "useRadio", () => $0d5c49892c1215da$export$37b0961d2f4751e2);
|
|
136
13
|
|
|
137
|
-
|
|
14
|
+
const $884aeceb3d67f00f$export$3b7b268d09480394 = new WeakMap();
|
|
138
15
|
|
|
139
|
-
case 'ArrowLeft':
|
|
140
|
-
if (direction === 'rtl' && orientation !== 'vertical') {
|
|
141
|
-
nextDir = 'next';
|
|
142
|
-
} else {
|
|
143
|
-
nextDir = 'prev';
|
|
144
|
-
}
|
|
145
16
|
|
|
146
|
-
break;
|
|
147
17
|
|
|
148
|
-
case 'ArrowDown':
|
|
149
|
-
nextDir = 'next';
|
|
150
|
-
break;
|
|
151
18
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
19
|
+
function $0d5c49892c1215da$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 } = $4vDl6$usePress({
|
|
31
|
+
isDisabled: isDisabled
|
|
32
|
+
});
|
|
33
|
+
let { focusableProps: focusableProps } = $4vDl6$useFocusable($4vDl6$mergeProps(props, {
|
|
34
|
+
onFocus: ()=>state.setLastFocusedValue(value)
|
|
35
|
+
}), ref);
|
|
36
|
+
let interactions = $4vDl6$mergeProps(pressProps, focusableProps);
|
|
37
|
+
let domProps = $4vDl6$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: $4vDl6$mergeProps(domProps, {
|
|
44
|
+
...interactions,
|
|
45
|
+
type: 'radio',
|
|
46
|
+
name: $884aeceb3d67f00f$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 $430f30ed08ec25fa$exports = {};
|
|
58
|
+
|
|
59
|
+
$parcel$export($430f30ed08ec25fa$exports, "useRadioGroup", () => $430f30ed08ec25fa$export$62b9571f283ff5c2);
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
155
63
|
|
|
156
|
-
default:
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
64
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
65
|
+
|
|
66
|
+
function $430f30ed08ec25fa$export$62b9571f283ff5c2(props, state) {
|
|
67
|
+
let { name: name , validationState: validationState , isReadOnly: isReadOnly , isRequired: isRequired , isDisabled: isDisabled , orientation: orientation = 'vertical' } = props;
|
|
68
|
+
let { direction: direction } = $4vDl6$useLocale();
|
|
69
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = $4vDl6$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 = $4vDl6$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 } = $4vDl6$useFocusWithin({
|
|
82
|
+
onBlurWithin () {
|
|
83
|
+
if (!state.selectedValue) state.setLastFocusedValue(null);
|
|
84
|
+
}
|
|
163
85
|
});
|
|
164
|
-
let
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
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 = $4vDl6$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 = $4vDl6$useId(name);
|
|
131
|
+
$884aeceb3d67f00f$export$3b7b268d09480394.set(state, groupName);
|
|
132
|
+
return {
|
|
133
|
+
radioGroupProps: $4vDl6$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
|
+
};
|
|
205
148
|
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
export {$0d5c49892c1215da$export$37b0961d2f4751e2 as useRadio, $430f30ed08ec25fa$export$62b9571f283ff5c2 as useRadioGroup};
|
|
206
154
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;;AAcO,MAAMA,wDAAe,GAAG,IAAIC,OAAJ,EAAxB;;ACWP;;;;;;;OAOO,SAASC,QAAT,CAAkBC,KAAlB,EAAyCC,KAAzC,EAAiEC,GAAjE,EAAyG;AAC9G,MAAI;AACFC,IAAAA,KADE;AAEFC,IAAAA,QAFE;AAGF,kBAAcC,SAHZ;AAIF,uBAAmBC;AAJjB,MAKAN,KALJ;AAOA,QAAMO,UAAU,GAAGP,KAAK,CAACO,UAAN,IAAoBN,KAAK,CAACM,UAA7C;AAEA,MAAIC,WAAW,GAAGJ,QAAQ,IAAI,IAA9B;AACA,MAAIK,YAAY,GAAGJ,SAAS,IAAI,IAAb,IAAqBC,cAAc,IAAI,IAA1D;;AACA,MAAI,CAACE,WAAD,IAAgB,CAACC,YAArB,EAAmC;AACjCC,IAAAA,OAAO,CAACC,IAAR,CAAa,kFAAb;AACD;;AAED,MAAIC,OAAO,GAAGX,KAAK,CAACY,aAAN,KAAwBV,KAAtC;;AAEA,MAAIW,QAAQ,GAAIC,CAAD,IAAO;AACpBA,IAAAA,CAAC,CAACC,eAAF;AACAf,IAAAA,KAAK,CAACgB,gBAAN,CAAuBd,KAAvB;AACD,GAHD;;AAKA,MAAI;AAACe,IAAAA;AAAD,MAAeC,QAAQ,CAAC;AAC1BZ,IAAAA;AAD0B,GAAD,CAA3B;AAIA,MAAI;AAACa,IAAAA;AAAD,MAAmBC,YAAY,CAACC,UAAU,CAACtB,KAAD,EAAQ;AACpDuB,IAAAA,OAAO,EAAE,MAAMtB,KAAK,CAACuB,mBAAN,CAA0BrB,KAA1B;AADqC,GAAR,CAAX,EAE/BD,GAF+B,CAAnC;AAGA,MAAIuB,YAA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LH,MAAAA,QAAQ,GAAGL,MAAM,CAACS,YAAP,EAAX;;AACA,UAAI,CAACJ,QAAL,EAAe;AACbL,QAAAA,MAAM,CAACO,WAAP,GAAqB/C,CAAC,CAAC0C,aAAvB;AACAG,QAAAA,QAAQ,GAAGL,MAAM,CAACU,SAAP,EAAX;AACD;AACF;;AACD,QAAIL,QAAJ,EAAc;AACZ;AACAA,MAAAA,QAAQ,CAACM,KAAT;AACAjE,MAAAA,KAAK,CAACgB,gBAAN,CAAuB2C,QAAQ,CAACzD,KAAhC;AACD;AACF,GA/CD;;AAiDA,MAAIgE,SAAS,GAAGC,KAAK,CAAClC,IAAD,CAArB;AACA,2DAAgBmC,GAAhB,CAAoBpE,KAApB,EAA2BkE,SAA3B;AAEA,SAAO;AACLG,IAAAA,eAAe,EAAEhD,UAAU,CAACI,QAAD;AACzB;AACA6C,MAAAA,IAAI,EAAE,YAFmB;AAGzBpB,MAAAA,SAHyB;AAIzB,sBAAgBb,eAAe,KAAK,SAApB,IAAiCP,SAJxB;AAKzB,2BAAqB/B,KAAK,CAAC,mBAAD,CALD;AAMzB,uBAAiBuC,UAAU,IAAIR,SANN;AAOzB,uBAAiBS,UAAU,IAAIT,SAPN;AAQzB,uBAAiBxB,UAAU,IAAIwB,SARN;AASzB,0BAAoBU;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 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 {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","children","ariaLabel","ariaLabelledby","isDisabled","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","useRadioGroup","validationState","isReadOnly","isRequired","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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,GAAG,MAAM,CAAC,QAAQ;YAC1B,EAAE,GAAG,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.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.9",
|
|
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.2.
|
|
25
|
-
"@react-aria/utils": "^3.
|
|
26
|
-
"@react-stately/radio": "^3.3.
|
|
27
|
-
"@react-types/radio": "^3.1.
|
|
21
|
+
"@react-aria/focus": "^3.5.3",
|
|
22
|
+
"@react-aria/i18n": "^3.3.7",
|
|
23
|
+
"@react-aria/interactions": "^3.8.2",
|
|
24
|
+
"@react-aria/label": "^3.2.4",
|
|
25
|
+
"@react-aria/utils": "^3.11.3",
|
|
26
|
+
"@react-stately/radio": "^3.3.5",
|
|
27
|
+
"@react-types/radio": "^3.1.5"
|
|
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": "ed8d8d984c2f7f2c31e8b18795b97858a95e4729"
|
|
36
36
|
}
|