@mui/x-data-grid 7.0.0-beta.5 → 7.0.0-beta.6

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 (47) hide show
  1. package/CHANGELOG.md +135 -49
  2. package/components/GridPinnedRows.d.ts +1 -2
  3. package/components/GridRow.js +5 -7
  4. package/components/cell/GridCell.d.ts +0 -2
  5. package/components/cell/GridCell.js +3 -7
  6. package/components/containers/GridRootStyles.js +0 -2
  7. package/components/virtualization/GridVirtualScroller.js +5 -3
  8. package/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
  9. package/hooks/features/dimensions/useGridDimensions.js +1 -0
  10. package/hooks/features/rows/useGridParamsApi.js +6 -10
  11. package/hooks/features/sorting/useGridSorting.js +2 -2
  12. package/hooks/features/virtualization/useGridVirtualScroller.js +6 -0
  13. package/index.js +1 -1
  14. package/internals/index.d.ts +1 -1
  15. package/internals/index.js +1 -1
  16. package/models/api/gridApiCommon.d.ts +2 -1
  17. package/models/api/gridInfiniteLoaderApi.d.ts +6 -0
  18. package/models/api/gridInfiniteLoaderApi.js +1 -0
  19. package/modern/components/GridRow.js +5 -7
  20. package/modern/components/cell/GridCell.js +3 -7
  21. package/modern/components/containers/GridRootStyles.js +0 -2
  22. package/modern/components/virtualization/GridVirtualScroller.js +5 -3
  23. package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
  24. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -0
  25. package/modern/hooks/features/rows/useGridParamsApi.js +6 -10
  26. package/modern/hooks/features/sorting/useGridSorting.js +2 -2
  27. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +5 -0
  28. package/modern/index.js +1 -1
  29. package/modern/internals/index.js +1 -1
  30. package/modern/models/api/gridInfiniteLoaderApi.js +1 -0
  31. package/modern/utils/createSelector.js +12 -20
  32. package/node/components/GridRow.js +5 -7
  33. package/node/components/cell/GridCell.js +3 -7
  34. package/node/components/containers/GridRootStyles.js +0 -2
  35. package/node/components/virtualization/GridVirtualScroller.js +5 -3
  36. package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
  37. package/node/hooks/features/dimensions/useGridDimensions.js +1 -0
  38. package/node/hooks/features/rows/useGridParamsApi.js +6 -10
  39. package/node/hooks/features/sorting/useGridSorting.js +2 -2
  40. package/node/hooks/features/virtualization/useGridVirtualScroller.js +5 -0
  41. package/node/index.js +1 -1
  42. package/node/internals/index.js +0 -7
  43. package/node/models/api/gridInfiniteLoaderApi.js +5 -0
  44. package/node/utils/createSelector.js +14 -23
  45. package/package.json +2 -2
  46. package/utils/createSelector.d.ts +0 -1
  47. package/utils/createSelector.js +12 -22
@@ -21,7 +21,7 @@ var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
21
21
  var _gridFocusStateSelector = require("../../hooks/features/focus/gridFocusStateSelector");
22
22
  var _useGridParamsApi = require("../../hooks/features/rows/useGridParamsApi");
23
23
  var _jsxRuntime = require("react/jsx-runtime");
24
- const _excluded = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "style", "gridHasScrollX", "colSpan", "disableDragEvents", "isNotVisible", "pinnedOffset", "pinnedPosition", "sectionIndex", "sectionLength", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
24
+ const _excluded = ["column", "rowId", "editCellState", "align", "children", "colIndex", "width", "className", "style", "gridHasScrollX", "colSpan", "disableDragEvents", "isNotVisible", "pinnedOffset", "pinnedPosition", "sectionIndex", "sectionLength", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
25
25
  _excluded2 = ["changeReason", "unstable_updateValueOnRender"];
26
26
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
27
27
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -83,7 +83,6 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
83
83
  editCellState,
84
84
  align,
85
85
  colIndex,
86
- height,
87
86
  width,
88
87
  className,
89
88
  style: styleProp,
@@ -212,8 +211,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
212
211
  };
213
212
  }
214
213
  const cellStyle = (0, _extends2.default)({
215
- '--width': `${width}px`,
216
- '--height': typeof height === 'number' ? `${height}px` : height
214
+ '--width': `${width}px`
217
215
  }, styleProp);
218
216
  if (pinnedPosition === PinnedPosition.LEFT) {
219
217
  cellStyle.left = pinnedOffset;
@@ -222,7 +220,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
222
220
  cellStyle.right = pinnedOffset;
223
221
  }
224
222
  return cellStyle;
225
- }, [width, height, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
223
+ }, [width, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
226
224
  React.useEffect(() => {
227
225
  if (!hasFocus || cellMode === _models.GridCellModes.Edit) {
228
226
  return;
@@ -332,8 +330,6 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
332
330
  isValidating: _propTypes.default.bool,
333
331
  value: _propTypes.default.any
334
332
  }),
335
- gridHasScrollX: _propTypes.default.bool.isRequired,
336
- height: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]).isRequired,
337
333
  isNotVisible: _propTypes.default.bool.isRequired,
338
334
  onClick: _propTypes.default.func,
339
335
  onDoubleClick: _propTypes.default.func,
@@ -448,8 +448,6 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
448
448
  lineHeight: 'calc(var(--height) - 1px)',
449
449
  // -1px for the border
450
450
 
451
- '--width': '0px',
452
- '--height': '0px',
453
451
  boxSizing: 'border-box',
454
452
  borderTop: `1px solid var(--rowBorderColor)`,
455
453
  overflow: 'hidden',
@@ -67,8 +67,10 @@ function GridVirtualScroller(props) {
67
67
  getContentProps,
68
68
  getRenderZoneProps,
69
69
  getScrollbarVerticalProps,
70
- getScrollbarHorizontalProps
70
+ getScrollbarHorizontalProps,
71
+ getRows
71
72
  } = virtualScroller;
73
+ const rows = getRows();
72
74
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridMainContainer.GridMainContainer, (0, _extends2.default)({
73
75
  className: classes.root
74
76
  }, getContainerProps(), {
@@ -83,11 +85,11 @@ function GridVirtualScroller(props) {
83
85
  })]
84
86
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridOverlays.GridOverlays, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridVirtualScrollerContent.GridVirtualScrollerContent, (0, _extends2.default)({}, getContentProps(), {
85
87
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridVirtualScrollerRenderZone.GridVirtualScrollerRenderZone, (0, _extends2.default)({}, getRenderZoneProps(), {
86
- children: [virtualScroller.getRows(), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.detailPanels, {
88
+ children: [rows, /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.detailPanels, {
87
89
  virtualScroller: virtualScroller
88
90
  })]
89
91
  }))
90
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridVirtualScrollerFiller.GridVirtualScrollerFiller, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridBottomContainer.GridBottomContainer, {
92
+ })), rows.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridVirtualScrollerFiller.GridVirtualScrollerFiller, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridBottomContainer.GridBottomContainer, {
91
93
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.pinnedRows, {
92
94
  position: "bottom",
93
95
  virtualScroller: virtualScroller
@@ -41,7 +41,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
41
41
  * * `apiRef.current.requestPipeProcessorsApplication` is called for the given group.
42
42
  */
43
43
  const useGridPipeProcessing = apiRef => {
44
- const processorsCache = React.useRef({});
44
+ const cache = React.useRef({});
45
45
  const isRunning = React.useRef(false);
46
46
  const runAppliers = React.useCallback(groupCache => {
47
47
  if (isRunning.current || !groupCache) {
@@ -54,52 +54,54 @@ const useGridPipeProcessing = apiRef => {
54
54
  isRunning.current = false;
55
55
  }, []);
56
56
  const registerPipeProcessor = React.useCallback((group, id, processor) => {
57
- if (!processorsCache.current[group]) {
58
- processorsCache.current[group] = {
57
+ if (!cache.current[group]) {
58
+ cache.current[group] = {
59
59
  processors: new Map(),
60
+ processorsAsArray: [],
60
61
  appliers: {}
61
62
  };
62
63
  }
63
- const groupCache = processorsCache.current[group];
64
+ const groupCache = cache.current[group];
64
65
  const oldProcessor = groupCache.processors.get(id);
65
66
  if (oldProcessor !== processor) {
66
67
  groupCache.processors.set(id, processor);
68
+ groupCache.processorsAsArray = Array.from(cache.current[group].processors.values());
67
69
  runAppliers(groupCache);
68
70
  }
69
71
  return () => {
70
- processorsCache.current[group].processors.set(id, null);
72
+ cache.current[group].processors.delete(id);
73
+ cache.current[group].processorsAsArray = Array.from(cache.current[group].processors.values());
71
74
  };
72
75
  }, [runAppliers]);
73
76
  const registerPipeApplier = React.useCallback((group, id, applier) => {
74
- if (!processorsCache.current[group]) {
75
- processorsCache.current[group] = {
77
+ if (!cache.current[group]) {
78
+ cache.current[group] = {
76
79
  processors: new Map(),
80
+ processorsAsArray: [],
77
81
  appliers: {}
78
82
  };
79
83
  }
80
- processorsCache.current[group].appliers[id] = applier;
84
+ cache.current[group].appliers[id] = applier;
81
85
  return () => {
82
- const _appliers = processorsCache.current[group].appliers,
86
+ const _appliers = cache.current[group].appliers,
83
87
  otherAppliers = (0, _objectWithoutPropertiesLoose2.default)(_appliers, [id].map(_toPropertyKey2.default));
84
- processorsCache.current[group].appliers = otherAppliers;
88
+ cache.current[group].appliers = otherAppliers;
85
89
  };
86
90
  }, []);
87
91
  const requestPipeProcessorsApplication = React.useCallback(group => {
88
- const groupCache = processorsCache.current[group];
89
- runAppliers(groupCache);
92
+ runAppliers(cache.current[group]);
90
93
  }, [runAppliers]);
91
94
  const applyPipeProcessors = React.useCallback((...args) => {
92
95
  const [group, value, context] = args;
93
- if (!processorsCache.current[group]) {
96
+ if (!cache.current[group]) {
94
97
  return value;
95
98
  }
96
- const preProcessors = Array.from(processorsCache.current[group].processors.values());
97
- return preProcessors.reduce((acc, preProcessor) => {
98
- if (!preProcessor) {
99
- return acc;
100
- }
101
- return preProcessor(acc, context);
102
- }, value);
99
+ const processors = cache.current[group].processorsAsArray;
100
+ let result = value;
101
+ for (let i = 0; i < processors.length; i += 1) {
102
+ result = processors[i](result, context);
103
+ }
104
+ return result;
103
105
  }, []);
104
106
  const preProcessingPrivateApi = {
105
107
  registerPipeProcessor,
@@ -238,6 +238,7 @@ function useGridDimensions(apiRef, props) {
238
238
  set('--DataGrid-headersTotalHeight', `${dimensions.headersTotalHeight}px`);
239
239
  set('--DataGrid-topContainerHeight', `${dimensions.topContainerHeight}px`);
240
240
  set('--DataGrid-bottomContainerHeight', `${dimensions.bottomContainerHeight}px`);
241
+ set('--height', `${dimensions.rowHeight}px`);
241
242
  }, [root, dimensions]);
242
243
  const isFirstSizing = React.useRef(true);
243
244
  const handleResize = React.useCallback(size => {
@@ -41,12 +41,13 @@ function useGridParamsApi(apiRef) {
41
41
  }, [apiRef]);
42
42
  const getCellParams = React.useCallback((id, field) => {
43
43
  const colDef = apiRef.current.getColumn(field);
44
- const value = apiRef.current.getCellValue(id, field);
45
44
  const row = apiRef.current.getRow(id);
46
45
  const rowNode = apiRef.current.getRowNode(id);
47
46
  if (!row || !rowNode) {
48
47
  throw new MissingRowIdError(`No row with id #${id} found`);
49
48
  }
49
+ const rawValue = row[field];
50
+ const value = colDef?.valueGetter ? colDef.valueGetter(rawValue, row, colDef, apiRef) : rawValue;
50
51
  const cellFocus = (0, _gridFocusStateSelector.gridFocusCellSelector)(apiRef);
51
52
  const cellTabIndex = (0, _gridFocusStateSelector.gridTabIndexCellSelector)(apiRef);
52
53
  const params = {
@@ -70,19 +71,14 @@ function useGridParamsApi(apiRef) {
70
71
  }, [apiRef]);
71
72
  const getCellValue = React.useCallback((id, field) => {
72
73
  const colDef = apiRef.current.getColumn(field);
73
- if (!colDef || !colDef.valueGetter) {
74
- const rowModel = apiRef.current.getRow(id);
75
- if (!rowModel) {
76
- throw new MissingRowIdError(`No row with id #${id} found`);
77
- }
78
- return rowModel[field];
79
- }
80
74
  const row = apiRef.current.getRow(id);
81
75
  if (!row) {
82
76
  throw new MissingRowIdError(`No row with id #${id} found`);
83
77
  }
84
- const value = row[colDef.field];
85
- return colDef.valueGetter(value, row, colDef, apiRef);
78
+ if (!colDef || !colDef.valueGetter) {
79
+ return row[field];
80
+ }
81
+ return colDef.valueGetter(row[colDef.field], row, colDef, apiRef);
86
82
  }, [apiRef]);
87
83
  const getRowValue = React.useCallback((row, colDef) => {
88
84
  const field = colDef.field;
@@ -50,7 +50,7 @@ const useGridSorting = (apiRef, props) => {
50
50
  const existingIdx = sortModel.findIndex(c => c.field === field);
51
51
  let newSortModel = [...sortModel];
52
52
  if (existingIdx > -1) {
53
- if (!sortItem) {
53
+ if (sortItem?.sort == null) {
54
54
  newSortModel.splice(existingIdx, 1);
55
55
  } else {
56
56
  newSortModel.splice(existingIdx, 1, sortItem);
@@ -126,7 +126,7 @@ const useGridSorting = (apiRef, props) => {
126
126
  const sortItem = createSortItem(column, direction);
127
127
  let sortModel;
128
128
  if (!allowMultipleSorting || props.disableMultipleColumnsSorting) {
129
- sortModel = !sortItem ? [] : [sortItem];
129
+ sortModel = sortItem?.sort == null ? [] : [sortItem];
130
130
  } else {
131
131
  sortModel = upsertSortModel(column.field, sortItem);
132
132
  }
@@ -284,6 +284,11 @@ const useGridVirtualScroller = () => {
284
284
  if (panel) {
285
285
  rows.push(panel);
286
286
  }
287
+ if (isLastVisible) {
288
+ rows.push(apiRef.current.getInfiniteLoadingTriggerElement?.({
289
+ lastRowId: id
290
+ }));
291
+ }
287
292
  });
288
293
  return rows;
289
294
  };
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.0.0-beta.5
2
+ * @mui/x-data-grid v7.0.0-beta.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -80,7 +80,6 @@ var _exportNames = {
80
80
  defaultGetRowsToExport: true,
81
81
  createSelector: true,
82
82
  createSelectorMemoized: true,
83
- unstable_resetCreateSelectorCache: true,
84
83
  findParentElementFromClassName: true,
85
84
  getActiveElement: true,
86
85
  isEventTargetInPortal: true,
@@ -391,12 +390,6 @@ Object.defineProperty(exports, "sortingStateInitializer", {
391
390
  return _useGridSorting.sortingStateInitializer;
392
391
  }
393
392
  });
394
- Object.defineProperty(exports, "unstable_resetCreateSelectorCache", {
395
- enumerable: true,
396
- get: function () {
397
- return _createSelector.unstable_resetCreateSelectorCache;
398
- }
399
- });
400
393
  Object.defineProperty(exports, "unwrapPrivateAPI", {
401
394
  enumerable: true,
402
395
  get: function () {
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -3,12 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.unstable_resetCreateSelectorCache = exports.createSelectorMemoized = exports.createSelector = void 0;
6
+ exports.createSelectorMemoized = exports.createSelector = void 0;
7
7
  var _reselect = require("reselect");
8
8
  var _warning = require("./warning");
9
- const cacheContainer = {
10
- cache: new WeakMap()
11
- };
9
+ const cache = new WeakMap();
12
10
  const missingInstanceIdWarning = (0, _warning.buildWarning)(['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`, e.g. `mySelector(apiRef)`, or pass the instance ID explicitly, e.g. `mySelector(state, apiRef.current.instanceId)`.']);
13
11
  function checkIsAPIRef(value) {
14
12
  return 'current' in value && 'instanceId' in value.current;
@@ -82,8 +80,7 @@ const createSelector = (a, b, c, d, e, f, ...rest) => {
82
80
  };
83
81
  exports.createSelector = createSelector;
84
82
  const createSelectorMemoized = (...args) => {
85
- const selector = (...selectorArgs) => {
86
- const [stateOrApiRef, instanceId] = selectorArgs;
83
+ const selector = (stateOrApiRef, instanceId) => {
87
84
  const isAPIRef = checkIsAPIRef(stateOrApiRef);
88
85
  const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
89
86
  const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
@@ -92,20 +89,20 @@ const createSelectorMemoized = (...args) => {
92
89
  missingInstanceIdWarning();
93
90
  }
94
91
  }
95
- const {
96
- cache
97
- } = cacheContainer;
98
- if (cache.get(cacheKey) && cache.get(cacheKey)?.get(args)) {
92
+ const cacheArgsInit = cache.get(cacheKey);
93
+ const cacheArgs = cacheArgsInit ?? new Map();
94
+ const cacheFn = cacheArgs?.get(args);
95
+ if (cacheArgs && cacheFn) {
99
96
  // We pass the cache key because the called selector might have as
100
97
  // dependency another selector created with this `createSelector`.
101
- return cache.get(cacheKey)?.get(args)(state, cacheKey);
98
+ return cacheFn(state, cacheKey);
102
99
  }
103
- const newSelector = (0, _reselect.createSelector)(...args);
104
- if (!cache.get(cacheKey)) {
105
- cache.set(cacheKey, new Map());
100
+ const fn = (0, _reselect.createSelector)(...args);
101
+ if (!cacheArgsInit) {
102
+ cache.set(cacheKey, cacheArgs);
106
103
  }
107
- cache.get(cacheKey)?.set(args, newSelector);
108
- return newSelector(state, cacheKey);
104
+ cacheArgs.set(args, fn);
105
+ return fn(state, cacheKey);
109
106
  };
110
107
 
111
108
  // We use this property to detect if the selector was created with createSelector
@@ -113,10 +110,4 @@ const createSelectorMemoized = (...args) => {
113
110
  selector.acceptsApiRef = true;
114
111
  return selector;
115
112
  };
116
-
117
- // eslint-disable-next-line @typescript-eslint/naming-convention
118
- exports.createSelectorMemoized = createSelectorMemoized;
119
- const unstable_resetCreateSelectorCache = () => {
120
- cacheContainer.cache = new WeakMap();
121
- };
122
- exports.unstable_resetCreateSelectorCache = unstable_resetCreateSelectorCache;
113
+ exports.createSelectorMemoized = createSelectorMemoized;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "7.0.0-beta.5",
3
+ "version": "7.0.0-beta.6",
4
4
  "description": "The community edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -36,7 +36,7 @@
36
36
  "directory": "packages/x-data-grid"
37
37
  },
38
38
  "dependencies": {
39
- "@babel/runtime": "^7.23.9",
39
+ "@babel/runtime": "^7.24.0",
40
40
  "@mui/system": "^5.15.9",
41
41
  "@mui/utils": "^5.15.9",
42
42
  "clsx": "^2.1.0",
@@ -20,5 +20,4 @@ type SelectorArgs<Selectors extends ReadonlyArray<Selector<any>>, Result> = [sel
20
20
  type CreateSelectorFunction = <Selectors extends ReadonlyArray<Selector<any>>, Result>(...items: SelectorArgs<Selectors, Result>) => OutputSelector<StateFromSelectorList<Selectors>, Result>;
21
21
  export declare const createSelector: CreateSelectorFunction;
22
22
  export declare const createSelectorMemoized: CreateSelectorFunction;
23
- export declare const unstable_resetCreateSelectorCache: () => void;
24
23
  export {};
@@ -1,8 +1,6 @@
1
1
  import { createSelector as reselectCreateSelector } from 'reselect';
2
2
  import { buildWarning } from './warning';
3
- const cacheContainer = {
4
- cache: new WeakMap()
5
- };
3
+ const cache = new WeakMap();
6
4
  const missingInstanceIdWarning = buildWarning(['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`, e.g. `mySelector(apiRef)`, or pass the instance ID explicitly, e.g. `mySelector(state, apiRef.current.instanceId)`.']);
7
5
  function checkIsAPIRef(value) {
8
6
  return 'current' in value && 'instanceId' in value.current;
@@ -75,9 +73,7 @@ export const createSelector = (a, b, c, d, e, f, ...rest) => {
75
73
  return selector;
76
74
  };
77
75
  export const createSelectorMemoized = (...args) => {
78
- const selector = (...selectorArgs) => {
79
- var _cache$get, _cache$get3;
80
- const [stateOrApiRef, instanceId] = selectorArgs;
76
+ const selector = (stateOrApiRef, instanceId) => {
81
77
  const isAPIRef = checkIsAPIRef(stateOrApiRef);
82
78
  const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId != null ? instanceId : DEFAULT_INSTANCE_ID;
83
79
  const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
@@ -86,30 +82,24 @@ export const createSelectorMemoized = (...args) => {
86
82
  missingInstanceIdWarning();
87
83
  }
88
84
  }
89
- const {
90
- cache
91
- } = cacheContainer;
92
- if (cache.get(cacheKey) && (_cache$get = cache.get(cacheKey)) != null && _cache$get.get(args)) {
93
- var _cache$get2;
85
+ const cacheArgsInit = cache.get(cacheKey);
86
+ const cacheArgs = cacheArgsInit != null ? cacheArgsInit : new Map();
87
+ const cacheFn = cacheArgs == null ? void 0 : cacheArgs.get(args);
88
+ if (cacheArgs && cacheFn) {
94
89
  // We pass the cache key because the called selector might have as
95
90
  // dependency another selector created with this `createSelector`.
96
- return (_cache$get2 = cache.get(cacheKey)) == null ? void 0 : _cache$get2.get(args)(state, cacheKey);
91
+ return cacheFn(state, cacheKey);
97
92
  }
98
- const newSelector = reselectCreateSelector(...args);
99
- if (!cache.get(cacheKey)) {
100
- cache.set(cacheKey, new Map());
93
+ const fn = reselectCreateSelector(...args);
94
+ if (!cacheArgsInit) {
95
+ cache.set(cacheKey, cacheArgs);
101
96
  }
102
- (_cache$get3 = cache.get(cacheKey)) == null || _cache$get3.set(args, newSelector);
103
- return newSelector(state, cacheKey);
97
+ cacheArgs.set(args, fn);
98
+ return fn(state, cacheKey);
104
99
  };
105
100
 
106
101
  // We use this property to detect if the selector was created with createSelector
107
102
  // or it's only a simple function the receives the state and returns part of it.
108
103
  selector.acceptsApiRef = true;
109
104
  return selector;
110
- };
111
-
112
- // eslint-disable-next-line @typescript-eslint/naming-convention
113
- export const unstable_resetCreateSelectorCache = () => {
114
- cacheContainer.cache = new WeakMap();
115
105
  };