@react-aria/grid 3.9.2-nightly.4704 → 3.9.2-nightly.4709

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.
@@ -52,7 +52,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
52
52
  // If focus was on a cell, start searching from the parent row
53
53
  if (this.isCell(startItem)) key = startItem.parentKey;
54
54
  // Find the next item
55
- key = this.findNextKey(key);
55
+ key = this.findNextKey(key, (item)=>item.type === 'item');
56
56
  if (key != null) {
57
57
  // If focus was on a cell, focus the cell with the same index in the next row.
58
58
  if (this.isCell(startItem)) {
@@ -69,7 +69,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
69
69
  // If focus is on a cell, start searching from the parent row
70
70
  if (this.isCell(startItem)) key = startItem.parentKey;
71
71
  // Find the previous item
72
- key = this.findPreviousKey(key);
72
+ key = this.findPreviousKey(key, (item)=>item.type === 'item');
73
73
  if (key != null) {
74
74
  // If focus was on a cell, focus the cell with the same index in the previous row.
75
75
  if (this.isCell(startItem)) {
@@ -133,7 +133,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
133
133
  }
134
134
  }
135
135
  // Find the first row
136
- key = this.findNextKey();
136
+ key = this.findNextKey(null, (item)=>item.type === 'item');
137
137
  // If global flag is set (or if focus mode is cell), focus the first cell in the first row.
138
138
  if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') {
139
139
  let item = this.collection.getItem(key);
@@ -156,7 +156,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
156
156
  }
157
157
  }
158
158
  // Find the last row
159
- key = this.findPreviousKey();
159
+ key = this.findPreviousKey(null, (item)=>item.type === 'item');
160
160
  // If global flag is set (or if focus mode is cell), focus the last cell in the last row.
161
161
  if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') {
162
162
  let item = this.collection.getItem(key);
@@ -183,10 +183,10 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
183
183
  let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y + pageHeight);
184
184
  while(itemRect && itemRect.y + itemRect.height < pageY){
185
185
  let nextKey = this.getKeyBelow(key);
186
+ // If nextKey is undefined, we've reached the last row already
187
+ if (nextKey == null) break;
186
188
  itemRect = this.layoutDelegate.getItemRect(nextKey);
187
- // Guard against case where maxY of the last key is barely less than pageY due to rounding
188
- // and thus it attempts to set key to null
189
- if (nextKey != null) key = nextKey;
189
+ key = nextKey;
190
190
  }
191
191
  return key;
192
192
  }
@@ -208,7 +208,7 @@ class $3187c0e19200cb16$export$de9feff04fda126e {
208
208
  return item.key;
209
209
  }
210
210
  }
211
- key = this.findNextKey(key);
211
+ key = this.findNextKey(key, (item)=>item.type === 'item');
212
212
  // Wrap around when reaching the end of the collection
213
213
  if (key == null && !hasWrapped) {
214
214
  key = this.getFirstKey();
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAoBM,MAAM;IAmBD,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,IAAI,CAAC,UAAU,CAAC,SAAU,CAAA,CAAC,QAAQ,KAAK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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;\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 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 (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\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 (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n }\n\n getKeyBelow(key: Key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the next item\n key = this.findNextKey(key);\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 return getNthItem(getChildNodes(item, this.collection), startItem.index).key;\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n }\n\n getKeyAbove(key: Key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the previous item\n key = this.findPreviousKey(key);\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 return getNthItem(getChildNodes(item, this.collection), startItem.index).key;\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n }\n\n getKeyRightOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return;\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;\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)) {\n let parent = this.collection.getItem(item.parentKey);\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);\n\n if (next) {\n return next.key;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey;\n }\n\n return this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key);\n }\n }\n\n getKeyLeftOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return;\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;\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)) {\n let parent = this.collection.getItem(item.parentKey);\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);\n\n if (prev) {\n return prev.key;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey;\n }\n\n return this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key);\n }\n }\n\n getFirstKey(key?: Key, global?: boolean) {\n let item: Node<T>;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return;\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) {\n let parent = this.collection.getItem(item.parentKey);\n return getFirstItem(getChildNodes(parent, this.collection)).key;\n }\n }\n\n // Find the first row\n key = this.findNextKey();\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 key = getFirstItem(getChildNodes(item, this.collection)).key;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getLastKey(key?: Key, global?: boolean) {\n let item: Node<T>;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return;\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) {\n let parent = this.collection.getItem(item.parentKey);\n let children = getChildNodes(parent, this.collection);\n return getLastItem(children).key;\n }\n }\n\n // Find the last row\n key = this.findPreviousKey();\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 let children = getChildNodes(item, this.collection);\n key = getLastItem(children).key;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getKeyPageAbove(key: Key) {\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) {\n key = this.getKeyAbove(key);\n itemRect = this.layoutDelegate.getItemRect(key);\n }\n\n return key;\n }\n\n getKeyPageBelow(key: Key) {\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 itemRect = this.layoutDelegate.getItemRect(nextKey);\n\n // Guard against case where maxY of the last key is barely less than pageY due to rounding\n // and thus it attempts to set key to null\n if (nextKey != null) {\n key = nextKey;\n }\n }\n\n return key;\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey ?? this.getFirstKey();\n\n // If the starting key is a cell, search from its parent row.\n let startItem = collection.getItem(key);\n if (startItem.type === 'cell') {\n key = startItem.parentKey;\n }\n\n let hasWrapped = false;\n while (key != null) {\n let item = collection.getItem(key);\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;\n }\n\n return item.key;\n }\n }\n\n key = this.findNextKey(key);\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":[],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id/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;\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 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 (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\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 (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n }\n\n getKeyBelow(key: Key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\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 return getNthItem(getChildNodes(item, this.collection), startItem.index).key;\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n }\n\n getKeyAbove(key: Key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\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 return getNthItem(getChildNodes(item, this.collection), startItem.index).key;\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n }\n\n getKeyRightOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return;\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;\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)) {\n let parent = this.collection.getItem(item.parentKey);\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);\n\n if (next) {\n return next.key;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey;\n }\n\n return this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key);\n }\n }\n\n getKeyLeftOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return;\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;\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)) {\n let parent = this.collection.getItem(item.parentKey);\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);\n\n if (prev) {\n return prev.key;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey;\n }\n\n return this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key);\n }\n }\n\n getFirstKey(key?: Key, global?: boolean) {\n let item: Node<T>;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return;\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) {\n let parent = this.collection.getItem(item.parentKey);\n return getFirstItem(getChildNodes(parent, this.collection)).key;\n }\n }\n\n // Find the first row\n key = this.findNextKey(null, 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 key = getFirstItem(getChildNodes(item, this.collection)).key;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getLastKey(key?: Key, global?: boolean) {\n let item: Node<T>;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return;\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) {\n let parent = this.collection.getItem(item.parentKey);\n let children = getChildNodes(parent, this.collection);\n return getLastItem(children).key;\n }\n }\n\n // Find the last row\n key = this.findPreviousKey(null, 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 let children = getChildNodes(item, this.collection);\n key = getLastItem(children).key;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getKeyPageAbove(key: Key) {\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) {\n key = this.getKeyAbove(key);\n itemRect = this.layoutDelegate.getItemRect(key);\n }\n\n return key;\n }\n\n getKeyPageBelow(key: Key) {\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 if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey ?? this.getFirstKey();\n\n // If the starting key is a cell, search from its parent row.\n let startItem = collection.getItem(key);\n if (startItem.type === 'cell') {\n key = startItem.parentKey;\n }\n\n let hasWrapped = false;\n while (key != null) {\n let item = collection.getItem(key);\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;\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"}
@@ -46,7 +46,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
46
46
  // If focus was on a cell, start searching from the parent row
47
47
  if (this.isCell(startItem)) key = startItem.parentKey;
48
48
  // Find the next item
49
- key = this.findNextKey(key);
49
+ key = this.findNextKey(key, (item)=>item.type === 'item');
50
50
  if (key != null) {
51
51
  // If focus was on a cell, focus the cell with the same index in the next row.
52
52
  if (this.isCell(startItem)) {
@@ -63,7 +63,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
63
63
  // If focus is on a cell, start searching from the parent row
64
64
  if (this.isCell(startItem)) key = startItem.parentKey;
65
65
  // Find the previous item
66
- key = this.findPreviousKey(key);
66
+ key = this.findPreviousKey(key, (item)=>item.type === 'item');
67
67
  if (key != null) {
68
68
  // If focus was on a cell, focus the cell with the same index in the previous row.
69
69
  if (this.isCell(startItem)) {
@@ -127,7 +127,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
127
127
  }
128
128
  }
129
129
  // Find the first row
130
- key = this.findNextKey();
130
+ key = this.findNextKey(null, (item)=>item.type === 'item');
131
131
  // If global flag is set (or if focus mode is cell), focus the first cell in the first row.
132
132
  if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') {
133
133
  let item = this.collection.getItem(key);
@@ -150,7 +150,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
150
150
  }
151
151
  }
152
152
  // Find the last row
153
- key = this.findPreviousKey();
153
+ key = this.findPreviousKey(null, (item)=>item.type === 'item');
154
154
  // If global flag is set (or if focus mode is cell), focus the last cell in the last row.
155
155
  if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') {
156
156
  let item = this.collection.getItem(key);
@@ -177,10 +177,10 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
177
177
  let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y + pageHeight);
178
178
  while(itemRect && itemRect.y + itemRect.height < pageY){
179
179
  let nextKey = this.getKeyBelow(key);
180
+ // If nextKey is undefined, we've reached the last row already
181
+ if (nextKey == null) break;
180
182
  itemRect = this.layoutDelegate.getItemRect(nextKey);
181
- // Guard against case where maxY of the last key is barely less than pageY due to rounding
182
- // and thus it attempts to set key to null
183
- if (nextKey != null) key = nextKey;
183
+ key = nextKey;
184
184
  }
185
185
  return key;
186
186
  }
@@ -202,7 +202,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
202
202
  return item.key;
203
203
  }
204
204
  }
205
- key = this.findNextKey(key);
205
+ key = this.findNextKey(key, (item)=>item.type === 'item');
206
206
  // Wrap around when reaching the end of the collection
207
207
  if (key == null && !hasWrapped) {
208
208
  key = this.getFirstKey();
@@ -46,7 +46,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
46
46
  // If focus was on a cell, start searching from the parent row
47
47
  if (this.isCell(startItem)) key = startItem.parentKey;
48
48
  // Find the next item
49
- key = this.findNextKey(key);
49
+ key = this.findNextKey(key, (item)=>item.type === 'item');
50
50
  if (key != null) {
51
51
  // If focus was on a cell, focus the cell with the same index in the next row.
52
52
  if (this.isCell(startItem)) {
@@ -63,7 +63,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
63
63
  // If focus is on a cell, start searching from the parent row
64
64
  if (this.isCell(startItem)) key = startItem.parentKey;
65
65
  // Find the previous item
66
- key = this.findPreviousKey(key);
66
+ key = this.findPreviousKey(key, (item)=>item.type === 'item');
67
67
  if (key != null) {
68
68
  // If focus was on a cell, focus the cell with the same index in the previous row.
69
69
  if (this.isCell(startItem)) {
@@ -127,7 +127,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
127
127
  }
128
128
  }
129
129
  // Find the first row
130
- key = this.findNextKey();
130
+ key = this.findNextKey(null, (item)=>item.type === 'item');
131
131
  // If global flag is set (or if focus mode is cell), focus the first cell in the first row.
132
132
  if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') {
133
133
  let item = this.collection.getItem(key);
@@ -150,7 +150,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
150
150
  }
151
151
  }
152
152
  // Find the last row
153
- key = this.findPreviousKey();
153
+ key = this.findPreviousKey(null, (item)=>item.type === 'item');
154
154
  // If global flag is set (or if focus mode is cell), focus the last cell in the last row.
155
155
  if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') {
156
156
  let item = this.collection.getItem(key);
@@ -177,10 +177,10 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
177
177
  let pageY = Math.min(this.layoutDelegate.getContentSize().height, itemRect.y + pageHeight);
178
178
  while(itemRect && itemRect.y + itemRect.height < pageY){
179
179
  let nextKey = this.getKeyBelow(key);
180
+ // If nextKey is undefined, we've reached the last row already
181
+ if (nextKey == null) break;
180
182
  itemRect = this.layoutDelegate.getItemRect(nextKey);
181
- // Guard against case where maxY of the last key is barely less than pageY due to rounding
182
- // and thus it attempts to set key to null
183
- if (nextKey != null) key = nextKey;
183
+ key = nextKey;
184
184
  }
185
185
  return key;
186
186
  }
@@ -202,7 +202,7 @@ class $d1c300d9c497e402$export$de9feff04fda126e {
202
202
  return item.key;
203
203
  }
204
204
  }
205
- key = this.findNextKey(key);
205
+ key = this.findNextKey(key, (item)=>item.type === 'item');
206
206
  // Wrap around when reaching the end of the collection
207
207
  if (key == null && !hasWrapped) {
208
208
  key = this.getFirstKey();
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAoBM,MAAM;IAmBD,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,IAAI,CAAC,UAAU,CAAC,SAAU,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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;\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 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 (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\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 (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n }\n\n getKeyBelow(key: Key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the next item\n key = this.findNextKey(key);\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 return getNthItem(getChildNodes(item, this.collection), startItem.index).key;\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n }\n\n getKeyAbove(key: Key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\n }\n\n // Find the previous item\n key = this.findPreviousKey(key);\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 return getNthItem(getChildNodes(item, this.collection), startItem.index).key;\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n }\n\n getKeyRightOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return;\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;\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)) {\n let parent = this.collection.getItem(item.parentKey);\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);\n\n if (next) {\n return next.key;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey;\n }\n\n return this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key);\n }\n }\n\n getKeyLeftOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return;\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;\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)) {\n let parent = this.collection.getItem(item.parentKey);\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);\n\n if (prev) {\n return prev.key;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey;\n }\n\n return this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key);\n }\n }\n\n getFirstKey(key?: Key, global?: boolean) {\n let item: Node<T>;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return;\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) {\n let parent = this.collection.getItem(item.parentKey);\n return getFirstItem(getChildNodes(parent, this.collection)).key;\n }\n }\n\n // Find the first row\n key = this.findNextKey();\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 key = getFirstItem(getChildNodes(item, this.collection)).key;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getLastKey(key?: Key, global?: boolean) {\n let item: Node<T>;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return;\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) {\n let parent = this.collection.getItem(item.parentKey);\n let children = getChildNodes(parent, this.collection);\n return getLastItem(children).key;\n }\n }\n\n // Find the last row\n key = this.findPreviousKey();\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 let children = getChildNodes(item, this.collection);\n key = getLastItem(children).key;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getKeyPageAbove(key: Key) {\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) {\n key = this.getKeyAbove(key);\n itemRect = this.layoutDelegate.getItemRect(key);\n }\n\n return key;\n }\n\n getKeyPageBelow(key: Key) {\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 itemRect = this.layoutDelegate.getItemRect(nextKey);\n\n // Guard against case where maxY of the last key is barely less than pageY due to rounding\n // and thus it attempts to set key to null\n if (nextKey != null) {\n key = nextKey;\n }\n }\n\n return key;\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey ?? this.getFirstKey();\n\n // If the starting key is a cell, search from its parent row.\n let startItem = collection.getItem(key);\n if (startItem.type === 'cell') {\n key = startItem.parentKey;\n }\n\n let hasWrapped = false;\n while (key != null) {\n let item = collection.getItem(key);\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;\n }\n\n return item.key;\n }\n }\n\n key = this.findNextKey(key);\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.vis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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;\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 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 (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyBefore(key);\n }\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 (!this.isDisabled(item) && (!pred || pred(item))) {\n return key;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n }\n\n getKeyBelow(key: Key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus was on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\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 return getNthItem(getChildNodes(item, this.collection), startItem.index).key;\n }\n\n // Otherwise, focus the next row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n }\n\n getKeyAbove(key: Key) {\n let startItem = this.collection.getItem(key);\n if (!startItem) {\n return;\n }\n\n // If focus is on a cell, start searching from the parent row\n if (this.isCell(startItem)) {\n key = startItem.parentKey;\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 return getNthItem(getChildNodes(item, this.collection), startItem.index).key;\n }\n\n // Otherwise, focus the previous row\n if (this.focusMode === 'row') {\n return key;\n }\n }\n }\n\n getKeyRightOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return;\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;\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)) {\n let parent = this.collection.getItem(item.parentKey);\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);\n\n if (next) {\n return next.key;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey;\n }\n\n return this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key);\n }\n }\n\n getKeyLeftOf(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n return;\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;\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)) {\n let parent = this.collection.getItem(item.parentKey);\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);\n\n if (prev) {\n return prev.key;\n }\n\n // focus row only if focusMode is set to row\n if (this.focusMode === 'row') {\n return item.parentKey;\n }\n\n return this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key);\n }\n }\n\n getFirstKey(key?: Key, global?: boolean) {\n let item: Node<T>;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return;\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) {\n let parent = this.collection.getItem(item.parentKey);\n return getFirstItem(getChildNodes(parent, this.collection)).key;\n }\n }\n\n // Find the first row\n key = this.findNextKey(null, 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 key = getFirstItem(getChildNodes(item, this.collection)).key;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getLastKey(key?: Key, global?: boolean) {\n let item: Node<T>;\n if (key != null) {\n item = this.collection.getItem(key);\n if (!item) {\n return;\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) {\n let parent = this.collection.getItem(item.parentKey);\n let children = getChildNodes(parent, this.collection);\n return getLastItem(children).key;\n }\n }\n\n // Find the last row\n key = this.findPreviousKey(null, 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 let children = getChildNodes(item, this.collection);\n key = getLastItem(children).key;\n }\n\n // Otherwise, focus the row itself.\n return key;\n }\n\n getKeyPageAbove(key: Key) {\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) {\n key = this.getKeyAbove(key);\n itemRect = this.layoutDelegate.getItemRect(key);\n }\n\n return key;\n }\n\n getKeyPageBelow(key: Key) {\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 if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey ?? this.getFirstKey();\n\n // If the starting key is a cell, search from its parent row.\n let startItem = collection.getItem(key);\n if (startItem.type === 'cell') {\n key = startItem.parentKey;\n }\n\n let hasWrapped = false;\n while (key != null) {\n let item = collection.getItem(key);\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;\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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/grid",
3
- "version": "3.9.2-nightly.4704+546ffa41f",
3
+ "version": "3.9.2-nightly.4709+4fc70174a",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,18 +22,18 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/focus": "3.0.0-nightly.2992+546ffa41f",
26
- "@react-aria/i18n": "3.0.0-nightly.2992+546ffa41f",
27
- "@react-aria/interactions": "3.0.0-nightly.2992+546ffa41f",
28
- "@react-aria/live-announcer": "3.0.0-nightly.2992+546ffa41f",
29
- "@react-aria/selection": "3.0.0-nightly.2992+546ffa41f",
30
- "@react-aria/utils": "3.0.0-nightly.2992+546ffa41f",
31
- "@react-stately/collections": "3.0.0-nightly.2992+546ffa41f",
32
- "@react-stately/grid": "3.8.8-nightly.4704+546ffa41f",
33
- "@react-stately/selection": "3.0.0-nightly.2992+546ffa41f",
34
- "@react-types/checkbox": "3.0.0-nightly.2992+546ffa41f",
35
- "@react-types/grid": "3.2.7-nightly.4704+546ffa41f",
36
- "@react-types/shared": "3.0.0-nightly.2992+546ffa41f",
25
+ "@react-aria/focus": "3.0.0-nightly.2997+4fc70174a",
26
+ "@react-aria/i18n": "3.0.0-nightly.2997+4fc70174a",
27
+ "@react-aria/interactions": "3.0.0-nightly.2997+4fc70174a",
28
+ "@react-aria/live-announcer": "3.0.0-nightly.2997+4fc70174a",
29
+ "@react-aria/selection": "3.0.0-nightly.2997+4fc70174a",
30
+ "@react-aria/utils": "3.0.0-nightly.2997+4fc70174a",
31
+ "@react-stately/collections": "3.0.0-nightly.2997+4fc70174a",
32
+ "@react-stately/grid": "3.8.8-nightly.4709+4fc70174a",
33
+ "@react-stately/selection": "3.0.0-nightly.2997+4fc70174a",
34
+ "@react-types/checkbox": "3.0.0-nightly.2997+4fc70174a",
35
+ "@react-types/grid": "3.2.7-nightly.4709+4fc70174a",
36
+ "@react-types/shared": "3.0.0-nightly.2997+4fc70174a",
37
37
  "@swc/helpers": "^0.5.0"
38
38
  },
39
39
  "peerDependencies": {
@@ -43,5 +43,5 @@
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  },
46
- "gitHead": "546ffa41f7d1d3a566950a14d8f46cf726891220"
46
+ "gitHead": "4fc70174ac35a5ebf06379f5cafaf943519a1eac"
47
47
  }
@@ -101,7 +101,7 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
101
101
  }
102
102
 
103
103
  // Find the next item
104
- key = this.findNextKey(key);
104
+ key = this.findNextKey(key, (item => item.type === 'item'));
105
105
  if (key != null) {
106
106
  // If focus was on a cell, focus the cell with the same index in the next row.
107
107
  if (this.isCell(startItem)) {
@@ -128,7 +128,7 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
128
128
  }
129
129
 
130
130
  // Find the previous item
131
- key = this.findPreviousKey(key);
131
+ key = this.findPreviousKey(key, item => item.type === 'item');
132
132
  if (key != null) {
133
133
  // If focus was on a cell, focus the cell with the same index in the previous row.
134
134
  if (this.isCell(startItem)) {
@@ -232,7 +232,7 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
232
232
  }
233
233
 
234
234
  // Find the first row
235
- key = this.findNextKey();
235
+ key = this.findNextKey(null, item => item.type === 'item');
236
236
 
237
237
  // If global flag is set (or if focus mode is cell), focus the first cell in the first row.
238
238
  if ((key != null && item && this.isCell(item) && global) || this.focusMode === 'cell') {
@@ -262,7 +262,7 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
262
262
  }
263
263
 
264
264
  // Find the last row
265
- key = this.findPreviousKey();
265
+ key = this.findPreviousKey(null, item => item.type === 'item');
266
266
 
267
267
  // If global flag is set (or if focus mode is cell), focus the last cell in the last row.
268
268
  if ((key != null && item && this.isCell(item) && global) || this.focusMode === 'cell') {
@@ -303,13 +303,13 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
303
303
 
304
304
  while (itemRect && (itemRect.y + itemRect.height) < pageY) {
305
305
  let nextKey = this.getKeyBelow(key);
306
- itemRect = this.layoutDelegate.getItemRect(nextKey);
307
-
308
- // Guard against case where maxY of the last key is barely less than pageY due to rounding
309
- // and thus it attempts to set key to null
310
- if (nextKey != null) {
311
- key = nextKey;
306
+ // If nextKey is undefined, we've reached the last row already
307
+ if (nextKey == null) {
308
+ break;
312
309
  }
310
+
311
+ itemRect = this.layoutDelegate.getItemRect(nextKey);
312
+ key = nextKey;
313
313
  }
314
314
 
315
315
  return key;
@@ -345,7 +345,7 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
345
345
  }
346
346
  }
347
347
 
348
- key = this.findNextKey(key);
348
+ key = this.findNextKey(key, item => item.type === 'item');
349
349
 
350
350
  // Wrap around when reaching the end of the collection
351
351
  if (key == null && !hasWrapped) {