@react-aria/listbox 3.7.3-nightly.3696 → 3.7.3-nightly.3705
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +229 -0
- package/package.json +16 -11
package/dist/import.mjs
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import {filterDOMProps as $frWMC$filterDOMProps, useId as $frWMC$useId, mergeProps as $frWMC$mergeProps, useSlotId as $frWMC$useSlotId, isMac as $frWMC$isMac, isWebKit as $frWMC$isWebKit} from "@react-aria/utils";
|
|
2
|
+
import {useFocusWithin as $frWMC$useFocusWithin, useHover as $frWMC$useHover, isFocusVisible as $frWMC$isFocusVisible} from "@react-aria/interactions";
|
|
3
|
+
import {useLabel as $frWMC$useLabel} from "@react-aria/label";
|
|
4
|
+
import {useSelectableList as $frWMC$useSelectableList, useSelectableItem as $frWMC$useSelectableItem} from "@react-aria/selection";
|
|
5
|
+
import {getItemCount as $frWMC$getItemCount} from "@react-stately/collections";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/ /*
|
|
18
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
/*
|
|
29
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
30
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
31
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
32
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
+
*
|
|
34
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
35
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
36
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
37
|
+
* governing permissions and limitations under the License.
|
|
38
|
+
*/ const $b1f0cad8af73213b$export$3585ede4d035bf14 = new WeakMap();
|
|
39
|
+
function $b1f0cad8af73213b$var$normalizeKey(key) {
|
|
40
|
+
if (typeof key === "string") return key.replace(/\s*/g, "");
|
|
41
|
+
return "" + key;
|
|
42
|
+
}
|
|
43
|
+
function $b1f0cad8af73213b$export$9145995848b05025(state, itemKey) {
|
|
44
|
+
let data = $b1f0cad8af73213b$export$3585ede4d035bf14.get(state);
|
|
45
|
+
if (!data) throw new Error("Unknown list");
|
|
46
|
+
return `${data.id}-option-${$b1f0cad8af73213b$var$normalizeKey(itemKey)}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
|
|
55
|
+
let domProps = (0, $frWMC$filterDOMProps)(props, {
|
|
56
|
+
labelable: true
|
|
57
|
+
});
|
|
58
|
+
let { listProps: listProps } = (0, $frWMC$useSelectableList)({
|
|
59
|
+
...props,
|
|
60
|
+
ref: ref,
|
|
61
|
+
selectionManager: state.selectionManager,
|
|
62
|
+
collection: state.collection,
|
|
63
|
+
disabledKeys: state.disabledKeys
|
|
64
|
+
});
|
|
65
|
+
let { focusWithinProps: focusWithinProps } = (0, $frWMC$useFocusWithin)({
|
|
66
|
+
onFocusWithin: props.onFocus,
|
|
67
|
+
onBlurWithin: props.onBlur,
|
|
68
|
+
onFocusWithinChange: props.onFocusChange
|
|
69
|
+
});
|
|
70
|
+
// Share list id and some props with child options.
|
|
71
|
+
let id = (0, $frWMC$useId)(props.id);
|
|
72
|
+
(0, $b1f0cad8af73213b$export$3585ede4d035bf14).set(state, {
|
|
73
|
+
id: id,
|
|
74
|
+
shouldUseVirtualFocus: props.shouldUseVirtualFocus,
|
|
75
|
+
shouldSelectOnPressUp: props.shouldSelectOnPressUp,
|
|
76
|
+
shouldFocusOnHover: props.shouldFocusOnHover,
|
|
77
|
+
isVirtualized: props.isVirtualized,
|
|
78
|
+
onAction: props.onAction
|
|
79
|
+
});
|
|
80
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = (0, $frWMC$useLabel)({
|
|
81
|
+
...props,
|
|
82
|
+
id: id,
|
|
83
|
+
// listbox is not an HTML input element so it
|
|
84
|
+
// shouldn't be labeled by a <label> element.
|
|
85
|
+
labelElementType: "span"
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
labelProps: labelProps,
|
|
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)
|
|
94
|
+
})
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
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
|
+
*/
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
|
|
115
|
+
let { key: key } = props;
|
|
116
|
+
let data = (0, $b1f0cad8af73213b$export$3585ede4d035bf14).get(state);
|
|
117
|
+
var _props_isDisabled;
|
|
118
|
+
let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.disabledKeys.has(key);
|
|
119
|
+
var _props_isSelected;
|
|
120
|
+
let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : state.selectionManager.isSelected(key);
|
|
121
|
+
let isFocused = state.selectionManager.focusedKey === key;
|
|
122
|
+
var _props_shouldSelectOnPressUp;
|
|
123
|
+
let shouldSelectOnPressUp = (_props_shouldSelectOnPressUp = props.shouldSelectOnPressUp) !== null && _props_shouldSelectOnPressUp !== void 0 ? _props_shouldSelectOnPressUp : data.shouldSelectOnPressUp;
|
|
124
|
+
var _props_shouldFocusOnHover;
|
|
125
|
+
let shouldFocusOnHover = (_props_shouldFocusOnHover = props.shouldFocusOnHover) !== null && _props_shouldFocusOnHover !== void 0 ? _props_shouldFocusOnHover : data.shouldFocusOnHover;
|
|
126
|
+
var _props_shouldUseVirtualFocus;
|
|
127
|
+
let shouldUseVirtualFocus = (_props_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _props_shouldUseVirtualFocus !== void 0 ? _props_shouldUseVirtualFocus : data.shouldUseVirtualFocus;
|
|
128
|
+
var _props_isVirtualized;
|
|
129
|
+
let isVirtualized = (_props_isVirtualized = props.isVirtualized) !== null && _props_isVirtualized !== void 0 ? _props_isVirtualized : data.isVirtualized;
|
|
130
|
+
let labelId = (0, $frWMC$useSlotId)();
|
|
131
|
+
let descriptionId = (0, $frWMC$useSlotId)();
|
|
132
|
+
let optionProps = {
|
|
133
|
+
role: "option",
|
|
134
|
+
"aria-disabled": isDisabled,
|
|
135
|
+
"aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined
|
|
136
|
+
};
|
|
137
|
+
// Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply "text".
|
|
138
|
+
// We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.
|
|
139
|
+
// https://bugs.webkit.org/show_bug.cgi?id=209279
|
|
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;
|
|
144
|
+
}
|
|
145
|
+
if (isVirtualized) {
|
|
146
|
+
optionProps["aria-posinset"] = state.collection.getItem(key).index + 1;
|
|
147
|
+
optionProps["aria-setsize"] = (0, $frWMC$getItemCount)(state.collection);
|
|
148
|
+
}
|
|
149
|
+
let { itemProps: itemProps , isPressed: isPressed , hasAction: hasAction , allowsSelection: allowsSelection } = (0, $frWMC$useSelectableItem)({
|
|
150
|
+
selectionManager: state.selectionManager,
|
|
151
|
+
key: key,
|
|
152
|
+
ref: ref,
|
|
153
|
+
shouldSelectOnPressUp: shouldSelectOnPressUp,
|
|
154
|
+
allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,
|
|
155
|
+
isVirtualized: isVirtualized,
|
|
156
|
+
shouldUseVirtualFocus: shouldUseVirtualFocus,
|
|
157
|
+
isDisabled: isDisabled,
|
|
158
|
+
onAction: data.onAction ? ()=>data.onAction(key) : undefined
|
|
159
|
+
});
|
|
160
|
+
let { hoverProps: hoverProps } = (0, $frWMC$useHover)({
|
|
161
|
+
isDisabled: isDisabled || !shouldFocusOnHover,
|
|
162
|
+
onHoverStart () {
|
|
163
|
+
if (!(0, $frWMC$isFocusVisible)()) {
|
|
164
|
+
state.selectionManager.setFocused(true);
|
|
165
|
+
state.selectionManager.setFocusedKey(key);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
optionProps: {
|
|
171
|
+
...optionProps,
|
|
172
|
+
...(0, $frWMC$mergeProps)(itemProps, hoverProps),
|
|
173
|
+
id: (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key)
|
|
174
|
+
},
|
|
175
|
+
labelProps: {
|
|
176
|
+
id: labelId
|
|
177
|
+
},
|
|
178
|
+
descriptionProps: {
|
|
179
|
+
id: descriptionId
|
|
180
|
+
},
|
|
181
|
+
isFocused: isFocused,
|
|
182
|
+
isSelected: isSelected,
|
|
183
|
+
isDisabled: isDisabled,
|
|
184
|
+
isPressed: isPressed,
|
|
185
|
+
allowsSelection: allowsSelection,
|
|
186
|
+
hasAction: hasAction
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
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
|
+
*/
|
|
202
|
+
function $af383d3bef1cfdc9$export$c3f9f39876e4bc7(props) {
|
|
203
|
+
let { heading: heading , "aria-label": ariaLabel } = props;
|
|
204
|
+
let headingId = (0, $frWMC$useId)();
|
|
205
|
+
return {
|
|
206
|
+
itemProps: {
|
|
207
|
+
role: "presentation"
|
|
208
|
+
},
|
|
209
|
+
headingProps: heading ? {
|
|
210
|
+
// Techincally, listbox cannot contain headings according to ARIA.
|
|
211
|
+
// We hide the heading from assistive technology, and only use it
|
|
212
|
+
// as a label for the nested group.
|
|
213
|
+
id: headingId,
|
|
214
|
+
"aria-hidden": true
|
|
215
|
+
} : {},
|
|
216
|
+
groupProps: {
|
|
217
|
+
role: "group",
|
|
218
|
+
"aria-label": ariaLabel,
|
|
219
|
+
"aria-labelledby": heading ? headingId : undefined
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
export {$c132121280ec012d$export$50eacbbf140a3141 as useListBox, $293f70390ea03370$export$497855f14858aa34 as useOption, $af383d3bef1cfdc9$export$c3f9f39876e4bc7 as useListBoxSection, $b1f0cad8af73213b$export$3585ede4d035bf14 as listData, $b1f0cad8af73213b$export$9145995848b05025 as getItemId};
|
|
229
|
+
//# sourceMappingURL=module.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/listbox",
|
|
3
|
-
"version": "3.7.3-nightly.
|
|
3
|
+
"version": "3.7.3-nightly.3705+93b3c951e",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
8
13
|
"types": "dist/types.d.ts",
|
|
9
14
|
"source": "src/index.ts",
|
|
10
15
|
"files": [
|
|
@@ -17,15 +22,15 @@
|
|
|
17
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
18
23
|
},
|
|
19
24
|
"dependencies": {
|
|
20
|
-
"@react-aria/focus": "3.0.0-nightly.
|
|
21
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
22
|
-
"@react-aria/label": "3.0.0-nightly.
|
|
23
|
-
"@react-aria/selection": "3.0.0-nightly.
|
|
24
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
25
|
-
"@react-stately/collections": "3.0.0-nightly.
|
|
26
|
-
"@react-stately/list": "3.6.2-nightly.
|
|
27
|
-
"@react-types/listbox": "3.3.6-nightly.
|
|
28
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
25
|
+
"@react-aria/focus": "3.0.0-nightly.2005+93b3c951e",
|
|
26
|
+
"@react-aria/interactions": "3.0.0-nightly.2005+93b3c951e",
|
|
27
|
+
"@react-aria/label": "3.0.0-nightly.2005+93b3c951e",
|
|
28
|
+
"@react-aria/selection": "3.0.0-nightly.2005+93b3c951e",
|
|
29
|
+
"@react-aria/utils": "3.0.0-nightly.2005+93b3c951e",
|
|
30
|
+
"@react-stately/collections": "3.0.0-nightly.2005+93b3c951e",
|
|
31
|
+
"@react-stately/list": "3.6.2-nightly.3705+93b3c951e",
|
|
32
|
+
"@react-types/listbox": "3.3.6-nightly.3705+93b3c951e",
|
|
33
|
+
"@react-types/shared": "3.0.0-nightly.2005+93b3c951e",
|
|
29
34
|
"@swc/helpers": "^0.4.14"
|
|
30
35
|
},
|
|
31
36
|
"peerDependencies": {
|
|
@@ -34,5 +39,5 @@
|
|
|
34
39
|
"publishConfig": {
|
|
35
40
|
"access": "public"
|
|
36
41
|
},
|
|
37
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "93b3c951eb784b14183f9988f2d188b34de8f42d"
|
|
38
43
|
}
|