@react-aria/gridlist 3.1.3-nightly.3698 → 3.1.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 +285 -0
- package/package.json +16 -11
package/dist/import.mjs
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import {useId as $13Gtr$useId, filterDOMProps as $13Gtr$filterDOMProps, mergeProps as $13Gtr$mergeProps, useSlotId as $13Gtr$useSlotId, scrollIntoViewport as $13Gtr$scrollIntoViewport, getScrollParent as $13Gtr$getScrollParent} from "@react-aria/utils";
|
|
2
|
+
import {useHighlightSelectionDescription as $13Gtr$useHighlightSelectionDescription, useGridSelectionAnnouncement as $13Gtr$useGridSelectionAnnouncement, useGridSelectionCheckbox as $13Gtr$useGridSelectionCheckbox} from "@react-aria/grid";
|
|
3
|
+
import {useSelectableList as $13Gtr$useSelectableList, useSelectableItem as $13Gtr$useSelectableItem} from "@react-aria/selection";
|
|
4
|
+
import {focusSafely as $13Gtr$focusSafely, getFocusableTreeWalker as $13Gtr$getFocusableTreeWalker} from "@react-aria/focus";
|
|
5
|
+
import {isFocusVisible as $13Gtr$isFocusVisible} from "@react-aria/interactions";
|
|
6
|
+
import {useLocale as $13Gtr$useLocale} from "@react-aria/i18n";
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
10
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
+
* governing permissions and limitations under the License.
|
|
18
|
+
*/ /*
|
|
19
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
20
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
22
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
+
*
|
|
24
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
25
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
26
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
27
|
+
* governing permissions and limitations under the License.
|
|
28
|
+
*/
|
|
29
|
+
/*
|
|
30
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
31
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
32
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
33
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
34
|
+
*
|
|
35
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
36
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
37
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
38
|
+
* governing permissions and limitations under the License.
|
|
39
|
+
*/ const $ce9b18daab526bbd$export$5b9bb410392e3991 = new WeakMap();
|
|
40
|
+
function $ce9b18daab526bbd$export$f45c25170b9a99c2(state, key) {
|
|
41
|
+
let { id: id } = $ce9b18daab526bbd$export$5b9bb410392e3991.get(state);
|
|
42
|
+
if (!id) throw new Error("Unknown list");
|
|
43
|
+
return `${id}-${$ce9b18daab526bbd$export$e0c709538cb8ae18(key)}`;
|
|
44
|
+
}
|
|
45
|
+
function $ce9b18daab526bbd$export$e0c709538cb8ae18(key) {
|
|
46
|
+
if (typeof key === "string") return key.replace(/\s*/g, "");
|
|
47
|
+
return "" + key;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
function $f47efb0c3a859cf2$export$664f9155035607eb(props, state, ref) {
|
|
54
|
+
let { isVirtualized: isVirtualized , keyboardDelegate: keyboardDelegate , onAction: onAction } = props;
|
|
55
|
+
if (!props["aria-label"] && !props["aria-labelledby"]) console.warn("An aria-label or aria-labelledby prop is required for accessibility.");
|
|
56
|
+
let { listProps: listProps } = (0, $13Gtr$useSelectableList)({
|
|
57
|
+
selectionManager: state.selectionManager,
|
|
58
|
+
collection: state.collection,
|
|
59
|
+
disabledKeys: state.disabledKeys,
|
|
60
|
+
ref: ref,
|
|
61
|
+
keyboardDelegate: keyboardDelegate,
|
|
62
|
+
isVirtualized: isVirtualized,
|
|
63
|
+
selectOnFocus: state.selectionManager.selectionBehavior === "replace"
|
|
64
|
+
});
|
|
65
|
+
let id = (0, $13Gtr$useId)(props.id);
|
|
66
|
+
(0, $ce9b18daab526bbd$export$5b9bb410392e3991).set(state, {
|
|
67
|
+
id: id,
|
|
68
|
+
onAction: onAction
|
|
69
|
+
});
|
|
70
|
+
let descriptionProps = (0, $13Gtr$useHighlightSelectionDescription)({
|
|
71
|
+
selectionManager: state.selectionManager,
|
|
72
|
+
hasItemActions: !!onAction
|
|
73
|
+
});
|
|
74
|
+
let domProps = (0, $13Gtr$filterDOMProps)(props, {
|
|
75
|
+
labelable: true
|
|
76
|
+
});
|
|
77
|
+
let gridProps = (0, $13Gtr$mergeProps)(domProps, {
|
|
78
|
+
role: "grid",
|
|
79
|
+
id: id,
|
|
80
|
+
"aria-multiselectable": state.selectionManager.selectionMode === "multiple" ? "true" : undefined
|
|
81
|
+
}, state.collection.size === 0 ? {} : listProps, descriptionProps);
|
|
82
|
+
if (isVirtualized) {
|
|
83
|
+
gridProps["aria-rowcount"] = state.collection.size;
|
|
84
|
+
gridProps["aria-colcount"] = 1;
|
|
85
|
+
}
|
|
86
|
+
(0, $13Gtr$useGridSelectionAnnouncement)({}, state);
|
|
87
|
+
return {
|
|
88
|
+
gridProps: gridProps
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
95
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
96
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
97
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
98
|
+
*
|
|
99
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
100
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
101
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
102
|
+
* governing permissions and limitations under the License.
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
function $4e8b0456ef72939f$export$9610e69494fadfd2(props, state, ref) {
|
|
110
|
+
// Copied from useGridCell + some modifications to make it not so grid specific
|
|
111
|
+
let { node: node , isVirtualized: isVirtualized , shouldSelectOnPressUp: shouldSelectOnPressUp } = props;
|
|
112
|
+
let { direction: direction } = (0, $13Gtr$useLocale)();
|
|
113
|
+
let { onAction: onAction } = (0, $ce9b18daab526bbd$export$5b9bb410392e3991).get(state);
|
|
114
|
+
let descriptionId = (0, $13Gtr$useSlotId)();
|
|
115
|
+
let focus = ()=>{
|
|
116
|
+
// Don't shift focus to the row if the active element is a element within the row already
|
|
117
|
+
// (e.g. clicking on a row button)
|
|
118
|
+
if (!ref.current.contains(document.activeElement)) (0, $13Gtr$focusSafely)(ref.current);
|
|
119
|
+
};
|
|
120
|
+
let { itemProps: itemProps , ...itemStates } = (0, $13Gtr$useSelectableItem)({
|
|
121
|
+
selectionManager: state.selectionManager,
|
|
122
|
+
key: node.key,
|
|
123
|
+
ref: ref,
|
|
124
|
+
isVirtualized: isVirtualized,
|
|
125
|
+
shouldSelectOnPressUp: shouldSelectOnPressUp,
|
|
126
|
+
onAction: onAction ? ()=>onAction(node.key) : undefined,
|
|
127
|
+
focus: focus
|
|
128
|
+
});
|
|
129
|
+
let onKeyDown = (e)=>{
|
|
130
|
+
if (!e.currentTarget.contains(e.target)) return;
|
|
131
|
+
let walker = (0, $13Gtr$getFocusableTreeWalker)(ref.current);
|
|
132
|
+
walker.currentNode = document.activeElement;
|
|
133
|
+
switch(e.key){
|
|
134
|
+
case "ArrowLeft":
|
|
135
|
+
{
|
|
136
|
+
// Find the next focusable element within the row.
|
|
137
|
+
let focusable = direction === "rtl" ? walker.nextNode() : walker.previousNode();
|
|
138
|
+
if (focusable) {
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
e.stopPropagation();
|
|
141
|
+
(0, $13Gtr$focusSafely)(focusable);
|
|
142
|
+
(0, $13Gtr$scrollIntoViewport)(focusable, {
|
|
143
|
+
containingElement: (0, $13Gtr$getScrollParent)(ref.current)
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
// If there is no next focusable child, then return focus back to the row
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
e.stopPropagation();
|
|
149
|
+
if (direction === "rtl") {
|
|
150
|
+
(0, $13Gtr$focusSafely)(ref.current);
|
|
151
|
+
(0, $13Gtr$scrollIntoViewport)(ref.current, {
|
|
152
|
+
containingElement: (0, $13Gtr$getScrollParent)(ref.current)
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
walker.currentNode = ref.current;
|
|
156
|
+
let lastElement = $4e8b0456ef72939f$var$last(walker);
|
|
157
|
+
if (lastElement) {
|
|
158
|
+
(0, $13Gtr$focusSafely)(lastElement);
|
|
159
|
+
(0, $13Gtr$scrollIntoViewport)(lastElement, {
|
|
160
|
+
containingElement: (0, $13Gtr$getScrollParent)(ref.current)
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case "ArrowRight":
|
|
168
|
+
{
|
|
169
|
+
let focusable1 = direction === "rtl" ? walker.previousNode() : walker.nextNode();
|
|
170
|
+
if (focusable1) {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
e.stopPropagation();
|
|
173
|
+
(0, $13Gtr$focusSafely)(focusable1);
|
|
174
|
+
(0, $13Gtr$scrollIntoViewport)(focusable1, {
|
|
175
|
+
containingElement: (0, $13Gtr$getScrollParent)(ref.current)
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
if (direction === "ltr") {
|
|
181
|
+
(0, $13Gtr$focusSafely)(ref.current);
|
|
182
|
+
(0, $13Gtr$scrollIntoViewport)(ref.current, {
|
|
183
|
+
containingElement: (0, $13Gtr$getScrollParent)(ref.current)
|
|
184
|
+
});
|
|
185
|
+
} else {
|
|
186
|
+
walker.currentNode = ref.current;
|
|
187
|
+
let lastElement1 = $4e8b0456ef72939f$var$last(walker);
|
|
188
|
+
if (lastElement1) {
|
|
189
|
+
(0, $13Gtr$focusSafely)(lastElement1);
|
|
190
|
+
(0, $13Gtr$scrollIntoViewport)(lastElement1, {
|
|
191
|
+
containingElement: (0, $13Gtr$getScrollParent)(ref.current)
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case "ArrowUp":
|
|
199
|
+
case "ArrowDown":
|
|
200
|
+
// Prevent this event from reaching row children, e.g. menu buttons. We want arrow keys to navigate
|
|
201
|
+
// to the row above/below instead. We need to re-dispatch the event from a higher parent so it still
|
|
202
|
+
// bubbles and gets handled by useSelectableCollection.
|
|
203
|
+
if (!e.altKey && ref.current.contains(e.target)) {
|
|
204
|
+
e.stopPropagation();
|
|
205
|
+
e.preventDefault();
|
|
206
|
+
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
|
|
207
|
+
}
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
let onFocus = (e)=>{
|
|
212
|
+
if (e.target !== ref.current) {
|
|
213
|
+
// useSelectableItem only handles setting the focused key when
|
|
214
|
+
// the focused element is the row itself. We also want to
|
|
215
|
+
// set the focused key when a child element receives focus.
|
|
216
|
+
// If focus is currently visible (e.g. the user is navigating with the keyboard),
|
|
217
|
+
// then skip this. We want to restore focus to the previously focused row
|
|
218
|
+
// in that case since the list should act like a single tab stop.
|
|
219
|
+
if (!(0, $13Gtr$isFocusVisible)()) state.selectionManager.setFocusedKey(node.key);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
let rowProps = (0, $13Gtr$mergeProps)(itemProps, {
|
|
224
|
+
role: "row",
|
|
225
|
+
onKeyDownCapture: onKeyDown,
|
|
226
|
+
onFocus: onFocus,
|
|
227
|
+
"aria-label": node.textValue || undefined,
|
|
228
|
+
"aria-selected": state.selectionManager.canSelectItem(node.key) ? state.selectionManager.isSelected(node.key) : undefined,
|
|
229
|
+
"aria-disabled": state.selectionManager.isDisabled(node.key) || undefined,
|
|
230
|
+
"aria-labelledby": descriptionId && node.textValue ? `${(0, $ce9b18daab526bbd$export$f45c25170b9a99c2)(state, node.key)} ${descriptionId}` : undefined,
|
|
231
|
+
id: (0, $ce9b18daab526bbd$export$f45c25170b9a99c2)(state, node.key)
|
|
232
|
+
});
|
|
233
|
+
if (isVirtualized) rowProps["aria-rowindex"] = node.index + 1;
|
|
234
|
+
let gridCellProps = {
|
|
235
|
+
role: "gridcell",
|
|
236
|
+
"aria-colindex": 1
|
|
237
|
+
};
|
|
238
|
+
return {
|
|
239
|
+
rowProps: rowProps,
|
|
240
|
+
gridCellProps: gridCellProps,
|
|
241
|
+
descriptionProps: {
|
|
242
|
+
id: descriptionId
|
|
243
|
+
},
|
|
244
|
+
...itemStates
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function $4e8b0456ef72939f$var$last(walker) {
|
|
248
|
+
let next;
|
|
249
|
+
let last;
|
|
250
|
+
do {
|
|
251
|
+
last = walker.lastChild();
|
|
252
|
+
if (last) next = last;
|
|
253
|
+
}while (last);
|
|
254
|
+
return next;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
/*
|
|
259
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
260
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
261
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
262
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
263
|
+
*
|
|
264
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
265
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
266
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
267
|
+
* governing permissions and limitations under the License.
|
|
268
|
+
*/
|
|
269
|
+
|
|
270
|
+
function $e52ffc04a4adbd52$export$e29f2573fabbf7b9(props, state) {
|
|
271
|
+
let { key: key } = props;
|
|
272
|
+
const { checkboxProps: checkboxProps } = (0, $13Gtr$useGridSelectionCheckbox)(props, state);
|
|
273
|
+
return {
|
|
274
|
+
checkboxProps: {
|
|
275
|
+
...checkboxProps,
|
|
276
|
+
"aria-labelledby": `${checkboxProps.id} ${(0, $ce9b18daab526bbd$export$f45c25170b9a99c2)(state, key)}`
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
export {$f47efb0c3a859cf2$export$664f9155035607eb as useGridList, $4e8b0456ef72939f$export$9610e69494fadfd2 as useGridListItem, $e52ffc04a4adbd52$export$e29f2573fabbf7b9 as useGridListSelectionCheckbox};
|
|
285
|
+
//# sourceMappingURL=module.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/gridlist",
|
|
3
|
-
"version": "3.1.3-nightly.
|
|
3
|
+
"version": "3.1.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/grid": "3.5.3-nightly.
|
|
22
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
23
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
24
|
-
"@react-aria/selection": "3.0.0-nightly.
|
|
25
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
26
|
-
"@react-stately/list": "3.6.2-nightly.
|
|
27
|
-
"@react-types/checkbox": "3.0.0-nightly.
|
|
28
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
25
|
+
"@react-aria/focus": "3.0.0-nightly.2005+93b3c951e",
|
|
26
|
+
"@react-aria/grid": "3.5.3-nightly.3705+93b3c951e",
|
|
27
|
+
"@react-aria/i18n": "3.0.0-nightly.2005+93b3c951e",
|
|
28
|
+
"@react-aria/interactions": "3.0.0-nightly.2005+93b3c951e",
|
|
29
|
+
"@react-aria/selection": "3.0.0-nightly.2005+93b3c951e",
|
|
30
|
+
"@react-aria/utils": "3.0.0-nightly.2005+93b3c951e",
|
|
31
|
+
"@react-stately/list": "3.6.2-nightly.3705+93b3c951e",
|
|
32
|
+
"@react-types/checkbox": "3.0.0-nightly.2005+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
|
}
|