@mui/x-data-grid 7.13.0 → 7.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +82 -2
  2. package/components/cell/GridCell.js +11 -12
  3. package/components/cell/GridEditSingleSelectCell.js +2 -3
  4. package/components/menu/columnMenu/GridColumnMenuContainer.js +2 -2
  5. package/components/panel/GridPanel.js +1 -2
  6. package/components/panel/filterPanel/GridFilterForm.js +9 -4
  7. package/components/toolbar/GridToolbarDensitySelector.js +2 -2
  8. package/components/toolbar/GridToolbarExportContainer.js +2 -2
  9. package/components/toolbar/GridToolbarQuickFilter.js +5 -3
  10. package/hooks/features/rows/useGridParamsApi.js +2 -1
  11. package/hooks/utils/useGridSelector.d.ts +4 -1
  12. package/hooks/utils/useGridSelector.js +38 -0
  13. package/index.js +1 -1
  14. package/internals/index.d.ts +2 -1
  15. package/internals/index.js +2 -1
  16. package/locales/csCZ.js +4 -5
  17. package/locales/heIL.js +4 -5
  18. package/models/gridDataSource.d.ts +6 -6
  19. package/models/params/gridCellParams.d.ts +4 -0
  20. package/modern/components/cell/GridCell.js +11 -12
  21. package/modern/components/cell/GridEditSingleSelectCell.js +2 -3
  22. package/modern/components/menu/columnMenu/GridColumnMenuContainer.js +2 -2
  23. package/modern/components/panel/GridPanel.js +1 -2
  24. package/modern/components/panel/filterPanel/GridFilterForm.js +9 -4
  25. package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
  26. package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
  27. package/modern/components/toolbar/GridToolbarQuickFilter.js +5 -3
  28. package/modern/hooks/features/rows/useGridParamsApi.js +2 -1
  29. package/modern/hooks/utils/useGridSelector.js +38 -0
  30. package/modern/index.js +1 -1
  31. package/modern/internals/index.js +2 -1
  32. package/modern/locales/csCZ.js +4 -5
  33. package/modern/locales/heIL.js +4 -5
  34. package/modern/utils/createSelector.js +116 -0
  35. package/modern/utils/keyboardUtils.js +1 -11
  36. package/node/components/cell/GridCell.js +11 -12
  37. package/node/components/cell/GridEditSingleSelectCell.js +2 -3
  38. package/node/components/menu/columnMenu/GridColumnMenuContainer.js +1 -1
  39. package/node/components/panel/GridPanel.js +1 -2
  40. package/node/components/panel/filterPanel/GridFilterForm.js +9 -4
  41. package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
  42. package/node/components/toolbar/GridToolbarExportContainer.js +1 -1
  43. package/node/components/toolbar/GridToolbarQuickFilter.js +5 -3
  44. package/node/hooks/features/rows/useGridParamsApi.js +2 -1
  45. package/node/hooks/utils/useGridSelector.js +41 -2
  46. package/node/index.js +1 -1
  47. package/node/internals/index.js +22 -0
  48. package/node/locales/csCZ.js +4 -5
  49. package/node/locales/heIL.js +4 -5
  50. package/node/utils/createSelector.js +119 -2
  51. package/node/utils/keyboardUtils.js +2 -15
  52. package/package.json +4 -4
  53. package/utils/createSelector.d.ts +19 -0
  54. package/utils/createSelector.js +116 -0
  55. package/utils/keyboardUtils.d.ts +1 -9
  56. package/utils/keyboardUtils.js +1 -11
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.13.0
2
+ * @mui/x-data-grid v7.14.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -85,7 +85,10 @@ var _exportNames = {
85
85
  getColumnsToExport: true,
86
86
  defaultGetRowsToExport: true,
87
87
  createSelector: true,
88
+ createSelectorV8: true,
88
89
  createSelectorMemoized: true,
90
+ createSelectorMemoizedV8: true,
91
+ useGridSelectorV8: true,
89
92
  findParentElementFromClassName: true,
90
93
  getActiveElement: true,
91
94
  isEventTargetInPortal: true,
@@ -197,6 +200,18 @@ Object.defineProperty(exports, "createSelectorMemoized", {
197
200
  return _createSelector.createSelectorMemoized;
198
201
  }
199
202
  });
203
+ Object.defineProperty(exports, "createSelectorMemoizedV8", {
204
+ enumerable: true,
205
+ get: function () {
206
+ return _createSelector.createSelectorMemoizedV8;
207
+ }
208
+ });
209
+ Object.defineProperty(exports, "createSelectorV8", {
210
+ enumerable: true,
211
+ get: function () {
212
+ return _createSelector.createSelectorV8;
213
+ }
214
+ });
200
215
  Object.defineProperty(exports, "defaultGetRowsToExport", {
201
216
  enumerable: true,
202
217
  get: function () {
@@ -605,6 +620,12 @@ Object.defineProperty(exports, "useGridScroll", {
605
620
  return _useGridScroll.useGridScroll;
606
621
  }
607
622
  });
623
+ Object.defineProperty(exports, "useGridSelectorV8", {
624
+ enumerable: true,
625
+ get: function () {
626
+ return _useGridSelector.useGridSelectorV8;
627
+ }
628
+ });
608
629
  Object.defineProperty(exports, "useGridSorting", {
609
630
  enumerable: true,
610
631
  get: function () {
@@ -748,6 +769,7 @@ Object.keys(_createControllablePromise).forEach(function (key) {
748
769
  });
749
770
  });
750
771
  var _createSelector = require("../utils/createSelector");
772
+ var _useGridSelector = require("../hooks/utils/useGridSelector");
751
773
  var _domUtils = require("../utils/domUtils");
752
774
  var _keyboardUtils = require("../utils/keyboardUtils");
753
775
  var _utils2 = require("../utils/utils");
@@ -44,11 +44,10 @@ const csCZGrid = {
44
44
  toolbarExportPrint: 'Vytisknout',
45
45
  toolbarExportExcel: 'Stáhnout jako Excel',
46
46
  // Columns management text
47
- // columnsManagementSearchTitle: 'Search',
48
- // columnsManagementNoColumns: 'No columns',
49
- // columnsManagementShowHideAllText: 'Show/Hide All',
50
- // columnsManagementReset: 'Reset',
51
-
47
+ columnsManagementSearchTitle: 'Hledat sloupce',
48
+ columnsManagementNoColumns: 'Žádné sloupce',
49
+ columnsManagementShowHideAllText: 'Zobrazit/skrýt vše',
50
+ columnsManagementReset: 'Resetovat',
52
51
  // Filter panel text
53
52
  filterPanelAddFilter: 'Přidat filtr',
54
53
  filterPanelRemoveAll: 'Odstranit vše',
@@ -36,11 +36,10 @@ const heILGrid = {
36
36
  toolbarExportPrint: 'הדפסה',
37
37
  toolbarExportExcel: 'ייצוא ל- Excel',
38
38
  // Columns management text
39
- // columnsManagementSearchTitle: 'Search',
40
- // columnsManagementNoColumns: 'No columns',
41
- // columnsManagementShowHideAllText: 'Show/Hide All',
42
- // columnsManagementReset: 'Reset',
43
-
39
+ columnsManagementSearchTitle: 'חיפוש',
40
+ columnsManagementNoColumns: 'אין עמודות',
41
+ columnsManagementShowHideAllText: 'הצג/הסתר הכל',
42
+ columnsManagementReset: 'אתחול',
44
43
  // Filter panel text
45
44
  filterPanelAddFilter: 'הוסף מסנן',
46
45
  filterPanelRemoveAll: 'מחק הכל',
@@ -3,9 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createSelectorMemoized = exports.createSelector = void 0;
6
+ exports.createSelectorV8 = exports.createSelectorMemoizedV8 = exports.createSelectorMemoized = exports.createSelector = void 0;
7
7
  var _reselect = require("reselect");
8
8
  var _warning = require("../internals/utils/warning");
9
+ // TODO v8: Remove this type
10
+
11
+ // TODO v8: Rename this type to `OutputSelector`
12
+
13
+ // TODO v8: Remove this type
14
+
15
+ // TODO v8: Rename this type to `SelectorArgs`
16
+
17
+ // TODO v8: Remove this type
18
+
19
+ // TODO v8: Rename this type to `CreateSelectorFunction`
20
+
9
21
  const cache = new WeakMap();
10
22
  function checkIsAPIRef(value) {
11
23
  return 'current' in value && 'instanceId' in value.current;
@@ -13,6 +25,8 @@ function checkIsAPIRef(value) {
13
25
  const DEFAULT_INSTANCE_ID = {
14
26
  id: 'default'
15
27
  };
28
+
29
+ // TODO v8: Remove this function
16
30
  const createSelector = (a, b, c, d, e, f, ...other) => {
17
31
  if (other.length > 0) {
18
32
  throw new Error('Unsupported number of selectors');
@@ -77,7 +91,76 @@ const createSelector = (a, b, c, d, e, f, ...other) => {
77
91
  selector.acceptsApiRef = true;
78
92
  return selector;
79
93
  };
94
+
95
+ // TODO v8: Rename this function to `createSelector`
80
96
  exports.createSelector = createSelector;
97
+ const createSelectorV8 = (a, b, c, d, e, f, ...other) => {
98
+ if (other.length > 0) {
99
+ throw new Error('Unsupported number of selectors');
100
+ }
101
+ let selector;
102
+ if (a && b && c && d && e && f) {
103
+ selector = (stateOrApiRef, args, instanceIdParam) => {
104
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
105
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
106
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
107
+ const va = a(state, args, instanceId);
108
+ const vb = b(state, args, instanceId);
109
+ const vc = c(state, args, instanceId);
110
+ const vd = d(state, args, instanceId);
111
+ const ve = e(state, args, instanceId);
112
+ return f(va, vb, vc, vd, ve, args);
113
+ };
114
+ } else if (a && b && c && d && e) {
115
+ selector = (stateOrApiRef, args, instanceIdParam) => {
116
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
117
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
118
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
119
+ const va = a(state, args, instanceId);
120
+ const vb = b(state, args, instanceId);
121
+ const vc = c(state, args, instanceId);
122
+ const vd = d(state, args, instanceId);
123
+ return e(va, vb, vc, vd, args);
124
+ };
125
+ } else if (a && b && c && d) {
126
+ selector = (stateOrApiRef, args, instanceIdParam) => {
127
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
128
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
129
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
130
+ const va = a(state, args, instanceId);
131
+ const vb = b(state, args, instanceId);
132
+ const vc = c(state, args, instanceId);
133
+ return d(va, vb, vc, args);
134
+ };
135
+ } else if (a && b && c) {
136
+ selector = (stateOrApiRef, args, instanceIdParam) => {
137
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
138
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
139
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
140
+ const va = a(state, args, instanceId);
141
+ const vb = b(state, args, instanceId);
142
+ return c(va, vb, args);
143
+ };
144
+ } else if (a && b) {
145
+ selector = (stateOrApiRef, args, instanceIdParam) => {
146
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
147
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
148
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
149
+ const va = a(state, args, instanceId);
150
+ return b(va, args);
151
+ };
152
+ } else {
153
+ throw new Error('Missing arguments');
154
+ }
155
+
156
+ // We use this property to detect if the selector was created with createSelector
157
+ // or it's only a simple function the receives the state and returns part of it.
158
+ selector.acceptsApiRef = true;
159
+ return selector;
160
+ };
161
+
162
+ // TODO v8: Remove this function
163
+ exports.createSelectorV8 = createSelectorV8;
81
164
  const createSelectorMemoized = (...args) => {
82
165
  const selector = (stateOrApiRef, instanceId) => {
83
166
  const isAPIRef = checkIsAPIRef(stateOrApiRef);
@@ -109,4 +192,38 @@ const createSelectorMemoized = (...args) => {
109
192
  selector.acceptsApiRef = true;
110
193
  return selector;
111
194
  };
112
- exports.createSelectorMemoized = createSelectorMemoized;
195
+
196
+ // TODO v8: Rename this function to `createSelectorMemoized`
197
+ exports.createSelectorMemoized = createSelectorMemoized;
198
+ const createSelectorMemoizedV8 = (...args) => {
199
+ const selector = (stateOrApiRef, selectorArgs, instanceId) => {
200
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
201
+ const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
202
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
203
+ if (process.env.NODE_ENV !== 'production') {
204
+ if (cacheKey.id === 'default') {
205
+ (0, _warning.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)`.']);
206
+ }
207
+ }
208
+ const cacheArgsInit = cache.get(cacheKey);
209
+ const cacheArgs = cacheArgsInit ?? new Map();
210
+ const cacheFn = cacheArgs?.get(args);
211
+ if (cacheArgs && cacheFn) {
212
+ // We pass the cache key because the called selector might have as
213
+ // dependency another selector created with this `createSelector`.
214
+ return cacheFn(state, selectorArgs, cacheKey);
215
+ }
216
+ const fn = (0, _reselect.createSelector)(...args);
217
+ if (!cacheArgsInit) {
218
+ cache.set(cacheKey, cacheArgs);
219
+ }
220
+ cacheArgs.set(args, fn);
221
+ return fn(state, selectorArgs, cacheKey);
222
+ };
223
+
224
+ // We use this property to detect if the selector was created with createSelector
225
+ // or it's only a simple function the receives the state and returns part of it.
226
+ selector.acceptsApiRef = true;
227
+ return selector;
228
+ };
229
+ exports.createSelectorMemoizedV8 = createSelectorMemoizedV8;
@@ -3,21 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isNavigationKey = exports.isMultipleKey = exports.isKeyboardEvent = exports.isHideMenuKey = exports.isEscapeKey = exports.isCellExitEditModeKeys = exports.isCellEnterEditModeKeys = exports.isCellEditCommitKeys = exports.GRID_MULTIPLE_SELECTION_KEYS = exports.GRID_CELL_EXIT_EDIT_MODE_KEYS = exports.GRID_CELL_EDIT_COMMIT_KEYS = void 0;
6
+ exports.isNavigationKey = exports.isMultipleKey = exports.isKeyboardEvent = exports.isHideMenuKey = exports.isCellExitEditModeKeys = exports.isCellEnterEditModeKeys = exports.isCellEditCommitKeys = exports.GRID_MULTIPLE_SELECTION_KEYS = exports.GRID_CELL_EXIT_EDIT_MODE_KEYS = exports.GRID_CELL_EDIT_COMMIT_KEYS = void 0;
7
7
  exports.isPasteShortcut = isPasteShortcut;
8
8
  exports.isPrintableKey = isPrintableKey;
9
- exports.isTabKey = void 0;
10
- /**
11
- * @deprecated there is no meaninfuly logic abstracted, use event.key directly.
12
- */
13
- const isEscapeKey = key => key === 'Escape';
14
-
15
- /**
16
- * @deprecated there is no meaninfuly logic abstracted, use event.key directly.
17
- */
18
- exports.isEscapeKey = isEscapeKey;
19
- const isTabKey = key => key === 'Tab';
20
-
21
9
  // Non printable keys have a name, for example "ArrowRight", see the whole list:
22
10
  // https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
23
11
  // So event.key.length === 1 is often enough.
@@ -25,7 +13,6 @@ const isTabKey = key => key === 'Tab';
25
13
  // However, we also need to ignore shortcuts, for example: select all:
26
14
  // - Windows: Ctrl+A, event.ctrlKey is true
27
15
  // - macOS: ⌘ Command+A, event.metaKey is true
28
- exports.isTabKey = isTabKey;
29
16
  function isPrintableKey(event) {
30
17
  return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
31
18
  }
@@ -44,7 +31,7 @@ const isNavigationKey = key => key.indexOf('Arrow') === 0 || key.indexOf('Page')
44
31
  exports.isNavigationKey = isNavigationKey;
45
32
  const isKeyboardEvent = event => !!event.key;
46
33
  exports.isKeyboardEvent = isKeyboardEvent;
47
- const isHideMenuKey = key => isTabKey(key) || isEscapeKey(key);
34
+ const isHideMenuKey = key => key === 'Tab' || key === 'Escape';
48
35
 
49
36
  // In theory, on macOS, ctrl + v doesn't trigger a paste, so the function should return false.
50
37
  // However, maybe it's overkill to fix, so let's be lazy.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "7.13.0",
3
+ "version": "7.14.0",
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",
@@ -38,12 +38,12 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@babel/runtime": "^7.25.0",
41
- "@mui/system": "^5.16.5",
42
- "@mui/utils": "^5.16.5",
41
+ "@mui/system": "^5.16.7",
42
+ "@mui/utils": "^5.16.6",
43
43
  "clsx": "^2.1.1",
44
44
  "prop-types": "^15.8.1",
45
45
  "reselect": "^4.1.8",
46
- "@mui/x-internals": "7.13.0"
46
+ "@mui/x-internals": "7.14.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@emotion/react": "^11.9.0",
@@ -9,6 +9,14 @@ export interface OutputSelector<State, Result> {
9
9
  (state: State, instanceId: GridCoreApi['instanceId']): Result;
10
10
  acceptsApiRef: boolean;
11
11
  }
12
+ export interface OutputSelectorV8<State, Args, Result> {
13
+ (apiRef: React.MutableRefObject<{
14
+ state: State;
15
+ instanceId: GridCoreApi['instanceId'];
16
+ }>, args: Args): Result;
17
+ (state: State, instanceId: GridCoreApi['instanceId']): Result;
18
+ acceptsApiRef: boolean;
19
+ }
12
20
  type StateFromSelector<T> = T extends (first: infer F, ...args: any[]) => any ? F extends {
13
21
  state: infer F2;
14
22
  } ? F2 : F : never;
@@ -17,7 +25,18 @@ type StateFromSelectorList<Selectors extends readonly any[]> = Selectors extends
17
25
  ...other: infer R
18
26
  ] ? StateFromSelector<F> extends StateFromSelectorList<R> ? StateFromSelector<F> : StateFromSelectorList<R> : {};
19
27
  type SelectorArgs<Selectors extends ReadonlyArray<Selector<any>>, Result> = [selectors: [...Selectors], combiner: (...args: SelectorResultArray<Selectors>) => Result] | [...Selectors, (...args: SelectorResultArray<Selectors>) => Result];
28
+ type SelectorResultArrayWithArgs<Selectors extends ReadonlyArray<Selector<any>>, Args> = [
29
+ ...SelectorResultArray<Selectors>,
30
+ Args
31
+ ];
32
+ type SelectorArgsV8<Selectors extends ReadonlyArray<Selector<any>>, Args, Result> = [
33
+ selectors: [...Selectors],
34
+ combiner: (...args: SelectorResultArrayWithArgs<Selectors, Args>) => Result
35
+ ] | [...Selectors, (...args: SelectorResultArrayWithArgs<Selectors, Args>) => Result];
20
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>;
21
38
  export declare const createSelector: CreateSelectorFunction;
39
+ export declare const createSelectorV8: CreateSelectorFunctionV8;
22
40
  export declare const createSelectorMemoized: CreateSelectorFunction;
41
+ export declare const createSelectorMemoizedV8: CreateSelectorFunctionV8;
23
42
  export {};
@@ -1,5 +1,18 @@
1
1
  import { createSelector as reselectCreateSelector } from 'reselect';
2
2
  import { warnOnce } from '../internals/utils/warning';
3
+
4
+ // TODO v8: Remove this type
5
+
6
+ // TODO v8: Rename this type to `OutputSelector`
7
+
8
+ // TODO v8: Remove this type
9
+
10
+ // TODO v8: Rename this type to `SelectorArgs`
11
+
12
+ // TODO v8: Remove this type
13
+
14
+ // TODO v8: Rename this type to `CreateSelectorFunction`
15
+
3
16
  const cache = new WeakMap();
4
17
  function checkIsAPIRef(value) {
5
18
  return 'current' in value && 'instanceId' in value.current;
@@ -7,6 +20,8 @@ function checkIsAPIRef(value) {
7
20
  const DEFAULT_INSTANCE_ID = {
8
21
  id: 'default'
9
22
  };
23
+
24
+ // TODO v8: Remove this function
10
25
  export const createSelector = (a, b, c, d, e, f, ...other) => {
11
26
  if (other.length > 0) {
12
27
  throw new Error('Unsupported number of selectors');
@@ -71,6 +86,74 @@ export const createSelector = (a, b, c, d, e, f, ...other) => {
71
86
  selector.acceptsApiRef = true;
72
87
  return selector;
73
88
  };
89
+
90
+ // TODO v8: Rename this function to `createSelector`
91
+ export const createSelectorV8 = (a, b, c, d, e, f, ...other) => {
92
+ if (other.length > 0) {
93
+ throw new Error('Unsupported number of selectors');
94
+ }
95
+ let selector;
96
+ if (a && b && c && d && e && f) {
97
+ selector = (stateOrApiRef, args, instanceIdParam) => {
98
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
99
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
100
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
101
+ const va = a(state, args, instanceId);
102
+ const vb = b(state, args, instanceId);
103
+ const vc = c(state, args, instanceId);
104
+ const vd = d(state, args, instanceId);
105
+ const ve = e(state, args, instanceId);
106
+ return f(va, vb, vc, vd, ve, args);
107
+ };
108
+ } else if (a && b && c && d && e) {
109
+ selector = (stateOrApiRef, args, instanceIdParam) => {
110
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
111
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
112
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
113
+ const va = a(state, args, instanceId);
114
+ const vb = b(state, args, instanceId);
115
+ const vc = c(state, args, instanceId);
116
+ const vd = d(state, args, instanceId);
117
+ return e(va, vb, vc, vd, args);
118
+ };
119
+ } else if (a && b && c && d) {
120
+ selector = (stateOrApiRef, args, instanceIdParam) => {
121
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
122
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
123
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
124
+ const va = a(state, args, instanceId);
125
+ const vb = b(state, args, instanceId);
126
+ const vc = c(state, args, instanceId);
127
+ return d(va, vb, vc, args);
128
+ };
129
+ } else if (a && b && c) {
130
+ selector = (stateOrApiRef, args, instanceIdParam) => {
131
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
132
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
133
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
134
+ const va = a(state, args, instanceId);
135
+ const vb = b(state, args, instanceId);
136
+ return c(va, vb, args);
137
+ };
138
+ } else if (a && b) {
139
+ selector = (stateOrApiRef, args, instanceIdParam) => {
140
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
141
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
142
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
143
+ const va = a(state, args, instanceId);
144
+ return b(va, args);
145
+ };
146
+ } else {
147
+ throw new Error('Missing arguments');
148
+ }
149
+
150
+ // We use this property to detect if the selector was created with createSelector
151
+ // or it's only a simple function the receives the state and returns part of it.
152
+ selector.acceptsApiRef = true;
153
+ return selector;
154
+ };
155
+
156
+ // TODO v8: Remove this function
74
157
  export const createSelectorMemoized = (...args) => {
75
158
  const selector = (stateOrApiRef, instanceId) => {
76
159
  const isAPIRef = checkIsAPIRef(stateOrApiRef);
@@ -97,6 +180,39 @@ export const createSelectorMemoized = (...args) => {
97
180
  return fn(state, cacheKey);
98
181
  };
99
182
 
183
+ // We use this property to detect if the selector was created with createSelector
184
+ // or it's only a simple function the receives the state and returns part of it.
185
+ selector.acceptsApiRef = true;
186
+ return selector;
187
+ };
188
+
189
+ // TODO v8: Rename this function to `createSelectorMemoized`
190
+ export const createSelectorMemoizedV8 = (...args) => {
191
+ const selector = (stateOrApiRef, selectorArgs, instanceId) => {
192
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
193
+ const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
194
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
195
+ if (process.env.NODE_ENV !== 'production') {
196
+ if (cacheKey.id === 'default') {
197
+ 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)`.']);
198
+ }
199
+ }
200
+ const cacheArgsInit = cache.get(cacheKey);
201
+ const cacheArgs = cacheArgsInit ?? new Map();
202
+ const cacheFn = cacheArgs?.get(args);
203
+ if (cacheArgs && cacheFn) {
204
+ // We pass the cache key because the called selector might have as
205
+ // dependency another selector created with this `createSelector`.
206
+ return cacheFn(state, selectorArgs, cacheKey);
207
+ }
208
+ const fn = reselectCreateSelector(...args);
209
+ if (!cacheArgsInit) {
210
+ cache.set(cacheKey, cacheArgs);
211
+ }
212
+ cacheArgs.set(args, fn);
213
+ return fn(state, selectorArgs, cacheKey);
214
+ };
215
+
100
216
  // We use this property to detect if the selector was created with createSelector
101
217
  // or it's only a simple function the receives the state and returns part of it.
102
218
  selector.acceptsApiRef = true;
@@ -1,12 +1,4 @@
1
1
  import * as React from 'react';
2
- /**
3
- * @deprecated there is no meaninfuly logic abstracted, use event.key directly.
4
- */
5
- export declare const isEscapeKey: (key: string) => boolean;
6
- /**
7
- * @deprecated there is no meaninfuly logic abstracted, use event.key directly.
8
- */
9
- export declare const isTabKey: (key: string) => boolean;
10
2
  export declare function isPrintableKey(event: React.KeyboardEvent<HTMLElement>): boolean;
11
3
  export declare const GRID_MULTIPLE_SELECTION_KEYS: string[];
12
4
  export declare const GRID_CELL_EXIT_EDIT_MODE_KEYS: string[];
@@ -17,5 +9,5 @@ export declare const isCellExitEditModeKeys: (key: string) => boolean;
17
9
  export declare const isCellEditCommitKeys: (key: string) => boolean;
18
10
  export declare const isNavigationKey: (key: string) => boolean;
19
11
  export declare const isKeyboardEvent: (event: any) => event is React.KeyboardEvent<HTMLElement>;
20
- export declare const isHideMenuKey: (key: React.KeyboardEvent["key"]) => boolean;
12
+ export declare const isHideMenuKey: (key: React.KeyboardEvent["key"]) => key is "Tab" | "Escape";
21
13
  export declare function isPasteShortcut(event: React.KeyboardEvent): boolean;
@@ -1,13 +1,3 @@
1
- /**
2
- * @deprecated there is no meaninfuly logic abstracted, use event.key directly.
3
- */
4
- export const isEscapeKey = key => key === 'Escape';
5
-
6
- /**
7
- * @deprecated there is no meaninfuly logic abstracted, use event.key directly.
8
- */
9
- export const isTabKey = key => key === 'Tab';
10
-
11
1
  // Non printable keys have a name, for example "ArrowRight", see the whole list:
12
2
  // https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
13
3
  // So event.key.length === 1 is often enough.
@@ -27,7 +17,7 @@ export const isCellExitEditModeKeys = key => GRID_CELL_EXIT_EDIT_MODE_KEYS.index
27
17
  export const isCellEditCommitKeys = key => GRID_CELL_EDIT_COMMIT_KEYS.indexOf(key) > -1;
28
18
  export const isNavigationKey = key => key.indexOf('Arrow') === 0 || key.indexOf('Page') === 0 || key === ' ' || key === 'Home' || key === 'End';
29
19
  export const isKeyboardEvent = event => !!event.key;
30
- export const isHideMenuKey = key => isTabKey(key) || isEscapeKey(key);
20
+ export const isHideMenuKey = key => key === 'Tab' || key === 'Escape';
31
21
 
32
22
  // In theory, on macOS, ctrl + v doesn't trigger a paste, so the function should return false.
33
23
  // However, maybe it's overkill to fix, so let's be lazy.