@mui/x-data-grid 5.13.1 → 5.15.1
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 +147 -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/gridStringColDef.d.ts +3 -0
- package/colDef/gridStringColDef.js +6 -0
- 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/GridEditInputCell.d.ts +2 -5
- package/components/cell/GridEditInputCell.js +13 -14
- package/components/cell/GridEditSingleSelectCell.d.ts +4 -0
- package/components/cell/GridEditSingleSelectCell.js +11 -4
- 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/GridToolbarDensitySelector.js +13 -4
- package/components/toolbar/GridToolbarExport.js +20 -10
- package/components/toolbar/GridToolbarExportContainer.js +13 -2
- package/constants/envConstants.d.ts +1 -1
- package/constants/envConstants.js +2 -11
- 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 +11 -9
- package/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- 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 +7 -8
- 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 +11 -4
- 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 +32 -18
- 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/gridStringColDef.js +6 -0
- 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/GridEditInputCell.js +13 -14
- package/legacy/components/cell/GridEditSingleSelectCell.js +11 -3
- 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/GridToolbarDensitySelector.js +14 -5
- package/legacy/components/toolbar/GridToolbarExport.js +20 -10
- package/legacy/components/toolbar/GridToolbarExportContainer.js +15 -2
- package/legacy/constants/envConstants.js +2 -11
- 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 +11 -9
- package/legacy/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- 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 +7 -8
- 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 +11 -4
- 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 +33 -18
- 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 +9 -2
- 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 +9 -2
- 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 +21 -14
- package/legacy/locales/jaJP.js +11 -4
- package/legacy/locales/koKR.js +35 -24
- package/legacy/locales/nbNO.js +9 -2
- package/legacy/locales/nlNL.js +9 -2
- package/legacy/locales/plPL.js +8 -1
- package/legacy/locales/ptBR.js +9 -2
- package/legacy/locales/roRO.js +9 -2
- 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/legacy/utils/keyboardUtils.js +8 -5
- 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 +9 -2
- 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 +9 -2
- 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 +21 -14
- package/locales/jaJP.js +11 -4
- package/locales/koKR.js +31 -24
- package/locales/nbNO.js +9 -2
- package/locales/nlNL.js +9 -2
- package/locales/plPL.js +8 -1
- package/locales/ptBR.js +9 -2
- package/locales/roRO.js +9 -2
- 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/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/gridStringColDef.js +6 -0
- 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/GridEditInputCell.js +13 -14
- package/modern/components/cell/GridEditSingleSelectCell.js +11 -4
- 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/GridToolbarDensitySelector.js +11 -4
- package/modern/components/toolbar/GridToolbarExport.js +20 -10
- package/modern/components/toolbar/GridToolbarExportContainer.js +11 -2
- package/modern/constants/envConstants.js +2 -11
- 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 +9 -9
- package/modern/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- 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 +7 -8
- 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 +8 -3
- 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 +31 -17
- 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 +9 -2
- 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 +9 -2
- 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 +21 -14
- package/modern/locales/jaJP.js +11 -4
- package/modern/locales/koKR.js +31 -24
- package/modern/locales/nbNO.js +9 -2
- package/modern/locales/nlNL.js +9 -2
- package/modern/locales/plPL.js +8 -1
- package/modern/locales/ptBR.js +9 -2
- package/modern/locales/roRO.js +9 -2
- 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/modern/utils/keyboardUtils.js +7 -2
- 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/gridStringColDef.js +5 -0
- 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/GridEditInputCell.js +15 -16
- package/node/components/cell/GridEditSingleSelectCell.js +10 -4
- 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/GridToolbarDensitySelector.js +13 -4
- package/node/components/toolbar/GridToolbarExport.js +16 -10
- package/node/components/toolbar/GridToolbarExportContainer.js +13 -2
- package/node/constants/envConstants.js +2 -13
- 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 +11 -9
- package/node/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- 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 +7 -8
- 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 +11 -4
- 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 +32 -18
- 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 +9 -2
- 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 +9 -2
- 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 +21 -14
- package/node/locales/jaJP.js +11 -4
- package/node/locales/koKR.js +31 -24
- package/node/locales/nbNO.js +9 -2
- package/node/locales/nlNL.js +9 -2
- package/node/locales/plPL.js +8 -1
- package/node/locales/ptBR.js +9 -2
- package/node/locales/roRO.js +9 -2
- 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/node/utils/keyboardUtils.js +10 -4
- package/package.json +1 -1
- package/utils/getGridLocalization.d.ts +1 -1
- package/utils/keyboardUtils.d.ts +2 -2
- package/utils/keyboardUtils.js +7 -2
|
@@ -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]
|
|
@@ -61,9 +61,9 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
61
61
|
checkboxSelection,
|
|
62
62
|
disableMultipleSelection,
|
|
63
63
|
disableSelectionOnClick,
|
|
64
|
-
isRowSelectable,
|
|
65
64
|
pagination,
|
|
66
|
-
paginationMode
|
|
65
|
+
paginationMode,
|
|
66
|
+
isRowSelectable: propIsRowSelectable
|
|
67
67
|
} = props;
|
|
68
68
|
const canHaveMultipleSelection = !disableMultipleSelection || checkboxSelection;
|
|
69
69
|
const visibleRows = useGridVisibleRows(apiRef, props);
|
|
@@ -112,9 +112,22 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
112
112
|
}
|
|
113
113
|
}, [apiRef, logger]);
|
|
114
114
|
const isRowSelected = React.useCallback(id => gridSelectionStateSelector(apiRef.current.state).includes(id), [apiRef]);
|
|
115
|
+
const isRowSelectable = React.useCallback(id => {
|
|
116
|
+
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const rowNode = apiRef.current.getRowNode(id);
|
|
121
|
+
|
|
122
|
+
if ((rowNode == null ? void 0 : rowNode.position) === 'footer' || rowNode != null && rowNode.isPinned) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return true;
|
|
127
|
+
}, [apiRef, propIsRowSelectable]);
|
|
115
128
|
const getSelectedRows = React.useCallback(() => selectedGridRowsSelector(apiRef), [apiRef]);
|
|
116
129
|
const selectRow = React.useCallback((id, isSelected = true, resetSelection = false) => {
|
|
117
|
-
if (
|
|
130
|
+
if (!apiRef.current.isRowSelectable(id)) {
|
|
118
131
|
return;
|
|
119
132
|
}
|
|
120
133
|
|
|
@@ -138,10 +151,10 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
138
151
|
apiRef.current.setSelectionModel(newSelection);
|
|
139
152
|
}
|
|
140
153
|
}
|
|
141
|
-
}, [apiRef,
|
|
154
|
+
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
142
155
|
const selectRows = React.useCallback((ids, isSelected = true, resetSelection = false) => {
|
|
143
156
|
logger.debug(`Setting selection for several rows`);
|
|
144
|
-
const selectableIds =
|
|
157
|
+
const selectableIds = ids.filter(id => apiRef.current.isRowSelectable(id));
|
|
145
158
|
let newSelection;
|
|
146
159
|
|
|
147
160
|
if (resetSelection) {
|
|
@@ -165,7 +178,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
165
178
|
if (isSelectionValid) {
|
|
166
179
|
apiRef.current.setSelectionModel(newSelection);
|
|
167
180
|
}
|
|
168
|
-
}, [apiRef,
|
|
181
|
+
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
169
182
|
const selectRowRange = React.useCallback(({
|
|
170
183
|
startId,
|
|
171
184
|
endId
|
|
@@ -189,7 +202,8 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
189
202
|
selectRowRange,
|
|
190
203
|
setSelectionModel,
|
|
191
204
|
getSelectedRows,
|
|
192
|
-
isRowSelected
|
|
205
|
+
isRowSelected,
|
|
206
|
+
isRowSelectable
|
|
193
207
|
};
|
|
194
208
|
useGridApiMethod(apiRef, selectionApi, 'GridSelectionApi');
|
|
195
209
|
/**
|
|
@@ -257,6 +271,10 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
257
271
|
}
|
|
258
272
|
}
|
|
259
273
|
|
|
274
|
+
if (params.rowNode.isPinned) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
260
278
|
if (event.shiftKey && (canHaveMultipleSelection || checkboxSelection)) {
|
|
261
279
|
expandMouseRowRangeSelection(params.id);
|
|
262
280
|
} else {
|
|
@@ -371,13 +389,13 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
371
389
|
React.useEffect(() => {
|
|
372
390
|
if (isStateControlled) {
|
|
373
391
|
return;
|
|
374
|
-
} // isRowSelectable changed
|
|
392
|
+
} // props.isRowSelectable changed
|
|
375
393
|
|
|
376
394
|
|
|
377
395
|
const currentSelection = gridSelectionStateSelector(apiRef.current.state);
|
|
378
396
|
|
|
379
397
|
if (isRowSelectable) {
|
|
380
|
-
const newSelection = currentSelection.filter(id => isRowSelectable(
|
|
398
|
+
const newSelection = currentSelection.filter(id => isRowSelectable(id));
|
|
381
399
|
|
|
382
400
|
if (newSelection.length < currentSelection.length) {
|
|
383
401
|
apiRef.current.setSelectionModel(newSelection);
|
|
@@ -404,7 +422,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
404
422
|
let isSelectable = true;
|
|
405
423
|
|
|
406
424
|
if (isRowSelectable) {
|
|
407
|
-
isSelectable = isRowSelectable(
|
|
425
|
+
isSelectable = isRowSelectable(id);
|
|
408
426
|
}
|
|
409
427
|
|
|
410
428
|
return isSelectable && currentPageRowsLookup[id]; // Check if the row is in the current page
|
|
@@ -46,25 +46,24 @@ const parseSortItem = (sortItem, apiRef) => {
|
|
|
46
46
|
comparator
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
+
|
|
49
50
|
/**
|
|
50
51
|
* Compare two rows according to a list of valid sort items.
|
|
51
52
|
* The `row1Params` and `row2Params` must have the same length as `parsedSortItems`,
|
|
52
53
|
* and each of their index must contain the `GridSortCellParams` of the sort item with the same index.
|
|
53
54
|
* @param {GridParsedSortItem[]} parsedSortItems All the sort items with which we want to compare the rows.
|
|
54
|
-
* @param {
|
|
55
|
-
* @param {
|
|
55
|
+
* @param {GridRowAggregatedSortingParams} row1 The node and params of the 1st row for each sort item.
|
|
56
|
+
* @param {GridRowAggregatedSortingParams} row2 The node and params of the 2nd row for each sort item.
|
|
56
57
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const compareRows = (parsedSortItems, row1Params, row2Params) => {
|
|
58
|
+
const compareRows = (parsedSortItems, row1, row2) => {
|
|
60
59
|
return parsedSortItems.reduce((res, item, index) => {
|
|
61
60
|
if (res !== 0) {
|
|
62
61
|
// return the results of the first comparator which distinguish the two rows
|
|
63
62
|
return res;
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
const sortCellParams1 =
|
|
67
|
-
const sortCellParams2 =
|
|
65
|
+
const sortCellParams1 = row1.params[index];
|
|
66
|
+
const sortCellParams2 = row2.params[index];
|
|
68
67
|
res = item.comparator(sortCellParams1.value, sortCellParams2.value, sortCellParams1, sortCellParams2);
|
|
69
68
|
return res;
|
|
70
69
|
}, 0);
|
|
@@ -84,10 +83,10 @@ export const buildAggregatedSortingApplier = (sortModel, apiRef) => {
|
|
|
84
83
|
return null;
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
return rowList => rowList.map(
|
|
88
|
-
|
|
89
|
-
params: comparatorList.map(el => el.getSortCellParams(
|
|
90
|
-
})).sort((a, b) => compareRows(comparatorList, a
|
|
86
|
+
return rowList => rowList.map(node => ({
|
|
87
|
+
node,
|
|
88
|
+
params: comparatorList.map(el => el.getSortCellParams(node.id))
|
|
89
|
+
})).sort((a, b) => compareRows(comparatorList, a, b)).map(row => row.node.id);
|
|
91
90
|
};
|
|
92
91
|
export const getNextGridSortDirection = (sortingOrder, current) => {
|
|
93
92
|
const currentIdx = sortingOrder.indexOf(current);
|
|
@@ -7,4 +7,4 @@ export declare const sortingStateInitializer: GridStateInitializer<Pick<DataGrid
|
|
|
7
7
|
* @requires useGridRows (event)
|
|
8
8
|
* @requires useGridColumns (event)
|
|
9
9
|
*/
|
|
10
|
-
export declare const useGridSorting: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'sortModel' | 'onSortModelChange' | 'sortingOrder' | 'sortingMode' | 'disableMultipleColumnsSorting'>) => void;
|
|
10
|
+
export declare const useGridSorting: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'initialState' | 'sortModel' | 'onSortModelChange' | 'sortingOrder' | 'sortingMode' | 'disableMultipleColumnsSorting'>) => void;
|
|
@@ -29,6 +29,8 @@ export const sortingStateInitializer = (state, props) => {
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
export const useGridSorting = (apiRef, props) => {
|
|
32
|
+
var _props$initialState3, _props$initialState3$;
|
|
33
|
+
|
|
32
34
|
const logger = useGridLogger(apiRef, 'useGridSorting');
|
|
33
35
|
apiRef.current.unstable_registerControlState({
|
|
34
36
|
stateId: 'sortModel',
|
|
@@ -152,10 +154,17 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
152
154
|
* PRE-PROCESSING
|
|
153
155
|
*/
|
|
154
156
|
|
|
155
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
157
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
158
|
+
var _props$initialState2, _props$initialState2$;
|
|
159
|
+
|
|
156
160
|
const sortModelToExport = gridSortModelSelector(apiRef);
|
|
161
|
+
const shouldExportSortModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
162
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
163
|
+
props.sortModel != null || // Always export if the model has been initialized
|
|
164
|
+
((_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.sorting) == null ? void 0 : _props$initialState2$.sortModel) != null || // Export if the model is not empty
|
|
165
|
+
sortModelToExport.length > 0;
|
|
157
166
|
|
|
158
|
-
if (
|
|
167
|
+
if (!shouldExportSortModel) {
|
|
159
168
|
return prevState;
|
|
160
169
|
}
|
|
161
170
|
|
|
@@ -164,7 +173,7 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
164
173
|
sortModel: sortModelToExport
|
|
165
174
|
}
|
|
166
175
|
});
|
|
167
|
-
}, [apiRef]);
|
|
176
|
+
}, [apiRef, props.sortModel, (_props$initialState3 = props.initialState) == null ? void 0 : (_props$initialState3$ = _props$initialState3.sorting) == null ? void 0 : _props$initialState3$.sortModel]);
|
|
168
177
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
169
178
|
var _context$stateToResto;
|
|
170
179
|
|
|
@@ -180,12 +189,39 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
180
189
|
});
|
|
181
190
|
}, [apiRef, props.disableMultipleColumnsSorting]);
|
|
182
191
|
const flatSortingMethod = React.useCallback(params => {
|
|
192
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
193
|
+
|
|
183
194
|
if (!params.sortRowList) {
|
|
184
|
-
|
|
195
|
+
const bodyRowIds = [];
|
|
196
|
+
const footerRowIds = [];
|
|
197
|
+
gridRowIdsSelector(apiRef).forEach(rowId => {
|
|
198
|
+
if (rowTree[rowId].isPinned) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (rowTree[rowId].position === 'footer') {
|
|
203
|
+
footerRowIds.push(rowId);
|
|
204
|
+
} else {
|
|
205
|
+
bodyRowIds.push(rowId);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
return [...bodyRowIds, ...footerRowIds];
|
|
185
209
|
}
|
|
186
210
|
|
|
187
|
-
const
|
|
188
|
-
|
|
211
|
+
const bodyRows = [];
|
|
212
|
+
const footerRowIds = [];
|
|
213
|
+
Object.values(rowTree).forEach(rowNode => {
|
|
214
|
+
if (rowNode.isPinned) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (rowNode.position === 'footer') {
|
|
219
|
+
footerRowIds.push(rowNode.id);
|
|
220
|
+
} else {
|
|
221
|
+
bodyRows.push(rowNode);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
return [...params.sortRowList(bodyRows), ...footerRowIds];
|
|
189
225
|
}, [apiRef]);
|
|
190
226
|
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
191
227
|
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
@@ -3,9 +3,10 @@ export interface GridStatePersistenceApi<InitialState extends GridInitialStateCo
|
|
|
3
3
|
/**
|
|
4
4
|
* Generates a serializable object containing the exportable parts of the DataGrid state.
|
|
5
5
|
* These values can then be passed to the `initialState` prop or injected using the `restoreState` method.
|
|
6
|
+
* @param {GridExportStateParams} params With all properties from [[GridExportStateParams]]
|
|
6
7
|
* @returns {GridInitialState} The exported state.
|
|
7
8
|
*/
|
|
8
|
-
exportState: () => InitialState;
|
|
9
|
+
exportState: (params?: GridExportStateParams) => InitialState;
|
|
9
10
|
/**
|
|
10
11
|
* Inject the given values into the state of the DataGrid.
|
|
11
12
|
* @param {GridInitialState} stateToRestore The exported state to restore.
|
|
@@ -19,6 +20,16 @@ export interface GridRestoreStatePreProcessingValue {
|
|
|
19
20
|
*/
|
|
20
21
|
callbacks: (() => void)[];
|
|
21
22
|
}
|
|
23
|
+
export interface GridExportStateParams {
|
|
24
|
+
/**
|
|
25
|
+
* By default, the grid exports all the models.
|
|
26
|
+
* You can switch this property to `true` to only exports models that are either controlled, initialized or modified.
|
|
27
|
+
* For instance, with this property, if you don't control or initialize the `filterModel` and you did not apply any filter, the model won't be exported.
|
|
28
|
+
* Note that the column dimensions are not a model. The grid only exports the dimensions of the modified columns even when `exportOnlyDirtyModels` is false.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
exportOnlyDirtyModels?: boolean;
|
|
32
|
+
}
|
|
22
33
|
export interface GridRestoreStatePreProcessingContext<I extends GridInitialStateCommunity> {
|
|
23
34
|
stateToRestore: I;
|
|
24
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { GridStatePersistenceApi } from './gridStatePersistenceInterface';
|
|
1
|
+
export type { GridStatePersistenceApi, GridExportStateParams, } from './gridStatePersistenceInterface';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useGridApiMethod } from '../../utils';
|
|
3
3
|
export const useGridStatePersistence = apiRef => {
|
|
4
|
-
const exportState = React.useCallback(() => {
|
|
5
|
-
const stateToExport = apiRef.current.unstable_applyPipeProcessors('exportState', {});
|
|
4
|
+
const exportState = React.useCallback((params = {}) => {
|
|
5
|
+
const stateToExport = apiRef.current.unstable_applyPipeProcessors('exportState', {}, params);
|
|
6
6
|
return stateToExport;
|
|
7
7
|
}, [apiRef]);
|
|
8
8
|
const restoreState = React.useCallback(stateToRestore => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { GridRenderContext } from '../../../models';
|
|
2
|
+
import { GridRenderContext, GridRowEntry } from '../../../models';
|
|
3
3
|
import { GridRowId, GridRowModel } from '../../../models/gridRows';
|
|
4
4
|
export declare function binarySearch(offset: number, positions: number[], sliceStart?: number, sliceEnd?: number): number;
|
|
5
5
|
export declare const getRenderableIndexes: ({ firstIndex, lastIndex, buffer, minFirstIndex, maxLastIndex, }: {
|
|
@@ -29,6 +29,8 @@ export declare const useGridVirtualScroller: (props: UseGridVirtualScrollerProps
|
|
|
29
29
|
maxLastColumn?: number | undefined;
|
|
30
30
|
availableSpace?: number | null | undefined;
|
|
31
31
|
ignoreAutoHeight?: boolean | undefined;
|
|
32
|
+
rows?: GridRowEntry<any>[] | undefined;
|
|
33
|
+
rowIndexOffset?: number | undefined;
|
|
32
34
|
}) => JSX.Element[] | null;
|
|
33
35
|
getRootProps: ({ style, ...other }?: {
|
|
34
36
|
style?: {} | undefined;
|
|
@@ -170,10 +170,8 @@ export const useGridVirtualScroller = props => {
|
|
|
170
170
|
React.useEffect(() => {
|
|
171
171
|
setContainerWidth(rootRef.current.clientWidth);
|
|
172
172
|
}, [rowsMeta.currentPageTotalHeight]);
|
|
173
|
-
const handleResize = React.useCallback(
|
|
174
|
-
|
|
175
|
-
setContainerWidth(rootRef.current.clientWidth);
|
|
176
|
-
}
|
|
173
|
+
const handleResize = React.useCallback(params => {
|
|
174
|
+
setContainerWidth(params.width);
|
|
177
175
|
}, []);
|
|
178
176
|
useGridApiEventHandler(apiRef, 'resize', handleResize);
|
|
179
177
|
const updateRenderZonePosition = React.useCallback(nextRenderContext => {
|
|
@@ -289,10 +287,11 @@ export const useGridVirtualScroller = props => {
|
|
|
289
287
|
minFirstColumn = renderZoneMinColumnIndex,
|
|
290
288
|
maxLastColumn = renderZoneMaxColumnIndex,
|
|
291
289
|
availableSpace = containerWidth,
|
|
292
|
-
ignoreAutoHeight
|
|
290
|
+
ignoreAutoHeight,
|
|
291
|
+
rowIndexOffset = 0
|
|
293
292
|
} = params;
|
|
294
293
|
|
|
295
|
-
if (!
|
|
294
|
+
if (!nextRenderContext || availableSpace == null) {
|
|
296
295
|
return null;
|
|
297
296
|
}
|
|
298
297
|
|
|
@@ -307,14 +306,31 @@ export const useGridVirtualScroller = props => {
|
|
|
307
306
|
});
|
|
308
307
|
const renderedRows = [];
|
|
309
308
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
309
|
+
if (params.rows) {
|
|
310
|
+
params.rows.forEach(row => {
|
|
311
|
+
renderedRows.push(row);
|
|
312
|
+
apiRef.current.unstable_calculateColSpan({
|
|
313
|
+
rowId: row.id,
|
|
314
|
+
minFirstColumn,
|
|
315
|
+
maxLastColumn,
|
|
316
|
+
columns: visibleColumns
|
|
317
|
+
});
|
|
317
318
|
});
|
|
319
|
+
} else {
|
|
320
|
+
if (!currentPage.range) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
for (let i = firstRowToRender; i < lastRowToRender; i += 1) {
|
|
325
|
+
const row = currentPage.rows[i];
|
|
326
|
+
renderedRows.push(row);
|
|
327
|
+
apiRef.current.unstable_calculateColSpan({
|
|
328
|
+
rowId: row.id,
|
|
329
|
+
minFirstColumn,
|
|
330
|
+
maxLastColumn,
|
|
331
|
+
columns: visibleColumns
|
|
332
|
+
});
|
|
333
|
+
}
|
|
318
334
|
}
|
|
319
335
|
|
|
320
336
|
const [initialFirstColumnToRender, lastColumnToRender] = getRenderableIndexes({
|
|
@@ -335,7 +351,7 @@ export const useGridVirtualScroller = props => {
|
|
|
335
351
|
const rows = [];
|
|
336
352
|
|
|
337
353
|
for (let i = 0; i < renderedRows.length; i += 1) {
|
|
338
|
-
var _rootProps$components;
|
|
354
|
+
var _currentPage$range5, _rootProps$components;
|
|
339
355
|
|
|
340
356
|
const {
|
|
341
357
|
id,
|
|
@@ -347,10 +363,8 @@ export const useGridVirtualScroller = props => {
|
|
|
347
363
|
|
|
348
364
|
if (selectedRowsLookup[id] == null) {
|
|
349
365
|
isSelected = false;
|
|
350
|
-
} else if (typeof rootProps.isRowSelectable === 'function') {
|
|
351
|
-
isSelected = rootProps.isRowSelectable(apiRef.current.getRowParams(id));
|
|
352
366
|
} else {
|
|
353
|
-
isSelected =
|
|
367
|
+
isSelected = apiRef.current.isRowSelectable(id);
|
|
354
368
|
}
|
|
355
369
|
|
|
356
370
|
rows.push( /*#__PURE__*/_jsx(rootProps.components.Row, _extends({
|
|
@@ -368,7 +382,7 @@ export const useGridVirtualScroller = props => {
|
|
|
368
382
|
firstColumnToRender: firstColumnToRender,
|
|
369
383
|
lastColumnToRender: lastColumnToRender,
|
|
370
384
|
selected: isSelected,
|
|
371
|
-
index: currentPage.range.firstRowIndex + firstRowToRender + i,
|
|
385
|
+
index: rowIndexOffset + ((currentPage == null ? void 0 : (_currentPage$range5 = currentPage.range) == null ? void 0 : _currentPage$range5.firstRowIndex) || 0) + firstRowToRender + i,
|
|
372
386
|
containerWidth: availableSpace,
|
|
373
387
|
isLastVisible: lastVisibleRowIndex
|
|
374
388
|
}, typeof getRowProps === 'function' ? getRowProps(id, model) : {}, (_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.row), id));
|
|
@@ -14,8 +14,8 @@ declare enum GridSignature {
|
|
|
14
14
|
interface RegistryContainer {
|
|
15
15
|
registry: CleanupTracking | null;
|
|
16
16
|
}
|
|
17
|
-
export declare function createUseGridApiEventHandler(registryContainer: RegistryContainer): <Api extends GridApiCommon, E extends keyof import("../../models").GridEventLookup>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E> | undefined, options?: EventListenerOptions
|
|
17
|
+
export declare function createUseGridApiEventHandler(registryContainer: RegistryContainer): <Api extends GridApiCommon, E extends keyof import("../../models").GridEventLookup>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E> | undefined, options?: EventListenerOptions) => void;
|
|
18
18
|
export declare const unstable_resetCleanupTracking: () => void;
|
|
19
|
-
export declare const useGridApiEventHandler: <Api extends GridApiCommon, E extends keyof import("../../models").GridEventLookup>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E> | undefined, options?: EventListenerOptions
|
|
19
|
+
export declare const useGridApiEventHandler: <Api extends GridApiCommon, E extends keyof import("../../models").GridEventLookup>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E> | undefined, options?: EventListenerOptions) => void;
|
|
20
20
|
export declare function useGridApiOptionHandler<Api extends GridApiCommon, E extends GridEventsStr>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E>): void;
|
|
21
21
|
export { GridSignature };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommon } from '../../models';
|
|
3
|
-
export declare const useGridNativeEventListener: <Api extends GridApiCommon, E extends Event>(apiRef: React.MutableRefObject<Api>, ref: React.MutableRefObject<HTMLDivElement | null> | (() => Element | undefined | null), eventName: string, handler?: ((event: E) => any) | undefined, options?: AddEventListenerOptions
|
|
3
|
+
export declare const useGridNativeEventListener: <Api extends GridApiCommon, E extends Event>(apiRef: React.MutableRefObject<Api>, ref: React.MutableRefObject<HTMLDivElement | null> | (() => Element | undefined | null), eventName: string, handler?: ((event: E) => any) | undefined, options?: AddEventListenerOptions) => void;
|
|
@@ -20,7 +20,7 @@ export const useGridNativeEventListener = (apiRef, ref, eventName, handler, opti
|
|
|
20
20
|
targetElement = ref && ref.current ? ref.current : null;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
if (targetElement &&
|
|
23
|
+
if (targetElement && eventName && !added) {
|
|
24
24
|
logger.debug(`Binding native ${eventName} event`);
|
|
25
25
|
targetElement.addEventListener(eventName, wrapHandler, options);
|
|
26
26
|
const boundElem = targetElement;
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { GridColumnHeaders } from '../components/columnHeaders/GridColumnHeaders
|
|
|
5
5
|
export { GridColumnHeadersInner } from '../components/columnHeaders/GridColumnHeadersInner';
|
|
6
6
|
export { useGridRegisterPipeProcessor } from '../hooks/core/pipeProcessing';
|
|
7
7
|
export type { GridPipeProcessor } from '../hooks/core/pipeProcessing';
|
|
8
|
-
export { useGridRegisterStrategyProcessor } from '../hooks/core/strategyProcessing';
|
|
8
|
+
export { useGridRegisterStrategyProcessor, GRID_DEFAULT_STRATEGY, } from '../hooks/core/strategyProcessing';
|
|
9
9
|
export type { GridStrategyProcessor } from '../hooks/core/strategyProcessing';
|
|
10
10
|
export { useGridInitialization } from '../hooks/core/useGridInitialization';
|
|
11
11
|
export { useGridClipboard } from '../hooks/features/clipboard/useGridClipboard';
|
|
@@ -27,9 +27,12 @@ export { useGridEditing as useGridEditing_new, editingStateInitializer as editin
|
|
|
27
27
|
export { useGridEditing as useGridEditing_old, editingStateInitializer as editingStateInitializer_old, } from '../hooks/features/editRows/useGridEditing.old';
|
|
28
28
|
export { useGridRows, rowsStateInitializer } from '../hooks/features/rows/useGridRows';
|
|
29
29
|
export { useGridRowsPreProcessors } from '../hooks/features/rows/useGridRowsPreProcessors';
|
|
30
|
-
export type { GridRowTreeCreationParams, GridRowTreeCreationValue, } from '../hooks/features/rows/gridRowsState';
|
|
30
|
+
export type { GridRowTreeCreationParams, GridRowTreeCreationValue, GridHydrateRowsValue, GridPinnedRowsState, } from '../hooks/features/rows/gridRowsState';
|
|
31
31
|
export { useGridRowsMeta, rowsMetaStateInitializer } from '../hooks/features/rows/useGridRowsMeta';
|
|
32
32
|
export { useGridParamsApi } from '../hooks/features/rows/useGridParamsApi';
|
|
33
|
+
export { getRowIdFromRowModel } from '../hooks/features/rows/gridRowsUtils';
|
|
34
|
+
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, } from '../hooks/features/rows/gridRowsSelector';
|
|
35
|
+
export { calculatePinnedRowsHeight } from '../hooks/features/rows/gridRowsUtils';
|
|
33
36
|
export { useGridSelection, selectionStateInitializer, } from '../hooks/features/selection/useGridSelection';
|
|
34
37
|
export { useGridSelectionPreProcessors } from '../hooks/features/selection/useGridSelectionPreProcessors';
|
|
35
38
|
export { useGridSorting, sortingStateInitializer } from '../hooks/features/sorting/useGridSorting';
|
|
@@ -48,7 +51,7 @@ export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/ex
|
|
|
48
51
|
export { createSelector, unstable_resetCreateSelectorCache } from '../utils/createSelector';
|
|
49
52
|
export { findParentElementFromClassName } from '../utils/domUtils';
|
|
50
53
|
export { isNavigationKey } from '../utils/keyboardUtils';
|
|
51
|
-
export { clamp, isDeepEqual } from '../utils/utils';
|
|
54
|
+
export { clamp, isDeepEqual, isNumber, isFunction } from '../utils/utils';
|
|
52
55
|
export { buildWarning } from '../utils/warning';
|
|
53
56
|
export { exportAs } from '../utils/exportAs';
|
|
54
57
|
export type { GridApiCommunity } from '../models/api/gridApiCommunity';
|
package/internals/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { GridVirtualScrollerRenderZone } from '../components/virtualization/Grid
|
|
|
4
4
|
export { GridColumnHeaders } from '../components/columnHeaders/GridColumnHeaders';
|
|
5
5
|
export { GridColumnHeadersInner } from '../components/columnHeaders/GridColumnHeadersInner';
|
|
6
6
|
export { useGridRegisterPipeProcessor } from '../hooks/core/pipeProcessing';
|
|
7
|
-
export { useGridRegisterStrategyProcessor } from '../hooks/core/strategyProcessing';
|
|
7
|
+
export { useGridRegisterStrategyProcessor, GRID_DEFAULT_STRATEGY } from '../hooks/core/strategyProcessing';
|
|
8
8
|
export { useGridInitialization } from '../hooks/core/useGridInitialization';
|
|
9
9
|
export { useGridClipboard } from '../hooks/features/clipboard/useGridClipboard';
|
|
10
10
|
export { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';
|
|
@@ -25,6 +25,9 @@ export { useGridRows, rowsStateInitializer } from '../hooks/features/rows/useGri
|
|
|
25
25
|
export { useGridRowsPreProcessors } from '../hooks/features/rows/useGridRowsPreProcessors';
|
|
26
26
|
export { useGridRowsMeta, rowsMetaStateInitializer } from '../hooks/features/rows/useGridRowsMeta';
|
|
27
27
|
export { useGridParamsApi } from '../hooks/features/rows/useGridParamsApi';
|
|
28
|
+
export { getRowIdFromRowModel } from '../hooks/features/rows/gridRowsUtils';
|
|
29
|
+
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector } from '../hooks/features/rows/gridRowsSelector';
|
|
30
|
+
export { calculatePinnedRowsHeight } from '../hooks/features/rows/gridRowsUtils';
|
|
28
31
|
export { useGridSelection, selectionStateInitializer } from '../hooks/features/selection/useGridSelection';
|
|
29
32
|
export { useGridSelectionPreProcessors } from '../hooks/features/selection/useGridSelectionPreProcessors';
|
|
30
33
|
export { useGridSorting, sortingStateInitializer } from '../hooks/features/sorting/useGridSorting';
|
|
@@ -39,6 +42,6 @@ export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/ex
|
|
|
39
42
|
export { createSelector, unstable_resetCreateSelectorCache } from '../utils/createSelector';
|
|
40
43
|
export { findParentElementFromClassName } from '../utils/domUtils';
|
|
41
44
|
export { isNavigationKey } from '../utils/keyboardUtils';
|
|
42
|
-
export { clamp, isDeepEqual } from '../utils/utils';
|
|
45
|
+
export { clamp, isDeepEqual, isNumber, isFunction } from '../utils/utils';
|
|
43
46
|
export { buildWarning } from '../utils/warning';
|
|
44
47
|
export { exportAs } from '../utils/exportAs';
|
|
@@ -157,6 +157,12 @@ DataGridRaw.propTypes = {
|
|
|
157
157
|
*/
|
|
158
158
|
disableExtendRowFullWidth: PropTypes.bool,
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* If `true`, modification to a cell will not be discarded if the mode is changed from "edit" to "view" while processing props.
|
|
162
|
+
* @default false
|
|
163
|
+
*/
|
|
164
|
+
disableIgnoreModificationsIfProcessingProps: PropTypes.bool,
|
|
165
|
+
|
|
160
166
|
/**
|
|
161
167
|
* If `true`, the selection on click on a row or cell is disabled.
|
|
162
168
|
* @default false
|
|
@@ -60,7 +60,7 @@ export var useDataGridComponent = function useDataGridComponent(props) {
|
|
|
60
60
|
var useGridEditing = (_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.newEditingApi ? useGridEditing_new : useGridEditing_old;
|
|
61
61
|
useGridEditing(apiRef, props);
|
|
62
62
|
useGridFocus(apiRef, props);
|
|
63
|
-
useGridPreferencesPanel(apiRef);
|
|
63
|
+
useGridPreferencesPanel(apiRef, props);
|
|
64
64
|
useGridFilter(apiRef, props);
|
|
65
65
|
useGridSorting(apiRef, props);
|
|
66
66
|
useGridDensity(apiRef, props);
|
|
@@ -42,6 +42,7 @@ export var DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
42
42
|
disableMultipleColumnsSorting: false,
|
|
43
43
|
disableSelectionOnClick: false,
|
|
44
44
|
disableVirtualization: false,
|
|
45
|
+
disableIgnoreModificationsIfProcessingProps: false,
|
|
45
46
|
editMode: GridEditModes.Cell,
|
|
46
47
|
filterMode: GridFeatureModeConstant.client,
|
|
47
48
|
headerHeight: 56,
|