@react-aria/grid 3.9.2-nightly.4701 → 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;;AAqBM,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, 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';\nimport {RefObject} from 'react';\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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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.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;;AAqBM,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,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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, 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';\nimport {RefObject} from 'react';\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(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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, (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/dist/types.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, Size, Collection, AriaLabelingProps, DOMAttributes, DOMProps, FocusableElement } from "@react-types/shared";
1
+ import { Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, RefObject, Size, Collection, AriaLabelingProps, DOMAttributes, DOMProps, FocusableElement } from "@react-types/shared";
2
2
  import { GridCollection, GridNode } from "@react-types/grid";
3
- import { RefObject } from "react";
4
3
  import { SelectionManager, MultipleSelectionManager } from "@react-stately/selection";
5
4
  import { GridState } from "@react-stately/grid";
6
5
  import { SelectableItemStates } from "@react-aria/selection";
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AAkBA,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,CAAC;IACd,SAAS,CAAC,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC7C,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC;IAC/B,SAAS,CAAC,QAAQ,EAAE,KAAK,QAAQ,CAAC;IAClC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IACzC,SAAS,CAAC,SAAS,MAAC;gBAER,OAAO,EAAE,4BAA4B,CAAC,CAAC;IAUnD,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAI9B,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK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C;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"}
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,CAAC;IACd,SAAS,CAAC,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC7C,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC;IAC/B,SAAS,CAAC,QAAQ,EAAE,KAAK,QAAQ,CAAC;IAClC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IACzC,SAAS,CAAC,SAAS,MAAC;gBAER,OAAO,EAAE,4BAA4B,CAAC,CAA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J;AC5QD;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"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAuDM,SAAS,0CAAW,KAAgB,EAAE,KAAsC,EAAE,GAAkC;IACrH,IAAI,iBACF,aAAa,oBACb,gBAAgB,aAChB,SAAS,aACT,SAAS,cACT,UAAU,eACV,WAAW,gBACX,YAAY,EACb,GAAG;IACJ,IAAI,EAAC,kBAAkB,OAAO,EAAC,GAAG;IAElC,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,WAAW,CAAA,GAAA,gCAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAC1B,IAAI,mBAAmB,MAAM,gBAAgB,CAAC,gBAAgB;IAC9D,IAAI,WAAW,CAAA,GAAA,oBAAM,EAAE,IAAM,oBAAoB,IAAI,CAAA,GAAA,8CAAmB,EAAE;YACxE,YAAY,MAAM,UAAU;YAC5B,cAAc,MAAM,YAAY;8BAChC;iBACA;uBACA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,aAAa,KAAK,aAAa,SAAS;IAC1E,GACA,MAAM,4BAA4B,GAAG,sBAAsB,iBAC3D,mGAAmG;IACnG,MAAM,UAAU,CAAC,IAAI,KAAK,KAAK;QAAC,UAAU,mBAAmB,KAAK;IAAC,GACnE;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} 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 {RefObject, 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 * 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 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 });\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},\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"}
1
+ {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAuDM,SAAS,0CAAW,KAAgB,EAAE,KAAsC,EAAE,GAAkC;IACrH,IAAI,iBACF,aAAa,oBACb,gBAAgB,aAChB,SAAS,aACT,SAAS,cACT,UAAU,eACV,WAAW,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AAC,EAAE,MAAM,GACpC,QAAQ,UAAU,CAAC;YAGrB;QACF;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,iBAC3D,mGAAmG;IACnG,MAAM,UAAU,CAAC,IAAI,KAAK,KAAK;QAAC,UAAU,mBAAmB,KAAK;IAAC,GACnE;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 * 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 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 });\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},\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"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAuDM,SAAS,0CAAW,KAAgB,EAAE,KAAsC,EAAE,GAAkC;IACrH,IAAI,iBACF,aAAa,oBACb,gBAAgB,aAChB,SAAS,aACT,SAAS,cACT,UAAU,eACV,WAAW,gBACX,YAAY,EACb,GAAG;IACJ,IAAI,EAAC,kBAAkB,OAAO,EAAC,GAAG;IAElC,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,WAAW,CAAA,GAAA,kBAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,mBAAmB,MAAM,gBAAgB,CAAC,gBAAgB;IAC9D,IAAI,WAAW,CAAA,GAAA,cAAM,EAAE,IAAM,oBAAoB,IAAI,CAAA,GAAA,yCAAmB,EAAE;YACxE,YAAY,MAAM,UAAU;YAC5B,cAAc,MAAM,YAAY;8BAChC;iBACA;uBACA;sBACA;uBACA;QACF,IAAI;QAAC;QAAkB,MAAM,UAAU;QAAE,MAAM,YAAY;QAAE;QAAkB;QAAK;QAAW;QAAU;KAAU;IAEnH,IAAI,mBAAC,eAAe,EAAC,GAAG,CAAA,GAAA,8BAAsB,EA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F,IAAI,eAAe;QACjB,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,IAAI;QAClD,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,WAAW;IAC3D;IAEA,CAAA,GAAA,yCAA2B,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} 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 {RefObject, 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 * 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 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 });\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},\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.module.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAuDM,SAAS,0CAAW,KAAgB,EAAE,KAAsC,EAAE,GAAkC;IACrH,IAAI,iBACF,aAAa,oBACb,gBAAgB,aAChB,SAAS,aACT,SAAS,cACT,UAAU,eACV,WAAW,gBACX,YAAY,EACb,GAAG;IACJ,IAAI,EAAC,kBAAkB,OAAO,EAAC,GAAG;IAElC,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,0HAA0H;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;KAAQ;IAEZ,qFAAqF;IACrF,IAAI,sBAAsB,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;YACvC,QAAQ,gBAAgB,MAAM;qBAC9B;QACF,CAAA,GAAI;QAAC;QAAS,gBAAgB,MAAM;KAAC;IAErC,IAAI,mBAAmB,CAAA,GAAA,0BAAkB,EAAE,KAAK;QAC9C,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,YAA2B,CAAA,GAAA,iBAAS,EACtC,UACA;QACE,MAAM;YACN;QACA,wBAAwB,QAAQ,aAAa,KAAK,aAAa,SAAS;IAC1E,GACA,MAAM,4BAA4B,GAAG,sBAAsB,iBAC3D,mGAAmG;IACnG,MAAM,UAAU,CAAC,IAAI,KAAK,KAAK;QAAC,UAAU,mBAAmB,KAAK;IAAC,GACnE;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,yCAA2B,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 * 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 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 });\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},\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.module.js.map"}
@@ -88,7 +88,7 @@ function $cf2021be63b01ef4$export$c7e10bfc0c59f67c(props, state, ref) {
88
88
  let prev = keyboardDelegate.getKeyLeftOf(node.key);
89
89
  if (prev !== node.key) {
90
90
  // We prevent the capturing event from reaching children of the cell, e.g. pickers.
91
- // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
91
+ // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
92
92
  // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
93
93
  ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
94
94
  break;
@@ -126,7 +126,7 @@ function $cf2021be63b01ef4$export$c7e10bfc0c59f67c(props, state, ref) {
126
126
  let next = keyboardDelegate.getKeyRightOf(node.key);
127
127
  if (next !== node.key) {
128
128
  // We prevent the capturing event from reaching children of the cell, e.g. pickers.
129
- // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
129
+ // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
130
130
  // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
131
131
  ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
132
132
  break;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AA0CM,SAAS,0CAA4C,KAAoB,EAAE,KAAsB,EAAE,GAAuC;IAC/I,IAAI,QACF,IAAI,iBACJ,aAAa,aACb,YAAY,gCACZ,qBAAqB,YACrB,QAAQ,EACT,GAAG;IAEJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAC1B,IAAI,oBAAC,gBAAgB,EAAE,SAAS,gBAAC,YAAY,EAAC,EAAC,GAAG,CAAA,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esContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';\nimport {getScrollParent, mergeProps, scrollIntoViewport} from '@react-aria/utils';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {isFocusVisible} from '@react-aria/interactions';\nimport {KeyboardEvent as ReactKeyboardEvent, RefObject, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSelectableItem} from '@react-aria/selection';\n\nexport interface GridCellProps {\n /** An object representing the grid cell. Contains all the relevant information that makes up the grid cell. */\n node: GridNode<unknown>,\n /** Whether the grid cell is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether the cell or its first focusable child element should be focused when the grid cell is focused. */\n focusMode?: 'child' | 'cell',\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the cell.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface GridCellAria {\n /** Props for the grid cell element. */\n gridCellProps: DOMAttributes,\n /** Whether the cell is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a cell in a grid.\n * @param props - Props for the cell.\n * @param state - State of the parent grid, as returned by `useGridState`.\n */\nexport function useGridCell<T, C extends GridCollection<T>>(props: GridCellProps, state: GridState<T, C>, ref: RefObject<FocusableElement | null>): GridCellAria {\n let {\n node,\n isVirtualized,\n focusMode = 'child',\n shouldSelectOnPressUp,\n onAction\n } = props;\n\n let {direction} = useLocale();\n let {keyboardDelegate, actions: {onCellAction}} = gridMap.get(state);\n\n // We need to track the key of the item at the time it was last focused so that we force\n // focus to go to the item when the DOM node is reused for a different item in a virtualizer.\n let keyWhenFocused = useRef(null);\n\n // Handles focusing the cell. If there is a focusable child,\n // it is focused, otherwise the cell itself is focused.\n let focus = () => {\n let treeWalker = getFocusableTreeWalker(ref.current);\n if (focusMode === 'child') {\n // If focus is already on a focusable child within the cell, early return so we don't shift focus\n if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) {\n return;\n }\n\n let focusable = state.selectionManager.childFocusStrategy === 'last'\n ? last(treeWalker)\n : treeWalker.firstChild() as FocusableElement;\n if (focusable) {\n focusSafely(focusable);\n return;\n }\n }\n\n if (\n (keyWhenFocused.current != null && node.key !== keyWhenFocused.current) ||\n !ref.current.contains(document.activeElement)\n ) {\n focusSafely(ref.current);\n }\n };\n\n let {itemProps, isPressed} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n focus,\n shouldSelectOnPressUp,\n onAction: onCellAction ? () => onCellAction(node.key) : onAction,\n isDisabled: state.collection.size === 0\n });\n\n let onKeyDownCapture = (e: ReactKeyboardEvent) => {\n if (!e.currentTarget.contains(e.target as Element) || state.isKeyboardNavigationDisabled) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = document.activeElement;\n\n switch (e.key) {\n case 'ArrowLeft': {\n // Find the next focusable element within the cell.\n let focusable = direction === 'rtl'\n ? walker.nextNode() as FocusableElement\n : walker.previousNode() as FocusableElement;\n\n // Don't focus the cell itself if focusMode is \"child\"\n if (focusMode === 'child' && focusable === ref.current) {\n focusable = null;\n }\n\n e.preventDefault();\n e.stopPropagation();\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n // If there is no next focusable child, then move to the next cell to the left of this one.\n // This will be handled by useSelectableCollection. However, if there is no cell to the left\n // of this one, only one column, and the grid doesn't focus rows, then the next key will be the\n // same as this one. In that case we need to handle focusing either the cell or the first/last\n // child, depending on the focus mode.\n let prev = keyboardDelegate.getKeyLeftOf(node.key);\n if (prev !== node.key) {\n // We prevent the capturing event from reaching children of the cell, e.g. pickers.\n // We want arrow keys to navigate to the next cell instead. We need to re-dispatch \n // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n break;\n }\n\n if (focusMode === 'cell' && direction === 'rtl') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n focusable = direction === 'rtl'\n ? walker.firstChild() as FocusableElement\n : last(walker);\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n let focusable = direction === 'rtl'\n ? walker.previousNode() as FocusableElement\n : walker.nextNode() as FocusableElement;\n\n if (focusMode === 'child' && focusable === ref.current) {\n focusable = null;\n }\n\n e.preventDefault();\n e.stopPropagation();\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n let next = keyboardDelegate.getKeyRightOf(node.key);\n if (next !== node.key) {\n // We prevent the capturing event from reaching children of the cell, e.g. pickers.\n // We want arrow keys to navigate to the next cell instead. We need to re-dispatch \n // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n break;\n }\n\n if (focusMode === 'cell' && direction === 'ltr') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n focusable = direction === 'rtl'\n ? last(walker)\n : walker.firstChild() as FocusableElement;\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching cell children, e.g. menu buttons. We want arrow keys to navigate\n // to the cell above/below instead. We need to re-dispatch the event from a higher parent so it still\n // bubbles and gets handled by useSelectableCollection.\n if (!e.altKey && ref.current.contains(e.target as Element)) {\n e.stopPropagation();\n e.preventDefault();\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n }\n break;\n }\n };\n\n // Grid cells can have focusable elements inside them. In this case, focus should\n // be marshalled to that element rather than focusing the cell itself.\n let onFocus = (e) => {\n keyWhenFocused.current = node.key;\n if (e.target !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the gridcell itself. We also want to\n // set the focused key when a child element receives focus.\n // If focus is currently visible (e.g. the user is navigating with the keyboard),\n // then skip this. We want to restore focus to the previously focused row/cell\n // in that case since the table should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n\n // If the cell itself is focused, wait a frame so that focus finishes propagatating\n // up to the tree, and move focus to a focusable child if possible.\n requestAnimationFrame(() => {\n if (focusMode === 'child' && document.activeElement === ref.current) {\n focus();\n }\n });\n };\n\n let gridCellProps: DOMAttributes = mergeProps(itemProps, {\n role: 'gridcell',\n onKeyDownCapture,\n onFocus\n });\n\n if (isVirtualized) {\n gridCellProps['aria-colindex'] = (node.colIndex ?? node.index) + 1; // aria-colindex is 1-based\n }\n\n // When pressing with a pointer and cell selection is not enabled, usePress will be applied to the\n // row rather than the cell. However, when the row is draggable, usePress cannot preventDefault\n // on pointer down, so the browser will try to focus the cell which has a tabIndex applied.\n // To avoid this, remove the tabIndex from the cell briefly on pointer down.\n if (shouldSelectOnPressUp && gridCellProps.tabIndex != null && gridCellProps.onPointerDown == null) {\n gridCellProps.onPointerDown = (e) => {\n let el = e.currentTarget;\n let tabindex = el.getAttribute('tabindex');\n el.removeAttribute('tabindex');\n requestAnimationFrame(() => {\n el.setAttribute('tabindex', tabindex);\n });\n };\n }\n\n return {\n gridCellProps,\n isPressed\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n"],"names":[],"version":3,"file":"useGridCell.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AA0CM,SAAS,0CAA4C,KAAoB,EAAE,KAAsB,EAAE,GAAuC;IAC/I,IAAI,QACF,IAAI,iBACJ,aAAa,aACb,YAAY,gCACZ,qBAAqB,YACrB,QAAQ,EACT,GAAG;IAEJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAC1B,IAAI,oBAAC,gBAAgB,EAAE,SAAS,gBAAC,YAAY,EAAC,EAAC,GAAG,CAAA,GAAA,iCAAM,EAAE,GAAG,CAAC;IAE9D,wFAAwF;IACxF,6FAA6F;IAC7F,IAAI,iBAAiB,CAAA,GAAA,mBAAK,EAAE;IAE5B,4DAA4D;IAC5D,uDAAuD;IACvD,IAAI,QAAQ;QACV,IAAI,aAAa,CAAA,GAAA,4CAAqB,EAAE,IAAI,OAAO;QACnD,IAAI,cAAc,SAAS;YACzB,iGAAiG;YACjG,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,KAAK,IAAI,OAAO,KAAK,SAAS,aAAa,EACxF;YAGF,IAAI,YAAY,MAAM,gBAAgB,CAAC,kBAAkB,KAAK,SAC1D,2BAAK,cACL,WAAW,UAAU;YACzB,IAAI,WAAW;gBACb,CAAA,GAAA,iCAAU,EAAE;gBACZ;YACF;QACF;QAEA,IACE,AAAC,eAAe,OAAO,IAAI,QAAQ,KAAK,GAAG,KAAK,eAAe,OAAO,IACtE,CAAC,I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Aa,CAAC,gBAAgB,GAAG,AAAC,CAAA,CAAA,iBAAA,KAAK,QAAQ,cAAb,4BAAA,iBAAiB,KAAK,KAAK,AAAD,IAAK,GAAG,2BAA2B;IAGjG,kGAAkG;IAClG,+FAA+F;IAC/F,2FAA2F;IAC3F,4EAA4E;IAC5E,IAAI,yBAAyB,cAAc,QAAQ,IAAI,QAAQ,cAAc,aAAa,IAAI,MAC5F,cAAc,aAAa,GAAG,CAAC;QAC7B,IAAI,KAAK,EAAE,aAAa;QACxB,IAAI,WAAW,GAAG,YAAY,CAAC;QAC/B,GAAG,eAAe,CAAC;QACnB,sBAAsB;YACpB,GAAG,YAAY,CAAC,YAAY;QAC9B;IACF;IAGF,OAAO;uBACL;mBACA;IACF;AACF;AAEA,SAAS,2BAAK,MAAkB;IAC9B,IAAI;IACJ,IAAI;IACJ,GAAG;QACD,OAAO,OAAO,SAAS;QACvB,IAAI,MACF,OAAO;IAEX,QAAS,MAAM;IACf,OAAO;AACT","sources":["packages/@react-aria/grid/src/useGridCell.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';\nimport {getScrollParent, mergeProps, scrollIntoViewport} from '@react-aria/utils';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {isFocusVisible} from '@react-aria/interactions';\nimport {KeyboardEvent as ReactKeyboardEvent, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSelectableItem} from '@react-aria/selection';\n\nexport interface GridCellProps {\n /** An object representing the grid cell. Contains all the relevant information that makes up the grid cell. */\n node: GridNode<unknown>,\n /** Whether the grid cell is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether the cell or its first focusable child element should be focused when the grid cell is focused. */\n focusMode?: 'child' | 'cell',\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the cell.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface GridCellAria {\n /** Props for the grid cell element. */\n gridCellProps: DOMAttributes,\n /** Whether the cell is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a cell in a grid.\n * @param props - Props for the cell.\n * @param state - State of the parent grid, as returned by `useGridState`.\n */\nexport function useGridCell<T, C extends GridCollection<T>>(props: GridCellProps, state: GridState<T, C>, ref: RefObject<FocusableElement | null>): GridCellAria {\n let {\n node,\n isVirtualized,\n focusMode = 'child',\n shouldSelectOnPressUp,\n onAction\n } = props;\n\n let {direction} = useLocale();\n let {keyboardDelegate, actions: {onCellAction}} = gridMap.get(state);\n\n // We need to track the key of the item at the time it was last focused so that we force\n // focus to go to the item when the DOM node is reused for a different item in a virtualizer.\n let keyWhenFocused = useRef(null);\n\n // Handles focusing the cell. If there is a focusable child,\n // it is focused, otherwise the cell itself is focused.\n let focus = () => {\n let treeWalker = getFocusableTreeWalker(ref.current);\n if (focusMode === 'child') {\n // If focus is already on a focusable child within the cell, early return so we don't shift focus\n if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) {\n return;\n }\n\n let focusable = state.selectionManager.childFocusStrategy === 'last'\n ? last(treeWalker)\n : treeWalker.firstChild() as FocusableElement;\n if (focusable) {\n focusSafely(focusable);\n return;\n }\n }\n\n if (\n (keyWhenFocused.current != null && node.key !== keyWhenFocused.current) ||\n !ref.current.contains(document.activeElement)\n ) {\n focusSafely(ref.current);\n }\n };\n\n let {itemProps, isPressed} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n focus,\n shouldSelectOnPressUp,\n onAction: onCellAction ? () => onCellAction(node.key) : onAction,\n isDisabled: state.collection.size === 0\n });\n\n let onKeyDownCapture = (e: ReactKeyboardEvent) => {\n if (!e.currentTarget.contains(e.target as Element) || state.isKeyboardNavigationDisabled) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = document.activeElement;\n\n switch (e.key) {\n case 'ArrowLeft': {\n // Find the next focusable element within the cell.\n let focusable = direction === 'rtl'\n ? walker.nextNode() as FocusableElement\n : walker.previousNode() as FocusableElement;\n\n // Don't focus the cell itself if focusMode is \"child\"\n if (focusMode === 'child' && focusable === ref.current) {\n focusable = null;\n }\n\n e.preventDefault();\n e.stopPropagation();\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n // If there is no next focusable child, then move to the next cell to the left of this one.\n // This will be handled by useSelectableCollection. However, if there is no cell to the left\n // of this one, only one column, and the grid doesn't focus rows, then the next key will be the\n // same as this one. In that case we need to handle focusing either the cell or the first/last\n // child, depending on the focus mode.\n let prev = keyboardDelegate.getKeyLeftOf(node.key);\n if (prev !== node.key) {\n // We prevent the capturing event from reaching children of the cell, e.g. pickers.\n // We want arrow keys to navigate to the next cell instead. We need to re-dispatch\n // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n break;\n }\n\n if (focusMode === 'cell' && direction === 'rtl') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n focusable = direction === 'rtl'\n ? walker.firstChild() as FocusableElement\n : last(walker);\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n let focusable = direction === 'rtl'\n ? walker.previousNode() as FocusableElement\n : walker.nextNode() as FocusableElement;\n\n if (focusMode === 'child' && focusable === ref.current) {\n focusable = null;\n }\n\n e.preventDefault();\n e.stopPropagation();\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n let next = keyboardDelegate.getKeyRightOf(node.key);\n if (next !== node.key) {\n // We prevent the capturing event from reaching children of the cell, e.g. pickers.\n // We want arrow keys to navigate to the next cell instead. We need to re-dispatch\n // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n break;\n }\n\n if (focusMode === 'cell' && direction === 'ltr') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n focusable = direction === 'rtl'\n ? last(walker)\n : walker.firstChild() as FocusableElement;\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching cell children, e.g. menu buttons. We want arrow keys to navigate\n // to the cell above/below instead. We need to re-dispatch the event from a higher parent so it still\n // bubbles and gets handled by useSelectableCollection.\n if (!e.altKey && ref.current.contains(e.target as Element)) {\n e.stopPropagation();\n e.preventDefault();\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n }\n break;\n }\n };\n\n // Grid cells can have focusable elements inside them. In this case, focus should\n // be marshalled to that element rather than focusing the cell itself.\n let onFocus = (e) => {\n keyWhenFocused.current = node.key;\n if (e.target !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the gridcell itself. We also want to\n // set the focused key when a child element receives focus.\n // If focus is currently visible (e.g. the user is navigating with the keyboard),\n // then skip this. We want to restore focus to the previously focused row/cell\n // in that case since the table should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n\n // If the cell itself is focused, wait a frame so that focus finishes propagatating\n // up to the tree, and move focus to a focusable child if possible.\n requestAnimationFrame(() => {\n if (focusMode === 'child' && document.activeElement === ref.current) {\n focus();\n }\n });\n };\n\n let gridCellProps: DOMAttributes = mergeProps(itemProps, {\n role: 'gridcell',\n onKeyDownCapture,\n onFocus\n });\n\n if (isVirtualized) {\n gridCellProps['aria-colindex'] = (node.colIndex ?? node.index) + 1; // aria-colindex is 1-based\n }\n\n // When pressing with a pointer and cell selection is not enabled, usePress will be applied to the\n // row rather than the cell. However, when the row is draggable, usePress cannot preventDefault\n // on pointer down, so the browser will try to focus the cell which has a tabIndex applied.\n // To avoid this, remove the tabIndex from the cell briefly on pointer down.\n if (shouldSelectOnPressUp && gridCellProps.tabIndex != null && gridCellProps.onPointerDown == null) {\n gridCellProps.onPointerDown = (e) => {\n let el = e.currentTarget;\n let tabindex = el.getAttribute('tabindex');\n el.removeAttribute('tabindex');\n requestAnimationFrame(() => {\n el.setAttribute('tabindex', tabindex);\n });\n };\n }\n\n return {\n gridCellProps,\n isPressed\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n"],"names":[],"version":3,"file":"useGridCell.main.js.map"}
@@ -82,7 +82,7 @@ function $ab90dcbc1b5466d0$export$c7e10bfc0c59f67c(props, state, ref) {
82
82
  let prev = keyboardDelegate.getKeyLeftOf(node.key);
83
83
  if (prev !== node.key) {
84
84
  // We prevent the capturing event from reaching children of the cell, e.g. pickers.
85
- // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
85
+ // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
86
86
  // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
87
87
  ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
88
88
  break;
@@ -120,7 +120,7 @@ function $ab90dcbc1b5466d0$export$c7e10bfc0c59f67c(props, state, ref) {
120
120
  let next = keyboardDelegate.getKeyRightOf(node.key);
121
121
  if (next !== node.key) {
122
122
  // We prevent the capturing event from reaching children of the cell, e.g. pickers.
123
- // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
123
+ // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
124
124
  // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
125
125
  ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
126
126
  break;
@@ -82,7 +82,7 @@ function $ab90dcbc1b5466d0$export$c7e10bfc0c59f67c(props, state, ref) {
82
82
  let prev = keyboardDelegate.getKeyLeftOf(node.key);
83
83
  if (prev !== node.key) {
84
84
  // We prevent the capturing event from reaching children of the cell, e.g. pickers.
85
- // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
85
+ // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
86
86
  // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
87
87
  ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
88
88
  break;
@@ -120,7 +120,7 @@ function $ab90dcbc1b5466d0$export$c7e10bfc0c59f67c(props, state, ref) {
120
120
  let next = keyboardDelegate.getKeyRightOf(node.key);
121
121
  if (next !== node.key) {
122
122
  // We prevent the capturing event from reaching children of the cell, e.g. pickers.
123
- // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
123
+ // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
124
124
  // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
125
125
  ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
126
126
  break;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA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CAAC;QAC/B,GAAG,eAAe,CAAC;QACnB,sBAAsB;YACpB,GAAG,YAAY,CAAC,YAAY;QAC9B;IACF;IAGF,OAAO;uBACL;mBACA;IACF;AACF;AAEA,SAAS,2BAAK,MAAkB;IAC9B,IAAI;IACJ,IAAI;IACJ,GAAG;QACD,OAAO,OAAO,SAAS;QACvB,IAAI,MACF,OAAO;IAEX,QAAS,MAAM;IACf,OAAO;AACT","sources":["packages/@react-aria/grid/src/useGridCell.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';\nimport {getScrollParent, mergeProps, scrollIntoViewport} from '@react-aria/utils';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {isFocusVisible} from '@react-aria/interactions';\nimport {KeyboardEvent as ReactKeyboardEvent, RefObject, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSelectableItem} from '@react-aria/selection';\n\nexport interface GridCellProps {\n /** An object representing the grid cell. Contains all the relevant information that makes up the grid cell. */\n node: GridNode<unknown>,\n /** Whether the grid cell is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether the cell or its first focusable child element should be focused when the grid cell is focused. */\n focusMode?: 'child' | 'cell',\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the cell.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface GridCellAria {\n /** Props for the grid cell element. */\n gridCellProps: DOMAttributes,\n /** Whether the cell is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a cell in a grid.\n * @param props - Props for the cell.\n * @param state - State of the parent grid, as returned by `useGridState`.\n */\nexport function useGridCell<T, C extends GridCollection<T>>(props: GridCellProps, state: GridState<T, C>, ref: RefObject<FocusableElement | null>): GridCellAria {\n let {\n node,\n isVirtualized,\n focusMode = 'child',\n shouldSelectOnPressUp,\n onAction\n } = props;\n\n let {direction} = useLocale();\n let {keyboardDelegate, actions: {onCellAction}} = gridMap.get(state);\n\n // We need to track the key of the item at the time it was last focused so that we force\n // focus to go to the item when the DOM node is reused for a different item in a virtualizer.\n let keyWhenFocused = useRef(null);\n\n // Handles focusing the cell. If there is a focusable child,\n // it is focused, otherwise the cell itself is focused.\n let focus = () => {\n let treeWalker = getFocusableTreeWalker(ref.current);\n if (focusMode === 'child') {\n // If focus is already on a focusable child within the cell, early return so we don't shift focus\n if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) {\n return;\n }\n\n let focusable = state.selectionManager.childFocusStrategy === 'last'\n ? last(treeWalker)\n : treeWalker.firstChild() as FocusableElement;\n if (focusable) {\n focusSafely(focusable);\n return;\n }\n }\n\n if (\n (keyWhenFocused.current != null && node.key !== keyWhenFocused.current) ||\n !ref.current.contains(document.activeElement)\n ) {\n focusSafely(ref.current);\n }\n };\n\n let {itemProps, isPressed} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n focus,\n shouldSelectOnPressUp,\n onAction: onCellAction ? () => onCellAction(node.key) : onAction,\n isDisabled: state.collection.size === 0\n });\n\n let onKeyDownCapture = (e: ReactKeyboardEvent) => {\n if (!e.currentTarget.contains(e.target as Element) || state.isKeyboardNavigationDisabled) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = document.activeElement;\n\n switch (e.key) {\n case 'ArrowLeft': {\n // Find the next focusable element within the cell.\n let focusable = direction === 'rtl'\n ? walker.nextNode() as FocusableElement\n : walker.previousNode() as FocusableElement;\n\n // Don't focus the cell itself if focusMode is \"child\"\n if (focusMode === 'child' && focusable === ref.current) {\n focusable = null;\n }\n\n e.preventDefault();\n e.stopPropagation();\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n // If there is no next focusable child, then move to the next cell to the left of this one.\n // This will be handled by useSelectableCollection. However, if there is no cell to the left\n // of this one, only one column, and the grid doesn't focus rows, then the next key will be the\n // same as this one. In that case we need to handle focusing either the cell or the first/last\n // child, depending on the focus mode.\n let prev = keyboardDelegate.getKeyLeftOf(node.key);\n if (prev !== node.key) {\n // We prevent the capturing event from reaching children of the cell, e.g. pickers.\n // We want arrow keys to navigate to the next cell instead. We need to re-dispatch \n // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n break;\n }\n\n if (focusMode === 'cell' && direction === 'rtl') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n focusable = direction === 'rtl'\n ? walker.firstChild() as FocusableElement\n : last(walker);\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n let focusable = direction === 'rtl'\n ? walker.previousNode() as FocusableElement\n : walker.nextNode() as FocusableElement;\n\n if (focusMode === 'child' && focusable === ref.current) {\n focusable = null;\n }\n\n e.preventDefault();\n e.stopPropagation();\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n let next = keyboardDelegate.getKeyRightOf(node.key);\n if (next !== node.key) {\n // We prevent the capturing event from reaching children of the cell, e.g. pickers.\n // We want arrow keys to navigate to the next cell instead. We need to re-dispatch \n // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n break;\n }\n\n if (focusMode === 'cell' && direction === 'ltr') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n focusable = direction === 'rtl'\n ? last(walker)\n : walker.firstChild() as FocusableElement;\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching cell children, e.g. menu buttons. We want arrow keys to navigate\n // to the cell above/below instead. We need to re-dispatch the event from a higher parent so it still\n // bubbles and gets handled by useSelectableCollection.\n if (!e.altKey && ref.current.contains(e.target as Element)) {\n e.stopPropagation();\n e.preventDefault();\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n }\n break;\n }\n };\n\n // Grid cells can have focusable elements inside them. In this case, focus should\n // be marshalled to that element rather than focusing the cell itself.\n let onFocus = (e) => {\n keyWhenFocused.current = node.key;\n if (e.target !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the gridcell itself. We also want to\n // set the focused key when a child element receives focus.\n // If focus is currently visible (e.g. the user is navigating with the keyboard),\n // then skip this. We want to restore focus to the previously focused row/cell\n // in that case since the table should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n\n // If the cell itself is focused, wait a frame so that focus finishes propagatating\n // up to the tree, and move focus to a focusable child if possible.\n requestAnimationFrame(() => {\n if (focusMode === 'child' && document.activeElement === ref.current) {\n focus();\n }\n });\n };\n\n let gridCellProps: DOMAttributes = mergeProps(itemProps, {\n role: 'gridcell',\n onKeyDownCapture,\n onFocus\n });\n\n if (isVirtualized) {\n gridCellProps['aria-colindex'] = (node.colIndex ?? node.index) + 1; // aria-colindex is 1-based\n }\n\n // When pressing with a pointer and cell selection is not enabled, usePress will be applied to the\n // row rather than the cell. However, when the row is draggable, usePress cannot preventDefault\n // on pointer down, so the browser will try to focus the cell which has a tabIndex applied.\n // To avoid this, remove the tabIndex from the cell briefly on pointer down.\n if (shouldSelectOnPressUp && gridCellProps.tabIndex != null && gridCellProps.onPointerDown == null) {\n gridCellProps.onPointerDown = (e) => {\n let el = e.currentTarget;\n let tabindex = el.getAttribute('tabindex');\n el.removeAttribute('tabindex');\n requestAnimationFrame(() => {\n el.setAttribute('tabindex', tabindex);\n });\n };\n }\n\n return {\n gridCellProps,\n isPressed\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n"],"names":[],"version":3,"file":"useGridCell.module.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AA0CM,SAAS,0CAA4C,KAAoB,EAAE,KAAsB,EAAE,GAAuC;IAC/I,IAAI,QACF,IAAI,iBACJ,aAAa,aACb,YAAY,gCACZ,qBAAqB,YACrB,QAAQ,EACT,GAAG;IAEJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,oBAAC,gBAAgB,EAAE,SAAS,gBAAC,YAAY,EAAC,EAAC,GAAG,CAAA,GAAA,yCAAM,EAAE,GAAG,CAAC;IAE9D,wFAAwF;IACxF,6FAA6F;IAC7F,IAAI,iBAAiB,CAAA,GAAA,aAAK,EAAE;IAE5B,4DAA4D;IAC5D,uDAAuD;IACvD,IAAI,QAAQ;QACV,IAAI,aAAa,CAAA,GAAA,6BAAqB,EAAE,IAAI,OAAO;QACnD,IAAI,cAAc,SAAS;YACzB,iGAAiG;YACjG,IAAI,IAAI,OAAO,CAAC,QAAQ,C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A,qBAAa,KAChB,MAAM,gBAAgB,CAAC,aAAa,CAAC,KAAK,GAAG;YAE/C;QACF;QAEA,mFAAmF;QACnF,mEAAmE;QACnE,sBAAsB;YACpB,IAAI,cAAc,WAAW,SAAS,aAAa,KAAK,IAAI,OAAO,EACjE;QAEJ;IACF;IAEA,IAAI,gBAA+B,CAAA,GAAA,iBAAS,EAAE,WAAW;QACvD,MAAM;0BACN;iBACA;IACF;QAGoC;IADpC,IAAI,eACF,aAAa,CAAC,gBAAgB,GAAG,AAAC,CAAA,CAAA,iBAAA,KAAK,QAAQ,cAAb,4BAAA,iBAAiB,KAAK,KAAK,AAAD,IAAK,GAAG,2BAA2B;IAGjG,kGAAkG;IAClG,+FAA+F;IAC/F,2FAA2F;IAC3F,4EAA4E;IAC5E,IAAI,yBAAyB,cAAc,QAAQ,IAAI,QAAQ,cAAc,aAAa,IAAI,MAC5F,cAAc,aAAa,GAAG,CAAC;QAC7B,IAAI,KAAK,EAAE,aAAa;QACxB,IAAI,WAAW,GAAG,YAAY,CAAC;QAC/B,GAAG,eAAe,CAAC;QACnB,sBAAsB;YACpB,GAAG,YAAY,CAAC,YAAY;QAC9B;IACF;IAGF,OAAO;uBACL;mBACA;IACF;AACF;AAEA,SAAS,2BAAK,MAAkB;IAC9B,IAAI;IACJ,IAAI;IACJ,GAAG;QACD,OAAO,OAAO,SAAS;QACvB,IAAI,MACF,OAAO;IAEX,QAAS,MAAM;IACf,OAAO;AACT","sources":["packages/@react-aria/grid/src/useGridCell.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';\nimport {getScrollParent, mergeProps, scrollIntoViewport} from '@react-aria/utils';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {isFocusVisible} from '@react-aria/interactions';\nimport {KeyboardEvent as ReactKeyboardEvent, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSelectableItem} from '@react-aria/selection';\n\nexport interface GridCellProps {\n /** An object representing the grid cell. Contains all the relevant information that makes up the grid cell. */\n node: GridNode<unknown>,\n /** Whether the grid cell is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether the cell or its first focusable child element should be focused when the grid cell is focused. */\n focusMode?: 'child' | 'cell',\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the cell.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface GridCellAria {\n /** Props for the grid cell element. */\n gridCellProps: DOMAttributes,\n /** Whether the cell is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a cell in a grid.\n * @param props - Props for the cell.\n * @param state - State of the parent grid, as returned by `useGridState`.\n */\nexport function useGridCell<T, C extends GridCollection<T>>(props: GridCellProps, state: GridState<T, C>, ref: RefObject<FocusableElement | null>): GridCellAria {\n let {\n node,\n isVirtualized,\n focusMode = 'child',\n shouldSelectOnPressUp,\n onAction\n } = props;\n\n let {direction} = useLocale();\n let {keyboardDelegate, actions: {onCellAction}} = gridMap.get(state);\n\n // We need to track the key of the item at the time it was last focused so that we force\n // focus to go to the item when the DOM node is reused for a different item in a virtualizer.\n let keyWhenFocused = useRef(null);\n\n // Handles focusing the cell. If there is a focusable child,\n // it is focused, otherwise the cell itself is focused.\n let focus = () => {\n let treeWalker = getFocusableTreeWalker(ref.current);\n if (focusMode === 'child') {\n // If focus is already on a focusable child within the cell, early return so we don't shift focus\n if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) {\n return;\n }\n\n let focusable = state.selectionManager.childFocusStrategy === 'last'\n ? last(treeWalker)\n : treeWalker.firstChild() as FocusableElement;\n if (focusable) {\n focusSafely(focusable);\n return;\n }\n }\n\n if (\n (keyWhenFocused.current != null && node.key !== keyWhenFocused.current) ||\n !ref.current.contains(document.activeElement)\n ) {\n focusSafely(ref.current);\n }\n };\n\n let {itemProps, isPressed} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n focus,\n shouldSelectOnPressUp,\n onAction: onCellAction ? () => onCellAction(node.key) : onAction,\n isDisabled: state.collection.size === 0\n });\n\n let onKeyDownCapture = (e: ReactKeyboardEvent) => {\n if (!e.currentTarget.contains(e.target as Element) || state.isKeyboardNavigationDisabled) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = document.activeElement;\n\n switch (e.key) {\n case 'ArrowLeft': {\n // Find the next focusable element within the cell.\n let focusable = direction === 'rtl'\n ? walker.nextNode() as FocusableElement\n : walker.previousNode() as FocusableElement;\n\n // Don't focus the cell itself if focusMode is \"child\"\n if (focusMode === 'child' && focusable === ref.current) {\n focusable = null;\n }\n\n e.preventDefault();\n e.stopPropagation();\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n // If there is no next focusable child, then move to the next cell to the left of this one.\n // This will be handled by useSelectableCollection. However, if there is no cell to the left\n // of this one, only one column, and the grid doesn't focus rows, then the next key will be the\n // same as this one. In that case we need to handle focusing either the cell or the first/last\n // child, depending on the focus mode.\n let prev = keyboardDelegate.getKeyLeftOf(node.key);\n if (prev !== node.key) {\n // We prevent the capturing event from reaching children of the cell, e.g. pickers.\n // We want arrow keys to navigate to the next cell instead. We need to re-dispatch\n // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n break;\n }\n\n if (focusMode === 'cell' && direction === 'rtl') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n focusable = direction === 'rtl'\n ? walker.firstChild() as FocusableElement\n : last(walker);\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n let focusable = direction === 'rtl'\n ? walker.previousNode() as FocusableElement\n : walker.nextNode() as FocusableElement;\n\n if (focusMode === 'child' && focusable === ref.current) {\n focusable = null;\n }\n\n e.preventDefault();\n e.stopPropagation();\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n let next = keyboardDelegate.getKeyRightOf(node.key);\n if (next !== node.key) {\n // We prevent the capturing event from reaching children of the cell, e.g. pickers.\n // We want arrow keys to navigate to the next cell instead. We need to re-dispatch\n // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n break;\n }\n\n if (focusMode === 'cell' && direction === 'ltr') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n focusable = direction === 'rtl'\n ? last(walker)\n : walker.firstChild() as FocusableElement;\n if (focusable) {\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching cell children, e.g. menu buttons. We want arrow keys to navigate\n // to the cell above/below instead. We need to re-dispatch the event from a higher parent so it still\n // bubbles and gets handled by useSelectableCollection.\n if (!e.altKey && ref.current.contains(e.target as Element)) {\n e.stopPropagation();\n e.preventDefault();\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n }\n break;\n }\n };\n\n // Grid cells can have focusable elements inside them. In this case, focus should\n // be marshalled to that element rather than focusing the cell itself.\n let onFocus = (e) => {\n keyWhenFocused.current = node.key;\n if (e.target !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the gridcell itself. We also want to\n // set the focused key when a child element receives focus.\n // If focus is currently visible (e.g. the user is navigating with the keyboard),\n // then skip this. We want to restore focus to the previously focused row/cell\n // in that case since the table should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n\n // If the cell itself is focused, wait a frame so that focus finishes propagatating\n // up to the tree, and move focus to a focusable child if possible.\n requestAnimationFrame(() => {\n if (focusMode === 'child' && document.activeElement === ref.current) {\n focus();\n }\n });\n };\n\n let gridCellProps: DOMAttributes = mergeProps(itemProps, {\n role: 'gridcell',\n onKeyDownCapture,\n onFocus\n });\n\n if (isVirtualized) {\n gridCellProps['aria-colindex'] = (node.colIndex ?? node.index) + 1; // aria-colindex is 1-based\n }\n\n // When pressing with a pointer and cell selection is not enabled, usePress will be applied to the\n // row rather than the cell. However, when the row is draggable, usePress cannot preventDefault\n // on pointer down, so the browser will try to focus the cell which has a tabIndex applied.\n // To avoid this, remove the tabIndex from the cell briefly on pointer down.\n if (shouldSelectOnPressUp && gridCellProps.tabIndex != null && gridCellProps.onPointerDown == null) {\n gridCellProps.onPointerDown = (e) => {\n let el = e.currentTarget;\n let tabindex = el.getAttribute('tabindex');\n el.removeAttribute('tabindex');\n requestAnimationFrame(() => {\n el.setAttribute('tabindex', tabindex);\n });\n };\n }\n\n return {\n gridCellProps,\n isPressed\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n"],"names":[],"version":3,"file":"useGridCell.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAqCM,SAAS,0CAAsE,KAAsB,EAAE,KAAQ,EAAE,GAAuC;QAgBlI,aAA8B;IAfzD,IAAI,QACF,IAAI,iBACJ,aAAa,yBACb,qBAAqB,YACrB,QAAQ,EACT,GAAG;IAEJ,IAAI,WAAC,OAAO,EAAC,GAAG,CAAA,GAAA,iCAAM,EAAE,GAAG,CAAC;IAC5B,IAAI,cAAc,QAAQ,WAAW,GAAG,IAAM,QAAQ,WAAW,CAAC,KAAK,GAAG,IAAI;IAC9E,IAAI,aAAC,SAAS,EAAE,GAAG,QAAO,GAAG,CAAA,GAAA,2CAAgB,EAAE;QAC7C,kBAAkB,MAAM,gBAAgB;QACxC,KAAK,KAAK,GAAG;aACb;uBACA;+BACA;QACA,UAAU,gBAAe,iBAAA,4BAAA,cAAA,KAAM,KAAK,cAAX,kCAAA,YAAa,QAAQ,IAAG,CAAA,GAAA,2BAAI,EAAE,iBAAA,4BAAA,eAAA,KAAM,KAAK,cAAX,mCAAA,aAAa,QAAQ,EAAE,eAAe;QAC7F,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC,KAAK,GAAG;IAE3D,IAAI,WAA0B;QAC5B,MAAM;QACN,iBAAiB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAAS,aAAa;QAChF,iBAAiB,OAAO,UAAU,IAAI;QACtC,GAAG,SAAS;IACd;IAEA,IAAI,eACF,QAAQ,CAAC,gBAAgB,GAAG,KAAK,KAAK,GAAG,GAAG,2BAA2B;IAGzE,OAAO;kBACL;QACA,GAAG,MAAM;IACX;AACF","sources":["packages/@react-aria/grid/src/useGridRow.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 {chain} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {RefObject} from 'react';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface GridRowProps<T> {\n /** An object representing the grid row. Contains all the relevant information that makes up the grid row. */\n node: GridNode<T>,\n /** Whether the grid row is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the row.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface GridRowAria extends SelectableItemStates {\n /** Props for the grid row element. */\n rowProps: DOMAttributes,\n /** Whether the row is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid.\n * @param props - Props for the row.\n * @param state - State of the parent grid, as returned by `useGridState`.\n */\nexport function useGridRow<T, C extends GridCollection<T>, S extends GridState<T, C>>(props: GridRowProps<T>, state: S, ref: RefObject<FocusableElement | null>): GridRowAria {\n let {\n node,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction\n } = props;\n\n let {actions} = gridMap.get(state);\n let onRowAction = actions.onRowAction ? () => actions.onRowAction(node.key) : onAction;\n let {itemProps, ...states} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction: onRowAction || node?.props?.onAction ? chain(node?.props?.onAction, onRowAction) : undefined,\n isDisabled: state.collection.size === 0\n });\n\n let isSelected = state.selectionManager.isSelected(node.key);\n\n let rowProps: DOMAttributes = {\n role: 'row',\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined,\n 'aria-disabled': states.isDisabled || undefined,\n ...itemProps\n };\n\n if (isVirtualized) {\n rowProps['aria-rowindex'] = node.index + 1; // aria-rowindex is 1 based\n }\n\n return {\n rowProps,\n ...states\n };\n}\n"],"names":[],"version":3,"file":"useGridRow.main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAoCM,SAAS,0CAAsE,KAAsB,EAAE,KAAQ,EAAE,GAAuC;QAgBlI,aAA8B;IAfzD,IAAI,QACF,IAAI,iBACJ,aAAa,yBACb,qBAAqB,YACrB,QAAQ,EACT,GAAG;IAEJ,IAAI,WAAC,OAAO,EAAC,GAAG,CAAA,GAAA,iCAAM,EAAE,GAAG,CAAC;IAC5B,IAAI,cAAc,QAAQ,WAAW,GAAG,IAAM,QAAQ,WAAW,CAAC,KAAK,GAAG,IAAI;IAC9E,IAAI,aAAC,SAAS,EAAE,GAAG,QAAO,GAAG,CAAA,GAAA,2CAAgB,EAAE;QAC7C,kBAAkB,MAAM,gBAAgB;QACxC,KAAK,KAAK,GAAG;aACb;uBACA;+BACA;QACA,UAAU,gBAAe,iBAAA,4BAAA,cAAA,KAAM,KAAK,cAAX,kCAAA,YAAa,QAAQ,IAAG,CAAA,GAAA,2BAAI,EAAE,iBAAA,4BAAA,eAAA,KAAM,KAAK,cAAX,mCAAA,aAAa,QAAQ,EAAE,eAAe;QAC7F,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC,KAAK,GAAG;IAE3D,IAAI,WAA0B;QAC5B,MAAM;QACN,iBAAiB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAAS,aAAa;QAChF,iBAAiB,OAAO,UAAU,IAAI;QACtC,GAAG,SAAS;IACd;IAEA,IAAI,eACF,QAAQ,CAAC,gBAAgB,GAAG,KAAK,KAAK,GAAG,GAAG,2BAA2B;IAGzE,OAAO;kBACL;QACA,GAAG,MAAM;IACX;AACF","sources":["packages/@react-aria/grid/src/useGridRow.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 {chain} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface GridRowProps<T> {\n /** An object representing the grid row. Contains all the relevant information that makes up the grid row. */\n node: GridNode<T>,\n /** Whether the grid row is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the row.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface GridRowAria extends SelectableItemStates {\n /** Props for the grid row element. */\n rowProps: DOMAttributes,\n /** Whether the row is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid.\n * @param props - Props for the row.\n * @param state - State of the parent grid, as returned by `useGridState`.\n */\nexport function useGridRow<T, C extends GridCollection<T>, S extends GridState<T, C>>(props: GridRowProps<T>, state: S, ref: RefObject<FocusableElement | null>): GridRowAria {\n let {\n node,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction\n } = props;\n\n let {actions} = gridMap.get(state);\n let onRowAction = actions.onRowAction ? () => actions.onRowAction(node.key) : onAction;\n let {itemProps, ...states} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction: onRowAction || node?.props?.onAction ? chain(node?.props?.onAction, onRowAction) : undefined,\n isDisabled: state.collection.size === 0\n });\n\n let isSelected = state.selectionManager.isSelected(node.key);\n\n let rowProps: DOMAttributes = {\n role: 'row',\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined,\n 'aria-disabled': states.isDisabled || undefined,\n ...itemProps\n };\n\n if (isVirtualized) {\n rowProps['aria-rowindex'] = node.index + 1; // aria-rowindex is 1 based\n }\n\n return {\n rowProps,\n ...states\n };\n}\n"],"names":[],"version":3,"file":"useGridRow.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAqCM,SAAS,0CAAsE,KAAsB,EAAE,KAAQ,EAAE,GAAuC;QAgBlI,aAA8B;IAfzD,IAAI,QACF,IAAI,iBACJ,aAAa,yBACb,qBAAqB,YACrB,QAAQ,EACT,GAAG;IAEJ,IAAI,WAAC,OAAO,EAAC,GAAG,CAAA,GAAA,yCAAM,EAAE,GAAG,CAAC;IAC5B,IAAI,cAAc,QAAQ,WAAW,GAAG,IAAM,QAAQ,WAAW,CAAC,KAAK,GAAG,IAAI;IAC9E,IAAI,aAAC,SAAS,EAAE,GAAG,QAAO,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAC7C,kBAAkB,MAAM,gBAAgB;QACxC,KAAK,KAAK,GAAG;aACb;uBACA;+BACA;QACA,UAAU,gBAAe,iBAAA,4BAAA,cAAA,KAAM,KAAK,cAAX,kCAAA,YAAa,QAAQ,IAAG,CAAA,GAAA,YAAI,EAAE,iBAAA,4BAAA,eAAA,KAAM,KAAK,cAAX,mCAAA,aAAa,QAAQ,EAAE,eAAe;QAC7F,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC,KAAK,GAAG;IAE3D,IAAI,WAA0B;QAC5B,MAAM;QACN,iBAAiB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAAS,aAAa;QAChF,iBAAiB,OAAO,UAAU,IAAI;QACtC,GAAG,SAAS;IACd;IAEA,IAAI,eACF,QAAQ,CAAC,gBAAgB,GAAG,KAAK,KAAK,GAAG,GAAG,2BAA2B;IAGzE,OAAO;kBACL;QACA,GAAG,MAAM;IACX;AACF","sources":["packages/@react-aria/grid/src/useGridRow.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 {chain} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {RefObject} from 'react';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface GridRowProps<T> {\n /** An object representing the grid row. Contains all the relevant information that makes up the grid row. */\n node: GridNode<T>,\n /** Whether the grid row is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the row.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface GridRowAria extends SelectableItemStates {\n /** Props for the grid row element. */\n rowProps: DOMAttributes,\n /** Whether the row is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid.\n * @param props - Props for the row.\n * @param state - State of the parent grid, as returned by `useGridState`.\n */\nexport function useGridRow<T, C extends GridCollection<T>, S extends GridState<T, C>>(props: GridRowProps<T>, state: S, ref: RefObject<FocusableElement | null>): GridRowAria {\n let {\n node,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction\n } = props;\n\n let {actions} = gridMap.get(state);\n let onRowAction = actions.onRowAction ? () => actions.onRowAction(node.key) : onAction;\n let {itemProps, ...states} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction: onRowAction || node?.props?.onAction ? chain(node?.props?.onAction, onRowAction) : undefined,\n isDisabled: state.collection.size === 0\n });\n\n let isSelected = state.selectionManager.isSelected(node.key);\n\n let rowProps: DOMAttributes = {\n role: 'row',\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined,\n 'aria-disabled': states.isDisabled || undefined,\n ...itemProps\n };\n\n if (isVirtualized) {\n rowProps['aria-rowindex'] = node.index + 1; // aria-rowindex is 1 based\n }\n\n return {\n rowProps,\n ...states\n };\n}\n"],"names":[],"version":3,"file":"useGridRow.module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAoCM,SAAS,0CAAsE,KAAsB,EAAE,KAAQ,EAAE,GAAuC;QAgBlI,aAA8B;IAfzD,IAAI,QACF,IAAI,iBACJ,aAAa,yBACb,qBAAqB,YACrB,QAAQ,EACT,GAAG;IAEJ,IAAI,WAAC,OAAO,EAAC,GAAG,CAAA,GAAA,yCAAM,EAAE,GAAG,CAAC;IAC5B,IAAI,cAAc,QAAQ,WAAW,GAAG,IAAM,QAAQ,WAAW,CAAC,KAAK,GAAG,IAAI;IAC9E,IAAI,aAAC,SAAS,EAAE,GAAG,QAAO,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAC7C,kBAAkB,MAAM,gBAAgB;QACxC,KAAK,KAAK,GAAG;aACb;uBACA;+BACA;QACA,UAAU,gBAAe,iBAAA,4BAAA,cAAA,KAAM,KAAK,cAAX,kCAAA,YAAa,QAAQ,IAAG,CAAA,GAAA,YAAI,EAAE,iBAAA,4BAAA,eAAA,KAAM,KAAK,cAAX,mCAAA,aAAa,QAAQ,EAAE,eAAe;QAC7F,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC,KAAK,GAAG;IAE3D,IAAI,WAA0B;QAC5B,MAAM;QACN,iBAAiB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAAS,aAAa;QAChF,iBAAiB,OAAO,UAAU,IAAI;QACtC,GAAG,SAAS;IACd;IAEA,IAAI,eACF,QAAQ,CAAC,gBAAgB,GAAG,KAAK,KAAK,GAAG,GAAG,2BAA2B;IAGzE,OAAO;kBACL;QACA,GAAG,MAAM;IACX;AACF","sources":["packages/@react-aria/grid/src/useGridRow.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 {chain} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {GridCollection, GridNode} from '@react-types/grid';\nimport {gridMap} from './utils';\nimport {GridState} from '@react-stately/grid';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface GridRowProps<T> {\n /** An object representing the grid row. Contains all the relevant information that makes up the grid row. */\n node: GridNode<T>,\n /** Whether the grid row is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n /**\n * Handler that is called when a user performs an action on the row.\n * Please use onCellAction at the collection level instead.\n * @deprecated\n **/\n onAction?: () => void\n}\n\nexport interface GridRowAria extends SelectableItemStates {\n /** Props for the grid row element. */\n rowProps: DOMAttributes,\n /** Whether the row is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid.\n * @param props - Props for the row.\n * @param state - State of the parent grid, as returned by `useGridState`.\n */\nexport function useGridRow<T, C extends GridCollection<T>, S extends GridState<T, C>>(props: GridRowProps<T>, state: S, ref: RefObject<FocusableElement | null>): GridRowAria {\n let {\n node,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction\n } = props;\n\n let {actions} = gridMap.get(state);\n let onRowAction = actions.onRowAction ? () => actions.onRowAction(node.key) : onAction;\n let {itemProps, ...states} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction: onRowAction || node?.props?.onAction ? chain(node?.props?.onAction, onRowAction) : undefined,\n isDisabled: state.collection.size === 0\n });\n\n let isSelected = state.selectionManager.isSelected(node.key);\n\n let rowProps: DOMAttributes = {\n role: 'row',\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined,\n 'aria-disabled': states.isDisabled || undefined,\n ...itemProps\n };\n\n if (isVirtualized) {\n rowProps['aria-rowindex'] = node.index + 1; // aria-rowindex is 1 based\n }\n\n return {\n rowProps,\n ...states\n };\n}\n"],"names":[],"version":3,"file":"useGridRow.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.4701+76365df43",
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.2989+76365df43",
26
- "@react-aria/i18n": "3.0.0-nightly.2989+76365df43",
27
- "@react-aria/interactions": "3.0.0-nightly.2989+76365df43",
28
- "@react-aria/live-announcer": "3.0.0-nightly.2989+76365df43",
29
- "@react-aria/selection": "3.0.0-nightly.2989+76365df43",
30
- "@react-aria/utils": "3.0.0-nightly.2989+76365df43",
31
- "@react-stately/collections": "3.0.0-nightly.2989+76365df43",
32
- "@react-stately/grid": "3.8.8-nightly.4701+76365df43",
33
- "@react-stately/selection": "3.0.0-nightly.2989+76365df43",
34
- "@react-types/checkbox": "3.0.0-nightly.2989+76365df43",
35
- "@react-types/grid": "3.2.7-nightly.4701+76365df43",
36
- "@react-types/shared": "3.0.0-nightly.2989+76365df43",
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": "76365df434b6f65b137113557ba14a32ea466c8f"
46
+ "gitHead": "4fc70174ac35a5ebf06379f5cafaf943519a1eac"
47
47
  }
@@ -10,11 +10,10 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, Size} from '@react-types/shared';
13
+ import {Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, RefObject, Size} from '@react-types/shared';
14
14
  import {DOMLayoutDelegate} from '@react-aria/selection';
15
15
  import {getChildNodes, getFirstItem, getLastItem, getNthItem} from '@react-stately/collections';
16
16
  import {GridCollection} from '@react-types/grid';
17
- import {RefObject} from 'react';
18
17
 
19
18
  export interface GridKeyboardDelegateOptions<C> {
20
19
  collection: C,
@@ -102,7 +101,7 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
102
101
  }
103
102
 
104
103
  // Find the next item
105
- key = this.findNextKey(key);
104
+ key = this.findNextKey(key, (item => item.type === 'item'));
106
105
  if (key != null) {
107
106
  // If focus was on a cell, focus the cell with the same index in the next row.
108
107
  if (this.isCell(startItem)) {
@@ -129,7 +128,7 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
129
128
  }
130
129
 
131
130
  // Find the previous item
132
- key = this.findPreviousKey(key);
131
+ key = this.findPreviousKey(key, item => item.type === 'item');
133
132
  if (key != null) {
134
133
  // If focus was on a cell, focus the cell with the same index in the previous row.
135
134
  if (this.isCell(startItem)) {
@@ -233,7 +232,7 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
233
232
  }
234
233
 
235
234
  // Find the first row
236
- key = this.findNextKey();
235
+ key = this.findNextKey(null, item => item.type === 'item');
237
236
 
238
237
  // If global flag is set (or if focus mode is cell), focus the first cell in the first row.
239
238
  if ((key != null && item && this.isCell(item) && global) || this.focusMode === 'cell') {
@@ -263,7 +262,7 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
263
262
  }
264
263
 
265
264
  // Find the last row
266
- key = this.findPreviousKey();
265
+ key = this.findPreviousKey(null, item => item.type === 'item');
267
266
 
268
267
  // If global flag is set (or if focus mode is cell), focus the last cell in the last row.
269
268
  if ((key != null && item && this.isCell(item) && global) || this.focusMode === 'cell') {
@@ -304,13 +303,13 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
304
303
 
305
304
  while (itemRect && (itemRect.y + itemRect.height) < pageY) {
306
305
  let nextKey = this.getKeyBelow(key);
307
- itemRect = this.layoutDelegate.getItemRect(nextKey);
308
-
309
- // Guard against case where maxY of the last key is barely less than pageY due to rounding
310
- // and thus it attempts to set key to null
311
- if (nextKey != null) {
312
- key = nextKey;
306
+ // If nextKey is undefined, we've reached the last row already
307
+ if (nextKey == null) {
308
+ break;
313
309
  }
310
+
311
+ itemRect = this.layoutDelegate.getItemRect(nextKey);
312
+ key = nextKey;
314
313
  }
315
314
 
316
315
  return key;
@@ -346,7 +345,7 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
346
345
  }
347
346
  }
348
347
 
349
- key = this.findNextKey(key);
348
+ key = this.findNextKey(key, item => item.type === 'item');
350
349
 
351
350
  // Wrap around when reaching the end of the collection
352
351
  if (key == null && !hasWrapped) {
package/src/useGrid.ts CHANGED
@@ -10,13 +10,13 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {AriaLabelingProps, DOMAttributes, DOMProps, Key, KeyboardDelegate} from '@react-types/shared';
13
+ import {AriaLabelingProps, DOMAttributes, DOMProps, Key, KeyboardDelegate, RefObject} from '@react-types/shared';
14
14
  import {filterDOMProps, mergeProps, useId} from '@react-aria/utils';
15
15
  import {GridCollection} from '@react-types/grid';
16
16
  import {GridKeyboardDelegate} from './GridKeyboardDelegate';
17
17
  import {gridMap} from './utils';
18
18
  import {GridState} from '@react-stately/grid';
19
- import {RefObject, useCallback, useMemo} from 'react';
19
+ import {useCallback, useMemo} from 'react';
20
20
  import {useCollator, useLocale} from '@react-aria/i18n';
21
21
  import {useGridSelectionAnnouncement} from './useGridSelectionAnnouncement';
22
22
  import {useHasTabbableChild} from '@react-aria/focus';
@@ -10,14 +10,14 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {DOMAttributes, FocusableElement} from '@react-types/shared';
13
+ import {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';
14
14
  import {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';
15
15
  import {getScrollParent, mergeProps, scrollIntoViewport} from '@react-aria/utils';
16
16
  import {GridCollection, GridNode} from '@react-types/grid';
17
17
  import {gridMap} from './utils';
18
18
  import {GridState} from '@react-stately/grid';
19
19
  import {isFocusVisible} from '@react-aria/interactions';
20
- import {KeyboardEvent as ReactKeyboardEvent, RefObject, useRef} from 'react';
20
+ import {KeyboardEvent as ReactKeyboardEvent, useRef} from 'react';
21
21
  import {useLocale} from '@react-aria/i18n';
22
22
  import {useSelectableItem} from '@react-aria/selection';
23
23
 
@@ -138,7 +138,7 @@ export function useGridCell<T, C extends GridCollection<T>>(props: GridCellProps
138
138
  let prev = keyboardDelegate.getKeyLeftOf(node.key);
139
139
  if (prev !== node.key) {
140
140
  // We prevent the capturing event from reaching children of the cell, e.g. pickers.
141
- // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
141
+ // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
142
142
  // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
143
143
  ref.current.parentElement.dispatchEvent(
144
144
  new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)
@@ -180,7 +180,7 @@ export function useGridCell<T, C extends GridCollection<T>>(props: GridCellProps
180
180
  let next = keyboardDelegate.getKeyRightOf(node.key);
181
181
  if (next !== node.key) {
182
182
  // We prevent the capturing event from reaching children of the cell, e.g. pickers.
183
- // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
183
+ // We want arrow keys to navigate to the next cell instead. We need to re-dispatch
184
184
  // the event from a higher parent so it still bubbles and gets handled by useSelectableCollection.
185
185
  ref.current.parentElement.dispatchEvent(
186
186
  new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)
package/src/useGridRow.ts CHANGED
@@ -11,11 +11,10 @@
11
11
  */
12
12
 
13
13
  import {chain} from '@react-aria/utils';
14
- import {DOMAttributes, FocusableElement} from '@react-types/shared';
14
+ import {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';
15
15
  import {GridCollection, GridNode} from '@react-types/grid';
16
16
  import {gridMap} from './utils';
17
17
  import {GridState} from '@react-stately/grid';
18
- import {RefObject} from 'react';
19
18
  import {SelectableItemStates, useSelectableItem} from '@react-aria/selection';
20
19
 
21
20
  export interface GridRowProps<T> {