@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
package/CHANGELOG.md CHANGED
@@ -3,6 +3,73 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 5.17.9
7
+
8
+ _Oct 28, 2022_
9
+
10
+ We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - ⚡ Fix memory leak during unmount of the DataGrid (#6579) @cherniavskii
13
+ - 🎁 Allow to disable the autofocus of the search field when opening the column visibility panel (#6630) @e-cloud
14
+ - 🐞 Bugfixes
15
+
16
+ ### `@mui/x-data-grid@v5.17.9` / `@mui/x-data-grid-pro@v5.17.9` / `@mui/x-data-grid-premium@v5.17.9`
17
+
18
+ #### Changes
19
+
20
+ - [DataGrid] Allow to disable autofocusing the search field in the columns panel (#6630) @e-cloud
21
+ - [DataGrid] Fix `setRows` method not persisting new rows data after `loading` prop change (#6637) @cherniavskii
22
+ - [DataGrid] Fix memory leak on grid unmount (#6579) @cherniavskii
23
+ - [l10n] Improve Bulgarian (bg-BG) locale (#6635) @AtanasVA
24
+
25
+ ### `@mui/x-date-pickers@v5.0.6` / `@mui/x-date-pickers-pro@v5.0.6`
26
+
27
+ #### Changes
28
+
29
+ - [pickers] Ignore milliseconds in mask logic (#6618) @alexfauquette
30
+ - [pickers] Update input when `inputFormat` is modified (#6617) @alexfauquette
31
+
32
+ ### Docs
33
+
34
+ - [docs] Add token to redirect feedbacks on slack (#6592) @alexfauquette
35
+ - [docs] Disable translations (#6639) @cherniavskii
36
+ - [docs] Fix code edit for when v6 will be stable (#6600) @oliviertassinari
37
+ - [docs] Fix typo in DataGrid demo page (#6632) (#6634) @LukasTy
38
+
39
+ ### Core
40
+
41
+ - [core] Upgrade monorepo (#6570) @cherniavskii
42
+
43
+ ## 5.17.8
44
+
45
+ _Oct 20, 2022_
46
+
47
+ We'd like to offer a big thanks to the 5 contributors who made this release possible. Here are some highlights ✨:
48
+
49
+ - 🐞 Bugfixes
50
+ - 🌍 Improve Turkish (tr-TR) locale on the data grid and pickers (#6573) @ramazansancar
51
+
52
+ ### `@mui/x-data-grid@v5.17.8` / `@mui/x-data-grid-pro@v5.17.8` / `@mui/x-data-grid-premium@v5.17.8`
53
+
54
+ #### Changes
55
+
56
+ - [DataGrid] Add `searchPredicate` prop to `GridColumnsPanel` component (#6572) @cherniavskii
57
+ - [DataGrid] Fix grid not updating state on `rowCount` prop change (#6474) @cherniavskii
58
+ - [DataGridPro] Fix row order being reset after updating the row (#6544) @cherniavskii
59
+ - [l10n] Improve Turkish (tr-TR) locale on the data grid and pickers (#6542) (#6573) @ramazansancar
60
+
61
+ ### `@mui/x-date-pickers@v5.0.5` / `@mui/x-date-pickers-pro@v5.0.5`
62
+
63
+ #### Changes
64
+
65
+ - [CalendarPicker] Don't move to closest enabled date when `props.date` contains a disabled date (#6537) @flaviendelangle
66
+ - [DateRangePicker] Fix calendar day outside of month layout shifting on hover (pick #6448) (#6538) @alexfauquette
67
+ - [pickers] Fix typescript issues (#6510) @flaviendelangle
68
+
69
+ ### Docs
70
+
71
+ - [docs] Fix 301 link to the sx prop page @oliviertassinari
72
+
6
73
  ## 5.17.7
7
74
 
8
75
  _Oct 13, 2022_
@@ -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.
@@ -149,7 +149,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
149
149
  /**
150
150
  * The row model of the row that the current cell belongs to.
151
151
  */
152
- row: PropTypes.object.isRequired,
152
+ row: PropTypes.any.isRequired,
153
153
 
154
154
  /**
155
155
  * The node of the row that the current cell belongs to.
@@ -203,7 +203,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
203
203
  /**
204
204
  * The row model of the row that the current cell belongs to.
205
205
  */
206
- row: PropTypes.object.isRequired,
206
+ row: PropTypes.any.isRequired,
207
207
 
208
208
  /**
209
209
  * The node of the row that the current cell belongs to.
@@ -179,7 +179,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
179
179
  /**
180
180
  * The row model of the row that the current cell belongs to.
181
181
  */
182
- row: PropTypes.object,
182
+ row: PropTypes.any,
183
183
 
184
184
  /**
185
185
  * The node of the row that the current cell belongs to.
@@ -252,7 +252,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
252
252
  /**
253
253
  * The row model of the row that the current cell belongs to.
254
254
  */
255
- row: PropTypes.object.isRequired,
255
+ row: PropTypes.any.isRequired,
256
256
 
257
257
  /**
258
258
  * The node of the row that the current cell belongs to.
@@ -174,7 +174,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
174
174
  /**
175
175
  * The row model of the row that the current cell belongs to.
176
176
  */
177
- row: PropTypes.object.isRequired,
177
+ row: PropTypes.any.isRequired,
178
178
 
179
179
  /**
180
180
  * The node of the row that the current cell belongs to.
@@ -1,7 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { GridPanelWrapperProps } from './GridPanelWrapper';
3
+ import type { GridStateColDef } from '../../models/colDef/gridColDef';
3
4
  export interface GridColumnsPanelProps extends GridPanelWrapperProps {
4
5
  sort?: 'asc' | 'desc';
6
+ searchPredicate?: (column: GridStateColDef, searchValue: string) => boolean;
7
+ autoFocusSearchField?: boolean;
5
8
  }
6
9
  declare function GridColumnsPanel(props: GridColumnsPanelProps): JSX.Element;
7
10
  declare namespace GridColumnsPanel {
@@ -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
  var _rootProps$components, _rootProps$components3, _rootProps$components4;
64
68
 
@@ -74,7 +78,9 @@ function GridColumnsPanel(props) {
74
78
  const classes = useUtilityClasses(ownerState);
75
79
 
76
80
  const {
77
- sort
81
+ sort,
82
+ searchPredicate = defaultSearchPredicate,
83
+ autoFocusSearchField = true
78
84
  } = props,
79
85
  other = _objectWithoutPropertiesLoose(props, _excluded);
80
86
 
@@ -128,11 +134,27 @@ function GridColumnsPanel(props) {
128
134
  }
129
135
 
130
136
  const searchValueToCheck = searchValue.toLowerCase();
131
- return sortedColumns.filter(column => (column.headerName || column.field).toLowerCase().indexOf(searchValueToCheck) > -1);
132
- }, [sortedColumns, searchValue]);
137
+ return sortedColumns.filter(column => searchPredicate(column, searchValueToCheck));
138
+ }, [sortedColumns, searchValue, searchPredicate]);
139
+ const firstSwitchRef = React.useRef(null);
133
140
  React.useEffect(() => {
134
- searchInputRef.current.focus();
135
- }, []);
141
+ if (autoFocusSearchField) {
142
+ searchInputRef.current.focus();
143
+ } else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
144
+ firstSwitchRef.current.focus();
145
+ }
146
+ }, [autoFocusSearchField]);
147
+ let firstHideableColumnFound = false;
148
+
149
+ const isFirstHideableColumn = column => {
150
+ if (firstHideableColumnFound === false && column.hideable !== false) {
151
+ firstHideableColumnFound = true;
152
+ return true;
153
+ }
154
+
155
+ return false;
156
+ };
157
+
136
158
  return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
137
159
  children: [/*#__PURE__*/_jsx(GridPanelHeader, {
138
160
  children: /*#__PURE__*/_jsx(rootProps.components.BaseTextField, _extends({
@@ -158,7 +180,8 @@ function GridColumnsPanel(props) {
158
180
  checked: columnVisibilityModel[column.field] !== false,
159
181
  onClick: toggleColumn,
160
182
  name: column.field,
161
- size: "small"
183
+ size: "small",
184
+ inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
162
185
  }, (_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.baseSwitch)),
163
186
  label: column.headerName || column.field
164
187
  }), !rootProps.disableColumnReorder && GRID_EXPERIMENTAL_ENABLED && /*#__PURE__*/_jsx(GridIconButtonRoot, {
@@ -191,6 +214,8 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
191
214
  // | These PropTypes are generated from the TypeScript type definitions |
192
215
  // | To update them edit the TypeScript types and run "yarn proptypes" |
193
216
  // ----------------------------------------------------------------------
217
+ autoFocusSearchField: PropTypes.bool,
218
+ searchPredicate: PropTypes.func,
194
219
  sort: PropTypes.oneOf(['asc', 'desc'])
195
220
  } : void 0;
196
221
  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]);
@@ -31,6 +31,7 @@ export interface GridRowsInternalCache extends Omit<GridRowTreeCreationParams, '
31
31
  * The value of the `loading` prop since the last time that the rows state was updated.
32
32
  */
33
33
  loadingPropBeforePartialUpdates: DataGridProcessedProps['loading'];
34
+ rowCountPropBeforePartialUpdates: DataGridProcessedProps['rowCount'];
34
35
  }
35
36
  export interface GridRowsState extends GridRowTreeCreationValue {
36
37
  /**
@@ -11,7 +11,7 @@ import { GridRowsInternalCache, GridRowsState } from './gridRowsState';
11
11
  */
12
12
  export declare function checkGridRowIdIsValid(id: GridRowId, row: GridRowModel | Partial<GridRowModel>, detailErrorMessage?: string): void;
13
13
  export declare const getRowIdFromRowModel: (rowModel: GridRowModel, getRowId?: GridRowIdGetter, detailErrorMessage?: string) => GridRowId;
14
- export declare const createRowsInternalCache: ({ rows, getRowId, loading, }: Pick<DataGridProcessedProps, 'rows' | 'getRowId' | 'loading'>) => GridRowsInternalCache;
14
+ export declare const createRowsInternalCache: ({ rows, getRowId, loading, rowCount, }: Pick<DataGridProcessedProps, 'rows' | 'getRowId' | 'loading' | 'rowCount'>) => GridRowsInternalCache;
15
15
  export declare const getRowsStateFromCache: ({ apiRef, previousTree, rowCountProp, loadingProp, }: {
16
16
  apiRef: React.MutableRefObject<GridApiCommunity>;
17
17
  previousTree: GridRowTreeConfig | null;
@@ -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({
@@ -91,12 +92,16 @@ export const useGridRows = (apiRef, props) => {
91
92
 
92
93
  const setRows = React.useCallback(rows => {
93
94
  logger.debug(`Updating all rows, new length ${rows.length}`);
94
- throttledRowsChange(createRowsInternalCache({
95
+ const cache = createRowsInternalCache({
95
96
  rows,
96
97
  getRowId: props.getRowId,
97
- loading: props.loading
98
- }), true);
99
- }, [logger, props.getRowId, props.loading, throttledRowsChange]);
98
+ loading: props.loading,
99
+ rowCount: props.rowCount
100
+ });
101
+ const prevCache = apiRef.current.unstable_caches.rows;
102
+ cache.rowsBeforePartialUpdates = prevCache.rowsBeforePartialUpdates;
103
+ throttledRowsChange(cache, true);
104
+ }, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange, apiRef]);
100
105
  const updateRows = React.useCallback(updates => {
101
106
  if (props.signature === GridSignature.DataGrid && updates.length > 1) {
102
107
  // TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
@@ -119,6 +124,7 @@ export const useGridRows = (apiRef, props) => {
119
124
  const newCache = {
120
125
  rowsBeforePartialUpdates: prevCache.rowsBeforePartialUpdates,
121
126
  loadingPropBeforePartialUpdates: prevCache.loadingPropBeforePartialUpdates,
127
+ rowCountPropBeforePartialUpdates: prevCache.rowCountPropBeforePartialUpdates,
122
128
  idRowsLookup: _extends({}, prevCache.idRowsLookup),
123
129
  idToIdLookup: _extends({}, prevCache.idToIdLookup),
124
130
  ids: [...prevCache.ids]
@@ -241,6 +247,7 @@ export const useGridRows = (apiRef, props) => {
241
247
  ids: updatedRows
242
248
  })
243
249
  }));
250
+ apiRef.current.unstable_caches.rows.ids = updatedRows;
244
251
  apiRef.current.publishEvent('rowsSet');
245
252
  }, [apiRef, logger]);
246
253
  const replaceRows = React.useCallback((firstRowToRender, newRows) => {
@@ -332,12 +339,13 @@ export const useGridRows = (apiRef, props) => {
332
339
  cache = createRowsInternalCache({
333
340
  rows: props.rows,
334
341
  getRowId: props.getRowId,
335
- loading: props.loading
342
+ loading: props.loading,
343
+ rowCount: props.rowCount
336
344
  });
337
345
  }
338
346
 
339
347
  throttledRowsChange(cache, false);
340
- }, [logger, apiRef, props.rows, props.getRowId, props.loading, throttledRowsChange]);
348
+ }, [logger, apiRef, props.rows, props.getRowId, props.loading, props.rowCount, throttledRowsChange]);
341
349
  const handleStrategyProcessorChange = React.useCallback(methodName => {
342
350
  if (methodName === 'rowTreeCreation') {
343
351
  groupRows();
@@ -386,7 +394,8 @@ export const useGridRows = (apiRef, props) => {
386
394
  }
387
395
 
388
396
  const areNewRowsAlreadyInState = apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows;
389
- const isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading; // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
397
+ const isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading;
398
+ const isNewRowCountAlreadyInState = apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates === props.rowCount; // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
390
399
 
391
400
  if (areNewRowsAlreadyInState) {
392
401
  // If the loading prop has changed, we need to update its value in the state because it won't be done by `throttledRowsChange`
@@ -400,6 +409,17 @@ export const useGridRows = (apiRef, props) => {
400
409
  apiRef.current.forceUpdate();
401
410
  }
402
411
 
412
+ if (!isNewRowCountAlreadyInState) {
413
+ apiRef.current.setState(state => _extends({}, state, {
414
+ rows: _extends({}, state.rows, {
415
+ totalRowCount: Math.max(props.rowCount || 0, state.rows.totalRowCount),
416
+ totalTopLevelRowCount: Math.max(props.rowCount || 0, state.rows.totalTopLevelRowCount)
417
+ })
418
+ }));
419
+ apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates = props.rowCount;
420
+ apiRef.current.forceUpdate();
421
+ }
422
+
403
423
  return;
404
424
  }
405
425
 
@@ -407,7 +427,8 @@ export const useGridRows = (apiRef, props) => {
407
427
  throttledRowsChange(createRowsInternalCache({
408
428
  rows: props.rows,
409
429
  getRowId: props.getRowId,
410
- loading: props.loading
430
+ loading: props.loading,
431
+ rowCount: props.rowCount
411
432
  }), false);
412
433
  }, [props.rows, props.rowCount, props.getRowId, props.loading, logger, throttledRowsChange, apiRef]);
413
434
  };
package/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.
@@ -723,7 +723,7 @@ DataGridRaw.propTypes = {
723
723
  /**
724
724
  * Set of rows of type [[GridRowsProp]].
725
725
  */
726
- rows: PropTypes.array.isRequired,
726
+ rows: PropTypes.arrayOf(PropTypes.object).isRequired,
727
727
 
728
728
  /**
729
729
  * Sets the type of space between rows added by `getRowSpacing`.
@@ -297,7 +297,7 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
297
297
  /**
298
298
  * The row model of the row that the current cell belongs to.
299
299
  */
300
- row: PropTypes.object.isRequired,
300
+ row: PropTypes.any.isRequired,
301
301
 
302
302
  /**
303
303
  * The node of the row that the current cell belongs to.
@@ -120,7 +120,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
120
120
  /**
121
121
  * The row model of the row that the current cell belongs to.
122
122
  */
123
- row: PropTypes.object.isRequired,
123
+ row: PropTypes.any.isRequired,
124
124
 
125
125
  /**
126
126
  * The node of the row that the current cell belongs to.
@@ -189,7 +189,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
189
189
  /**
190
190
  * The row model of the row that the current cell belongs to.
191
191
  */
192
- row: PropTypes.object.isRequired,
192
+ row: PropTypes.any.isRequired,
193
193
 
194
194
  /**
195
195
  * The node of the row that the current cell belongs to.
@@ -240,7 +240,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
240
240
  /**
241
241
  * The row model of the row that the current cell belongs to.
242
242
  */
243
- row: PropTypes.object.isRequired,
243
+ row: PropTypes.any.isRequired,
244
244
 
245
245
  /**
246
246
  * The node of the row that the current cell belongs to.
@@ -219,7 +219,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
219
219
  /**
220
220
  * The row model of the row that the current cell belongs to.
221
221
  */
222
- row: PropTypes.object,
222
+ row: PropTypes.any,
223
223
 
224
224
  /**
225
225
  * The node of the row that the current cell belongs to.
@@ -309,7 +309,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
309
309
  /**
310
310
  * The row model of the row that the current cell belongs to.
311
311
  */
312
- row: PropTypes.object.isRequired,
312
+ row: PropTypes.any.isRequired,
313
313
 
314
314
  /**
315
315
  * The node of the row that the current cell belongs to.
@@ -177,7 +177,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
177
177
  /**
178
178
  * The row model of the row that the current cell belongs to.
179
179
  */
180
- row: PropTypes.object.isRequired,
180
+ row: PropTypes.any.isRequired,
181
181
 
182
182
  /**
183
183
  * The node of the row that the current cell belongs to.
@@ -3,7 +3,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
4
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
5
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
- var _excluded = ["sort"];
6
+ var _excluded = ["sort", "searchPredicate", "autoFocusSearchField"];
7
7
  import * as React from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import { unstable_composeClasses as composeClasses } from '@mui/material';
@@ -66,6 +66,10 @@ var GridIconButtonRoot = styled(IconButton)({
66
66
  });
67
67
  var collator = new Intl.Collator();
68
68
 
69
+ var defaultSearchPredicate = function defaultSearchPredicate(column, searchValue) {
70
+ return (column.headerName || column.field).toLowerCase().indexOf(searchValue) > -1;
71
+ };
72
+
69
73
  function GridColumnsPanel(props) {
70
74
  var _rootProps$components, _rootProps$components3, _rootProps$components4;
71
75
 
@@ -86,6 +90,10 @@ function GridColumnsPanel(props) {
86
90
  var classes = useUtilityClasses(ownerState);
87
91
 
88
92
  var sort = props.sort,
93
+ _props$searchPredicat = props.searchPredicate,
94
+ searchPredicate = _props$searchPredicat === void 0 ? defaultSearchPredicate : _props$searchPredicat,
95
+ _props$autoFocusSearc = props.autoFocusSearchField,
96
+ autoFocusSearchField = _props$autoFocusSearc === void 0 ? true : _props$autoFocusSearc,
89
97
  other = _objectWithoutProperties(props, _excluded);
90
98
 
91
99
  var sortedColumns = React.useMemo(function () {
@@ -146,12 +154,28 @@ function GridColumnsPanel(props) {
146
154
 
147
155
  var searchValueToCheck = searchValue.toLowerCase();
148
156
  return sortedColumns.filter(function (column) {
149
- return (column.headerName || column.field).toLowerCase().indexOf(searchValueToCheck) > -1;
157
+ return searchPredicate(column, searchValueToCheck);
150
158
  });
151
- }, [sortedColumns, searchValue]);
159
+ }, [sortedColumns, searchValue, searchPredicate]);
160
+ var firstSwitchRef = React.useRef(null);
152
161
  React.useEffect(function () {
153
- searchInputRef.current.focus();
154
- }, []);
162
+ if (autoFocusSearchField) {
163
+ searchInputRef.current.focus();
164
+ } else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
165
+ firstSwitchRef.current.focus();
166
+ }
167
+ }, [autoFocusSearchField]);
168
+ var firstHideableColumnFound = false;
169
+
170
+ var isFirstHideableColumn = function isFirstHideableColumn(column) {
171
+ if (firstHideableColumnFound === false && column.hideable !== false) {
172
+ firstHideableColumnFound = true;
173
+ return true;
174
+ }
175
+
176
+ return false;
177
+ };
178
+
155
179
  return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
156
180
  children: [/*#__PURE__*/_jsx(GridPanelHeader, {
157
181
  children: /*#__PURE__*/_jsx(rootProps.components.BaseTextField, _extends({
@@ -177,7 +201,8 @@ function GridColumnsPanel(props) {
177
201
  checked: columnVisibilityModel[column.field] !== false,
178
202
  onClick: toggleColumn,
179
203
  name: column.field,
180
- size: "small"
204
+ size: "small",
205
+ inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
181
206
  }, (_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.baseSwitch)),
182
207
  label: column.headerName || column.field
183
208
  }), !rootProps.disableColumnReorder && GRID_EXPERIMENTAL_ENABLED && /*#__PURE__*/_jsx(GridIconButtonRoot, {
@@ -214,6 +239,8 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
214
239
  // | These PropTypes are generated from the TypeScript type definitions |
215
240
  // | To update them edit the TypeScript types and run "yarn proptypes" |
216
241
  // ----------------------------------------------------------------------
242
+ autoFocusSearchField: PropTypes.bool,
243
+ searchPredicate: PropTypes.func,
217
244
  sort: PropTypes.oneOf(['asc', 'desc'])
218
245
  } : void 0;
219
246
  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
  var isSyntheticEvent = function isSyntheticEvent(event) {
7
8
  return event.isPropagationStopped !== undefined;
@@ -62,6 +63,7 @@ export function useGridApiInitialization(inputApiRef, props) {
62
63
  React.useEffect(function () {
63
64
  var api = apiRef.current;
64
65
  return function () {
66
+ unstable_resetCreateSelectorCache(api.instanceId);
65
67
  api.publishEvent('unmount');
66
68
  };
67
69
  }, [apiRef]);
@@ -25,10 +25,12 @@ export var getRowIdFromRowModel = function getRowIdFromRowModel(rowModel, getRow
25
25
  export var createRowsInternalCache = function createRowsInternalCache(_ref) {
26
26
  var rows = _ref.rows,
27
27
  getRowId = _ref.getRowId,
28
- loading = _ref.loading;
28
+ loading = _ref.loading,
29
+ rowCount = _ref.rowCount;
29
30
  var cache = {
30
31
  rowsBeforePartialUpdates: rows,
31
32
  loadingPropBeforePartialUpdates: loading,
33
+ rowCountPropBeforePartialUpdates: rowCount,
32
34
  idRowsLookup: {},
33
35
  idToIdLookup: {},
34
36
  ids: []