@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
@@ -10,7 +10,6 @@ import ClickAwayListener from '@mui/material/ClickAwayListener';
10
10
  import Paper from '@mui/material/Paper';
11
11
  import Popper from '@mui/material/Popper';
12
12
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
13
- import { isEscapeKey } from '../../utils/keyboardUtils';
14
13
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
15
14
  import { jsx as _jsx } from "react/jsx-runtime";
16
15
  export const gridPanelClasses = generateUtilityClasses('MuiDataGrid', ['panel', 'paper']);
@@ -51,7 +50,7 @@ const GridPanel = /*#__PURE__*/React.forwardRef((props, ref) => {
51
50
  apiRef.current.hidePreferences();
52
51
  }, [apiRef]);
53
52
  const handleKeyDown = React.useCallback(event => {
54
- if (isEscapeKey(event.key)) {
53
+ if (event.key === 'Escape') {
55
54
  apiRef.current.hidePreferences();
56
55
  }
57
56
  }, [apiRef]);
@@ -281,10 +281,15 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
281
281
  variant: "standard",
282
282
  as: rootProps.slots.baseFormControl
283
283
  }, baseFormControlProps, logicOperatorInputProps, {
284
- sx: _extends({
285
- display: hasLogicOperatorColumn ? 'flex' : 'none',
286
- visibility: showMultiFilterOperators ? 'visible' : 'hidden'
287
- }, baseFormControlProps.sx || {}, logicOperatorInputProps.sx || {}),
284
+ sx: [hasLogicOperatorColumn ? {
285
+ display: 'flex'
286
+ } : {
287
+ display: 'none'
288
+ }, showMultiFilterOperators ? {
289
+ visibility: 'visible'
290
+ } : {
291
+ visibility: 'hidden'
292
+ }, baseFormControlProps.sx, logicOperatorInputProps.sx],
288
293
  className: clsx(classes.logicOperatorInput, baseFormControlProps.className, logicOperatorInputProps.className),
289
294
  ownerState: rootProps,
290
295
  children: /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
@@ -6,7 +6,7 @@ import MenuList from '@mui/material/MenuList';
6
6
  import MenuItem from '@mui/material/MenuItem';
7
7
  import ListItemIcon from '@mui/material/ListItemIcon';
8
8
  import { gridDensitySelector } from '../../hooks/features/density/densitySelector';
9
- import { isHideMenuKey, isTabKey } from '../../utils/keyboardUtils';
9
+ import { isHideMenuKey } from '../../utils/keyboardUtils';
10
10
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
11
11
  import { useGridSelector } from '../../hooks/utils/useGridSelector';
12
12
  import { GridMenu } from '../menu/GridMenu';
@@ -62,7 +62,7 @@ const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function GridTo
62
62
  setOpen(false);
63
63
  };
64
64
  const handleListKeyDown = event => {
65
- if (isTabKey(event.key)) {
65
+ if (event.key === 'Tab') {
66
66
  event.preventDefault();
67
67
  }
68
68
  if (isHideMenuKey(event.key)) {
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { unstable_useId as useId, unstable_useForkRef as useForkRef } from '@mui/utils';
5
5
  import MenuList from '@mui/material/MenuList';
6
- import { isHideMenuKey, isTabKey } from '../../utils/keyboardUtils';
6
+ import { isHideMenuKey } from '../../utils/keyboardUtils';
7
7
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
8
8
  import { GridMenu } from '../menu/GridMenu';
9
9
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
@@ -29,7 +29,7 @@ const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function GridTo
29
29
  };
30
30
  const handleMenuClose = () => setOpen(false);
31
31
  const handleListKeyDown = event => {
32
- if (isTabKey(event.key)) {
32
+ if (event.key === 'Tab') {
33
33
  event.preventDefault();
34
34
  }
35
35
  if (isHideMenuKey(event.key)) {
@@ -105,9 +105,11 @@ function GridToolbarQuickFilter(props) {
105
105
  endAdornment: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
106
106
  "aria-label": apiRef.current.getLocaleText('toolbarQuickFilterDeleteIconLabel'),
107
107
  size: "small",
108
- sx: {
109
- visibility: searchValue ? 'visible' : 'hidden'
110
- },
108
+ sx: [searchValue ? {
109
+ visibility: 'visible'
110
+ } : {
111
+ visibility: 'hidden'
112
+ }],
111
113
  onClick: handleSearchReset
112
114
  }, rootProps.slotProps?.baseIconButton, {
113
115
  children: /*#__PURE__*/_jsx(rootProps.slots.quickFilterClearIcon, {
@@ -51,7 +51,8 @@ export function useGridParamsApi(apiRef) {
51
51
  tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
52
52
  value,
53
53
  formattedValue: value,
54
- isEditable: false
54
+ isEditable: false,
55
+ api: {}
55
56
  };
56
57
  if (colDef && colDef.valueFormatter) {
57
58
  params.formattedValue = colDef.valueFormatter(value, row, colDef, apiRef);
@@ -6,12 +6,21 @@ import { warnOnce } from '../../internals/utils/warning';
6
6
  function isOutputSelector(selector) {
7
7
  return selector.acceptsApiRef;
8
8
  }
9
+ // TODO v8: Remove this function
9
10
  function applySelector(apiRef, selector) {
10
11
  if (isOutputSelector(selector)) {
11
12
  return selector(apiRef);
12
13
  }
13
14
  return selector(apiRef.current.state);
14
15
  }
16
+
17
+ // TODO v8: Rename this function to `applySelector`
18
+ function applySelectorV8(apiRef, selector, args, instanceId) {
19
+ if (isOutputSelector(selector)) {
20
+ return selector(apiRef, args);
21
+ }
22
+ return selector(apiRef.current.state, instanceId);
23
+ }
15
24
  const defaultCompare = Object.is;
16
25
  export const objectShallowCompare = fastObjectShallowCompare;
17
26
  const createRefs = () => ({
@@ -19,6 +28,8 @@ const createRefs = () => ({
19
28
  equals: null,
20
29
  selector: null
21
30
  });
31
+
32
+ // TODO v8: Remove this function
22
33
  export const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
23
34
  if (process.env.NODE_ENV !== 'production') {
24
35
  if (!apiRef.current.state) {
@@ -43,4 +54,31 @@ export const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
43
54
  });
44
55
  });
45
56
  return state;
57
+ };
58
+
59
+ // TODO v8: Rename this function to `useGridSelector`
60
+ export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = defaultCompare) => {
61
+ if (process.env.NODE_ENV !== 'production') {
62
+ if (!apiRef.current.state) {
63
+ warnOnce(['MUI X: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
64
+ }
65
+ }
66
+ const refs = useLazyRef(createRefs);
67
+ const didInit = refs.current.selector !== null;
68
+ const [state, setState] = React.useState(
69
+ // We don't use an initialization function to avoid allocations
70
+ didInit ? null : applySelectorV8(apiRef, selector, args, apiRef.current.instanceId));
71
+ refs.current.state = state;
72
+ refs.current.equals = equals;
73
+ refs.current.selector = selector;
74
+ useOnMount(() => {
75
+ return apiRef.current.store.subscribe(() => {
76
+ const newState = applySelectorV8(apiRef, refs.current.selector, args, apiRef.current.instanceId);
77
+ if (!refs.current.equals(refs.current.state, newState)) {
78
+ refs.current.state = newState;
79
+ setState(newState);
80
+ }
81
+ });
82
+ });
83
+ return state;
46
84
  };
package/modern/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
@@ -57,7 +57,8 @@ export { useGridVisibleRows, getVisibleRows } from '../hooks/utils/useGridVisibl
57
57
  export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
58
58
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
59
59
  export * from '../utils/createControllablePromise';
60
- export { createSelector, createSelectorMemoized } from '../utils/createSelector';
60
+ export { createSelector, createSelectorV8, createSelectorMemoized, createSelectorMemoizedV8 } from '../utils/createSelector';
61
+ export { useGridSelectorV8 } from '../hooks/utils/useGridSelector';
61
62
  export { gridRowGroupsToFetchSelector } from '../hooks/features/rows/gridRowsSelector';
62
63
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from '../utils/domUtils';
63
64
  export { isNavigationKey, isPasteShortcut } from '../utils/keyboardUtils';
@@ -38,11 +38,10 @@ const csCZGrid = {
38
38
  toolbarExportPrint: 'Vytisknout',
39
39
  toolbarExportExcel: 'Stáhnout jako Excel',
40
40
  // Columns management text
41
- // columnsManagementSearchTitle: 'Search',
42
- // columnsManagementNoColumns: 'No columns',
43
- // columnsManagementShowHideAllText: 'Show/Hide All',
44
- // columnsManagementReset: 'Reset',
45
-
41
+ columnsManagementSearchTitle: 'Hledat sloupce',
42
+ columnsManagementNoColumns: 'Žádné sloupce',
43
+ columnsManagementShowHideAllText: 'Zobrazit/skrýt vše',
44
+ columnsManagementReset: 'Resetovat',
46
45
  // Filter panel text
47
46
  filterPanelAddFilter: 'Přidat filtr',
48
47
  filterPanelRemoveAll: 'Odstranit vše',
@@ -30,11 +30,10 @@ const heILGrid = {
30
30
  toolbarExportPrint: 'הדפסה',
31
31
  toolbarExportExcel: 'ייצוא ל- Excel',
32
32
  // Columns management text
33
- // columnsManagementSearchTitle: 'Search',
34
- // columnsManagementNoColumns: 'No columns',
35
- // columnsManagementShowHideAllText: 'Show/Hide All',
36
- // columnsManagementReset: 'Reset',
37
-
33
+ columnsManagementSearchTitle: 'חיפוש',
34
+ columnsManagementNoColumns: 'אין עמודות',
35
+ columnsManagementShowHideAllText: 'הצג/הסתר הכל',
36
+ columnsManagementReset: 'אתחול',
38
37
  // Filter panel text
39
38
  filterPanelAddFilter: 'הוסף מסנן',
40
39
  filterPanelRemoveAll: 'מחק הכל',
@@ -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,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.
@@ -116,13 +116,12 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
116
116
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
117
117
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
118
118
  const field = column.field;
119
- const cellParamsWithAPI = (0, _useGridSelector.useGridSelector)(apiRef, () => {
119
+ const cellParams = (0, _useGridSelector.useGridSelector)(apiRef, () => {
120
120
  // This is required because `.getCellParams` tries to get the `state.rows.tree` entry
121
121
  // associated with `rowId`/`fieldId`, but this selector runs after the state has been
122
122
  // updated, while `rowId`/`fieldId` reference an entry in the old state.
123
123
  try {
124
- const cellParams = apiRef.current.getCellParams(rowId, field);
125
- const result = cellParams;
124
+ const result = apiRef.current.getCellParams(rowId, field);
126
125
  result.api = apiRef.current;
127
126
  return result;
128
127
  } catch (e) {
@@ -141,9 +140,9 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
141
140
  hasFocus,
142
141
  isEditable = false,
143
142
  value
144
- } = cellParamsWithAPI;
143
+ } = cellParams;
145
144
  const canManageOwnFocus = column.type === 'actions' && column.getActions?.(apiRef.current.getRowParams(rowId)).some(action => !action.props.disabled);
146
- const tabIndex = (cellMode === 'view' || !isEditable) && !canManageOwnFocus ? cellParamsWithAPI.tabIndex : -1;
145
+ const tabIndex = (cellMode === 'view' || !isEditable) && !canManageOwnFocus ? cellParams.tabIndex : -1;
147
146
  const {
148
147
  classes: rootClasses,
149
148
  getCellClassName
@@ -156,15 +155,15 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
156
155
  }).filter(Boolean).join(' '));
157
156
  const classNames = [pipesClassName];
158
157
  if (column.cellClassName) {
159
- classNames.push(typeof column.cellClassName === 'function' ? column.cellClassName(cellParamsWithAPI) : column.cellClassName);
158
+ classNames.push(typeof column.cellClassName === 'function' ? column.cellClassName(cellParams) : column.cellClassName);
160
159
  }
161
160
  if (column.display === 'flex') {
162
161
  classNames.push(_gridClasses.gridClasses['cell--flex']);
163
162
  }
164
163
  if (getCellClassName) {
165
- classNames.push(getCellClassName(cellParamsWithAPI));
164
+ classNames.push(getCellClassName(cellParams));
166
165
  }
167
- const valueToRender = cellParamsWithAPI.formattedValue ?? value;
166
+ const valueToRender = cellParams.formattedValue ?? value;
168
167
  const cellRef = React.useRef(null);
169
168
  const handleRef = (0, _utils.unstable_useForkRef)(ref, cellRef);
170
169
  const focusElementRef = React.useRef(null);
@@ -247,7 +246,7 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
247
246
  }
248
247
  }
249
248
  }, [hasFocus, cellMode, apiRef]);
250
- if (cellParamsWithAPI === EMPTY_CELL_PARAMS) {
249
+ if (cellParams === EMPTY_CELL_PARAMS) {
251
250
  return null;
252
251
  }
253
252
  let handleFocus = other.onFocus;
@@ -269,15 +268,15 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
269
268
  let children;
270
269
  let title;
271
270
  if (editCellState === null && column.renderCell) {
272
- children = column.renderCell(cellParamsWithAPI);
271
+ children = column.renderCell(cellParams);
273
272
  }
274
273
  if (editCellState !== null && column.renderEditCell) {
275
274
  const updatedRow = apiRef.current.getRowWithUpdatedValues(rowId, column.field);
276
275
 
277
276
  // eslint-disable-next-line @typescript-eslint/naming-convention
278
277
  const editCellStateRest = (0, _objectWithoutPropertiesLoose2.default)(editCellState, _excluded2);
279
- const formattedValue = column.valueFormatter ? column.valueFormatter(editCellState.value, updatedRow, column, apiRef) : cellParamsWithAPI.formattedValue;
280
- const params = (0, _extends2.default)({}, cellParamsWithAPI, {
278
+ const formattedValue = column.valueFormatter ? column.valueFormatter(editCellState.value, updatedRow, column, apiRef) : cellParams.formattedValue;
279
+ const params = (0, _extends2.default)({}, cellParams, {
281
280
  row: updatedRow,
282
281
  formattedValue
283
282
  }, editCellStateRest);
@@ -13,7 +13,6 @@ var React = _react;
13
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
14
  var _utils = require("@mui/utils");
15
15
  var _gridEditCellParams = require("../../models/params/gridEditCellParams");
16
- var _keyboardUtils = require("../../utils/keyboardUtils");
17
16
  var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
18
17
  var _gridEditRowModel = require("../../models/gridEditRowModel");
19
18
  var _filterPanelUtils = require("../panel/filterPanel/filterPanelUtils");
@@ -90,10 +89,10 @@ function GridEditSingleSelectCell(props) {
90
89
  setOpen(false);
91
90
  return;
92
91
  }
93
- if (reason === 'backdropClick' || (0, _keyboardUtils.isEscapeKey)(event.key)) {
92
+ if (reason === 'backdropClick' || event.key === 'Escape') {
94
93
  const params = apiRef.current.getCellParams(id, field);
95
94
  apiRef.current.publishEvent('cellEditStop', (0, _extends2.default)({}, params, {
96
- reason: (0, _keyboardUtils.isEscapeKey)(event.key) ? _gridEditCellParams.GridCellEditStopReasons.escapeKeyDown : _gridEditCellParams.GridCellEditStopReasons.cellFocusOut
95
+ reason: event.key === 'Escape' ? _gridEditCellParams.GridCellEditStopReasons.escapeKeyDown : _gridEditCellParams.GridCellEditStopReasons.cellFocusOut
97
96
  }));
98
97
  }
99
98
  };
@@ -32,7 +32,7 @@ const GridColumnMenuContainer = exports.GridColumnMenuContainer = /*#__PURE__*/R
32
32
  } = props,
33
33
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
34
34
  const handleListKeyDown = React.useCallback(event => {
35
- if ((0, _keyboardUtils.isTabKey)(event.key)) {
35
+ if (event.key === 'Tab') {
36
36
  event.preventDefault();
37
37
  }
38
38
  if ((0, _keyboardUtils.isHideMenuKey)(event.key)) {
@@ -16,7 +16,6 @@ var _ClickAwayListener = _interopRequireDefault(require("@mui/material/ClickAway
16
16
  var _Paper = _interopRequireDefault(require("@mui/material/Paper"));
17
17
  var _Popper = _interopRequireDefault(require("@mui/material/Popper"));
18
18
  var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
19
- var _keyboardUtils = require("../../utils/keyboardUtils");
20
19
  var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
21
20
  var _jsxRuntime = require("react/jsx-runtime");
22
21
  const _excluded = ["children", "className", "classes"];
@@ -60,7 +59,7 @@ const GridPanel = exports.GridPanel = /*#__PURE__*/React.forwardRef((props, ref)
60
59
  apiRef.current.hidePreferences();
61
60
  }, [apiRef]);
62
61
  const handleKeyDown = React.useCallback(event => {
63
- if ((0, _keyboardUtils.isEscapeKey)(event.key)) {
62
+ if (event.key === 'Escape') {
64
63
  apiRef.current.hidePreferences();
65
64
  }
66
65
  }, [apiRef]);
@@ -290,10 +290,15 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
290
290
  variant: "standard",
291
291
  as: rootProps.slots.baseFormControl
292
292
  }, baseFormControlProps, logicOperatorInputProps, {
293
- sx: (0, _extends2.default)({
294
- display: hasLogicOperatorColumn ? 'flex' : 'none',
295
- visibility: showMultiFilterOperators ? 'visible' : 'hidden'
296
- }, baseFormControlProps.sx || {}, logicOperatorInputProps.sx || {}),
293
+ sx: [hasLogicOperatorColumn ? {
294
+ display: 'flex'
295
+ } : {
296
+ display: 'none'
297
+ }, showMultiFilterOperators ? {
298
+ visibility: 'visible'
299
+ } : {
300
+ visibility: 'hidden'
301
+ }, baseFormControlProps.sx, logicOperatorInputProps.sx],
297
302
  className: (0, _clsx.default)(classes.logicOperatorInput, baseFormControlProps.className, logicOperatorInputProps.className),
298
303
  ownerState: rootProps,
299
304
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSelect, (0, _extends2.default)({
@@ -71,7 +71,7 @@ const GridToolbarDensitySelector = exports.GridToolbarDensitySelector = /*#__PUR
71
71
  setOpen(false);
72
72
  };
73
73
  const handleListKeyDown = event => {
74
- if ((0, _keyboardUtils.isTabKey)(event.key)) {
74
+ if (event.key === 'Tab') {
75
75
  event.preventDefault();
76
76
  }
77
77
  if ((0, _keyboardUtils.isHideMenuKey)(event.key)) {
@@ -38,7 +38,7 @@ const GridToolbarExportContainer = exports.GridToolbarExportContainer = /*#__PUR
38
38
  };
39
39
  const handleMenuClose = () => setOpen(false);
40
40
  const handleListKeyDown = event => {
41
- if ((0, _keyboardUtils.isTabKey)(event.key)) {
41
+ if (event.key === 'Tab') {
42
42
  event.preventDefault();
43
43
  }
44
44
  if ((0, _keyboardUtils.isHideMenuKey)(event.key)) {
@@ -114,9 +114,11 @@ function GridToolbarQuickFilter(props) {
114
114
  endAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, (0, _extends2.default)({
115
115
  "aria-label": apiRef.current.getLocaleText('toolbarQuickFilterDeleteIconLabel'),
116
116
  size: "small",
117
- sx: {
118
- visibility: searchValue ? 'visible' : 'hidden'
119
- },
117
+ sx: [searchValue ? {
118
+ visibility: 'visible'
119
+ } : {
120
+ visibility: 'hidden'
121
+ }],
120
122
  onClick: handleSearchReset
121
123
  }, rootProps.slotProps?.baseIconButton, {
122
124
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.quickFilterClearIcon, {
@@ -61,7 +61,8 @@ function useGridParamsApi(apiRef) {
61
61
  tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
62
62
  value,
63
63
  formattedValue: value,
64
- isEditable: false
64
+ isEditable: false,
65
+ api: {}
65
66
  };
66
67
  if (colDef && colDef.valueFormatter) {
67
68
  params.formattedValue = colDef.valueFormatter(value, row, colDef, apiRef);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useGridSelector = exports.objectShallowCompare = void 0;
6
+ exports.useGridSelectorV8 = exports.useGridSelector = exports.objectShallowCompare = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompare");
9
9
  var _useLazyRef = require("./useLazyRef");
@@ -14,12 +14,21 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
14
14
  function isOutputSelector(selector) {
15
15
  return selector.acceptsApiRef;
16
16
  }
17
+ // TODO v8: Remove this function
17
18
  function applySelector(apiRef, selector) {
18
19
  if (isOutputSelector(selector)) {
19
20
  return selector(apiRef);
20
21
  }
21
22
  return selector(apiRef.current.state);
22
23
  }
24
+
25
+ // TODO v8: Rename this function to `applySelector`
26
+ function applySelectorV8(apiRef, selector, args, instanceId) {
27
+ if (isOutputSelector(selector)) {
28
+ return selector(apiRef, args);
29
+ }
30
+ return selector(apiRef.current.state, instanceId);
31
+ }
23
32
  const defaultCompare = Object.is;
24
33
  const objectShallowCompare = exports.objectShallowCompare = _fastObjectShallowCompare.fastObjectShallowCompare;
25
34
  const createRefs = () => ({
@@ -27,6 +36,8 @@ const createRefs = () => ({
27
36
  equals: null,
28
37
  selector: null
29
38
  });
39
+
40
+ // TODO v8: Remove this function
30
41
  const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
31
42
  if (process.env.NODE_ENV !== 'production') {
32
43
  if (!apiRef.current.state) {
@@ -52,4 +63,32 @@ const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
52
63
  });
53
64
  return state;
54
65
  };
55
- exports.useGridSelector = useGridSelector;
66
+
67
+ // TODO v8: Rename this function to `useGridSelector`
68
+ exports.useGridSelector = useGridSelector;
69
+ const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = defaultCompare) => {
70
+ if (process.env.NODE_ENV !== 'production') {
71
+ if (!apiRef.current.state) {
72
+ (0, _warning.warnOnce)(['MUI X: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
73
+ }
74
+ }
75
+ const refs = (0, _useLazyRef.useLazyRef)(createRefs);
76
+ const didInit = refs.current.selector !== null;
77
+ const [state, setState] = React.useState(
78
+ // We don't use an initialization function to avoid allocations
79
+ didInit ? null : applySelectorV8(apiRef, selector, args, apiRef.current.instanceId));
80
+ refs.current.state = state;
81
+ refs.current.equals = equals;
82
+ refs.current.selector = selector;
83
+ (0, _useOnMount.useOnMount)(() => {
84
+ return apiRef.current.store.subscribe(() => {
85
+ const newState = applySelectorV8(apiRef, refs.current.selector, args, apiRef.current.instanceId);
86
+ if (!refs.current.equals(refs.current.state, newState)) {
87
+ refs.current.state = newState;
88
+ setState(newState);
89
+ }
90
+ });
91
+ });
92
+ return state;
93
+ };
94
+ exports.useGridSelectorV8 = useGridSelectorV8;