@mui/x-data-grid 8.0.0-alpha.2 → 8.0.0-alpha.4
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 +376 -0
- package/DataGrid/DataGrid.js +5 -13
- package/README.md +1 -1
- package/components/GridRow.js +1 -1
- package/components/cell/GridActionsCell.js +8 -1
- package/components/cell/GridCell.js +1 -1
- package/components/columnSelection/GridHeaderCheckbox.js +4 -1
- package/components/panel/GridColumnsPanel.js +1 -2
- package/components/panel/GridPanelContent.js +7 -3
- package/components/panel/GridPanelFooter.d.ts +1 -1
- package/components/panel/GridPanelFooter.js +4 -3
- package/components/panel/filterPanel/GridFilterForm.js +15 -15
- package/constants/dataGridPropsDefaultValues.js +1 -2
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +25 -9
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +5 -1
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +3 -6
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
- package/hooks/core/useGridStateInitialization.js +3 -3
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +4 -4
- package/hooks/features/columnResize/columnResizeSelector.d.ts +1 -1
- package/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +12 -12
- package/hooks/features/density/densitySelector.d.ts +1 -1
- package/hooks/features/editing/useGridCellEditing.js +3 -3
- package/hooks/features/editing/useGridRowEditing.js +3 -3
- package/hooks/features/filter/gridFilterSelector.d.ts +17 -17
- package/hooks/features/filter/useGridFilter.js +1 -1
- package/hooks/features/focus/gridFocusStateSelector.d.ts +8 -8
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +3 -3
- package/hooks/features/overlays/useGridOverlays.js +3 -1
- package/hooks/features/pagination/gridPaginationSelector.d.ts +15 -9
- package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
- package/hooks/features/rowSelection/useGridRowSelection.js +5 -4
- package/hooks/features/rowSelection/utils.d.ts +1 -1
- package/hooks/features/rows/gridRowSpanningSelectors.d.ts +3 -3
- package/hooks/features/rows/gridRowsInterfaces.d.ts +1 -8
- package/hooks/features/rows/gridRowsSelector.d.ts +23 -13
- package/hooks/features/rows/gridRowsSelector.js +0 -1
- package/hooks/features/rows/gridRowsUtils.js +0 -9
- package/hooks/features/rows/index.d.ts +1 -1
- package/hooks/features/rows/index.js +1 -1
- package/hooks/features/rows/useGridRowSpanning.d.ts +1 -1
- package/hooks/features/rows/useGridRowSpanning.js +16 -8
- package/hooks/features/rows/useGridRows.js +16 -18
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/sorting/gridSortingSelector.d.ts +10 -5
- package/hooks/features/sorting/gridSortingSelector.js +11 -0
- package/hooks/features/sorting/index.d.ts +2 -1
- package/hooks/features/sorting/index.js +1 -1
- package/hooks/features/sorting/useGridSorting.js +1 -1
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +5 -5
- package/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
- package/hooks/utils/useGridSelector.d.ts +4 -6
- package/hooks/utils/useGridSelector.js +6 -44
- package/index.js +1 -1
- package/internals/index.d.ts +3 -3
- package/internals/index.js +3 -3
- package/locales/heIL.js +14 -16
- package/locales/roRO.js +18 -20
- package/locales/trTR.js +12 -14
- package/models/api/gridStateApi.d.ts +1 -1
- package/models/controlStateItem.d.ts +2 -2
- package/models/events/gridEventLookup.d.ts +1 -0
- package/models/gridDataSource.d.ts +1 -1
- package/models/props/DataGridProps.d.ts +1 -9
- package/modern/DataGrid/DataGrid.js +5 -13
- package/modern/components/GridRow.js +1 -1
- package/modern/components/cell/GridActionsCell.js +8 -1
- package/modern/components/cell/GridCell.js +1 -1
- package/modern/components/columnSelection/GridHeaderCheckbox.js +4 -1
- package/modern/components/panel/GridColumnsPanel.js +1 -2
- package/modern/components/panel/GridPanelContent.js +7 -3
- package/modern/components/panel/GridPanelFooter.js +4 -3
- package/modern/components/panel/filterPanel/GridFilterForm.js +15 -15
- package/modern/constants/dataGridPropsDefaultValues.js +1 -2
- package/modern/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +5 -1
- package/modern/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
- package/modern/hooks/core/useGridStateInitialization.js +3 -3
- package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +3 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +3 -3
- package/modern/hooks/features/filter/useGridFilter.js +1 -1
- package/modern/hooks/features/overlays/useGridOverlays.js +3 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -4
- package/modern/hooks/features/rows/gridRowsSelector.js +0 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +0 -9
- package/modern/hooks/features/rows/index.js +1 -1
- package/modern/hooks/features/rows/useGridRowSpanning.js +16 -8
- package/modern/hooks/features/rows/useGridRows.js +16 -18
- package/modern/hooks/features/sorting/gridSortingSelector.js +11 -0
- package/modern/hooks/features/sorting/index.js +1 -1
- package/modern/hooks/features/sorting/useGridSorting.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
- package/modern/hooks/utils/useGridSelector.js +6 -44
- package/modern/index.js +1 -1
- package/modern/internals/index.js +3 -3
- package/modern/locales/heIL.js +14 -16
- package/modern/locales/roRO.js +18 -20
- package/modern/locales/trTR.js +12 -14
- package/modern/utils/createSelector.js +1 -120
- package/node/DataGrid/DataGrid.js +5 -13
- package/node/components/GridRow.js +1 -1
- package/node/components/cell/GridActionsCell.js +8 -1
- package/node/components/cell/GridCell.js +1 -1
- package/node/components/columnSelection/GridHeaderCheckbox.js +4 -1
- package/node/components/panel/GridColumnsPanel.js +1 -2
- package/node/components/panel/GridPanelContent.js +7 -3
- package/node/components/panel/GridPanelFooter.js +5 -4
- package/node/components/panel/filterPanel/GridFilterForm.js +15 -15
- package/node/constants/dataGridPropsDefaultValues.js +1 -2
- package/node/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +7 -1
- package/node/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
- package/node/hooks/core/useGridStateInitialization.js +3 -3
- package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/node/hooks/features/editing/useGridCellEditing.js +2 -2
- package/node/hooks/features/editing/useGridRowEditing.js +2 -2
- package/node/hooks/features/filter/useGridFilter.js +1 -1
- package/node/hooks/features/overlays/useGridOverlays.js +3 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +5 -4
- package/node/hooks/features/rows/gridRowsSelector.js +1 -2
- package/node/hooks/features/rows/gridRowsUtils.js +0 -9
- package/node/hooks/features/rows/index.js +0 -7
- package/node/hooks/features/rows/useGridRowSpanning.js +16 -8
- package/node/hooks/features/rows/useGridRows.js +15 -17
- package/node/hooks/features/sorting/gridSortingSelector.js +12 -1
- package/node/hooks/features/sorting/index.js +24 -16
- package/node/hooks/features/sorting/useGridSorting.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
- package/node/hooks/utils/useGridSelector.js +8 -47
- package/node/index.js +1 -1
- package/node/internals/index.js +15 -22
- package/node/locales/heIL.js +14 -16
- package/node/locales/roRO.js +18 -20
- package/node/locales/trTR.js +12 -14
- package/node/utils/createSelector.js +4 -125
- package/package.json +1 -1
- package/utils/createSelector.d.ts +4 -16
- package/utils/createSelector.js +1 -120
|
@@ -47,27 +47,22 @@ const GridFilterFormRoot = (0, _styles.styled)('div', {
|
|
|
47
47
|
theme
|
|
48
48
|
}) => ({
|
|
49
49
|
display: 'flex',
|
|
50
|
-
|
|
50
|
+
gap: theme.spacing(1.5)
|
|
51
51
|
}));
|
|
52
52
|
const FilterFormDeleteIcon = (0, _styles.styled)('div', {
|
|
53
53
|
name: 'MuiDataGrid',
|
|
54
54
|
slot: 'FilterFormDeleteIcon',
|
|
55
55
|
overridesResolver: (_, styles) => styles.filterFormDeleteIcon
|
|
56
|
-
})(
|
|
57
|
-
theme
|
|
58
|
-
}) => ({
|
|
56
|
+
})({
|
|
59
57
|
flexShrink: 0,
|
|
60
|
-
justifyContent: '
|
|
61
|
-
|
|
62
|
-
marginBottom: theme.spacing(0.2)
|
|
63
|
-
}));
|
|
58
|
+
justifyContent: 'center'
|
|
59
|
+
});
|
|
64
60
|
const FilterFormLogicOperatorInput = (0, _styles.styled)('div', {
|
|
65
61
|
name: 'MuiDataGrid',
|
|
66
62
|
slot: 'FilterFormLogicOperatorInput',
|
|
67
63
|
overridesResolver: (_, styles) => styles.filterFormLogicOperatorInput
|
|
68
64
|
})({
|
|
69
|
-
minWidth:
|
|
70
|
-
marginRight: 5,
|
|
65
|
+
minWidth: 75,
|
|
71
66
|
justifyContent: 'end'
|
|
72
67
|
});
|
|
73
68
|
const FilterFormColumnInput = (0, _styles.styled)('div', {
|
|
@@ -269,7 +264,6 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
|
|
|
269
264
|
ownerState: rootProps
|
|
270
265
|
}, other, {
|
|
271
266
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(FilterFormDeleteIcon, (0, _extends2.default)({
|
|
272
|
-
variant: "standard",
|
|
273
267
|
as: rootProps.slots.baseFormControl
|
|
274
268
|
}, baseFormControlProps, deleteIconProps, {
|
|
275
269
|
className: (0, _clsx.default)(classes.deleteIcon, baseFormControlProps.className, deleteIconProps.className),
|
|
@@ -286,7 +280,8 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
|
|
|
286
280
|
})
|
|
287
281
|
}))
|
|
288
282
|
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(FilterFormLogicOperatorInput, (0, _extends2.default)({
|
|
289
|
-
variant: "
|
|
283
|
+
variant: "outlined",
|
|
284
|
+
size: "small",
|
|
290
285
|
as: rootProps.slots.baseFormControl
|
|
291
286
|
}, baseFormControlProps, logicOperatorInputProps, {
|
|
292
287
|
sx: [hasLogicOperatorColumn ? {
|
|
@@ -316,7 +311,8 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
|
|
|
316
311
|
}), apiRef.current.getLocaleText(getLogicOperatorLocaleKey(logicOperator))))
|
|
317
312
|
}))
|
|
318
313
|
})), /*#__PURE__*/(0, _jsxRuntime.jsxs)(FilterFormColumnInput, (0, _extends2.default)({
|
|
319
|
-
variant: "
|
|
314
|
+
variant: "outlined",
|
|
315
|
+
size: "small",
|
|
320
316
|
as: rootProps.slots.baseFormControl
|
|
321
317
|
}, baseFormControlProps, columnInputProps, {
|
|
322
318
|
className: (0, _clsx.default)(classes.columnInput, baseFormControlProps.className, columnInputProps.className),
|
|
@@ -341,7 +337,8 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
|
|
|
341
337
|
}), getColumnLabel(col)))
|
|
342
338
|
}))]
|
|
343
339
|
})), /*#__PURE__*/(0, _jsxRuntime.jsxs)(FilterFormOperatorInput, (0, _extends2.default)({
|
|
344
|
-
variant: "
|
|
340
|
+
variant: "outlined",
|
|
341
|
+
size: "small",
|
|
345
342
|
as: rootProps.slots.baseFormControl
|
|
346
343
|
}, baseFormControlProps, operatorInputProps, {
|
|
347
344
|
className: (0, _clsx.default)(classes.operatorInput, baseFormControlProps.className, operatorInputProps.className),
|
|
@@ -367,12 +364,15 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
|
|
|
367
364
|
}), operator.label || apiRef.current.getLocaleText(`filterOperator${(0, _utils.unstable_capitalize)(operator.value)}`)))
|
|
368
365
|
}))]
|
|
369
366
|
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(FilterFormValueInput, (0, _extends2.default)({
|
|
370
|
-
variant: "
|
|
367
|
+
variant: "outlined",
|
|
368
|
+
size: "small",
|
|
371
369
|
as: rootProps.slots.baseFormControl
|
|
372
370
|
}, baseFormControlProps, valueInputPropsOther, {
|
|
373
371
|
className: (0, _clsx.default)(classes.valueInput, baseFormControlProps.className, valueInputPropsOther.className),
|
|
374
372
|
ownerState: rootProps,
|
|
375
373
|
children: currentOperator?.InputComponent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(currentOperator.InputComponent, (0, _extends2.default)({
|
|
374
|
+
variant: "outlined",
|
|
375
|
+
size: "small",
|
|
376
376
|
apiRef: apiRef,
|
|
377
377
|
item: item,
|
|
378
378
|
applyValue: applyFilterChanges,
|
|
@@ -51,15 +51,14 @@ const DATA_GRID_PROPS_DEFAULT_VALUES = exports.DATA_GRID_PROPS_DEFAULT_VALUES =
|
|
|
51
51
|
resizeThrottleMs: 60,
|
|
52
52
|
rowBufferPx: 150,
|
|
53
53
|
rowHeight: 52,
|
|
54
|
-
rowPositionsDebounceMs: 166,
|
|
55
54
|
rows: [],
|
|
56
55
|
rowSelection: true,
|
|
57
56
|
rowSpacingType: 'margin',
|
|
57
|
+
rowSpanning: false,
|
|
58
58
|
showCellVerticalBorder: false,
|
|
59
59
|
showColumnVerticalBorder: false,
|
|
60
60
|
sortingMode: 'client',
|
|
61
61
|
sortingOrder: ['asc', 'desc', null],
|
|
62
62
|
throttleRowsMs: 0,
|
|
63
|
-
unstable_rowSpanning: false,
|
|
64
63
|
virtualizeColumnsWithAutoRowHeight: false
|
|
65
64
|
};
|
|
@@ -2,4 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
});
|
|
5
|
+
});
|
|
6
|
+
exports.GridStrategyGroup = void 0;
|
|
7
|
+
let GridStrategyGroup = exports.GridStrategyGroup = /*#__PURE__*/function (GridStrategyGroup) {
|
|
8
|
+
GridStrategyGroup["DataSource"] = "dataSource";
|
|
9
|
+
GridStrategyGroup["RowTree"] = "rowTree";
|
|
10
|
+
return GridStrategyGroup;
|
|
11
|
+
}({});
|
|
@@ -9,13 +9,15 @@ exports.useGridStrategyProcessing = exports.GRID_STRATEGIES_PROCESSORS = exports
|
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var _toPropertyKey2 = _interopRequireDefault(require("@babel/runtime/helpers/toPropertyKey"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _gridStrategyProcessingApi = require("./gridStrategyProcessingApi");
|
|
12
13
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
13
14
|
const GRID_DEFAULT_STRATEGY = exports.GRID_DEFAULT_STRATEGY = 'none';
|
|
14
15
|
const GRID_STRATEGIES_PROCESSORS = exports.GRID_STRATEGIES_PROCESSORS = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
dataSourceRowsUpdate: _gridStrategyProcessingApi.GridStrategyGroup.DataSource,
|
|
17
|
+
rowTreeCreation: _gridStrategyProcessingApi.GridStrategyGroup.RowTree,
|
|
18
|
+
filtering: _gridStrategyProcessingApi.GridStrategyGroup.RowTree,
|
|
19
|
+
sorting: _gridStrategyProcessingApi.GridStrategyGroup.RowTree,
|
|
20
|
+
visibleRowsLookupCreation: _gridStrategyProcessingApi.GridStrategyGroup.RowTree
|
|
19
21
|
};
|
|
20
22
|
/**
|
|
21
23
|
* Implements a variant of the Strategy Pattern (see https://en.wikipedia.org/wiki/Strategy_pattern)
|
|
@@ -52,10 +54,7 @@ const GRID_STRATEGIES_PROCESSORS = exports.GRID_STRATEGIES_PROCESSORS = {
|
|
|
52
54
|
* =====================================================================================================================
|
|
53
55
|
*
|
|
54
56
|
* Each processor name is part of a strategy group which can only have one active strategy at the time.
|
|
55
|
-
*
|
|
56
|
-
* - row tree creation algorithm.
|
|
57
|
-
* - sorting algorithm.
|
|
58
|
-
* - filtering algorithm.
|
|
57
|
+
* There are two active groups named `rowTree` and `dataSource`.
|
|
59
58
|
*/
|
|
60
59
|
const useGridStrategyProcessing = apiRef => {
|
|
61
60
|
const availableStrategies = React.useRef(new Map());
|
|
@@ -32,8 +32,8 @@ const useGridStateInitialization = apiRef => {
|
|
|
32
32
|
const updatedControlStateIds = [];
|
|
33
33
|
Object.keys(controlStateMapRef.current).forEach(stateId => {
|
|
34
34
|
const controlState = controlStateMapRef.current[stateId];
|
|
35
|
-
const oldSubState = controlState.stateSelector(apiRef.current.state, apiRef.current.instanceId);
|
|
36
|
-
const newSubState = controlState.stateSelector(newState, apiRef.current.instanceId);
|
|
35
|
+
const oldSubState = controlState.stateSelector(apiRef.current.state, undefined, apiRef.current.instanceId);
|
|
36
|
+
const newSubState = controlState.stateSelector(newState, undefined, apiRef.current.instanceId);
|
|
37
37
|
if (newSubState === oldSubState) {
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
@@ -65,7 +65,7 @@ const useGridStateInitialization = apiRef => {
|
|
|
65
65
|
hasPropChanged
|
|
66
66
|
} = updatedControlStateIds[0];
|
|
67
67
|
const controlState = controlStateMapRef.current[stateId];
|
|
68
|
-
const model = controlState.stateSelector(newState, apiRef.current.instanceId);
|
|
68
|
+
const model = controlState.stateSelector(newState, undefined, apiRef.current.instanceId);
|
|
69
69
|
if (controlState.propOnChange && hasPropChanged) {
|
|
70
70
|
controlState.propOnChange(model, {
|
|
71
71
|
reason,
|
|
@@ -500,7 +500,8 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
500
500
|
const widthByField = extractColumnWidths(apiRef, options, columns);
|
|
501
501
|
const newColumns = columns.map(column => (0, _extends2.default)({}, column, {
|
|
502
502
|
width: widthByField[column.field],
|
|
503
|
-
computedWidth: widthByField[column.field]
|
|
503
|
+
computedWidth: widthByField[column.field],
|
|
504
|
+
flex: 0
|
|
504
505
|
}));
|
|
505
506
|
if (options.expand) {
|
|
506
507
|
const visibleColumns = state.orderedFields.map(field => state.lookup[field]).filter(c => state.columnVisibilityModel[c.field] !== false);
|
|
@@ -450,7 +450,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
450
450
|
|
|
451
451
|
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
452
452
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
453
|
-
const
|
|
453
|
+
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
454
454
|
|
|
455
455
|
// Update the ref here because updateStateToStopCellEditMode may change it later
|
|
456
456
|
const copyOfPrevCellModes = prevCellModesModel.current;
|
|
@@ -459,7 +459,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
459
459
|
Object.entries(cellModesModel).forEach(([id, fields]) => {
|
|
460
460
|
Object.entries(fields).forEach(([field, params]) => {
|
|
461
461
|
const prevMode = copyOfPrevCellModes[id]?.[field]?.mode || _gridEditRowModel.GridCellModes.View;
|
|
462
|
-
const originalId =
|
|
462
|
+
const originalId = apiRef.current.getRowId(rowsLookup[id]) ?? id;
|
|
463
463
|
if (params.mode === _gridEditRowModel.GridCellModes.Edit && prevMode === _gridEditRowModel.GridCellModes.View) {
|
|
464
464
|
updateStateToStartCellEditMode((0, _extends2.default)({
|
|
465
465
|
id: originalId,
|
|
@@ -579,7 +579,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
579
579
|
|
|
580
580
|
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
581
581
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
582
|
-
const
|
|
582
|
+
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
583
583
|
|
|
584
584
|
// Update the ref here because updateStateToStopRowEditMode may change it later
|
|
585
585
|
const copyOfPrevRowModesModel = prevRowModesModel.current;
|
|
@@ -591,7 +591,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
591
591
|
mode: _gridEditRowModel.GridRowModes.View
|
|
592
592
|
};
|
|
593
593
|
const prevMode = copyOfPrevRowModesModel[id]?.mode || _gridEditRowModel.GridRowModes.View;
|
|
594
|
-
const originalId =
|
|
594
|
+
const originalId = apiRef.current.getRowId(rowsLookup[id]) ?? id;
|
|
595
595
|
if (params.mode === _gridEditRowModel.GridRowModes.Edit && prevMode === _gridEditRowModel.GridRowModes.View) {
|
|
596
596
|
updateStateToStartRowEditMode((0, _extends2.default)({
|
|
597
597
|
id: originalId
|
|
@@ -68,7 +68,7 @@ const useGridFilter = (apiRef, props) => {
|
|
|
68
68
|
});
|
|
69
69
|
const updateFilteredRows = React.useCallback(() => {
|
|
70
70
|
apiRef.current.setState(state => {
|
|
71
|
-
const filterModel = (0, _gridFilterSelector.gridFilterModelSelector)(state, apiRef.current.instanceId);
|
|
71
|
+
const filterModel = (0, _gridFilterSelector.gridFilterModelSelector)(state, undefined, apiRef.current.instanceId);
|
|
72
72
|
const filterState = apiRef.current.getFilterState(filterModel);
|
|
73
73
|
const newState = (0, _extends2.default)({}, state, {
|
|
74
74
|
filter: (0, _extends2.default)({}, state.filter, filterState)
|
|
@@ -13,6 +13,7 @@ var _useGridApiContext = require("../../utils/useGridApiContext");
|
|
|
13
13
|
var _useGridRootProps = require("../../utils/useGridRootProps");
|
|
14
14
|
var _filter = require("../filter");
|
|
15
15
|
var _rows = require("../rows");
|
|
16
|
+
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
16
17
|
var _GridOverlays = require("../../../components/base/GridOverlays");
|
|
17
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
19
|
/**
|
|
@@ -24,7 +25,8 @@ const useGridOverlays = () => {
|
|
|
24
25
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
25
26
|
const totalRowCount = (0, _utils.useGridSelector)(apiRef, _rows.gridRowCountSelector);
|
|
26
27
|
const visibleRowCount = (0, _utils.useGridSelector)(apiRef, _filter.gridExpandedRowCountSelector);
|
|
27
|
-
const
|
|
28
|
+
const pinnedRowsCount = (0, _utils.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsCountSelector);
|
|
29
|
+
const noRows = totalRowCount === 0 && pinnedRowsCount === 0;
|
|
28
30
|
const loading = (0, _utils.useGridSelector)(apiRef, _rows.gridRowsLoadingSelector);
|
|
29
31
|
const showNoRowsOverlay = !loading && noRows;
|
|
30
32
|
const showNoResultsOverlay = !loading && totalRowCount > 0 && visibleRowCount === 0;
|
|
@@ -322,11 +322,12 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
322
322
|
|
|
323
323
|
const isMultipleSelectionDisabled = !checkboxSelection && !hasCtrlKey && !(0, _keyboardUtils.isKeyboardEvent)(event);
|
|
324
324
|
const resetSelection = !canHaveMultipleSelection || isMultipleSelectionDisabled;
|
|
325
|
-
const
|
|
326
|
-
if (
|
|
327
|
-
apiRef.current.selectRow(id,
|
|
325
|
+
const selectedRowsCount = apiRef.current.getSelectedRows().size;
|
|
326
|
+
if (canHaveMultipleSelection && selectedRowsCount > 1 && !hasCtrlKey) {
|
|
327
|
+
apiRef.current.selectRow(id, true, resetSelection);
|
|
328
328
|
} else {
|
|
329
|
-
apiRef.current.
|
|
329
|
+
const isSelected = apiRef.current.isRowSelected(id);
|
|
330
|
+
apiRef.current.selectRow(id, !isSelected, resetSelection);
|
|
330
331
|
}
|
|
331
332
|
}, [apiRef, canHaveMultipleSelection, checkboxSelection]);
|
|
332
333
|
const handleRowClick = React.useCallback((params, event) => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.gridTopLevelRowCountSelector = exports.gridRowsLookupSelector = exports.gridRowsLoadingSelector = exports.
|
|
6
|
+
exports.gridTopLevelRowCountSelector = exports.gridRowsLookupSelector = exports.gridRowsLoadingSelector = exports.gridRowTreeSelector = exports.gridRowTreeDepthsSelector = exports.gridRowMaximumTreeDepthSelector = exports.gridRowGroupsToFetchSelector = exports.gridRowGroupingNameSelector = exports.gridRowCountSelector = exports.gridPinnedRowsSelector = exports.gridPinnedRowsCountSelector = exports.gridDataRowIdsSelector = exports.gridAdditionalRowGroupsSelector = void 0;
|
|
7
7
|
var _createSelector = require("../../../utils/createSelector");
|
|
8
8
|
const gridRowsStateSelector = state => state.rows;
|
|
9
9
|
const gridRowCountSelector = exports.gridRowCountSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.totalRowCount);
|
|
@@ -12,7 +12,6 @@ const gridTopLevelRowCountSelector = exports.gridTopLevelRowCountSelector = (0,
|
|
|
12
12
|
|
|
13
13
|
// TODO rows v6: Rename
|
|
14
14
|
const gridRowsLookupSelector = exports.gridRowsLookupSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.dataRowIdToModelLookup);
|
|
15
|
-
const gridRowsDataRowIdToIdLookupSelector = exports.gridRowsDataRowIdToIdLookupSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.dataRowIdToIdLookup);
|
|
16
15
|
const gridRowTreeSelector = exports.gridRowTreeSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.tree);
|
|
17
16
|
const gridRowGroupsToFetchSelector = exports.gridRowGroupsToFetchSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.groupsToFetch);
|
|
18
17
|
const gridRowGroupingNameSelector = exports.gridRowGroupingNameSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.groupingName);
|
|
@@ -55,12 +55,10 @@ const createRowsInternalCache = ({
|
|
|
55
55
|
rows: []
|
|
56
56
|
};
|
|
57
57
|
const dataRowIdToModelLookup = {};
|
|
58
|
-
const dataRowIdToIdLookup = {};
|
|
59
58
|
for (let i = 0; i < rows.length; i += 1) {
|
|
60
59
|
const model = rows[i];
|
|
61
60
|
const id = getRowIdFromRowModel(model, getRowId);
|
|
62
61
|
dataRowIdToModelLookup[id] = model;
|
|
63
|
-
dataRowIdToIdLookup[id] = id;
|
|
64
62
|
updates.rows.push(id);
|
|
65
63
|
}
|
|
66
64
|
return {
|
|
@@ -68,7 +66,6 @@ const createRowsInternalCache = ({
|
|
|
68
66
|
loadingPropBeforePartialUpdates: loading,
|
|
69
67
|
rowCountPropBeforePartialUpdates: rowCount,
|
|
70
68
|
updates,
|
|
71
|
-
dataRowIdToIdLookup,
|
|
72
69
|
dataRowIdToModelLookup
|
|
73
70
|
};
|
|
74
71
|
};
|
|
@@ -102,7 +99,6 @@ const getRowsStateFromCache = ({
|
|
|
102
99
|
previousTree,
|
|
103
100
|
previousTreeDepths,
|
|
104
101
|
updates: cache.updates,
|
|
105
|
-
dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
|
|
106
102
|
dataRowIdToModelLookup: cache.dataRowIdToModelLookup,
|
|
107
103
|
previousGroupsToFetch
|
|
108
104
|
});
|
|
@@ -111,7 +107,6 @@ const getRowsStateFromCache = ({
|
|
|
111
107
|
const groupingParamsWithHydrateRows = apiRef.current.unstable_applyPipeProcessors('hydrateRows', {
|
|
112
108
|
tree: unProcessedTree,
|
|
113
109
|
treeDepths: unProcessedTreeDepths,
|
|
114
|
-
dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
|
|
115
110
|
dataRowIds: unProcessedDataRowIds,
|
|
116
111
|
dataRowIdToModelLookup: cache.dataRowIdToModelLookup
|
|
117
112
|
});
|
|
@@ -196,7 +191,6 @@ const updateCacheWithNewRows = ({
|
|
|
196
191
|
groupKeys
|
|
197
192
|
};
|
|
198
193
|
const dataRowIdToModelLookup = (0, _extends2.default)({}, previousCache.dataRowIdToModelLookup);
|
|
199
|
-
const dataRowIdToIdLookup = (0, _extends2.default)({}, previousCache.dataRowIdToIdLookup);
|
|
200
194
|
const alreadyAppliedActionsToRemove = {
|
|
201
195
|
insert: {},
|
|
202
196
|
modify: {},
|
|
@@ -229,7 +223,6 @@ const updateCacheWithNewRows = ({
|
|
|
229
223
|
// Remove the data row from the lookups and add it to the "delete" update.
|
|
230
224
|
partialUpdates.actions.remove.push(id);
|
|
231
225
|
delete dataRowIdToModelLookup[id];
|
|
232
|
-
delete dataRowIdToIdLookup[id];
|
|
233
226
|
return;
|
|
234
227
|
}
|
|
235
228
|
const oldRow = dataRowIdToModelLookup[id];
|
|
@@ -269,7 +262,6 @@ const updateCacheWithNewRows = ({
|
|
|
269
262
|
|
|
270
263
|
// Update the data row lookups.
|
|
271
264
|
dataRowIdToModelLookup[id] = partialRow;
|
|
272
|
-
dataRowIdToIdLookup[id] = id;
|
|
273
265
|
});
|
|
274
266
|
const actionTypeWithActionsToRemove = Object.keys(alreadyAppliedActionsToRemove);
|
|
275
267
|
for (let i = 0; i < actionTypeWithActionsToRemove.length; i += 1) {
|
|
@@ -281,7 +273,6 @@ const updateCacheWithNewRows = ({
|
|
|
281
273
|
}
|
|
282
274
|
return {
|
|
283
275
|
dataRowIdToModelLookup,
|
|
284
|
-
dataRowIdToIdLookup,
|
|
285
276
|
updates: partialUpdates,
|
|
286
277
|
rowsBeforePartialUpdates: previousCache.rowsBeforePartialUpdates,
|
|
287
278
|
loadingPropBeforePartialUpdates: previousCache.loadingPropBeforePartialUpdates,
|
|
@@ -8,7 +8,6 @@ var _exportNames = {
|
|
|
8
8
|
gridRowsLoadingSelector: true,
|
|
9
9
|
gridTopLevelRowCountSelector: true,
|
|
10
10
|
gridRowsLookupSelector: true,
|
|
11
|
-
gridRowsDataRowIdToIdLookupSelector: true,
|
|
12
11
|
gridRowTreeSelector: true,
|
|
13
12
|
gridRowGroupingNameSelector: true,
|
|
14
13
|
gridRowTreeDepthsSelector: true,
|
|
@@ -66,12 +65,6 @@ Object.defineProperty(exports, "gridRowTreeSelector", {
|
|
|
66
65
|
return _gridRowsSelector.gridRowTreeSelector;
|
|
67
66
|
}
|
|
68
67
|
});
|
|
69
|
-
Object.defineProperty(exports, "gridRowsDataRowIdToIdLookupSelector", {
|
|
70
|
-
enumerable: true,
|
|
71
|
-
get: function () {
|
|
72
|
-
return _gridRowsSelector.gridRowsDataRowIdToIdLookupSelector;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
68
|
Object.defineProperty(exports, "gridRowsLoadingSelector", {
|
|
76
69
|
enumerable: true,
|
|
77
70
|
get: function () {
|
|
@@ -14,6 +14,7 @@ var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
|
14
14
|
var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
15
15
|
var _gridVirtualizationSelectors = require("../virtualization/gridVirtualizationSelectors");
|
|
16
16
|
var _useGridSelector = require("../../utils/useGridSelector");
|
|
17
|
+
var _gridRowsSelector = require("./gridRowsSelector");
|
|
17
18
|
var _gridRowSpanningUtils = require("./gridRowSpanningUtils");
|
|
18
19
|
var _gridCheckboxSelectionColDef = require("../../../colDef/gridCheckboxSelectionColDef");
|
|
19
20
|
const EMPTY_STATE = {
|
|
@@ -43,7 +44,7 @@ const computeRowSpanningState = (apiRef, colDefs, visibleRows, range, rangeToPro
|
|
|
43
44
|
if (skippedFields.has(colDef.field)) {
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
|
-
for (let index = rangeToProcess.firstRowIndex; index
|
|
47
|
+
for (let index = rangeToProcess.firstRowIndex; index < rangeToProcess.lastRowIndex; index += 1) {
|
|
47
48
|
const row = visibleRows[index];
|
|
48
49
|
if (hiddenCells[row.id]?.[colDef.field]) {
|
|
49
50
|
continue;
|
|
@@ -137,7 +138,7 @@ const computeRowSpanningState = (apiRef, colDefs, visibleRows, range, rangeToPro
|
|
|
137
138
|
* @requires filterStateInitializer (method) - should be initialized before
|
|
138
139
|
*/
|
|
139
140
|
const rowSpanningStateInitializer = (state, props, apiRef) => {
|
|
140
|
-
if (props.
|
|
141
|
+
if (props.rowSpanning) {
|
|
141
142
|
const rowIds = state.rows.dataRowIds || [];
|
|
142
143
|
const orderedFields = state.columns.orderedFields || [];
|
|
143
144
|
const dataRowIdToModelLookup = state.rows.dataRowIdToModelLookup;
|
|
@@ -150,7 +151,7 @@ const rowSpanningStateInitializer = (state, props, apiRef) => {
|
|
|
150
151
|
}
|
|
151
152
|
const rangeToProcess = {
|
|
152
153
|
firstRowIndex: 0,
|
|
153
|
-
lastRowIndex: Math.min(DEFAULT_ROWS_TO_PROCESS
|
|
154
|
+
lastRowIndex: Math.min(DEFAULT_ROWS_TO_PROCESS, Math.max(rowIds.length, 0))
|
|
154
155
|
};
|
|
155
156
|
const rows = rowIds.map(id => ({
|
|
156
157
|
id,
|
|
@@ -182,10 +183,11 @@ const useGridRowSpanning = (apiRef, props) => {
|
|
|
182
183
|
} = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props);
|
|
183
184
|
const renderContext = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridRenderContextSelector);
|
|
184
185
|
const colDefs = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector);
|
|
186
|
+
const tree = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowTreeSelector);
|
|
185
187
|
const processedRange = (0, _useLazyRef.default)(() => {
|
|
186
188
|
return Object.keys(apiRef.current.state.rowSpanning.spannedCells).length > 0 ? {
|
|
187
189
|
firstRowIndex: 0,
|
|
188
|
-
lastRowIndex: Math.min(DEFAULT_ROWS_TO_PROCESS
|
|
190
|
+
lastRowIndex: Math.min(DEFAULT_ROWS_TO_PROCESS, Math.max(apiRef.current.state.rows.dataRowIds.length, 0))
|
|
189
191
|
} : EMPTY_RANGE;
|
|
190
192
|
});
|
|
191
193
|
const lastRange = React.useRef(EMPTY_RANGE);
|
|
@@ -197,7 +199,7 @@ const useGridRowSpanning = (apiRef, props) => {
|
|
|
197
199
|
// - The `paginationModel` is updated
|
|
198
200
|
// - The rows are updated
|
|
199
201
|
(resetState = true) => {
|
|
200
|
-
if (!props.
|
|
202
|
+
if (!props.rowSpanning) {
|
|
201
203
|
if (apiRef.current.state.rowSpanning !== EMPTY_STATE) {
|
|
202
204
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
203
205
|
rowSpanning: EMPTY_STATE
|
|
@@ -213,7 +215,7 @@ const useGridRowSpanning = (apiRef, props) => {
|
|
|
213
215
|
}
|
|
214
216
|
const rangeToProcess = (0, _gridRowSpanningUtils.getUnprocessedRange)({
|
|
215
217
|
firstRowIndex: renderContext.firstRowIndex,
|
|
216
|
-
lastRowIndex: Math.min(renderContext.lastRowIndex
|
|
218
|
+
lastRowIndex: Math.min(renderContext.lastRowIndex, range.lastRowIndex + 1)
|
|
217
219
|
}, processedRange.current);
|
|
218
220
|
if (rangeToProcess === null) {
|
|
219
221
|
return;
|
|
@@ -242,15 +244,21 @@ const useGridRowSpanning = (apiRef, props) => {
|
|
|
242
244
|
}
|
|
243
245
|
});
|
|
244
246
|
});
|
|
245
|
-
}, [apiRef, props.
|
|
247
|
+
}, [apiRef, props.rowSpanning, range, renderContext, visibleRows, colDefs, processedRange]);
|
|
246
248
|
const prevRenderContext = React.useRef(renderContext);
|
|
247
249
|
const isFirstRender = React.useRef(true);
|
|
248
250
|
const shouldResetState = React.useRef(false);
|
|
251
|
+
const previousTree = React.useRef(tree);
|
|
249
252
|
React.useEffect(() => {
|
|
250
253
|
const firstRender = isFirstRender.current;
|
|
251
254
|
if (isFirstRender.current) {
|
|
252
255
|
isFirstRender.current = false;
|
|
253
256
|
}
|
|
257
|
+
if (tree !== previousTree.current) {
|
|
258
|
+
previousTree.current = tree;
|
|
259
|
+
updateRowSpanningState(true);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
254
262
|
if (range && lastRange.current && (0, _gridRowSpanningUtils.isRowRangeUpdated)(range, lastRange.current)) {
|
|
255
263
|
lastRange.current = range;
|
|
256
264
|
shouldResetState.current = true;
|
|
@@ -264,6 +272,6 @@ const useGridRowSpanning = (apiRef, props) => {
|
|
|
264
272
|
return;
|
|
265
273
|
}
|
|
266
274
|
updateRowSpanningState();
|
|
267
|
-
}, [updateRowSpanningState, renderContext, range, lastRange]);
|
|
275
|
+
}, [updateRowSpanningState, renderContext, range, lastRange, tree]);
|
|
268
276
|
};
|
|
269
277
|
exports.useGridRowSpanning = useGridRowSpanning;
|
|
@@ -19,6 +19,7 @@ var _gridSortingSelector = require("../sorting/gridSortingSelector");
|
|
|
19
19
|
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
20
20
|
var _gridRowsUtils = require("./gridRowsUtils");
|
|
21
21
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
22
|
+
var _strategyProcessing = require("../../core/strategyProcessing");
|
|
22
23
|
const rowsStateInitializer = (state, props, apiRef) => {
|
|
23
24
|
const isDataSourceAvailable = !!props.unstable_dataSource;
|
|
24
25
|
apiRef.current.caches.rows = (0, _gridRowsUtils.createRowsInternalCache)({
|
|
@@ -247,7 +248,7 @@ const useGridRows = (apiRef, props) => {
|
|
|
247
248
|
throw new Error(`MUI X: The row reordering do not support reordering of footer or grouping rows.`);
|
|
248
249
|
}
|
|
249
250
|
apiRef.current.setState(state => {
|
|
250
|
-
const group = (0, _gridRowsSelector.gridRowTreeSelector)(state, apiRef.current.instanceId)[_gridRowsUtils.GRID_ROOT_GROUP_ID];
|
|
251
|
+
const group = (0, _gridRowsSelector.gridRowTreeSelector)(state, undefined, apiRef.current.instanceId)[_gridRowsUtils.GRID_ROOT_GROUP_ID];
|
|
251
252
|
const allRows = group.children;
|
|
252
253
|
const oldIndex = allRows.findIndex(row => row === rowId);
|
|
253
254
|
if (oldIndex === -1 || oldIndex === targetIndex) {
|
|
@@ -281,7 +282,6 @@ const useGridRows = (apiRef, props) => {
|
|
|
281
282
|
}
|
|
282
283
|
const tree = (0, _extends2.default)({}, (0, _gridRowsSelector.gridRowTreeSelector)(apiRef));
|
|
283
284
|
const dataRowIdToModelLookup = (0, _extends2.default)({}, (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef));
|
|
284
|
-
const dataRowIdToIdLookup = (0, _extends2.default)({}, (0, _gridRowsSelector.gridRowsDataRowIdToIdLookupSelector)(apiRef));
|
|
285
285
|
const rootGroup = tree[_gridRowsUtils.GRID_ROOT_GROUP_ID];
|
|
286
286
|
const rootGroupChildren = [...rootGroup.children];
|
|
287
287
|
const seenIds = new Set();
|
|
@@ -291,7 +291,6 @@ const useGridRows = (apiRef, props) => {
|
|
|
291
291
|
const [removedRowId] = rootGroupChildren.splice(firstRowToRender + i, 1, rowId);
|
|
292
292
|
if (!seenIds.has(removedRowId)) {
|
|
293
293
|
delete dataRowIdToModelLookup[removedRowId];
|
|
294
|
-
delete dataRowIdToIdLookup[removedRowId];
|
|
295
294
|
delete tree[removedRowId];
|
|
296
295
|
}
|
|
297
296
|
const rowTreeNodeConfig = {
|
|
@@ -302,7 +301,6 @@ const useGridRows = (apiRef, props) => {
|
|
|
302
301
|
groupingKey: null
|
|
303
302
|
};
|
|
304
303
|
dataRowIdToModelLookup[rowId] = rowModel;
|
|
305
|
-
dataRowIdToIdLookup[rowId] = rowId;
|
|
306
304
|
tree[rowId] = rowTreeNodeConfig;
|
|
307
305
|
seenIds.add(rowId);
|
|
308
306
|
}
|
|
@@ -313,17 +311,17 @@ const useGridRows = (apiRef, props) => {
|
|
|
313
311
|
// Removes potential remaining skeleton rows from the dataRowIds.
|
|
314
312
|
const dataRowIds = rootGroupChildren.filter(childId => tree[childId]?.type === 'leaf');
|
|
315
313
|
apiRef.current.caches.rows.dataRowIdToModelLookup = dataRowIdToModelLookup;
|
|
316
|
-
apiRef.current.caches.rows.dataRowIdToIdLookup = dataRowIdToIdLookup;
|
|
317
314
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
318
315
|
rows: (0, _extends2.default)({}, state.rows, {
|
|
316
|
+
loading: props.loading,
|
|
317
|
+
totalRowCount: Math.max(props.rowCount || 0, rootGroupChildren.length),
|
|
319
318
|
dataRowIdToModelLookup,
|
|
320
|
-
dataRowIdToIdLookup,
|
|
321
319
|
dataRowIds,
|
|
322
320
|
tree
|
|
323
321
|
})
|
|
324
322
|
}));
|
|
325
323
|
apiRef.current.publishEvent('rowsSet');
|
|
326
|
-
}, [apiRef, props.signature, props.getRowId]);
|
|
324
|
+
}, [apiRef, props.signature, props.getRowId, props.loading, props.rowCount]);
|
|
327
325
|
const rowApi = {
|
|
328
326
|
getRow,
|
|
329
327
|
setLoading,
|
|
@@ -390,7 +388,7 @@ const useGridRows = (apiRef, props) => {
|
|
|
390
388
|
const handleStrategyActivityChange = React.useCallback(() => {
|
|
391
389
|
// `rowTreeCreation` is the only processor ran when `strategyAvailabilityChange` is fired.
|
|
392
390
|
// All the other processors listen to `rowsSet` which will be published by the `groupRows` method below.
|
|
393
|
-
if (apiRef.current.getActiveStrategy(
|
|
391
|
+
if (apiRef.current.getActiveStrategy(_strategyProcessing.GridStrategyGroup.RowTree) !== (0, _gridRowsSelector.gridRowGroupingNameSelector)(apiRef)) {
|
|
394
392
|
groupRows();
|
|
395
393
|
}
|
|
396
394
|
}, [apiRef, groupRows]);
|
|
@@ -403,11 +401,10 @@ const useGridRows = (apiRef, props) => {
|
|
|
403
401
|
const applyHydrateRowsProcessor = React.useCallback(() => {
|
|
404
402
|
apiRef.current.setState(state => {
|
|
405
403
|
const response = apiRef.current.unstable_applyPipeProcessors('hydrateRows', {
|
|
406
|
-
tree: (0, _gridRowsSelector.gridRowTreeSelector)(state, apiRef.current.instanceId),
|
|
407
|
-
treeDepths: (0, _gridRowsSelector.gridRowTreeDepthsSelector)(state, apiRef.current.instanceId),
|
|
408
|
-
dataRowIds: (0, _gridRowsSelector.gridDataRowIdsSelector)(state, apiRef.current.instanceId),
|
|
409
|
-
dataRowIdToModelLookup: (0, _gridRowsSelector.gridRowsLookupSelector)(state, apiRef.current.instanceId)
|
|
410
|
-
dataRowIdToIdLookup: (0, _gridRowsSelector.gridRowsDataRowIdToIdLookupSelector)(state, apiRef.current.instanceId)
|
|
404
|
+
tree: (0, _gridRowsSelector.gridRowTreeSelector)(state, undefined, apiRef.current.instanceId),
|
|
405
|
+
treeDepths: (0, _gridRowsSelector.gridRowTreeDepthsSelector)(state, undefined, apiRef.current.instanceId),
|
|
406
|
+
dataRowIds: (0, _gridRowsSelector.gridDataRowIdsSelector)(state, undefined, apiRef.current.instanceId),
|
|
407
|
+
dataRowIdToModelLookup: (0, _gridRowsSelector.gridRowsLookupSelector)(state, undefined, apiRef.current.instanceId)
|
|
411
408
|
});
|
|
412
409
|
return (0, _extends2.default)({}, state, {
|
|
413
410
|
rows: (0, _extends2.default)({}, state.rows, response, {
|
|
@@ -439,7 +436,8 @@ const useGridRows = (apiRef, props) => {
|
|
|
439
436
|
isRowCountPropUpdated = true;
|
|
440
437
|
lastRowCount.current = props.rowCount;
|
|
441
438
|
}
|
|
442
|
-
const
|
|
439
|
+
const currentRows = props.unstable_dataSource ? Array.from(apiRef.current.getRowModels().values()) : props.rows;
|
|
440
|
+
const areNewRowsAlreadyInState = apiRef.current.caches.rows.rowsBeforePartialUpdates === currentRows;
|
|
443
441
|
const isNewLoadingAlreadyInState = apiRef.current.caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
444
442
|
const isNewRowCountAlreadyInState = apiRef.current.caches.rows.rowCountPropBeforePartialUpdates === props.rowCount;
|
|
445
443
|
|
|
@@ -469,16 +467,16 @@ const useGridRows = (apiRef, props) => {
|
|
|
469
467
|
return;
|
|
470
468
|
}
|
|
471
469
|
}
|
|
472
|
-
logger.debug(`Updating all rows, new length ${
|
|
470
|
+
logger.debug(`Updating all rows, new length ${currentRows?.length}`);
|
|
473
471
|
throttledRowsChange({
|
|
474
472
|
cache: (0, _gridRowsUtils.createRowsInternalCache)({
|
|
475
|
-
rows:
|
|
473
|
+
rows: currentRows,
|
|
476
474
|
getRowId: props.getRowId,
|
|
477
475
|
loading: props.loading,
|
|
478
476
|
rowCount: props.rowCount
|
|
479
477
|
}),
|
|
480
478
|
throttle: false
|
|
481
479
|
});
|
|
482
|
-
}, [props.rows, props.rowCount, props.getRowId, props.loading, logger, throttledRowsChange, apiRef]);
|
|
480
|
+
}, [props.rows, props.rowCount, props.getRowId, props.loading, props.unstable_dataSource, logger, throttledRowsChange, apiRef]);
|
|
483
481
|
};
|
|
484
482
|
exports.useGridRows = useGridRows;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.gridSortedRowIdsSelector = exports.gridSortedRowEntriesSelector = exports.gridSortModelSelector = exports.gridSortColumnLookupSelector = void 0;
|
|
6
|
+
exports.gridSortedRowIndexLookupSelector = exports.gridSortedRowIdsSelector = exports.gridSortedRowEntriesSelector = exports.gridSortModelSelector = exports.gridSortColumnLookupSelector = void 0;
|
|
7
7
|
var _createSelector = require("../../../utils/createSelector");
|
|
8
8
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
9
9
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
@@ -61,4 +61,15 @@ const gridSortColumnLookupSelector = exports.gridSortColumnLookupSelector = (0,
|
|
|
61
61
|
return res;
|
|
62
62
|
}, {});
|
|
63
63
|
return result;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @category Sorting
|
|
68
|
+
* @ignore - do not document.
|
|
69
|
+
*/
|
|
70
|
+
const gridSortedRowIndexLookupSelector = exports.gridSortedRowIndexLookupSelector = (0, _createSelector.createSelectorMemoized)(gridSortedRowIdsSelector, sortedIds => {
|
|
71
|
+
return sortedIds.reduce((acc, id, index) => {
|
|
72
|
+
acc[id] = index;
|
|
73
|
+
return acc;
|
|
74
|
+
}, Object.create(null));
|
|
64
75
|
});
|