@mui/x-data-grid 9.12.0 → 9.14.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 +301 -0
- package/DataGrid/DataGrid.js +1 -1
- package/DataGrid/DataGrid.mjs +1 -1
- package/components/GridPagination.js +1 -1
- package/components/GridPagination.mjs +1 -1
- package/components/GridRow.d.mts +1 -0
- package/components/GridRow.d.ts +1 -0
- package/components/GridRow.js +41 -6
- package/components/GridRow.mjs +41 -6
- package/components/GridScrollArea.js +20 -7
- package/components/GridScrollArea.mjs +21 -8
- package/components/base/GridOverlays.js +6 -5
- package/components/base/GridOverlays.mjs +6 -5
- package/components/cell/GridActionsCell.js +53 -50
- package/components/cell/GridActionsCell.mjs +53 -50
- package/components/cell/GridActionsCellItem.js +0 -1
- package/components/cell/GridActionsCellItem.mjs +0 -1
- package/components/cell/GridCell.js +15 -4
- package/components/cell/GridCell.mjs +15 -4
- package/components/cell/GridEditBooleanCell.d.mts +1 -1
- package/components/cell/GridEditBooleanCell.d.ts +1 -1
- package/components/cell/GridEditBooleanCell.js +4 -4
- package/components/cell/GridEditBooleanCell.mjs +4 -4
- package/components/cell/GridEditDateCell.d.mts +1 -1
- package/components/cell/GridEditDateCell.d.ts +1 -1
- package/components/cell/GridEditDateCell.js +5 -5
- package/components/cell/GridEditDateCell.mjs +5 -5
- package/components/cell/GridEditInputCell.d.mts +1 -1
- package/components/cell/GridEditInputCell.d.ts +1 -1
- package/components/cell/GridEditInputCell.js +1 -1
- package/components/cell/GridEditInputCell.mjs +1 -1
- package/components/cell/GridEditLongTextCell.d.mts +1 -1
- package/components/cell/GridEditLongTextCell.d.ts +1 -1
- package/components/cell/GridEditLongTextCell.js +2 -2
- package/components/cell/GridEditLongTextCell.mjs +2 -2
- package/components/cell/GridEditSingleSelectCell.d.mts +1 -1
- package/components/cell/GridEditSingleSelectCell.d.ts +1 -1
- package/components/cell/GridEditSingleSelectCell.js +4 -4
- package/components/cell/GridEditSingleSelectCell.mjs +4 -4
- package/components/quickFilter/QuickFilter.js +7 -2
- package/components/quickFilter/QuickFilter.mjs +7 -2
- package/components/toolbarV8/Toolbar.d.mts +5 -1
- package/components/toolbarV8/Toolbar.d.ts +5 -1
- package/components/toolbarV8/Toolbar.js +34 -12
- package/components/toolbarV8/Toolbar.mjs +33 -11
- package/components/virtualization/GridVirtualScroller.js +3 -0
- package/components/virtualization/GridVirtualScroller.mjs +3 -0
- package/hooks/core/useGridVirtualizer.js +14 -1
- package/hooks/core/useGridVirtualizer.mjs +14 -1
- package/hooks/features/columnResize/useGridColumnResize.js +4 -1
- package/hooks/features/columnResize/useGridColumnResize.mjs +4 -1
- package/hooks/features/dataSource/models.d.mts +2 -2
- package/hooks/features/dataSource/models.d.ts +2 -2
- package/hooks/features/dataSource/useGridDataSourceBase.js +12 -8
- package/hooks/features/dataSource/useGridDataSourceBase.mjs +13 -9
- package/hooks/features/pivoting/gridPivotingInterfaces.d.mts +2 -2
- package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +2 -2
- package/hooks/features/rowSelection/useGridRowSelection.d.mts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +51 -10
- package/hooks/features/rowSelection/useGridRowSelection.mjs +53 -12
- package/hooks/features/rowSelection/utils.js +5 -0
- package/hooks/features/rowSelection/utils.mjs +5 -0
- package/hooks/features/rows/gridRowsUtils.d.mts +37 -3
- package/hooks/features/rows/gridRowsUtils.d.ts +37 -3
- package/hooks/features/rows/gridRowsUtils.js +120 -23
- package/hooks/features/rows/gridRowsUtils.mjs +115 -22
- package/hooks/features/rows/useGridRows.js +10 -1
- package/hooks/features/rows/useGridRows.mjs +10 -1
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/index.d.mts +2 -2
- package/internals/index.d.ts +2 -2
- package/internals/index.js +28 -0
- package/internals/index.mjs +2 -2
- package/material/variables.d.mts +6 -1
- package/material/variables.d.ts +6 -1
- package/material/variables.js +17 -3
- package/material/variables.mjs +14 -4
- package/models/api/gridRowApi.d.mts +7 -7
- package/models/api/gridRowApi.d.ts +7 -7
- package/models/gridDataSource.d.mts +3 -0
- package/models/gridDataSource.d.ts +3 -0
- package/models/gridRows.d.mts +28 -1
- package/models/gridRows.d.ts +28 -1
- package/models/props/DataGridProps.d.mts +3 -3
- package/models/props/DataGridProps.d.ts +3 -3
- package/package.json +6 -6
- package/utils/keyboardUtils.d.mts +1 -0
- package/utils/keyboardUtils.d.ts +1 -0
- package/utils/keyboardUtils.js +6 -0
- package/utils/keyboardUtils.mjs +5 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
3
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
3
4
|
import { gridRowNodeSelector } from "./gridRowsSelector.mjs";
|
|
4
5
|
export const GRID_ROOT_GROUP_ID = `auto-generated-group-node-root`;
|
|
5
6
|
export const GRID_ID_AUTOGENERATED = Symbol('mui.id_autogenerated');
|
|
@@ -159,6 +160,79 @@ export const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows, di
|
|
|
159
160
|
}
|
|
160
161
|
return validDescendants;
|
|
161
162
|
};
|
|
163
|
+
export const isReplaceUpdate = update =>
|
|
164
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
165
|
+
update._action === 'replace';
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Extracts the replacement row from a `{ _action: 'replace', row }` update.
|
|
169
|
+
* The marker lives on the throwaway envelope, so the row object itself is never touched.
|
|
170
|
+
* @param {GridRowModelReplace} update The update provided to `updateRows()`.
|
|
171
|
+
* @returns {GridRowModel} The object to store as the row, verbatim.
|
|
172
|
+
*/
|
|
173
|
+
export const getReplaceRow = update => {
|
|
174
|
+
const {
|
|
175
|
+
row
|
|
176
|
+
} = update;
|
|
177
|
+
if (row == null) {
|
|
178
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Data Grid: A row update with \`_action: 'replace'\` was provided without a \`row\` property.
|
|
179
|
+
Without it, the Data Grid does not know which object to store for that row.
|
|
180
|
+
Provide the replacement object in the \`row\` property, for example \`updateRows([{ _action: 'replace', row }])\`.
|
|
181
|
+
For more detail, see https://mui.com/x/react-data-grid/row-updates/.` : _formatErrorMessage(304));
|
|
182
|
+
}
|
|
183
|
+
return row;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Merges a partial update into the existing row.
|
|
188
|
+
* Prototype-preservation rules:
|
|
189
|
+
* 1. If partialRow is a class instance (non-plain object), use its prototype — the
|
|
190
|
+
* caller is passing in a fully-constructed instance and owns the prototype chain.
|
|
191
|
+
* 2. If partialRow is a plain object (Object.prototype), prefer oldRow's prototype so
|
|
192
|
+
* that a partial-update object does not silently discard the existing row's class.
|
|
193
|
+
* 3. If both are plain objects the result is also a plain object (no-op).
|
|
194
|
+
*
|
|
195
|
+
* Note: private class fields (#field syntax) cannot be preserved through a spread-style
|
|
196
|
+
* merge because the brand check is tied to the original instance. Rows that rely on
|
|
197
|
+
* private fields must either supply a fully-constructed instance as partialRow (rule 1
|
|
198
|
+
* above) or use `_action: 'replace'` rather than a plain-object partial update.
|
|
199
|
+
* @param {GridRowModel} oldRow The row currently stored in the lookup.
|
|
200
|
+
* @param {GridRowModelUpdate} partialRow The update to merge into it.
|
|
201
|
+
* @returns {GridRowModel} The merged row.
|
|
202
|
+
*/
|
|
203
|
+
export const mergeRowUpdate = (oldRow, partialRow) => {
|
|
204
|
+
const partialRowProto = Object.getPrototypeOf(partialRow);
|
|
205
|
+
const isPartialRowPlain = partialRowProto === Object.prototype || partialRowProto === null;
|
|
206
|
+
const proto = isPartialRowPlain ? Object.getPrototypeOf(oldRow) : partialRowProto;
|
|
207
|
+
const merged = Object.create(proto);
|
|
208
|
+
Object.assign(merged, oldRow, partialRow);
|
|
209
|
+
return merged;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Warns when a replace demotes a class instance to a plain object, which happens when the
|
|
214
|
+
* replacement was built with a spread instead of being passed as-is.
|
|
215
|
+
* Dev-only, does nothing in production.
|
|
216
|
+
* @param {GridRowModel | undefined} oldRow The row being replaced, if any.
|
|
217
|
+
* @param {GridRowModel} replacement The row provided in a `{ _action: 'replace', row }` update.
|
|
218
|
+
*/
|
|
219
|
+
export const warnIfReplaceLosesPrototype = (oldRow, replacement) => {
|
|
220
|
+
if (process.env.NODE_ENV === 'production' || !oldRow) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const replacementProto = Object.getPrototypeOf(replacement);
|
|
224
|
+
if (replacementProto !== Object.prototype && replacementProto !== null) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const oldRowProto = Object.getPrototypeOf(oldRow);
|
|
228
|
+
if (oldRowProto === Object.prototype || oldRowProto === null) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// The message must stay free of row-specific details: `warnOnce()` caches by message, so
|
|
233
|
+
// interpolating the id would log once per row and grow the cache with every update.
|
|
234
|
+
warnOnce(["MUI X Data Grid: A plain object was provided as the `row` of a `_action: 'replace'` update, but the row it replaces is a class instance.", "Building the replacement with a spread (`{ _action: 'replace', row: { ...row } }`) creates a plain object, dropping the prototype chain and the private fields that `_action: 'replace'` exists to preserve.", "Pass the instance itself instead, for example `{ _action: 'replace', row }`.", 'For more detail, see https://mui.com/x/react-data-grid/row-updates/.']);
|
|
235
|
+
};
|
|
162
236
|
export const updateCacheWithNewRows = ({
|
|
163
237
|
previousCache,
|
|
164
238
|
getRowId,
|
|
@@ -172,10 +246,28 @@ export const updateCacheWithNewRows = ({
|
|
|
172
246
|
// Remove duplicate updates.
|
|
173
247
|
// A server can batch updates, and send several updates for the same row in one fn call.
|
|
174
248
|
const uniqueUpdates = new Map();
|
|
249
|
+
// Ids whose accumulated update is stored as the row instead of being merged into the
|
|
250
|
+
// existing one. The flag lives outside the row object so that it is never mutated.
|
|
251
|
+
const replaceIds = new Set();
|
|
175
252
|
updates.forEach(update => {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
253
|
+
// A replace is provided as a `{ _action: 'replace', row }` envelope: the marker stays
|
|
254
|
+
// on the throwaway envelope and the inner row is used verbatim, so that the object
|
|
255
|
+
// provided by the caller is the one that ends up in the lookup.
|
|
256
|
+
const isReplace = isReplaceUpdate(update);
|
|
257
|
+
const row = isReplace ? getReplaceRow(update) : update;
|
|
258
|
+
const id = getRowIdFromRowModel(row, getRowId, 'A row was provided without id when calling updateRows():');
|
|
259
|
+
if (isReplace) {
|
|
260
|
+
// A replace resets whatever has been accumulated for that id.
|
|
261
|
+
uniqueUpdates.set(id, row);
|
|
262
|
+
replaceIds.add(id);
|
|
263
|
+
} else if (uniqueUpdates.has(id)) {
|
|
264
|
+
const accumulatedUpdate = uniqueUpdates.get(id);
|
|
265
|
+
if (process.env.NODE_ENV !== 'production' && replaceIds.has(id)) {
|
|
266
|
+
warnOnce(["MUI X Data Grid: A row was provided with `_action: 'replace'` but it is not the last update for that row in this batch.", 'The remaining updates are merged onto the replacement, so the row keeps its prototype but is neither the same object nor carries its `#private` fields, which a merge cannot copy.', 'Make the replace the last update for that row if `apiRef.current.getRow(id)` must return the object you passed in.', 'For more detail, see https://mui.com/x/react-data-grid/row-updates/.']);
|
|
267
|
+
}
|
|
268
|
+
// The merge keeps the accumulated entry's prototype and the id stays in `replaceIds`,
|
|
269
|
+
// so the result is still applied as a replace.
|
|
270
|
+
uniqueUpdates.set(id, mergeRowUpdate(accumulatedUpdate, update));
|
|
179
271
|
} else {
|
|
180
272
|
uniqueUpdates.set(id, update);
|
|
181
273
|
}
|
|
@@ -227,6 +319,15 @@ export const updateCacheWithNewRows = ({
|
|
|
227
319
|
}
|
|
228
320
|
const oldRow = dataRowIdToModelLookup[id];
|
|
229
321
|
|
|
322
|
+
// Action === "replace"
|
|
323
|
+
// The bookkeeping is the same as for "modify" / "insert" below, only the way the row
|
|
324
|
+
// is stored differs: the object is stored as-is so that its prototype chain, private
|
|
325
|
+
// fields (#field) and reference identity are all preserved.
|
|
326
|
+
const isReplace = replaceIds.has(id);
|
|
327
|
+
if (isReplace) {
|
|
328
|
+
warnIfReplaceLosesPrototype(oldRow, partialRow);
|
|
329
|
+
}
|
|
330
|
+
|
|
230
331
|
// Action === "modify"
|
|
231
332
|
if (oldRow) {
|
|
232
333
|
// If the data row has been removed since the last state update,
|
|
@@ -242,23 +343,7 @@ export const updateCacheWithNewRows = ({
|
|
|
242
343
|
}
|
|
243
344
|
|
|
244
345
|
// Update the data row lookups.
|
|
245
|
-
|
|
246
|
-
// 1. If partialRow is a class instance (non-plain object), use its prototype — the
|
|
247
|
-
// caller is passing in a fully-constructed instance and owns the prototype chain.
|
|
248
|
-
// 2. If partialRow is a plain object (Object.prototype), prefer oldRow's prototype so
|
|
249
|
-
// that a partial-update object does not silently discard the existing row's class.
|
|
250
|
-
// 3. If both are plain objects the result is also a plain object (no-op).
|
|
251
|
-
//
|
|
252
|
-
// Note: private class fields (#field syntax) cannot be preserved through a spread-style
|
|
253
|
-
// merge because the brand check is tied to the original instance. Rows that rely on
|
|
254
|
-
// private fields must supply a fully-constructed instance as partialRow (rule 1 above)
|
|
255
|
-
// rather than a plain-object partial update.
|
|
256
|
-
const partialRowProto = Object.getPrototypeOf(partialRow);
|
|
257
|
-
const isPartialRowPlain = partialRowProto === Object.prototype || partialRowProto === null;
|
|
258
|
-
const proto = isPartialRowPlain ? Object.getPrototypeOf(oldRow) : partialRowProto;
|
|
259
|
-
const merged = Object.create(proto);
|
|
260
|
-
Object.assign(merged, oldRow, partialRow);
|
|
261
|
-
dataRowIdToModelLookup[id] = merged;
|
|
346
|
+
dataRowIdToModelLookup[id] = isReplace ? partialRow : mergeRowUpdate(oldRow, partialRow);
|
|
262
347
|
return;
|
|
263
348
|
}
|
|
264
349
|
|
|
@@ -299,16 +384,24 @@ export const minimalContentHeight = 'var(--DataGrid-overlayHeight, calc(var(--he
|
|
|
299
384
|
export function computeRowsUpdates(apiRef, updates, getRowId) {
|
|
300
385
|
const nonPinnedRowsUpdates = [];
|
|
301
386
|
updates.forEach(update => {
|
|
302
|
-
const
|
|
387
|
+
const isReplace = isReplaceUpdate(update);
|
|
388
|
+
const row = isReplace ? getReplaceRow(update) : update;
|
|
389
|
+
const id = getRowIdFromRowModel(row, getRowId, 'A row was provided without id when calling updateRows():');
|
|
303
390
|
const rowNode = gridRowNodeSelector(apiRef, id);
|
|
304
391
|
if (rowNode?.type === 'pinnedRow') {
|
|
305
392
|
// @ts-ignore because otherwise `release:build` doesn't work
|
|
306
393
|
const pinnedRowsCache = apiRef.current.caches.pinnedRows;
|
|
307
394
|
const prevModel = pinnedRowsCache.idLookup[id];
|
|
308
395
|
if (prevModel) {
|
|
309
|
-
|
|
396
|
+
if (isReplace) {
|
|
397
|
+
warnIfReplaceLosesPrototype(prevModel, row);
|
|
398
|
+
pinnedRowsCache.idLookup[id] = row;
|
|
399
|
+
} else {
|
|
400
|
+
pinnedRowsCache.idLookup[id] = mergeRowUpdate(prevModel, update);
|
|
401
|
+
}
|
|
310
402
|
}
|
|
311
403
|
} else {
|
|
404
|
+
// The envelope is passed through untouched, `updateCacheWithNewRows` unwraps it.
|
|
312
405
|
nonPinnedRowsUpdates.push(update);
|
|
313
406
|
}
|
|
314
407
|
});
|
|
@@ -57,6 +57,7 @@ const useGridRows = (apiRef, props, configuration) => {
|
|
|
57
57
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridRows');
|
|
58
58
|
const lastUpdateMs = React.useRef(Date.now());
|
|
59
59
|
const lastRowCount = React.useRef(props.rowCount);
|
|
60
|
+
const lastGetRowId = React.useRef(props.getRowId);
|
|
60
61
|
const timeout = (0, _useTimeout.useTimeout)();
|
|
61
62
|
|
|
62
63
|
// Get overridable methods from configuration
|
|
@@ -450,8 +451,16 @@ You need to upgrade to DataGridPro or DataGridPremium component to unlock this f
|
|
|
450
451
|
isRowCountPropUpdated = true;
|
|
451
452
|
lastRowCount.current = props.rowCount;
|
|
452
453
|
}
|
|
454
|
+
let isGetRowIdPropUpdated = false;
|
|
455
|
+
if (props.getRowId !== lastGetRowId.current) {
|
|
456
|
+
isGetRowIdPropUpdated = true;
|
|
457
|
+
lastGetRowId.current = props.getRowId;
|
|
458
|
+
}
|
|
453
459
|
const currentRows = props.dataSource ? (0, _gridRowsSelector.gridDataRowsSelector)(apiRef) : props.rows;
|
|
454
|
-
|
|
460
|
+
// Data source rows live in the state, not in props: there is never a new set to apply, and
|
|
461
|
+
// `gridDataRowsSelector` returns a new array each time so the identity check never holds.
|
|
462
|
+
// Only a new `getRowId` needs a rebuild, to re-key them.
|
|
463
|
+
const areNewRowsAlreadyInState = props.dataSource ? !isGetRowIdPropUpdated : apiRef.current.caches.rows.rowsBeforePartialUpdates === currentRows;
|
|
455
464
|
const isNewLoadingAlreadyInState = apiRef.current.caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
456
465
|
const isNewRowCountAlreadyInState = apiRef.current.caches.rows.rowCountPropBeforePartialUpdates === props.rowCount;
|
|
457
466
|
|
|
@@ -49,6 +49,7 @@ export const useGridRows = (apiRef, props, configuration) => {
|
|
|
49
49
|
const logger = useGridLogger(apiRef, 'useGridRows');
|
|
50
50
|
const lastUpdateMs = React.useRef(Date.now());
|
|
51
51
|
const lastRowCount = React.useRef(props.rowCount);
|
|
52
|
+
const lastGetRowId = React.useRef(props.getRowId);
|
|
52
53
|
const timeout = useTimeout();
|
|
53
54
|
|
|
54
55
|
// Get overridable methods from configuration
|
|
@@ -442,8 +443,16 @@ You need to upgrade to DataGridPro or DataGridPremium component to unlock this f
|
|
|
442
443
|
isRowCountPropUpdated = true;
|
|
443
444
|
lastRowCount.current = props.rowCount;
|
|
444
445
|
}
|
|
446
|
+
let isGetRowIdPropUpdated = false;
|
|
447
|
+
if (props.getRowId !== lastGetRowId.current) {
|
|
448
|
+
isGetRowIdPropUpdated = true;
|
|
449
|
+
lastGetRowId.current = props.getRowId;
|
|
450
|
+
}
|
|
445
451
|
const currentRows = props.dataSource ? gridDataRowsSelector(apiRef) : props.rows;
|
|
446
|
-
|
|
452
|
+
// Data source rows live in the state, not in props: there is never a new set to apply, and
|
|
453
|
+
// `gridDataRowsSelector` returns a new array each time so the identity check never holds.
|
|
454
|
+
// Only a new `getRowId` needs a rebuild, to re-key them.
|
|
455
|
+
const areNewRowsAlreadyInState = props.dataSource ? !isGetRowIdPropUpdated : apiRef.current.caches.rows.rowsBeforePartialUpdates === currentRows;
|
|
447
456
|
const isNewLoadingAlreadyInState = apiRef.current.caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
448
457
|
const isNewRowCountAlreadyInState = apiRef.current.caches.rows.rowCountPropBeforePartialUpdates === props.rowCount;
|
|
449
458
|
|
package/index.js
CHANGED
package/index.mjs
CHANGED
package/internals/index.d.mts
CHANGED
|
@@ -67,7 +67,7 @@ export type { GridRowTreeCreationParams, GridRowTreeCreationValue, GridHydrateRo
|
|
|
67
67
|
export { getTreeNodeDescendants, buildRootGroup } from "../hooks/features/rows/gridRowsUtils.mjs";
|
|
68
68
|
export { useGridRowsMeta, rowsMetaStateInitializer } from "../hooks/features/rows/useGridRowsMeta.mjs";
|
|
69
69
|
export { useGridParamsApi } from "../hooks/features/rows/useGridParamsApi.mjs";
|
|
70
|
-
export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED, getRowValue } from "../hooks/features/rows/gridRowsUtils.mjs";
|
|
70
|
+
export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED, getRowValue, isReplaceUpdate, getReplaceRow, warnIfReplaceLosesPrototype } from "../hooks/features/rows/gridRowsUtils.mjs";
|
|
71
71
|
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, gridRowSelector } from "../hooks/features/rows/gridRowsSelector.mjs";
|
|
72
72
|
export { headerFilteringStateInitializer, useGridHeaderFiltering } from "../hooks/features/headerFiltering/useGridHeaderFiltering.mjs";
|
|
73
73
|
export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.mjs";
|
|
@@ -110,7 +110,7 @@ export { NotRendered } from "../utils/assert.mjs";
|
|
|
110
110
|
export { createSelector, createRootSelector, createSelectorMemoized } from "../utils/createSelector.mjs";
|
|
111
111
|
export { gridRowGroupsToFetchSelector } from "../hooks/features/rows/gridRowsSelector.mjs";
|
|
112
112
|
export { findParentElementFromClassName, getActiveElement, getGridCellElement, isEventTargetInPortal } from "../utils/domUtils.mjs";
|
|
113
|
-
export { isNavigationKey, isPasteShortcut, isCopyShortcut, isUndoShortcut, isRedoShortcut, isFillDownShortcut, isFillRightShortcut } from "../utils/keyboardUtils.mjs";
|
|
113
|
+
export { isNavigationKey, isPasteShortcut, isCopyShortcut, isSelectAllShortcut, isUndoShortcut, isRedoShortcut, isFillDownShortcut, isFillRightShortcut } from "../utils/keyboardUtils.mjs";
|
|
114
114
|
export * from "../utils/utils.mjs";
|
|
115
115
|
export { exportAs } from "../utils/exportAs.mjs";
|
|
116
116
|
export * from "../utils/getPublicApiRef.mjs";
|
package/internals/index.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export type { GridRowTreeCreationParams, GridRowTreeCreationValue, GridHydrateRo
|
|
|
67
67
|
export { getTreeNodeDescendants, buildRootGroup } from "../hooks/features/rows/gridRowsUtils.js";
|
|
68
68
|
export { useGridRowsMeta, rowsMetaStateInitializer } from "../hooks/features/rows/useGridRowsMeta.js";
|
|
69
69
|
export { useGridParamsApi } from "../hooks/features/rows/useGridParamsApi.js";
|
|
70
|
-
export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED, getRowValue } from "../hooks/features/rows/gridRowsUtils.js";
|
|
70
|
+
export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED, getRowValue, isReplaceUpdate, getReplaceRow, warnIfReplaceLosesPrototype } from "../hooks/features/rows/gridRowsUtils.js";
|
|
71
71
|
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, gridRowSelector } from "../hooks/features/rows/gridRowsSelector.js";
|
|
72
72
|
export { headerFilteringStateInitializer, useGridHeaderFiltering } from "../hooks/features/headerFiltering/useGridHeaderFiltering.js";
|
|
73
73
|
export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.js";
|
|
@@ -110,7 +110,7 @@ export { NotRendered } from "../utils/assert.js";
|
|
|
110
110
|
export { createSelector, createRootSelector, createSelectorMemoized } from "../utils/createSelector.js";
|
|
111
111
|
export { gridRowGroupsToFetchSelector } from "../hooks/features/rows/gridRowsSelector.js";
|
|
112
112
|
export { findParentElementFromClassName, getActiveElement, getGridCellElement, isEventTargetInPortal } from "../utils/domUtils.js";
|
|
113
|
-
export { isNavigationKey, isPasteShortcut, isCopyShortcut, isUndoShortcut, isRedoShortcut, isFillDownShortcut, isFillRightShortcut } from "../utils/keyboardUtils.js";
|
|
113
|
+
export { isNavigationKey, isPasteShortcut, isCopyShortcut, isSelectAllShortcut, isUndoShortcut, isRedoShortcut, isFillDownShortcut, isFillRightShortcut } from "../utils/keyboardUtils.js";
|
|
114
114
|
export * from "../utils/utils.js";
|
|
115
115
|
export { exportAs } from "../utils/exportAs.js";
|
|
116
116
|
export * from "../utils/getPublicApiRef.js";
|
package/internals/index.js
CHANGED
|
@@ -80,6 +80,9 @@ var _exportNames = {
|
|
|
80
80
|
getRowIdFromRowModel: true,
|
|
81
81
|
GRID_ID_AUTOGENERATED: true,
|
|
82
82
|
getRowValue: true,
|
|
83
|
+
isReplaceUpdate: true,
|
|
84
|
+
getReplaceRow: true,
|
|
85
|
+
warnIfReplaceLosesPrototype: true,
|
|
83
86
|
useGridRowsMeta: true,
|
|
84
87
|
rowsMetaStateInitializer: true,
|
|
85
88
|
useGridParamsApi: true,
|
|
@@ -131,6 +134,7 @@ var _exportNames = {
|
|
|
131
134
|
isNavigationKey: true,
|
|
132
135
|
isPasteShortcut: true,
|
|
133
136
|
isCopyShortcut: true,
|
|
137
|
+
isSelectAllShortcut: true,
|
|
134
138
|
isUndoShortcut: true,
|
|
135
139
|
isRedoShortcut: true,
|
|
136
140
|
isFillDownShortcut: true,
|
|
@@ -389,6 +393,12 @@ Object.defineProperty(exports, "getGridFilter", {
|
|
|
389
393
|
return _GridFilterPanel.getGridFilter;
|
|
390
394
|
}
|
|
391
395
|
});
|
|
396
|
+
Object.defineProperty(exports, "getReplaceRow", {
|
|
397
|
+
enumerable: true,
|
|
398
|
+
get: function () {
|
|
399
|
+
return _gridRowsUtils.getReplaceRow;
|
|
400
|
+
}
|
|
401
|
+
});
|
|
392
402
|
Object.defineProperty(exports, "getRowIdFromRowModel", {
|
|
393
403
|
enumerable: true,
|
|
394
404
|
get: function () {
|
|
@@ -581,6 +591,18 @@ Object.defineProperty(exports, "isRedoShortcut", {
|
|
|
581
591
|
return _keyboardUtils.isRedoShortcut;
|
|
582
592
|
}
|
|
583
593
|
});
|
|
594
|
+
Object.defineProperty(exports, "isReplaceUpdate", {
|
|
595
|
+
enumerable: true,
|
|
596
|
+
get: function () {
|
|
597
|
+
return _gridRowsUtils.isReplaceUpdate;
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
Object.defineProperty(exports, "isSelectAllShortcut", {
|
|
601
|
+
enumerable: true,
|
|
602
|
+
get: function () {
|
|
603
|
+
return _keyboardUtils.isSelectAllShortcut;
|
|
604
|
+
}
|
|
605
|
+
});
|
|
584
606
|
Object.defineProperty(exports, "isSingleSelectColDef", {
|
|
585
607
|
enumerable: true,
|
|
586
608
|
get: function () {
|
|
@@ -971,6 +993,12 @@ Object.defineProperty(exports, "vars", {
|
|
|
971
993
|
return _cssVariables.vars;
|
|
972
994
|
}
|
|
973
995
|
});
|
|
996
|
+
Object.defineProperty(exports, "warnIfReplaceLosesPrototype", {
|
|
997
|
+
enumerable: true,
|
|
998
|
+
get: function () {
|
|
999
|
+
return _gridRowsUtils.warnIfReplaceLosesPrototype;
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
974
1002
|
var _gridStringColDef = require("../colDef/gridStringColDef");
|
|
975
1003
|
var _gridColumnTypesRegistry = require("../colDef/gridColumnTypesRegistry");
|
|
976
1004
|
var _gridPropsSelectors = require("../hooks/core/gridPropsSelectors");
|
package/internals/index.mjs
CHANGED
|
@@ -54,7 +54,7 @@ export { useGridRowsPreProcessors } from "../hooks/features/rows/useGridRowsPreP
|
|
|
54
54
|
export { getTreeNodeDescendants, buildRootGroup } from "../hooks/features/rows/gridRowsUtils.mjs";
|
|
55
55
|
export { useGridRowsMeta, rowsMetaStateInitializer } from "../hooks/features/rows/useGridRowsMeta.mjs";
|
|
56
56
|
export { useGridParamsApi } from "../hooks/features/rows/useGridParamsApi.mjs";
|
|
57
|
-
export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED, getRowValue } from "../hooks/features/rows/gridRowsUtils.mjs";
|
|
57
|
+
export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED, getRowValue, isReplaceUpdate, getReplaceRow, warnIfReplaceLosesPrototype } from "../hooks/features/rows/gridRowsUtils.mjs";
|
|
58
58
|
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, gridRowSelector } from "../hooks/features/rows/gridRowsSelector.mjs";
|
|
59
59
|
export { headerFilteringStateInitializer, useGridHeaderFiltering } from "../hooks/features/headerFiltering/useGridHeaderFiltering.mjs";
|
|
60
60
|
export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.mjs";
|
|
@@ -88,7 +88,7 @@ export { NotRendered } from "../utils/assert.mjs";
|
|
|
88
88
|
export { createSelector, createRootSelector, createSelectorMemoized } from "../utils/createSelector.mjs";
|
|
89
89
|
export { gridRowGroupsToFetchSelector } from "../hooks/features/rows/gridRowsSelector.mjs";
|
|
90
90
|
export { findParentElementFromClassName, getActiveElement, getGridCellElement, isEventTargetInPortal } from "../utils/domUtils.mjs";
|
|
91
|
-
export { isNavigationKey, isPasteShortcut, isCopyShortcut, isUndoShortcut, isRedoShortcut, isFillDownShortcut, isFillRightShortcut } from "../utils/keyboardUtils.mjs";
|
|
91
|
+
export { isNavigationKey, isPasteShortcut, isCopyShortcut, isSelectAllShortcut, isUndoShortcut, isRedoShortcut, isFillDownShortcut, isFillRightShortcut } from "../utils/keyboardUtils.mjs";
|
|
92
92
|
export * from "../utils/utils.mjs";
|
|
93
93
|
export { exportAs } from "../utils/exportAs.mjs";
|
|
94
94
|
export * from "../utils/getPublicApiRef.mjs";
|
package/material/variables.d.mts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import type { Theme } from '@mui/material/styles';
|
|
1
2
|
import type { GridCSSVariablesInterface } from "../constants/cssVariables.mjs";
|
|
2
3
|
export declare function useMaterialCSSVariables(): {
|
|
3
4
|
id: string;
|
|
4
5
|
variables: GridCSSVariablesInterface;
|
|
5
|
-
};
|
|
6
|
+
};
|
|
7
|
+
export declare function getBackgroundBase(theme: Theme): string;
|
|
8
|
+
export declare function getFontBody(theme: Theme): any;
|
|
9
|
+
export declare function getSpacingUnit(theme: Theme): any;
|
|
10
|
+
export declare function getBorderColor(theme: Theme): string;
|
package/material/variables.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import type { Theme } from '@mui/material/styles';
|
|
1
2
|
import type { GridCSSVariablesInterface } from "../constants/cssVariables.js";
|
|
2
3
|
export declare function useMaterialCSSVariables(): {
|
|
3
4
|
id: string;
|
|
4
5
|
variables: GridCSSVariablesInterface;
|
|
5
|
-
};
|
|
6
|
+
};
|
|
7
|
+
export declare function getBackgroundBase(theme: Theme): string;
|
|
8
|
+
export declare function getFontBody(theme: Theme): any;
|
|
9
|
+
export declare function getSpacingUnit(theme: Theme): any;
|
|
10
|
+
export declare function getBorderColor(theme: Theme): string;
|
package/material/variables.js
CHANGED
|
@@ -4,6 +4,10 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.getBackgroundBase = getBackgroundBase;
|
|
8
|
+
exports.getBorderColor = getBorderColor;
|
|
9
|
+
exports.getFontBody = getFontBody;
|
|
10
|
+
exports.getSpacingUnit = getSpacingUnit;
|
|
7
11
|
exports.useMaterialCSSVariables = useMaterialCSSVariables;
|
|
8
12
|
var React = _interopRequireWildcard(require("react"));
|
|
9
13
|
var _styles = require("@mui/material/styles");
|
|
@@ -25,19 +29,19 @@ function transformTheme(t) {
|
|
|
25
29
|
const borderColor = getBorderColor(t);
|
|
26
30
|
const dataGridPalette = (t.vars || t).palette.DataGrid;
|
|
27
31
|
const paperColor = (t.vars || t).palette.background.paper;
|
|
28
|
-
const backgroundBase =
|
|
32
|
+
const backgroundBase = getBackgroundBase(t);
|
|
29
33
|
const backgroundHeader = dataGridPalette?.headerBg ?? backgroundBase;
|
|
30
34
|
const backgroundPinned = dataGridPalette?.pinnedBg ?? backgroundBase;
|
|
31
35
|
const backgroundBackdrop = t.alpha((t.vars || t).palette.background.default, (t.vars || t).palette.action.disabledOpacity);
|
|
32
36
|
const backgroundOverlay = t.palette.mode === 'dark' ? (0, _GridRootStyles.colorMixIfSupported)(`color-mix(in srgb, ${paperColor} 90%, #fff)`, paperColor) : paperColor;
|
|
33
37
|
const selectedColor = (t.vars || t).palette.primary.main;
|
|
34
38
|
const radius = getRadius(t);
|
|
35
|
-
const fontBody =
|
|
39
|
+
const fontBody = getFontBody(t);
|
|
36
40
|
const fontSmall = t.vars?.font?.caption ?? formatFont(t.typography.caption);
|
|
37
41
|
const fontLarge = t.vars?.font?.body1 ?? formatFont(t.typography.body1);
|
|
38
42
|
const k = _cssVariables.vars.keys;
|
|
39
43
|
return {
|
|
40
|
-
[k.spacingUnit]:
|
|
44
|
+
[k.spacingUnit]: getSpacingUnit(t),
|
|
41
45
|
[k.colors.border.base]: borderColor,
|
|
42
46
|
[k.colors.background.base]: backgroundBase,
|
|
43
47
|
[k.colors.background.overlay]: backgroundOverlay,
|
|
@@ -85,6 +89,16 @@ function getRadius(theme) {
|
|
|
85
89
|
}
|
|
86
90
|
return typeof theme.shape.borderRadius === 'number' ? `${theme.shape.borderRadius}px` : theme.shape.borderRadius;
|
|
87
91
|
}
|
|
92
|
+
function getBackgroundBase(theme) {
|
|
93
|
+
const paperColor = (theme.vars || theme).palette.background.paper;
|
|
94
|
+
return (theme.vars || theme).palette.DataGrid?.bg ?? (theme.palette.mode === 'dark' ? (0, _GridRootStyles.colorMixIfSupported)(`color-mix(in srgb, ${paperColor} 95%, #fff)`, paperColor) : paperColor);
|
|
95
|
+
}
|
|
96
|
+
function getFontBody(theme) {
|
|
97
|
+
return theme.vars?.font?.body2 ?? formatFont(theme.typography.body2);
|
|
98
|
+
}
|
|
99
|
+
function getSpacingUnit(theme) {
|
|
100
|
+
return theme.vars ? theme.vars.spacing ?? theme.spacing(1) : theme.spacing(1);
|
|
101
|
+
}
|
|
88
102
|
function getBorderColor(theme) {
|
|
89
103
|
if (theme.vars) {
|
|
90
104
|
return theme.vars.palette.TableCell.border;
|
package/material/variables.mjs
CHANGED
|
@@ -18,19 +18,19 @@ function transformTheme(t) {
|
|
|
18
18
|
const borderColor = getBorderColor(t);
|
|
19
19
|
const dataGridPalette = (t.vars || t).palette.DataGrid;
|
|
20
20
|
const paperColor = (t.vars || t).palette.background.paper;
|
|
21
|
-
const backgroundBase =
|
|
21
|
+
const backgroundBase = getBackgroundBase(t);
|
|
22
22
|
const backgroundHeader = dataGridPalette?.headerBg ?? backgroundBase;
|
|
23
23
|
const backgroundPinned = dataGridPalette?.pinnedBg ?? backgroundBase;
|
|
24
24
|
const backgroundBackdrop = t.alpha((t.vars || t).palette.background.default, (t.vars || t).palette.action.disabledOpacity);
|
|
25
25
|
const backgroundOverlay = t.palette.mode === 'dark' ? colorMixIfSupported(`color-mix(in srgb, ${paperColor} 90%, #fff)`, paperColor) : paperColor;
|
|
26
26
|
const selectedColor = (t.vars || t).palette.primary.main;
|
|
27
27
|
const radius = getRadius(t);
|
|
28
|
-
const fontBody =
|
|
28
|
+
const fontBody = getFontBody(t);
|
|
29
29
|
const fontSmall = t.vars?.font?.caption ?? formatFont(t.typography.caption);
|
|
30
30
|
const fontLarge = t.vars?.font?.body1 ?? formatFont(t.typography.body1);
|
|
31
31
|
const k = vars.keys;
|
|
32
32
|
return {
|
|
33
|
-
[k.spacingUnit]:
|
|
33
|
+
[k.spacingUnit]: getSpacingUnit(t),
|
|
34
34
|
[k.colors.border.base]: borderColor,
|
|
35
35
|
[k.colors.background.base]: backgroundBase,
|
|
36
36
|
[k.colors.background.overlay]: backgroundOverlay,
|
|
@@ -78,7 +78,17 @@ function getRadius(theme) {
|
|
|
78
78
|
}
|
|
79
79
|
return typeof theme.shape.borderRadius === 'number' ? `${theme.shape.borderRadius}px` : theme.shape.borderRadius;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
export function getBackgroundBase(theme) {
|
|
82
|
+
const paperColor = (theme.vars || theme).palette.background.paper;
|
|
83
|
+
return (theme.vars || theme).palette.DataGrid?.bg ?? (theme.palette.mode === 'dark' ? colorMixIfSupported(`color-mix(in srgb, ${paperColor} 95%, #fff)`, paperColor) : paperColor);
|
|
84
|
+
}
|
|
85
|
+
export function getFontBody(theme) {
|
|
86
|
+
return theme.vars?.font?.body2 ?? formatFont(theme.typography.body2);
|
|
87
|
+
}
|
|
88
|
+
export function getSpacingUnit(theme) {
|
|
89
|
+
return theme.vars ? theme.vars.spacing ?? theme.spacing(1) : theme.spacing(1);
|
|
90
|
+
}
|
|
91
|
+
export function getBorderColor(theme) {
|
|
82
92
|
if (theme.vars) {
|
|
83
93
|
return theme.vars.palette.TableCell.border;
|
|
84
94
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GridRowModel, GridRowId, GridRowModelUpdate, GridValidRowModel, GridTreeNode } from "../gridRows.mjs";
|
|
1
|
+
import type { GridRowModel, GridRowId, GridRowModelUpdate, GridRowModelReplace, GridValidRowModel, GridTreeNode } from "../gridRows.mjs";
|
|
2
2
|
export type RowReorderDropPosition = 'above' | 'below' | 'inside';
|
|
3
3
|
export type RowReorderDragDirection = 'up' | 'down';
|
|
4
4
|
export interface GridRowGroupChildrenGetterParams {
|
|
@@ -58,10 +58,10 @@ export interface GridRowApi {
|
|
|
58
58
|
*/
|
|
59
59
|
setRows: (rows: GridRowModel[]) => void;
|
|
60
60
|
/**
|
|
61
|
-
* Allows to update, insert and delete rows.
|
|
62
|
-
* @param {GridRowModelUpdate
|
|
61
|
+
* Allows to update, insert, replace and delete rows.
|
|
62
|
+
* @param {Array<GridRowModelUpdate | GridRowModelReplace>} updates An array of rows with an `action` specifying what to do.
|
|
63
63
|
*/
|
|
64
|
-
updateRows: (updates: GridRowModelUpdate
|
|
64
|
+
updateRows: (updates: Array<GridRowModelUpdate | GridRowModelReplace>) => void;
|
|
65
65
|
/**
|
|
66
66
|
* Gets the row data with a given id.
|
|
67
67
|
* @param {GridRowId} id The id of the row.
|
|
@@ -139,11 +139,11 @@ export interface GridRowProApi {
|
|
|
139
139
|
}
|
|
140
140
|
export interface GridRowProPrivateApi {
|
|
141
141
|
/**
|
|
142
|
-
* Allows to update, insert and delete rows at a specific nested level.
|
|
143
|
-
* @param {GridRowModelUpdate
|
|
142
|
+
* Allows to update, insert, replace and delete rows at a specific nested level.
|
|
143
|
+
* @param {Array<GridRowModelUpdate | GridRowModelReplace>} updates An array of rows with an `action` specifying what to do.
|
|
144
144
|
* @param {string[]} nestedLevel The nested level of the rows to update, it represents the path to the row in the tree based on `node.groupingKey`.
|
|
145
145
|
*/
|
|
146
|
-
updateNestedRows: (updates: GridRowModelUpdate
|
|
146
|
+
updateNestedRows: (updates: Array<GridRowModelUpdate | GridRowModelReplace>, nestedLevel?: string[]) => void;
|
|
147
147
|
}
|
|
148
148
|
export interface GridRowSpanningPrivateApi {
|
|
149
149
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GridRowModel, GridRowId, GridRowModelUpdate, GridValidRowModel, GridTreeNode } from "../gridRows.js";
|
|
1
|
+
import type { GridRowModel, GridRowId, GridRowModelUpdate, GridRowModelReplace, GridValidRowModel, GridTreeNode } from "../gridRows.js";
|
|
2
2
|
export type RowReorderDropPosition = 'above' | 'below' | 'inside';
|
|
3
3
|
export type RowReorderDragDirection = 'up' | 'down';
|
|
4
4
|
export interface GridRowGroupChildrenGetterParams {
|
|
@@ -58,10 +58,10 @@ export interface GridRowApi {
|
|
|
58
58
|
*/
|
|
59
59
|
setRows: (rows: GridRowModel[]) => void;
|
|
60
60
|
/**
|
|
61
|
-
* Allows to update, insert and delete rows.
|
|
62
|
-
* @param {GridRowModelUpdate
|
|
61
|
+
* Allows to update, insert, replace and delete rows.
|
|
62
|
+
* @param {Array<GridRowModelUpdate | GridRowModelReplace>} updates An array of rows with an `action` specifying what to do.
|
|
63
63
|
*/
|
|
64
|
-
updateRows: (updates: GridRowModelUpdate
|
|
64
|
+
updateRows: (updates: Array<GridRowModelUpdate | GridRowModelReplace>) => void;
|
|
65
65
|
/**
|
|
66
66
|
* Gets the row data with a given id.
|
|
67
67
|
* @param {GridRowId} id The id of the row.
|
|
@@ -139,11 +139,11 @@ export interface GridRowProApi {
|
|
|
139
139
|
}
|
|
140
140
|
export interface GridRowProPrivateApi {
|
|
141
141
|
/**
|
|
142
|
-
* Allows to update, insert and delete rows at a specific nested level.
|
|
143
|
-
* @param {GridRowModelUpdate
|
|
142
|
+
* Allows to update, insert, replace and delete rows at a specific nested level.
|
|
143
|
+
* @param {Array<GridRowModelUpdate | GridRowModelReplace>} updates An array of rows with an `action` specifying what to do.
|
|
144
144
|
* @param {string[]} nestedLevel The nested level of the rows to update, it represents the path to the row in the tree based on `node.groupingKey`.
|
|
145
145
|
*/
|
|
146
|
-
updateNestedRows: (updates: GridRowModelUpdate
|
|
146
|
+
updateNestedRows: (updates: Array<GridRowModelUpdate | GridRowModelReplace>, nestedLevel?: string[]) => void;
|
|
147
147
|
}
|
|
148
148
|
export interface GridRowSpanningPrivateApi {
|
|
149
149
|
/**
|
|
@@ -64,6 +64,9 @@ export interface GridDataSource {
|
|
|
64
64
|
getRows(params: GridGetRowsParams): Promise<GridGetRowsResponse>;
|
|
65
65
|
/**
|
|
66
66
|
* This method will be called when the user updates a row.
|
|
67
|
+
* Resolve with the updated row to merge it into the existing one, or with a
|
|
68
|
+
* `{ _action: 'replace', row }` update ([[GridRowModelReplace]]) to store `row` as the new row
|
|
69
|
+
* without merging, which preserves its prototype chain, its `#private` fields and its identity.
|
|
67
70
|
* @param {GridUpdateRowParams} params The parameters required to update the row.
|
|
68
71
|
* @returns {Promise<any>} If resolved (synced on the backend), the grid will update the row and mutate the cache.
|
|
69
72
|
*/
|
|
@@ -64,6 +64,9 @@ export interface GridDataSource {
|
|
|
64
64
|
getRows(params: GridGetRowsParams): Promise<GridGetRowsResponse>;
|
|
65
65
|
/**
|
|
66
66
|
* This method will be called when the user updates a row.
|
|
67
|
+
* Resolve with the updated row to merge it into the existing one, or with a
|
|
68
|
+
* `{ _action: 'replace', row }` update ([[GridRowModelReplace]]) to store `row` as the new row
|
|
69
|
+
* without merging, which preserves its prototype chain, its `#private` fields and its identity.
|
|
67
70
|
* @param {GridUpdateRowParams} params The parameters required to update the row.
|
|
68
71
|
* @returns {Promise<any>} If resolved (synced on the backend), the grid will update the row and mutate the cache.
|
|
69
72
|
*/
|
package/models/gridRows.d.mts
CHANGED
|
@@ -7,9 +7,36 @@ export type GridRowsProp<R extends GridValidRowModel = GridValidRowModel> = Read
|
|
|
7
7
|
* The key value object representing the data of a row.
|
|
8
8
|
*/
|
|
9
9
|
export type GridRowModel<R extends GridValidRowModel = GridValidRowModel> = R;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use `GridRowModelUpdate` or `GridRowModelReplace` instead.
|
|
12
|
+
*/
|
|
10
13
|
export type GridUpdateAction = 'delete';
|
|
11
14
|
export interface GridRowModelUpdate extends GridRowModel {
|
|
12
|
-
|
|
15
|
+
/**
|
|
16
|
+
* - `'delete'` removes the row.
|
|
17
|
+
* - `undefined` (default) performs a shallow, `Object.assign`-style partial merge into
|
|
18
|
+
* the existing row, which produces a new object.
|
|
19
|
+
*
|
|
20
|
+
* To store an object as the row without merging, see [[GridRowModelReplace]].
|
|
21
|
+
*/
|
|
22
|
+
_action?: 'delete';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A row update that stores `row` as-is instead of merging it into the existing row.
|
|
26
|
+
* Use this when the row is a class instance (e.g. one with `#private` fields) whose
|
|
27
|
+
* prototype chain and object identity must be preserved across the update:
|
|
28
|
+
* `apiRef.current.getRow(id)` then returns the very object provided in `row`.
|
|
29
|
+
* Any field missing from `row` is removed from the stored row, because a replace is
|
|
30
|
+
* never a merge.
|
|
31
|
+
* It can be passed to `updateRows()` or returned from `processRowUpdate()`.
|
|
32
|
+
*/
|
|
33
|
+
export interface GridRowModelReplace<R extends GridValidRowModel = GridValidRowModel> {
|
|
34
|
+
_action: 'replace';
|
|
35
|
+
/**
|
|
36
|
+
* The object stored as the new row, verbatim. Pass the instance itself — spreading it
|
|
37
|
+
* (`{ ...row }`) creates a plain object and defeats the purpose.
|
|
38
|
+
*/
|
|
39
|
+
row: R;
|
|
13
40
|
}
|
|
14
41
|
/**
|
|
15
42
|
* The grid rows total height and row positions.
|