@mui/x-data-grid 6.8.0 → 6.9.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 +76 -5534
- package/components/GridPagination.d.ts +2 -2
- package/components/GridRow.js +10 -10
- package/components/cell/GridCell.js +6 -6
- package/components/cell/GridEditInputCell.js +9 -9
- package/components/panel/GridPanel.d.ts +1 -1
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -4
- package/hooks/features/columns/gridColumnsSelector.js +7 -7
- package/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/hooks/features/filter/gridFilterSelector.js +8 -8
- package/hooks/features/pagination/gridPaginationSelector.js +4 -4
- package/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
- package/hooks/features/rows/gridRowsSelector.js +3 -3
- package/hooks/features/sorting/gridSortingSelector.js +3 -3
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/legacy/components/GridRow.js +10 -10
- package/legacy/components/cell/GridCell.js +6 -6
- package/legacy/components/cell/GridEditInputCell.js +9 -9
- package/legacy/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -4
- package/legacy/hooks/features/columns/gridColumnsSelector.js +7 -7
- package/legacy/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/legacy/hooks/features/filter/gridFilterSelector.js +8 -8
- package/legacy/hooks/features/pagination/gridPaginationSelector.js +4 -4
- package/legacy/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
- package/legacy/hooks/features/rows/gridRowsSelector.js +3 -3
- package/legacy/hooks/features/sorting/gridSortingSelector.js +3 -3
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -1
- package/legacy/locales/ptBR.js +12 -13
- package/legacy/utils/createSelector.js +74 -6
- package/locales/ptBR.js +12 -13
- package/modern/components/GridRow.js +10 -10
- package/modern/components/cell/GridCell.js +6 -6
- package/modern/components/cell/GridEditInputCell.js +9 -9
- package/modern/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -4
- package/modern/hooks/features/columns/gridColumnsSelector.js +7 -7
- package/modern/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/modern/hooks/features/filter/gridFilterSelector.js +8 -8
- package/modern/hooks/features/pagination/gridPaginationSelector.js +4 -4
- package/modern/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
- package/modern/hooks/features/rows/gridRowsSelector.js +3 -3
- package/modern/hooks/features/sorting/gridSortingSelector.js +3 -3
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -1
- package/modern/locales/ptBR.js +12 -13
- package/modern/utils/createSelector.js +74 -6
- package/node/components/GridRow.js +10 -10
- package/node/components/cell/GridCell.js +6 -6
- package/node/components/cell/GridEditInputCell.js +9 -9
- package/node/hooks/features/columnGrouping/gridColumnGroupsSelector.js +3 -3
- package/node/hooks/features/columns/gridColumnsSelector.js +6 -6
- package/node/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/node/hooks/features/filter/gridFilterSelector.js +7 -7
- package/node/hooks/features/pagination/gridPaginationSelector.js +3 -3
- package/node/hooks/features/rowSelection/gridRowSelectionSelector.js +2 -2
- package/node/hooks/features/rows/gridRowsSelector.js +2 -2
- package/node/hooks/features/sorting/gridSortingSelector.js +2 -2
- package/node/index.js +1 -1
- package/node/internals/index.js +7 -0
- package/node/locales/ptBR.js +12 -13
- package/node/utils/createSelector.js +77 -8
- package/package.json +2 -2
- package/utils/createSelector.d.ts +1 -0
- package/utils/createSelector.js +74 -6
|
@@ -112,21 +112,21 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
112
112
|
/**
|
|
113
113
|
* GridApi that let you manipulate the grid.
|
|
114
114
|
*/
|
|
115
|
-
api: _propTypes.default.object,
|
|
115
|
+
api: _propTypes.default.object.isRequired,
|
|
116
116
|
/**
|
|
117
117
|
* The mode of the cell.
|
|
118
118
|
*/
|
|
119
|
-
cellMode: _propTypes.default.oneOf(['edit', 'view']),
|
|
119
|
+
cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
|
|
120
120
|
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
121
121
|
/**
|
|
122
122
|
* The column of the row that the current cell belongs to.
|
|
123
123
|
*/
|
|
124
|
-
colDef: _propTypes.default.object,
|
|
124
|
+
colDef: _propTypes.default.object.isRequired,
|
|
125
125
|
debounceMs: _propTypes.default.number,
|
|
126
126
|
/**
|
|
127
127
|
* The column field of the cell that triggered the event.
|
|
128
128
|
*/
|
|
129
|
-
field: _propTypes.default.string,
|
|
129
|
+
field: _propTypes.default.string.isRequired,
|
|
130
130
|
/**
|
|
131
131
|
* The cell value formatted with the column valueFormatter.
|
|
132
132
|
*/
|
|
@@ -134,11 +134,11 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
134
134
|
/**
|
|
135
135
|
* If true, the cell is the active element.
|
|
136
136
|
*/
|
|
137
|
-
hasFocus: _propTypes.default.bool,
|
|
137
|
+
hasFocus: _propTypes.default.bool.isRequired,
|
|
138
138
|
/**
|
|
139
139
|
* The grid row id.
|
|
140
140
|
*/
|
|
141
|
-
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
141
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
142
142
|
/**
|
|
143
143
|
* If true, the cell is editable.
|
|
144
144
|
*/
|
|
@@ -155,15 +155,15 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
155
155
|
/**
|
|
156
156
|
* The row model of the row that the current cell belongs to.
|
|
157
157
|
*/
|
|
158
|
-
row: _propTypes.default.any,
|
|
158
|
+
row: _propTypes.default.any.isRequired,
|
|
159
159
|
/**
|
|
160
160
|
* The node of the row that the current cell belongs to.
|
|
161
161
|
*/
|
|
162
|
-
rowNode: _propTypes.default.object,
|
|
162
|
+
rowNode: _propTypes.default.object.isRequired,
|
|
163
163
|
/**
|
|
164
164
|
* the tabIndex value.
|
|
165
165
|
*/
|
|
166
|
-
tabIndex: _propTypes.default.oneOf([-1, 0]),
|
|
166
|
+
tabIndex: _propTypes.default.oneOf([-1, 0]).isRequired,
|
|
167
167
|
/**
|
|
168
168
|
* The cell value.
|
|
169
169
|
* If the column has `valueGetter`, use `params.row` to directly access the fields.
|
|
@@ -11,11 +11,11 @@ var _createSelector = require("../../../utils/createSelector");
|
|
|
11
11
|
*/
|
|
12
12
|
const gridColumnGroupingSelector = state => state.columnGrouping;
|
|
13
13
|
exports.gridColumnGroupingSelector = gridColumnGroupingSelector;
|
|
14
|
-
const gridColumnGroupsUnwrappedModelSelector = (0, _createSelector.
|
|
14
|
+
const gridColumnGroupsUnwrappedModelSelector = (0, _createSelector.createSelectorMemoized)(gridColumnGroupingSelector, columnGrouping => columnGrouping?.unwrappedGroupingModel ?? {});
|
|
15
15
|
exports.gridColumnGroupsUnwrappedModelSelector = gridColumnGroupsUnwrappedModelSelector;
|
|
16
|
-
const gridColumnGroupsLookupSelector = (0, _createSelector.
|
|
16
|
+
const gridColumnGroupsLookupSelector = (0, _createSelector.createSelectorMemoized)(gridColumnGroupingSelector, columnGrouping => columnGrouping?.lookup ?? {});
|
|
17
17
|
exports.gridColumnGroupsLookupSelector = gridColumnGroupsLookupSelector;
|
|
18
|
-
const gridColumnGroupsHeaderStructureSelector = (0, _createSelector.
|
|
18
|
+
const gridColumnGroupsHeaderStructureSelector = (0, _createSelector.createSelectorMemoized)(gridColumnGroupingSelector, columnGrouping => columnGrouping?.headerStructure ?? []);
|
|
19
19
|
exports.gridColumnGroupsHeaderStructureSelector = gridColumnGroupsHeaderStructureSelector;
|
|
20
20
|
const gridColumnGroupsHeaderMaxDepthSelector = (0, _createSelector.createSelector)(gridColumnGroupingSelector, columnGrouping => columnGrouping?.maxDepth ?? 0);
|
|
21
21
|
exports.gridColumnGroupsHeaderMaxDepthSelector = gridColumnGroupsHeaderMaxDepthSelector;
|
|
@@ -30,7 +30,7 @@ const gridColumnLookupSelector = (0, _createSelector.createSelector)(gridColumns
|
|
|
30
30
|
* @category Columns
|
|
31
31
|
*/
|
|
32
32
|
exports.gridColumnLookupSelector = gridColumnLookupSelector;
|
|
33
|
-
const gridColumnDefinitionsSelector = (0, _createSelector.
|
|
33
|
+
const gridColumnDefinitionsSelector = (0, _createSelector.createSelectorMemoized)(gridColumnFieldsSelector, gridColumnLookupSelector, (allFields, lookup) => allFields.map(field => lookup[field]));
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Get the column visibility model, containing the visibility status of each column.
|
|
@@ -45,21 +45,21 @@ const gridColumnVisibilityModelSelector = (0, _createSelector.createSelector)(gr
|
|
|
45
45
|
* @category Visible Columns
|
|
46
46
|
*/
|
|
47
47
|
exports.gridColumnVisibilityModelSelector = gridColumnVisibilityModelSelector;
|
|
48
|
-
const gridVisibleColumnDefinitionsSelector = (0, _createSelector.
|
|
48
|
+
const gridVisibleColumnDefinitionsSelector = (0, _createSelector.createSelectorMemoized)(gridColumnDefinitionsSelector, gridColumnVisibilityModelSelector, (columns, columnVisibilityModel) => columns.filter(column => columnVisibilityModel[column.field] !== false));
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Get the field of each visible column.
|
|
52
52
|
* @category Visible Columns
|
|
53
53
|
*/
|
|
54
54
|
exports.gridVisibleColumnDefinitionsSelector = gridVisibleColumnDefinitionsSelector;
|
|
55
|
-
const gridVisibleColumnFieldsSelector = (0, _createSelector.
|
|
55
|
+
const gridVisibleColumnFieldsSelector = (0, _createSelector.createSelectorMemoized)(gridVisibleColumnDefinitionsSelector, visibleColumns => visibleColumns.map(column => column.field));
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Get the left position in pixel of each visible columns relative to the left of the first column.
|
|
59
59
|
* @category Visible Columns
|
|
60
60
|
*/
|
|
61
61
|
exports.gridVisibleColumnFieldsSelector = gridVisibleColumnFieldsSelector;
|
|
62
|
-
const gridColumnPositionsSelector = (0, _createSelector.
|
|
62
|
+
const gridColumnPositionsSelector = (0, _createSelector.createSelectorMemoized)(gridVisibleColumnDefinitionsSelector, visibleColumns => {
|
|
63
63
|
const positions = [];
|
|
64
64
|
let currentPosition = 0;
|
|
65
65
|
for (let i = 0; i < visibleColumns.length; i += 1) {
|
|
@@ -87,14 +87,14 @@ const gridColumnsTotalWidthSelector = (0, _createSelector.createSelector)(gridVi
|
|
|
87
87
|
* @category Columns
|
|
88
88
|
*/
|
|
89
89
|
exports.gridColumnsTotalWidthSelector = gridColumnsTotalWidthSelector;
|
|
90
|
-
const gridFilterableColumnDefinitionsSelector = (0, _createSelector.
|
|
90
|
+
const gridFilterableColumnDefinitionsSelector = (0, _createSelector.createSelectorMemoized)(gridColumnDefinitionsSelector, columns => columns.filter(col => col.filterable));
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* Get the filterable columns as a lookup (an object containing the field for keys and the definition for values).
|
|
94
94
|
* @category Columns
|
|
95
95
|
*/
|
|
96
96
|
exports.gridFilterableColumnDefinitionsSelector = gridFilterableColumnDefinitionsSelector;
|
|
97
|
-
const gridFilterableColumnLookupSelector = (0, _createSelector.
|
|
97
|
+
const gridFilterableColumnLookupSelector = (0, _createSelector.createSelectorMemoized)(gridColumnDefinitionsSelector, columns => columns.reduce((acc, col) => {
|
|
98
98
|
if (col.filterable) {
|
|
99
99
|
acc[col.field] = col;
|
|
100
100
|
}
|
|
@@ -161,22 +161,16 @@ function useGridDimensions(apiRef, props) {
|
|
|
161
161
|
if (!mainEl) {
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
|
-
const height = mainEl.clientHeight || 0;
|
|
165
|
-
const width = mainEl.clientWidth || 0;
|
|
166
164
|
const win = (0, _utils.unstable_ownerWindow)(mainEl);
|
|
167
165
|
const computedStyle = win.getComputedStyle(mainEl);
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
const newHeight = height - paddingTop - paddingBottom;
|
|
173
|
-
const newWidth = width - paddingLeft - paddingRight;
|
|
174
|
-
const hasHeightChanged = newHeight !== previousSize.current?.height;
|
|
175
|
-
const hasWidthChanged = newWidth !== previousSize.current?.width;
|
|
166
|
+
const height = parseFloat(computedStyle.height) || 0;
|
|
167
|
+
const width = parseFloat(computedStyle.width) || 0;
|
|
168
|
+
const hasHeightChanged = height !== previousSize.current?.height;
|
|
169
|
+
const hasWidthChanged = width !== previousSize.current?.width;
|
|
176
170
|
if (!previousSize.current || hasHeightChanged || hasWidthChanged) {
|
|
177
171
|
const size = {
|
|
178
|
-
width
|
|
179
|
-
height
|
|
172
|
+
width,
|
|
173
|
+
height
|
|
180
174
|
};
|
|
181
175
|
apiRef.current.publishEvent('resize', size);
|
|
182
176
|
previousSize.current = size;
|
|
@@ -53,7 +53,7 @@ const gridFilteredDescendantCountLookupSelector = (0, _createSelector.createSele
|
|
|
53
53
|
* @category Filtering
|
|
54
54
|
*/
|
|
55
55
|
exports.gridFilteredDescendantCountLookupSelector = gridFilteredDescendantCountLookupSelector;
|
|
56
|
-
const gridExpandedSortedRowEntriesSelector = (0, _createSelector.
|
|
56
|
+
const gridExpandedSortedRowEntriesSelector = (0, _createSelector.createSelectorMemoized)(gridVisibleRowsLookupSelector, _gridSortingSelector.gridSortedRowEntriesSelector, (visibleRowsLookup, sortedRows) => sortedRows.filter(row => visibleRowsLookup[row.id] !== false));
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* Get the id of the rows accessible after the filtering process.
|
|
@@ -61,7 +61,7 @@ const gridExpandedSortedRowEntriesSelector = (0, _createSelector.createSelector)
|
|
|
61
61
|
* @category Filtering
|
|
62
62
|
*/
|
|
63
63
|
exports.gridExpandedSortedRowEntriesSelector = gridExpandedSortedRowEntriesSelector;
|
|
64
|
-
const gridExpandedSortedRowIdsSelector = (0, _createSelector.
|
|
64
|
+
const gridExpandedSortedRowIdsSelector = (0, _createSelector.createSelectorMemoized)(gridExpandedSortedRowEntriesSelector, visibleSortedRowEntries => visibleSortedRowEntries.map(row => row.id));
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* Get the id and the model of the rows accessible after the filtering process.
|
|
@@ -69,7 +69,7 @@ const gridExpandedSortedRowIdsSelector = (0, _createSelector.createSelector)(gri
|
|
|
69
69
|
* @category Filtering
|
|
70
70
|
*/
|
|
71
71
|
exports.gridExpandedSortedRowIdsSelector = gridExpandedSortedRowIdsSelector;
|
|
72
|
-
const gridFilteredSortedRowEntriesSelector = (0, _createSelector.
|
|
72
|
+
const gridFilteredSortedRowEntriesSelector = (0, _createSelector.createSelectorMemoized)(gridFilteredRowsLookupSelector, _gridSortingSelector.gridSortedRowEntriesSelector, (filteredRowsLookup, sortedRows) => sortedRows.filter(row => filteredRowsLookup[row.id] !== false));
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Get the id of the rows accessible after the filtering process.
|
|
@@ -77,14 +77,14 @@ const gridFilteredSortedRowEntriesSelector = (0, _createSelector.createSelector)
|
|
|
77
77
|
* @category Filtering
|
|
78
78
|
*/
|
|
79
79
|
exports.gridFilteredSortedRowEntriesSelector = gridFilteredSortedRowEntriesSelector;
|
|
80
|
-
const gridFilteredSortedRowIdsSelector = (0, _createSelector.
|
|
80
|
+
const gridFilteredSortedRowIdsSelector = (0, _createSelector.createSelectorMemoized)(gridFilteredSortedRowEntriesSelector, filteredSortedRowEntries => filteredSortedRowEntries.map(row => row.id));
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Get the id and the model of the top level rows accessible after the filtering process.
|
|
84
84
|
* @category Filtering
|
|
85
85
|
*/
|
|
86
86
|
exports.gridFilteredSortedRowIdsSelector = gridFilteredSortedRowIdsSelector;
|
|
87
|
-
const gridFilteredSortedTopLevelRowEntriesSelector = (0, _createSelector.
|
|
87
|
+
const gridFilteredSortedTopLevelRowEntriesSelector = (0, _createSelector.createSelectorMemoized)(gridExpandedSortedRowEntriesSelector, _gridRowsSelector.gridRowTreeSelector, _gridRowsSelector.gridRowMaximumTreeDepthSelector, (visibleSortedRows, rowTree, rowTreeDepth) => {
|
|
88
88
|
if (rowTreeDepth < 2) {
|
|
89
89
|
return visibleSortedRows;
|
|
90
90
|
}
|
|
@@ -110,7 +110,7 @@ const gridFilteredTopLevelRowCountSelector = (0, _createSelector.createSelector)
|
|
|
110
110
|
* @ignore - do not document.
|
|
111
111
|
*/
|
|
112
112
|
exports.gridFilteredTopLevelRowCountSelector = gridFilteredTopLevelRowCountSelector;
|
|
113
|
-
const gridFilterActiveItemsSelector = (0, _createSelector.
|
|
113
|
+
const gridFilterActiveItemsSelector = (0, _createSelector.createSelectorMemoized)(gridFilterModelSelector, _gridColumnsSelector.gridColumnLookupSelector, (filterModel, columnLookup) => filterModel.items?.filter(item => {
|
|
114
114
|
if (!item.field) {
|
|
115
115
|
return false;
|
|
116
116
|
}
|
|
@@ -129,7 +129,7 @@ exports.gridFilterActiveItemsSelector = gridFilterActiveItemsSelector;
|
|
|
129
129
|
* @category Filtering
|
|
130
130
|
* @ignore - do not document.
|
|
131
131
|
*/
|
|
132
|
-
const gridFilterActiveItemsLookupSelector = (0, _createSelector.
|
|
132
|
+
const gridFilterActiveItemsLookupSelector = (0, _createSelector.createSelectorMemoized)(gridFilterActiveItemsSelector, activeFilters => {
|
|
133
133
|
const result = activeFilters.reduce((res, filterItem) => {
|
|
134
134
|
if (!res[filterItem.field]) {
|
|
135
135
|
res[filterItem.field] = [filterItem];
|
|
@@ -47,7 +47,7 @@ const gridPageCountSelector = (0, _createSelector.createSelector)(gridPagination
|
|
|
47
47
|
* @category Pagination
|
|
48
48
|
*/
|
|
49
49
|
exports.gridPageCountSelector = gridPageCountSelector;
|
|
50
|
-
const gridPaginationRowRangeSelector = (0, _createSelector.
|
|
50
|
+
const gridPaginationRowRangeSelector = (0, _createSelector.createSelectorMemoized)(gridPaginationModelSelector, _gridRowsSelector.gridRowTreeSelector, _gridRowsSelector.gridRowMaximumTreeDepthSelector, _gridFilterSelector.gridExpandedSortedRowEntriesSelector, _gridFilterSelector.gridFilteredSortedTopLevelRowEntriesSelector, (paginationModel, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) => {
|
|
51
51
|
const visibleTopLevelRowCount = visibleSortedTopLevelRowEntries.length;
|
|
52
52
|
const topLevelFirstRowIndex = Math.min(paginationModel.pageSize * paginationModel.page, visibleTopLevelRowCount - 1);
|
|
53
53
|
const topLevelLastRowIndex = Math.min(topLevelFirstRowIndex + paginationModel.pageSize - 1, visibleTopLevelRowCount - 1);
|
|
@@ -90,7 +90,7 @@ const gridPaginationRowRangeSelector = (0, _createSelector.createSelector)(gridP
|
|
|
90
90
|
* @category Pagination
|
|
91
91
|
*/
|
|
92
92
|
exports.gridPaginationRowRangeSelector = gridPaginationRowRangeSelector;
|
|
93
|
-
const gridPaginatedVisibleSortedGridRowEntriesSelector = (0, _createSelector.
|
|
93
|
+
const gridPaginatedVisibleSortedGridRowEntriesSelector = (0, _createSelector.createSelectorMemoized)(_gridFilterSelector.gridExpandedSortedRowEntriesSelector, gridPaginationRowRangeSelector, (visibleSortedRowEntries, paginationRange) => {
|
|
94
94
|
if (!paginationRange) {
|
|
95
95
|
return [];
|
|
96
96
|
}
|
|
@@ -102,7 +102,7 @@ const gridPaginatedVisibleSortedGridRowEntriesSelector = (0, _createSelector.cre
|
|
|
102
102
|
* @category Pagination
|
|
103
103
|
*/
|
|
104
104
|
exports.gridPaginatedVisibleSortedGridRowEntriesSelector = gridPaginatedVisibleSortedGridRowEntriesSelector;
|
|
105
|
-
const gridPaginatedVisibleSortedGridRowIdsSelector = (0, _createSelector.
|
|
105
|
+
const gridPaginatedVisibleSortedGridRowIdsSelector = (0, _createSelector.createSelectorMemoized)(_gridFilterSelector.gridExpandedSortedRowIdsSelector, gridPaginationRowRangeSelector, (visibleSortedRowIds, paginationRange) => {
|
|
106
106
|
if (!paginationRange) {
|
|
107
107
|
return [];
|
|
108
108
|
}
|
|
@@ -10,9 +10,9 @@ const gridRowSelectionStateSelector = state => state.rowSelection;
|
|
|
10
10
|
exports.gridRowSelectionStateSelector = gridRowSelectionStateSelector;
|
|
11
11
|
const selectedGridRowsCountSelector = (0, _createSelector.createSelector)(gridRowSelectionStateSelector, selection => selection.length);
|
|
12
12
|
exports.selectedGridRowsCountSelector = selectedGridRowsCountSelector;
|
|
13
|
-
const selectedGridRowsSelector = (0, _createSelector.
|
|
13
|
+
const selectedGridRowsSelector = (0, _createSelector.createSelectorMemoized)(gridRowSelectionStateSelector, _gridRowsSelector.gridRowsLookupSelector, (selectedRows, rowsLookup) => new Map(selectedRows.map(id => [id, rowsLookup[id]])));
|
|
14
14
|
exports.selectedGridRowsSelector = selectedGridRowsSelector;
|
|
15
|
-
const selectedIdsLookupSelector = (0, _createSelector.
|
|
15
|
+
const selectedIdsLookupSelector = (0, _createSelector.createSelectorMemoized)(gridRowSelectionStateSelector, selection => selection.reduce((lookup, rowId) => {
|
|
16
16
|
lookup[rowId] = rowId;
|
|
17
17
|
return lookup;
|
|
18
18
|
}, {}));
|
|
@@ -24,7 +24,7 @@ const gridRowGroupingNameSelector = (0, _createSelector.createSelector)(gridRows
|
|
|
24
24
|
exports.gridRowGroupingNameSelector = gridRowGroupingNameSelector;
|
|
25
25
|
const gridRowTreeDepthsSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.treeDepths);
|
|
26
26
|
exports.gridRowTreeDepthsSelector = gridRowTreeDepthsSelector;
|
|
27
|
-
const gridRowMaximumTreeDepthSelector = (0, _createSelector.
|
|
27
|
+
const gridRowMaximumTreeDepthSelector = (0, _createSelector.createSelectorMemoized)(gridRowsStateSelector, rows => {
|
|
28
28
|
const entries = Object.entries(rows.treeDepths);
|
|
29
29
|
if (entries.length === 0) {
|
|
30
30
|
return 1;
|
|
@@ -44,7 +44,7 @@ const gridAdditionalRowGroupsSelector = (0, _createSelector.createSelector)(grid
|
|
|
44
44
|
* @ignore - do not document.
|
|
45
45
|
*/
|
|
46
46
|
exports.gridAdditionalRowGroupsSelector = gridAdditionalRowGroupsSelector;
|
|
47
|
-
const gridPinnedRowsSelector = (0, _createSelector.
|
|
47
|
+
const gridPinnedRowsSelector = (0, _createSelector.createSelectorMemoized)(gridAdditionalRowGroupsSelector, additionalRowGroups => {
|
|
48
48
|
const rawPinnedRows = additionalRowGroups?.pinnedRows;
|
|
49
49
|
return {
|
|
50
50
|
bottom: rawPinnedRows?.bottom?.map(rowEntry => ({
|
|
@@ -23,7 +23,7 @@ const gridSortedRowIdsSelector = (0, _createSelector.createSelector)(gridSorting
|
|
|
23
23
|
* @category Sorting
|
|
24
24
|
*/
|
|
25
25
|
exports.gridSortedRowIdsSelector = gridSortedRowIdsSelector;
|
|
26
|
-
const gridSortedRowEntriesSelector = (0, _createSelector.
|
|
26
|
+
const gridSortedRowEntriesSelector = (0, _createSelector.createSelectorMemoized)(gridSortedRowIdsSelector, _gridRowsSelector.gridRowsLookupSelector,
|
|
27
27
|
// TODO rows v6: Is this the best approach ?
|
|
28
28
|
(sortedIds, idRowsLookup) => sortedIds.map(id => ({
|
|
29
29
|
id,
|
|
@@ -41,7 +41,7 @@ exports.gridSortModelSelector = gridSortModelSelector;
|
|
|
41
41
|
* @category Sorting
|
|
42
42
|
* @ignore - do not document.
|
|
43
43
|
*/
|
|
44
|
-
const gridSortColumnLookupSelector = (0, _createSelector.
|
|
44
|
+
const gridSortColumnLookupSelector = (0, _createSelector.createSelectorMemoized)(gridSortModelSelector, sortModel => {
|
|
45
45
|
const result = sortModel.reduce((res, sortItem, index) => {
|
|
46
46
|
res[sortItem.field] = {
|
|
47
47
|
sortDirection: sortItem.sort,
|
package/node/index.js
CHANGED
package/node/internals/index.js
CHANGED
|
@@ -76,6 +76,7 @@ var _exportNames = {
|
|
|
76
76
|
getColumnsToExport: true,
|
|
77
77
|
defaultGetRowsToExport: true,
|
|
78
78
|
createSelector: true,
|
|
79
|
+
createSelectorMemoized: true,
|
|
79
80
|
unstable_resetCreateSelectorCache: true,
|
|
80
81
|
findParentElementFromClassName: true,
|
|
81
82
|
getActiveElement: true,
|
|
@@ -180,6 +181,12 @@ Object.defineProperty(exports, "createSelector", {
|
|
|
180
181
|
return _createSelector.createSelector;
|
|
181
182
|
}
|
|
182
183
|
});
|
|
184
|
+
Object.defineProperty(exports, "createSelectorMemoized", {
|
|
185
|
+
enumerable: true,
|
|
186
|
+
get: function () {
|
|
187
|
+
return _createSelector.createSelectorMemoized;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
183
190
|
Object.defineProperty(exports, "defaultGetRowsToExport", {
|
|
184
191
|
enumerable: true,
|
|
185
192
|
get: function () {
|
package/node/locales/ptBR.js
CHANGED
|
@@ -74,12 +74,12 @@ const ptBRGrid = {
|
|
|
74
74
|
// 'filterOperator<=': '<=',
|
|
75
75
|
|
|
76
76
|
// Header filter operators text
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
headerFilterOperatorContains: 'Contém',
|
|
78
|
+
headerFilterOperatorEquals: 'Igual',
|
|
79
|
+
headerFilterOperatorStartsWith: 'Começa com',
|
|
80
|
+
headerFilterOperatorEndsWith: 'Termina com',
|
|
81
|
+
headerFilterOperatorIs: 'É',
|
|
82
|
+
headerFilterOperatorNot: 'Não é',
|
|
83
83
|
// headerFilterOperatorAfter: 'Is after',
|
|
84
84
|
// headerFilterOperatorOnOrAfter: 'Is on or after',
|
|
85
85
|
// headerFilterOperatorBefore: 'Is before',
|
|
@@ -87,13 +87,12 @@ const ptBRGrid = {
|
|
|
87
87
|
// headerFilterOperatorIsEmpty: 'Is empty',
|
|
88
88
|
// headerFilterOperatorIsNotEmpty: 'Is not empty',
|
|
89
89
|
// headerFilterOperatorIsAnyOf: 'Is any of',
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
'headerFilterOperator=': 'Igual',
|
|
91
|
+
'headerFilterOperator!=': 'Não igual',
|
|
92
|
+
'headerFilterOperator>': 'Maior que',
|
|
93
|
+
'headerFilterOperator>=': 'Maior que ou igual a',
|
|
94
|
+
'headerFilterOperator<': 'Menor que',
|
|
95
|
+
'headerFilterOperator<=': 'Menor que ou igual a',
|
|
97
96
|
// Filter values text
|
|
98
97
|
filterValueAny: 'qualquer',
|
|
99
98
|
filterValueTrue: 'verdadeiro',
|
|
@@ -3,21 +3,90 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.unstable_resetCreateSelectorCache = exports.createSelector = void 0;
|
|
6
|
+
exports.unstable_resetCreateSelectorCache = exports.createSelectorMemoized = exports.createSelector = void 0;
|
|
7
7
|
var _reselect = require("reselect");
|
|
8
8
|
var _warning = require("./warning");
|
|
9
9
|
const cacheContainer = {
|
|
10
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
|
+
function checkIsAPIRef(value) {
|
|
14
|
+
return 'current' in value && 'instanceId' in value.current;
|
|
15
|
+
}
|
|
16
|
+
const DEFAULT_INSTANCE_ID = {
|
|
17
|
+
id: 'default'
|
|
18
|
+
};
|
|
19
|
+
const createSelector = (a, b, c, d, e, f, ...rest) => {
|
|
20
|
+
if (rest.length > 0) {
|
|
21
|
+
throw new Error('Unsupported number of selectors');
|
|
22
|
+
}
|
|
23
|
+
let selector;
|
|
24
|
+
if (a && b && c && d && e && f) {
|
|
25
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
26
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
27
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
28
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
29
|
+
const va = a(state, instanceId);
|
|
30
|
+
const vb = b(state, instanceId);
|
|
31
|
+
const vc = c(state, instanceId);
|
|
32
|
+
const vd = d(state, instanceId);
|
|
33
|
+
const ve = e(state, instanceId);
|
|
34
|
+
return f(va, vb, vc, vd, ve);
|
|
35
|
+
};
|
|
36
|
+
} else if (a && b && c && d && e) {
|
|
37
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
38
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
39
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
40
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
41
|
+
const va = a(state, instanceId);
|
|
42
|
+
const vb = b(state, instanceId);
|
|
43
|
+
const vc = c(state, instanceId);
|
|
44
|
+
const vd = d(state, instanceId);
|
|
45
|
+
return e(va, vb, vc, vd);
|
|
46
|
+
};
|
|
47
|
+
} else if (a && b && c && d) {
|
|
48
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
49
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
50
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
51
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
52
|
+
const va = a(state, instanceId);
|
|
53
|
+
const vb = b(state, instanceId);
|
|
54
|
+
const vc = c(state, instanceId);
|
|
55
|
+
return d(va, vb, vc);
|
|
56
|
+
};
|
|
57
|
+
} else if (a && b && c) {
|
|
58
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
59
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
60
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
61
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
62
|
+
const va = a(state, instanceId);
|
|
63
|
+
const vb = b(state, instanceId);
|
|
64
|
+
return c(va, vb);
|
|
65
|
+
};
|
|
66
|
+
} else if (a && b) {
|
|
67
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
68
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
69
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
70
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
71
|
+
const va = a(state, instanceId);
|
|
72
|
+
return b(va);
|
|
73
|
+
};
|
|
74
|
+
} else {
|
|
75
|
+
throw new Error('Missing arguments');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// We use this property to detect if the selector was created with createSelector
|
|
79
|
+
// or it's only a simple function the receives the state and returns part of it.
|
|
80
|
+
selector.acceptsApiRef = true;
|
|
81
|
+
return selector;
|
|
82
|
+
};
|
|
83
|
+
exports.createSelector = createSelector;
|
|
84
|
+
const createSelectorMemoized = (...args) => {
|
|
14
85
|
const selector = (...selectorArgs) => {
|
|
15
86
|
const [stateOrApiRef, instanceId] = selectorArgs;
|
|
16
|
-
const
|
|
17
|
-
const cacheKey =
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
const state = isApiRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
87
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
88
|
+
const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
|
|
89
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
21
90
|
if (process.env.NODE_ENV !== 'production') {
|
|
22
91
|
if (cacheKey.id === 'default') {
|
|
23
92
|
missingInstanceIdWarning();
|
|
@@ -46,7 +115,7 @@ const createSelector = (...args) => {
|
|
|
46
115
|
};
|
|
47
116
|
|
|
48
117
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
49
|
-
exports.
|
|
118
|
+
exports.createSelectorMemoized = createSelectorMemoized;
|
|
50
119
|
const unstable_resetCreateSelectorCache = () => {
|
|
51
120
|
cacheContainer.cache = new WeakMap();
|
|
52
121
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.9.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",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"directory": "packages/grid/x-data-grid"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@babel/runtime": "^7.
|
|
38
|
+
"@babel/runtime": "^7.22.5",
|
|
39
39
|
"@mui/utils": "^5.13.1",
|
|
40
40
|
"clsx": "^1.2.1",
|
|
41
41
|
"prop-types": "^15.8.1",
|
|
@@ -19,5 +19,6 @@ 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 createSelectorMemoized: CreateSelectorFunction;
|
|
22
23
|
export declare const unstable_resetCreateSelectorCache: () => void;
|
|
23
24
|
export {};
|
package/utils/createSelector.js
CHANGED
|
@@ -4,15 +4,83 @@ const cacheContainer = {
|
|
|
4
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
|
+
function checkIsAPIRef(value) {
|
|
8
|
+
return 'current' in value && 'instanceId' in value.current;
|
|
9
|
+
}
|
|
10
|
+
const DEFAULT_INSTANCE_ID = {
|
|
11
|
+
id: 'default'
|
|
12
|
+
};
|
|
13
|
+
export const createSelector = (a, b, c, d, e, f, ...rest) => {
|
|
14
|
+
if (rest.length > 0) {
|
|
15
|
+
throw new Error('Unsupported number of selectors');
|
|
16
|
+
}
|
|
17
|
+
let selector;
|
|
18
|
+
if (a && b && c && d && e && f) {
|
|
19
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
20
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
21
|
+
const instanceId = instanceIdParam != null ? instanceIdParam : isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID;
|
|
22
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
23
|
+
const va = a(state, instanceId);
|
|
24
|
+
const vb = b(state, instanceId);
|
|
25
|
+
const vc = c(state, instanceId);
|
|
26
|
+
const vd = d(state, instanceId);
|
|
27
|
+
const ve = e(state, instanceId);
|
|
28
|
+
return f(va, vb, vc, vd, ve);
|
|
29
|
+
};
|
|
30
|
+
} else if (a && b && c && d && e) {
|
|
31
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
32
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
33
|
+
const instanceId = instanceIdParam != null ? instanceIdParam : isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID;
|
|
34
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
35
|
+
const va = a(state, instanceId);
|
|
36
|
+
const vb = b(state, instanceId);
|
|
37
|
+
const vc = c(state, instanceId);
|
|
38
|
+
const vd = d(state, instanceId);
|
|
39
|
+
return e(va, vb, vc, vd);
|
|
40
|
+
};
|
|
41
|
+
} else if (a && b && c && d) {
|
|
42
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
43
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
44
|
+
const instanceId = instanceIdParam != null ? instanceIdParam : isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID;
|
|
45
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
46
|
+
const va = a(state, instanceId);
|
|
47
|
+
const vb = b(state, instanceId);
|
|
48
|
+
const vc = c(state, instanceId);
|
|
49
|
+
return d(va, vb, vc);
|
|
50
|
+
};
|
|
51
|
+
} else if (a && b && c) {
|
|
52
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
53
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
54
|
+
const instanceId = instanceIdParam != null ? instanceIdParam : isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID;
|
|
55
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
56
|
+
const va = a(state, instanceId);
|
|
57
|
+
const vb = b(state, instanceId);
|
|
58
|
+
return c(va, vb);
|
|
59
|
+
};
|
|
60
|
+
} else if (a && b) {
|
|
61
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
62
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
63
|
+
const instanceId = instanceIdParam != null ? instanceIdParam : isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID;
|
|
64
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
65
|
+
const va = a(state, instanceId);
|
|
66
|
+
return b(va);
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
throw new Error('Missing arguments');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// We use this property to detect if the selector was created with createSelector
|
|
73
|
+
// or it's only a simple function the receives the state and returns part of it.
|
|
74
|
+
selector.acceptsApiRef = true;
|
|
75
|
+
return selector;
|
|
76
|
+
};
|
|
77
|
+
export const createSelectorMemoized = (...args) => {
|
|
8
78
|
const selector = (...selectorArgs) => {
|
|
9
79
|
var _cache$get, _cache$get3;
|
|
10
80
|
const [stateOrApiRef, instanceId] = selectorArgs;
|
|
11
|
-
const
|
|
12
|
-
const cacheKey =
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
const state = isApiRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
81
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
82
|
+
const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId != null ? instanceId : DEFAULT_INSTANCE_ID;
|
|
83
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
16
84
|
if (process.env.NODE_ENV !== 'production') {
|
|
17
85
|
if (cacheKey.id === 'default') {
|
|
18
86
|
missingInstanceIdWarning();
|