@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
|
@@ -19,7 +19,7 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
19
19
|
toolbarFiltersTooltipShow: 'Show filters',
|
|
20
20
|
toolbarFiltersTooltipActive: count => count !== 1 ? `${count} active filters` : `${count} active filter`,
|
|
21
21
|
// Quick filter toolbar field
|
|
22
|
-
toolbarQuickFilterPlaceholder: 'Search
|
|
22
|
+
toolbarQuickFilterPlaceholder: 'Search…',
|
|
23
23
|
toolbarQuickFilterLabel: 'Search',
|
|
24
24
|
toolbarQuickFilterDeleteIconLabel: 'Clear',
|
|
25
25
|
// Export selector toolbar button text
|
|
@@ -111,5 +111,12 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
111
111
|
// Used core components translation keys
|
|
112
112
|
MuiTablePagination: {},
|
|
113
113
|
// Row reordering text
|
|
114
|
-
rowReorderingHeaderName: 'Row reordering'
|
|
114
|
+
rowReorderingHeaderName: 'Row reordering',
|
|
115
|
+
// Aggregation
|
|
116
|
+
aggregationMenuItemHeader: 'Aggregation',
|
|
117
|
+
aggregationFunctionLabelSum: 'sum',
|
|
118
|
+
aggregationFunctionLabelAvg: 'avg',
|
|
119
|
+
aggregationFunctionLabelMin: 'min',
|
|
120
|
+
aggregationFunctionLabelMax: 'max',
|
|
121
|
+
aggregationFunctionLabelSize: 'size'
|
|
115
122
|
};
|
|
@@ -26,11 +26,11 @@ export const useGridColumnSpanning = apiRef => {
|
|
|
26
26
|
columnIndex,
|
|
27
27
|
rowId,
|
|
28
28
|
minFirstColumnIndex,
|
|
29
|
-
maxLastColumnIndex
|
|
29
|
+
maxLastColumnIndex,
|
|
30
|
+
columns
|
|
30
31
|
} = params;
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const column = visibleColumns[columnIndex];
|
|
32
|
+
const columnsLength = columns.length;
|
|
33
|
+
const column = columns[columnIndex];
|
|
34
34
|
const colSpan = typeof column.colSpan === 'function' ? column.colSpan(apiRef.current.getCellParams(rowId, column.field)) : column.colSpan;
|
|
35
35
|
|
|
36
36
|
if (!colSpan || colSpan === 1) {
|
|
@@ -52,7 +52,7 @@ export const useGridColumnSpanning = apiRef => {
|
|
|
52
52
|
const nextColumnIndex = columnIndex + j; // Cells should be spanned only within their column section (left-pinned, right-pinned and unpinned).
|
|
53
53
|
|
|
54
54
|
if (nextColumnIndex >= minFirstColumnIndex && nextColumnIndex < maxLastColumnIndex) {
|
|
55
|
-
const nextColumn =
|
|
55
|
+
const nextColumn = columns[nextColumnIndex];
|
|
56
56
|
width += nextColumn.computedWidth;
|
|
57
57
|
setCellColSpanInfo(rowId, columnIndex + j, {
|
|
58
58
|
spannedByColSpan: true,
|
|
@@ -78,14 +78,16 @@ export const useGridColumnSpanning = apiRef => {
|
|
|
78
78
|
const calculateColSpan = React.useCallback(({
|
|
79
79
|
rowId,
|
|
80
80
|
minFirstColumn,
|
|
81
|
-
maxLastColumn
|
|
81
|
+
maxLastColumn,
|
|
82
|
+
columns
|
|
82
83
|
}) => {
|
|
83
84
|
for (let i = minFirstColumn; i < maxLastColumn; i += 1) {
|
|
84
85
|
const cellProps = calculateCellColSpan({
|
|
85
86
|
columnIndex: i,
|
|
86
87
|
rowId,
|
|
87
88
|
minFirstColumnIndex: minFirstColumn,
|
|
88
|
-
maxLastColumnIndex: maxLastColumn
|
|
89
|
+
maxLastColumnIndex: maxLastColumn,
|
|
90
|
+
columns
|
|
89
91
|
});
|
|
90
92
|
|
|
91
93
|
if (cellProps.colSpan > 1) {
|
|
@@ -186,14 +186,19 @@ export function useGridColumns(apiRef, props) {
|
|
|
186
186
|
* PRE-PROCESSING
|
|
187
187
|
*/
|
|
188
188
|
|
|
189
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
189
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
190
190
|
const columnsStateToExport = {};
|
|
191
191
|
|
|
192
192
|
if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
|
|
193
193
|
const columnVisibilityModelToExport = gridColumnVisibilityModelSelector(apiRef);
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
if
|
|
194
|
+
const shouldExportColumnVisibilityModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
195
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
196
|
+
props.columnVisibilityModel != null || // Always export if the model has been initialized
|
|
197
|
+
// TODO v6 Do a nullish check instead to export even if the initial model equals "{}"
|
|
198
|
+
Object.keys(props.initialState?.columns?.columnVisibilityModel ?? {}).length > 0 || // Always export if the model is not empty
|
|
199
|
+
Object.keys(columnVisibilityModelToExport).length > 0;
|
|
200
|
+
|
|
201
|
+
if (shouldExportColumnVisibilityModel) {
|
|
197
202
|
columnsStateToExport.columnVisibilityModel = columnVisibilityModelToExport;
|
|
198
203
|
}
|
|
199
204
|
}
|
|
@@ -224,7 +229,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
224
229
|
return _extends({}, prevState, {
|
|
225
230
|
columns: columnsStateToExport
|
|
226
231
|
});
|
|
227
|
-
}, [apiRef]);
|
|
232
|
+
}, [apiRef, props.columnVisibilityModel, props.initialState?.columns]);
|
|
228
233
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
229
234
|
const columnVisibilityModelToImport = apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel ? context.stateToRestore.columns?.columnVisibilityModel : undefined;
|
|
230
235
|
const initialState = context.stateToRestore.columns;
|
|
@@ -8,6 +8,7 @@ import { gridDensityHeaderHeightSelector, gridDensityRowHeightSelector } from '.
|
|
|
8
8
|
import { useGridSelector } from '../../utils';
|
|
9
9
|
import { getVisibleRows } from '../../utils/useGridVisibleRows';
|
|
10
10
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
11
|
+
import { calculatePinnedRowsHeight } from '../rows/gridRowsUtils';
|
|
11
12
|
const isTestEnvironment = process.env.NODE_ENV === 'test';
|
|
12
13
|
|
|
13
14
|
const hasScroll = ({
|
|
@@ -45,6 +46,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
45
46
|
const updateGridDimensionsRef = React.useCallback(() => {
|
|
46
47
|
const rootElement = apiRef.current.rootElementRef?.current;
|
|
47
48
|
const columnsTotalWidth = gridColumnsTotalWidthSelector(apiRef);
|
|
49
|
+
const pinnedRowsHeight = calculatePinnedRowsHeight(apiRef);
|
|
48
50
|
|
|
49
51
|
if (!rootDimensionsRef.current) {
|
|
50
52
|
return;
|
|
@@ -90,7 +92,10 @@ export function useGridDimensions(apiRef, props) {
|
|
|
90
92
|
width: Math.round(columnsTotalWidth),
|
|
91
93
|
height: rowsMeta.currentPageTotalHeight
|
|
92
94
|
},
|
|
93
|
-
container:
|
|
95
|
+
container: {
|
|
96
|
+
width: viewportOuterSize.width,
|
|
97
|
+
height: viewportOuterSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom
|
|
98
|
+
},
|
|
94
99
|
scrollBarSize
|
|
95
100
|
});
|
|
96
101
|
hasScrollY = scrollInformation.hasScrollY;
|
|
@@ -98,7 +98,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
98
98
|
let reason;
|
|
99
99
|
|
|
100
100
|
if (isPrintableKey(event.key)) {
|
|
101
|
-
if (event.
|
|
101
|
+
if (event.ctrlKey && event.key !== 'v' || event.metaKey && event.key !== 'v' || event.altKey) {
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -141,6 +141,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
141
141
|
field,
|
|
142
142
|
reason
|
|
143
143
|
} = params;
|
|
144
|
+
apiRef.current.unstable_runPendingEditCellValueMutation(id, field);
|
|
144
145
|
let cellToFocusAfter;
|
|
145
146
|
|
|
146
147
|
if (reason === GridCellEditStopReasons.enterKeyDown) {
|
|
@@ -154,7 +155,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
154
155
|
let ignoreModifications = reason === 'escapeKeyDown';
|
|
155
156
|
const editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
156
157
|
|
|
157
|
-
if (editingState[id][field].isProcessingProps) {
|
|
158
|
+
if (editingState[id][field].isProcessingProps && !props.disableIgnoreModificationsIfProcessingProps) {
|
|
158
159
|
// The user wants to stop editing the cell but we can't wait for the props to be processed.
|
|
159
160
|
// In this case, discard the modifications.
|
|
160
161
|
ignoreModifications = true;
|
|
@@ -166,7 +167,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
166
167
|
ignoreModifications,
|
|
167
168
|
cellToFocusAfter
|
|
168
169
|
});
|
|
169
|
-
}, [apiRef]);
|
|
170
|
+
}, [apiRef, props.disableIgnoreModificationsIfProcessingProps]);
|
|
170
171
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', runIfEditModeIsCell(handleCellDoubleClick));
|
|
171
172
|
useGridApiEventHandler(apiRef, 'cellFocusOut', runIfEditModeIsCell(handleCellFocusOut));
|
|
172
173
|
useGridApiEventHandler(apiRef, 'cellKeyDown', runIfEditModeIsCell(handleCellKeyDown));
|
|
@@ -394,7 +395,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
394
395
|
newProps.value = column.preProcessEditCellProps ? editingState[id][field].value : parsedValue;
|
|
395
396
|
updateOrDeleteFieldState(id, field, newProps);
|
|
396
397
|
editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
397
|
-
return !editingState[id][field]
|
|
398
|
+
return !editingState[id]?.[field]?.error;
|
|
398
399
|
}, [apiRef, throwIfNotEditable, throwIfNotInMode, updateOrDeleteFieldState]);
|
|
399
400
|
const getRowWithUpdatedValuesFromCellEditing = React.useCallback((id, field) => {
|
|
400
401
|
const column = apiRef.current.getColumn(field);
|
|
@@ -28,7 +28,7 @@ export function useGridEditing(apiRef, props) {
|
|
|
28
28
|
stateSelector: gridEditRowsStateSelector,
|
|
29
29
|
changeEvent: 'editRowsModelChange'
|
|
30
30
|
});
|
|
31
|
-
const isCellEditable = React.useCallback(params => !params.rowNode.isAutoGenerated && !!params.colDef.editable && !!params.colDef.renderEditCell && (!props.isCellEditable || props.isCellEditable(params)), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
+
const isCellEditable = React.useCallback(params => !params.rowNode.isAutoGenerated && !params.rowNode.isPinned && !!params.colDef.editable && !!params.colDef.renderEditCell && (!props.isCellEditable || props.isCellEditable(params)), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
32
|
[props.isCellEditable]);
|
|
33
33
|
|
|
34
34
|
const maybeDebounce = (id, field, debounceMs, callback) => {
|
|
@@ -152,7 +152,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
152
152
|
let reason;
|
|
153
153
|
|
|
154
154
|
if (isPrintableKey(event.key)) {
|
|
155
|
-
if (event.
|
|
155
|
+
if (event.ctrlKey && event.key !== 'v' || event.metaKey && event.key !== 'v' || event.altKey) {
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -212,7 +212,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
212
212
|
let ignoreModifications = reason === 'escapeKeyDown';
|
|
213
213
|
const editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
214
214
|
|
|
215
|
-
if (!ignoreModifications) {
|
|
215
|
+
if (!ignoreModifications && !props.disableIgnoreModificationsIfProcessingProps) {
|
|
216
216
|
// The user wants to stop editing the cell but we can't wait for the props to be processed.
|
|
217
217
|
// In this case, discard the modifications if any field is processing its props.
|
|
218
218
|
ignoreModifications = Object.values(editingState[id]).some(fieldProps => {
|
|
@@ -226,7 +226,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
226
226
|
field,
|
|
227
227
|
cellToFocusAfter
|
|
228
228
|
});
|
|
229
|
-
}, [apiRef]);
|
|
229
|
+
}, [apiRef, props.disableIgnoreModificationsIfProcessingProps]);
|
|
230
230
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', runIfEditModeIsRow(handleCellDoubleClick));
|
|
231
231
|
useGridApiEventHandler(apiRef, 'cellFocusIn', runIfEditModeIsRow(handleCellFocusIn));
|
|
232
232
|
useGridApiEventHandler(apiRef, 'cellFocusOut', runIfEditModeIsRow(handleCellFocusOut));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { gridColumnDefinitionsSelector, gridVisibleColumnDefinitionsSelector } from '../columns';
|
|
2
2
|
import { gridFilteredSortedRowIdsSelector } from '../filter';
|
|
3
|
+
import { gridPinnedRowsSelector, gridRowTreeSelector } from '../rows/gridRowsSelector';
|
|
3
4
|
export const getColumnsToExport = ({
|
|
4
5
|
apiRef,
|
|
5
6
|
options
|
|
@@ -17,11 +18,18 @@ export const defaultGetRowsToExport = ({
|
|
|
17
18
|
apiRef
|
|
18
19
|
}) => {
|
|
19
20
|
const filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
|
|
21
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
20
22
|
const selectedRows = apiRef.current.getSelectedRows();
|
|
23
|
+
const bodyRows = filteredSortedRowIds.filter(id => (rowTree[id].position ?? 'body') === 'body');
|
|
24
|
+
const pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
25
|
+
const topPinnedRowsIds = pinnedRows?.top?.map(row => row.id) || [];
|
|
26
|
+
const bottomPinnedRowsIds = pinnedRows?.bottom?.map(row => row.id) || [];
|
|
27
|
+
bodyRows.unshift(...topPinnedRowsIds);
|
|
28
|
+
bodyRows.push(...bottomPinnedRowsIds);
|
|
21
29
|
|
|
22
30
|
if (selectedRows.size > 0) {
|
|
23
|
-
return
|
|
31
|
+
return bodyRows.filter(id => selectedRows.has(id));
|
|
24
32
|
}
|
|
25
33
|
|
|
26
|
-
return
|
|
34
|
+
return bodyRows;
|
|
27
35
|
};
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { GridLinkOperator } from '../../../models';
|
|
3
3
|
import { buildWarning } from '../../../utils/warning';
|
|
4
4
|
import { gridColumnFieldsSelector, gridColumnLookupSelector } from '../columns';
|
|
5
|
+
import { gridRowTreeSelector } from '../rows/gridRowsSelector';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Adds default values to the optional fields of a filter items.
|
|
@@ -80,6 +81,7 @@ export const buildAggregatedFilterItemsApplier = (filterModel, apiRef) => {
|
|
|
80
81
|
items,
|
|
81
82
|
linkOperator = GridLinkOperator.And
|
|
82
83
|
} = filterModel;
|
|
84
|
+
const tree = gridRowTreeSelector(apiRef);
|
|
83
85
|
|
|
84
86
|
const getFilterCallbackFromItem = filterItem => {
|
|
85
87
|
if (!filterItem.columnField || !filterItem.operatorValue) {
|
|
@@ -141,6 +143,10 @@ export const buildAggregatedFilterItemsApplier = (filterModel, apiRef) => {
|
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
return (rowId, shouldApplyFilter) => {
|
|
146
|
+
if (tree[rowId].position === 'footer') {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
|
|
144
150
|
const filteredAppliers = shouldApplyFilter ? appliers.filter(applier => shouldApplyFilter(applier.item.columnField)) : appliers; // Return `false` as soon as we have a failing filter
|
|
145
151
|
|
|
146
152
|
if (linkOperator === GridLinkOperator.And) {
|
|
@@ -109,7 +109,23 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
109
109
|
|
|
110
110
|
if (targetColumnField) {
|
|
111
111
|
const filterModel = gridFilterModelSelector(apiRef);
|
|
112
|
-
const filterItemsWithValue = filterModel.items.filter(item =>
|
|
112
|
+
const filterItemsWithValue = filterModel.items.filter(item => {
|
|
113
|
+
if (item.value !== undefined) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const column = apiRef.current.getColumn(item.columnField);
|
|
118
|
+
const filterOperator = column.filterOperators?.find(operator => operator.value === item.operatorValue);
|
|
119
|
+
const requiresFilterValue = typeof filterOperator?.requiresFilterValue === 'undefined' ? true : filterOperator?.requiresFilterValue; // Operators like `isEmpty` don't have and don't require `item.value`.
|
|
120
|
+
// So we don't want to remove them from the filter model if `item.value === undefined`.
|
|
121
|
+
// See https://github.com/mui/mui-x/issues/5402
|
|
122
|
+
|
|
123
|
+
if (requiresFilterValue) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return true;
|
|
128
|
+
});
|
|
113
129
|
let newFilterItems;
|
|
114
130
|
const filterItemOnTarget = filterItemsWithValue.find(item => item.columnField === targetColumnField);
|
|
115
131
|
|
|
@@ -188,10 +204,15 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
188
204
|
* PRE-PROCESSING
|
|
189
205
|
*/
|
|
190
206
|
|
|
191
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
207
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
192
208
|
const filterModelToExport = gridFilterModelSelector(apiRef);
|
|
209
|
+
const shouldExportFilterModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
210
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
211
|
+
props.filterModel != null || // Always export if the model has been initialized
|
|
212
|
+
props.initialState?.filter?.filterModel != null || // Export if the model is not equal to the default value
|
|
213
|
+
!isDeepEqual(filterModelToExport, getDefaultGridFilterModel());
|
|
193
214
|
|
|
194
|
-
if (
|
|
215
|
+
if (!shouldExportFilterModel) {
|
|
195
216
|
return prevState;
|
|
196
217
|
}
|
|
197
218
|
|
|
@@ -200,7 +221,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
200
221
|
filterModel: filterModelToExport
|
|
201
222
|
}
|
|
202
223
|
});
|
|
203
|
-
}, [apiRef]);
|
|
224
|
+
}, [apiRef, props.filterModel, props.initialState?.filter?.filterModel]);
|
|
204
225
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
205
226
|
const filterModel = context.stateToRestore.filter?.filterModel;
|
|
206
227
|
|
|
@@ -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,18 +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,
|
|
39
|
+
const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left') => {
|
|
32
40
|
const visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);
|
|
33
|
-
const rowId = visibleSortedRows[rowIndex]?.id;
|
|
34
41
|
const nextCellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, colIndex);
|
|
35
42
|
|
|
36
43
|
if (nextCellColSpanInfo && nextCellColSpanInfo.spannedByColSpan) {
|
|
@@ -39,12 +46,15 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
39
46
|
} else if (closestColumnToUse === 'right') {
|
|
40
47
|
colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
|
|
41
48
|
}
|
|
42
|
-
}
|
|
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.
|
|
43
51
|
|
|
44
|
-
|
|
52
|
+
|
|
53
|
+
const rowIndexRelativeToAllRows = visibleSortedRows.findIndex(row => row.id === rowId);
|
|
54
|
+
logger.debug(`Navigating to cell row ${rowIndexRelativeToAllRows}, col ${colIndex}`);
|
|
45
55
|
apiRef.current.scrollToIndexes({
|
|
46
56
|
colIndex,
|
|
47
|
-
rowIndex
|
|
57
|
+
rowIndex: rowIndexRelativeToAllRows
|
|
48
58
|
});
|
|
49
59
|
const field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
50
60
|
apiRef.current.setCellFocus(rowId, field);
|
|
@@ -57,19 +67,21 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
57
67
|
const field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
58
68
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
59
69
|
}, [apiRef, logger]);
|
|
70
|
+
const getRowIdFromIndex = React.useCallback(rowIndex => {
|
|
71
|
+
return currentPageRows[rowIndex].id;
|
|
72
|
+
}, [currentPageRows]);
|
|
60
73
|
const handleCellNavigationKeyDown = React.useCallback((params, event) => {
|
|
61
74
|
const dimensions = apiRef.current.getRootDimensions();
|
|
62
75
|
|
|
63
|
-
if (
|
|
76
|
+
if (currentPageRows.length === 0 || !dimensions) {
|
|
64
77
|
return;
|
|
65
78
|
}
|
|
66
79
|
|
|
67
80
|
const viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
68
|
-
const visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);
|
|
69
81
|
const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
70
|
-
const rowIndexBefore =
|
|
71
|
-
const firstRowIndexInPage =
|
|
72
|
-
const lastRowIndexInPage =
|
|
82
|
+
const rowIndexBefore = currentPageRows.findIndex(row => row.id === params.id);
|
|
83
|
+
const firstRowIndexInPage = 0;
|
|
84
|
+
const lastRowIndexInPage = currentPageRows.length - 1;
|
|
73
85
|
const firstColIndex = 0;
|
|
74
86
|
const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
75
87
|
let shouldPreventDefault = true;
|
|
@@ -80,7 +92,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
80
92
|
{
|
|
81
93
|
// "Enter" is only triggered by the row / cell editing feature
|
|
82
94
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
83
|
-
goToCell(colIndexBefore, rowIndexBefore + 1);
|
|
95
|
+
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
|
|
84
96
|
}
|
|
85
97
|
|
|
86
98
|
break;
|
|
@@ -89,7 +101,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
89
101
|
case 'ArrowUp':
|
|
90
102
|
{
|
|
91
103
|
if (rowIndexBefore > firstRowIndexInPage) {
|
|
92
|
-
goToCell(colIndexBefore, rowIndexBefore - 1);
|
|
104
|
+
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore - 1));
|
|
93
105
|
} else {
|
|
94
106
|
goToHeader(colIndexBefore, event);
|
|
95
107
|
}
|
|
@@ -100,7 +112,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
100
112
|
case 'ArrowRight':
|
|
101
113
|
{
|
|
102
114
|
if (colIndexBefore < lastColIndex) {
|
|
103
|
-
goToCell(colIndexBefore + 1, rowIndexBefore, 'right');
|
|
115
|
+
goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');
|
|
104
116
|
}
|
|
105
117
|
|
|
106
118
|
break;
|
|
@@ -109,7 +121,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
109
121
|
case 'ArrowLeft':
|
|
110
122
|
{
|
|
111
123
|
if (colIndexBefore > firstColIndex) {
|
|
112
|
-
goToCell(colIndexBefore - 1, rowIndexBefore);
|
|
124
|
+
goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore));
|
|
113
125
|
}
|
|
114
126
|
|
|
115
127
|
break;
|
|
@@ -119,9 +131,9 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
119
131
|
{
|
|
120
132
|
// "Tab" is only triggered by the row / cell editing feature
|
|
121
133
|
if (event.shiftKey && colIndexBefore > firstColIndex) {
|
|
122
|
-
goToCell(colIndexBefore - 1, rowIndexBefore, 'left');
|
|
134
|
+
goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore), 'left');
|
|
123
135
|
} else if (!event.shiftKey && colIndexBefore < lastColIndex) {
|
|
124
|
-
goToCell(colIndexBefore + 1, rowIndexBefore, 'right');
|
|
136
|
+
goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');
|
|
125
137
|
}
|
|
126
138
|
|
|
127
139
|
break;
|
|
@@ -142,7 +154,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
142
154
|
}
|
|
143
155
|
|
|
144
156
|
if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {
|
|
145
|
-
goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
|
|
157
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));
|
|
146
158
|
}
|
|
147
159
|
|
|
148
160
|
break;
|
|
@@ -151,7 +163,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
151
163
|
case 'PageDown':
|
|
152
164
|
{
|
|
153
165
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
154
|
-
goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
|
|
166
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));
|
|
155
167
|
}
|
|
156
168
|
|
|
157
169
|
break;
|
|
@@ -163,7 +175,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
163
175
|
const nextRowIndex = Math.max(rowIndexBefore - viewportPageSize, firstRowIndexInPage);
|
|
164
176
|
|
|
165
177
|
if (nextRowIndex !== rowIndexBefore && nextRowIndex >= firstRowIndexInPage) {
|
|
166
|
-
goToCell(colIndexBefore, nextRowIndex);
|
|
178
|
+
goToCell(colIndexBefore, getRowIdFromIndex(nextRowIndex));
|
|
167
179
|
} else {
|
|
168
180
|
goToHeader(colIndexBefore, event);
|
|
169
181
|
}
|
|
@@ -174,9 +186,9 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
174
186
|
case 'Home':
|
|
175
187
|
{
|
|
176
188
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
177
|
-
goToCell(firstColIndex, firstRowIndexInPage);
|
|
189
|
+
goToCell(firstColIndex, getRowIdFromIndex(firstRowIndexInPage));
|
|
178
190
|
} else {
|
|
179
|
-
goToCell(firstColIndex, rowIndexBefore);
|
|
191
|
+
goToCell(firstColIndex, getRowIdFromIndex(rowIndexBefore));
|
|
180
192
|
}
|
|
181
193
|
|
|
182
194
|
break;
|
|
@@ -185,9 +197,9 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
185
197
|
case 'End':
|
|
186
198
|
{
|
|
187
199
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
188
|
-
goToCell(lastColIndex, lastRowIndexInPage);
|
|
200
|
+
goToCell(lastColIndex, getRowIdFromIndex(lastRowIndexInPage));
|
|
189
201
|
} else {
|
|
190
|
-
goToCell(lastColIndex, rowIndexBefore);
|
|
202
|
+
goToCell(lastColIndex, getRowIdFromIndex(rowIndexBefore));
|
|
191
203
|
}
|
|
192
204
|
|
|
193
205
|
break;
|
|
@@ -202,7 +214,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
202
214
|
if (shouldPreventDefault) {
|
|
203
215
|
event.preventDefault();
|
|
204
216
|
}
|
|
205
|
-
}, [apiRef,
|
|
217
|
+
}, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);
|
|
206
218
|
const handleColumnHeaderKeyDown = React.useCallback((params, event) => {
|
|
207
219
|
const headerTitleNode = event.currentTarget.querySelector(`.${gridClasses.columnHeaderTitleContainerContent}`);
|
|
208
220
|
const isFromInsideContent = !!headerTitleNode && headerTitleNode.contains(event.target);
|
|
@@ -221,8 +233,8 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
221
233
|
|
|
222
234
|
const viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
223
235
|
const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
224
|
-
const firstRowIndexInPage =
|
|
225
|
-
const lastRowIndexInPage =
|
|
236
|
+
const firstRowIndexInPage = 0;
|
|
237
|
+
const lastRowIndexInPage = currentPageRows.length - 1;
|
|
226
238
|
const firstColIndex = 0;
|
|
227
239
|
const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
228
240
|
let shouldPreventDefault = true;
|
|
@@ -231,7 +243,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
231
243
|
case 'ArrowDown':
|
|
232
244
|
{
|
|
233
245
|
if (firstRowIndexInPage !== null) {
|
|
234
|
-
goToCell(colIndexBefore, firstRowIndexInPage);
|
|
246
|
+
goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
|
|
235
247
|
}
|
|
236
248
|
|
|
237
249
|
break;
|
|
@@ -258,7 +270,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
258
270
|
case 'PageDown':
|
|
259
271
|
{
|
|
260
272
|
if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
|
|
261
|
-
goToCell(colIndexBefore, Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage));
|
|
273
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));
|
|
262
274
|
}
|
|
263
275
|
|
|
264
276
|
break;
|
|
@@ -300,7 +312,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
300
312
|
if (shouldPreventDefault) {
|
|
301
313
|
event.preventDefault();
|
|
302
314
|
}
|
|
303
|
-
}, [apiRef,
|
|
315
|
+
}, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);
|
|
304
316
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
305
317
|
// Ignore portal
|
|
306
318
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -61,11 +61,12 @@ export const useGridPage = (apiRef, props) => {
|
|
|
61
61
|
* PRE-PROCESSING
|
|
62
62
|
*/
|
|
63
63
|
|
|
64
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
64
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
65
65
|
const pageToExport = gridPageSelector(apiRef);
|
|
66
|
-
const shouldExportPage = // Always export if the
|
|
66
|
+
const shouldExportPage = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
67
|
+
!context.exportOnlyDirtyModels || // Always export if the page is controlled
|
|
67
68
|
props.page != null || // Always export if the page has been initialized
|
|
68
|
-
props.initialState?.pagination?.page != null || // Export if the page
|
|
69
|
+
props.initialState?.pagination?.page != null || // Export if the page is not equal to the default value
|
|
69
70
|
pageToExport !== 0;
|
|
70
71
|
|
|
71
72
|
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, {
|
|
@@ -47,11 +48,12 @@ export const useGridPageSize = (apiRef, props) => {
|
|
|
47
48
|
* PRE-PROCESSING
|
|
48
49
|
*/
|
|
49
50
|
|
|
50
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
51
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
51
52
|
const pageSizeToExport = gridPageSizeSelector(apiRef);
|
|
52
|
-
const shouldExportPageSize = // Always export if the
|
|
53
|
+
const shouldExportPageSize = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
54
|
+
!context.exportOnlyDirtyModels || // Always export if the page size is controlled
|
|
53
55
|
props.pageSize != null || // Always export if the page size has been initialized
|
|
54
|
-
props.initialState?.pagination?.pageSize != null || // Export if the page size
|
|
56
|
+
props.initialState?.pagination?.pageSize != null || // Export if the page size is not equal to the default value
|
|
55
57
|
pageSizeToExport !== defaultPageSize(props.autoPageSize);
|
|
56
58
|
|
|
57
59
|
if (!shouldExportPageSize) {
|
|
@@ -90,7 +92,8 @@ export const useGridPageSize = (apiRef, props) => {
|
|
|
90
92
|
return;
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
const
|
|
95
|
+
const pinnedRowsHeight = calculatePinnedRowsHeight(apiRef);
|
|
96
|
+
const maximumPageSizeWithoutScrollBar = Math.floor((dimensions.viewportInnerSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom) / rowHeight);
|
|
94
97
|
apiRef.current.setPageSize(maximumPageSizeWithoutScrollBar);
|
|
95
98
|
}, [apiRef, props.autoPageSize, rowHeight]);
|
|
96
99
|
useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleUpdateAutoPageSize);
|
|
@@ -13,7 +13,7 @@ export const preferencePanelStateInitializer = (state, props) => _extends({}, st
|
|
|
13
13
|
* TODO: Add a single `setPreferencePanel` method to avoid multiple `setState`
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
export const useGridPreferencesPanel = apiRef => {
|
|
16
|
+
export const useGridPreferencesPanel = (apiRef, props) => {
|
|
17
17
|
const logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
|
|
18
18
|
const hideTimeout = React.useRef();
|
|
19
19
|
const immediateTimeout = React.useRef();
|
|
@@ -70,17 +70,21 @@ export const useGridPreferencesPanel = apiRef => {
|
|
|
70
70
|
* PRE-PROCESSING
|
|
71
71
|
*/
|
|
72
72
|
|
|
73
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
73
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
74
74
|
const preferencePanelToExport = gridPreferencePanelStateSelector(apiRef.current.state);
|
|
75
|
+
const shouldExportPreferencePanel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
76
|
+
!context.exportOnlyDirtyModels || // Always export if the panel was initialized
|
|
77
|
+
props.initialState?.preferencePanel != null || // Always export if the panel is opened
|
|
78
|
+
preferencePanelToExport.open;
|
|
75
79
|
|
|
76
|
-
if (!
|
|
80
|
+
if (!shouldExportPreferencePanel) {
|
|
77
81
|
return prevState;
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
return _extends({}, prevState, {
|
|
81
85
|
preferencePanel: preferencePanelToExport
|
|
82
86
|
});
|
|
83
|
-
}, [apiRef]);
|
|
87
|
+
}, [apiRef, props.initialState?.preferencePanel]);
|
|
84
88
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
85
89
|
const preferencePanel = context.stateToRestore.preferencePanel;
|
|
86
90
|
|