@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
|
@@ -8,4 +8,21 @@ export const gridRowsIdToIdLookupSelector = createSelector(gridRowsStateSelector
|
|
|
8
8
|
export const gridRowTreeSelector = createSelector(gridRowsStateSelector, rows => rows.tree);
|
|
9
9
|
export const gridRowGroupingNameSelector = createSelector(gridRowsStateSelector, rows => rows.groupingName);
|
|
10
10
|
export const gridRowTreeDepthSelector = createSelector(gridRowsStateSelector, rows => rows.treeDepth);
|
|
11
|
-
export const gridRowIdsSelector = createSelector(gridRowsStateSelector, rows => rows.ids);
|
|
11
|
+
export const gridRowIdsSelector = createSelector(gridRowsStateSelector, rows => rows.ids);
|
|
12
|
+
/**
|
|
13
|
+
* @ignore - do not document.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const gridAdditionalRowGroupsSelector = createSelector(gridRowsStateSelector, rows => rows?.additionalRowGroups);
|
|
17
|
+
/**
|
|
18
|
+
* @ignore - do not document.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export const gridPinnedRowsSelector = createSelector(gridAdditionalRowGroupsSelector, additionalRowGroups => additionalRowGroups?.pinnedRows);
|
|
22
|
+
/**
|
|
23
|
+
* @ignore - do not document.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export const gridPinnedRowsCountSelector = createSelector(gridPinnedRowsSelector, pinnedRows => {
|
|
27
|
+
return (pinnedRows?.top?.length || 0) + (pinnedRows?.bottom?.length || 0);
|
|
28
|
+
});
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["rowsBeforePartialUpdates"];
|
|
4
|
-
|
|
4
|
+
import { gridPinnedRowsSelector } from './gridRowsSelector';
|
|
5
5
|
/**
|
|
6
6
|
* A helper function to check if the id provided is valid.
|
|
7
7
|
* @param {GridRowId} id Id as [[GridRowId]].
|
|
8
8
|
* @param {GridRowModel | Partial<GridRowModel>} row Row as [[GridRowModel]].
|
|
9
9
|
* @param {string} detailErrorMessage A custom error message to display for invalid IDs
|
|
10
10
|
*/
|
|
11
|
+
|
|
11
12
|
export function checkGridRowIdIsValid(id, row, detailErrorMessage = 'A row was provided without id in the rows prop:') {
|
|
12
13
|
if (id == null) {
|
|
13
14
|
throw new Error(['MUI: The data grid component requires all rows to have a unique `id` property.', 'Alternatively, you can use the `getRowId` prop to specify a custom id for each row.', detailErrorMessage, JSON.stringify(row)].join('\n'));
|
|
@@ -55,7 +56,7 @@ export const getRowsStateFromCache = ({
|
|
|
55
56
|
previousTree
|
|
56
57
|
}));
|
|
57
58
|
const processedGroupingResponse = apiRef.current.unstable_applyPipeProcessors('hydrateRows', groupingResponse);
|
|
58
|
-
const dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(node => node.parent == null).length;
|
|
59
|
+
const dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(node => node.parent == null && !node.isPinned).length;
|
|
59
60
|
return _extends({}, processedGroupingResponse, {
|
|
60
61
|
groupingResponseBeforeRowHydration: groupingResponse,
|
|
61
62
|
loading: loadingProp,
|
|
@@ -84,4 +85,19 @@ export const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) =>
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
return validDescendants;
|
|
87
|
-
};
|
|
88
|
+
};
|
|
89
|
+
export function calculatePinnedRowsHeight(apiRef) {
|
|
90
|
+
const pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
91
|
+
const topPinnedRowsHeight = pinnedRows?.top?.reduce((acc, value) => {
|
|
92
|
+
acc += apiRef.current.unstable_getRowHeight(value.id);
|
|
93
|
+
return acc;
|
|
94
|
+
}, 0) || 0;
|
|
95
|
+
const bottomPinnedRowsHeight = pinnedRows?.bottom?.reduce((acc, value) => {
|
|
96
|
+
acc += apiRef.current.unstable_getRowHeight(value.id);
|
|
97
|
+
return acc;
|
|
98
|
+
}, 0) || 0;
|
|
99
|
+
return {
|
|
100
|
+
top: topPinnedRowsHeight,
|
|
101
|
+
bottom: bottomPinnedRowsHeight
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './gridRowsMetaSelector';
|
|
2
2
|
export * from './gridRowsMetaState';
|
|
3
|
-
export
|
|
3
|
+
export { gridRowsStateSelector, gridRowCountSelector, gridRowsLoadingSelector, gridTopLevelRowCountSelector, gridRowsLookupSelector, gridRowsIdToIdLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthSelector, gridRowIdsSelector } from './gridRowsSelector';
|
|
4
4
|
export { checkGridRowIdIsValid } from './gridRowsUtils';
|
|
@@ -9,6 +9,7 @@ import { gridFilterStateSelector } from '../filter/gridFilterSelector';
|
|
|
9
9
|
import { gridPaginationSelector } from '../pagination/gridPaginationSelector';
|
|
10
10
|
import { gridSortingStateSelector } from '../sorting/gridSortingSelector';
|
|
11
11
|
import { useGridRegisterPipeApplier } from '../../core/pipeProcessing';
|
|
12
|
+
import { gridPinnedRowsSelector } from './gridRowsSelector';
|
|
12
13
|
export const rowsMetaStateInitializer = state => _extends({}, state, {
|
|
13
14
|
rowsMeta: {
|
|
14
15
|
currentPageTotalHeight: 0,
|
|
@@ -35,13 +36,12 @@ 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(() => {
|
|
39
41
|
hasRowWithAutoHeight.current = false;
|
|
40
42
|
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
43
|
|
|
44
|
+
const calculateRowProcessedSizes = row => {
|
|
45
45
|
if (!rowsHeightLookup.current[row.id]) {
|
|
46
46
|
rowsHeightLookup.current[row.id] = {
|
|
47
47
|
sizes: {
|
|
@@ -111,9 +111,22 @@ export const useGridRowsMeta = (apiRef, props) => {
|
|
|
111
111
|
|
|
112
112
|
const processedSizes = apiRef.current.unstable_applyPipeProcessors('rowHeight', initialHeights, row);
|
|
113
113
|
rowsHeightLookup.current[row.id].sizes = processedSizes;
|
|
114
|
+
return processedSizes;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const positions = [];
|
|
118
|
+
const currentPageTotalHeight = currentPage.rows.reduce((acc, row) => {
|
|
119
|
+
positions.push(acc);
|
|
120
|
+
const processedSizes = calculateRowProcessedSizes(row);
|
|
114
121
|
const finalRowHeight = Object.values(processedSizes).reduce((acc2, value) => acc2 + value, 0);
|
|
115
122
|
return acc + finalRowHeight;
|
|
116
123
|
}, 0);
|
|
124
|
+
pinnedRows?.top?.forEach(row => {
|
|
125
|
+
calculateRowProcessedSizes(row);
|
|
126
|
+
});
|
|
127
|
+
pinnedRows?.bottom?.forEach(row => {
|
|
128
|
+
calculateRowProcessedSizes(row);
|
|
129
|
+
});
|
|
117
130
|
apiRef.current.setState(state => {
|
|
118
131
|
return _extends({}, state, {
|
|
119
132
|
rowsMeta: {
|
|
@@ -129,7 +142,7 @@ export const useGridRowsMeta = (apiRef, props) => {
|
|
|
129
142
|
}
|
|
130
143
|
|
|
131
144
|
apiRef.current.forceUpdate();
|
|
132
|
-
}, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight]);
|
|
145
|
+
}, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight, pinnedRows]);
|
|
133
146
|
const getRowHeight = React.useCallback(rowId => {
|
|
134
147
|
const height = rowsHeightLookup.current[rowId];
|
|
135
148
|
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) {
|
|
@@ -91,8 +92,10 @@ export const useGridScroll = (apiRef, props) => {
|
|
|
91
92
|
const pageSize = gridPageSizeSelector(apiRef);
|
|
92
93
|
const elementIndex = !props.pagination ? params.rowIndex : params.rowIndex - page * pageSize;
|
|
93
94
|
const targetOffsetHeight = rowsMeta.positions[elementIndex + 1] ? rowsMeta.positions[elementIndex + 1] - rowsMeta.positions[elementIndex] : rowsMeta.currentPageTotalHeight - rowsMeta.positions[elementIndex];
|
|
95
|
+
const topPinnedRowsHeight = windowRef.current.querySelector(`.${gridClasses['pinnedRows--top']}`)?.clientHeight || 0;
|
|
96
|
+
const bottomPinnedRowsHeight = windowRef.current.querySelector(`.${gridClasses['pinnedRows--bottom']}`)?.clientHeight || 0;
|
|
94
97
|
scrollCoordinates.top = scrollIntoView({
|
|
95
|
-
clientHeight: windowRef.current.clientHeight,
|
|
98
|
+
clientHeight: windowRef.current.clientHeight - topPinnedRowsHeight - bottomPinnedRowsHeight,
|
|
96
99
|
scrollTop: windowRef.current.scrollTop,
|
|
97
100
|
offsetHeight: targetOffsetHeight,
|
|
98
101
|
offsetTop: rowsMeta.positions[elementIndex]
|
|
@@ -57,9 +57,9 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
57
57
|
checkboxSelection,
|
|
58
58
|
disableMultipleSelection,
|
|
59
59
|
disableSelectionOnClick,
|
|
60
|
-
isRowSelectable,
|
|
61
60
|
pagination,
|
|
62
|
-
paginationMode
|
|
61
|
+
paginationMode,
|
|
62
|
+
isRowSelectable: propIsRowSelectable
|
|
63
63
|
} = props;
|
|
64
64
|
const canHaveMultipleSelection = !disableMultipleSelection || checkboxSelection;
|
|
65
65
|
const visibleRows = useGridVisibleRows(apiRef, props);
|
|
@@ -106,9 +106,22 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
106
106
|
}
|
|
107
107
|
}, [apiRef, logger]);
|
|
108
108
|
const isRowSelected = React.useCallback(id => gridSelectionStateSelector(apiRef.current.state).includes(id), [apiRef]);
|
|
109
|
+
const isRowSelectable = React.useCallback(id => {
|
|
110
|
+
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const rowNode = apiRef.current.getRowNode(id);
|
|
115
|
+
|
|
116
|
+
if (rowNode?.position === 'footer' || rowNode?.isPinned) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return true;
|
|
121
|
+
}, [apiRef, propIsRowSelectable]);
|
|
109
122
|
const getSelectedRows = React.useCallback(() => selectedGridRowsSelector(apiRef), [apiRef]);
|
|
110
123
|
const selectRow = React.useCallback((id, isSelected = true, resetSelection = false) => {
|
|
111
|
-
if (
|
|
124
|
+
if (!apiRef.current.isRowSelectable(id)) {
|
|
112
125
|
return;
|
|
113
126
|
}
|
|
114
127
|
|
|
@@ -132,10 +145,10 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
132
145
|
apiRef.current.setSelectionModel(newSelection);
|
|
133
146
|
}
|
|
134
147
|
}
|
|
135
|
-
}, [apiRef,
|
|
148
|
+
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
136
149
|
const selectRows = React.useCallback((ids, isSelected = true, resetSelection = false) => {
|
|
137
150
|
logger.debug(`Setting selection for several rows`);
|
|
138
|
-
const selectableIds =
|
|
151
|
+
const selectableIds = ids.filter(id => apiRef.current.isRowSelectable(id));
|
|
139
152
|
let newSelection;
|
|
140
153
|
|
|
141
154
|
if (resetSelection) {
|
|
@@ -159,7 +172,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
159
172
|
if (isSelectionValid) {
|
|
160
173
|
apiRef.current.setSelectionModel(newSelection);
|
|
161
174
|
}
|
|
162
|
-
}, [apiRef,
|
|
175
|
+
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
163
176
|
const selectRowRange = React.useCallback(({
|
|
164
177
|
startId,
|
|
165
178
|
endId
|
|
@@ -183,7 +196,8 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
183
196
|
selectRowRange,
|
|
184
197
|
setSelectionModel,
|
|
185
198
|
getSelectedRows,
|
|
186
|
-
isRowSelected
|
|
199
|
+
isRowSelected,
|
|
200
|
+
isRowSelectable
|
|
187
201
|
};
|
|
188
202
|
useGridApiMethod(apiRef, selectionApi, 'GridSelectionApi');
|
|
189
203
|
/**
|
|
@@ -251,6 +265,10 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
251
265
|
}
|
|
252
266
|
}
|
|
253
267
|
|
|
268
|
+
if (params.rowNode.isPinned) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
254
272
|
if (event.shiftKey && (canHaveMultipleSelection || checkboxSelection)) {
|
|
255
273
|
expandMouseRowRangeSelection(params.id);
|
|
256
274
|
} else {
|
|
@@ -363,13 +381,13 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
363
381
|
React.useEffect(() => {
|
|
364
382
|
if (isStateControlled) {
|
|
365
383
|
return;
|
|
366
|
-
} // isRowSelectable changed
|
|
384
|
+
} // props.isRowSelectable changed
|
|
367
385
|
|
|
368
386
|
|
|
369
387
|
const currentSelection = gridSelectionStateSelector(apiRef.current.state);
|
|
370
388
|
|
|
371
389
|
if (isRowSelectable) {
|
|
372
|
-
const newSelection = currentSelection.filter(id => isRowSelectable(
|
|
390
|
+
const newSelection = currentSelection.filter(id => isRowSelectable(id));
|
|
373
391
|
|
|
374
392
|
if (newSelection.length < currentSelection.length) {
|
|
375
393
|
apiRef.current.setSelectionModel(newSelection);
|
|
@@ -396,7 +414,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
396
414
|
let isSelectable = true;
|
|
397
415
|
|
|
398
416
|
if (isRowSelectable) {
|
|
399
|
-
isSelectable = isRowSelectable(
|
|
417
|
+
isSelectable = isRowSelectable(id);
|
|
400
418
|
}
|
|
401
419
|
|
|
402
420
|
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);
|
|
@@ -146,10 +146,15 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
146
146
|
* PRE-PROCESSING
|
|
147
147
|
*/
|
|
148
148
|
|
|
149
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
149
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
150
150
|
const sortModelToExport = gridSortModelSelector(apiRef);
|
|
151
|
+
const shouldExportSortModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
152
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
153
|
+
props.sortModel != null || // Always export if the model has been initialized
|
|
154
|
+
props.initialState?.sorting?.sortModel != null || // Export if the model is not empty
|
|
155
|
+
sortModelToExport.length > 0;
|
|
151
156
|
|
|
152
|
-
if (
|
|
157
|
+
if (!shouldExportSortModel) {
|
|
153
158
|
return prevState;
|
|
154
159
|
}
|
|
155
160
|
|
|
@@ -158,7 +163,7 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
158
163
|
sortModel: sortModelToExport
|
|
159
164
|
}
|
|
160
165
|
});
|
|
161
|
-
}, [apiRef]);
|
|
166
|
+
}, [apiRef, props.sortModel, props.initialState?.sorting?.sortModel]);
|
|
162
167
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
163
168
|
const sortModel = context.stateToRestore.sorting?.sortModel;
|
|
164
169
|
|
|
@@ -172,12 +177,39 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
172
177
|
});
|
|
173
178
|
}, [apiRef, props.disableMultipleColumnsSorting]);
|
|
174
179
|
const flatSortingMethod = React.useCallback(params => {
|
|
180
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
181
|
+
|
|
175
182
|
if (!params.sortRowList) {
|
|
176
|
-
|
|
183
|
+
const bodyRowIds = [];
|
|
184
|
+
const footerRowIds = [];
|
|
185
|
+
gridRowIdsSelector(apiRef).forEach(rowId => {
|
|
186
|
+
if (rowTree[rowId].isPinned) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (rowTree[rowId].position === 'footer') {
|
|
191
|
+
footerRowIds.push(rowId);
|
|
192
|
+
} else {
|
|
193
|
+
bodyRowIds.push(rowId);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
return [...bodyRowIds, ...footerRowIds];
|
|
177
197
|
}
|
|
178
198
|
|
|
179
|
-
const
|
|
180
|
-
|
|
199
|
+
const bodyRows = [];
|
|
200
|
+
const footerRowIds = [];
|
|
201
|
+
Object.values(rowTree).forEach(rowNode => {
|
|
202
|
+
if (rowNode.isPinned) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (rowNode.position === 'footer') {
|
|
207
|
+
footerRowIds.push(rowNode.id);
|
|
208
|
+
} else {
|
|
209
|
+
bodyRows.push(rowNode);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
return [...params.sortRowList(bodyRows), ...footerRowIds];
|
|
181
213
|
}, [apiRef]);
|
|
182
214
|
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
183
215
|
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
@@ -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 => {
|
|
@@ -86,8 +86,15 @@ export const useGridVirtualScroller = props => {
|
|
|
86
86
|
const [containerWidth, setContainerWidth] = React.useState(null);
|
|
87
87
|
const prevTotalWidth = React.useRef(columnsTotalWidth);
|
|
88
88
|
const getNearestIndexToRender = React.useCallback(offset => {
|
|
89
|
-
const
|
|
90
|
-
const
|
|
89
|
+
const lastMeasuredIndexRelativeToAllRows = apiRef.current.unstable_getLastMeasuredRowIndex();
|
|
90
|
+
const lastMeasuredIndexRelativeToCurrentPage = lastMeasuredIndexRelativeToAllRows - (currentPage.range?.firstRowIndex || 0);
|
|
91
|
+
const lastMeasuredIndex = Math.max(0, lastMeasuredIndexRelativeToCurrentPage);
|
|
92
|
+
let allRowsMeasured = lastMeasuredIndex === Infinity;
|
|
93
|
+
|
|
94
|
+
if (currentPage.range?.lastRowIndex && !allRowsMeasured) {
|
|
95
|
+
// Check if all rows in this page are already measured
|
|
96
|
+
allRowsMeasured = lastMeasuredIndex >= currentPage.range.lastRowIndex;
|
|
97
|
+
}
|
|
91
98
|
|
|
92
99
|
if (allRowsMeasured || rowsMeta.positions[lastMeasuredIndex] >= offset) {
|
|
93
100
|
// If all rows were measured (when no row has "auto" as height) or all rows before the offset
|
|
@@ -100,7 +107,7 @@ export const useGridVirtualScroller = props => {
|
|
|
100
107
|
|
|
101
108
|
|
|
102
109
|
return exponentialSearch(offset, rowsMeta.positions, lastMeasuredIndex);
|
|
103
|
-
}, [apiRef, rowsMeta.positions]);
|
|
110
|
+
}, [apiRef, currentPage.range?.firstRowIndex, currentPage.range?.lastRowIndex, rowsMeta.positions]);
|
|
104
111
|
const computeRenderContext = React.useCallback(() => {
|
|
105
112
|
if (disableVirtualization) {
|
|
106
113
|
return {
|
|
@@ -159,10 +166,8 @@ export const useGridVirtualScroller = props => {
|
|
|
159
166
|
React.useEffect(() => {
|
|
160
167
|
setContainerWidth(rootRef.current.clientWidth);
|
|
161
168
|
}, [rowsMeta.currentPageTotalHeight]);
|
|
162
|
-
const handleResize = React.useCallback(
|
|
163
|
-
|
|
164
|
-
setContainerWidth(rootRef.current.clientWidth);
|
|
165
|
-
}
|
|
169
|
+
const handleResize = React.useCallback(params => {
|
|
170
|
+
setContainerWidth(params.width);
|
|
166
171
|
}, []);
|
|
167
172
|
useGridApiEventHandler(apiRef, 'resize', handleResize);
|
|
168
173
|
const updateRenderZonePosition = React.useCallback(nextRenderContext => {
|
|
@@ -278,10 +283,11 @@ export const useGridVirtualScroller = props => {
|
|
|
278
283
|
minFirstColumn = renderZoneMinColumnIndex,
|
|
279
284
|
maxLastColumn = renderZoneMaxColumnIndex,
|
|
280
285
|
availableSpace = containerWidth,
|
|
281
|
-
ignoreAutoHeight
|
|
286
|
+
ignoreAutoHeight,
|
|
287
|
+
rowIndexOffset = 0
|
|
282
288
|
} = params;
|
|
283
289
|
|
|
284
|
-
if (!
|
|
290
|
+
if (!nextRenderContext || availableSpace == null) {
|
|
285
291
|
return null;
|
|
286
292
|
}
|
|
287
293
|
|
|
@@ -296,14 +302,31 @@ export const useGridVirtualScroller = props => {
|
|
|
296
302
|
});
|
|
297
303
|
const renderedRows = [];
|
|
298
304
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
305
|
+
if (params.rows) {
|
|
306
|
+
params.rows.forEach(row => {
|
|
307
|
+
renderedRows.push(row);
|
|
308
|
+
apiRef.current.unstable_calculateColSpan({
|
|
309
|
+
rowId: row.id,
|
|
310
|
+
minFirstColumn,
|
|
311
|
+
maxLastColumn,
|
|
312
|
+
columns: visibleColumns
|
|
313
|
+
});
|
|
306
314
|
});
|
|
315
|
+
} else {
|
|
316
|
+
if (!currentPage.range) {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
for (let i = firstRowToRender; i < lastRowToRender; i += 1) {
|
|
321
|
+
const row = currentPage.rows[i];
|
|
322
|
+
renderedRows.push(row);
|
|
323
|
+
apiRef.current.unstable_calculateColSpan({
|
|
324
|
+
rowId: row.id,
|
|
325
|
+
minFirstColumn,
|
|
326
|
+
maxLastColumn,
|
|
327
|
+
columns: visibleColumns
|
|
328
|
+
});
|
|
329
|
+
}
|
|
307
330
|
}
|
|
308
331
|
|
|
309
332
|
const [initialFirstColumnToRender, lastColumnToRender] = getRenderableIndexes({
|
|
@@ -334,10 +357,8 @@ export const useGridVirtualScroller = props => {
|
|
|
334
357
|
|
|
335
358
|
if (selectedRowsLookup[id] == null) {
|
|
336
359
|
isSelected = false;
|
|
337
|
-
} else if (typeof rootProps.isRowSelectable === 'function') {
|
|
338
|
-
isSelected = rootProps.isRowSelectable(apiRef.current.getRowParams(id));
|
|
339
360
|
} else {
|
|
340
|
-
isSelected =
|
|
361
|
+
isSelected = apiRef.current.isRowSelectable(id);
|
|
341
362
|
}
|
|
342
363
|
|
|
343
364
|
rows.push( /*#__PURE__*/_jsx(rootProps.components.Row, _extends({
|
|
@@ -355,7 +376,7 @@ export const useGridVirtualScroller = props => {
|
|
|
355
376
|
firstColumnToRender: firstColumnToRender,
|
|
356
377
|
lastColumnToRender: lastColumnToRender,
|
|
357
378
|
selected: isSelected,
|
|
358
|
-
index: currentPage
|
|
379
|
+
index: rowIndexOffset + (currentPage?.range?.firstRowIndex || 0) + firstRowToRender + i,
|
|
359
380
|
containerWidth: availableSpace,
|
|
360
381
|
isLastVisible: lastVisibleRowIndex
|
|
361
382
|
}, typeof getRowProps === 'function' ? getRowProps(id, model) : {}, rootProps.componentsProps?.row), id));
|
|
@@ -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/modern/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';
|
package/modern/locales/arSD.js
CHANGED
|
@@ -21,7 +21,7 @@ const arSDGrid = {
|
|
|
21
21
|
toolbarFiltersTooltipShow: 'اظهر المرشِحات',
|
|
22
22
|
toolbarFiltersTooltipActive: count => count !== 1 ? `${count} من المرشِحات النشطة` : `مرشِح نشط`,
|
|
23
23
|
// Quick filter toolbar field
|
|
24
|
-
// toolbarQuickFilterPlaceholder: 'Search
|
|
24
|
+
// toolbarQuickFilterPlaceholder: 'Search…',
|
|
25
25
|
// toolbarQuickFilterLabel: 'Search',
|
|
26
26
|
// toolbarQuickFilterDeleteIconLabel: 'Clear',
|
|
27
27
|
// Export selector toolbar button text
|
|
@@ -111,6 +111,13 @@ const arSDGrid = {
|
|
|
111
111
|
expandDetailPanel: 'توسيع',
|
|
112
112
|
collapseDetailPanel: 'طوي' // Row reordering text
|
|
113
113
|
// rowReorderingHeaderName: 'Row reordering',
|
|
114
|
+
// Aggregation
|
|
115
|
+
// aggregationMenuItemHeader: 'Aggregation',
|
|
116
|
+
// aggregationFunctionLabelSum: 'sum',
|
|
117
|
+
// aggregationFunctionLabelAvg: 'avg',
|
|
118
|
+
// aggregationFunctionLabelMin: 'min',
|
|
119
|
+
// aggregationFunctionLabelMax: 'max',
|
|
120
|
+
// aggregationFunctionLabelSize: 'size',
|
|
114
121
|
|
|
115
122
|
};
|
|
116
123
|
export const arSD = getGridLocalization(arSDGrid, arSDCore);
|
package/modern/locales/bgBG.js
CHANGED
|
@@ -21,7 +21,7 @@ const bgBGGrid = {
|
|
|
21
21
|
toolbarFiltersTooltipShow: 'Покажи Филтрите',
|
|
22
22
|
toolbarFiltersTooltipActive: count => `${count} активни филтри`,
|
|
23
23
|
// Quick filter toolbar field
|
|
24
|
-
// toolbarQuickFilterPlaceholder: 'Search
|
|
24
|
+
// toolbarQuickFilterPlaceholder: 'Search…',
|
|
25
25
|
// toolbarQuickFilterLabel: 'Search',
|
|
26
26
|
// toolbarQuickFilterDeleteIconLabel: 'Clear',
|
|
27
27
|
// Export selector toolbar button text
|
|
@@ -111,6 +111,13 @@ const bgBGGrid = {
|
|
|
111
111
|
expandDetailPanel: 'Разгъване',
|
|
112
112
|
collapseDetailPanel: 'Свиване' // Row reordering text
|
|
113
113
|
// rowReorderingHeaderName: 'Row reordering',
|
|
114
|
+
// Aggregation
|
|
115
|
+
// aggregationMenuItemHeader: 'Aggregation',
|
|
116
|
+
// aggregationFunctionLabelSum: 'sum',
|
|
117
|
+
// aggregationFunctionLabelAvg: 'avg',
|
|
118
|
+
// aggregationFunctionLabelMin: 'min',
|
|
119
|
+
// aggregationFunctionLabelMax: 'max',
|
|
120
|
+
// aggregationFunctionLabelSize: 'size',
|
|
114
121
|
|
|
115
122
|
};
|
|
116
123
|
export const bgBG = getGridLocalization(bgBGGrid, bgBGCore);
|
package/modern/locales/csCZ.js
CHANGED
|
@@ -31,7 +31,7 @@ const csCZGrid = {
|
|
|
31
31
|
return `${count} ${pluralForm}`;
|
|
32
32
|
},
|
|
33
33
|
// Quick filter toolbar field
|
|
34
|
-
// toolbarQuickFilterPlaceholder: 'Search
|
|
34
|
+
// toolbarQuickFilterPlaceholder: 'Search…',
|
|
35
35
|
// toolbarQuickFilterLabel: 'Search',
|
|
36
36
|
// toolbarQuickFilterDeleteIconLabel: 'Clear',
|
|
37
37
|
// Export selector toolbar button text
|
|
@@ -146,6 +146,13 @@ const csCZGrid = {
|
|
|
146
146
|
// collapseDetailPanel: 'Collapse',
|
|
147
147
|
// Row reordering text
|
|
148
148
|
// rowReorderingHeaderName: 'Row reordering',
|
|
149
|
+
// Aggregation
|
|
150
|
+
// aggregationMenuItemHeader: 'Aggregation',
|
|
151
|
+
// aggregationFunctionLabelSum: 'sum',
|
|
152
|
+
// aggregationFunctionLabelAvg: 'avg',
|
|
153
|
+
// aggregationFunctionLabelMin: 'min',
|
|
154
|
+
// aggregationFunctionLabelMax: 'max',
|
|
155
|
+
// aggregationFunctionLabelSize: 'size',
|
|
149
156
|
|
|
150
157
|
};
|
|
151
158
|
export const csCZ = getGridLocalization(csCZGrid, csCZCore);
|
package/modern/locales/daDK.js
CHANGED
|
@@ -21,7 +21,7 @@ const daDKGrid = {
|
|
|
21
21
|
toolbarFiltersTooltipShow: 'Vis filtre',
|
|
22
22
|
toolbarFiltersTooltipActive: count => count !== 1 ? `${count} aktive filtre` : `${count} aktivt filter`,
|
|
23
23
|
// Quick filter toolbar field
|
|
24
|
-
// toolbarQuickFilterPlaceholder: 'Search
|
|
24
|
+
// toolbarQuickFilterPlaceholder: 'Search…',
|
|
25
25
|
// toolbarQuickFilterLabel: 'Search',
|
|
26
26
|
// toolbarQuickFilterDeleteIconLabel: 'Clear',
|
|
27
27
|
// Export selector toolbar button text
|
|
@@ -111,6 +111,13 @@ const daDKGrid = {
|
|
|
111
111
|
expandDetailPanel: 'Udvid',
|
|
112
112
|
collapseDetailPanel: 'Kollaps' // Row reordering text
|
|
113
113
|
// rowReorderingHeaderName: 'Row reordering',
|
|
114
|
+
// Aggregation
|
|
115
|
+
// aggregationMenuItemHeader: 'Aggregation',
|
|
116
|
+
// aggregationFunctionLabelSum: 'sum',
|
|
117
|
+
// aggregationFunctionLabelAvg: 'avg',
|
|
118
|
+
// aggregationFunctionLabelMin: 'min',
|
|
119
|
+
// aggregationFunctionLabelMax: 'max',
|
|
120
|
+
// aggregationFunctionLabelSize: 'size',
|
|
114
121
|
|
|
115
122
|
};
|
|
116
123
|
export const daDK = getGridLocalization(daDKGrid, daDKCore);
|