@react-aria/gridlist 3.14.4 → 3.15.0

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.
Files changed (40) hide show
  1. package/dist/import.mjs +2 -8
  2. package/dist/main.js +5 -11
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +2 -8
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +3 -0
  7. package/package.json +15 -20
  8. package/src/index.ts +3 -7
  9. package/dist/types.d.ts +0 -135
  10. package/dist/types.d.ts.map +0 -1
  11. package/dist/useGridList.main.js +0 -83
  12. package/dist/useGridList.main.js.map +0 -1
  13. package/dist/useGridList.mjs +0 -78
  14. package/dist/useGridList.module.js +0 -78
  15. package/dist/useGridList.module.js.map +0 -1
  16. package/dist/useGridListItem.main.js +0 -305
  17. package/dist/useGridListItem.main.js.map +0 -1
  18. package/dist/useGridListItem.mjs +0 -300
  19. package/dist/useGridListItem.module.js +0 -300
  20. package/dist/useGridListItem.module.js.map +0 -1
  21. package/dist/useGridListSection.main.js +0 -43
  22. package/dist/useGridListSection.main.js.map +0 -1
  23. package/dist/useGridListSection.mjs +0 -38
  24. package/dist/useGridListSection.module.js +0 -38
  25. package/dist/useGridListSection.module.js.map +0 -1
  26. package/dist/useGridListSelectionCheckbox.main.js +0 -34
  27. package/dist/useGridListSelectionCheckbox.main.js.map +0 -1
  28. package/dist/useGridListSelectionCheckbox.mjs +0 -29
  29. package/dist/useGridListSelectionCheckbox.module.js +0 -29
  30. package/dist/useGridListSelectionCheckbox.module.js.map +0 -1
  31. package/dist/utils.main.js +0 -31
  32. package/dist/utils.main.js.map +0 -1
  33. package/dist/utils.mjs +0 -25
  34. package/dist/utils.module.js +0 -25
  35. package/dist/utils.module.js.map +0 -1
  36. package/src/useGridList.ts +0 -182
  37. package/src/useGridListItem.ts +0 -346
  38. package/src/useGridListSection.ts +0 -60
  39. package/src/useGridListSelectionCheckbox.ts +0 -32
  40. package/src/utils.ts +0 -43
@@ -1,300 +0,0 @@
1
- import {getRowId as $ce9b18daab526bbd$export$f45c25170b9a99c2, listMap as $ce9b18daab526bbd$export$5b9bb410392e3991} from "./utils.module.js";
2
- import {useSlotId as $lxFUG$useSlotId, isFocusWithin as $lxFUG$isFocusWithin, chain as $lxFUG$chain, getActiveElement as $lxFUG$getActiveElement, nodeContains as $lxFUG$nodeContains, getEventTarget as $lxFUG$getEventTarget, scrollIntoViewport as $lxFUG$scrollIntoViewport, getScrollParent as $lxFUG$getScrollParent, useSyntheticLinkProps as $lxFUG$useSyntheticLinkProps, mergeProps as $lxFUG$mergeProps} from "@react-aria/utils";
3
- import {focusSafely as $lxFUG$focusSafely, getFocusableTreeWalker as $lxFUG$getFocusableTreeWalker} from "@react-aria/focus";
4
- import {useRef as $lxFUG$useRef} from "react";
5
- import {isFocusVisible as $lxFUG$isFocusVisible} from "@react-aria/interactions";
6
- import {useSelectableItem as $lxFUG$useSelectableItem} from "@react-aria/selection";
7
- import {useLocale as $lxFUG$useLocale} from "@react-aria/i18n";
8
-
9
- /*
10
- * Copyright 2022 Adobe. All rights reserved.
11
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License. You may obtain a copy
13
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
- *
15
- * Unless required by applicable law or agreed to in writing, software distributed under
16
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
- * OF ANY KIND, either express or implied. See the License for the specific language
18
- * governing permissions and limitations under the License.
19
- */
20
-
21
-
22
-
23
-
24
-
25
-
26
- const $4e8b0456ef72939f$var$EXPANSION_KEYS = {
27
- 'expand': {
28
- ltr: 'ArrowRight',
29
- rtl: 'ArrowLeft'
30
- },
31
- 'collapse': {
32
- ltr: 'ArrowLeft',
33
- rtl: 'ArrowRight'
34
- }
35
- };
36
- function $4e8b0456ef72939f$export$9610e69494fadfd2(props, state, ref) {
37
- var _node_props, _node_props1;
38
- // Copied from useGridCell + some modifications to make it not so grid specific
39
- let { node: node, isVirtualized: isVirtualized } = props;
40
- // let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/gridlist');
41
- let { direction: direction } = (0, $lxFUG$useLocale)();
42
- let { onAction: onAction, linkBehavior: linkBehavior, keyboardNavigationBehavior: keyboardNavigationBehavior, shouldSelectOnPressUp: shouldSelectOnPressUp } = (0, $ce9b18daab526bbd$export$5b9bb410392e3991).get(state);
43
- let descriptionId = (0, $lxFUG$useSlotId)();
44
- // We need to track the key of the item at the time it was last focused so that we force
45
- // focus to go to the item when the DOM node is reused for a different item in a virtualizer.
46
- let keyWhenFocused = (0, $lxFUG$useRef)(null);
47
- let focus = ()=>{
48
- // Don't shift focus to the row if the active element is a element within the row already
49
- // (e.g. clicking on a row button)
50
- if (ref.current !== null && (keyWhenFocused.current != null && node.key !== keyWhenFocused.current || !(0, $lxFUG$isFocusWithin)(ref.current))) (0, $lxFUG$focusSafely)(ref.current);
51
- };
52
- let treeGridRowProps = {};
53
- let hasChildRows = props.hasChildItems;
54
- let hasLink = state.selectionManager.isLink(node.key);
55
- if (node != null && 'expandedKeys' in state) {
56
- var _state_collection_getChildren, _state_collection;
57
- // TODO: ideally node.hasChildNodes would be a way to tell if a row has child nodes, but the row's contents make it so that value is always
58
- // true...
59
- let children = (_state_collection_getChildren = (_state_collection = state.collection).getChildren) === null || _state_collection_getChildren === void 0 ? void 0 : _state_collection_getChildren.call(_state_collection, node.key);
60
- hasChildRows = hasChildRows || [
61
- ...children !== null && children !== void 0 ? children : []
62
- ].length > 1;
63
- if (onAction == null && !hasLink && state.selectionManager.selectionMode === 'none' && hasChildRows) onAction = ()=>state.toggleKey(node.key);
64
- let isExpanded = hasChildRows ? state.expandedKeys.has(node.key) : undefined;
65
- let setSize = 1;
66
- let index = node.index;
67
- if (node.level >= 0 && (node === null || node === void 0 ? void 0 : node.parentKey) != null) {
68
- let parent = state.collection.getItem(node.parentKey);
69
- if (parent) {
70
- // siblings must exist because our original node exists
71
- let siblings = $4e8b0456ef72939f$var$getDirectChildren(parent, state.collection);
72
- setSize = [
73
- ...siblings
74
- ].filter((row)=>row.type === 'item').length;
75
- if (index > 0 && siblings[0].type !== 'item') index -= 1; // subtract one for the parent item's content node
76
- }
77
- } else setSize = [
78
- ...state.collection
79
- ].filter((row)=>row.level === 0 && row.type === 'item').length;
80
- treeGridRowProps = {
81
- 'aria-expanded': isExpanded,
82
- 'aria-level': node.level + 1,
83
- 'aria-posinset': index + 1,
84
- 'aria-setsize': setSize
85
- };
86
- }
87
- let { itemProps: itemProps, ...itemStates } = (0, $lxFUG$useSelectableItem)({
88
- selectionManager: state.selectionManager,
89
- key: node.key,
90
- ref: ref,
91
- isVirtualized: isVirtualized,
92
- shouldSelectOnPressUp: props.shouldSelectOnPressUp || shouldSelectOnPressUp,
93
- onAction: onAction || ((_node_props = node.props) === null || _node_props === void 0 ? void 0 : _node_props.onAction) ? (0, $lxFUG$chain)((_node_props1 = node.props) === null || _node_props1 === void 0 ? void 0 : _node_props1.onAction, onAction ? ()=>onAction(node.key) : undefined) : undefined,
94
- focus: focus,
95
- linkBehavior: linkBehavior
96
- });
97
- let onKeyDownCapture = (e)=>{
98
- let activeElement = (0, $lxFUG$getActiveElement)();
99
- if (!(0, $lxFUG$nodeContains)(e.currentTarget, (0, $lxFUG$getEventTarget)(e)) || !ref.current || !activeElement) return;
100
- let walker = (0, $lxFUG$getFocusableTreeWalker)(ref.current);
101
- walker.currentNode = activeElement;
102
- if ('expandedKeys' in state && activeElement === ref.current) {
103
- if (e.key === $4e8b0456ef72939f$var$EXPANSION_KEYS['expand'][direction] && state.selectionManager.focusedKey === node.key && hasChildRows && !state.expandedKeys.has(node.key)) {
104
- state.toggleKey(node.key);
105
- e.stopPropagation();
106
- return;
107
- } else if (e.key === $4e8b0456ef72939f$var$EXPANSION_KEYS['collapse'][direction] && state.selectionManager.focusedKey === node.key && hasChildRows && state.expandedKeys.has(node.key)) {
108
- state.toggleKey(node.key);
109
- e.stopPropagation();
110
- return;
111
- }
112
- }
113
- switch(e.key){
114
- case 'ArrowLeft':
115
- if (keyboardNavigationBehavior === 'arrow') {
116
- // Find the next focusable element within the row.
117
- let focusable = direction === 'rtl' ? walker.nextNode() : walker.previousNode();
118
- if (focusable) {
119
- e.preventDefault();
120
- e.stopPropagation();
121
- (0, $lxFUG$focusSafely)(focusable);
122
- (0, $lxFUG$scrollIntoViewport)(focusable, {
123
- containingElement: (0, $lxFUG$getScrollParent)(ref.current)
124
- });
125
- } else {
126
- // If there is no next focusable child, then return focus back to the row
127
- e.preventDefault();
128
- e.stopPropagation();
129
- if (direction === 'rtl') {
130
- (0, $lxFUG$focusSafely)(ref.current);
131
- (0, $lxFUG$scrollIntoViewport)(ref.current, {
132
- containingElement: (0, $lxFUG$getScrollParent)(ref.current)
133
- });
134
- } else {
135
- walker.currentNode = ref.current;
136
- let lastElement = $4e8b0456ef72939f$var$last(walker);
137
- if (lastElement) {
138
- (0, $lxFUG$focusSafely)(lastElement);
139
- (0, $lxFUG$scrollIntoViewport)(lastElement, {
140
- containingElement: (0, $lxFUG$getScrollParent)(ref.current)
141
- });
142
- }
143
- }
144
- }
145
- }
146
- break;
147
- case 'ArrowRight':
148
- if (keyboardNavigationBehavior === 'arrow') {
149
- let focusable = direction === 'rtl' ? walker.previousNode() : walker.nextNode();
150
- if (focusable) {
151
- e.preventDefault();
152
- e.stopPropagation();
153
- (0, $lxFUG$focusSafely)(focusable);
154
- (0, $lxFUG$scrollIntoViewport)(focusable, {
155
- containingElement: (0, $lxFUG$getScrollParent)(ref.current)
156
- });
157
- } else {
158
- e.preventDefault();
159
- e.stopPropagation();
160
- if (direction === 'ltr') {
161
- (0, $lxFUG$focusSafely)(ref.current);
162
- (0, $lxFUG$scrollIntoViewport)(ref.current, {
163
- containingElement: (0, $lxFUG$getScrollParent)(ref.current)
164
- });
165
- } else {
166
- walker.currentNode = ref.current;
167
- let lastElement = $4e8b0456ef72939f$var$last(walker);
168
- if (lastElement) {
169
- (0, $lxFUG$focusSafely)(lastElement);
170
- (0, $lxFUG$scrollIntoViewport)(lastElement, {
171
- containingElement: (0, $lxFUG$getScrollParent)(ref.current)
172
- });
173
- }
174
- }
175
- }
176
- }
177
- break;
178
- case 'ArrowUp':
179
- case 'ArrowDown':
180
- // Prevent this event from reaching row children, e.g. menu buttons. We want arrow keys to navigate
181
- // to the row above/below instead. We need to re-dispatch the event from a higher parent so it still
182
- // bubbles and gets handled by useSelectableCollection.
183
- if (!e.altKey && (0, $lxFUG$nodeContains)(ref.current, (0, $lxFUG$getEventTarget)(e))) {
184
- var _ref_current_parentElement;
185
- e.stopPropagation();
186
- e.preventDefault();
187
- (_ref_current_parentElement = ref.current.parentElement) === null || _ref_current_parentElement === void 0 ? void 0 : _ref_current_parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
188
- }
189
- break;
190
- }
191
- };
192
- let onFocus = (e)=>{
193
- keyWhenFocused.current = node.key;
194
- if ((0, $lxFUG$getEventTarget)(e) !== ref.current) {
195
- // useSelectableItem only handles setting the focused key when
196
- // the focused element is the row itself. We also want to
197
- // set the focused key when a child element receives focus.
198
- // If focus is currently visible (e.g. the user is navigating with the keyboard),
199
- // then skip this. We want to restore focus to the previously focused row
200
- // in that case since the list should act like a single tab stop.
201
- if (!(0, $lxFUG$isFocusVisible)()) state.selectionManager.setFocusedKey(node.key);
202
- return;
203
- }
204
- };
205
- let onKeyDown = (e)=>{
206
- let activeElement = (0, $lxFUG$getActiveElement)();
207
- if (!(0, $lxFUG$nodeContains)(e.currentTarget, (0, $lxFUG$getEventTarget)(e)) || !ref.current || !activeElement) return;
208
- switch(e.key){
209
- case 'Tab':
210
- if (keyboardNavigationBehavior === 'tab') {
211
- // If there is another focusable element within this item, stop propagation so the tab key
212
- // is handled by the browser and not by useSelectableCollection (which would take us out of the list).
213
- let walker = (0, $lxFUG$getFocusableTreeWalker)(ref.current, {
214
- tabbable: true
215
- });
216
- walker.currentNode = activeElement;
217
- let next = e.shiftKey ? walker.previousNode() : walker.nextNode();
218
- if (next) e.stopPropagation();
219
- }
220
- }
221
- };
222
- let syntheticLinkProps = (0, $lxFUG$useSyntheticLinkProps)(node.props);
223
- let linkProps = itemStates.hasAction ? syntheticLinkProps : {};
224
- // TODO: re-add when we get translations and fix this for iOS VO
225
- // let rowAnnouncement;
226
- // if (onAction) {
227
- // rowAnnouncement = stringFormatter.format('hasActionAnnouncement');
228
- // } else if (hasLink) {
229
- // rowAnnouncement = stringFormatter.format('hasLinkAnnouncement', {
230
- // link: node.props.href
231
- // });
232
- // }
233
- let rowProps = (0, $lxFUG$mergeProps)(itemProps, linkProps, {
234
- role: 'row',
235
- onKeyDownCapture: onKeyDownCapture,
236
- onKeyDown: onKeyDown,
237
- onFocus: onFocus,
238
- // 'aria-label': [(node.textValue || undefined), rowAnnouncement].filter(Boolean).join(', '),
239
- 'aria-label': node['aria-label'] || node.textValue || undefined,
240
- 'aria-selected': state.selectionManager.canSelectItem(node.key) ? state.selectionManager.isSelected(node.key) : undefined,
241
- 'aria-disabled': state.selectionManager.isDisabled(node.key) || undefined,
242
- 'aria-labelledby': descriptionId && (node['aria-label'] || node.textValue) ? `${(0, $ce9b18daab526bbd$export$f45c25170b9a99c2)(state, node.key)} ${descriptionId}` : undefined,
243
- id: (0, $ce9b18daab526bbd$export$f45c25170b9a99c2)(state, node.key)
244
- });
245
- if (isVirtualized) {
246
- let { collection: collection } = state;
247
- let nodes = [
248
- ...collection
249
- ];
250
- // TODO: refactor ListCollection to store an absolute index of a node's position?
251
- rowProps['aria-rowindex'] = nodes.find((node)=>node.type === 'section') ? [
252
- ...collection.getKeys()
253
- ].filter((key)=>{
254
- var _collection_getItem;
255
- return ((_collection_getItem = collection.getItem(key)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.type) !== 'section';
256
- }).findIndex((key)=>key === node.key) + 1 : node.index + 1;
257
- }
258
- let gridCellProps = {
259
- role: 'gridcell',
260
- 'aria-colindex': 1
261
- };
262
- // TODO: should isExpanded and hasChildRows be a item state that gets returned by the hook?
263
- return {
264
- rowProps: {
265
- ...(0, $lxFUG$mergeProps)(rowProps, treeGridRowProps)
266
- },
267
- gridCellProps: gridCellProps,
268
- descriptionProps: {
269
- id: descriptionId
270
- },
271
- ...itemStates
272
- };
273
- }
274
- function $4e8b0456ef72939f$var$last(walker) {
275
- let next = null;
276
- let last = null;
277
- do {
278
- last = walker.lastChild();
279
- if (last) next = last;
280
- }while (last);
281
- return next;
282
- }
283
- function $4e8b0456ef72939f$var$getDirectChildren(parent, collection) {
284
- var _collection_getChildren;
285
- // We can't assume that we can use firstChildKey because if a person builds a tree using hooks, they would not have access to that property (using type Node vs CollectionNode)
286
- // Instead, get all children and start at the first node (rather than just using firstChildKey) and only look at its siblings
287
- let children = (_collection_getChildren = collection.getChildren) === null || _collection_getChildren === void 0 ? void 0 : _collection_getChildren.call(collection, parent.key);
288
- let childArray = children ? Array.from(children) : [];
289
- let node = childArray.length > 0 ? childArray[0] : null;
290
- let siblings = [];
291
- while(node){
292
- siblings.push(node);
293
- node = node.nextKey != null ? collection.getItem(node.nextKey) : null;
294
- }
295
- return siblings;
296
- }
297
-
298
-
299
- export {$4e8b0456ef72939f$export$9610e69494fadfd2 as useGridListItem};
300
- //# sourceMappingURL=useGridListItem.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAiCD,MAAM,uCAAiB;IACrB,UAAU;QACR,KAAK;QACL,KAAK;IACP;IACA,YAAY;QACV,KAAK;QACL,KAAK;IACP;AACF;AAQO,SAAS,0CAAmB,KAA8B,EAAE,KAAkC,EAAE,GAAuC;QAuEpH,aAA6B;IAtErD,+EAA+E;IAC/E,IAAI,QACF,IAAI,iBACJ,aAAa,EACd,GAAG;IAEJ,2FAA2F;IAC3F,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,YAAC,QAAQ,gBAAE,YAAY,8BAAE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AFf,+KAA+K;IAC/K,6HAA6H;IAC7H,IAAI,YAAW,0BAAA,WAAW,WAAW,cAAtB,8CAAA,6BAAA,YAAyB,OAAO,GAAG;IAClD,IAAI,aAAa,WAAW,MAAM,IAAI,CAAC,YAAY,EAAE;IACrD,IAAI,OAAO,WAAW,MAAM,GAAG,IAAK,UAAU,CAAC,EAAE,GAAG;IACpD,IAAI,WAAwB,EAAE;IAC9B,MAAO,KAAM;QACX,SAAS,IAAI,CAAC;QACd,OAAO,KAAK,OAAO,IAAI,OAAO,WAAW,OAAO,CAAC,KAAK,OAAO,IAAI;IACnE;IACA,OAAO;AACT","sources":["packages/@react-aria/gridlist/src/useGridListItem.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {chain, getActiveElement, getEventTarget, getScrollParent, isFocusWithin, mergeProps, nodeContains, scrollIntoViewport, useSlotId, useSyntheticLinkProps} from '@react-aria/utils';\nimport {Collection, DOMAttributes, FocusableElement, Key, RefObject, Node as RSNode} from '@react-types/shared';\nimport {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';\nimport {getRowId, listMap} from './utils';\nimport {HTMLAttributes, KeyboardEvent as ReactKeyboardEvent, useRef} from 'react';\nimport {isFocusVisible} from '@react-aria/interactions';\nimport type {ListState} from '@react-stately/list';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\nimport type {TreeState} from '@react-stately/tree';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface AriaGridListItemOptions {\n /** An object representing the list item. Contains all the relevant information that makes up the list row. */\n node: RSNode<unknown>,\n /** Whether the list row is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /** Whether this item has children, even if not loaded yet. */\n hasChildItems?: boolean\n}\n\nexport interface GridListItemAria extends SelectableItemStates {\n /** Props for the list row element. */\n rowProps: DOMAttributes,\n /** Props for the grid cell element within the list row. */\n gridCellProps: DOMAttributes,\n /** Props for the list item description element, if any. */\n descriptionProps: DOMAttributes\n}\n\nconst EXPANSION_KEYS = {\n 'expand': {\n ltr: 'ArrowRight',\n rtl: 'ArrowLeft'\n },\n 'collapse': {\n ltr: 'ArrowLeft',\n rtl: 'ArrowRight'\n }\n};\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid list.\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useListState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useGridListItem<T>(props: AriaGridListItemOptions, state: ListState<T> | TreeState<T>, ref: RefObject<FocusableElement | null>): GridListItemAria {\n // Copied from useGridCell + some modifications to make it not so grid specific\n let {\n node,\n isVirtualized\n } = props;\n\n // let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/gridlist');\n let {direction} = useLocale();\n let {onAction, linkBehavior, keyboardNavigationBehavior, shouldSelectOnPressUp} = listMap.get(state)!;\n let descriptionId = useSlotId();\n\n // We need to track the key of the item at the time it was last focused so that we force\n // focus to go to the item when the DOM node is reused for a different item in a virtualizer.\n let keyWhenFocused = useRef<Key | null>(null);\n let focus = () => {\n // Don't shift focus to the row if the active element is a element within the row already\n // (e.g. clicking on a row button)\n if (\n ref.current !== null &&\n ((keyWhenFocused.current != null && node.key !== keyWhenFocused.current) ||\n !isFocusWithin(ref.current))\n ) {\n focusSafely(ref.current);\n }\n };\n\n let treeGridRowProps: HTMLAttributes<HTMLElement> = {};\n let hasChildRows = props.hasChildItems;\n let hasLink = state.selectionManager.isLink(node.key);\n if (node != null && 'expandedKeys' in state) {\n // TODO: ideally node.hasChildNodes would be a way to tell if a row has child nodes, but the row's contents make it so that value is always\n // true...\n let children = state.collection.getChildren?.(node.key);\n hasChildRows = hasChildRows || [...(children ?? [])].length > 1;\n\n if (onAction == null && !hasLink && state.selectionManager.selectionMode === 'none' && hasChildRows) {\n onAction = () => state.toggleKey(node.key);\n }\n\n let isExpanded = hasChildRows ? state.expandedKeys.has(node.key) : undefined;\n let setSize = 1;\n let index = node.index;\n if (node.level >= 0 && node?.parentKey != null) {\n let parent = state.collection.getItem(node.parentKey);\n if (parent) {\n // siblings must exist because our original node exists\n let siblings = getDirectChildren(parent, state.collection);\n setSize = [...siblings].filter(row => row.type === 'item').length;\n if (index > 0 && siblings[0].type !== 'item') {\n index -= 1; // subtract one for the parent item's content node\n }\n }\n } else {\n setSize = [...state.collection].filter(row => row.level === 0 && row.type === 'item').length;\n }\n\n treeGridRowProps = {\n 'aria-expanded': isExpanded,\n 'aria-level': node.level + 1,\n 'aria-posinset': index + 1,\n 'aria-setsize': setSize\n };\n }\n\n let {itemProps, ...itemStates} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp || shouldSelectOnPressUp,\n onAction: onAction || node.props?.onAction ? chain(node.props?.onAction, onAction ? () => onAction(node.key) : undefined) : undefined,\n focus,\n linkBehavior\n });\n\n let onKeyDownCapture = (e: ReactKeyboardEvent) => {\n let activeElement = getActiveElement();\n if (!nodeContains(e.currentTarget, getEventTarget(e) as Element) || !ref.current || !activeElement) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = activeElement;\n\n if ('expandedKeys' in state && activeElement === ref.current) {\n if ((e.key === EXPANSION_KEYS['expand'][direction]) && state.selectionManager.focusedKey === node.key && hasChildRows && !state.expandedKeys.has(node.key)) {\n state.toggleKey(node.key);\n e.stopPropagation();\n return;\n } else if ((e.key === EXPANSION_KEYS['collapse'][direction]) && state.selectionManager.focusedKey === node.key && hasChildRows && state.expandedKeys.has(node.key)) {\n state.toggleKey(node.key);\n e.stopPropagation();\n return;\n }\n }\n\n switch (e.key) {\n case 'ArrowLeft': {\n if (keyboardNavigationBehavior === 'arrow') {\n // Find the next focusable element within the row.\n let focusable = direction === 'rtl'\n ? walker.nextNode() as FocusableElement\n : walker.previousNode() as FocusableElement;\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n // If there is no next focusable child, then return focus back to the row\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n if (lastElement) {\n focusSafely(lastElement);\n scrollIntoViewport(lastElement, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n if (keyboardNavigationBehavior === 'arrow') {\n let focusable = direction === 'rtl'\n ? walker.previousNode() as FocusableElement\n : walker.nextNode() as FocusableElement;\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'ltr') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n if (lastElement) {\n focusSafely(lastElement);\n scrollIntoViewport(lastElement, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching row children, e.g. menu buttons. We want arrow keys to navigate\n // to the row above/below instead. We need to re-dispatch the event from a higher parent so it still\n // bubbles and gets handled by useSelectableCollection.\n if (!e.altKey && nodeContains(ref.current, getEventTarget(e) as Element)) {\n e.stopPropagation();\n e.preventDefault();\n ref.current.parentElement?.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n }\n break;\n }\n };\n\n let onFocus = (e) => {\n keyWhenFocused.current = node.key;\n if (getEventTarget(e) !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the row itself. We also want to\n // set the focused key when a child element receives focus.\n // If focus is currently visible (e.g. the user is navigating with the keyboard),\n // then skip this. We want to restore focus to the previously focused row\n // in that case since the list should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n };\n\n let onKeyDown = (e) => {\n let activeElement = getActiveElement();\n if (!nodeContains(e.currentTarget, getEventTarget(e) as Element) || !ref.current || !activeElement) {\n return;\n }\n\n switch (e.key) {\n case 'Tab': {\n if (keyboardNavigationBehavior === 'tab') {\n // If there is another focusable element within this item, stop propagation so the tab key\n // is handled by the browser and not by useSelectableCollection (which would take us out of the list).\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n walker.currentNode = activeElement;\n let next = e.shiftKey ? walker.previousNode() : walker.nextNode();\n\n if (next) {\n e.stopPropagation();\n }\n }\n }\n }\n };\n\n let syntheticLinkProps = useSyntheticLinkProps(node.props);\n let linkProps = itemStates.hasAction ? syntheticLinkProps : {};\n // TODO: re-add when we get translations and fix this for iOS VO\n // let rowAnnouncement;\n // if (onAction) {\n // rowAnnouncement = stringFormatter.format('hasActionAnnouncement');\n // } else if (hasLink) {\n // rowAnnouncement = stringFormatter.format('hasLinkAnnouncement', {\n // link: node.props.href\n // });\n // }\n\n let rowProps: DOMAttributes = mergeProps(itemProps, linkProps, {\n role: 'row',\n onKeyDownCapture,\n onKeyDown,\n onFocus,\n // 'aria-label': [(node.textValue || undefined), rowAnnouncement].filter(Boolean).join(', '),\n 'aria-label': node['aria-label'] || node.textValue || undefined,\n 'aria-selected': state.selectionManager.canSelectItem(node.key) ? state.selectionManager.isSelected(node.key) : undefined,\n 'aria-disabled': state.selectionManager.isDisabled(node.key) || undefined,\n 'aria-labelledby': descriptionId && (node['aria-label'] || node.textValue) ? `${getRowId(state, node.key)} ${descriptionId}` : undefined,\n id: getRowId(state, node.key)\n });\n\n if (isVirtualized) {\n let {collection} = state;\n let nodes = [...collection];\n // TODO: refactor ListCollection to store an absolute index of a node's position?\n rowProps['aria-rowindex'] = nodes.find(node => node.type === 'section') ? [...collection.getKeys()].filter((key) => collection.getItem(key)?.type !== 'section').findIndex((key) => key === node.key) + 1 : node.index + 1;\n }\n\n let gridCellProps = {\n role: 'gridcell',\n 'aria-colindex': 1\n };\n\n // TODO: should isExpanded and hasChildRows be a item state that gets returned by the hook?\n return {\n rowProps: {...mergeProps(rowProps, treeGridRowProps)},\n gridCellProps,\n descriptionProps: {\n id: descriptionId\n },\n ...itemStates\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement | null = null;\n let last: FocusableElement | null = null;\n do {\n last = walker.lastChild() as FocusableElement | null;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n\nfunction getDirectChildren<T>(parent: RSNode<T>, collection: Collection<RSNode<T>>) {\n // We can't assume that we can use firstChildKey because if a person builds a tree using hooks, they would not have access to that property (using type Node vs CollectionNode)\n // Instead, get all children and start at the first node (rather than just using firstChildKey) and only look at its siblings\n let children = collection.getChildren?.(parent.key);\n let childArray = children ? Array.from(children) : [];\n let node = childArray.length > 0 ? childArray[0] : null;\n let siblings: RSNode<T>[] = [];\n while (node) {\n siblings.push(node);\n node = node.nextKey != null ? collection.getItem(node.nextKey) : null;\n }\n return siblings;\n}\n"],"names":[],"version":3,"file":"useGridListItem.module.js.map"}
@@ -1,43 +0,0 @@
1
- var $4IyTr$reactariautils = require("@react-aria/utils");
2
-
3
-
4
- function $parcel$export(e, n, v, s) {
5
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
- }
7
-
8
- $parcel$export(module.exports, "useGridListSection", () => $6e114d409ef8350d$export$8a024deed275af3f);
9
- /*
10
- * Copyright 2020 Adobe. All rights reserved.
11
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License. You may obtain a copy
13
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
- *
15
- * Unless required by applicable law or agreed to in writing, software distributed under
16
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
- * OF ANY KIND, either express or implied. See the License for the specific language
18
- * governing permissions and limitations under the License.
19
- */
20
- function $6e114d409ef8350d$export$8a024deed275af3f(props, state, ref) {
21
- let { 'aria-label': ariaLabel } = props;
22
- let headingId = (0, $4IyTr$reactariautils.useSlotId)();
23
- let labelProps = (0, $4IyTr$reactariautils.useLabels)({
24
- 'aria-label': ariaLabel,
25
- 'aria-labelledby': headingId
26
- });
27
- return {
28
- rowProps: {
29
- role: 'row'
30
- },
31
- rowHeaderProps: {
32
- id: headingId,
33
- role: 'rowheader'
34
- },
35
- rowGroupProps: {
36
- role: 'rowgroup',
37
- ...labelProps
38
- }
39
- };
40
- }
41
-
42
-
43
- //# sourceMappingURL=useGridListSection.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA4BM,SAAS,0CAAsB,KAA+B,EAAE,KAAmB,EAAE,GAAkC;IAC5H,IAAI,EAAC,cAAc,SAAS,EAAC,GAAG;IAChC,IAAI,YAAY,CAAA,GAAA,+BAAQ;IACxB,IAAI,aAAa,CAAA,GAAA,+BAAQ,EAAE;QACzB,cAAc;QACd,mBAAmB;IACrB;IAEA,OAAO;QACL,UAAU;YACR,MAAM;QACR;QACA,gBAAgB;YACd,IAAI;YACJ,MAAM;QACR;QACA,eAAe;YACb,MAAM;YACN,GAAG,UAAU;QACf;IACF;AACF","sources":["packages/@react-aria/gridlist/src/useGridListSection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport type {ListState} from '@react-stately/list';\nimport {useLabels, useSlotId} from '@react-aria/utils';\n\nexport interface AriaGridListSectionProps {\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\nexport interface GridListSectionAria {\n /** Props for the wrapper list item. */\n rowProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n rowHeaderProps: DOMAttributes,\n\n /** Props for the grid's row group element. */\n rowGroupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a grid list.\n * See `useGridList` for more details about grid list.\n * @param props - Props for the section.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useGridListSection<T>(props: AriaGridListSectionProps, state: ListState<T>, ref: RefObject<HTMLElement | null>): GridListSectionAria {\n let {'aria-label': ariaLabel} = props;\n let headingId = useSlotId();\n let labelProps = useLabels({\n 'aria-label': ariaLabel,\n 'aria-labelledby': headingId\n });\n\n return {\n rowProps: {\n role: 'row'\n },\n rowHeaderProps: {\n id: headingId,\n role: 'rowheader'\n },\n rowGroupProps: {\n role: 'rowgroup',\n ...labelProps\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridListSection.main.js.map"}
@@ -1,38 +0,0 @@
1
- import {useSlotId as $6QchP$useSlotId, useLabels as $6QchP$useLabels} from "@react-aria/utils";
2
-
3
- /*
4
- * Copyright 2020 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */
14
- function $d6848ac28ff5c637$export$8a024deed275af3f(props, state, ref) {
15
- let { 'aria-label': ariaLabel } = props;
16
- let headingId = (0, $6QchP$useSlotId)();
17
- let labelProps = (0, $6QchP$useLabels)({
18
- 'aria-label': ariaLabel,
19
- 'aria-labelledby': headingId
20
- });
21
- return {
22
- rowProps: {
23
- role: 'row'
24
- },
25
- rowHeaderProps: {
26
- id: headingId,
27
- role: 'rowheader'
28
- },
29
- rowGroupProps: {
30
- role: 'rowgroup',
31
- ...labelProps
32
- }
33
- };
34
- }
35
-
36
-
37
- export {$d6848ac28ff5c637$export$8a024deed275af3f as useGridListSection};
38
- //# sourceMappingURL=useGridListSection.module.js.map
@@ -1,38 +0,0 @@
1
- import {useSlotId as $6QchP$useSlotId, useLabels as $6QchP$useLabels} from "@react-aria/utils";
2
-
3
- /*
4
- * Copyright 2020 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */
14
- function $d6848ac28ff5c637$export$8a024deed275af3f(props, state, ref) {
15
- let { 'aria-label': ariaLabel } = props;
16
- let headingId = (0, $6QchP$useSlotId)();
17
- let labelProps = (0, $6QchP$useLabels)({
18
- 'aria-label': ariaLabel,
19
- 'aria-labelledby': headingId
20
- });
21
- return {
22
- rowProps: {
23
- role: 'row'
24
- },
25
- rowHeaderProps: {
26
- id: headingId,
27
- role: 'rowheader'
28
- },
29
- rowGroupProps: {
30
- role: 'rowgroup',
31
- ...labelProps
32
- }
33
- };
34
- }
35
-
36
-
37
- export {$d6848ac28ff5c637$export$8a024deed275af3f as useGridListSection};
38
- //# sourceMappingURL=useGridListSection.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AA4BM,SAAS,0CAAsB,KAA+B,EAAE,KAAmB,EAAE,GAAkC;IAC5H,IAAI,EAAC,cAAc,SAAS,EAAC,GAAG;IAChC,IAAI,YAAY,CAAA,GAAA,gBAAQ;IACxB,IAAI,aAAa,CAAA,GAAA,gBAAQ,EAAE;QACzB,cAAc;QACd,mBAAmB;IACrB;IAEA,OAAO;QACL,UAAU;YACR,MAAM;QACR;QACA,gBAAgB;YACd,IAAI;YACJ,MAAM;QACR;QACA,eAAe;YACb,MAAM;YACN,GAAG,UAAU;QACf;IACF;AACF","sources":["packages/@react-aria/gridlist/src/useGridListSection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport type {ListState} from '@react-stately/list';\nimport {useLabels, useSlotId} from '@react-aria/utils';\n\nexport interface AriaGridListSectionProps {\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\nexport interface GridListSectionAria {\n /** Props for the wrapper list item. */\n rowProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n rowHeaderProps: DOMAttributes,\n\n /** Props for the grid's row group element. */\n rowGroupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a grid list.\n * See `useGridList` for more details about grid list.\n * @param props - Props for the section.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useGridListSection<T>(props: AriaGridListSectionProps, state: ListState<T>, ref: RefObject<HTMLElement | null>): GridListSectionAria {\n let {'aria-label': ariaLabel} = props;\n let headingId = useSlotId();\n let labelProps = useLabels({\n 'aria-label': ariaLabel,\n 'aria-labelledby': headingId\n });\n\n return {\n rowProps: {\n role: 'row'\n },\n rowHeaderProps: {\n id: headingId,\n role: 'rowheader'\n },\n rowGroupProps: {\n role: 'rowgroup',\n ...labelProps\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridListSection.module.js.map"}
@@ -1,34 +0,0 @@
1
- var $7db02799adae605d$exports = require("./utils.main.js");
2
- var $c2nZL$reactariagrid = require("@react-aria/grid");
3
-
4
-
5
- function $parcel$export(e, n, v, s) {
6
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
- }
8
-
9
- $parcel$export(module.exports, "useGridListSelectionCheckbox", () => $43131ea217bc2ad3$export$e29f2573fabbf7b9);
10
- /*
11
- * Copyright 2022 Adobe. All rights reserved.
12
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License. You may obtain a copy
14
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software distributed under
17
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
- * OF ANY KIND, either express or implied. See the License for the specific language
19
- * governing permissions and limitations under the License.
20
- */
21
-
22
- function $43131ea217bc2ad3$export$e29f2573fabbf7b9(props, state) {
23
- let { key: key } = props;
24
- const { checkboxProps: checkboxProps } = (0, $c2nZL$reactariagrid.useGridSelectionCheckbox)(props, state);
25
- return {
26
- checkboxProps: {
27
- ...checkboxProps,
28
- 'aria-labelledby': `${checkboxProps.id} ${(0, $7db02799adae605d$exports.getRowId)(state, key)}`
29
- }
30
- };
31
- }
32
-
33
-
34
- //# sourceMappingURL=useGridListSelectionCheckbox.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAWM,SAAS,0CAAgC,KAAqC,EAAE,KAAmB;IACxG,IAAI,OAAC,GAAG,EAAC,GAAG;IACZ,MAAM,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,6CAAuB,EAAE,OAAO;IAExD,OAAO;QACL,eAAe;YACb,GAAG,aAAa;YAChB,mBAAmB,GAAG,cAAc,EAAE,CAAC,CAAC,EAAE,CAAA,GAAA,kCAAO,EAAE,OAAO,MAAM;QAClE;IACF;AACF","sources":["packages/@react-aria/gridlist/src/useGridListSelectionCheckbox.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria, useGridSelectionCheckbox} from '@react-aria/grid';\nimport {getRowId} from './utils';\nimport type {ListState} from '@react-stately/list';\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid list.\n * @param props - Props for the selection checkbox.\n * @param state - State of the list, as returned by `useListState`.\n */\nexport function useGridListSelectionCheckbox<T>(props: AriaGridSelectionCheckboxProps, state: ListState<T>): GridSelectionCheckboxAria {\n let {key} = props;\n const {checkboxProps} = useGridSelectionCheckbox(props, state as any);\n\n return {\n checkboxProps: {\n ...checkboxProps,\n 'aria-labelledby': `${checkboxProps.id} ${getRowId(state, key)}`\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridListSelectionCheckbox.main.js.map"}
@@ -1,29 +0,0 @@
1
- import {getRowId as $ce9b18daab526bbd$export$f45c25170b9a99c2} from "./utils.mjs";
2
- import {useGridSelectionCheckbox as $hdH6v$useGridSelectionCheckbox} from "@react-aria/grid";
3
-
4
- /*
5
- * Copyright 2022 Adobe. All rights reserved.
6
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License. You may obtain a copy
8
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software distributed under
11
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
- * OF ANY KIND, either express or implied. See the License for the specific language
13
- * governing permissions and limitations under the License.
14
- */
15
-
16
- function $e52ffc04a4adbd52$export$e29f2573fabbf7b9(props, state) {
17
- let { key: key } = props;
18
- const { checkboxProps: checkboxProps } = (0, $hdH6v$useGridSelectionCheckbox)(props, state);
19
- return {
20
- checkboxProps: {
21
- ...checkboxProps,
22
- 'aria-labelledby': `${checkboxProps.id} ${(0, $ce9b18daab526bbd$export$f45c25170b9a99c2)(state, key)}`
23
- }
24
- };
25
- }
26
-
27
-
28
- export {$e52ffc04a4adbd52$export$e29f2573fabbf7b9 as useGridListSelectionCheckbox};
29
- //# sourceMappingURL=useGridListSelectionCheckbox.module.js.map
@@ -1,29 +0,0 @@
1
- import {getRowId as $ce9b18daab526bbd$export$f45c25170b9a99c2} from "./utils.module.js";
2
- import {useGridSelectionCheckbox as $hdH6v$useGridSelectionCheckbox} from "@react-aria/grid";
3
-
4
- /*
5
- * Copyright 2022 Adobe. All rights reserved.
6
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License. You may obtain a copy
8
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software distributed under
11
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
- * OF ANY KIND, either express or implied. See the License for the specific language
13
- * governing permissions and limitations under the License.
14
- */
15
-
16
- function $e52ffc04a4adbd52$export$e29f2573fabbf7b9(props, state) {
17
- let { key: key } = props;
18
- const { checkboxProps: checkboxProps } = (0, $hdH6v$useGridSelectionCheckbox)(props, state);
19
- return {
20
- checkboxProps: {
21
- ...checkboxProps,
22
- 'aria-labelledby': `${checkboxProps.id} ${(0, $ce9b18daab526bbd$export$f45c25170b9a99c2)(state, key)}`
23
- }
24
- };
25
- }
26
-
27
-
28
- export {$e52ffc04a4adbd52$export$e29f2573fabbf7b9 as useGridListSelectionCheckbox};
29
- //# sourceMappingURL=useGridListSelectionCheckbox.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAWM,SAAS,0CAAgC,KAAqC,EAAE,KAAmB;IACxG,IAAI,OAAC,GAAG,EAAC,GAAG;IACZ,MAAM,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,+BAAuB,EAAE,OAAO;IAExD,OAAO;QACL,eAAe;YACb,GAAG,aAAa;YAChB,mBAAmB,GAAG,cAAc,EAAE,CAAC,CAAC,EAAE,CAAA,GAAA,yCAAO,EAAE,OAAO,MAAM;QAClE;IACF;AACF","sources":["packages/@react-aria/gridlist/src/useGridListSelectionCheckbox.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria, useGridSelectionCheckbox} from '@react-aria/grid';\nimport {getRowId} from './utils';\nimport type {ListState} from '@react-stately/list';\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid list.\n * @param props - Props for the selection checkbox.\n * @param state - State of the list, as returned by `useListState`.\n */\nexport function useGridListSelectionCheckbox<T>(props: AriaGridSelectionCheckboxProps, state: ListState<T>): GridSelectionCheckboxAria {\n let {key} = props;\n const {checkboxProps} = useGridSelectionCheckbox(props, state as any);\n\n return {\n checkboxProps: {\n ...checkboxProps,\n 'aria-labelledby': `${checkboxProps.id} ${getRowId(state, key)}`\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridListSelectionCheckbox.module.js.map"}
@@ -1,31 +0,0 @@
1
-
2
- function $parcel$export(e, n, v, s) {
3
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
- }
5
-
6
- $parcel$export(module.exports, "listMap", () => $7db02799adae605d$export$5b9bb410392e3991);
7
- $parcel$export(module.exports, "getRowId", () => $7db02799adae605d$export$f45c25170b9a99c2);
8
- /*
9
- * Copyright 2020 Adobe. All rights reserved.
10
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License. You may obtain a copy
12
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software distributed under
15
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
- * OF ANY KIND, either express or implied. See the License for the specific language
17
- * governing permissions and limitations under the License.
18
- */ const $7db02799adae605d$export$5b9bb410392e3991 = new WeakMap();
19
- function $7db02799adae605d$export$f45c25170b9a99c2(state, key) {
20
- var _listMap_get;
21
- let { id: id } = (_listMap_get = $7db02799adae605d$export$5b9bb410392e3991.get(state)) !== null && _listMap_get !== void 0 ? _listMap_get : {};
22
- if (!id) throw new Error('Unknown list');
23
- return `${id}-${$7db02799adae605d$export$e0c709538cb8ae18(key)}`;
24
- }
25
- function $7db02799adae605d$export$e0c709538cb8ae18(key) {
26
- if (typeof key === 'string') return key.replace(/\s*/g, '');
27
- return '' + key;
28
- }
29
-
30
-
31
- //# sourceMappingURL=utils.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAeM,MAAM,4CAAsD,IAAI;AAEhE,SAAS,0CAAY,KAAmB,EAAE,GAAQ;QAC5C;IAAX,IAAI,MAAC,EAAE,EAAC,GAAG,CAAA,eAAA,0CAAQ,GAAG,CAAC,oBAAZ,0BAAA,eAAsB,CAAC;IAClC,IAAI,CAAC,IACH,MAAM,IAAI,MAAM;IAGlB,OAAO,GAAG,GAAG,CAAC,EAAE,0CAAa,MAAM;AACrC;AAEO,SAAS,0CAAa,GAAQ;IACnC,IAAI,OAAO,QAAQ,UACjB,OAAO,IAAI,OAAO,CAAC,QAAQ;IAG7B,OAAO,KAAK;AACd","sources":["packages/@react-aria/gridlist/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from '@react-types/shared';\nimport type {ListState} from '@react-stately/list';\n\ninterface ListMapShared {\n id: string,\n onAction?: (key: Key) => void,\n linkBehavior?: 'action' | 'selection' | 'override',\n keyboardNavigationBehavior: 'arrow' | 'tab',\n shouldSelectOnPressUp?: boolean\n}\n\n// Used to share:\n// id of the list and onAction between useList, useListItem, and useListSelectionCheckbox\nexport const listMap: WeakMap<ListState<unknown>, ListMapShared> = new WeakMap<ListState<unknown>, ListMapShared>();\n\nexport function getRowId<T>(state: ListState<T>, key: Key): string {\n let {id} = listMap.get(state) ?? {};\n if (!id) {\n throw new Error('Unknown list');\n }\n\n return `${id}-${normalizeKey(key)}`;\n}\n\nexport function normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n"],"names":[],"version":3,"file":"utils.main.js.map"}