@mui/x-data-grid 6.16.3 → 6.18.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 +127 -0
- package/DataGrid/DataGrid.js +13 -0
- package/DataGrid/useDataGridProps.js +3 -1
- package/colDef/gridStringOperators.js +1 -2
- package/components/containers/GridRootStyles.js +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +6 -2
- package/hooks/core/useGridInitialization.d.ts +1 -1
- package/hooks/core/useGridInitialization.js +3 -0
- package/hooks/features/filter/gridFilterUtils.d.ts +8 -25
- package/hooks/features/filter/gridFilterUtils.js +55 -24
- package/hooks/features/filter/useGridFilter.js +2 -2
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +9 -1
- package/index.js +1 -1
- package/legacy/DataGrid/DataGrid.js +13 -0
- package/legacy/DataGrid/useDataGridProps.js +3 -1
- package/legacy/colDef/gridStringOperators.js +1 -2
- package/legacy/components/containers/GridRootStyles.js +2 -1
- package/legacy/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +6 -2
- package/legacy/hooks/core/useGridInitialization.js +3 -0
- package/legacy/hooks/features/filter/gridFilterUtils.js +40 -17
- package/legacy/hooks/features/filter/useGridFilter.js +2 -2
- package/legacy/hooks/features/rows/useGridRowsMeta.js +2 -2
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +9 -1
- package/legacy/index.js +1 -1
- package/legacy/locales/ptBR.js +13 -14
- package/legacy/utils/utils.js +1 -1
- package/locales/ptBR.js +13 -14
- package/models/api/gridApiCommon.d.ts +3 -2
- package/models/api/gridApiCommunity.d.ts +2 -1
- package/models/api/gridCoreApi.d.ts +7 -1
- package/models/api/gridEditingApi.d.ts +2 -2
- package/models/api/gridFilterApi.d.ts +1 -1
- package/models/api/gridLocaleTextApi.d.ts +3 -2
- package/models/props/DataGridProps.d.ts +13 -0
- package/modern/DataGrid/DataGrid.js +13 -0
- package/modern/DataGrid/useDataGridProps.js +3 -1
- package/modern/colDef/gridStringOperators.js +1 -2
- package/modern/components/containers/GridRootStyles.js +2 -1
- package/modern/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +6 -2
- package/modern/hooks/core/useGridInitialization.js +3 -0
- package/modern/hooks/features/filter/gridFilterUtils.js +55 -24
- package/modern/hooks/features/filter/useGridFilter.js +2 -2
- package/modern/hooks/features/rows/useGridRowsMeta.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +9 -1
- package/modern/index.js +1 -1
- package/modern/locales/ptBR.js +13 -14
- package/modern/utils/utils.js +1 -1
- package/node/DataGrid/DataGrid.js +13 -0
- package/node/DataGrid/useDataGridProps.js +3 -1
- package/node/colDef/gridStringOperators.js +1 -2
- package/node/components/containers/GridRootStyles.js +2 -1
- package/node/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +6 -2
- package/node/hooks/core/useGridInitialization.js +3 -0
- package/node/hooks/features/filter/gridFilterUtils.js +56 -27
- package/node/hooks/features/filter/useGridFilter.js +2 -2
- package/node/hooks/features/rows/useGridRowsMeta.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +9 -1
- package/node/index.js +1 -1
- package/node/locales/ptBR.js +13 -14
- package/node/utils/utils.js +1 -1
- package/package.json +2 -2
- package/utils/utils.d.ts +1 -1
- package/utils/utils.js +1 -1
|
@@ -36,6 +36,10 @@ function GridColumnMenuSortItem(props) {
|
|
|
36
36
|
})) {
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
|
+
var getLabel = function getLabel(key) {
|
|
40
|
+
var label = apiRef.current.getLocaleText(key);
|
|
41
|
+
return typeof label === 'function' ? label(colDef) : label;
|
|
42
|
+
};
|
|
39
43
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
40
44
|
children: [sortingOrder.includes('asc') && sortDirection !== 'asc' ? /*#__PURE__*/_jsxs(MenuItem, {
|
|
41
45
|
onClick: onSortMenuItemClick,
|
|
@@ -45,7 +49,7 @@ function GridColumnMenuSortItem(props) {
|
|
|
45
49
|
fontSize: "small"
|
|
46
50
|
})
|
|
47
51
|
}), /*#__PURE__*/_jsx(ListItemText, {
|
|
48
|
-
children:
|
|
52
|
+
children: getLabel('columnMenuSortAsc')
|
|
49
53
|
})]
|
|
50
54
|
}) : null, sortingOrder.includes('desc') && sortDirection !== 'desc' ? /*#__PURE__*/_jsxs(MenuItem, {
|
|
51
55
|
onClick: onSortMenuItemClick,
|
|
@@ -55,7 +59,7 @@ function GridColumnMenuSortItem(props) {
|
|
|
55
59
|
fontSize: "small"
|
|
56
60
|
})
|
|
57
61
|
}), /*#__PURE__*/_jsx(ListItemText, {
|
|
58
|
-
children:
|
|
62
|
+
children: getLabel('columnMenuSortDesc')
|
|
59
63
|
})]
|
|
60
64
|
}) : null, sortingOrder.includes(null) && sortDirection != null ? /*#__PURE__*/_jsxs(MenuItem, {
|
|
61
65
|
onClick: onSortMenuItemClick,
|
|
@@ -15,5 +15,8 @@ export var useGridInitialization = function useGridInitialization(inputApiRef, p
|
|
|
15
15
|
useGridPipeProcessing(privateApiRef);
|
|
16
16
|
useGridStrategyProcessing(privateApiRef);
|
|
17
17
|
useGridLocaleText(privateApiRef, props);
|
|
18
|
+
privateApiRef.current.register('private', {
|
|
19
|
+
rootProps: props
|
|
20
|
+
});
|
|
18
21
|
return privateApiRef;
|
|
19
22
|
};
|
|
@@ -17,7 +17,7 @@ try {
|
|
|
17
17
|
/**
|
|
18
18
|
* Adds default values to the optional fields of a filter items.
|
|
19
19
|
* @param {GridFilterItem} item The raw filter item.
|
|
20
|
-
* @param {React.MutableRefObject<
|
|
20
|
+
* @param {React.MutableRefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
|
|
21
21
|
* @return {GridFilterItem} The clean filter item with an uniq ID and an always-defined operator.
|
|
22
22
|
* TODO: Make the typing reflect the different between GridFilterInputItem and GridFilterItem.
|
|
23
23
|
*/
|
|
@@ -79,6 +79,12 @@ export var mergeStateWithFilterModel = function mergeStateWithFilterModel(filter
|
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
|
+
var removeDiacritics = function removeDiacritics(value) {
|
|
83
|
+
if (typeof value === 'string') {
|
|
84
|
+
return value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
85
|
+
}
|
|
86
|
+
return value;
|
|
87
|
+
};
|
|
82
88
|
var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem, apiRef) {
|
|
83
89
|
if (!filterItem.field || !filterItem.operator) {
|
|
84
90
|
return null;
|
|
@@ -97,6 +103,10 @@ var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem, a
|
|
|
97
103
|
} else {
|
|
98
104
|
parsedValue = filterItem.value;
|
|
99
105
|
}
|
|
106
|
+
var ignoreDiacritics = apiRef.current.rootProps.ignoreDiacritics;
|
|
107
|
+
if (ignoreDiacritics) {
|
|
108
|
+
parsedValue = removeDiacritics(parsedValue);
|
|
109
|
+
}
|
|
100
110
|
var newFilterItem = _extends({}, filterItem, {
|
|
101
111
|
value: parsedValue
|
|
102
112
|
});
|
|
@@ -122,6 +132,9 @@ var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem, a
|
|
|
122
132
|
item: newFilterItem,
|
|
123
133
|
fn: function fn(row) {
|
|
124
134
|
var value = apiRef.current.getRowValue(row, column);
|
|
135
|
+
if (ignoreDiacritics) {
|
|
136
|
+
value = removeDiacritics(value);
|
|
137
|
+
}
|
|
125
138
|
return _applyFilterOnRow(value, row, column, apiRef);
|
|
126
139
|
}
|
|
127
140
|
};
|
|
@@ -136,6 +149,9 @@ var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem, a
|
|
|
136
149
|
fn: function fn(rowId) {
|
|
137
150
|
var params = apiRef.current.getCellParams(rowId, newFilterItem.field);
|
|
138
151
|
GLOBAL_API_REF.current = apiRef;
|
|
152
|
+
if (ignoreDiacritics) {
|
|
153
|
+
params.value = removeDiacritics(params.value);
|
|
154
|
+
}
|
|
139
155
|
var result = applyFilterOnRow(params);
|
|
140
156
|
GLOBAL_API_REF.current = null;
|
|
141
157
|
return result;
|
|
@@ -146,12 +162,11 @@ var filterItemsApplierId = 1;
|
|
|
146
162
|
|
|
147
163
|
/**
|
|
148
164
|
* Generates a method to easily check if a row is matching the current filter model.
|
|
149
|
-
* @param {GridRowIdGetter | undefined} getRowId The getter for row's id.
|
|
150
165
|
* @param {GridFilterModel} filterModel The model with which we want to filter the rows.
|
|
151
|
-
* @param {React.MutableRefObject<
|
|
166
|
+
* @param {React.MutableRefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
|
|
152
167
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
153
168
|
*/
|
|
154
|
-
|
|
169
|
+
var buildAggregatedFilterItemsApplier = function buildAggregatedFilterItemsApplier(filterModel, apiRef, disableEval) {
|
|
155
170
|
var items = filterModel.items;
|
|
156
171
|
var appliers = items.map(function (item) {
|
|
157
172
|
return getFilterCallbackFromItem(item, apiRef);
|
|
@@ -168,7 +183,7 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
|
|
|
168
183
|
for (var i = 0; i < appliers.length; i += 1) {
|
|
169
184
|
var applier = appliers[i];
|
|
170
185
|
if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
|
|
171
|
-
resultPerItemId[applier.item.id] = applier.v7 ? applier.fn(row) : applier.fn(getRowId
|
|
186
|
+
resultPerItemId[applier.item.id] = applier.v7 ? applier.fn(row) : applier.fn(apiRef.current.getRowId(row));
|
|
172
187
|
}
|
|
173
188
|
}
|
|
174
189
|
return resultPerItemId;
|
|
@@ -180,11 +195,11 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
|
|
|
180
195
|
var filterItemTemplate = "(function filterItem$$(getRowId, appliers, row, shouldApplyFilter) {\n ".concat(appliers.map(function (applier, i) {
|
|
181
196
|
return "const shouldApply".concat(i, " = !shouldApplyFilter || shouldApplyFilter(").concat(JSON.stringify(applier.item.field), ");");
|
|
182
197
|
}).join('\n'), "\n\n const result$$ = {\n ").concat(appliers.map(function (applier, i) {
|
|
183
|
-
return "".concat(JSON.stringify(String(applier.item.id)), ":\n !shouldApply").concat(i, " ?\n false :\n ").concat(applier.v7 ? "appliers[".concat(i, "].fn(row)") : "appliers[".concat(i, "].fn(
|
|
198
|
+
return "".concat(JSON.stringify(String(applier.item.id)), ":\n !shouldApply").concat(i, " ?\n false :\n ").concat(applier.v7 ? "appliers[".concat(i, "].fn(row)") : "appliers[".concat(i, "].fn(getRowId(row))"), ",\n ");
|
|
184
199
|
}).join('\n'), "};\n\n return result$$;\n })");
|
|
185
200
|
var filterItemCore = evalCode(filterItemTemplate.replaceAll('$$', String(filterItemsApplierId)));
|
|
186
201
|
var filterItem = function filterItem(row, shouldApplyItem) {
|
|
187
|
-
return filterItemCore(getRowId, appliers, row, shouldApplyItem);
|
|
202
|
+
return filterItemCore(apiRef.current.getRowId, appliers, row, shouldApplyItem);
|
|
188
203
|
};
|
|
189
204
|
filterItemsApplierId += 1;
|
|
190
205
|
return filterItem;
|
|
@@ -192,12 +207,11 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
|
|
|
192
207
|
|
|
193
208
|
/**
|
|
194
209
|
* Generates a method to easily check if a row is matching the current quick filter.
|
|
195
|
-
* @param {GridRowIdGetter | undefined} getRowId The getter for row's id.
|
|
196
210
|
* @param {any[]} filterModel The model with which we want to filter the rows.
|
|
197
|
-
* @param {React.MutableRefObject<
|
|
211
|
+
* @param {React.MutableRefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
|
|
198
212
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
199
213
|
*/
|
|
200
|
-
|
|
214
|
+
var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilterApplier(filterModel, apiRef) {
|
|
201
215
|
var _filterModel$quickFil, _filterModel$quickFil2, _filterModel$quickFil3;
|
|
202
216
|
var quickFilterValues = (_filterModel$quickFil = (_filterModel$quickFil2 = filterModel.quickFilterValues) == null ? void 0 : _filterModel$quickFil2.filter(Boolean)) != null ? _filterModel$quickFil : [];
|
|
203
217
|
if (quickFilterValues.length === 0) {
|
|
@@ -206,6 +220,7 @@ export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilt
|
|
|
206
220
|
var quickFilterExcludeHiddenColumns = (_filterModel$quickFil3 = filterModel.quickFilterExcludeHiddenColumns) != null ? _filterModel$quickFil3 : false;
|
|
207
221
|
var columnFields = quickFilterExcludeHiddenColumns ? gridVisibleColumnFieldsSelector(apiRef) : gridColumnFieldsSelector(apiRef);
|
|
208
222
|
var appliersPerField = [];
|
|
223
|
+
var ignoreDiacritics = apiRef.current.rootProps.ignoreDiacritics;
|
|
209
224
|
columnFields.forEach(function (field) {
|
|
210
225
|
var column = apiRef.current.getColumn(field);
|
|
211
226
|
var getApplyQuickFilterFn = column == null ? void 0 : column.getApplyQuickFilterFn;
|
|
@@ -215,7 +230,8 @@ export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilt
|
|
|
215
230
|
if (getApplyQuickFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
|
|
216
231
|
appliersPerField.push({
|
|
217
232
|
column: column,
|
|
218
|
-
appliers: quickFilterValues.map(function (
|
|
233
|
+
appliers: quickFilterValues.map(function (quickFilterValue) {
|
|
234
|
+
var value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
|
|
219
235
|
return {
|
|
220
236
|
v7: true,
|
|
221
237
|
fn: getApplyQuickFilterFnV7(value, column, apiRef)
|
|
@@ -225,7 +241,8 @@ export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilt
|
|
|
225
241
|
} else if (getApplyQuickFilterFn) {
|
|
226
242
|
appliersPerField.push({
|
|
227
243
|
column: column,
|
|
228
|
-
appliers: quickFilterValues.map(function (
|
|
244
|
+
appliers: quickFilterValues.map(function (quickFilterValue) {
|
|
245
|
+
var value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
|
|
229
246
|
return {
|
|
230
247
|
v7: false,
|
|
231
248
|
fn: getApplyQuickFilterFn(value, column, apiRef)
|
|
@@ -250,11 +267,14 @@ export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilt
|
|
|
250
267
|
continue;
|
|
251
268
|
}
|
|
252
269
|
var applier = appliers[v];
|
|
253
|
-
var value = apiRef.current.
|
|
270
|
+
var value = apiRef.current.getRowFormattedValue(row, column);
|
|
254
271
|
if (applier.fn === null) {
|
|
255
272
|
continue;
|
|
256
273
|
}
|
|
257
274
|
if (applier.v7) {
|
|
275
|
+
if (ignoreDiacritics) {
|
|
276
|
+
value = removeDiacritics(value);
|
|
277
|
+
}
|
|
258
278
|
var isMatching = applier.fn(value, row, column, apiRef);
|
|
259
279
|
if (isMatching) {
|
|
260
280
|
result[filterValue] = true;
|
|
@@ -262,7 +282,10 @@ export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilt
|
|
|
262
282
|
}
|
|
263
283
|
} else {
|
|
264
284
|
var _usedCellParams$_fiel;
|
|
265
|
-
var cellParams = (_usedCellParams$_fiel = usedCellParams[_field]) != null ? _usedCellParams$_fiel : apiRef.current.getCellParams(getRowId
|
|
285
|
+
var cellParams = (_usedCellParams$_fiel = usedCellParams[_field]) != null ? _usedCellParams$_fiel : apiRef.current.getCellParams(apiRef.current.getRowId(row), _field);
|
|
286
|
+
if (ignoreDiacritics) {
|
|
287
|
+
cellParams.value = removeDiacritics(cellParams.value);
|
|
288
|
+
}
|
|
266
289
|
usedCellParams[_field] = cellParams;
|
|
267
290
|
var _isMatching = applier.fn(cellParams);
|
|
268
291
|
if (_isMatching) {
|
|
@@ -278,9 +301,9 @@ export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilt
|
|
|
278
301
|
return result;
|
|
279
302
|
};
|
|
280
303
|
};
|
|
281
|
-
export var buildAggregatedFilterApplier = function buildAggregatedFilterApplier(
|
|
282
|
-
var isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(
|
|
283
|
-
var isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(
|
|
304
|
+
export var buildAggregatedFilterApplier = function buildAggregatedFilterApplier(filterModel, apiRef, disableEval) {
|
|
305
|
+
var isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(filterModel, apiRef, disableEval);
|
|
306
|
+
var isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(filterModel, apiRef);
|
|
284
307
|
return function isRowMatchingFilters(row, shouldApplyFilter, result) {
|
|
285
308
|
var _isRowMatchingFilterI, _isRowMatchingQuickFi;
|
|
286
309
|
result.passingFilterItems = (_isRowMatchingFilterI = isRowMatchingFilterItems == null ? void 0 : isRowMatchingFilterItems(row, shouldApplyFilter)) != null ? _isRowMatchingFilterI : null;
|
|
@@ -62,7 +62,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
|
62
62
|
var updateFilteredRows = React.useCallback(function () {
|
|
63
63
|
apiRef.current.setState(function (state) {
|
|
64
64
|
var filterModel = gridFilterModelSelector(state, apiRef.current.instanceId);
|
|
65
|
-
var isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(
|
|
65
|
+
var isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(filterModel, apiRef, props.disableEval) : null;
|
|
66
66
|
var filteringResult = apiRef.current.applyStrategyProcessor('filtering', {
|
|
67
67
|
isRowMatchingFilters: isRowMatchingFilters,
|
|
68
68
|
filterModel: filterModel != null ? filterModel : getDefaultGridFilterModel()
|
|
@@ -76,7 +76,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
78
|
apiRef.current.publishEvent('filteredRowsSet');
|
|
79
|
-
}, [apiRef, props.filterMode, props.
|
|
79
|
+
}, [apiRef, props.filterMode, props.disableEval]);
|
|
80
80
|
var addColumnMenuItem = React.useCallback(function (columnMenuItems, colDef) {
|
|
81
81
|
if (colDef == null || colDef.filterable === false || props.disableColumnFilter) {
|
|
82
82
|
return columnMenuItems;
|
|
@@ -179,8 +179,8 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
|
|
|
179
179
|
hydrateRowsMeta();
|
|
180
180
|
}, [hydrateRowsMeta]);
|
|
181
181
|
var debouncedHydrateRowsMeta = React.useMemo(function () {
|
|
182
|
-
return debounce(hydrateRowsMeta);
|
|
183
|
-
}, [hydrateRowsMeta]);
|
|
182
|
+
return debounce(hydrateRowsMeta, props.rowPositionsDebounceMs);
|
|
183
|
+
}, [hydrateRowsMeta, props.rowPositionsDebounceMs]);
|
|
184
184
|
var storeMeasuredRowHeight = React.useCallback(function (id, height, position) {
|
|
185
185
|
if (!rowsHeightLookup.current[id] || !rowsHeightLookup.current[id].autoHeight) {
|
|
186
186
|
return;
|
|
@@ -501,6 +501,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
501
501
|
rowStyleCache.current = Object.create(null);
|
|
502
502
|
}
|
|
503
503
|
var rows = [];
|
|
504
|
+
var isRowWithFocusedCellRendered = false;
|
|
504
505
|
for (var _i = 0; _i < renderedRows.length; _i += 1) {
|
|
505
506
|
var _currentPage$range5;
|
|
506
507
|
var _renderedRows$_i = renderedRows[_i],
|
|
@@ -533,6 +534,13 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
533
534
|
var style = _extends({}, rowStyle, rootRowStyle);
|
|
534
535
|
rowStyleCache.current[_id] = style;
|
|
535
536
|
}
|
|
537
|
+
var index = rowIndexOffset + ((currentPage == null || (_currentPage$range5 = currentPage.range) == null ? void 0 : _currentPage$range5.firstRowIndex) || 0) + firstRowToRender + _i;
|
|
538
|
+
if (isRowWithFocusedCellNotInRange && (cellFocus == null ? void 0 : cellFocus.id) === _id) {
|
|
539
|
+
index = indexOfRowWithFocusedCell;
|
|
540
|
+
isRowWithFocusedCellRendered = true;
|
|
541
|
+
} else if (isRowWithFocusedCellRendered) {
|
|
542
|
+
index -= 1;
|
|
543
|
+
}
|
|
536
544
|
rows.push( /*#__PURE__*/_jsx(rootProps.slots.row, _extends({
|
|
537
545
|
row: _model,
|
|
538
546
|
rowId: _id,
|
|
@@ -546,7 +554,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
546
554
|
firstColumnToRender: firstColumnToRender,
|
|
547
555
|
lastColumnToRender: lastColumnToRender,
|
|
548
556
|
selected: isSelected,
|
|
549
|
-
index:
|
|
557
|
+
index: index,
|
|
550
558
|
containerWidth: availableSpace,
|
|
551
559
|
isLastVisible: lastVisibleRowIndex,
|
|
552
560
|
position: position
|
package/legacy/index.js
CHANGED
package/legacy/locales/ptBR.js
CHANGED
|
@@ -62,13 +62,12 @@ var ptBRGrid = {
|
|
|
62
62
|
filterOperatorIsEmpty: 'está vazio',
|
|
63
63
|
filterOperatorIsNotEmpty: 'não está vazio',
|
|
64
64
|
filterOperatorIsAnyOf: 'é qualquer um dos',
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
'filterOperator=': 'igual à',
|
|
66
|
+
'filterOperator!=': 'diferente de',
|
|
67
|
+
'filterOperator>': 'maior que',
|
|
68
|
+
'filterOperator>=': 'maior ou igual que',
|
|
69
|
+
'filterOperator<': 'menor que',
|
|
70
|
+
'filterOperator<=': 'menor ou igual que',
|
|
72
71
|
// Header filter operators text
|
|
73
72
|
headerFilterOperatorContains: 'Contém',
|
|
74
73
|
headerFilterOperatorEquals: 'Igual',
|
|
@@ -76,13 +75,13 @@ var ptBRGrid = {
|
|
|
76
75
|
headerFilterOperatorEndsWith: 'Termina com',
|
|
77
76
|
headerFilterOperatorIs: 'É',
|
|
78
77
|
headerFilterOperatorNot: 'Não é',
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
headerFilterOperatorAfter: 'Depois de',
|
|
79
|
+
headerFilterOperatorOnOrAfter: 'Está entre ou depois de',
|
|
80
|
+
headerFilterOperatorBefore: 'Antes de',
|
|
81
|
+
headerFilterOperatorOnOrBefore: 'Está entre ou antes de',
|
|
82
|
+
headerFilterOperatorIsEmpty: 'É vazio',
|
|
83
|
+
headerFilterOperatorIsNotEmpty: 'Não é vazio',
|
|
84
|
+
headerFilterOperatorIsAnyOf: 'É algum',
|
|
86
85
|
'headerFilterOperator=': 'Igual',
|
|
87
86
|
'headerFilterOperator!=': 'Não igual',
|
|
88
87
|
'headerFilterOperator>': 'Maior que',
|
package/legacy/utils/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
2
|
export function isNumber(value) {
|
|
3
|
-
return typeof value === 'number';
|
|
3
|
+
return typeof value === 'number' && !Number.isNaN(value);
|
|
4
4
|
}
|
|
5
5
|
export function isFunction(value) {
|
|
6
6
|
return typeof value === 'function';
|
package/locales/ptBR.js
CHANGED
|
@@ -60,13 +60,12 @@ const ptBRGrid = {
|
|
|
60
60
|
filterOperatorIsEmpty: 'está vazio',
|
|
61
61
|
filterOperatorIsNotEmpty: 'não está vazio',
|
|
62
62
|
filterOperatorIsAnyOf: 'é qualquer um dos',
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
'filterOperator=': 'igual à',
|
|
64
|
+
'filterOperator!=': 'diferente de',
|
|
65
|
+
'filterOperator>': 'maior que',
|
|
66
|
+
'filterOperator>=': 'maior ou igual que',
|
|
67
|
+
'filterOperator<': 'menor que',
|
|
68
|
+
'filterOperator<=': 'menor ou igual que',
|
|
70
69
|
// Header filter operators text
|
|
71
70
|
headerFilterOperatorContains: 'Contém',
|
|
72
71
|
headerFilterOperatorEquals: 'Igual',
|
|
@@ -74,13 +73,13 @@ const ptBRGrid = {
|
|
|
74
73
|
headerFilterOperatorEndsWith: 'Termina com',
|
|
75
74
|
headerFilterOperatorIs: 'É',
|
|
76
75
|
headerFilterOperatorNot: 'Não é',
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
headerFilterOperatorAfter: 'Depois de',
|
|
77
|
+
headerFilterOperatorOnOrAfter: 'Está entre ou depois de',
|
|
78
|
+
headerFilterOperatorBefore: 'Antes de',
|
|
79
|
+
headerFilterOperatorOnOrBefore: 'Está entre ou antes de',
|
|
80
|
+
headerFilterOperatorIsEmpty: 'É vazio',
|
|
81
|
+
headerFilterOperatorIsNotEmpty: 'Não é vazio',
|
|
82
|
+
headerFilterOperatorIsAnyOf: 'É algum',
|
|
84
83
|
'headerFilterOperator=': 'Igual',
|
|
85
84
|
'headerFilterOperator!=': 'Não igual',
|
|
86
85
|
'headerFilterOperator>': 'Maior que',
|
|
@@ -27,9 +27,10 @@ import type { GridStatePersistenceApi } from '../../hooks/features/statePersiste
|
|
|
27
27
|
import { GridColumnGroupingApi } from './gridColumnGroupingApi';
|
|
28
28
|
import type { GridInitialStateCommunity, GridStateCommunity } from '../gridStateCommunity';
|
|
29
29
|
import { GridHeaderFilteringApi, GridHeaderFilteringPrivateApi } from './gridHeaderFilteringApi';
|
|
30
|
+
import type { DataGridProcessedProps } from '../props/DataGridProps';
|
|
30
31
|
export interface GridApiCommon<GridState extends GridStateCommunity = any, GridInitialState extends GridInitialStateCommunity = any> extends GridCoreApi, GridPipeProcessingApi, GridDensityApi, GridDimensionsApi, GridRowApi, GridRowsMetaApi, GridEditingApi, GridParamsApi, GridColumnApi, GridRowSelectionApi, GridSortApi, GridPaginationApi, GridCsvExportApi, GridFocusApi, GridFilterApi, GridColumnMenuApi, GridPreferencesPanelApi, GridPrintExportApi, GridVirtualizationApi, GridLocaleTextApi, GridScrollApi, GridColumnSpanningApi, GridStateApi<GridState>, GridStatePersistenceApi<GridInitialState>, GridColumnGroupingApi, GridHeaderFilteringApi {
|
|
31
32
|
}
|
|
32
|
-
export interface GridPrivateOnlyApiCommon<Api extends GridApiCommon, PrivateApi extends GridPrivateApiCommon> extends GridCorePrivateApi<Api, PrivateApi>, GridStatePrivateApi<PrivateApi['state']>, GridPipeProcessingPrivateApi, GridStrategyProcessingApi, GridColumnSpanningPrivateApi, GridRowsMetaPrivateApi, GridDimensionsPrivateApi, GridEditingPrivateApi, GridLoggerApi, GridFocusPrivateApi, GridHeaderFilteringPrivateApi, GridVirtualizationPrivateApi {
|
|
33
|
+
export interface GridPrivateOnlyApiCommon<Api extends GridApiCommon, PrivateApi extends GridPrivateApiCommon, Props extends DataGridProcessedProps> extends GridCorePrivateApi<Api, PrivateApi, Props>, GridStatePrivateApi<PrivateApi['state']>, GridPipeProcessingPrivateApi, GridStrategyProcessingApi, GridColumnSpanningPrivateApi, GridRowsMetaPrivateApi, GridDimensionsPrivateApi, GridEditingPrivateApi, GridLoggerApi, GridFocusPrivateApi, GridHeaderFilteringPrivateApi, GridVirtualizationPrivateApi {
|
|
33
34
|
}
|
|
34
|
-
export interface GridPrivateApiCommon extends GridApiCommon, GridPrivateOnlyApiCommon<GridApiCommon, GridPrivateApiCommon> {
|
|
35
|
+
export interface GridPrivateApiCommon extends GridApiCommon, GridPrivateOnlyApiCommon<GridApiCommon, GridPrivateApiCommon, DataGridProcessedProps> {
|
|
35
36
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GridInitialStateCommunity, GridStateCommunity } from '../gridStateCommunity';
|
|
2
|
+
import type { DataGridProcessedProps } from '../props/DataGridProps';
|
|
2
3
|
import type { GridApiCommon, GridPrivateOnlyApiCommon } from './gridApiCommon';
|
|
3
4
|
import type { GridColumnReorderApi } from './gridColumnApi';
|
|
4
5
|
import { GridRowProApi } from './gridRowApi';
|
|
@@ -8,5 +9,5 @@ import { GridRowMultiSelectionApi } from './gridRowSelectionApi';
|
|
|
8
9
|
*/
|
|
9
10
|
export interface GridApiCommunity extends GridApiCommon<GridStateCommunity, GridInitialStateCommunity> {
|
|
10
11
|
}
|
|
11
|
-
export interface GridPrivateApiCommunity extends GridApiCommunity, GridPrivateOnlyApiCommon<GridApiCommunity, GridPrivateApiCommunity>, GridRowMultiSelectionApi, GridColumnReorderApi, GridRowProApi {
|
|
12
|
+
export interface GridPrivateApiCommunity extends GridApiCommunity, GridPrivateOnlyApiCommon<GridApiCommunity, GridPrivateApiCommunity, DataGridProcessedProps>, GridRowMultiSelectionApi, GridColumnReorderApi, GridRowProApi {
|
|
12
13
|
}
|
|
@@ -4,6 +4,7 @@ import { Store } from '../../utils/Store';
|
|
|
4
4
|
import { EventManager, EventListenerOptions } from '../../utils/EventManager';
|
|
5
5
|
import { GridApiCaches } from '../gridApiCaches';
|
|
6
6
|
import type { GridApiCommon, GridPrivateApiCommon } from './gridApiCommon';
|
|
7
|
+
import type { DataGridProcessedProps } from '../props/DataGridProps';
|
|
7
8
|
/**
|
|
8
9
|
* The core API interface that is available in the grid `apiRef`.
|
|
9
10
|
*/
|
|
@@ -41,7 +42,7 @@ export interface GridCoreApi {
|
|
|
41
42
|
*/
|
|
42
43
|
store: Store<GridApiCommon['state']>;
|
|
43
44
|
}
|
|
44
|
-
export interface GridCorePrivateApi<GridPublicApi extends GridApiCommon, GridPrivateApi extends GridPrivateApiCommon> {
|
|
45
|
+
export interface GridCorePrivateApi<GridPublicApi extends GridApiCommon, GridPrivateApi extends GridPrivateApiCommon, GridProps extends DataGridProcessedProps> {
|
|
45
46
|
/**
|
|
46
47
|
* The caches used by hooks and state initializers.
|
|
47
48
|
*/
|
|
@@ -71,6 +72,11 @@ export interface GridCorePrivateApi<GridPublicApi extends GridApiCommon, GridPri
|
|
|
71
72
|
* @returns {GridPublicApi} The public api.
|
|
72
73
|
*/
|
|
73
74
|
getPublicApi: () => GridPublicApi;
|
|
75
|
+
/**
|
|
76
|
+
* Allows to access the root props outside of the React component.
|
|
77
|
+
* Do not use in React components - use the `useGridRootProps` hook instead.
|
|
78
|
+
*/
|
|
79
|
+
rootProps: GridProps;
|
|
74
80
|
/**
|
|
75
81
|
* The React ref of the grid column container virtualized div element.
|
|
76
82
|
*/
|
|
@@ -172,7 +172,7 @@ export interface GridCellEditingApi extends GridEditingSharedApi {
|
|
|
172
172
|
startCellEditMode(params: GridStartCellEditModeParams): void;
|
|
173
173
|
/**
|
|
174
174
|
* Puts the cell corresponding to the given row id and field into view mode and updates the original row with the new value stored.
|
|
175
|
-
* If `params.ignoreModifications` is `
|
|
175
|
+
* If `params.ignoreModifications` is `true` it will discard the modifications made.
|
|
176
176
|
* @param {GridStopCellEditModeParams} params The row id and field of the cell to stop editing.
|
|
177
177
|
*/
|
|
178
178
|
stopCellEditMode(params: GridStopCellEditModeParams): void;
|
|
@@ -210,7 +210,7 @@ export interface GridRowEditingApi extends GridEditingSharedApi {
|
|
|
210
210
|
startRowEditMode(params: GridStartRowEditModeParams): void;
|
|
211
211
|
/**
|
|
212
212
|
* Puts the row corresponding to the given id and into view mode and updates the original row with the new values stored.
|
|
213
|
-
* If `params.ignoreModifications` is `
|
|
213
|
+
* If `params.ignoreModifications` is `true` it will discard the modifications made.
|
|
214
214
|
* @param {GridStopCellEditModeParams} params The row id and field of the cell to stop editing.
|
|
215
215
|
*/
|
|
216
216
|
stopRowEditMode(params: GridStopRowEditModeParams): void;
|
|
@@ -48,7 +48,7 @@ export interface GridFilterApi {
|
|
|
48
48
|
*/
|
|
49
49
|
setFilterModel: (model: GridFilterModel, reason?: GridControlledStateReasonLookup['filter']) => void;
|
|
50
50
|
/**
|
|
51
|
-
* Set the quick filter values
|
|
51
|
+
* Set the quick filter values to the one given by `values`
|
|
52
52
|
* @param {any[]} values The list of element to quick filter
|
|
53
53
|
*/
|
|
54
54
|
setQuickFilterValues: (values: any[]) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ComponentsPropsList } from '@mui/material/styles';
|
|
3
|
+
import { GridColDef } from '../colDef';
|
|
3
4
|
/**
|
|
4
5
|
* Set the types of the texts in the grid.
|
|
5
6
|
*/
|
|
@@ -88,8 +89,8 @@ export interface GridLocaleText {
|
|
|
88
89
|
columnMenuFilter: React.ReactNode;
|
|
89
90
|
columnMenuHideColumn: React.ReactNode;
|
|
90
91
|
columnMenuUnsort: React.ReactNode;
|
|
91
|
-
columnMenuSortAsc: React.ReactNode;
|
|
92
|
-
columnMenuSortDesc: React.ReactNode;
|
|
92
|
+
columnMenuSortAsc: React.ReactNode | ((colDef: GridColDef) => React.ReactNode);
|
|
93
|
+
columnMenuSortDesc: React.ReactNode | ((colDef: GridColDef) => React.ReactNode);
|
|
93
94
|
columnHeaderFiltersTooltipActive: (count: number) => React.ReactNode;
|
|
94
95
|
columnHeaderFiltersLabel: string;
|
|
95
96
|
columnHeaderSortIconLabel: string;
|
|
@@ -235,6 +235,12 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
235
235
|
* @default false
|
|
236
236
|
*/
|
|
237
237
|
hideFooterSelectedRowCount: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* If `true`, the diacritics (accents) are ignored when filtering or quick filtering.
|
|
240
|
+
* E.g. when filter value is `cafe`, the rows with `café` will be visible.
|
|
241
|
+
* @default false
|
|
242
|
+
*/
|
|
243
|
+
ignoreDiacritics: boolean;
|
|
238
244
|
/**
|
|
239
245
|
* If `true`, the selection model will retain selected rows that do not exist.
|
|
240
246
|
* Useful when using server side pagination and row selections need to be retained
|
|
@@ -340,6 +346,13 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
340
346
|
* @default '\t'
|
|
341
347
|
*/
|
|
342
348
|
clipboardCopyCellDelimiter: string;
|
|
349
|
+
/**
|
|
350
|
+
* The milliseconds delay to wait after measuring the row height before recalculating row positions.
|
|
351
|
+
* Setting it to a lower value could be useful when using dynamic row height,
|
|
352
|
+
* but might reduce performance when displaying a large number of rows.
|
|
353
|
+
* @default 166
|
|
354
|
+
*/
|
|
355
|
+
rowPositionsDebounceMs: number;
|
|
343
356
|
}
|
|
344
357
|
/**
|
|
345
358
|
* The `DataGrid` props with no default value.
|
|
@@ -278,6 +278,12 @@ DataGridRaw.propTypes = {
|
|
|
278
278
|
* @default false
|
|
279
279
|
*/
|
|
280
280
|
hideFooterSelectedRowCount: PropTypes.bool,
|
|
281
|
+
/**
|
|
282
|
+
* If `true`, the diacritics (accents) are ignored when filtering or quick filtering.
|
|
283
|
+
* E.g. when filter value is `cafe`, the rows with `café` will be visible.
|
|
284
|
+
* @default false
|
|
285
|
+
*/
|
|
286
|
+
ignoreDiacritics: PropTypes.bool,
|
|
281
287
|
/**
|
|
282
288
|
* The initial state of the DataGrid.
|
|
283
289
|
* The data in it will be set in the state on initialization but will not be controlled.
|
|
@@ -596,6 +602,13 @@ DataGridRaw.propTypes = {
|
|
|
596
602
|
* Controls the modes of the rows.
|
|
597
603
|
*/
|
|
598
604
|
rowModesModel: PropTypes.object,
|
|
605
|
+
/**
|
|
606
|
+
* The milliseconds delay to wait after measuring the row height before recalculating row positions.
|
|
607
|
+
* Setting it to a lower value could be useful when using dynamic row height,
|
|
608
|
+
* but might reduce performance when displaying a large number of rows.
|
|
609
|
+
* @default 166
|
|
610
|
+
*/
|
|
611
|
+
rowPositionsDebounceMs: PropTypes.number,
|
|
599
612
|
/**
|
|
600
613
|
* Set of rows of type [[GridRowsProp]].
|
|
601
614
|
*/
|
|
@@ -51,6 +51,7 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
51
51
|
hideFooterPagination: false,
|
|
52
52
|
hideFooterRowCount: false,
|
|
53
53
|
hideFooterSelectedRowCount: false,
|
|
54
|
+
ignoreDiacritics: false,
|
|
54
55
|
logger: console,
|
|
55
56
|
logLevel: process.env.NODE_ENV === 'production' ? 'error' : 'warn',
|
|
56
57
|
pagination: false,
|
|
@@ -68,7 +69,8 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
68
69
|
keepNonExistentRowsSelected: false,
|
|
69
70
|
keepColumnPositionIfDraggedOutside: false,
|
|
70
71
|
unstable_ignoreValueFormatterDuringExport: false,
|
|
71
|
-
clipboardCopyCellDelimiter: '\t'
|
|
72
|
+
clipboardCopyCellDelimiter: '\t',
|
|
73
|
+
rowPositionsDebounceMs: 166
|
|
72
74
|
};
|
|
73
75
|
const defaultSlots = uncapitalizeObjectKeys(DATA_GRID_DEFAULT_SLOTS_COMPONENTS);
|
|
74
76
|
export const useDataGridProps = inProps => {
|
|
@@ -7,8 +7,7 @@ export const getGridStringQuickFilterFn = tagInternalFilter(value => {
|
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
9
|
const filterRegex = new RegExp(escapeRegExp(value), 'i');
|
|
10
|
-
return
|
|
11
|
-
const columnValue = apiRef.current.getRowFormattedValue(row, column);
|
|
10
|
+
return columnValue => {
|
|
12
11
|
return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
|
|
13
12
|
};
|
|
14
13
|
});
|
|
@@ -191,7 +191,8 @@ export const GridRootStyles = styled('div', {
|
|
|
191
191
|
overflow: 'visible !important'
|
|
192
192
|
},
|
|
193
193
|
[`& .${gridClasses.cell} > *`]: {
|
|
194
|
-
overflow: 'visible !important'
|
|
194
|
+
overflow: 'visible !important',
|
|
195
|
+
whiteSpace: 'nowrap'
|
|
195
196
|
}
|
|
196
197
|
},
|
|
197
198
|
[`& .${gridClasses['virtualScrollerContent--overflowed']} .${gridClasses['row--lastVisible']} .${gridClasses.cell}`]: {
|
|
@@ -33,6 +33,10 @@ function GridColumnMenuSortItem(props) {
|
|
|
33
33
|
if (!colDef || !colDef.sortable || !sortingOrder.some(item => !!item)) {
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
|
+
const getLabel = key => {
|
|
37
|
+
const label = apiRef.current.getLocaleText(key);
|
|
38
|
+
return typeof label === 'function' ? label(colDef) : label;
|
|
39
|
+
};
|
|
36
40
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
37
41
|
children: [sortingOrder.includes('asc') && sortDirection !== 'asc' ? /*#__PURE__*/_jsxs(MenuItem, {
|
|
38
42
|
onClick: onSortMenuItemClick,
|
|
@@ -42,7 +46,7 @@ function GridColumnMenuSortItem(props) {
|
|
|
42
46
|
fontSize: "small"
|
|
43
47
|
})
|
|
44
48
|
}), /*#__PURE__*/_jsx(ListItemText, {
|
|
45
|
-
children:
|
|
49
|
+
children: getLabel('columnMenuSortAsc')
|
|
46
50
|
})]
|
|
47
51
|
}) : null, sortingOrder.includes('desc') && sortDirection !== 'desc' ? /*#__PURE__*/_jsxs(MenuItem, {
|
|
48
52
|
onClick: onSortMenuItemClick,
|
|
@@ -52,7 +56,7 @@ function GridColumnMenuSortItem(props) {
|
|
|
52
56
|
fontSize: "small"
|
|
53
57
|
})
|
|
54
58
|
}), /*#__PURE__*/_jsx(ListItemText, {
|
|
55
|
-
children:
|
|
59
|
+
children: getLabel('columnMenuSortDesc')
|
|
56
60
|
})]
|
|
57
61
|
}) : null, sortingOrder.includes(null) && sortDirection != null ? /*#__PURE__*/_jsxs(MenuItem, {
|
|
58
62
|
onClick: onSortMenuItemClick,
|
|
@@ -15,5 +15,8 @@ export const useGridInitialization = (inputApiRef, props) => {
|
|
|
15
15
|
useGridPipeProcessing(privateApiRef);
|
|
16
16
|
useGridStrategyProcessing(privateApiRef);
|
|
17
17
|
useGridLocaleText(privateApiRef, props);
|
|
18
|
+
privateApiRef.current.register('private', {
|
|
19
|
+
rootProps: props
|
|
20
|
+
});
|
|
18
21
|
return privateApiRef;
|
|
19
22
|
};
|