@mui/x-data-grid 5.11.0 → 5.11.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 +101 -16
- package/README.md +1 -2
- package/components/base/GridOverlays.js +1 -1
- package/components/containers/GridRoot.js +25 -5
- package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
- package/components/toolbar/GridToolbarQuickFilter.js +1 -2
- package/constants/defaultGridSlotsComponents.js +3 -2
- package/constants/gridClasses.d.ts +12 -0
- package/constants/gridClasses.js +1 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +4 -0
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -9
- package/hooks/features/rows/gridRowsState.d.ts +14 -5
- package/hooks/features/rows/gridRowsUtils.d.ts +13 -1
- package/hooks/features/rows/gridRowsUtils.js +54 -0
- package/hooks/features/rows/useGridRows.js +63 -102
- package/index.js +1 -1
- package/legacy/components/base/GridOverlays.js +1 -1
- package/legacy/components/containers/GridRoot.js +23 -5
- package/legacy/components/toolbar/GridToolbarQuickFilter.js +1 -2
- package/legacy/constants/defaultGridSlotsComponents.js +3 -2
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -10
- package/legacy/hooks/features/rows/gridRowsUtils.js +55 -0
- package/legacy/hooks/features/rows/useGridRows.js +75 -111
- package/legacy/index.js +1 -1
- package/legacy/locales/ruRU.js +3 -3
- package/locales/ruRU.js +3 -3
- package/models/api/gridCoreApi.d.ts +1 -1
- package/models/gridIconSlotsComponent.d.ts +5 -0
- package/modern/components/base/GridOverlays.js +1 -1
- package/modern/components/containers/GridRoot.js +25 -3
- package/modern/components/toolbar/GridToolbarQuickFilter.js +1 -2
- package/modern/constants/defaultGridSlotsComponents.js +3 -2
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -9
- package/modern/hooks/features/rows/gridRowsUtils.js +54 -0
- package/modern/hooks/features/rows/useGridRows.js +63 -102
- package/modern/index.js +1 -1
- package/modern/locales/ruRU.js +3 -3
- package/node/components/base/GridOverlays.js +1 -1
- package/node/components/containers/GridRoot.js +24 -3
- package/node/components/toolbar/GridToolbarQuickFilter.js +1 -3
- package/node/constants/defaultGridSlotsComponents.js +2 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -8
- package/node/hooks/features/rows/gridRowsUtils.js +67 -1
- package/node/hooks/features/rows/useGridRows.js +63 -99
- package/node/index.js +1 -1
- package/node/locales/ruRU.js +3 -3
- package/package.json +3 -2
|
@@ -7,76 +7,21 @@ import { GridSignature, useGridApiEventHandler } from '../../utils/useGridApiEve
|
|
|
7
7
|
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
8
8
|
import { gridSortedRowIdsSelector } from '../sorting/gridSortingSelector';
|
|
9
9
|
import { gridFilteredRowsLookupSelector } from '../filter/gridFilterSelector';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
function getGridRowId(rowModel, getRowId, detailErrorMessage) {
|
|
13
|
-
const id = getRowId ? getRowId(rowModel) : rowModel.id;
|
|
14
|
-
checkGridRowIdIsValid(id, rowModel, detailErrorMessage);
|
|
15
|
-
return id;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const convertRowsPropToState = ({
|
|
19
|
-
prevCache: prevState,
|
|
20
|
-
rows,
|
|
21
|
-
getRowId
|
|
22
|
-
}) => {
|
|
23
|
-
let value;
|
|
24
|
-
|
|
25
|
-
if (rows) {
|
|
26
|
-
value = {
|
|
27
|
-
idRowsLookup: {},
|
|
28
|
-
idToIdLookup: {},
|
|
29
|
-
ids: []
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
for (let i = 0; i < rows.length; i += 1) {
|
|
33
|
-
const row = rows[i];
|
|
34
|
-
const id = getGridRowId(row, getRowId);
|
|
35
|
-
value.idRowsLookup[id] = row;
|
|
36
|
-
value.idToIdLookup[id] = id;
|
|
37
|
-
value.ids.push(id);
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
value = prevState.value;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
value,
|
|
45
|
-
rowsBeforePartialUpdates: rows != null ? rows : prevState.rowsBeforePartialUpdates
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const getRowsStateFromCache = (rowsCache, previousTree, apiRef, rowCountProp, loadingProp) => {
|
|
50
|
-
const {
|
|
51
|
-
value
|
|
52
|
-
} = rowsCache;
|
|
53
|
-
const rowCount = rowCountProp != null ? rowCountProp : 0;
|
|
54
|
-
const groupingResponse = apiRef.current.unstable_applyStrategyProcessor('rowTreeCreation', _extends({}, value, {
|
|
55
|
-
previousTree
|
|
56
|
-
}));
|
|
57
|
-
const dataTopLevelRowCount = groupingResponse.treeDepth === 1 ? groupingResponse.ids.length : Object.values(groupingResponse.tree).filter(node => node.parent == null).length;
|
|
58
|
-
return _extends({}, groupingResponse, {
|
|
59
|
-
loading: loadingProp,
|
|
60
|
-
totalRowCount: Math.max(rowCount, groupingResponse.ids.length),
|
|
61
|
-
totalTopLevelRowCount: Math.max(rowCount, dataTopLevelRowCount)
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
|
|
10
|
+
import { getTreeNodeDescendants, createRowsInternalCache, getRowsStateFromCache, getRowIdFromRowModel } from './gridRowsUtils';
|
|
11
|
+
import { useGridRegisterPipeApplier } from '../../core/pipeProcessing';
|
|
65
12
|
export const rowsStateInitializer = (state, props, apiRef) => {
|
|
66
|
-
apiRef.current.unstable_caches.rows =
|
|
13
|
+
apiRef.current.unstable_caches.rows = createRowsInternalCache({
|
|
67
14
|
rows: props.rows,
|
|
68
15
|
getRowId: props.getRowId,
|
|
69
|
-
|
|
70
|
-
value: {
|
|
71
|
-
idRowsLookup: {},
|
|
72
|
-
idToIdLookup: {},
|
|
73
|
-
ids: []
|
|
74
|
-
},
|
|
75
|
-
rowsBeforePartialUpdates: []
|
|
76
|
-
}
|
|
16
|
+
loading: props.loading
|
|
77
17
|
});
|
|
78
18
|
return _extends({}, state, {
|
|
79
|
-
rows: getRowsStateFromCache(
|
|
19
|
+
rows: getRowsStateFromCache({
|
|
20
|
+
apiRef,
|
|
21
|
+
previousTree: null,
|
|
22
|
+
rowCountProp: props.rowCount,
|
|
23
|
+
loadingProp: props.loading
|
|
24
|
+
})
|
|
80
25
|
});
|
|
81
26
|
};
|
|
82
27
|
export const useGridRows = (apiRef, props) => {
|
|
@@ -105,7 +50,12 @@ export const useGridRows = (apiRef, props) => {
|
|
|
105
50
|
timeout.current = null;
|
|
106
51
|
lastUpdateMs.current = Date.now();
|
|
107
52
|
apiRef.current.setState(state => _extends({}, state, {
|
|
108
|
-
rows: getRowsStateFromCache(
|
|
53
|
+
rows: getRowsStateFromCache({
|
|
54
|
+
apiRef,
|
|
55
|
+
previousTree: gridRowTreeSelector(apiRef),
|
|
56
|
+
rowCountProp: props.rowCount,
|
|
57
|
+
loadingProp: props.loading
|
|
58
|
+
})
|
|
109
59
|
}));
|
|
110
60
|
apiRef.current.publishEvent('rowsSet');
|
|
111
61
|
apiRef.current.forceUpdate();
|
|
@@ -138,12 +88,12 @@ export const useGridRows = (apiRef, props) => {
|
|
|
138
88
|
|
|
139
89
|
const setRows = React.useCallback(rows => {
|
|
140
90
|
logger.debug(`Updating all rows, new length ${rows.length}`);
|
|
141
|
-
throttledRowsChange(
|
|
91
|
+
throttledRowsChange(createRowsInternalCache({
|
|
142
92
|
rows,
|
|
143
|
-
|
|
144
|
-
|
|
93
|
+
getRowId: props.getRowId,
|
|
94
|
+
loading: props.loading
|
|
145
95
|
}), true);
|
|
146
|
-
}, [
|
|
96
|
+
}, [logger, props.getRowId, props.loading, throttledRowsChange]);
|
|
147
97
|
const updateRows = React.useCallback(updates => {
|
|
148
98
|
if (props.signature === GridSignature.DataGrid && updates.length > 1) {
|
|
149
99
|
// TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
|
|
@@ -153,7 +103,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
153
103
|
|
|
154
104
|
const uniqUpdates = new Map();
|
|
155
105
|
updates.forEach(update => {
|
|
156
|
-
const id =
|
|
106
|
+
const id = getRowIdFromRowModel(update, props.getRowId, 'A row was provided without id when calling updateRows():');
|
|
157
107
|
|
|
158
108
|
if (uniqUpdates.has(id)) {
|
|
159
109
|
uniqUpdates.set(id, _extends({}, uniqUpdates.get(id), update));
|
|
@@ -162,16 +112,19 @@ export const useGridRows = (apiRef, props) => {
|
|
|
162
112
|
}
|
|
163
113
|
});
|
|
164
114
|
const deletedRowIds = [];
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
115
|
+
const prevCache = apiRef.current.unstable_caches.rows;
|
|
116
|
+
const newCache = {
|
|
117
|
+
rowsBeforePartialUpdates: prevCache.rowsBeforePartialUpdates,
|
|
118
|
+
loadingPropBeforePartialUpdates: prevCache.loadingPropBeforePartialUpdates,
|
|
119
|
+
idRowsLookup: _extends({}, prevCache.idRowsLookup),
|
|
120
|
+
idToIdLookup: _extends({}, prevCache.idToIdLookup),
|
|
121
|
+
ids: [...prevCache.ids]
|
|
169
122
|
};
|
|
170
123
|
uniqUpdates.forEach((partialRow, id) => {
|
|
171
124
|
// eslint-disable-next-line no-underscore-dangle
|
|
172
125
|
if (partialRow._action === 'delete') {
|
|
173
|
-
delete
|
|
174
|
-
delete
|
|
126
|
+
delete newCache.idRowsLookup[id];
|
|
127
|
+
delete newCache.idToIdLookup[id];
|
|
175
128
|
deletedRowIds.push(id);
|
|
176
129
|
return;
|
|
177
130
|
}
|
|
@@ -179,24 +132,20 @@ export const useGridRows = (apiRef, props) => {
|
|
|
179
132
|
const oldRow = apiRef.current.getRow(id);
|
|
180
133
|
|
|
181
134
|
if (!oldRow) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
135
|
+
newCache.idRowsLookup[id] = partialRow;
|
|
136
|
+
newCache.idToIdLookup[id] = id;
|
|
137
|
+
newCache.ids.push(id);
|
|
185
138
|
return;
|
|
186
139
|
}
|
|
187
140
|
|
|
188
|
-
|
|
141
|
+
newCache.idRowsLookup[id] = _extends({}, apiRef.current.getRow(id), partialRow);
|
|
189
142
|
});
|
|
190
143
|
|
|
191
144
|
if (deletedRowIds.length > 0) {
|
|
192
|
-
|
|
145
|
+
newCache.ids = newCache.ids.filter(id => !deletedRowIds.includes(id));
|
|
193
146
|
}
|
|
194
147
|
|
|
195
|
-
|
|
196
|
-
value: newStateValue
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
throttledRowsChange(state, true);
|
|
148
|
+
throttledRowsChange(newCache, true);
|
|
200
149
|
}, [props.signature, props.getRowId, throttledRowsChange, apiRef]);
|
|
201
150
|
const getRowModels = React.useCallback(() => {
|
|
202
151
|
const allRows = gridRowIdsSelector(apiRef);
|
|
@@ -310,25 +259,25 @@ export const useGridRows = (apiRef, props) => {
|
|
|
310
259
|
|
|
311
260
|
const groupRows = React.useCallback(() => {
|
|
312
261
|
logger.info(`Row grouping pre-processing have changed, regenerating the row tree`);
|
|
313
|
-
let
|
|
262
|
+
let cache;
|
|
314
263
|
|
|
315
264
|
if (apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows) {
|
|
316
|
-
// The `props.rows`
|
|
317
|
-
// We can
|
|
318
|
-
|
|
265
|
+
// The `props.rows` did not change since the last row grouping
|
|
266
|
+
// We can use the current rows cache which contains the partial updates done recently.
|
|
267
|
+
cache = apiRef.current.unstable_caches.rows;
|
|
319
268
|
} else {
|
|
320
269
|
// The `props.rows` has changed since the last row grouping
|
|
321
270
|
// We must use the new `props.rows` on the new grouping
|
|
322
271
|
// This occurs because this event is triggered before the `useEffect` on the rows when both the grouping pre-processing and the rows changes on the same render
|
|
323
|
-
|
|
272
|
+
cache = createRowsInternalCache({
|
|
273
|
+
rows: props.rows,
|
|
274
|
+
getRowId: props.getRowId,
|
|
275
|
+
loading: props.loading
|
|
276
|
+
});
|
|
324
277
|
}
|
|
325
278
|
|
|
326
|
-
throttledRowsChange(
|
|
327
|
-
|
|
328
|
-
getRowId: props.getRowId,
|
|
329
|
-
prevCache: apiRef.current.unstable_caches.rows
|
|
330
|
-
}), false);
|
|
331
|
-
}, [logger, apiRef, props.rows, props.getRowId, throttledRowsChange]);
|
|
279
|
+
throttledRowsChange(cache, false);
|
|
280
|
+
}, [logger, apiRef, props.rows, props.getRowId, props.loading, throttledRowsChange]);
|
|
332
281
|
const handleStrategyProcessorChange = React.useCallback(methodName => {
|
|
333
282
|
if (methodName === 'rowTreeCreation') {
|
|
334
283
|
groupRows();
|
|
@@ -343,6 +292,18 @@ export const useGridRows = (apiRef, props) => {
|
|
|
343
292
|
}, [apiRef, groupRows]);
|
|
344
293
|
useGridApiEventHandler(apiRef, 'activeStrategyProcessorChange', handleStrategyProcessorChange);
|
|
345
294
|
useGridApiEventHandler(apiRef, 'strategyAvailabilityChange', handleStrategyActivityChange);
|
|
295
|
+
/**
|
|
296
|
+
* APPLIERS
|
|
297
|
+
*/
|
|
298
|
+
|
|
299
|
+
const applyHydrateRowsProcessor = React.useCallback(() => {
|
|
300
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
301
|
+
rows: _extends({}, state.rows, apiRef.current.unstable_applyPipeProcessors('hydrateRows', state.rows.groupingResponseBeforeRowHydration))
|
|
302
|
+
}));
|
|
303
|
+
apiRef.current.publishEvent('rowsSet');
|
|
304
|
+
apiRef.current.forceUpdate();
|
|
305
|
+
}, [apiRef]);
|
|
306
|
+
useGridRegisterPipeApplier(apiRef, 'hydrateRows', applyHydrateRowsProcessor);
|
|
346
307
|
useGridApiMethod(apiRef, rowApi, 'GridRowApi');
|
|
347
308
|
/**
|
|
348
309
|
* EFFECTS
|
|
@@ -365,15 +326,15 @@ export const useGridRows = (apiRef, props) => {
|
|
|
365
326
|
} // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
|
|
366
327
|
|
|
367
328
|
|
|
368
|
-
if (apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows) {
|
|
329
|
+
if (apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows && apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading) {
|
|
369
330
|
return;
|
|
370
331
|
}
|
|
371
332
|
|
|
372
333
|
logger.debug(`Updating all rows, new length ${props.rows.length}`);
|
|
373
|
-
throttledRowsChange(
|
|
334
|
+
throttledRowsChange(createRowsInternalCache({
|
|
374
335
|
rows: props.rows,
|
|
375
336
|
getRowId: props.getRowId,
|
|
376
|
-
|
|
337
|
+
loading: props.loading
|
|
377
338
|
}), false);
|
|
378
|
-
}, [props.rows, props.rowCount, props.getRowId, logger, throttledRowsChange, apiRef]);
|
|
339
|
+
}, [props.rows, props.rowCount, props.getRowId, props.loading, logger, throttledRowsChange, apiRef]);
|
|
379
340
|
};
|
package/index.js
CHANGED
|
@@ -77,7 +77,7 @@ export function GridOverlays() {
|
|
|
77
77
|
overlay = /*#__PURE__*/_jsx(rootProps.components.NoResultsOverlay, _extends({}, (_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.noResultsOverlay));
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
if (
|
|
80
|
+
if (loading) {
|
|
81
81
|
var _rootProps$components3;
|
|
82
82
|
|
|
83
83
|
overlay = /*#__PURE__*/_jsx(rootProps.components.LoadingOverlay, _extends({}, (_rootProps$components3 = rootProps.componentsProps) == null ? void 0 : _rootProps$components3.loadingOverlay));
|
|
@@ -5,18 +5,29 @@ var _excluded = ["children", "className"];
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
|
-
import { useForkRef, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/material/utils';
|
|
8
|
+
import { useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, capitalize } from '@mui/material/utils';
|
|
9
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
9
10
|
import { GridRootStyles } from './GridRootStyles';
|
|
10
11
|
import { gridVisibleColumnDefinitionsSelector } from '../../hooks/features/columns/gridColumnsSelector';
|
|
11
12
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
12
13
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
13
14
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
14
|
-
import {
|
|
15
|
+
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
15
16
|
import { gridRowCountSelector } from '../../hooks/features/rows/gridRowsSelector';
|
|
17
|
+
import { gridDensityValueSelector } from '../../hooks/features/density/densitySelector';
|
|
16
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
-
var GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
18
|
-
var _rootProps$classes;
|
|
19
19
|
|
|
20
|
+
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
21
|
+
var autoHeight = ownerState.autoHeight,
|
|
22
|
+
density = ownerState.density,
|
|
23
|
+
classes = ownerState.classes;
|
|
24
|
+
var slots = {
|
|
25
|
+
root: ['root', autoHeight && 'autoHeight', "root--density".concat(capitalize(density))]
|
|
26
|
+
};
|
|
27
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
20
31
|
var rootProps = useGridRootProps();
|
|
21
32
|
|
|
22
33
|
var children = props.children,
|
|
@@ -26,8 +37,15 @@ var GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
26
37
|
var apiRef = useGridApiContext();
|
|
27
38
|
var visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
28
39
|
var totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
|
|
40
|
+
var densityValue = useGridSelector(apiRef, gridDensityValueSelector);
|
|
29
41
|
var rootContainerRef = React.useRef(null);
|
|
30
42
|
var handleRef = useForkRef(rootContainerRef, ref);
|
|
43
|
+
var ownerState = {
|
|
44
|
+
density: densityValue,
|
|
45
|
+
classes: rootProps.classes,
|
|
46
|
+
autoHeight: rootProps.autoHeight
|
|
47
|
+
};
|
|
48
|
+
var classes = useUtilityClasses(ownerState);
|
|
31
49
|
apiRef.current.rootElementRef = rootContainerRef; // Our implementation of <NoSsr />
|
|
32
50
|
|
|
33
51
|
var _React$useState = React.useState(false),
|
|
@@ -50,7 +68,7 @@ var GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
50
68
|
|
|
51
69
|
return /*#__PURE__*/_jsx(GridRootStyles, _extends({
|
|
52
70
|
ref: handleRef,
|
|
53
|
-
className: clsx(className,
|
|
71
|
+
className: clsx(className, classes.root),
|
|
54
72
|
role: "grid",
|
|
55
73
|
"aria-colcount": visibleColumns.length,
|
|
56
74
|
"aria-rowcount": totalRowCount,
|
|
@@ -5,7 +5,6 @@ var _excluded = ["quickFilterParser", "debounceMs"];
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import TextField from '@mui/material/TextField';
|
|
8
|
-
import SearchIcon from '@mui/icons-material/Search';
|
|
9
8
|
import { styled } from '@mui/material/styles';
|
|
10
9
|
import { debounce } from '@mui/material/utils';
|
|
11
10
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
@@ -74,7 +73,7 @@ function GridToolbarQuickFilter(props) {
|
|
|
74
73
|
"aria-label": apiRef.current.getLocaleText('toolbarQuickFilterLabel'),
|
|
75
74
|
type: "search",
|
|
76
75
|
InputProps: {
|
|
77
|
-
startAdornment: /*#__PURE__*/_jsx(
|
|
76
|
+
startAdornment: /*#__PURE__*/_jsx(rootProps.components.QuickFilterIcon, {
|
|
78
77
|
fontSize: "small"
|
|
79
78
|
})
|
|
80
79
|
}
|
|
@@ -7,7 +7,7 @@ import MUISwitch from '@mui/material/Switch';
|
|
|
7
7
|
import MUIButton from '@mui/material/Button';
|
|
8
8
|
import MUITooltip from '@mui/material/Tooltip';
|
|
9
9
|
import MUIPopper from '@mui/material/Popper';
|
|
10
|
-
import { GridArrowDownwardIcon, GridArrowUpwardIcon, GridCell, GridCheckIcon, GridCloseIcon, GridColumnIcon, GridColumnMenu, GridColumnsPanel, GridFilterAltIcon, GridFilterListIcon, GridFilterPanel, GridFooter, GridHeader, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridPreferencesPanel, GridRow, GridSaveAltIcon, GridSeparatorIcon, GridTableRowsIcon, GridTripleDotsVerticalIcon, GridViewHeadlineIcon, GridViewStreamIcon, GridMoreVertIcon, GridExpandMoreIcon, GridKeyboardArrowRight, GridAddIcon, GridRemoveIcon, GridDragIcon, GridColumnHeaderFilterIconButton } from '../components';
|
|
10
|
+
import { GridArrowDownwardIcon, GridArrowUpwardIcon, GridCell, GridCheckIcon, GridCloseIcon, GridColumnIcon, GridColumnMenu, GridColumnsPanel, GridFilterAltIcon, GridFilterListIcon, GridFilterPanel, GridFooter, GridHeader, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridPreferencesPanel, GridRow, GridSaveAltIcon, GridSeparatorIcon, GridTableRowsIcon, GridTripleDotsVerticalIcon, GridViewHeadlineIcon, GridViewStreamIcon, GridMoreVertIcon, GridExpandMoreIcon, GridKeyboardArrowRight, GridAddIcon, GridRemoveIcon, GridDragIcon, GridColumnHeaderFilterIconButton, GridSearchIcon } from '../components';
|
|
11
11
|
import { GridColumnUnsortedIcon } from '../components/columnHeaders/GridColumnUnsortedIcon';
|
|
12
12
|
import { ErrorOverlay } from '../components/ErrorOverlay';
|
|
13
13
|
import { GridNoResultsOverlay } from '../components/GridNoResultsOverlay';
|
|
@@ -34,7 +34,8 @@ var DEFAULT_GRID_ICON_SLOTS_COMPONENTS = {
|
|
|
34
34
|
GroupingCriteriaExpandIcon: GridKeyboardArrowRight,
|
|
35
35
|
DetailPanelExpandIcon: GridAddIcon,
|
|
36
36
|
DetailPanelCollapseIcon: GridRemoveIcon,
|
|
37
|
-
RowReorderIcon: GridDragIcon
|
|
37
|
+
RowReorderIcon: GridDragIcon,
|
|
38
|
+
QuickFilterIcon: GridSearchIcon
|
|
38
39
|
};
|
|
39
40
|
/**
|
|
40
41
|
* TODO: Differentiate community and pro value and interface
|
|
@@ -2,4 +2,4 @@ import { generateUtilityClasses, generateUtilityClass } from '@mui/material';
|
|
|
2
2
|
export function getDataGridUtilityClass(slot) {
|
|
3
3
|
return generateUtilityClass('MuiDataGrid', slot);
|
|
4
4
|
}
|
|
5
|
-
export var gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle']);
|
|
5
|
+
export var gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle']);
|
|
@@ -47,31 +47,27 @@ export var useGridPipeProcessing = function useGridPipeProcessing(apiRef) {
|
|
|
47
47
|
var registerPipeProcessor = React.useCallback(function (group, id, processor) {
|
|
48
48
|
if (!processorsCache.current[group]) {
|
|
49
49
|
processorsCache.current[group] = {
|
|
50
|
-
processors:
|
|
50
|
+
processors: new Map(),
|
|
51
51
|
appliers: {}
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
var groupCache = processorsCache.current[group];
|
|
56
|
-
var oldProcessor = groupCache.processors
|
|
56
|
+
var oldProcessor = groupCache.processors.get(id);
|
|
57
57
|
|
|
58
58
|
if (oldProcessor !== processor) {
|
|
59
|
-
groupCache.processors
|
|
59
|
+
groupCache.processors.set(id, processor);
|
|
60
60
|
runAppliers(groupCache);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
return function () {
|
|
64
|
-
|
|
65
|
-
removedGroupProcessor = _processors[id],
|
|
66
|
-
otherProcessors = _objectWithoutProperties(_processors, [id].map(_toPropertyKey));
|
|
67
|
-
|
|
68
|
-
processorsCache.current[group].processors = otherProcessors;
|
|
64
|
+
processorsCache.current[group].processors.set(id, null);
|
|
69
65
|
};
|
|
70
66
|
}, [runAppliers]);
|
|
71
67
|
var registerPipeApplier = React.useCallback(function (group, id, applier) {
|
|
72
68
|
if (!processorsCache.current[group]) {
|
|
73
69
|
processorsCache.current[group] = {
|
|
74
|
-
processors:
|
|
70
|
+
processors: new Map(),
|
|
75
71
|
appliers: {}
|
|
76
72
|
};
|
|
77
73
|
}
|
|
@@ -104,8 +100,12 @@ export var useGridPipeProcessing = function useGridPipeProcessing(apiRef) {
|
|
|
104
100
|
return value;
|
|
105
101
|
}
|
|
106
102
|
|
|
107
|
-
var preProcessors =
|
|
103
|
+
var preProcessors = Array.from(processorsCache.current[group].processors.values());
|
|
108
104
|
return preProcessors.reduce(function (acc, preProcessor) {
|
|
105
|
+
if (!preProcessor) {
|
|
106
|
+
return acc;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
109
|
return preProcessor(acc, context);
|
|
110
110
|
}, value);
|
|
111
111
|
}, []);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["rowsBeforePartialUpdates"];
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* A helper function to check if the id provided is valid.
|
|
@@ -13,6 +16,58 @@ export function checkGridRowIdIsValid(id, row) {
|
|
|
13
16
|
throw new Error(['MUI: The data grid component requires all rows to have a unique `id` property.', 'Alternatively, you can use the `getRowId` prop to specify a custom id for each row.', detailErrorMessage, JSON.stringify(row)].join('\n'));
|
|
14
17
|
}
|
|
15
18
|
}
|
|
19
|
+
export var getRowIdFromRowModel = function getRowIdFromRowModel(rowModel, getRowId, detailErrorMessage) {
|
|
20
|
+
var id = getRowId ? getRowId(rowModel) : rowModel.id;
|
|
21
|
+
checkGridRowIdIsValid(id, rowModel, detailErrorMessage);
|
|
22
|
+
return id;
|
|
23
|
+
};
|
|
24
|
+
export var createRowsInternalCache = function createRowsInternalCache(_ref) {
|
|
25
|
+
var rows = _ref.rows,
|
|
26
|
+
getRowId = _ref.getRowId,
|
|
27
|
+
loading = _ref.loading;
|
|
28
|
+
var cache = {
|
|
29
|
+
rowsBeforePartialUpdates: rows,
|
|
30
|
+
loadingPropBeforePartialUpdates: loading,
|
|
31
|
+
idRowsLookup: {},
|
|
32
|
+
idToIdLookup: {},
|
|
33
|
+
ids: []
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
for (var i = 0; i < rows.length; i += 1) {
|
|
37
|
+
var row = rows[i];
|
|
38
|
+
var id = getRowIdFromRowModel(row, getRowId);
|
|
39
|
+
cache.idRowsLookup[id] = row;
|
|
40
|
+
cache.idToIdLookup[id] = id;
|
|
41
|
+
cache.ids.push(id);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return cache;
|
|
45
|
+
};
|
|
46
|
+
export var getRowsStateFromCache = function getRowsStateFromCache(_ref2) {
|
|
47
|
+
var apiRef = _ref2.apiRef,
|
|
48
|
+
previousTree = _ref2.previousTree,
|
|
49
|
+
rowCountProp = _ref2.rowCountProp,
|
|
50
|
+
loadingProp = _ref2.loadingProp;
|
|
51
|
+
|
|
52
|
+
var _apiRef$current$unsta = apiRef.current.unstable_caches.rows,
|
|
53
|
+
rowsBeforePartialUpdates = _apiRef$current$unsta.rowsBeforePartialUpdates,
|
|
54
|
+
cacheForGrouping = _objectWithoutProperties(_apiRef$current$unsta, _excluded);
|
|
55
|
+
|
|
56
|
+
var rowCount = rowCountProp != null ? rowCountProp : 0;
|
|
57
|
+
var groupingResponse = apiRef.current.unstable_applyStrategyProcessor('rowTreeCreation', _extends({}, cacheForGrouping, {
|
|
58
|
+
previousTree: previousTree
|
|
59
|
+
}));
|
|
60
|
+
var processedGroupingResponse = apiRef.current.unstable_applyPipeProcessors('hydrateRows', groupingResponse);
|
|
61
|
+
var dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(function (node) {
|
|
62
|
+
return node.parent == null;
|
|
63
|
+
}).length;
|
|
64
|
+
return _extends({}, processedGroupingResponse, {
|
|
65
|
+
groupingResponseBeforeRowHydration: groupingResponse,
|
|
66
|
+
loading: loadingProp,
|
|
67
|
+
totalRowCount: Math.max(rowCount, processedGroupingResponse.ids.length),
|
|
68
|
+
totalTopLevelRowCount: Math.max(rowCount, dataTopLevelRowCount)
|
|
69
|
+
});
|
|
70
|
+
};
|
|
16
71
|
export var getTreeNodeDescendants = function getTreeNodeDescendants(tree, parentId, skipAutoGeneratedRows) {
|
|
17
72
|
var _tree$parentId;
|
|
18
73
|
|