@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
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import { gridColumnDefinitionsSelector, gridVisibleColumnDefinitionsSelector } from '../columns';
|
|
2
3
|
import { gridFilteredSortedRowIdsSelector } from '../filter';
|
|
4
|
+
import { gridPinnedRowsSelector, gridRowTreeSelector } from '../rows/gridRowsSelector';
|
|
3
5
|
export var getColumnsToExport = function getColumnsToExport(_ref) {
|
|
4
6
|
var apiRef = _ref.apiRef,
|
|
5
7
|
options = _ref.options;
|
|
@@ -21,15 +23,32 @@ export var getColumnsToExport = function getColumnsToExport(_ref) {
|
|
|
21
23
|
});
|
|
22
24
|
};
|
|
23
25
|
export var defaultGetRowsToExport = function defaultGetRowsToExport(_ref2) {
|
|
26
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
27
|
+
|
|
24
28
|
var apiRef = _ref2.apiRef;
|
|
25
29
|
var filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
|
|
30
|
+
var rowTree = gridRowTreeSelector(apiRef);
|
|
26
31
|
var selectedRows = apiRef.current.getSelectedRows();
|
|
32
|
+
var bodyRows = filteredSortedRowIds.filter(function (id) {
|
|
33
|
+
var _rowTree$id$position;
|
|
34
|
+
|
|
35
|
+
return ((_rowTree$id$position = rowTree[id].position) != null ? _rowTree$id$position : 'body') === 'body';
|
|
36
|
+
});
|
|
37
|
+
var pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
38
|
+
var topPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.map(function (row) {
|
|
39
|
+
return row.id;
|
|
40
|
+
})) || [];
|
|
41
|
+
var bottomPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.map(function (row) {
|
|
42
|
+
return row.id;
|
|
43
|
+
})) || [];
|
|
44
|
+
bodyRows.unshift.apply(bodyRows, _toConsumableArray(topPinnedRowsIds));
|
|
45
|
+
bodyRows.push.apply(bodyRows, _toConsumableArray(bottomPinnedRowsIds));
|
|
27
46
|
|
|
28
47
|
if (selectedRows.size > 0) {
|
|
29
|
-
return
|
|
48
|
+
return bodyRows.filter(function (id) {
|
|
30
49
|
return selectedRows.has(id);
|
|
31
50
|
});
|
|
32
51
|
}
|
|
33
52
|
|
|
34
|
-
return
|
|
53
|
+
return bodyRows;
|
|
35
54
|
};
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { GridLinkOperator } from '../../../models';
|
|
3
3
|
import { buildWarning } from '../../../utils/warning';
|
|
4
4
|
import { gridColumnFieldsSelector, gridColumnLookupSelector } from '../columns';
|
|
5
|
+
import { gridRowTreeSelector } from '../rows/gridRowsSelector';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Adds default values to the optional fields of a filter items.
|
|
@@ -89,6 +90,7 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
|
|
|
89
90
|
var items = filterModel.items,
|
|
90
91
|
_filterModel$linkOper = filterModel.linkOperator,
|
|
91
92
|
linkOperator = _filterModel$linkOper === void 0 ? GridLinkOperator.And : _filterModel$linkOper;
|
|
93
|
+
var tree = gridRowTreeSelector(apiRef);
|
|
92
94
|
|
|
93
95
|
var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem) {
|
|
94
96
|
if (!filterItem.columnField || !filterItem.operatorValue) {
|
|
@@ -158,6 +160,10 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
|
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
return function (rowId, shouldApplyFilter) {
|
|
163
|
+
if (tree[rowId].position === 'footer') {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
|
|
161
167
|
var filteredAppliers = shouldApplyFilter ? appliers.filter(function (applier) {
|
|
162
168
|
return shouldApplyFilter(applier.item.columnField);
|
|
163
169
|
}) : appliers; // Return `false` as soon as we have a failing filter
|
|
@@ -35,7 +35,7 @@ export var filterStateInitializer = function filterStateInitializer(state, props
|
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
38
|
-
var _props$componentsProp2;
|
|
38
|
+
var _props$initialState3, _props$initialState3$, _props$componentsProp2;
|
|
39
39
|
|
|
40
40
|
var logger = useGridLogger(apiRef, 'useGridFilter');
|
|
41
41
|
apiRef.current.unstable_registerControlState({
|
|
@@ -125,7 +125,25 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
|
125
125
|
if (targetColumnField) {
|
|
126
126
|
var filterModel = gridFilterModelSelector(apiRef);
|
|
127
127
|
var filterItemsWithValue = filterModel.items.filter(function (item) {
|
|
128
|
-
|
|
128
|
+
var _column$filterOperato;
|
|
129
|
+
|
|
130
|
+
if (item.value !== undefined) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
var column = apiRef.current.getColumn(item.columnField);
|
|
135
|
+
var filterOperator = (_column$filterOperato = column.filterOperators) == null ? void 0 : _column$filterOperato.find(function (operator) {
|
|
136
|
+
return operator.value === item.operatorValue;
|
|
137
|
+
});
|
|
138
|
+
var requiresFilterValue = typeof (filterOperator == null ? void 0 : filterOperator.requiresFilterValue) === 'undefined' ? true : filterOperator == null ? void 0 : filterOperator.requiresFilterValue; // Operators like `isEmpty` don't have and don't require `item.value`.
|
|
139
|
+
// So we don't want to remove them from the filter model if `item.value === undefined`.
|
|
140
|
+
// See https://github.com/mui/mui-x/issues/5402
|
|
141
|
+
|
|
142
|
+
if (requiresFilterValue) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return true;
|
|
129
147
|
});
|
|
130
148
|
var newFilterItems;
|
|
131
149
|
var filterItemOnTarget = filterItemsWithValue.find(function (item) {
|
|
@@ -209,10 +227,17 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
|
209
227
|
* PRE-PROCESSING
|
|
210
228
|
*/
|
|
211
229
|
|
|
212
|
-
var stateExportPreProcessing = React.useCallback(function (prevState) {
|
|
230
|
+
var stateExportPreProcessing = React.useCallback(function (prevState, context) {
|
|
231
|
+
var _props$initialState2, _props$initialState2$;
|
|
232
|
+
|
|
213
233
|
var filterModelToExport = gridFilterModelSelector(apiRef);
|
|
234
|
+
var shouldExportFilterModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
235
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
236
|
+
props.filterModel != null || // Always export if the model has been initialized
|
|
237
|
+
((_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.filter) == null ? void 0 : _props$initialState2$.filterModel) != null || // Export if the model is not equal to the default value
|
|
238
|
+
!isDeepEqual(filterModelToExport, getDefaultGridFilterModel());
|
|
214
239
|
|
|
215
|
-
if (
|
|
240
|
+
if (!shouldExportFilterModel) {
|
|
216
241
|
return prevState;
|
|
217
242
|
}
|
|
218
243
|
|
|
@@ -221,7 +246,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
|
221
246
|
filterModel: filterModelToExport
|
|
222
247
|
}
|
|
223
248
|
});
|
|
224
|
-
}, [apiRef]);
|
|
249
|
+
}, [apiRef, props.filterModel, (_props$initialState3 = props.initialState) == null ? void 0 : (_props$initialState3$ = _props$initialState3.filter) == null ? void 0 : _props$initialState3$.filterModel]);
|
|
225
250
|
var stateRestorePreProcessing = React.useCallback(function (params, context) {
|
|
226
251
|
var _context$stateToResto;
|
|
227
252
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
|
|
3
4
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
@@ -9,6 +10,12 @@ import { gridClasses } from '../../../constants/gridClasses';
|
|
|
9
10
|
import { GridCellModes } from '../../../models/gridEditRowModel';
|
|
10
11
|
import { isNavigationKey } from '../../../utils/keyboardUtils';
|
|
11
12
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
|
|
13
|
+
import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
14
|
+
|
|
15
|
+
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
16
|
+
var pinnedRows = gridPinnedRowsSelector(apiRef) || {};
|
|
17
|
+
return [].concat(_toConsumableArray(pinnedRows.top || []), _toConsumableArray(rows), _toConsumableArray(pinnedRows.bottom || []));
|
|
18
|
+
}
|
|
12
19
|
/**
|
|
13
20
|
* @requires useGridSorting (method) - can be after
|
|
14
21
|
* @requires useGridFilter (state) - can be after
|
|
@@ -19,21 +26,22 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPan
|
|
|
19
26
|
* @requires useGridColumnSpanning (method) - can be after
|
|
20
27
|
*/
|
|
21
28
|
|
|
29
|
+
|
|
22
30
|
export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef, props) {
|
|
23
31
|
var logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
|
|
24
|
-
var
|
|
32
|
+
var initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;
|
|
33
|
+
var currentPageRows = React.useMemo(function () {
|
|
34
|
+
return enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows);
|
|
35
|
+
}, [apiRef, initialCurrentPageRows]);
|
|
25
36
|
/**
|
|
26
37
|
* @param {number} colIndex Index of the column to focus
|
|
27
38
|
* @param {number} rowIndex index of the row to focus
|
|
28
39
|
* @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
|
|
29
40
|
*/
|
|
30
41
|
|
|
31
|
-
var goToCell = React.useCallback(function (colIndex,
|
|
32
|
-
var _visibleSortedRows$ro;
|
|
33
|
-
|
|
42
|
+
var goToCell = React.useCallback(function (colIndex, rowId) {
|
|
34
43
|
var closestColumnToUse = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'left';
|
|
35
44
|
var visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);
|
|
36
|
-
var rowId = (_visibleSortedRows$ro = visibleSortedRows[rowIndex]) == null ? void 0 : _visibleSortedRows$ro.id;
|
|
37
45
|
var nextCellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, colIndex);
|
|
38
46
|
|
|
39
47
|
if (nextCellColSpanInfo && nextCellColSpanInfo.spannedByColSpan) {
|
|
@@ -42,12 +50,17 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
42
50
|
} else if (closestColumnToUse === 'right') {
|
|
43
51
|
colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
|
|
44
52
|
}
|
|
45
|
-
}
|
|
53
|
+
} // `scrollToIndexes` requires a rowIndex relative to all visible rows.
|
|
54
|
+
// Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
|
|
46
55
|
|
|
47
|
-
|
|
56
|
+
|
|
57
|
+
var rowIndexRelativeToAllRows = visibleSortedRows.findIndex(function (row) {
|
|
58
|
+
return row.id === rowId;
|
|
59
|
+
});
|
|
60
|
+
logger.debug("Navigating to cell row ".concat(rowIndexRelativeToAllRows, ", col ").concat(colIndex));
|
|
48
61
|
apiRef.current.scrollToIndexes({
|
|
49
62
|
colIndex: colIndex,
|
|
50
|
-
rowIndex:
|
|
63
|
+
rowIndex: rowIndexRelativeToAllRows
|
|
51
64
|
});
|
|
52
65
|
var field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
53
66
|
apiRef.current.setCellFocus(rowId, field);
|
|
@@ -60,21 +73,23 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
60
73
|
var field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
61
74
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
62
75
|
}, [apiRef, logger]);
|
|
76
|
+
var getRowIdFromIndex = React.useCallback(function (rowIndex) {
|
|
77
|
+
return currentPageRows[rowIndex].id;
|
|
78
|
+
}, [currentPageRows]);
|
|
63
79
|
var handleCellNavigationKeyDown = React.useCallback(function (params, event) {
|
|
64
80
|
var dimensions = apiRef.current.getRootDimensions();
|
|
65
81
|
|
|
66
|
-
if (
|
|
82
|
+
if (currentPageRows.length === 0 || !dimensions) {
|
|
67
83
|
return;
|
|
68
84
|
}
|
|
69
85
|
|
|
70
86
|
var viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
71
|
-
var visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);
|
|
72
87
|
var colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
73
|
-
var rowIndexBefore =
|
|
88
|
+
var rowIndexBefore = currentPageRows.findIndex(function (row) {
|
|
74
89
|
return row.id === params.id;
|
|
75
90
|
});
|
|
76
|
-
var firstRowIndexInPage =
|
|
77
|
-
var lastRowIndexInPage =
|
|
91
|
+
var firstRowIndexInPage = 0;
|
|
92
|
+
var lastRowIndexInPage = currentPageRows.length - 1;
|
|
78
93
|
var firstColIndex = 0;
|
|
79
94
|
var lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
80
95
|
var shouldPreventDefault = true;
|
|
@@ -85,7 +100,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
85
100
|
{
|
|
86
101
|
// "Enter" is only triggered by the row / cell editing feature
|
|
87
102
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
88
|
-
goToCell(colIndexBefore, rowIndexBefore + 1);
|
|
103
|
+
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
|
|
89
104
|
}
|
|
90
105
|
|
|
91
106
|
break;
|
|
@@ -94,7 +109,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
94
109
|
case 'ArrowUp':
|
|
95
110
|
{
|
|
96
111
|
if (rowIndexBefore > firstRowIndexInPage) {
|
|
97
|
-
goToCell(colIndexBefore, rowIndexBefore - 1);
|
|
112
|
+
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore - 1));
|
|
98
113
|
} else {
|
|
99
114
|
goToHeader(colIndexBefore, event);
|
|
100
115
|
}
|
|
@@ -105,7 +120,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
105
120
|
case 'ArrowRight':
|
|
106
121
|
{
|
|
107
122
|
if (colIndexBefore < lastColIndex) {
|
|
108
|
-
goToCell(colIndexBefore + 1, rowIndexBefore, 'right');
|
|
123
|
+
goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
break;
|
|
@@ -114,7 +129,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
114
129
|
case 'ArrowLeft':
|
|
115
130
|
{
|
|
116
131
|
if (colIndexBefore > firstColIndex) {
|
|
117
|
-
goToCell(colIndexBefore - 1, rowIndexBefore);
|
|
132
|
+
goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore));
|
|
118
133
|
}
|
|
119
134
|
|
|
120
135
|
break;
|
|
@@ -124,9 +139,9 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
124
139
|
{
|
|
125
140
|
// "Tab" is only triggered by the row / cell editing feature
|
|
126
141
|
if (event.shiftKey && colIndexBefore > firstColIndex) {
|
|
127
|
-
goToCell(colIndexBefore - 1, rowIndexBefore, 'left');
|
|
142
|
+
goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore), 'left');
|
|
128
143
|
} else if (!event.shiftKey && colIndexBefore < lastColIndex) {
|
|
129
|
-
goToCell(colIndexBefore + 1, rowIndexBefore, 'right');
|
|
144
|
+
goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');
|
|
130
145
|
}
|
|
131
146
|
|
|
132
147
|
break;
|
|
@@ -147,7 +162,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
147
162
|
}
|
|
148
163
|
|
|
149
164
|
if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {
|
|
150
|
-
goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
|
|
165
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));
|
|
151
166
|
}
|
|
152
167
|
|
|
153
168
|
break;
|
|
@@ -156,7 +171,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
156
171
|
case 'PageDown':
|
|
157
172
|
{
|
|
158
173
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
159
|
-
goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
|
|
174
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));
|
|
160
175
|
}
|
|
161
176
|
|
|
162
177
|
break;
|
|
@@ -168,7 +183,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
168
183
|
var nextRowIndex = Math.max(rowIndexBefore - viewportPageSize, firstRowIndexInPage);
|
|
169
184
|
|
|
170
185
|
if (nextRowIndex !== rowIndexBefore && nextRowIndex >= firstRowIndexInPage) {
|
|
171
|
-
goToCell(colIndexBefore, nextRowIndex);
|
|
186
|
+
goToCell(colIndexBefore, getRowIdFromIndex(nextRowIndex));
|
|
172
187
|
} else {
|
|
173
188
|
goToHeader(colIndexBefore, event);
|
|
174
189
|
}
|
|
@@ -179,9 +194,9 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
179
194
|
case 'Home':
|
|
180
195
|
{
|
|
181
196
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
182
|
-
goToCell(firstColIndex, firstRowIndexInPage);
|
|
197
|
+
goToCell(firstColIndex, getRowIdFromIndex(firstRowIndexInPage));
|
|
183
198
|
} else {
|
|
184
|
-
goToCell(firstColIndex, rowIndexBefore);
|
|
199
|
+
goToCell(firstColIndex, getRowIdFromIndex(rowIndexBefore));
|
|
185
200
|
}
|
|
186
201
|
|
|
187
202
|
break;
|
|
@@ -190,9 +205,9 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
190
205
|
case 'End':
|
|
191
206
|
{
|
|
192
207
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
193
|
-
goToCell(lastColIndex, lastRowIndexInPage);
|
|
208
|
+
goToCell(lastColIndex, getRowIdFromIndex(lastRowIndexInPage));
|
|
194
209
|
} else {
|
|
195
|
-
goToCell(lastColIndex, rowIndexBefore);
|
|
210
|
+
goToCell(lastColIndex, getRowIdFromIndex(rowIndexBefore));
|
|
196
211
|
}
|
|
197
212
|
|
|
198
213
|
break;
|
|
@@ -207,10 +222,8 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
207
222
|
if (shouldPreventDefault) {
|
|
208
223
|
event.preventDefault();
|
|
209
224
|
}
|
|
210
|
-
}, [apiRef,
|
|
225
|
+
}, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);
|
|
211
226
|
var handleColumnHeaderKeyDown = React.useCallback(function (params, event) {
|
|
212
|
-
var _currentPage$range$fi, _currentPage$range, _currentPage$range$la, _currentPage$range2;
|
|
213
|
-
|
|
214
227
|
var headerTitleNode = event.currentTarget.querySelector(".".concat(gridClasses.columnHeaderTitleContainerContent));
|
|
215
228
|
var isFromInsideContent = !!headerTitleNode && headerTitleNode.contains(event.target);
|
|
216
229
|
|
|
@@ -228,8 +241,8 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
228
241
|
|
|
229
242
|
var viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
230
243
|
var colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
231
|
-
var firstRowIndexInPage =
|
|
232
|
-
var lastRowIndexInPage =
|
|
244
|
+
var firstRowIndexInPage = 0;
|
|
245
|
+
var lastRowIndexInPage = currentPageRows.length - 1;
|
|
233
246
|
var firstColIndex = 0;
|
|
234
247
|
var lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
235
248
|
var shouldPreventDefault = true;
|
|
@@ -238,7 +251,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
238
251
|
case 'ArrowDown':
|
|
239
252
|
{
|
|
240
253
|
if (firstRowIndexInPage !== null) {
|
|
241
|
-
goToCell(colIndexBefore, firstRowIndexInPage);
|
|
254
|
+
goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
|
|
242
255
|
}
|
|
243
256
|
|
|
244
257
|
break;
|
|
@@ -265,7 +278,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
265
278
|
case 'PageDown':
|
|
266
279
|
{
|
|
267
280
|
if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
|
|
268
|
-
goToCell(colIndexBefore, Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage));
|
|
281
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));
|
|
269
282
|
}
|
|
270
283
|
|
|
271
284
|
break;
|
|
@@ -307,7 +320,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
307
320
|
if (shouldPreventDefault) {
|
|
308
321
|
event.preventDefault();
|
|
309
322
|
}
|
|
310
|
-
}, [apiRef,
|
|
323
|
+
}, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);
|
|
311
324
|
var handleCellKeyDown = React.useCallback(function (params, event) {
|
|
312
325
|
// Ignore portal
|
|
313
326
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -67,13 +67,14 @@ export var useGridPage = function useGridPage(apiRef, props) {
|
|
|
67
67
|
* PRE-PROCESSING
|
|
68
68
|
*/
|
|
69
69
|
|
|
70
|
-
var stateExportPreProcessing = React.useCallback(function (prevState) {
|
|
70
|
+
var stateExportPreProcessing = React.useCallback(function (prevState, context) {
|
|
71
71
|
var _props$initialState, _props$initialState$p;
|
|
72
72
|
|
|
73
73
|
var pageToExport = gridPageSelector(apiRef);
|
|
74
|
-
var shouldExportPage = // Always export if the
|
|
74
|
+
var shouldExportPage = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
75
|
+
!context.exportOnlyDirtyModels || // Always export if the page is controlled
|
|
75
76
|
props.page != null || // Always export if the page has been initialized
|
|
76
|
-
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.page) != null || // Export if the page
|
|
77
|
+
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.page) != null || // Export if the page is not equal to the default value
|
|
77
78
|
pageToExport !== 0;
|
|
78
79
|
|
|
79
80
|
if (!shouldExportPage) {
|
|
@@ -4,6 +4,7 @@ import { useGridLogger, useGridApiMethod, useGridApiEventHandler, useGridSelecto
|
|
|
4
4
|
import { gridPageSizeSelector } from './gridPaginationSelector';
|
|
5
5
|
import { gridDensityRowHeightSelector } from '../density';
|
|
6
6
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
7
|
+
import { calculatePinnedRowsHeight } from '../rows/gridRowsUtils';
|
|
7
8
|
export var defaultPageSize = function defaultPageSize(autoPageSize) {
|
|
8
9
|
return autoPageSize ? 0 : 100;
|
|
9
10
|
};
|
|
@@ -55,13 +56,14 @@ export var useGridPageSize = function useGridPageSize(apiRef, props) {
|
|
|
55
56
|
* PRE-PROCESSING
|
|
56
57
|
*/
|
|
57
58
|
|
|
58
|
-
var stateExportPreProcessing = React.useCallback(function (prevState) {
|
|
59
|
+
var stateExportPreProcessing = React.useCallback(function (prevState, context) {
|
|
59
60
|
var _props$initialState, _props$initialState$p;
|
|
60
61
|
|
|
61
62
|
var pageSizeToExport = gridPageSizeSelector(apiRef);
|
|
62
|
-
var shouldExportPageSize = // Always export if the
|
|
63
|
+
var shouldExportPageSize = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
64
|
+
!context.exportOnlyDirtyModels || // Always export if the page size is controlled
|
|
63
65
|
props.pageSize != null || // Always export if the page size has been initialized
|
|
64
|
-
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.pageSize) != null || // Export if the page size
|
|
66
|
+
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.pageSize) != null || // Export if the page size is not equal to the default value
|
|
65
67
|
pageSizeToExport !== defaultPageSize(props.autoPageSize);
|
|
66
68
|
|
|
67
69
|
if (!shouldExportPageSize) {
|
|
@@ -102,7 +104,8 @@ export var useGridPageSize = function useGridPageSize(apiRef, props) {
|
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
|
-
var
|
|
107
|
+
var pinnedRowsHeight = calculatePinnedRowsHeight(apiRef);
|
|
108
|
+
var maximumPageSizeWithoutScrollBar = Math.floor((dimensions.viewportInnerSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom) / rowHeight);
|
|
106
109
|
apiRef.current.setPageSize(maximumPageSizeWithoutScrollBar);
|
|
107
110
|
}, [apiRef, props.autoPageSize, rowHeight]);
|
|
108
111
|
useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleUpdateAutoPageSize);
|
|
@@ -17,7 +17,9 @@ export var preferencePanelStateInitializer = function preferencePanelStateInitia
|
|
|
17
17
|
* TODO: Add a single `setPreferencePanel` method to avoid multiple `setState`
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef) {
|
|
20
|
+
export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef, props) {
|
|
21
|
+
var _props$initialState3;
|
|
22
|
+
|
|
21
23
|
var logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
|
|
22
24
|
var hideTimeout = React.useRef();
|
|
23
25
|
var immediateTimeout = React.useRef();
|
|
@@ -80,17 +82,23 @@ export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef) {
|
|
|
80
82
|
* PRE-PROCESSING
|
|
81
83
|
*/
|
|
82
84
|
|
|
83
|
-
var stateExportPreProcessing = React.useCallback(function (prevState) {
|
|
85
|
+
var stateExportPreProcessing = React.useCallback(function (prevState, context) {
|
|
86
|
+
var _props$initialState2;
|
|
87
|
+
|
|
84
88
|
var preferencePanelToExport = gridPreferencePanelStateSelector(apiRef.current.state);
|
|
89
|
+
var shouldExportPreferencePanel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
90
|
+
!context.exportOnlyDirtyModels || // Always export if the panel was initialized
|
|
91
|
+
((_props$initialState2 = props.initialState) == null ? void 0 : _props$initialState2.preferencePanel) != null || // Always export if the panel is opened
|
|
92
|
+
preferencePanelToExport.open;
|
|
85
93
|
|
|
86
|
-
if (!
|
|
94
|
+
if (!shouldExportPreferencePanel) {
|
|
87
95
|
return prevState;
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
return _extends({}, prevState, {
|
|
91
99
|
preferencePanel: preferencePanelToExport
|
|
92
100
|
});
|
|
93
|
-
}, [apiRef]);
|
|
101
|
+
}, [apiRef, (_props$initialState3 = props.initialState) == null ? void 0 : _props$initialState3.preferencePanel]);
|
|
94
102
|
var stateRestorePreProcessing = React.useCallback(function (params, context) {
|
|
95
103
|
var preferencePanel = context.stateToRestore.preferencePanel;
|
|
96
104
|
|
|
@@ -28,4 +28,27 @@ export var gridRowTreeDepthSelector = createSelector(gridRowsStateSelector, func
|
|
|
28
28
|
});
|
|
29
29
|
export var gridRowIdsSelector = createSelector(gridRowsStateSelector, function (rows) {
|
|
30
30
|
return rows.ids;
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* @ignore - do not document.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
export var gridAdditionalRowGroupsSelector = createSelector(gridRowsStateSelector, function (rows) {
|
|
37
|
+
return rows == null ? void 0 : rows.additionalRowGroups;
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* @ignore - do not document.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
export var gridPinnedRowsSelector = createSelector(gridAdditionalRowGroupsSelector, function (additionalRowGroups) {
|
|
44
|
+
return additionalRowGroups == null ? void 0 : additionalRowGroups.pinnedRows;
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* @ignore - do not document.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
export var gridPinnedRowsCountSelector = createSelector(gridPinnedRowsSelector, function (pinnedRows) {
|
|
51
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
52
|
+
|
|
53
|
+
return ((pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.length) || 0) + ((pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.length) || 0);
|
|
31
54
|
});
|
|
@@ -2,13 +2,14 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["rowsBeforePartialUpdates"];
|
|
5
|
-
|
|
5
|
+
import { gridPinnedRowsSelector } from './gridRowsSelector';
|
|
6
6
|
/**
|
|
7
7
|
* A helper function to check if the id provided is valid.
|
|
8
8
|
* @param {GridRowId} id Id as [[GridRowId]].
|
|
9
9
|
* @param {GridRowModel | Partial<GridRowModel>} row Row as [[GridRowModel]].
|
|
10
10
|
* @param {string} detailErrorMessage A custom error message to display for invalid IDs
|
|
11
11
|
*/
|
|
12
|
+
|
|
12
13
|
export function checkGridRowIdIsValid(id, row) {
|
|
13
14
|
var detailErrorMessage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'A row was provided without id in the rows prop:';
|
|
14
15
|
|
|
@@ -59,7 +60,7 @@ export var getRowsStateFromCache = function getRowsStateFromCache(_ref2) {
|
|
|
59
60
|
}));
|
|
60
61
|
var processedGroupingResponse = apiRef.current.unstable_applyPipeProcessors('hydrateRows', groupingResponse);
|
|
61
62
|
var dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(function (node) {
|
|
62
|
-
return node.parent == null;
|
|
63
|
+
return node.parent == null && !node.isPinned;
|
|
63
64
|
}).length;
|
|
64
65
|
return _extends({}, processedGroupingResponse, {
|
|
65
66
|
groupingResponseBeforeRowHydration: groupingResponse,
|
|
@@ -91,4 +92,21 @@ export var getTreeNodeDescendants = function getTreeNodeDescendants(tree, parent
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
return validDescendants;
|
|
94
|
-
};
|
|
95
|
+
};
|
|
96
|
+
export function calculatePinnedRowsHeight(apiRef) {
|
|
97
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
98
|
+
|
|
99
|
+
var pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
100
|
+
var topPinnedRowsHeight = (pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.reduce(function (acc, value) {
|
|
101
|
+
acc += apiRef.current.unstable_getRowHeight(value.id);
|
|
102
|
+
return acc;
|
|
103
|
+
}, 0)) || 0;
|
|
104
|
+
var bottomPinnedRowsHeight = (pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.reduce(function (acc, value) {
|
|
105
|
+
acc += apiRef.current.unstable_getRowHeight(value.id);
|
|
106
|
+
return acc;
|
|
107
|
+
}, 0)) || 0;
|
|
108
|
+
return {
|
|
109
|
+
top: topPinnedRowsHeight,
|
|
110
|
+
bottom: bottomPinnedRowsHeight
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -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 var rowsMetaStateInitializer = function rowsMetaStateInitializer(state) {
|
|
13
14
|
return _extends({}, state, {
|
|
14
15
|
rowsMeta: {
|
|
@@ -35,13 +36,14 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
|
|
|
35
36
|
var paginationState = useGridSelector(apiRef, gridPaginationSelector);
|
|
36
37
|
var sortingState = useGridSelector(apiRef, gridSortingStateSelector);
|
|
37
38
|
var currentPage = useGridVisibleRows(apiRef, props);
|
|
39
|
+
var pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
|
|
38
40
|
var hydrateRowsMeta = React.useCallback(function () {
|
|
41
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
42
|
+
|
|
39
43
|
hasRowWithAutoHeight.current = false;
|
|
40
44
|
var densityFactor = gridDensityFactorSelector(apiRef.current.state, apiRef.current.instanceId);
|
|
41
|
-
var positions = [];
|
|
42
|
-
var currentPageTotalHeight = currentPage.rows.reduce(function (acc, row) {
|
|
43
|
-
positions.push(acc);
|
|
44
45
|
|
|
46
|
+
var calculateRowProcessedSizes = function calculateRowProcessedSizes(row) {
|
|
45
47
|
if (!rowsHeightLookup.current[row.id]) {
|
|
46
48
|
rowsHeightLookup.current[row.id] = {
|
|
47
49
|
sizes: {
|
|
@@ -112,11 +114,24 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
|
|
|
112
114
|
|
|
113
115
|
var processedSizes = apiRef.current.unstable_applyPipeProcessors('rowHeight', initialHeights, row);
|
|
114
116
|
rowsHeightLookup.current[row.id].sizes = processedSizes;
|
|
117
|
+
return processedSizes;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var positions = [];
|
|
121
|
+
var currentPageTotalHeight = currentPage.rows.reduce(function (acc, row) {
|
|
122
|
+
positions.push(acc);
|
|
123
|
+
var processedSizes = calculateRowProcessedSizes(row);
|
|
115
124
|
var finalRowHeight = Object.values(processedSizes).reduce(function (acc2, value) {
|
|
116
125
|
return acc2 + value;
|
|
117
126
|
}, 0);
|
|
118
127
|
return acc + finalRowHeight;
|
|
119
128
|
}, 0);
|
|
129
|
+
pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.forEach(function (row) {
|
|
130
|
+
calculateRowProcessedSizes(row);
|
|
131
|
+
});
|
|
132
|
+
pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.forEach(function (row) {
|
|
133
|
+
calculateRowProcessedSizes(row);
|
|
134
|
+
});
|
|
120
135
|
apiRef.current.setState(function (state) {
|
|
121
136
|
return _extends({}, state, {
|
|
122
137
|
rowsMeta: {
|
|
@@ -132,7 +147,7 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
|
|
|
132
147
|
}
|
|
133
148
|
|
|
134
149
|
apiRef.current.forceUpdate();
|
|
135
|
-
}, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight]);
|
|
150
|
+
}, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight, pinnedRows]);
|
|
136
151
|
var getRowHeight = React.useCallback(function (rowId) {
|
|
137
152
|
var height = rowsHeightLookup.current[rowId];
|
|
138
153
|
return height ? height.sizes.base : rowHeightFromDensity;
|
|
@@ -10,7 +10,8 @@ var flatRowTreeCreationMethod = function flatRowTreeCreationMethod(_ref) {
|
|
|
10
10
|
for (var i = 0; i < ids.length; i += 1) {
|
|
11
11
|
var rowId = ids[i];
|
|
12
12
|
|
|
13
|
-
if (previousTree && previousTree[rowId] && previousTree[rowId].depth === 0 && previousTree[rowId].parent == null
|
|
13
|
+
if (previousTree && previousTree[rowId] && previousTree[rowId].depth === 0 && previousTree[rowId].parent == null && // pinned row can be unpinned
|
|
14
|
+
!previousTree[rowId].isPinned) {
|
|
14
15
|
tree[rowId] = previousTree[rowId];
|
|
15
16
|
} else {
|
|
16
17
|
tree[rowId] = {
|
|
@@ -7,7 +7,8 @@ import { gridPageSelector, gridPageSizeSelector } from '../pagination/gridPagina
|
|
|
7
7
|
import { gridRowCountSelector } from '../rows/gridRowsSelector';
|
|
8
8
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
9
9
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
10
|
-
import { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelector';
|
|
10
|
+
import { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelector';
|
|
11
|
+
import { gridClasses } from '../../../constants/gridClasses'; // Logic copied from https://www.w3.org/TR/wai-aria-practices/examples/listbox/js/listbox.js
|
|
11
12
|
// Similar to https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
|
|
12
13
|
|
|
13
14
|
function scrollIntoView(dimensions) {
|
|
@@ -87,13 +88,17 @@ export var useGridScroll = function useGridScroll(apiRef, props) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
if (params.rowIndex != null) {
|
|
91
|
+
var _querySelector, _querySelector2;
|
|
92
|
+
|
|
90
93
|
var rowsMeta = gridRowsMetaSelector(apiRef.current.state);
|
|
91
94
|
var page = gridPageSelector(apiRef);
|
|
92
95
|
var pageSize = gridPageSizeSelector(apiRef);
|
|
93
96
|
var elementIndex = !props.pagination ? params.rowIndex : params.rowIndex - page * pageSize;
|
|
94
97
|
var targetOffsetHeight = rowsMeta.positions[elementIndex + 1] ? rowsMeta.positions[elementIndex + 1] - rowsMeta.positions[elementIndex] : rowsMeta.currentPageTotalHeight - rowsMeta.positions[elementIndex];
|
|
98
|
+
var topPinnedRowsHeight = ((_querySelector = windowRef.current.querySelector(".".concat(gridClasses['pinnedRows--top']))) == null ? void 0 : _querySelector.clientHeight) || 0;
|
|
99
|
+
var bottomPinnedRowsHeight = ((_querySelector2 = windowRef.current.querySelector(".".concat(gridClasses['pinnedRows--bottom']))) == null ? void 0 : _querySelector2.clientHeight) || 0;
|
|
95
100
|
scrollCoordinates.top = scrollIntoView({
|
|
96
|
-
clientHeight: windowRef.current.clientHeight,
|
|
101
|
+
clientHeight: windowRef.current.clientHeight - topPinnedRowsHeight - bottomPinnedRowsHeight,
|
|
97
102
|
scrollTop: windowRef.current.scrollTop,
|
|
98
103
|
offsetHeight: targetOffsetHeight,
|
|
99
104
|
offsetTop: rowsMeta.positions[elementIndex]
|