@mui/x-data-grid 5.17.7 → 5.17.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/DataGrid/DataGrid.js +1 -1
  3. package/components/cell/GridActionsCell.js +1 -1
  4. package/components/cell/GridBooleanCell.js +1 -1
  5. package/components/cell/GridEditBooleanCell.js +1 -1
  6. package/components/cell/GridEditDateCell.js +1 -1
  7. package/components/cell/GridEditInputCell.js +1 -1
  8. package/components/cell/GridEditSingleSelectCell.js +1 -1
  9. package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  10. package/components/panel/GridColumnsPanel.d.ts +3 -0
  11. package/components/panel/GridColumnsPanel.js +32 -7
  12. package/hooks/core/useGridApiInitialization.js +2 -0
  13. package/hooks/features/rows/gridRowsState.d.ts +1 -0
  14. package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
  15. package/hooks/features/rows/gridRowsUtils.js +3 -1
  16. package/hooks/features/rows/useGridRows.js +30 -9
  17. package/index.js +1 -1
  18. package/legacy/DataGrid/DataGrid.js +1 -1
  19. package/legacy/components/cell/GridActionsCell.js +1 -1
  20. package/legacy/components/cell/GridBooleanCell.js +1 -1
  21. package/legacy/components/cell/GridEditBooleanCell.js +1 -1
  22. package/legacy/components/cell/GridEditDateCell.js +1 -1
  23. package/legacy/components/cell/GridEditInputCell.js +1 -1
  24. package/legacy/components/cell/GridEditSingleSelectCell.js +1 -1
  25. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  26. package/legacy/components/panel/GridColumnsPanel.js +33 -6
  27. package/legacy/hooks/core/useGridApiInitialization.js +2 -0
  28. package/legacy/hooks/features/rows/gridRowsUtils.js +3 -1
  29. package/legacy/hooks/features/rows/useGridRows.js +32 -9
  30. package/legacy/index.js +1 -1
  31. package/legacy/locales/bgBG.js +1 -1
  32. package/legacy/locales/trTR.js +17 -17
  33. package/legacy/utils/createSelector.js +8 -2
  34. package/locales/bgBG.js +1 -1
  35. package/locales/trTR.js +17 -17
  36. package/modern/DataGrid/DataGrid.js +1 -1
  37. package/modern/components/cell/GridActionsCell.js +1 -1
  38. package/modern/components/cell/GridBooleanCell.js +1 -1
  39. package/modern/components/cell/GridEditBooleanCell.js +1 -1
  40. package/modern/components/cell/GridEditDateCell.js +1 -1
  41. package/modern/components/cell/GridEditInputCell.js +1 -1
  42. package/modern/components/cell/GridEditSingleSelectCell.js +1 -1
  43. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  44. package/modern/components/panel/GridColumnsPanel.js +32 -7
  45. package/modern/hooks/core/useGridApiInitialization.js +2 -0
  46. package/modern/hooks/features/rows/gridRowsUtils.js +3 -1
  47. package/modern/hooks/features/rows/useGridRows.js +30 -9
  48. package/modern/index.js +1 -1
  49. package/modern/locales/bgBG.js +1 -1
  50. package/modern/locales/trTR.js +17 -17
  51. package/modern/utils/createSelector.js +8 -2
  52. package/node/DataGrid/DataGrid.js +1 -1
  53. package/node/components/cell/GridActionsCell.js +1 -1
  54. package/node/components/cell/GridBooleanCell.js +1 -1
  55. package/node/components/cell/GridEditBooleanCell.js +1 -1
  56. package/node/components/cell/GridEditDateCell.js +1 -1
  57. package/node/components/cell/GridEditInputCell.js +1 -1
  58. package/node/components/cell/GridEditSingleSelectCell.js +1 -1
  59. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  60. package/node/components/panel/GridColumnsPanel.js +32 -7
  61. package/node/hooks/core/useGridApiInitialization.js +3 -0
  62. package/node/hooks/features/rows/gridRowsUtils.js +3 -1
  63. package/node/hooks/features/rows/useGridRows.js +30 -9
  64. package/node/index.js +1 -1
  65. package/node/locales/bgBG.js +1 -1
  66. package/node/locales/trTR.js +17 -17
  67. package/node/utils/createSelector.js +8 -2
  68. package/package.json +1 -1
  69. package/utils/createSelector.d.ts +2 -1
  70. package/utils/createSelector.js +8 -2
@@ -16,7 +16,8 @@ export var rowsStateInitializer = function rowsStateInitializer(state, props, ap
16
16
  apiRef.current.unstable_caches.rows = createRowsInternalCache({
17
17
  rows: props.rows,
18
18
  getRowId: props.getRowId,
19
- loading: props.loading
19
+ loading: props.loading,
20
+ rowCount: props.rowCount
20
21
  });
21
22
  return _extends({}, state, {
22
23
  rows: getRowsStateFromCache({
@@ -97,12 +98,16 @@ export var useGridRows = function useGridRows(apiRef, props) {
97
98
 
98
99
  var setRows = React.useCallback(function (rows) {
99
100
  logger.debug("Updating all rows, new length ".concat(rows.length));
100
- throttledRowsChange(createRowsInternalCache({
101
+ var cache = createRowsInternalCache({
101
102
  rows: rows,
102
103
  getRowId: props.getRowId,
103
- loading: props.loading
104
- }), true);
105
- }, [logger, props.getRowId, props.loading, throttledRowsChange]);
104
+ loading: props.loading,
105
+ rowCount: props.rowCount
106
+ });
107
+ var prevCache = apiRef.current.unstable_caches.rows;
108
+ cache.rowsBeforePartialUpdates = prevCache.rowsBeforePartialUpdates;
109
+ throttledRowsChange(cache, true);
110
+ }, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange, apiRef]);
106
111
  var updateRows = React.useCallback(function (updates) {
107
112
  if (props.signature === GridSignature.DataGrid && updates.length > 1) {
108
113
  // TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
@@ -125,6 +130,7 @@ export var useGridRows = function useGridRows(apiRef, props) {
125
130
  var newCache = {
126
131
  rowsBeforePartialUpdates: prevCache.rowsBeforePartialUpdates,
127
132
  loadingPropBeforePartialUpdates: prevCache.loadingPropBeforePartialUpdates,
133
+ rowCountPropBeforePartialUpdates: prevCache.rowCountPropBeforePartialUpdates,
128
134
  idRowsLookup: _extends({}, prevCache.idRowsLookup),
129
135
  idToIdLookup: _extends({}, prevCache.idToIdLookup),
130
136
  ids: _toConsumableArray(prevCache.ids)
@@ -265,6 +271,7 @@ export var useGridRows = function useGridRows(apiRef, props) {
265
271
  })
266
272
  });
267
273
  });
274
+ apiRef.current.unstable_caches.rows.ids = updatedRows;
268
275
  apiRef.current.publishEvent('rowsSet');
269
276
  }, [apiRef, logger]);
270
277
  var replaceRows = React.useCallback(function (firstRowToRender, newRows) {
@@ -363,12 +370,13 @@ export var useGridRows = function useGridRows(apiRef, props) {
363
370
  cache = createRowsInternalCache({
364
371
  rows: props.rows,
365
372
  getRowId: props.getRowId,
366
- loading: props.loading
373
+ loading: props.loading,
374
+ rowCount: props.rowCount
367
375
  });
368
376
  }
369
377
 
370
378
  throttledRowsChange(cache, false);
371
- }, [logger, apiRef, props.rows, props.getRowId, props.loading, throttledRowsChange]);
379
+ }, [logger, apiRef, props.rows, props.getRowId, props.loading, props.rowCount, throttledRowsChange]);
372
380
  var handleStrategyProcessorChange = React.useCallback(function (methodName) {
373
381
  if (methodName === 'rowTreeCreation') {
374
382
  groupRows();
@@ -419,7 +427,8 @@ export var useGridRows = function useGridRows(apiRef, props) {
419
427
  }
420
428
 
421
429
  var areNewRowsAlreadyInState = apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows;
422
- var isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading; // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
430
+ var isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading;
431
+ var isNewRowCountAlreadyInState = apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates === props.rowCount; // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
423
432
 
424
433
  if (areNewRowsAlreadyInState) {
425
434
  // If the loading prop has changed, we need to update its value in the state because it won't be done by `throttledRowsChange`
@@ -435,6 +444,19 @@ export var useGridRows = function useGridRows(apiRef, props) {
435
444
  apiRef.current.forceUpdate();
436
445
  }
437
446
 
447
+ if (!isNewRowCountAlreadyInState) {
448
+ apiRef.current.setState(function (state) {
449
+ return _extends({}, state, {
450
+ rows: _extends({}, state.rows, {
451
+ totalRowCount: Math.max(props.rowCount || 0, state.rows.totalRowCount),
452
+ totalTopLevelRowCount: Math.max(props.rowCount || 0, state.rows.totalTopLevelRowCount)
453
+ })
454
+ });
455
+ });
456
+ apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates = props.rowCount;
457
+ apiRef.current.forceUpdate();
458
+ }
459
+
438
460
  return;
439
461
  }
440
462
 
@@ -442,7 +464,8 @@ export var useGridRows = function useGridRows(apiRef, props) {
442
464
  throttledRowsChange(createRowsInternalCache({
443
465
  rows: props.rows,
444
466
  getRowId: props.getRowId,
445
- loading: props.loading
467
+ loading: props.loading,
468
+ rowCount: props.rowCount
446
469
  }), false);
447
470
  }, [props.rows, props.rowCount, props.getRowId, props.loading, logger, throttledRowsChange, apiRef]);
448
471
  };
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.7
1
+ /** @license MUI v5.17.9
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -86,7 +86,7 @@ var bgBGGrid = {
86
86
  return count !== 1 ? "".concat(count.toLocaleString(), " \u0438\u0437\u0431\u0440\u0430\u043D\u0438 \u0440\u0435\u0434\u043E\u0432\u0435") : "".concat(count.toLocaleString(), " \u0438\u0437\u0431\u0440\u0430\u043D \u0440\u0435\u0434");
87
87
  },
88
88
  // Total row amount footer text
89
- footerTotalRows: 'Общо Rедове:',
89
+ footerTotalRows: 'Общо Редове:',
90
90
  // Total visible row amount footer text
91
91
  footerTotalVisibleRows: function footerTotalVisibleRows(visibleCount, totalCount) {
92
92
  return "".concat(visibleCount.toLocaleString(), " \u043E\u0442 ").concat(totalCount.toLocaleString());
@@ -41,7 +41,7 @@ var trTRGrid = {
41
41
  // Filter panel text
42
42
  filterPanelAddFilter: 'Filtre Ekle',
43
43
  filterPanelDeleteIconLabel: 'Kaldır',
44
- // filterPanelLinkOperator: 'Logic operator',
44
+ filterPanelLinkOperator: 'Mantıksal operatörler',
45
45
  filterPanelOperators: 'Operatör',
46
46
  // TODO v6: rename to filterPanelOperator
47
47
  filterPanelOperatorAnd: 'Ve',
@@ -93,13 +93,13 @@ var trTRGrid = {
93
93
  },
94
94
  // Checkbox selection text
95
95
  checkboxSelectionHeaderName: 'Seçim',
96
- // checkboxSelectionSelectAllRows: 'Select all rows',
97
- // checkboxSelectionUnselectAllRows: 'Unselect all rows',
98
- // checkboxSelectionSelectRow: 'Select row',
99
- // checkboxSelectionUnselectRow: 'Unselect row',
96
+ checkboxSelectionSelectAllRows: 'Tüm satırları seç',
97
+ checkboxSelectionUnselectAllRows: 'Tüm satırların seçimini kaldır',
98
+ checkboxSelectionSelectRow: 'Satırı seç',
99
+ checkboxSelectionUnselectRow: 'Satır seçimini bırak',
100
100
  // Boolean cell text
101
- // booleanCellTrueLabel: 'yes',
102
- // booleanCellFalseLabel: 'no',
101
+ booleanCellTrueLabel: 'Evet',
102
+ booleanCellFalseLabel: 'Hayır',
103
103
  // Actions cell more text
104
104
  actionsCellMore: 'daha fazla',
105
105
  // Column pinning text
@@ -119,17 +119,17 @@ var trTRGrid = {
119
119
  return "".concat(name, " i\xE7in gruplamay\u0131 kald\u0131r");
120
120
  },
121
121
  // Master/detail
122
- // detailPanelToggle: 'Detail panel toggle',
122
+ detailPanelToggle: 'Detay görünümüne geçiş',
123
123
  expandDetailPanel: 'Genişlet',
124
- collapseDetailPanel: 'Gizle' // Row reordering text
125
- // rowReorderingHeaderName: 'Row reordering',
124
+ collapseDetailPanel: 'Gizle',
125
+ // Row reordering text
126
+ rowReorderingHeaderName: 'Satırı yeniden sırala',
126
127
  // Aggregation
127
- // aggregationMenuItemHeader: 'Aggregation',
128
- // aggregationFunctionLabelSum: 'sum',
129
- // aggregationFunctionLabelAvg: 'avg',
130
- // aggregationFunctionLabelMin: 'min',
131
- // aggregationFunctionLabelMax: 'max',
132
- // aggregationFunctionLabelSize: 'size',
133
-
128
+ aggregationMenuItemHeader: 'Toplama',
129
+ aggregationFunctionLabelSum: 'top',
130
+ aggregationFunctionLabelAvg: 'ort',
131
+ aggregationFunctionLabelMin: 'min',
132
+ aggregationFunctionLabelMax: 'maks',
133
+ aggregationFunctionLabelSize: 'boyut'
134
134
  };
135
135
  export var trTR = getGridLocalization(trTRGrid, trTRCore);
@@ -58,6 +58,12 @@ export var createSelector = function createSelector() {
58
58
  return selector;
59
59
  }; // eslint-disable-next-line @typescript-eslint/naming-convention
60
60
 
61
- export var unstable_resetCreateSelectorCache = function unstable_resetCreateSelectorCache() {
62
- cacheContainer.cache = null;
61
+ export var unstable_resetCreateSelectorCache = function unstable_resetCreateSelectorCache(cacheKey) {
62
+ if (typeof cacheKey !== 'undefined') {
63
+ if (cacheContainer.cache && cacheContainer.cache[cacheKey]) {
64
+ delete cacheContainer.cache[cacheKey];
65
+ }
66
+ } else {
67
+ cacheContainer.cache = null;
68
+ }
63
69
  };
package/locales/bgBG.js CHANGED
@@ -80,7 +80,7 @@ const bgBGGrid = {
80
80
  // Rows selected footer text
81
81
  footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} избрани редове` : `${count.toLocaleString()} избран ред`,
82
82
  // Total row amount footer text
83
- footerTotalRows: 'Общо Rедове:',
83
+ footerTotalRows: 'Общо Редове:',
84
84
  // Total visible row amount footer text
85
85
  footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} от ${totalCount.toLocaleString()}`,
86
86
  // Checkbox selection text
package/locales/trTR.js CHANGED
@@ -39,7 +39,7 @@ const trTRGrid = {
39
39
  // Filter panel text
40
40
  filterPanelAddFilter: 'Filtre Ekle',
41
41
  filterPanelDeleteIconLabel: 'Kaldır',
42
- // filterPanelLinkOperator: 'Logic operator',
42
+ filterPanelLinkOperator: 'Mantıksal operatörler',
43
43
  filterPanelOperators: 'Operatör',
44
44
  // TODO v6: rename to filterPanelOperator
45
45
  filterPanelOperatorAnd: 'Ve',
@@ -85,13 +85,13 @@ const trTRGrid = {
85
85
  footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} / ${totalCount.toLocaleString()}`,
86
86
  // Checkbox selection text
87
87
  checkboxSelectionHeaderName: 'Seçim',
88
- // checkboxSelectionSelectAllRows: 'Select all rows',
89
- // checkboxSelectionUnselectAllRows: 'Unselect all rows',
90
- // checkboxSelectionSelectRow: 'Select row',
91
- // checkboxSelectionUnselectRow: 'Unselect row',
88
+ checkboxSelectionSelectAllRows: 'Tüm satırları seç',
89
+ checkboxSelectionUnselectAllRows: 'Tüm satırların seçimini kaldır',
90
+ checkboxSelectionSelectRow: 'Satırı seç',
91
+ checkboxSelectionUnselectRow: 'Satır seçimini bırak',
92
92
  // Boolean cell text
93
- // booleanCellTrueLabel: 'yes',
94
- // booleanCellFalseLabel: 'no',
93
+ booleanCellTrueLabel: 'Evet',
94
+ booleanCellFalseLabel: 'Hayır',
95
95
  // Actions cell more text
96
96
  actionsCellMore: 'daha fazla',
97
97
  // Column pinning text
@@ -107,17 +107,17 @@ const trTRGrid = {
107
107
  groupColumn: name => `${name} için grupla`,
108
108
  unGroupColumn: name => `${name} için gruplamayı kaldır`,
109
109
  // Master/detail
110
- // detailPanelToggle: 'Detail panel toggle',
110
+ detailPanelToggle: 'Detay görünümüne geçiş',
111
111
  expandDetailPanel: 'Genişlet',
112
- collapseDetailPanel: 'Gizle' // Row reordering text
113
- // rowReorderingHeaderName: 'Row reordering',
112
+ collapseDetailPanel: 'Gizle',
113
+ // Row reordering text
114
+ rowReorderingHeaderName: 'Satırı yeniden sırala',
114
115
  // Aggregation
115
- // aggregationMenuItemHeader: 'Aggregation',
116
- // aggregationFunctionLabelSum: 'sum',
117
- // aggregationFunctionLabelAvg: 'avg',
118
- // aggregationFunctionLabelMin: 'min',
119
- // aggregationFunctionLabelMax: 'max',
120
- // aggregationFunctionLabelSize: 'size',
121
-
116
+ aggregationMenuItemHeader: 'Toplama',
117
+ aggregationFunctionLabelSum: 'top',
118
+ aggregationFunctionLabelAvg: 'ort',
119
+ aggregationFunctionLabelMin: 'min',
120
+ aggregationFunctionLabelMax: 'maks',
121
+ aggregationFunctionLabelSize: 'boyut'
122
122
  };
123
123
  export const trTR = getGridLocalization(trTRGrid, trTRCore);
@@ -721,7 +721,7 @@ DataGridRaw.propTypes = {
721
721
  /**
722
722
  * Set of rows of type [[GridRowsProp]].
723
723
  */
724
- rows: PropTypes.array.isRequired,
724
+ rows: PropTypes.arrayOf(PropTypes.object).isRequired,
725
725
 
726
726
  /**
727
727
  * Sets the type of space between rows added by `getRowSpacing`.
@@ -261,7 +261,7 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
261
261
  /**
262
262
  * The row model of the row that the current cell belongs to.
263
263
  */
264
- row: PropTypes.object.isRequired,
264
+ row: PropTypes.any.isRequired,
265
265
 
266
266
  /**
267
267
  * The node of the row that the current cell belongs to.
@@ -110,7 +110,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
110
110
  /**
111
111
  * The row model of the row that the current cell belongs to.
112
112
  */
113
- row: PropTypes.object.isRequired,
113
+ row: PropTypes.any.isRequired,
114
114
 
115
115
  /**
116
116
  * The node of the row that the current cell belongs to.
@@ -147,7 +147,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
147
147
  /**
148
148
  * The row model of the row that the current cell belongs to.
149
149
  */
150
- row: PropTypes.object.isRequired,
150
+ row: PropTypes.any.isRequired,
151
151
 
152
152
  /**
153
153
  * The node of the row that the current cell belongs to.
@@ -201,7 +201,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
201
201
  /**
202
202
  * The row model of the row that the current cell belongs to.
203
203
  */
204
- row: PropTypes.object.isRequired,
204
+ row: PropTypes.any.isRequired,
205
205
 
206
206
  /**
207
207
  * The node of the row that the current cell belongs to.
@@ -175,7 +175,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
175
175
  /**
176
176
  * The row model of the row that the current cell belongs to.
177
177
  */
178
- row: PropTypes.object,
178
+ row: PropTypes.any,
179
179
 
180
180
  /**
181
181
  * The node of the row that the current cell belongs to.
@@ -246,7 +246,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
246
246
  /**
247
247
  * The row model of the row that the current cell belongs to.
248
248
  */
249
- row: PropTypes.object.isRequired,
249
+ row: PropTypes.any.isRequired,
250
250
 
251
251
  /**
252
252
  * The node of the row that the current cell belongs to.
@@ -170,7 +170,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
170
170
  /**
171
171
  * The row model of the row that the current cell belongs to.
172
172
  */
173
- row: PropTypes.object.isRequired,
173
+ row: PropTypes.any.isRequired,
174
174
 
175
175
  /**
176
176
  * The node of the row that the current cell belongs to.
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["sort"];
3
+ const _excluded = ["sort", "searchPredicate", "autoFocusSearchField"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { unstable_composeClasses as composeClasses } from '@mui/material';
@@ -59,6 +59,10 @@ const GridIconButtonRoot = styled(IconButton)({
59
59
  });
60
60
  const collator = new Intl.Collator();
61
61
 
62
+ const defaultSearchPredicate = (column, searchValue) => {
63
+ return (column.headerName || column.field).toLowerCase().indexOf(searchValue) > -1;
64
+ };
65
+
62
66
  function GridColumnsPanel(props) {
63
67
  const apiRef = useGridApiContext();
64
68
  const searchInputRef = React.useRef(null);
@@ -72,7 +76,9 @@ function GridColumnsPanel(props) {
72
76
  const classes = useUtilityClasses(ownerState);
73
77
 
74
78
  const {
75
- sort
79
+ sort,
80
+ searchPredicate = defaultSearchPredicate,
81
+ autoFocusSearchField = true
76
82
  } = props,
77
83
  other = _objectWithoutPropertiesLoose(props, _excluded);
78
84
 
@@ -126,11 +132,27 @@ function GridColumnsPanel(props) {
126
132
  }
127
133
 
128
134
  const searchValueToCheck = searchValue.toLowerCase();
129
- return sortedColumns.filter(column => (column.headerName || column.field).toLowerCase().indexOf(searchValueToCheck) > -1);
130
- }, [sortedColumns, searchValue]);
135
+ return sortedColumns.filter(column => searchPredicate(column, searchValueToCheck));
136
+ }, [sortedColumns, searchValue, searchPredicate]);
137
+ const firstSwitchRef = React.useRef(null);
131
138
  React.useEffect(() => {
132
- searchInputRef.current.focus();
133
- }, []);
139
+ if (autoFocusSearchField) {
140
+ searchInputRef.current.focus();
141
+ } else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
142
+ firstSwitchRef.current.focus();
143
+ }
144
+ }, [autoFocusSearchField]);
145
+ let firstHideableColumnFound = false;
146
+
147
+ const isFirstHideableColumn = column => {
148
+ if (firstHideableColumnFound === false && column.hideable !== false) {
149
+ firstHideableColumnFound = true;
150
+ return true;
151
+ }
152
+
153
+ return false;
154
+ };
155
+
134
156
  return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
135
157
  children: [/*#__PURE__*/_jsx(GridPanelHeader, {
136
158
  children: /*#__PURE__*/_jsx(rootProps.components.BaseTextField, _extends({
@@ -153,7 +175,8 @@ function GridColumnsPanel(props) {
153
175
  checked: columnVisibilityModel[column.field] !== false,
154
176
  onClick: toggleColumn,
155
177
  name: column.field,
156
- size: "small"
178
+ size: "small",
179
+ inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
157
180
  }, rootProps.componentsProps?.baseSwitch)),
158
181
  label: column.headerName || column.field
159
182
  }), !rootProps.disableColumnReorder && GRID_EXPERIMENTAL_ENABLED && /*#__PURE__*/_jsx(GridIconButtonRoot, {
@@ -185,6 +208,8 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
185
208
  // | These PropTypes are generated from the TypeScript type definitions |
186
209
  // | To update them edit the TypeScript types and run "yarn proptypes" |
187
210
  // ----------------------------------------------------------------------
211
+ autoFocusSearchField: PropTypes.bool,
212
+ searchPredicate: PropTypes.func,
188
213
  sort: PropTypes.oneOf(['asc', 'desc'])
189
214
  } : void 0;
190
215
  export { GridColumnsPanel };
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { useGridApiMethod } from '../utils/useGridApiMethod';
3
3
  import { GridSignature } from '../utils/useGridApiEventHandler';
4
4
  import { EventManager } from '../../utils/EventManager';
5
+ import { unstable_resetCreateSelectorCache } from '../../utils/createSelector';
5
6
 
6
7
  const isSyntheticEvent = event => {
7
8
  return event.isPropagationStopped !== undefined;
@@ -53,6 +54,7 @@ export function useGridApiInitialization(inputApiRef, props) {
53
54
  React.useEffect(() => {
54
55
  const api = apiRef.current;
55
56
  return () => {
57
+ unstable_resetCreateSelectorCache(api.instanceId);
56
58
  api.publishEvent('unmount');
57
59
  };
58
60
  }, [apiRef]);
@@ -22,11 +22,13 @@ export const getRowIdFromRowModel = (rowModel, getRowId, detailErrorMessage) =>
22
22
  export const createRowsInternalCache = ({
23
23
  rows,
24
24
  getRowId,
25
- loading
25
+ loading,
26
+ rowCount
26
27
  }) => {
27
28
  const cache = {
28
29
  rowsBeforePartialUpdates: rows,
29
30
  loadingPropBeforePartialUpdates: loading,
31
+ rowCountPropBeforePartialUpdates: rowCount,
30
32
  idRowsLookup: {},
31
33
  idToIdLookup: {},
32
34
  ids: []
@@ -13,7 +13,8 @@ export const rowsStateInitializer = (state, props, apiRef) => {
13
13
  apiRef.current.unstable_caches.rows = createRowsInternalCache({
14
14
  rows: props.rows,
15
15
  getRowId: props.getRowId,
16
- loading: props.loading
16
+ loading: props.loading,
17
+ rowCount: props.rowCount
17
18
  });
18
19
  return _extends({}, state, {
19
20
  rows: getRowsStateFromCache({
@@ -87,12 +88,16 @@ export const useGridRows = (apiRef, props) => {
87
88
 
88
89
  const setRows = React.useCallback(rows => {
89
90
  logger.debug(`Updating all rows, new length ${rows.length}`);
90
- throttledRowsChange(createRowsInternalCache({
91
+ const cache = createRowsInternalCache({
91
92
  rows,
92
93
  getRowId: props.getRowId,
93
- loading: props.loading
94
- }), true);
95
- }, [logger, props.getRowId, props.loading, throttledRowsChange]);
94
+ loading: props.loading,
95
+ rowCount: props.rowCount
96
+ });
97
+ const prevCache = apiRef.current.unstable_caches.rows;
98
+ cache.rowsBeforePartialUpdates = prevCache.rowsBeforePartialUpdates;
99
+ throttledRowsChange(cache, true);
100
+ }, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange, apiRef]);
96
101
  const updateRows = React.useCallback(updates => {
97
102
  if (props.signature === GridSignature.DataGrid && updates.length > 1) {
98
103
  // TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
@@ -115,6 +120,7 @@ export const useGridRows = (apiRef, props) => {
115
120
  const newCache = {
116
121
  rowsBeforePartialUpdates: prevCache.rowsBeforePartialUpdates,
117
122
  loadingPropBeforePartialUpdates: prevCache.loadingPropBeforePartialUpdates,
123
+ rowCountPropBeforePartialUpdates: prevCache.rowCountPropBeforePartialUpdates,
118
124
  idRowsLookup: _extends({}, prevCache.idRowsLookup),
119
125
  idToIdLookup: _extends({}, prevCache.idToIdLookup),
120
126
  ids: [...prevCache.ids]
@@ -233,6 +239,7 @@ export const useGridRows = (apiRef, props) => {
233
239
  ids: updatedRows
234
240
  })
235
241
  }));
242
+ apiRef.current.unstable_caches.rows.ids = updatedRows;
236
243
  apiRef.current.publishEvent('rowsSet');
237
244
  }, [apiRef, logger]);
238
245
  const replaceRows = React.useCallback((firstRowToRender, newRows) => {
@@ -324,12 +331,13 @@ export const useGridRows = (apiRef, props) => {
324
331
  cache = createRowsInternalCache({
325
332
  rows: props.rows,
326
333
  getRowId: props.getRowId,
327
- loading: props.loading
334
+ loading: props.loading,
335
+ rowCount: props.rowCount
328
336
  });
329
337
  }
330
338
 
331
339
  throttledRowsChange(cache, false);
332
- }, [logger, apiRef, props.rows, props.getRowId, props.loading, throttledRowsChange]);
340
+ }, [logger, apiRef, props.rows, props.getRowId, props.loading, props.rowCount, throttledRowsChange]);
333
341
  const handleStrategyProcessorChange = React.useCallback(methodName => {
334
342
  if (methodName === 'rowTreeCreation') {
335
343
  groupRows();
@@ -378,7 +386,8 @@ export const useGridRows = (apiRef, props) => {
378
386
  }
379
387
 
380
388
  const areNewRowsAlreadyInState = apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows;
381
- const isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading; // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
389
+ const isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading;
390
+ const isNewRowCountAlreadyInState = apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates === props.rowCount; // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
382
391
 
383
392
  if (areNewRowsAlreadyInState) {
384
393
  // If the loading prop has changed, we need to update its value in the state because it won't be done by `throttledRowsChange`
@@ -392,6 +401,17 @@ export const useGridRows = (apiRef, props) => {
392
401
  apiRef.current.forceUpdate();
393
402
  }
394
403
 
404
+ if (!isNewRowCountAlreadyInState) {
405
+ apiRef.current.setState(state => _extends({}, state, {
406
+ rows: _extends({}, state.rows, {
407
+ totalRowCount: Math.max(props.rowCount || 0, state.rows.totalRowCount),
408
+ totalTopLevelRowCount: Math.max(props.rowCount || 0, state.rows.totalTopLevelRowCount)
409
+ })
410
+ }));
411
+ apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates = props.rowCount;
412
+ apiRef.current.forceUpdate();
413
+ }
414
+
395
415
  return;
396
416
  }
397
417
 
@@ -399,7 +419,8 @@ export const useGridRows = (apiRef, props) => {
399
419
  throttledRowsChange(createRowsInternalCache({
400
420
  rows: props.rows,
401
421
  getRowId: props.getRowId,
402
- loading: props.loading
422
+ loading: props.loading,
423
+ rowCount: props.rowCount
403
424
  }), false);
404
425
  }, [props.rows, props.rowCount, props.getRowId, props.loading, logger, throttledRowsChange, apiRef]);
405
426
  };
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.7
1
+ /** @license MUI v5.17.9
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -80,7 +80,7 @@ const bgBGGrid = {
80
80
  // Rows selected footer text
81
81
  footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} избрани редове` : `${count.toLocaleString()} избран ред`,
82
82
  // Total row amount footer text
83
- footerTotalRows: 'Общо Rедове:',
83
+ footerTotalRows: 'Общо Редове:',
84
84
  // Total visible row amount footer text
85
85
  footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} от ${totalCount.toLocaleString()}`,
86
86
  // Checkbox selection text
@@ -39,7 +39,7 @@ const trTRGrid = {
39
39
  // Filter panel text
40
40
  filterPanelAddFilter: 'Filtre Ekle',
41
41
  filterPanelDeleteIconLabel: 'Kaldır',
42
- // filterPanelLinkOperator: 'Logic operator',
42
+ filterPanelLinkOperator: 'Mantıksal operatörler',
43
43
  filterPanelOperators: 'Operatör',
44
44
  // TODO v6: rename to filterPanelOperator
45
45
  filterPanelOperatorAnd: 'Ve',
@@ -85,13 +85,13 @@ const trTRGrid = {
85
85
  footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} / ${totalCount.toLocaleString()}`,
86
86
  // Checkbox selection text
87
87
  checkboxSelectionHeaderName: 'Seçim',
88
- // checkboxSelectionSelectAllRows: 'Select all rows',
89
- // checkboxSelectionUnselectAllRows: 'Unselect all rows',
90
- // checkboxSelectionSelectRow: 'Select row',
91
- // checkboxSelectionUnselectRow: 'Unselect row',
88
+ checkboxSelectionSelectAllRows: 'Tüm satırları seç',
89
+ checkboxSelectionUnselectAllRows: 'Tüm satırların seçimini kaldır',
90
+ checkboxSelectionSelectRow: 'Satırı seç',
91
+ checkboxSelectionUnselectRow: 'Satır seçimini bırak',
92
92
  // Boolean cell text
93
- // booleanCellTrueLabel: 'yes',
94
- // booleanCellFalseLabel: 'no',
93
+ booleanCellTrueLabel: 'Evet',
94
+ booleanCellFalseLabel: 'Hayır',
95
95
  // Actions cell more text
96
96
  actionsCellMore: 'daha fazla',
97
97
  // Column pinning text
@@ -107,17 +107,17 @@ const trTRGrid = {
107
107
  groupColumn: name => `${name} için grupla`,
108
108
  unGroupColumn: name => `${name} için gruplamayı kaldır`,
109
109
  // Master/detail
110
- // detailPanelToggle: 'Detail panel toggle',
110
+ detailPanelToggle: 'Detay görünümüne geçiş',
111
111
  expandDetailPanel: 'Genişlet',
112
- collapseDetailPanel: 'Gizle' // Row reordering text
113
- // rowReorderingHeaderName: 'Row reordering',
112
+ collapseDetailPanel: 'Gizle',
113
+ // Row reordering text
114
+ rowReorderingHeaderName: 'Satırı yeniden sırala',
114
115
  // Aggregation
115
- // aggregationMenuItemHeader: 'Aggregation',
116
- // aggregationFunctionLabelSum: 'sum',
117
- // aggregationFunctionLabelAvg: 'avg',
118
- // aggregationFunctionLabelMin: 'min',
119
- // aggregationFunctionLabelMax: 'max',
120
- // aggregationFunctionLabelSize: 'size',
121
-
116
+ aggregationMenuItemHeader: 'Toplama',
117
+ aggregationFunctionLabelSum: 'top',
118
+ aggregationFunctionLabelAvg: 'ort',
119
+ aggregationFunctionLabelMin: 'min',
120
+ aggregationFunctionLabelMax: 'maks',
121
+ aggregationFunctionLabelSize: 'boyut'
122
122
  };
123
123
  export const trTR = getGridLocalization(trTRGrid, trTRCore);
@@ -51,6 +51,12 @@ export const createSelector = (...args) => {
51
51
  return selector;
52
52
  }; // eslint-disable-next-line @typescript-eslint/naming-convention
53
53
 
54
- export const unstable_resetCreateSelectorCache = () => {
55
- cacheContainer.cache = null;
54
+ export const unstable_resetCreateSelectorCache = cacheKey => {
55
+ if (typeof cacheKey !== 'undefined') {
56
+ if (cacheContainer.cache && cacheContainer.cache[cacheKey]) {
57
+ delete cacheContainer.cache[cacheKey];
58
+ }
59
+ } else {
60
+ cacheContainer.cache = null;
61
+ }
56
62
  };