@mui/x-data-grid 8.0.0-alpha.2 → 8.0.0-alpha.3

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/DataGrid/DataGrid.js +0 -8
  3. package/components/columnSelection/GridHeaderCheckbox.js +4 -1
  4. package/constants/dataGridPropsDefaultValues.js +0 -1
  5. package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +25 -9
  6. package/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +5 -1
  7. package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +3 -6
  8. package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
  9. package/hooks/features/columnResize/useGridColumnResize.js +2 -1
  10. package/hooks/features/editing/useGridCellEditing.js +3 -3
  11. package/hooks/features/editing/useGridRowEditing.js +3 -3
  12. package/hooks/features/rows/gridRowsInterfaces.d.ts +1 -8
  13. package/hooks/features/rows/gridRowsSelector.d.ts +0 -1
  14. package/hooks/features/rows/gridRowsSelector.js +0 -1
  15. package/hooks/features/rows/gridRowsUtils.js +0 -9
  16. package/hooks/features/rows/index.d.ts +1 -1
  17. package/hooks/features/rows/index.js +1 -1
  18. package/hooks/features/rows/useGridRows.js +12 -14
  19. package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
  20. package/index.js +1 -1
  21. package/internals/index.d.ts +1 -1
  22. package/internals/index.js +1 -1
  23. package/locales/heIL.js +14 -16
  24. package/locales/trTR.js +12 -14
  25. package/models/events/gridEventLookup.d.ts +1 -0
  26. package/models/gridDataSource.d.ts +1 -1
  27. package/models/props/DataGridProps.d.ts +0 -8
  28. package/modern/DataGrid/DataGrid.js +0 -8
  29. package/modern/components/columnSelection/GridHeaderCheckbox.js +4 -1
  30. package/modern/constants/dataGridPropsDefaultValues.js +0 -1
  31. package/modern/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +5 -1
  32. package/modern/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
  33. package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
  34. package/modern/hooks/features/editing/useGridCellEditing.js +3 -3
  35. package/modern/hooks/features/editing/useGridRowEditing.js +3 -3
  36. package/modern/hooks/features/rows/gridRowsSelector.js +0 -1
  37. package/modern/hooks/features/rows/gridRowsUtils.js +0 -9
  38. package/modern/hooks/features/rows/index.js +1 -1
  39. package/modern/hooks/features/rows/useGridRows.js +12 -14
  40. package/modern/index.js +1 -1
  41. package/modern/internals/index.js +1 -1
  42. package/modern/locales/heIL.js +14 -16
  43. package/modern/locales/trTR.js +12 -14
  44. package/node/DataGrid/DataGrid.js +0 -8
  45. package/node/components/columnSelection/GridHeaderCheckbox.js +4 -1
  46. package/node/constants/dataGridPropsDefaultValues.js +0 -1
  47. package/node/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +7 -1
  48. package/node/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
  49. package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
  50. package/node/hooks/features/editing/useGridCellEditing.js +2 -2
  51. package/node/hooks/features/editing/useGridRowEditing.js +2 -2
  52. package/node/hooks/features/rows/gridRowsSelector.js +1 -2
  53. package/node/hooks/features/rows/gridRowsUtils.js +0 -9
  54. package/node/hooks/features/rows/index.js +0 -7
  55. package/node/hooks/features/rows/useGridRows.js +11 -13
  56. package/node/index.js +1 -1
  57. package/node/internals/index.js +7 -0
  58. package/node/locales/heIL.js +14 -16
  59. package/node/locales/trTR.js +12 -14
  60. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,108 @@
5
5
  All notable changes to this project will be documented in this file.
6
6
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
7
7
 
8
+ ## 8.0.0-alpha.3
9
+
10
+ _Dec 5, 2024_
11
+
12
+ We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - 💫 Support [Server-side lazy loading](https://mui.com/x/react-data-grid/server-side-data/lazy-loading/) on the Data Grid. Use [data source](https://mui.com/x/react-data-grid/server-side-data/#data-source) to fetch a range of rows on demand and update the rows in the same way as described in [Infinite loading](https://mui.com/x/react-data-grid/row-updates/#infinite-loading) and [Lazy loading](https://mui.com/x/react-data-grid/row-updates/#lazy-loading) without the need to use any additional event listeners and callbacks.
15
+ - 🎯 Improved [data caching](https://mui.com/x/react-data-grid/server-side-data/#data-caching). Check out our [recommendations](https://mui.com/x/react-data-grid/server-side-data/#improving-the-cache-hit-rate) for improving the cache hit rate.
16
+
17
+ Special thanks go out to the community contributors who have helped make this release possible:
18
+ @ihsanberkozcan, @k-rajat19, @perezShaked.
19
+ Following are all team members who have contributed to this release:
20
+ @arminmeh, @cherniavskii, @flaviendelangle, @JCQuintas, @MBilalShafi, @noraleonte.
21
+
22
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
23
+
24
+ ### Data Grid
25
+
26
+ #### Breaking changes
27
+
28
+ - The "Select all" checkbox is now checked when all the selectable rows are selected, ignoring rows that are not selectable because of the `isRowSelectable` prop.
29
+ - The `rowPositionsDebounceMs` prop was removed.
30
+ - The `gridRowsDataRowIdToIdLookupSelector` selector was removed. Use the `gridRowsLookupSelector` selector in combination with the `getRowId()` API method instead.
31
+ ```diff
32
+ -const idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
33
+ -const rowId = idToIdLookup[id]
34
+ +const rowsLookup = gridRowsLookupSelector(apiRef);
35
+ +const rowId = apiRef.current.getRowId(rowsLookup[id])
36
+ ```
37
+ - The Grid is now more aligned with the WAI-ARIA authoring practices and sets the `role` attribute to `treegrid` if the Data Grid is used with row grouping feature.
38
+
39
+ #### `@mui/x-data-grid@8.0.0-alpha.3`
40
+
41
+ - [DataGrid] Fix deselection not working with `isRowSelectable` (#15692) @MBilalShafi
42
+ - [DataGrid] Make column autosizing work with flex columns (#15465) @cherniavskii
43
+ - [DataGrid] Remove `gridRowsDataRowIdToIdLookupSelector` selector (#15698) @arminmeh
44
+ - [DataGrid] Remove `rowPositionsDebounceMs` prop (#15482) @k-rajat19
45
+ - [l10n] Improve Hebrew (he-IL) locale (#15699) @perezShaked
46
+ - [l10n] Improve Turkish (tr-TR) locale (#15734) @ihsanberkozcan
47
+
48
+ #### `@mui/x-data-grid-pro@8.0.0-alpha.3` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
49
+
50
+ Same changes as in `@mui/x-data-grid@8.0.0-alpha.3`, plus:
51
+
52
+ - [DataGridPro] Cleanup pinned rows on removal (#15697) @cherniavskii
53
+ - [DataGridPro] Server-side lazy loading (#13878) @arminmeh
54
+
55
+ #### `@mui/x-data-grid-premium@8.0.0-alpha.3` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
56
+
57
+ Same changes as in `@mui/x-data-grid-pro@8.0.0-alpha.3`, plus:
58
+
59
+ - [DataGridPremium] Remove the `ariaV8` experimental flag (#15694) @arminmeh
60
+
61
+ ### Date and Time Pickers
62
+
63
+ #### Breaking changes
64
+
65
+ - The `onOpen()` and `onClose()` methods of the `usePickerContext()` hook have been replaced with a single `setOpen` method — [Learn more](https://next.mui.com/x/migration/migration-pickers-v7/#usepickercontext).
66
+
67
+ #### `@mui/x-date-pickers@8.0.0-alpha.3`
68
+
69
+ - [pickers] Replace the `onOpen()` and `onClose()` methods of `usePickerContext()` with a single `setOpen()` method. (#15701) @flaviendelangle
70
+
71
+ #### `@mui/x-date-pickers-pro@8.0.0-alpha.3` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
72
+
73
+ Same changes as in `@mui/x-date-pickers@8.0.0-alpha.3`.
74
+
75
+ ### Charts
76
+
77
+ #### `@mui/x-charts@8.0.0-alpha.3`
78
+
79
+ - [charts] Improve SVG `pattern` and `gradient` support (#15720) @JCQuintas
80
+
81
+ #### `@mui/x-charts-pro@8.0.0-alpha.3` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
82
+
83
+ Same changes as in `@mui/x-charts@8.0.0-alpha.3`.
84
+
85
+ ### Tree View
86
+
87
+ #### `@mui/x-tree-view@8.0.0-alpha.3`
88
+
89
+ No changes since `@mui/x-tree-view-pro@v8.0.0-alpha.2`.
90
+
91
+ #### `@mui/x-tree-view-pro@8.0.0-alpha.3` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
92
+
93
+ Same changes as in `@mui/x-tree-view@8.0.0-alpha.3`.
94
+
95
+ ### Docs
96
+
97
+ - [docs] Add a customization demo for the Date and Time Pickers overview page (#15118) @noraleonte
98
+ - [docs] Fix typo in charts axis documentation (#15743) @JCQuintas
99
+ - [docs] Improve SEO titles for the Data Grid (#15695) @MBilalShafi
100
+
101
+ ### Core
102
+
103
+ - [core] Add `@mui/x-tree-view-pro` to `releaseChangelog` (#15316) @flaviendelangle
104
+ - [code-infra] Lock file maintenance (#11894)
105
+ - [code-infra] Check if `preset-safe` folder exists in codemod test (#15703) @JCQuintas
106
+ - [code-infra] Import Pickers `preset-safe` into global codemod config (#15659) @JCQuintas
107
+ - [code-infra] Playwright 1.49 (#15493) @JCQuintas
108
+ - [test] Force hover in headless Chrome (#15710) @cherniavskii
109
+
8
110
  ## v8.0.0-alpha.2
9
111
 
10
112
  _Nov 29, 2024_
@@ -682,14 +682,6 @@ DataGridRaw.propTypes = {
682
682
  * Controls the modes of the rows.
683
683
  */
684
684
  rowModesModel: PropTypes.object,
685
- /**
686
- * The milliseconds delay to wait after measuring the row height before recalculating row positions.
687
- * Setting it to a lower value could be useful when using dynamic row height,
688
- * but might reduce performance when displaying a large number of rows.
689
- * @default 166
690
- * @deprecated
691
- */
692
- rowPositionsDebounceMs: PropTypes.number,
693
685
  /**
694
686
  * Set of rows of type [[GridRowsProp]].
695
687
  * @default []
@@ -56,10 +56,13 @@ const GridHeaderCheckbox = /*#__PURE__*/React.forwardRef(function GridHeaderChec
56
56
  // Convert to an object to make O(1) checking if a row exists or not
57
57
  // TODO create selector that returns visibleRowIds/paginatedVisibleRowIds as an object
58
58
  return rowIds.reduce((acc, id) => {
59
+ if (!apiRef.current.isRowSelectable(id)) {
60
+ return acc;
61
+ }
59
62
  acc[id] = true;
60
63
  return acc;
61
64
  }, {});
62
- }, [rootProps.pagination, rootProps.checkboxSelectionVisibleOnly, paginatedVisibleRowIds, visibleRowIds]);
65
+ }, [apiRef, rootProps.pagination, rootProps.checkboxSelectionVisibleOnly, paginatedVisibleRowIds, visibleRowIds]);
63
66
 
64
67
  // Amount of rows selected and that are visible in the current page
65
68
  const currentSelectionSize = React.useMemo(() => filteredSelection.filter(id => selectionCandidates[id]).length, [filteredSelection, selectionCandidates]);
@@ -45,7 +45,6 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
45
45
  resizeThrottleMs: 60,
46
46
  rowBufferPx: 150,
47
47
  rowHeight: 52,
48
- rowPositionsDebounceMs: 166,
49
48
  rows: [],
50
49
  rowSelection: true,
51
50
  rowSpacingType: 'margin',
@@ -1,26 +1,42 @@
1
1
  import { GridRowTreeCreationParams, GridRowTreeCreationValue, GridRowsState } from '../../features/rows/gridRowsInterfaces';
2
2
  import { GridFilteringMethodParams, GridFilteringMethodValue, GridFilterState, GridVisibleRowsLookupState } from '../../features/filter/gridFilterState';
3
3
  import { GridSortingMethodParams, GridSortingMethodValue } from '../../features/sorting/gridSortingState';
4
+ import { GridGetRowsParams, GridGetRowsResponse } from '../../../models/gridDataSource';
4
5
  export type GridStrategyProcessorName = keyof GridStrategyProcessingLookup;
5
- export type GridStrategyGroup = GridStrategyProcessingLookup[keyof GridStrategyProcessingLookup]['group'];
6
+ export declare enum GridStrategyGroup {
7
+ DataSource = "dataSource",
8
+ RowTree = "rowTree"
9
+ }
10
+ export type GridStrategyGroupValue = `${GridStrategyGroup}`;
6
11
  export interface GridStrategyProcessingLookup {
12
+ dataSourceRowsUpdate: {
13
+ group: GridStrategyGroup.DataSource;
14
+ params: {
15
+ response: GridGetRowsResponse;
16
+ fetchParams: GridGetRowsParams;
17
+ } | {
18
+ error: Error;
19
+ fetchParams: GridGetRowsParams;
20
+ };
21
+ value: void;
22
+ };
7
23
  rowTreeCreation: {
8
- group: 'rowTree';
24
+ group: GridStrategyGroup.RowTree;
9
25
  params: GridRowTreeCreationParams;
10
26
  value: GridRowTreeCreationValue;
11
27
  };
12
28
  filtering: {
13
- group: 'rowTree';
29
+ group: GridStrategyGroup.RowTree;
14
30
  params: GridFilteringMethodParams;
15
31
  value: GridFilteringMethodValue;
16
32
  };
17
33
  sorting: {
18
- group: 'rowTree';
34
+ group: GridStrategyGroup.RowTree;
19
35
  params: GridSortingMethodParams;
20
36
  value: GridSortingMethodValue;
21
37
  };
22
38
  visibleRowsLookupCreation: {
23
- group: 'rowTree';
39
+ group: GridStrategyGroup.RowTree;
24
40
  params: {
25
41
  tree: GridRowsState['tree'];
26
42
  filteredRowsLookup: GridFilterState['filteredRowsLookup'];
@@ -42,17 +58,17 @@ export interface GridStrategyProcessingApi {
42
58
  registerStrategyProcessor: <P extends GridStrategyProcessorName>(strategyName: string, processorName: P, processor: GridStrategyProcessor<P>) => () => void;
43
59
  /**
44
60
  * Set a callback to know if a strategy is available.
45
- * @param {GridStrategyGroup} strategyGroup The group for which we set strategy availability.
61
+ * @param {GridStrategyGroupValue} strategyGroup The group for which we set strategy availability.
46
62
  * @param {string} strategyName The name of the strategy.
47
63
  * @param {boolean} callback A callback to know if this strategy is available.
48
64
  */
49
- setStrategyAvailability: (strategyGroup: GridStrategyGroup, strategyName: string, callback: () => boolean) => void;
65
+ setStrategyAvailability: (strategyGroup: GridStrategyGroupValue, strategyName: string, callback: () => boolean) => void;
50
66
  /**
51
67
  * Returns the name of the active strategy of a given strategy group
52
- * @param {GridStrategyGroup} strategyGroup The group from which we want the active strategy.
68
+ * @param {GridStrategyGroupValue} strategyGroup The group from which we want the active strategy.
53
69
  * @returns {string} The name of the active strategy.
54
70
  */
55
- getActiveStrategy: (strategyGroup: GridStrategyGroup) => string;
71
+ getActiveStrategy: (strategyGroup: GridStrategyGroupValue) => string;
56
72
  /**
57
73
  * Run the processor registered for the active strategy.
58
74
  * @param {GridStrategyProcessorName} processorName The name of the processor to run.
@@ -1 +1,5 @@
1
- export {};
1
+ export let GridStrategyGroup = /*#__PURE__*/function (GridStrategyGroup) {
2
+ GridStrategyGroup["DataSource"] = "dataSource";
3
+ GridStrategyGroup["RowTree"] = "rowTree";
4
+ return GridStrategyGroup;
5
+ }({});
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { GridPrivateApiCommon } from '../../../models/api/gridApiCommon';
3
- import { GridStrategyProcessorName, GridStrategyProcessingLookup } from './gridStrategyProcessingApi';
3
+ import { GridStrategyProcessorName, GridStrategyGroupValue } from './gridStrategyProcessingApi';
4
4
  export declare const GRID_DEFAULT_STRATEGY = "none";
5
5
  export declare const GRID_STRATEGIES_PROCESSORS: {
6
- [P in GridStrategyProcessorName]: GridStrategyProcessingLookup[P]['group'];
6
+ [P in GridStrategyProcessorName]: GridStrategyGroupValue;
7
7
  };
8
8
  /**
9
9
  * Implements a variant of the Strategy Pattern (see https://en.wikipedia.org/wiki/Strategy_pattern)
@@ -40,9 +40,6 @@ export declare const GRID_STRATEGIES_PROCESSORS: {
40
40
  * =====================================================================================================================
41
41
  *
42
42
  * Each processor name is part of a strategy group which can only have one active strategy at the time.
43
- * For now, there is only one strategy group named `rowTree` which customize
44
- * - row tree creation algorithm.
45
- * - sorting algorithm.
46
- * - filtering algorithm.
43
+ * There are two active groups named `rowTree` and `dataSource`.
47
44
  */
48
45
  export declare const useGridStrategyProcessing: (apiRef: React.MutableRefObject<GridPrivateApiCommon>) => void;
@@ -1,13 +1,15 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _toPropertyKey from "@babel/runtime/helpers/esm/toPropertyKey";
3
3
  import * as React from 'react';
4
+ import { GridStrategyGroup } from "./gridStrategyProcessingApi.js";
4
5
  import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
5
6
  export const GRID_DEFAULT_STRATEGY = 'none';
6
7
  export const GRID_STRATEGIES_PROCESSORS = {
7
- rowTreeCreation: 'rowTree',
8
- filtering: 'rowTree',
9
- sorting: 'rowTree',
10
- visibleRowsLookupCreation: 'rowTree'
8
+ dataSourceRowsUpdate: GridStrategyGroup.DataSource,
9
+ rowTreeCreation: GridStrategyGroup.RowTree,
10
+ filtering: GridStrategyGroup.RowTree,
11
+ sorting: GridStrategyGroup.RowTree,
12
+ visibleRowsLookupCreation: GridStrategyGroup.RowTree
11
13
  };
12
14
  /**
13
15
  * Implements a variant of the Strategy Pattern (see https://en.wikipedia.org/wiki/Strategy_pattern)
@@ -44,10 +46,7 @@ export const GRID_STRATEGIES_PROCESSORS = {
44
46
  * =====================================================================================================================
45
47
  *
46
48
  * Each processor name is part of a strategy group which can only have one active strategy at the time.
47
- * For now, there is only one strategy group named `rowTree` which customize
48
- * - row tree creation algorithm.
49
- * - sorting algorithm.
50
- * - filtering algorithm.
49
+ * There are two active groups named `rowTree` and `dataSource`.
51
50
  */
52
51
  export const useGridStrategyProcessing = apiRef => {
53
52
  const availableStrategies = React.useRef(new Map());
@@ -491,7 +491,8 @@ export const useGridColumnResize = (apiRef, props) => {
491
491
  const widthByField = extractColumnWidths(apiRef, options, columns);
492
492
  const newColumns = columns.map(column => _extends({}, column, {
493
493
  width: widthByField[column.field],
494
- computedWidth: widthByField[column.field]
494
+ computedWidth: widthByField[column.field],
495
+ flex: 0
495
496
  }));
496
497
  if (options.expand) {
497
498
  const visibleColumns = state.orderedFields.map(field => state.lookup[field]).filter(c => state.columnVisibilityModel[c.field] !== false);
@@ -11,7 +11,7 @@ import { GridEditModes, GridCellModes } from "../../../models/gridEditRowModel.j
11
11
  import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
12
12
  import { gridEditRowsStateSelector } from "./gridEditingSelectors.js";
13
13
  import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.js";
14
- import { gridRowsDataRowIdToIdLookupSelector } from "../rows/gridRowsSelector.js";
14
+ import { gridRowsLookupSelector } from "../rows/gridRowsSelector.js";
15
15
  import { deepClone } from "../../../utils/utils.js";
16
16
  import { GridCellEditStartReasons, GridCellEditStopReasons } from "../../../models/params/gridEditCellParams.js";
17
17
  import { getDefaultCellValue } from "./utils.js";
@@ -442,7 +442,7 @@ export const useGridCellEditing = (apiRef, props) => {
442
442
 
443
443
  // Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
444
444
  useEnhancedEffect(() => {
445
- const idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
445
+ const rowsLookup = gridRowsLookupSelector(apiRef);
446
446
 
447
447
  // Update the ref here because updateStateToStopCellEditMode may change it later
448
448
  const copyOfPrevCellModes = prevCellModesModel.current;
@@ -451,7 +451,7 @@ export const useGridCellEditing = (apiRef, props) => {
451
451
  Object.entries(cellModesModel).forEach(([id, fields]) => {
452
452
  Object.entries(fields).forEach(([field, params]) => {
453
453
  const prevMode = copyOfPrevCellModes[id]?.[field]?.mode || GridCellModes.View;
454
- const originalId = idToIdLookup[id] ?? id;
454
+ const originalId = apiRef.current.getRowId(rowsLookup[id]) ?? id;
455
455
  if (params.mode === GridCellModes.Edit && prevMode === GridCellModes.View) {
456
456
  updateStateToStartCellEditMode(_extends({
457
457
  id: originalId,
@@ -12,7 +12,7 @@ import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
12
12
  import { gridEditRowsStateSelector } from "./gridEditingSelectors.js";
13
13
  import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.js";
14
14
  import { gridColumnFieldsSelector, gridVisibleColumnFieldsSelector } from "../columns/gridColumnsSelector.js";
15
- import { gridRowsDataRowIdToIdLookupSelector } from "../rows/gridRowsSelector.js";
15
+ import { gridRowsLookupSelector } from "../rows/gridRowsSelector.js";
16
16
  import { deepClone } from "../../../utils/utils.js";
17
17
  import { GridRowEditStopReasons, GridRowEditStartReasons } from "../../../models/params/gridRowParams.js";
18
18
  import { GRID_ACTIONS_COLUMN_TYPE } from "../../../colDef/index.js";
@@ -571,7 +571,7 @@ export const useGridRowEditing = (apiRef, props) => {
571
571
 
572
572
  // Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
573
573
  useEnhancedEffect(() => {
574
- const idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
574
+ const rowsLookup = gridRowsLookupSelector(apiRef);
575
575
 
576
576
  // Update the ref here because updateStateToStopRowEditMode may change it later
577
577
  const copyOfPrevRowModesModel = prevRowModesModel.current;
@@ -583,7 +583,7 @@ export const useGridRowEditing = (apiRef, props) => {
583
583
  mode: GridRowModes.View
584
584
  };
585
585
  const prevMode = copyOfPrevRowModesModel[id]?.mode || GridRowModes.View;
586
- const originalId = idToIdLookup[id] ?? id;
586
+ const originalId = apiRef.current.getRowId(rowsLookup[id]) ?? id;
587
587
  if (params.mode === GridRowModes.Edit && prevMode === GridRowModes.View) {
588
588
  updateStateToStartRowEditMode(_extends({
589
589
  id: originalId
@@ -18,10 +18,6 @@ export interface GridRowsInternalCache {
18
18
  * Lookup containing the latest model at all time (even those not stored in the state yet).
19
19
  */
20
20
  dataRowIdToModelLookup: GridRowIdToModelLookup;
21
- /**
22
- * Lookup containing the latest ids at all time (even those not stored in the state yet).
23
- */
24
- dataRowIdToIdLookup: GridRowIdToIdLookup;
25
21
  /**
26
22
  * List of updates (partial or full) applied since the last time the state was synced with the cache.
27
23
  * It is used to build the tree.
@@ -59,7 +55,6 @@ export interface GridRowsState {
59
55
  */
60
56
  totalTopLevelRowCount: number;
61
57
  dataRowIdToModelLookup: GridRowIdToModelLookup;
62
- dataRowIdToIdLookup: GridRowIdToIdLookup;
63
58
  additionalRowGroups?: {
64
59
  pinnedRows?: GridPinnedRowsState;
65
60
  };
@@ -74,7 +69,6 @@ export interface GridRowTreeCreationParams {
74
69
  previousTree: GridRowTreeConfig | null;
75
70
  previousTreeDepths: GridTreeDepths | null;
76
71
  updates: GridRowsPartialUpdates | GridRowsFullUpdate;
77
- dataRowIdToIdLookup: GridRowIdToIdLookup;
78
72
  dataRowIdToModelLookup: GridRowIdToModelLookup;
79
73
  previousGroupsToFetch?: GridRowId[];
80
74
  }
@@ -91,10 +85,9 @@ export type GridRowTreeUpdatedGroupsManager = {
91
85
  export type GridRowTreeCreationValue = Pick<GridRowsState, 'groupingName' | 'tree' | 'treeDepths' | 'dataRowIds' | 'groupsToFetch'> & {
92
86
  updatedGroupsManager?: GridRowTreeUpdatedGroupsManager;
93
87
  };
94
- export type GridHydrateRowsValue = Pick<GridRowsState, 'tree' | 'treeDepths' | 'dataRowIds' | 'dataRowIdToIdLookup' | 'dataRowIdToModelLookup' | 'additionalRowGroups'>;
88
+ export type GridHydrateRowsValue = Pick<GridRowsState, 'tree' | 'treeDepths' | 'dataRowIds' | 'dataRowIdToModelLookup' | 'additionalRowGroups'>;
95
89
  export type GridRowsPartialUpdateAction = 'insert' | 'modify' | 'remove';
96
90
  export type GridRowIdToModelLookup<R extends GridValidRowModel = GridValidRowModel> = Record<string, R>;
97
- export type GridRowIdToIdLookup = Record<string, GridRowId>;
98
91
  export type GridTreeDepths = {
99
92
  [depth: number]: number;
100
93
  };
@@ -3,7 +3,6 @@ export declare const gridRowCountSelector: import("../../..").OutputSelector<Gri
3
3
  export declare const gridRowsLoadingSelector: import("../../..").OutputSelector<GridStateCommunity, boolean | undefined>;
4
4
  export declare const gridTopLevelRowCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
5
5
  export declare const gridRowsLookupSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridRowsInterfaces").GridRowIdToModelLookup<import("../../..").GridValidRowModel>>;
6
- export declare const gridRowsDataRowIdToIdLookupSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridRowsInterfaces").GridRowIdToIdLookup>;
7
6
  export declare const gridRowTreeSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowTreeConfig>;
8
7
  export declare const gridRowGroupsToFetchSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowId[] | undefined>;
9
8
  export declare const gridRowGroupingNameSelector: import("../../..").OutputSelector<GridStateCommunity, string>;
@@ -6,7 +6,6 @@ export const gridTopLevelRowCountSelector = createSelector(gridRowsStateSelector
6
6
 
7
7
  // TODO rows v6: Rename
8
8
  export const gridRowsLookupSelector = createSelector(gridRowsStateSelector, rows => rows.dataRowIdToModelLookup);
9
- export const gridRowsDataRowIdToIdLookupSelector = createSelector(gridRowsStateSelector, rows => rows.dataRowIdToIdLookup);
10
9
  export const gridRowTreeSelector = createSelector(gridRowsStateSelector, rows => rows.tree);
11
10
  export const gridRowGroupsToFetchSelector = createSelector(gridRowsStateSelector, rows => rows.groupsToFetch);
12
11
  export const gridRowGroupingNameSelector = createSelector(gridRowsStateSelector, rows => rows.groupingName);
@@ -42,12 +42,10 @@ export const createRowsInternalCache = ({
42
42
  rows: []
43
43
  };
44
44
  const dataRowIdToModelLookup = {};
45
- const dataRowIdToIdLookup = {};
46
45
  for (let i = 0; i < rows.length; i += 1) {
47
46
  const model = rows[i];
48
47
  const id = getRowIdFromRowModel(model, getRowId);
49
48
  dataRowIdToModelLookup[id] = model;
50
- dataRowIdToIdLookup[id] = id;
51
49
  updates.rows.push(id);
52
50
  }
53
51
  return {
@@ -55,7 +53,6 @@ export const createRowsInternalCache = ({
55
53
  loadingPropBeforePartialUpdates: loading,
56
54
  rowCountPropBeforePartialUpdates: rowCount,
57
55
  updates,
58
- dataRowIdToIdLookup,
59
56
  dataRowIdToModelLookup
60
57
  };
61
58
  };
@@ -87,7 +84,6 @@ export const getRowsStateFromCache = ({
87
84
  previousTree,
88
85
  previousTreeDepths,
89
86
  updates: cache.updates,
90
- dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
91
87
  dataRowIdToModelLookup: cache.dataRowIdToModelLookup,
92
88
  previousGroupsToFetch
93
89
  });
@@ -96,7 +92,6 @@ export const getRowsStateFromCache = ({
96
92
  const groupingParamsWithHydrateRows = apiRef.current.unstable_applyPipeProcessors('hydrateRows', {
97
93
  tree: unProcessedTree,
98
94
  treeDepths: unProcessedTreeDepths,
99
- dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
100
95
  dataRowIds: unProcessedDataRowIds,
101
96
  dataRowIdToModelLookup: cache.dataRowIdToModelLookup
102
97
  });
@@ -177,7 +172,6 @@ export const updateCacheWithNewRows = ({
177
172
  groupKeys
178
173
  };
179
174
  const dataRowIdToModelLookup = _extends({}, previousCache.dataRowIdToModelLookup);
180
- const dataRowIdToIdLookup = _extends({}, previousCache.dataRowIdToIdLookup);
181
175
  const alreadyAppliedActionsToRemove = {
182
176
  insert: {},
183
177
  modify: {},
@@ -210,7 +204,6 @@ export const updateCacheWithNewRows = ({
210
204
  // Remove the data row from the lookups and add it to the "delete" update.
211
205
  partialUpdates.actions.remove.push(id);
212
206
  delete dataRowIdToModelLookup[id];
213
- delete dataRowIdToIdLookup[id];
214
207
  return;
215
208
  }
216
209
  const oldRow = dataRowIdToModelLookup[id];
@@ -250,7 +243,6 @@ export const updateCacheWithNewRows = ({
250
243
 
251
244
  // Update the data row lookups.
252
245
  dataRowIdToModelLookup[id] = partialRow;
253
- dataRowIdToIdLookup[id] = id;
254
246
  });
255
247
  const actionTypeWithActionsToRemove = Object.keys(alreadyAppliedActionsToRemove);
256
248
  for (let i = 0; i < actionTypeWithActionsToRemove.length; i += 1) {
@@ -262,7 +254,6 @@ export const updateCacheWithNewRows = ({
262
254
  }
263
255
  return {
264
256
  dataRowIdToModelLookup,
265
- dataRowIdToIdLookup,
266
257
  updates: partialUpdates,
267
258
  rowsBeforePartialUpdates: previousCache.rowsBeforePartialUpdates,
268
259
  loadingPropBeforePartialUpdates: previousCache.loadingPropBeforePartialUpdates,
@@ -1,5 +1,5 @@
1
1
  export * from './gridRowsMetaSelector';
2
2
  export * from './gridRowsMetaState';
3
- export { gridRowCountSelector, gridRowsLoadingSelector, gridTopLevelRowCountSelector, gridRowsLookupSelector, gridRowsDataRowIdToIdLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridRowMaximumTreeDepthSelector, gridDataRowIdsSelector, } from './gridRowsSelector';
3
+ export { gridRowCountSelector, gridRowsLoadingSelector, gridTopLevelRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridRowMaximumTreeDepthSelector, gridDataRowIdsSelector, } from './gridRowsSelector';
4
4
  export type { GridRowsState, GridRowIdToModelLookup } from './gridRowsInterfaces';
5
5
  export { GRID_ROOT_GROUP_ID, checkGridRowIdIsValid, isAutogeneratedRow } from './gridRowsUtils';
@@ -1,4 +1,4 @@
1
1
  export * from "./gridRowsMetaSelector.js";
2
2
  export * from "./gridRowsMetaState.js";
3
- export { gridRowCountSelector, gridRowsLoadingSelector, gridTopLevelRowCountSelector, gridRowsLookupSelector, gridRowsDataRowIdToIdLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridRowMaximumTreeDepthSelector, gridDataRowIdsSelector } from "./gridRowsSelector.js";
3
+ export { gridRowCountSelector, gridRowsLoadingSelector, gridTopLevelRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridRowMaximumTreeDepthSelector, gridDataRowIdsSelector } from "./gridRowsSelector.js";
4
4
  export { GRID_ROOT_GROUP_ID, checkGridRowIdIsValid, isAutogeneratedRow } from "./gridRowsUtils.js";
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import useLazyRef from '@mui/utils/useLazyRef';
4
4
  import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
5
5
  import { useGridLogger } from "../../utils/useGridLogger.js";
6
- import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowsDataRowIdToIdLookupSelector, gridRowMaximumTreeDepthSelector, gridRowGroupsToFetchSelector } from "./gridRowsSelector.js";
6
+ import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowMaximumTreeDepthSelector, gridRowGroupsToFetchSelector } from "./gridRowsSelector.js";
7
7
  import { useTimeout } from "../../utils/useTimeout.js";
8
8
  import { GridSignature, useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
9
9
  import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
@@ -11,6 +11,7 @@ import { gridSortedRowIdsSelector } from "../sorting/gridSortingSelector.js";
11
11
  import { gridFilteredRowsLookupSelector } from "../filter/gridFilterSelector.js";
12
12
  import { getTreeNodeDescendants, createRowsInternalCache, getRowsStateFromCache, isAutogeneratedRowNode, GRID_ROOT_GROUP_ID, GRID_ID_AUTOGENERATED, updateCacheWithNewRows, getTopLevelRowCount, getRowIdFromRowModel, computeRowsUpdates } from "./gridRowsUtils.js";
13
13
  import { useGridRegisterPipeApplier } from "../../core/pipeProcessing/index.js";
14
+ import { GridStrategyGroup } from "../../core/strategyProcessing/index.js";
14
15
  export const rowsStateInitializer = (state, props, apiRef) => {
15
16
  const isDataSourceAvailable = !!props.unstable_dataSource;
16
17
  apiRef.current.caches.rows = createRowsInternalCache({
@@ -272,7 +273,6 @@ export const useGridRows = (apiRef, props) => {
272
273
  }
273
274
  const tree = _extends({}, gridRowTreeSelector(apiRef));
274
275
  const dataRowIdToModelLookup = _extends({}, gridRowsLookupSelector(apiRef));
275
- const dataRowIdToIdLookup = _extends({}, gridRowsDataRowIdToIdLookupSelector(apiRef));
276
276
  const rootGroup = tree[GRID_ROOT_GROUP_ID];
277
277
  const rootGroupChildren = [...rootGroup.children];
278
278
  const seenIds = new Set();
@@ -282,7 +282,6 @@ export const useGridRows = (apiRef, props) => {
282
282
  const [removedRowId] = rootGroupChildren.splice(firstRowToRender + i, 1, rowId);
283
283
  if (!seenIds.has(removedRowId)) {
284
284
  delete dataRowIdToModelLookup[removedRowId];
285
- delete dataRowIdToIdLookup[removedRowId];
286
285
  delete tree[removedRowId];
287
286
  }
288
287
  const rowTreeNodeConfig = {
@@ -293,7 +292,6 @@ export const useGridRows = (apiRef, props) => {
293
292
  groupingKey: null
294
293
  };
295
294
  dataRowIdToModelLookup[rowId] = rowModel;
296
- dataRowIdToIdLookup[rowId] = rowId;
297
295
  tree[rowId] = rowTreeNodeConfig;
298
296
  seenIds.add(rowId);
299
297
  }
@@ -304,17 +302,17 @@ export const useGridRows = (apiRef, props) => {
304
302
  // Removes potential remaining skeleton rows from the dataRowIds.
305
303
  const dataRowIds = rootGroupChildren.filter(childId => tree[childId]?.type === 'leaf');
306
304
  apiRef.current.caches.rows.dataRowIdToModelLookup = dataRowIdToModelLookup;
307
- apiRef.current.caches.rows.dataRowIdToIdLookup = dataRowIdToIdLookup;
308
305
  apiRef.current.setState(state => _extends({}, state, {
309
306
  rows: _extends({}, state.rows, {
307
+ loading: props.loading,
308
+ totalRowCount: Math.max(props.rowCount || 0, rootGroupChildren.length),
310
309
  dataRowIdToModelLookup,
311
- dataRowIdToIdLookup,
312
310
  dataRowIds,
313
311
  tree
314
312
  })
315
313
  }));
316
314
  apiRef.current.publishEvent('rowsSet');
317
- }, [apiRef, props.signature, props.getRowId]);
315
+ }, [apiRef, props.signature, props.getRowId, props.loading, props.rowCount]);
318
316
  const rowApi = {
319
317
  getRow,
320
318
  setLoading,
@@ -381,7 +379,7 @@ export const useGridRows = (apiRef, props) => {
381
379
  const handleStrategyActivityChange = React.useCallback(() => {
382
380
  // `rowTreeCreation` is the only processor ran when `strategyAvailabilityChange` is fired.
383
381
  // All the other processors listen to `rowsSet` which will be published by the `groupRows` method below.
384
- if (apiRef.current.getActiveStrategy('rowTree') !== gridRowGroupingNameSelector(apiRef)) {
382
+ if (apiRef.current.getActiveStrategy(GridStrategyGroup.RowTree) !== gridRowGroupingNameSelector(apiRef)) {
385
383
  groupRows();
386
384
  }
387
385
  }, [apiRef, groupRows]);
@@ -397,8 +395,7 @@ export const useGridRows = (apiRef, props) => {
397
395
  tree: gridRowTreeSelector(state, apiRef.current.instanceId),
398
396
  treeDepths: gridRowTreeDepthsSelector(state, apiRef.current.instanceId),
399
397
  dataRowIds: gridDataRowIdsSelector(state, apiRef.current.instanceId),
400
- dataRowIdToModelLookup: gridRowsLookupSelector(state, apiRef.current.instanceId),
401
- dataRowIdToIdLookup: gridRowsDataRowIdToIdLookupSelector(state, apiRef.current.instanceId)
398
+ dataRowIdToModelLookup: gridRowsLookupSelector(state, apiRef.current.instanceId)
402
399
  });
403
400
  return _extends({}, state, {
404
401
  rows: _extends({}, state.rows, response, {
@@ -430,7 +427,8 @@ export const useGridRows = (apiRef, props) => {
430
427
  isRowCountPropUpdated = true;
431
428
  lastRowCount.current = props.rowCount;
432
429
  }
433
- const areNewRowsAlreadyInState = apiRef.current.caches.rows.rowsBeforePartialUpdates === props.rows;
430
+ const currentRows = props.unstable_dataSource ? Array.from(apiRef.current.getRowModels().values()) : props.rows;
431
+ const areNewRowsAlreadyInState = apiRef.current.caches.rows.rowsBeforePartialUpdates === currentRows;
434
432
  const isNewLoadingAlreadyInState = apiRef.current.caches.rows.loadingPropBeforePartialUpdates === props.loading;
435
433
  const isNewRowCountAlreadyInState = apiRef.current.caches.rows.rowCountPropBeforePartialUpdates === props.rowCount;
436
434
 
@@ -460,15 +458,15 @@ export const useGridRows = (apiRef, props) => {
460
458
  return;
461
459
  }
462
460
  }
463
- logger.debug(`Updating all rows, new length ${props.rows?.length}`);
461
+ logger.debug(`Updating all rows, new length ${currentRows?.length}`);
464
462
  throttledRowsChange({
465
463
  cache: createRowsInternalCache({
466
- rows: props.rows,
464
+ rows: currentRows,
467
465
  getRowId: props.getRowId,
468
466
  loading: props.loading,
469
467
  rowCount: props.rowCount
470
468
  }),
471
469
  throttle: false
472
470
  });
473
- }, [props.rows, props.rowCount, props.getRowId, props.loading, logger, throttledRowsChange, apiRef]);
471
+ }, [props.rows, props.rowCount, props.getRowId, props.loading, props.unstable_dataSource, logger, throttledRowsChange, apiRef]);
474
472
  };
@@ -7,4 +7,4 @@ export declare const rowsMetaStateInitializer: GridStateInitializer;
7
7
  * @requires useGridPageSize (method)
8
8
  * @requires useGridPage (method)
9
9
  */
10
- export declare const useGridRowsMeta: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "getRowHeight" | "getEstimatedRowHeight" | "getRowSpacing" | "pagination" | "paginationMode" | "rowHeight" | "rowPositionsDebounceMs">) => void;
10
+ export declare const useGridRowsMeta: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "getRowHeight" | "getEstimatedRowHeight" | "getRowSpacing" | "pagination" | "paginationMode" | "rowHeight">) => void;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v8.0.0-alpha.2
2
+ * @mui/x-data-grid v8.0.0-alpha.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -11,7 +11,7 @@ export { getGridFilter } from '../components/panel/filterPanel/GridFilterPanel';
11
11
  export { getValueOptions } from '../components/panel/filterPanel/filterPanelUtils';
12
12
  export { useGridRegisterPipeProcessor } from '../hooks/core/pipeProcessing';
13
13
  export type { GridPipeProcessor } from '../hooks/core/pipeProcessing';
14
- export { useGridRegisterStrategyProcessor, GRID_DEFAULT_STRATEGY, } from '../hooks/core/strategyProcessing';
14
+ export { GridStrategyGroup, useGridRegisterStrategyProcessor, GRID_DEFAULT_STRATEGY, } from '../hooks/core/strategyProcessing';
15
15
  export type { GridStrategyProcessor } from '../hooks/core/strategyProcessing';
16
16
  export { useGridInitialization } from '../hooks/core/useGridInitialization';
17
17
  export { unwrapPrivateAPI } from '../hooks/core/useGridApiInitialization';
@@ -7,7 +7,7 @@ export { DATA_GRID_DEFAULT_SLOTS_COMPONENTS } from "../constants/defaultGridSlot
7
7
  export { getGridFilter } from "../components/panel/filterPanel/GridFilterPanel.js";
8
8
  export { getValueOptions } from "../components/panel/filterPanel/filterPanelUtils.js";
9
9
  export { useGridRegisterPipeProcessor } from "../hooks/core/pipeProcessing/index.js";
10
- export { useGridRegisterStrategyProcessor, GRID_DEFAULT_STRATEGY } from "../hooks/core/strategyProcessing/index.js";
10
+ export { GridStrategyGroup, useGridRegisterStrategyProcessor, GRID_DEFAULT_STRATEGY } from "../hooks/core/strategyProcessing/index.js";
11
11
  export { useGridInitialization } from "../hooks/core/useGridInitialization.js";
12
12
  export { unwrapPrivateAPI } from "../hooks/core/useGridApiInitialization.js";
13
13
  export { useGridClipboard } from "../hooks/features/clipboard/useGridClipboard.js";