@mui/x-data-grid 5.13.0 → 5.15.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/CHANGELOG.md +156 -6
- package/DataGrid/DataGrid.js +6 -0
- package/DataGrid/useDataGridComponent.js +1 -1
- package/DataGrid/useDataGridProps.js +1 -0
- package/colDef/gridActionsColDef.js +2 -0
- package/colDef/gridBooleanColDef.js +3 -1
- package/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/colDef/gridDateOperators.d.ts +1 -1
- package/colDef/gridDateOperators.js +4 -2
- package/colDef/gridNumericOperators.js +4 -2
- package/colDef/gridStringColDef.d.ts +3 -0
- package/colDef/gridStringColDef.js +6 -0
- package/colDef/gridStringOperators.js +4 -2
- package/components/GridRow.js +5 -1
- package/components/base/GridOverlays.js +4 -1
- package/components/cell/GridBooleanCell.d.ts +5 -2
- package/components/cell/GridBooleanCell.js +93 -2
- package/components/cell/GridEditDateCell.js +5 -1
- package/components/cell/index.d.ts +1 -0
- package/components/cell/index.js +1 -0
- package/components/columnSelection/GridCellCheckboxRenderer.js +12 -1
- package/components/containers/GridRoot.js +4 -2
- package/components/containers/GridRootStyles.js +10 -0
- package/components/toolbar/GridToolbarExport.js +20 -10
- package/constants/gridClasses.d.ts +41 -1
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +9 -2
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +2 -1
- package/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/hooks/features/columns/useGridColumns.d.ts +1 -1
- package/hooks/features/columns/useGridColumns.js +13 -6
- package/hooks/features/dimensions/useGridDimensions.js +6 -1
- package/hooks/features/editRows/useGridCellEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridCellEditing.new.js +7 -4
- package/hooks/features/editRows/useGridEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +3 -3
- package/hooks/features/export/utils.d.ts +1 -1
- package/hooks/features/export/utils.js +16 -2
- package/hooks/features/filter/gridFilterUtils.js +6 -0
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.js +30 -5
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +42 -34
- package/hooks/features/pagination/useGridPage.js +4 -3
- package/hooks/features/pagination/useGridPageSize.js +7 -4
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
- package/hooks/features/rows/gridRowsSelector.d.ts +14 -0
- package/hooks/features/rows/gridRowsSelector.js +20 -1
- package/hooks/features/rows/gridRowsState.d.ts +8 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +5 -1
- package/hooks/features/rows/gridRowsUtils.js +21 -3
- package/hooks/features/rows/index.d.ts +1 -1
- package/hooks/features/rows/index.js +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +19 -4
- package/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/hooks/features/scroll/useGridScroll.js +7 -2
- package/hooks/features/selection/useGridSelection.js +28 -10
- package/hooks/features/sorting/gridSortingUtils.d.ts +1 -0
- package/hooks/features/sorting/gridSortingUtils.js +10 -11
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/sorting/useGridSorting.js +42 -6
- package/hooks/features/statePersistence/gridStatePersistenceInterface.d.ts +12 -1
- package/hooks/features/statePersistence/index.d.ts +1 -1
- package/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +3 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +46 -21
- package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
- package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
- package/hooks/utils/useGridNativeEventListener.js +1 -1
- package/index.js +1 -1
- package/internals/index.d.ts +6 -3
- package/internals/index.js +5 -2
- package/legacy/DataGrid/DataGrid.js +6 -0
- package/legacy/DataGrid/useDataGridComponent.js +1 -1
- package/legacy/DataGrid/useDataGridProps.js +1 -0
- package/legacy/colDef/gridActionsColDef.js +2 -0
- package/legacy/colDef/gridBooleanColDef.js +3 -1
- package/legacy/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/legacy/colDef/gridDateOperators.js +4 -2
- package/legacy/colDef/gridNumericOperators.js +4 -2
- package/legacy/colDef/gridStringColDef.js +6 -0
- package/legacy/colDef/gridStringOperators.js +4 -2
- package/legacy/components/GridRow.js +5 -1
- package/legacy/components/base/GridOverlays.js +4 -1
- package/legacy/components/cell/GridBooleanCell.js +93 -2
- package/legacy/components/cell/GridEditDateCell.js +5 -1
- package/legacy/components/cell/index.js +1 -0
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +11 -1
- package/legacy/components/containers/GridRoot.js +4 -2
- package/legacy/components/containers/GridRootStyles.js +3 -3
- package/legacy/components/toolbar/GridToolbarExport.js +20 -10
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +9 -2
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/legacy/hooks/features/columns/useGridColumns.js +13 -8
- package/legacy/hooks/features/dimensions/useGridDimensions.js +6 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +7 -4
- package/legacy/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/legacy/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +3 -3
- package/legacy/hooks/features/export/utils.js +21 -2
- package/legacy/hooks/features/filter/gridFilterUtils.js +6 -0
- package/legacy/hooks/features/filter/useGridFilter.js +30 -5
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +47 -34
- package/legacy/hooks/features/pagination/useGridPage.js +4 -3
- package/legacy/hooks/features/pagination/useGridPageSize.js +7 -4
- package/legacy/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
- package/legacy/hooks/features/rows/gridRowsSelector.js +23 -0
- package/legacy/hooks/features/rows/gridRowsUtils.js +21 -3
- package/legacy/hooks/features/rows/index.js +1 -1
- package/legacy/hooks/features/rows/useGridRowsMeta.js +19 -4
- package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/legacy/hooks/features/scroll/useGridScroll.js +7 -2
- package/legacy/hooks/features/selection/useGridSelection.js +30 -12
- package/legacy/hooks/features/sorting/gridSortingUtils.js +11 -12
- package/legacy/hooks/features/sorting/useGridSorting.js +42 -6
- package/legacy/hooks/features/statePersistence/useGridStatePersistence.js +2 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +51 -25
- package/legacy/hooks/utils/useGridNativeEventListener.js +1 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +5 -2
- package/legacy/locales/arSD.js +8 -1
- package/legacy/locales/bgBG.js +8 -1
- package/legacy/locales/csCZ.js +8 -1
- package/legacy/locales/daDK.js +8 -1
- package/legacy/locales/deDE.js +12 -5
- package/legacy/locales/elGR.js +8 -1
- package/legacy/locales/esES.js +8 -1
- package/legacy/locales/faIR.js +8 -1
- package/legacy/locales/fiFI.js +8 -1
- package/legacy/locales/frFR.js +18 -11
- package/legacy/locales/heIL.js +9 -2
- package/legacy/locales/huHU.js +8 -1
- package/legacy/locales/index.js +2 -1
- package/legacy/locales/itIT.js +8 -1
- package/legacy/locales/jaJP.js +11 -4
- package/legacy/locales/koKR.js +8 -1
- package/legacy/locales/nbNO.js +9 -2
- package/legacy/locales/nlNL.js +21 -14
- package/legacy/locales/plPL.js +8 -1
- package/legacy/locales/ptBR.js +17 -10
- package/legacy/locales/roRO.js +12 -5
- package/legacy/locales/ruRU.js +8 -1
- package/legacy/locales/skSK.js +9 -2
- package/legacy/locales/svSE.js +9 -2
- package/legacy/locales/trTR.js +8 -1
- package/legacy/locales/ukUA.js +8 -1
- package/legacy/locales/viVN.js +8 -1
- package/legacy/locales/zhCN.js +38 -27
- package/legacy/locales/zhTW.js +135 -0
- package/legacy/models/events/gridEvents.js +1 -0
- package/locales/arSD.js +8 -1
- package/locales/bgBG.js +8 -1
- package/locales/csCZ.js +8 -1
- package/locales/daDK.js +8 -1
- package/locales/deDE.js +12 -5
- package/locales/elGR.js +8 -1
- package/locales/esES.js +8 -1
- package/locales/faIR.js +8 -1
- package/locales/fiFI.js +8 -1
- package/locales/frFR.js +18 -11
- package/locales/heIL.js +9 -2
- package/locales/huHU.js +8 -1
- package/locales/index.d.ts +1 -0
- package/locales/index.js +2 -1
- package/locales/itIT.js +8 -1
- package/locales/jaJP.js +11 -4
- package/locales/koKR.js +8 -1
- package/locales/nbNO.js +9 -2
- package/locales/nlNL.js +21 -14
- package/locales/plPL.js +8 -1
- package/locales/ptBR.js +17 -10
- package/locales/roRO.js +12 -5
- package/locales/ruRU.js +8 -1
- package/locales/skSK.js +9 -2
- package/locales/svSE.js +9 -2
- package/locales/trTR.js +8 -1
- package/locales/ukUA.js +8 -1
- package/locales/viVN.js +8 -1
- package/locales/zhCN.js +34 -27
- package/locales/zhTW.d.ts +2 -0
- package/locales/zhTW.js +123 -0
- package/models/api/gridColumnSpanning.d.ts +2 -0
- package/models/api/gridLocaleTextApi.d.ts +8 -2
- package/models/api/gridSelectionApi.d.ts +6 -0
- package/models/events/gridEvents.d.ts +1 -0
- package/models/events/gridEvents.js +1 -0
- package/models/gridFilterOperator.d.ts +6 -0
- package/models/gridRows.d.ts +15 -1
- package/models/params/gridCellParams.d.ts +4 -4
- package/models/props/DataGridProps.d.ts +5 -0
- package/modern/DataGrid/DataGrid.js +6 -0
- package/modern/DataGrid/useDataGridComponent.js +1 -1
- package/modern/DataGrid/useDataGridProps.js +1 -0
- package/modern/colDef/gridActionsColDef.js +2 -0
- package/modern/colDef/gridBooleanColDef.js +3 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/modern/colDef/gridDateOperators.js +4 -2
- package/modern/colDef/gridNumericOperators.js +4 -2
- package/modern/colDef/gridStringColDef.js +6 -0
- package/modern/colDef/gridStringOperators.js +4 -2
- package/modern/components/GridRow.js +5 -1
- package/modern/components/base/GridOverlays.js +4 -1
- package/modern/components/cell/GridBooleanCell.js +93 -2
- package/modern/components/cell/GridEditDateCell.js +5 -1
- package/modern/components/cell/index.js +1 -0
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +12 -1
- package/modern/components/containers/GridRoot.js +4 -2
- package/modern/components/containers/GridRootStyles.js +10 -0
- package/modern/components/toolbar/GridToolbarExport.js +20 -10
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +9 -2
- package/modern/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/modern/hooks/features/columns/useGridColumns.js +10 -5
- package/modern/hooks/features/dimensions/useGridDimensions.js +6 -1
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +5 -4
- package/modern/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/modern/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +3 -3
- package/modern/hooks/features/export/utils.js +10 -2
- package/modern/hooks/features/filter/gridFilterUtils.js +6 -0
- package/modern/hooks/features/filter/useGridFilter.js +25 -4
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +42 -30
- package/modern/hooks/features/pagination/useGridPage.js +4 -3
- package/modern/hooks/features/pagination/useGridPageSize.js +7 -4
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +8 -4
- package/modern/hooks/features/rows/gridRowsSelector.js +18 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +19 -3
- package/modern/hooks/features/rows/index.js +1 -1
- package/modern/hooks/features/rows/useGridRowsMeta.js +17 -4
- package/modern/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/modern/hooks/features/scroll/useGridScroll.js +5 -2
- package/modern/hooks/features/selection/useGridSelection.js +28 -10
- package/modern/hooks/features/sorting/gridSortingUtils.js +10 -11
- package/modern/hooks/features/sorting/useGridSorting.js +38 -6
- package/modern/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +41 -20
- package/modern/hooks/utils/useGridNativeEventListener.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +5 -2
- package/modern/locales/arSD.js +8 -1
- package/modern/locales/bgBG.js +8 -1
- package/modern/locales/csCZ.js +8 -1
- package/modern/locales/daDK.js +8 -1
- package/modern/locales/deDE.js +12 -5
- package/modern/locales/elGR.js +8 -1
- package/modern/locales/esES.js +8 -1
- package/modern/locales/faIR.js +8 -1
- package/modern/locales/fiFI.js +8 -1
- package/modern/locales/frFR.js +18 -11
- package/modern/locales/heIL.js +9 -2
- package/modern/locales/huHU.js +8 -1
- package/modern/locales/index.js +2 -1
- package/modern/locales/itIT.js +8 -1
- package/modern/locales/jaJP.js +11 -4
- package/modern/locales/koKR.js +8 -1
- package/modern/locales/nbNO.js +9 -2
- package/modern/locales/nlNL.js +21 -14
- package/modern/locales/plPL.js +8 -1
- package/modern/locales/ptBR.js +17 -10
- package/modern/locales/roRO.js +12 -5
- package/modern/locales/ruRU.js +8 -1
- package/modern/locales/skSK.js +9 -2
- package/modern/locales/svSE.js +9 -2
- package/modern/locales/trTR.js +8 -1
- package/modern/locales/ukUA.js +8 -1
- package/modern/locales/viVN.js +8 -1
- package/modern/locales/zhCN.js +34 -27
- package/modern/locales/zhTW.js +123 -0
- package/modern/models/events/gridEvents.js +1 -0
- package/node/DataGrid/DataGrid.js +6 -0
- package/node/DataGrid/useDataGridComponent.js +1 -1
- package/node/DataGrid/useDataGridProps.js +1 -0
- package/node/colDef/gridActionsColDef.js +2 -0
- package/node/colDef/gridBooleanColDef.js +3 -1
- package/node/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/node/colDef/gridDateOperators.js +4 -2
- package/node/colDef/gridNumericOperators.js +4 -2
- package/node/colDef/gridStringColDef.js +5 -0
- package/node/colDef/gridStringOperators.js +4 -2
- package/node/components/GridRow.js +5 -1
- package/node/components/base/GridOverlays.js +4 -1
- package/node/components/cell/GridBooleanCell.js +93 -2
- package/node/components/cell/GridEditDateCell.js +7 -1
- package/node/components/cell/index.js +13 -0
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +12 -1
- package/node/components/containers/GridRoot.js +3 -1
- package/node/components/containers/GridRootStyles.js +10 -0
- package/node/components/toolbar/GridToolbarExport.js +16 -10
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +9 -2
- package/node/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/node/hooks/features/columns/useGridColumns.js +13 -6
- package/node/hooks/features/dimensions/useGridDimensions.js +7 -1
- package/node/hooks/features/editRows/useGridCellEditing.new.js +7 -4
- package/node/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/node/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/node/hooks/features/editRows/useGridRowEditing.new.js +3 -3
- package/node/hooks/features/export/utils.js +17 -2
- package/node/hooks/features/filter/gridFilterUtils.js +7 -0
- package/node/hooks/features/filter/useGridFilter.js +30 -5
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +43 -34
- package/node/hooks/features/pagination/useGridPage.js +4 -3
- package/node/hooks/features/pagination/useGridPageSize.js +8 -4
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
- package/node/hooks/features/rows/gridRowsSelector.js +24 -2
- package/node/hooks/features/rows/gridRowsUtils.js +23 -2
- package/node/hooks/features/rows/index.js +70 -12
- package/node/hooks/features/rows/useGridRowsMeta.js +20 -4
- package/node/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/node/hooks/features/scroll/useGridScroll.js +7 -1
- package/node/hooks/features/selection/useGridSelection.js +28 -10
- package/node/hooks/features/sorting/gridSortingUtils.js +10 -11
- package/node/hooks/features/sorting/useGridSorting.js +42 -6
- package/node/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +46 -21
- package/node/hooks/utils/useGridNativeEventListener.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +46 -0
- package/node/locales/arSD.js +8 -1
- package/node/locales/bgBG.js +8 -1
- package/node/locales/csCZ.js +8 -1
- package/node/locales/daDK.js +8 -1
- package/node/locales/deDE.js +12 -5
- package/node/locales/elGR.js +8 -1
- package/node/locales/esES.js +8 -1
- package/node/locales/faIR.js +8 -1
- package/node/locales/fiFI.js +8 -1
- package/node/locales/frFR.js +18 -11
- package/node/locales/heIL.js +9 -2
- package/node/locales/huHU.js +8 -1
- package/node/locales/index.js +13 -0
- package/node/locales/itIT.js +8 -1
- package/node/locales/jaJP.js +11 -4
- package/node/locales/koKR.js +8 -1
- package/node/locales/nbNO.js +9 -2
- package/node/locales/nlNL.js +21 -14
- package/node/locales/plPL.js +8 -1
- package/node/locales/ptBR.js +17 -10
- package/node/locales/roRO.js +12 -5
- package/node/locales/ruRU.js +8 -1
- package/node/locales/skSK.js +9 -2
- package/node/locales/svSE.js +9 -2
- package/node/locales/trTR.js +8 -1
- package/node/locales/ukUA.js +8 -1
- package/node/locales/viVN.js +8 -1
- package/node/locales/zhCN.js +34 -27
- package/node/locales/zhTW.js +133 -0
- package/node/models/events/gridEvents.js +1 -0
- package/package.json +2 -2
- package/utils/getGridLocalization.d.ts +1 -1
|
@@ -9,6 +9,12 @@ import { gridClasses } from '../../../constants/gridClasses';
|
|
|
9
9
|
import { GridCellModes } from '../../../models/gridEditRowModel';
|
|
10
10
|
import { isNavigationKey } from '../../../utils/keyboardUtils';
|
|
11
11
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
|
|
12
|
+
import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
13
|
+
|
|
14
|
+
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
15
|
+
const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
|
|
16
|
+
return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];
|
|
17
|
+
}
|
|
12
18
|
/**
|
|
13
19
|
* @requires useGridSorting (method) - can be after
|
|
14
20
|
* @requires useGridFilter (state) - can be after
|
|
@@ -19,20 +25,19 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPan
|
|
|
19
25
|
* @requires useGridColumnSpanning (method) - can be after
|
|
20
26
|
*/
|
|
21
27
|
|
|
28
|
+
|
|
22
29
|
export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
23
30
|
const logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
|
|
24
|
-
const
|
|
31
|
+
const initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;
|
|
32
|
+
const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
|
|
25
33
|
/**
|
|
26
34
|
* @param {number} colIndex Index of the column to focus
|
|
27
35
|
* @param {number} rowIndex index of the row to focus
|
|
28
36
|
* @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
|
|
29
37
|
*/
|
|
30
38
|
|
|
31
|
-
const goToCell = React.useCallback((colIndex,
|
|
32
|
-
var _visibleSortedRows$ro;
|
|
33
|
-
|
|
39
|
+
const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left') => {
|
|
34
40
|
const visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);
|
|
35
|
-
const rowId = (_visibleSortedRows$ro = visibleSortedRows[rowIndex]) == null ? void 0 : _visibleSortedRows$ro.id;
|
|
36
41
|
const nextCellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, colIndex);
|
|
37
42
|
|
|
38
43
|
if (nextCellColSpanInfo && nextCellColSpanInfo.spannedByColSpan) {
|
|
@@ -41,12 +46,15 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
41
46
|
} else if (closestColumnToUse === 'right') {
|
|
42
47
|
colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
|
|
43
48
|
}
|
|
44
|
-
}
|
|
49
|
+
} // `scrollToIndexes` requires a rowIndex relative to all visible rows.
|
|
50
|
+
// Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
|
|
45
51
|
|
|
46
|
-
|
|
52
|
+
|
|
53
|
+
const rowIndexRelativeToAllRows = visibleSortedRows.findIndex(row => row.id === rowId);
|
|
54
|
+
logger.debug(`Navigating to cell row ${rowIndexRelativeToAllRows}, col ${colIndex}`);
|
|
47
55
|
apiRef.current.scrollToIndexes({
|
|
48
56
|
colIndex,
|
|
49
|
-
rowIndex
|
|
57
|
+
rowIndex: rowIndexRelativeToAllRows
|
|
50
58
|
});
|
|
51
59
|
const field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
52
60
|
apiRef.current.setCellFocus(rowId, field);
|
|
@@ -59,19 +67,21 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
59
67
|
const field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
60
68
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
61
69
|
}, [apiRef, logger]);
|
|
70
|
+
const getRowIdFromIndex = React.useCallback(rowIndex => {
|
|
71
|
+
return currentPageRows[rowIndex].id;
|
|
72
|
+
}, [currentPageRows]);
|
|
62
73
|
const handleCellNavigationKeyDown = React.useCallback((params, event) => {
|
|
63
74
|
const dimensions = apiRef.current.getRootDimensions();
|
|
64
75
|
|
|
65
|
-
if (
|
|
76
|
+
if (currentPageRows.length === 0 || !dimensions) {
|
|
66
77
|
return;
|
|
67
78
|
}
|
|
68
79
|
|
|
69
80
|
const viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
70
|
-
const visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);
|
|
71
81
|
const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
72
|
-
const rowIndexBefore =
|
|
73
|
-
const firstRowIndexInPage =
|
|
74
|
-
const lastRowIndexInPage =
|
|
82
|
+
const rowIndexBefore = currentPageRows.findIndex(row => row.id === params.id);
|
|
83
|
+
const firstRowIndexInPage = 0;
|
|
84
|
+
const lastRowIndexInPage = currentPageRows.length - 1;
|
|
75
85
|
const firstColIndex = 0;
|
|
76
86
|
const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
77
87
|
let shouldPreventDefault = true;
|
|
@@ -82,7 +92,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
82
92
|
{
|
|
83
93
|
// "Enter" is only triggered by the row / cell editing feature
|
|
84
94
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
85
|
-
goToCell(colIndexBefore, rowIndexBefore + 1);
|
|
95
|
+
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
break;
|
|
@@ -91,7 +101,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
91
101
|
case 'ArrowUp':
|
|
92
102
|
{
|
|
93
103
|
if (rowIndexBefore > firstRowIndexInPage) {
|
|
94
|
-
goToCell(colIndexBefore, rowIndexBefore - 1);
|
|
104
|
+
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore - 1));
|
|
95
105
|
} else {
|
|
96
106
|
goToHeader(colIndexBefore, event);
|
|
97
107
|
}
|
|
@@ -102,7 +112,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
102
112
|
case 'ArrowRight':
|
|
103
113
|
{
|
|
104
114
|
if (colIndexBefore < lastColIndex) {
|
|
105
|
-
goToCell(colIndexBefore + 1, rowIndexBefore, 'right');
|
|
115
|
+
goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');
|
|
106
116
|
}
|
|
107
117
|
|
|
108
118
|
break;
|
|
@@ -111,7 +121,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
111
121
|
case 'ArrowLeft':
|
|
112
122
|
{
|
|
113
123
|
if (colIndexBefore > firstColIndex) {
|
|
114
|
-
goToCell(colIndexBefore - 1, rowIndexBefore);
|
|
124
|
+
goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore));
|
|
115
125
|
}
|
|
116
126
|
|
|
117
127
|
break;
|
|
@@ -121,9 +131,9 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
121
131
|
{
|
|
122
132
|
// "Tab" is only triggered by the row / cell editing feature
|
|
123
133
|
if (event.shiftKey && colIndexBefore > firstColIndex) {
|
|
124
|
-
goToCell(colIndexBefore - 1, rowIndexBefore, 'left');
|
|
134
|
+
goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore), 'left');
|
|
125
135
|
} else if (!event.shiftKey && colIndexBefore < lastColIndex) {
|
|
126
|
-
goToCell(colIndexBefore + 1, rowIndexBefore, 'right');
|
|
136
|
+
goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');
|
|
127
137
|
}
|
|
128
138
|
|
|
129
139
|
break;
|
|
@@ -144,7 +154,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
144
154
|
}
|
|
145
155
|
|
|
146
156
|
if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {
|
|
147
|
-
goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
|
|
157
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));
|
|
148
158
|
}
|
|
149
159
|
|
|
150
160
|
break;
|
|
@@ -153,7 +163,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
153
163
|
case 'PageDown':
|
|
154
164
|
{
|
|
155
165
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
156
|
-
goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
|
|
166
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));
|
|
157
167
|
}
|
|
158
168
|
|
|
159
169
|
break;
|
|
@@ -165,7 +175,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
165
175
|
const nextRowIndex = Math.max(rowIndexBefore - viewportPageSize, firstRowIndexInPage);
|
|
166
176
|
|
|
167
177
|
if (nextRowIndex !== rowIndexBefore && nextRowIndex >= firstRowIndexInPage) {
|
|
168
|
-
goToCell(colIndexBefore, nextRowIndex);
|
|
178
|
+
goToCell(colIndexBefore, getRowIdFromIndex(nextRowIndex));
|
|
169
179
|
} else {
|
|
170
180
|
goToHeader(colIndexBefore, event);
|
|
171
181
|
}
|
|
@@ -176,9 +186,9 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
176
186
|
case 'Home':
|
|
177
187
|
{
|
|
178
188
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
179
|
-
goToCell(firstColIndex, firstRowIndexInPage);
|
|
189
|
+
goToCell(firstColIndex, getRowIdFromIndex(firstRowIndexInPage));
|
|
180
190
|
} else {
|
|
181
|
-
goToCell(firstColIndex, rowIndexBefore);
|
|
191
|
+
goToCell(firstColIndex, getRowIdFromIndex(rowIndexBefore));
|
|
182
192
|
}
|
|
183
193
|
|
|
184
194
|
break;
|
|
@@ -187,9 +197,9 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
187
197
|
case 'End':
|
|
188
198
|
{
|
|
189
199
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
190
|
-
goToCell(lastColIndex, lastRowIndexInPage);
|
|
200
|
+
goToCell(lastColIndex, getRowIdFromIndex(lastRowIndexInPage));
|
|
191
201
|
} else {
|
|
192
|
-
goToCell(lastColIndex, rowIndexBefore);
|
|
202
|
+
goToCell(lastColIndex, getRowIdFromIndex(rowIndexBefore));
|
|
193
203
|
}
|
|
194
204
|
|
|
195
205
|
break;
|
|
@@ -204,10 +214,8 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
204
214
|
if (shouldPreventDefault) {
|
|
205
215
|
event.preventDefault();
|
|
206
216
|
}
|
|
207
|
-
}, [apiRef,
|
|
217
|
+
}, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);
|
|
208
218
|
const handleColumnHeaderKeyDown = React.useCallback((params, event) => {
|
|
209
|
-
var _currentPage$range$fi, _currentPage$range, _currentPage$range$la, _currentPage$range2;
|
|
210
|
-
|
|
211
219
|
const headerTitleNode = event.currentTarget.querySelector(`.${gridClasses.columnHeaderTitleContainerContent}`);
|
|
212
220
|
const isFromInsideContent = !!headerTitleNode && headerTitleNode.contains(event.target);
|
|
213
221
|
|
|
@@ -225,8 +233,8 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
225
233
|
|
|
226
234
|
const viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
227
235
|
const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
228
|
-
const firstRowIndexInPage =
|
|
229
|
-
const lastRowIndexInPage =
|
|
236
|
+
const firstRowIndexInPage = 0;
|
|
237
|
+
const lastRowIndexInPage = currentPageRows.length - 1;
|
|
230
238
|
const firstColIndex = 0;
|
|
231
239
|
const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
232
240
|
let shouldPreventDefault = true;
|
|
@@ -235,7 +243,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
235
243
|
case 'ArrowDown':
|
|
236
244
|
{
|
|
237
245
|
if (firstRowIndexInPage !== null) {
|
|
238
|
-
goToCell(colIndexBefore, firstRowIndexInPage);
|
|
246
|
+
goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
|
|
239
247
|
}
|
|
240
248
|
|
|
241
249
|
break;
|
|
@@ -262,7 +270,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
262
270
|
case 'PageDown':
|
|
263
271
|
{
|
|
264
272
|
if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
|
|
265
|
-
goToCell(colIndexBefore, Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage));
|
|
273
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));
|
|
266
274
|
}
|
|
267
275
|
|
|
268
276
|
break;
|
|
@@ -304,7 +312,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
304
312
|
if (shouldPreventDefault) {
|
|
305
313
|
event.preventDefault();
|
|
306
314
|
}
|
|
307
|
-
}, [apiRef,
|
|
315
|
+
}, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);
|
|
308
316
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
309
317
|
// Ignore portal
|
|
310
318
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -63,13 +63,14 @@ export const useGridPage = (apiRef, props) => {
|
|
|
63
63
|
* PRE-PROCESSING
|
|
64
64
|
*/
|
|
65
65
|
|
|
66
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
66
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
67
67
|
var _props$initialState, _props$initialState$p;
|
|
68
68
|
|
|
69
69
|
const pageToExport = gridPageSelector(apiRef);
|
|
70
|
-
const shouldExportPage = // Always export if the
|
|
70
|
+
const shouldExportPage = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
71
|
+
!context.exportOnlyDirtyModels || // Always export if the page is controlled
|
|
71
72
|
props.page != null || // Always export if the page has been initialized
|
|
72
|
-
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.page) != null || // Export if the page
|
|
73
|
+
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.page) != null || // Export if the page is not equal to the default value
|
|
73
74
|
pageToExport !== 0;
|
|
74
75
|
|
|
75
76
|
if (!shouldExportPage) {
|
|
@@ -4,6 +4,7 @@ import { useGridLogger, useGridApiMethod, useGridApiEventHandler, useGridSelecto
|
|
|
4
4
|
import { gridPageSizeSelector } from './gridPaginationSelector';
|
|
5
5
|
import { gridDensityRowHeightSelector } from '../density';
|
|
6
6
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
7
|
+
import { calculatePinnedRowsHeight } from '../rows/gridRowsUtils';
|
|
7
8
|
export const defaultPageSize = autoPageSize => autoPageSize ? 0 : 100;
|
|
8
9
|
|
|
9
10
|
const mergeStateWithPageSize = pageSize => state => _extends({}, state, {
|
|
@@ -49,13 +50,14 @@ export const useGridPageSize = (apiRef, props) => {
|
|
|
49
50
|
* PRE-PROCESSING
|
|
50
51
|
*/
|
|
51
52
|
|
|
52
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
53
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
53
54
|
var _props$initialState, _props$initialState$p;
|
|
54
55
|
|
|
55
56
|
const pageSizeToExport = gridPageSizeSelector(apiRef);
|
|
56
|
-
const shouldExportPageSize = // Always export if the
|
|
57
|
+
const shouldExportPageSize = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
58
|
+
!context.exportOnlyDirtyModels || // Always export if the page size is controlled
|
|
57
59
|
props.pageSize != null || // Always export if the page size has been initialized
|
|
58
|
-
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.pageSize) != null || // Export if the page size
|
|
60
|
+
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.pageSize) != null || // Export if the page size is not equal to the default value
|
|
59
61
|
pageSizeToExport !== defaultPageSize(props.autoPageSize);
|
|
60
62
|
|
|
61
63
|
if (!shouldExportPageSize) {
|
|
@@ -96,7 +98,8 @@ export const useGridPageSize = (apiRef, props) => {
|
|
|
96
98
|
return;
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
const
|
|
101
|
+
const pinnedRowsHeight = calculatePinnedRowsHeight(apiRef);
|
|
102
|
+
const maximumPageSizeWithoutScrollBar = Math.floor((dimensions.viewportInnerSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom) / rowHeight);
|
|
100
103
|
apiRef.current.setPageSize(maximumPageSizeWithoutScrollBar);
|
|
101
104
|
}, [apiRef, props.autoPageSize, rowHeight]);
|
|
102
105
|
useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleUpdateAutoPageSize);
|
|
@@ -6,4 +6,4 @@ export declare const preferencePanelStateInitializer: GridStateInitializer<Pick<
|
|
|
6
6
|
/**
|
|
7
7
|
* TODO: Add a single `setPreferencePanel` method to avoid multiple `setState`
|
|
8
8
|
*/
|
|
9
|
-
export declare const useGridPreferencesPanel: (apiRef: React.MutableRefObject<GridApiCommunity>) => void;
|
|
9
|
+
export declare const useGridPreferencesPanel: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'initialState'>) => void;
|
|
@@ -17,7 +17,9 @@ export const preferencePanelStateInitializer = (state, props) => {
|
|
|
17
17
|
* TODO: Add a single `setPreferencePanel` method to avoid multiple `setState`
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
export const useGridPreferencesPanel = apiRef => {
|
|
20
|
+
export const useGridPreferencesPanel = (apiRef, props) => {
|
|
21
|
+
var _props$initialState3;
|
|
22
|
+
|
|
21
23
|
const logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
|
|
22
24
|
const hideTimeout = React.useRef();
|
|
23
25
|
const immediateTimeout = React.useRef();
|
|
@@ -74,17 +76,23 @@ export const useGridPreferencesPanel = apiRef => {
|
|
|
74
76
|
* PRE-PROCESSING
|
|
75
77
|
*/
|
|
76
78
|
|
|
77
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
79
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
80
|
+
var _props$initialState2;
|
|
81
|
+
|
|
78
82
|
const preferencePanelToExport = gridPreferencePanelStateSelector(apiRef.current.state);
|
|
83
|
+
const shouldExportPreferencePanel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
84
|
+
!context.exportOnlyDirtyModels || // Always export if the panel was initialized
|
|
85
|
+
((_props$initialState2 = props.initialState) == null ? void 0 : _props$initialState2.preferencePanel) != null || // Always export if the panel is opened
|
|
86
|
+
preferencePanelToExport.open;
|
|
79
87
|
|
|
80
|
-
if (!
|
|
88
|
+
if (!shouldExportPreferencePanel) {
|
|
81
89
|
return prevState;
|
|
82
90
|
}
|
|
83
91
|
|
|
84
92
|
return _extends({}, prevState, {
|
|
85
93
|
preferencePanel: preferencePanelToExport
|
|
86
94
|
});
|
|
87
|
-
}, [apiRef]);
|
|
95
|
+
}, [apiRef, (_props$initialState3 = props.initialState) == null ? void 0 : _props$initialState3.preferencePanel]);
|
|
88
96
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
89
97
|
const preferencePanel = context.stateToRestore.preferencePanel;
|
|
90
98
|
|
|
@@ -9,3 +9,17 @@ export declare const gridRowTreeSelector: import("../../../utils/createSelector"
|
|
|
9
9
|
export declare const gridRowGroupingNameSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string>;
|
|
10
10
|
export declare const gridRowTreeDepthSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
11
11
|
export declare const gridRowIdsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridRowId[]>;
|
|
12
|
+
/**
|
|
13
|
+
* @ignore - do not document.
|
|
14
|
+
*/
|
|
15
|
+
export declare const gridAdditionalRowGroupsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, {
|
|
16
|
+
pinnedRows?: import("./gridRowsState").GridPinnedRowsState | undefined;
|
|
17
|
+
} | undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* @ignore - do not document.
|
|
20
|
+
*/
|
|
21
|
+
export declare const gridPinnedRowsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridRowsState").GridPinnedRowsState | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* @ignore - do not document.
|
|
24
|
+
*/
|
|
25
|
+
export declare const gridPinnedRowsCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
@@ -8,4 +8,23 @@ export const gridRowsIdToIdLookupSelector = createSelector(gridRowsStateSelector
|
|
|
8
8
|
export const gridRowTreeSelector = createSelector(gridRowsStateSelector, rows => rows.tree);
|
|
9
9
|
export const gridRowGroupingNameSelector = createSelector(gridRowsStateSelector, rows => rows.groupingName);
|
|
10
10
|
export const gridRowTreeDepthSelector = createSelector(gridRowsStateSelector, rows => rows.treeDepth);
|
|
11
|
-
export const gridRowIdsSelector = createSelector(gridRowsStateSelector, rows => rows.ids);
|
|
11
|
+
export const gridRowIdsSelector = createSelector(gridRowsStateSelector, rows => rows.ids);
|
|
12
|
+
/**
|
|
13
|
+
* @ignore - do not document.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const gridAdditionalRowGroupsSelector = createSelector(gridRowsStateSelector, rows => rows == null ? void 0 : rows.additionalRowGroups);
|
|
17
|
+
/**
|
|
18
|
+
* @ignore - do not document.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export const gridPinnedRowsSelector = createSelector(gridAdditionalRowGroupsSelector, additionalRowGroups => additionalRowGroups == null ? void 0 : additionalRowGroups.pinnedRows);
|
|
22
|
+
/**
|
|
23
|
+
* @ignore - do not document.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export const gridPinnedRowsCountSelector = createSelector(gridPinnedRowsSelector, pinnedRows => {
|
|
27
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
28
|
+
|
|
29
|
+
return ((pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.length) || 0) + ((pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.length) || 0);
|
|
30
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GridRowId, GridRowsLookup, GridRowTreeConfig } from '../../../models/gridRows';
|
|
1
|
+
import { GridRowId, GridRowsLookup, GridRowTreeConfig, GridRowEntry } from '../../../models/gridRows';
|
|
2
2
|
import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
3
3
|
export interface GridRowTreeCreationParams {
|
|
4
4
|
ids: GridRowId[];
|
|
@@ -17,6 +17,9 @@ export interface GridRowTreeCreationValue {
|
|
|
17
17
|
ids: GridRowId[];
|
|
18
18
|
idRowsLookup: GridRowsLookup;
|
|
19
19
|
idToIdLookup: Record<string, GridRowId>;
|
|
20
|
+
additionalRowGroups?: {
|
|
21
|
+
pinnedRows?: GridPinnedRowsState;
|
|
22
|
+
};
|
|
20
23
|
}
|
|
21
24
|
export interface GridRowsInternalCache extends Omit<GridRowTreeCreationParams, 'previousTree'> {
|
|
22
25
|
/**
|
|
@@ -51,3 +54,7 @@ export interface GridRowsState extends GridRowTreeCreationValue {
|
|
|
51
54
|
groupingResponseBeforeRowHydration: GridRowTreeCreationValue;
|
|
52
55
|
}
|
|
53
56
|
export declare type GridHydrateRowsValue = GridRowTreeCreationValue;
|
|
57
|
+
export interface GridPinnedRowsState {
|
|
58
|
+
top?: GridRowEntry[];
|
|
59
|
+
bottom?: GridRowEntry[];
|
|
60
|
+
}
|
|
@@ -10,7 +10,7 @@ import { GridRowsInternalCache, GridRowsState } from './gridRowsState';
|
|
|
10
10
|
* @param {string} detailErrorMessage A custom error message to display for invalid IDs
|
|
11
11
|
*/
|
|
12
12
|
export declare function checkGridRowIdIsValid(id: GridRowId, row: GridRowModel | Partial<GridRowModel>, detailErrorMessage?: string): void;
|
|
13
|
-
export declare const getRowIdFromRowModel: (rowModel: GridRowModel, getRowId?: GridRowIdGetter
|
|
13
|
+
export declare const getRowIdFromRowModel: (rowModel: GridRowModel, getRowId?: GridRowIdGetter, detailErrorMessage?: string) => GridRowId;
|
|
14
14
|
export declare const createRowsInternalCache: ({ rows, getRowId, loading, }: Pick<DataGridProcessedProps, 'rows' | 'getRowId' | 'loading'>) => GridRowsInternalCache;
|
|
15
15
|
export declare const getRowsStateFromCache: ({ apiRef, previousTree, rowCountProp, loadingProp, }: {
|
|
16
16
|
apiRef: React.MutableRefObject<GridApiCommunity>;
|
|
@@ -19,3 +19,7 @@ export declare const getRowsStateFromCache: ({ apiRef, previousTree, rowCountPro
|
|
|
19
19
|
loadingProp: boolean | undefined;
|
|
20
20
|
}) => GridRowsState;
|
|
21
21
|
export declare const getTreeNodeDescendants: (tree: GridRowTreeConfig, parentId: GridRowId, skipAutoGeneratedRows: boolean) => GridRowId[];
|
|
22
|
+
export declare function calculatePinnedRowsHeight(apiRef: React.MutableRefObject<GridApiCommunity>): {
|
|
23
|
+
top: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["rowsBeforePartialUpdates"];
|
|
4
|
-
|
|
4
|
+
import { gridPinnedRowsSelector } from './gridRowsSelector';
|
|
5
5
|
/**
|
|
6
6
|
* A helper function to check if the id provided is valid.
|
|
7
7
|
* @param {GridRowId} id Id as [[GridRowId]].
|
|
8
8
|
* @param {GridRowModel | Partial<GridRowModel>} row Row as [[GridRowModel]].
|
|
9
9
|
* @param {string} detailErrorMessage A custom error message to display for invalid IDs
|
|
10
10
|
*/
|
|
11
|
+
|
|
11
12
|
export function checkGridRowIdIsValid(id, row, detailErrorMessage = 'A row was provided without id in the rows prop:') {
|
|
12
13
|
if (id == null) {
|
|
13
14
|
throw new Error(['MUI: The data grid component requires all rows to have a unique `id` property.', 'Alternatively, you can use the `getRowId` prop to specify a custom id for each row.', detailErrorMessage, JSON.stringify(row)].join('\n'));
|
|
@@ -55,7 +56,7 @@ export const getRowsStateFromCache = ({
|
|
|
55
56
|
previousTree
|
|
56
57
|
}));
|
|
57
58
|
const processedGroupingResponse = apiRef.current.unstable_applyPipeProcessors('hydrateRows', groupingResponse);
|
|
58
|
-
const dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(node => node.parent == null).length;
|
|
59
|
+
const dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(node => node.parent == null && !node.isPinned).length;
|
|
59
60
|
return _extends({}, processedGroupingResponse, {
|
|
60
61
|
groupingResponseBeforeRowHydration: groupingResponse,
|
|
61
62
|
loading: loadingProp,
|
|
@@ -86,4 +87,21 @@ export const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) =>
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
return validDescendants;
|
|
89
|
-
};
|
|
90
|
+
};
|
|
91
|
+
export function calculatePinnedRowsHeight(apiRef) {
|
|
92
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
93
|
+
|
|
94
|
+
const pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
95
|
+
const topPinnedRowsHeight = (pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.reduce((acc, value) => {
|
|
96
|
+
acc += apiRef.current.unstable_getRowHeight(value.id);
|
|
97
|
+
return acc;
|
|
98
|
+
}, 0)) || 0;
|
|
99
|
+
const bottomPinnedRowsHeight = (pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.reduce((acc, value) => {
|
|
100
|
+
acc += apiRef.current.unstable_getRowHeight(value.id);
|
|
101
|
+
return acc;
|
|
102
|
+
}, 0)) || 0;
|
|
103
|
+
return {
|
|
104
|
+
top: topPinnedRowsHeight,
|
|
105
|
+
bottom: bottomPinnedRowsHeight
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './gridRowsMetaSelector';
|
|
2
2
|
export * from './gridRowsMetaState';
|
|
3
|
-
export
|
|
3
|
+
export { gridRowsStateSelector, gridRowCountSelector, gridRowsLoadingSelector, gridTopLevelRowCountSelector, gridRowsLookupSelector, gridRowsIdToIdLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthSelector, gridRowIdsSelector, } from './gridRowsSelector';
|
|
4
4
|
export type { GridRowsState } from './gridRowsState';
|
|
5
5
|
export { checkGridRowIdIsValid } from './gridRowsUtils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './gridRowsMetaSelector';
|
|
2
2
|
export * from './gridRowsMetaState';
|
|
3
|
-
export
|
|
3
|
+
export { gridRowsStateSelector, gridRowCountSelector, gridRowsLoadingSelector, gridTopLevelRowCountSelector, gridRowsLookupSelector, gridRowsIdToIdLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthSelector, gridRowIdsSelector } from './gridRowsSelector';
|
|
4
4
|
export { checkGridRowIdIsValid } from './gridRowsUtils';
|
|
@@ -9,6 +9,7 @@ import { gridFilterStateSelector } from '../filter/gridFilterSelector';
|
|
|
9
9
|
import { gridPaginationSelector } from '../pagination/gridPaginationSelector';
|
|
10
10
|
import { gridSortingStateSelector } from '../sorting/gridSortingSelector';
|
|
11
11
|
import { useGridRegisterPipeApplier } from '../../core/pipeProcessing';
|
|
12
|
+
import { gridPinnedRowsSelector } from './gridRowsSelector';
|
|
12
13
|
export const rowsMetaStateInitializer = state => _extends({}, state, {
|
|
13
14
|
rowsMeta: {
|
|
14
15
|
currentPageTotalHeight: 0,
|
|
@@ -35,13 +36,14 @@ export const useGridRowsMeta = (apiRef, props) => {
|
|
|
35
36
|
const paginationState = useGridSelector(apiRef, gridPaginationSelector);
|
|
36
37
|
const sortingState = useGridSelector(apiRef, gridSortingStateSelector);
|
|
37
38
|
const currentPage = useGridVisibleRows(apiRef, props);
|
|
39
|
+
const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
|
|
38
40
|
const hydrateRowsMeta = React.useCallback(() => {
|
|
41
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
42
|
+
|
|
39
43
|
hasRowWithAutoHeight.current = false;
|
|
40
44
|
const densityFactor = gridDensityFactorSelector(apiRef.current.state, apiRef.current.instanceId);
|
|
41
|
-
const positions = [];
|
|
42
|
-
const currentPageTotalHeight = currentPage.rows.reduce((acc, row) => {
|
|
43
|
-
positions.push(acc);
|
|
44
45
|
|
|
46
|
+
const calculateRowProcessedSizes = row => {
|
|
45
47
|
if (!rowsHeightLookup.current[row.id]) {
|
|
46
48
|
rowsHeightLookup.current[row.id] = {
|
|
47
49
|
sizes: {
|
|
@@ -113,9 +115,22 @@ export const useGridRowsMeta = (apiRef, props) => {
|
|
|
113
115
|
|
|
114
116
|
const processedSizes = apiRef.current.unstable_applyPipeProcessors('rowHeight', initialHeights, row);
|
|
115
117
|
rowsHeightLookup.current[row.id].sizes = processedSizes;
|
|
118
|
+
return processedSizes;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const positions = [];
|
|
122
|
+
const currentPageTotalHeight = currentPage.rows.reduce((acc, row) => {
|
|
123
|
+
positions.push(acc);
|
|
124
|
+
const processedSizes = calculateRowProcessedSizes(row);
|
|
116
125
|
const finalRowHeight = Object.values(processedSizes).reduce((acc2, value) => acc2 + value, 0);
|
|
117
126
|
return acc + finalRowHeight;
|
|
118
127
|
}, 0);
|
|
128
|
+
pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.forEach(row => {
|
|
129
|
+
calculateRowProcessedSizes(row);
|
|
130
|
+
});
|
|
131
|
+
pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.forEach(row => {
|
|
132
|
+
calculateRowProcessedSizes(row);
|
|
133
|
+
});
|
|
119
134
|
apiRef.current.setState(state => {
|
|
120
135
|
return _extends({}, state, {
|
|
121
136
|
rowsMeta: {
|
|
@@ -131,7 +146,7 @@ export const useGridRowsMeta = (apiRef, props) => {
|
|
|
131
146
|
}
|
|
132
147
|
|
|
133
148
|
apiRef.current.forceUpdate();
|
|
134
|
-
}, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight]);
|
|
149
|
+
}, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight, pinnedRows]);
|
|
135
150
|
const getRowHeight = React.useCallback(rowId => {
|
|
136
151
|
const height = rowsHeightLookup.current[rowId];
|
|
137
152
|
return height ? height.sizes.base : rowHeightFromDensity;
|
|
@@ -11,7 +11,8 @@ const flatRowTreeCreationMethod = ({
|
|
|
11
11
|
for (let i = 0; i < ids.length; i += 1) {
|
|
12
12
|
const rowId = ids[i];
|
|
13
13
|
|
|
14
|
-
if (previousTree && previousTree[rowId] && previousTree[rowId].depth === 0 && previousTree[rowId].parent == null
|
|
14
|
+
if (previousTree && previousTree[rowId] && previousTree[rowId].depth === 0 && previousTree[rowId].parent == null && // pinned row can be unpinned
|
|
15
|
+
!previousTree[rowId].isPinned) {
|
|
15
16
|
tree[rowId] = previousTree[rowId];
|
|
16
17
|
} else {
|
|
17
18
|
tree[rowId] = {
|
|
@@ -6,7 +6,8 @@ import { gridPageSelector, gridPageSizeSelector } from '../pagination/gridPagina
|
|
|
6
6
|
import { gridRowCountSelector } from '../rows/gridRowsSelector';
|
|
7
7
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
8
8
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
9
|
-
import { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelector';
|
|
9
|
+
import { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelector';
|
|
10
|
+
import { gridClasses } from '../../../constants/gridClasses'; // Logic copied from https://www.w3.org/TR/wai-aria-practices/examples/listbox/js/listbox.js
|
|
10
11
|
// Similar to https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
|
|
11
12
|
|
|
12
13
|
function scrollIntoView(dimensions) {
|
|
@@ -88,13 +89,17 @@ export const useGridScroll = (apiRef, props) => {
|
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
if (params.rowIndex != null) {
|
|
92
|
+
var _querySelector, _querySelector2;
|
|
93
|
+
|
|
91
94
|
const rowsMeta = gridRowsMetaSelector(apiRef.current.state);
|
|
92
95
|
const page = gridPageSelector(apiRef);
|
|
93
96
|
const pageSize = gridPageSizeSelector(apiRef);
|
|
94
97
|
const elementIndex = !props.pagination ? params.rowIndex : params.rowIndex - page * pageSize;
|
|
95
98
|
const targetOffsetHeight = rowsMeta.positions[elementIndex + 1] ? rowsMeta.positions[elementIndex + 1] - rowsMeta.positions[elementIndex] : rowsMeta.currentPageTotalHeight - rowsMeta.positions[elementIndex];
|
|
99
|
+
const topPinnedRowsHeight = ((_querySelector = windowRef.current.querySelector(`.${gridClasses['pinnedRows--top']}`)) == null ? void 0 : _querySelector.clientHeight) || 0;
|
|
100
|
+
const bottomPinnedRowsHeight = ((_querySelector2 = windowRef.current.querySelector(`.${gridClasses['pinnedRows--bottom']}`)) == null ? void 0 : _querySelector2.clientHeight) || 0;
|
|
96
101
|
scrollCoordinates.top = scrollIntoView({
|
|
97
|
-
clientHeight: windowRef.current.clientHeight,
|
|
102
|
+
clientHeight: windowRef.current.clientHeight - topPinnedRowsHeight - bottomPinnedRowsHeight,
|
|
98
103
|
scrollTop: windowRef.current.scrollTop,
|
|
99
104
|
offsetHeight: targetOffsetHeight,
|
|
100
105
|
offsetTop: rowsMeta.positions[elementIndex]
|