@react-aria/grid 3.11.1 → 3.12.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.
- package/dist/GridKeyboardDelegate.main.js +19 -10
- package/dist/GridKeyboardDelegate.main.js.map +1 -1
- package/dist/GridKeyboardDelegate.mjs +20 -11
- package/dist/GridKeyboardDelegate.module.js +20 -11
- package/dist/GridKeyboardDelegate.module.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/useGrid.main.js +3 -2
- package/dist/useGrid.main.js.map +1 -1
- package/dist/useGrid.mjs +3 -2
- package/dist/useGrid.module.js +3 -2
- package/dist/useGrid.module.js.map +1 -1
- package/dist/useGridCell.main.js +12 -9
- package/dist/useGridCell.main.js.map +1 -1
- package/dist/useGridCell.mjs +5 -2
- package/dist/useGridCell.module.js +5 -2
- package/dist/useGridCell.module.js.map +1 -1
- package/dist/useGridSelectionAnnouncement.main.js +13 -4
- package/dist/useGridSelectionAnnouncement.main.js.map +1 -1
- package/dist/useGridSelectionAnnouncement.mjs +13 -4
- package/dist/useGridSelectionAnnouncement.module.js +13 -4
- package/dist/useGridSelectionAnnouncement.module.js.map +1 -1
- package/package.json +13 -13
- package/src/GridKeyboardDelegate.ts +34 -11
- package/src/useGrid.ts +8 -1
- package/src/useGridCell.ts +7 -2
- package/src/useGridSelectionAnnouncement.ts +14 -4
|
@@ -51,6 +51,21 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
|
|
|
51
51
|
}
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
|
+
getKeyForItemInRowByIndex(key, index = 0) {
|
|
55
|
+
if (index < 0) return null;
|
|
56
|
+
let item = this.collection.getItem(key);
|
|
57
|
+
if (!item) return null;
|
|
58
|
+
let i = 0;
|
|
59
|
+
for (let child of (0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection)){
|
|
60
|
+
var _child_key;
|
|
61
|
+
if (child.colSpan && child.colSpan + i > index) return (_child_key = child.key) !== null && _child_key !== void 0 ? _child_key : null;
|
|
62
|
+
if (child.colSpan) i = i + child.colSpan - 1;
|
|
63
|
+
var _child_key1;
|
|
64
|
+
if (i === index) return (_child_key1 = child.key) !== null && _child_key1 !== void 0 ? _child_key1 : null;
|
|
65
|
+
i++;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
54
69
|
getKeyBelow(fromKey) {
|
|
55
70
|
let key = fromKey;
|
|
56
71
|
let startItem = this.collection.getItem(key);
|
|
@@ -64,11 +79,8 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
|
|
|
64
79
|
if (key != null) {
|
|
65
80
|
// If focus was on a cell, focus the cell with the same index in the next row.
|
|
66
81
|
if (this.isCell(startItem)) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (!item) return null;
|
|
70
|
-
var _startItem_index, _getNthItem_key;
|
|
71
|
-
return (_getNthItem_key = (_getNthItem = (0, $iKGCm$reactstatelycollections.getNthItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) !== null && _getNthItem_key !== void 0 ? _getNthItem_key : null;
|
|
82
|
+
let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;
|
|
83
|
+
return this.getKeyForItemInRowByIndex(key, startIndex);
|
|
72
84
|
}
|
|
73
85
|
// Otherwise, focus the next row
|
|
74
86
|
if (this.focusMode === 'row') return key;
|
|
@@ -88,11 +100,8 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
|
|
|
88
100
|
if (key != null) {
|
|
89
101
|
// If focus was on a cell, focus the cell with the same index in the previous row.
|
|
90
102
|
if (this.isCell(startItem)) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!item) return null;
|
|
94
|
-
var _startItem_index;
|
|
95
|
-
return ((_getNthItem = (0, $iKGCm$reactstatelycollections.getNthItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) || null;
|
|
103
|
+
let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;
|
|
104
|
+
return this.getKeyForItemInRowByIndex(key, startIndex);
|
|
96
105
|
}
|
|
97
106
|
// Otherwise, focus the previous row
|
|
98
107
|
if (this.focusMode === 'row') return key;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAoBM,MAAM;IAsBD,OAAO,IAAa,EAAE;QAC9B,OAAO,KAAK,IAAI,KAAK;IACvB;IAEU,MAAM,IAAa,EAAE;QAC7B,OAAO,KAAK,IAAI,KAAK,SAAS,KAAK,IAAI,KAAK;IAC9C;IAEQ,WAAW,IAAmB,EAAE;YACK;QAA3C,OAAO,IAAI,CAAC,gBAAgB,KAAK,SAAU,CAAA,EAAA,cAAA,KAAK,KAAK,cAAV,kCAAA,YAAY,UAAU,KAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,GAAG,CAAA;IACrG;IAEU,gBAAgB,OAAa,EAAE,IAAiC,EAAE;QAC1E,IAAI,MAAM,WAAW,OACjB,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,WAC7B,IAAI,CAAC,UAAU,CAAC,UAAU;QAE9B,MAAO,OAAO,KAAM;YAClB,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACnC,IAAI,CAAC,MACH,OAAO;YAET,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAU,CAAA,CAAC,QAAQ,KAAK,KAAI,GAC/C,OAAO;YAGT,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QACrC;QACA,OAAO;IACT;IAEU,YAAY,OAAa,EAAE,IAAiC,EAAE;QACtE,IAAI,MAAM,WAAW,OACjB,IAAI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,WAAW;IAC5C;IAdA,YAAY,MAAwB,CAAE;QACpC,IAAI,CAAC,MAAM,GAAG;IAChB;AAaF","sources":["packages/@react-aria/grid/src/GridKeyboardDelegate.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 {Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, RefObject, Size} from '@react-types/shared';\nimport {DOMLayoutDelegate} from '@react-aria/selection';\nimport {getChildNodes, getFirstItem, getLastItem, getNthItem} from '@react-stately/collections';\nimport {GridCollection} from '@react-types/grid';\n\nexport interface GridKeyboardDelegateOptions<C> {\n collection: C,\n disabledKeys: Set<Key>,\n disabledBehavior?: DisabledBehavior,\n ref?: RefObject<HTMLElement | null>,\n direction: Direction,\n collator?: Intl.Collator,\n layoutDelegate?: LayoutDelegate,\n /** @deprecated - Use layoutDelegate instead. */\n layout?: DeprecatedLayout,\n focusMode?: 'row' | 'cell'\n}\n\nexport class GridKeyboardDelegate<T, C extends GridCollection<T>> implements KeyboardDelegate {\n collection: C;\n protected disabledKeys: Set<Key>;\n protected disabledBehavior: DisabledBehavior;\n protected direction: Direction;\n protected collator: Intl.Collator | undefined;\n protected layoutDelegate: LayoutDelegate;\n protected focusMode;\n\n constructor(options: GridKeyboardDelegateOptions<C>) {\n this.collection = options.collection;\n this.disabledKeys = options.disabledKeys;\n this.disabledBehavior = options.disabledBehavior || 'all';\n this.direction = options.direction;\n this.collator = options.collator;\n if (!options.layout && !options.ref) {\n throw new Error('Either a layout or a ref must be specified.');\n }\n this.layoutDelegate = options.layoutDelegate || (options.layout ? new DeprecatedLayoutDelegate(options.layout) : new DOMLayoutDelegate(options.ref!));\n this.focusMode = options.focusMode || 'row';\n }\n\n protected isCell(node: Node<T>) {\n return node.type === 'cell';\n }\n\n protected isRow(node: Node<T>) {\n return node.type === 'row' || node.type === 'item';\n }\n\n private isDisabled(item: Node<unknown>) {\n return this.disabledBehavior === 'all' && (item.props?.isDisabled || this.disabledKeys.has(item.key));\n }\n\n protected findPreviousKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyBefore(fromKey)\n : this.collection.getLastKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\n return null;\n }\n\n protected findNextKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyAfter(fromKey)\n : this.collection.getFirstKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n return null;\n }\n }\n return null;\n }\n\n getKeyBelow(fromKey: Key) {\n let key: Key | null = fromKey;\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return null;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey ?? null;\n }\n if (key == null) {\n return null;\n }\n\n // Find the next item\n key = this.findNextKey(key, (item => item.type === 'item'));\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the next row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n return getNthItem(getChildNodes(item, this.collection), startItem.index ?? 0)?.key ?? null;\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n return null;\n }\n\n getKeyAbove(fromKey: Key) {\n let key: Key | null = fromKey;\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return null;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey ?? null;\n }\n if (key == null) {\n return null;\n }\n\n // Find the previous item\n key = this.findPreviousKey(key, item => item.type === 'item');\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the previous row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n return getNthItem(getChildNodes(item, this.collection), startItem.index ?? 0)?.key || null;\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n return null;\n }\n\n getKeyRightOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If focus is on a row, focus the first child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return (this.direction === 'rtl'\n ? getLastItem(children)?.key\n : getFirstItem(children)?.key) ?? null;\n }\n\n // If focus is on a cell, focus the next cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item) && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n let next = (this.direction === 'rtl'\n ? getNthItem(children, item.index - 1)\n : getNthItem(children, item.index + 1)) ?? null;\n\n if (next) {\n return next.key ?? null;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey ?? null;\n }\n\n return (this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key)) ?? null;\n }\n return null;\n }\n\n getKeyLeftOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If focus is on a row, focus the last child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return (this.direction === 'rtl'\n ? getFirstItem(children)?.key\n : getLastItem(children)?.key) ?? null;\n }\n\n // If focus is on a cell, focus the previous cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item) && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n let prev = (this.direction === 'rtl'\n ? getNthItem(children, item.index + 1)\n : getNthItem(children, item.index - 1)) ?? null;\n\n if (prev) {\n return prev.key ?? null;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey ?? null;\n }\n\n return (this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key)) ?? null;\n }\n return null;\n }\n\n getFirstKey(fromKey?: Key, global?: boolean) {\n let key: Key | null = fromKey ?? null;\n let item: Node<T> | undefined | null;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the first cell in the parent row.\n if (this.isCell(item) && !global && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n return getFirstItem(getChildNodes(parent, this.collection))?.key ?? null;\n }\n }\n\n // Find the first row\n key = this.findNextKey(undefined, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the first cell in the first row.\n if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n key = getFirstItem(getChildNodes(item, this.collection))?.key ?? null;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getLastKey(fromKey?: Key, global?: boolean) {\n let key: Key | null = fromKey ?? null;\n let item: Node<T> | undefined | null;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the last cell in the parent row.\n if (this.isCell(item) && !global && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n return getLastItem(children)?.key ?? null;\n }\n }\n\n // Find the last row\n key = this.findPreviousKey(undefined, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the last cell in the last row.\n if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n let children = getChildNodes(item, this.collection);\n key = getLastItem(children)?.key ?? null;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getKeyPageAbove(fromKey: Key) {\n let key: Key | null = fromKey;\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);\n\n while (itemRect && itemRect.y > pageY && key != null) {\n key = this.getKeyAbove(key) ?? null;\n if (key == null) {\n break;\n }\n itemRect = this.layoutDelegate.getItemRect(key);\n }\n\n return key;\n }\n\n getKeyPageBelow(fromKey: Key) {\n let key: Key | null = fromKey;\n let itemRect = this.layoutDelegate.getItemRect(key);\n\n if (!itemRect) {\n return null;\n }\n\n let pageHeight = this.layoutDelegate.getVisibleRect().height;\n let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y + pageHeight);\n\n while (itemRect && (itemRect.y + itemRect.height) < pageY) {\n let nextKey = this.getKeyBelow(key);\n // If nextKey is undefined, we've reached the last row already\n if (nextKey == null) {\n break;\n }\n\n itemRect = this.layoutDelegate.getItemRect(nextKey);\n key = nextKey;\n }\n\n return key;\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n let key: Key | null = fromKey ?? null;\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n key = fromKey ?? this.getFirstKey();\n if (key == null) {\n return null;\n }\n\n // If the starting key is a cell, search from its parent row.\n let startItem = collection.getItem(key);\n if (!startItem) {\n return null;\n }\n if (startItem.type === 'cell') {\n key = startItem.parentKey ?? null;\n }\n\n let hasWrapped = false;\n while (key != null) {\n let item = collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // check row text value for match\n if (item.textValue) {\n let substring = item.textValue.slice(0, search.length);\n if (this.collator.compare(substring, search) === 0) {\n if (this.isRow(item) && this.focusMode === 'cell') {\n return getFirstItem(getChildNodes(item, this.collection))?.key ?? null;\n }\n\n return item.key;\n }\n }\n\n key = this.findNextKey(key, item => item.type === 'item');\n\n // Wrap around when reaching the end of the collection\n if (key == null && !hasWrapped) {\n key = this.getFirstKey();\n hasWrapped = true;\n }\n }\n\n return null;\n }\n}\n\n/* Backward compatibility for old Virtualizer Layout interface. */\ninterface DeprecatedLayout {\n getLayoutInfo(key: Key): DeprecatedLayoutInfo,\n getContentSize(): Size,\n virtualizer: DeprecatedVirtualizer\n}\n\ninterface DeprecatedLayoutInfo {\n rect: Rect\n}\n\ninterface DeprecatedVirtualizer {\n visibleRect: Rect\n}\n\nclass DeprecatedLayoutDelegate implements LayoutDelegate {\n layout: DeprecatedLayout;\n\n constructor(layout: DeprecatedLayout) {\n this.layout = layout;\n }\n\n getContentSize(): Size {\n return this.layout.getContentSize();\n }\n\n getItemRect(key: Key): Rect | null {\n return this.layout.getLayoutInfo(key)?.rect || null;\n }\n\n getVisibleRect(): Rect {\n return this.layout.virtualizer.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"GridKeyboardDelegate.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAoBM,MAAM;IAsBD,OAAO,IAAa,EAAE;QAC9B,OAAO,KAAK,IAAI,KAAK;IACvB;IAEU,MAAM,IAAa,EAAE;QAC7B,OAAO,KAAK,IAAI,KAAK,SAAS,KAAK,IAAI,KAAK;IAC9C;IAEQ,WAAW,IAAmB,EAAE;YACK;QAA3C,OAAO,IAAI,CAAC,gBAAgB,KAAK,SAAU,CAAA,EAAA,cAAA,KAAK,KAAK,cAAV,kCAAA,YAAY,UAAU,KAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,GAAG,CAAA;IACrG;IAEU,gBAAgB,OAAa,EAAE,IAAiC,EAAE;QAC1E,IAAI,MAAM,WAAW,OACjB,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,WAC7B,IAAI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,QAAQ,GAAG,EACjC,MAAM,IAAI,MAAM;QAElB,IAAI,CAAC,cAAc,GAAG,QAAQ,cAAc,IAAK,CAAA,QAAQ,MAAM,GAAG,IAAI,+CAAyB,QAAQ,MAAM,IAAI,IAAI,CAAA,GAAA,2CAAgB,EAAE,QAAQ,GAAG,CAAC;QACnJ,IAAI,CAAC,SAAS,GAAG,QAAQ,SAAS,IAAI;IACxC;AA8YF;AAiBA,MAAM;IAOJ,iBAAuB;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc;IACnC;IAEA,YAAY,GAAQ,EAAe;YAC1B;QAAP,OAAO,EAAA,6BAAA,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,kBAA1B,iDAAA,2BAAgC,IAAI,KAAI;IACjD;IAEA,iBAAuB;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW;IAC5C;IAdA,YAAY,MAAwB,CAAE;QACpC,IAAI,CAAC,MAAM,GAAG;IAChB;AAaF","sources":["packages/@react-aria/grid/src/GridKeyboardDelegate.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 {Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, RefObject, Size} from '@react-types/shared';\nimport {DOMLayoutDelegate} from '@react-aria/selection';\nimport {getChildNodes, getFirstItem, getLastItem, getNthItem} from '@react-stately/collections';\nimport {GridCollection, GridNode} from '@react-types/grid';\n\nexport interface GridKeyboardDelegateOptions<C> {\n collection: C,\n disabledKeys: Set<Key>,\n disabledBehavior?: DisabledBehavior,\n ref?: RefObject<HTMLElement | null>,\n direction: Direction,\n collator?: Intl.Collator,\n layoutDelegate?: LayoutDelegate,\n /** @deprecated - Use layoutDelegate instead. */\n layout?: DeprecatedLayout,\n focusMode?: 'row' | 'cell'\n}\n\nexport class GridKeyboardDelegate<T, C extends GridCollection<T>> implements KeyboardDelegate {\n collection: C;\n protected disabledKeys: Set<Key>;\n protected disabledBehavior: DisabledBehavior;\n protected direction: Direction;\n protected collator: Intl.Collator | undefined;\n protected layoutDelegate: LayoutDelegate;\n protected focusMode;\n\n constructor(options: GridKeyboardDelegateOptions<C>) {\n this.collection = options.collection;\n this.disabledKeys = options.disabledKeys;\n this.disabledBehavior = options.disabledBehavior || 'all';\n this.direction = options.direction;\n this.collator = options.collator;\n if (!options.layout && !options.ref) {\n throw new Error('Either a layout or a ref must be specified.');\n }\n this.layoutDelegate = options.layoutDelegate || (options.layout ? new DeprecatedLayoutDelegate(options.layout) : new DOMLayoutDelegate(options.ref!));\n this.focusMode = options.focusMode || 'row';\n }\n\n protected isCell(node: Node<T>) {\n return node.type === 'cell';\n }\n\n protected isRow(node: Node<T>) {\n return node.type === 'row' || node.type === 'item';\n }\n\n private isDisabled(item: Node<unknown>) {\n return this.disabledBehavior === 'all' && (item.props?.isDisabled || this.disabledKeys.has(item.key));\n }\n\n protected findPreviousKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyBefore(fromKey)\n : this.collection.getLastKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\n return null;\n }\n\n protected findNextKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyAfter(fromKey)\n : this.collection.getFirstKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n return null;\n }\n }\n return null;\n }\n\n protected getKeyForItemInRowByIndex(key: Key, index: number = 0): Key | null {\n if (index < 0) {\n return null;\n }\n\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n let i = 0;\n for (let child of getChildNodes(item, this.collection) as Iterable<GridNode<T>>) {\n if (child.colSpan && child.colSpan + i > index) {\n return child.key ?? null;\n }\n\n if (child.colSpan) {\n i = i + child.colSpan - 1;\n }\n\n if (i === index) {\n return child.key ?? null;\n }\n\n i++;\n }\n return null;\n }\n\n getKeyBelow(fromKey: Key) {\n let key: Key | null = fromKey;\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return null;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey ?? null;\n }\n if (key == null) {\n return null;\n }\n\n // Find the next item\n key = this.findNextKey(key, (item => item.type === 'item'));\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the next row.\n if (this.isCell(startItem)) {\n let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;\n return this.getKeyForItemInRowByIndex(key, startIndex);\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n return null;\n }\n\n getKeyAbove(fromKey: Key) {\n let key: Key | null = fromKey;\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return null;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey ?? null;\n }\n if (key == null) {\n return null;\n }\n\n // Find the previous item\n key = this.findPreviousKey(key, item => item.type === 'item');\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the previous row.\n if (this.isCell(startItem)) {\n let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;\n return this.getKeyForItemInRowByIndex(key, startIndex);\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n return null;\n }\n\n getKeyRightOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If focus is on a row, focus the first child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return (this.direction === 'rtl'\n ? getLastItem(children)?.key\n : getFirstItem(children)?.key) ?? null;\n }\n\n // If focus is on a cell, focus the next cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item) && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n let next = (this.direction === 'rtl'\n ? getNthItem(children, item.index - 1)\n : getNthItem(children, item.index + 1)) ?? null;\n\n if (next) {\n return next.key ?? null;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey ?? null;\n }\n\n return (this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key)) ?? null;\n }\n return null;\n }\n\n getKeyLeftOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If focus is on a row, focus the last child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return (this.direction === 'rtl'\n ? getFirstItem(children)?.key\n : getLastItem(children)?.key) ?? null;\n }\n\n // If focus is on a cell, focus the previous cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item) && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n let prev = (this.direction === 'rtl'\n ? getNthItem(children, item.index + 1)\n : getNthItem(children, item.index - 1)) ?? null;\n\n if (prev) {\n return prev.key ?? null;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey ?? null;\n }\n\n return (this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key)) ?? null;\n }\n return null;\n }\n\n getFirstKey(fromKey?: Key, global?: boolean) {\n let key: Key | null = fromKey ?? null;\n let item: Node<T> | undefined | null;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the first cell in the parent row.\n if (this.isCell(item) && !global && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n return getFirstItem(getChildNodes(parent, this.collection))?.key ?? null;\n }\n }\n\n // Find the first row\n key = this.findNextKey(undefined, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the first cell in the first row.\n if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n key = getFirstItem(getChildNodes(item, this.collection))?.key ?? null;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getLastKey(fromKey?: Key, global?: boolean) {\n let key: Key | null = fromKey ?? null;\n let item: Node<T> | undefined | null;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the last cell in the parent row.\n if (this.isCell(item) && !global && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n return getLastItem(children)?.key ?? null;\n }\n }\n\n // Find the last row\n key = this.findPreviousKey(undefined, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the last cell in the last row.\n if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n let children = getChildNodes(item, this.collection);\n key = getLastItem(children)?.key ?? null;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getKeyPageAbove(fromKey: Key) {\n let key: Key | null = fromKey;\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);\n\n while (itemRect && itemRect.y > pageY && key != null) {\n key = this.getKeyAbove(key) ?? null;\n if (key == null) {\n break;\n }\n itemRect = this.layoutDelegate.getItemRect(key);\n }\n\n return key;\n }\n\n getKeyPageBelow(fromKey: Key) {\n let key: Key | null = fromKey;\n let itemRect = this.layoutDelegate.getItemRect(key);\n\n if (!itemRect) {\n return null;\n }\n\n let pageHeight = this.layoutDelegate.getVisibleRect().height;\n let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y + pageHeight);\n\n while (itemRect && (itemRect.y + itemRect.height) < pageY) {\n let nextKey = this.getKeyBelow(key);\n // If nextKey is undefined, we've reached the last row already\n if (nextKey == null) {\n break;\n }\n\n itemRect = this.layoutDelegate.getItemRect(nextKey);\n key = nextKey;\n }\n\n return key;\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n let key: Key | null = fromKey ?? null;\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n key = fromKey ?? this.getFirstKey();\n if (key == null) {\n return null;\n }\n\n // If the starting key is a cell, search from its parent row.\n let startItem = collection.getItem(key);\n if (!startItem) {\n return null;\n }\n if (startItem.type === 'cell') {\n key = startItem.parentKey ?? null;\n }\n\n let hasWrapped = false;\n while (key != null) {\n let item = collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // check row text value for match\n if (item.textValue) {\n let substring = item.textValue.slice(0, search.length);\n if (this.collator.compare(substring, search) === 0) {\n if (this.isRow(item) && this.focusMode === 'cell') {\n return getFirstItem(getChildNodes(item, this.collection))?.key ?? null;\n }\n\n return item.key;\n }\n }\n\n key = this.findNextKey(key, item => item.type === 'item');\n\n // Wrap around when reaching the end of the collection\n if (key == null && !hasWrapped) {\n key = this.getFirstKey();\n hasWrapped = true;\n }\n }\n\n return null;\n }\n}\n\n/* Backward compatibility for old Virtualizer Layout interface. */\ninterface DeprecatedLayout {\n getLayoutInfo(key: Key): DeprecatedLayoutInfo,\n getContentSize(): Size,\n virtualizer: DeprecatedVirtualizer\n}\n\ninterface DeprecatedLayoutInfo {\n rect: Rect\n}\n\ninterface DeprecatedVirtualizer {\n visibleRect: Rect\n}\n\nclass DeprecatedLayoutDelegate implements LayoutDelegate {\n layout: DeprecatedLayout;\n\n constructor(layout: DeprecatedLayout) {\n this.layout = layout;\n }\n\n getContentSize(): Size {\n return this.layout.getContentSize();\n }\n\n getItemRect(key: Key): Rect | null {\n return this.layout.getLayoutInfo(key)?.rect || null;\n }\n\n getVisibleRect(): Rect {\n return this.layout.virtualizer.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"GridKeyboardDelegate.main.js.map"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {DOMLayoutDelegate as $kbsd1$DOMLayoutDelegate} from "@react-aria/selection";
|
|
2
|
-
import {
|
|
2
|
+
import {getChildNodes as $kbsd1$getChildNodes, getLastItem as $kbsd1$getLastItem, getFirstItem as $kbsd1$getFirstItem, getNthItem as $kbsd1$getNthItem} from "@react-stately/collections";
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -45,6 +45,21 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
|
|
|
45
45
|
}
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
|
+
getKeyForItemInRowByIndex(key, index = 0) {
|
|
49
|
+
if (index < 0) return null;
|
|
50
|
+
let item = this.collection.getItem(key);
|
|
51
|
+
if (!item) return null;
|
|
52
|
+
let i = 0;
|
|
53
|
+
for (let child of (0, $kbsd1$getChildNodes)(item, this.collection)){
|
|
54
|
+
var _child_key;
|
|
55
|
+
if (child.colSpan && child.colSpan + i > index) return (_child_key = child.key) !== null && _child_key !== void 0 ? _child_key : null;
|
|
56
|
+
if (child.colSpan) i = i + child.colSpan - 1;
|
|
57
|
+
var _child_key1;
|
|
58
|
+
if (i === index) return (_child_key1 = child.key) !== null && _child_key1 !== void 0 ? _child_key1 : null;
|
|
59
|
+
i++;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
48
63
|
getKeyBelow(fromKey) {
|
|
49
64
|
let key = fromKey;
|
|
50
65
|
let startItem = this.collection.getItem(key);
|
|
@@ -58,11 +73,8 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
|
|
|
58
73
|
if (key != null) {
|
|
59
74
|
// If focus was on a cell, focus the cell with the same index in the next row.
|
|
60
75
|
if (this.isCell(startItem)) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!item) return null;
|
|
64
|
-
var _startItem_index, _getNthItem_key;
|
|
65
|
-
return (_getNthItem_key = (_getNthItem = (0, $kbsd1$getNthItem)((0, $kbsd1$getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) !== null && _getNthItem_key !== void 0 ? _getNthItem_key : null;
|
|
76
|
+
let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;
|
|
77
|
+
return this.getKeyForItemInRowByIndex(key, startIndex);
|
|
66
78
|
}
|
|
67
79
|
// Otherwise, focus the next row
|
|
68
80
|
if (this.focusMode === 'row') return key;
|
|
@@ -82,11 +94,8 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
|
|
|
82
94
|
if (key != null) {
|
|
83
95
|
// If focus was on a cell, focus the cell with the same index in the previous row.
|
|
84
96
|
if (this.isCell(startItem)) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!item) return null;
|
|
88
|
-
var _startItem_index;
|
|
89
|
-
return ((_getNthItem = (0, $kbsd1$getNthItem)((0, $kbsd1$getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) || null;
|
|
97
|
+
let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;
|
|
98
|
+
return this.getKeyForItemInRowByIndex(key, startIndex);
|
|
90
99
|
}
|
|
91
100
|
// Otherwise, focus the previous row
|
|
92
101
|
if (this.focusMode === 'row') return key;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {DOMLayoutDelegate as $kbsd1$DOMLayoutDelegate} from "@react-aria/selection";
|
|
2
|
-
import {
|
|
2
|
+
import {getChildNodes as $kbsd1$getChildNodes, getLastItem as $kbsd1$getLastItem, getFirstItem as $kbsd1$getFirstItem, getNthItem as $kbsd1$getNthItem} from "@react-stately/collections";
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -45,6 +45,21 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
|
|
|
45
45
|
}
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
|
+
getKeyForItemInRowByIndex(key, index = 0) {
|
|
49
|
+
if (index < 0) return null;
|
|
50
|
+
let item = this.collection.getItem(key);
|
|
51
|
+
if (!item) return null;
|
|
52
|
+
let i = 0;
|
|
53
|
+
for (let child of (0, $kbsd1$getChildNodes)(item, this.collection)){
|
|
54
|
+
var _child_key;
|
|
55
|
+
if (child.colSpan && child.colSpan + i > index) return (_child_key = child.key) !== null && _child_key !== void 0 ? _child_key : null;
|
|
56
|
+
if (child.colSpan) i = i + child.colSpan - 1;
|
|
57
|
+
var _child_key1;
|
|
58
|
+
if (i === index) return (_child_key1 = child.key) !== null && _child_key1 !== void 0 ? _child_key1 : null;
|
|
59
|
+
i++;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
48
63
|
getKeyBelow(fromKey) {
|
|
49
64
|
let key = fromKey;
|
|
50
65
|
let startItem = this.collection.getItem(key);
|
|
@@ -58,11 +73,8 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
|
|
|
58
73
|
if (key != null) {
|
|
59
74
|
// If focus was on a cell, focus the cell with the same index in the next row.
|
|
60
75
|
if (this.isCell(startItem)) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!item) return null;
|
|
64
|
-
var _startItem_index, _getNthItem_key;
|
|
65
|
-
return (_getNthItem_key = (_getNthItem = (0, $kbsd1$getNthItem)((0, $kbsd1$getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) !== null && _getNthItem_key !== void 0 ? _getNthItem_key : null;
|
|
76
|
+
let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;
|
|
77
|
+
return this.getKeyForItemInRowByIndex(key, startIndex);
|
|
66
78
|
}
|
|
67
79
|
// Otherwise, focus the next row
|
|
68
80
|
if (this.focusMode === 'row') return key;
|
|
@@ -82,11 +94,8 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
|
|
|
82
94
|
if (key != null) {
|
|
83
95
|
// If focus was on a cell, focus the cell with the same index in the previous row.
|
|
84
96
|
if (this.isCell(startItem)) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!item) return null;
|
|
88
|
-
var _startItem_index;
|
|
89
|
-
return ((_getNthItem = (0, $kbsd1$getNthItem)((0, $kbsd1$getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) || null;
|
|
97
|
+
let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;
|
|
98
|
+
return this.getKeyForItemInRowByIndex(key, startIndex);
|
|
90
99
|
}
|
|
91
100
|
// Otherwise, focus the previous row
|
|
92
101
|
if (this.focusMode === 'row') return key;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAoBM,MAAM;IAsBD,OAAO,IAAa,EAAE;QAC9B,OAAO,KAAK,IAAI,KAAK;IACvB;IAEU,MAAM,IAAa,EAAE;QAC7B,OAAO,KAAK,IAAI,KAAK,SAAS,KAAK,IAAI,KAAK;IAC9C;IAEQ,WAAW,IAAmB,EAAE;YACK;QAA3C,OAAO,IAAI,CAAC,gBAAgB,KAAK,SAAU,CAAA,EAAA,cAAA,KAAK,KAAK,cAAV,kCAAA,YAAY,UAAU,KAAI,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AAI,CAAC,QAAQ,GAAG,EACjC,MAAM,IAAI,MAAM;QAElB,IAAI,CAAC,cAAc,GAAG,QAAQ,cAAc,IAAK,CAAA,QAAQ,MAAM,GAAG,IAAI,+CAAyB,QAAQ,MAAM,IAAI,IAAI,CAAA,GAAA,wBAAgB,EAAE,QAAQ,GAAG,CAAC;QACnJ,IAAI,CAAC,SAAS,GAAG,QAAQ,SAAS,IAAI;IACxC;AAuXF;AAiBA,MAAM;IAOJ,iBAAuB;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc;IACnC;IAEA,YAAY,GAAQ,EAAe;YAC1B;QAAP,OAAO,EAAA,6BAAA,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,kBAA1B,iDAAA,2BAAgC,IAAI,KAAI;IACjD;IAEA,iBAAuB;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW;IAC5C;IAdA,YAAY,MAAwB,CAAE;QACpC,IAAI,CAAC,MAAM,GAAG;IAChB;AAaF","sources":["packages/@react-aria/grid/src/GridKeyboardDelegate.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 {Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, RefObject, Size} from '@react-types/shared';\nimport {DOMLayoutDelegate} from '@react-aria/selection';\nimport {getChildNodes, getFirstItem, getLastItem, getNthItem} from '@react-stately/collections';\nimport {GridCollection} from '@react-types/grid';\n\nexport interface GridKeyboardDelegateOptions<C> {\n collection: C,\n disabledKeys: Set<Key>,\n disabledBehavior?: DisabledBehavior,\n ref?: RefObject<HTMLElement | null>,\n direction: Direction,\n collator?: Intl.Collator,\n layoutDelegate?: LayoutDelegate,\n /** @deprecated - Use layoutDelegate instead. */\n layout?: DeprecatedLayout,\n focusMode?: 'row' | 'cell'\n}\n\nexport class GridKeyboardDelegate<T, C extends GridCollection<T>> implements KeyboardDelegate {\n collection: C;\n protected disabledKeys: Set<Key>;\n protected disabledBehavior: DisabledBehavior;\n protected direction: Direction;\n protected collator: Intl.Collator | undefined;\n protected layoutDelegate: LayoutDelegate;\n protected focusMode;\n\n constructor(options: GridKeyboardDelegateOptions<C>) {\n this.collection = options.collection;\n this.disabledKeys = options.disabledKeys;\n this.disabledBehavior = options.disabledBehavior || 'all';\n this.direction = options.direction;\n this.collator = options.collator;\n if (!options.layout && !options.ref) {\n throw new Error('Either a layout or a ref must be specified.');\n }\n this.layoutDelegate = options.layoutDelegate || (options.layout ? new DeprecatedLayoutDelegate(options.layout) : new DOMLayoutDelegate(options.ref!));\n this.focusMode = options.focusMode || 'row';\n }\n\n protected isCell(node: Node<T>) {\n return node.type === 'cell';\n }\n\n protected isRow(node: Node<T>) {\n return node.type === 'row' || node.type === 'item';\n }\n\n private isDisabled(item: Node<unknown>) {\n return this.disabledBehavior === 'all' && (item.props?.isDisabled || this.disabledKeys.has(item.key));\n }\n\n protected findPreviousKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyBefore(fromKey)\n : this.collection.getLastKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\n return null;\n }\n\n protected findNextKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyAfter(fromKey)\n : this.collection.getFirstKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n return null;\n }\n }\n return null;\n }\n\n getKeyBelow(fromKey: Key) {\n let key: Key | null = fromKey;\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return null;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey ?? null;\n }\n if (key == null) {\n return null;\n }\n\n // Find the next item\n key = this.findNextKey(key, (item => item.type === 'item'));\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the next row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n return getNthItem(getChildNodes(item, this.collection), startItem.index ?? 0)?.key ?? null;\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n return null;\n }\n\n getKeyAbove(fromKey: Key) {\n let key: Key | null = fromKey;\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return null;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey ?? null;\n }\n if (key == null) {\n return null;\n }\n\n // Find the previous item\n key = this.findPreviousKey(key, item => item.type === 'item');\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the previous row.\n if (this.isCell(startItem)) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n return getNthItem(getChildNodes(item, this.collection), startItem.index ?? 0)?.key || null;\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n return null;\n }\n\n getKeyRightOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If focus is on a row, focus the first child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return (this.direction === 'rtl'\n ? getLastItem(children)?.key\n : getFirstItem(children)?.key) ?? null;\n }\n\n // If focus is on a cell, focus the next cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item) && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n let next = (this.direction === 'rtl'\n ? getNthItem(children, item.index - 1)\n : getNthItem(children, item.index + 1)) ?? null;\n\n if (next) {\n return next.key ?? null;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey ?? null;\n }\n\n return (this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key)) ?? null;\n }\n return null;\n }\n\n getKeyLeftOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If focus is on a row, focus the last child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return (this.direction === 'rtl'\n ? getFirstItem(children)?.key\n : getLastItem(children)?.key) ?? null;\n }\n\n // If focus is on a cell, focus the previous cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item) && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n let prev = (this.direction === 'rtl'\n ? getNthItem(children, item.index + 1)\n : getNthItem(children, item.index - 1)) ?? null;\n\n if (prev) {\n return prev.key ?? null;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey ?? null;\n }\n\n return (this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key)) ?? null;\n }\n return null;\n }\n\n getFirstKey(fromKey?: Key, global?: boolean) {\n let key: Key | null = fromKey ?? null;\n let item: Node<T> | undefined | null;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the first cell in the parent row.\n if (this.isCell(item) && !global && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n return getFirstItem(getChildNodes(parent, this.collection))?.key ?? null;\n }\n }\n\n // Find the first row\n key = this.findNextKey(undefined, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the first cell in the first row.\n if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n key = getFirstItem(getChildNodes(item, this.collection))?.key ?? null;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getLastKey(fromKey?: Key, global?: boolean) {\n let key: Key | null = fromKey ?? null;\n let item: Node<T> | undefined | null;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the last cell in the parent row.\n if (this.isCell(item) && !global && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n return getLastItem(children)?.key ?? null;\n }\n }\n\n // Find the last row\n key = this.findPreviousKey(undefined, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the last cell in the last row.\n if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n let children = getChildNodes(item, this.collection);\n key = getLastItem(children)?.key ?? null;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getKeyPageAbove(fromKey: Key) {\n let key: Key | null = fromKey;\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);\n\n while (itemRect && itemRect.y > pageY && key != null) {\n key = this.getKeyAbove(key) ?? null;\n if (key == null) {\n break;\n }\n itemRect = this.layoutDelegate.getItemRect(key);\n }\n\n return key;\n }\n\n getKeyPageBelow(fromKey: Key) {\n let key: Key | null = fromKey;\n let itemRect = this.layoutDelegate.getItemRect(key);\n\n if (!itemRect) {\n return null;\n }\n\n let pageHeight = this.layoutDelegate.getVisibleRect().height;\n let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y + pageHeight);\n\n while (itemRect && (itemRect.y + itemRect.height) < pageY) {\n let nextKey = this.getKeyBelow(key);\n // If nextKey is undefined, we've reached the last row already\n if (nextKey == null) {\n break;\n }\n\n itemRect = this.layoutDelegate.getItemRect(nextKey);\n key = nextKey;\n }\n\n return key;\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n let key: Key | null = fromKey ?? null;\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n key = fromKey ?? this.getFirstKey();\n if (key == null) {\n return null;\n }\n\n // If the starting key is a cell, search from its parent row.\n let startItem = collection.getItem(key);\n if (!startItem) {\n return null;\n }\n if (startItem.type === 'cell') {\n key = startItem.parentKey ?? null;\n }\n\n let hasWrapped = false;\n while (key != null) {\n let item = collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // check row text value for match\n if (item.textValue) {\n let substring = item.textValue.slice(0, search.length);\n if (this.collator.compare(substring, search) === 0) {\n if (this.isRow(item) && this.focusMode === 'cell') {\n return getFirstItem(getChildNodes(item, this.collection))?.key ?? null;\n }\n\n return item.key;\n }\n }\n\n key = this.findNextKey(key, item => item.type === 'item');\n\n // Wrap around when reaching the end of the collection\n if (key == null && !hasWrapped) {\n key = this.getFirstKey();\n hasWrapped = true;\n }\n }\n\n return null;\n }\n}\n\n/* Backward compatibility for old Virtualizer Layout interface. */\ninterface DeprecatedLayout {\n getLayoutInfo(key: Key): DeprecatedLayoutInfo,\n getContentSize(): Size,\n virtualizer: DeprecatedVirtualizer\n}\n\ninterface DeprecatedLayoutInfo {\n rect: Rect\n}\n\ninterface DeprecatedVirtualizer {\n visibleRect: Rect\n}\n\nclass DeprecatedLayoutDelegate implements LayoutDelegate {\n layout: DeprecatedLayout;\n\n constructor(layout: DeprecatedLayout) {\n this.layout = layout;\n }\n\n getContentSize(): Size {\n return this.layout.getContentSize();\n }\n\n getItemRect(key: Key): Rect | null {\n return this.layout.getLayoutInfo(key)?.rect || null;\n }\n\n getVisibleRect(): Rect {\n return this.layout.virtualizer.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"GridKeyboardDeleg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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 {Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, RefObject, Size} from '@react-types/shared';\nimport {DOMLayoutDelegate} from '@react-aria/selection';\nimport {getChildNodes, getFirstItem, getLastItem, getNthItem} from '@react-stately/collections';\nimport {GridCollection, GridNode} from '@react-types/grid';\n\nexport interface GridKeyboardDelegateOptions<C> {\n collection: C,\n disabledKeys: Set<Key>,\n disabledBehavior?: DisabledBehavior,\n ref?: RefObject<HTMLElement | null>,\n direction: Direction,\n collator?: Intl.Collator,\n layoutDelegate?: LayoutDelegate,\n /** @deprecated - Use layoutDelegate instead. */\n layout?: DeprecatedLayout,\n focusMode?: 'row' | 'cell'\n}\n\nexport class GridKeyboardDelegate<T, C extends GridCollection<T>> implements KeyboardDelegate {\n collection: C;\n protected disabledKeys: Set<Key>;\n protected disabledBehavior: DisabledBehavior;\n protected direction: Direction;\n protected collator: Intl.Collator | undefined;\n protected layoutDelegate: LayoutDelegate;\n protected focusMode;\n\n constructor(options: GridKeyboardDelegateOptions<C>) {\n this.collection = options.collection;\n this.disabledKeys = options.disabledKeys;\n this.disabledBehavior = options.disabledBehavior || 'all';\n this.direction = options.direction;\n this.collator = options.collator;\n if (!options.layout && !options.ref) {\n throw new Error('Either a layout or a ref must be specified.');\n }\n this.layoutDelegate = options.layoutDelegate || (options.layout ? new DeprecatedLayoutDelegate(options.layout) : new DOMLayoutDelegate(options.ref!));\n this.focusMode = options.focusMode || 'row';\n }\n\n protected isCell(node: Node<T>) {\n return node.type === 'cell';\n }\n\n protected isRow(node: Node<T>) {\n return node.type === 'row' || node.type === 'item';\n }\n\n private isDisabled(item: Node<unknown>) {\n return this.disabledBehavior === 'all' && (item.props?.isDisabled || this.disabledKeys.has(item.key));\n }\n\n protected findPreviousKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyBefore(fromKey)\n : this.collection.getLastKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\n return null;\n }\n\n protected findNextKey(fromKey?: Key, pred?: (item: Node<T>) => boolean) {\n let key = fromKey != null\n ? this.collection.getKeyAfter(fromKey)\n : this.collection.getFirstKey();\n\n while (key != null) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n if (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n return null;\n }\n }\n return null;\n }\n\n protected getKeyForItemInRowByIndex(key: Key, index: number = 0): Key | null {\n if (index < 0) {\n return null;\n }\n\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n let i = 0;\n for (let child of getChildNodes(item, this.collection) as Iterable<GridNode<T>>) {\n if (child.colSpan && child.colSpan + i > index) {\n return child.key ?? null;\n }\n\n if (child.colSpan) {\n i = i + child.colSpan - 1;\n }\n\n if (i === index) {\n return child.key ?? null;\n }\n\n i++;\n }\n return null;\n }\n\n getKeyBelow(fromKey: Key) {\n let key: Key | null = fromKey;\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return null;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey ?? null;\n }\n if (key == null) {\n return null;\n }\n\n // Find the next item\n key = this.findNextKey(key, (item => item.type === 'item'));\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the next row.\n if (this.isCell(startItem)) {\n let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;\n return this.getKeyForItemInRowByIndex(key, startIndex);\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n return null;\n }\n\n getKeyAbove(fromKey: Key) {\n let key: Key | null = fromKey;\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return null;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey ?? null;\n }\n if (key == null) {\n return null;\n }\n\n // Find the previous item\n key = this.findPreviousKey(key, item => item.type === 'item');\n if (key != null) {\n // If focus was on a cell, focus the cell with the same index in the previous row.\n if (this.isCell(startItem)) {\n let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;\n return this.getKeyForItemInRowByIndex(key, startIndex);\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n return null;\n }\n\n getKeyRightOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If focus is on a row, focus the first child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return (this.direction === 'rtl'\n ? getLastItem(children)?.key\n : getFirstItem(children)?.key) ?? null;\n }\n\n // If focus is on a cell, focus the next cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item) && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n let next = (this.direction === 'rtl'\n ? getNthItem(children, item.index - 1)\n : getNthItem(children, item.index + 1)) ?? null;\n\n if (next) {\n return next.key ?? null;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey ?? null;\n }\n\n return (this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key)) ?? null;\n }\n return null;\n }\n\n getKeyLeftOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If focus is on a row, focus the last child cell.\n if (this.isRow(item)) {\n let children = getChildNodes(item, this.collection);\n return (this.direction === 'rtl'\n ? getFirstItem(children)?.key\n : getLastItem(children)?.key) ?? null;\n }\n\n // If focus is on a cell, focus the previous cell if any,\n // otherwise focus the parent row.\n if (this.isCell(item) && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n let prev = (this.direction === 'rtl'\n ? getNthItem(children, item.index + 1)\n : getNthItem(children, item.index - 1)) ?? null;\n\n if (prev) {\n return prev.key ?? null;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey ?? null;\n }\n\n return (this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key)) ?? null;\n }\n return null;\n }\n\n getFirstKey(fromKey?: Key, global?: boolean) {\n let key: Key | null = fromKey ?? null;\n let item: Node<T> | undefined | null;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the first cell in the parent row.\n if (this.isCell(item) && !global && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n return getFirstItem(getChildNodes(parent, this.collection))?.key ?? null;\n }\n }\n\n // Find the first row\n key = this.findNextKey(undefined, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the first cell in the first row.\n if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n key = getFirstItem(getChildNodes(item, this.collection))?.key ?? null;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getLastKey(fromKey?: Key, global?: boolean) {\n let key: Key | null = fromKey ?? null;\n let item: Node<T> | undefined | null;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // If global flag is not set, and a cell is currently focused,\n // move focus to the last cell in the parent row.\n if (this.isCell(item) && !global && item.parentKey != null) {\n let parent = this.collection.getItem(item.parentKey);\n if (!parent) {\n return null;\n }\n let children = getChildNodes(parent, this.collection);\n return getLastItem(children)?.key ?? null;\n }\n }\n\n // Find the last row\n key = this.findPreviousKey(undefined, item => item.type === 'item');\n\n // If global flag is set (or if focus mode is cell), focus the last cell in the last row.\n if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) {\n let item = this.collection.getItem(key);\n if (!item) {\n return null;\n }\n let children = getChildNodes(item, this.collection);\n key = getLastItem(children)?.key ?? null;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getKeyPageAbove(fromKey: Key) {\n let key: Key | null = fromKey;\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);\n\n while (itemRect && itemRect.y > pageY && key != null) {\n key = this.getKeyAbove(key) ?? null;\n if (key == null) {\n break;\n }\n itemRect = this.layoutDelegate.getItemRect(key);\n }\n\n return key;\n }\n\n getKeyPageBelow(fromKey: Key) {\n let key: Key | null = fromKey;\n let itemRect = this.layoutDelegate.getItemRect(key);\n\n if (!itemRect) {\n return null;\n }\n\n let pageHeight = this.layoutDelegate.getVisibleRect().height;\n let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y + pageHeight);\n\n while (itemRect && (itemRect.y + itemRect.height) < pageY) {\n let nextKey = this.getKeyBelow(key);\n // If nextKey is undefined, we've reached the last row already\n if (nextKey == null) {\n break;\n }\n\n itemRect = this.layoutDelegate.getItemRect(nextKey);\n key = nextKey;\n }\n\n return key;\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n let key: Key | null = fromKey ?? null;\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n key = fromKey ?? this.getFirstKey();\n if (key == null) {\n return null;\n }\n\n // If the starting key is a cell, search from its parent row.\n let startItem = collection.getItem(key);\n if (!startItem) {\n return null;\n }\n if (startItem.type === 'cell') {\n key = startItem.parentKey ?? null;\n }\n\n let hasWrapped = false;\n while (key != null) {\n let item = collection.getItem(key);\n if (!item) {\n return null;\n }\n\n // check row text value for match\n if (item.textValue) {\n let substring = item.textValue.slice(0, search.length);\n if (this.collator.compare(substring, search) === 0) {\n if (this.isRow(item) && this.focusMode === 'cell') {\n return getFirstItem(getChildNodes(item, this.collection))?.key ?? null;\n }\n\n return item.key;\n }\n }\n\n key = this.findNextKey(key, item => item.type === 'item');\n\n // Wrap around when reaching the end of the collection\n if (key == null && !hasWrapped) {\n key = this.getFirstKey();\n hasWrapped = true;\n }\n }\n\n return null;\n }\n}\n\n/* Backward compatibility for old Virtualizer Layout interface. */\ninterface DeprecatedLayout {\n getLayoutInfo(key: Key): DeprecatedLayoutInfo,\n getContentSize(): Size,\n virtualizer: DeprecatedVirtualizer\n}\n\ninterface DeprecatedLayoutInfo {\n rect: Rect\n}\n\ninterface DeprecatedVirtualizer {\n visibleRect: Rect\n}\n\nclass DeprecatedLayoutDelegate implements LayoutDelegate {\n layout: DeprecatedLayout;\n\n constructor(layout: DeprecatedLayout) {\n this.layout = layout;\n }\n\n getContentSize(): Size {\n return this.layout.getContentSize();\n }\n\n getItemRect(key: Key): Rect | null {\n return this.layout.getLayoutInfo(key)?.rect || null;\n }\n\n getVisibleRect(): Rect {\n return this.layout.virtualizer.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"GridKeyboardDelegate.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
|
|
|
29
29
|
protected isRow(node: Node<T>): boolean;
|
|
30
30
|
protected findPreviousKey(fromKey?: Key, pred?: (item: Node<T>) => boolean): Key | null;
|
|
31
31
|
protected findNextKey(fromKey?: Key, pred?: (item: Node<T>) => boolean): Key | null;
|
|
32
|
+
protected getKeyForItemInRowByIndex(key: Key, index?: number): Key | null;
|
|
32
33
|
getKeyBelow(fromKey: Key): Key | null;
|
|
33
34
|
getKeyAbove(fromKey: Key): Key | null;
|
|
34
35
|
getKeyRightOf(key: Key): Key | null;
|
|
@@ -78,6 +79,11 @@ export function useHighlightSelectionDescription(props: HighlightSelectionDescri
|
|
|
78
79
|
export interface GridProps extends DOMProps, AriaLabelingProps {
|
|
79
80
|
/** Whether the grid uses virtual scrolling. */
|
|
80
81
|
isVirtualized?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Whether typeahead navigation is disabled.
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
disallowTypeAhead?: boolean;
|
|
81
87
|
/**
|
|
82
88
|
* An optional keyboard delegate implementation for type to select,
|
|
83
89
|
* to override the default.
|
|
@@ -157,6 +163,8 @@ export interface GridCellProps {
|
|
|
157
163
|
focusMode?: 'child' | 'cell';
|
|
158
164
|
/** Whether selection should occur on press up instead of press down. */
|
|
159
165
|
shouldSelectOnPressUp?: boolean;
|
|
166
|
+
/** Indicates how many columns the data cell spans. */
|
|
167
|
+
colSpan?: number;
|
|
160
168
|
/**
|
|
161
169
|
* Handler that is called when a user performs an action on the cell.
|
|
162
170
|
* Please use onCellAction at the collection level instead.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAiBA,6CAA6C,CAAC;IAC5C,UAAU,EAAE,CAAC,CAAC;IACd,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,GAAG,CAAC,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAC;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC;IACzB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gDAAgD;IAChD,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;CAC3B;AAED,kCAAkC,CAAC,EAAE,CAAC,SAAS,eAAe,CAAC,CAAC,CAAE,YAAW,gBAAgB;IAC3F,UAAU,EAAE,CAAC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C,CAAC;IACxB,gEAAgE;IAChE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,6GAA6G;IAC7G,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;QAII;IACJ,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAED;IACE,uCAAuC;IACvC,aAAa,EAAE,aAAa,CAAC;IAC7B,wDAAwD;IACxD,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;;GAIG;AACH,4BAA4B,CAAC,EAAE,CAAC,SAAS,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,YAAY,CAwO/J;ACrRD;IACE,qCAAqC;IACrC,GAAG,EAAE,GAAG,CAAA;CACT;AAED;IACE,oDAAoD;IACpD,aAAa,EAAE,iBAAiB,CAAA;CACjC;AAGD;;;;GAIG;AACH,yCAAyC,CAAC,EAAE,CAAC,SAAS,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,8BAA8B,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,yBAAyB,CAsBjK","sources":["packages/@react-aria/grid/src/packages/@react-aria/grid/src/GridKeyboardDelegate.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/utils.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGridSelectionAnnouncement.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useHighlightSelectionDescription.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGrid.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGridRowGroup.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGridRow.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGridCell.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/useGridSelectionCheckbox.ts","packages/@react-aria/grid/src/packages/@react-aria/grid/src/index.ts","packages/@react-aria/grid/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {GridKeyboardDelegate} from './GridKeyboardDelegate';\nexport {useGrid} from './useGrid';\nexport {useGridRowGroup} from './useGridRowGroup';\nexport {useGridRow} from './useGridRow';\nexport {useGridCell} from './useGridCell';\nexport {useGridSelectionCheckbox} from './useGridSelectionCheckbox';\nexport {useHighlightSelectionDescription} from './useHighlightSelectionDescription';\nexport {useGridSelectionAnnouncement} from './useGridSelectionAnnouncement';\n\nexport type {GridProps, GridAria} from './useGrid';\nexport type {GridCellAria, GridCellProps} from './useGridCell';\nexport type {GridRowGroupAria} from './useGridRowGroup';\nexport type {GridRowProps, GridRowAria} from './useGridRow';\nexport type {GridKeyboardDelegateOptions} from './GridKeyboardDelegate';\nexport type {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria} from './useGridSelectionCheckbox';\nexport type {HighlightSelectionDescriptionProps} from './useHighlightSelectionDescription';\nexport type {GridSelectionAnnouncementProps} from './useGridSelectionAnnouncement';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/dist/useGrid.main.js
CHANGED
|
@@ -34,7 +34,7 @@ $parcel$export(module.exports, "useGrid", () => $11d770dfabe45077$export$f6b86a0
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref) {
|
|
37
|
-
let { isVirtualized: isVirtualized, keyboardDelegate: keyboardDelegate, focusMode: focusMode, scrollRef: scrollRef, getRowText: getRowText, onRowAction: onRowAction, onCellAction: onCellAction } = props;
|
|
37
|
+
let { isVirtualized: isVirtualized, disallowTypeAhead: disallowTypeAhead, keyboardDelegate: keyboardDelegate, focusMode: focusMode, scrollRef: scrollRef, getRowText: getRowText, onRowAction: onRowAction, onCellAction: onCellAction } = props;
|
|
38
38
|
let { selectionManager: manager } = state;
|
|
39
39
|
if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
40
40
|
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
@@ -68,7 +68,8 @@ function $11d770dfabe45077$export$f6b86a04e5d66d90(props, state, ref) {
|
|
|
68
68
|
selectionManager: manager,
|
|
69
69
|
keyboardDelegate: delegate,
|
|
70
70
|
isVirtualized: isVirtualized,
|
|
71
|
-
scrollRef: scrollRef
|
|
71
|
+
scrollRef: scrollRef,
|
|
72
|
+
disallowTypeAhead: disallowTypeAhead
|
|
72
73
|
});
|
|
73
74
|
let id = (0, $lBaOG$reactariautils.useId)(props.id);
|
|
74
75
|
(0, $8ee34951196858d0$exports.gridMap).set(state, {
|
package/dist/useGrid.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AA4DM,SAAS,0CAAW,KAAgB,EAAE,KAAsC,EAAE,GAAkC;IACrH,IAAI,iBACF,aAAa,qBACb,iBAAiB,oBACjB,gBAAgB,aAChB,SAAS,aACT,SAAS,cACT,UAAU,eACV,WAAW,gBACX,YAAY,EACb,GAAG;IACJ,IAAI,EAAC,kBAAkB,OAAO,EAAC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QAEA,gEAAgE;QAChE,IAAI,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GACpC;QAGF,QAAQ,UAAU,CAAC;IACrB,GAAG;QAAC;KAAQ;IAEZ,qFAAqF;IACrF,IAAI,sBAAsB,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;YACvC,QAAQ,gBAAgB,MAAM;qBAC9B;QACF,CAAA,GAAI;QAAC;QAAS,gBAAgB,MAAM;KAAC;IAErC,IAAI,mBAAmB,CAAA,GAAA,yCAAkB,EAAE,KAAK;QAC9C,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,YAA2B,CAAA,GAAA,gCAAS,EACtC,UACA;QACE,MAAM;YACN;QACA,wBAAwB,QAAQ,aAAa,KAAK,aAAa,SAAS;IAC1E,GACA,MAAM,4BAA4B,GAAG,sBAAsB,iBAE3D,AADA,mGAAmG;IAClG,MAAM,UAAU,CAAC,IAAI,KAAK,KAAK;QAAC,UAAU,mBAAmB,KAAK;IAAC,KAAM,WAC1E;IAGF,IAAI,eAAe;QACjB,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,IAAI;QAClD,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,WAAW;IAC3D;IAEA,CAAA,GAAA,sDAA2B,EAAE;oBAAC;IAAU,GAAG;IAC3C,OAAO;mBACL;IACF;AACF","sources":["packages/@react-aria/grid/src/useGrid.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 {AriaLabelingProps, DOMAttributes, DOMProps, Key, KeyboardDelegate, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {GridCollection} from '@react-types/grid';\nimport {GridKeyboardDelegate} from './GridKeyboardDelegate';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {useCallback, useMemo} from 'react';\nimport {useCollator, useLocale} from '@react-aria/i18n';\nimport {useGridSelectionAnnouncement} from './useGridSelectionAnnouncement';\nimport {useHasTabbableChild} from '@react-aria/focus';\nimport {useHighlightSelectionDescription} from './useHighlightSelectionDescription';\nimport {useSelectableCollection} from '@react-aria/selection';\n\nexport interface GridProps extends DOMProps, AriaLabelingProps {\n /** Whether the grid uses virtual scrolling. */\n isVirtualized?: boolean,\n /**\n * Whether typeahead navigation is disabled.\n * @default false\n */\n disallowTypeAhead?: boolean,\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * Whether initial grid focus should be placed on the grid row or grid cell.\n * @default 'row'\n */\n focusMode?: 'row' | 'cell',\n /**\n * A function that returns the text that should be announced by assistive technology when a row is added or removed from selection.\n * @default (key) => state.collection.getItem(key)?.textValue\n */\n getRowText?: (key: Key) => string,\n /**\n * The ref attached to the scrollable body. Used to provided automatic scrolling on item focus for non-virtualized grids.\n */\n scrollRef?: RefObject<HTMLElement | null>,\n /** Handler that is called when a user performs an action on the row. */\n onRowAction?: (key: Key) => void,\n /** Handler that is called when a user performs an action on the cell. */\n onCellAction?: (key: Key) => void\n}\n\nexport interface GridAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a grid component.\n * A grid displays data in one or more rows and columns and enables a user to navigate its contents via directional navigation keys.\n * @param props - Props for the grid.\n * @param state - State for the grid, as returned by `useGridState`.\n * @param ref - The ref attached to the grid element.\n */\nexport function useGrid<T>(props: GridProps, state: GridState<T, GridCollection<T>>, ref: RefObject<HTMLElement | null>): GridAria {\n let {\n isVirtualized,\n disallowTypeAhead,\n keyboardDelegate,\n focusMode,\n scrollRef,\n getRowText,\n onRowAction,\n onCellAction\n } = props;\n let {selectionManager: manager} = state;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let {direction} = useLocale();\n let disabledBehavior = state.selectionManager.disabledBehavior;\n let delegate = useMemo(() => keyboardDelegate || new GridKeyboardDelegate({\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n disabledBehavior,\n ref,\n direction,\n collator,\n focusMode\n }), [keyboardDelegate, state.collection, state.disabledKeys, disabledBehavior, ref, direction, collator, focusMode]);\n\n let {collectionProps} = useSelectableCollection({\n ref,\n selectionManager: manager,\n keyboardDelegate: delegate,\n isVirtualized,\n scrollRef,\n disallowTypeAhead\n });\n\n let id = useId(props.id);\n gridMap.set(state, {keyboardDelegate: delegate, actions: {onRowAction, onCellAction}});\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: manager,\n hasItemActions: !!(onRowAction || onCellAction)\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n let onFocus = useCallback((e) => {\n if (manager.isFocused) {\n // If a focus event bubbled through a portal, reset focus state.\n if (!e.currentTarget.contains(e.target)) {\n manager.setFocused(false);\n }\n\n return;\n }\n\n // Focus events can bubble through portals. Ignore these events.\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n manager.setFocused(true);\n }, [manager]);\n\n // Continue to track collection focused state even if keyboard navigation is disabled\n let navDisabledHandlers = useMemo(() => ({\n onBlur: collectionProps.onBlur,\n onFocus\n }), [onFocus, collectionProps.onBlur]);\n\n let hasTabbableChild = useHasTabbableChild(ref, {\n isDisabled: state.collection.size !== 0\n });\n\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable': manager.selectionMode === 'multiple' ? 'true' : undefined\n },\n state.isKeyboardNavigationDisabled ? navDisabledHandlers : collectionProps,\n // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.\n (state.collection.size === 0 && {tabIndex: hasTabbableChild ? -1 : 0}) || undefined,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = state.collection.columnCount;\n }\n\n useGridSelectionAnnouncement({getRowText}, state);\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useGrid.main.js.map"}
|
package/dist/useGrid.mjs
CHANGED
|
@@ -28,7 +28,7 @@ import {useSelectableCollection as $eV0xE$useSelectableCollection} from "@react-
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref) {
|
|
31
|
-
let { isVirtualized: isVirtualized, keyboardDelegate: keyboardDelegate, focusMode: focusMode, scrollRef: scrollRef, getRowText: getRowText, onRowAction: onRowAction, onCellAction: onCellAction } = props;
|
|
31
|
+
let { isVirtualized: isVirtualized, disallowTypeAhead: disallowTypeAhead, keyboardDelegate: keyboardDelegate, focusMode: focusMode, scrollRef: scrollRef, getRowText: getRowText, onRowAction: onRowAction, onCellAction: onCellAction } = props;
|
|
32
32
|
let { selectionManager: manager } = state;
|
|
33
33
|
if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
34
34
|
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
@@ -62,7 +62,8 @@ function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref) {
|
|
|
62
62
|
selectionManager: manager,
|
|
63
63
|
keyboardDelegate: delegate,
|
|
64
64
|
isVirtualized: isVirtualized,
|
|
65
|
-
scrollRef: scrollRef
|
|
65
|
+
scrollRef: scrollRef,
|
|
66
|
+
disallowTypeAhead: disallowTypeAhead
|
|
66
67
|
});
|
|
67
68
|
let id = (0, $eV0xE$useId)(props.id);
|
|
68
69
|
(0, $1af922eb41e03c8f$export$e6235c0d09b995d0).set(state, {
|
package/dist/useGrid.module.js
CHANGED
|
@@ -28,7 +28,7 @@ import {useSelectableCollection as $eV0xE$useSelectableCollection} from "@react-
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref) {
|
|
31
|
-
let { isVirtualized: isVirtualized, keyboardDelegate: keyboardDelegate, focusMode: focusMode, scrollRef: scrollRef, getRowText: getRowText, onRowAction: onRowAction, onCellAction: onCellAction } = props;
|
|
31
|
+
let { isVirtualized: isVirtualized, disallowTypeAhead: disallowTypeAhead, keyboardDelegate: keyboardDelegate, focusMode: focusMode, scrollRef: scrollRef, getRowText: getRowText, onRowAction: onRowAction, onCellAction: onCellAction } = props;
|
|
32
32
|
let { selectionManager: manager } = state;
|
|
33
33
|
if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
34
34
|
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
@@ -62,7 +62,8 @@ function $83c6e2eafa584c67$export$f6b86a04e5d66d90(props, state, ref) {
|
|
|
62
62
|
selectionManager: manager,
|
|
63
63
|
keyboardDelegate: delegate,
|
|
64
64
|
isVirtualized: isVirtualized,
|
|
65
|
-
scrollRef: scrollRef
|
|
65
|
+
scrollRef: scrollRef,
|
|
66
|
+
disallowTypeAhead: disallowTypeAhead
|
|
66
67
|
});
|
|
67
68
|
let id = (0, $eV0xE$useId)(props.id);
|
|
68
69
|
(0, $1af922eb41e03c8f$export$e6235c0d09b995d0).set(state, {
|