@mui/x-data-grid 7.22.1 → 8.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 +143 -92
- package/README.md +2 -2
- package/colDef/gridBooleanOperators.js +4 -6
- package/components/GridDetailPanels.js +0 -1
- package/components/GridPinnedRows.js +0 -1
- package/components/GridRow.d.ts +2 -2
- package/components/GridRow.js +3 -28
- package/components/base/GridOverlays.js +10 -8
- package/components/cell/GridActionsCell.js +1 -2
- package/components/cell/GridActionsCellItem.js +1 -2
- package/components/cell/GridCell.d.ts +41 -3
- package/components/cell/GridCell.js +1 -9
- package/components/cell/GridEditInputCell.js +0 -67
- package/components/containers/GridRootStyles.js +1 -0
- package/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +1 -2
- package/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +1 -2
- package/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +1 -2
- package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +3 -4
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +1 -0
- package/components/panel/filterPanel/GridFilterInputBoolean.js +14 -5
- package/components/toolbar/GridToolbar.d.ts +2 -2
- package/components/toolbar/GridToolbar.js +12 -4
- package/components/toolbar/GridToolbarColumnsButton.js +1 -1
- package/components/toolbar/GridToolbarDensitySelector.js +2 -4
- package/components/toolbar/GridToolbarExport.d.ts +2 -2
- package/components/toolbar/GridToolbarExport.js +9 -6
- package/components/toolbar/GridToolbarExportContainer.js +1 -2
- package/components/toolbar/index.d.ts +1 -1
- package/components/virtualization/GridVirtualScrollbar.js +6 -0
- package/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/hooks/features/editing/useGridCellEditing.js +23 -4
- package/hooks/features/editing/useGridRowEditing.js +23 -2
- package/hooks/features/export/useGridCsvExport.js +1 -1
- package/hooks/features/export/useGridPrintExport.js +1 -1
- package/hooks/features/pagination/useGridPaginationModel.js +2 -2
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +30 -16
- package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.js +1 -5
- package/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/hooks/utils/useGridSelector.d.ts +3 -2
- package/hooks/utils/useGridSelector.js +27 -2
- package/index.d.ts +0 -1
- package/index.js +1 -1
- package/locales/plPL.js +25 -28
- package/locales/trTR.js +2 -2
- package/material/index.js +4 -0
- package/models/gridSlotsComponent.d.ts +10 -0
- package/models/gridSlotsComponentsProps.d.ts +8 -0
- package/models/props/DataGridProps.d.ts +1 -1
- package/modern/colDef/gridBooleanOperators.js +4 -6
- package/modern/components/GridDetailPanels.js +0 -1
- package/modern/components/GridPinnedRows.js +0 -1
- package/modern/components/GridRow.js +3 -28
- package/modern/components/base/GridOverlays.js +10 -8
- package/modern/components/cell/GridActionsCell.js +1 -2
- package/modern/components/cell/GridActionsCellItem.js +1 -2
- package/modern/components/cell/GridCell.js +1 -9
- package/modern/components/cell/GridEditInputCell.js +0 -67
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +1 -2
- package/modern/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +1 -2
- package/modern/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +1 -2
- package/modern/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +3 -4
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +14 -5
- package/modern/components/toolbar/GridToolbar.js +12 -4
- package/modern/components/toolbar/GridToolbarColumnsButton.js +1 -1
- package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -4
- package/modern/components/toolbar/GridToolbarExport.js +9 -6
- package/modern/components/toolbar/GridToolbarExportContainer.js +1 -2
- package/modern/components/virtualization/GridVirtualScrollbar.js +6 -0
- package/modern/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/modern/hooks/features/editing/useGridCellEditing.js +23 -4
- package/modern/hooks/features/editing/useGridRowEditing.js +23 -2
- package/modern/hooks/features/export/useGridCsvExport.js +1 -1
- package/modern/hooks/features/export/useGridPrintExport.js +1 -1
- package/modern/hooks/features/pagination/useGridPaginationModel.js +2 -2
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +30 -16
- package/modern/hooks/features/rows/gridRowsUtils.js +1 -5
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/modern/hooks/utils/useGridSelector.js +27 -2
- package/modern/index.js +1 -1
- package/modern/locales/plPL.js +25 -28
- package/modern/locales/trTR.js +2 -2
- package/modern/material/index.js +4 -0
- package/modern/utils/createSelector.js +11 -1
- package/modern/utils/utils.js +1 -3
- package/node/colDef/gridBooleanOperators.js +3 -5
- package/node/components/GridDetailPanels.js +0 -1
- package/node/components/GridPinnedRows.js +0 -1
- package/node/components/GridRow.js +3 -28
- package/node/components/base/GridOverlays.js +10 -8
- package/node/components/cell/GridActionsCell.js +1 -2
- package/node/components/cell/GridActionsCellItem.js +1 -2
- package/node/components/cell/GridCell.js +1 -9
- package/node/components/cell/GridEditInputCell.js +0 -67
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +1 -2
- package/node/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +1 -2
- package/node/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +1 -2
- package/node/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +3 -4
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +16 -5
- package/node/components/toolbar/GridToolbar.js +12 -4
- package/node/components/toolbar/GridToolbarColumnsButton.js +3 -3
- package/node/components/toolbar/GridToolbarDensitySelector.js +2 -4
- package/node/components/toolbar/GridToolbarExport.js +9 -6
- package/node/components/toolbar/GridToolbarExportContainer.js +1 -2
- package/node/components/virtualization/GridVirtualScrollbar.js +6 -0
- package/node/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/node/hooks/features/editing/useGridCellEditing.js +23 -4
- package/node/hooks/features/editing/useGridRowEditing.js +23 -2
- package/node/hooks/features/export/useGridCsvExport.js +2 -2
- package/node/hooks/features/export/useGridPrintExport.js +2 -2
- package/node/hooks/features/pagination/useGridPaginationModel.js +2 -2
- package/node/hooks/features/rowSelection/useGridRowSelection.js +29 -15
- package/node/hooks/features/rows/gridRowsUtils.js +2 -8
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/node/hooks/utils/useGridSelector.js +29 -3
- package/node/index.js +1 -1
- package/node/locales/plPL.js +25 -28
- package/node/locales/trTR.js +2 -2
- package/node/material/index.js +4 -0
- package/node/utils/createSelector.js +11 -1
- package/node/utils/utils.js +1 -3
- package/package.json +3 -3
- package/utils/createSelector.d.ts +1 -1
- package/utils/createSelector.js +11 -1
- package/utils/utils.js +1 -3
|
@@ -241,26 +241,45 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
241
241
|
mode: GridCellModes.Edit
|
|
242
242
|
}, other));
|
|
243
243
|
}, [throwIfNotEditable, throwIfNotInMode, updateFieldInCellModesModel]);
|
|
244
|
-
const updateStateToStartCellEditMode = useEventCallback(params => {
|
|
244
|
+
const updateStateToStartCellEditMode = useEventCallback(async params => {
|
|
245
245
|
const {
|
|
246
246
|
id,
|
|
247
247
|
field,
|
|
248
248
|
deleteValue,
|
|
249
249
|
initialValue
|
|
250
250
|
} = params;
|
|
251
|
-
|
|
251
|
+
const value = apiRef.current.getCellValue(id, field);
|
|
252
|
+
let newValue = value;
|
|
252
253
|
if (deleteValue) {
|
|
253
254
|
newValue = getDefaultCellValue(apiRef.current.getColumn(field));
|
|
254
255
|
} else if (initialValue) {
|
|
255
256
|
newValue = initialValue;
|
|
256
257
|
}
|
|
257
|
-
const
|
|
258
|
+
const column = apiRef.current.getColumn(field);
|
|
259
|
+
const shouldProcessEditCellProps = !!column.preProcessEditCellProps && deleteValue;
|
|
260
|
+
let newProps = {
|
|
258
261
|
value: newValue,
|
|
259
262
|
error: false,
|
|
260
|
-
isProcessingProps:
|
|
263
|
+
isProcessingProps: shouldProcessEditCellProps
|
|
261
264
|
};
|
|
262
265
|
updateOrDeleteFieldState(id, field, newProps);
|
|
263
266
|
apiRef.current.setCellFocus(id, field);
|
|
267
|
+
if (shouldProcessEditCellProps) {
|
|
268
|
+
newProps = await Promise.resolve(column.preProcessEditCellProps({
|
|
269
|
+
id,
|
|
270
|
+
row: apiRef.current.getRow(id),
|
|
271
|
+
props: newProps,
|
|
272
|
+
hasChanged: newValue !== value
|
|
273
|
+
}));
|
|
274
|
+
// Check if still in edit mode before updating
|
|
275
|
+
if (apiRef.current.getCellMode(id, field) === GridCellModes.Edit) {
|
|
276
|
+
const editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
277
|
+
updateOrDeleteFieldState(id, field, _extends({}, newProps, {
|
|
278
|
+
value: editingState[id][field].value,
|
|
279
|
+
isProcessingProps: false
|
|
280
|
+
}));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
264
283
|
});
|
|
265
284
|
const stopCellEditMode = React.useCallback(params => {
|
|
266
285
|
const {
|
|
@@ -318,10 +318,11 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
318
318
|
if (!cellParams.isEditable) {
|
|
319
319
|
return acc;
|
|
320
320
|
}
|
|
321
|
+
const column = apiRef.current.getColumn(field);
|
|
321
322
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
322
323
|
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
323
324
|
if (deleteValue) {
|
|
324
|
-
newValue = getDefaultCellValue(
|
|
325
|
+
newValue = getDefaultCellValue(column);
|
|
325
326
|
} else if (initialValue) {
|
|
326
327
|
newValue = initialValue;
|
|
327
328
|
}
|
|
@@ -329,7 +330,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
329
330
|
acc[field] = {
|
|
330
331
|
value: newValue,
|
|
331
332
|
error: false,
|
|
332
|
-
isProcessingProps:
|
|
333
|
+
isProcessingProps: !!column.preProcessEditCellProps && deleteValue
|
|
333
334
|
};
|
|
334
335
|
return acc;
|
|
335
336
|
}, {});
|
|
@@ -337,6 +338,26 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
337
338
|
if (fieldToFocus) {
|
|
338
339
|
apiRef.current.setCellFocus(id, fieldToFocus);
|
|
339
340
|
}
|
|
341
|
+
columnFields.filter(field => !!apiRef.current.getColumn(field).preProcessEditCellProps && deleteValue).forEach(field => {
|
|
342
|
+
const column = apiRef.current.getColumn(field);
|
|
343
|
+
const value = apiRef.current.getCellValue(id, field);
|
|
344
|
+
const newValue = deleteValue ? getDefaultCellValue(column) : initialValue ?? value;
|
|
345
|
+
Promise.resolve(column.preProcessEditCellProps({
|
|
346
|
+
id,
|
|
347
|
+
row: apiRef.current.getRow(id),
|
|
348
|
+
props: newProps[field],
|
|
349
|
+
hasChanged: newValue !== value
|
|
350
|
+
})).then(processedProps => {
|
|
351
|
+
// Check if still in edit mode before updating
|
|
352
|
+
if (apiRef.current.getRowMode(id) === GridRowModes.Edit) {
|
|
353
|
+
const editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
354
|
+
updateOrDeleteFieldState(id, field, _extends({}, processedProps, {
|
|
355
|
+
value: editingState[id][field].value,
|
|
356
|
+
isProcessingProps: false
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
});
|
|
340
361
|
});
|
|
341
362
|
const stopRowEditMode = React.useCallback(params => {
|
|
342
363
|
const {
|
|
@@ -5,7 +5,7 @@ import { exportAs } from "../../../utils/exportAs.js";
|
|
|
5
5
|
import { buildCSV } from "./serializers/csvSerializer.js";
|
|
6
6
|
import { getColumnsToExport, defaultGetRowsToExport } from "./utils.js";
|
|
7
7
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
|
|
8
|
-
import { GridCsvExportMenuItem } from "../../../components/toolbar/
|
|
8
|
+
import { GridCsvExportMenuItem } from "../../../components/toolbar/index.js";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
/**
|
|
11
11
|
* @requires useGridColumns (state)
|
|
@@ -11,7 +11,7 @@ import { GRID_ID_AUTOGENERATED } from "../rows/gridRowsUtils.js";
|
|
|
11
11
|
import { defaultGetRowsToExport, getColumnsToExport } from "./utils.js";
|
|
12
12
|
import { getDerivedPaginationModel } from "../pagination/useGridPaginationModel.js";
|
|
13
13
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
|
|
14
|
-
import { GridPrintExportMenuItem } from "../../../components/toolbar/
|
|
14
|
+
import { GridPrintExportMenuItem } from "../../../components/toolbar/index.js";
|
|
15
15
|
import { getTotalHeaderHeight } from "../columns/gridColumnsUtils.js";
|
|
16
16
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from "../../../colDef/gridCheckboxSelectionColDef.js";
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -75,7 +75,7 @@ export const useGridPaginationModel = (apiRef, props) => {
|
|
|
75
75
|
pagination: _extends({}, state.pagination, {
|
|
76
76
|
paginationModel: getDerivedPaginationModel(state.pagination, props.signature, paginationModel)
|
|
77
77
|
})
|
|
78
|
-
}));
|
|
78
|
+
}), 'setPaginationModel');
|
|
79
79
|
}, [apiRef, logger, props.signature]);
|
|
80
80
|
const paginationModelApi = {
|
|
81
81
|
setPage,
|
|
@@ -113,7 +113,7 @@ export const useGridPaginationModel = (apiRef, props) => {
|
|
|
113
113
|
pagination: _extends({}, state.pagination, {
|
|
114
114
|
paginationModel: getDerivedPaginationModel(state.pagination, props.signature, paginationModel)
|
|
115
115
|
})
|
|
116
|
-
}));
|
|
116
|
+
}), 'stateRestorePreProcessing');
|
|
117
117
|
return params;
|
|
118
118
|
}, [apiRef, props.autoPageSize, props.signature]);
|
|
119
119
|
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
@@ -9,4 +9,4 @@ export declare const rowSelectionStateInitializer: GridStateInitializer<Pick<Dat
|
|
|
9
9
|
* @requires useGridFocus (state) - can be after
|
|
10
10
|
* @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
|
|
11
11
|
*/
|
|
12
|
-
export declare const useGridRowSelection: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "checkboxSelection" | "rowSelectionModel" | "onRowSelectionModelChange" | "disableMultipleRowSelection" | "disableRowSelectionOnClick" | "isRowSelectable" | "checkboxSelectionVisibleOnly" | "pagination" | "paginationMode" | "classes" | "keepNonExistentRowsSelected" | "rowSelection" | "rowSelectionPropagation" | "signature">) => void;
|
|
12
|
+
export declare const useGridRowSelection: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "checkboxSelection" | "rowSelectionModel" | "onRowSelectionModelChange" | "disableMultipleRowSelection" | "disableRowSelectionOnClick" | "isRowSelectable" | "checkboxSelectionVisibleOnly" | "pagination" | "paginationMode" | "filterMode" | "classes" | "keepNonExistentRowsSelected" | "rowSelection" | "rowSelectionPropagation" | "signature">) => void;
|
|
@@ -4,7 +4,7 @@ import { GridSignature, useGridApiEventHandler } from "../../utils/useGridApiEve
|
|
|
4
4
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
5
5
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
6
6
|
import { useGridSelector } from "../../utils/useGridSelector.js";
|
|
7
|
-
import { gridRowMaximumTreeDepthSelector, gridRowTreeSelector } from "../rows/gridRowsSelector.js";
|
|
7
|
+
import { gridRowsLookupSelector, gridRowMaximumTreeDepthSelector, gridRowTreeSelector } from "../rows/gridRowsSelector.js";
|
|
8
8
|
import { gridRowSelectionStateSelector, selectedGridRowsSelector, selectedIdsLookupSelector } from "./gridRowSelectionSelector.js";
|
|
9
9
|
import { gridPaginatedVisibleSortedGridRowIdsSelector } from "../pagination/index.js";
|
|
10
10
|
import { gridFocusCellSelector } from "../focus/gridFocusStateSelector.js";
|
|
@@ -171,30 +171,33 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
171
171
|
let newSelection;
|
|
172
172
|
if (resetSelection) {
|
|
173
173
|
if (isSelected) {
|
|
174
|
-
newSelection = selectableIds;
|
|
174
|
+
newSelection = new Set(selectableIds);
|
|
175
175
|
if (applyAutoSelection) {
|
|
176
176
|
const addRow = rowId => {
|
|
177
|
-
newSelection.
|
|
177
|
+
newSelection.add(rowId);
|
|
178
178
|
};
|
|
179
179
|
selectableIds.forEach(id => {
|
|
180
180
|
findRowsToSelect(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
183
|
} else {
|
|
184
|
-
newSelection =
|
|
184
|
+
newSelection = new Set();
|
|
185
|
+
}
|
|
186
|
+
const currentLookup = selectedIdsLookupSelector(apiRef);
|
|
187
|
+
if (newSelection.size === Object.keys(currentLookup).length && Array.from(newSelection).every(id => currentLookup[id] === id)) {
|
|
188
|
+
return;
|
|
185
189
|
}
|
|
186
190
|
} else {
|
|
187
|
-
|
|
188
|
-
const selectionLookup = _extends({}, selectedIdsLookupSelector(apiRef));
|
|
191
|
+
newSelection = new Set(Object.values(selectedIdsLookupSelector(apiRef)));
|
|
189
192
|
const addRow = rowId => {
|
|
190
|
-
|
|
193
|
+
newSelection.add(rowId);
|
|
191
194
|
};
|
|
192
195
|
const removeRow = rowId => {
|
|
193
|
-
delete
|
|
196
|
+
newSelection.delete(rowId);
|
|
194
197
|
};
|
|
195
198
|
selectableIds.forEach(id => {
|
|
196
199
|
if (isSelected) {
|
|
197
|
-
|
|
200
|
+
newSelection.add(id);
|
|
198
201
|
if (applyAutoSelection) {
|
|
199
202
|
findRowsToSelect(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
200
203
|
}
|
|
@@ -205,11 +208,10 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
205
208
|
}
|
|
206
209
|
}
|
|
207
210
|
});
|
|
208
|
-
newSelection = Object.values(selectionLookup);
|
|
209
211
|
}
|
|
210
|
-
const isSelectionValid = newSelection.
|
|
212
|
+
const isSelectionValid = newSelection.size < 2 || canHaveMultipleSelection;
|
|
211
213
|
if (isSelectionValid) {
|
|
212
|
-
apiRef.current.setRowSelectionModel(newSelection);
|
|
214
|
+
apiRef.current.setRowSelectionModel(Array.from(newSelection));
|
|
213
215
|
}
|
|
214
216
|
}, [logger, applyAutoSelection, canHaveMultipleSelection, apiRef, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents]);
|
|
215
217
|
const selectRowRange = React.useCallback(({
|
|
@@ -252,13 +254,20 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
252
254
|
return;
|
|
253
255
|
}
|
|
254
256
|
const currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
257
|
+
const rowsLookup = gridRowsLookupSelector(apiRef);
|
|
255
258
|
const filteredRowsLookup = gridFilteredRowsLookupSelector(apiRef);
|
|
256
259
|
|
|
257
260
|
// We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
258
261
|
const selectionLookup = _extends({}, selectedIdsLookupSelector(apiRef));
|
|
262
|
+
const isNonExistent = id => {
|
|
263
|
+
if (props.filterMode === 'server') {
|
|
264
|
+
return !rowsLookup[id];
|
|
265
|
+
}
|
|
266
|
+
return filteredRowsLookup[id] !== true;
|
|
267
|
+
};
|
|
259
268
|
let hasChanged = false;
|
|
260
269
|
currentSelection.forEach(id => {
|
|
261
|
-
if (
|
|
270
|
+
if (isNonExistent(id)) {
|
|
262
271
|
if (props.keepNonExistentRowsSelected) {
|
|
263
272
|
return;
|
|
264
273
|
}
|
|
@@ -284,15 +293,20 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
284
293
|
}
|
|
285
294
|
}
|
|
286
295
|
});
|
|
287
|
-
|
|
296
|
+
|
|
297
|
+
// For nested data, on row tree updation (filtering, adding rows, etc.) when the selection is
|
|
298
|
+
// not empty, we need to re-run scanning of the tree to propagate the selection changes
|
|
299
|
+
// Example: A parent whose de-selected children are filtered out should now be selected
|
|
300
|
+
const shouldReapplyPropagation = isNestedData && props.rowSelectionPropagation?.parents && Object.keys(selectionLookup).length > 0;
|
|
301
|
+
if (hasChanged || shouldReapplyPropagation && !sortModelUpdated) {
|
|
288
302
|
const newSelection = Object.values(selectionLookup);
|
|
289
|
-
if (
|
|
303
|
+
if (shouldReapplyPropagation) {
|
|
290
304
|
apiRef.current.selectRows(newSelection, true, true);
|
|
291
305
|
} else {
|
|
292
306
|
apiRef.current.setRowSelectionModel(newSelection);
|
|
293
307
|
}
|
|
294
308
|
}
|
|
295
|
-
}, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, tree]);
|
|
309
|
+
}, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, props.filterMode, tree]);
|
|
296
310
|
const handleSingleRowSelection = React.useCallback((id, event) => {
|
|
297
311
|
const hasCtrlKey = event.metaKey || event.ctrlKey;
|
|
298
312
|
|
|
@@ -37,7 +37,7 @@ export declare function calculatePinnedRowsHeight(apiRef: React.MutableRefObject
|
|
|
37
37
|
top: number;
|
|
38
38
|
bottom: number;
|
|
39
39
|
};
|
|
40
|
-
export declare
|
|
40
|
+
export declare const minimalContentHeight = "var(--DataGrid-overlayHeight, calc(var(--height) * 2))";
|
|
41
41
|
export declare function computeRowsUpdates(apiRef: React.MutableRefObject<GridApiCommunity>, updates: GridRowModelUpdate[], getRowId: DataGridProcessedProps['getRowId']): GridRowModelUpdate[];
|
|
42
42
|
export declare const getValidRowHeight: (rowHeightProp: any, defaultRowHeight: number, warningMessage: string) => number;
|
|
43
43
|
export declare const rowHeightWarning: string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { gridPinnedRowsSelector } from "./gridRowsSelector.js";
|
|
3
|
-
import { gridDimensionsSelector } from "../dimensions/gridDimensionsSelectors.js";
|
|
4
3
|
export const GRID_ROOT_GROUP_ID = `auto-generated-group-node-root`;
|
|
5
4
|
export const GRID_ID_AUTOGENERATED = Symbol('mui.id_autogenerated');
|
|
6
5
|
export const buildRootGroup = () => ({
|
|
@@ -285,10 +284,7 @@ export function calculatePinnedRowsHeight(apiRef) {
|
|
|
285
284
|
bottom: bottomPinnedRowsHeight
|
|
286
285
|
};
|
|
287
286
|
}
|
|
288
|
-
export
|
|
289
|
-
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
290
|
-
return `var(--DataGrid-overlayHeight, ${2 * dimensions.rowHeight}px)`;
|
|
291
|
-
}
|
|
287
|
+
export const minimalContentHeight = 'var(--DataGrid-overlayHeight, calc(var(--height) * 2))';
|
|
292
288
|
export function computeRowsUpdates(apiRef, updates, getRowId) {
|
|
293
289
|
const nonPinnedRowsUpdates = [];
|
|
294
290
|
updates.forEach(update => {
|
|
@@ -21,11 +21,11 @@ import { clamp, range } from "../../../utils/utils.js";
|
|
|
21
21
|
import { selectedIdsLookupSelector } from "../rowSelection/gridRowSelectionSelector.js";
|
|
22
22
|
import { gridRowsMetaSelector } from "../rows/gridRowsMetaSelector.js";
|
|
23
23
|
import { getFirstNonSpannedColumnToRender } from "../columns/gridColumnsUtils.js";
|
|
24
|
-
import { getMinimalContentHeight } from "../rows/gridRowsUtils.js";
|
|
25
24
|
import { gridRenderContextSelector, gridVirtualizationRowEnabledSelector, gridVirtualizationColumnEnabledSelector } from "./gridVirtualizationSelectors.js";
|
|
26
25
|
import { EMPTY_RENDER_CONTEXT } from "./useGridVirtualization.js";
|
|
27
26
|
import { gridRowSpanningHiddenCellsOriginMapSelector } from "../rows/gridRowSpanningSelectors.js";
|
|
28
27
|
import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
|
|
28
|
+
import { minimalContentHeight } from "../rows/gridRowsUtils.js";
|
|
29
29
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
30
30
|
const MINIMUM_COLUMN_WIDTH = 50;
|
|
31
31
|
var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
|
|
@@ -381,11 +381,11 @@ export const useGridVirtualScroller = () => {
|
|
|
381
381
|
flexBasis: contentHeight,
|
|
382
382
|
flexShrink: 0
|
|
383
383
|
};
|
|
384
|
-
if (
|
|
385
|
-
size.flexBasis =
|
|
384
|
+
if (size.flexBasis === 0) {
|
|
385
|
+
size.flexBasis = minimalContentHeight; // Give room to show the overlay when there no rows.
|
|
386
386
|
}
|
|
387
387
|
return size;
|
|
388
|
-
}, [
|
|
388
|
+
}, [columnsTotalWidth, contentHeight, needsHorizontalScrollbar]);
|
|
389
389
|
React.useEffect(() => {
|
|
390
390
|
apiRef.current.publishEvent('virtualScrollerContentSizeChange');
|
|
391
391
|
}, [apiRef, contentSize]);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
|
|
3
3
|
import type { GridApiCommon } from '../../models/api/gridApiCommon';
|
|
4
|
-
import { OutputSelector, OutputSelectorV8 } from '../../utils/createSelector';
|
|
4
|
+
import type { OutputSelector, OutputSelectorV8 } from '../../utils/createSelector';
|
|
5
5
|
type Selector<Api extends GridApiCommon, Args, T> = ((state: Api['state']) => T) | OutputSelectorV8<Api['state'], Args, T>;
|
|
6
6
|
export declare const objectShallowCompare: typeof fastObjectShallowCompare;
|
|
7
|
+
export declare const argsEqual: (prev: any, curr: any) => boolean;
|
|
7
8
|
export declare const useGridSelector: <Api extends GridApiCommon, T>(apiRef: React.MutableRefObject<Api>, selector: ((state: Api["state"]) => T) | OutputSelector<Api["state"], T>, equals?: (a: T, b: T) => boolean) => T;
|
|
8
|
-
export declare const useGridSelectorV8: <Api extends GridApiCommon, Args, T>(apiRef: React.MutableRefObject<Api>, selector: Selector<Api, Args, T>, args?: Args, equals?: (a:
|
|
9
|
+
export declare const useGridSelectorV8: <Api extends GridApiCommon, Args, T>(apiRef: React.MutableRefObject<Api>, selector: Selector<Api, Args, T>, args?: Args, equals?: <U = T>(a: U, b: U) => boolean) => T;
|
|
9
10
|
export {};
|
|
@@ -23,10 +23,26 @@ function applySelectorV8(apiRef, selector, args, instanceId) {
|
|
|
23
23
|
}
|
|
24
24
|
const defaultCompare = Object.is;
|
|
25
25
|
export const objectShallowCompare = fastObjectShallowCompare;
|
|
26
|
+
const arrayShallowCompare = (a, b) => {
|
|
27
|
+
if (a === b) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
31
|
+
};
|
|
32
|
+
export const argsEqual = (prev, curr) => {
|
|
33
|
+
let fn = Object.is;
|
|
34
|
+
if (curr instanceof Array) {
|
|
35
|
+
fn = arrayShallowCompare;
|
|
36
|
+
} else if (curr instanceof Object) {
|
|
37
|
+
fn = objectShallowCompare;
|
|
38
|
+
}
|
|
39
|
+
return fn(prev, curr);
|
|
40
|
+
};
|
|
26
41
|
const createRefs = () => ({
|
|
27
42
|
state: null,
|
|
28
43
|
equals: null,
|
|
29
|
-
selector: null
|
|
44
|
+
selector: null,
|
|
45
|
+
args: null
|
|
30
46
|
});
|
|
31
47
|
|
|
32
48
|
// TODO v8: Remove this function
|
|
@@ -71,9 +87,18 @@ export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = d
|
|
|
71
87
|
refs.current.state = state;
|
|
72
88
|
refs.current.equals = equals;
|
|
73
89
|
refs.current.selector = selector;
|
|
90
|
+
const prevArgs = refs.current.args;
|
|
91
|
+
refs.current.args = args;
|
|
92
|
+
if (didInit && !argsEqual(prevArgs, args)) {
|
|
93
|
+
const newState = applySelectorV8(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
|
|
94
|
+
if (!refs.current.equals(refs.current.state, newState)) {
|
|
95
|
+
refs.current.state = newState;
|
|
96
|
+
setState(newState);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
74
99
|
useOnMount(() => {
|
|
75
100
|
return apiRef.current.store.subscribe(() => {
|
|
76
|
-
const newState = applySelectorV8(apiRef, refs.current.selector, args, apiRef.current.instanceId);
|
|
101
|
+
const newState = applySelectorV8(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
|
|
77
102
|
if (!refs.current.equals(refs.current.state, newState)) {
|
|
78
103
|
refs.current.state = newState;
|
|
79
104
|
setState(newState);
|
package/index.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ export * from './context';
|
|
|
13
13
|
export * from './colDef';
|
|
14
14
|
export * from './utils';
|
|
15
15
|
export type { DataGridProps, GridExperimentalFeatures } from './models/props/DataGridProps';
|
|
16
|
-
export type { GridToolbarExportProps } from './components/toolbar/GridToolbarExport';
|
|
17
16
|
export type { GridExportFormat, GridExportExtension } from './models/gridExport';
|
|
18
17
|
export { GridColumnHeaders } from './components/GridColumnHeaders';
|
|
19
18
|
export type { GridColumnHeadersProps } from './components/GridColumnHeaders';
|
package/index.js
CHANGED
package/locales/plPL.js
CHANGED
|
@@ -30,11 +30,10 @@ const plPLGrid = {
|
|
|
30
30
|
toolbarExportPrint: 'Drukuj',
|
|
31
31
|
toolbarExportExcel: 'Pobierz jako plik Excel',
|
|
32
32
|
// Columns management text
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
columnsManagementSearchTitle: 'Szukaj',
|
|
34
|
+
columnsManagementNoColumns: 'Brak kolumn',
|
|
35
|
+
columnsManagementShowHideAllText: 'Wyświetl/Ukryj wszystkie',
|
|
36
|
+
columnsManagementReset: 'Resetuj',
|
|
38
37
|
// Filter panel text
|
|
39
38
|
filterPanelAddFilter: 'Dodaj filtr',
|
|
40
39
|
filterPanelRemoveAll: 'Usuń wszystkie',
|
|
@@ -48,9 +47,9 @@ const plPLGrid = {
|
|
|
48
47
|
filterPanelInputPlaceholder: 'Filtrowana wartość',
|
|
49
48
|
// Filter operators text
|
|
50
49
|
filterOperatorContains: 'zawiera',
|
|
51
|
-
|
|
50
|
+
filterOperatorDoesNotContain: 'nie zawiera',
|
|
52
51
|
filterOperatorEquals: 'równa się',
|
|
53
|
-
|
|
52
|
+
filterOperatorDoesNotEqual: 'nie równa się',
|
|
54
53
|
filterOperatorStartsWith: 'zaczyna się od',
|
|
55
54
|
filterOperatorEndsWith: 'kończy się na',
|
|
56
55
|
filterOperatorIs: 'równa się',
|
|
@@ -71,27 +70,26 @@ const plPLGrid = {
|
|
|
71
70
|
|
|
72
71
|
// Header filter operators text
|
|
73
72
|
headerFilterOperatorContains: 'Zawiera',
|
|
74
|
-
|
|
73
|
+
headerFilterOperatorDoesNotContain: 'Nie zawiera',
|
|
75
74
|
headerFilterOperatorEquals: 'Równa się',
|
|
76
|
-
|
|
75
|
+
headerFilterOperatorDoesNotEqual: 'Nie równa się',
|
|
77
76
|
headerFilterOperatorStartsWith: 'Zaczyna się od',
|
|
78
77
|
headerFilterOperatorEndsWith: 'Kończy się na',
|
|
79
|
-
|
|
78
|
+
headerFilterOperatorIs: 'Jest',
|
|
80
79
|
headerFilterOperatorNot: 'Niepuste',
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
80
|
+
headerFilterOperatorAfter: 'Jest po',
|
|
81
|
+
headerFilterOperatorOnOrAfter: 'Jest w lub po',
|
|
82
|
+
headerFilterOperatorBefore: 'Jest przed',
|
|
83
|
+
headerFilterOperatorOnOrBefore: 'Jest w lub przed',
|
|
84
|
+
headerFilterOperatorIsEmpty: 'Jest pusty',
|
|
85
|
+
headerFilterOperatorIsNotEmpty: 'Nie jest pusty',
|
|
86
|
+
headerFilterOperatorIsAnyOf: 'Is any of',
|
|
87
|
+
'headerFilterOperator=': 'Równa się',
|
|
88
|
+
'headerFilterOperator!=': 'Nie równa się',
|
|
89
|
+
'headerFilterOperator>': 'Większy niż',
|
|
90
|
+
'headerFilterOperator>=': 'Większy lub równy',
|
|
91
|
+
'headerFilterOperator<': 'Mniejszy niż',
|
|
92
|
+
'headerFilterOperator<=': 'Mniejszy lub równe',
|
|
95
93
|
// Filter values text
|
|
96
94
|
filterValueAny: 'dowolny',
|
|
97
95
|
filterValueTrue: 'prawda',
|
|
@@ -139,14 +137,13 @@ const plPLGrid = {
|
|
|
139
137
|
groupColumn: name => `Grupuj według ${name}`,
|
|
140
138
|
unGroupColumn: name => `Rozgrupuj ${name}`,
|
|
141
139
|
// Master/detail
|
|
142
|
-
|
|
140
|
+
detailPanelToggle: 'Szczegóły',
|
|
143
141
|
expandDetailPanel: 'Rozwiń',
|
|
144
142
|
collapseDetailPanel: 'Zwiń',
|
|
145
143
|
// Row reordering text
|
|
146
|
-
rowReorderingHeaderName: 'Porządkowanie wierszy'
|
|
147
|
-
|
|
144
|
+
rowReorderingHeaderName: 'Porządkowanie wierszy',
|
|
148
145
|
// Aggregation
|
|
149
|
-
|
|
146
|
+
aggregationMenuItemHeader: 'Agregacja'
|
|
150
147
|
// aggregationFunctionLabelSum: 'sum',
|
|
151
148
|
// aggregationFunctionLabelAvg: 'avg',
|
|
152
149
|
// aggregationFunctionLabelMin: 'min',
|
package/locales/trTR.js
CHANGED
|
@@ -69,9 +69,9 @@ const trTRGrid = {
|
|
|
69
69
|
'filterOperator<=': '<=',
|
|
70
70
|
// Header filter operators text
|
|
71
71
|
headerFilterOperatorContains: 'Şunu içerir',
|
|
72
|
-
|
|
72
|
+
headerFilterOperatorDoesNotContain: 'İçermez',
|
|
73
73
|
headerFilterOperatorEquals: 'Şuna eşittir',
|
|
74
|
-
|
|
74
|
+
headerFilterOperatorDoesNotEqual: 'Eşit değildir',
|
|
75
75
|
headerFilterOperatorStartsWith: 'Şununla başlar',
|
|
76
76
|
headerFilterOperatorEndsWith: 'Şununla biter',
|
|
77
77
|
headerFilterOperatorIs: 'Eşittir',
|
package/material/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import MUIBadge from '@mui/material/Badge';
|
|
3
3
|
import MUICheckbox from '@mui/material/Checkbox';
|
|
4
4
|
import MUIDivider from '@mui/material/Divider';
|
|
5
|
+
import MUIMenuList from '@mui/material/MenuList';
|
|
6
|
+
import MUIMenuItem from '@mui/material/MenuItem';
|
|
5
7
|
import MUITextField from '@mui/material/TextField';
|
|
6
8
|
import MUIFormControl from '@mui/material/FormControl';
|
|
7
9
|
import MUISelect from '@mui/material/Select';
|
|
@@ -56,6 +58,8 @@ const materialSlots = _extends({}, iconSlots, {
|
|
|
56
58
|
baseBadge: MUIBadge,
|
|
57
59
|
baseCheckbox: MUICheckbox,
|
|
58
60
|
baseDivider: MUIDivider,
|
|
61
|
+
baseMenuList: MUIMenuList,
|
|
62
|
+
baseMenuItem: MUIMenuItem,
|
|
59
63
|
baseTextField: MUITextField,
|
|
60
64
|
baseFormControl: MUIFormControl,
|
|
61
65
|
baseSelect: MUISelect,
|
|
@@ -23,6 +23,16 @@ export interface GridBaseSlots {
|
|
|
23
23
|
* @default Divider
|
|
24
24
|
*/
|
|
25
25
|
baseDivider: React.JSXElementConstructor<GridSlotProps['baseDivider']>;
|
|
26
|
+
/**
|
|
27
|
+
* The custom MenuList component used in the grid.
|
|
28
|
+
* @default MenuList
|
|
29
|
+
*/
|
|
30
|
+
baseMenuList: React.JSXElementConstructor<GridSlotProps['baseMenuList']>;
|
|
31
|
+
/**
|
|
32
|
+
* The custom MenuItem component used in the grid.
|
|
33
|
+
* @default MenuItem
|
|
34
|
+
*/
|
|
35
|
+
baseMenuItem: React.JSXElementConstructor<GridSlotProps['baseMenuItem']>;
|
|
26
36
|
/**
|
|
27
37
|
* The custom InputAdornment component used in the grid.
|
|
28
38
|
* @default InputAdornment
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { BadgeProps } from '@mui/material/Badge';
|
|
3
3
|
import type { CheckboxProps } from '@mui/material/Checkbox';
|
|
4
|
+
import type { MenuListProps } from '@mui/material/MenuList';
|
|
5
|
+
import type { MenuItemProps } from '@mui/material/MenuItem';
|
|
4
6
|
import type { TextFieldProps } from '@mui/material/TextField';
|
|
5
7
|
import type { FormControlProps } from '@mui/material/FormControl';
|
|
6
8
|
import type { SelectProps } from '@mui/material/Select';
|
|
@@ -38,6 +40,10 @@ export interface BaseCheckboxPropsOverrides {
|
|
|
38
40
|
}
|
|
39
41
|
export interface BaseDividerPropsOverrides {
|
|
40
42
|
}
|
|
43
|
+
export interface BaseMenuListPropsOverrides {
|
|
44
|
+
}
|
|
45
|
+
export interface BaseMenuItemPropsOverrides {
|
|
46
|
+
}
|
|
41
47
|
export interface BaseTextFieldPropsOverrides {
|
|
42
48
|
}
|
|
43
49
|
export interface BaseFormControlPropsOverrides {
|
|
@@ -104,6 +110,8 @@ export interface GridSlotProps {
|
|
|
104
110
|
baseBadge: BadgeProps & BaseBadgePropsOverrides;
|
|
105
111
|
baseCheckbox: CheckboxProps & BaseCheckboxPropsOverrides;
|
|
106
112
|
baseDivider: DividerProps & BaseDividerPropsOverrides;
|
|
113
|
+
baseMenuList: MenuListProps & BaseMenuListPropsOverrides;
|
|
114
|
+
baseMenuItem: MenuItemProps & BaseMenuItemPropsOverrides;
|
|
107
115
|
baseTextField: TextFieldProps & BaseTextFieldPropsOverrides;
|
|
108
116
|
baseFormControl: FormControlProps & BaseFormControlPropsOverrides;
|
|
109
117
|
baseSelect: SelectProps & BaseSelectPropsOverrides;
|
|
@@ -613,7 +613,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
613
613
|
* @param {GridPaginationModel} model Updated pagination model.
|
|
614
614
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
615
615
|
*/
|
|
616
|
-
onPaginationModelChange?: (model: GridPaginationModel, details: GridCallbackDetails) => void;
|
|
616
|
+
onPaginationModelChange?: (model: GridPaginationModel, details: GridCallbackDetails<'pagination'>) => void;
|
|
617
617
|
/**
|
|
618
618
|
* Callback fired when the row count has changed.
|
|
619
619
|
* @param {number} count Updated row count.
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { GridFilterInputBoolean } from "../components/panel/filterPanel/GridFilterInputBoolean.js";
|
|
1
|
+
import { GridFilterInputBoolean, sanitizeFilterItemValue } from "../components/panel/filterPanel/GridFilterInputBoolean.js";
|
|
2
2
|
export const getGridBooleanOperators = () => [{
|
|
3
3
|
value: 'is',
|
|
4
4
|
getApplyFilterFn: filterItem => {
|
|
5
|
-
|
|
5
|
+
const sanitizedValue = sanitizeFilterItemValue(filterItem.value);
|
|
6
|
+
if (sanitizedValue === undefined) {
|
|
6
7
|
return null;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
return value => {
|
|
10
|
-
return Boolean(value) === valueAsBoolean;
|
|
11
|
-
};
|
|
9
|
+
return value => Boolean(value) === sanitizedValue;
|
|
12
10
|
},
|
|
13
11
|
InputComponent: GridFilterInputBoolean
|
|
14
12
|
}];
|