@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.
- package/CHANGELOG.md +110 -0
- package/components/GridAutoSizer.js +3 -0
- package/components/GridPagination.d.ts +6 -6
- package/components/GridRow.js +3 -1
- package/components/cell/GridActionsCellItem.d.ts +2 -2
- package/components/cell/GridEditDateCell.js +37 -16
- package/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
- package/components/panel/GridColumnsPanel.d.ts +8 -0
- package/components/panel/GridColumnsPanel.js +18 -6
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
- package/components/toolbar/GridToolbarColumnsButton.d.ts +1 -1
- package/components/toolbar/GridToolbarDensitySelector.d.ts +1 -1
- package/components/toolbar/GridToolbarExportContainer.d.ts +1 -1
- package/hooks/core/useGridApiInitialization.js +3 -3
- package/hooks/features/columns/gridColumnsSelector.d.ts +3 -3
- package/hooks/features/editing/useGridCellEditing.js +5 -1
- package/hooks/features/editing/useGridEditing.js +1 -3
- package/hooks/features/editing/useGridRowEditing.js +5 -1
- package/hooks/features/filter/gridFilterState.js +6 -1
- package/hooks/features/filter/useGridFilter.js +5 -0
- package/hooks/features/rowSelection/useGridRowSelection.js +5 -26
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +36 -16
- package/index.js +9 -1
- package/legacy/components/GridAutoSizer.js +3 -0
- package/legacy/components/GridRow.js +4 -1
- package/legacy/components/cell/GridEditBooleanCell.js +19 -21
- package/legacy/components/cell/GridEditDateCell.js +69 -39
- package/legacy/components/cell/GridEditInputCell.js +25 -27
- package/legacy/components/cell/GridEditSingleSelectCell.js +26 -28
- package/legacy/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
- package/legacy/components/panel/GridColumnsPanel.js +19 -6
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
- package/legacy/hooks/core/useGridApiInitialization.js +3 -3
- package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
- package/legacy/hooks/features/editing/useGridCellEditing.js +120 -120
- package/legacy/hooks/features/editing/useGridEditing.js +17 -21
- package/legacy/hooks/features/editing/useGridRowEditing.js +5 -1
- package/legacy/hooks/features/export/useGridPrintExport.js +45 -47
- package/legacy/hooks/features/filter/gridFilterState.js +6 -1
- package/legacy/hooks/features/filter/useGridFilter.js +5 -0
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +5 -24
- package/legacy/hooks/features/rows/gridRowsUtils.js +2 -2
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +6 -6
- package/legacy/index.js +9 -1
- package/legacy/locales/coreLocales.js +0 -1
- package/legacy/locales/frFR.js +7 -9
- package/legacy/locales/huHU.js +15 -20
- package/legacy/locales/jaJP.js +1 -1
- package/legacy/locales/nlNL.js +3 -3
- package/legacy/locales/ptBR.js +7 -9
- package/legacy/locales/ruRU.js +1 -1
- package/legacy/locales/urPK.js +6 -6
- package/legacy/models/gridColumnGrouping.js +4 -0
- package/legacy/models/params/gridRowParams.js +8 -0
- package/legacy/utils/createSelector.js +14 -22
- package/legacy/utils/utils.js +1 -1
- package/locales/coreLocales.js +0 -1
- package/locales/frFR.js +7 -9
- package/locales/huHU.js +15 -20
- package/locales/jaJP.js +1 -1
- package/locales/nlNL.js +3 -3
- package/locales/ptBR.js +7 -9
- package/locales/ruRU.js +1 -1
- package/locales/urPK.js +6 -6
- package/models/api/gridCoreApi.d.ts +3 -1
- package/models/api/gridEditingApi.d.ts +4 -0
- package/models/gridColumnGrouping.js +4 -0
- package/models/params/gridRowParams.js +8 -0
- package/modern/components/GridAutoSizer.js +3 -0
- package/modern/components/GridRow.js +3 -1
- package/modern/components/cell/GridEditDateCell.js +37 -16
- package/modern/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
- package/modern/components/panel/GridColumnsPanel.js +18 -6
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +33 -29
- package/modern/hooks/core/useGridApiInitialization.js +3 -3
- package/modern/hooks/features/editing/useGridCellEditing.js +5 -1
- package/modern/hooks/features/editing/useGridEditing.js +1 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +5 -1
- package/modern/hooks/features/filter/gridFilterState.js +6 -1
- package/modern/hooks/features/filter/useGridFilter.js +5 -0
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -26
- package/modern/index.js +9 -1
- package/modern/locales/coreLocales.js +0 -1
- package/modern/locales/frFR.js +7 -9
- package/modern/locales/huHU.js +15 -20
- package/modern/locales/jaJP.js +1 -1
- package/modern/locales/nlNL.js +3 -3
- package/modern/locales/ptBR.js +7 -9
- package/modern/locales/ruRU.js +1 -1
- package/modern/locales/urPK.js +6 -6
- package/modern/models/gridColumnGrouping.js +4 -0
- package/modern/models/params/gridRowParams.js +8 -0
- package/modern/utils/createSelector.js +12 -22
- package/modern/utils/utils.js +1 -1
- package/node/components/GridAutoSizer.js +3 -1
- package/node/components/GridRow.js +3 -1
- package/node/components/cell/GridCell.js +1 -0
- package/node/components/cell/GridEditDateCell.js +37 -16
- package/node/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
- package/node/components/panel/GridColumnsPanel.js +18 -6
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +32 -29
- package/node/hooks/core/useGridApiInitialization.js +3 -3
- package/node/hooks/features/editing/useGridCellEditing.js +5 -1
- package/node/hooks/features/editing/useGridEditing.js +1 -3
- package/node/hooks/features/editing/useGridRowEditing.js +5 -1
- package/node/hooks/features/filter/gridFilterState.js +5 -0
- package/node/hooks/features/filter/useGridFilter.js +5 -0
- package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -25
- package/node/index.js +1 -1
- package/node/locales/frFR.js +7 -9
- package/node/locales/huHU.js +15 -20
- package/node/locales/jaJP.js +1 -1
- package/node/locales/nlNL.js +3 -3
- package/node/locales/ptBR.js +7 -9
- package/node/locales/ruRU.js +1 -1
- package/node/locales/urPK.js +6 -6
- package/node/models/gridColumnGrouping.js +4 -0
- package/node/models/params/gridEditCellParams.js +1 -0
- package/node/models/params/gridRowParams.js +9 -0
- package/node/utils/createSelector.js +12 -22
- package/node/utils/utils.js +1 -1
- package/package.json +1 -1
- package/utils/createSelector.d.ts +4 -4
- package/utils/createSelector.js +14 -22
- package/utils/utils.d.ts +1 -1
- package/utils/utils.js +1 -1
package/node/index.js
CHANGED
package/node/locales/frFR.js
CHANGED
|
@@ -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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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;
|
package/node/locales/huHU.js
CHANGED
|
@@ -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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
124
|
-
|
|
120
|
+
rowReorderingHeaderName: 'Sorok újrarendezése',
|
|
125
121
|
// Aggregation
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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;
|
package/node/locales/jaJP.js
CHANGED
|
@@ -43,7 +43,7 @@ const jaJPGrid = {
|
|
|
43
43
|
columnsPanelHideAllButton: 'すべて非表示',
|
|
44
44
|
// Filter panel text
|
|
45
45
|
filterPanelAddFilter: 'フィルター追加',
|
|
46
|
-
|
|
46
|
+
filterPanelRemoveAll: 'すべて削除',
|
|
47
47
|
filterPanelDeleteIconLabel: '削除',
|
|
48
48
|
filterPanelLogicOperator: '論理演算子',
|
|
49
49
|
filterPanelOperator: '演算子',
|
package/node/locales/nlNL.js
CHANGED
|
@@ -43,7 +43,7 @@ const nlNLGrid = {
|
|
|
43
43
|
columnsPanelHideAllButton: 'Alles verbergen',
|
|
44
44
|
// Filter panel text
|
|
45
45
|
filterPanelAddFilter: 'Filter toevoegen',
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
116
|
+
detailPanelToggle: 'Detailmenu in- of uitklappen',
|
|
117
117
|
expandDetailPanel: 'Uitklappen',
|
|
118
118
|
collapseDetailPanel: 'Inklappen',
|
|
119
119
|
// Row reordering text
|
package/node/locales/ptBR.js
CHANGED
|
@@ -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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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;
|
package/node/locales/ruRU.js
CHANGED
|
@@ -82,7 +82,7 @@ const ruRUGrid = {
|
|
|
82
82
|
// Column menu text
|
|
83
83
|
columnMenuLabel: 'Меню',
|
|
84
84
|
columnMenuShowColumns: 'Показать столбцы',
|
|
85
|
-
|
|
85
|
+
columnMenuManageColumns: 'Управление колонками',
|
|
86
86
|
columnMenuFilter: 'Фильтр',
|
|
87
87
|
columnMenuHideColumn: 'Скрыть',
|
|
88
88
|
columnMenuUnsort: 'Отменить сортировку',
|
package/node/locales/urPK.js
CHANGED
|
@@ -119,12 +119,12 @@ const urPKGrid = {
|
|
|
119
119
|
// Row reordering text
|
|
120
120
|
rowReorderingHeaderName: 'قطاروں کی ترتیب تبدیل کریں',
|
|
121
121
|
// Aggregation
|
|
122
|
-
aggregationMenuItemHeader: '
|
|
123
|
-
aggregationFunctionLabelSum: '
|
|
124
|
-
aggregationFunctionLabelAvg: '
|
|
125
|
-
aggregationFunctionLabelMin: '
|
|
126
|
-
aggregationFunctionLabelMax: '
|
|
127
|
-
aggregationFunctionLabelSize: '
|
|
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;
|
|
@@ -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:
|
|
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 ??
|
|
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
|
|
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
|
|
32
|
+
return cache.get(cacheKey)?.get(args)(state, cacheKey);
|
|
37
33
|
}
|
|
38
34
|
const newSelector = (0, _reselect.createSelector)(...args);
|
|
39
|
-
if (!cache
|
|
40
|
-
cache
|
|
35
|
+
if (!cache.get(cacheKey)) {
|
|
36
|
+
cache.set(cacheKey, new Map());
|
|
41
37
|
}
|
|
42
|
-
cache
|
|
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 =
|
|
55
|
-
|
|
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;
|
package/node/utils/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Selector, SelectorResultArray } from 'reselect';
|
|
3
|
-
type
|
|
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:
|
|
7
|
+
instanceId: GridCoreApi['instanceId'];
|
|
8
8
|
}>): Result;
|
|
9
|
-
(state: State, instanceId?:
|
|
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: (
|
|
22
|
+
export declare const unstable_resetCreateSelectorCache: () => void;
|
|
23
23
|
export {};
|
package/utils/createSelector.js
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
import { createSelector as reselectCreateSelector } from 'reselect';
|
|
2
2
|
import { buildWarning } from './warning';
|
|
3
3
|
const cacheContainer = {
|
|
4
|
-
cache:
|
|
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 :
|
|
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
|
|
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
|
|
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
|
|
34
|
-
cache
|
|
31
|
+
if (!cache.get(cacheKey)) {
|
|
32
|
+
cache.set(cacheKey, new Map());
|
|
35
33
|
}
|
|
36
|
-
cache
|
|
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 =
|
|
48
|
-
|
|
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