react-aria 3.49.0 → 3.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/private/autocomplete/useAutocomplete.cjs +16 -7
- package/dist/private/autocomplete/useAutocomplete.cjs.map +1 -1
- package/dist/private/autocomplete/useAutocomplete.js +16 -7
- package/dist/private/autocomplete/useAutocomplete.js.map +1 -1
- package/dist/private/autocomplete/useAutocomplete.mjs +16 -7
- package/dist/private/autocomplete/useAutocomplete.mjs.map +1 -1
- package/dist/private/breadcrumbs/useBreadcrumbs.cjs.map +1 -1
- package/dist/private/breadcrumbs/useBreadcrumbs.js.map +1 -1
- package/dist/private/breadcrumbs/useBreadcrumbs.mjs.map +1 -1
- package/dist/private/calendar/useCalendarBase.cjs.map +1 -1
- package/dist/private/calendar/useCalendarBase.js.map +1 -1
- package/dist/private/calendar/useCalendarBase.mjs.map +1 -1
- package/dist/private/calendar/useCalendarCell.cjs.map +1 -1
- package/dist/private/calendar/useCalendarCell.js.map +1 -1
- package/dist/private/calendar/useCalendarCell.mjs.map +1 -1
- package/dist/private/calendar/useCalendarYearPicker.cjs +4 -4
- package/dist/private/calendar/useCalendarYearPicker.cjs.map +1 -1
- package/dist/private/calendar/useCalendarYearPicker.js +4 -4
- package/dist/private/calendar/useCalendarYearPicker.js.map +1 -1
- package/dist/private/calendar/useCalendarYearPicker.mjs +4 -4
- package/dist/private/calendar/useCalendarYearPicker.mjs.map +1 -1
- package/dist/private/calendar/utils.cjs.map +1 -1
- package/dist/private/calendar/utils.js.map +1 -1
- package/dist/private/calendar/utils.mjs.map +1 -1
- package/dist/private/color/useColorArea.cjs.map +1 -1
- package/dist/private/color/useColorArea.js.map +1 -1
- package/dist/private/color/useColorArea.mjs.map +1 -1
- package/dist/private/color/useColorSwatch.cjs.map +1 -1
- package/dist/private/color/useColorSwatch.js.map +1 -1
- package/dist/private/color/useColorSwatch.mjs.map +1 -1
- package/dist/private/combobox/useComboBox.cjs +2 -0
- package/dist/private/combobox/useComboBox.cjs.map +1 -1
- package/dist/private/combobox/useComboBox.js +2 -0
- package/dist/private/combobox/useComboBox.js.map +1 -1
- package/dist/private/combobox/useComboBox.mjs +2 -0
- package/dist/private/combobox/useComboBox.mjs.map +1 -1
- package/dist/private/datepicker/useDateField.cjs.map +1 -1
- package/dist/private/datepicker/useDateField.js.map +1 -1
- package/dist/private/datepicker/useDateField.mjs.map +1 -1
- package/dist/private/datepicker/useDatePicker.cjs.map +1 -1
- package/dist/private/datepicker/useDatePicker.js.map +1 -1
- package/dist/private/datepicker/useDatePicker.mjs.map +1 -1
- package/dist/private/datepicker/useDateRangePicker.cjs.map +1 -1
- package/dist/private/datepicker/useDateRangePicker.js.map +1 -1
- package/dist/private/datepicker/useDateRangePicker.mjs.map +1 -1
- package/dist/private/datepicker/useDisplayNames.cjs +1 -2
- package/dist/private/datepicker/useDisplayNames.cjs.map +1 -1
- package/dist/private/datepicker/useDisplayNames.js +1 -2
- package/dist/private/datepicker/useDisplayNames.js.map +1 -1
- package/dist/private/datepicker/useDisplayNames.mjs +1 -2
- package/dist/private/datepicker/useDisplayNames.mjs.map +1 -1
- package/dist/private/dnd/DragManager.cjs +4 -1
- package/dist/private/dnd/DragManager.cjs.map +1 -1
- package/dist/private/dnd/DragManager.js +4 -1
- package/dist/private/dnd/DragManager.js.map +1 -1
- package/dist/private/dnd/DragManager.mjs +4 -1
- package/dist/private/dnd/DragManager.mjs.map +1 -1
- package/dist/private/dnd/useDrag.cjs.map +1 -1
- package/dist/private/dnd/useDrag.js.map +1 -1
- package/dist/private/dnd/useDrag.mjs.map +1 -1
- package/dist/private/dnd/useDraggableItem.cjs.map +1 -1
- package/dist/private/dnd/useDraggableItem.js.map +1 -1
- package/dist/private/dnd/useDraggableItem.mjs.map +1 -1
- package/dist/private/dnd/useDropIndicator.cjs.map +1 -1
- package/dist/private/dnd/useDropIndicator.js.map +1 -1
- package/dist/private/dnd/useDropIndicator.mjs.map +1 -1
- package/dist/private/dnd/useVirtualDrop.cjs.map +1 -1
- package/dist/private/dnd/useVirtualDrop.js.map +1 -1
- package/dist/private/dnd/useVirtualDrop.mjs.map +1 -1
- package/dist/private/dnd/utils.cjs +13 -3
- package/dist/private/dnd/utils.cjs.map +1 -1
- package/dist/private/dnd/utils.js +13 -3
- package/dist/private/dnd/utils.js.map +1 -1
- package/dist/private/dnd/utils.mjs +13 -3
- package/dist/private/dnd/utils.mjs.map +1 -1
- package/dist/private/form/useFormValidation.cjs +1 -1
- package/dist/private/form/useFormValidation.cjs.map +1 -1
- package/dist/private/form/useFormValidation.js +1 -1
- package/dist/private/form/useFormValidation.js.map +1 -1
- package/dist/private/form/useFormValidation.mjs +1 -1
- package/dist/private/form/useFormValidation.mjs.map +1 -1
- package/dist/private/grid/useGridSelectionAnnouncement.cjs.map +1 -1
- package/dist/private/grid/useGridSelectionAnnouncement.js.map +1 -1
- package/dist/private/grid/useGridSelectionAnnouncement.mjs.map +1 -1
- package/dist/private/grid/useGridSelectionCheckbox.cjs.map +1 -1
- package/dist/private/grid/useGridSelectionCheckbox.js.map +1 -1
- package/dist/private/grid/useGridSelectionCheckbox.mjs.map +1 -1
- package/dist/private/grid/useHighlightSelectionDescription.cjs.map +1 -1
- package/dist/private/grid/useHighlightSelectionDescription.js.map +1 -1
- package/dist/private/grid/useHighlightSelectionDescription.mjs.map +1 -1
- package/dist/private/gridlist/useGridList.cjs +2 -1
- package/dist/private/gridlist/useGridList.cjs.map +1 -1
- package/dist/private/gridlist/useGridList.js +2 -1
- package/dist/private/gridlist/useGridList.js.map +1 -1
- package/dist/private/gridlist/useGridList.mjs +2 -1
- package/dist/private/gridlist/useGridList.mjs.map +1 -1
- package/dist/private/gridlist/useGridListItem.cjs +62 -21
- package/dist/private/gridlist/useGridListItem.cjs.map +1 -1
- package/dist/private/gridlist/useGridListItem.js +63 -22
- package/dist/private/gridlist/useGridListItem.js.map +1 -1
- package/dist/private/gridlist/useGridListItem.mjs +62 -21
- package/dist/private/gridlist/useGridListItem.mjs.map +1 -1
- package/dist/private/interactions/createEventHandler.cjs +3 -0
- package/dist/private/interactions/createEventHandler.cjs.map +1 -1
- package/dist/private/interactions/createEventHandler.js +3 -0
- package/dist/private/interactions/createEventHandler.js.map +1 -1
- package/dist/private/interactions/createEventHandler.mjs +3 -0
- package/dist/private/interactions/createEventHandler.mjs.map +1 -1
- package/dist/private/interactions/useFocusVisible.cjs +16 -5
- package/dist/private/interactions/useFocusVisible.cjs.map +1 -1
- package/dist/private/interactions/useFocusVisible.js +16 -5
- package/dist/private/interactions/useFocusVisible.js.map +1 -1
- package/dist/private/interactions/useFocusVisible.mjs +16 -5
- package/dist/private/interactions/useFocusVisible.mjs.map +1 -1
- package/dist/private/menu/useMenu.cjs.map +1 -1
- package/dist/private/menu/useMenu.js.map +1 -1
- package/dist/private/menu/useMenu.mjs.map +1 -1
- package/dist/private/menu/useMenuItem.cjs +1 -1
- package/dist/private/menu/useMenuItem.cjs.map +1 -1
- package/dist/private/menu/useMenuItem.js +1 -1
- package/dist/private/menu/useMenuItem.js.map +1 -1
- package/dist/private/menu/useMenuItem.mjs +1 -1
- package/dist/private/menu/useMenuItem.mjs.map +1 -1
- package/dist/private/menu/useMenuTrigger.cjs.map +1 -1
- package/dist/private/menu/useMenuTrigger.js.map +1 -1
- package/dist/private/menu/useMenuTrigger.mjs.map +1 -1
- package/dist/private/menu/utils.cjs.map +1 -1
- package/dist/private/menu/utils.js.map +1 -1
- package/dist/private/menu/utils.mjs.map +1 -1
- package/dist/private/numberfield/useNumberField.cjs.map +1 -1
- package/dist/private/numberfield/useNumberField.js.map +1 -1
- package/dist/private/numberfield/useNumberField.mjs.map +1 -1
- package/dist/private/overlays/DismissButton.cjs.map +1 -1
- package/dist/private/overlays/DismissButton.js.map +1 -1
- package/dist/private/overlays/DismissButton.mjs.map +1 -1
- package/dist/private/overlays/calculatePosition.cjs +7 -7
- package/dist/private/overlays/calculatePosition.cjs.map +1 -1
- package/dist/private/overlays/calculatePosition.js +7 -7
- package/dist/private/overlays/calculatePosition.js.map +1 -1
- package/dist/private/overlays/calculatePosition.mjs +7 -7
- package/dist/private/overlays/calculatePosition.mjs.map +1 -1
- package/dist/private/overlays/useOverlayPosition.cjs +3 -2
- package/dist/private/overlays/useOverlayPosition.cjs.map +1 -1
- package/dist/private/overlays/useOverlayPosition.js +3 -2
- package/dist/private/overlays/useOverlayPosition.js.map +1 -1
- package/dist/private/overlays/useOverlayPosition.mjs +3 -2
- package/dist/private/overlays/useOverlayPosition.mjs.map +1 -1
- package/dist/private/searchfield/useSearchField.cjs.map +1 -1
- package/dist/private/searchfield/useSearchField.js.map +1 -1
- package/dist/private/searchfield/useSearchField.mjs.map +1 -1
- package/dist/private/select/useSelect.cjs +1 -2
- package/dist/private/select/useSelect.cjs.map +1 -1
- package/dist/private/select/useSelect.js +1 -2
- package/dist/private/select/useSelect.js.map +1 -1
- package/dist/private/select/useSelect.mjs +1 -2
- package/dist/private/select/useSelect.mjs.map +1 -1
- package/dist/private/selection/ListKeyboardDelegate.cjs +31 -3
- package/dist/private/selection/ListKeyboardDelegate.cjs.map +1 -1
- package/dist/private/selection/ListKeyboardDelegate.js +31 -3
- package/dist/private/selection/ListKeyboardDelegate.js.map +1 -1
- package/dist/private/selection/ListKeyboardDelegate.mjs +31 -3
- package/dist/private/selection/ListKeyboardDelegate.mjs.map +1 -1
- package/dist/private/selection/useSelectableCollection.cjs +20 -14
- package/dist/private/selection/useSelectableCollection.cjs.map +1 -1
- package/dist/private/selection/useSelectableCollection.js +26 -19
- package/dist/private/selection/useSelectableCollection.js.map +1 -1
- package/dist/private/selection/useSelectableCollection.mjs +20 -14
- package/dist/private/selection/useSelectableCollection.mjs.map +1 -1
- package/dist/private/selection/useTypeSelect.cjs +50 -18
- package/dist/private/selection/useTypeSelect.cjs.map +1 -1
- package/dist/private/selection/useTypeSelect.js +51 -19
- package/dist/private/selection/useTypeSelect.js.map +1 -1
- package/dist/private/selection/useTypeSelect.mjs +51 -19
- package/dist/private/selection/useTypeSelect.mjs.map +1 -1
- package/dist/private/spinbutton/useSpinButton.cjs.map +1 -1
- package/dist/private/spinbutton/useSpinButton.js.map +1 -1
- package/dist/private/spinbutton/useSpinButton.mjs.map +1 -1
- package/dist/private/steplist/useStepList.cjs.map +1 -1
- package/dist/private/steplist/useStepList.js.map +1 -1
- package/dist/private/steplist/useStepList.mjs.map +1 -1
- package/dist/private/table/useTable.cjs.map +1 -1
- package/dist/private/table/useTable.js.map +1 -1
- package/dist/private/table/useTable.mjs.map +1 -1
- package/dist/private/table/useTableColumnHeader.cjs.map +1 -1
- package/dist/private/table/useTableColumnHeader.js.map +1 -1
- package/dist/private/table/useTableColumnHeader.mjs.map +1 -1
- package/dist/private/table/useTableColumnResize.cjs.map +1 -1
- package/dist/private/table/useTableColumnResize.js.map +1 -1
- package/dist/private/table/useTableColumnResize.mjs.map +1 -1
- package/dist/private/table/useTableRow.cjs.map +1 -1
- package/dist/private/table/useTableRow.js.map +1 -1
- package/dist/private/table/useTableRow.mjs.map +1 -1
- package/dist/private/table/useTableSelectionCheckbox.cjs.map +1 -1
- package/dist/private/table/useTableSelectionCheckbox.js.map +1 -1
- package/dist/private/table/useTableSelectionCheckbox.mjs.map +1 -1
- package/dist/private/tabs/TabsKeyboardDelegate.cjs +2 -2
- package/dist/private/tabs/TabsKeyboardDelegate.cjs.map +1 -1
- package/dist/private/tabs/TabsKeyboardDelegate.js +2 -2
- package/dist/private/tabs/TabsKeyboardDelegate.js.map +1 -1
- package/dist/private/tabs/TabsKeyboardDelegate.mjs +2 -2
- package/dist/private/tabs/TabsKeyboardDelegate.mjs.map +1 -1
- package/dist/private/tag/useTag.cjs.map +1 -1
- package/dist/private/tag/useTag.js.map +1 -1
- package/dist/private/tag/useTag.mjs.map +1 -1
- package/dist/private/toast/useToast.cjs.map +1 -1
- package/dist/private/toast/useToast.js.map +1 -1
- package/dist/private/toast/useToast.mjs.map +1 -1
- package/dist/private/toast/useToastRegion.cjs.map +1 -1
- package/dist/private/toast/useToastRegion.js.map +1 -1
- package/dist/private/toast/useToastRegion.mjs.map +1 -1
- package/dist/private/toolbar/useToolbar.cjs +0 -1
- package/dist/private/toolbar/useToolbar.cjs.map +1 -1
- package/dist/private/toolbar/useToolbar.js +0 -1
- package/dist/private/toolbar/useToolbar.js.map +1 -1
- package/dist/private/toolbar/useToolbar.mjs +0 -1
- package/dist/private/toolbar/useToolbar.mjs.map +1 -1
- package/dist/private/tree/useTree.cjs.map +1 -1
- package/dist/private/tree/useTree.js.map +1 -1
- package/dist/private/tree/useTree.mjs.map +1 -1
- package/dist/private/tree/useTreeItem.cjs.map +1 -1
- package/dist/private/tree/useTreeItem.js.map +1 -1
- package/dist/private/tree/useTreeItem.mjs.map +1 -1
- package/dist/private/utils/isElementVisible.cjs +1 -1
- package/dist/private/utils/isElementVisible.cjs.map +1 -1
- package/dist/private/utils/isElementVisible.js +1 -1
- package/dist/private/utils/isElementVisible.js.map +1 -1
- package/dist/private/utils/isElementVisible.mjs +1 -1
- package/dist/private/utils/isElementVisible.mjs.map +1 -1
- package/dist/private/utils/isFocusable.cjs +3 -1
- package/dist/private/utils/isFocusable.cjs.map +1 -1
- package/dist/private/utils/isFocusable.js +3 -1
- package/dist/private/utils/isFocusable.js.map +1 -1
- package/dist/private/utils/isFocusable.mjs +3 -1
- package/dist/private/utils/isFocusable.mjs.map +1 -1
- package/dist/types/src/dnd/utils.d.ts +2 -2
- package/dist/types/src/gridlist/useGridList.d.ts +7 -0
- package/dist/types/src/menu/useMenu.d.ts +1 -1
- package/dist/types/src/menu/utils.d.ts +1 -1
- package/dist/types/src/overlays/calculatePosition.d.ts +1 -0
- package/dist/types/src/overlays/useOverlayPosition.d.ts +8 -0
- package/dist/types/src/selection/ListKeyboardDelegate.d.ts +1 -0
- package/dist/types/src/selection/useSelectableCollection.d.ts +7 -0
- package/dist/types/src/tree/useTree.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;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GAAG;IACnB;IAEA,IAAI,gBAAgB;QAClB,MAAM;QACN,iBAAiB;IACnB;IAEA,2FAA2F;IAC3F,OAAO;QACL,UAAU;YAAC,GAAG,CAAA,GAAA,oCAAS,EAAE,UAAU,iBAAiB;QAAA;uBACpD;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,GAAG,UAAU;IACf;AACF;AAEA,SAAS,2BAAK,MAAkB;IAC9B,IAAI,OAAgC;IACpC,IAAI,OAAgC;IACpC,GAAG;QACD,OAAO,OAAO,SAAS;QACvB,IAAI,MACF,OAAO;IAEX,QAAS,MAAM;IACf,OAAO;AACT;AAEA,SAAS,wCAAqB,MAAiB,EAAE,UAAiC;IAChF,+KAA+K;IAC/K,6HAA6H;IAC7H,IAAI,WAAW,WAAW,WAAW,GAAG,OAAO,GAAG;IAClD,IAAI,aAAa,WAAW,MAAM,IAAI,CAAC,YAAY,EAAE;IACrD,IAAI,OAAO,WAAW,MAAM,GAAG,IAAI,UAAU,CAAC,EAAE,GAAG;IACnD,IAAI,WAAwB,EAAE;IAC9B,MAAO,KAAM;QACX,SAAS,IAAI,CAAC;QACd,OAAO,KAAK,OAAO,IAAI,OAAO,WAAW,OAAO,CAAC,KAAK,OAAO,IAAI;IACnE;IACA,OAAO;AACT","sources":["packages/react-aria/src/gridlist/useGridListItem.ts"],"sourcesContent":["/*\n * Copyright 2022 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 '../utils/chain';\n\nimport {\n Collection,\n DOMAttributes,\n FocusableElement,\n Key,\n RefObject,\n Node as RSNode\n} from '@react-types/shared';\nimport {focusSafely} from '../interactions/focusSafely';\nimport {\n getActiveElement,\n getEventTarget,\n isFocusWithin,\n nodeContains\n} from '../utils/shadowdom/DOMFunctions';\nimport {getFocusableTreeWalker} from '../focus/FocusScope';\nimport {getRowId, listMap} from './utils';\nimport {getScrollParent} from '../utils/getScrollParent';\nimport {HTMLAttributes, KeyboardEvent as ReactKeyboardEvent, useRef} from 'react';\nimport {isFocusVisible} from '../interactions/useFocusVisible';\nimport type {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {scrollIntoViewport} from '../utils/scrollIntoView';\nimport {SelectableItemStates, useSelectableItem} from '../selection/useSelectableItem';\nimport type {TreeState} from 'react-stately/useTreeState';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useSlotId} from '../utils/useId';\nimport {useSyntheticLinkProps} from '../utils/openLink';\n\nexport interface AriaGridListItemOptions {\n /**\n * An object representing the list item. Contains all the relevant information that makes up the\n * list row.\n */\n node: RSNode<unknown>;\n /** Whether the list 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 /** Whether this item has children, even if not loaded yet. */\n hasChildItems?: boolean;\n}\n\nexport interface GridListItemAria extends SelectableItemStates {\n /** Props for the list row element. */\n rowProps: DOMAttributes;\n /** Props for the grid cell element within the list row. */\n gridCellProps: DOMAttributes;\n /** Props for the list item description element, if any. */\n descriptionProps: DOMAttributes;\n}\n\nconst EXPANSION_KEYS = {\n expand: {\n ltr: 'ArrowRight',\n rtl: 'ArrowLeft'\n },\n collapse: {\n ltr: 'ArrowLeft',\n rtl: 'ArrowRight'\n }\n};\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid list.\n *\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useListState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useGridListItem<T>(\n props: AriaGridListItemOptions,\n state: ListState<T> | TreeState<T>,\n ref: RefObject<FocusableElement | null>\n): GridListItemAria {\n // Copied from useGridCell + some modifications to make it not so grid specific\n let {node, isVirtualized} = props;\n\n // let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/gridlist');\n let {direction} = useLocale();\n let {onAction, linkBehavior, keyboardNavigationBehavior, shouldSelectOnPressUp} =\n listMap.get(state)!;\n let descriptionId = useSlotId();\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<Key | null>(null);\n let focus = () => {\n // Don't shift focus to the row if the active element is a element within the row already\n // (e.g. clicking on a row button)\n if (\n ref.current !== null &&\n ((keyWhenFocused.current != null && node.key !== keyWhenFocused.current) ||\n !isFocusWithin(ref.current))\n ) {\n focusSafely(ref.current);\n }\n };\n\n let treeGridRowProps: HTMLAttributes<HTMLElement> = {};\n let hasChildRows = props.hasChildItems;\n let hasLink = state.selectionManager.isLink(node.key);\n if (node != null && 'expandedKeys' in state) {\n // 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\n // true...\n let children = state.collection.getChildren?.(node.key);\n hasChildRows = hasChildRows || [...(children ?? [])].length > 1;\n\n if (\n onAction == null &&\n !hasLink &&\n state.selectionManager.selectionMode === 'none' &&\n hasChildRows\n ) {\n onAction = () => state.toggleKey(node.key);\n }\n\n let isExpanded = hasChildRows ? state.expandedKeys.has(node.key) : undefined;\n let setSize = 1;\n let index = node.index;\n if (node.level >= 0 && node?.parentKey != null) {\n let parent = state.collection.getItem(node.parentKey);\n if (parent) {\n // siblings must exist because our original node exists\n let siblings = getDirectChildren(parent, state.collection);\n setSize = [...siblings].filter(row => row.type === 'item').length;\n if (index > 0 && siblings[0].type !== 'item') {\n index -= 1; // subtract one for the parent item's content node\n }\n }\n } else {\n setSize = [...state.collection].filter(row => row.level === 0 && row.type === 'item').length;\n }\n\n treeGridRowProps = {\n 'aria-expanded': isExpanded,\n 'aria-level': node.level + 1,\n 'aria-posinset': index + 1,\n 'aria-setsize': setSize\n };\n }\n\n let {itemProps, ...itemStates} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp || shouldSelectOnPressUp,\n onAction:\n onAction || node.props?.onAction\n ? chain(node.props?.onAction, onAction ? () => onAction(node.key) : undefined)\n : undefined,\n focus,\n linkBehavior\n });\n\n let onKeyDownCapture = (e: ReactKeyboardEvent) => {\n let activeElement = getActiveElement();\n if (\n !nodeContains(e.currentTarget, getEventTarget(e) as Element) ||\n !ref.current ||\n !activeElement\n ) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = activeElement;\n\n if ('expandedKeys' in state && activeElement === ref.current) {\n if (\n e.key === EXPANSION_KEYS['expand'][direction] &&\n state.selectionManager.focusedKey === node.key &&\n hasChildRows &&\n !state.expandedKeys.has(node.key)\n ) {\n state.toggleKey(node.key);\n e.stopPropagation();\n return;\n } else if (\n e.key === EXPANSION_KEYS['collapse'][direction] &&\n state.selectionManager.focusedKey === node.key\n ) {\n // If item is collapsible, collapse it; else move to parent\n if (hasChildRows && state.expandedKeys.has(node.key)) {\n state.toggleKey(node.key);\n e.stopPropagation();\n return;\n } else if (\n !state.expandedKeys.has(node.key) &&\n node.parentKey &&\n state.collection.getItem(node.parentKey)?.type === 'item'\n ) {\n // Item is a leaf or already collapsed, move focus to parent\n state.selectionManager.setFocusedKey(node.parentKey);\n e.stopPropagation();\n return;\n }\n }\n }\n\n switch (e.key) {\n case 'ArrowLeft': {\n if (keyboardNavigationBehavior === 'arrow') {\n // Find the next focusable element within the row.\n let focusable =\n direction === 'rtl'\n ? (walker.nextNode() as FocusableElement)\n : (walker.previousNode() as FocusableElement);\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n // If there is no next focusable child, then return focus back to the row\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n // oxlint-disable-next-line max-depth\n if (lastElement) {\n focusSafely(lastElement);\n scrollIntoViewport(lastElement, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n if (keyboardNavigationBehavior === 'arrow') {\n let focusable =\n direction === 'rtl'\n ? (walker.previousNode() as FocusableElement)\n : (walker.nextNode() as FocusableElement);\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'ltr') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n // oxlint-disable-next-line max-depth\n if (lastElement) {\n focusSafely(lastElement);\n scrollIntoViewport(lastElement, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching row children, e.g. menu buttons. We want arrow keys to navigate\n // to the row 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 && nodeContains(ref.current, getEventTarget(e) 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 let onFocus = e => {\n keyWhenFocused.current = node.key;\n if (getEventTarget(e) !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the row 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\n // in that case since the list should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n };\n\n let onKeyDown = e => {\n let activeElement = getActiveElement();\n if (\n !nodeContains(e.currentTarget, getEventTarget(e) as Element) ||\n !ref.current ||\n !activeElement\n ) {\n return;\n }\n\n switch (e.key) {\n case 'Tab': {\n if (keyboardNavigationBehavior === 'tab') {\n // If there is another focusable element within this item, stop propagation so the tab key\n // is handled by the browser and not by useSelectableCollection (which would take us out of the list).\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n walker.currentNode = activeElement;\n let next = e.shiftKey ? walker.previousNode() : walker.nextNode();\n\n if (next) {\n e.stopPropagation();\n }\n }\n }\n }\n };\n\n let syntheticLinkProps = useSyntheticLinkProps(node.props);\n let linkProps = itemStates.hasAction ? syntheticLinkProps : {};\n // TODO: re-add when we get translations and fix this for iOS VO\n // let rowAnnouncement;\n // if (onAction) {\n // rowAnnouncement = stringFormatter.format('hasActionAnnouncement');\n // } else if (hasLink) {\n // rowAnnouncement = stringFormatter.format('hasLinkAnnouncement', {\n // link: node.props.href\n // });\n // }\n\n let rowProps: DOMAttributes = mergeProps(itemProps, linkProps, {\n role: 'row',\n onKeyDownCapture,\n onKeyDown,\n onFocus,\n // 'aria-label': [(node.textValue || undefined), rowAnnouncement].filter(Boolean).join(', '),\n 'aria-label': node['aria-label'] || node.textValue || undefined,\n 'aria-selected': state.selectionManager.canSelectItem(node.key)\n ? state.selectionManager.isSelected(node.key)\n : undefined,\n 'aria-disabled': state.selectionManager.isDisabled(node.key) || undefined,\n 'aria-labelledby':\n descriptionId && (node['aria-label'] || node.textValue)\n ? `${getRowId(state, node.key)} ${descriptionId}`\n : undefined,\n id: getRowId(state, node.key)\n });\n\n if (isVirtualized) {\n let {collection} = state;\n let nodes = [...collection];\n // TODO: refactor ListCollection to store an absolute index of a node's position?\n rowProps['aria-rowindex'] = nodes.find(node => node.type === 'section')\n ? [...collection.getKeys()]\n .filter(key => collection.getItem(key)?.type !== 'section')\n .findIndex(key => key === node.key) + 1\n : node.index + 1;\n }\n\n let gridCellProps = {\n role: 'gridcell',\n 'aria-colindex': 1\n };\n\n // TODO: should isExpanded and hasChildRows be a item state that gets returned by the hook?\n return {\n rowProps: {...mergeProps(rowProps, treeGridRowProps)},\n gridCellProps,\n descriptionProps: {\n id: descriptionId\n },\n ...itemStates\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement | null = null;\n let last: FocusableElement | null = null;\n do {\n last = walker.lastChild() as FocusableElement | null;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n\nfunction getDirectChildren<T>(parent: RSNode<T>, collection: Collection<RSNode<T>>) {\n // We can't assume that we can use firstChildKey because if a person builds a tree using hooks, they would not have access to that property (using type Node vs CollectionNode)\n // Instead, get all children and start at the first node (rather than just using firstChildKey) and only look at its siblings\n let children = collection.getChildren?.(parent.key);\n let childArray = children ? Array.from(children) : [];\n let node = childArray.length > 0 ? childArray[0] : null;\n let siblings: RSNode<T>[] = [];\n while (node) {\n siblings.push(node);\n node = node.nextKey != null ? collection.getItem(node.nextKey) : null;\n }\n return siblings;\n}\n"],"names":[],"version":3,"file":"useGridListItem.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AA8DD,MAAM,uCAAiB;IACrB,QAAQ;QACN,KAAK;QACL,KAAK;IACP;IACA,UAAU;QACR,KAAK;QACL,KAAK;IACP;AACF;AASO,SAAS,0CACd,KAA8B,EAC9B,KAAkC,EAClC,GAAuC;IAEvC,+EAA+E;IAC/E,IAAI,QAAC,IAAI,iBAAE,aAAa,EAAC,GAAG;IAE5B,2FAA2F;IAC3F,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,mCAAQ;IAC1B,IAAI,YAAC,QAAQ,gBAAE,YAAY,8BAAE,0BAA0B,yBAAE,qBAAqB,EAAC,GAC7E,CAAA,GAAA,iCAAM,EAAE,GAAG,CAAC;IACd,IAAI,gBAAgB,CAAA,GAAA,mCAAQ;IAE5B,wF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U,CAAC,EAAE,GAAG;IACnD,IAAI,WAAwB,EAAE;IAC9B,MAAO,KAAM;QACX,SAAS,IAAI,CAAC;QACd,OAAO,KAAK,OAAO,IAAI,OAAO,WAAW,OAAO,CAAC,KAAK,OAAO,IAAI;IACnE;IACA,OAAO;AACT","sources":["packages/react-aria/src/gridlist/useGridListItem.ts"],"sourcesContent":["/*\n * Copyright 2022 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 '../utils/chain';\nimport {\n Collection,\n DOMAttributes,\n FocusableElement,\n Key,\n RefObject,\n Node as RSNode\n} from '@react-types/shared';\nimport {focusSafely} from '../interactions/focusSafely';\nimport {\n getActiveElement,\n getEventTarget,\n isFocusWithin,\n nodeContains\n} from '../utils/shadowdom/DOMFunctions';\nimport {getFocusableTreeWalker} from '../focus/FocusScope';\nimport {getRowId, listMap} from './utils';\nimport {getScrollParent} from '../utils/getScrollParent';\nimport {\n HTMLAttributes,\n KeyboardEvent as ReactKeyboardEvent,\n MouseEvent as ReactMouseEvent,\n PointerEvent as ReactPointerEvent,\n useRef\n} from 'react';\nimport {isFocusVisible} from '../interactions/useFocusVisible';\nimport {isTabbable} from '../utils/isFocusable';\nimport type {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {scrollIntoViewport} from '../utils/scrollIntoView';\nimport {SelectableItemStates, useSelectableItem} from '../selection/useSelectableItem';\nimport type {TreeState} from 'react-stately/useTreeState';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useSlotId} from '../utils/useId';\nimport {useSyntheticLinkProps} from '../utils/openLink';\n\nexport interface AriaGridListItemOptions {\n /**\n * An object representing the list item. Contains all the relevant information that makes up the\n * list row.\n */\n node: RSNode<unknown>;\n /** Whether the list 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 /** Whether this item has children, even if not loaded yet. */\n hasChildItems?: boolean;\n}\n\nexport interface GridListItemAria extends SelectableItemStates {\n /** Props for the list row element. */\n rowProps: DOMAttributes;\n /** Props for the grid cell element within the list row. */\n gridCellProps: DOMAttributes;\n /** Props for the list item description element, if any. */\n descriptionProps: DOMAttributes;\n}\n\nconst EXPANSION_KEYS = {\n expand: {\n ltr: 'ArrowRight',\n rtl: 'ArrowLeft'\n },\n collapse: {\n ltr: 'ArrowLeft',\n rtl: 'ArrowRight'\n }\n};\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid list.\n *\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useListState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useGridListItem<T>(\n props: AriaGridListItemOptions,\n state: ListState<T> | TreeState<T>,\n ref: RefObject<FocusableElement | null>\n): GridListItemAria {\n // Copied from useGridCell + some modifications to make it not so grid specific\n let {node, isVirtualized} = props;\n\n // let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/gridlist');\n let {direction} = useLocale();\n let {onAction, linkBehavior, keyboardNavigationBehavior, shouldSelectOnPressUp} =\n listMap.get(state)!;\n let descriptionId = useSlotId();\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<Key | null>(null);\n let focus = () => {\n // Don't shift focus to the row if the active element is a element within the row already\n // (e.g. clicking on a row button)\n if (\n ref.current !== null &&\n ((keyWhenFocused.current != null && node.key !== keyWhenFocused.current) ||\n !isFocusWithin(ref.current))\n ) {\n focusSafely(ref.current);\n }\n };\n\n let treeGridRowProps: HTMLAttributes<HTMLElement> = {};\n let hasChildRows = props.hasChildItems;\n let hasLink = state.selectionManager.isLink(node.key);\n if (node != null && 'expandedKeys' in state) {\n // 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\n // true...\n let children = state.collection.getChildren?.(node.key);\n hasChildRows = hasChildRows || [...(children ?? [])].length > 1;\n\n if (\n onAction == null &&\n !hasLink &&\n state.selectionManager.selectionMode === 'none' &&\n hasChildRows\n ) {\n onAction = () => state.toggleKey(node.key);\n }\n\n let isExpanded = hasChildRows ? state.expandedKeys.has(node.key) : undefined;\n let setSize = 1;\n let index = node.index;\n if (node.level >= 0 && node?.parentKey != null) {\n let parent = state.collection.getItem(node.parentKey);\n if (parent) {\n // siblings must exist because our original node exists\n let siblings = getDirectChildren(parent, state.collection);\n setSize = [...siblings].filter(row => row.type === 'item').length;\n if (index > 0 && siblings[0].type !== 'item') {\n index -= 1; // subtract one for the parent item's content node\n }\n }\n } else {\n setSize = [...state.collection].filter(row => row.level === 0 && row.type === 'item').length;\n }\n\n treeGridRowProps = {\n 'aria-expanded': isExpanded,\n 'aria-level': node.level + 1,\n 'aria-posinset': index + 1,\n 'aria-setsize': setSize\n };\n }\n\n let {itemProps, ...itemStates} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp || shouldSelectOnPressUp,\n onAction:\n onAction || node.props?.onAction\n ? chain(node.props?.onAction, onAction ? () => onAction(node.key) : undefined)\n : undefined,\n focus,\n linkBehavior\n });\n\n let onKeyDownCapture = (e: ReactKeyboardEvent) => {\n let activeElement = getActiveElement();\n if (\n !nodeContains(e.currentTarget, getEventTarget(e) as Element) ||\n !ref.current ||\n !activeElement\n ) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = activeElement;\n\n if (\n handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, ref.current)\n ) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowLeft': {\n if (keyboardNavigationBehavior === 'arrow') {\n // Find the next focusable element within the row.\n let focusable =\n direction === 'rtl'\n ? (walker.nextNode() as FocusableElement)\n : (walker.previousNode() as FocusableElement);\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n // If there is no next focusable child, then return focus back to the row\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n // oxlint-disable-next-line max-depth\n if (lastElement) {\n focusSafely(lastElement);\n scrollIntoViewport(lastElement, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n if (keyboardNavigationBehavior === 'arrow') {\n let focusable =\n direction === 'rtl'\n ? (walker.previousNode() as FocusableElement)\n : (walker.nextNode() as FocusableElement);\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'ltr') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n // oxlint-disable-next-line max-depth\n if (lastElement) {\n focusSafely(lastElement);\n scrollIntoViewport(lastElement, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching row children, e.g. menu buttons. We want arrow keys to navigate\n // to the row 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 && nodeContains(ref.current, getEventTarget(e) 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 let onFocus = e => {\n keyWhenFocused.current = node.key;\n if (getEventTarget(e) !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the row 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\n // in that case since the list should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n };\n\n let onKeyDown = (e: ReactKeyboardEvent) => {\n let activeElement = getActiveElement();\n if (\n !nodeContains(e.currentTarget, getEventTarget(e) as Element) ||\n !ref.current ||\n !activeElement\n ) {\n return;\n }\n\n if (keyboardNavigationBehavior === 'tab') {\n // Stop propagation for all events that originate from the children of the gridlist item since we don't want to trigger\n // grid level interactions (row navigation/typeselect/etc)\n // exception made for Tab since that needs to propagate to useSelectableCollection to tab out of the gridlist, might be others?\n if (getEventTarget(e) !== ref.current && e.key !== 'Tab') {\n e.stopPropagation();\n return;\n }\n\n if (\n handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, ref.current)\n ) {\n return;\n }\n }\n\n switch (e.key) {\n case 'Tab': {\n if (keyboardNavigationBehavior === 'tab') {\n // If there is another focusable element within this item, stop propagation so the tab key\n // is handled by the browser and not by useSelectableCollection (which would take us out of the list).\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n walker.currentNode = activeElement;\n let next = e.shiftKey ? walker.previousNode() : walker.nextNode();\n\n if (next) {\n e.stopPropagation();\n }\n }\n }\n }\n };\n\n let syntheticLinkProps = useSyntheticLinkProps(node.props);\n let linkProps = itemStates.hasAction ? syntheticLinkProps : {};\n // TODO: re-add when we get translations and fix this for iOS VO\n // let rowAnnouncement;\n // if (onAction) {\n // rowAnnouncement = stringFormatter.format('hasActionAnnouncement');\n // } else if (hasLink) {\n // rowAnnouncement = stringFormatter.format('hasLinkAnnouncement', {\n // link: node.props.href\n // });\n // }\n\n let rowProps: DOMAttributes = mergeProps(itemProps, linkProps, {\n role: 'row',\n onKeyDownCapture: keyboardNavigationBehavior === 'arrow' ? onKeyDownCapture : undefined,\n onFocus,\n // 'aria-label': [(node.textValue || undefined), rowAnnouncement].filter(Boolean).join(', '),\n 'aria-label': node['aria-label'] || node.textValue || undefined,\n 'aria-selected': state.selectionManager.canSelectItem(node.key)\n ? state.selectionManager.isSelected(node.key)\n : undefined,\n 'aria-disabled': state.selectionManager.isDisabled(node.key) || undefined,\n 'aria-labelledby':\n descriptionId && (node['aria-label'] || node.textValue)\n ? `${getRowId(state, node.key)} ${descriptionId}`\n : undefined,\n id: getRowId(state, node.key)\n });\n\n // we need to guard against space/enter triggering selection/row link via usePress (from itemProps) so check if propagation\n // is stopped. this also fixes space not working in a textfield in a tree parent row\n let baseOnKeyDown = rowProps.onKeyDown;\n rowProps.onKeyDown = (e: ReactKeyboardEvent<FocusableElement>) => {\n onKeyDown(e as ReactKeyboardEvent);\n if (!e.isPropagationStopped()) {\n baseOnKeyDown?.(e);\n }\n };\n\n // guard against presses triggering row selecition when they happen on elements within the row\n // am currently assuming if it is tabbable it is interactive, but maybe can use a different kind of check\n let baseOnPointerDown = rowProps.onPointerDown;\n rowProps.onPointerDown = (e: ReactPointerEvent<FocusableElement>) => {\n let target = getEventTarget(e) as Element | null;\n if (target && target !== ref.current && isTabbable(target)) {\n e.stopPropagation();\n return;\n }\n baseOnPointerDown?.(e);\n };\n\n let baseOnMouseDown = rowProps.onMouseDown;\n rowProps.onMouseDown = (e: ReactMouseEvent<FocusableElement>) => {\n let target = getEventTarget(e) as Element | null;\n if (target && target !== ref.current && isTabbable(target)) {\n e.stopPropagation();\n return;\n }\n baseOnMouseDown?.(e);\n };\n\n if (isVirtualized) {\n let {collection} = state;\n let nodes = [...collection];\n // TODO: refactor ListCollection to store an absolute index of a node's position?\n rowProps['aria-rowindex'] = nodes.find(node => node.type === 'section')\n ? [...collection.getKeys()]\n .filter(key => collection.getItem(key)?.type !== 'section')\n .findIndex(key => key === node.key) + 1\n : node.index + 1;\n }\n\n let gridCellProps = {\n role: 'gridcell',\n 'aria-colindex': 1\n };\n\n // TODO: should isExpanded and hasChildRows be a item state that gets returned by the hook?\n return {\n rowProps: {...mergeProps(rowProps, treeGridRowProps)},\n gridCellProps,\n descriptionProps: {\n id: descriptionId\n },\n ...itemStates\n };\n}\n\nfunction handleTreeExpansionKeys<T>(\n e: ReactKeyboardEvent,\n state: ListState<T> | TreeState<T>,\n node: RSNode<unknown>,\n hasChildRows: boolean | undefined,\n direction: string,\n activeElement: Element | null,\n rowRef: FocusableElement | null\n): boolean {\n if (!('expandedKeys' in state) || activeElement !== rowRef) {\n return false;\n }\n if (\n e.key === EXPANSION_KEYS['expand'][direction] &&\n state.selectionManager.focusedKey === node.key &&\n hasChildRows &&\n !state.expandedKeys.has(node.key)\n ) {\n state.toggleKey(node.key);\n e.stopPropagation();\n return true;\n } else if (\n e.key === EXPANSION_KEYS['collapse'][direction] &&\n state.selectionManager.focusedKey === node.key\n ) {\n // If item is collapsible, collapse it; else move to parent\n if (hasChildRows && state.expandedKeys.has(node.key)) {\n state.toggleKey(node.key);\n e.stopPropagation();\n return true;\n } else if (\n !state.expandedKeys.has(node.key) &&\n node.parentKey &&\n state.collection.getItem(node.parentKey)?.type === 'item'\n ) {\n // Item is a leaf or already collapsed, move focus to parent\n state.selectionManager.setFocusedKey(node.parentKey);\n e.stopPropagation();\n return true;\n }\n }\n return false;\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement | null = null;\n let last: FocusableElement | null = null;\n do {\n last = walker.lastChild() as FocusableElement | null;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n\nfunction getDirectChildren<T>(parent: RSNode<T>, collection: Collection<RSNode<T>>) {\n // We can't assume that we can use firstChildKey because if a person builds a tree using hooks, they would not have access to that property (using type Node vs CollectionNode)\n // Instead, get all children and start at the first node (rather than just using firstChildKey) and only look at its siblings\n let children = collection.getChildren?.(parent.key);\n let childArray = children ? Array.from(children) : [];\n let node = childArray.length > 0 ? childArray[0] : null;\n let siblings: RSNode<T>[] = [];\n while (node) {\n siblings.push(node);\n node = node.nextKey != null ? collection.getItem(node.nextKey) : null;\n }\n return siblings;\n}\n"],"names":[],"version":3,"file":"useGridListItem.cjs.map"}
|
|
@@ -5,6 +5,7 @@ import {getFocusableTreeWalker as $903814aeb7d53b38$export$2d6ec8fc375ceafa} fro
|
|
|
5
5
|
import {getRowId as $781ed2e01df48c52$export$f45c25170b9a99c2, listMap as $781ed2e01df48c52$export$5b9bb410392e3991} from "./utils.js";
|
|
6
6
|
import {getScrollParent as $5b46e0a1626c2890$export$cfa2225e87938781} from "../utils/getScrollParent.js";
|
|
7
7
|
import {isFocusVisible as $b50b1cc8a843ace7$export$b9b3dfddab17db27} from "../interactions/useFocusVisible.js";
|
|
8
|
+
import {isTabbable as $ee5e22534121197a$export$bebd5a1431fec25d} from "../utils/isFocusable.js";
|
|
8
9
|
import {mergeProps as $64c36edd757dfa16$export$9d1611c77c2fe928} from "../utils/mergeProps.js";
|
|
9
10
|
import {scrollIntoViewport as $6507765bd7f5ad94$export$c826860796309d1b} from "../utils/scrollIntoView.js";
|
|
10
11
|
import {useSelectableItem as $0d8cf6a15fe85601$export$ecf600387e221c37} from "../selection/useSelectableItem.js";
|
|
@@ -37,6 +38,7 @@ import {useRef as $45hvd$useRef} from "react";
|
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
|
|
41
|
+
|
|
40
42
|
const $7d08662b45460e3b$var$EXPANSION_KEYS = {
|
|
41
43
|
expand: {
|
|
42
44
|
ltr: 'ArrowRight',
|
|
@@ -113,26 +115,7 @@ function $7d08662b45460e3b$export$9610e69494fadfd2(props, state, ref) {
|
|
|
113
115
|
if (!(0, $d8ac7ed472840322$export$4282f70798064fe0)(e.currentTarget, (0, $d8ac7ed472840322$export$e58f029f0fbfdb29)(e)) || !ref.current || !activeElement) return;
|
|
114
116
|
let walker = (0, $903814aeb7d53b38$export$2d6ec8fc375ceafa)(ref.current);
|
|
115
117
|
walker.currentNode = activeElement;
|
|
116
|
-
if (
|
|
117
|
-
if (e.key === $7d08662b45460e3b$var$EXPANSION_KEYS['expand'][direction] && state.selectionManager.focusedKey === node.key && hasChildRows && !state.expandedKeys.has(node.key)) {
|
|
118
|
-
state.toggleKey(node.key);
|
|
119
|
-
e.stopPropagation();
|
|
120
|
-
return;
|
|
121
|
-
} else if (e.key === $7d08662b45460e3b$var$EXPANSION_KEYS['collapse'][direction] && state.selectionManager.focusedKey === node.key) {
|
|
122
|
-
var _state_collection_getItem;
|
|
123
|
-
// If item is collapsible, collapse it; else move to parent
|
|
124
|
-
if (hasChildRows && state.expandedKeys.has(node.key)) {
|
|
125
|
-
state.toggleKey(node.key);
|
|
126
|
-
e.stopPropagation();
|
|
127
|
-
return;
|
|
128
|
-
} else if (!state.expandedKeys.has(node.key) && node.parentKey && ((_state_collection_getItem = state.collection.getItem(node.parentKey)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.type) === 'item') {
|
|
129
|
-
// Item is a leaf or already collapsed, move focus to parent
|
|
130
|
-
state.selectionManager.setFocusedKey(node.parentKey);
|
|
131
|
-
e.stopPropagation();
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
118
|
+
if ($7d08662b45460e3b$var$handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, ref.current)) return;
|
|
136
119
|
switch(e.key){
|
|
137
120
|
case 'ArrowLeft':
|
|
138
121
|
if (keyboardNavigationBehavior === 'arrow') {
|
|
@@ -230,6 +213,16 @@ function $7d08662b45460e3b$export$9610e69494fadfd2(props, state, ref) {
|
|
|
230
213
|
let onKeyDown = (e)=>{
|
|
231
214
|
let activeElement = (0, $d8ac7ed472840322$export$cd4e5573fbe2b576)();
|
|
232
215
|
if (!(0, $d8ac7ed472840322$export$4282f70798064fe0)(e.currentTarget, (0, $d8ac7ed472840322$export$e58f029f0fbfdb29)(e)) || !ref.current || !activeElement) return;
|
|
216
|
+
if (keyboardNavigationBehavior === 'tab') {
|
|
217
|
+
// Stop propagation for all events that originate from the children of the gridlist item since we don't want to trigger
|
|
218
|
+
// grid level interactions (row navigation/typeselect/etc)
|
|
219
|
+
// exception made for Tab since that needs to propagate to useSelectableCollection to tab out of the gridlist, might be others?
|
|
220
|
+
if ((0, $d8ac7ed472840322$export$e58f029f0fbfdb29)(e) !== ref.current && e.key !== 'Tab') {
|
|
221
|
+
e.stopPropagation();
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if ($7d08662b45460e3b$var$handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, ref.current)) return;
|
|
225
|
+
}
|
|
233
226
|
switch(e.key){
|
|
234
227
|
case 'Tab':
|
|
235
228
|
if (keyboardNavigationBehavior === 'tab') {
|
|
@@ -257,8 +250,7 @@ function $7d08662b45460e3b$export$9610e69494fadfd2(props, state, ref) {
|
|
|
257
250
|
// }
|
|
258
251
|
let rowProps = (0, $64c36edd757dfa16$export$9d1611c77c2fe928)(itemProps, linkProps, {
|
|
259
252
|
role: 'row',
|
|
260
|
-
onKeyDownCapture: onKeyDownCapture,
|
|
261
|
-
onKeyDown: onKeyDown,
|
|
253
|
+
onKeyDownCapture: keyboardNavigationBehavior === 'arrow' ? onKeyDownCapture : undefined,
|
|
262
254
|
onFocus: onFocus,
|
|
263
255
|
// 'aria-label': [(node.textValue || undefined), rowAnnouncement].filter(Boolean).join(', '),
|
|
264
256
|
'aria-label': node['aria-label'] || node.textValue || undefined,
|
|
@@ -267,6 +259,33 @@ function $7d08662b45460e3b$export$9610e69494fadfd2(props, state, ref) {
|
|
|
267
259
|
'aria-labelledby': descriptionId && (node['aria-label'] || node.textValue) ? `${(0, $781ed2e01df48c52$export$f45c25170b9a99c2)(state, node.key)} ${descriptionId}` : undefined,
|
|
268
260
|
id: (0, $781ed2e01df48c52$export$f45c25170b9a99c2)(state, node.key)
|
|
269
261
|
});
|
|
262
|
+
// we need to guard against space/enter triggering selection/row link via usePress (from itemProps) so check if propagation
|
|
263
|
+
// is stopped. this also fixes space not working in a textfield in a tree parent row
|
|
264
|
+
let baseOnKeyDown = rowProps.onKeyDown;
|
|
265
|
+
rowProps.onKeyDown = (e)=>{
|
|
266
|
+
onKeyDown(e);
|
|
267
|
+
if (!e.isPropagationStopped()) baseOnKeyDown === null || baseOnKeyDown === void 0 ? void 0 : baseOnKeyDown(e);
|
|
268
|
+
};
|
|
269
|
+
// guard against presses triggering row selecition when they happen on elements within the row
|
|
270
|
+
// am currently assuming if it is tabbable it is interactive, but maybe can use a different kind of check
|
|
271
|
+
let baseOnPointerDown = rowProps.onPointerDown;
|
|
272
|
+
rowProps.onPointerDown = (e)=>{
|
|
273
|
+
let target = (0, $d8ac7ed472840322$export$e58f029f0fbfdb29)(e);
|
|
274
|
+
if (target && target !== ref.current && (0, $ee5e22534121197a$export$bebd5a1431fec25d)(target)) {
|
|
275
|
+
e.stopPropagation();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
baseOnPointerDown === null || baseOnPointerDown === void 0 ? void 0 : baseOnPointerDown(e);
|
|
279
|
+
};
|
|
280
|
+
let baseOnMouseDown = rowProps.onMouseDown;
|
|
281
|
+
rowProps.onMouseDown = (e)=>{
|
|
282
|
+
let target = (0, $d8ac7ed472840322$export$e58f029f0fbfdb29)(e);
|
|
283
|
+
if (target && target !== ref.current && (0, $ee5e22534121197a$export$bebd5a1431fec25d)(target)) {
|
|
284
|
+
e.stopPropagation();
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
baseOnMouseDown === null || baseOnMouseDown === void 0 ? void 0 : baseOnMouseDown(e);
|
|
288
|
+
};
|
|
270
289
|
if (isVirtualized) {
|
|
271
290
|
let { collection: collection } = state;
|
|
272
291
|
let nodes = [
|
|
@@ -296,6 +315,28 @@ function $7d08662b45460e3b$export$9610e69494fadfd2(props, state, ref) {
|
|
|
296
315
|
...itemStates
|
|
297
316
|
};
|
|
298
317
|
}
|
|
318
|
+
function $7d08662b45460e3b$var$handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, rowRef) {
|
|
319
|
+
if (!('expandedKeys' in state) || activeElement !== rowRef) return false;
|
|
320
|
+
if (e.key === $7d08662b45460e3b$var$EXPANSION_KEYS['expand'][direction] && state.selectionManager.focusedKey === node.key && hasChildRows && !state.expandedKeys.has(node.key)) {
|
|
321
|
+
state.toggleKey(node.key);
|
|
322
|
+
e.stopPropagation();
|
|
323
|
+
return true;
|
|
324
|
+
} else if (e.key === $7d08662b45460e3b$var$EXPANSION_KEYS['collapse'][direction] && state.selectionManager.focusedKey === node.key) {
|
|
325
|
+
var _state_collection_getItem;
|
|
326
|
+
// If item is collapsible, collapse it; else move to parent
|
|
327
|
+
if (hasChildRows && state.expandedKeys.has(node.key)) {
|
|
328
|
+
state.toggleKey(node.key);
|
|
329
|
+
e.stopPropagation();
|
|
330
|
+
return true;
|
|
331
|
+
} else if (!state.expandedKeys.has(node.key) && node.parentKey && ((_state_collection_getItem = state.collection.getItem(node.parentKey)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.type) === 'item') {
|
|
332
|
+
// Item is a leaf or already collapsed, move focus to parent
|
|
333
|
+
state.selectionManager.setFocusedKey(node.parentKey);
|
|
334
|
+
e.stopPropagation();
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
299
340
|
function $7d08662b45460e3b$var$last(walker) {
|
|
300
341
|
let next = null;
|
|
301
342
|
let last = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAwDD,MAAM,uCAAiB;IACrB,QAAQ;QACN,KAAK;QACL,KAAK;IACP;IACA,UAAU;QACR,KAAK;QACL,KAAK;IACP;AACF;AASO,SAAS,0CACd,KAA8B,EAC9B,KAAkC,EAClC,GAAuC;QA4EvB,aACF;IA3Ed,+EAA+E;IA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,MAAO,QAAQ,KAAK,GAAG,IAAI,IACxC,KAAK,KAAK,GAAG;IACnB;IAEA,IAAI,gBAAgB;QAClB,MAAM;QACN,iBAAiB;IACnB;IAEA,2FAA2F;IAC3F,OAAO;QACL,UAAU;YAAC,GAAG,CAAA,GAAA,yCAAS,EAAE,UAAU,iBAAiB;QAAA;uBACpD;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,GAAG,UAAU;IACf;AACF;AAEA,SAAS,2BAAK,MAAkB;IAC9B,IAAI,OAAgC;IACpC,IAAI,OAAgC;IACpC,GAAG;QACD,OAAO,OAAO,SAAS;QACvB,IAAI,MACF,OAAO;IAEX,QAAS,MAAM;IACf,OAAO;AACT;AAEA,SAAS,wCAAqB,MAAiB,EAAE,UAAiC;QAGjE;IAFf,+KAA+K;IAC/K,6HAA6H;IAC7H,IAAI,YAAW,0BAAA,WAAW,WAAW,cAAtB,8CAAA,6BAAA,YAAyB,OAAO,GAAG;IAClD,IAAI,aAAa,WAAW,MAAM,IAAI,CAAC,YAAY,EAAE;IACrD,IAAI,OAAO,WAAW,MAAM,GAAG,IAAI,UAAU,CAAC,EAAE,GAAG;IACnD,IAAI,WAAwB,EAAE;IAC9B,MAAO,KAAM;QACX,SAAS,IAAI,CAAC;QACd,OAAO,KAAK,OAAO,IAAI,OAAO,WAAW,OAAO,CAAC,KAAK,OAAO,IAAI;IACnE;IACA,OAAO;AACT","sources":["packages/react-aria/src/gridlist/useGridListItem.ts"],"sourcesContent":["/*\n * Copyright 2022 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 '../utils/chain';\n\nimport {\n Collection,\n DOMAttributes,\n FocusableElement,\n Key,\n RefObject,\n Node as RSNode\n} from '@react-types/shared';\nimport {focusSafely} from '../interactions/focusSafely';\nimport {\n getActiveElement,\n getEventTarget,\n isFocusWithin,\n nodeContains\n} from '../utils/shadowdom/DOMFunctions';\nimport {getFocusableTreeWalker} from '../focus/FocusScope';\nimport {getRowId, listMap} from './utils';\nimport {getScrollParent} from '../utils/getScrollParent';\nimport {HTMLAttributes, KeyboardEvent as ReactKeyboardEvent, useRef} from 'react';\nimport {isFocusVisible} from '../interactions/useFocusVisible';\nimport type {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {scrollIntoViewport} from '../utils/scrollIntoView';\nimport {SelectableItemStates, useSelectableItem} from '../selection/useSelectableItem';\nimport type {TreeState} from 'react-stately/useTreeState';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useSlotId} from '../utils/useId';\nimport {useSyntheticLinkProps} from '../utils/openLink';\n\nexport interface AriaGridListItemOptions {\n /**\n * An object representing the list item. Contains all the relevant information that makes up the\n * list row.\n */\n node: RSNode<unknown>;\n /** Whether the list 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 /** Whether this item has children, even if not loaded yet. */\n hasChildItems?: boolean;\n}\n\nexport interface GridListItemAria extends SelectableItemStates {\n /** Props for the list row element. */\n rowProps: DOMAttributes;\n /** Props for the grid cell element within the list row. */\n gridCellProps: DOMAttributes;\n /** Props for the list item description element, if any. */\n descriptionProps: DOMAttributes;\n}\n\nconst EXPANSION_KEYS = {\n expand: {\n ltr: 'ArrowRight',\n rtl: 'ArrowLeft'\n },\n collapse: {\n ltr: 'ArrowLeft',\n rtl: 'ArrowRight'\n }\n};\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid list.\n *\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useListState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useGridListItem<T>(\n props: AriaGridListItemOptions,\n state: ListState<T> | TreeState<T>,\n ref: RefObject<FocusableElement | null>\n): GridListItemAria {\n // Copied from useGridCell + some modifications to make it not so grid specific\n let {node, isVirtualized} = props;\n\n // let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/gridlist');\n let {direction} = useLocale();\n let {onAction, linkBehavior, keyboardNavigationBehavior, shouldSelectOnPressUp} =\n listMap.get(state)!;\n let descriptionId = useSlotId();\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<Key | null>(null);\n let focus = () => {\n // Don't shift focus to the row if the active element is a element within the row already\n // (e.g. clicking on a row button)\n if (\n ref.current !== null &&\n ((keyWhenFocused.current != null && node.key !== keyWhenFocused.current) ||\n !isFocusWithin(ref.current))\n ) {\n focusSafely(ref.current);\n }\n };\n\n let treeGridRowProps: HTMLAttributes<HTMLElement> = {};\n let hasChildRows = props.hasChildItems;\n let hasLink = state.selectionManager.isLink(node.key);\n if (node != null && 'expandedKeys' in state) {\n // 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\n // true...\n let children = state.collection.getChildren?.(node.key);\n hasChildRows = hasChildRows || [...(children ?? [])].length > 1;\n\n if (\n onAction == null &&\n !hasLink &&\n state.selectionManager.selectionMode === 'none' &&\n hasChildRows\n ) {\n onAction = () => state.toggleKey(node.key);\n }\n\n let isExpanded = hasChildRows ? state.expandedKeys.has(node.key) : undefined;\n let setSize = 1;\n let index = node.index;\n if (node.level >= 0 && node?.parentKey != null) {\n let parent = state.collection.getItem(node.parentKey);\n if (parent) {\n // siblings must exist because our original node exists\n let siblings = getDirectChildren(parent, state.collection);\n setSize = [...siblings].filter(row => row.type === 'item').length;\n if (index > 0 && siblings[0].type !== 'item') {\n index -= 1; // subtract one for the parent item's content node\n }\n }\n } else {\n setSize = [...state.collection].filter(row => row.level === 0 && row.type === 'item').length;\n }\n\n treeGridRowProps = {\n 'aria-expanded': isExpanded,\n 'aria-level': node.level + 1,\n 'aria-posinset': index + 1,\n 'aria-setsize': setSize\n };\n }\n\n let {itemProps, ...itemStates} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp || shouldSelectOnPressUp,\n onAction:\n onAction || node.props?.onAction\n ? chain(node.props?.onAction, onAction ? () => onAction(node.key) : undefined)\n : undefined,\n focus,\n linkBehavior\n });\n\n let onKeyDownCapture = (e: ReactKeyboardEvent) => {\n let activeElement = getActiveElement();\n if (\n !nodeContains(e.currentTarget, getEventTarget(e) as Element) ||\n !ref.current ||\n !activeElement\n ) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = activeElement;\n\n if ('expandedKeys' in state && activeElement === ref.current) {\n if (\n e.key === EXPANSION_KEYS['expand'][direction] &&\n state.selectionManager.focusedKey === node.key &&\n hasChildRows &&\n !state.expandedKeys.has(node.key)\n ) {\n state.toggleKey(node.key);\n e.stopPropagation();\n return;\n } else if (\n e.key === EXPANSION_KEYS['collapse'][direction] &&\n state.selectionManager.focusedKey === node.key\n ) {\n // If item is collapsible, collapse it; else move to parent\n if (hasChildRows && state.expandedKeys.has(node.key)) {\n state.toggleKey(node.key);\n e.stopPropagation();\n return;\n } else if (\n !state.expandedKeys.has(node.key) &&\n node.parentKey &&\n state.collection.getItem(node.parentKey)?.type === 'item'\n ) {\n // Item is a leaf or already collapsed, move focus to parent\n state.selectionManager.setFocusedKey(node.parentKey);\n e.stopPropagation();\n return;\n }\n }\n }\n\n switch (e.key) {\n case 'ArrowLeft': {\n if (keyboardNavigationBehavior === 'arrow') {\n // Find the next focusable element within the row.\n let focusable =\n direction === 'rtl'\n ? (walker.nextNode() as FocusableElement)\n : (walker.previousNode() as FocusableElement);\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n // If there is no next focusable child, then return focus back to the row\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n // oxlint-disable-next-line max-depth\n if (lastElement) {\n focusSafely(lastElement);\n scrollIntoViewport(lastElement, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n if (keyboardNavigationBehavior === 'arrow') {\n let focusable =\n direction === 'rtl'\n ? (walker.previousNode() as FocusableElement)\n : (walker.nextNode() as FocusableElement);\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'ltr') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n // oxlint-disable-next-line max-depth\n if (lastElement) {\n focusSafely(lastElement);\n scrollIntoViewport(lastElement, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching row children, e.g. menu buttons. We want arrow keys to navigate\n // to the row 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 && nodeContains(ref.current, getEventTarget(e) 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 let onFocus = e => {\n keyWhenFocused.current = node.key;\n if (getEventTarget(e) !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the row 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\n // in that case since the list should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n };\n\n let onKeyDown = e => {\n let activeElement = getActiveElement();\n if (\n !nodeContains(e.currentTarget, getEventTarget(e) as Element) ||\n !ref.current ||\n !activeElement\n ) {\n return;\n }\n\n switch (e.key) {\n case 'Tab': {\n if (keyboardNavigationBehavior === 'tab') {\n // If there is another focusable element within this item, stop propagation so the tab key\n // is handled by the browser and not by useSelectableCollection (which would take us out of the list).\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n walker.currentNode = activeElement;\n let next = e.shiftKey ? walker.previousNode() : walker.nextNode();\n\n if (next) {\n e.stopPropagation();\n }\n }\n }\n }\n };\n\n let syntheticLinkProps = useSyntheticLinkProps(node.props);\n let linkProps = itemStates.hasAction ? syntheticLinkProps : {};\n // TODO: re-add when we get translations and fix this for iOS VO\n // let rowAnnouncement;\n // if (onAction) {\n // rowAnnouncement = stringFormatter.format('hasActionAnnouncement');\n // } else if (hasLink) {\n // rowAnnouncement = stringFormatter.format('hasLinkAnnouncement', {\n // link: node.props.href\n // });\n // }\n\n let rowProps: DOMAttributes = mergeProps(itemProps, linkProps, {\n role: 'row',\n onKeyDownCapture,\n onKeyDown,\n onFocus,\n // 'aria-label': [(node.textValue || undefined), rowAnnouncement].filter(Boolean).join(', '),\n 'aria-label': node['aria-label'] || node.textValue || undefined,\n 'aria-selected': state.selectionManager.canSelectItem(node.key)\n ? state.selectionManager.isSelected(node.key)\n : undefined,\n 'aria-disabled': state.selectionManager.isDisabled(node.key) || undefined,\n 'aria-labelledby':\n descriptionId && (node['aria-label'] || node.textValue)\n ? `${getRowId(state, node.key)} ${descriptionId}`\n : undefined,\n id: getRowId(state, node.key)\n });\n\n if (isVirtualized) {\n let {collection} = state;\n let nodes = [...collection];\n // TODO: refactor ListCollection to store an absolute index of a node's position?\n rowProps['aria-rowindex'] = nodes.find(node => node.type === 'section')\n ? [...collection.getKeys()]\n .filter(key => collection.getItem(key)?.type !== 'section')\n .findIndex(key => key === node.key) + 1\n : node.index + 1;\n }\n\n let gridCellProps = {\n role: 'gridcell',\n 'aria-colindex': 1\n };\n\n // TODO: should isExpanded and hasChildRows be a item state that gets returned by the hook?\n return {\n rowProps: {...mergeProps(rowProps, treeGridRowProps)},\n gridCellProps,\n descriptionProps: {\n id: descriptionId\n },\n ...itemStates\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement | null = null;\n let last: FocusableElement | null = null;\n do {\n last = walker.lastChild() as FocusableElement | null;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n\nfunction getDirectChildren<T>(parent: RSNode<T>, collection: Collection<RSNode<T>>) {\n // We can't assume that we can use firstChildKey because if a person builds a tree using hooks, they would not have access to that property (using type Node vs CollectionNode)\n // Instead, get all children and start at the first node (rather than just using firstChildKey) and only look at its siblings\n let children = collection.getChildren?.(parent.key);\n let childArray = children ? Array.from(children) : [];\n let node = childArray.length > 0 ? childArray[0] : null;\n let siblings: RSNode<T>[] = [];\n while (node) {\n siblings.push(node);\n node = node.nextKey != null ? collection.getItem(node.nextKey) : null;\n }\n return siblings;\n}\n"],"names":[],"version":3,"file":"useGridListItem.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AA8DD,MAAM,uCAAiB;IACrB,QAAQ;QACN,KAAK;QACL,KAAK;IACP;IACA,UAAU;QACR,KAAK;QACL,KAAK;IACP;AACF;AASO,SAAS,0CACd,KAA8B,EAC9B,KAAkC,EAClC,GAAuC;QA4EvB,aACF;IA3Ed,+EAA+E;IAC/E,IAAI,QAAC,IAAI,iBAAE,aAAa,EAAC,GAAG;IAE5B,2FAA2F;IAC3F,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAQ;IAC1B,IAAI,YAAC,QAAQ,gBAAE,YAAY,8BAAE,0BAA0B,yBAAE,qBAAqB,EAAC,G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B,OAAO;QACT;IACF;IACA,OAAO;AACT;AAEA,SAAS,2BAAK,MAAkB;IAC9B,IAAI,OAAgC;IACpC,IAAI,OAAgC;IACpC,GAAG;QACD,OAAO,OAAO,SAAS;QACvB,IAAI,MACF,OAAO;IAEX,QAAS,MAAM;IACf,OAAO;AACT;AAEA,SAAS,wCAAqB,MAAiB,EAAE,UAAiC;QAGjE;IAFf,+KAA+K;IAC/K,6HAA6H;IAC7H,IAAI,YAAW,0BAAA,WAAW,WAAW,cAAtB,8CAAA,6BAAA,YAAyB,OAAO,GAAG;IAClD,IAAI,aAAa,WAAW,MAAM,IAAI,CAAC,YAAY,EAAE;IACrD,IAAI,OAAO,WAAW,MAAM,GAAG,IAAI,UAAU,CAAC,EAAE,GAAG;IACnD,IAAI,WAAwB,EAAE;IAC9B,MAAO,KAAM;QACX,SAAS,IAAI,CAAC;QACd,OAAO,KAAK,OAAO,IAAI,OAAO,WAAW,OAAO,CAAC,KAAK,OAAO,IAAI;IACnE;IACA,OAAO;AACT","sources":["packages/react-aria/src/gridlist/useGridListItem.ts"],"sourcesContent":["/*\n * Copyright 2022 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 '../utils/chain';\nimport {\n Collection,\n DOMAttributes,\n FocusableElement,\n Key,\n RefObject,\n Node as RSNode\n} from '@react-types/shared';\nimport {focusSafely} from '../interactions/focusSafely';\nimport {\n getActiveElement,\n getEventTarget,\n isFocusWithin,\n nodeContains\n} from '../utils/shadowdom/DOMFunctions';\nimport {getFocusableTreeWalker} from '../focus/FocusScope';\nimport {getRowId, listMap} from './utils';\nimport {getScrollParent} from '../utils/getScrollParent';\nimport {\n HTMLAttributes,\n KeyboardEvent as ReactKeyboardEvent,\n MouseEvent as ReactMouseEvent,\n PointerEvent as ReactPointerEvent,\n useRef\n} from 'react';\nimport {isFocusVisible} from '../interactions/useFocusVisible';\nimport {isTabbable} from '../utils/isFocusable';\nimport type {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {scrollIntoViewport} from '../utils/scrollIntoView';\nimport {SelectableItemStates, useSelectableItem} from '../selection/useSelectableItem';\nimport type {TreeState} from 'react-stately/useTreeState';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useSlotId} from '../utils/useId';\nimport {useSyntheticLinkProps} from '../utils/openLink';\n\nexport interface AriaGridListItemOptions {\n /**\n * An object representing the list item. Contains all the relevant information that makes up the\n * list row.\n */\n node: RSNode<unknown>;\n /** Whether the list 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 /** Whether this item has children, even if not loaded yet. */\n hasChildItems?: boolean;\n}\n\nexport interface GridListItemAria extends SelectableItemStates {\n /** Props for the list row element. */\n rowProps: DOMAttributes;\n /** Props for the grid cell element within the list row. */\n gridCellProps: DOMAttributes;\n /** Props for the list item description element, if any. */\n descriptionProps: DOMAttributes;\n}\n\nconst EXPANSION_KEYS = {\n expand: {\n ltr: 'ArrowRight',\n rtl: 'ArrowLeft'\n },\n collapse: {\n ltr: 'ArrowLeft',\n rtl: 'ArrowRight'\n }\n};\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid list.\n *\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useListState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useGridListItem<T>(\n props: AriaGridListItemOptions,\n state: ListState<T> | TreeState<T>,\n ref: RefObject<FocusableElement | null>\n): GridListItemAria {\n // Copied from useGridCell + some modifications to make it not so grid specific\n let {node, isVirtualized} = props;\n\n // let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/gridlist');\n let {direction} = useLocale();\n let {onAction, linkBehavior, keyboardNavigationBehavior, shouldSelectOnPressUp} =\n listMap.get(state)!;\n let descriptionId = useSlotId();\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<Key | null>(null);\n let focus = () => {\n // Don't shift focus to the row if the active element is a element within the row already\n // (e.g. clicking on a row button)\n if (\n ref.current !== null &&\n ((keyWhenFocused.current != null && node.key !== keyWhenFocused.current) ||\n !isFocusWithin(ref.current))\n ) {\n focusSafely(ref.current);\n }\n };\n\n let treeGridRowProps: HTMLAttributes<HTMLElement> = {};\n let hasChildRows = props.hasChildItems;\n let hasLink = state.selectionManager.isLink(node.key);\n if (node != null && 'expandedKeys' in state) {\n // 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\n // true...\n let children = state.collection.getChildren?.(node.key);\n hasChildRows = hasChildRows || [...(children ?? [])].length > 1;\n\n if (\n onAction == null &&\n !hasLink &&\n state.selectionManager.selectionMode === 'none' &&\n hasChildRows\n ) {\n onAction = () => state.toggleKey(node.key);\n }\n\n let isExpanded = hasChildRows ? state.expandedKeys.has(node.key) : undefined;\n let setSize = 1;\n let index = node.index;\n if (node.level >= 0 && node?.parentKey != null) {\n let parent = state.collection.getItem(node.parentKey);\n if (parent) {\n // siblings must exist because our original node exists\n let siblings = getDirectChildren(parent, state.collection);\n setSize = [...siblings].filter(row => row.type === 'item').length;\n if (index > 0 && siblings[0].type !== 'item') {\n index -= 1; // subtract one for the parent item's content node\n }\n }\n } else {\n setSize = [...state.collection].filter(row => row.level === 0 && row.type === 'item').length;\n }\n\n treeGridRowProps = {\n 'aria-expanded': isExpanded,\n 'aria-level': node.level + 1,\n 'aria-posinset': index + 1,\n 'aria-setsize': setSize\n };\n }\n\n let {itemProps, ...itemStates} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp || shouldSelectOnPressUp,\n onAction:\n onAction || node.props?.onAction\n ? chain(node.props?.onAction, onAction ? () => onAction(node.key) : undefined)\n : undefined,\n focus,\n linkBehavior\n });\n\n let onKeyDownCapture = (e: ReactKeyboardEvent) => {\n let activeElement = getActiveElement();\n if (\n !nodeContains(e.currentTarget, getEventTarget(e) as Element) ||\n !ref.current ||\n !activeElement\n ) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = activeElement;\n\n if (\n handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, ref.current)\n ) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowLeft': {\n if (keyboardNavigationBehavior === 'arrow') {\n // Find the next focusable element within the row.\n let focusable =\n direction === 'rtl'\n ? (walker.nextNode() as FocusableElement)\n : (walker.previousNode() as FocusableElement);\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n // If there is no next focusable child, then return focus back to the row\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n // oxlint-disable-next-line max-depth\n if (lastElement) {\n focusSafely(lastElement);\n scrollIntoViewport(lastElement, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n if (keyboardNavigationBehavior === 'arrow') {\n let focusable =\n direction === 'rtl'\n ? (walker.previousNode() as FocusableElement)\n : (walker.nextNode() as FocusableElement);\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n scrollIntoViewport(focusable, {containingElement: getScrollParent(ref.current)});\n } else {\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'ltr') {\n focusSafely(ref.current);\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n // oxlint-disable-next-line max-depth\n if (lastElement) {\n focusSafely(lastElement);\n scrollIntoViewport(lastElement, {containingElement: getScrollParent(ref.current)});\n }\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching row children, e.g. menu buttons. We want arrow keys to navigate\n // to the row 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 && nodeContains(ref.current, getEventTarget(e) 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 let onFocus = e => {\n keyWhenFocused.current = node.key;\n if (getEventTarget(e) !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the row 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\n // in that case since the list should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n };\n\n let onKeyDown = (e: ReactKeyboardEvent) => {\n let activeElement = getActiveElement();\n if (\n !nodeContains(e.currentTarget, getEventTarget(e) as Element) ||\n !ref.current ||\n !activeElement\n ) {\n return;\n }\n\n if (keyboardNavigationBehavior === 'tab') {\n // Stop propagation for all events that originate from the children of the gridlist item since we don't want to trigger\n // grid level interactions (row navigation/typeselect/etc)\n // exception made for Tab since that needs to propagate to useSelectableCollection to tab out of the gridlist, might be others?\n if (getEventTarget(e) !== ref.current && e.key !== 'Tab') {\n e.stopPropagation();\n return;\n }\n\n if (\n handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, ref.current)\n ) {\n return;\n }\n }\n\n switch (e.key) {\n case 'Tab': {\n if (keyboardNavigationBehavior === 'tab') {\n // If there is another focusable element within this item, stop propagation so the tab key\n // is handled by the browser and not by useSelectableCollection (which would take us out of the list).\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n walker.currentNode = activeElement;\n let next = e.shiftKey ? walker.previousNode() : walker.nextNode();\n\n if (next) {\n e.stopPropagation();\n }\n }\n }\n }\n };\n\n let syntheticLinkProps = useSyntheticLinkProps(node.props);\n let linkProps = itemStates.hasAction ? syntheticLinkProps : {};\n // TODO: re-add when we get translations and fix this for iOS VO\n // let rowAnnouncement;\n // if (onAction) {\n // rowAnnouncement = stringFormatter.format('hasActionAnnouncement');\n // } else if (hasLink) {\n // rowAnnouncement = stringFormatter.format('hasLinkAnnouncement', {\n // link: node.props.href\n // });\n // }\n\n let rowProps: DOMAttributes = mergeProps(itemProps, linkProps, {\n role: 'row',\n onKeyDownCapture: keyboardNavigationBehavior === 'arrow' ? onKeyDownCapture : undefined,\n onFocus,\n // 'aria-label': [(node.textValue || undefined), rowAnnouncement].filter(Boolean).join(', '),\n 'aria-label': node['aria-label'] || node.textValue || undefined,\n 'aria-selected': state.selectionManager.canSelectItem(node.key)\n ? state.selectionManager.isSelected(node.key)\n : undefined,\n 'aria-disabled': state.selectionManager.isDisabled(node.key) || undefined,\n 'aria-labelledby':\n descriptionId && (node['aria-label'] || node.textValue)\n ? `${getRowId(state, node.key)} ${descriptionId}`\n : undefined,\n id: getRowId(state, node.key)\n });\n\n // we need to guard against space/enter triggering selection/row link via usePress (from itemProps) so check if propagation\n // is stopped. this also fixes space not working in a textfield in a tree parent row\n let baseOnKeyDown = rowProps.onKeyDown;\n rowProps.onKeyDown = (e: ReactKeyboardEvent<FocusableElement>) => {\n onKeyDown(e as ReactKeyboardEvent);\n if (!e.isPropagationStopped()) {\n baseOnKeyDown?.(e);\n }\n };\n\n // guard against presses triggering row selecition when they happen on elements within the row\n // am currently assuming if it is tabbable it is interactive, but maybe can use a different kind of check\n let baseOnPointerDown = rowProps.onPointerDown;\n rowProps.onPointerDown = (e: ReactPointerEvent<FocusableElement>) => {\n let target = getEventTarget(e) as Element | null;\n if (target && target !== ref.current && isTabbable(target)) {\n e.stopPropagation();\n return;\n }\n baseOnPointerDown?.(e);\n };\n\n let baseOnMouseDown = rowProps.onMouseDown;\n rowProps.onMouseDown = (e: ReactMouseEvent<FocusableElement>) => {\n let target = getEventTarget(e) as Element | null;\n if (target && target !== ref.current && isTabbable(target)) {\n e.stopPropagation();\n return;\n }\n baseOnMouseDown?.(e);\n };\n\n if (isVirtualized) {\n let {collection} = state;\n let nodes = [...collection];\n // TODO: refactor ListCollection to store an absolute index of a node's position?\n rowProps['aria-rowindex'] = nodes.find(node => node.type === 'section')\n ? [...collection.getKeys()]\n .filter(key => collection.getItem(key)?.type !== 'section')\n .findIndex(key => key === node.key) + 1\n : node.index + 1;\n }\n\n let gridCellProps = {\n role: 'gridcell',\n 'aria-colindex': 1\n };\n\n // TODO: should isExpanded and hasChildRows be a item state that gets returned by the hook?\n return {\n rowProps: {...mergeProps(rowProps, treeGridRowProps)},\n gridCellProps,\n descriptionProps: {\n id: descriptionId\n },\n ...itemStates\n };\n}\n\nfunction handleTreeExpansionKeys<T>(\n e: ReactKeyboardEvent,\n state: ListState<T> | TreeState<T>,\n node: RSNode<unknown>,\n hasChildRows: boolean | undefined,\n direction: string,\n activeElement: Element | null,\n rowRef: FocusableElement | null\n): boolean {\n if (!('expandedKeys' in state) || activeElement !== rowRef) {\n return false;\n }\n if (\n e.key === EXPANSION_KEYS['expand'][direction] &&\n state.selectionManager.focusedKey === node.key &&\n hasChildRows &&\n !state.expandedKeys.has(node.key)\n ) {\n state.toggleKey(node.key);\n e.stopPropagation();\n return true;\n } else if (\n e.key === EXPANSION_KEYS['collapse'][direction] &&\n state.selectionManager.focusedKey === node.key\n ) {\n // If item is collapsible, collapse it; else move to parent\n if (hasChildRows && state.expandedKeys.has(node.key)) {\n state.toggleKey(node.key);\n e.stopPropagation();\n return true;\n } else if (\n !state.expandedKeys.has(node.key) &&\n node.parentKey &&\n state.collection.getItem(node.parentKey)?.type === 'item'\n ) {\n // Item is a leaf or already collapsed, move focus to parent\n state.selectionManager.setFocusedKey(node.parentKey);\n e.stopPropagation();\n return true;\n }\n }\n return false;\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement | null = null;\n let last: FocusableElement | null = null;\n do {\n last = walker.lastChild() as FocusableElement | null;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n\nfunction getDirectChildren<T>(parent: RSNode<T>, collection: Collection<RSNode<T>>) {\n // We can't assume that we can use firstChildKey because if a person builds a tree using hooks, they would not have access to that property (using type Node vs CollectionNode)\n // Instead, get all children and start at the first node (rather than just using firstChildKey) and only look at its siblings\n let children = collection.getChildren?.(parent.key);\n let childArray = children ? Array.from(children) : [];\n let node = childArray.length > 0 ? childArray[0] : null;\n let siblings: RSNode<T>[] = [];\n while (node) {\n siblings.push(node);\n node = node.nextKey != null ? collection.getItem(node.nextKey) : null;\n }\n return siblings;\n}\n"],"names":[],"version":3,"file":"useGridListItem.js.map"}
|
|
@@ -5,6 +5,7 @@ import {getFocusableTreeWalker as $535772f9d2c1f38d$export$2d6ec8fc375ceafa} fro
|
|
|
5
5
|
import {getRowId as $c1c90317e8bffe4d$export$f45c25170b9a99c2, listMap as $c1c90317e8bffe4d$export$5b9bb410392e3991} from "./utils.mjs";
|
|
6
6
|
import {getScrollParent as $3578607fe3d4b096$export$cfa2225e87938781} from "../utils/getScrollParent.mjs";
|
|
7
7
|
import {isFocusVisible as $8f5a2122b0992be3$export$b9b3dfddab17db27} from "../interactions/useFocusVisible.mjs";
|
|
8
|
+
import {isTabbable as $3b8b240c1bf84ab9$export$bebd5a1431fec25d} from "../utils/isFocusable.mjs";
|
|
8
9
|
import {mergeProps as $bbaa08b3cd72f041$export$9d1611c77c2fe928} from "../utils/mergeProps.mjs";
|
|
9
10
|
import {scrollIntoViewport as $51a3e22a5186a962$export$c826860796309d1b} from "../utils/scrollIntoView.mjs";
|
|
10
11
|
import {useSelectableItem as $f6ba6936bfd098a0$export$ecf600387e221c37} from "../selection/useSelectableItem.mjs";
|
|
@@ -37,6 +38,7 @@ import {useRef as $2igou$useRef} from "react";
|
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
|
|
41
|
+
|
|
40
42
|
const $be7bed9611dd7497$var$EXPANSION_KEYS = {
|
|
41
43
|
expand: {
|
|
42
44
|
ltr: 'ArrowRight',
|
|
@@ -111,25 +113,7 @@ function $be7bed9611dd7497$export$9610e69494fadfd2(props, state, ref) {
|
|
|
111
113
|
if (!(0, $23f2114a1b82827e$export$4282f70798064fe0)(e.currentTarget, (0, $23f2114a1b82827e$export$e58f029f0fbfdb29)(e)) || !ref.current || !activeElement) return;
|
|
112
114
|
let walker = (0, $535772f9d2c1f38d$export$2d6ec8fc375ceafa)(ref.current);
|
|
113
115
|
walker.currentNode = activeElement;
|
|
114
|
-
if (
|
|
115
|
-
if (e.key === $be7bed9611dd7497$var$EXPANSION_KEYS['expand'][direction] && state.selectionManager.focusedKey === node.key && hasChildRows && !state.expandedKeys.has(node.key)) {
|
|
116
|
-
state.toggleKey(node.key);
|
|
117
|
-
e.stopPropagation();
|
|
118
|
-
return;
|
|
119
|
-
} else if (e.key === $be7bed9611dd7497$var$EXPANSION_KEYS['collapse'][direction] && state.selectionManager.focusedKey === node.key) {
|
|
120
|
-
// If item is collapsible, collapse it; else move to parent
|
|
121
|
-
if (hasChildRows && state.expandedKeys.has(node.key)) {
|
|
122
|
-
state.toggleKey(node.key);
|
|
123
|
-
e.stopPropagation();
|
|
124
|
-
return;
|
|
125
|
-
} else if (!state.expandedKeys.has(node.key) && node.parentKey && state.collection.getItem(node.parentKey)?.type === 'item') {
|
|
126
|
-
// Item is a leaf or already collapsed, move focus to parent
|
|
127
|
-
state.selectionManager.setFocusedKey(node.parentKey);
|
|
128
|
-
e.stopPropagation();
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
116
|
+
if ($be7bed9611dd7497$var$handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, ref.current)) return;
|
|
133
117
|
switch(e.key){
|
|
134
118
|
case 'ArrowLeft':
|
|
135
119
|
if (keyboardNavigationBehavior === 'arrow') {
|
|
@@ -226,6 +210,16 @@ function $be7bed9611dd7497$export$9610e69494fadfd2(props, state, ref) {
|
|
|
226
210
|
let onKeyDown = (e)=>{
|
|
227
211
|
let activeElement = (0, $23f2114a1b82827e$export$cd4e5573fbe2b576)();
|
|
228
212
|
if (!(0, $23f2114a1b82827e$export$4282f70798064fe0)(e.currentTarget, (0, $23f2114a1b82827e$export$e58f029f0fbfdb29)(e)) || !ref.current || !activeElement) return;
|
|
213
|
+
if (keyboardNavigationBehavior === 'tab') {
|
|
214
|
+
// Stop propagation for all events that originate from the children of the gridlist item since we don't want to trigger
|
|
215
|
+
// grid level interactions (row navigation/typeselect/etc)
|
|
216
|
+
// exception made for Tab since that needs to propagate to useSelectableCollection to tab out of the gridlist, might be others?
|
|
217
|
+
if ((0, $23f2114a1b82827e$export$e58f029f0fbfdb29)(e) !== ref.current && e.key !== 'Tab') {
|
|
218
|
+
e.stopPropagation();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if ($be7bed9611dd7497$var$handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, ref.current)) return;
|
|
222
|
+
}
|
|
229
223
|
switch(e.key){
|
|
230
224
|
case 'Tab':
|
|
231
225
|
if (keyboardNavigationBehavior === 'tab') {
|
|
@@ -253,8 +247,7 @@ function $be7bed9611dd7497$export$9610e69494fadfd2(props, state, ref) {
|
|
|
253
247
|
// }
|
|
254
248
|
let rowProps = (0, $bbaa08b3cd72f041$export$9d1611c77c2fe928)(itemProps, linkProps, {
|
|
255
249
|
role: 'row',
|
|
256
|
-
onKeyDownCapture: onKeyDownCapture,
|
|
257
|
-
onKeyDown: onKeyDown,
|
|
250
|
+
onKeyDownCapture: keyboardNavigationBehavior === 'arrow' ? onKeyDownCapture : undefined,
|
|
258
251
|
onFocus: onFocus,
|
|
259
252
|
// 'aria-label': [(node.textValue || undefined), rowAnnouncement].filter(Boolean).join(', '),
|
|
260
253
|
'aria-label': node['aria-label'] || node.textValue || undefined,
|
|
@@ -263,6 +256,33 @@ function $be7bed9611dd7497$export$9610e69494fadfd2(props, state, ref) {
|
|
|
263
256
|
'aria-labelledby': descriptionId && (node['aria-label'] || node.textValue) ? `${(0, $c1c90317e8bffe4d$export$f45c25170b9a99c2)(state, node.key)} ${descriptionId}` : undefined,
|
|
264
257
|
id: (0, $c1c90317e8bffe4d$export$f45c25170b9a99c2)(state, node.key)
|
|
265
258
|
});
|
|
259
|
+
// we need to guard against space/enter triggering selection/row link via usePress (from itemProps) so check if propagation
|
|
260
|
+
// is stopped. this also fixes space not working in a textfield in a tree parent row
|
|
261
|
+
let baseOnKeyDown = rowProps.onKeyDown;
|
|
262
|
+
rowProps.onKeyDown = (e)=>{
|
|
263
|
+
onKeyDown(e);
|
|
264
|
+
if (!e.isPropagationStopped()) baseOnKeyDown?.(e);
|
|
265
|
+
};
|
|
266
|
+
// guard against presses triggering row selecition when they happen on elements within the row
|
|
267
|
+
// am currently assuming if it is tabbable it is interactive, but maybe can use a different kind of check
|
|
268
|
+
let baseOnPointerDown = rowProps.onPointerDown;
|
|
269
|
+
rowProps.onPointerDown = (e)=>{
|
|
270
|
+
let target = (0, $23f2114a1b82827e$export$e58f029f0fbfdb29)(e);
|
|
271
|
+
if (target && target !== ref.current && (0, $3b8b240c1bf84ab9$export$bebd5a1431fec25d)(target)) {
|
|
272
|
+
e.stopPropagation();
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
baseOnPointerDown?.(e);
|
|
276
|
+
};
|
|
277
|
+
let baseOnMouseDown = rowProps.onMouseDown;
|
|
278
|
+
rowProps.onMouseDown = (e)=>{
|
|
279
|
+
let target = (0, $23f2114a1b82827e$export$e58f029f0fbfdb29)(e);
|
|
280
|
+
if (target && target !== ref.current && (0, $3b8b240c1bf84ab9$export$bebd5a1431fec25d)(target)) {
|
|
281
|
+
e.stopPropagation();
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
baseOnMouseDown?.(e);
|
|
285
|
+
};
|
|
266
286
|
if (isVirtualized) {
|
|
267
287
|
let { collection: collection } = state;
|
|
268
288
|
let nodes = [
|
|
@@ -289,6 +309,27 @@ function $be7bed9611dd7497$export$9610e69494fadfd2(props, state, ref) {
|
|
|
289
309
|
...itemStates
|
|
290
310
|
};
|
|
291
311
|
}
|
|
312
|
+
function $be7bed9611dd7497$var$handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, rowRef) {
|
|
313
|
+
if (!('expandedKeys' in state) || activeElement !== rowRef) return false;
|
|
314
|
+
if (e.key === $be7bed9611dd7497$var$EXPANSION_KEYS['expand'][direction] && state.selectionManager.focusedKey === node.key && hasChildRows && !state.expandedKeys.has(node.key)) {
|
|
315
|
+
state.toggleKey(node.key);
|
|
316
|
+
e.stopPropagation();
|
|
317
|
+
return true;
|
|
318
|
+
} else if (e.key === $be7bed9611dd7497$var$EXPANSION_KEYS['collapse'][direction] && state.selectionManager.focusedKey === node.key) {
|
|
319
|
+
// If item is collapsible, collapse it; else move to parent
|
|
320
|
+
if (hasChildRows && state.expandedKeys.has(node.key)) {
|
|
321
|
+
state.toggleKey(node.key);
|
|
322
|
+
e.stopPropagation();
|
|
323
|
+
return true;
|
|
324
|
+
} else if (!state.expandedKeys.has(node.key) && node.parentKey && state.collection.getItem(node.parentKey)?.type === 'item') {
|
|
325
|
+
// Item is a leaf or already collapsed, move focus to parent
|
|
326
|
+
state.selectionManager.setFocusedKey(node.parentKey);
|
|
327
|
+
e.stopPropagation();
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
292
333
|
function $be7bed9611dd7497$var$last(walker) {
|
|
293
334
|
let next = null;
|
|
294
335
|
let last = null;
|