@react-aria/gridlist
Advanced tools
Comparing version 3.0.0-nightly-a98da553e-241116 to 3.0.0-nightly-b3a4d6c11-241119
@@ -59,3 +59,3 @@ var $7db02799adae605d$exports = require("./utils.main.js"); | ||
// (e.g. clicking on a row button) | ||
if (keyWhenFocused.current != null && node.key !== keyWhenFocused.current || !((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.contains(document.activeElement))) (0, $911qM$reactariafocus.focusSafely)(ref.current); | ||
if (ref.current !== null && (keyWhenFocused.current != null && node.key !== keyWhenFocused.current || !((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.contains(document.activeElement)))) (0, $911qM$reactariafocus.focusSafely)(ref.current); | ||
}; | ||
@@ -66,9 +66,24 @@ let treeGridRowProps = {}; | ||
if (node != null && 'expandedKeys' in state) { | ||
var _state_collection_getChildren, _state_collection, _filter_at; | ||
// TODO: ideally node.hasChildNodes would be a way to tell if a row has child nodes, but the row's contents make it so that value is always | ||
// true... | ||
let children = (_state_collection_getChildren = (_state_collection = state.collection).getChildren) === null || _state_collection_getChildren === void 0 ? void 0 : _state_collection_getChildren.call(_state_collection, node.key); | ||
hasChildRows = [ | ||
...state.collection.getChildren(node.key) | ||
...children !== null && children !== void 0 ? children : [] | ||
].length > 1; | ||
if (onAction == null && !hasLink && state.selectionManager.selectionMode === 'none' && hasChildRows) onAction = ()=>state.toggleKey(node.key); | ||
let isExpanded = hasChildRows ? state.expandedKeys.has(node.key) : undefined; | ||
let setSize = 1; | ||
var _filter_at_index; | ||
if (node.level > 0 && (node === null || node === void 0 ? void 0 : node.parentKey) != null) { | ||
let parent = state.collection.getItem(node.parentKey); | ||
if (parent) { | ||
var _state_collection_getChildren1, _state_collection1; | ||
// siblings must exist because our original node exists, same with lastItem | ||
let siblings = (_state_collection_getChildren1 = (_state_collection1 = state.collection).getChildren) === null || _state_collection_getChildren1 === void 0 ? void 0 : _state_collection_getChildren1.call(_state_collection1, parent.key); | ||
setSize = (0, $911qM$reactstatelycollections.getLastItem)(siblings).index + 1; | ||
} | ||
} else setSize = ((_filter_at_index = (_filter_at = [ | ||
...state.collection | ||
].filter((row)=>row.level === 0).at(-1)) === null || _filter_at === void 0 ? void 0 : _filter_at.index) !== null && _filter_at_index !== void 0 ? _filter_at_index : 0) + 1; | ||
treeGridRowProps = { | ||
@@ -78,5 +93,3 @@ 'aria-expanded': isExpanded, | ||
'aria-posinset': (node === null || node === void 0 ? void 0 : node.index) + 1, | ||
'aria-setsize': node.level > 0 ? (0, $911qM$reactstatelycollections.getLastItem)(state.collection.getChildren(node === null || node === void 0 ? void 0 : node.parentKey)).index + 1 : [ | ||
...state.collection | ||
].filter((row)=>row.level === 0).at(-1).index + 1 | ||
'aria-setsize': setSize | ||
}; | ||
@@ -95,3 +108,3 @@ } | ||
let onKeyDown = (e)=>{ | ||
if (!e.currentTarget.contains(e.target)) return; | ||
if (!e.currentTarget.contains(e.target) || !ref.current || !document.activeElement) return; | ||
let walker = (0, $911qM$reactariafocus.getFocusableTreeWalker)(ref.current); | ||
@@ -181,5 +194,6 @@ walker.currentNode = document.activeElement; | ||
if (!e.altKey && ref.current.contains(e.target)) { | ||
var _ref_current_parentElement; | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
(_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)); | ||
} | ||
@@ -253,4 +267,4 @@ break; | ||
function $f7116f5928c03f32$var$last(walker) { | ||
let next; | ||
let last; | ||
let next = null; | ||
let last = null; | ||
do { | ||
@@ -257,0 +271,0 @@ last = walker.lastChild(); |
@@ -53,3 +53,3 @@ import {getRowId as $ce9b18daab526bbd$export$f45c25170b9a99c2, listMap as $ce9b18daab526bbd$export$5b9bb410392e3991} from "./utils.module.js"; | ||
// (e.g. clicking on a row button) | ||
if (keyWhenFocused.current != null && node.key !== keyWhenFocused.current || !((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.contains(document.activeElement))) (0, $lxFUG$focusSafely)(ref.current); | ||
if (ref.current !== null && (keyWhenFocused.current != null && node.key !== keyWhenFocused.current || !((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.contains(document.activeElement)))) (0, $lxFUG$focusSafely)(ref.current); | ||
}; | ||
@@ -60,9 +60,24 @@ let treeGridRowProps = {}; | ||
if (node != null && 'expandedKeys' in state) { | ||
var _state_collection_getChildren, _state_collection, _filter_at; | ||
// TODO: ideally node.hasChildNodes would be a way to tell if a row has child nodes, but the row's contents make it so that value is always | ||
// true... | ||
let children = (_state_collection_getChildren = (_state_collection = state.collection).getChildren) === null || _state_collection_getChildren === void 0 ? void 0 : _state_collection_getChildren.call(_state_collection, node.key); | ||
hasChildRows = [ | ||
...state.collection.getChildren(node.key) | ||
...children !== null && children !== void 0 ? children : [] | ||
].length > 1; | ||
if (onAction == null && !hasLink && state.selectionManager.selectionMode === 'none' && hasChildRows) onAction = ()=>state.toggleKey(node.key); | ||
let isExpanded = hasChildRows ? state.expandedKeys.has(node.key) : undefined; | ||
let setSize = 1; | ||
var _filter_at_index; | ||
if (node.level > 0 && (node === null || node === void 0 ? void 0 : node.parentKey) != null) { | ||
let parent = state.collection.getItem(node.parentKey); | ||
if (parent) { | ||
var _state_collection_getChildren1, _state_collection1; | ||
// siblings must exist because our original node exists, same with lastItem | ||
let siblings = (_state_collection_getChildren1 = (_state_collection1 = state.collection).getChildren) === null || _state_collection_getChildren1 === void 0 ? void 0 : _state_collection_getChildren1.call(_state_collection1, parent.key); | ||
setSize = (0, $lxFUG$getLastItem)(siblings).index + 1; | ||
} | ||
} else setSize = ((_filter_at_index = (_filter_at = [ | ||
...state.collection | ||
].filter((row)=>row.level === 0).at(-1)) === null || _filter_at === void 0 ? void 0 : _filter_at.index) !== null && _filter_at_index !== void 0 ? _filter_at_index : 0) + 1; | ||
treeGridRowProps = { | ||
@@ -72,5 +87,3 @@ 'aria-expanded': isExpanded, | ||
'aria-posinset': (node === null || node === void 0 ? void 0 : node.index) + 1, | ||
'aria-setsize': node.level > 0 ? (0, $lxFUG$getLastItem)(state.collection.getChildren(node === null || node === void 0 ? void 0 : node.parentKey)).index + 1 : [ | ||
...state.collection | ||
].filter((row)=>row.level === 0).at(-1).index + 1 | ||
'aria-setsize': setSize | ||
}; | ||
@@ -89,3 +102,3 @@ } | ||
let onKeyDown = (e)=>{ | ||
if (!e.currentTarget.contains(e.target)) return; | ||
if (!e.currentTarget.contains(e.target) || !ref.current || !document.activeElement) return; | ||
let walker = (0, $lxFUG$getFocusableTreeWalker)(ref.current); | ||
@@ -175,5 +188,6 @@ walker.currentNode = document.activeElement; | ||
if (!e.altKey && ref.current.contains(e.target)) { | ||
var _ref_current_parentElement; | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)); | ||
(_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)); | ||
} | ||
@@ -247,4 +261,4 @@ break; | ||
function $4e8b0456ef72939f$var$last(walker) { | ||
let next; | ||
let last; | ||
let next = null; | ||
let last = null; | ||
do { | ||
@@ -251,0 +265,0 @@ last = walker.lastChild(); |
@@ -20,3 +20,4 @@ | ||
function $7db02799adae605d$export$f45c25170b9a99c2(state, key) { | ||
let { id: id } = $7db02799adae605d$export$5b9bb410392e3991.get(state); | ||
var _listMap_get; | ||
let { id: id } = (_listMap_get = $7db02799adae605d$export$5b9bb410392e3991.get(state)) !== null && _listMap_get !== void 0 ? _listMap_get : {}; | ||
if (!id) throw new Error('Unknown list'); | ||
@@ -23,0 +24,0 @@ return `${id}-${$7db02799adae605d$export$e0c709538cb8ae18(key)}`; |
@@ -13,3 +13,4 @@ /* | ||
function $ce9b18daab526bbd$export$f45c25170b9a99c2(state, key) { | ||
let { id: id } = $ce9b18daab526bbd$export$5b9bb410392e3991.get(state); | ||
var _listMap_get; | ||
let { id: id } = (_listMap_get = $ce9b18daab526bbd$export$5b9bb410392e3991.get(state)) !== null && _listMap_get !== void 0 ? _listMap_get : {}; | ||
if (!id) throw new Error('Unknown list'); | ||
@@ -16,0 +17,0 @@ return `${id}-${$ce9b18daab526bbd$export$e0c709538cb8ae18(key)}`; |
{ | ||
"name": "@react-aria/gridlist", | ||
"version": "3.0.0-nightly-a98da553e-241116", | ||
"version": "3.0.0-nightly-b3a4d6c11-241119", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,17 +25,17 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-aria/focus": "^3.0.0-nightly-a98da553e-241116", | ||
"@react-aria/grid": "^3.0.0-nightly-a98da553e-241116", | ||
"@react-aria/i18n": "^3.0.0-nightly-a98da553e-241116", | ||
"@react-aria/interactions": "^3.0.0-nightly-a98da553e-241116", | ||
"@react-aria/selection": "^3.0.0-nightly-a98da553e-241116", | ||
"@react-aria/utils": "^3.0.0-nightly-a98da553e-241116", | ||
"@react-stately/collections": "^3.0.0-nightly-a98da553e-241116", | ||
"@react-stately/list": "^3.0.0-nightly-a98da553e-241116", | ||
"@react-stately/tree": "^3.0.0-nightly-a98da553e-241116", | ||
"@react-types/shared": "^3.0.0-nightly-a98da553e-241116", | ||
"@react-aria/focus": "^3.0.0-nightly-b3a4d6c11-241119", | ||
"@react-aria/grid": "^3.0.0-nightly-b3a4d6c11-241119", | ||
"@react-aria/i18n": "^3.0.0-nightly-b3a4d6c11-241119", | ||
"@react-aria/interactions": "^3.0.0-nightly-b3a4d6c11-241119", | ||
"@react-aria/selection": "^3.0.0-nightly-b3a4d6c11-241119", | ||
"@react-aria/utils": "^3.0.0-nightly-b3a4d6c11-241119", | ||
"@react-stately/collections": "^3.0.0-nightly-b3a4d6c11-241119", | ||
"@react-stately/list": "^3.0.0-nightly-b3a4d6c11-241119", | ||
"@react-stately/tree": "^3.0.0-nightly-b3a4d6c11-241119", | ||
"@react-types/shared": "^3.0.0-nightly-b3a4d6c11-241119", | ||
"@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" | ||
}, | ||
@@ -42,0 +42,0 @@ "publishConfig": { |
@@ -14,3 +14,3 @@ /* | ||
import {chain, getScrollParent, mergeProps, scrollIntoViewport, useSlotId, useSyntheticLinkProps} from '@react-aria/utils'; | ||
import {DOMAttributes, FocusableElement, RefObject, Node as RSNode} from '@react-types/shared'; | ||
import {DOMAttributes, FocusableElement, Key, RefObject, Node as RSNode} from '@react-types/shared'; | ||
import {focusSafely, getFocusableTreeWalker} from '@react-aria/focus'; | ||
@@ -71,3 +71,3 @@ import {getLastItem} from '@react-stately/collections'; | ||
let {direction} = useLocale(); | ||
let {onAction, linkBehavior, keyboardNavigationBehavior} = listMap.get(state); | ||
let {onAction, linkBehavior, keyboardNavigationBehavior} = listMap.get(state)!; | ||
let descriptionId = useSlotId(); | ||
@@ -77,3 +77,3 @@ | ||
// 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); | ||
let focus = () => { | ||
@@ -83,4 +83,5 @@ // Don't shift focus to the row if the active element is a element within the row already | ||
if ( | ||
(keyWhenFocused.current != null && node.key !== keyWhenFocused.current) || | ||
!ref.current?.contains(document.activeElement) | ||
ref.current !== null && | ||
((keyWhenFocused.current != null && node.key !== keyWhenFocused.current) || | ||
!ref.current?.contains(document.activeElement)) | ||
) { | ||
@@ -97,3 +98,4 @@ focusSafely(ref.current); | ||
// true... | ||
hasChildRows = [...state.collection.getChildren(node.key)].length > 1; | ||
let children = state.collection.getChildren?.(node.key); | ||
hasChildRows = [...(children ?? [])].length > 1; | ||
if (onAction == null && !hasLink && state.selectionManager.selectionMode === 'none' && hasChildRows) { | ||
@@ -104,2 +106,13 @@ onAction = () => state.toggleKey(node.key); | ||
let isExpanded = hasChildRows ? state.expandedKeys.has(node.key) : undefined; | ||
let setSize = 1; | ||
if (node.level > 0 && node?.parentKey != null) { | ||
let parent = state.collection.getItem(node.parentKey); | ||
if (parent) { | ||
// siblings must exist because our original node exists, same with lastItem | ||
let siblings = state.collection.getChildren?.(parent.key)!; | ||
setSize = getLastItem(siblings)!.index + 1; | ||
} | ||
} else { | ||
setSize = ([...state.collection].filter(row => row.level === 0).at(-1)?.index ?? 0) + 1; | ||
} | ||
treeGridRowProps = { | ||
@@ -109,5 +122,3 @@ 'aria-expanded': isExpanded, | ||
'aria-posinset': node?.index + 1, | ||
'aria-setsize': node.level > 0 ? | ||
(getLastItem(state.collection.getChildren(node?.parentKey))).index + 1 : | ||
[...state.collection].filter(row => row.level === 0).at(-1).index + 1 | ||
'aria-setsize': setSize | ||
}; | ||
@@ -128,3 +139,3 @@ } | ||
let onKeyDown = (e: ReactKeyboardEvent) => { | ||
if (!e.currentTarget.contains(e.target as Element)) { | ||
if (!e.currentTarget.contains(e.target as Element) || !ref.current || !document.activeElement) { | ||
return; | ||
@@ -217,3 +228,3 @@ } | ||
e.preventDefault(); | ||
ref.current.parentElement.dispatchEvent( | ||
ref.current.parentElement?.dispatchEvent( | ||
new KeyboardEvent(e.nativeEvent.type, e.nativeEvent) | ||
@@ -299,6 +310,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) { | ||
@@ -305,0 +316,0 @@ next = last; |
@@ -18,3 +18,3 @@ /* | ||
id: string, | ||
onAction: (key: Key) => void, | ||
onAction?: (key: Key) => void, | ||
linkBehavior?: 'action' | 'selection' | 'override', | ||
@@ -29,3 +29,3 @@ keyboardNavigationBehavior: 'arrow' | 'tab' | ||
export function getRowId<T>(state: ListState<T>, key: Key) { | ||
let {id} = listMap.get(state); | ||
let {id} = listMap.get(state) ?? {}; | ||
if (!id) { | ||
@@ -32,0 +32,0 @@ throw new Error('Unknown list'); |
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
159651
1783
+ Addedreact@19.0.0-rc-fb9a90fa48-20240614(transitive)
+ Addedreact-dom@19.0.0-rc-fb9a90fa48-20240614(transitive)
+ Addedscheduler@0.25.0-rc-fb9a90fa48-20240614(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedreact@18.3.1(transitive)
- Removedreact-dom@18.3.1(transitive)
- Removedscheduler@0.23.2(transitive)
Updated@react-aria/interactions@^3.0.0-nightly-b3a4d6c11-241119
Updated@react-aria/selection@^3.0.0-nightly-b3a4d6c11-241119
Updated@react-stately/collections@^3.0.0-nightly-b3a4d6c11-241119