@mui/x-data-grid 5.17.5 → 6.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +297 -19
- package/DataGrid/DataGrid.js +1 -11
- package/DataGrid/useDataGridProps.js +4 -4
- package/colDef/gridStringColDef.js +0 -1
- package/components/DataGridVirtualScroller.js +5 -3
- package/components/GridRow.js +4 -3
- package/components/base/GridBody.js +1 -2
- package/components/base/GridOverlays.js +52 -12
- package/components/cell/GridActionsCell.js +1 -1
- package/components/cell/GridBooleanCell.js +3 -2
- 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.d.ts +2 -2
- package/components/columnSelection/GridCellCheckboxRenderer.js +2 -7
- package/components/containers/GridOverlay.js +0 -5
- package/components/containers/GridRootStyles.js +2 -0
- package/components/panel/GridColumnsPanel.js +4 -18
- package/constants/gridClasses.d.ts +8 -0
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +1 -1
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +1 -1
- 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/editRows/useGridCellEditing.new.js +2 -2
- package/hooks/features/editRows/useGridEditing.new.js +3 -2
- package/hooks/features/editRows/useGridEditing.old.js +2 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +2 -2
- package/hooks/features/export/useGridPrintExport.js +31 -17
- package/hooks/features/export/utils.js +1 -5
- package/hooks/features/filter/gridFilterSelector.js +2 -2
- package/hooks/features/filter/useGridFilter.js +6 -6
- package/hooks/features/pagination/gridPaginationSelector.js +2 -2
- package/hooks/features/rows/gridRowsInterfaces.d.ts +106 -0
- package/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
- package/hooks/features/rows/gridRowsSelector.d.ts +17 -7
- package/hooks/features/rows/gridRowsSelector.js +38 -6
- package/hooks/features/rows/gridRowsUtils.d.ts +16 -4
- package/hooks/features/rows/gridRowsUtils.js +222 -39
- package/hooks/features/rows/index.d.ts +3 -3
- package/hooks/features/rows/index.js +2 -2
- package/hooks/features/rows/useGridRows.js +161 -124
- package/hooks/features/rows/useGridRowsPreProcessors.js +78 -26
- package/hooks/features/selection/useGridSelection.js +3 -3
- package/hooks/features/sorting/gridSortingSelector.js +9 -4
- package/hooks/features/sorting/gridSortingState.d.ts +2 -2
- package/hooks/features/sorting/useGridSorting.js +9 -33
- package/hooks/features/virtualization/useGridVirtualScroller.js +4 -10
- package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +1 -0
- package/legacy/DataGrid/DataGrid.js +1 -11
- package/legacy/DataGrid/useDataGridProps.js +4 -4
- package/legacy/colDef/gridStringColDef.js +0 -1
- package/legacy/components/DataGridVirtualScroller.js +5 -3
- package/legacy/components/GridRow.js +4 -3
- package/legacy/components/base/GridBody.js +1 -2
- package/legacy/components/base/GridOverlays.js +54 -12
- package/legacy/components/cell/GridActionsCell.js +1 -1
- package/legacy/components/cell/GridBooleanCell.js +3 -2
- 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 +2 -7
- package/legacy/components/containers/GridOverlay.js +0 -5
- 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/editRows/useGridCellEditing.new.js +2 -2
- package/legacy/hooks/features/editRows/useGridEditing.new.js +3 -2
- package/legacy/hooks/features/editRows/useGridEditing.old.js +2 -1
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +2 -2
- package/legacy/hooks/features/export/useGridPrintExport.js +33 -20
- package/legacy/hooks/features/export/utils.js +1 -3
- package/legacy/hooks/features/filter/gridFilterSelector.js +2 -2
- package/legacy/hooks/features/filter/useGridFilter.js +6 -6
- package/legacy/hooks/features/pagination/gridPaginationSelector.js +2 -2
- package/legacy/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
- package/legacy/hooks/features/rows/gridRowsSelector.js +52 -9
- package/legacy/hooks/features/rows/gridRowsUtils.js +238 -46
- package/legacy/hooks/features/rows/index.js +2 -2
- package/legacy/hooks/features/rows/useGridRows.js +163 -134
- package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +81 -26
- package/legacy/hooks/features/selection/useGridSelection.js +3 -3
- package/legacy/hooks/features/sorting/gridSortingSelector.js +5 -2
- package/legacy/hooks/features/sorting/useGridSorting.js +11 -33
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +4 -10
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -0
- package/legacy/models/events/index.js +1 -2
- package/legacy/models/gridFeatureMode.js +1 -4
- package/legacy/models/params/index.js +0 -1
- package/models/api/gridCoreApi.d.ts +2 -2
- package/models/api/gridParamsApi.d.ts +2 -2
- package/models/api/gridRowApi.d.ts +7 -5
- package/models/colDef/gridColDef.d.ts +0 -12
- package/models/events/gridEventListener.d.ts +2 -3
- package/models/events/gridEventLookup.d.ts +5 -13
- 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 +1 -3
- package/models/gridFeatureMode.d.ts +0 -4
- package/models/gridFeatureMode.js +1 -4
- package/models/gridRows.d.ts +100 -30
- package/models/gridSortModel.d.ts +2 -2
- package/models/params/gridCellParams.d.ts +7 -11
- 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/DataGrid/useDataGridProps.js +4 -4
- package/modern/colDef/gridStringColDef.js +0 -1
- package/modern/components/DataGridVirtualScroller.js +5 -3
- package/modern/components/GridRow.js +4 -3
- package/modern/components/base/GridBody.js +1 -2
- package/modern/components/base/GridOverlays.js +52 -12
- package/modern/components/cell/GridActionsCell.js +1 -1
- package/modern/components/cell/GridBooleanCell.js +3 -2
- 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 +2 -7
- package/modern/components/containers/GridOverlay.js +0 -5
- 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/editRows/useGridCellEditing.new.js +2 -2
- package/modern/hooks/features/editRows/useGridEditing.new.js +3 -2
- package/modern/hooks/features/editRows/useGridEditing.old.js +2 -1
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +2 -2
- package/modern/hooks/features/export/useGridPrintExport.js +30 -16
- package/modern/hooks/features/export/utils.js +1 -1
- package/modern/hooks/features/filter/gridFilterSelector.js +2 -2
- package/modern/hooks/features/filter/useGridFilter.js +6 -6
- package/modern/hooks/features/pagination/gridPaginationSelector.js +2 -2
- package/{legacy/models/params/gridColumnVisibilityChangeParams.js → modern/hooks/features/rows/gridRowsInterfaces.js} +0 -0
- package/modern/hooks/features/rows/gridRowsSelector.js +28 -6
- package/modern/hooks/features/rows/gridRowsUtils.js +220 -37
- package/modern/hooks/features/rows/index.js +2 -2
- package/modern/hooks/features/rows/useGridRows.js +158 -121
- package/modern/hooks/features/rows/useGridRowsPreProcessors.js +78 -26
- package/modern/hooks/features/selection/useGridSelection.js +3 -3
- package/modern/hooks/features/sorting/gridSortingSelector.js +3 -2
- package/modern/hooks/features/sorting/useGridSorting.js +9 -33
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +4 -10
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/models/events/index.js +1 -2
- package/modern/models/gridFeatureMode.js +1 -4
- package/modern/models/params/index.js +0 -1
- package/node/DataGrid/DataGrid.js +1 -11
- package/node/DataGrid/useDataGridProps.js +3 -3
- package/node/colDef/gridStringColDef.js +0 -1
- package/node/components/DataGridVirtualScroller.js +5 -3
- package/node/components/GridRow.js +3 -2
- package/node/components/base/GridBody.js +1 -3
- package/node/components/base/GridOverlays.js +57 -12
- package/node/components/cell/GridActionsCell.js +1 -1
- package/node/components/cell/GridBooleanCell.js +4 -2
- 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 +2 -7
- package/node/components/containers/GridOverlay.js +0 -5
- 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/editRows/useGridCellEditing.new.js +1 -1
- package/node/hooks/features/editRows/useGridEditing.new.js +4 -2
- package/node/hooks/features/editRows/useGridEditing.old.js +3 -1
- package/node/hooks/features/editRows/useGridRowEditing.new.js +1 -1
- package/node/hooks/features/export/useGridPrintExport.js +31 -17
- package/node/hooks/features/export/utils.js +1 -5
- package/node/hooks/features/filter/gridFilterSelector.js +1 -1
- package/node/hooks/features/filter/useGridFilter.js +5 -6
- package/node/hooks/features/pagination/gridPaginationSelector.js +1 -1
- package/node/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
- package/node/hooks/features/rows/gridRowsSelector.js +43 -10
- package/node/hooks/features/rows/gridRowsUtils.js +239 -40
- package/node/hooks/features/rows/index.js +23 -9
- package/node/hooks/features/rows/useGridRows.js +161 -122
- package/node/hooks/features/rows/useGridRowsPreProcessors.js +81 -26
- package/node/hooks/features/selection/useGridSelection.js +3 -3
- package/node/hooks/features/sorting/gridSortingSelector.js +9 -4
- package/node/hooks/features/sorting/useGridSorting.js +9 -33
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -10
- package/node/index.js +1 -1
- package/node/internals/index.js +14 -2
- package/node/models/events/index.js +0 -13
- package/node/models/gridFeatureMode.js +1 -7
- package/node/models/params/index.js +0 -13
- package/package.json +3 -3
- package/hooks/features/rows/gridRowsState.d.ts +0 -60
- package/legacy/models/events/gridEvents.js +0 -92
- 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/hooks/features/rows/gridRowsState.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
|
@@ -239,10 +239,10 @@ const applyInitialState = (columnsState, initialState) => {
|
|
|
239
239
|
newColumnLookup[field] = newColDef;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
const newColumnsState = {
|
|
242
|
+
const newColumnsState = (0, _extends2.default)({}, columnsState, {
|
|
243
243
|
all: newOrderedFields,
|
|
244
244
|
lookup: newColumnLookup
|
|
245
|
-
};
|
|
245
|
+
});
|
|
246
246
|
return newColumnsState;
|
|
247
247
|
};
|
|
248
248
|
/**
|
|
@@ -278,33 +278,34 @@ const createColumnsState = ({
|
|
|
278
278
|
columnsToUpsert,
|
|
279
279
|
initialState,
|
|
280
280
|
columnTypes,
|
|
281
|
-
|
|
282
|
-
shouldRegenColumnVisibilityModelFromColumns,
|
|
281
|
+
columnVisibilityModel = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef),
|
|
283
282
|
keepOnlyColumnsToUpsert = false
|
|
284
283
|
}) => {
|
|
285
284
|
var _apiRef$current$getRo, _apiRef$current$getRo2, _apiRef$current, _apiRef$current$getRo3;
|
|
286
285
|
|
|
287
286
|
const isInsideStateInitializer = !apiRef.current.state.columns;
|
|
288
|
-
let
|
|
287
|
+
let columnsState;
|
|
289
288
|
|
|
290
289
|
if (isInsideStateInitializer) {
|
|
291
|
-
|
|
290
|
+
columnsState = {
|
|
292
291
|
all: [],
|
|
293
|
-
lookup: {}
|
|
292
|
+
lookup: {},
|
|
293
|
+
columnVisibilityModel
|
|
294
294
|
};
|
|
295
295
|
} else {
|
|
296
296
|
const currentState = (0, _gridColumnsSelector.gridColumnsSelector)(apiRef.current.state);
|
|
297
|
-
|
|
297
|
+
columnsState = {
|
|
298
298
|
all: keepOnlyColumnsToUpsert ? [] : [...currentState.all],
|
|
299
|
-
lookup: (0, _extends2.default)({}, currentState.lookup)
|
|
300
|
-
|
|
299
|
+
lookup: (0, _extends2.default)({}, currentState.lookup),
|
|
300
|
+
// Will be cleaned later if keepOnlyColumnsToUpsert=true
|
|
301
|
+
columnVisibilityModel
|
|
301
302
|
};
|
|
302
303
|
}
|
|
303
304
|
|
|
304
305
|
let columnsToKeep = {};
|
|
305
306
|
|
|
306
307
|
if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
|
|
307
|
-
columnsToKeep = Object.keys(
|
|
308
|
+
columnsToKeep = Object.keys(columnsState.lookup).reduce((acc, key) => (0, _extends2.default)({}, acc, {
|
|
308
309
|
[key]: false
|
|
309
310
|
}), {});
|
|
310
311
|
}
|
|
@@ -316,7 +317,7 @@ const createColumnsState = ({
|
|
|
316
317
|
} = newColumn;
|
|
317
318
|
columnsToUpsertLookup[field] = true;
|
|
318
319
|
columnsToKeep[field] = true;
|
|
319
|
-
let existingState =
|
|
320
|
+
let existingState = columnsState.lookup[field];
|
|
320
321
|
|
|
321
322
|
if (existingState == null) {
|
|
322
323
|
// New Column
|
|
@@ -325,9 +326,9 @@ const createColumnsState = ({
|
|
|
325
326
|
field,
|
|
326
327
|
hasBeenResized: false
|
|
327
328
|
});
|
|
328
|
-
|
|
329
|
+
columnsState.all.push(field);
|
|
329
330
|
} else if (keepOnlyColumnsToUpsert) {
|
|
330
|
-
|
|
331
|
+
columnsState.all.push(field);
|
|
331
332
|
}
|
|
332
333
|
|
|
333
334
|
let hasBeenResized = existingState.hasBeenResized;
|
|
@@ -340,91 +341,22 @@ const createColumnsState = ({
|
|
|
340
341
|
}
|
|
341
342
|
}
|
|
342
343
|
});
|
|
343
|
-
|
|
344
|
-
hide: newColumn.hide == null ? false : newColumn.hide
|
|
345
|
-
}, newColumn, {
|
|
344
|
+
columnsState.lookup[field] = (0, _extends2.default)({}, existingState, newColumn, {
|
|
346
345
|
hasBeenResized
|
|
347
346
|
});
|
|
348
347
|
});
|
|
349
348
|
|
|
350
349
|
if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
|
|
351
|
-
Object.keys(
|
|
350
|
+
Object.keys(columnsState.lookup).forEach(field => {
|
|
352
351
|
if (!columnsToKeep[field]) {
|
|
353
|
-
delete
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
const columnsLookupBeforePreProcessing = (0, _extends2.default)({}, columnsStateWithoutColumnVisibilityModel.lookup);
|
|
359
|
-
const columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsStateWithoutColumnVisibilityModel); // TODO v6: remove the sync between the columns `hide` option and the model.
|
|
360
|
-
|
|
361
|
-
let columnVisibilityModel = {};
|
|
362
|
-
|
|
363
|
-
if (shouldRegenColumnVisibilityModelFromColumns) {
|
|
364
|
-
let hasModelChanged = false;
|
|
365
|
-
const newColumnVisibilityModel = (0, _extends2.default)({}, currentColumnVisibilityModel);
|
|
366
|
-
|
|
367
|
-
if (isInsideStateInitializer) {
|
|
368
|
-
columnsStateWithPreProcessing.all.forEach(field => {
|
|
369
|
-
newColumnVisibilityModel[field] = !columnsStateWithoutColumnVisibilityModel.lookup[field].hide;
|
|
370
|
-
});
|
|
371
|
-
} else if (keepOnlyColumnsToUpsert) {
|
|
372
|
-
// At this point, `keepOnlyColumnsToUpsert` has a new meaning: keep the columns
|
|
373
|
-
// passed via `columnToUpsert` + columns added by the pre-processors. We do the following
|
|
374
|
-
// cleanup because a given column may have been removed from the `columns` prop but it still
|
|
375
|
-
// exists in the state.
|
|
376
|
-
Object.keys(newColumnVisibilityModel).forEach(field => {
|
|
377
|
-
if (!columnsStateWithPreProcessing.lookup[field]) {
|
|
378
|
-
delete newColumnVisibilityModel[field];
|
|
379
|
-
hasModelChanged = true;
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
columnsStateWithPreProcessing.all.forEach(field => {
|
|
385
|
-
// If neither the `columnsToUpsert` nor the pre-processors updated the column,
|
|
386
|
-
// Then we don't want to update the visibility status of the column in the model.
|
|
387
|
-
if (!columnsToUpsertLookup[field] && columnsLookupBeforePreProcessing[field] === columnsStateWithPreProcessing.lookup[field]) {
|
|
388
|
-
return;
|
|
389
|
-
} // We always assume that a column not in the model is visible by default. However, there's an
|
|
390
|
-
// edge case where the column is not in the model but it also doesn't exist in the `columns`
|
|
391
|
-
// prop, meaning that the column is being added. In that case, we assume that the column was
|
|
392
|
-
// not visible before for it be added to the model.
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
let isVisibleBefore = currentColumnVisibilityModel[field];
|
|
396
|
-
|
|
397
|
-
if (isVisibleBefore === undefined) {
|
|
398
|
-
if (isInsideStateInitializer) {
|
|
399
|
-
isVisibleBefore = true;
|
|
400
|
-
} else {
|
|
401
|
-
const currentState = (0, _gridColumnsSelector.gridColumnsSelector)(apiRef.current.state);
|
|
402
|
-
isVisibleBefore = !!currentState.lookup[field];
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
const isVisibleAfter = !columnsStateWithPreProcessing.lookup[field].hide;
|
|
407
|
-
|
|
408
|
-
if (isVisibleAfter !== isVisibleBefore) {
|
|
409
|
-
hasModelChanged = true;
|
|
410
|
-
newColumnVisibilityModel[field] = isVisibleAfter;
|
|
352
|
+
delete columnsState.lookup[field];
|
|
411
353
|
}
|
|
412
354
|
});
|
|
413
|
-
|
|
414
|
-
if (hasModelChanged || isInsideStateInitializer) {
|
|
415
|
-
columnVisibilityModel = newColumnVisibilityModel;
|
|
416
|
-
} else {
|
|
417
|
-
columnVisibilityModel = currentColumnVisibilityModel;
|
|
418
|
-
}
|
|
419
|
-
} else {
|
|
420
|
-
columnVisibilityModel = currentColumnVisibilityModel;
|
|
421
355
|
}
|
|
422
356
|
|
|
357
|
+
const columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsState);
|
|
423
358
|
const columnsStateWithPortableColumns = applyInitialState(columnsStateWithPreProcessing, initialState);
|
|
424
|
-
|
|
425
|
-
columnVisibilityModel
|
|
426
|
-
});
|
|
427
|
-
return hydrateColumnsWidth(columnsState, (_apiRef$current$getRo = (_apiRef$current$getRo2 = (_apiRef$current = apiRef.current).getRootDimensions) == null ? void 0 : (_apiRef$current$getRo3 = _apiRef$current$getRo2.call(_apiRef$current)) == null ? void 0 : _apiRef$current$getRo3.viewportInnerSize.width) != null ? _apiRef$current$getRo : 0);
|
|
359
|
+
return hydrateColumnsWidth(columnsStateWithPortableColumns, (_apiRef$current$getRo = (_apiRef$current$getRo2 = (_apiRef$current = apiRef.current).getRootDimensions) == null ? void 0 : (_apiRef$current$getRo3 = _apiRef$current$getRo2.call(_apiRef$current)) == null ? void 0 : _apiRef$current$getRo3.viewportInnerSize.width) != null ? _apiRef$current$getRo : 0);
|
|
428
360
|
};
|
|
429
361
|
|
|
430
362
|
exports.createColumnsState = createColumnsState;
|
|
@@ -33,20 +33,15 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
33
33
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
34
34
|
|
|
35
35
|
const columnsStateInitializer = (state, props, apiRef) => {
|
|
36
|
-
var _props$initialState,
|
|
36
|
+
var _props$initialState, _ref, _props$columnVisibili, _props$initialState2, _props$initialState2$;
|
|
37
37
|
|
|
38
|
-
const isUsingColumnVisibilityModel = !!props.columnVisibilityModel || !!((_props$initialState = props.initialState) != null && (_props$initialState$c = _props$initialState.columns) != null && _props$initialState$c.columnVisibilityModel);
|
|
39
|
-
apiRef.current.unstable_caches.columns = {
|
|
40
|
-
isUsingColumnVisibilityModel
|
|
41
|
-
};
|
|
42
38
|
const columnsTypes = (0, _gridColumnsUtils.computeColumnTypes)(props.columnTypes);
|
|
43
39
|
const columnsState = (0, _gridColumnsUtils.createColumnsState)({
|
|
44
40
|
apiRef,
|
|
45
41
|
columnTypes: columnsTypes,
|
|
46
42
|
columnsToUpsert: props.columns,
|
|
47
|
-
initialState: (_props$
|
|
48
|
-
|
|
49
|
-
currentColumnVisibilityModel: (_ref = (_props$columnVisibili = props.columnVisibilityModel) != null ? _props$columnVisibili : (_props$initialState3 = props.initialState) == null ? void 0 : (_props$initialState3$ = _props$initialState3.columns) == null ? void 0 : _props$initialState3$.columnVisibilityModel) != null ? _ref : {},
|
|
43
|
+
initialState: (_props$initialState = props.initialState) == null ? void 0 : _props$initialState.columns,
|
|
44
|
+
columnVisibilityModel: (_ref = (_props$columnVisibili = props.columnVisibilityModel) != null ? _props$columnVisibili : (_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.columns) == null ? void 0 : _props$initialState2$.columnVisibilityModel) != null ? _ref : {},
|
|
50
45
|
keepOnlyColumnsToUpsert: true
|
|
51
46
|
});
|
|
52
47
|
return (0, _extends2.default)({}, state, {
|
|
@@ -63,7 +58,7 @@ const columnsStateInitializer = (state, props, apiRef) => {
|
|
|
63
58
|
exports.columnsStateInitializer = columnsStateInitializer;
|
|
64
59
|
|
|
65
60
|
function useGridColumns(apiRef, props) {
|
|
66
|
-
var _props$
|
|
61
|
+
var _props$initialState4, _props$componentsProp2;
|
|
67
62
|
|
|
68
63
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridColumns');
|
|
69
64
|
const columnTypes = React.useMemo(() => (0, _gridColumnsUtils.computeColumnTypes)(props.columnTypes), [props.columnTypes]);
|
|
@@ -108,8 +103,7 @@ function useGridColumns(apiRef, props) {
|
|
|
108
103
|
columnTypes,
|
|
109
104
|
columnsToUpsert: [],
|
|
110
105
|
initialState: undefined,
|
|
111
|
-
|
|
112
|
-
currentColumnVisibilityModel: model,
|
|
106
|
+
columnVisibilityModel: model,
|
|
113
107
|
keepOnlyColumnsToUpsert: false
|
|
114
108
|
})
|
|
115
109
|
}));
|
|
@@ -122,40 +116,22 @@ function useGridColumns(apiRef, props) {
|
|
|
122
116
|
columnTypes,
|
|
123
117
|
columnsToUpsert: columns,
|
|
124
118
|
initialState: undefined,
|
|
125
|
-
shouldRegenColumnVisibilityModelFromColumns: true,
|
|
126
119
|
keepOnlyColumnsToUpsert: false
|
|
127
120
|
});
|
|
128
121
|
setGridColumnsState(columnsState);
|
|
129
122
|
}, [apiRef, setGridColumnsState, columnTypes]);
|
|
130
123
|
const updateColumn = React.useCallback(column => apiRef.current.updateColumns([column]), [apiRef]);
|
|
131
124
|
const setColumnVisibility = React.useCallback((field, isVisible) => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (isVisible !== isCurrentlyVisible) {
|
|
142
|
-
const newModel = (0, _extends2.default)({}, columnVisibilityModel, {
|
|
143
|
-
[field]: isVisible
|
|
144
|
-
});
|
|
145
|
-
apiRef.current.setColumnVisibilityModel(newModel);
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
const column = apiRef.current.getColumn(field);
|
|
149
|
-
const newColumn = (0, _extends2.default)({}, column, {
|
|
150
|
-
hide: !isVisible
|
|
125
|
+
var _columnVisibilityMode;
|
|
126
|
+
|
|
127
|
+
const columnVisibilityModel = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef);
|
|
128
|
+
const isCurrentlyVisible = (_columnVisibilityMode = columnVisibilityModel[field]) != null ? _columnVisibilityMode : true;
|
|
129
|
+
|
|
130
|
+
if (isVisible !== isCurrentlyVisible) {
|
|
131
|
+
const newModel = (0, _extends2.default)({}, columnVisibilityModel, {
|
|
132
|
+
[field]: isVisible
|
|
151
133
|
});
|
|
152
|
-
apiRef.current.
|
|
153
|
-
const params = {
|
|
154
|
-
field,
|
|
155
|
-
colDef: newColumn,
|
|
156
|
-
isVisible
|
|
157
|
-
};
|
|
158
|
-
apiRef.current.publishEvent('columnVisibilityChange', params);
|
|
134
|
+
apiRef.current.setColumnVisibilityModel(newModel);
|
|
159
135
|
}
|
|
160
136
|
}, [apiRef]);
|
|
161
137
|
const setColumnIndex = React.useCallback((field, targetIndexPosition) => {
|
|
@@ -215,22 +191,19 @@ function useGridColumns(apiRef, props) {
|
|
|
215
191
|
*/
|
|
216
192
|
|
|
217
193
|
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
|
|
221
|
-
var _props$initialState$c2, _props$initialState4, _props$initialState4$;
|
|
222
|
-
|
|
223
|
-
const columnVisibilityModelToExport = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef);
|
|
224
|
-
const shouldExportColumnVisibilityModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
225
|
-
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
226
|
-
props.columnVisibilityModel != null || // Always export if the model has been initialized
|
|
227
|
-
// TODO v6 Do a nullish check instead to export even if the initial model equals "{}"
|
|
228
|
-
Object.keys((_props$initialState$c2 = (_props$initialState4 = props.initialState) == null ? void 0 : (_props$initialState4$ = _props$initialState4.columns) == null ? void 0 : _props$initialState4$.columnVisibilityModel) != null ? _props$initialState$c2 : {}).length > 0 || // Always export if the model is not empty
|
|
229
|
-
Object.keys(columnVisibilityModelToExport).length > 0;
|
|
194
|
+
var _props$initialState$c, _props$initialState3, _props$initialState3$;
|
|
230
195
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
196
|
+
const columnsStateToExport = {};
|
|
197
|
+
const columnVisibilityModelToExport = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef);
|
|
198
|
+
const shouldExportColumnVisibilityModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
199
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
200
|
+
props.columnVisibilityModel != null || // Always export if the model has been initialized
|
|
201
|
+
// TODO v6 Do a nullish check instead to export even if the initial model equals "{}"
|
|
202
|
+
Object.keys((_props$initialState$c = (_props$initialState3 = props.initialState) == null ? void 0 : (_props$initialState3$ = _props$initialState3.columns) == null ? void 0 : _props$initialState3$.columnVisibilityModel) != null ? _props$initialState$c : {}).length > 0 || // Always export if the model is not empty
|
|
203
|
+
Object.keys(columnVisibilityModelToExport).length > 0;
|
|
204
|
+
|
|
205
|
+
if (shouldExportColumnVisibilityModel) {
|
|
206
|
+
columnsStateToExport.columnVisibilityModel = columnVisibilityModelToExport;
|
|
234
207
|
}
|
|
235
208
|
|
|
236
209
|
columnsStateToExport.orderedFields = (0, _gridColumnsSelector.gridColumnFieldsSelector)(apiRef);
|
|
@@ -261,11 +234,11 @@ function useGridColumns(apiRef, props) {
|
|
|
261
234
|
return (0, _extends2.default)({}, prevState, {
|
|
262
235
|
columns: columnsStateToExport
|
|
263
236
|
});
|
|
264
|
-
}, [apiRef, props.columnVisibilityModel, (_props$
|
|
237
|
+
}, [apiRef, props.columnVisibilityModel, (_props$initialState4 = props.initialState) == null ? void 0 : _props$initialState4.columns]);
|
|
265
238
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
266
239
|
var _context$stateToResto;
|
|
267
240
|
|
|
268
|
-
const columnVisibilityModelToImport =
|
|
241
|
+
const columnVisibilityModelToImport = (_context$stateToResto = context.stateToRestore.columns) == null ? void 0 : _context$stateToResto.columnVisibilityModel;
|
|
269
242
|
const initialState = context.stateToRestore.columns;
|
|
270
243
|
|
|
271
244
|
if (columnVisibilityModelToImport == null && initialState == null) {
|
|
@@ -277,8 +250,7 @@ function useGridColumns(apiRef, props) {
|
|
|
277
250
|
columnTypes,
|
|
278
251
|
columnsToUpsert: [],
|
|
279
252
|
initialState,
|
|
280
|
-
|
|
281
|
-
currentColumnVisibilityModel: columnVisibilityModelToImport,
|
|
253
|
+
columnVisibilityModel: columnVisibilityModelToImport,
|
|
282
254
|
keepOnlyColumnsToUpsert: false
|
|
283
255
|
});
|
|
284
256
|
apiRef.current.setState((0, _gridColumnsUtils.mergeColumnsState)(columnsState));
|
|
@@ -316,7 +288,6 @@ function useGridColumns(apiRef, props) {
|
|
|
316
288
|
};
|
|
317
289
|
|
|
318
290
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'viewportInnerSizeChange', handleGridSizeChange);
|
|
319
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'columnVisibilityChange', props.onColumnVisibilityChange);
|
|
320
291
|
/**
|
|
321
292
|
* APPLIERS
|
|
322
293
|
*/
|
|
@@ -328,7 +299,6 @@ function useGridColumns(apiRef, props) {
|
|
|
328
299
|
columnTypes,
|
|
329
300
|
columnsToUpsert: [],
|
|
330
301
|
initialState: undefined,
|
|
331
|
-
shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
|
|
332
302
|
keepOnlyColumnsToUpsert: false
|
|
333
303
|
});
|
|
334
304
|
setGridColumnsState(columnsState);
|
|
@@ -358,7 +328,6 @@ function useGridColumns(apiRef, props) {
|
|
|
358
328
|
columnTypes,
|
|
359
329
|
initialState: undefined,
|
|
360
330
|
// 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`
|
|
361
|
-
shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
|
|
362
331
|
columnsToUpsert: props.columns,
|
|
363
332
|
keepOnlyColumnsToUpsert: true
|
|
364
333
|
});
|
|
@@ -468,7 +468,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
468
468
|
}
|
|
469
469
|
}, [cellModesModelProp, updateCellModesModel]);
|
|
470
470
|
React.useEffect(() => {
|
|
471
|
-
const idToIdLookup = (0, _gridRowsSelector.
|
|
471
|
+
const idToIdLookup = (0, _gridRowsSelector.gridRowsDataRowIdToIdLookupSelector)(apiRef); // Update the ref here because updateStateToStopCellEditMode may change it later
|
|
472
472
|
|
|
473
473
|
const copyOfPrevCellModes = prevCellModesModel.current;
|
|
474
474
|
prevCellModesModel.current = (0, _utils2.deepClone)(cellModesModel); // Do a deep-clone because the attributes might be changed later
|
|
@@ -21,6 +21,8 @@ var _useGridRowEditing = require("./useGridRowEditing.new");
|
|
|
21
21
|
|
|
22
22
|
var _gridEditRowsSelector = require("./gridEditRowsSelector");
|
|
23
23
|
|
|
24
|
+
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
25
|
+
|
|
24
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
27
|
|
|
26
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -39,7 +41,7 @@ const useGridEditing = (apiRef, props) => {
|
|
|
39
41
|
isCellEditable: isCellEditableProp
|
|
40
42
|
} = props;
|
|
41
43
|
const isCellEditable = React.useCallback(params => {
|
|
42
|
-
if (params.rowNode
|
|
44
|
+
if ((0, _gridRowsUtils.isAutoGeneratedRow)(params.rowNode)) {
|
|
43
45
|
return false;
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -55,7 +57,7 @@ const useGridEditing = (apiRef, props) => {
|
|
|
55
57
|
return isCellEditableProp(params);
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
if (params.rowNode.
|
|
60
|
+
if (params.rowNode.type === 'pinnedRow') {
|
|
59
61
|
return false;
|
|
60
62
|
}
|
|
61
63
|
|
|
@@ -26,6 +26,8 @@ var _useGridCellEditing = require("./useGridCellEditing.old");
|
|
|
26
26
|
|
|
27
27
|
var _useGridRowEditing = require("./useGridRowEditing.old");
|
|
28
28
|
|
|
29
|
+
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
30
|
+
|
|
29
31
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
30
32
|
|
|
31
33
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -56,7 +58,7 @@ function useGridEditing(apiRef, props) {
|
|
|
56
58
|
stateSelector: _gridEditRowsSelector.gridEditRowsStateSelector,
|
|
57
59
|
changeEvent: 'editRowsModelChange'
|
|
58
60
|
});
|
|
59
|
-
const isCellEditable = React.useCallback(params => !params.rowNode
|
|
61
|
+
const isCellEditable = React.useCallback(params => !(0, _gridRowsUtils.isAutoGeneratedRow)(params.rowNode) && params.rowNode.type !== 'pinnedRow' && !!params.colDef.editable && !!params.colDef.renderEditCell && (!props.isCellEditable || props.isCellEditable(params)), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
62
|
[props.isCellEditable]);
|
|
61
63
|
|
|
62
64
|
const maybeDebounce = (id, field, debounceMs, callback) => {
|
|
@@ -609,7 +609,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
609
609
|
}
|
|
610
610
|
}, [rowModesModelProp, updateRowModesModel]);
|
|
611
611
|
React.useEffect(() => {
|
|
612
|
-
const idToIdLookup = (0, _gridRowsSelector.
|
|
612
|
+
const idToIdLookup = (0, _gridRowsSelector.gridRowsDataRowIdToIdLookupSelector)(apiRef); // Update the ref here because updateStateToStopRowEditMode may change it later
|
|
613
613
|
|
|
614
614
|
const copyOfPrevRowModesModel = prevRowModesModel.current;
|
|
615
615
|
prevRowModesModel.current = (0, _utils2.deepClone)(rowModesModel); // Do a deep-clone because the attributes might be changed later
|
|
@@ -39,6 +39,14 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
39
39
|
|
|
40
40
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
41
41
|
|
|
42
|
+
function raf() {
|
|
43
|
+
return new Promise(resolve => {
|
|
44
|
+
requestAnimationFrame(() => {
|
|
45
|
+
resolve();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
42
50
|
/**
|
|
43
51
|
* @requires useGridColumns (state)
|
|
44
52
|
* @requires useGridFilter (state)
|
|
@@ -56,6 +64,7 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
56
64
|
// the new state needs to be in place before the grid can be sized correctly
|
|
57
65
|
|
|
58
66
|
const updateGridColumnsForPrint = React.useCallback((fields, allColumns) => new Promise(resolve => {
|
|
67
|
+
// TODO remove unused Promise
|
|
59
68
|
if (!fields && !allColumns) {
|
|
60
69
|
resolve();
|
|
61
70
|
return;
|
|
@@ -75,12 +84,10 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
75
84
|
});
|
|
76
85
|
apiRef.current.setColumnVisibilityModel(newColumnVisibilityModel);
|
|
77
86
|
resolve();
|
|
78
|
-
}), [apiRef]);
|
|
87
|
+
}), [apiRef]); // TODO move outside of this scope and remove React.useCallback
|
|
88
|
+
|
|
79
89
|
const buildPrintWindow = React.useCallback(title => {
|
|
80
90
|
const iframeEl = document.createElement('iframe');
|
|
81
|
-
iframeEl.id = 'grid-print-window'; // Without this 'onload' event won't fire in some browsers
|
|
82
|
-
|
|
83
|
-
iframeEl.src = window.location.href;
|
|
84
91
|
iframeEl.style.position = 'absolute';
|
|
85
92
|
iframeEl.style.width = '0px';
|
|
86
93
|
iframeEl.style.height = '0px';
|
|
@@ -88,17 +95,14 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
88
95
|
return iframeEl;
|
|
89
96
|
}, []);
|
|
90
97
|
const handlePrintWindowLoad = React.useCallback((printWindow, options) => {
|
|
91
|
-
var
|
|
98
|
+
var _querySelector, _querySelector2;
|
|
92
99
|
|
|
93
100
|
const normalizeOptions = (0, _extends2.default)({
|
|
94
101
|
copyStyles: true,
|
|
95
102
|
hideToolbar: false,
|
|
96
103
|
hideFooter: false
|
|
97
|
-
}, options);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
printWindow.onload = null;
|
|
101
|
-
const printDoc = printWindow.contentDocument || ((_printWindow$contentW = printWindow.contentWindow) == null ? void 0 : _printWindow$contentW.document);
|
|
104
|
+
}, options);
|
|
105
|
+
const printDoc = printWindow.contentDocument;
|
|
102
106
|
|
|
103
107
|
if (!printDoc) {
|
|
104
108
|
return;
|
|
@@ -138,10 +142,12 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
138
142
|
} // Expand container height to accommodate all rows
|
|
139
143
|
|
|
140
144
|
|
|
141
|
-
gridClone.style.height = `${rowsMeta.currentPageTotalHeight + totalHeaderHeight + gridToolbarElementHeight + gridFooterElementHeight}px`; //
|
|
145
|
+
gridClone.style.height = `${rowsMeta.currentPageTotalHeight + totalHeaderHeight + gridToolbarElementHeight + gridFooterElementHeight}px`; // printDoc.body.appendChild(gridClone); should be enough but a clone isolation bug in Safari
|
|
146
|
+
// prevents us to do it
|
|
142
147
|
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
const container = document.createElement('div');
|
|
149
|
+
container.appendChild(gridClone);
|
|
150
|
+
printDoc.body.innerHTML = container.innerHTML;
|
|
145
151
|
const defaultPageStyle = typeof normalizeOptions.pageStyle === 'function' ? normalizeOptions.pageStyle() : normalizeOptions.pageStyle;
|
|
146
152
|
|
|
147
153
|
if (typeof defaultPageStyle === 'string') {
|
|
@@ -235,17 +241,25 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
235
241
|
|
|
236
242
|
await updateGridColumnsForPrint(options == null ? void 0 : options.fields, options == null ? void 0 : options.allColumns);
|
|
237
243
|
apiRef.current.unstable_disableVirtualization();
|
|
244
|
+
await raf(); // wait for the state changes to take action
|
|
245
|
+
|
|
238
246
|
const printWindow = buildPrintWindow(options == null ? void 0 : options.fileName);
|
|
239
|
-
doc.current.body.appendChild(printWindow);
|
|
240
247
|
|
|
241
248
|
if (process.env.NODE_ENV === 'test') {
|
|
242
|
-
// In test env, run the all pipeline without waiting for loading
|
|
249
|
+
doc.current.body.appendChild(printWindow); // In test env, run the all pipeline without waiting for loading
|
|
250
|
+
|
|
243
251
|
handlePrintWindowLoad(printWindow, options);
|
|
244
252
|
handlePrintWindowAfterPrint(printWindow);
|
|
245
253
|
} else {
|
|
246
|
-
printWindow.onload = () =>
|
|
254
|
+
printWindow.onload = () => {
|
|
255
|
+
handlePrintWindowLoad(printWindow, options);
|
|
256
|
+
|
|
257
|
+
printWindow.contentWindow.onafterprint = () => {
|
|
258
|
+
handlePrintWindowAfterPrint(printWindow);
|
|
259
|
+
};
|
|
260
|
+
};
|
|
247
261
|
|
|
248
|
-
|
|
262
|
+
doc.current.body.appendChild(printWindow);
|
|
249
263
|
}
|
|
250
264
|
}, [props, logger, apiRef, buildPrintWindow, handlePrintWindowLoad, handlePrintWindowAfterPrint, updateGridColumnsForPrint]);
|
|
251
265
|
const printExportApi = {
|
|
@@ -35,11 +35,7 @@ const defaultGetRowsToExport = ({
|
|
|
35
35
|
const filteredSortedRowIds = (0, _filter.gridFilteredSortedRowIdsSelector)(apiRef);
|
|
36
36
|
const rowTree = (0, _gridRowsSelector.gridRowTreeSelector)(apiRef);
|
|
37
37
|
const selectedRows = apiRef.current.getSelectedRows();
|
|
38
|
-
const bodyRows = filteredSortedRowIds.filter(id =>
|
|
39
|
-
var _rowTree$id$position;
|
|
40
|
-
|
|
41
|
-
return ((_rowTree$id$position = rowTree[id].position) != null ? _rowTree$id$position : 'body') === 'body';
|
|
42
|
-
});
|
|
38
|
+
const bodyRows = filteredSortedRowIds.filter(id => rowTree[id].type !== 'footer');
|
|
43
39
|
const pinnedRows = (0, _gridRowsSelector.gridPinnedRowsSelector)(apiRef);
|
|
44
40
|
const topPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.map(row => row.id)) || [];
|
|
45
41
|
const bottomPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.map(row => row.id)) || [];
|
|
@@ -100,7 +100,7 @@ const gridVisibleRowsSelector = gridVisibleSortedRowIdsSelector;
|
|
|
100
100
|
*/
|
|
101
101
|
|
|
102
102
|
exports.gridVisibleRowsSelector = gridVisibleRowsSelector;
|
|
103
|
-
const gridVisibleSortedTopLevelRowEntriesSelector = (0, _createSelector.createSelector)(gridVisibleSortedRowEntriesSelector, _gridRowsSelector.gridRowTreeSelector, _gridRowsSelector.
|
|
103
|
+
const gridVisibleSortedTopLevelRowEntriesSelector = (0, _createSelector.createSelector)(gridVisibleSortedRowEntriesSelector, _gridRowsSelector.gridRowTreeSelector, _gridRowsSelector.gridRowMaximumTreeDepthSelector, (visibleSortedRows, rowTree, rowTreeDepth) => {
|
|
104
104
|
if (rowTreeDepth < 2) {
|
|
105
105
|
return visibleSortedRows;
|
|
106
106
|
}
|
|
@@ -11,8 +11,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
|
|
14
|
-
var _gridFeatureMode = require("../../../models/gridFeatureMode");
|
|
15
|
-
|
|
16
14
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
17
15
|
|
|
18
16
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
@@ -80,7 +78,7 @@ const useGridFilter = (apiRef, props) => {
|
|
|
80
78
|
const updateFilteredRows = React.useCallback(() => {
|
|
81
79
|
apiRef.current.setState(state => {
|
|
82
80
|
const filterModel = (0, _gridFilterSelector.gridFilterModelSelector)(state, apiRef.current.instanceId);
|
|
83
|
-
const isRowMatchingFilters = props.filterMode ===
|
|
81
|
+
const isRowMatchingFilters = props.filterMode === 'client' ? (0, _gridFilterUtils.buildAggregatedFilterApplier)(filterModel, apiRef) : null;
|
|
84
82
|
const filteringResult = apiRef.current.unstable_applyStrategyProcessor('filtering', {
|
|
85
83
|
isRowMatchingFilters,
|
|
86
84
|
filterModel: filterModel != null ? filterModel : (0, _gridFilterState.getDefaultGridFilterModel)()
|
|
@@ -289,8 +287,9 @@ const useGridFilter = (apiRef, props) => {
|
|
|
289
287
|
return initialValue;
|
|
290
288
|
}, [props.components.FilterPanel, (_props$componentsProp2 = props.componentsProps) == null ? void 0 : _props$componentsProp2.filterPanel]);
|
|
291
289
|
const flatFilteringMethod = React.useCallback(params => {
|
|
292
|
-
if (props.filterMode ===
|
|
293
|
-
const
|
|
290
|
+
if (props.filterMode === 'client' && params.isRowMatchingFilters) {
|
|
291
|
+
const tree = (0, _rows.gridRowTreeSelector)(apiRef);
|
|
292
|
+
const rowIds = tree[_rows.GRID_ROOT_GROUP_ID].children;
|
|
294
293
|
const filteredRowsLookup = {};
|
|
295
294
|
|
|
296
295
|
for (let i = 0; i < rowIds.length; i += 1) {
|
|
@@ -312,7 +311,7 @@ const useGridFilter = (apiRef, props) => {
|
|
|
312
311
|
|
|
313
312
|
return {
|
|
314
313
|
filteredRowsLookup,
|
|
315
|
-
// For flat tree, the `visibleRowsLookup` and the `filteredRowsLookup` since no row is collapsed.
|
|
314
|
+
// For flat tree, the `visibleRowsLookup` and the `filteredRowsLookup` are equals since no row is collapsed.
|
|
316
315
|
visibleRowsLookup: filteredRowsLookup,
|
|
317
316
|
filteredDescendantCountLookup: {}
|
|
318
317
|
};
|
|
@@ -44,7 +44,7 @@ const gridPageCountSelector = (0, _createSelector.createSelector)(gridPagination
|
|
|
44
44
|
*/
|
|
45
45
|
|
|
46
46
|
exports.gridPageCountSelector = gridPageCountSelector;
|
|
47
|
-
const gridPaginationRowRangeSelector = (0, _createSelector.createSelector)(gridPaginationSelector, _gridRowsSelector.gridRowTreeSelector, _gridRowsSelector.
|
|
47
|
+
const gridPaginationRowRangeSelector = (0, _createSelector.createSelector)(gridPaginationSelector, _gridRowsSelector.gridRowTreeSelector, _gridRowsSelector.gridRowMaximumTreeDepthSelector, _gridFilterSelector.gridVisibleSortedRowEntriesSelector, _gridFilterSelector.gridVisibleSortedTopLevelRowEntriesSelector, (pagination, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) => {
|
|
48
48
|
const visibleTopLevelRowCount = visibleSortedTopLevelRowEntries.length;
|
|
49
49
|
const topLevelFirstRowIndex = Math.min(pagination.pageSize * pagination.page, visibleTopLevelRowCount - 1);
|
|
50
50
|
const topLevelLastRowIndex = Math.min(topLevelFirstRowIndex + pagination.pageSize - 1, visibleTopLevelRowCount - 1); // The range contains no element
|
|
File without changes
|