@mui/x-data-grid 5.7.0 → 5.8.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 +74 -0
- package/DataGrid/DataGrid.d.ts +8 -3
- package/DataGrid/DataGrid.js +27 -4
- package/DataGrid/useDataGridComponent.js +2 -4
- package/DataGrid/useDataGridProps.d.ts +2 -1
- package/colDef/gridBooleanColDef.d.ts +1 -1
- package/colDef/gridBooleanOperators.d.ts +1 -1
- package/colDef/gridDateColDef.d.ts +5 -9
- package/colDef/gridDateColDef.js +2 -2
- package/colDef/gridDateOperators.d.ts +1 -1
- package/{models/colDef → colDef}/gridDefaultColumnTypes.d.ts +1 -1
- package/{models/colDef → colDef}/gridDefaultColumnTypes.js +6 -6
- package/colDef/gridNumericColDef.d.ts +1 -1
- package/colDef/gridNumericOperators.d.ts +2 -2
- package/colDef/gridStringColDef.d.ts +1 -1
- package/colDef/gridStringOperators.d.ts +1 -1
- package/colDef/index.d.ts +1 -0
- package/colDef/index.js +2 -1
- package/components/GridRow.js +1 -1
- package/components/cell/GridCell.d.ts +4 -4
- package/components/cell/GridCell.js +2 -2
- package/components/cell/GridEditInputCell.js +2 -2
- package/components/cell/GridEditSingleSelectCell.js +2 -2
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +12 -0
- package/components/columnHeaders/{ColumnHeaderFilterIcon.js → GridColumnHeaderFilterIconButton.js} +22 -4
- package/components/columnHeaders/GridColumnHeaderItem.js +5 -5
- package/components/columnHeaders/index.d.ts +1 -0
- package/components/columnHeaders/index.js +1 -0
- package/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
- package/components/containers/GridRoot.js +29 -17
- package/components/menu/columnMenu/GridColumnMenu.js +1 -1
- package/components/panel/GridPanel.d.ts +2 -2
- package/components/panel/GridPreferencesPanel.js +1 -1
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +15 -3
- package/hooks/core/index.d.ts +1 -1
- package/hooks/core/{preProcessing/gridPreProcessingApi.d.ts → pipeProcessing/gridPipeProcessingApi.d.ts} +19 -18
- package/hooks/core/{preProcessing/gridPreProcessingApi.js → pipeProcessing/gridPipeProcessingApi.js} +0 -0
- package/hooks/core/pipeProcessing/index.d.ts +3 -0
- package/hooks/core/pipeProcessing/index.js +3 -0
- package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +27 -0
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +74 -0
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +7 -0
- package/hooks/core/{preProcessing/useGridRegisterPreProcessor.js → pipeProcessing/useGridRegisterPipeProcessor.js} +2 -2
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +27 -16
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +26 -15
- package/hooks/core/useGridInitialization.js +2 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +6 -6
- package/hooks/features/columns/gridColumnsUtils.d.ts +3 -3
- package/hooks/features/columns/gridColumnsUtils.js +49 -17
- package/hooks/features/columns/useGridColumns.js +36 -27
- package/hooks/features/dimensions/gridDimensionsApi.d.ts +5 -0
- package/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/hooks/features/editRows/useGridCellEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridCellEditing.new.js +22 -7
- package/hooks/features/editRows/useGridRowEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +22 -7
- package/hooks/features/events/useGridEvents.d.ts +1 -1
- package/hooks/features/events/useGridEvents.js +2 -0
- package/hooks/features/filter/gridFilterSelector.d.ts +3 -9
- package/hooks/features/filter/useGridFilter.js +4 -4
- package/hooks/features/{keyboard → keyboardNavigation}/useGridKeyboardNavigation.d.ts +2 -5
- package/hooks/features/{keyboard → keyboardNavigation}/useGridKeyboardNavigation.js +27 -6
- package/hooks/features/pagination/gridPaginationSelector.d.ts +1 -3
- package/hooks/features/pagination/useGridPage.js +9 -4
- package/hooks/features/pagination/useGridPageSize.js +3 -3
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +18 -5
- package/hooks/features/rows/gridRowsSelector.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +8 -0
- package/hooks/features/rows/gridRowsUtils.js +11 -0
- package/hooks/features/rows/index.d.ts +1 -0
- package/hooks/features/rows/index.js +1 -1
- package/hooks/features/rows/useGridRows.js +3 -3
- package/hooks/features/rows/useGridRowsMeta.js +3 -3
- package/hooks/features/scroll/useGridScroll.js +4 -13
- package/hooks/features/selection/gridSelectionSelector.d.ts +1 -3
- package/hooks/features/selection/useGridSelection.d.ts +4 -2
- package/hooks/features/selection/useGridSelection.js +72 -25
- package/hooks/features/selection/useGridSelectionPreProcessors.js +2 -2
- package/hooks/features/sorting/gridSortingSelector.d.ts +1 -3
- package/hooks/features/sorting/gridSortingUtils.d.ts +1 -2
- package/hooks/features/sorting/useGridSorting.js +3 -3
- package/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/hooks/utils/useGridRootProps.d.ts +1 -1
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +3 -6
- package/internals/index.js +2 -3
- package/legacy/DataGrid/DataGrid.js +27 -4
- package/legacy/DataGrid/useDataGridComponent.js +2 -4
- package/legacy/colDef/gridDateColDef.js +2 -2
- package/legacy/{models/colDef → colDef}/gridDefaultColumnTypes.js +6 -6
- package/legacy/colDef/index.js +2 -1
- package/legacy/components/GridRow.js +1 -1
- package/legacy/components/cell/GridCell.js +2 -2
- package/legacy/components/cell/GridEditInputCell.js +2 -2
- package/legacy/components/cell/GridEditSingleSelectCell.js +2 -2
- package/legacy/components/columnHeaders/{ColumnHeaderFilterIcon.js → GridColumnHeaderFilterIconButton.js} +22 -4
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +5 -5
- package/legacy/components/columnHeaders/index.js +1 -0
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/legacy/components/containers/GridRoot.js +34 -17
- package/legacy/components/menu/columnMenu/GridColumnMenu.js +1 -1
- package/legacy/components/panel/GridPreferencesPanel.js +1 -1
- package/legacy/constants/defaultGridSlotsComponents.js +2 -1
- package/legacy/hooks/core/{preProcessing/gridPreProcessingApi.js → pipeProcessing/gridPipeProcessingApi.js} +0 -0
- package/legacy/hooks/core/pipeProcessing/index.js +3 -0
- package/legacy/hooks/core/pipeProcessing/useGridPipeProcessing.js +83 -0
- package/legacy/hooks/core/{preProcessing/useGridRegisterPreProcessor.js → pipeProcessing/useGridRegisterPipeProcessor.js} +2 -2
- package/legacy/hooks/core/strategyProcessing/useGridStrategyProcessing.js +26 -15
- package/legacy/hooks/core/useGridInitialization.js +2 -2
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/legacy/hooks/features/columns/gridColumnsUtils.js +49 -18
- package/legacy/hooks/features/columns/useGridColumns.js +36 -27
- package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +22 -7
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +22 -7
- package/legacy/hooks/features/events/useGridEvents.js +2 -0
- package/legacy/hooks/features/filter/useGridFilter.js +4 -4
- package/legacy/hooks/features/{keyboard → keyboardNavigation}/useGridKeyboardNavigation.js +27 -6
- package/legacy/hooks/features/pagination/useGridPage.js +11 -4
- package/legacy/hooks/features/pagination/useGridPageSize.js +3 -3
- package/legacy/hooks/features/preferencesPanel/useGridPreferencesPanel.js +18 -5
- package/legacy/hooks/features/rows/gridRowsUtils.js +13 -0
- package/legacy/hooks/features/rows/index.js +1 -1
- package/legacy/hooks/features/rows/useGridRows.js +5 -5
- package/legacy/hooks/features/rows/useGridRowsMeta.js +3 -3
- package/legacy/hooks/features/scroll/useGridScroll.js +4 -13
- package/legacy/hooks/features/selection/useGridSelection.js +74 -25
- package/legacy/hooks/features/selection/useGridSelectionPreProcessors.js +2 -2
- package/legacy/hooks/features/sorting/useGridSorting.js +3 -3
- package/legacy/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +2 -3
- package/legacy/locales/daDK.js +36 -32
- package/legacy/models/colDef/index.js +1 -2
- package/legacy/models/events/gridEvents.js +4 -2
- package/legacy/models/gridRows.js +1 -33
- package/legacy/models/index.js +2 -2
- package/{modern/hooks/core/preProcessing/gridPreProcessingApi.js → legacy/models/params/gridPreferencePanelParams.js} +0 -0
- package/legacy/models/params/index.js +2 -1
- package/locales/daDK.js +32 -32
- package/models/api/gridApiCommon.d.ts +2 -2
- package/models/api/gridEditingApi.d.ts +2 -2
- package/models/api/gridParamsApi.d.ts +5 -5
- package/models/api/gridRowApi.d.ts +2 -2
- package/models/colDef/gridColDef.d.ts +33 -28
- package/models/colDef/index.d.ts +0 -1
- package/models/colDef/index.js +1 -2
- package/models/events/gridEventLookup.d.ts +12 -6
- package/models/events/gridEvents.d.ts +11 -5
- package/models/events/gridEvents.js +4 -2
- package/models/gridCell.d.ts +1 -0
- package/models/gridEditRowModel.d.ts +1 -1
- package/models/gridFilterOperator.d.ts +3 -2
- package/models/gridRows.d.ts +10 -18
- package/models/gridRows.js +1 -31
- package/models/gridSlotsComponent.d.ts +5 -0
- package/models/gridSlotsComponentsProps.d.ts +1 -0
- package/models/gridSortModel.d.ts +3 -4
- package/models/index.d.ts +1 -1
- package/models/index.js +2 -2
- package/models/params/gridCellParams.d.ts +14 -14
- package/models/params/gridColumnHeaderParams.d.ts +3 -2
- package/models/params/gridEditCellParams.d.ts +2 -3
- package/models/params/gridPreferencePanelParams.d.ts +3 -0
- package/models/params/gridPreferencePanelParams.js +1 -0
- package/models/params/gridRowParams.d.ts +7 -8
- package/models/params/gridValueOptionsParams.d.ts +3 -3
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +2 -1
- package/models/props/DataGridProps.d.ts +36 -16
- package/modern/DataGrid/DataGrid.js +27 -4
- package/modern/DataGrid/useDataGridComponent.js +2 -4
- package/modern/colDef/gridDateColDef.js +2 -2
- package/modern/{models/colDef → colDef}/gridDefaultColumnTypes.js +6 -6
- package/modern/colDef/index.js +2 -1
- package/modern/components/GridRow.js +1 -1
- package/modern/components/cell/GridCell.js +2 -2
- package/modern/components/cell/GridEditInputCell.js +2 -2
- package/modern/components/cell/GridEditSingleSelectCell.js +2 -2
- package/modern/components/columnHeaders/{ColumnHeaderFilterIcon.js → GridColumnHeaderFilterIconButton.js} +22 -4
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +3 -3
- package/modern/components/columnHeaders/index.js +1 -0
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/modern/components/containers/GridRoot.js +29 -17
- package/modern/components/menu/columnMenu/GridColumnMenu.js +1 -1
- package/modern/components/panel/GridPreferencesPanel.js +1 -1
- package/modern/constants/defaultGridSlotsComponents.js +2 -1
- package/modern/hooks/core/pipeProcessing/gridPipeProcessingApi.js +1 -0
- package/modern/hooks/core/pipeProcessing/index.js +3 -0
- package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +74 -0
- package/modern/hooks/core/{preProcessing/useGridRegisterPreProcessor.js → pipeProcessing/useGridRegisterPipeProcessor.js} +2 -2
- package/modern/hooks/core/strategyProcessing/useGridStrategyProcessing.js +26 -15
- package/modern/hooks/core/useGridInitialization.js +2 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/modern/hooks/features/columns/gridColumnsUtils.js +49 -17
- package/modern/hooks/features/columns/useGridColumns.js +36 -27
- package/modern/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +22 -7
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +22 -7
- package/modern/hooks/features/events/useGridEvents.js +2 -0
- package/modern/hooks/features/filter/useGridFilter.js +4 -4
- package/modern/hooks/features/{keyboard → keyboardNavigation}/useGridKeyboardNavigation.js +27 -6
- package/modern/hooks/features/pagination/useGridPage.js +9 -4
- package/modern/hooks/features/pagination/useGridPageSize.js +3 -3
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +18 -5
- package/modern/hooks/features/rows/gridRowsUtils.js +11 -0
- package/modern/hooks/features/rows/index.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +1 -1
- package/modern/hooks/features/rows/useGridRowsMeta.js +3 -3
- package/modern/hooks/features/scroll/useGridScroll.js +4 -9
- package/modern/hooks/features/selection/useGridSelection.js +72 -25
- package/modern/hooks/features/selection/useGridSelectionPreProcessors.js +2 -2
- package/modern/hooks/features/sorting/useGridSorting.js +3 -3
- package/modern/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -3
- package/modern/locales/daDK.js +32 -32
- package/modern/models/colDef/index.js +1 -2
- package/modern/models/events/gridEvents.js +4 -2
- package/modern/models/gridRows.js +1 -31
- package/modern/models/index.js +2 -2
- package/modern/models/params/gridPreferencePanelParams.js +1 -0
- package/modern/models/params/index.js +2 -1
- package/node/DataGrid/DataGrid.js +27 -4
- package/node/DataGrid/useDataGridComponent.js +2 -5
- package/node/colDef/gridDateColDef.js +2 -2
- package/node/{models/colDef → colDef}/gridDefaultColumnTypes.js +6 -6
- package/node/colDef/index.js +13 -0
- package/node/components/GridRow.js +1 -1
- package/node/components/cell/GridCell.js +2 -2
- package/node/components/cell/GridEditInputCell.js +2 -2
- package/node/components/cell/GridEditSingleSelectCell.js +2 -2
- package/node/components/columnHeaders/{ColumnHeaderFilterIcon.js → GridColumnHeaderFilterIconButton.js} +23 -5
- package/node/components/columnHeaders/GridColumnHeaderItem.js +5 -6
- package/node/components/columnHeaders/index.js +13 -0
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/node/components/containers/GridRoot.js +28 -17
- package/node/components/menu/columnMenu/GridColumnMenu.js +1 -1
- package/node/components/panel/GridPreferencesPanel.js +1 -1
- package/node/constants/defaultGridSlotsComponents.js +1 -0
- package/node/hooks/core/{preProcessing/gridPreProcessingApi.js → pipeProcessing/gridPipeProcessingApi.js} +0 -0
- package/node/hooks/core/pipeProcessing/index.js +44 -0
- package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +93 -0
- package/node/hooks/core/{preProcessing/useGridRegisterPreProcessor.js → pipeProcessing/useGridRegisterPipeProcessor.js} +4 -4
- package/node/hooks/core/strategyProcessing/useGridStrategyProcessing.js +26 -15
- package/node/hooks/core/useGridInitialization.js +2 -2
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/node/hooks/features/columns/gridColumnsUtils.js +54 -21
- package/node/hooks/features/columns/useGridColumns.js +36 -27
- package/node/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/node/hooks/features/editRows/useGridCellEditing.new.js +24 -7
- package/node/hooks/features/editRows/useGridRowEditing.new.js +24 -7
- package/node/hooks/features/events/useGridEvents.js +2 -0
- package/node/hooks/features/filter/useGridFilter.js +4 -4
- package/node/hooks/features/{keyboard → keyboardNavigation}/useGridKeyboardNavigation.js +29 -6
- package/node/hooks/features/pagination/useGridPage.js +8 -3
- package/node/hooks/features/pagination/useGridPageSize.js +3 -3
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +20 -5
- package/node/hooks/features/rows/gridRowsUtils.js +18 -0
- package/node/hooks/features/rows/index.js +15 -1
- package/node/hooks/features/rows/useGridRows.js +5 -5
- package/node/hooks/features/rows/useGridRowsMeta.js +3 -3
- package/node/hooks/features/scroll/useGridScroll.js +3 -13
- package/node/hooks/features/selection/useGridSelection.js +71 -24
- package/node/hooks/features/selection/useGridSelectionPreProcessors.js +2 -2
- package/node/hooks/features/sorting/useGridSorting.js +3 -3
- package/node/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/node/index.js +1 -1
- package/node/internals/index.js +4 -12
- package/node/locales/daDK.js +32 -32
- package/node/models/colDef/index.js +0 -13
- package/node/models/events/gridEvents.js +4 -2
- package/node/models/gridRows.js +1 -34
- package/node/models/index.js +13 -13
- package/node/models/params/gridPreferencePanelParams.js +5 -0
- package/node/models/params/index.js +13 -0
- package/package.json +1 -1
- package/components/columnHeaders/ColumnHeaderFilterIcon.d.ts +0 -5
- package/hooks/core/preProcessing/index.d.ts +0 -3
- package/hooks/core/preProcessing/index.js +0 -3
- package/hooks/core/preProcessing/useGridPreProcessing.d.ts +0 -6
- package/hooks/core/preProcessing/useGridPreProcessing.js +0 -53
- package/hooks/core/preProcessing/useGridRegisterPreProcessor.d.ts +0 -7
- package/hooks/features/keyboard/useGridKeyboard.d.ts +0 -10
- package/hooks/features/keyboard/useGridKeyboard.js +0 -70
- package/legacy/hooks/core/preProcessing/index.js +0 -3
- package/legacy/hooks/core/preProcessing/useGridPreProcessing.js +0 -62
- package/legacy/hooks/features/keyboard/useGridKeyboard.js +0 -70
- package/modern/hooks/core/preProcessing/index.js +0 -3
- package/modern/hooks/core/preProcessing/useGridPreProcessing.js +0 -53
- package/modern/hooks/features/keyboard/useGridKeyboard.js +0 -70
- package/node/hooks/core/preProcessing/index.js +0 -44
- package/node/hooks/core/preProcessing/useGridPreProcessing.js +0 -72
- package/node/hooks/features/keyboard/useGridKeyboard.js +0 -91
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
-
import { DEFAULT_GRID_COL_TYPE_KEY, getGridDefaultColumnTypes } from '../../../
|
|
5
|
+
import { DEFAULT_GRID_COL_TYPE_KEY, getGridDefaultColumnTypes } from '../../../colDef';
|
|
5
6
|
import { gridColumnsSelector, gridColumnVisibilityModelSelector } from './gridColumnsSelector';
|
|
6
7
|
import { clamp } from '../../../utils/utils';
|
|
7
8
|
export var COLUMNS_DIMENSION_PROPERTIES = ['maxWidth', 'minWidth', 'width', 'flex'];
|
|
@@ -253,7 +254,7 @@ export var createColumnsState = function createColumnsState(_ref5) {
|
|
|
253
254
|
var apiRef = _ref5.apiRef,
|
|
254
255
|
columnsToUpsert = _ref5.columnsToUpsert,
|
|
255
256
|
initialState = _ref5.initialState,
|
|
256
|
-
|
|
257
|
+
columnTypes = _ref5.columnTypes,
|
|
257
258
|
_ref5$currentColumnVi = _ref5.currentColumnVisibilityModel,
|
|
258
259
|
currentColumnVisibilityModel = _ref5$currentColumnVi === void 0 ? gridColumnVisibilityModelSelector(apiRef) : _ref5$currentColumnVi,
|
|
259
260
|
shouldRegenColumnVisibilityModelFromColumns = _ref5.shouldRegenColumnVisibilityModelFromColumns,
|
|
@@ -262,7 +263,7 @@ export var createColumnsState = function createColumnsState(_ref5) {
|
|
|
262
263
|
var isInsideStateInitializer = !apiRef.current.state.columns;
|
|
263
264
|
var columnsStateWithoutColumnVisibilityModel;
|
|
264
265
|
|
|
265
|
-
if (isInsideStateInitializer
|
|
266
|
+
if (isInsideStateInitializer) {
|
|
266
267
|
columnsStateWithoutColumnVisibilityModel = {
|
|
267
268
|
all: [],
|
|
268
269
|
lookup: {}
|
|
@@ -270,35 +271,65 @@ export var createColumnsState = function createColumnsState(_ref5) {
|
|
|
270
271
|
} else {
|
|
271
272
|
var currentState = gridColumnsSelector(apiRef.current.state);
|
|
272
273
|
columnsStateWithoutColumnVisibilityModel = {
|
|
273
|
-
all: _toConsumableArray(currentState.all),
|
|
274
|
-
lookup: _extends({}, currentState.lookup)
|
|
274
|
+
all: keepOnlyColumnsToUpsert ? [] : _toConsumableArray(currentState.all),
|
|
275
|
+
lookup: _extends({}, currentState.lookup) // Will be cleaned later if keepOnlyColumnsToUpsert=true
|
|
276
|
+
|
|
275
277
|
};
|
|
276
278
|
}
|
|
277
279
|
|
|
280
|
+
var columnsToKeep = {};
|
|
281
|
+
|
|
282
|
+
if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
|
|
283
|
+
columnsToKeep = Object.keys(columnsStateWithoutColumnVisibilityModel.lookup).reduce(function (acc, key) {
|
|
284
|
+
return _extends({}, acc, _defineProperty({}, key, false));
|
|
285
|
+
}, {});
|
|
286
|
+
}
|
|
287
|
+
|
|
278
288
|
var columnsToUpsertLookup = {};
|
|
279
289
|
columnsToUpsert.forEach(function (newColumn) {
|
|
280
|
-
|
|
290
|
+
var field = newColumn.field;
|
|
291
|
+
columnsToUpsertLookup[field] = true;
|
|
292
|
+
columnsToKeep[field] = true;
|
|
293
|
+
var existingState = columnsStateWithoutColumnVisibilityModel.lookup[field];
|
|
281
294
|
|
|
282
|
-
if (
|
|
295
|
+
if (existingState == null) {
|
|
283
296
|
// New Column
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
297
|
+
existingState = _extends({}, getGridColDef(columnTypes, newColumn.type), {
|
|
298
|
+
// TODO v6: Inline `getGridColDef`
|
|
299
|
+
field: field,
|
|
300
|
+
hasBeenResized: false
|
|
301
|
+
});
|
|
302
|
+
columnsStateWithoutColumnVisibilityModel.all.push(field);
|
|
303
|
+
} else if (keepOnlyColumnsToUpsert) {
|
|
304
|
+
columnsStateWithoutColumnVisibilityModel.all.push(field);
|
|
305
|
+
}
|
|
288
306
|
|
|
289
|
-
|
|
290
|
-
return newColumn[propertyName] !== undefined;
|
|
291
|
-
})) {
|
|
292
|
-
mergedColumn.hasBeenResized = true;
|
|
293
|
-
}
|
|
307
|
+
var hasValidDimension = false;
|
|
294
308
|
|
|
295
|
-
|
|
309
|
+
if (!existingState.hasBeenResized) {
|
|
310
|
+
hasValidDimension = COLUMNS_DIMENSION_PROPERTIES.some(function (key) {
|
|
311
|
+
return newColumn[key] !== undefined;
|
|
312
|
+
});
|
|
296
313
|
}
|
|
314
|
+
|
|
315
|
+
columnsStateWithoutColumnVisibilityModel.lookup[field] = _extends({}, existingState, {
|
|
316
|
+
hide: newColumn.hide == null ? false : newColumn.hide
|
|
317
|
+
}, newColumn, {
|
|
318
|
+
hasBeenResized: existingState.hasBeenResized || hasValidDimension
|
|
319
|
+
});
|
|
297
320
|
});
|
|
298
321
|
|
|
322
|
+
if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
|
|
323
|
+
Object.keys(columnsStateWithoutColumnVisibilityModel.lookup).forEach(function (field) {
|
|
324
|
+
if (!columnsToKeep[field]) {
|
|
325
|
+
delete columnsStateWithoutColumnVisibilityModel.lookup[field];
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
299
330
|
var columnsLookupBeforePreProcessing = _extends({}, columnsStateWithoutColumnVisibilityModel.lookup);
|
|
300
331
|
|
|
301
|
-
var columnsStateWithPreProcessing = apiRef.current.
|
|
332
|
+
var columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsStateWithoutColumnVisibilityModel); // TODO v6: remove the sync between the columns `hide` option and the model.
|
|
302
333
|
|
|
303
334
|
var columnVisibilityModel = {};
|
|
304
335
|
|
|
@@ -7,7 +7,7 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
|
7
7
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
8
8
|
import { gridColumnFieldsSelector, gridColumnDefinitionsSelector, gridColumnLookupSelector, gridColumnsMetaSelector, gridColumnsSelector, gridColumnVisibilityModelSelector, gridVisibleColumnDefinitionsSelector, gridColumnPositionsSelector } from './gridColumnsSelector';
|
|
9
9
|
import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
10
|
-
import {
|
|
10
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
11
11
|
import { hydrateColumnsWidth, computeColumnTypes, createColumnsState, mergeColumnsState, COLUMNS_DIMENSION_PROPERTIES } from './gridColumnsUtils';
|
|
12
12
|
import { GridPreferencePanelsValue } from '../preferencesPanel';
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -18,7 +18,7 @@ export var columnsStateInitializer = function columnsStateInitializer(state, pro
|
|
|
18
18
|
var columnsTypes = computeColumnTypes(props.columnTypes);
|
|
19
19
|
var columnsState = createColumnsState({
|
|
20
20
|
apiRef: apiRef,
|
|
21
|
-
|
|
21
|
+
columnTypes: columnsTypes,
|
|
22
22
|
columnsToUpsert: props.columns,
|
|
23
23
|
initialState: (_props$initialState2 = props.initialState) == null ? void 0 : _props$initialState2.columns,
|
|
24
24
|
shouldRegenColumnVisibilityModelFromColumns: !isUsingColumnVisibilityModel,
|
|
@@ -39,15 +39,17 @@ export function useGridColumns(apiRef, props) {
|
|
|
39
39
|
var _props$initialState4, _props$initialState4$, _props$componentsProp2;
|
|
40
40
|
|
|
41
41
|
var logger = useGridLogger(apiRef, 'useGridColumns');
|
|
42
|
-
var
|
|
42
|
+
var columnTypes = React.useMemo(function () {
|
|
43
43
|
return computeColumnTypes(props.columnTypes);
|
|
44
44
|
}, [props.columnTypes]);
|
|
45
|
+
var previousColumnsProp = React.useRef(props.columns);
|
|
46
|
+
var previousColumnTypesProp = React.useRef(columnTypes);
|
|
45
47
|
/**
|
|
46
48
|
* If `initialState.columns.columnVisibilityModel` or `columnVisibilityModel` was defined during the 1st render, we are directly updating the model
|
|
47
49
|
* If not, we keep the old behavior and update the `GridColDef.hide` option (which will update the state model through the `GridColDef.hide` => `columnVisibilityModel` sync in `createColumnsState`
|
|
48
50
|
*/
|
|
49
51
|
|
|
50
|
-
var isUsingColumnVisibilityModel = React.useRef(!!props.columnVisibilityModel || !!((_props$initialState4 = props.initialState) != null && (_props$initialState4$ = _props$initialState4.columns) != null && _props$initialState4$.columnVisibilityModel))
|
|
52
|
+
var isUsingColumnVisibilityModel = React.useRef(!!props.columnVisibilityModel || !!((_props$initialState4 = props.initialState) != null && (_props$initialState4$ = _props$initialState4.columns) != null && _props$initialState4$.columnVisibilityModel));
|
|
51
53
|
apiRef.current.unstable_updateControlState({
|
|
52
54
|
stateId: 'visibleColumns',
|
|
53
55
|
propModel: props.columnVisibilityModel,
|
|
@@ -96,7 +98,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
96
98
|
return _extends({}, state, {
|
|
97
99
|
columns: createColumnsState({
|
|
98
100
|
apiRef: apiRef,
|
|
99
|
-
|
|
101
|
+
columnTypes: columnTypes,
|
|
100
102
|
columnsToUpsert: [],
|
|
101
103
|
initialState: undefined,
|
|
102
104
|
shouldRegenColumnVisibilityModelFromColumns: false,
|
|
@@ -107,18 +109,18 @@ export function useGridColumns(apiRef, props) {
|
|
|
107
109
|
});
|
|
108
110
|
apiRef.current.forceUpdate();
|
|
109
111
|
}
|
|
110
|
-
}, [apiRef,
|
|
112
|
+
}, [apiRef, columnTypes]);
|
|
111
113
|
var updateColumns = React.useCallback(function (columns) {
|
|
112
114
|
var columnsState = createColumnsState({
|
|
113
115
|
apiRef: apiRef,
|
|
114
|
-
|
|
116
|
+
columnTypes: columnTypes,
|
|
115
117
|
columnsToUpsert: columns,
|
|
116
118
|
initialState: undefined,
|
|
117
119
|
shouldRegenColumnVisibilityModelFromColumns: true,
|
|
118
120
|
keepOnlyColumnsToUpsert: false
|
|
119
121
|
});
|
|
120
122
|
setGridColumnsState(columnsState);
|
|
121
|
-
}, [apiRef, setGridColumnsState,
|
|
123
|
+
}, [apiRef, setGridColumnsState, columnTypes]);
|
|
122
124
|
var updateColumn = React.useCallback(function (column) {
|
|
123
125
|
return apiRef.current.updateColumns([column]);
|
|
124
126
|
}, [apiRef]);
|
|
@@ -126,7 +128,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
126
128
|
// We keep updating the `hide` option of `GridColDef` when not controlling the model to avoid any breaking change.
|
|
127
129
|
// `updateColumns` take care of updating the model itself if needs be.
|
|
128
130
|
// TODO v6: stop using the `hide` field even when the model is not defined
|
|
129
|
-
if (isUsingColumnVisibilityModel) {
|
|
131
|
+
if (isUsingColumnVisibilityModel.current) {
|
|
130
132
|
var _columnVisibilityMode;
|
|
131
133
|
|
|
132
134
|
var columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
|
|
@@ -152,7 +154,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
152
154
|
};
|
|
153
155
|
apiRef.current.publishEvent(GridEvents.columnVisibilityChange, params);
|
|
154
156
|
}
|
|
155
|
-
}, [apiRef
|
|
157
|
+
}, [apiRef]);
|
|
156
158
|
var setColumnIndex = React.useCallback(function (field, targetIndexPosition) {
|
|
157
159
|
var allColumns = gridColumnFieldsSelector(apiRef);
|
|
158
160
|
var oldIndexPosition = allColumns.findIndex(function (col) {
|
|
@@ -217,7 +219,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
217
219
|
var stateExportPreProcessing = React.useCallback(function (prevState) {
|
|
218
220
|
var columnsStateToExport = {};
|
|
219
221
|
|
|
220
|
-
if (isUsingColumnVisibilityModel) {
|
|
222
|
+
if (isUsingColumnVisibilityModel.current) {
|
|
221
223
|
var columnVisibilityModelToExport = gridColumnVisibilityModelSelector(apiRef);
|
|
222
224
|
var hasHiddenColumns = Object.values(columnVisibilityModelToExport).some(function (value) {
|
|
223
225
|
return value === false;
|
|
@@ -248,11 +250,11 @@ export function useGridColumns(apiRef, props) {
|
|
|
248
250
|
return _extends({}, prevState, {
|
|
249
251
|
columns: columnsStateToExport
|
|
250
252
|
});
|
|
251
|
-
}, [apiRef
|
|
253
|
+
}, [apiRef]);
|
|
252
254
|
var stateRestorePreProcessing = React.useCallback(function (params, context) {
|
|
253
255
|
var _context$stateToResto;
|
|
254
256
|
|
|
255
|
-
var columnVisibilityModelToImport = isUsingColumnVisibilityModel ? (_context$stateToResto = context.stateToRestore.columns) == null ? void 0 : _context$stateToResto.columnVisibilityModel : undefined;
|
|
257
|
+
var columnVisibilityModelToImport = isUsingColumnVisibilityModel.current ? (_context$stateToResto = context.stateToRestore.columns) == null ? void 0 : _context$stateToResto.columnVisibilityModel : undefined;
|
|
256
258
|
var initialState = context.stateToRestore.columns;
|
|
257
259
|
|
|
258
260
|
if (columnVisibilityModelToImport == null && initialState == null) {
|
|
@@ -261,10 +263,10 @@ export function useGridColumns(apiRef, props) {
|
|
|
261
263
|
|
|
262
264
|
var columnsState = createColumnsState({
|
|
263
265
|
apiRef: apiRef,
|
|
264
|
-
|
|
266
|
+
columnTypes: columnTypes,
|
|
265
267
|
columnsToUpsert: [],
|
|
266
268
|
initialState: initialState,
|
|
267
|
-
shouldRegenColumnVisibilityModelFromColumns: !isUsingColumnVisibilityModel,
|
|
269
|
+
shouldRegenColumnVisibilityModelFromColumns: !isUsingColumnVisibilityModel.current,
|
|
268
270
|
currentColumnVisibilityModel: columnVisibilityModelToImport,
|
|
269
271
|
keepOnlyColumnsToUpsert: false
|
|
270
272
|
});
|
|
@@ -275,7 +277,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
275
277
|
}
|
|
276
278
|
|
|
277
279
|
return params;
|
|
278
|
-
}, [apiRef,
|
|
280
|
+
}, [apiRef, columnTypes]);
|
|
279
281
|
var preferencePanelPreProcessing = React.useCallback(function (initialValue, value) {
|
|
280
282
|
if (value === GridPreferencePanelsValue.columns) {
|
|
281
283
|
var _props$componentsProp;
|
|
@@ -286,14 +288,14 @@ export function useGridColumns(apiRef, props) {
|
|
|
286
288
|
|
|
287
289
|
return initialValue;
|
|
288
290
|
}, [props.components.ColumnsPanel, (_props$componentsProp2 = props.componentsProps) == null ? void 0 : _props$componentsProp2.columnsPanel]);
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
291
|
+
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
292
|
+
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
293
|
+
useGridRegisterPipeProcessor(apiRef, 'preferencePanel', preferencePanelPreProcessing);
|
|
292
294
|
/**
|
|
293
295
|
* EVENTS
|
|
294
296
|
*/
|
|
295
297
|
|
|
296
|
-
var
|
|
298
|
+
var handlepipeProcessorRegister = React.useCallback(function (name) {
|
|
297
299
|
if (name !== 'hydrateColumns') {
|
|
298
300
|
return;
|
|
299
301
|
}
|
|
@@ -301,14 +303,14 @@ export function useGridColumns(apiRef, props) {
|
|
|
301
303
|
logger.info("Columns pre-processing have changed, regenerating the columns");
|
|
302
304
|
var columnsState = createColumnsState({
|
|
303
305
|
apiRef: apiRef,
|
|
304
|
-
|
|
306
|
+
columnTypes: columnTypes,
|
|
305
307
|
columnsToUpsert: [],
|
|
306
308
|
initialState: undefined,
|
|
307
|
-
shouldRegenColumnVisibilityModelFromColumns: !isUsingColumnVisibilityModel,
|
|
309
|
+
shouldRegenColumnVisibilityModelFromColumns: !isUsingColumnVisibilityModel.current,
|
|
308
310
|
keepOnlyColumnsToUpsert: false
|
|
309
311
|
});
|
|
310
312
|
setGridColumnsState(columnsState);
|
|
311
|
-
}, [apiRef, logger, setGridColumnsState,
|
|
313
|
+
}, [apiRef, logger, setGridColumnsState, columnTypes]);
|
|
312
314
|
var prevInnerWidth = React.useRef(null);
|
|
313
315
|
|
|
314
316
|
var handleGridSizeChange = function handleGridSizeChange(viewportInnerSize) {
|
|
@@ -318,7 +320,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
318
320
|
}
|
|
319
321
|
};
|
|
320
322
|
|
|
321
|
-
useGridApiEventHandler(apiRef, GridEvents.
|
|
323
|
+
useGridApiEventHandler(apiRef, GridEvents.pipeProcessorRegister, handlepipeProcessorRegister);
|
|
322
324
|
useGridApiEventHandler(apiRef, GridEvents.viewportInnerSizeChange, handleGridSizeChange);
|
|
323
325
|
useGridApiOptionHandler(apiRef, GridEvents.columnVisibilityChange, props.onColumnVisibilityChange);
|
|
324
326
|
/**
|
|
@@ -335,17 +337,24 @@ export function useGridColumns(apiRef, props) {
|
|
|
335
337
|
}
|
|
336
338
|
|
|
337
339
|
logger.info("GridColumns have changed, new length ".concat(props.columns.length));
|
|
340
|
+
|
|
341
|
+
if (previousColumnsProp.current === props.columns && previousColumnTypesProp.current === columnTypes) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
|
|
338
345
|
var columnsState = createColumnsState({
|
|
339
346
|
apiRef: apiRef,
|
|
340
|
-
|
|
347
|
+
columnTypes: columnTypes,
|
|
341
348
|
initialState: undefined,
|
|
342
349
|
// If the user provides a model, we don't want to set it in the state here because it has it's dedicated `useEffect` which calls `setColumnVisibilityModel`
|
|
343
|
-
shouldRegenColumnVisibilityModelFromColumns: !isUsingColumnVisibilityModel,
|
|
350
|
+
shouldRegenColumnVisibilityModelFromColumns: !isUsingColumnVisibilityModel.current,
|
|
344
351
|
columnsToUpsert: props.columns,
|
|
345
352
|
keepOnlyColumnsToUpsert: true
|
|
346
353
|
});
|
|
354
|
+
previousColumnsProp.current = props.columns;
|
|
355
|
+
previousColumnTypesProp.current = columnTypes;
|
|
347
356
|
setGridColumnsState(columnsState);
|
|
348
|
-
}, [logger, apiRef, setGridColumnsState, props.columns,
|
|
357
|
+
}, [logger, apiRef, setGridColumnsState, props.columns, columnTypes]);
|
|
349
358
|
React.useEffect(function () {
|
|
350
359
|
if (props.columnVisibilityModel !== undefined) {
|
|
351
360
|
apiRef.current.setColumnVisibilityModel(props.columnVisibilityModel);
|
|
@@ -136,7 +136,8 @@ export function useGridDimensions(apiRef, props) {
|
|
|
136
136
|
var dimensionsApi = {
|
|
137
137
|
resize: resize,
|
|
138
138
|
getRootDimensions: getRootDimensions,
|
|
139
|
-
unstable_getViewportPageSize: getViewportPageSize
|
|
139
|
+
unstable_getViewportPageSize: getViewportPageSize,
|
|
140
|
+
unstable_updateGridDimensionsRef: updateGridDimensionsRef
|
|
140
141
|
};
|
|
141
142
|
useGridApiMethod(apiRef, dimensionsApi, 'GridDimensionsApi');
|
|
142
143
|
var debounceResize = React.useMemo(function () {
|
|
@@ -9,9 +9,12 @@ import { GridEditModes, GridCellModes } from '../../../models/gridEditRowModel';
|
|
|
9
9
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
10
10
|
import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
11
11
|
import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
12
|
+
import { buildWarning } from '../../../utils/warning';
|
|
12
13
|
import { GridCellEditStartReasons, GridCellEditStopReasons } from '../../../models/params/gridEditCellParams';
|
|
14
|
+
var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
13
15
|
export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
14
|
-
var processRowUpdate = props.processRowUpdate
|
|
16
|
+
var processRowUpdate = props.processRowUpdate,
|
|
17
|
+
onProcessRowUpdateError = props.onProcessRowUpdateError;
|
|
15
18
|
|
|
16
19
|
var runIfEditModeIsCell = function runIfEditModeIsCell(callback) {
|
|
17
20
|
return function () {
|
|
@@ -231,17 +234,29 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
231
234
|
}) : _extends({}, row, _defineProperty({}, field, value));
|
|
232
235
|
|
|
233
236
|
if (processRowUpdate) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
var handleError = function handleError(errorThrown) {
|
|
238
|
+
if (onProcessRowUpdateError) {
|
|
239
|
+
onProcessRowUpdateError(errorThrown);
|
|
240
|
+
} else {
|
|
241
|
+
missingOnProcessRowUpdateErrorWarning();
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
try {
|
|
246
|
+
Promise.resolve(processRowUpdate(rowUpdate, row)).then(function (finalRowUpdate) {
|
|
247
|
+
apiRef.current.updateRows([finalRowUpdate]);
|
|
248
|
+
updateFocusedCellIfNeeded();
|
|
249
|
+
updateOrDeleteFieldState(id, field, null);
|
|
250
|
+
}).catch(handleError);
|
|
251
|
+
} catch (errorThrown) {
|
|
252
|
+
handleError(errorThrown);
|
|
253
|
+
}
|
|
239
254
|
} else {
|
|
240
255
|
apiRef.current.updateRows([rowUpdate]);
|
|
241
256
|
updateFocusedCellIfNeeded();
|
|
242
257
|
updateOrDeleteFieldState(id, field, null);
|
|
243
258
|
}
|
|
244
|
-
}, [apiRef, processRowUpdate, throwIfNotInMode, updateOrDeleteFieldState]);
|
|
259
|
+
}, [apiRef, onProcessRowUpdateError, processRowUpdate, throwIfNotInMode, updateOrDeleteFieldState]);
|
|
245
260
|
var setCellEditingEditCellValue = React.useCallback( /*#__PURE__*/function () {
|
|
246
261
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
|
|
247
262
|
var id, field, value, column, row, parsedValue, editingState, newProps, hasChanged;
|
|
@@ -11,11 +11,14 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
|
11
11
|
import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
12
12
|
import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
13
13
|
import { gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
14
|
+
import { buildWarning } from '../../../utils/warning';
|
|
14
15
|
import { GridRowEditStopReasons, GridRowEditStartReasons } from '../../../models/params/gridRowParams';
|
|
16
|
+
var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
15
17
|
export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
16
18
|
var focusTimeout = React.useRef(null);
|
|
17
19
|
var nextFocusedCell = React.useRef(null);
|
|
18
|
-
var processRowUpdate = props.processRowUpdate
|
|
20
|
+
var processRowUpdate = props.processRowUpdate,
|
|
21
|
+
onProcessRowUpdateError = props.onProcessRowUpdateError;
|
|
19
22
|
|
|
20
23
|
var runIfEditModeIsRow = function runIfEditModeIsRow(callback) {
|
|
21
24
|
return function () {
|
|
@@ -352,17 +355,29 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
352
355
|
});
|
|
353
356
|
|
|
354
357
|
if (processRowUpdate) {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
358
|
+
var handleError = function handleError(errorThrown) {
|
|
359
|
+
if (onProcessRowUpdateError) {
|
|
360
|
+
onProcessRowUpdateError(errorThrown);
|
|
361
|
+
} else {
|
|
362
|
+
missingOnProcessRowUpdateErrorWarning();
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
try {
|
|
367
|
+
Promise.resolve(processRowUpdate(rowUpdate, row)).then(function (finalRowUpdate) {
|
|
368
|
+
apiRef.current.updateRows([finalRowUpdate]);
|
|
369
|
+
updateFocusedCellIfNeeded();
|
|
370
|
+
updateOrDeleteRowState(id, null);
|
|
371
|
+
}).catch(handleError);
|
|
372
|
+
} catch (errorThrown) {
|
|
373
|
+
handleError(errorThrown);
|
|
374
|
+
}
|
|
360
375
|
} else {
|
|
361
376
|
apiRef.current.updateRows([rowUpdate]);
|
|
362
377
|
updateFocusedCellIfNeeded();
|
|
363
378
|
updateOrDeleteRowState(id, null);
|
|
364
379
|
}
|
|
365
|
-
}, [apiRef, processRowUpdate, throwIfNotInMode, updateOrDeleteRowState]);
|
|
380
|
+
}, [apiRef, onProcessRowUpdateError, processRowUpdate, throwIfNotInMode, updateOrDeleteRowState]);
|
|
366
381
|
var setRowEditingEditCellValue = React.useCallback(function (params) {
|
|
367
382
|
var id = params.id,
|
|
368
383
|
field = params.field,
|
|
@@ -17,6 +17,8 @@ export function useGridEvents(apiRef, props) {
|
|
|
17
17
|
useGridApiOptionHandler(apiRef, GridEvents.cellDoubleClick, props.onCellDoubleClick);
|
|
18
18
|
useGridApiOptionHandler(apiRef, GridEvents.cellKeyDown, props.onCellKeyDown);
|
|
19
19
|
useGridApiOptionHandler(apiRef, GridEvents.cellFocusOut, props.onCellFocusOut);
|
|
20
|
+
useGridApiOptionHandler(apiRef, GridEvents.preferencePanelClose, props.onPreferencePanelClose);
|
|
21
|
+
useGridApiOptionHandler(apiRef, GridEvents.preferencePanelOpen, props.onPreferencePanelOpen);
|
|
20
22
|
useGridApiOptionHandler(apiRef, GridEvents.rowDoubleClick, props.onRowDoubleClick);
|
|
21
23
|
useGridApiOptionHandler(apiRef, GridEvents.rowClick, props.onRowClick);
|
|
22
24
|
useGridApiOptionHandler(apiRef, GridEvents.componentError, props.onError);
|
|
@@ -12,7 +12,7 @@ import { getDefaultGridFilterModel } from './gridFilterState';
|
|
|
12
12
|
import { gridFilterModelSelector, gridVisibleSortedRowEntriesSelector } from './gridFilterSelector';
|
|
13
13
|
import { useFirstRender } from '../../utils/useFirstRender';
|
|
14
14
|
import { gridRowIdsSelector } from '../rows';
|
|
15
|
-
import {
|
|
15
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
16
16
|
import { GRID_DEFAULT_STRATEGY, useGridRegisterStrategyProcessor } from '../../core/strategyProcessing';
|
|
17
17
|
import { buildAggregatedFilterApplier, sanitizeFilterModel, mergeStateWithFilterModel } from './gridFilterUtils';
|
|
18
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -234,9 +234,9 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
|
234
234
|
filteredDescendantCountLookup: {}
|
|
235
235
|
};
|
|
236
236
|
}, [apiRef, props.filterMode]);
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
238
|
+
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
239
|
+
useGridRegisterPipeProcessor(apiRef, 'preferencePanel', preferencePanelPreProcessing);
|
|
240
240
|
useGridRegisterStrategyProcessor(apiRef, GRID_DEFAULT_STRATEGY, 'filtering', flatFilteringMethod);
|
|
241
241
|
/**
|
|
242
242
|
* EVENTS
|
|
@@ -7,13 +7,12 @@ import { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelecto
|
|
|
7
7
|
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
8
8
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../colDef/gridCheckboxSelectionColDef';
|
|
9
9
|
import { gridClasses } from '../../../constants/gridClasses';
|
|
10
|
+
import { GridCellModes } from '../../../models/gridEditRowModel';
|
|
11
|
+
import { isNavigationKey } from '../../../utils/keyboardUtils';
|
|
10
12
|
/**
|
|
11
|
-
* @requires useGridPage (state)
|
|
12
|
-
* @requires useGridPageSize (state)
|
|
13
|
-
* @requires useGridFilter (state)
|
|
14
|
-
* @requires useGridColumns (state, method)
|
|
15
|
-
* @requires useGridRows (state, method)
|
|
16
13
|
* @requires useGridSorting (method) - can be after
|
|
14
|
+
* @requires useGridFilter (state) - can be after
|
|
15
|
+
* @requires useGridColumns (state, method) - can be after
|
|
17
16
|
* @requires useGridDimensions (method) - can be after
|
|
18
17
|
* @requires useGridFocus (method) - can be after
|
|
19
18
|
* @requires useGridScroll (method) - can be after
|
|
@@ -113,8 +112,16 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
113
112
|
break;
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
case 'PageDown':
|
|
117
115
|
case ' ':
|
|
116
|
+
{
|
|
117
|
+
if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {
|
|
118
|
+
goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
case 'PageDown':
|
|
118
125
|
{
|
|
119
126
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
120
127
|
goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
|
|
@@ -269,6 +276,20 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
269
276
|
event.preventDefault();
|
|
270
277
|
}
|
|
271
278
|
}, [apiRef, currentPage, goToCell, goToHeader]);
|
|
279
|
+
var handleCellKeyDown = React.useCallback(function (params, event) {
|
|
280
|
+
// Ignore portal
|
|
281
|
+
if (!event.currentTarget.contains(event.target)) {
|
|
282
|
+
return;
|
|
283
|
+
} // Get the most recent params because the cell mode may have changed by another listener
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
var cellParams = apiRef.current.getCellParams(params.id, params.field);
|
|
287
|
+
|
|
288
|
+
if (cellParams.cellMode !== GridCellModes.Edit && isNavigationKey(event.key)) {
|
|
289
|
+
apiRef.current.publishEvent(GridEvents.cellNavigationKeyDown, cellParams, event);
|
|
290
|
+
}
|
|
291
|
+
}, [apiRef]);
|
|
272
292
|
useGridApiEventHandler(apiRef, GridEvents.cellNavigationKeyDown, handleCellNavigationKeyDown);
|
|
273
293
|
useGridApiEventHandler(apiRef, GridEvents.columnHeaderKeyDown, handleColumnHeaderKeyDown);
|
|
294
|
+
useGridApiEventHandler(apiRef, GridEvents.cellKeyDown, handleCellKeyDown);
|
|
274
295
|
};
|
|
@@ -3,8 +3,8 @@ import * as React from 'react';
|
|
|
3
3
|
import { useGridLogger, useGridSelector, useGridApiMethod, useGridApiEventHandler } from '../../utils';
|
|
4
4
|
import { GridEvents } from '../../../models/events';
|
|
5
5
|
import { gridVisibleTopLevelRowCountSelector } from '../filter';
|
|
6
|
-
import { gridPageSelector } from './gridPaginationSelector';
|
|
7
|
-
import {
|
|
6
|
+
import { gridPageSelector, gridPageSizeSelector } from './gridPaginationSelector';
|
|
7
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
8
8
|
import { buildWarning } from '../../../utils/warning';
|
|
9
9
|
export var getPageCount = function getPageCount(rowCount, pageSize) {
|
|
10
10
|
if (pageSize > 0 && rowCount > 0) {
|
|
@@ -95,8 +95,8 @@ export var useGridPage = function useGridPage(apiRef, props) {
|
|
|
95
95
|
apiRef.current.setState(mergeStateWithPage(page));
|
|
96
96
|
return params;
|
|
97
97
|
}, [apiRef]);
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
99
|
+
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
100
100
|
/**
|
|
101
101
|
* EVENTS
|
|
102
102
|
*/
|
|
@@ -114,7 +114,14 @@ export var useGridPage = function useGridPage(apiRef, props) {
|
|
|
114
114
|
apiRef.current.forceUpdate();
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
+
var handlePageChange = function handlePageChange() {
|
|
118
|
+
return apiRef.current.scrollToIndexes({
|
|
119
|
+
rowIndex: gridPageSelector(apiRef) * gridPageSizeSelector(apiRef)
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
117
123
|
useGridApiEventHandler(apiRef, GridEvents.pageSizeChange, handlePageSizeChange);
|
|
124
|
+
useGridApiEventHandler(apiRef, GridEvents.pageChange, handlePageChange);
|
|
118
125
|
/**
|
|
119
126
|
* EFFECTS
|
|
120
127
|
*/
|
|
@@ -4,7 +4,7 @@ import { GridEvents } from '../../../models/events';
|
|
|
4
4
|
import { useGridLogger, useGridApiMethod, useGridApiEventHandler, useGridSelector } from '../../utils';
|
|
5
5
|
import { gridPageSizeSelector } from './gridPaginationSelector';
|
|
6
6
|
import { gridDensityRowHeightSelector } from '../density';
|
|
7
|
-
import {
|
|
7
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
8
8
|
export var defaultPageSize = function defaultPageSize(autoPageSize) {
|
|
9
9
|
return autoPageSize ? 0 : 100;
|
|
10
10
|
};
|
|
@@ -90,8 +90,8 @@ export var useGridPageSize = function useGridPageSize(apiRef, props) {
|
|
|
90
90
|
|
|
91
91
|
return params;
|
|
92
92
|
}, [apiRef]);
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
94
|
+
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
95
95
|
/**
|
|
96
96
|
* EVENTS
|
|
97
97
|
*/
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { GridEvents } from '../../../models/events';
|
|
3
4
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
5
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
5
|
-
import {
|
|
6
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
6
7
|
import { gridPreferencePanelStateSelector } from './gridPreferencePanelSelector';
|
|
8
|
+
import { useGridSelector } from '../../utils/useGridSelector';
|
|
7
9
|
export var preferencePanelStateInitializer = function preferencePanelStateInitializer(state, props) {
|
|
8
10
|
var _props$initialState$p, _props$initialState;
|
|
9
11
|
|
|
@@ -19,6 +21,7 @@ export var preferencePanelStateInitializer = function preferencePanelStateInitia
|
|
|
19
21
|
|
|
20
22
|
export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef) {
|
|
21
23
|
var logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
|
|
24
|
+
var preferencePanelState = useGridSelector(apiRef, gridPreferencePanelStateSelector);
|
|
22
25
|
var hideTimeout = React.useRef();
|
|
23
26
|
var immediateTimeout = React.useRef();
|
|
24
27
|
/**
|
|
@@ -27,6 +30,13 @@ export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef) {
|
|
|
27
30
|
|
|
28
31
|
var hidePreferences = React.useCallback(function () {
|
|
29
32
|
logger.debug('Hiding Preferences Panel');
|
|
33
|
+
|
|
34
|
+
if (preferencePanelState.openedPanelValue) {
|
|
35
|
+
apiRef.current.publishEvent(GridEvents.preferencePanelClose, {
|
|
36
|
+
openedPanelValue: preferencePanelState.openedPanelValue
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
apiRef.current.setState(function (state) {
|
|
31
41
|
return _extends({}, state, {
|
|
32
42
|
preferencePanel: {
|
|
@@ -35,7 +45,7 @@ export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef) {
|
|
|
35
45
|
});
|
|
36
46
|
});
|
|
37
47
|
apiRef.current.forceUpdate();
|
|
38
|
-
}, [apiRef, logger]); // This is to prevent the preferences from closing when you open a select box or another panel,
|
|
48
|
+
}, [apiRef, logger, preferencePanelState.openedPanelValue]); // This is to prevent the preferences from closing when you open a select box or another panel,
|
|
39
49
|
// The issue is in MUI core V4 => Fixed in V5
|
|
40
50
|
|
|
41
51
|
var doNotHidePanel = React.useCallback(function () {
|
|
@@ -59,8 +69,11 @@ export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef) {
|
|
|
59
69
|
})
|
|
60
70
|
});
|
|
61
71
|
});
|
|
72
|
+
apiRef.current.publishEvent(GridEvents.preferencePanelOpen, {
|
|
73
|
+
openedPanelValue: newValue
|
|
74
|
+
});
|
|
62
75
|
apiRef.current.forceUpdate();
|
|
63
|
-
}, [doNotHidePanel, apiRef
|
|
76
|
+
}, [logger, doNotHidePanel, apiRef]);
|
|
64
77
|
useGridApiMethod(apiRef, {
|
|
65
78
|
showPreferences: showPreferences,
|
|
66
79
|
hidePreferences: hidePreferencesDelayed
|
|
@@ -93,8 +106,8 @@ export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef) {
|
|
|
93
106
|
|
|
94
107
|
return params;
|
|
95
108
|
}, [apiRef]);
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
110
|
+
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
98
111
|
/**
|
|
99
112
|
* EFFECTS
|
|
100
113
|
*/
|