@mui/x-data-grid 6.0.4 → 6.2.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 (131) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/components/GridAutoSizer.js +3 -0
  3. package/components/GridPagination.d.ts +6 -6
  4. package/components/GridRow.js +3 -1
  5. package/components/cell/GridActionsCellItem.d.ts +2 -2
  6. package/components/cell/GridEditDateCell.js +37 -16
  7. package/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
  8. package/components/panel/GridColumnsPanel.d.ts +8 -0
  9. package/components/panel/GridColumnsPanel.js +18 -6
  10. package/components/panel/GridPanel.d.ts +1 -1
  11. package/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
  12. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
  13. package/components/toolbar/GridToolbarColumnsButton.d.ts +1 -1
  14. package/components/toolbar/GridToolbarDensitySelector.d.ts +1 -1
  15. package/components/toolbar/GridToolbarExportContainer.d.ts +1 -1
  16. package/hooks/core/useGridApiInitialization.js +3 -3
  17. package/hooks/features/columns/gridColumnsSelector.d.ts +3 -3
  18. package/hooks/features/editing/useGridCellEditing.js +5 -1
  19. package/hooks/features/editing/useGridEditing.js +1 -3
  20. package/hooks/features/editing/useGridRowEditing.js +5 -1
  21. package/hooks/features/filter/gridFilterState.js +6 -1
  22. package/hooks/features/filter/useGridFilter.js +5 -0
  23. package/hooks/features/rowSelection/useGridRowSelection.js +5 -26
  24. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +36 -16
  25. package/index.js +9 -1
  26. package/legacy/components/GridAutoSizer.js +3 -0
  27. package/legacy/components/GridRow.js +4 -1
  28. package/legacy/components/cell/GridEditBooleanCell.js +19 -21
  29. package/legacy/components/cell/GridEditDateCell.js +69 -39
  30. package/legacy/components/cell/GridEditInputCell.js +25 -27
  31. package/legacy/components/cell/GridEditSingleSelectCell.js +26 -28
  32. package/legacy/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
  33. package/legacy/components/panel/GridColumnsPanel.js +19 -6
  34. package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
  35. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
  36. package/legacy/hooks/core/useGridApiInitialization.js +3 -3
  37. package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
  38. package/legacy/hooks/features/editing/useGridCellEditing.js +120 -120
  39. package/legacy/hooks/features/editing/useGridEditing.js +17 -21
  40. package/legacy/hooks/features/editing/useGridRowEditing.js +5 -1
  41. package/legacy/hooks/features/export/useGridPrintExport.js +45 -47
  42. package/legacy/hooks/features/filter/gridFilterState.js +6 -1
  43. package/legacy/hooks/features/filter/useGridFilter.js +5 -0
  44. package/legacy/hooks/features/rowSelection/useGridRowSelection.js +5 -24
  45. package/legacy/hooks/features/rows/gridRowsUtils.js +2 -2
  46. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +6 -6
  47. package/legacy/index.js +9 -1
  48. package/legacy/locales/coreLocales.js +0 -1
  49. package/legacy/locales/frFR.js +7 -9
  50. package/legacy/locales/huHU.js +15 -20
  51. package/legacy/locales/jaJP.js +1 -1
  52. package/legacy/locales/nlNL.js +3 -3
  53. package/legacy/locales/ptBR.js +7 -9
  54. package/legacy/locales/ruRU.js +1 -1
  55. package/legacy/locales/urPK.js +6 -6
  56. package/legacy/models/gridColumnGrouping.js +4 -0
  57. package/legacy/models/params/gridRowParams.js +8 -0
  58. package/legacy/utils/createSelector.js +14 -22
  59. package/legacy/utils/utils.js +1 -1
  60. package/locales/coreLocales.js +0 -1
  61. package/locales/frFR.js +7 -9
  62. package/locales/huHU.js +15 -20
  63. package/locales/jaJP.js +1 -1
  64. package/locales/nlNL.js +3 -3
  65. package/locales/ptBR.js +7 -9
  66. package/locales/ruRU.js +1 -1
  67. package/locales/urPK.js +6 -6
  68. package/models/api/gridCoreApi.d.ts +3 -1
  69. package/models/api/gridEditingApi.d.ts +4 -0
  70. package/models/gridColumnGrouping.js +4 -0
  71. package/models/params/gridRowParams.js +8 -0
  72. package/modern/components/GridAutoSizer.js +3 -0
  73. package/modern/components/GridRow.js +3 -1
  74. package/modern/components/cell/GridEditDateCell.js +37 -16
  75. package/modern/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
  76. package/modern/components/panel/GridColumnsPanel.js +18 -6
  77. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
  78. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +33 -29
  79. package/modern/hooks/core/useGridApiInitialization.js +3 -3
  80. package/modern/hooks/features/editing/useGridCellEditing.js +5 -1
  81. package/modern/hooks/features/editing/useGridEditing.js +1 -3
  82. package/modern/hooks/features/editing/useGridRowEditing.js +5 -1
  83. package/modern/hooks/features/filter/gridFilterState.js +6 -1
  84. package/modern/hooks/features/filter/useGridFilter.js +5 -0
  85. package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -26
  86. package/modern/index.js +9 -1
  87. package/modern/locales/coreLocales.js +0 -1
  88. package/modern/locales/frFR.js +7 -9
  89. package/modern/locales/huHU.js +15 -20
  90. package/modern/locales/jaJP.js +1 -1
  91. package/modern/locales/nlNL.js +3 -3
  92. package/modern/locales/ptBR.js +7 -9
  93. package/modern/locales/ruRU.js +1 -1
  94. package/modern/locales/urPK.js +6 -6
  95. package/modern/models/gridColumnGrouping.js +4 -0
  96. package/modern/models/params/gridRowParams.js +8 -0
  97. package/modern/utils/createSelector.js +12 -22
  98. package/modern/utils/utils.js +1 -1
  99. package/node/components/GridAutoSizer.js +3 -1
  100. package/node/components/GridRow.js +3 -1
  101. package/node/components/cell/GridCell.js +1 -0
  102. package/node/components/cell/GridEditDateCell.js +37 -16
  103. package/node/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
  104. package/node/components/panel/GridColumnsPanel.js +18 -6
  105. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
  106. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +32 -29
  107. package/node/hooks/core/useGridApiInitialization.js +3 -3
  108. package/node/hooks/features/editing/useGridCellEditing.js +5 -1
  109. package/node/hooks/features/editing/useGridEditing.js +1 -3
  110. package/node/hooks/features/editing/useGridRowEditing.js +5 -1
  111. package/node/hooks/features/filter/gridFilterState.js +5 -0
  112. package/node/hooks/features/filter/useGridFilter.js +5 -0
  113. package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -25
  114. package/node/index.js +1 -1
  115. package/node/locales/frFR.js +7 -9
  116. package/node/locales/huHU.js +15 -20
  117. package/node/locales/jaJP.js +1 -1
  118. package/node/locales/nlNL.js +3 -3
  119. package/node/locales/ptBR.js +7 -9
  120. package/node/locales/ruRU.js +1 -1
  121. package/node/locales/urPK.js +6 -6
  122. package/node/models/gridColumnGrouping.js +4 -0
  123. package/node/models/params/gridEditCellParams.js +1 -0
  124. package/node/models/params/gridRowParams.js +9 -0
  125. package/node/utils/createSelector.js +12 -22
  126. package/node/utils/utils.js +1 -1
  127. package/package.json +1 -1
  128. package/utils/createSelector.d.ts +4 -4
  129. package/utils/createSelector.js +14 -22
  130. package/utils/utils.d.ts +1 -1
  131. package/utils/utils.js +1 -1
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.0.4
2
+ * @mui/x-data-grid v6.2.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -117,16 +117,14 @@ const frFRGrid = {
117
117
  expandDetailPanel: 'Afficher',
118
118
  collapseDetailPanel: 'Masquer',
119
119
  // Row reordering text
120
- rowReorderingHeaderName: 'Positionnement des lignes'
121
-
120
+ rowReorderingHeaderName: 'Positionnement des lignes',
122
121
  // Aggregation
123
- // aggregationMenuItemHeader: 'Aggregation',
124
- // aggregationFunctionLabelSum: 'sum',
125
- // aggregationFunctionLabelAvg: 'avg',
126
- // aggregationFunctionLabelMin: 'min',
127
- // aggregationFunctionLabelMax: 'max',
128
- // aggregationFunctionLabelSize: 'size',
122
+ aggregationMenuItemHeader: 'Agrégation',
123
+ aggregationFunctionLabelSum: 'Somme',
124
+ aggregationFunctionLabelAvg: 'Moyenne',
125
+ aggregationFunctionLabelMin: 'Minimum',
126
+ aggregationFunctionLabelMax: 'Maximum',
127
+ aggregationFunctionLabelSize: "Nombre d'éléments"
129
128
  };
130
-
131
129
  const frFR = (0, _getGridLocalization.getGridLocalization)(frFRGrid, _locale.frFR);
132
130
  exports.frFR = frFR;
@@ -26,17 +26,15 @@ const huHUGrid = {
26
26
  toolbarFiltersTooltipShow: 'Szűrők megjelenítése',
27
27
  toolbarFiltersTooltipActive: count => `${count} aktív szűrő`,
28
28
  // Quick filter toolbar field
29
- // toolbarQuickFilterPlaceholder: 'Search…',
30
- // toolbarQuickFilterLabel: 'Search',
31
- // toolbarQuickFilterDeleteIconLabel: 'Clear',
32
-
29
+ toolbarQuickFilterPlaceholder: 'Keresés…',
30
+ toolbarQuickFilterLabel: 'Keresés',
31
+ toolbarQuickFilterDeleteIconLabel: 'Törlés',
33
32
  // Export selector toolbar button text
34
33
  toolbarExport: 'Exportálás',
35
34
  toolbarExportLabel: 'Exportálás',
36
35
  toolbarExportCSV: 'Mentés CSV fájlként',
37
36
  toolbarExportPrint: 'Nyomtatás',
38
- // toolbarExportExcel: 'Download as Excel',
39
-
37
+ toolbarExportExcel: 'Mentés Excel fájlként',
40
38
  // Columns panel text
41
39
  columnsPanelTextFieldLabel: 'Oszlop keresése',
42
40
  columnsPanelTextFieldPlaceholder: 'Oszlop neve',
@@ -45,7 +43,7 @@ const huHUGrid = {
45
43
  columnsPanelHideAllButton: 'Összes elrejtése',
46
44
  // Filter panel text
47
45
  filterPanelAddFilter: 'Szűrő hozzáadása',
48
- // filterPanelRemoveAll: 'Remove all',
46
+ filterPanelRemoveAll: 'Összes törlése',
49
47
  filterPanelDeleteIconLabel: 'Törlés',
50
48
  filterPanelLogicOperator: 'Logikai operátor',
51
49
  filterPanelOperator: 'Operátorok',
@@ -75,7 +73,7 @@ const huHUGrid = {
75
73
  // Column menu text
76
74
  columnMenuLabel: 'Menü',
77
75
  columnMenuShowColumns: 'Oszlopok megjelenítése',
78
- // columnMenuManageColumns: 'Manage columns',
76
+ columnMenuManageColumns: 'Oszlopok kezelése',
79
77
  columnMenuFilter: 'Szűrők',
80
78
  columnMenuHideColumn: 'Elrejtés',
81
79
  columnMenuUnsort: 'Sorrend visszaállítása',
@@ -115,21 +113,18 @@ const huHUGrid = {
115
113
  groupColumn: name => `Csoportosítás ${name} szerint`,
116
114
  unGroupColumn: name => `${name} szerinti csoportosítás törlése`,
117
115
  // Master/detail
118
- // detailPanelToggle: 'Detail panel toggle',
116
+ detailPanelToggle: 'Részletek panel váltása',
119
117
  expandDetailPanel: 'Kibontás',
120
- collapseDetailPanel: 'Összecsukás'
121
-
118
+ collapseDetailPanel: 'Összecsukás',
122
119
  // Row reordering text
123
- // rowReorderingHeaderName: 'Row reordering',
124
-
120
+ rowReorderingHeaderName: 'Sorok újrarendezése',
125
121
  // Aggregation
126
- // aggregationMenuItemHeader: 'Aggregation',
127
- // aggregationFunctionLabelSum: 'sum',
128
- // aggregationFunctionLabelAvg: 'avg',
129
- // aggregationFunctionLabelMin: 'min',
130
- // aggregationFunctionLabelMax: 'max',
131
- // aggregationFunctionLabelSize: 'size',
122
+ aggregationMenuItemHeader: 'Összesítés',
123
+ aggregationFunctionLabelSum: 'Összeg',
124
+ aggregationFunctionLabelAvg: 'Átlag',
125
+ aggregationFunctionLabelMin: 'Minimum',
126
+ aggregationFunctionLabelMax: 'Maximum',
127
+ aggregationFunctionLabelSize: 'Darabszám'
132
128
  };
133
-
134
129
  const huHU = (0, _getGridLocalization.getGridLocalization)(huHUGrid, _locale.huHU);
135
130
  exports.huHU = huHU;
@@ -43,7 +43,7 @@ const jaJPGrid = {
43
43
  columnsPanelHideAllButton: 'すべて非表示',
44
44
  // Filter panel text
45
45
  filterPanelAddFilter: 'フィルター追加',
46
- // filterPanelRemoveAll: 'Remove all',
46
+ filterPanelRemoveAll: 'すべて削除',
47
47
  filterPanelDeleteIconLabel: '削除',
48
48
  filterPanelLogicOperator: '論理演算子',
49
49
  filterPanelOperator: '演算子',
@@ -43,7 +43,7 @@ const nlNLGrid = {
43
43
  columnsPanelHideAllButton: 'Alles verbergen',
44
44
  // Filter panel text
45
45
  filterPanelAddFilter: 'Filter toevoegen',
46
- // filterPanelRemoveAll: 'Remove all',
46
+ filterPanelRemoveAll: 'Alles verwijderen',
47
47
  filterPanelDeleteIconLabel: 'Verwijderen',
48
48
  filterPanelLogicOperator: 'Logische operator',
49
49
  filterPanelOperator: 'Operatoren',
@@ -73,7 +73,7 @@ const nlNLGrid = {
73
73
  // Column menu text
74
74
  columnMenuLabel: 'Menu',
75
75
  columnMenuShowColumns: 'Toon kolommen',
76
- // columnMenuManageColumns: 'Manage columns',
76
+ columnMenuManageColumns: 'Kolommen beheren',
77
77
  columnMenuFilter: 'Filteren',
78
78
  columnMenuHideColumn: 'Verbergen',
79
79
  columnMenuUnsort: 'Annuleer sortering',
@@ -113,7 +113,7 @@ const nlNLGrid = {
113
113
  groupColumn: name => `Groepeer op ${name}`,
114
114
  unGroupColumn: name => `Stop groeperen op ${name}`,
115
115
  // Master/detail
116
- // detailPanelToggle: 'Detail panel toggle',
116
+ detailPanelToggle: 'Detailmenu in- of uitklappen',
117
117
  expandDetailPanel: 'Uitklappen',
118
118
  collapseDetailPanel: 'Inklappen',
119
119
  // Row reordering text
@@ -117,16 +117,14 @@ const ptBRGrid = {
117
117
  expandDetailPanel: 'Expandir',
118
118
  collapseDetailPanel: 'Esconder',
119
119
  // Row reordering text
120
- rowReorderingHeaderName: 'Reorganizar linhas'
121
-
120
+ rowReorderingHeaderName: 'Reorganizar linhas',
122
121
  // Aggregation
123
- // aggregationMenuItemHeader: 'Aggregation',
124
- // aggregationFunctionLabelSum: 'sum',
125
- // aggregationFunctionLabelAvg: 'avg',
126
- // aggregationFunctionLabelMin: 'min',
127
- // aggregationFunctionLabelMax: 'max',
128
- // aggregationFunctionLabelSize: 'size',
122
+ aggregationMenuItemHeader: 'Agrupar',
123
+ aggregationFunctionLabelSum: 'soma',
124
+ aggregationFunctionLabelAvg: 'média',
125
+ aggregationFunctionLabelMin: 'mín',
126
+ aggregationFunctionLabelMax: 'máx',
127
+ aggregationFunctionLabelSize: 'tamanho'
129
128
  };
130
-
131
129
  const ptBR = (0, _getGridLocalization.getGridLocalization)(ptBRGrid, _locale.ptBR);
132
130
  exports.ptBR = ptBR;
@@ -82,7 +82,7 @@ const ruRUGrid = {
82
82
  // Column menu text
83
83
  columnMenuLabel: 'Меню',
84
84
  columnMenuShowColumns: 'Показать столбцы',
85
- // columnMenuManageColumns: 'Manage columns',
85
+ columnMenuManageColumns: 'Управление колонками',
86
86
  columnMenuFilter: 'Фильтр',
87
87
  columnMenuHideColumn: 'Скрыть',
88
88
  columnMenuUnsort: 'Отменить сортировку',
@@ -119,12 +119,12 @@ const urPKGrid = {
119
119
  // Row reordering text
120
120
  rowReorderingHeaderName: 'قطاروں کی ترتیب تبدیل کریں',
121
121
  // Aggregation
122
- aggregationMenuItemHeader: 'Aggregation',
123
- aggregationFunctionLabelSum: 'sum',
124
- aggregationFunctionLabelAvg: 'avg',
125
- aggregationFunctionLabelMin: 'min',
126
- aggregationFunctionLabelMax: 'max',
127
- aggregationFunctionLabelSize: 'size'
122
+ aggregationMenuItemHeader: 'ایگریگیشن',
123
+ aggregationFunctionLabelSum: 'کل',
124
+ aggregationFunctionLabelAvg: 'اوسط',
125
+ aggregationFunctionLabelMin: 'کم از کم',
126
+ aggregationFunctionLabelMax: 'زیادہ سے زیادہ',
127
+ aggregationFunctionLabelSize: 'سائز'
128
128
  };
129
129
  const urPK = (0, _getGridLocalization.getGridLocalization)(urPKGrid, _coreLocales.urPKCore);
130
130
  exports.urPK = urPK;
@@ -10,4 +10,8 @@ function isLeaf(node) {
10
10
 
11
11
  /**
12
12
  * A function used to process headerClassName params.
13
+ */
14
+
15
+ /**
16
+ * The union type representing the [[GridColDef]] column header class type.
13
17
  */
@@ -29,4 +29,5 @@ var GridCellEditStopReasons = /*#__PURE__*/function (GridCellEditStopReasons) {
29
29
  /**
30
30
  * Params passed to the `cellEditStop event.
31
31
  */
32
+ // https://github.com/mui/mui-x/pull/3738#discussion_r798504277
32
33
  exports.GridCellEditStopReasons = GridCellEditStopReasons;
@@ -39,4 +39,13 @@ var GridRowEditStopReasons = /*#__PURE__*/function (GridRowEditStopReasons) {
39
39
  GridRowEditStopReasons["shiftTabKeyDown"] = "shiftTabKeyDown";
40
40
  return GridRowEditStopReasons;
41
41
  }(GridRowEditStopReasons || {});
42
+ /**
43
+ * Object passed as parameter in the row `getRowSpacing` callback prop.
44
+ * @demos
45
+ * - [Row spacing](/x/react-data-grid/row-height/#row-spacing)
46
+ */
47
+ /**
48
+ * The getRowSpacing return value.
49
+ */
50
+ // https://github.com/mui/mui-x/pull/3738#discussion_r798504277
42
51
  exports.GridRowEditStopReasons = GridRowEditStopReasons;
@@ -7,39 +7,35 @@ exports.unstable_resetCreateSelectorCache = exports.createSelector = void 0;
7
7
  var _reselect = require("reselect");
8
8
  var _warning = require("./warning");
9
9
  const cacheContainer = {
10
- cache: null
10
+ cache: new WeakMap()
11
11
  };
12
12
  const missingInstanceIdWarning = (0, _warning.buildWarning)(['MUI: 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
13
  const createSelector = (...args) => {
14
- if (cacheContainer.cache === null) {
15
- cacheContainer.cache = {};
16
- }
17
14
  const selector = (...selectorArgs) => {
18
15
  const [stateOrApiRef, instanceId] = selectorArgs;
19
16
  const isApiRef = !!stateOrApiRef.current;
20
- const cacheKey = isApiRef ? stateOrApiRef.current.instanceId : instanceId ?? 'default';
17
+ const cacheKey = isApiRef ? stateOrApiRef.current.instanceId : instanceId ?? {
18
+ id: 'default'
19
+ };
21
20
  const state = isApiRef ? stateOrApiRef.current.state : stateOrApiRef;
22
21
  if (process.env.NODE_ENV !== 'production') {
23
- if (cacheKey === 'default') {
22
+ if (cacheKey.id === 'default') {
24
23
  missingInstanceIdWarning();
25
24
  }
26
25
  }
27
- if (cacheContainer.cache === null) {
28
- cacheContainer.cache = {};
29
- }
30
26
  const {
31
27
  cache
32
28
  } = cacheContainer;
33
- if (cache[cacheKey] && cache[cacheKey].get(args)) {
29
+ if (cache.get(cacheKey) && cache.get(cacheKey)?.get(args)) {
34
30
  // We pass the cache key because the called selector might have as
35
31
  // dependency another selector created with this `createSelector`.
36
- return cache[cacheKey].get(args)(state, cacheKey);
32
+ return cache.get(cacheKey)?.get(args)(state, cacheKey);
37
33
  }
38
34
  const newSelector = (0, _reselect.createSelector)(...args);
39
- if (!cache[cacheKey]) {
40
- cache[cacheKey] = new Map();
35
+ if (!cache.get(cacheKey)) {
36
+ cache.set(cacheKey, new Map());
41
37
  }
42
- cache[cacheKey].set(args, newSelector);
38
+ cache.get(cacheKey)?.set(args, newSelector);
43
39
  return newSelector(state, cacheKey);
44
40
  };
45
41
 
@@ -51,13 +47,7 @@ const createSelector = (...args) => {
51
47
 
52
48
  // eslint-disable-next-line @typescript-eslint/naming-convention
53
49
  exports.createSelector = createSelector;
54
- const unstable_resetCreateSelectorCache = cacheKey => {
55
- if (typeof cacheKey !== 'undefined') {
56
- if (cacheContainer.cache && cacheContainer.cache[cacheKey]) {
57
- delete cacheContainer.cache[cacheKey];
58
- }
59
- } else {
60
- cacheContainer.cache = null;
61
- }
50
+ const unstable_resetCreateSelectorCache = () => {
51
+ cacheContainer.cache = new WeakMap();
62
52
  };
63
53
  exports.unstable_resetCreateSelectorCache = unstable_resetCreateSelectorCache;
@@ -47,7 +47,7 @@ const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
47
47
  /**
48
48
  * Based on `fast-deep-equal`
49
49
  *
50
- * MIT License
50
+ * MIT License
51
51
  *
52
52
  * Copyright (c) 2017 Evgeny Poberezkin
53
53
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "6.0.4",
3
+ "version": "6.2.0",
4
4
  "description": "The community edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { Selector, SelectorResultArray } from 'reselect';
3
- type CacheKey = number | string;
3
+ import type { GridCoreApi } from '../models/api/gridCoreApi';
4
4
  export interface OutputSelector<State, Result> {
5
5
  (apiRef: React.MutableRefObject<{
6
6
  state: State;
7
- instanceId: number;
7
+ instanceId: GridCoreApi['instanceId'];
8
8
  }>): Result;
9
- (state: State, instanceId?: number): Result;
9
+ (state: State, instanceId?: GridCoreApi['instanceId']): Result;
10
10
  acceptsApiRef: boolean;
11
11
  }
12
12
  type StateFromSelector<T> = T extends (first: infer F, ...args: any[]) => any ? F extends {
@@ -19,5 +19,5 @@ type StateFromSelectorList<Selectors extends readonly any[]> = Selectors extends
19
19
  type SelectorArgs<Selectors extends ReadonlyArray<Selector<any>>, Result> = [selectors: [...Selectors], combiner: (...args: SelectorResultArray<Selectors>) => Result] | [...Selectors, (...args: SelectorResultArray<Selectors>) => Result];
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
- export declare const unstable_resetCreateSelectorCache: (cacheKey?: CacheKey) => void;
22
+ export declare const unstable_resetCreateSelectorCache: () => void;
23
23
  export {};
@@ -1,39 +1,37 @@
1
1
  import { createSelector as reselectCreateSelector } from 'reselect';
2
2
  import { buildWarning } from './warning';
3
3
  const cacheContainer = {
4
- cache: null
4
+ cache: new WeakMap()
5
5
  };
6
6
  const missingInstanceIdWarning = buildWarning(['MUI: 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
7
  export const createSelector = (...args) => {
8
- if (cacheContainer.cache === null) {
9
- cacheContainer.cache = {};
10
- }
11
8
  const selector = (...selectorArgs) => {
9
+ var _cache$get, _cache$get3;
12
10
  const [stateOrApiRef, instanceId] = selectorArgs;
13
11
  const isApiRef = !!stateOrApiRef.current;
14
- const cacheKey = isApiRef ? stateOrApiRef.current.instanceId : instanceId != null ? instanceId : 'default';
12
+ const cacheKey = isApiRef ? stateOrApiRef.current.instanceId : instanceId != null ? instanceId : {
13
+ id: 'default'
14
+ };
15
15
  const state = isApiRef ? stateOrApiRef.current.state : stateOrApiRef;
16
16
  if (process.env.NODE_ENV !== 'production') {
17
- if (cacheKey === 'default') {
17
+ if (cacheKey.id === 'default') {
18
18
  missingInstanceIdWarning();
19
19
  }
20
20
  }
21
- if (cacheContainer.cache === null) {
22
- cacheContainer.cache = {};
23
- }
24
21
  const {
25
22
  cache
26
23
  } = cacheContainer;
27
- if (cache[cacheKey] && cache[cacheKey].get(args)) {
24
+ if (cache.get(cacheKey) && (_cache$get = cache.get(cacheKey)) != null && _cache$get.get(args)) {
25
+ var _cache$get2;
28
26
  // We pass the cache key because the called selector might have as
29
27
  // dependency another selector created with this `createSelector`.
30
- return cache[cacheKey].get(args)(state, cacheKey);
28
+ return (_cache$get2 = cache.get(cacheKey)) == null ? void 0 : _cache$get2.get(args)(state, cacheKey);
31
29
  }
32
30
  const newSelector = reselectCreateSelector(...args);
33
- if (!cache[cacheKey]) {
34
- cache[cacheKey] = new Map();
31
+ if (!cache.get(cacheKey)) {
32
+ cache.set(cacheKey, new Map());
35
33
  }
36
- cache[cacheKey].set(args, newSelector);
34
+ (_cache$get3 = cache.get(cacheKey)) == null ? void 0 : _cache$get3.set(args, newSelector);
37
35
  return newSelector(state, cacheKey);
38
36
  };
39
37
 
@@ -44,12 +42,6 @@ export const createSelector = (...args) => {
44
42
  };
45
43
 
46
44
  // eslint-disable-next-line @typescript-eslint/naming-convention
47
- export const unstable_resetCreateSelectorCache = cacheKey => {
48
- if (typeof cacheKey !== 'undefined') {
49
- if (cacheContainer.cache && cacheContainer.cache[cacheKey]) {
50
- delete cacheContainer.cache[cacheKey];
51
- }
52
- } else {
53
- cacheContainer.cache = null;
54
- }
45
+ export const unstable_resetCreateSelectorCache = () => {
46
+ cacheContainer.cache = new WeakMap();
55
47
  };
package/utils/utils.d.ts CHANGED
@@ -11,7 +11,7 @@ export declare const clamp: (value: number, min: number, max: number) => number;
11
11
  /**
12
12
  * Based on `fast-deep-equal`
13
13
  *
14
- * MIT License
14
+ * MIT License
15
15
  *
16
16
  * Copyright (c) 2017 Evgeny Poberezkin
17
17
  *
package/utils/utils.js CHANGED
@@ -33,7 +33,7 @@ export const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
33
33
  /**
34
34
  * Based on `fast-deep-equal`
35
35
  *
36
- * MIT License
36
+ * MIT License
37
37
  *
38
38
  * Copyright (c) 2017 Evgeny Poberezkin
39
39
  *