@lumx/react 4.3.2-alpha.9 → 4.4.1-alpha.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/_internal/DpdvhbTO.js +159 -0
- package/_internal/DpdvhbTO.js.map +1 -0
- package/index.d.ts +263 -647
- package/index.js +2964 -4567
- package/index.js.map +1 -1
- package/package.json +16 -7
- package/utils/index.d.ts +1 -2
- package/utils/index.js +1324 -5
- package/utils/index.js.map +1 -1
- package/_internal/BcRzrT9Y.js +0 -1480
- package/_internal/BcRzrT9Y.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BcRzrT9Y.js","sources":["../../src/utils/disabled/DisabledStateContext.tsx","../../src/hooks/useClickAway.tsx","../../src/utils/ClickAwayProvider/ClickAwayProvider.tsx","../../src/utils/A11YLiveMessage/index.tsx","../../src/utils/Portal/PortalProvider.tsx","../../src/utils/Portal/Portal.tsx","../../src/utils/moving-focus/utils/createGridMap.ts","../../src/utils/moving-focus/utils/tabStopIsEnabled.ts","../../src/utils/moving-focus/constants.ts","../../src/utils/moving-focus/utils/buildLoopAroundObject.ts","../../src/utils/moving-focus/utils/getCell.ts","../../src/utils/moving-focus/utils/getCellCoordinates.ts","../../src/utils/moving-focus/utils/shouldLoopListVertically.ts","../../src/utils/moving-focus/utils/shouldLoopListHorizontally.ts","../../src/utils/moving-focus/utils/getPointerTypeFromEvent.ts","../../src/utils/moving-focus/ducks/keyboard-navigation.ts","../../src/utils/moving-focus/ducks/tab-stop.ts","../../src/utils/moving-focus/ducks/slice.ts","../../src/utils/moving-focus/components/MovingFocusProvider/context.ts","../../src/utils/moving-focus/components/MovingFocusProvider/index.tsx","../../src/utils/moving-focus/hooks/useVirtualFocus/useVirtualFocus.ts","../../src/utils/moving-focus/hooks/useVirtualFocus/useVirtualFocusParent.ts"],"sourcesContent":["import React, { useContext } from 'react';\n\nimport { DisabledStateContextValue } from '@lumx/core/js/utils/disabledState';\n\nexport const DisabledStateContext = React.createContext<DisabledStateContextValue>({ state: null });\n\nexport type DisabledStateProviderProps = DisabledStateContextValue & {\n children: React.ReactNode;\n};\n\n/**\n * Disabled state provider.\n * All nested LumX Design System components inherit this disabled state.\n */\nexport function DisabledStateProvider({ children, ...value }: DisabledStateProviderProps) {\n return <DisabledStateContext.Provider value={value}>{children}</DisabledStateContext.Provider>;\n}\n\n/**\n * Get DisabledState context value\n */\nexport function useDisabledStateContext(): DisabledStateContextValue {\n return useContext(DisabledStateContext);\n}\n","import { RefObject, useEffect } from 'react';\n\nimport { Falsy } from '@lumx/react/utils/type';\n\nimport isEmpty from 'lodash/isEmpty';\n\nconst EVENT_TYPES = ['mousedown', 'touchstart'];\n\nfunction isClickAway(targets: HTMLElement[], refs: Array<RefObject<HTMLElement>>): boolean {\n // The targets elements are not contained in any of the listed element references.\n return !refs.some((ref) => targets.some((target) => ref?.current?.contains(target)));\n}\n\nexport interface ClickAwayParameters {\n /**\n * A callback function to call when the user clicks away from the elements.\n */\n callback: EventListener | Falsy;\n /**\n * Elements considered within the click away context (clicking outside them will trigger the click away callback).\n */\n childrenRefs: RefObject<Array<RefObject<HTMLElement>>>;\n}\n\n/**\n * Listen to clicks away from the given elements and callback the passed in function.\n *\n * Warning: If you need to detect click away on nested React portals, please use the `ClickAwayProvider` component.\n */\nexport function useClickAway({ callback, childrenRefs }: ClickAwayParameters): void {\n useEffect(() => {\n const { current: currentRefs } = childrenRefs;\n if (!callback || !currentRefs || isEmpty(currentRefs)) {\n return undefined;\n }\n const listener: EventListener = (evt) => {\n const targets = [evt.composedPath?.()[0], evt.target] as HTMLElement[];\n if (isClickAway(targets, currentRefs)) {\n callback(evt);\n }\n };\n\n EVENT_TYPES.forEach((evtType) => document.addEventListener(evtType, listener));\n return () => {\n EVENT_TYPES.forEach((evtType) => document.removeEventListener(evtType, listener));\n };\n }, [callback, childrenRefs]);\n}\n","import { createContext, RefObject, useContext, useEffect, useMemo, useRef } from 'react';\nimport { ClickAwayParameters, useClickAway } from '@lumx/react/hooks/useClickAway';\n\ninterface ContextValue {\n childrenRefs: Array<RefObject<HTMLElement>>;\n addRefs(...newChildrenRefs: Array<RefObject<HTMLElement>>): void;\n}\n\nconst ClickAwayAncestorContext = createContext<ContextValue | null>(null);\n\ninterface ClickAwayProviderProps extends ClickAwayParameters {\n /**\n * (Optional) Element that should be considered as part of the parent\n */\n parentRef?: RefObject<HTMLElement>;\n /**\n * Children\n */\n children?: React.ReactNode;\n}\n\n/**\n * Component combining the `useClickAway` hook with a React context to hook into the React component tree and make sure\n * we take into account both the DOM tree and the React tree to detect click away.\n *\n * @return the react component.\n */\nexport const ClickAwayProvider: React.FC<ClickAwayProviderProps> = ({\n children,\n callback,\n childrenRefs,\n parentRef,\n}) => {\n const parentContext = useContext(ClickAwayAncestorContext);\n const currentContext = useMemo(() => {\n const context: ContextValue = {\n childrenRefs: [],\n /**\n * Add element refs to the current context and propagate to the parent context.\n */\n addRefs(...newChildrenRefs) {\n // Add element refs that should be considered as inside the click away context.\n context.childrenRefs.push(...newChildrenRefs);\n\n if (parentContext) {\n // Also add then to the parent context\n parentContext.addRefs(...newChildrenRefs);\n if (parentRef) {\n // The parent element is also considered as inside the parent click away context but not inside the current context\n parentContext.addRefs(parentRef);\n }\n }\n },\n };\n return context;\n }, [parentContext, parentRef]);\n\n useEffect(() => {\n const { current: currentRefs } = childrenRefs;\n if (!currentRefs) {\n return;\n }\n currentContext.addRefs(...currentRefs);\n }, [currentContext, childrenRefs]);\n\n useClickAway({ callback, childrenRefs: useRef(currentContext.childrenRefs) });\n return <ClickAwayAncestorContext.Provider value={currentContext}>{children}</ClickAwayAncestorContext.Provider>;\n};\nClickAwayProvider.displayName = 'ClickAwayProvider';\n","import React, { AriaAttributes, ReactNode } from 'react';\n\nimport { visuallyHidden, join } from '@lumx/core/js/utils/classNames';\n\nexport interface A11YLiveMessageProps {\n /** The message that will be read. */\n children?: ReactNode;\n /** Whether the message should be hidden */\n hidden?: boolean;\n /**\n * The type of message.\n * Default to \"polite\"\n * Assertive should only be used for messages than need immediate attention.\n */\n type?: AriaAttributes['aria-live'];\n /**\n * Indicates whether assistive technologies will present all, or only parts of, the changed region based on\n * the change notifications defined by the aria-relevant attribute.\n */\n atomic?: AriaAttributes['aria-atomic'];\n /**\n * Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.\n * @see atomic.\n */\n relevant?: AriaAttributes['aria-relevant'];\n /**\n * Whether the live region reads a current status or\n * raises an alert.\n * Only use `alert` for time sensitive information that should be read immediately\n * as it will interrupt anything being currently read.\n */\n role?: 'status' | 'alert';\n /** Scope, for tracking purposes */\n scope?: string;\n /** Optionnal classname */\n className?: string;\n}\n\n/**\n * Live region to read a message to screen readers.\n * Messages can be \"polite\" and be read when possible or\n * \"assertive\" and interrupt any message currently be read. (To be used sparingly)\n *\n * More information here: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions\n *\n * @family A11Y\n * @param A11YLiveMessageProps\n * @returns A11YLiveMessage\n */\nexport const A11YLiveMessage: React.FC<A11YLiveMessageProps> = ({\n type = 'polite',\n atomic,\n role,\n hidden,\n relevant,\n children,\n className,\n ...forwardedProps\n}) => {\n return (\n <div\n {...forwardedProps}\n className={join(hidden ? visuallyHidden() : undefined, className)}\n role={role}\n aria-live={type}\n aria-atomic={atomic}\n aria-relevant={relevant}\n >\n {children}\n </div>\n );\n};\n","import React from 'react';\n\ntype Container = DocumentFragment | Element;\n\n/**\n * Portal initializing function.\n * If it does not provide a container, the Portal children will render in classic React tree and not in a portal.\n */\nexport type PortalInit = () => {\n container?: Container;\n teardown?: () => void;\n};\n\nexport const PortalContext = React.createContext<PortalInit>(() => ({ container: document.body }));\n\nexport interface PortalProviderProps {\n children?: React.ReactNode;\n value: PortalInit;\n}\n\n/**\n * Customize where <Portal> wrapped elements render (tooltip, popover, dialog, etc.)\n */\nexport const PortalProvider: React.FC<PortalProviderProps> = PortalContext.Provider;\n","import React from 'react';\nimport { createPortal } from 'react-dom';\nimport { PortalContext } from './PortalProvider';\n\nexport interface PortalProps {\n enabled?: boolean;\n children: React.ReactNode;\n}\n\n/**\n * Render children in a portal outside the current DOM position\n * (defaults to `document.body` but can be customized with the PortalContextProvider)\n */\nexport const Portal: React.FC<PortalProps> = ({ children, enabled = true }) => {\n const init = React.useContext(PortalContext);\n const context = React.useMemo(\n () => {\n return enabled ? init() : null;\n },\n // Only update on 'enabled'\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [enabled],\n );\n\n React.useLayoutEffect(() => {\n return context?.teardown;\n }, [context?.teardown, enabled]);\n\n if (!context?.container) {\n return <>{children}</>;\n }\n return createPortal(children, context.container);\n};\n","import groupBy from 'lodash/groupBy';\nimport isNil from 'lodash/isNil';\n\nimport { GridMap, TabStop, TabStopRowKey } from '../types';\n\n/**\n * Create a map from the given tab stop to sort them by rowKey;\n */\nexport function createGridMap(tabStops: readonly TabStop[]): GridMap {\n /** Group all tabStop by rows to easily access them by their row keys */\n const tabStopsByRowKey = groupBy(tabStops, 'rowKey');\n /**\n * An array with each row key in the order set in the tabStops array.\n * Each rowKey will only appear once.\n */\n const rowKeys = tabStops.reduce<TabStopRowKey[]>((acc, { rowKey }) => {\n if (!isNil(rowKey) && !acc.includes(rowKey)) {\n return [...acc, rowKey];\n }\n return acc;\n }, []);\n\n return {\n tabStopsByRowKey,\n rowKeys,\n };\n}\n","import { TabStop } from '../types';\n\n/** Check if the given tab stop is enabled */\nexport const tabStopIsEnabled = (tabStop: TabStop) => !tabStop.disabled;\n","export const LOOP_AROUND_TYPES = {\n /**\n * Will continue navigation to the next row or column and loop back to the start\n * when the last tab stop is reached\n */\n nextLoop: 'next-loop',\n /**\n * Will continue navigation to the next row or column until\n * the last tab stop is reached\n */\n nextEnd: 'next-end',\n /**\n * Will loop within the current row or column\n */\n inside: 'inside',\n} as const;\n\nexport const CELL_SEARCH_DIRECTION = {\n /** Look ahead of the given position */\n asc: 'asc',\n /** Look before the given position */\n desc: 'desc',\n} as const;\n","import { LOOP_AROUND_TYPES } from '../constants';\nimport { LoopAround, LoopAroundByAxis } from '../types';\n\n/**\n * Build a loopAround configuration to ensure both row and col behavior are set.\n *\n * Setting a boolean will set the following behaviors:\n *\n * * true => { row: 'next-loop', col: 'next-loop' }\n * * false => { row: 'next-end', col: 'next-end' }\n */\nexport function buildLoopAroundObject(loopAround?: LoopAround): LoopAroundByAxis {\n if (typeof loopAround === 'boolean' || loopAround === undefined) {\n const newLoopAround: LoopAround = loopAround\n ? { row: LOOP_AROUND_TYPES.nextLoop, col: LOOP_AROUND_TYPES.nextLoop }\n : { row: LOOP_AROUND_TYPES.nextEnd, col: LOOP_AROUND_TYPES.nextEnd };\n\n return newLoopAround;\n }\n return loopAround;\n}\n","import find from 'lodash/find';\nimport findLast from 'lodash/findLast';\n\nimport { CELL_SEARCH_DIRECTION } from '../constants';\nimport { CellSelector, CoordsType, DirectionCoords, GridMap, TabStop } from '../types';\n\nimport { tabStopIsEnabled } from './tabStopIsEnabled';\n\n/**\n * Check that the given coordinate is a simple number\n */\nconst isNumberCoords = (coords: CoordsType): coords is number => typeof coords === 'number';\n\n/**\n * Check that the given coordinate is a direction\n */\nfunction isDirectionCoords(coords: CoordsType): coords is DirectionCoords {\n return Boolean(typeof coords !== 'number' && typeof coords?.from === 'number');\n}\n\n/**\n * Search the given column of a grid map for a cell.\n */\nfunction findCellInCol(\n gridMap: GridMap,\n col: number,\n rowCoords: DirectionCoords,\n cellSelector: CellSelector = tabStopIsEnabled,\n) {\n /** The rowIndex might not be strictly successive, so we need to use the actual row index keys. */\n const { rowKeys, tabStopsByRowKey } = gridMap;\n const lastIndex = rowKeys.length - 1;\n /**\n * If the rowCoords.from is set at -1, it means we should search from the start/end.\n */\n let searchIndex = rowCoords.from;\n if (searchIndex === -1) {\n searchIndex = rowCoords.direction === CELL_SEARCH_DIRECTION.desc ? lastIndex : 0;\n }\n\n const searchCellFunc = rowCoords.direction === CELL_SEARCH_DIRECTION.desc ? findLast : find;\n const rowKeyWithEnabledCell = searchCellFunc(rowKeys, (rowKey, index) => {\n const row = tabStopsByRowKey[rowKey];\n const cell = row[col];\n const hasCell = Boolean(cell);\n const cellRowIndex = index;\n\n /** Check that the target row index is in the right direction of the search */\n const correctRowIndex =\n rowCoords.direction === CELL_SEARCH_DIRECTION.desc\n ? cellRowIndex <= searchIndex\n : cellRowIndex >= searchIndex;\n\n if (cell && correctRowIndex) {\n return cellSelector ? hasCell && cellSelector(cell) : hasCell;\n }\n return false;\n });\n const row = rowKeyWithEnabledCell !== undefined ? tabStopsByRowKey[rowKeyWithEnabledCell] : undefined;\n return row?.[col];\n}\n\n/**\n * Search the given column of a grid map for a cell.\n */\nfunction findCellInRow(\n gridMap: GridMap,\n row: number,\n colCoords: DirectionCoords,\n cellSelector: CellSelector = tabStopIsEnabled,\n) {\n const { direction, from } = colCoords || {};\n const { rowKeys, tabStopsByRowKey } = gridMap;\n const rowKey = rowKeys[row];\n const currentRow = tabStopsByRowKey[rowKey];\n if (!currentRow) {\n return undefined;\n }\n\n const searchCellFunc = direction === CELL_SEARCH_DIRECTION.desc ? findLast : find;\n const cell = searchCellFunc(currentRow, cellSelector, from);\n return cell;\n}\n\n/**\n * Parse each column of the given gridMap to find the first cell matching the selector.\n * The direction and starting point of the search can be set using the coordinates attribute.\n */\nfunction parseColsForCell(\n /** The gridMap to search */\n gridMap: GridMap,\n /** The coordinate to search */\n { direction = CELL_SEARCH_DIRECTION.asc, from }: DirectionCoords,\n cellSelector: CellSelector = tabStopIsEnabled,\n) {\n if (from === undefined) {\n return undefined;\n }\n\n const { rowKeys, tabStopsByRowKey } = gridMap;\n\n /** As we cannot know for certain when to stop, we need to know which column is the last column */\n const maxColIndex = rowKeys.reduce<number>((maxLength, rowIndex) => {\n const rowLength = tabStopsByRowKey[rowIndex].length;\n return rowLength > maxLength ? rowLength - 1 : maxLength;\n }, 0);\n\n /** If \"from\" is set as -1, start from the end. */\n const fromIndex = from === -1 ? maxColIndex : from || 0;\n\n for (\n let index = fromIndex;\n direction === CELL_SEARCH_DIRECTION.desc ? index > -1 : index <= maxColIndex;\n direction === CELL_SEARCH_DIRECTION.desc ? (index -= 1) : (index += 1)\n ) {\n const rowWithEnabledCed = findCellInCol(\n gridMap,\n index,\n { direction, from: direction === CELL_SEARCH_DIRECTION.desc ? -1 : 0 },\n cellSelector,\n );\n\n if (rowWithEnabledCed) {\n return rowWithEnabledCed;\n }\n }\n\n return undefined;\n}\n\n/**\n * Search for a cell in a gridMap\n *\n * This allows you to\n * * Select a cell at a specific coordinate\n * * Search for a cell from a specific column in any direction\n * * Search for a cell from a specific row in any direction\n *\n * If no cell is found, returns undefined\n */\nexport function getCell(\n /** The gridMap object to search in. */\n gridMap: GridMap,\n /** The coordinates of the cell to select */\n coords: {\n /** The row on or from witch to look for */\n row: CoordsType;\n /** The column on or from witch to look for */\n col: CoordsType;\n },\n /**\n * A selector function to select the cell.\n * Selects enabled cells by default.\n */\n cellSelector: CellSelector = tabStopIsEnabled,\n): TabStop | undefined {\n const { row, col } = coords || {};\n const { rowKeys, tabStopsByRowKey } = gridMap || {};\n\n /** Defined row and col */\n if (isNumberCoords(row) && isNumberCoords(col)) {\n const rowKey = rowKeys[row];\n return tabStopsByRowKey[rowKey][col];\n }\n\n /** Defined row but variable col */\n if (isDirectionCoords(col) && isNumberCoords(row)) {\n return findCellInRow(gridMap, row, col, cellSelector);\n }\n\n if (isDirectionCoords(row)) {\n if (isDirectionCoords(col)) {\n return parseColsForCell(gridMap, col, cellSelector);\n }\n return findCellInCol(gridMap, col, row, cellSelector);\n }\n\n return undefined;\n}\n","import isNil from 'lodash/isNil';\n\nimport { GridMap, TabStop } from '../types';\n\nexport function getCellCoordinates(gridMap: GridMap, tabStop: TabStop) {\n const currentRowKey = tabStop.rowKey;\n if (isNil(currentRowKey)) {\n return undefined;\n }\n const { rowKeys, tabStopsByRowKey } = gridMap;\n const rowIndex = rowKeys.findIndex((rowKey) => rowKey === currentRowKey);\n const row = tabStopsByRowKey[currentRowKey];\n const columnOffset = row.findIndex((ts) => ts.id === tabStop.id);\n\n return {\n rowIndex,\n row,\n columnOffset,\n };\n}\n","import { KeyDirection, LoopAroundByAxis } from '../types';\n\n/** Check whether the list should vertically loop with the given configuration */\nexport function shouldLoopListVertically(direction: KeyDirection, loopAround: Pick<LoopAroundByAxis, 'col'>): boolean {\n return (\n (direction === 'vertical' && loopAround?.col !== 'next-end') ||\n (direction === 'both' && loopAround?.col !== 'next-end')\n );\n}\n","import { KeyDirection, LoopAroundByAxis } from '../types';\n\n/** Check whether the list should horizontally loop with the given configuration */\nexport function shouldLoopListHorizontally(\n direction: KeyDirection,\n loopAround: Pick<LoopAroundByAxis, 'row'>,\n): boolean {\n return (\n (direction === 'horizontal' && loopAround?.row !== 'next-end') ||\n (direction === 'both' && loopAround?.row !== 'next-end')\n );\n}\n","/**\n * Get the correct pointer type from the given event.\n * This is used when a tab stop is selected, to check if is has been selected using a keyboard or a pointer\n * (pen / mouse / touch)\n */\nexport function getPointerTypeFromEvent(event?: PointerEvent | Event) {\n return event && 'pointerType' in event && Boolean(event.pointerType) ? 'pointer' : 'keyboard';\n}\n","import find from 'lodash/find';\nimport findLast from 'lodash/findLast';\nimport findLastIndex from 'lodash/findLastIndex';\nimport isNil from 'lodash/isNil';\n\nimport { LOOP_AROUND_TYPES } from '../constants';\nimport { KeyDirection, KeyNavAction, Navigation, Reducer, State, TabStop } from '../types';\nimport {\n createGridMap,\n getCell,\n getCellCoordinates,\n shouldLoopListHorizontally,\n shouldLoopListVertically,\n tabStopIsEnabled,\n} from '../utils';\n\n// Event keys used for keyboard navigation.\nexport const VERTICAL_NAV_KEYS = ['ArrowUp', 'ArrowDown', 'Home', 'End'] as const;\nexport const HORIZONTAL_NAV_KEYS = ['ArrowLeft', 'ArrowRight', 'Home', 'End'] as const;\nexport const KEY_NAV_KEYS = [...HORIZONTAL_NAV_KEYS, ...VERTICAL_NAV_KEYS] as const;\nexport const NAV_KEYS: { [direction in KeyDirection]: ReadonlyArray<string> } = {\n both: KEY_NAV_KEYS,\n vertical: VERTICAL_NAV_KEYS,\n horizontal: HORIZONTAL_NAV_KEYS,\n};\n\n// Event keys union type\nexport type EventKey = (typeof KEY_NAV_KEYS)[number];\n\n// Handle all navigation moves resulting in a new state.\nconst MOVES: {\n [N in Navigation]: (state: State, currentTabStop: TabStop, index: number) => State;\n} = {\n // Move to the next item.\n // The grid is flatten so the item after the last of a row will be the\n // first item of the next row.\n NEXT(state, _, index) {\n for (let i = index + 1; i < state.tabStops.length; ++i) {\n const tabStop = state.tabStops[i];\n\n if (!tabStop.disabled) {\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop.id,\n };\n }\n }\n return state;\n },\n\n // Move to the previous item.\n // The grid is flatten so the item before the first of a row will be the\n // last item of the previous row.\n PREVIOUS(state, _, index) {\n for (let i = index - 1; i >= 0; --i) {\n const tabStop = state.tabStops[i];\n\n if (!tabStop.disabled) {\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop.id,\n };\n }\n }\n return state;\n },\n\n // Moving to the next row\n // We move to the next row, and we stay in the same column.\n // If we are in the last row, then we move to the first not disabled item of the next column.\n NEXT_ROW(state, currentTabStop) {\n const currentRowKey = currentTabStop.rowKey;\n if (isNil(currentRowKey)) {\n return state;\n }\n const gridMap = state.gridMap || createGridMap(state.tabStops);\n const cellCoordinates = getCellCoordinates(gridMap, currentTabStop);\n if (!cellCoordinates) {\n return state;\n }\n const { rowIndex, columnOffset } = cellCoordinates;\n const nextRow = rowIndex + 1;\n\n /** First try to get the next cell in the current column */\n let tabStop = getCell(gridMap, {\n row: {\n from: nextRow,\n direction: 'asc',\n },\n col: columnOffset,\n });\n\n // If none were found, search for the next cell depending on the loop around parameter\n if (!tabStop) {\n switch (state.loopAround.col) {\n /**\n * If columns are configured to be looped inside,\n * get the first enabled cell of the current column\n */\n case LOOP_AROUND_TYPES.inside:\n tabStop = getCell(gridMap, {\n col: columnOffset,\n row: {\n from: 0,\n direction: 'asc',\n },\n });\n break;\n /**\n * If columns are configured to be go to the next,\n * search for the next enabled cell from the next column\n */\n case LOOP_AROUND_TYPES.nextEnd:\n case LOOP_AROUND_TYPES.nextLoop:\n default:\n tabStop = getCell(gridMap, {\n row: {\n from: 0,\n direction: 'asc',\n },\n col: {\n from: columnOffset + 1,\n direction: 'asc',\n },\n });\n break;\n }\n }\n\n /**\n * If still none is found and the columns are configured to loop\n * search starting from the start\n */\n if (!tabStop && state.loopAround.col === LOOP_AROUND_TYPES.nextLoop) {\n tabStop = getCell(gridMap, {\n row: {\n from: 0,\n direction: 'asc',\n },\n col: {\n from: 0,\n direction: 'asc',\n },\n });\n }\n\n if (tabStop) {\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop.id,\n gridMap,\n };\n }\n\n return { ...state, allowFocusing: true, gridMap };\n },\n\n // Moving to the previous row\n // We move to the previous row, and we stay in the same column.\n // If we are in the first row, then we move to the last not disabled item of the previous column.\n PREVIOUS_ROW(state, currentTabStop) {\n const currentRowKey = currentTabStop.rowKey;\n if (isNil(currentRowKey)) {\n return state;\n }\n const gridMap = state.gridMap || createGridMap(state.tabStops);\n const cellCoordinates = getCellCoordinates(gridMap, currentTabStop);\n if (!cellCoordinates) {\n return state;\n }\n const { rowIndex, columnOffset } = cellCoordinates;\n const previousRow = rowIndex - 1;\n let tabStop;\n /** Search for the previous enabled cell in the current column */\n if (previousRow >= 0) {\n tabStop = getCell(gridMap, {\n row: {\n from: previousRow,\n direction: 'desc',\n },\n col: columnOffset,\n });\n }\n\n // If none were found, search for the previous cell depending on the loop around parameter\n if (!tabStop) {\n switch (state.loopAround.col) {\n /**\n * If columns are configured to be looped inside,\n * get the last enabled cell of the current column\n */\n case LOOP_AROUND_TYPES.inside:\n tabStop = getCell(gridMap, {\n col: columnOffset,\n row: {\n from: -1,\n direction: 'desc',\n },\n });\n break;\n /**\n * If columns are configured to be go to the previous,\n * search for the last enabled cell from the previous column\n */\n case LOOP_AROUND_TYPES.nextEnd:\n case LOOP_AROUND_TYPES.nextLoop:\n default:\n if (columnOffset - 1 >= 0) {\n tabStop = getCell(gridMap, {\n row: {\n from: -1,\n direction: 'desc',\n },\n col: {\n from: columnOffset - 1,\n direction: 'desc',\n },\n });\n break;\n }\n }\n }\n /**\n * If still none is found and the columns are configured to loop\n * search starting from the end\n */\n if (!tabStop && state.loopAround.col === LOOP_AROUND_TYPES.nextLoop) {\n tabStop = getCell(gridMap, {\n row: {\n from: -1,\n direction: 'desc',\n },\n col: {\n from: -1,\n direction: 'desc',\n },\n });\n }\n\n if (tabStop) {\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop.id,\n gridMap,\n };\n }\n\n return { ...state, allowFocusing: true, gridMap };\n },\n // Moving to the very first not disabled item of the list\n VERY_FIRST(state) {\n // The very first not disabled item' index.\n const tabStop = state.tabStops.find(tabStopIsEnabled);\n if (tabStop) {\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop.id,\n };\n }\n return state;\n },\n // Moving to the very last not disabled item of the list\n VERY_LAST(state) {\n // The very last not disabled item' index.\n const tabStop = findLast(state.tabStops, tabStopIsEnabled);\n if (tabStop) {\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop.id,\n };\n }\n return state;\n },\n NEXT_COLUMN(state, currentTabStop, index) {\n const currentRowKey = currentTabStop.rowKey;\n if (isNil(currentRowKey)) {\n return state;\n }\n const gridMap = state.gridMap || createGridMap(state.tabStops);\n const cellCoordinates = getCellCoordinates(gridMap, currentTabStop);\n if (!cellCoordinates) {\n return state;\n }\n const { rowIndex, columnOffset } = cellCoordinates;\n // Parse the current row and look for the next enabled cell\n let tabStop = getCell(gridMap, {\n row: rowIndex,\n col: {\n from: columnOffset + 1,\n direction: 'asc',\n },\n });\n\n // If none were found, search for the next cell depending on the loop around parameter\n if (!tabStop) {\n switch (state.loopAround.row) {\n /**\n * If rows are configured to be looped inside,\n * get the first enabled cell of the current rows\n */\n case LOOP_AROUND_TYPES.inside:\n tabStop = getCell(gridMap, {\n row: rowIndex,\n col: {\n from: 0,\n direction: 'asc',\n },\n });\n break;\n /**\n * If rows are configured to be go to the next,\n * search for the next enabled cell from the next row\n */\n case LOOP_AROUND_TYPES.nextEnd:\n case LOOP_AROUND_TYPES.nextLoop:\n default:\n tabStop = find(state.tabStops, tabStopIsEnabled, index + 1);\n break;\n }\n }\n /**\n * If still none is found and the row are configured to loop\n * search starting from the start\n */\n if (!tabStop && state.loopAround.row === LOOP_AROUND_TYPES.nextLoop) {\n tabStop = find(state.tabStops, tabStopIsEnabled);\n }\n\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop?.id || state.selectedId,\n gridMap,\n };\n },\n PREVIOUS_COLUMN(state, currentTabStop, index) {\n const currentRowKey = currentTabStop.rowKey;\n if (isNil(currentRowKey)) {\n return state;\n }\n const gridMap = state.gridMap || createGridMap(state.tabStops);\n const cellCoordinates = getCellCoordinates(gridMap, currentTabStop);\n if (!cellCoordinates) {\n return state;\n }\n const { rowIndex, columnOffset } = cellCoordinates;\n\n const previousColumn = columnOffset - 1;\n let tabStop;\n\n if (previousColumn >= 0) {\n // Parse the current row and look for the next enable cell\n tabStop = getCell(gridMap, {\n row: rowIndex,\n col: {\n from: previousColumn,\n direction: 'desc',\n },\n });\n }\n if (!tabStop) {\n switch (state.loopAround.row) {\n /**\n * If rows are configured to be looped inside,\n * get the last enabled cell of the current row\n */\n case LOOP_AROUND_TYPES.inside:\n tabStop = getCell(gridMap, {\n row: rowIndex,\n col: {\n from: -1,\n direction: 'desc',\n },\n });\n break;\n /**\n * If rows are configured to be go to the next,\n * search for the previous enabled cell from the previous row\n */\n case LOOP_AROUND_TYPES.nextEnd:\n case LOOP_AROUND_TYPES.nextLoop:\n default:\n if (index - 1 >= 0) {\n tabStop = findLast(state.tabStops, tabStopIsEnabled, index - 1);\n }\n break;\n }\n }\n /**\n * If still none is found and the rows are configured to loop\n * search starting from the end\n */\n if (!tabStop && state.loopAround.row === LOOP_AROUND_TYPES.nextLoop) {\n tabStop = findLast(state.tabStops, tabStopIsEnabled);\n }\n\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop?.id || state.selectedId,\n gridMap,\n };\n },\n FIRST_IN_COLUMN(state, currentTabStop) {\n const currentRowKey = currentTabStop.rowKey;\n if (isNil(currentRowKey)) {\n return state;\n }\n const gridMap = state.gridMap || createGridMap(state.tabStops);\n const cellCoordinates = getCellCoordinates(gridMap, currentTabStop);\n if (!cellCoordinates) {\n return state;\n }\n const { columnOffset } = cellCoordinates;\n\n const tabStop = getCell(gridMap, {\n col: columnOffset,\n row: {\n from: 0,\n direction: 'asc',\n },\n });\n\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop?.id || state.selectedId,\n gridMap,\n };\n },\n LAST_IN_COLUMN(state, currentTabStop) {\n const currentRowKey = currentTabStop.rowKey;\n if (isNil(currentRowKey)) {\n return state;\n }\n const gridMap = state.gridMap || createGridMap(state.tabStops);\n const cellCoordinates = getCellCoordinates(gridMap, currentTabStop);\n if (!cellCoordinates) {\n return state;\n }\n const { columnOffset } = cellCoordinates;\n\n const tabStop = getCell(gridMap, {\n col: columnOffset,\n row: {\n from: -1,\n direction: 'desc',\n },\n });\n\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop?.id || state.selectedId,\n gridMap,\n };\n },\n // Moving to the first item in row\n FIRST_IN_ROW(state, currentTabStop) {\n const currentRowKey = currentTabStop.rowKey;\n if (isNil(currentRowKey)) {\n return state;\n }\n const gridMap = state.gridMap || createGridMap(state.tabStops);\n const cellCoordinates = getCellCoordinates(gridMap, currentTabStop);\n if (!cellCoordinates) {\n return state;\n }\n const { rowIndex } = cellCoordinates;\n\n const tabStop = getCell(gridMap, {\n row: rowIndex,\n col: {\n from: 0,\n direction: 'asc',\n },\n });\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop?.id || state.selectedId,\n gridMap,\n };\n },\n // Moving to the last item in row\n LAST_IN_ROW(state, currentTabStop) {\n const currentRowKey = currentTabStop.rowKey;\n if (isNil(currentRowKey)) {\n return state;\n }\n const gridMap = state.gridMap || createGridMap(state.tabStops);\n const cellCoordinates = getCellCoordinates(gridMap, currentTabStop);\n if (!cellCoordinates) {\n return state;\n }\n const { rowIndex } = cellCoordinates;\n\n const tabStop = getCell(gridMap, {\n row: rowIndex,\n col: {\n from: -1,\n direction: 'desc',\n },\n });\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop?.id || state.selectedId,\n gridMap,\n };\n },\n};\n\n/** Handle `KEY_NAV` action to update */\nexport const KEY_NAV: Reducer<KeyNavAction> = (state, action) => {\n const { id = state.selectedId || state.tabStops[0]?.id, key, ctrlKey } = action.payload;\n const index = state.tabStops.findIndex((tabStop) => tabStop.id === id);\n if (index === -1) {\n // tab stop not registered\n return state;\n }\n const currentTabStop = state.tabStops[index];\n if (currentTabStop.disabled) {\n return state;\n }\n\n const isGrid = currentTabStop.rowKey !== null;\n const isFirst = index === state.tabStops.findIndex(tabStopIsEnabled);\n const isLast = index === findLastIndex(state.tabStops, tabStopIsEnabled);\n // Translates the user key down event info into a navigation instruction.\n let navigation: Navigation | null = null;\n // eslint-disable-next-line default-case\n switch (key) {\n case 'ArrowLeft':\n if (isGrid) {\n navigation = 'PREVIOUS_COLUMN';\n } else if (state.direction === 'horizontal' || state.direction === 'both') {\n navigation =\n shouldLoopListHorizontally(state.direction, state.loopAround) && isFirst ? 'VERY_LAST' : 'PREVIOUS';\n }\n break;\n case 'ArrowRight':\n if (isGrid) {\n navigation = 'NEXT_COLUMN';\n } else if (state.direction === 'horizontal' || state.direction === 'both') {\n navigation =\n shouldLoopListHorizontally(state.direction, state.loopAround) && isLast ? 'VERY_FIRST' : 'NEXT';\n }\n break;\n case 'ArrowUp':\n if (isGrid) {\n navigation = 'PREVIOUS_ROW';\n } else if (state.direction === 'vertical' || state.direction === 'both') {\n navigation =\n shouldLoopListVertically(state.direction, state.loopAround) && isFirst ? 'VERY_LAST' : 'PREVIOUS';\n }\n break;\n case 'ArrowDown':\n if (isGrid) {\n navigation = 'NEXT_ROW';\n } else if (state.direction === 'vertical' || state.direction === 'both') {\n navigation =\n shouldLoopListVertically(state.direction, state.loopAround) && isLast ? 'VERY_FIRST' : 'NEXT';\n }\n break;\n case 'Home':\n if (isGrid && !ctrlKey) {\n navigation = state.gridJumpToShortcutDirection === 'vertical' ? 'FIRST_IN_COLUMN' : 'FIRST_IN_ROW';\n } else {\n navigation = 'VERY_FIRST';\n }\n break;\n case 'End':\n if (isGrid && !ctrlKey) {\n navigation = state.gridJumpToShortcutDirection === 'vertical' ? 'LAST_IN_COLUMN' : 'LAST_IN_ROW';\n } else {\n navigation = 'VERY_LAST';\n }\n break;\n }\n\n if (!navigation) {\n return state;\n }\n\n const newState = MOVES[navigation](state, currentTabStop, index);\n\n return { ...newState, isUsingKeyboard: true };\n};\n","import findLast from 'lodash/findLast';\nimport findLastIndex from 'lodash/findLastIndex';\n\nimport {\n Reducer,\n RegisterAction,\n ResetSelectedTabStopAction,\n SelectTabStopAction,\n SetAllowFocusingAction,\n State,\n UnregisterAction,\n UpdateTabStopAction,\n} from '../types';\nimport { tabStopIsEnabled } from '../utils';\n\n/** Determine the updated value for selectedId: */\nexport const getUpdatedSelectedId = (\n tabStops: State['tabStops'],\n currentSelectedId: State['selectedId'],\n defaultSelectedId: State['selectedId'] = null,\n): State['selectedId'] => {\n // Get tab stop by id\n const tabStop = currentSelectedId && tabStops.find((ts) => ts.id === currentSelectedId && !ts.disabled);\n if (!tabStop) {\n // Fallback to default selected id if available, or first enabled tab stop if not\n return tabStops.find((ts) => ts.id === defaultSelectedId)?.id || tabStops.find(tabStopIsEnabled)?.id || null;\n }\n return tabStop?.id || defaultSelectedId;\n};\n\n/** Handle `REGISTER_TAB_STOP` action registering a new tab stop. */\nexport const REGISTER_TAB_STOP: Reducer<RegisterAction> = (state, action) => {\n const newTabStop = action.payload;\n const newTabStopElement = newTabStop.domElementRef.current;\n\n if (!newTabStopElement) {\n return state;\n }\n\n // Find index of tab stop that\n const indexToInsertAt = findLastIndex(state.tabStops, (tabStop) => {\n if (tabStop.id === newTabStop.id) {\n // tab stop already registered\n return false;\n }\n const domTabStop = tabStop.domElementRef.current;\n\n // New tab stop is following the current tab stop\n return domTabStop?.compareDocumentPosition(newTabStopElement) === Node.DOCUMENT_POSITION_FOLLOWING;\n });\n const insertIndex = indexToInsertAt + 1;\n\n // Insert new tab stop at position `indexToInsertAt`.\n const newTabStops = [...state.tabStops];\n newTabStops.splice(insertIndex, 0, newTabStop);\n\n // Handle autofocus if needed\n let { selectedId, allowFocusing } = state;\n if (\n (state.autofocus === 'first' && insertIndex === 0) ||\n (state.autofocus === 'last' && insertIndex === newTabStops.length - 1) ||\n newTabStop.autofocus\n ) {\n allowFocusing = true;\n selectedId = newTabStop.id;\n }\n\n const newSelectedId =\n newTabStop.id === state.defaultSelectedId && !newTabStop.disabled\n ? newTabStop.id\n : getUpdatedSelectedId(newTabStops, selectedId, state.defaultSelectedId);\n\n return {\n ...state,\n /**\n * If the tab currently being registered is enabled and set as default selected,\n * set as selected.\n *\n */\n selectedId: newSelectedId,\n tabStops: newTabStops,\n gridMap: null,\n allowFocusing,\n };\n};\n\n/** Handle `UNREGISTER_TAB_STOP` action un-registering a new tab stop. */\nexport const UNREGISTER_TAB_STOP: Reducer<UnregisterAction> = (state, action) => {\n const { id } = action.payload;\n const newTabStops = state.tabStops.filter((tabStop) => tabStop.id !== id);\n if (newTabStops.length === state.tabStops.length) {\n // tab stop already unregistered\n return state;\n }\n\n /** Get the previous enabled tab stop */\n const previousTabStopIndex = state.tabStops.findIndex(\n (tabStop) => tabStop.id === state.selectedId && tabStopIsEnabled(tabStop),\n );\n\n const newLocal = previousTabStopIndex - 1 > -1;\n const previousTabStop = newLocal ? findLast(newTabStops, tabStopIsEnabled, previousTabStopIndex - 1) : undefined;\n\n return {\n ...state,\n /** Set the focus on either the previous tab stop if found or the one set as default */\n selectedId: getUpdatedSelectedId(newTabStops, state.selectedId, previousTabStop?.id || state.defaultSelectedId),\n tabStops: newTabStops,\n gridMap: null,\n };\n};\n\n/** Handle `UPDATE_TAB_STOP` action updating properties of a tab stop. */\nexport const UPDATE_TAB_STOP: Reducer<UpdateTabStopAction> = (state, action) => {\n const { id, rowKey, disabled } = action.payload;\n const index = state.tabStops.findIndex((tabStop) => tabStop.id === id);\n if (index === -1) {\n // tab stop not registered\n return state;\n }\n\n const tabStop = state.tabStops[index];\n if (tabStop.disabled === disabled && tabStop.rowKey === rowKey) {\n // Nothing to do so short-circuit.\n return state;\n }\n\n const newTabStop = { ...tabStop, rowKey, disabled };\n const newTabStops = [...state.tabStops];\n newTabStops.splice(index, 1, newTabStop);\n\n return {\n ...state,\n selectedId: getUpdatedSelectedId(newTabStops, state.selectedId, state.defaultSelectedId),\n tabStops: newTabStops,\n gridMap: null,\n };\n};\n\n/** Handle `SELECT_TAB_STOP` action selecting a tab stop. */\nexport const SELECT_TAB_STOP: Reducer<SelectTabStopAction> = (state, action) => {\n const { id, type } = action.payload;\n\n const tabStop = state.tabStops.find((ts) => ts.id === id);\n if (!tabStop || tabStop.disabled) {\n return state;\n }\n\n return {\n ...state,\n allowFocusing: true,\n selectedId: tabStop.id,\n isUsingKeyboard: type === 'keyboard',\n };\n};\n\nexport const SET_ALLOW_FOCUSING: Reducer<SetAllowFocusingAction> = (state, action) => {\n return {\n ...state,\n selectedId: getUpdatedSelectedId(state.tabStops, null, state.defaultSelectedId),\n allowFocusing: action.payload.allow,\n isUsingKeyboard: Boolean(action.payload.isKeyboardNavigation),\n };\n};\n\n/** Handle `RESET_SELECTED_TAB_STOP` action reseting the selected tab stop. */\nexport const RESET_SELECTED_TAB_STOP: Reducer<ResetSelectedTabStopAction> = (state) => {\n return {\n ...state,\n allowFocusing: false,\n selectedId: getUpdatedSelectedId(state.tabStops, null, state.defaultSelectedId),\n defaultSelectedId: getUpdatedSelectedId(state.tabStops, null, state.defaultSelectedId),\n isUsingKeyboard: false,\n };\n};\n","import findLast from 'lodash/findLast';\n\nimport { Action, OptionsUpdatedAction, Reducer, State } from '../types';\nimport { buildLoopAroundObject, tabStopIsEnabled } from '../utils';\nimport { KEY_NAV } from './keyboard-navigation';\nimport {\n REGISTER_TAB_STOP,\n UNREGISTER_TAB_STOP,\n UPDATE_TAB_STOP,\n SELECT_TAB_STOP,\n SET_ALLOW_FOCUSING,\n RESET_SELECTED_TAB_STOP,\n} from './tab-stop';\n\nexport const INITIAL_STATE: State = {\n selectedId: null,\n allowFocusing: false,\n tabStops: [],\n direction: 'horizontal',\n loopAround: buildLoopAroundObject(false),\n gridMap: null,\n defaultSelectedId: null,\n autofocus: undefined,\n isUsingKeyboard: false,\n};\n\nconst OPTIONS_UPDATED: Reducer<OptionsUpdatedAction> = (state, action) => {\n const { autofocus } = action.payload;\n let { selectedId, allowFocusing } = state;\n\n // Update selectedId when updating the `autofocus` option.\n if (!state.autofocus && autofocus) {\n if (autofocus === 'first') {\n selectedId = state.tabStops.find(tabStopIsEnabled)?.id || null;\n } else if (autofocus === 'last') {\n selectedId = findLast(state.tabStops, tabStopIsEnabled)?.id || null;\n }\n allowFocusing = true;\n }\n\n return {\n ...state,\n ...action.payload,\n selectedId,\n allowFocusing: action.payload.allowFocusing || allowFocusing,\n loopAround: buildLoopAroundObject(action.payload.loopAround),\n };\n};\n\n/** Reducers for each action type: */\nconst REDUCERS: { [Type in Action['type']]: Reducer<Extract<Action, { type: Type }>> } = {\n REGISTER_TAB_STOP,\n UNREGISTER_TAB_STOP,\n UPDATE_TAB_STOP,\n SELECT_TAB_STOP,\n OPTIONS_UPDATED,\n KEY_NAV,\n SET_ALLOW_FOCUSING,\n RESET_SELECTED_TAB_STOP,\n};\n\n/** Main reducer */\nexport const reducer: Reducer<Action> = (state, action) => {\n return REDUCERS[action.type]?.(state, action as any) || state;\n};\n","import React from 'react';\n\nimport noop from 'lodash/noop';\n\nimport { INITIAL_STATE } from '../../ducks/slice';\nimport { Action, State } from '../../types';\n\nexport type MovingFocusContext = Readonly<{\n state: State;\n dispatch: React.Dispatch<Action>;\n}>;\n\nexport const MovingFocusContext = React.createContext<MovingFocusContext>({\n state: INITIAL_STATE,\n dispatch: noop,\n});\n","import React from 'react';\n\nimport { INITIAL_STATE, reducer } from '../../ducks/slice';\nimport { MovingFocusOptions } from '../../types';\nimport { buildLoopAroundObject } from '../../utils';\nimport { MovingFocusContext } from './context';\n\nexport interface MovingFocusProviderProps {\n /**\n * The child content, which will include the DOM elements to rove between using the tab key.\n */\n children: React.ReactNode;\n /**\n * An optional object to customize the behaviour of the moving focus. It is fine to pass a new object every time\n * the containing component is rendered, and the options can be updated at any time.\n */\n options?: Partial<MovingFocusOptions>;\n}\n\n/**\n * Creates a roving tabindex context.\n */\nexport const MovingFocusProvider: React.FC<MovingFocusProviderProps> = ({ children, options }) => {\n const [state, dispatch] = React.useReducer(reducer, INITIAL_STATE, (st) => ({\n ...st,\n ...options,\n direction: options?.direction || st.direction,\n loopAround: buildLoopAroundObject(options?.loopAround),\n selectedId: options?.defaultSelectedId || INITIAL_STATE.selectedId,\n }));\n const isMounted = React.useRef(false);\n\n // Update the options whenever they change:\n React.useEffect(() => {\n // Skip update on mount (already up to date)\n if (!isMounted.current) {\n isMounted.current = true;\n return;\n }\n dispatch({\n type: 'OPTIONS_UPDATED',\n payload: {\n direction: options?.direction || INITIAL_STATE.direction,\n loopAround: buildLoopAroundObject(options?.loopAround || INITIAL_STATE.loopAround),\n defaultSelectedId: options?.defaultSelectedId || INITIAL_STATE.defaultSelectedId,\n autofocus: options?.autofocus || INITIAL_STATE.autofocus,\n allowFocusing: options?.allowFocusing || INITIAL_STATE.allowFocusing,\n listKey: options?.listKey || INITIAL_STATE.listKey,\n firstFocusDirection: options?.firstFocusDirection || INITIAL_STATE.firstFocusDirection,\n gridJumpToShortcutDirection:\n options?.gridJumpToShortcutDirection || INITIAL_STATE.gridJumpToShortcutDirection,\n },\n });\n }, [\n isMounted,\n options?.allowFocusing,\n options?.autofocus,\n options?.defaultSelectedId,\n options?.direction,\n options?.loopAround,\n options?.listKey,\n options?.firstFocusDirection,\n options?.gridJumpToShortcutDirection,\n ]);\n\n // Create a cached object to use as the context value:\n const context = React.useMemo(() => ({ state, dispatch }), [state]);\n\n return <MovingFocusContext.Provider value={context}>{children}</MovingFocusContext.Provider>;\n};\n","import React, { useEffect } from 'react';\n\nimport { MovingFocusContext } from '../../components/MovingFocusProvider/context';\nimport { BaseHookOptions } from '../../types';\nimport { getPointerTypeFromEvent } from '../../utils';\n\n/**\n * Hook options\n */\ntype Options = [\n /** The DOM id of the tab stop. */\n id: string,\n ...baseOptions: BaseHookOptions,\n];\n\n/**\n * Hook to use in tab stop element of a virtual focus (ex: options of a listbox in a combobox).\n *\n * @returns true if the current tab stop has virtual focus\n */\nexport const useVirtualFocus: (...args: Options) => boolean = (\n id,\n domElementRef,\n disabled = false,\n rowKey = null,\n autofocus = false,\n) => {\n const isMounted = React.useRef(false);\n const { state, dispatch } = React.useContext(MovingFocusContext);\n\n // Register the tab stop on mount and unregister it on unmount:\n React.useEffect(\n () => {\n const { current: domElement } = domElementRef;\n if (!domElement) {\n return undefined;\n }\n // Select tab stop on click\n const onClick = (event?: PointerEvent | Event) => {\n dispatch({\n type: 'SELECT_TAB_STOP',\n payload: { id, type: getPointerTypeFromEvent(event) },\n });\n };\n domElement.addEventListener('click', onClick);\n\n // Register tab stop in context\n dispatch({ type: 'REGISTER_TAB_STOP', payload: { id, domElementRef, rowKey, disabled, autofocus } });\n\n return () => {\n domElement.removeEventListener('click', onClick);\n dispatch({ type: 'UNREGISTER_TAB_STOP', payload: { id } });\n };\n },\n /**\n * Pass the list key as dependency to make tab stops\n * re-register when it changes.\n */\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [state.listKey],\n );\n\n /*\n * Update the tab stop data if `rowKey` or `disabled` change.\n * The isMounted flag is used to prevent this effect running on mount, which is benign but redundant (as the\n * REGISTER_TAB_STOP action would have just been dispatched).\n */\n React.useEffect(\n () => {\n if (isMounted.current) {\n dispatch({ type: 'UPDATE_TAB_STOP', payload: { id, rowKey, disabled } });\n } else {\n isMounted.current = true;\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [disabled, rowKey],\n );\n\n const isActive = id === state.selectedId;\n\n // Scroll element into view when highlighted\n useEffect(() => {\n const { current } = domElementRef;\n if (isActive && current && current.scrollIntoView) {\n /**\n * In some cases, the selected item is contained in a popover\n * that won't be immediately set in the correct position.\n * Setting a small timeout before scroll the item into view\n * leaves it time to settle at the correct position.\n */\n const timeout = setTimeout(() => {\n current.scrollIntoView({ block: 'nearest' });\n }, 10);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n\n return undefined;\n }, [domElementRef, isActive]);\n\n const focused = isActive && state.allowFocusing;\n\n // Determine if the current tab stop is the currently active one:\n return focused;\n};\n","import React from 'react';\n\nimport { MovingFocusContext } from '../../components/MovingFocusProvider/context';\nimport { NAV_KEYS } from '../../ducks/keyboard-navigation';\n\n/**\n * Hook to use in a virtual focus parent (ex: `aria-activedescendant` on the input of a combobox).\n * * @returns the id of the currently active tab stop (virtual focus)\n */\nexport const useVirtualFocusParent = (ref: React.RefObject<HTMLElement>): string | undefined => {\n const { state, dispatch } = React.useContext(MovingFocusContext);\n\n React.useEffect(() => {\n const { current: element } = ref;\n if (!element) {\n return undefined;\n }\n\n function handleKeyDown(evt: KeyboardEvent) {\n const eventKey = evt.key as any;\n if (\n // Don't move if the current direction doesn't allow key\n !NAV_KEYS[state.direction].includes(eventKey) ||\n // Don't move if alt key is pressed\n evt.altKey ||\n // Don't move the focus if it hasn't been set yet and `firstFocusDirection` doesn't allow key\n (!state.allowFocusing &&\n state.firstFocusDirection &&\n !NAV_KEYS[state.firstFocusDirection].includes(eventKey))\n ) {\n return;\n }\n // If focus isn't allowed yet, simply enable it to stay on first item\n if (!state.allowFocusing && eventKey === 'ArrowDown') {\n dispatch({ type: 'SET_ALLOW_FOCUSING', payload: { allow: true, isKeyboardNavigation: true } });\n } else {\n dispatch({ type: 'KEY_NAV', payload: { key: eventKey, ctrlKey: evt.ctrlKey } });\n }\n\n evt.preventDefault();\n }\n element.addEventListener('keydown', handleKeyDown);\n return () => {\n element.removeEventListener('keydown', handleKeyDown);\n };\n }, [dispatch, ref, state.allowFocusing, state.direction, state.firstFocusDirection]);\n const focused = (state.allowFocusing && state.selectedId) || undefined;\n return focused;\n};\n"],"names":["DisabledStateContext","React","createContext","state","DisabledStateProvider","children","value","_jsx","Provider","useDisabledStateContext","useContext","EVENT_TYPES","isClickAway","targets","refs","some","ref","target","current","contains","useClickAway","callback","childrenRefs","useEffect","currentRefs","isEmpty","undefined","listener","evt","composedPath","forEach","evtType","document","addEventListener","removeEventListener","ClickAwayAncestorContext","ClickAwayProvider","parentRef","parentContext","currentContext","useMemo","context","addRefs","newChildrenRefs","push","useRef","displayName","A11YLiveMessage","type","atomic","role","hidden","relevant","className","forwardedProps","join","visuallyHidden","PortalContext","container","body","PortalProvider","Portal","enabled","init","useLayoutEffect","teardown","_Fragment","createPortal","createGridMap","tabStops","tabStopsByRowKey","groupBy","rowKeys","reduce","acc","rowKey","isNil","includes","tabStopIsEnabled","tabStop","disabled","LOOP_AROUND_TYPES","nextLoop","nextEnd","inside","CELL_SEARCH_DIRECTION","asc","desc","buildLoopAroundObject","loopAround","newLoopAround","row","col","isNumberCoords","coords","isDirectionCoords","Boolean","from","findCellInCol","gridMap","rowCoords","cellSelector","lastIndex","length","searchIndex","direction","searchCellFunc","findLast","find","rowKeyWithEnabledCell","index","cell","hasCell","cellRowIndex","correctRowIndex","findCellInRow","colCoords","currentRow","parseColsForCell","maxColIndex","maxLength","rowIndex","rowLength","fromIndex","rowWithEnabledCed","getCell","getCellCoordinates","currentRowKey","findIndex","columnOffset","ts","id","shouldLoopListVertically","shouldLoopListHorizontally","getPointerTypeFromEvent","event","pointerType","VERTICAL_NAV_KEYS","HORIZONTAL_NAV_KEYS","KEY_NAV_KEYS","NAV_KEYS","both","vertical","horizontal","MOVES","NEXT","_","i","allowFocusing","selectedId","PREVIOUS","NEXT_ROW","currentTabStop","cellCoordinates","nextRow","PREVIOUS_ROW","previousRow","VERY_FIRST","VERY_LAST","NEXT_COLUMN","PREVIOUS_COLUMN","previousColumn","FIRST_IN_COLUMN","LAST_IN_COLUMN","FIRST_IN_ROW","LAST_IN_ROW","KEY_NAV","action","key","ctrlKey","payload","isGrid","isFirst","isLast","findLastIndex","navigation","gridJumpToShortcutDirection","newState","isUsingKeyboard","getUpdatedSelectedId","currentSelectedId","defaultSelectedId","REGISTER_TAB_STOP","newTabStop","newTabStopElement","domElementRef","indexToInsertAt","domTabStop","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","insertIndex","newTabStops","splice","autofocus","newSelectedId","UNREGISTER_TAB_STOP","filter","previousTabStopIndex","newLocal","previousTabStop","UPDATE_TAB_STOP","SELECT_TAB_STOP","SET_ALLOW_FOCUSING","allow","isKeyboardNavigation","RESET_SELECTED_TAB_STOP","INITIAL_STATE","OPTIONS_UPDATED","REDUCERS","reducer","MovingFocusContext","dispatch","noop","MovingFocusProvider","options","useReducer","st","isMounted","listKey","firstFocusDirection","useVirtualFocus","domElement","onClick","isActive","scrollIntoView","timeout","setTimeout","block","clearTimeout","focused","useVirtualFocusParent","element","handleKeyDown","eventKey","altKey","preventDefault"],"mappings":";;;;;;;;;;;;AAIO,MAAMA,oBAAoB,gBAAGC,cAAK,CAACC,aAAa,CAA4B;AAAEC,EAAAA,KAAK,EAAE;AAAK,CAAC,CAAC;AAMnG;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAAC;EAAEC,QAAQ;EAAE,GAAGC;AAAkC,CAAC,EAAE;AACtF,EAAA,oBAAOC,GAAA,CAACP,oBAAoB,CAACQ,QAAQ,EAAA;AAACF,IAAAA,KAAK,EAAEA,KAAM;AAAAD,IAAAA,QAAA,EAAEA;AAAQ,GAAgC,CAAC;AAClG;;AAEA;AACA;AACA;AACO,SAASI,uBAAuBA,GAA8B;EACjE,OAAOC,UAAU,CAACV,oBAAoB,CAAC;AAC3C;;ACjBA,MAAMW,WAAW,GAAG,CAAC,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