1 line
33 KiB
JSON
1 line
33 KiB
JSON
{"ast":null,"code":"import * as React from 'react';\nimport { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';\nimport { useGridLogger } from '../../utils/useGridLogger';\nimport { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';\nimport { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelector';\nimport { useGridVisibleRows } from '../../utils/useGridVisibleRows';\nimport { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../colDef/gridCheckboxSelectionColDef';\nimport { gridClasses } from '../../../constants/gridClasses';\nimport { GridCellModes } from '../../../models/gridEditRowModel';\nimport { isNavigationKey } from '../../../utils/keyboardUtils';\nimport { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';\nimport { gridPinnedRowsSelector } from '../rows/gridRowsSelector';\nfunction enrichPageRowsWithPinnedRows(apiRef, rows) {\n const pinnedRows = gridPinnedRowsSelector(apiRef) || {};\n return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];\n}\n/**\n * @requires useGridSorting (method) - can be after\n * @requires useGridFilter (state) - can be after\n * @requires useGridColumns (state, method) - can be after\n * @requires useGridDimensions (method) - can be after\n * @requires useGridFocus (method) - can be after\n * @requires useGridScroll (method) - can be after\n * @requires useGridColumnSpanning (method) - can be after\n */\n\nexport const useGridKeyboardNavigation = (apiRef, props) => {\n const logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');\n const initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;\n const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);\n /**\n * @param {number} colIndex Index of the column to focus\n * @param {number} rowIndex index of the row to focus\n * @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.\n * TODO replace with apiRef.current.unstable_moveFocusToRelativeCell()\n */\n\n const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left') => {\n const visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);\n const nextCellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, colIndex);\n if (nextCellColSpanInfo && nextCellColSpanInfo.spannedByColSpan) {\n if (closestColumnToUse === 'left') {\n colIndex = nextCellColSpanInfo.leftVisibleCellIndex;\n } else if (closestColumnToUse === 'right') {\n colIndex = nextCellColSpanInfo.rightVisibleCellIndex;\n }\n } // `scrollToIndexes` requires a rowIndex relative to all visible rows.\n // Those rows do not include pinned rows, but pinned rows do not need scroll anyway.\n\n const rowIndexRelativeToAllRows = visibleSortedRows.findIndex(row => row.id === rowId);\n logger.debug(`Navigating to cell row ${rowIndexRelativeToAllRows}, col ${colIndex}`);\n apiRef.current.scrollToIndexes({\n colIndex,\n rowIndex: rowIndexRelativeToAllRows\n });\n const field = apiRef.current.getVisibleColumns()[colIndex].field;\n apiRef.current.setCellFocus(rowId, field);\n }, [apiRef, logger]);\n const goToHeader = React.useCallback((colIndex, event) => {\n logger.debug(`Navigating to header col ${colIndex}`);\n apiRef.current.scrollToIndexes({\n colIndex\n });\n const field = apiRef.current.getVisibleColumns()[colIndex].field;\n apiRef.current.setColumnHeaderFocus(field, event);\n }, [apiRef, logger]);\n const getRowIdFromIndex = React.useCallback(rowIndex => {\n return currentPageRows[rowIndex].id;\n }, [currentPageRows]);\n const handleCellNavigationKeyDown = React.useCallback((params, event) => {\n const dimensions = apiRef.current.getRootDimensions();\n if (currentPageRows.length === 0 || !dimensions) {\n return;\n }\n const viewportPageSize = apiRef.current.unstable_getViewportPageSize();\n const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;\n const rowIndexBefore = currentPageRows.findIndex(row => row.id === params.id);\n const firstRowIndexInPage = 0;\n const lastRowIndexInPage = currentPageRows.length - 1;\n const firstColIndex = 0;\n const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;\n let shouldPreventDefault = true;\n switch (event.key) {\n case 'ArrowDown':\n case 'Enter':\n {\n // TODO v6: Remove Enter case because `cellNavigationKeyDown` is not fired by the new editing API\n // \"Enter\" is only triggered by the row / cell editing feature\n if (rowIndexBefore < lastRowIndexInPage) {\n goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));\n }\n break;\n }\n case 'ArrowUp':\n {\n if (rowIndexBefore > firstRowIndexInPage) {\n goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore - 1));\n } else {\n goToHeader(colIndexBefore, event);\n }\n break;\n }\n case 'ArrowRight':\n {\n if (colIndexBefore < lastColIndex) {\n goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');\n }\n break;\n }\n case 'ArrowLeft':\n {\n if (colIndexBefore > firstColIndex) {\n goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore));\n }\n break;\n }\n case 'Tab':\n {\n // \"Tab\" is only triggered by the row / cell editing feature\n if (event.shiftKey && colIndexBefore > firstColIndex) {\n goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore), 'left');\n } else if (!event.shiftKey && colIndexBefore < lastColIndex) {\n goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');\n }\n break;\n }\n case ' ':\n {\n const field = params.field;\n if (field === GRID_DETAIL_PANEL_TOGGLE_FIELD) {\n break;\n }\n const colDef = params.colDef;\n if (colDef && colDef.type === 'treeDataGroup') {\n break;\n }\n if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {\n goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));\n }\n break;\n }\n case 'PageDown':\n {\n if (rowIndexBefore < lastRowIndexInPage) {\n goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));\n }\n break;\n }\n case 'PageUp':\n {\n // Go to the first row before going to header\n const nextRowIndex = Math.max(rowIndexBefore - viewportPageSize, firstRowIndexInPage);\n if (nextRowIndex !== rowIndexBefore && nextRowIndex >= firstRowIndexInPage) {\n goToCell(colIndexBefore, getRowIdFromIndex(nextRowIndex));\n } else {\n goToHeader(colIndexBefore, event);\n }\n break;\n }\n case 'Home':\n {\n if (event.ctrlKey || event.metaKey || event.shiftKey) {\n goToCell(firstColIndex, getRowIdFromIndex(firstRowIndexInPage));\n } else {\n goToCell(firstColIndex, getRowIdFromIndex(rowIndexBefore));\n }\n break;\n }\n case 'End':\n {\n if (event.ctrlKey || event.metaKey || event.shiftKey) {\n goToCell(lastColIndex, getRowIdFromIndex(lastRowIndexInPage));\n } else {\n goToCell(lastColIndex, getRowIdFromIndex(rowIndexBefore));\n }\n break;\n }\n default:\n {\n shouldPreventDefault = false;\n }\n }\n if (shouldPreventDefault) {\n event.preventDefault();\n }\n }, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);\n const handleColumnHeaderKeyDown = React.useCallback((params, event) => {\n const headerTitleNode = event.currentTarget.querySelector(`.${gridClasses.columnHeaderTitleContainerContent}`);\n const isFromInsideContent = !!headerTitleNode && headerTitleNode.contains(event.target);\n if (isFromInsideContent && params.field !== GRID_CHECKBOX_SELECTION_COL_DEF.field) {\n // When focus is on a nested input, keyboard events have no effect to avoid conflicts with native events.\n // There is one exception for the checkBoxHeader\n return;\n }\n const dimensions = apiRef.current.getRootDimensions();\n if (!dimensions) {\n return;\n }\n const viewportPageSize = apiRef.current.unstable_getViewportPageSize();\n const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;\n const firstRowIndexInPage = 0;\n const lastRowIndexInPage = currentPageRows.length - 1;\n const firstColIndex = 0;\n const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;\n let shouldPreventDefault = true;\n switch (event.key) {\n case 'ArrowDown':\n {\n if (firstRowIndexInPage !== null) {\n goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));\n }\n break;\n }\n case 'ArrowRight':\n {\n if (colIndexBefore < lastColIndex) {\n goToHeader(colIndexBefore + 1, event);\n }\n break;\n }\n case 'ArrowLeft':\n {\n if (colIndexBefore > firstColIndex) {\n goToHeader(colIndexBefore - 1, event);\n }\n break;\n }\n case 'PageDown':\n {\n if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {\n goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));\n }\n break;\n }\n case 'Home':\n {\n goToHeader(firstColIndex, event);\n break;\n }\n case 'End':\n {\n goToHeader(lastColIndex, event);\n break;\n }\n case 'Enter':\n {\n if (event.ctrlKey || event.metaKey) {\n apiRef.current.toggleColumnMenu(params.field);\n }\n break;\n }\n case ' ':\n {\n // prevent Space event from scrolling\n break;\n }\n default:\n {\n shouldPreventDefault = false;\n }\n }\n if (shouldPreventDefault) {\n event.preventDefault();\n }\n }, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);\n const handleCellKeyDown = React.useCallback((params, event) => {\n // Ignore portal\n if (!event.currentTarget.contains(event.target)) {\n return;\n } // Get the most recent params because the cell mode may have changed by another listener\n\n const cellParams = apiRef.current.getCellParams(params.id, params.field);\n if (cellParams.cellMode !== GridCellModes.Edit && isNavigationKey(event.key)) {\n apiRef.current.publishEvent('cellNavigationKeyDown', cellParams, event);\n }\n }, [apiRef]);\n useGridApiEventHandler(apiRef, 'cellNavigationKeyDown', handleCellNavigationKeyDown);\n useGridApiEventHandler(apiRef, 'columnHeaderKeyDown', handleColumnHeaderKeyDown);\n useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);\n};","map":{"version":3,"names":["React","gridVisibleColumnDefinitionsSelector","useGridLogger","useGridApiEventHandler","gridVisibleSortedRowEntriesSelector","useGridVisibleRows","GRID_CHECKBOX_SELECTION_COL_DEF","gridClasses","GridCellModes","isNavigationKey","GRID_DETAIL_PANEL_TOGGLE_FIELD","gridPinnedRowsSelector","enrichPageRowsWithPinnedRows","apiRef","rows","pinnedRows","top","bottom","useGridKeyboardNavigation","props","logger","initialCurrentPageRows","currentPageRows","useMemo","goToCell","useCallback","colIndex","rowId","closestColumnToUse","visibleSortedRows","nextCellColSpanInfo","current","unstable_getCellColSpanInfo","spannedByColSpan","leftVisibleCellIndex","rightVisibleCellIndex","rowIndexRelativeToAllRows","findIndex","row","id","debug","scrollToIndexes","rowIndex","field","getVisibleColumns","setCellFocus","goToHeader","event","setColumnHeaderFocus","getRowIdFromIndex","handleCellNavigationKeyDown","params","dimensions","getRootDimensions","length","viewportPageSize","unstable_getViewportPageSize","colIndexBefore","getColumnIndex","rowIndexBefore","firstRowIndexInPage","lastRowIndexInPage","firstColIndex","lastColIndex","shouldPreventDefault","key","shiftKey","colDef","type","Math","min","nextRowIndex","max","ctrlKey","metaKey","preventDefault","handleColumnHeaderKeyDown","headerTitleNode","currentTarget","querySelector","columnHeaderTitleContainerContent","isFromInsideContent","contains","target","toggleColumnMenu","handleCellKeyDown","cellParams","getCellParams","cellMode","Edit","publishEvent"],"sources":["/home/gnx/Desktop/ETB/ETB-FrontEnd/node_modules/@mui/x-data-grid/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js"],"sourcesContent":["import * as React from 'react';\nimport { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';\nimport { useGridLogger } from '../../utils/useGridLogger';\nimport { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';\nimport { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelector';\nimport { useGridVisibleRows } from '../../utils/useGridVisibleRows';\nimport { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../colDef/gridCheckboxSelectionColDef';\nimport { gridClasses } from '../../../constants/gridClasses';\nimport { GridCellModes } from '../../../models/gridEditRowModel';\nimport { isNavigationKey } from '../../../utils/keyboardUtils';\nimport { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';\nimport { gridPinnedRowsSelector } from '../rows/gridRowsSelector';\n\nfunction enrichPageRowsWithPinnedRows(apiRef, rows) {\n const pinnedRows = gridPinnedRowsSelector(apiRef) || {};\n return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];\n}\n/**\n * @requires useGridSorting (method) - can be after\n * @requires useGridFilter (state) - can be after\n * @requires useGridColumns (state, method) - can be after\n * @requires useGridDimensions (method) - can be after\n * @requires useGridFocus (method) - can be after\n * @requires useGridScroll (method) - can be after\n * @requires useGridColumnSpanning (method) - can be after\n */\n\n\nexport const useGridKeyboardNavigation = (apiRef, props) => {\n const logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');\n const initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;\n const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);\n /**\n * @param {number} colIndex Index of the column to focus\n * @param {number} rowIndex index of the row to focus\n * @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.\n * TODO replace with apiRef.current.unstable_moveFocusToRelativeCell()\n */\n\n const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left') => {\n const visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);\n const nextCellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, colIndex);\n\n if (nextCellColSpanInfo && nextCellColSpanInfo.spannedByColSpan) {\n if (closestColumnToUse === 'left') {\n colIndex = nextCellColSpanInfo.leftVisibleCellIndex;\n } else if (closestColumnToUse === 'right') {\n colIndex = nextCellColSpanInfo.rightVisibleCellIndex;\n }\n } // `scrollToIndexes` requires a rowIndex relative to all visible rows.\n // Those rows do not include pinned rows, but pinned rows do not need scroll anyway.\n\n\n const rowIndexRelativeToAllRows = visibleSortedRows.findIndex(row => row.id === rowId);\n logger.debug(`Navigating to cell row ${rowIndexRelativeToAllRows}, col ${colIndex}`);\n apiRef.current.scrollToIndexes({\n colIndex,\n rowIndex: rowIndexRelativeToAllRows\n });\n const field = apiRef.current.getVisibleColumns()[colIndex].field;\n apiRef.current.setCellFocus(rowId, field);\n }, [apiRef, logger]);\n const goToHeader = React.useCallback((colIndex, event) => {\n logger.debug(`Navigating to header col ${colIndex}`);\n apiRef.current.scrollToIndexes({\n colIndex\n });\n const field = apiRef.current.getVisibleColumns()[colIndex].field;\n apiRef.current.setColumnHeaderFocus(field, event);\n }, [apiRef, logger]);\n const getRowIdFromIndex = React.useCallback(rowIndex => {\n return currentPageRows[rowIndex].id;\n }, [currentPageRows]);\n const handleCellNavigationKeyDown = React.useCallback((params, event) => {\n const dimensions = apiRef.current.getRootDimensions();\n\n if (currentPageRows.length === 0 || !dimensions) {\n return;\n }\n\n const viewportPageSize = apiRef.current.unstable_getViewportPageSize();\n const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;\n const rowIndexBefore = currentPageRows.findIndex(row => row.id === params.id);\n const firstRowIndexInPage = 0;\n const lastRowIndexInPage = currentPageRows.length - 1;\n const firstColIndex = 0;\n const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;\n let shouldPreventDefault = true;\n\n switch (event.key) {\n case 'ArrowDown':\n case 'Enter':\n {\n // TODO v6: Remove Enter case because `cellNavigationKeyDown` is not fired by the new editing API\n // \"Enter\" is only triggered by the row / cell editing feature\n if (rowIndexBefore < lastRowIndexInPage) {\n goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));\n }\n\n break;\n }\n\n case 'ArrowUp':\n {\n if (rowIndexBefore > firstRowIndexInPage) {\n goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore - 1));\n } else {\n goToHeader(colIndexBefore, event);\n }\n\n break;\n }\n\n case 'ArrowRight':\n {\n if (colIndexBefore < lastColIndex) {\n goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');\n }\n\n break;\n }\n\n case 'ArrowLeft':\n {\n if (colIndexBefore > firstColIndex) {\n goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore));\n }\n\n break;\n }\n\n case 'Tab':\n {\n // \"Tab\" is only triggered by the row / cell editing feature\n if (event.shiftKey && colIndexBefore > firstColIndex) {\n goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore), 'left');\n } else if (!event.shiftKey && colIndexBefore < lastColIndex) {\n goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');\n }\n\n break;\n }\n\n case ' ':\n {\n const field = params.field;\n\n if (field === GRID_DETAIL_PANEL_TOGGLE_FIELD) {\n break;\n }\n\n const colDef = params.colDef;\n\n if (colDef && colDef.type === 'treeDataGroup') {\n break;\n }\n\n if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {\n goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));\n }\n\n break;\n }\n\n case 'PageDown':\n {\n if (rowIndexBefore < lastRowIndexInPage) {\n goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));\n }\n\n break;\n }\n\n case 'PageUp':\n {\n // Go to the first row before going to header\n const nextRowIndex = Math.max(rowIndexBefore - viewportPageSize, firstRowIndexInPage);\n\n if (nextRowIndex !== rowIndexBefore && nextRowIndex >= firstRowIndexInPage) {\n goToCell(colIndexBefore, getRowIdFromIndex(nextRowIndex));\n } else {\n goToHeader(colIndexBefore, event);\n }\n\n break;\n }\n\n case 'Home':\n {\n if (event.ctrlKey || event.metaKey || event.shiftKey) {\n goToCell(firstColIndex, getRowIdFromIndex(firstRowIndexInPage));\n } else {\n goToCell(firstColIndex, getRowIdFromIndex(rowIndexBefore));\n }\n\n break;\n }\n\n case 'End':\n {\n if (event.ctrlKey || event.metaKey || event.shiftKey) {\n goToCell(lastColIndex, getRowIdFromIndex(lastRowIndexInPage));\n } else {\n goToCell(lastColIndex, getRowIdFromIndex(rowIndexBefore));\n }\n\n break;\n }\n\n default:\n {\n shouldPreventDefault = false;\n }\n }\n\n if (shouldPreventDefault) {\n event.preventDefault();\n }\n }, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);\n const handleColumnHeaderKeyDown = React.useCallback((params, event) => {\n const headerTitleNode = event.currentTarget.querySelector(`.${gridClasses.columnHeaderTitleContainerContent}`);\n const isFromInsideContent = !!headerTitleNode && headerTitleNode.contains(event.target);\n\n if (isFromInsideContent && params.field !== GRID_CHECKBOX_SELECTION_COL_DEF.field) {\n // When focus is on a nested input, keyboard events have no effect to avoid conflicts with native events.\n // There is one exception for the checkBoxHeader\n return;\n }\n\n const dimensions = apiRef.current.getRootDimensions();\n\n if (!dimensions) {\n return;\n }\n\n const viewportPageSize = apiRef.current.unstable_getViewportPageSize();\n const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;\n const firstRowIndexInPage = 0;\n const lastRowIndexInPage = currentPageRows.length - 1;\n const firstColIndex = 0;\n const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;\n let shouldPreventDefault = true;\n\n switch (event.key) {\n case 'ArrowDown':\n {\n if (firstRowIndexInPage !== null) {\n goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));\n }\n\n break;\n }\n\n case 'ArrowRight':\n {\n if (colIndexBefore < lastColIndex) {\n goToHeader(colIndexBefore + 1, event);\n }\n\n break;\n }\n\n case 'ArrowLeft':\n {\n if (colIndexBefore > firstColIndex) {\n goToHeader(colIndexBefore - 1, event);\n }\n\n break;\n }\n\n case 'PageDown':\n {\n if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {\n goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));\n }\n\n break;\n }\n\n case 'Home':\n {\n goToHeader(firstColIndex, event);\n break;\n }\n\n case 'End':\n {\n goToHeader(lastColIndex, event);\n break;\n }\n\n case 'Enter':\n {\n if (event.ctrlKey || event.metaKey) {\n apiRef.current.toggleColumnMenu(params.field);\n }\n\n break;\n }\n\n case ' ':\n {\n // prevent Space event from scrolling\n break;\n }\n\n default:\n {\n shouldPreventDefault = false;\n }\n }\n\n if (shouldPreventDefault) {\n event.preventDefault();\n }\n }, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);\n const handleCellKeyDown = React.useCallback((params, event) => {\n // Ignore portal\n if (!event.currentTarget.contains(event.target)) {\n return;\n } // Get the most recent params because the cell mode may have changed by another listener\n\n\n const cellParams = apiRef.current.getCellParams(params.id, params.field);\n\n if (cellParams.cellMode !== GridCellModes.Edit && isNavigationKey(event.key)) {\n apiRef.current.publishEvent('cellNavigationKeyDown', cellParams, event);\n }\n }, [apiRef]);\n useGridApiEventHandler(apiRef, 'cellNavigationKeyDown', handleCellNavigationKeyDown);\n useGridApiEventHandler(apiRef, 'columnHeaderKeyDown', handleColumnHeaderKeyDown);\n useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);\n};"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,oCAAoC,QAAQ,gCAAgC;AACrF,SAASC,aAAa,QAAQ,2BAA2B;AACzD,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SAASC,mCAAmC,QAAQ,8BAA8B;AAClF,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,+BAA+B,QAAQ,6CAA6C;AAC7F,SAASC,WAAW,QAAQ,gCAAgC;AAC5D,SAASC,aAAa,QAAQ,kCAAkC;AAChE,SAASC,eAAe,QAAQ,8BAA8B;AAC9D,SAASC,8BAA8B,QAAQ,+CAA+C;AAC9F,SAASC,sBAAsB,QAAQ,0BAA0B;AAEjE,SAASC,4BAA4BA,CAACC,MAAM,EAAEC,IAAI,EAAE;EAClD,MAAMC,UAAU,GAAGJ,sBAAsB,CAACE,MAAM,CAAC,IAAI,CAAC,CAAC;EACvD,OAAO,CAAC,IAAIE,UAAU,CAACC,GAAG,IAAI,EAAE,CAAC,EAAE,GAAGF,IAAI,EAAE,IAAIC,UAAU,CAACE,MAAM,IAAI,EAAE,CAAC,CAAC;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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