@react-aria/listbox 3.7.2-nightly.3599 → 3.7.2-nightly.3600
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 +95 -48
- package/dist/main.js.map +1 -1
- package/dist/module.mjs +95 -48
- package/dist/module.mjs.map +1 -1
- package/package.json +12 -12
package/dist/main.js
CHANGED
|
@@ -13,15 +13,45 @@ $parcel$export(module.exports, "useOption", () => $c164f9f79f4cef2d$export$49785
|
|
|
13
13
|
$parcel$export(module.exports, "useListBoxSection", () => $f32afd5f225c3320$export$c3f9f39876e4bc7);
|
|
14
14
|
$parcel$export(module.exports, "listData", () => $87beb89ab4a308fd$export$3585ede4d035bf14);
|
|
15
15
|
$parcel$export(module.exports, "getItemId", () => $87beb89ab4a308fd$export$9145995848b05025);
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/*
|
|
17
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
18
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
19
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
20
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
23
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
24
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
25
|
+
* governing permissions and limitations under the License.
|
|
26
|
+
*/ /*
|
|
27
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
28
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
29
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
30
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
31
|
+
*
|
|
32
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
33
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
34
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
35
|
+
* governing permissions and limitations under the License.
|
|
36
|
+
*/
|
|
37
|
+
/*
|
|
38
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
39
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
40
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
41
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
+
*
|
|
43
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
44
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
45
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
46
|
+
* governing permissions and limitations under the License.
|
|
47
|
+
*/ const $87beb89ab4a308fd$export$3585ede4d035bf14 = new WeakMap();
|
|
18
48
|
function $87beb89ab4a308fd$var$normalizeKey(key) {
|
|
19
|
-
if (typeof key ===
|
|
20
|
-
return
|
|
49
|
+
if (typeof key === "string") return key.replace(/\s*/g, "");
|
|
50
|
+
return "" + key;
|
|
21
51
|
}
|
|
22
52
|
function $87beb89ab4a308fd$export$9145995848b05025(state, itemKey) {
|
|
23
53
|
let data = $87beb89ab4a308fd$export$3585ede4d035bf14.get(state);
|
|
24
|
-
if (!data) throw new Error(
|
|
54
|
+
if (!data) throw new Error("Unknown list");
|
|
25
55
|
return `${data.id}-option-${$87beb89ab4a308fd$var$normalizeKey(itemKey)}`;
|
|
26
56
|
}
|
|
27
57
|
|
|
@@ -31,24 +61,24 @@ function $87beb89ab4a308fd$export$9145995848b05025(state, itemKey) {
|
|
|
31
61
|
|
|
32
62
|
|
|
33
63
|
function $a3ce5bb3074610af$export$50eacbbf140a3141(props, state, ref) {
|
|
34
|
-
let domProps = $eFCLV$reactariautils.filterDOMProps(props, {
|
|
64
|
+
let domProps = (0, $eFCLV$reactariautils.filterDOMProps)(props, {
|
|
35
65
|
labelable: true
|
|
36
66
|
});
|
|
37
|
-
let { listProps: listProps } = $eFCLV$reactariaselection.useSelectableList({
|
|
67
|
+
let { listProps: listProps } = (0, $eFCLV$reactariaselection.useSelectableList)({
|
|
38
68
|
...props,
|
|
39
69
|
ref: ref,
|
|
40
70
|
selectionManager: state.selectionManager,
|
|
41
71
|
collection: state.collection,
|
|
42
72
|
disabledKeys: state.disabledKeys
|
|
43
73
|
});
|
|
44
|
-
let { focusWithinProps: focusWithinProps } = $eFCLV$reactariainteractions.useFocusWithin({
|
|
74
|
+
let { focusWithinProps: focusWithinProps } = (0, $eFCLV$reactariainteractions.useFocusWithin)({
|
|
45
75
|
onFocusWithin: props.onFocus,
|
|
46
76
|
onBlurWithin: props.onBlur,
|
|
47
77
|
onFocusWithinChange: props.onFocusChange
|
|
48
78
|
});
|
|
49
79
|
// Share list id and some props with child options.
|
|
50
|
-
let id = $eFCLV$reactariautils.useId(props.id);
|
|
51
|
-
$87beb89ab4a308fd$export$3585ede4d035bf14.set(state, {
|
|
80
|
+
let id = (0, $eFCLV$reactariautils.useId)(props.id);
|
|
81
|
+
(0, $87beb89ab4a308fd$export$3585ede4d035bf14).set(state, {
|
|
52
82
|
id: id,
|
|
53
83
|
shouldUseVirtualFocus: props.shouldUseVirtualFocus,
|
|
54
84
|
shouldSelectOnPressUp: props.shouldSelectOnPressUp,
|
|
@@ -56,34 +86,43 @@ function $a3ce5bb3074610af$export$50eacbbf140a3141(props, state, ref) {
|
|
|
56
86
|
isVirtualized: props.isVirtualized,
|
|
57
87
|
onAction: props.onAction
|
|
58
88
|
});
|
|
59
|
-
let { labelProps: labelProps , fieldProps: fieldProps } = $eFCLV$reactarialabel.useLabel({
|
|
89
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = (0, $eFCLV$reactarialabel.useLabel)({
|
|
60
90
|
...props,
|
|
61
91
|
id: id,
|
|
62
92
|
// listbox is not an HTML input element so it
|
|
63
93
|
// shouldn't be labeled by a <label> element.
|
|
64
|
-
labelElementType:
|
|
94
|
+
labelElementType: "span"
|
|
65
95
|
});
|
|
66
96
|
return {
|
|
67
97
|
labelProps: labelProps,
|
|
68
|
-
listBoxProps: $eFCLV$reactariautils.mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode ===
|
|
69
|
-
|
|
70
|
-
} : {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
...$eFCLV$reactariautils.mergeProps(fieldProps, listProps)
|
|
98
|
+
listBoxProps: (0, $eFCLV$reactariautils.mergeProps)(domProps, focusWithinProps, state.selectionManager.selectionMode === "multiple" ? {
|
|
99
|
+
"aria-multiselectable": "true"
|
|
100
|
+
} : {}, {
|
|
101
|
+
role: "listbox",
|
|
102
|
+
...(0, $eFCLV$reactariautils.mergeProps)(fieldProps, listProps)
|
|
74
103
|
})
|
|
75
104
|
};
|
|
76
105
|
}
|
|
77
106
|
|
|
78
107
|
|
|
79
|
-
|
|
108
|
+
/*
|
|
109
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
110
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
111
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
112
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
113
|
+
*
|
|
114
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
115
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
116
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
117
|
+
* governing permissions and limitations under the License.
|
|
118
|
+
*/
|
|
80
119
|
|
|
81
120
|
|
|
82
121
|
|
|
83
122
|
|
|
84
123
|
function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
|
|
85
124
|
let { key: key } = props;
|
|
86
|
-
let data = $87beb89ab4a308fd$export$3585ede4d035bf14.get(state);
|
|
125
|
+
let data = (0, $87beb89ab4a308fd$export$3585ede4d035bf14).get(state);
|
|
87
126
|
var _isDisabled;
|
|
88
127
|
let isDisabled = (_isDisabled = props.isDisabled) !== null && _isDisabled !== void 0 ? _isDisabled : state.disabledKeys.has(key);
|
|
89
128
|
var _isSelected;
|
|
@@ -97,26 +136,26 @@ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
|
|
|
97
136
|
let shouldUseVirtualFocus = (_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _shouldUseVirtualFocus !== void 0 ? _shouldUseVirtualFocus : data.shouldUseVirtualFocus;
|
|
98
137
|
var _isVirtualized;
|
|
99
138
|
let isVirtualized = (_isVirtualized = props.isVirtualized) !== null && _isVirtualized !== void 0 ? _isVirtualized : data.isVirtualized;
|
|
100
|
-
let labelId = $eFCLV$reactariautils.useSlotId();
|
|
101
|
-
let descriptionId = $eFCLV$reactariautils.useSlotId();
|
|
139
|
+
let labelId = (0, $eFCLV$reactariautils.useSlotId)();
|
|
140
|
+
let descriptionId = (0, $eFCLV$reactariautils.useSlotId)();
|
|
102
141
|
let optionProps = {
|
|
103
|
-
role:
|
|
104
|
-
|
|
105
|
-
|
|
142
|
+
role: "option",
|
|
143
|
+
"aria-disabled": isDisabled,
|
|
144
|
+
"aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined
|
|
106
145
|
};
|
|
107
146
|
// Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply "text".
|
|
108
147
|
// We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.
|
|
109
148
|
// https://bugs.webkit.org/show_bug.cgi?id=209279
|
|
110
|
-
if (!($eFCLV$reactariautils.isMac() && $eFCLV$reactariautils.isWebKit())) {
|
|
111
|
-
optionProps[
|
|
112
|
-
optionProps[
|
|
113
|
-
optionProps[
|
|
149
|
+
if (!((0, $eFCLV$reactariautils.isMac)() && (0, $eFCLV$reactariautils.isWebKit)())) {
|
|
150
|
+
optionProps["aria-label"] = props["aria-label"];
|
|
151
|
+
optionProps["aria-labelledby"] = labelId;
|
|
152
|
+
optionProps["aria-describedby"] = descriptionId;
|
|
114
153
|
}
|
|
115
154
|
if (isVirtualized) {
|
|
116
|
-
optionProps[
|
|
117
|
-
optionProps[
|
|
155
|
+
optionProps["aria-posinset"] = state.collection.getItem(key).index + 1;
|
|
156
|
+
optionProps["aria-setsize"] = (0, $eFCLV$reactstatelycollections.getItemCount)(state.collection);
|
|
118
157
|
}
|
|
119
|
-
let { itemProps: itemProps , isPressed: isPressed , hasAction: hasAction , allowsSelection: allowsSelection } = $eFCLV$reactariaselection.useSelectableItem({
|
|
158
|
+
let { itemProps: itemProps , isPressed: isPressed , hasAction: hasAction , allowsSelection: allowsSelection } = (0, $eFCLV$reactariaselection.useSelectableItem)({
|
|
120
159
|
selectionManager: state.selectionManager,
|
|
121
160
|
key: key,
|
|
122
161
|
ref: ref,
|
|
@@ -125,13 +164,12 @@ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
|
|
|
125
164
|
isVirtualized: isVirtualized,
|
|
126
165
|
shouldUseVirtualFocus: shouldUseVirtualFocus,
|
|
127
166
|
isDisabled: isDisabled,
|
|
128
|
-
onAction: data.onAction ? ()=>data.onAction(key)
|
|
129
|
-
: undefined
|
|
167
|
+
onAction: data.onAction ? ()=>data.onAction(key) : undefined
|
|
130
168
|
});
|
|
131
|
-
let { hoverProps: hoverProps } = $eFCLV$reactariainteractions.useHover({
|
|
169
|
+
let { hoverProps: hoverProps } = (0, $eFCLV$reactariainteractions.useHover)({
|
|
132
170
|
isDisabled: isDisabled || !shouldFocusOnHover,
|
|
133
171
|
onHoverStart () {
|
|
134
|
-
if (
|
|
172
|
+
if (!(0, $eFCLV$reactariainteractions.isFocusVisible)()) {
|
|
135
173
|
state.selectionManager.setFocused(true);
|
|
136
174
|
state.selectionManager.setFocusedKey(key);
|
|
137
175
|
}
|
|
@@ -140,8 +178,8 @@ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
|
|
|
140
178
|
return {
|
|
141
179
|
optionProps: {
|
|
142
180
|
...optionProps,
|
|
143
|
-
|
|
144
|
-
id: $87beb89ab4a308fd$export$9145995848b05025(state, key)
|
|
181
|
+
...(0, $eFCLV$reactariautils.mergeProps)(itemProps, hoverProps),
|
|
182
|
+
id: (0, $87beb89ab4a308fd$export$9145995848b05025)(state, key)
|
|
145
183
|
},
|
|
146
184
|
labelProps: {
|
|
147
185
|
id: labelId
|
|
@@ -159,26 +197,35 @@ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
|
|
|
159
197
|
}
|
|
160
198
|
|
|
161
199
|
|
|
162
|
-
|
|
200
|
+
/*
|
|
201
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
202
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
203
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
204
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
205
|
+
*
|
|
206
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
207
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
208
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
209
|
+
* governing permissions and limitations under the License.
|
|
210
|
+
*/
|
|
163
211
|
function $f32afd5f225c3320$export$c3f9f39876e4bc7(props) {
|
|
164
|
-
let { heading: heading ,
|
|
165
|
-
let headingId = $eFCLV$reactariautils.useId();
|
|
212
|
+
let { heading: heading , "aria-label": ariaLabel } = props;
|
|
213
|
+
let headingId = (0, $eFCLV$reactariautils.useId)();
|
|
166
214
|
return {
|
|
167
215
|
itemProps: {
|
|
168
|
-
role:
|
|
216
|
+
role: "presentation"
|
|
169
217
|
},
|
|
170
218
|
headingProps: heading ? {
|
|
171
219
|
// Techincally, listbox cannot contain headings according to ARIA.
|
|
172
220
|
// We hide the heading from assistive technology, and only use it
|
|
173
221
|
// as a label for the nested group.
|
|
174
222
|
id: headingId,
|
|
175
|
-
|
|
176
|
-
} : {
|
|
177
|
-
},
|
|
223
|
+
"aria-hidden": true
|
|
224
|
+
} : {},
|
|
178
225
|
groupProps: {
|
|
179
|
-
role:
|
|
180
|
-
|
|
181
|
-
|
|
226
|
+
role: "group",
|
|
227
|
+
"aria-label": ariaLabel,
|
|
228
|
+
"aria-labelledby": heading ? headingId : undefined
|
|
182
229
|
}
|
|
183
230
|
};
|
|
184
231
|
}
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AEwBO,KAAK,CAAC,yCAAQ,GAAG,GAAG,CAAC,OAAO;SAE1B,kCAAY,CAAC,GAAQ,EAAU,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC,GAAG,KAAK,CAAQ,SACzB,MAAM,CAAC,GAAG,CAAC,OAAO,SAAS,CAAE;IAG/B,MAAM,CAAC,CAAE,IAAG,GAAG;AACjB,CAAC;SAEe,yCAAS,CAAI,KAAmB,EAAE,OAAY,EAAU,CAAC;IACvE,GAAG,CAAC,IAAI,GAAG,yCAAQ,CAAC,GAAG,CAAC,KAAK;IAE7B,EAAE,GAAG,IAAI,EACP,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAc;IAGhC,MAAM,IAAI,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,kCAAY,CAAC,OAAO;AAClD,CAAC;;;;;;;SD0Be,yCAAU,CAAI,KAA4B,EAAE,KAAmB,EAAE,GAA2B,EAAe,CAAC;IAC1H,GAAG,CAAC,QAAQ,GAAG,oCAAc,CAAC,KAAK,EAAE,CAAC;QAAA,SAAS,EAAE,IAAI;IAAA,CAAC;IACtD,GAAG,CAAC,CAAC,YAAA,SAAS,EAAA,CAAC,GAAG,2CAAiB,CAAC,CAAC;WAChC,KAAK;aACR,GAAG;QACH,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,YAAY,EAAE,KAAK,CAAC,YAAY;IAClC,CAAC;IAED,GAAG,CAAC,CAAC,mBAAA,gBAAgB,EAAA,CAAC,GAAG,2C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AU;YACnC,EAAE,EAAE,yCAAS,CAAC,KAAK,EAAE,GAAG;QAC1B,CAAC;QACD,UAAU,EAAE,CAAC;YACX,EAAE,EAAE,OAAO;QACb,CAAC;QACD,gBAAgB,EAAE,CAAC;YACjB,EAAE,EAAE,aAAa;QACnB,CAAC;mBACD,SAAS;oBACT,UAAU;oBACV,UAAU;mBACV,SAAS;yBACT,eAAe;mBACf,SAAS;IACX,CAAC;AACH,CAAC;;;;SC7He,wCAAiB,CAAC,KAA8B,EAAsB,CAAC;IACrF,GAAG,CAAC,CAAC,UAAA,OAAO,GAAE,CAAY,aAAE,SAAS,EAAA,CAAC,GAAG,KAAK;IAC9C,GAAG,CAAC,SAAS,GAAG,2BAAK;IAErB,MAAM,CAAC,CAAC;QACN,SAAS,EAAE,CAAC;YACV,IAAI,EAAE,CAAc;QACtB,CAAC;QACD,YAAY,EAAE,OAAO,GAAG,CAAC;YACvB,EAAkE,AAAlE,gEAAkE;YAClE,EAAiE,AAAjE,+DAAiE;YACjE,EAAmC,AAAnC,iCAAmC;YACnC,EAAE,EAAE,SAAS;YACb,CAAa,cAAE,IAAI;QACrB,CAAC,GAAG,CAAC;QAAA,CAAC;QACN,UAAU,EAAE,CAAC;YACX,IAAI,EAAE,CAAO;YACb,CAAY,aAAE,SAAS;YACvB,CAAiB,kBAAE,OAAO,GAAG,SAAS,GAAG,SAAS;QACpD,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/listbox/src/index.ts","packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/useListBoxSection.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 {useListBox} from './useListBox';\nexport {useOption} from './useOption';\nexport {useListBoxSection} from './useListBoxSection';\nexport {listData, getItemId} from './utils';\n\nexport type {AriaListBoxOptions, ListBoxAria} from './useListBox';\nexport type {AriaOptionProps, OptionAria} from './useOption';\nexport type {AriaListBoxSectionProps, ListBoxSectionAria} from './useListBoxSection';\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 {AriaListBoxProps} from '@react-types/listbox';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {Key, ReactNode, RefObject} from 'react';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useId} from '@react-aria/utils';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface ListBoxAria {\n /** Props for the listbox element. */\n listBoxProps: DOMAttributes,\n /** Props for the listbox's visual label element (if any). */\n labelProps: DOMAttributes\n}\n\nexport interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {\n /** Whether the listbox uses virtual scrolling. */\n isVirtualized?: boolean,\n\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n\n /**\n * Whether the listbox items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean,\n\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n\n /** Whether options should be focused when the user hovers over them. */\n shouldFocusOnHover?: boolean,\n\n /**\n * An optional visual label for the listbox.\n */\n label?: ReactNode,\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends on\n * the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void\n}\n\n/**\n * Provides the behavior and accessibility implementation for a listbox component.\n * A listbox displays a list of options and allows a user to select one or more of them.\n * @param props - Props for the listbox.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ListBoxAria {\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys\n });\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: props.onFocus,\n onBlurWithin: props.onBlur,\n onFocusWithinChange: props.onFocusChange\n });\n\n // Share list id and some props with child options.\n let id = useId(props.id);\n listData.set(state, {\n id,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n shouldFocusOnHover: props.shouldFocusOnHover,\n isVirtualized: props.isVirtualized,\n onAction: props.onAction\n });\n\n let {labelProps, fieldProps} = useLabel({\n ...props,\n id,\n // listbox is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n\n return {\n labelProps,\n listBoxProps: mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n 'aria-multiselectable': 'true'\n } : {}, {\n role: 'listbox',\n ...mergeProps(fieldProps, listProps)\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 {Key} from 'react';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n id: string,\n shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean,\n isVirtualized?: boolean,\n onAction?: (key: Key) => void\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n let data = listData.get(state);\n\n if (!data) {\n throw new Error('Unknown list');\n }\n\n return `${data.id}-option-${normalizeKey(itemKey)}`;\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 {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {Key, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface OptionAria extends SelectableItemStates {\n /** Props for the option element. */\n optionProps: DOMAttributes,\n\n /** Props for the main text element inside the option. */\n labelProps: DOMAttributes,\n\n /** Props for the description text element inside the option, if any. */\n descriptionProps: DOMAttributes,\n\n /** Whether the option is currently focused. */\n isFocused: boolean\n}\n\nexport interface AriaOptionProps {\n /**\n * Whether the option is disabled.\n * @deprecated\n */\n isDisabled?: boolean,\n\n /**\n * Whether the option is selected.\n * @deprecated\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the option. */\n 'aria-label'?: string,\n\n /** The unique key for the option. */\n key: Key,\n\n /**\n * Whether selection should occur on press up instead of press down.\n * @deprecated\n */\n shouldSelectOnPressUp?: boolean,\n\n /**\n * Whether the option should be focused when the user hovers over it.\n * @deprecated\n */\n shouldFocusOnHover?: boolean,\n\n /**\n * Whether the option is contained in a virtual scrolling listbox.\n * @deprecated\n */\n isVirtualized?: boolean,\n\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n * @deprecated\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<FocusableElement>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.disabledKeys.has(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let isFocused = state.selectionManager.focusedKey === key;\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n if (isVirtualized) {\n optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let {itemProps, isPressed, hasAction, allowsSelection} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled,\n onAction: data.onAction ? () => data.onAction(key) : undefined\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(itemProps, hoverProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isSelected,\n isDisabled,\n isPressed,\n allowsSelection,\n hasAction\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 {DOMAttributes} from '@react-types/shared';\nimport {ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface AriaListBoxSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\nexport interface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n headingProps: DOMAttributes,\n\n /** Props for the group element. */\n groupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, listbox cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, and only use it\n // as a label for the nested group.\n id: headingId,\n 'aria-hidden': true\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;ACZA;;;;;;;;;;CAUC,GAED,AAYO,MAAM,4CAAW,IAAI;AAE5B,SAAS,mCAAa,GAAQ,EAAU;IACtC,IAAI,OAAO,QAAQ,UACjB,OAAO,IAAI,OAAO,CAAC,QAAQ;IAG7B,OAAO,KAAK;AACd;AAEO,SAAS,0CAAa,KAAmB,EAAE,OAAY,EAAU;IACtE,IAAI,OAAO,0CAAS,GAAG,CAAC;IAExB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,gBAAgB;IAGlC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,mCAAa,SAAS,CAAC;AACrD;;;;;;;AD0BO,SAAS,0CAAc,KAA4B,EAAE,KAAmB,EAAE,GAA2B,EAAe;IACzH,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW,IAAI;IAAA;IACrD,IAAI,aAAC,UAAS,EAAC,GAAG,CAAA,GAAA,2CAAiB,AAAD,E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e,EAAC,GAAG,CAAA,GAAA,2CAAgB,EAAE;QACzE,kBAAkB,MAAM,gBAAgB;aACxC;aACA;+BACA;QACA,4BAA4B,yBAAyB;uBACrD;+BACA;oBACA;QACA,UAAU,KAAK,QAAQ,GAAG,IAAM,KAAK,QAAQ,CAAC,OAAO,SAAS;IAChE;IAEA,IAAI,cAAC,WAAU,EAAC,GAAG,CAAA,GAAA,qCAAQ,AAAD,EAAE;QAC1B,YAAY,cAAc,CAAC;QAC3B,gBAAe;YACb,IAAI,CAAC,CAAA,GAAA,2CAAa,KAAK;gBACrB,MAAM,gBAAgB,CAAC,UAAU,CAAC,IAAI;gBACtC,MAAM,gBAAgB,CAAC,aAAa,CAAC;YACvC,CAAC;QACH;IACF;IAEA,OAAO;QACL,aAAa;YACX,GAAG,WAAW;YACd,GAAG,CAAA,GAAA,gCAAU,AAAD,EAAE,WAAW,WAAW;YACpC,IAAI,CAAA,GAAA,yCAAS,AAAD,EAAE,OAAO;QACvB;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;mBACA;oBACA;oBACA;mBACA;yBACA;mBACA;IACF;AACF;;;ACpKA;;;;;;;;;;CAUC,GAED;AA2BO,SAAS,yCAAkB,KAA8B,EAAsB;IACpF,IAAI,WAAC,QAAO,EAAE,cAAc,UAAS,EAAC,GAAG;IACzC,IAAI,YAAY,CAAA,GAAA,2BAAK,AAAD;IAEpB,OAAO;QACL,WAAW;YACT,MAAM;QACR;QACA,cAAc,UAAU;YACtB,kEAAkE;YAClE,iEAAiE;YACjE,mCAAmC;YACnC,IAAI;YACJ,eAAe,IAAI;QACrB,IAAI,CAAC,CAAC;QACN,YAAY;YACV,MAAM;YACN,cAAc;YACd,mBAAmB,UAAU,YAAY,SAAS;QACpD;IACF;AACF;;","sources":["packages/@react-aria/listbox/src/index.ts","packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/useListBoxSection.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 {useListBox} from './useListBox';\nexport {useOption} from './useOption';\nexport {useListBoxSection} from './useListBoxSection';\nexport {listData, getItemId} from './utils';\n\nexport type {AriaListBoxOptions, ListBoxAria} from './useListBox';\nexport type {AriaOptionProps, OptionAria} from './useOption';\nexport type {AriaListBoxSectionProps, ListBoxSectionAria} from './useListBoxSection';\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 {AriaListBoxProps} from '@react-types/listbox';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {Key, ReactNode, RefObject} from 'react';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useId} from '@react-aria/utils';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface ListBoxAria {\n /** Props for the listbox element. */\n listBoxProps: DOMAttributes,\n /** Props for the listbox's visual label element (if any). */\n labelProps: DOMAttributes\n}\n\nexport interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {\n /** Whether the listbox uses virtual scrolling. */\n isVirtualized?: boolean,\n\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n\n /**\n * Whether the listbox items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean,\n\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n\n /** Whether options should be focused when the user hovers over them. */\n shouldFocusOnHover?: boolean,\n\n /**\n * An optional visual label for the listbox.\n */\n label?: ReactNode,\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends on\n * the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void\n}\n\n/**\n * Provides the behavior and accessibility implementation for a listbox component.\n * A listbox displays a list of options and allows a user to select one or more of them.\n * @param props - Props for the listbox.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ListBoxAria {\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys\n });\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: props.onFocus,\n onBlurWithin: props.onBlur,\n onFocusWithinChange: props.onFocusChange\n });\n\n // Share list id and some props with child options.\n let id = useId(props.id);\n listData.set(state, {\n id,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n shouldFocusOnHover: props.shouldFocusOnHover,\n isVirtualized: props.isVirtualized,\n onAction: props.onAction\n });\n\n let {labelProps, fieldProps} = useLabel({\n ...props,\n id,\n // listbox is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n\n return {\n labelProps,\n listBoxProps: mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n 'aria-multiselectable': 'true'\n } : {}, {\n role: 'listbox',\n ...mergeProps(fieldProps, listProps)\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 {Key} from 'react';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n id: string,\n shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean,\n isVirtualized?: boolean,\n onAction?: (key: Key) => void\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n let data = listData.get(state);\n\n if (!data) {\n throw new Error('Unknown list');\n }\n\n return `${data.id}-option-${normalizeKey(itemKey)}`;\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 {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {Key, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface OptionAria extends SelectableItemStates {\n /** Props for the option element. */\n optionProps: DOMAttributes,\n\n /** Props for the main text element inside the option. */\n labelProps: DOMAttributes,\n\n /** Props for the description text element inside the option, if any. */\n descriptionProps: DOMAttributes,\n\n /** Whether the option is currently focused. */\n isFocused: boolean\n}\n\nexport interface AriaOptionProps {\n /**\n * Whether the option is disabled.\n * @deprecated\n */\n isDisabled?: boolean,\n\n /**\n * Whether the option is selected.\n * @deprecated\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the option. */\n 'aria-label'?: string,\n\n /** The unique key for the option. */\n key: Key,\n\n /**\n * Whether selection should occur on press up instead of press down.\n * @deprecated\n */\n shouldSelectOnPressUp?: boolean,\n\n /**\n * Whether the option should be focused when the user hovers over it.\n * @deprecated\n */\n shouldFocusOnHover?: boolean,\n\n /**\n * Whether the option is contained in a virtual scrolling listbox.\n * @deprecated\n */\n isVirtualized?: boolean,\n\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n * @deprecated\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<FocusableElement>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.disabledKeys.has(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let isFocused = state.selectionManager.focusedKey === key;\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n if (isVirtualized) {\n optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let {itemProps, isPressed, hasAction, allowsSelection} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled,\n onAction: data.onAction ? () => data.onAction(key) : undefined\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(itemProps, hoverProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isSelected,\n isDisabled,\n isPressed,\n allowsSelection,\n hasAction\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 {DOMAttributes} from '@react-types/shared';\nimport {ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface AriaListBoxSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\nexport interface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n headingProps: DOMAttributes,\n\n /** Props for the group element. */\n groupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, listbox cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, and only use it\n // as a label for the nested group.\n id: headingId,\n 'aria-hidden': true\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.mjs
CHANGED
|
@@ -4,15 +4,45 @@ import {useLabel as $frWMC$useLabel} from "@react-aria/label";
|
|
|
4
4
|
import {useSelectableList as $frWMC$useSelectableList, useSelectableItem as $frWMC$useSelectableItem} from "@react-aria/selection";
|
|
5
5
|
import {getItemCount as $frWMC$getItemCount} from "@react-stately/collections";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/ /*
|
|
18
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
/*
|
|
29
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
30
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
31
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
32
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
+
*
|
|
34
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
35
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
36
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
37
|
+
* governing permissions and limitations under the License.
|
|
38
|
+
*/ const $b1f0cad8af73213b$export$3585ede4d035bf14 = new WeakMap();
|
|
9
39
|
function $b1f0cad8af73213b$var$normalizeKey(key) {
|
|
10
|
-
if (typeof key ===
|
|
11
|
-
return
|
|
40
|
+
if (typeof key === "string") return key.replace(/\s*/g, "");
|
|
41
|
+
return "" + key;
|
|
12
42
|
}
|
|
13
43
|
function $b1f0cad8af73213b$export$9145995848b05025(state, itemKey) {
|
|
14
44
|
let data = $b1f0cad8af73213b$export$3585ede4d035bf14.get(state);
|
|
15
|
-
if (!data) throw new Error(
|
|
45
|
+
if (!data) throw new Error("Unknown list");
|
|
16
46
|
return `${data.id}-option-${$b1f0cad8af73213b$var$normalizeKey(itemKey)}`;
|
|
17
47
|
}
|
|
18
48
|
|
|
@@ -22,24 +52,24 @@ function $b1f0cad8af73213b$export$9145995848b05025(state, itemKey) {
|
|
|
22
52
|
|
|
23
53
|
|
|
24
54
|
function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
|
|
25
|
-
let domProps = $frWMC$filterDOMProps(props, {
|
|
55
|
+
let domProps = (0, $frWMC$filterDOMProps)(props, {
|
|
26
56
|
labelable: true
|
|
27
57
|
});
|
|
28
|
-
let { listProps: listProps } = $frWMC$useSelectableList({
|
|
58
|
+
let { listProps: listProps } = (0, $frWMC$useSelectableList)({
|
|
29
59
|
...props,
|
|
30
60
|
ref: ref,
|
|
31
61
|
selectionManager: state.selectionManager,
|
|
32
62
|
collection: state.collection,
|
|
33
63
|
disabledKeys: state.disabledKeys
|
|
34
64
|
});
|
|
35
|
-
let { focusWithinProps: focusWithinProps } = $frWMC$useFocusWithin({
|
|
65
|
+
let { focusWithinProps: focusWithinProps } = (0, $frWMC$useFocusWithin)({
|
|
36
66
|
onFocusWithin: props.onFocus,
|
|
37
67
|
onBlurWithin: props.onBlur,
|
|
38
68
|
onFocusWithinChange: props.onFocusChange
|
|
39
69
|
});
|
|
40
70
|
// Share list id and some props with child options.
|
|
41
|
-
let id = $frWMC$useId(props.id);
|
|
42
|
-
$b1f0cad8af73213b$export$3585ede4d035bf14.set(state, {
|
|
71
|
+
let id = (0, $frWMC$useId)(props.id);
|
|
72
|
+
(0, $b1f0cad8af73213b$export$3585ede4d035bf14).set(state, {
|
|
43
73
|
id: id,
|
|
44
74
|
shouldUseVirtualFocus: props.shouldUseVirtualFocus,
|
|
45
75
|
shouldSelectOnPressUp: props.shouldSelectOnPressUp,
|
|
@@ -47,34 +77,43 @@ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
|
|
|
47
77
|
isVirtualized: props.isVirtualized,
|
|
48
78
|
onAction: props.onAction
|
|
49
79
|
});
|
|
50
|
-
let { labelProps: labelProps , fieldProps: fieldProps } = $frWMC$useLabel({
|
|
80
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = (0, $frWMC$useLabel)({
|
|
51
81
|
...props,
|
|
52
82
|
id: id,
|
|
53
83
|
// listbox is not an HTML input element so it
|
|
54
84
|
// shouldn't be labeled by a <label> element.
|
|
55
|
-
labelElementType:
|
|
85
|
+
labelElementType: "span"
|
|
56
86
|
});
|
|
57
87
|
return {
|
|
58
88
|
labelProps: labelProps,
|
|
59
|
-
listBoxProps: $frWMC$mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode ===
|
|
60
|
-
|
|
61
|
-
} : {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
...$frWMC$mergeProps(fieldProps, listProps)
|
|
89
|
+
listBoxProps: (0, $frWMC$mergeProps)(domProps, focusWithinProps, state.selectionManager.selectionMode === "multiple" ? {
|
|
90
|
+
"aria-multiselectable": "true"
|
|
91
|
+
} : {}, {
|
|
92
|
+
role: "listbox",
|
|
93
|
+
...(0, $frWMC$mergeProps)(fieldProps, listProps)
|
|
65
94
|
})
|
|
66
95
|
};
|
|
67
96
|
}
|
|
68
97
|
|
|
69
98
|
|
|
70
|
-
|
|
99
|
+
/*
|
|
100
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
101
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
102
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
103
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
104
|
+
*
|
|
105
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
106
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
107
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
108
|
+
* governing permissions and limitations under the License.
|
|
109
|
+
*/
|
|
71
110
|
|
|
72
111
|
|
|
73
112
|
|
|
74
113
|
|
|
75
114
|
function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
|
|
76
115
|
let { key: key } = props;
|
|
77
|
-
let data = $b1f0cad8af73213b$export$3585ede4d035bf14.get(state);
|
|
116
|
+
let data = (0, $b1f0cad8af73213b$export$3585ede4d035bf14).get(state);
|
|
78
117
|
var _isDisabled;
|
|
79
118
|
let isDisabled = (_isDisabled = props.isDisabled) !== null && _isDisabled !== void 0 ? _isDisabled : state.disabledKeys.has(key);
|
|
80
119
|
var _isSelected;
|
|
@@ -88,26 +127,26 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
|
|
|
88
127
|
let shouldUseVirtualFocus = (_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _shouldUseVirtualFocus !== void 0 ? _shouldUseVirtualFocus : data.shouldUseVirtualFocus;
|
|
89
128
|
var _isVirtualized;
|
|
90
129
|
let isVirtualized = (_isVirtualized = props.isVirtualized) !== null && _isVirtualized !== void 0 ? _isVirtualized : data.isVirtualized;
|
|
91
|
-
let labelId = $frWMC$useSlotId();
|
|
92
|
-
let descriptionId = $frWMC$useSlotId();
|
|
130
|
+
let labelId = (0, $frWMC$useSlotId)();
|
|
131
|
+
let descriptionId = (0, $frWMC$useSlotId)();
|
|
93
132
|
let optionProps = {
|
|
94
|
-
role:
|
|
95
|
-
|
|
96
|
-
|
|
133
|
+
role: "option",
|
|
134
|
+
"aria-disabled": isDisabled,
|
|
135
|
+
"aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined
|
|
97
136
|
};
|
|
98
137
|
// Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply "text".
|
|
99
138
|
// We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.
|
|
100
139
|
// https://bugs.webkit.org/show_bug.cgi?id=209279
|
|
101
|
-
if (!($frWMC$isMac() && $frWMC$isWebKit())) {
|
|
102
|
-
optionProps[
|
|
103
|
-
optionProps[
|
|
104
|
-
optionProps[
|
|
140
|
+
if (!((0, $frWMC$isMac)() && (0, $frWMC$isWebKit)())) {
|
|
141
|
+
optionProps["aria-label"] = props["aria-label"];
|
|
142
|
+
optionProps["aria-labelledby"] = labelId;
|
|
143
|
+
optionProps["aria-describedby"] = descriptionId;
|
|
105
144
|
}
|
|
106
145
|
if (isVirtualized) {
|
|
107
|
-
optionProps[
|
|
108
|
-
optionProps[
|
|
146
|
+
optionProps["aria-posinset"] = state.collection.getItem(key).index + 1;
|
|
147
|
+
optionProps["aria-setsize"] = (0, $frWMC$getItemCount)(state.collection);
|
|
109
148
|
}
|
|
110
|
-
let { itemProps: itemProps , isPressed: isPressed , hasAction: hasAction , allowsSelection: allowsSelection } = $frWMC$useSelectableItem({
|
|
149
|
+
let { itemProps: itemProps , isPressed: isPressed , hasAction: hasAction , allowsSelection: allowsSelection } = (0, $frWMC$useSelectableItem)({
|
|
111
150
|
selectionManager: state.selectionManager,
|
|
112
151
|
key: key,
|
|
113
152
|
ref: ref,
|
|
@@ -116,13 +155,12 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
|
|
|
116
155
|
isVirtualized: isVirtualized,
|
|
117
156
|
shouldUseVirtualFocus: shouldUseVirtualFocus,
|
|
118
157
|
isDisabled: isDisabled,
|
|
119
|
-
onAction: data.onAction ? ()=>data.onAction(key)
|
|
120
|
-
: undefined
|
|
158
|
+
onAction: data.onAction ? ()=>data.onAction(key) : undefined
|
|
121
159
|
});
|
|
122
|
-
let { hoverProps: hoverProps } = $frWMC$useHover({
|
|
160
|
+
let { hoverProps: hoverProps } = (0, $frWMC$useHover)({
|
|
123
161
|
isDisabled: isDisabled || !shouldFocusOnHover,
|
|
124
162
|
onHoverStart () {
|
|
125
|
-
if (
|
|
163
|
+
if (!(0, $frWMC$isFocusVisible)()) {
|
|
126
164
|
state.selectionManager.setFocused(true);
|
|
127
165
|
state.selectionManager.setFocusedKey(key);
|
|
128
166
|
}
|
|
@@ -131,8 +169,8 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
|
|
|
131
169
|
return {
|
|
132
170
|
optionProps: {
|
|
133
171
|
...optionProps,
|
|
134
|
-
|
|
135
|
-
id: $b1f0cad8af73213b$export$9145995848b05025(state, key)
|
|
172
|
+
...(0, $frWMC$mergeProps)(itemProps, hoverProps),
|
|
173
|
+
id: (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key)
|
|
136
174
|
},
|
|
137
175
|
labelProps: {
|
|
138
176
|
id: labelId
|
|
@@ -150,26 +188,35 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
|
|
|
150
188
|
}
|
|
151
189
|
|
|
152
190
|
|
|
153
|
-
|
|
191
|
+
/*
|
|
192
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
193
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
194
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
195
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
*
|
|
197
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
198
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
199
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
200
|
+
* governing permissions and limitations under the License.
|
|
201
|
+
*/
|
|
154
202
|
function $af383d3bef1cfdc9$export$c3f9f39876e4bc7(props) {
|
|
155
|
-
let { heading: heading ,
|
|
156
|
-
let headingId = $frWMC$useId();
|
|
203
|
+
let { heading: heading , "aria-label": ariaLabel } = props;
|
|
204
|
+
let headingId = (0, $frWMC$useId)();
|
|
157
205
|
return {
|
|
158
206
|
itemProps: {
|
|
159
|
-
role:
|
|
207
|
+
role: "presentation"
|
|
160
208
|
},
|
|
161
209
|
headingProps: heading ? {
|
|
162
210
|
// Techincally, listbox cannot contain headings according to ARIA.
|
|
163
211
|
// We hide the heading from assistive technology, and only use it
|
|
164
212
|
// as a label for the nested group.
|
|
165
213
|
id: headingId,
|
|
166
|
-
|
|
167
|
-
} : {
|
|
168
|
-
},
|
|
214
|
+
"aria-hidden": true
|
|
215
|
+
} : {},
|
|
169
216
|
groupProps: {
|
|
170
|
-
role:
|
|
171
|
-
|
|
172
|
-
|
|
217
|
+
role: "group",
|
|
218
|
+
"aria-label": ariaLabel,
|
|
219
|
+
"aria-labelledby": heading ? headingId : undefined
|
|
173
220
|
}
|
|
174
221
|
};
|
|
175
222
|
}
|
package/dist/module.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AEwBO,KAAK,CAAC,yCAAQ,GAAG,GAAG,CAAC,OAAO;SAE1B,kCAAY,CAAC,GAAQ,EAAU,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC,GAAG,KAAK,CAAQ,SACzB,MAAM,CAAC,GAAG,CAAC,OAAO,SAAS,CAAE;IAG/B,MAAM,CAAC,CAAE,IAAG,GAAG;AACjB,CAAC;SAEe,yCAAS,CAAI,KAAmB,EAAE,OAAY,EAAU,CAAC;IACvE,GAAG,CAAC,IAAI,GAAG,yCAAQ,CAAC,GAAG,CAAC,KAAK;IAE7B,EAAE,GAAG,IAAI,EACP,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAc;IAGhC,MAAM,IAAI,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,kCAAY,CAAC,OAAO;AAClD,CAAC;;;;;;;SD0Be,yCAAU,CAAI,KAA4B,EAAE,KAAmB,EAAE,GAA2B,EAAe,CAAC;IAC1H,GAAG,CAAC,QAAQ,GAAG,qBAAc,CAAC,KAAK,EAAE,CAAC;QAAA,SAAS,EAAE,IAAI;IAAA,CAAC;IACtD,GAAG,CAAC,CAAC,YAAA,SAAS,EAAA,CAAC,GAAG,wBAAiB,CAAC,CAAC;WAChC,KAAK;aACR,GAAG;QACH,gBAAgB,E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,CAAC,gBAAgB,CAAC,aAAa,CAAC,GAAG;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,CAAC,CAAC;QACN,WAAW,EAAE,CAAC;eACT,WAAW;eACX,iBAAU,CAAC,SAAS,EAAE,UAAU;YACnC,EAAE,EAAE,yCAAS,CAAC,KAAK,EAAE,GAAG;QAC1B,CAAC;QACD,UAAU,EAAE,CAAC;YACX,EAAE,EAAE,OAAO;QACb,CAAC;QACD,gBAAgB,EAAE,CAAC;YACjB,EAAE,EAAE,aAAa;QACnB,CAAC;mBACD,SAAS;oBACT,UAAU;oBACV,UAAU;mBACV,SAAS;yBACT,eAAe;mBACf,SAAS;IACX,CAAC;AACH,CAAC;;;;SC7He,wCAAiB,CAAC,KAA8B,EAAsB,CAAC;IACrF,GAAG,CAAC,CAAC,UAAA,OAAO,GAAE,CAAY,aAAE,SAAS,EAAA,CAAC,GAAG,KAAK;IAC9C,GAAG,CAAC,SAAS,GAAG,YAAK;IAErB,MAAM,CAAC,CAAC;QACN,SAAS,EAAE,CAAC;YACV,IAAI,EAAE,CAAc;QACtB,CAAC;QACD,YAAY,EAAE,OAAO,GAAG,CAAC;YACvB,EAAkE,AAAlE,gEAAkE;YAClE,EAAiE,AAAjE,+DAAiE;YACjE,EAAmC,AAAnC,iCAAmC;YACnC,EAAE,EAAE,SAAS;YACb,CAAa,cAAE,IAAI;QACrB,CAAC,GAAG,CAAC;QAAA,CAAC;QACN,UAAU,EAAE,CAAC;YACX,IAAI,EAAE,CAAO;YACb,CAAY,aAAE,SAAS;YACvB,CAAiB,kBAAE,OAAO,GAAG,SAAS,GAAG,SAAS;QACpD,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/listbox/src/index.ts","packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/useListBoxSection.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 {useListBox} from './useListBox';\nexport {useOption} from './useOption';\nexport {useListBoxSection} from './useListBoxSection';\nexport {listData, getItemId} from './utils';\n\nexport type {AriaListBoxOptions, ListBoxAria} from './useListBox';\nexport type {AriaOptionProps, OptionAria} from './useOption';\nexport type {AriaListBoxSectionProps, ListBoxSectionAria} from './useListBoxSection';\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 {AriaListBoxProps} from '@react-types/listbox';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {Key, ReactNode, RefObject} from 'react';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useId} from '@react-aria/utils';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface ListBoxAria {\n /** Props for the listbox element. */\n listBoxProps: DOMAttributes,\n /** Props for the listbox's visual label element (if any). */\n labelProps: DOMAttributes\n}\n\nexport interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {\n /** Whether the listbox uses virtual scrolling. */\n isVirtualized?: boolean,\n\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n\n /**\n * Whether the listbox items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean,\n\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n\n /** Whether options should be focused when the user hovers over them. */\n shouldFocusOnHover?: boolean,\n\n /**\n * An optional visual label for the listbox.\n */\n label?: ReactNode,\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends on\n * the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void\n}\n\n/**\n * Provides the behavior and accessibility implementation for a listbox component.\n * A listbox displays a list of options and allows a user to select one or more of them.\n * @param props - Props for the listbox.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ListBoxAria {\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys\n });\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: props.onFocus,\n onBlurWithin: props.onBlur,\n onFocusWithinChange: props.onFocusChange\n });\n\n // Share list id and some props with child options.\n let id = useId(props.id);\n listData.set(state, {\n id,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n shouldFocusOnHover: props.shouldFocusOnHover,\n isVirtualized: props.isVirtualized,\n onAction: props.onAction\n });\n\n let {labelProps, fieldProps} = useLabel({\n ...props,\n id,\n // listbox is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n\n return {\n labelProps,\n listBoxProps: mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n 'aria-multiselectable': 'true'\n } : {}, {\n role: 'listbox',\n ...mergeProps(fieldProps, listProps)\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 {Key} from 'react';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n id: string,\n shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean,\n isVirtualized?: boolean,\n onAction?: (key: Key) => void\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n let data = listData.get(state);\n\n if (!data) {\n throw new Error('Unknown list');\n }\n\n return `${data.id}-option-${normalizeKey(itemKey)}`;\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 {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {Key, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface OptionAria extends SelectableItemStates {\n /** Props for the option element. */\n optionProps: DOMAttributes,\n\n /** Props for the main text element inside the option. */\n labelProps: DOMAttributes,\n\n /** Props for the description text element inside the option, if any. */\n descriptionProps: DOMAttributes,\n\n /** Whether the option is currently focused. */\n isFocused: boolean\n}\n\nexport interface AriaOptionProps {\n /**\n * Whether the option is disabled.\n * @deprecated\n */\n isDisabled?: boolean,\n\n /**\n * Whether the option is selected.\n * @deprecated\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the option. */\n 'aria-label'?: string,\n\n /** The unique key for the option. */\n key: Key,\n\n /**\n * Whether selection should occur on press up instead of press down.\n * @deprecated\n */\n shouldSelectOnPressUp?: boolean,\n\n /**\n * Whether the option should be focused when the user hovers over it.\n * @deprecated\n */\n shouldFocusOnHover?: boolean,\n\n /**\n * Whether the option is contained in a virtual scrolling listbox.\n * @deprecated\n */\n isVirtualized?: boolean,\n\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n * @deprecated\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<FocusableElement>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.disabledKeys.has(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let isFocused = state.selectionManager.focusedKey === key;\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n if (isVirtualized) {\n optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let {itemProps, isPressed, hasAction, allowsSelection} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled,\n onAction: data.onAction ? () => data.onAction(key) : undefined\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(itemProps, hoverProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isSelected,\n isDisabled,\n isPressed,\n allowsSelection,\n hasAction\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 {DOMAttributes} from '@react-types/shared';\nimport {ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface AriaListBoxSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\nexport interface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n headingProps: DOMAttributes,\n\n /** Props for the group element. */\n groupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, listbox cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, and only use it\n // as a label for the nested group.\n id: headingId,\n 'aria-hidden': true\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"module.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;ACZA;;;;;;;;;;CAUC,GAED,AAYO,MAAM,4CAAW,IAAI;AAE5B,SAAS,mCAAa,GAAQ,EAAU;IACtC,IAAI,OAAO,QAAQ,UACjB,OAAO,IAAI,OAAO,CAAC,QAAQ;IAG7B,OAAO,KAAK;AACd;AAEO,SAAS,0CAAa,KAAmB,EAAE,OAAY,EAAU;IACtE,IAAI,OAAO,0CAAS,GAAG,CAAC;IAExB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,gBAAgB;IAGlC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,mCAAa,SAAS,CAAC;AACrD;;;;;;;AD0BO,SAAS,0CAAc,KAA4B,EAAE,KAAmB,EA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,SAAS;QACpD;IACF;AACF;;","sources":["packages/@react-aria/listbox/src/index.ts","packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/useListBoxSection.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 {useListBox} from './useListBox';\nexport {useOption} from './useOption';\nexport {useListBoxSection} from './useListBoxSection';\nexport {listData, getItemId} from './utils';\n\nexport type {AriaListBoxOptions, ListBoxAria} from './useListBox';\nexport type {AriaOptionProps, OptionAria} from './useOption';\nexport type {AriaListBoxSectionProps, ListBoxSectionAria} from './useListBoxSection';\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 {AriaListBoxProps} from '@react-types/listbox';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {Key, ReactNode, RefObject} from 'react';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useId} from '@react-aria/utils';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface ListBoxAria {\n /** Props for the listbox element. */\n listBoxProps: DOMAttributes,\n /** Props for the listbox's visual label element (if any). */\n labelProps: DOMAttributes\n}\n\nexport interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {\n /** Whether the listbox uses virtual scrolling. */\n isVirtualized?: boolean,\n\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n\n /**\n * Whether the listbox items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean,\n\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n\n /** Whether options should be focused when the user hovers over them. */\n shouldFocusOnHover?: boolean,\n\n /**\n * An optional visual label for the listbox.\n */\n label?: ReactNode,\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends on\n * the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void\n}\n\n/**\n * Provides the behavior and accessibility implementation for a listbox component.\n * A listbox displays a list of options and allows a user to select one or more of them.\n * @param props - Props for the listbox.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ListBoxAria {\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys\n });\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: props.onFocus,\n onBlurWithin: props.onBlur,\n onFocusWithinChange: props.onFocusChange\n });\n\n // Share list id and some props with child options.\n let id = useId(props.id);\n listData.set(state, {\n id,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n shouldFocusOnHover: props.shouldFocusOnHover,\n isVirtualized: props.isVirtualized,\n onAction: props.onAction\n });\n\n let {labelProps, fieldProps} = useLabel({\n ...props,\n id,\n // listbox is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n\n return {\n labelProps,\n listBoxProps: mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n 'aria-multiselectable': 'true'\n } : {}, {\n role: 'listbox',\n ...mergeProps(fieldProps, listProps)\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 {Key} from 'react';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n id: string,\n shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean,\n isVirtualized?: boolean,\n onAction?: (key: Key) => void\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n let data = listData.get(state);\n\n if (!data) {\n throw new Error('Unknown list');\n }\n\n return `${data.id}-option-${normalizeKey(itemKey)}`;\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 {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {Key, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface OptionAria extends SelectableItemStates {\n /** Props for the option element. */\n optionProps: DOMAttributes,\n\n /** Props for the main text element inside the option. */\n labelProps: DOMAttributes,\n\n /** Props for the description text element inside the option, if any. */\n descriptionProps: DOMAttributes,\n\n /** Whether the option is currently focused. */\n isFocused: boolean\n}\n\nexport interface AriaOptionProps {\n /**\n * Whether the option is disabled.\n * @deprecated\n */\n isDisabled?: boolean,\n\n /**\n * Whether the option is selected.\n * @deprecated\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the option. */\n 'aria-label'?: string,\n\n /** The unique key for the option. */\n key: Key,\n\n /**\n * Whether selection should occur on press up instead of press down.\n * @deprecated\n */\n shouldSelectOnPressUp?: boolean,\n\n /**\n * Whether the option should be focused when the user hovers over it.\n * @deprecated\n */\n shouldFocusOnHover?: boolean,\n\n /**\n * Whether the option is contained in a virtual scrolling listbox.\n * @deprecated\n */\n isVirtualized?: boolean,\n\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n * @deprecated\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<FocusableElement>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.disabledKeys.has(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let isFocused = state.selectionManager.focusedKey === key;\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n if (isVirtualized) {\n optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let {itemProps, isPressed, hasAction, allowsSelection} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled,\n onAction: data.onAction ? () => data.onAction(key) : undefined\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(itemProps, hoverProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isSelected,\n isDisabled,\n isPressed,\n allowsSelection,\n hasAction\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 {DOMAttributes} from '@react-types/shared';\nimport {ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface AriaListBoxSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\nexport interface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n headingProps: DOMAttributes,\n\n /** Props for the group element. */\n groupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, listbox cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, and only use it\n // as a label for the nested group.\n id: headingId,\n 'aria-hidden': true\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"module.mjs.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/listbox",
|
|
3
|
-
"version": "3.7.2-nightly.
|
|
3
|
+
"version": "3.7.2-nightly.3600+bfce84fee",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@react-aria/
|
|
27
|
-
"@react-aria/
|
|
28
|
-
"@react-aria/
|
|
29
|
-
"@react-aria/
|
|
30
|
-
"@react-
|
|
31
|
-
"@react-stately/
|
|
32
|
-
"@react-
|
|
33
|
-
"@react-types/
|
|
34
|
-
"@
|
|
25
|
+
"@react-aria/focus": "3.0.0-nightly.1900+bfce84fee",
|
|
26
|
+
"@react-aria/interactions": "3.0.0-nightly.1900+bfce84fee",
|
|
27
|
+
"@react-aria/label": "3.0.0-nightly.1900+bfce84fee",
|
|
28
|
+
"@react-aria/selection": "3.0.0-nightly.1900+bfce84fee",
|
|
29
|
+
"@react-aria/utils": "3.0.0-nightly.1900+bfce84fee",
|
|
30
|
+
"@react-stately/collections": "3.0.0-nightly.1900+bfce84fee",
|
|
31
|
+
"@react-stately/list": "3.6.1-nightly.3600+bfce84fee",
|
|
32
|
+
"@react-types/listbox": "3.3.6-nightly.3600+bfce84fee",
|
|
33
|
+
"@react-types/shared": "3.0.0-nightly.1900+bfce84fee",
|
|
34
|
+
"@swc/helpers": "^0.4.14"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "bfce84fee12a027d9cbc38b43e1747e3e4b4b169"
|
|
43
43
|
}
|