@mui/x-data-grid 5.17.4 → 6.0.0-alpha.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 +179 -4
- package/DataGrid/DataGrid.js +1 -11
- package/colDef/gridStringColDef.js +0 -1
- package/components/cell/GridActionsCell.js +1 -1
- package/components/cell/GridBooleanCell.js +1 -1
- package/components/cell/GridEditBooleanCell.js +1 -1
- package/components/cell/GridEditDateCell.js +1 -1
- package/components/cell/GridEditInputCell.js +1 -1
- package/components/cell/GridEditSingleSelectCell.js +1 -1
- package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/components/containers/GridRootStyles.js +2 -0
- package/components/panel/GridColumnsPanel.js +4 -18
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -4
- package/hooks/features/columns/gridColumnsUtils.d.ts +3 -4
- package/hooks/features/columns/gridColumnsUtils.js +21 -92
- package/hooks/features/columns/useGridColumns.d.ts +1 -1
- package/hooks/features/columns/useGridColumns.js +28 -61
- package/hooks/features/selection/useGridSelection.js +1 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
- package/index.js +1 -1
- package/legacy/DataGrid/DataGrid.js +1 -11
- package/legacy/colDef/gridStringColDef.js +0 -1
- package/legacy/components/cell/GridActionsCell.js +1 -1
- package/legacy/components/cell/GridBooleanCell.js +1 -1
- package/legacy/components/cell/GridEditBooleanCell.js +1 -1
- package/legacy/components/cell/GridEditDateCell.js +1 -1
- package/legacy/components/cell/GridEditInputCell.js +1 -1
- package/legacy/components/cell/GridEditSingleSelectCell.js +1 -1
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/legacy/components/containers/GridRootStyles.js +2 -1
- package/legacy/components/panel/GridColumnsPanel.js +9 -23
- package/legacy/hooks/features/columns/gridColumnsUtils.js +22 -94
- package/legacy/hooks/features/columns/useGridColumns.js +27 -60
- package/legacy/hooks/features/selection/useGridSelection.js +1 -1
- package/legacy/index.js +1 -1
- package/legacy/models/events/index.js +1 -2
- package/legacy/models/params/index.js +0 -1
- package/models/api/gridCoreApi.d.ts +2 -2
- package/models/colDef/gridColDef.d.ts +0 -12
- package/models/events/gridEventListener.d.ts +2 -3
- package/models/events/gridEventLookup.d.ts +2 -10
- package/models/events/gridEventPublisher.d.ts +9 -10
- package/models/events/index.d.ts +0 -1
- package/models/events/index.js +1 -2
- package/models/gridApiCaches.d.ts +0 -2
- package/models/params/gridEditCellParams.d.ts +2 -2
- package/models/params/index.d.ts +0 -1
- package/models/params/index.js +0 -1
- package/models/props/DataGridProps.d.ts +0 -9
- package/modern/DataGrid/DataGrid.js +1 -11
- package/modern/colDef/gridStringColDef.js +0 -1
- package/modern/components/cell/GridActionsCell.js +1 -1
- package/modern/components/cell/GridBooleanCell.js +1 -1
- package/modern/components/cell/GridEditBooleanCell.js +1 -1
- package/modern/components/cell/GridEditDateCell.js +1 -1
- package/modern/components/cell/GridEditInputCell.js +1 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +1 -1
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/modern/components/containers/GridRootStyles.js +2 -0
- package/modern/components/panel/GridColumnsPanel.js +4 -18
- package/modern/hooks/features/columns/gridColumnsUtils.js +21 -92
- package/modern/hooks/features/columns/useGridColumns.js +21 -54
- package/modern/hooks/features/selection/useGridSelection.js +1 -1
- package/modern/index.js +1 -1
- package/modern/models/events/index.js +1 -2
- package/modern/models/params/index.js +0 -1
- package/node/DataGrid/DataGrid.js +1 -11
- package/node/colDef/gridStringColDef.js +0 -1
- package/node/components/cell/GridActionsCell.js +1 -1
- package/node/components/cell/GridBooleanCell.js +1 -1
- package/node/components/cell/GridEditBooleanCell.js +1 -1
- package/node/components/cell/GridEditDateCell.js +1 -1
- package/node/components/cell/GridEditInputCell.js +1 -1
- package/node/components/cell/GridEditSingleSelectCell.js +1 -1
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/node/components/containers/GridRootStyles.js +2 -0
- package/node/components/panel/GridColumnsPanel.js +4 -18
- package/node/hooks/features/columns/gridColumnsUtils.js +20 -88
- package/node/hooks/features/columns/useGridColumns.js +29 -60
- package/node/hooks/features/selection/useGridSelection.js +1 -1
- package/node/index.js +1 -1
- package/node/models/events/index.js +0 -13
- package/node/models/params/index.js +0 -13
- package/package.json +3 -3
- package/legacy/models/events/gridEvents.js +0 -92
- package/legacy/models/params/gridColumnVisibilityChangeParams.js +0 -1
- package/models/events/gridEvents.d.ts +0 -91
- package/models/events/gridEvents.js +0 -92
- package/models/params/gridColumnVisibilityChangeParams.d.ts +0 -18
- package/models/params/gridColumnVisibilityChangeParams.js +0 -1
- package/modern/models/events/gridEvents.js +0 -92
- package/modern/models/params/gridColumnVisibilityChangeParams.js +0 -1
- package/node/models/events/gridEvents.js +0 -97
- package/node/models/params/gridColumnVisibilityChangeParams.js +0 -5
|
@@ -217,10 +217,11 @@ export const applyInitialState = (columnsState, initialState) => {
|
|
|
217
217
|
newColumnLookup[field] = newColDef;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
const newColumnsState = {
|
|
220
|
+
const newColumnsState = _extends({}, columnsState, {
|
|
221
221
|
all: newOrderedFields,
|
|
222
222
|
lookup: newColumnLookup
|
|
223
|
-
};
|
|
223
|
+
});
|
|
224
|
+
|
|
224
225
|
return newColumnsState;
|
|
225
226
|
};
|
|
226
227
|
/**
|
|
@@ -250,31 +251,32 @@ export const createColumnsState = ({
|
|
|
250
251
|
columnsToUpsert,
|
|
251
252
|
initialState,
|
|
252
253
|
columnTypes,
|
|
253
|
-
|
|
254
|
-
shouldRegenColumnVisibilityModelFromColumns,
|
|
254
|
+
columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef),
|
|
255
255
|
keepOnlyColumnsToUpsert = false
|
|
256
256
|
}) => {
|
|
257
257
|
const isInsideStateInitializer = !apiRef.current.state.columns;
|
|
258
|
-
let
|
|
258
|
+
let columnsState;
|
|
259
259
|
|
|
260
260
|
if (isInsideStateInitializer) {
|
|
261
|
-
|
|
261
|
+
columnsState = {
|
|
262
262
|
all: [],
|
|
263
|
-
lookup: {}
|
|
263
|
+
lookup: {},
|
|
264
|
+
columnVisibilityModel
|
|
264
265
|
};
|
|
265
266
|
} else {
|
|
266
267
|
const currentState = gridColumnsSelector(apiRef.current.state);
|
|
267
|
-
|
|
268
|
+
columnsState = {
|
|
268
269
|
all: keepOnlyColumnsToUpsert ? [] : [...currentState.all],
|
|
269
|
-
lookup: _extends({}, currentState.lookup)
|
|
270
|
-
|
|
270
|
+
lookup: _extends({}, currentState.lookup),
|
|
271
|
+
// Will be cleaned later if keepOnlyColumnsToUpsert=true
|
|
272
|
+
columnVisibilityModel
|
|
271
273
|
};
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
let columnsToKeep = {};
|
|
275
277
|
|
|
276
278
|
if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
|
|
277
|
-
columnsToKeep = Object.keys(
|
|
279
|
+
columnsToKeep = Object.keys(columnsState.lookup).reduce((acc, key) => _extends({}, acc, {
|
|
278
280
|
[key]: false
|
|
279
281
|
}), {});
|
|
280
282
|
}
|
|
@@ -286,7 +288,7 @@ export const createColumnsState = ({
|
|
|
286
288
|
} = newColumn;
|
|
287
289
|
columnsToUpsertLookup[field] = true;
|
|
288
290
|
columnsToKeep[field] = true;
|
|
289
|
-
let existingState =
|
|
291
|
+
let existingState = columnsState.lookup[field];
|
|
290
292
|
|
|
291
293
|
if (existingState == null) {
|
|
292
294
|
// New Column
|
|
@@ -295,9 +297,9 @@ export const createColumnsState = ({
|
|
|
295
297
|
field,
|
|
296
298
|
hasBeenResized: false
|
|
297
299
|
});
|
|
298
|
-
|
|
300
|
+
columnsState.all.push(field);
|
|
299
301
|
} else if (keepOnlyColumnsToUpsert) {
|
|
300
|
-
|
|
302
|
+
columnsState.all.push(field);
|
|
301
303
|
}
|
|
302
304
|
|
|
303
305
|
let hasBeenResized = existingState.hasBeenResized;
|
|
@@ -310,95 +312,22 @@ export const createColumnsState = ({
|
|
|
310
312
|
}
|
|
311
313
|
}
|
|
312
314
|
});
|
|
313
|
-
|
|
314
|
-
hide: newColumn.hide == null ? false : newColumn.hide
|
|
315
|
-
}, newColumn, {
|
|
315
|
+
columnsState.lookup[field] = _extends({}, existingState, newColumn, {
|
|
316
316
|
hasBeenResized
|
|
317
317
|
});
|
|
318
318
|
});
|
|
319
319
|
|
|
320
320
|
if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
|
|
321
|
-
Object.keys(
|
|
321
|
+
Object.keys(columnsState.lookup).forEach(field => {
|
|
322
322
|
if (!columnsToKeep[field]) {
|
|
323
|
-
delete
|
|
323
|
+
delete columnsState.lookup[field];
|
|
324
324
|
}
|
|
325
325
|
});
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
const columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsStateWithoutColumnVisibilityModel); // TODO v6: remove the sync between the columns `hide` option and the model.
|
|
331
|
-
|
|
332
|
-
let columnVisibilityModel = {};
|
|
333
|
-
|
|
334
|
-
if (shouldRegenColumnVisibilityModelFromColumns) {
|
|
335
|
-
let hasModelChanged = false;
|
|
336
|
-
|
|
337
|
-
const newColumnVisibilityModel = _extends({}, currentColumnVisibilityModel);
|
|
338
|
-
|
|
339
|
-
if (isInsideStateInitializer) {
|
|
340
|
-
columnsStateWithPreProcessing.all.forEach(field => {
|
|
341
|
-
newColumnVisibilityModel[field] = !columnsStateWithoutColumnVisibilityModel.lookup[field].hide;
|
|
342
|
-
});
|
|
343
|
-
} else if (keepOnlyColumnsToUpsert) {
|
|
344
|
-
// At this point, `keepOnlyColumnsToUpsert` has a new meaning: keep the columns
|
|
345
|
-
// passed via `columnToUpsert` + columns added by the pre-processors. We do the following
|
|
346
|
-
// cleanup because a given column may have been removed from the `columns` prop but it still
|
|
347
|
-
// exists in the state.
|
|
348
|
-
Object.keys(newColumnVisibilityModel).forEach(field => {
|
|
349
|
-
if (!columnsStateWithPreProcessing.lookup[field]) {
|
|
350
|
-
delete newColumnVisibilityModel[field];
|
|
351
|
-
hasModelChanged = true;
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
columnsStateWithPreProcessing.all.forEach(field => {
|
|
357
|
-
// If neither the `columnsToUpsert` nor the pre-processors updated the column,
|
|
358
|
-
// Then we don't want to update the visibility status of the column in the model.
|
|
359
|
-
if (!columnsToUpsertLookup[field] && columnsLookupBeforePreProcessing[field] === columnsStateWithPreProcessing.lookup[field]) {
|
|
360
|
-
return;
|
|
361
|
-
} // We always assume that a column not in the model is visible by default. However, there's an
|
|
362
|
-
// edge case where the column is not in the model but it also doesn't exist in the `columns`
|
|
363
|
-
// prop, meaning that the column is being added. In that case, we assume that the column was
|
|
364
|
-
// not visible before for it be added to the model.
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
let isVisibleBefore = currentColumnVisibilityModel[field];
|
|
368
|
-
|
|
369
|
-
if (isVisibleBefore === undefined) {
|
|
370
|
-
if (isInsideStateInitializer) {
|
|
371
|
-
isVisibleBefore = true;
|
|
372
|
-
} else {
|
|
373
|
-
const currentState = gridColumnsSelector(apiRef.current.state);
|
|
374
|
-
isVisibleBefore = !!currentState.lookup[field];
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
const isVisibleAfter = !columnsStateWithPreProcessing.lookup[field].hide;
|
|
379
|
-
|
|
380
|
-
if (isVisibleAfter !== isVisibleBefore) {
|
|
381
|
-
hasModelChanged = true;
|
|
382
|
-
newColumnVisibilityModel[field] = isVisibleAfter;
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
if (hasModelChanged || isInsideStateInitializer) {
|
|
387
|
-
columnVisibilityModel = newColumnVisibilityModel;
|
|
388
|
-
} else {
|
|
389
|
-
columnVisibilityModel = currentColumnVisibilityModel;
|
|
390
|
-
}
|
|
391
|
-
} else {
|
|
392
|
-
columnVisibilityModel = currentColumnVisibilityModel;
|
|
393
|
-
}
|
|
394
|
-
|
|
328
|
+
const columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsState);
|
|
395
329
|
const columnsStateWithPortableColumns = applyInitialState(columnsStateWithPreProcessing, initialState);
|
|
396
|
-
|
|
397
|
-
const columnsState = _extends({}, columnsStateWithPortableColumns, {
|
|
398
|
-
columnVisibilityModel
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
return hydrateColumnsWidth(columnsState, apiRef.current.getRootDimensions?.()?.viewportInnerSize.width ?? 0);
|
|
330
|
+
return hydrateColumnsWidth(columnsStateWithPortableColumns, apiRef.current.getRootDimensions?.()?.viewportInnerSize.width ?? 0);
|
|
402
331
|
};
|
|
403
332
|
export const mergeColumnsState = columnsState => state => _extends({}, state, {
|
|
404
333
|
columns: columnsState
|
|
@@ -3,24 +3,19 @@ import * as React from 'react';
|
|
|
3
3
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
4
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
5
5
|
import { gridColumnFieldsSelector, gridColumnDefinitionsSelector, gridColumnLookupSelector, gridColumnsMetaSelector, gridColumnsSelector, gridColumnVisibilityModelSelector, gridVisibleColumnDefinitionsSelector, gridColumnPositionsSelector } from './gridColumnsSelector';
|
|
6
|
-
import { useGridApiEventHandler
|
|
6
|
+
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
7
7
|
import { useGridRegisterPipeProcessor, useGridRegisterPipeApplier } from '../../core/pipeProcessing';
|
|
8
8
|
import { hydrateColumnsWidth, computeColumnTypes, createColumnsState, mergeColumnsState, COLUMNS_DIMENSION_PROPERTIES } from './gridColumnsUtils';
|
|
9
9
|
import { GridPreferencePanelsValue } from '../preferencesPanel';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
export const columnsStateInitializer = (state, props, apiRef) => {
|
|
12
|
-
const isUsingColumnVisibilityModel = !!props.columnVisibilityModel || !!props.initialState?.columns?.columnVisibilityModel;
|
|
13
|
-
apiRef.current.unstable_caches.columns = {
|
|
14
|
-
isUsingColumnVisibilityModel
|
|
15
|
-
};
|
|
16
12
|
const columnsTypes = computeColumnTypes(props.columnTypes);
|
|
17
13
|
const columnsState = createColumnsState({
|
|
18
14
|
apiRef,
|
|
19
15
|
columnTypes: columnsTypes,
|
|
20
16
|
columnsToUpsert: props.columns,
|
|
21
17
|
initialState: props.initialState?.columns,
|
|
22
|
-
|
|
23
|
-
currentColumnVisibilityModel: props.columnVisibilityModel ?? props.initialState?.columns?.columnVisibilityModel ?? {},
|
|
18
|
+
columnVisibilityModel: props.columnVisibilityModel ?? props.initialState?.columns?.columnVisibilityModel ?? {},
|
|
24
19
|
keepOnlyColumnsToUpsert: true
|
|
25
20
|
});
|
|
26
21
|
return _extends({}, state, {
|
|
@@ -77,8 +72,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
77
72
|
columnTypes,
|
|
78
73
|
columnsToUpsert: [],
|
|
79
74
|
initialState: undefined,
|
|
80
|
-
|
|
81
|
-
currentColumnVisibilityModel: model,
|
|
75
|
+
columnVisibilityModel: model,
|
|
82
76
|
keepOnlyColumnsToUpsert: false
|
|
83
77
|
})
|
|
84
78
|
}));
|
|
@@ -91,41 +85,21 @@ export function useGridColumns(apiRef, props) {
|
|
|
91
85
|
columnTypes,
|
|
92
86
|
columnsToUpsert: columns,
|
|
93
87
|
initialState: undefined,
|
|
94
|
-
shouldRegenColumnVisibilityModelFromColumns: true,
|
|
95
88
|
keepOnlyColumnsToUpsert: false
|
|
96
89
|
});
|
|
97
90
|
setGridColumnsState(columnsState);
|
|
98
91
|
}, [apiRef, setGridColumnsState, columnTypes]);
|
|
99
92
|
const updateColumn = React.useCallback(column => apiRef.current.updateColumns([column]), [apiRef]);
|
|
100
93
|
const setColumnVisibility = React.useCallback((field, isVisible) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// TODO v6: stop using the `hide` field even when the model is not defined
|
|
104
|
-
if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
|
|
105
|
-
const columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
|
|
106
|
-
const isCurrentlyVisible = columnVisibilityModel[field] ?? true;
|
|
107
|
-
|
|
108
|
-
if (isVisible !== isCurrentlyVisible) {
|
|
109
|
-
const newModel = _extends({}, columnVisibilityModel, {
|
|
110
|
-
[field]: isVisible
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
apiRef.current.setColumnVisibilityModel(newModel);
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
const column = apiRef.current.getColumn(field);
|
|
94
|
+
const columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
|
|
95
|
+
const isCurrentlyVisible = columnVisibilityModel[field] ?? true;
|
|
117
96
|
|
|
118
|
-
|
|
119
|
-
|
|
97
|
+
if (isVisible !== isCurrentlyVisible) {
|
|
98
|
+
const newModel = _extends({}, columnVisibilityModel, {
|
|
99
|
+
[field]: isVisible
|
|
120
100
|
});
|
|
121
101
|
|
|
122
|
-
apiRef.current.
|
|
123
|
-
const params = {
|
|
124
|
-
field,
|
|
125
|
-
colDef: newColumn,
|
|
126
|
-
isVisible
|
|
127
|
-
};
|
|
128
|
-
apiRef.current.publishEvent('columnVisibilityChange', params);
|
|
102
|
+
apiRef.current.setColumnVisibilityModel(newModel);
|
|
129
103
|
}
|
|
130
104
|
}, [apiRef]);
|
|
131
105
|
const setColumnIndex = React.useCallback((field, targetIndexPosition) => {
|
|
@@ -188,19 +162,16 @@ export function useGridColumns(apiRef, props) {
|
|
|
188
162
|
|
|
189
163
|
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
190
164
|
const columnsStateToExport = {};
|
|
191
|
-
|
|
192
|
-
if
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (shouldExportColumnVisibilityModel) {
|
|
202
|
-
columnsStateToExport.columnVisibilityModel = columnVisibilityModelToExport;
|
|
203
|
-
}
|
|
165
|
+
const columnVisibilityModelToExport = gridColumnVisibilityModelSelector(apiRef);
|
|
166
|
+
const shouldExportColumnVisibilityModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
167
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
168
|
+
props.columnVisibilityModel != null || // Always export if the model has been initialized
|
|
169
|
+
// TODO v6 Do a nullish check instead to export even if the initial model equals "{}"
|
|
170
|
+
Object.keys(props.initialState?.columns?.columnVisibilityModel ?? {}).length > 0 || // Always export if the model is not empty
|
|
171
|
+
Object.keys(columnVisibilityModelToExport).length > 0;
|
|
172
|
+
|
|
173
|
+
if (shouldExportColumnVisibilityModel) {
|
|
174
|
+
columnsStateToExport.columnVisibilityModel = columnVisibilityModelToExport;
|
|
204
175
|
}
|
|
205
176
|
|
|
206
177
|
columnsStateToExport.orderedFields = gridColumnFieldsSelector(apiRef);
|
|
@@ -231,7 +202,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
231
202
|
});
|
|
232
203
|
}, [apiRef, props.columnVisibilityModel, props.initialState?.columns]);
|
|
233
204
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
234
|
-
const columnVisibilityModelToImport =
|
|
205
|
+
const columnVisibilityModelToImport = context.stateToRestore.columns?.columnVisibilityModel;
|
|
235
206
|
const initialState = context.stateToRestore.columns;
|
|
236
207
|
|
|
237
208
|
if (columnVisibilityModelToImport == null && initialState == null) {
|
|
@@ -243,8 +214,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
243
214
|
columnTypes,
|
|
244
215
|
columnsToUpsert: [],
|
|
245
216
|
initialState,
|
|
246
|
-
|
|
247
|
-
currentColumnVisibilityModel: columnVisibilityModelToImport,
|
|
217
|
+
columnVisibilityModel: columnVisibilityModelToImport,
|
|
248
218
|
keepOnlyColumnsToUpsert: false
|
|
249
219
|
});
|
|
250
220
|
apiRef.current.setState(mergeColumnsState(columnsState));
|
|
@@ -280,7 +250,6 @@ export function useGridColumns(apiRef, props) {
|
|
|
280
250
|
};
|
|
281
251
|
|
|
282
252
|
useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleGridSizeChange);
|
|
283
|
-
useGridApiOptionHandler(apiRef, 'columnVisibilityChange', props.onColumnVisibilityChange);
|
|
284
253
|
/**
|
|
285
254
|
* APPLIERS
|
|
286
255
|
*/
|
|
@@ -292,7 +261,6 @@ export function useGridColumns(apiRef, props) {
|
|
|
292
261
|
columnTypes,
|
|
293
262
|
columnsToUpsert: [],
|
|
294
263
|
initialState: undefined,
|
|
295
|
-
shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
|
|
296
264
|
keepOnlyColumnsToUpsert: false
|
|
297
265
|
});
|
|
298
266
|
setGridColumnsState(columnsState);
|
|
@@ -322,7 +290,6 @@ export function useGridColumns(apiRef, props) {
|
|
|
322
290
|
columnTypes,
|
|
323
291
|
initialState: undefined,
|
|
324
292
|
// 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`
|
|
325
|
-
shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
|
|
326
293
|
columnsToUpsert: props.columns,
|
|
327
294
|
keepOnlyColumnsToUpsert: true
|
|
328
295
|
});
|
|
@@ -357,7 +357,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
357
357
|
return;
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
-
if (event.key
|
|
360
|
+
if (event.key === 'a' && (event.ctrlKey || event.metaKey)) {
|
|
361
361
|
event.preventDefault();
|
|
362
362
|
selectRows(apiRef.current.getAllRowIds(), true);
|
|
363
363
|
}
|
package/modern/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './gridColumnHeaderParams';
|
|
2
2
|
export * from './gridColumnOrderChangeParams';
|
|
3
3
|
export * from './gridColumnResizeParams';
|
|
4
|
-
export * from './gridColumnVisibilityChangeParams';
|
|
5
4
|
export * from './gridEditCellParams';
|
|
6
5
|
export * from './gridRowParams';
|
|
7
6
|
export * from './gridScrollParams';
|
|
@@ -498,16 +498,6 @@ DataGridRaw.propTypes = {
|
|
|
498
498
|
*/
|
|
499
499
|
onColumnOrderChange: _propTypes.default.func,
|
|
500
500
|
|
|
501
|
-
/**
|
|
502
|
-
* Callback fired when a column visibility changes.
|
|
503
|
-
* Only works when no `columnVisibilityModel` is provided and if we change the visibility of a single column at a time.
|
|
504
|
-
* @param {GridColumnVisibilityChangeParams} params With all properties from [[GridColumnVisibilityChangeParams]].
|
|
505
|
-
* @param {MuiEvent<{}>} event The event object.
|
|
506
|
-
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
507
|
-
* @deprecated Use `onColumnVisibilityModelChange` instead.
|
|
508
|
-
*/
|
|
509
|
-
onColumnVisibilityChange: _propTypes.default.func,
|
|
510
|
-
|
|
511
501
|
/**
|
|
512
502
|
* Callback fired when the column visibility model changes.
|
|
513
503
|
* @param {GridColumnVisibilityModel} model The new model.
|
|
@@ -744,7 +734,7 @@ DataGridRaw.propTypes = {
|
|
|
744
734
|
/**
|
|
745
735
|
* Set of rows of type [[GridRowsProp]].
|
|
746
736
|
*/
|
|
747
|
-
rows: _propTypes.default.
|
|
737
|
+
rows: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
748
738
|
|
|
749
739
|
/**
|
|
750
740
|
* Sets the type of space between rows added by `getRowSpacing`.
|
|
@@ -285,7 +285,7 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
|
|
|
285
285
|
/**
|
|
286
286
|
* The row model of the row that the current cell belongs to.
|
|
287
287
|
*/
|
|
288
|
-
row: _propTypes.default.
|
|
288
|
+
row: _propTypes.default.any.isRequired,
|
|
289
289
|
|
|
290
290
|
/**
|
|
291
291
|
* The node of the row that the current cell belongs to.
|
|
@@ -131,7 +131,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
|
|
|
131
131
|
/**
|
|
132
132
|
* The row model of the row that the current cell belongs to.
|
|
133
133
|
*/
|
|
134
|
-
row: _propTypes.default.
|
|
134
|
+
row: _propTypes.default.any.isRequired,
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* The node of the row that the current cell belongs to.
|
|
@@ -173,7 +173,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
|
|
|
173
173
|
/**
|
|
174
174
|
* The row model of the row that the current cell belongs to.
|
|
175
175
|
*/
|
|
176
|
-
row: _propTypes.default.
|
|
176
|
+
row: _propTypes.default.any.isRequired,
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* The node of the row that the current cell belongs to.
|
|
@@ -229,7 +229,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
|
|
|
229
229
|
/**
|
|
230
230
|
* The row model of the row that the current cell belongs to.
|
|
231
231
|
*/
|
|
232
|
-
row: _propTypes.default.
|
|
232
|
+
row: _propTypes.default.any.isRequired,
|
|
233
233
|
|
|
234
234
|
/**
|
|
235
235
|
* The node of the row that the current cell belongs to.
|
|
@@ -205,7 +205,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
205
205
|
/**
|
|
206
206
|
* The row model of the row that the current cell belongs to.
|
|
207
207
|
*/
|
|
208
|
-
row: _propTypes.default.
|
|
208
|
+
row: _propTypes.default.any,
|
|
209
209
|
|
|
210
210
|
/**
|
|
211
211
|
* The node of the row that the current cell belongs to.
|
|
@@ -276,7 +276,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
276
276
|
/**
|
|
277
277
|
* The row model of the row that the current cell belongs to.
|
|
278
278
|
*/
|
|
279
|
-
row: _propTypes.default.
|
|
279
|
+
row: _propTypes.default.any.isRequired,
|
|
280
280
|
|
|
281
281
|
/**
|
|
282
282
|
* The node of the row that the current cell belongs to.
|
|
@@ -198,7 +198,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
198
198
|
/**
|
|
199
199
|
* The row model of the row that the current cell belongs to.
|
|
200
200
|
*/
|
|
201
|
-
row: _propTypes.default.
|
|
201
|
+
row: _propTypes.default.any.isRequired,
|
|
202
202
|
|
|
203
203
|
/**
|
|
204
204
|
* The node of the row that the current cell belongs to.
|
|
@@ -136,6 +136,8 @@ const GridRootStyles = (0, _styles.styled)('div', {
|
|
|
136
136
|
height: '100%',
|
|
137
137
|
display: 'flex',
|
|
138
138
|
flexDirection: 'column',
|
|
139
|
+
overflowAnchor: 'none',
|
|
140
|
+
// Keep the same scrolling position
|
|
139
141
|
[`&.${_gridClasses.gridClasses.autoHeight}`]: {
|
|
140
142
|
height: 'auto',
|
|
141
143
|
[`& .${_gridClasses.gridClasses['row--lastVisible']} .${_gridClasses.gridClasses.cell}`]: {
|
|
@@ -130,25 +130,11 @@ function GridColumnsPanel(props) {
|
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
const toggleAllColumns = React.useCallback(isVisible => {
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.filter(col => col.hideable !== false).map(col => [col.field, false])));
|
|
139
|
-
} // TODO v6: Remove
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return apiRef.current.updateColumns(columns.map(col => {
|
|
143
|
-
if (col.hideable !== false) {
|
|
144
|
-
return {
|
|
145
|
-
field: col.field,
|
|
146
|
-
hide: !isVisible
|
|
147
|
-
};
|
|
148
|
-
}
|
|
133
|
+
if (isVisible) {
|
|
134
|
+
return apiRef.current.setColumnVisibilityModel({});
|
|
135
|
+
}
|
|
149
136
|
|
|
150
|
-
|
|
151
|
-
}));
|
|
137
|
+
return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.filter(col => col.hideable !== false).map(col => [col.field, false])));
|
|
152
138
|
}, [apiRef, columns]);
|
|
153
139
|
const handleSearchValueChange = React.useCallback(event => {
|
|
154
140
|
setSearchValue(event.target.value);
|