@react-aria/grid
Advanced tools
Comparing version 3.0.0-nightly-987f174ba-241015 to 3.0.0-nightly-993de98ad-241210
@@ -37,5 +37,7 @@ var $iKGCm$reactariaselection = require("@react-aria/selection"); | ||
let item = this.collection.getItem(key); | ||
if (!item) return null; | ||
if (!this.isDisabled(item) && (!pred || pred(item))) return key; | ||
key = this.collection.getKeyBefore(key); | ||
} | ||
return null; | ||
} | ||
@@ -46,11 +48,17 @@ findNextKey(fromKey, pred) { | ||
let item = this.collection.getItem(key); | ||
if (!item) return null; | ||
if (!this.isDisabled(item) && (!pred || pred(item))) return key; | ||
key = this.collection.getKeyAfter(key); | ||
if (key == null) return null; | ||
} | ||
return null; | ||
} | ||
getKeyBelow(key) { | ||
getKeyBelow(fromKey) { | ||
let key = fromKey; | ||
let startItem = this.collection.getItem(key); | ||
if (!startItem) return; | ||
if (!startItem) return null; | ||
var _startItem_parentKey; | ||
// If focus was on a cell, start searching from the parent row | ||
if (this.isCell(startItem)) key = startItem.parentKey; | ||
if (this.isCell(startItem)) key = (_startItem_parentKey = startItem.parentKey) !== null && _startItem_parentKey !== void 0 ? _startItem_parentKey : null; | ||
if (key == null) return null; | ||
// Find the next item | ||
@@ -61,4 +69,7 @@ key = this.findNextKey(key, (item)=>item.type === 'item'); | ||
if (this.isCell(startItem)) { | ||
var _getNthItem; | ||
let item = this.collection.getItem(key); | ||
return (0, $iKGCm$reactstatelycollections.getNthItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection), startItem.index).key; | ||
if (!item) return null; | ||
var _startItem_index, _getNthItem_key; | ||
return (_getNthItem_key = (_getNthItem = (0, $iKGCm$reactstatelycollections.getNthItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) !== null && _getNthItem_key !== void 0 ? _getNthItem_key : null; | ||
} | ||
@@ -68,8 +79,12 @@ // Otherwise, focus the next row | ||
} | ||
return null; | ||
} | ||
getKeyAbove(key) { | ||
getKeyAbove(fromKey) { | ||
let key = fromKey; | ||
let startItem = this.collection.getItem(key); | ||
if (!startItem) return; | ||
if (!startItem) return null; | ||
var _startItem_parentKey; | ||
// If focus is on a cell, start searching from the parent row | ||
if (this.isCell(startItem)) key = startItem.parentKey; | ||
if (this.isCell(startItem)) key = (_startItem_parentKey = startItem.parentKey) !== null && _startItem_parentKey !== void 0 ? _startItem_parentKey : null; | ||
if (key == null) return null; | ||
// Find the previous item | ||
@@ -80,4 +95,7 @@ key = this.findPreviousKey(key, (item)=>item.type === 'item'); | ||
if (this.isCell(startItem)) { | ||
var _getNthItem; | ||
let item = this.collection.getItem(key); | ||
return (0, $iKGCm$reactstatelycollections.getNthItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection), startItem.index).key; | ||
if (!item) return null; | ||
var _startItem_index; | ||
return ((_getNthItem = (0, $iKGCm$reactstatelycollections.getNthItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) || null; | ||
} | ||
@@ -87,61 +105,85 @@ // Otherwise, focus the previous row | ||
} | ||
return null; | ||
} | ||
getKeyRightOf(key) { | ||
let item = this.collection.getItem(key); | ||
if (!item) return; | ||
if (!item) return null; | ||
// If focus is on a row, focus the first child cell. | ||
if (this.isRow(item)) { | ||
var _getLastItem, _getFirstItem; | ||
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection); | ||
return this.direction === 'rtl' ? (0, $iKGCm$reactstatelycollections.getLastItem)(children).key : (0, $iKGCm$reactstatelycollections.getFirstItem)(children).key; | ||
var _ref; | ||
return (_ref = this.direction === 'rtl' ? (_getLastItem = (0, $iKGCm$reactstatelycollections.getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key : (_getFirstItem = (0, $iKGCm$reactstatelycollections.getFirstItem)(children)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _ref !== void 0 ? _ref : null; | ||
} | ||
// If focus is on a cell, focus the next cell if any, | ||
// otherwise focus the parent row. | ||
if (this.isCell(item)) { | ||
if (this.isCell(item) && item.parentKey != null) { | ||
let parent = this.collection.getItem(item.parentKey); | ||
if (!parent) return null; | ||
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(parent, this.collection); | ||
let next = this.direction === 'rtl' ? (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index - 1) : (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index + 1); | ||
if (next) return next.key; | ||
var _ref1; | ||
let next = (_ref1 = this.direction === 'rtl' ? (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index - 1) : (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index + 1)) !== null && _ref1 !== void 0 ? _ref1 : null; | ||
var _next_key; | ||
if (next) return (_next_key = next.key) !== null && _next_key !== void 0 ? _next_key : null; | ||
var _item_parentKey; | ||
// focus row only if focusMode is set to row | ||
if (this.focusMode === 'row') return item.parentKey; | ||
return this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key); | ||
if (this.focusMode === 'row') return (_item_parentKey = item.parentKey) !== null && _item_parentKey !== void 0 ? _item_parentKey : null; | ||
var _ref2; | ||
return (_ref2 = this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key)) !== null && _ref2 !== void 0 ? _ref2 : null; | ||
} | ||
return null; | ||
} | ||
getKeyLeftOf(key) { | ||
let item = this.collection.getItem(key); | ||
if (!item) return; | ||
if (!item) return null; | ||
// If focus is on a row, focus the last child cell. | ||
if (this.isRow(item)) { | ||
var _getFirstItem, _getLastItem; | ||
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection); | ||
return this.direction === 'rtl' ? (0, $iKGCm$reactstatelycollections.getFirstItem)(children).key : (0, $iKGCm$reactstatelycollections.getLastItem)(children).key; | ||
var _ref; | ||
return (_ref = this.direction === 'rtl' ? (_getFirstItem = (0, $iKGCm$reactstatelycollections.getFirstItem)(children)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key : (_getLastItem = (0, $iKGCm$reactstatelycollections.getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _ref !== void 0 ? _ref : null; | ||
} | ||
// If focus is on a cell, focus the previous cell if any, | ||
// otherwise focus the parent row. | ||
if (this.isCell(item)) { | ||
if (this.isCell(item) && item.parentKey != null) { | ||
let parent = this.collection.getItem(item.parentKey); | ||
if (!parent) return null; | ||
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(parent, this.collection); | ||
let prev = this.direction === 'rtl' ? (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index + 1) : (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index - 1); | ||
if (prev) return prev.key; | ||
var _ref1; | ||
let prev = (_ref1 = this.direction === 'rtl' ? (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index + 1) : (0, $iKGCm$reactstatelycollections.getNthItem)(children, item.index - 1)) !== null && _ref1 !== void 0 ? _ref1 : null; | ||
var _prev_key; | ||
if (prev) return (_prev_key = prev.key) !== null && _prev_key !== void 0 ? _prev_key : null; | ||
var _item_parentKey; | ||
// focus row only if focusMode is set to row | ||
if (this.focusMode === 'row') return item.parentKey; | ||
return this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key); | ||
if (this.focusMode === 'row') return (_item_parentKey = item.parentKey) !== null && _item_parentKey !== void 0 ? _item_parentKey : null; | ||
var _ref2; | ||
return (_ref2 = this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key)) !== null && _ref2 !== void 0 ? _ref2 : null; | ||
} | ||
return null; | ||
} | ||
getFirstKey(key, global) { | ||
getFirstKey(fromKey, global) { | ||
let key = fromKey !== null && fromKey !== void 0 ? fromKey : null; | ||
let item; | ||
if (key != null) { | ||
item = this.collection.getItem(key); | ||
if (!item) return; | ||
if (!item) return null; | ||
// If global flag is not set, and a cell is currently focused, | ||
// move focus to the first cell in the parent row. | ||
if (this.isCell(item) && !global) { | ||
if (this.isCell(item) && !global && item.parentKey != null) { | ||
var _getFirstItem; | ||
let parent = this.collection.getItem(item.parentKey); | ||
return (0, $iKGCm$reactstatelycollections.getFirstItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(parent, this.collection)).key; | ||
if (!parent) return null; | ||
var _getFirstItem_key; | ||
return (_getFirstItem_key = (_getFirstItem = (0, $iKGCm$reactstatelycollections.getFirstItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(parent, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null; | ||
} | ||
} | ||
// Find the first row | ||
key = this.findNextKey(null, (item)=>item.type === 'item'); | ||
key = this.findNextKey(undefined, (item)=>item.type === 'item'); | ||
// If global flag is set (or if focus mode is cell), focus the first cell in the first row. | ||
if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') { | ||
if (key != null && (item && this.isCell(item) && global || this.focusMode === 'cell')) { | ||
var _getFirstItem1; | ||
let item = this.collection.getItem(key); | ||
key = (0, $iKGCm$reactstatelycollections.getFirstItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection)).key; | ||
if (!item) return null; | ||
var _getFirstItem_key1; | ||
key = (_getFirstItem_key1 = (_getFirstItem1 = (0, $iKGCm$reactstatelycollections.getFirstItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection))) === null || _getFirstItem1 === void 0 ? void 0 : _getFirstItem1.key) !== null && _getFirstItem_key1 !== void 0 ? _getFirstItem_key1 : null; | ||
} | ||
@@ -151,22 +193,29 @@ // Otherwise, focus the row itself. | ||
} | ||
getLastKey(key, global) { | ||
getLastKey(fromKey, global) { | ||
let key = fromKey !== null && fromKey !== void 0 ? fromKey : null; | ||
let item; | ||
if (key != null) { | ||
item = this.collection.getItem(key); | ||
if (!item) return; | ||
if (!item) return null; | ||
// If global flag is not set, and a cell is currently focused, | ||
// move focus to the last cell in the parent row. | ||
if (this.isCell(item) && !global) { | ||
if (this.isCell(item) && !global && item.parentKey != null) { | ||
var _getLastItem; | ||
let parent = this.collection.getItem(item.parentKey); | ||
if (!parent) return null; | ||
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(parent, this.collection); | ||
return (0, $iKGCm$reactstatelycollections.getLastItem)(children).key; | ||
var _getLastItem_key; | ||
return (_getLastItem_key = (_getLastItem = (0, $iKGCm$reactstatelycollections.getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _getLastItem_key !== void 0 ? _getLastItem_key : null; | ||
} | ||
} | ||
// Find the last row | ||
key = this.findPreviousKey(null, (item)=>item.type === 'item'); | ||
key = this.findPreviousKey(undefined, (item)=>item.type === 'item'); | ||
// If global flag is set (or if focus mode is cell), focus the last cell in the last row. | ||
if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') { | ||
if (key != null && (item && this.isCell(item) && global || this.focusMode === 'cell')) { | ||
var _getLastItem1; | ||
let item = this.collection.getItem(key); | ||
if (!item) return null; | ||
let children = (0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection); | ||
key = (0, $iKGCm$reactstatelycollections.getLastItem)(children).key; | ||
var _getLastItem_key1; | ||
key = (_getLastItem_key1 = (_getLastItem1 = (0, $iKGCm$reactstatelycollections.getLastItem)(children)) === null || _getLastItem1 === void 0 ? void 0 : _getLastItem1.key) !== null && _getLastItem_key1 !== void 0 ? _getLastItem_key1 : null; | ||
} | ||
@@ -176,8 +225,11 @@ // Otherwise, focus the row itself. | ||
} | ||
getKeyPageAbove(key) { | ||
getKeyPageAbove(fromKey) { | ||
let key = fromKey; | ||
let itemRect = this.layoutDelegate.getItemRect(key); | ||
if (!itemRect) return null; | ||
let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height); | ||
while(itemRect && itemRect.y > pageY){ | ||
key = this.getKeyAbove(key); | ||
while(itemRect && itemRect.y > pageY && key != null){ | ||
var _this_getKeyAbove; | ||
key = (_this_getKeyAbove = this.getKeyAbove(key)) !== null && _this_getKeyAbove !== void 0 ? _this_getKeyAbove : null; | ||
if (key == null) break; | ||
itemRect = this.layoutDelegate.getItemRect(key); | ||
@@ -187,3 +239,4 @@ } | ||
} | ||
getKeyPageBelow(key) { | ||
getKeyPageBelow(fromKey) { | ||
let key = fromKey; | ||
let itemRect = this.layoutDelegate.getItemRect(key); | ||
@@ -203,11 +256,16 @@ if (!itemRect) return null; | ||
getKeyForSearch(search, fromKey) { | ||
let key = fromKey !== null && fromKey !== void 0 ? fromKey : null; | ||
if (!this.collator) return null; | ||
let collection = this.collection; | ||
let key = fromKey !== null && fromKey !== void 0 ? fromKey : this.getFirstKey(); | ||
key = fromKey !== null && fromKey !== void 0 ? fromKey : this.getFirstKey(); | ||
if (key == null) return null; | ||
// If the starting key is a cell, search from its parent row. | ||
let startItem = collection.getItem(key); | ||
if (startItem.type === 'cell') key = startItem.parentKey; | ||
if (!startItem) return null; | ||
var _startItem_parentKey; | ||
if (startItem.type === 'cell') key = (_startItem_parentKey = startItem.parentKey) !== null && _startItem_parentKey !== void 0 ? _startItem_parentKey : null; | ||
let hasWrapped = false; | ||
while(key != null){ | ||
let item = collection.getItem(key); | ||
if (!item) return null; | ||
// check row text value for match | ||
@@ -217,3 +275,5 @@ if (item.textValue) { | ||
if (this.collator.compare(substring, search) === 0) { | ||
if (this.isRow(item) && this.focusMode === 'cell') return (0, $iKGCm$reactstatelycollections.getFirstItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection)).key; | ||
var _getFirstItem; | ||
var _getFirstItem_key; | ||
if (this.isRow(item) && this.focusMode === 'cell') return (_getFirstItem_key = (_getFirstItem = (0, $iKGCm$reactstatelycollections.getFirstItem)((0, $iKGCm$reactstatelycollections.getChildNodes)(item, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null; | ||
return item.key; | ||
@@ -237,2 +297,3 @@ } | ||
this.collator = options.collator; | ||
if (!options.layout && !options.ref) throw new Error('Either a layout or a ref must be specified.'); | ||
this.layoutDelegate = options.layoutDelegate || (options.layout ? new $3187c0e19200cb16$var$DeprecatedLayoutDelegate(options.layout) : new (0, $iKGCm$reactariaselection.DOMLayoutDelegate)(options.ref)); | ||
@@ -239,0 +300,0 @@ this.focusMode = options.focusMode || 'row'; |
@@ -31,5 +31,7 @@ import {DOMLayoutDelegate as $kbsd1$DOMLayoutDelegate} from "@react-aria/selection"; | ||
let item = this.collection.getItem(key); | ||
if (!item) return null; | ||
if (!this.isDisabled(item) && (!pred || pred(item))) return key; | ||
key = this.collection.getKeyBefore(key); | ||
} | ||
return null; | ||
} | ||
@@ -40,11 +42,17 @@ findNextKey(fromKey, pred) { | ||
let item = this.collection.getItem(key); | ||
if (!item) return null; | ||
if (!this.isDisabled(item) && (!pred || pred(item))) return key; | ||
key = this.collection.getKeyAfter(key); | ||
if (key == null) return null; | ||
} | ||
return null; | ||
} | ||
getKeyBelow(key) { | ||
getKeyBelow(fromKey) { | ||
let key = fromKey; | ||
let startItem = this.collection.getItem(key); | ||
if (!startItem) return; | ||
if (!startItem) return null; | ||
var _startItem_parentKey; | ||
// If focus was on a cell, start searching from the parent row | ||
if (this.isCell(startItem)) key = startItem.parentKey; | ||
if (this.isCell(startItem)) key = (_startItem_parentKey = startItem.parentKey) !== null && _startItem_parentKey !== void 0 ? _startItem_parentKey : null; | ||
if (key == null) return null; | ||
// Find the next item | ||
@@ -55,4 +63,7 @@ key = this.findNextKey(key, (item)=>item.type === 'item'); | ||
if (this.isCell(startItem)) { | ||
var _getNthItem; | ||
let item = this.collection.getItem(key); | ||
return (0, $kbsd1$getNthItem)((0, $kbsd1$getChildNodes)(item, this.collection), startItem.index).key; | ||
if (!item) return null; | ||
var _startItem_index, _getNthItem_key; | ||
return (_getNthItem_key = (_getNthItem = (0, $kbsd1$getNthItem)((0, $kbsd1$getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) !== null && _getNthItem_key !== void 0 ? _getNthItem_key : null; | ||
} | ||
@@ -62,8 +73,12 @@ // Otherwise, focus the next row | ||
} | ||
return null; | ||
} | ||
getKeyAbove(key) { | ||
getKeyAbove(fromKey) { | ||
let key = fromKey; | ||
let startItem = this.collection.getItem(key); | ||
if (!startItem) return; | ||
if (!startItem) return null; | ||
var _startItem_parentKey; | ||
// If focus is on a cell, start searching from the parent row | ||
if (this.isCell(startItem)) key = startItem.parentKey; | ||
if (this.isCell(startItem)) key = (_startItem_parentKey = startItem.parentKey) !== null && _startItem_parentKey !== void 0 ? _startItem_parentKey : null; | ||
if (key == null) return null; | ||
// Find the previous item | ||
@@ -74,4 +89,7 @@ key = this.findPreviousKey(key, (item)=>item.type === 'item'); | ||
if (this.isCell(startItem)) { | ||
var _getNthItem; | ||
let item = this.collection.getItem(key); | ||
return (0, $kbsd1$getNthItem)((0, $kbsd1$getChildNodes)(item, this.collection), startItem.index).key; | ||
if (!item) return null; | ||
var _startItem_index; | ||
return ((_getNthItem = (0, $kbsd1$getNthItem)((0, $kbsd1$getChildNodes)(item, this.collection), (_startItem_index = startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0)) === null || _getNthItem === void 0 ? void 0 : _getNthItem.key) || null; | ||
} | ||
@@ -81,61 +99,85 @@ // Otherwise, focus the previous row | ||
} | ||
return null; | ||
} | ||
getKeyRightOf(key) { | ||
let item = this.collection.getItem(key); | ||
if (!item) return; | ||
if (!item) return null; | ||
// If focus is on a row, focus the first child cell. | ||
if (this.isRow(item)) { | ||
var _getLastItem, _getFirstItem; | ||
let children = (0, $kbsd1$getChildNodes)(item, this.collection); | ||
return this.direction === 'rtl' ? (0, $kbsd1$getLastItem)(children).key : (0, $kbsd1$getFirstItem)(children).key; | ||
var _ref; | ||
return (_ref = this.direction === 'rtl' ? (_getLastItem = (0, $kbsd1$getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key : (_getFirstItem = (0, $kbsd1$getFirstItem)(children)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _ref !== void 0 ? _ref : null; | ||
} | ||
// If focus is on a cell, focus the next cell if any, | ||
// otherwise focus the parent row. | ||
if (this.isCell(item)) { | ||
if (this.isCell(item) && item.parentKey != null) { | ||
let parent = this.collection.getItem(item.parentKey); | ||
if (!parent) return null; | ||
let children = (0, $kbsd1$getChildNodes)(parent, this.collection); | ||
let next = this.direction === 'rtl' ? (0, $kbsd1$getNthItem)(children, item.index - 1) : (0, $kbsd1$getNthItem)(children, item.index + 1); | ||
if (next) return next.key; | ||
var _ref1; | ||
let next = (_ref1 = this.direction === 'rtl' ? (0, $kbsd1$getNthItem)(children, item.index - 1) : (0, $kbsd1$getNthItem)(children, item.index + 1)) !== null && _ref1 !== void 0 ? _ref1 : null; | ||
var _next_key; | ||
if (next) return (_next_key = next.key) !== null && _next_key !== void 0 ? _next_key : null; | ||
var _item_parentKey; | ||
// focus row only if focusMode is set to row | ||
if (this.focusMode === 'row') return item.parentKey; | ||
return this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key); | ||
if (this.focusMode === 'row') return (_item_parentKey = item.parentKey) !== null && _item_parentKey !== void 0 ? _item_parentKey : null; | ||
var _ref2; | ||
return (_ref2 = this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key)) !== null && _ref2 !== void 0 ? _ref2 : null; | ||
} | ||
return null; | ||
} | ||
getKeyLeftOf(key) { | ||
let item = this.collection.getItem(key); | ||
if (!item) return; | ||
if (!item) return null; | ||
// If focus is on a row, focus the last child cell. | ||
if (this.isRow(item)) { | ||
var _getFirstItem, _getLastItem; | ||
let children = (0, $kbsd1$getChildNodes)(item, this.collection); | ||
return this.direction === 'rtl' ? (0, $kbsd1$getFirstItem)(children).key : (0, $kbsd1$getLastItem)(children).key; | ||
var _ref; | ||
return (_ref = this.direction === 'rtl' ? (_getFirstItem = (0, $kbsd1$getFirstItem)(children)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key : (_getLastItem = (0, $kbsd1$getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _ref !== void 0 ? _ref : null; | ||
} | ||
// If focus is on a cell, focus the previous cell if any, | ||
// otherwise focus the parent row. | ||
if (this.isCell(item)) { | ||
if (this.isCell(item) && item.parentKey != null) { | ||
let parent = this.collection.getItem(item.parentKey); | ||
if (!parent) return null; | ||
let children = (0, $kbsd1$getChildNodes)(parent, this.collection); | ||
let prev = this.direction === 'rtl' ? (0, $kbsd1$getNthItem)(children, item.index + 1) : (0, $kbsd1$getNthItem)(children, item.index - 1); | ||
if (prev) return prev.key; | ||
var _ref1; | ||
let prev = (_ref1 = this.direction === 'rtl' ? (0, $kbsd1$getNthItem)(children, item.index + 1) : (0, $kbsd1$getNthItem)(children, item.index - 1)) !== null && _ref1 !== void 0 ? _ref1 : null; | ||
var _prev_key; | ||
if (prev) return (_prev_key = prev.key) !== null && _prev_key !== void 0 ? _prev_key : null; | ||
var _item_parentKey; | ||
// focus row only if focusMode is set to row | ||
if (this.focusMode === 'row') return item.parentKey; | ||
return this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key); | ||
if (this.focusMode === 'row') return (_item_parentKey = item.parentKey) !== null && _item_parentKey !== void 0 ? _item_parentKey : null; | ||
var _ref2; | ||
return (_ref2 = this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key)) !== null && _ref2 !== void 0 ? _ref2 : null; | ||
} | ||
return null; | ||
} | ||
getFirstKey(key, global) { | ||
getFirstKey(fromKey, global) { | ||
let key = fromKey !== null && fromKey !== void 0 ? fromKey : null; | ||
let item; | ||
if (key != null) { | ||
item = this.collection.getItem(key); | ||
if (!item) return; | ||
if (!item) return null; | ||
// If global flag is not set, and a cell is currently focused, | ||
// move focus to the first cell in the parent row. | ||
if (this.isCell(item) && !global) { | ||
if (this.isCell(item) && !global && item.parentKey != null) { | ||
var _getFirstItem; | ||
let parent = this.collection.getItem(item.parentKey); | ||
return (0, $kbsd1$getFirstItem)((0, $kbsd1$getChildNodes)(parent, this.collection)).key; | ||
if (!parent) return null; | ||
var _getFirstItem_key; | ||
return (_getFirstItem_key = (_getFirstItem = (0, $kbsd1$getFirstItem)((0, $kbsd1$getChildNodes)(parent, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null; | ||
} | ||
} | ||
// Find the first row | ||
key = this.findNextKey(null, (item)=>item.type === 'item'); | ||
key = this.findNextKey(undefined, (item)=>item.type === 'item'); | ||
// If global flag is set (or if focus mode is cell), focus the first cell in the first row. | ||
if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') { | ||
if (key != null && (item && this.isCell(item) && global || this.focusMode === 'cell')) { | ||
var _getFirstItem1; | ||
let item = this.collection.getItem(key); | ||
key = (0, $kbsd1$getFirstItem)((0, $kbsd1$getChildNodes)(item, this.collection)).key; | ||
if (!item) return null; | ||
var _getFirstItem_key1; | ||
key = (_getFirstItem_key1 = (_getFirstItem1 = (0, $kbsd1$getFirstItem)((0, $kbsd1$getChildNodes)(item, this.collection))) === null || _getFirstItem1 === void 0 ? void 0 : _getFirstItem1.key) !== null && _getFirstItem_key1 !== void 0 ? _getFirstItem_key1 : null; | ||
} | ||
@@ -145,22 +187,29 @@ // Otherwise, focus the row itself. | ||
} | ||
getLastKey(key, global) { | ||
getLastKey(fromKey, global) { | ||
let key = fromKey !== null && fromKey !== void 0 ? fromKey : null; | ||
let item; | ||
if (key != null) { | ||
item = this.collection.getItem(key); | ||
if (!item) return; | ||
if (!item) return null; | ||
// If global flag is not set, and a cell is currently focused, | ||
// move focus to the last cell in the parent row. | ||
if (this.isCell(item) && !global) { | ||
if (this.isCell(item) && !global && item.parentKey != null) { | ||
var _getLastItem; | ||
let parent = this.collection.getItem(item.parentKey); | ||
if (!parent) return null; | ||
let children = (0, $kbsd1$getChildNodes)(parent, this.collection); | ||
return (0, $kbsd1$getLastItem)(children).key; | ||
var _getLastItem_key; | ||
return (_getLastItem_key = (_getLastItem = (0, $kbsd1$getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _getLastItem_key !== void 0 ? _getLastItem_key : null; | ||
} | ||
} | ||
// Find the last row | ||
key = this.findPreviousKey(null, (item)=>item.type === 'item'); | ||
key = this.findPreviousKey(undefined, (item)=>item.type === 'item'); | ||
// If global flag is set (or if focus mode is cell), focus the last cell in the last row. | ||
if (key != null && item && this.isCell(item) && global || this.focusMode === 'cell') { | ||
if (key != null && (item && this.isCell(item) && global || this.focusMode === 'cell')) { | ||
var _getLastItem1; | ||
let item = this.collection.getItem(key); | ||
if (!item) return null; | ||
let children = (0, $kbsd1$getChildNodes)(item, this.collection); | ||
key = (0, $kbsd1$getLastItem)(children).key; | ||
var _getLastItem_key1; | ||
key = (_getLastItem_key1 = (_getLastItem1 = (0, $kbsd1$getLastItem)(children)) === null || _getLastItem1 === void 0 ? void 0 : _getLastItem1.key) !== null && _getLastItem_key1 !== void 0 ? _getLastItem_key1 : null; | ||
} | ||
@@ -170,8 +219,11 @@ // Otherwise, focus the row itself. | ||
} | ||
getKeyPageAbove(key) { | ||
getKeyPageAbove(fromKey) { | ||
let key = fromKey; | ||
let itemRect = this.layoutDelegate.getItemRect(key); | ||
if (!itemRect) return null; | ||
let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height); | ||
while(itemRect && itemRect.y > pageY){ | ||
key = this.getKeyAbove(key); | ||
while(itemRect && itemRect.y > pageY && key != null){ | ||
var _this_getKeyAbove; | ||
key = (_this_getKeyAbove = this.getKeyAbove(key)) !== null && _this_getKeyAbove !== void 0 ? _this_getKeyAbove : null; | ||
if (key == null) break; | ||
itemRect = this.layoutDelegate.getItemRect(key); | ||
@@ -181,3 +233,4 @@ } | ||
} | ||
getKeyPageBelow(key) { | ||
getKeyPageBelow(fromKey) { | ||
let key = fromKey; | ||
let itemRect = this.layoutDelegate.getItemRect(key); | ||
@@ -197,11 +250,16 @@ if (!itemRect) return null; | ||
getKeyForSearch(search, fromKey) { | ||
let key = fromKey !== null && fromKey !== void 0 ? fromKey : null; | ||
if (!this.collator) return null; | ||
let collection = this.collection; | ||
let key = fromKey !== null && fromKey !== void 0 ? fromKey : this.getFirstKey(); | ||
key = fromKey !== null && fromKey !== void 0 ? fromKey : this.getFirstKey(); | ||
if (key == null) return null; | ||
// If the starting key is a cell, search from its parent row. | ||
let startItem = collection.getItem(key); | ||
if (startItem.type === 'cell') key = startItem.parentKey; | ||
if (!startItem) return null; | ||
var _startItem_parentKey; | ||
if (startItem.type === 'cell') key = (_startItem_parentKey = startItem.parentKey) !== null && _startItem_parentKey !== void 0 ? _startItem_parentKey : null; | ||
let hasWrapped = false; | ||
while(key != null){ | ||
let item = collection.getItem(key); | ||
if (!item) return null; | ||
// check row text value for match | ||
@@ -211,3 +269,5 @@ if (item.textValue) { | ||
if (this.collator.compare(substring, search) === 0) { | ||
if (this.isRow(item) && this.focusMode === 'cell') return (0, $kbsd1$getFirstItem)((0, $kbsd1$getChildNodes)(item, this.collection)).key; | ||
var _getFirstItem; | ||
var _getFirstItem_key; | ||
if (this.isRow(item) && this.focusMode === 'cell') return (_getFirstItem_key = (_getFirstItem = (0, $kbsd1$getFirstItem)((0, $kbsd1$getChildNodes)(item, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null; | ||
return item.key; | ||
@@ -231,2 +291,3 @@ } | ||
this.collator = options.collator; | ||
if (!options.layout && !options.ref) throw new Error('Either a layout or a ref must be specified.'); | ||
this.layoutDelegate = options.layoutDelegate || (options.layout ? new $d1c300d9c497e402$var$DeprecatedLayoutDelegate(options.layout) : new (0, $kbsd1$DOMLayoutDelegate)(options.ref)); | ||
@@ -233,0 +294,0 @@ this.focusMode = options.focusMode || 'row'; |
@@ -24,3 +24,3 @@ import { Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, RefObject, Size, Collection, AriaLabelingProps, DOMAttributes, DOMProps, FocusableElement } from "@react-types/shared"; | ||
protected direction: Direction; | ||
protected collator: Intl.Collator; | ||
protected collator: Intl.Collator | undefined; | ||
protected layoutDelegate: LayoutDelegate; | ||
@@ -31,13 +31,13 @@ protected focusMode: any; | ||
protected isRow(node: Node<T>): boolean; | ||
protected findPreviousKey(fromKey?: Key, pred?: (item: Node<T>) => boolean): Key; | ||
protected findNextKey(fromKey?: Key, pred?: (item: Node<T>) => boolean): Key; | ||
getKeyBelow(key: Key): Key; | ||
getKeyAbove(key: Key): Key; | ||
getKeyRightOf(key: Key): Key; | ||
getKeyLeftOf(key: Key): Key; | ||
getFirstKey(key?: Key, global?: boolean): Key; | ||
getLastKey(key?: Key, global?: boolean): Key; | ||
getKeyPageAbove(key: Key): Key; | ||
getKeyPageBelow(key: Key): Key; | ||
getKeyForSearch(search: string, fromKey?: Key): Key; | ||
protected findPreviousKey(fromKey?: Key, pred?: (item: Node<T>) => boolean): Key | null; | ||
protected findNextKey(fromKey?: Key, pred?: (item: Node<T>) => boolean): Key | null; | ||
getKeyBelow(fromKey: Key): Key | null; | ||
getKeyAbove(fromKey: Key): Key | null; | ||
getKeyRightOf(key: Key): Key | null; | ||
getKeyLeftOf(key: Key): Key | null; | ||
getFirstKey(fromKey?: Key, global?: boolean): Key | null; | ||
getLastKey(fromKey?: Key, global?: boolean): Key | null; | ||
getKeyPageAbove(fromKey: Key): Key | null; | ||
getKeyPageBelow(fromKey: Key): Key | null; | ||
getKeyForSearch(search: string, fromKey?: Key): Key | null; | ||
} | ||
@@ -44,0 +44,0 @@ interface DeprecatedLayout { |
@@ -118,3 +118,3 @@ var $3187c0e19200cb16$exports = require("./GridKeyboardDelegate.main.js"); | ||
tabIndex: hasTabbableChild ? -1 : 0 | ||
}, descriptionProps); | ||
} || undefined, descriptionProps); | ||
if (isVirtualized) { | ||
@@ -121,0 +121,0 @@ gridProps['aria-rowcount'] = state.collection.size; |
@@ -112,3 +112,3 @@ import {GridKeyboardDelegate as $d1c300d9c497e402$export$de9feff04fda126e} from "./GridKeyboardDelegate.module.js"; | ||
tabIndex: hasTabbableChild ? -1 : 0 | ||
}, descriptionProps); | ||
} || undefined, descriptionProps); | ||
if (isVirtualized) { | ||
@@ -115,0 +115,0 @@ gridProps['aria-rowcount'] = state.collection.size; |
@@ -42,13 +42,15 @@ var $8ee34951196858d0$exports = require("./utils.main.js"); | ||
let focus = ()=>{ | ||
let treeWalker = (0, $9yLAi$reactariafocus.getFocusableTreeWalker)(ref.current); | ||
if (focusMode === 'child') { | ||
// If focus is already on a focusable child within the cell, early return so we don't shift focus | ||
if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) return; | ||
let focusable = state.selectionManager.childFocusStrategy === 'last' ? $cf2021be63b01ef4$var$last(treeWalker) : treeWalker.firstChild(); | ||
if (focusable) { | ||
(0, $9yLAi$reactariafocus.focusSafely)(focusable); | ||
return; | ||
if (ref.current) { | ||
let treeWalker = (0, $9yLAi$reactariafocus.getFocusableTreeWalker)(ref.current); | ||
if (focusMode === 'child') { | ||
// If focus is already on a focusable child within the cell, early return so we don't shift focus | ||
if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) return; | ||
let focusable = state.selectionManager.childFocusStrategy === 'last' ? $cf2021be63b01ef4$var$last(treeWalker) : treeWalker.firstChild(); | ||
if (focusable) { | ||
(0, $9yLAi$reactariafocus.focusSafely)(focusable); | ||
return; | ||
} | ||
} | ||
if (keyWhenFocused.current != null && node.key !== keyWhenFocused.current || !ref.current.contains(document.activeElement)) (0, $9yLAi$reactariafocus.focusSafely)(ref.current); | ||
} | ||
if (keyWhenFocused.current != null && node.key !== keyWhenFocused.current || !ref.current.contains(document.activeElement)) (0, $9yLAi$reactariafocus.focusSafely)(ref.current); | ||
}; | ||
@@ -66,3 +68,3 @@ let { itemProps: itemProps, isPressed: isPressed } = (0, $9yLAi$reactariaselection.useSelectableItem)({ | ||
let onKeyDownCapture = (e)=>{ | ||
if (!e.currentTarget.contains(e.target) || state.isKeyboardNavigationDisabled) return; | ||
if (!e.currentTarget.contains(e.target) || state.isKeyboardNavigationDisabled || !ref.current || !document.activeElement) return; | ||
let walker = (0, $9yLAi$reactariafocus.getFocusableTreeWalker)(ref.current); | ||
@@ -85,2 +87,3 @@ walker.currentNode = document.activeElement; | ||
} else { | ||
var _keyboardDelegate_getKeyLeftOf; | ||
// If there is no next focusable child, then move to the next cell to the left of this one. | ||
@@ -91,8 +94,9 @@ // This will be handled by useSelectableCollection. However, if there is no cell to the left | ||
// child, depending on the focus mode. | ||
let prev = keyboardDelegate.getKeyLeftOf(node.key); | ||
let prev = (_keyboardDelegate_getKeyLeftOf = keyboardDelegate.getKeyLeftOf) === null || _keyboardDelegate_getKeyLeftOf === void 0 ? void 0 : _keyboardDelegate_getKeyLeftOf.call(keyboardDelegate, node.key); | ||
if (prev !== node.key) { | ||
// We prevent the capturing event from reaching children of the cell, e.g. pickers. | ||
var // We prevent the capturing event from reaching children of the cell, e.g. pickers. | ||
// We want arrow keys to navigate to the next cell instead. We need to re-dispatch | ||
// the event from a higher parent so it still bubbles and gets handled by useSelectableCollection. | ||
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
_ref_current_parentElement; | ||
(_ref_current_parentElement = ref.current.parentElement) === null || _ref_current_parentElement === void 0 ? void 0 : _ref_current_parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
break; | ||
@@ -130,8 +134,10 @@ } | ||
} else { | ||
let next = keyboardDelegate.getKeyRightOf(node.key); | ||
var _keyboardDelegate_getKeyRightOf; | ||
let next = (_keyboardDelegate_getKeyRightOf = keyboardDelegate.getKeyRightOf) === null || _keyboardDelegate_getKeyRightOf === void 0 ? void 0 : _keyboardDelegate_getKeyRightOf.call(keyboardDelegate, node.key); | ||
if (next !== node.key) { | ||
// We prevent the capturing event from reaching children of the cell, e.g. pickers. | ||
var // We prevent the capturing event from reaching children of the cell, e.g. pickers. | ||
// We want arrow keys to navigate to the next cell instead. We need to re-dispatch | ||
// the event from a higher parent so it still bubbles and gets handled by useSelectableCollection. | ||
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
_ref_current_parentElement1; | ||
(_ref_current_parentElement1 = ref.current.parentElement) === null || _ref_current_parentElement1 === void 0 ? void 0 : _ref_current_parentElement1.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
break; | ||
@@ -163,5 +169,6 @@ } | ||
if (!e.altKey && ref.current.contains(e.target)) { | ||
var _ref_current_parentElement2; | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
(_ref_current_parentElement2 = ref.current.parentElement) === null || _ref_current_parentElement2 === void 0 ? void 0 : _ref_current_parentElement2.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
} | ||
@@ -207,3 +214,3 @@ break; | ||
requestAnimationFrame(()=>{ | ||
el.setAttribute('tabindex', tabindex); | ||
if (tabindex != null) el.setAttribute('tabindex', tabindex); | ||
}); | ||
@@ -217,4 +224,4 @@ }; | ||
function $cf2021be63b01ef4$var$last(walker) { | ||
let next; | ||
let last; | ||
let next = null; | ||
let last = null; | ||
do { | ||
@@ -221,0 +228,0 @@ last = walker.lastChild(); |
@@ -36,13 +36,15 @@ import {gridMap as $1af922eb41e03c8f$export$e6235c0d09b995d0} from "./utils.module.js"; | ||
let focus = ()=>{ | ||
let treeWalker = (0, $j4Qbl$getFocusableTreeWalker)(ref.current); | ||
if (focusMode === 'child') { | ||
// If focus is already on a focusable child within the cell, early return so we don't shift focus | ||
if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) return; | ||
let focusable = state.selectionManager.childFocusStrategy === 'last' ? $ab90dcbc1b5466d0$var$last(treeWalker) : treeWalker.firstChild(); | ||
if (focusable) { | ||
(0, $j4Qbl$focusSafely)(focusable); | ||
return; | ||
if (ref.current) { | ||
let treeWalker = (0, $j4Qbl$getFocusableTreeWalker)(ref.current); | ||
if (focusMode === 'child') { | ||
// If focus is already on a focusable child within the cell, early return so we don't shift focus | ||
if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) return; | ||
let focusable = state.selectionManager.childFocusStrategy === 'last' ? $ab90dcbc1b5466d0$var$last(treeWalker) : treeWalker.firstChild(); | ||
if (focusable) { | ||
(0, $j4Qbl$focusSafely)(focusable); | ||
return; | ||
} | ||
} | ||
if (keyWhenFocused.current != null && node.key !== keyWhenFocused.current || !ref.current.contains(document.activeElement)) (0, $j4Qbl$focusSafely)(ref.current); | ||
} | ||
if (keyWhenFocused.current != null && node.key !== keyWhenFocused.current || !ref.current.contains(document.activeElement)) (0, $j4Qbl$focusSafely)(ref.current); | ||
}; | ||
@@ -60,3 +62,3 @@ let { itemProps: itemProps, isPressed: isPressed } = (0, $j4Qbl$useSelectableItem)({ | ||
let onKeyDownCapture = (e)=>{ | ||
if (!e.currentTarget.contains(e.target) || state.isKeyboardNavigationDisabled) return; | ||
if (!e.currentTarget.contains(e.target) || state.isKeyboardNavigationDisabled || !ref.current || !document.activeElement) return; | ||
let walker = (0, $j4Qbl$getFocusableTreeWalker)(ref.current); | ||
@@ -79,2 +81,3 @@ walker.currentNode = document.activeElement; | ||
} else { | ||
var _keyboardDelegate_getKeyLeftOf; | ||
// If there is no next focusable child, then move to the next cell to the left of this one. | ||
@@ -85,8 +88,9 @@ // This will be handled by useSelectableCollection. However, if there is no cell to the left | ||
// child, depending on the focus mode. | ||
let prev = keyboardDelegate.getKeyLeftOf(node.key); | ||
let prev = (_keyboardDelegate_getKeyLeftOf = keyboardDelegate.getKeyLeftOf) === null || _keyboardDelegate_getKeyLeftOf === void 0 ? void 0 : _keyboardDelegate_getKeyLeftOf.call(keyboardDelegate, node.key); | ||
if (prev !== node.key) { | ||
// We prevent the capturing event from reaching children of the cell, e.g. pickers. | ||
var // We prevent the capturing event from reaching children of the cell, e.g. pickers. | ||
// We want arrow keys to navigate to the next cell instead. We need to re-dispatch | ||
// the event from a higher parent so it still bubbles and gets handled by useSelectableCollection. | ||
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
_ref_current_parentElement; | ||
(_ref_current_parentElement = ref.current.parentElement) === null || _ref_current_parentElement === void 0 ? void 0 : _ref_current_parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
break; | ||
@@ -124,8 +128,10 @@ } | ||
} else { | ||
let next = keyboardDelegate.getKeyRightOf(node.key); | ||
var _keyboardDelegate_getKeyRightOf; | ||
let next = (_keyboardDelegate_getKeyRightOf = keyboardDelegate.getKeyRightOf) === null || _keyboardDelegate_getKeyRightOf === void 0 ? void 0 : _keyboardDelegate_getKeyRightOf.call(keyboardDelegate, node.key); | ||
if (next !== node.key) { | ||
// We prevent the capturing event from reaching children of the cell, e.g. pickers. | ||
var // We prevent the capturing event from reaching children of the cell, e.g. pickers. | ||
// We want arrow keys to navigate to the next cell instead. We need to re-dispatch | ||
// the event from a higher parent so it still bubbles and gets handled by useSelectableCollection. | ||
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
_ref_current_parentElement1; | ||
(_ref_current_parentElement1 = ref.current.parentElement) === null || _ref_current_parentElement1 === void 0 ? void 0 : _ref_current_parentElement1.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
break; | ||
@@ -157,5 +163,6 @@ } | ||
if (!e.altKey && ref.current.contains(e.target)) { | ||
var _ref_current_parentElement2; | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
(_ref_current_parentElement2 = ref.current.parentElement) === null || _ref_current_parentElement2 === void 0 ? void 0 : _ref_current_parentElement2.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
} | ||
@@ -201,3 +208,3 @@ break; | ||
requestAnimationFrame(()=>{ | ||
el.setAttribute('tabindex', tabindex); | ||
if (tabindex != null) el.setAttribute('tabindex', tabindex); | ||
}); | ||
@@ -211,4 +218,4 @@ }; | ||
function $ab90dcbc1b5466d0$var$last(walker) { | ||
let next; | ||
let last; | ||
let next = null; | ||
let last = null; | ||
do { | ||
@@ -215,0 +222,0 @@ last = walker.lastChild(); |
@@ -28,3 +28,6 @@ var $8ee34951196858d0$exports = require("./utils.main.js"); | ||
let { actions: actions } = (0, $8ee34951196858d0$exports.gridMap).get(state); | ||
let onRowAction = actions.onRowAction ? ()=>actions.onRowAction(node.key) : onAction; | ||
let onRowAction = actions.onRowAction ? ()=>{ | ||
var _actions_onRowAction; | ||
return (_actions_onRowAction = actions.onRowAction) === null || _actions_onRowAction === void 0 ? void 0 : _actions_onRowAction.call(actions, node.key); | ||
} : onAction; | ||
let { itemProps: itemProps, ...states } = (0, $apCYc$reactariaselection.useSelectableItem)({ | ||
@@ -31,0 +34,0 @@ selectionManager: state.selectionManager, |
@@ -22,3 +22,6 @@ import {gridMap as $1af922eb41e03c8f$export$e6235c0d09b995d0} from "./utils.module.js"; | ||
let { actions: actions } = (0, $1af922eb41e03c8f$export$e6235c0d09b995d0).get(state); | ||
let onRowAction = actions.onRowAction ? ()=>actions.onRowAction(node.key) : onAction; | ||
let onRowAction = actions.onRowAction ? ()=>{ | ||
var _actions_onRowAction; | ||
return (_actions_onRowAction = actions.onRowAction) === null || _actions_onRowAction === void 0 ? void 0 : _actions_onRowAction.call(actions, node.key); | ||
} : onAction; | ||
let { itemProps: itemProps, ...states } = (0, $kA5if$useSelectableItem)({ | ||
@@ -25,0 +28,0 @@ selectionManager: state.selectionManager, |
@@ -40,3 +40,3 @@ var $085250522aa37816$exports = require("./intlStrings.main.js"); | ||
let selectionBehavior = props.selectionManager.selectionBehavior; | ||
let message = undefined; | ||
let message; | ||
if (shouldLongPress) message = stringFormatter.format('longPressToSelect'); | ||
@@ -43,0 +43,0 @@ return selectionBehavior === 'replace' && selectionMode !== 'none' && props.hasItemActions ? message : undefined; |
@@ -34,3 +34,3 @@ import $kh5JA$intlStringsmodulejs from "./intlStrings.module.js"; | ||
let selectionBehavior = props.selectionManager.selectionBehavior; | ||
let message = undefined; | ||
let message; | ||
if (shouldLongPress) message = stringFormatter.format('longPressToSelect'); | ||
@@ -37,0 +37,0 @@ return selectionBehavior === 'replace' && selectionMode !== 'none' && props.hasItemActions ? message : undefined; |
{ | ||
"name": "@react-aria/grid", | ||
"version": "3.0.0-nightly-987f174ba-241015", | ||
"version": "3.0.0-nightly-993de98ad-241210", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,19 +25,19 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-aria/focus": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-aria/i18n": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-aria/interactions": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-aria/live-announcer": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-aria/selection": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-aria/utils": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-stately/collections": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-stately/grid": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-stately/selection": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-types/checkbox": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-types/grid": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-types/shared": "^3.0.0-nightly-987f174ba-241015", | ||
"@react-aria/focus": "^3.0.0-nightly-993de98ad-241210", | ||
"@react-aria/i18n": "^3.0.0-nightly-993de98ad-241210", | ||
"@react-aria/interactions": "^3.0.0-nightly-993de98ad-241210", | ||
"@react-aria/live-announcer": "^3.0.0-nightly-993de98ad-241210", | ||
"@react-aria/selection": "^3.0.0-nightly-993de98ad-241210", | ||
"@react-aria/utils": "^3.0.0-nightly-993de98ad-241210", | ||
"@react-stately/collections": "^3.0.0-nightly-993de98ad-241210", | ||
"@react-stately/grid": "^3.0.0-nightly-993de98ad-241210", | ||
"@react-stately/selection": "^3.0.0-nightly-993de98ad-241210", | ||
"@react-types/checkbox": "^3.0.0-nightly-993de98ad-241210", | ||
"@react-types/grid": "^3.0.0-nightly-993de98ad-241210", | ||
"@react-types/shared": "^3.0.0-nightly-993de98ad-241210", | ||
"@swc/helpers": "^0.5.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0", | ||
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" | ||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", | ||
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" | ||
}, | ||
@@ -47,3 +47,3 @@ "publishConfig": { | ||
}, | ||
"stableVersion": "3.10.5" | ||
"stableVersion": "3.11.0" | ||
} |
@@ -36,3 +36,3 @@ /* | ||
protected direction: Direction; | ||
protected collator: Intl.Collator; | ||
protected collator: Intl.Collator | undefined; | ||
protected layoutDelegate: LayoutDelegate; | ||
@@ -47,3 +47,6 @@ protected focusMode; | ||
this.collator = options.collator; | ||
this.layoutDelegate = options.layoutDelegate || (options.layout ? new DeprecatedLayoutDelegate(options.layout) : new DOMLayoutDelegate(options.ref)); | ||
if (!options.layout && !options.ref) { | ||
throw new Error('Either a layout or a ref must be specified.'); | ||
} | ||
this.layoutDelegate = options.layoutDelegate || (options.layout ? new DeprecatedLayoutDelegate(options.layout) : new DOMLayoutDelegate(options.ref!)); | ||
this.focusMode = options.focusMode || 'row'; | ||
@@ -71,2 +74,5 @@ } | ||
let item = this.collection.getItem(key); | ||
if (!item) { | ||
return null; | ||
} | ||
if (!this.isDisabled(item) && (!pred || pred(item))) { | ||
@@ -78,2 +84,3 @@ return key; | ||
} | ||
return null; | ||
} | ||
@@ -88,2 +95,5 @@ | ||
let item = this.collection.getItem(key); | ||
if (!item) { | ||
return null; | ||
} | ||
if (!this.isDisabled(item) && (!pred || pred(item))) { | ||
@@ -94,9 +104,14 @@ return key; | ||
key = this.collection.getKeyAfter(key); | ||
if (key == null) { | ||
return null; | ||
} | ||
} | ||
return null; | ||
} | ||
getKeyBelow(key: Key) { | ||
getKeyBelow(fromKey: Key) { | ||
let key: Key | null = fromKey; | ||
let startItem = this.collection.getItem(key); | ||
if (!startItem) { | ||
return; | ||
return null; | ||
} | ||
@@ -106,4 +121,7 @@ | ||
if (this.isCell(startItem)) { | ||
key = startItem.parentKey; | ||
key = startItem.parentKey ?? null; | ||
} | ||
if (key == null) { | ||
return null; | ||
} | ||
@@ -116,3 +134,6 @@ // Find the next item | ||
let item = this.collection.getItem(key); | ||
return getNthItem(getChildNodes(item, this.collection), startItem.index).key; | ||
if (!item) { | ||
return null; | ||
} | ||
return getNthItem(getChildNodes(item, this.collection), startItem.index ?? 0)?.key ?? null; | ||
} | ||
@@ -125,8 +146,10 @@ | ||
} | ||
return null; | ||
} | ||
getKeyAbove(key: Key) { | ||
getKeyAbove(fromKey: Key) { | ||
let key: Key | null = fromKey; | ||
let startItem = this.collection.getItem(key); | ||
if (!startItem) { | ||
return; | ||
return null; | ||
} | ||
@@ -136,4 +159,7 @@ | ||
if (this.isCell(startItem)) { | ||
key = startItem.parentKey; | ||
key = startItem.parentKey ?? null; | ||
} | ||
if (key == null) { | ||
return null; | ||
} | ||
@@ -146,3 +172,6 @@ // Find the previous item | ||
let item = this.collection.getItem(key); | ||
return getNthItem(getChildNodes(item, this.collection), startItem.index).key; | ||
if (!item) { | ||
return null; | ||
} | ||
return getNthItem(getChildNodes(item, this.collection), startItem.index ?? 0)?.key || null; | ||
} | ||
@@ -155,2 +184,3 @@ | ||
} | ||
return null; | ||
} | ||
@@ -161,3 +191,3 @@ | ||
if (!item) { | ||
return; | ||
return null; | ||
} | ||
@@ -168,5 +198,5 @@ | ||
let children = getChildNodes(item, this.collection); | ||
return this.direction === 'rtl' | ||
? getLastItem(children).key | ||
: getFirstItem(children).key; | ||
return (this.direction === 'rtl' | ||
? getLastItem(children)?.key | ||
: getFirstItem(children)?.key) ?? null; | ||
} | ||
@@ -176,11 +206,14 @@ | ||
// otherwise focus the parent row. | ||
if (this.isCell(item)) { | ||
if (this.isCell(item) && item.parentKey != null) { | ||
let parent = this.collection.getItem(item.parentKey); | ||
if (!parent) { | ||
return null; | ||
} | ||
let children = getChildNodes(parent, this.collection); | ||
let next = this.direction === 'rtl' | ||
let next = (this.direction === 'rtl' | ||
? getNthItem(children, item.index - 1) | ||
: getNthItem(children, item.index + 1); | ||
: getNthItem(children, item.index + 1)) ?? null; | ||
if (next) { | ||
return next.key; | ||
return next.key ?? null; | ||
} | ||
@@ -190,7 +223,8 @@ | ||
if (this.focusMode === 'row') { | ||
return item.parentKey; | ||
return item.parentKey ?? null; | ||
} | ||
return this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key); | ||
return (this.direction === 'rtl' ? this.getFirstKey(key) : this.getLastKey(key)) ?? null; | ||
} | ||
return null; | ||
} | ||
@@ -201,3 +235,3 @@ | ||
if (!item) { | ||
return; | ||
return null; | ||
} | ||
@@ -208,5 +242,5 @@ | ||
let children = getChildNodes(item, this.collection); | ||
return this.direction === 'rtl' | ||
? getFirstItem(children).key | ||
: getLastItem(children).key; | ||
return (this.direction === 'rtl' | ||
? getFirstItem(children)?.key | ||
: getLastItem(children)?.key) ?? null; | ||
} | ||
@@ -216,11 +250,14 @@ | ||
// otherwise focus the parent row. | ||
if (this.isCell(item)) { | ||
if (this.isCell(item) && item.parentKey != null) { | ||
let parent = this.collection.getItem(item.parentKey); | ||
if (!parent) { | ||
return null; | ||
} | ||
let children = getChildNodes(parent, this.collection); | ||
let prev = this.direction === 'rtl' | ||
let prev = (this.direction === 'rtl' | ||
? getNthItem(children, item.index + 1) | ||
: getNthItem(children, item.index - 1); | ||
: getNthItem(children, item.index - 1)) ?? null; | ||
if (prev) { | ||
return prev.key; | ||
return prev.key ?? null; | ||
} | ||
@@ -230,15 +267,17 @@ | ||
if (this.focusMode === 'row') { | ||
return item.parentKey; | ||
return item.parentKey ?? null; | ||
} | ||
return this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key); | ||
return (this.direction === 'rtl' ? this.getLastKey(key) : this.getFirstKey(key)) ?? null; | ||
} | ||
return null; | ||
} | ||
getFirstKey(key?: Key, global?: boolean) { | ||
let item: Node<T>; | ||
getFirstKey(fromKey?: Key, global?: boolean) { | ||
let key: Key | null = fromKey ?? null; | ||
let item: Node<T> | undefined | null; | ||
if (key != null) { | ||
item = this.collection.getItem(key); | ||
if (!item) { | ||
return; | ||
return null; | ||
} | ||
@@ -248,5 +287,8 @@ | ||
// move focus to the first cell in the parent row. | ||
if (this.isCell(item) && !global) { | ||
if (this.isCell(item) && !global && item.parentKey != null) { | ||
let parent = this.collection.getItem(item.parentKey); | ||
return getFirstItem(getChildNodes(parent, this.collection)).key; | ||
if (!parent) { | ||
return null; | ||
} | ||
return getFirstItem(getChildNodes(parent, this.collection))?.key ?? null; | ||
} | ||
@@ -256,8 +298,11 @@ } | ||
// Find the first row | ||
key = this.findNextKey(null, item => item.type === 'item'); | ||
key = this.findNextKey(undefined, item => item.type === 'item'); | ||
// If global flag is set (or if focus mode is cell), focus the first cell in the first row. | ||
if ((key != null && item && this.isCell(item) && global) || this.focusMode === 'cell') { | ||
if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) { | ||
let item = this.collection.getItem(key); | ||
key = getFirstItem(getChildNodes(item, this.collection)).key; | ||
if (!item) { | ||
return null; | ||
} | ||
key = getFirstItem(getChildNodes(item, this.collection))?.key ?? null; | ||
} | ||
@@ -269,8 +314,9 @@ | ||
getLastKey(key?: Key, global?: boolean) { | ||
let item: Node<T>; | ||
getLastKey(fromKey?: Key, global?: boolean) { | ||
let key: Key | null = fromKey ?? null; | ||
let item: Node<T> | undefined | null; | ||
if (key != null) { | ||
item = this.collection.getItem(key); | ||
if (!item) { | ||
return; | ||
return null; | ||
} | ||
@@ -280,6 +326,9 @@ | ||
// move focus to the last cell in the parent row. | ||
if (this.isCell(item) && !global) { | ||
if (this.isCell(item) && !global && item.parentKey != null) { | ||
let parent = this.collection.getItem(item.parentKey); | ||
if (!parent) { | ||
return null; | ||
} | ||
let children = getChildNodes(parent, this.collection); | ||
return getLastItem(children).key; | ||
return getLastItem(children)?.key ?? null; | ||
} | ||
@@ -289,9 +338,12 @@ } | ||
// Find the last row | ||
key = this.findPreviousKey(null, item => item.type === 'item'); | ||
key = this.findPreviousKey(undefined, item => item.type === 'item'); | ||
// If global flag is set (or if focus mode is cell), focus the last cell in the last row. | ||
if ((key != null && item && this.isCell(item) && global) || this.focusMode === 'cell') { | ||
if (key != null && ((item && this.isCell(item) && global) || this.focusMode === 'cell')) { | ||
let item = this.collection.getItem(key); | ||
if (!item) { | ||
return null; | ||
} | ||
let children = getChildNodes(item, this.collection); | ||
key = getLastItem(children).key; | ||
key = getLastItem(children)?.key ?? null; | ||
} | ||
@@ -303,3 +355,4 @@ | ||
getKeyPageAbove(key: Key) { | ||
getKeyPageAbove(fromKey: Key) { | ||
let key: Key | null = fromKey; | ||
let itemRect = this.layoutDelegate.getItemRect(key); | ||
@@ -312,4 +365,7 @@ if (!itemRect) { | ||
while (itemRect && itemRect.y > pageY) { | ||
key = this.getKeyAbove(key); | ||
while (itemRect && itemRect.y > pageY && key != null) { | ||
key = this.getKeyAbove(key) ?? null; | ||
if (key == null) { | ||
break; | ||
} | ||
itemRect = this.layoutDelegate.getItemRect(key); | ||
@@ -321,3 +377,4 @@ } | ||
getKeyPageBelow(key: Key) { | ||
getKeyPageBelow(fromKey: Key) { | ||
let key: Key | null = fromKey; | ||
let itemRect = this.layoutDelegate.getItemRect(key); | ||
@@ -347,2 +404,3 @@ | ||
getKeyForSearch(search: string, fromKey?: Key) { | ||
let key: Key | null = fromKey ?? null; | ||
if (!this.collator) { | ||
@@ -353,8 +411,14 @@ return null; | ||
let collection = this.collection; | ||
let key = fromKey ?? this.getFirstKey(); | ||
key = fromKey ?? this.getFirstKey(); | ||
if (key == null) { | ||
return null; | ||
} | ||
// If the starting key is a cell, search from its parent row. | ||
let startItem = collection.getItem(key); | ||
if (!startItem) { | ||
return null; | ||
} | ||
if (startItem.type === 'cell') { | ||
key = startItem.parentKey; | ||
key = startItem.parentKey ?? null; | ||
} | ||
@@ -365,2 +429,5 @@ | ||
let item = collection.getItem(key); | ||
if (!item) { | ||
return null; | ||
} | ||
@@ -372,3 +439,3 @@ // check row text value for match | ||
if (this.isRow(item) && this.focusMode === 'cell') { | ||
return getFirstItem(getChildNodes(item, this.collection)).key; | ||
return getFirstItem(getChildNodes(item, this.collection))?.key ?? null; | ||
} | ||
@@ -375,0 +442,0 @@ |
@@ -152,3 +152,3 @@ /* | ||
// If collection is empty, make sure the grid is tabbable unless there is a child tabbable element. | ||
state.collection.size === 0 && {tabIndex: hasTabbableChild ? -1 : 0}, | ||
(state.collection.size === 0 && {tabIndex: hasTabbableChild ? -1 : 0}) || undefined, | ||
descriptionProps | ||
@@ -155,0 +155,0 @@ ); |
@@ -13,3 +13,3 @@ /* | ||
import {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared'; | ||
import {DOMAttributes, FocusableElement, Key, RefObject} from '@react-types/shared'; | ||
import {focusSafely, getFocusableTreeWalker} from '@react-aria/focus'; | ||
@@ -64,7 +64,7 @@ import {getScrollParent, mergeProps, scrollIntoViewport} from '@react-aria/utils'; | ||
let {direction} = useLocale(); | ||
let {keyboardDelegate, actions: {onCellAction}} = gridMap.get(state); | ||
let {keyboardDelegate, actions: {onCellAction}} = gridMap.get(state)!; | ||
// We need to track the key of the item at the time it was last focused so that we force | ||
// focus to go to the item when the DOM node is reused for a different item in a virtualizer. | ||
let keyWhenFocused = useRef(null); | ||
let keyWhenFocused = useRef<Key | null>(null); | ||
@@ -74,24 +74,26 @@ // Handles focusing the cell. If there is a focusable child, | ||
let focus = () => { | ||
let treeWalker = getFocusableTreeWalker(ref.current); | ||
if (focusMode === 'child') { | ||
// If focus is already on a focusable child within the cell, early return so we don't shift focus | ||
if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) { | ||
return; | ||
if (ref.current) { | ||
let treeWalker = getFocusableTreeWalker(ref.current); | ||
if (focusMode === 'child') { | ||
// If focus is already on a focusable child within the cell, early return so we don't shift focus | ||
if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) { | ||
return; | ||
} | ||
let focusable = state.selectionManager.childFocusStrategy === 'last' | ||
? last(treeWalker) | ||
: treeWalker.firstChild() as FocusableElement; | ||
if (focusable) { | ||
focusSafely(focusable); | ||
return; | ||
} | ||
} | ||
let focusable = state.selectionManager.childFocusStrategy === 'last' | ||
? last(treeWalker) | ||
: treeWalker.firstChild() as FocusableElement; | ||
if (focusable) { | ||
focusSafely(focusable); | ||
return; | ||
if ( | ||
(keyWhenFocused.current != null && node.key !== keyWhenFocused.current) || | ||
!ref.current.contains(document.activeElement) | ||
) { | ||
focusSafely(ref.current); | ||
} | ||
} | ||
if ( | ||
(keyWhenFocused.current != null && node.key !== keyWhenFocused.current) || | ||
!ref.current.contains(document.activeElement) | ||
) { | ||
focusSafely(ref.current); | ||
} | ||
}; | ||
@@ -111,3 +113,3 @@ | ||
let onKeyDownCapture = (e: ReactKeyboardEvent) => { | ||
if (!e.currentTarget.contains(e.target as Element) || state.isKeyboardNavigationDisabled) { | ||
if (!e.currentTarget.contains(e.target as Element) || state.isKeyboardNavigationDisabled || !ref.current || !document.activeElement) { | ||
return; | ||
@@ -122,3 +124,3 @@ } | ||
// Find the next focusable element within the cell. | ||
let focusable = direction === 'rtl' | ||
let focusable: FocusableElement | null = direction === 'rtl' | ||
? walker.nextNode() as FocusableElement | ||
@@ -143,3 +145,3 @@ : walker.previousNode() as FocusableElement; | ||
// child, depending on the focus mode. | ||
let prev = keyboardDelegate.getKeyLeftOf(node.key); | ||
let prev = keyboardDelegate.getKeyLeftOf?.(node.key); | ||
if (prev !== node.key) { | ||
@@ -149,3 +151,3 @@ // We prevent the capturing event from reaching children of the cell, e.g. pickers. | ||
// the event from a higher parent so it still bubbles and gets handled by useSelectableCollection. | ||
ref.current.parentElement.dispatchEvent( | ||
ref.current.parentElement?.dispatchEvent( | ||
new KeyboardEvent(e.nativeEvent.type, e.nativeEvent) | ||
@@ -173,3 +175,3 @@ ); | ||
case 'ArrowRight': { | ||
let focusable = direction === 'rtl' | ||
let focusable: FocusableElement | null = direction === 'rtl' | ||
? walker.previousNode() as FocusableElement | ||
@@ -188,3 +190,3 @@ : walker.nextNode() as FocusableElement; | ||
} else { | ||
let next = keyboardDelegate.getKeyRightOf(node.key); | ||
let next = keyboardDelegate.getKeyRightOf?.(node.key); | ||
if (next !== node.key) { | ||
@@ -194,3 +196,3 @@ // We prevent the capturing event from reaching children of the cell, e.g. pickers. | ||
// the event from a higher parent so it still bubbles and gets handled by useSelectableCollection. | ||
ref.current.parentElement.dispatchEvent( | ||
ref.current.parentElement?.dispatchEvent( | ||
new KeyboardEvent(e.nativeEvent.type, e.nativeEvent) | ||
@@ -225,3 +227,3 @@ ); | ||
e.preventDefault(); | ||
ref.current.parentElement.dispatchEvent( | ||
ref.current.parentElement?.dispatchEvent( | ||
new KeyboardEvent(e.nativeEvent.type, e.nativeEvent) | ||
@@ -280,3 +282,5 @@ ); | ||
requestAnimationFrame(() => { | ||
el.setAttribute('tabindex', tabindex); | ||
if (tabindex != null) { | ||
el.setAttribute('tabindex', tabindex); | ||
} | ||
}); | ||
@@ -293,6 +297,6 @@ }; | ||
function last(walker: TreeWalker) { | ||
let next: FocusableElement; | ||
let last: FocusableElement; | ||
let next: FocusableElement | null = null; | ||
let last: FocusableElement | null = null; | ||
do { | ||
last = walker.lastChild() as FocusableElement; | ||
last = walker.lastChild() as FocusableElement | null; | ||
if (last) { | ||
@@ -299,0 +303,0 @@ next = last; |
@@ -55,4 +55,4 @@ /* | ||
let {actions} = gridMap.get(state); | ||
let onRowAction = actions.onRowAction ? () => actions.onRowAction(node.key) : onAction; | ||
let {actions} = gridMap.get(state)!; | ||
let onRowAction = actions.onRowAction ? () => actions.onRowAction?.(node.key) : onAction; | ||
let {itemProps, ...states} = useSelectableItem({ | ||
@@ -59,0 +59,0 @@ selectionManager: state.selectionManager, |
@@ -61,3 +61,3 @@ /* | ||
let isReplace = state.selectionManager.selectionBehavior === 'replace'; | ||
let messages = []; | ||
let messages: string[] = []; | ||
@@ -64,0 +64,0 @@ if ((state.selectionManager.selectedKeys.size === 1 && isReplace)) { |
@@ -42,3 +42,3 @@ /* | ||
let message = undefined; | ||
let message: string | undefined; | ||
if (shouldLongPress) { | ||
@@ -45,0 +45,0 @@ message = stringFormatter.format('longPressToSelect'); |
@@ -20,4 +20,4 @@ /* | ||
actions: { | ||
onRowAction: (key: Key) => void, | ||
onCellAction: (key: Key) => void | ||
onRowAction?: (key: Key) => void, | ||
onCellAction?: (key: Key) => void | ||
} | ||
@@ -24,0 +24,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
532106
5721
Updated@react-aria/interactions@^3.0.0-nightly-993de98ad-241210
Updated@react-aria/live-announcer@^3.0.0-nightly-993de98ad-241210
Updated@react-aria/selection@^3.0.0-nightly-993de98ad-241210
Updated@react-stately/collections@^3.0.0-nightly-993de98ad-241210
Updated@react-stately/selection@^3.0.0-nightly-993de98ad-241210
Updated@react-types/checkbox@^3.0.0-nightly-993de98ad-241210