@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.
Files changed (138) hide show
  1. package/CHANGELOG.md +376 -0
  2. package/DataGrid/DataGrid.js +5 -13
  3. package/README.md +1 -1
  4. package/components/GridRow.js +1 -1
  5. package/components/cell/GridActionsCell.js +8 -1
  6. package/components/cell/GridCell.js +1 -1
  7. package/components/columnSelection/GridHeaderCheckbox.js +4 -1
  8. package/components/panel/GridColumnsPanel.js +1 -2
  9. package/components/panel/GridPanelContent.js +7 -3
  10. package/components/panel/GridPanelFooter.d.ts +1 -1
  11. package/components/panel/GridPanelFooter.js +4 -3
  12. package/components/panel/filterPanel/GridFilterForm.js +15 -15
  13. package/constants/dataGridPropsDefaultValues.js +1 -2
  14. package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +25 -9
  15. package/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +5 -1
  16. package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +3 -6
  17. package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
  18. package/hooks/core/useGridStateInitialization.js +3 -3
  19. package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +4 -4
  20. package/hooks/features/columnResize/columnResizeSelector.d.ts +1 -1
  21. package/hooks/features/columnResize/useGridColumnResize.js +2 -1
  22. package/hooks/features/columns/gridColumnsSelector.d.ts +12 -12
  23. package/hooks/features/density/densitySelector.d.ts +1 -1
  24. package/hooks/features/editing/useGridCellEditing.js +3 -3
  25. package/hooks/features/editing/useGridRowEditing.js +3 -3
  26. package/hooks/features/filter/gridFilterSelector.d.ts +17 -17
  27. package/hooks/features/filter/useGridFilter.js +1 -1
  28. package/hooks/features/focus/gridFocusStateSelector.d.ts +8 -8
  29. package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +3 -3
  30. package/hooks/features/overlays/useGridOverlays.js +3 -1
  31. package/hooks/features/pagination/gridPaginationSelector.d.ts +15 -9
  32. package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
  33. package/hooks/features/rowSelection/useGridRowSelection.js +5 -4
  34. package/hooks/features/rowSelection/utils.d.ts +1 -1
  35. package/hooks/features/rows/gridRowSpanningSelectors.d.ts +3 -3
  36. package/hooks/features/rows/gridRowsInterfaces.d.ts +1 -8
  37. package/hooks/features/rows/gridRowsSelector.d.ts +23 -13
  38. package/hooks/features/rows/gridRowsSelector.js +0 -1
  39. package/hooks/features/rows/gridRowsUtils.js +0 -9
  40. package/hooks/features/rows/index.d.ts +1 -1
  41. package/hooks/features/rows/index.js +1 -1
  42. package/hooks/features/rows/useGridRowSpanning.d.ts +1 -1
  43. package/hooks/features/rows/useGridRowSpanning.js +16 -8
  44. package/hooks/features/rows/useGridRows.js +16 -18
  45. package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
  46. package/hooks/features/sorting/gridSortingSelector.d.ts +10 -5
  47. package/hooks/features/sorting/gridSortingSelector.js +11 -0
  48. package/hooks/features/sorting/index.d.ts +2 -1
  49. package/hooks/features/sorting/index.js +1 -1
  50. package/hooks/features/sorting/useGridSorting.js +1 -1
  51. package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +5 -5
  52. package/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
  53. package/hooks/utils/useGridSelector.d.ts +4 -6
  54. package/hooks/utils/useGridSelector.js +6 -44
  55. package/index.js +1 -1
  56. package/internals/index.d.ts +3 -3
  57. package/internals/index.js +3 -3
  58. package/locales/heIL.js +14 -16
  59. package/locales/roRO.js +18 -20
  60. package/locales/trTR.js +12 -14
  61. package/models/api/gridStateApi.d.ts +1 -1
  62. package/models/controlStateItem.d.ts +2 -2
  63. package/models/events/gridEventLookup.d.ts +1 -0
  64. package/models/gridDataSource.d.ts +1 -1
  65. package/models/props/DataGridProps.d.ts +1 -9
  66. package/modern/DataGrid/DataGrid.js +5 -13
  67. package/modern/components/GridRow.js +1 -1
  68. package/modern/components/cell/GridActionsCell.js +8 -1
  69. package/modern/components/cell/GridCell.js +1 -1
  70. package/modern/components/columnSelection/GridHeaderCheckbox.js +4 -1
  71. package/modern/components/panel/GridColumnsPanel.js +1 -2
  72. package/modern/components/panel/GridPanelContent.js +7 -3
  73. package/modern/components/panel/GridPanelFooter.js +4 -3
  74. package/modern/components/panel/filterPanel/GridFilterForm.js +15 -15
  75. package/modern/constants/dataGridPropsDefaultValues.js +1 -2
  76. package/modern/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +5 -1
  77. package/modern/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
  78. package/modern/hooks/core/useGridStateInitialization.js +3 -3
  79. package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
  80. package/modern/hooks/features/editing/useGridCellEditing.js +3 -3
  81. package/modern/hooks/features/editing/useGridRowEditing.js +3 -3
  82. package/modern/hooks/features/filter/useGridFilter.js +1 -1
  83. package/modern/hooks/features/overlays/useGridOverlays.js +3 -1
  84. package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -4
  85. package/modern/hooks/features/rows/gridRowsSelector.js +0 -1
  86. package/modern/hooks/features/rows/gridRowsUtils.js +0 -9
  87. package/modern/hooks/features/rows/index.js +1 -1
  88. package/modern/hooks/features/rows/useGridRowSpanning.js +16 -8
  89. package/modern/hooks/features/rows/useGridRows.js +16 -18
  90. package/modern/hooks/features/sorting/gridSortingSelector.js +11 -0
  91. package/modern/hooks/features/sorting/index.js +1 -1
  92. package/modern/hooks/features/sorting/useGridSorting.js +1 -1
  93. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
  94. package/modern/hooks/utils/useGridSelector.js +6 -44
  95. package/modern/index.js +1 -1
  96. package/modern/internals/index.js +3 -3
  97. package/modern/locales/heIL.js +14 -16
  98. package/modern/locales/roRO.js +18 -20
  99. package/modern/locales/trTR.js +12 -14
  100. package/modern/utils/createSelector.js +1 -120
  101. package/node/DataGrid/DataGrid.js +5 -13
  102. package/node/components/GridRow.js +1 -1
  103. package/node/components/cell/GridActionsCell.js +8 -1
  104. package/node/components/cell/GridCell.js +1 -1
  105. package/node/components/columnSelection/GridHeaderCheckbox.js +4 -1
  106. package/node/components/panel/GridColumnsPanel.js +1 -2
  107. package/node/components/panel/GridPanelContent.js +7 -3
  108. package/node/components/panel/GridPanelFooter.js +5 -4
  109. package/node/components/panel/filterPanel/GridFilterForm.js +15 -15
  110. package/node/constants/dataGridPropsDefaultValues.js +1 -2
  111. package/node/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +7 -1
  112. package/node/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
  113. package/node/hooks/core/useGridStateInitialization.js +3 -3
  114. package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
  115. package/node/hooks/features/editing/useGridCellEditing.js +2 -2
  116. package/node/hooks/features/editing/useGridRowEditing.js +2 -2
  117. package/node/hooks/features/filter/useGridFilter.js +1 -1
  118. package/node/hooks/features/overlays/useGridOverlays.js +3 -1
  119. package/node/hooks/features/rowSelection/useGridRowSelection.js +5 -4
  120. package/node/hooks/features/rows/gridRowsSelector.js +1 -2
  121. package/node/hooks/features/rows/gridRowsUtils.js +0 -9
  122. package/node/hooks/features/rows/index.js +0 -7
  123. package/node/hooks/features/rows/useGridRowSpanning.js +16 -8
  124. package/node/hooks/features/rows/useGridRows.js +15 -17
  125. package/node/hooks/features/sorting/gridSortingSelector.js +12 -1
  126. package/node/hooks/features/sorting/index.js +24 -16
  127. package/node/hooks/features/sorting/useGridSorting.js +1 -1
  128. package/node/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
  129. package/node/hooks/utils/useGridSelector.js +8 -47
  130. package/node/index.js +1 -1
  131. package/node/internals/index.js +15 -22
  132. package/node/locales/heIL.js +14 -16
  133. package/node/locales/roRO.js +18 -20
  134. package/node/locales/trTR.js +12 -14
  135. package/node/utils/createSelector.js +4 -125
  136. package/package.json +1 -1
  137. package/utils/createSelector.d.ts +4 -16
  138. package/utils/createSelector.js +1 -120
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "8.0.0-alpha.2",
3
+ "version": "8.0.0-alpha.4",
4
4
  "description": "The Community plan edition of the Data Grid components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -1,20 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { Selector, SelectorResultArray } from 'reselect';
3
3
  import type { GridCoreApi } from '../models/api/gridCoreApi';
4
- export interface OutputSelector<State, Result> {
5
- (apiRef: React.MutableRefObject<{
6
- state: State;
7
- instanceId: GridCoreApi['instanceId'];
8
- }>): Result;
9
- (state: State, instanceId: GridCoreApi['instanceId']): Result;
10
- acceptsApiRef: boolean;
11
- }
12
- export interface OutputSelectorV8<State, Args, Result> {
4
+ export interface OutputSelector<State, Args, Result> {
13
5
  (apiRef: React.MutableRefObject<{
14
6
  state: State;
15
7
  instanceId: GridCoreApi['instanceId'];
16
8
  }>, args?: Args): Result;
17
- (state: State, instanceId: GridCoreApi['instanceId']): Result;
9
+ (state: State, args?: Args, instanceId?: GridCoreApi['instanceId']): Result;
18
10
  acceptsApiRef: boolean;
19
11
  }
20
12
  type StateFromSelector<T> = T extends (first: infer F, ...args: any[]) => any ? F extends {
@@ -24,19 +16,15 @@ type StateFromSelectorList<Selectors extends readonly any[]> = Selectors extends
24
16
  f: infer F,
25
17
  ...other: infer R
26
18
  ] ? StateFromSelector<F> extends StateFromSelectorList<R> ? StateFromSelector<F> : StateFromSelectorList<R> : {};
27
- type SelectorArgs<Selectors extends ReadonlyArray<Selector<any>>, Result> = [selectors: [...Selectors], combiner: (...args: SelectorResultArray<Selectors>) => Result] | [...Selectors, (...args: SelectorResultArray<Selectors>) => Result];
28
19
  type SelectorResultArrayWithArgs<Selectors extends ReadonlyArray<Selector<any>>, Args> = [
29
20
  ...SelectorResultArray<Selectors>,
30
21
  Args
31
22
  ];
32
- type SelectorArgsV8<Selectors extends ReadonlyArray<Selector<any>>, Args, Result> = [
23
+ type SelectorArgs<Selectors extends ReadonlyArray<Selector<any>>, Args, Result> = [
33
24
  selectors: [...Selectors],
34
25
  combiner: (...args: SelectorResultArrayWithArgs<Selectors, Args>) => Result
35
26
  ] | [...Selectors, (...args: SelectorResultArrayWithArgs<Selectors, Args>) => Result];
36
- type CreateSelectorFunction = <Selectors extends ReadonlyArray<Selector<any>>, Result>(...items: SelectorArgs<Selectors, Result>) => OutputSelector<StateFromSelectorList<Selectors>, Result>;
37
- type CreateSelectorFunctionV8 = <Selectors extends ReadonlyArray<Selector<any>>, Args, Result>(...items: SelectorArgsV8<Selectors, Args, Result>) => OutputSelectorV8<StateFromSelectorList<Selectors>, Args, Result>;
27
+ type CreateSelectorFunction = <Selectors extends ReadonlyArray<Selector<any>>, Args, Result>(...items: SelectorArgs<Selectors, Args, Result>) => OutputSelector<StateFromSelectorList<Selectors>, Args, Result>;
38
28
  export declare const createSelector: CreateSelectorFunction;
39
- export declare const createSelectorV8: CreateSelectorFunctionV8;
40
29
  export declare const createSelectorMemoized: CreateSelectorFunction;
41
- export declare const createSelectorMemoizedV8: CreateSelectorFunctionV8;
42
30
  export {};
@@ -8,19 +8,6 @@ const reselectCreateSelector = createSelectorCreator({
8
8
  equalityCheck: Object.is
9
9
  }
10
10
  });
11
-
12
- // TODO v8: Remove this type
13
-
14
- // TODO v8: Rename this type to `OutputSelector`
15
-
16
- // TODO v8: Remove this type
17
-
18
- // TODO v8: Rename this type to `SelectorArgs`
19
-
20
- // TODO v8: Remove this type
21
-
22
- // TODO v8: Rename this type to `CreateSelectorFunction`
23
-
24
11
  const cache = new WeakMap();
25
12
  function checkIsAPIRef(value) {
26
13
  return 'current' in value && 'instanceId' in value.current;
@@ -28,83 +15,12 @@ function checkIsAPIRef(value) {
28
15
  const DEFAULT_INSTANCE_ID = {
29
16
  id: 'default'
30
17
  };
31
-
32
- // TODO v8: Remove this function
33
18
  export const createSelector = (a, b, c, d, e, f, ...other) => {
34
19
  if (other.length > 0) {
35
20
  throw new Error('Unsupported number of selectors');
36
21
  }
37
22
  let selector;
38
23
 
39
- // eslint-disable-next-line id-denylist
40
- if (a && b && c && d && e && f) {
41
- selector = (stateOrApiRef, instanceIdParam) => {
42
- const isAPIRef = checkIsAPIRef(stateOrApiRef);
43
- const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
44
- const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
45
- const va = a(state, instanceId);
46
- const vb = b(state, instanceId);
47
- const vc = c(state, instanceId);
48
- const vd = d(state, instanceId);
49
- const ve = e(state, instanceId);
50
- return f(va, vb, vc, vd, ve);
51
- };
52
- // eslint-disable-next-line id-denylist
53
- } else if (a && b && c && d && e) {
54
- selector = (stateOrApiRef, instanceIdParam) => {
55
- const isAPIRef = checkIsAPIRef(stateOrApiRef);
56
- const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
57
- const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
58
- const va = a(state, instanceId);
59
- const vb = b(state, instanceId);
60
- const vc = c(state, instanceId);
61
- const vd = d(state, instanceId);
62
- return e(va, vb, vc, vd);
63
- };
64
- } else if (a && b && c && d) {
65
- selector = (stateOrApiRef, instanceIdParam) => {
66
- const isAPIRef = checkIsAPIRef(stateOrApiRef);
67
- const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
68
- const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
69
- const va = a(state, instanceId);
70
- const vb = b(state, instanceId);
71
- const vc = c(state, instanceId);
72
- return d(va, vb, vc);
73
- };
74
- } else if (a && b && c) {
75
- selector = (stateOrApiRef, instanceIdParam) => {
76
- const isAPIRef = checkIsAPIRef(stateOrApiRef);
77
- const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
78
- const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
79
- const va = a(state, instanceId);
80
- const vb = b(state, instanceId);
81
- return c(va, vb);
82
- };
83
- } else if (a && b) {
84
- selector = (stateOrApiRef, instanceIdParam) => {
85
- const isAPIRef = checkIsAPIRef(stateOrApiRef);
86
- const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
87
- const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
88
- const va = a(state, instanceId);
89
- return b(va);
90
- };
91
- } else {
92
- throw new Error('Missing arguments');
93
- }
94
-
95
- // We use this property to detect if the selector was created with createSelector
96
- // or it's only a simple function the receives the state and returns part of it.
97
- selector.acceptsApiRef = true;
98
- return selector;
99
- };
100
-
101
- // TODO v8: Rename this function to `createSelector`
102
- export const createSelectorV8 = (a, b, c, d, e, f, ...other) => {
103
- if (other.length > 0) {
104
- throw new Error('Unsupported number of selectors');
105
- }
106
- let selector;
107
-
108
24
  // eslint-disable-next-line id-denylist
109
25
  if (a && b && c && d && e && f) {
110
26
  selector = (stateOrApiRef, args, instanceIdParam) => {
@@ -166,49 +82,14 @@ export const createSelectorV8 = (a, b, c, d, e, f, ...other) => {
166
82
  selector.acceptsApiRef = true;
167
83
  return selector;
168
84
  };
169
-
170
- // TODO v8: Remove this function
171
85
  export const createSelectorMemoized = (...args) => {
172
- const selector = (stateOrApiRef, instanceId) => {
173
- const isAPIRef = checkIsAPIRef(stateOrApiRef);
174
- const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
175
- const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
176
- if (process.env.NODE_ENV !== 'production') {
177
- if (cacheKey.id === 'default') {
178
- warnOnce(['MUI X: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, for example `mySelector(apiRef)`, or pass the instance ID explicitly, for example `mySelector(state, apiRef.current.instanceId)`.']);
179
- }
180
- }
181
- const cacheArgsInit = cache.get(cacheKey);
182
- const cacheArgs = cacheArgsInit ?? new Map();
183
- const cacheFn = cacheArgs?.get(args);
184
- if (cacheArgs && cacheFn) {
185
- // We pass the cache key because the called selector might have as
186
- // dependency another selector created with this `createSelector`.
187
- return cacheFn(state, cacheKey);
188
- }
189
- const fn = reselectCreateSelector(...args);
190
- if (!cacheArgsInit) {
191
- cache.set(cacheKey, cacheArgs);
192
- }
193
- cacheArgs.set(args, fn);
194
- return fn(state, cacheKey);
195
- };
196
-
197
- // We use this property to detect if the selector was created with createSelector
198
- // or it's only a simple function the receives the state and returns part of it.
199
- selector.acceptsApiRef = true;
200
- return selector;
201
- };
202
-
203
- // TODO v8: Rename this function to `createSelectorMemoized`
204
- export const createSelectorMemoizedV8 = (...args) => {
205
86
  const selector = (stateOrApiRef, selectorArgs, instanceId) => {
206
87
  const isAPIRef = checkIsAPIRef(stateOrApiRef);
207
88
  const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
208
89
  const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
209
90
  if (process.env.NODE_ENV !== 'production') {
210
91
  if (cacheKey.id === 'default') {
211
- warnOnce(['MUI X: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, for example `mySelector(apiRef)`, or pass the instance ID explicitly, for example `mySelector(state, apiRef.current.instanceId)`.']);
92
+ warnOnce(['MUI X: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, for example `mySelector(apiRef)`, or pass the instance ID explicitly, for example `mySelector(state, args, apiRef.current.instanceId)`.']);
212
93
  }
213
94
  }
214
95
  const cacheArgsInit = cache.get(cacheKey);