@mui/x-data-grid 7.0.0-beta.7 → 7.0.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.
Files changed (190) hide show
  1. package/CHANGELOG.md +195 -12
  2. package/DataGrid/DataGrid.js +13 -17
  3. package/DataGrid/useDataGridProps.js +3 -5
  4. package/README.md +1 -1
  5. package/components/GridFooter.js +2 -3
  6. package/components/GridHeader.js +1 -2
  7. package/components/GridPagination.d.ts +6 -5
  8. package/components/GridPagination.js +12 -4
  9. package/components/GridRow.js +13 -17
  10. package/components/base/GridFooterPlaceholder.js +1 -2
  11. package/components/base/GridOverlays.js +3 -6
  12. package/components/cell/GridActionsCell.js +4 -6
  13. package/components/cell/GridActionsCellItem.d.ts +8 -25
  14. package/components/cell/GridActionsCellItem.js +8 -5
  15. package/components/cell/GridBooleanCell.d.ts +1 -0
  16. package/components/cell/GridBooleanCell.js +3 -2
  17. package/components/cell/GridCell.js +7 -8
  18. package/components/cell/GridEditBooleanCell.js +1 -2
  19. package/components/cell/GridEditDateCell.js +2 -3
  20. package/components/cell/GridEditInputCell.js +2 -2
  21. package/components/cell/GridEditSingleSelectCell.js +5 -8
  22. package/components/columnHeaders/ColumnHeaderMenuIcon.js +2 -3
  23. package/components/columnHeaders/GridColumnGroupHeader.js +4 -5
  24. package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +2 -3
  25. package/components/columnHeaders/GridColumnHeaderItem.js +5 -6
  26. package/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -2
  27. package/components/columnHeaders/GridColumnHeaderTitle.js +2 -3
  28. package/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -1
  29. package/components/columnSelection/GridCellCheckboxRenderer.js +3 -5
  30. package/components/columnSelection/GridHeaderCheckbox.js +1 -2
  31. package/components/columnsManagement/GridColumnsManagement.js +17 -21
  32. package/components/containers/GridRoot.js +3 -3
  33. package/components/menu/GridMenu.js +4 -6
  34. package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  35. package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +2 -3
  36. package/components/panel/GridColumnsPanel.js +1 -2
  37. package/components/panel/GridPanel.d.ts +1 -10
  38. package/components/panel/GridPanel.js +1 -2
  39. package/components/panel/GridPreferencesPanel.js +2 -3
  40. package/components/panel/filterPanel/GridFilterForm.js +24 -27
  41. package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +1 -1
  42. package/components/panel/filterPanel/GridFilterInputBoolean.js +6 -7
  43. package/components/panel/filterPanel/GridFilterInputDate.d.ts +1 -1
  44. package/components/panel/filterPanel/GridFilterInputDate.js +3 -4
  45. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +11 -15
  46. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +10 -14
  47. package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +1 -1
  48. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +10 -11
  49. package/components/panel/filterPanel/GridFilterInputValue.d.ts +1 -1
  50. package/components/panel/filterPanel/GridFilterInputValue.js +5 -7
  51. package/components/panel/filterPanel/GridFilterPanel.js +5 -9
  52. package/components/panel/filterPanel/filterPanelUtils.js +1 -1
  53. package/components/toolbar/GridToolbarColumnsButton.js +3 -5
  54. package/components/toolbar/GridToolbarDensitySelector.js +8 -10
  55. package/components/toolbar/GridToolbarExport.js +2 -2
  56. package/components/toolbar/GridToolbarExportContainer.js +3 -5
  57. package/components/toolbar/GridToolbarFilterButton.js +3 -5
  58. package/components/toolbar/GridToolbarQuickFilter.js +4 -5
  59. package/components/virtualization/GridVirtualScrollerContent.js +1 -2
  60. package/components/virtualization/GridVirtualScrollerRenderZone.js +1 -2
  61. package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +1 -2
  62. package/hooks/core/useGridApiInitialization.js +4 -6
  63. package/hooks/features/clipboard/useGridClipboard.js +6 -5
  64. package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -16
  65. package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +4 -8
  66. package/hooks/features/columnGrouping/useGridColumnGrouping.js +12 -23
  67. package/hooks/features/columnHeaders/useGridColumnHeaders.js +6 -8
  68. package/hooks/features/columnMenu/useGridColumnMenuSlots.js +2 -2
  69. package/hooks/features/columnResize/useGridColumnResize.js +9 -19
  70. package/hooks/features/columns/gridColumnsSelector.js +1 -2
  71. package/hooks/features/columns/gridColumnsUtils.d.ts +0 -9
  72. package/hooks/features/columns/gridColumnsUtils.js +2 -22
  73. package/hooks/features/columns/useGridColumnSpanning.js +1 -2
  74. package/hooks/features/columns/useGridColumns.js +11 -19
  75. package/hooks/features/density/densitySelector.d.ts +4 -2
  76. package/hooks/features/density/densitySelector.js +8 -2
  77. package/hooks/features/density/densityState.d.ts +1 -4
  78. package/hooks/features/density/useGridDensity.d.ts +2 -4
  79. package/hooks/features/density/useGridDensity.js +21 -29
  80. package/hooks/features/dimensions/useGridDimensions.js +3 -5
  81. package/hooks/features/editing/useGridCellEditing.js +4 -6
  82. package/hooks/features/editing/useGridEditing.js +1 -2
  83. package/hooks/features/editing/useGridRowEditing.js +4 -6
  84. package/hooks/features/export/serializers/csvSerializer.d.ts +2 -0
  85. package/hooks/features/export/serializers/csvSerializer.js +25 -16
  86. package/hooks/features/export/useGridCsvExport.js +9 -10
  87. package/hooks/features/export/useGridPrintExport.js +9 -15
  88. package/hooks/features/export/utils.js +2 -3
  89. package/hooks/features/filter/gridFilterSelector.js +15 -22
  90. package/hooks/features/filter/gridFilterUtils.js +10 -16
  91. package/hooks/features/filter/useGridFilter.js +9 -15
  92. package/hooks/features/focus/useGridFocus.js +5 -6
  93. package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +1 -4
  94. package/hooks/features/headerFiltering/useGridHeaderFiltering.js +12 -17
  95. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -2
  96. package/hooks/features/pagination/gridPaginationSelector.js +1 -2
  97. package/hooks/features/pagination/useGridPagination.js +2 -3
  98. package/hooks/features/pagination/useGridPaginationModel.js +6 -11
  99. package/hooks/features/pagination/useGridRowCount.js +3 -6
  100. package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +7 -12
  101. package/hooks/features/rowSelection/useGridRowSelection.js +11 -16
  102. package/hooks/features/rows/gridRowsSelector.js +11 -19
  103. package/hooks/features/rows/gridRowsUtils.js +7 -9
  104. package/hooks/features/rows/useGridParamsApi.js +1 -1
  105. package/hooks/features/rows/useGridRows.js +4 -13
  106. package/hooks/features/rows/useGridRowsMeta.js +7 -13
  107. package/hooks/features/scroll/useGridScroll.js +2 -3
  108. package/hooks/features/sorting/gridSortingSelector.js +4 -7
  109. package/hooks/features/sorting/useGridSorting.js +8 -14
  110. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
  111. package/hooks/features/virtualization/useGridVirtualScroller.js +220 -71
  112. package/hooks/utils/useGridApiEventHandler.js +5 -10
  113. package/hooks/utils/useGridNativeEventListener.js +1 -2
  114. package/index.js +1 -1
  115. package/internals/index.d.ts +2 -0
  116. package/internals/index.js +1 -0
  117. package/internals/utils/useProps.js +1 -2
  118. package/joy/joySlots.js +7 -13
  119. package/models/api/gridRowsMetaApi.d.ts +1 -1
  120. package/models/api/index.d.ts +1 -1
  121. package/models/api/index.js +0 -1
  122. package/models/events/gridEventLookup.d.ts +7 -0
  123. package/models/gridExport.d.ts +6 -0
  124. package/models/gridStateCommunity.d.ts +1 -0
  125. package/models/props/DataGridProps.d.ts +23 -27
  126. package/modern/DataGrid/DataGrid.js +13 -17
  127. package/modern/DataGrid/useDataGridProps.js +3 -5
  128. package/modern/components/GridPagination.js +11 -2
  129. package/modern/components/cell/GridActionsCell.js +1 -1
  130. package/modern/components/cell/GridActionsCellItem.js +4 -0
  131. package/modern/components/cell/GridBooleanCell.js +3 -2
  132. package/modern/components/containers/GridRoot.js +3 -3
  133. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  134. package/modern/components/panel/filterPanel/GridFilterInputDate.js +1 -1
  135. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
  136. package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  137. package/modern/components/toolbar/GridToolbarDensitySelector.js +5 -5
  138. package/modern/hooks/features/clipboard/useGridClipboard.js +4 -2
  139. package/modern/hooks/features/columnResize/useGridColumnResize.js +1 -1
  140. package/modern/hooks/features/columns/gridColumnsUtils.js +0 -19
  141. package/modern/hooks/features/density/densitySelector.js +8 -2
  142. package/modern/hooks/features/density/useGridDensity.js +21 -29
  143. package/modern/hooks/features/editing/useGridCellEditing.js +1 -1
  144. package/modern/hooks/features/editing/useGridRowEditing.js +1 -1
  145. package/modern/hooks/features/export/serializers/csvSerializer.js +23 -12
  146. package/modern/hooks/features/export/useGridCsvExport.js +2 -1
  147. package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
  148. package/modern/hooks/features/rowSelection/useGridRowSelection.js +3 -2
  149. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +211 -57
  150. package/modern/index.js +1 -1
  151. package/modern/internals/index.js +1 -0
  152. package/modern/models/api/index.js +0 -1
  153. package/modern/utils/createSelector.js +1 -1
  154. package/modern/utils/domUtils.js +1 -1
  155. package/modern/utils/keyboardUtils.js +1 -1
  156. package/node/DataGrid/DataGrid.js +13 -17
  157. package/node/DataGrid/useDataGridProps.js +3 -5
  158. package/node/components/GridPagination.js +9 -1
  159. package/node/components/cell/GridActionsCell.js +1 -1
  160. package/node/components/cell/GridActionsCellItem.js +4 -0
  161. package/node/components/cell/GridBooleanCell.js +3 -2
  162. package/node/components/containers/GridRoot.js +2 -2
  163. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  164. package/node/components/panel/filterPanel/GridFilterInputDate.js +1 -1
  165. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
  166. package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  167. package/node/components/toolbar/GridToolbarDensitySelector.js +4 -4
  168. package/node/hooks/features/clipboard/useGridClipboard.js +4 -2
  169. package/node/hooks/features/columnResize/useGridColumnResize.js +1 -1
  170. package/node/hooks/features/columns/gridColumnsUtils.js +0 -20
  171. package/node/hooks/features/density/densitySelector.js +9 -3
  172. package/node/hooks/features/density/useGridDensity.js +22 -30
  173. package/node/hooks/features/editing/useGridCellEditing.js +1 -1
  174. package/node/hooks/features/editing/useGridRowEditing.js +1 -1
  175. package/node/hooks/features/export/serializers/csvSerializer.js +23 -12
  176. package/node/hooks/features/export/useGridCsvExport.js +2 -1
  177. package/node/hooks/features/filter/gridFilterUtils.js +1 -1
  178. package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -1
  179. package/node/hooks/features/virtualization/useGridVirtualScroller.js +211 -57
  180. package/node/index.js +1 -1
  181. package/node/internals/index.js +12 -0
  182. package/node/models/api/index.js +0 -11
  183. package/node/utils/createSelector.js +1 -1
  184. package/node/utils/domUtils.js +1 -1
  185. package/node/utils/keyboardUtils.js +1 -1
  186. package/package.json +4 -4
  187. package/utils/createSelector.js +9 -9
  188. package/utils/domUtils.js +4 -7
  189. package/utils/getGridLocalization.js +9 -12
  190. package/utils/keyboardUtils.js +1 -1
@@ -106,9 +106,8 @@ export const useGridEditing = (apiRef, props) => {
106
106
  return props.editMode === GridEditModes.Cell ? apiRef.current.getRowWithUpdatedValuesFromCellEditing(id, field) : apiRef.current.getRowWithUpdatedValuesFromRowEditing(id);
107
107
  }, [apiRef, props.editMode]);
108
108
  const getEditCellMeta = React.useCallback((id, field) => {
109
- var _editingState$id$fiel, _editingState$id;
110
109
  const editingState = gridEditRowsStateSelector(apiRef.current.state);
111
- return (_editingState$id$fiel = (_editingState$id = editingState[id]) == null ? void 0 : _editingState$id[field]) != null ? _editingState$id$fiel : null;
110
+ return editingState[id]?.[field] ?? null;
112
111
  }, [apiRef]);
113
112
  const editingSharedApi = {
114
113
  isCellEditable,
@@ -16,7 +16,7 @@ import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
16
16
  import { deepClone } from '../../../utils/utils';
17
17
  import { GridRowEditStopReasons, GridRowEditStartReasons } from '../../../models/params/gridRowParams';
18
18
  import { GRID_ACTIONS_COLUMN_TYPE } from '../../../colDef';
19
- const missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI X: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/#server-side-persistence.'], 'error');
19
+ const missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI X: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/#server-side-persistence.'], 'error');
20
20
  export const useGridRowEditing = (apiRef, props) => {
21
21
  const [rowModesModel, setRowModesModel] = React.useState({});
22
22
  const rowModesModelRef = React.useRef(rowModesModel);
@@ -76,8 +76,7 @@ export const useGridRowEditing = (apiRef, props) => {
76
76
  // focus we check if the next cell that received focus is from a different row.
77
77
  nextFocusedCell.current = null;
78
78
  focusTimeout.current = setTimeout(() => {
79
- var _nextFocusedCell$curr;
80
- if (((_nextFocusedCell$curr = nextFocusedCell.current) == null ? void 0 : _nextFocusedCell$curr.id) !== params.id) {
79
+ if (nextFocusedCell.current?.id !== params.id) {
81
80
  // The row might have been deleted during the click
82
81
  if (!apiRef.current.getRow(params.id)) {
83
82
  return;
@@ -541,9 +540,8 @@ export const useGridRowEditing = (apiRef, props) => {
541
540
  prevRowModesModel.current = deepClone(rowModesModel); // Do a deep-clone because the attributes might be changed later
542
541
 
543
542
  Object.entries(rowModesModel).forEach(([id, params]) => {
544
- var _copyOfPrevRowModesMo, _idToIdLookup$id;
545
- const prevMode = ((_copyOfPrevRowModesMo = copyOfPrevRowModesModel[id]) == null ? void 0 : _copyOfPrevRowModesMo.mode) || GridRowModes.View;
546
- const originalId = (_idToIdLookup$id = idToIdLookup[id]) != null ? _idToIdLookup$id : id;
543
+ const prevMode = copyOfPrevRowModesModel[id]?.mode || GridRowModes.View;
544
+ const originalId = idToIdLookup[id] ?? id;
547
545
  if (params.mode === GridRowModes.Edit && prevMode === GridRowModes.View) {
548
546
  updateStateToStartRowEditMode(_extends({
549
547
  id: originalId
@@ -6,6 +6,7 @@ import type { GridApiCommunity } from '../../../../models/api/gridApiCommunity';
6
6
  export declare const serializeCellValue: (cellParams: GridCellParams, options: {
7
7
  delimiterCharacter: string;
8
8
  ignoreValueFormatter: boolean;
9
+ shouldAppendQuotes: boolean;
9
10
  }) => any;
10
11
  interface BuildCSVOptions {
11
12
  columns: GridStateColDef[];
@@ -15,6 +16,7 @@ interface BuildCSVOptions {
15
16
  includeColumnGroupsHeaders: NonNullable<GridCsvExportOptions['includeColumnGroupsHeaders']>;
16
17
  ignoreValueFormatter: boolean;
17
18
  apiRef: React.MutableRefObject<GridApiCommunity>;
19
+ shouldAppendQuotes: boolean;
18
20
  }
19
21
  export declare function buildCSV(options: BuildCSVOptions): string;
20
22
  export {};
@@ -1,10 +1,13 @@
1
1
  import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../../colDef';
2
2
  import { buildWarning } from '../../../../utils/warning';
3
- function sanitizeCellValue(value, delimiterCharacter) {
3
+ function sanitizeCellValue(value, delimiterCharacter, shouldAppendQuotes) {
4
4
  if (typeof value === 'string') {
5
5
  // Make sure value containing delimiter or line break won't be split into multiple rows
6
6
  if ([delimiterCharacter, '\n', '\r', '"'].some(delimiter => value.includes(delimiter))) {
7
- return `"${value.replace(/"/g, '""')}"`;
7
+ if (shouldAppendQuotes) {
8
+ return `"${value.replace(/"/g, '""')}"`;
9
+ }
10
+ return `${value.replace(/"/g, '""')}`;
8
11
  }
9
12
  return value;
10
13
  }
@@ -13,18 +16,17 @@ function sanitizeCellValue(value, delimiterCharacter) {
13
16
  export const serializeCellValue = (cellParams, options) => {
14
17
  const {
15
18
  delimiterCharacter,
16
- ignoreValueFormatter
19
+ ignoreValueFormatter,
20
+ shouldAppendQuotes
17
21
  } = options;
18
22
  let value;
19
23
  if (ignoreValueFormatter) {
20
- var _cellParams$value2;
21
24
  const columnType = cellParams.colDef.type;
22
25
  if (columnType === 'number') {
23
26
  value = String(cellParams.value);
24
27
  } else if (columnType === 'date' || columnType === 'dateTime') {
25
- var _cellParams$value;
26
- value = (_cellParams$value = cellParams.value) == null ? void 0 : _cellParams$value.toISOString();
27
- } else if (typeof ((_cellParams$value2 = cellParams.value) == null ? void 0 : _cellParams$value2.toString) === 'function') {
28
+ value = cellParams.value?.toISOString();
29
+ } else if (typeof cellParams.value?.toString === 'function') {
28
30
  value = cellParams.value.toString();
29
31
  } else {
30
32
  value = cellParams.value;
@@ -32,7 +34,7 @@ export const serializeCellValue = (cellParams, options) => {
32
34
  } else {
33
35
  value = cellParams.formattedValue;
34
36
  }
35
- return sanitizeCellValue(value, delimiterCharacter);
37
+ return sanitizeCellValue(value, delimiterCharacter, shouldAppendQuotes);
36
38
  };
37
39
  const objectFormattedValueWarning = buildWarning(['MUI X: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
38
40
  class CSVRow {
@@ -49,7 +51,7 @@ class CSVRow {
49
51
  if (value === null || value === undefined) {
50
52
  this.rowString += '';
51
53
  } else if (typeof this.options.sanitizeCellValue === 'function') {
52
- this.rowString += this.options.sanitizeCellValue(value, this.options.delimiterCharacter);
54
+ this.rowString += this.options.sanitizeCellValue(value, this.options.delimiterCharacter, this.options.shouldAppendQuotes);
53
55
  } else {
54
56
  this.rowString += value;
55
57
  }
@@ -64,10 +66,12 @@ const serializeRow = ({
64
66
  columns,
65
67
  getCellParams,
66
68
  delimiterCharacter,
67
- ignoreValueFormatter
69
+ ignoreValueFormatter,
70
+ shouldAppendQuotes
68
71
  }) => {
69
72
  const row = new CSVRow({
70
- delimiterCharacter
73
+ delimiterCharacter,
74
+ shouldAppendQuotes
71
75
  });
72
76
  columns.forEach(column => {
73
77
  const cellParams = getCellParams(id, column.field);
@@ -78,7 +82,8 @@ const serializeRow = ({
78
82
  }
79
83
  row.addValue(serializeCellValue(cellParams, {
80
84
  delimiterCharacter,
81
- ignoreValueFormatter
85
+ ignoreValueFormatter,
86
+ shouldAppendQuotes
82
87
  }));
83
88
  });
84
89
  return row.getRowString();
@@ -91,14 +96,16 @@ export function buildCSV(options) {
91
96
  includeHeaders,
92
97
  includeColumnGroupsHeaders,
93
98
  ignoreValueFormatter,
94
- apiRef
99
+ apiRef,
100
+ shouldAppendQuotes
95
101
  } = options;
96
102
  const CSVBody = rowIds.reduce((acc, id) => `${acc}${serializeRow({
97
103
  id,
98
104
  columns,
99
105
  getCellParams: apiRef.current.getCellParams,
100
106
  delimiterCharacter,
101
- ignoreValueFormatter
107
+ ignoreValueFormatter,
108
+ shouldAppendQuotes
102
109
  })}\r\n`, '').trim();
103
110
  if (!includeHeaders) {
104
111
  return CSVBody;
@@ -117,7 +124,8 @@ export function buildCSV(options) {
117
124
  for (let i = 0; i < maxColumnGroupsDepth; i += 1) {
118
125
  const headerGroupRow = new CSVRow({
119
126
  delimiterCharacter,
120
- sanitizeCellValue
127
+ sanitizeCellValue,
128
+ shouldAppendQuotes
121
129
  });
122
130
  headerRows.push(headerGroupRow);
123
131
  filteredColumns.forEach(column => {
@@ -129,7 +137,8 @@ export function buildCSV(options) {
129
137
  }
130
138
  const mainHeaderRow = new CSVRow({
131
139
  delimiterCharacter,
132
- sanitizeCellValue
140
+ sanitizeCellValue,
141
+ shouldAppendQuotes
133
142
  });
134
143
  filteredColumns.forEach(column => {
135
144
  mainHeaderRow.addValue(column.headerName || column.field);
@@ -17,15 +17,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
17
17
  export const useGridCsvExport = (apiRef, props) => {
18
18
  const logger = useGridLogger(apiRef, 'useGridCsvExport');
19
19
  const ignoreValueFormatterProp = props.ignoreValueFormatterDuringExport;
20
- const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.csvExport : ignoreValueFormatterProp) || false;
20
+ const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.csvExport : ignoreValueFormatterProp) || false;
21
21
  const getDataAsCsv = React.useCallback((options = {}) => {
22
- var _options$getRowsToExp, _options$includeHeade, _options$includeColum;
23
22
  logger.debug(`Get data as CSV`);
24
23
  const exportedColumns = getColumnsToExport({
25
24
  apiRef,
26
25
  options
27
26
  });
28
- const getRowsToExport = (_options$getRowsToExp = options.getRowsToExport) != null ? _options$getRowsToExp : defaultGetRowsToExport;
27
+ const getRowsToExport = options.getRowsToExport ?? defaultGetRowsToExport;
29
28
  const exportedRowIds = getRowsToExport({
30
29
  apiRef
31
30
  });
@@ -33,19 +32,20 @@ export const useGridCsvExport = (apiRef, props) => {
33
32
  columns: exportedColumns,
34
33
  rowIds: exportedRowIds,
35
34
  delimiterCharacter: options.delimiter || ',',
36
- includeHeaders: (_options$includeHeade = options.includeHeaders) != null ? _options$includeHeade : true,
37
- includeColumnGroupsHeaders: (_options$includeColum = options.includeColumnGroupsHeaders) != null ? _options$includeColum : true,
35
+ includeHeaders: options.includeHeaders ?? true,
36
+ includeColumnGroupsHeaders: options.includeColumnGroupsHeaders ?? true,
38
37
  ignoreValueFormatter,
39
- apiRef
38
+ apiRef,
39
+ shouldAppendQuotes: options.shouldAppendQuotes ?? true
40
40
  });
41
41
  }, [logger, apiRef, ignoreValueFormatter]);
42
42
  const exportDataAsCsv = React.useCallback(options => {
43
43
  logger.debug(`Export data as CSV`);
44
44
  const csv = getDataAsCsv(options);
45
- const blob = new Blob([options != null && options.utf8WithBom ? new Uint8Array([0xef, 0xbb, 0xbf]) : '', csv], {
45
+ const blob = new Blob([options?.utf8WithBom ? new Uint8Array([0xef, 0xbb, 0xbf]) : '', csv], {
46
46
  type: 'text/csv'
47
47
  });
48
- exportAs(blob, 'csv', options == null ? void 0 : options.fileName);
48
+ exportAs(blob, 'csv', options?.fileName);
49
49
  }, [logger, getDataAsCsv]);
50
50
  const csvExportApi = {
51
51
  getDataAsCsv,
@@ -57,8 +57,7 @@ export const useGridCsvExport = (apiRef, props) => {
57
57
  * PRE-PROCESSING
58
58
  */
59
59
  const addExportMenuButtons = React.useCallback((initialValue, options) => {
60
- var _options$csvOptions;
61
- if ((_options$csvOptions = options.csvOptions) != null && _options$csvOptions.disableToolbarButton) {
60
+ if (options.csvOptions?.disableToolbarButton) {
62
61
  return initialValue;
63
62
  }
64
63
  return [...initialValue, {
@@ -75,7 +75,6 @@ export const useGridPrintExport = (apiRef, props) => {
75
75
  apiRef.current.setRows(newRows);
76
76
  }, [apiRef]);
77
77
  const handlePrintWindowLoad = React.useCallback((printWindow, options) => {
78
- var _querySelector, _querySelector2;
79
78
  const normalizeOptions = _extends({
80
79
  copyStyles: true,
81
80
  hideToolbar: false,
@@ -96,16 +95,14 @@ export const useGridPrintExport = (apiRef, props) => {
96
95
 
97
96
  // See https://support.google.com/chrome/thread/191619088?hl=en&msgid=193009642
98
97
  gridClone.style.contain = 'size';
99
- let gridToolbarElementHeight = ((_querySelector = gridRootElement.querySelector(`.${gridClasses.toolbarContainer}`)) == null ? void 0 : _querySelector.offsetHeight) || 0;
100
- let gridFooterElementHeight = ((_querySelector2 = gridRootElement.querySelector(`.${gridClasses.footerContainer}`)) == null ? void 0 : _querySelector2.offsetHeight) || 0;
98
+ let gridToolbarElementHeight = gridRootElement.querySelector(`.${gridClasses.toolbarContainer}`)?.offsetHeight || 0;
99
+ let gridFooterElementHeight = gridRootElement.querySelector(`.${gridClasses.footerContainer}`)?.offsetHeight || 0;
101
100
  if (normalizeOptions.hideToolbar) {
102
- var _gridClone$querySelec;
103
- (_gridClone$querySelec = gridClone.querySelector(`.${gridClasses.toolbarContainer}`)) == null || _gridClone$querySelec.remove();
101
+ gridClone.querySelector(`.${gridClasses.toolbarContainer}`)?.remove();
104
102
  gridToolbarElementHeight = 0;
105
103
  }
106
104
  if (normalizeOptions.hideFooter) {
107
- var _gridClone$querySelec2;
108
- (_gridClone$querySelec2 = gridClone.querySelector(`.${gridClasses.footerContainer}`)) == null || _gridClone$querySelec2.remove();
105
+ gridClone.querySelector(`.${gridClasses.footerContainer}`)?.remove();
109
106
  gridFooterElementHeight = 0;
110
107
  }
111
108
 
@@ -186,13 +183,12 @@ export const useGridPrintExport = (apiRef, props) => {
186
183
  }
187
184
  }, [apiRef, doc, props.columnHeaderHeight]);
188
185
  const handlePrintWindowAfterPrint = React.useCallback(printWindow => {
189
- var _previousGridState$cu;
190
186
  // Remove the print iframe
191
187
  doc.current.body.removeChild(printWindow);
192
188
 
193
189
  // Revert grid to previous state
194
190
  apiRef.current.restoreState(previousGridState.current || {});
195
- if (!((_previousGridState$cu = previousGridState.current) != null && (_previousGridState$cu = _previousGridState$cu.columns) != null && _previousGridState$cu.columnVisibilityModel)) {
191
+ if (!previousGridState.current?.columns?.columnVisibilityModel) {
196
192
  // if the apiRef.current.exportState(); did not exported the column visibility, we update it
197
193
  apiRef.current.setColumnVisibilityModel(previousColumnVisibility.current);
198
194
  }
@@ -205,7 +201,6 @@ export const useGridPrintExport = (apiRef, props) => {
205
201
  previousRows.current = [];
206
202
  }, [apiRef]);
207
203
  const exportDataAsPrint = React.useCallback(async options => {
208
- var _options$getRowsToExp;
209
204
  logger.debug(`Export data as Print`);
210
205
  if (!apiRef.current.rootElementRef.current) {
211
206
  throw new Error('MUI X: No grid root element available.');
@@ -229,11 +224,11 @@ export const useGridPrintExport = (apiRef, props) => {
229
224
  }));
230
225
  apiRef.current.forceUpdate();
231
226
  }
232
- await updateGridColumnsForPrint(options == null ? void 0 : options.fields, options == null ? void 0 : options.allColumns, options == null ? void 0 : options.includeCheckboxes);
233
- updateGridRowsForPrint((_options$getRowsToExp = options == null ? void 0 : options.getRowsToExport) != null ? _options$getRowsToExp : defaultGetRowsToExport);
227
+ await updateGridColumnsForPrint(options?.fields, options?.allColumns, options?.includeCheckboxes);
228
+ updateGridRowsForPrint(options?.getRowsToExport ?? defaultGetRowsToExport);
234
229
  apiRef.current.unstable_setVirtualization(false);
235
230
  await raf(); // wait for the state changes to take action
236
- const printWindow = buildPrintWindow(options == null ? void 0 : options.fileName);
231
+ const printWindow = buildPrintWindow(options?.fileName);
237
232
  if (process.env.NODE_ENV === 'test') {
238
233
  doc.current.body.appendChild(printWindow);
239
234
  // In test env, run the all pipeline without waiting for loading
@@ -262,8 +257,7 @@ export const useGridPrintExport = (apiRef, props) => {
262
257
  * PRE-PROCESSING
263
258
  */
264
259
  const addExportMenuButtons = React.useCallback((initialValue, options) => {
265
- var _options$printOptions;
266
- if ((_options$printOptions = options.printOptions) != null && _options$printOptions.disableToolbarButton) {
260
+ if (options.printOptions?.disableToolbarButton) {
267
261
  return initialValue;
268
262
  }
269
263
  return [...initialValue, {
@@ -21,14 +21,13 @@ export const getColumnsToExport = ({
21
21
  export const defaultGetRowsToExport = ({
22
22
  apiRef
23
23
  }) => {
24
- var _pinnedRows$top, _pinnedRows$bottom;
25
24
  const filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
26
25
  const rowTree = gridRowTreeSelector(apiRef);
27
26
  const selectedRows = apiRef.current.getSelectedRows();
28
27
  const bodyRows = filteredSortedRowIds.filter(id => rowTree[id].type !== 'footer');
29
28
  const pinnedRows = gridPinnedRowsSelector(apiRef);
30
- const topPinnedRowsIds = (pinnedRows == null || (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.map(row => row.id)) || [];
31
- const bottomPinnedRowsIds = (pinnedRows == null || (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.map(row => row.id)) || [];
29
+ const topPinnedRowsIds = pinnedRows?.top?.map(row => row.id) || [];
30
+ const bottomPinnedRowsIds = pinnedRows?.bottom?.map(row => row.id) || [];
32
31
  bodyRows.unshift(...topPinnedRowsIds);
33
32
  bodyRows.push(...bottomPinnedRowsIds);
34
33
  if (selectedRows.size > 0) {
@@ -74,10 +74,7 @@ export const gridFilteredSortedTopLevelRowEntriesSelector = createSelectorMemoiz
74
74
  if (rowTreeDepth < 2) {
75
75
  return visibleSortedRows;
76
76
  }
77
- return visibleSortedRows.filter(row => {
78
- var _rowTree$row$id;
79
- return ((_rowTree$row$id = rowTree[row.id]) == null ? void 0 : _rowTree$row$id.depth) === 0;
80
- });
77
+ return visibleSortedRows.filter(row => rowTree[row.id]?.depth === 0);
81
78
  });
82
79
 
83
80
  /**
@@ -96,24 +93,20 @@ export const gridFilteredTopLevelRowCountSelector = createSelector(gridFilteredS
96
93
  * @category Filtering
97
94
  * @ignore - do not document.
98
95
  */
99
- export const gridFilterActiveItemsSelector = createSelectorMemoized(gridFilterModelSelector, gridColumnLookupSelector, (filterModel, columnLookup) => {
100
- var _filterModel$items;
101
- return (_filterModel$items = filterModel.items) == null ? void 0 : _filterModel$items.filter(item => {
102
- var _column$filterOperato, _item$value;
103
- if (!item.field) {
104
- return false;
105
- }
106
- const column = columnLookup[item.field];
107
- if (!(column != null && column.filterOperators) || (column == null || (_column$filterOperato = column.filterOperators) == null ? void 0 : _column$filterOperato.length) === 0) {
108
- return false;
109
- }
110
- const filterOperator = column.filterOperators.find(operator => operator.value === item.operator);
111
- if (!filterOperator) {
112
- return false;
113
- }
114
- return !filterOperator.InputComponent || item.value != null && ((_item$value = item.value) == null ? void 0 : _item$value.toString()) !== '';
115
- });
116
- });
96
+ export const gridFilterActiveItemsSelector = createSelectorMemoized(gridFilterModelSelector, gridColumnLookupSelector, (filterModel, columnLookup) => filterModel.items?.filter(item => {
97
+ if (!item.field) {
98
+ return false;
99
+ }
100
+ const column = columnLookup[item.field];
101
+ if (!column?.filterOperators || column?.filterOperators?.length === 0) {
102
+ return false;
103
+ }
104
+ const filterOperator = column.filterOperators.find(operator => operator.value === item.operator);
105
+ if (!filterOperator) {
106
+ return false;
107
+ }
108
+ return !filterOperator.InputComponent || item.value != null && item.value?.toString() !== '';
109
+ }));
117
110
  /**
118
111
  * @category Filtering
119
112
  * @ignore - do not document.
@@ -87,9 +87,8 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
87
87
  }
88
88
  let parsedValue;
89
89
  if (column.valueParser) {
90
- var _filterItem$value;
91
90
  const parser = column.valueParser;
92
- parsedValue = Array.isArray(filterItem.value) ? (_filterItem$value = filterItem.value) == null ? void 0 : _filterItem$value.map(x => parser(x, undefined, column, apiRef)) : parser(filterItem.value, undefined, column, apiRef);
91
+ parsedValue = Array.isArray(filterItem.value) ? filterItem.value?.map(x => parser(x, undefined, column, apiRef)) : parser(filterItem.value, undefined, column, apiRef);
93
92
  } else {
94
93
  parsedValue = filterItem.value;
95
94
  }
@@ -103,7 +102,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
103
102
  value: parsedValue
104
103
  });
105
104
  const filterOperators = column.filterOperators;
106
- if (!(filterOperators != null && filterOperators.length)) {
105
+ if (!filterOperators?.length) {
107
106
  throw new Error(`MUI X: No filter operators found for column '${column.field}'.`);
108
107
  }
109
108
  const filterOperator = filterOperators.find(operator => operator.value === newFilterItem.operator);
@@ -157,7 +156,7 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) =>
157
156
  }
158
157
 
159
158
  // We generate a new function with `new Function()` to avoid expensive patterns for JS engines
160
- // such as a dynamic object assignment, e.g. `{ [dynamicKey]: value }`.
159
+ // such as a dynamic object assignment, for example `{ [dynamicKey]: value }`.
161
160
  const filterItemCore = new Function('appliers', 'row', 'shouldApplyFilter', `"use strict";
162
161
  ${appliers.map((applier, i) => `const shouldApply${i} = !shouldApplyFilter || shouldApplyFilter(${JSON.stringify(applier.item.field)});`).join('\n')}
163
162
 
@@ -173,8 +172,7 @@ return result$$;`.replaceAll('$$', String(filterItemsApplierId)));
173
172
  return filterItem;
174
173
  };
175
174
  export const shouldQuickFilterExcludeHiddenColumns = filterModel => {
176
- var _filterModel$quickFil;
177
- return (_filterModel$quickFil = filterModel.quickFilterExcludeHiddenColumns) != null ? _filterModel$quickFil : true;
175
+ return filterModel.quickFilterExcludeHiddenColumns ?? true;
178
176
  };
179
177
 
180
178
  /**
@@ -184,8 +182,7 @@ export const shouldQuickFilterExcludeHiddenColumns = filterModel => {
184
182
  * @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.
185
183
  */
186
184
  const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
187
- var _filterModel$quickFil2, _filterModel$quickFil3;
188
- const quickFilterValues = (_filterModel$quickFil2 = (_filterModel$quickFil3 = filterModel.quickFilterValues) == null ? void 0 : _filterModel$quickFil3.filter(Boolean)) != null ? _filterModel$quickFil2 : [];
185
+ const quickFilterValues = filterModel.quickFilterValues?.filter(Boolean) ?? [];
189
186
  if (quickFilterValues.length === 0) {
190
187
  return null;
191
188
  }
@@ -197,7 +194,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
197
194
  const publicApiRef = getPublicApiRef(apiRef);
198
195
  columnFields.forEach(field => {
199
196
  const column = apiRef.current.getColumn(field);
200
- const getApplyQuickFilterFn = column == null ? void 0 : column.getApplyQuickFilterFn;
197
+ const getApplyQuickFilterFn = column?.getApplyQuickFilterFn;
201
198
  if (getApplyQuickFilterFn) {
202
199
  appliersPerField.push({
203
200
  column,
@@ -252,9 +249,8 @@ export const buildAggregatedFilterApplier = (filterModel, apiRef, disableEval) =
252
249
  const isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(filterModel, apiRef, disableEval);
253
250
  const isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(filterModel, apiRef);
254
251
  return function isRowMatchingFilters(row, shouldApplyFilter, result) {
255
- var _isRowMatchingFilterI, _isRowMatchingQuickFi;
256
- result.passingFilterItems = (_isRowMatchingFilterI = isRowMatchingFilterItems == null ? void 0 : isRowMatchingFilterItems(row, shouldApplyFilter)) != null ? _isRowMatchingFilterI : null;
257
- result.passingQuickFilterValues = (_isRowMatchingQuickFi = isRowMatchingQuickFilter == null ? void 0 : isRowMatchingQuickFilter(row, shouldApplyFilter)) != null ? _isRowMatchingQuickFi : null;
252
+ result.passingFilterItems = isRowMatchingFilterItems?.(row, shouldApplyFilter) ?? null;
253
+ result.passingQuickFilterValues = isRowMatchingQuickFilter?.(row, shouldApplyFilter) ?? null;
258
254
  };
259
255
  };
260
256
  const isNotNull = result => result != null;
@@ -271,12 +267,11 @@ export const passFilterLogic = (allFilterItemResults, allQuickFilterResults, fil
271
267
 
272
268
  // get result for filter items model
273
269
  if (cleanedFilterItemResults.length > 0) {
274
- var _filterModel$logicOpe;
275
270
  // Return true if the item pass with one of the rows
276
271
  const filterItemPredicate = item => {
277
272
  return cleanedFilterItemResults.some(filterItemResult => filterItemResult[item.id]);
278
273
  };
279
- const logicOperator = (_filterModel$logicOpe = filterModel.logicOperator) != null ? _filterModel$logicOpe : getDefaultGridFilterModel().logicOperator;
274
+ const logicOperator = filterModel.logicOperator ?? getDefaultGridFilterModel().logicOperator;
280
275
  if (logicOperator === GridLogicOperator.And) {
281
276
  const passesAllFilters = cleanedFilterItems.every(filterItemPredicate);
282
277
  if (!passesAllFilters) {
@@ -292,12 +287,11 @@ export const passFilterLogic = (allFilterItemResults, allQuickFilterResults, fil
292
287
 
293
288
  // get result for quick filter model
294
289
  if (cleanedQuickFilterResults.length > 0 && filterModel.quickFilterValues != null) {
295
- var _filterModel$quickFil4;
296
290
  // Return true if the item pass with one of the rows
297
291
  const quickFilterValuePredicate = value => {
298
292
  return cleanedQuickFilterResults.some(quickFilterValueResult => quickFilterValueResult[value]);
299
293
  };
300
- const quickFilterLogicOperator = (_filterModel$quickFil4 = filterModel.quickFilterLogicOperator) != null ? _filterModel$quickFil4 : getDefaultGridFilterModel().quickFilterLogicOperator;
294
+ const quickFilterLogicOperator = filterModel.quickFilterLogicOperator ?? getDefaultGridFilterModel().quickFilterLogicOperator;
301
295
  if (quickFilterLogicOperator === GridLogicOperator.And) {
302
296
  const passesAllQuickFilterValues = filterModel.quickFilterValues.every(quickFilterValuePredicate);
303
297
  if (!passesAllQuickFilterValues) {
@@ -18,8 +18,7 @@ import { buildAggregatedFilterApplier, sanitizeFilterModel, mergeStateWithFilter
18
18
  import { isDeepEqual } from '../../../utils/utils';
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
20
  export const filterStateInitializer = (state, props, apiRef) => {
21
- var _ref, _props$filterModel, _props$initialState;
22
- const filterModel = (_ref = (_props$filterModel = props.filterModel) != null ? _props$filterModel : (_props$initialState = props.initialState) == null || (_props$initialState = _props$initialState.filter) == null ? void 0 : _props$initialState.filterModel) != null ? _ref : getDefaultGridFilterModel();
21
+ const filterModel = props.filterModel ?? props.initialState?.filter?.filterModel ?? getDefaultGridFilterModel();
23
22
  return _extends({}, state, {
24
23
  filter: {
25
24
  filterModel: sanitizeFilterModel(filterModel, props.disableMultipleColumnsFiltering, apiRef),
@@ -49,7 +48,6 @@ function createMemoizedValues() {
49
48
  * @requires useGridRows (event)
50
49
  */
51
50
  export const useGridFilter = (apiRef, props) => {
52
- var _props$initialState3, _props$slotProps2;
53
51
  const logger = useGridLogger(apiRef, 'useGridFilter');
54
52
  apiRef.current.registerControlState({
55
53
  stateId: 'filter',
@@ -64,7 +62,7 @@ export const useGridFilter = (apiRef, props) => {
64
62
  const isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(filterModel, apiRef, props.disableEval) : null;
65
63
  const filteringResult = apiRef.current.applyStrategyProcessor('filtering', {
66
64
  isRowMatchingFilters,
67
- filterModel: filterModel != null ? filterModel : getDefaultGridFilterModel()
65
+ filterModel: filterModel ?? getDefaultGridFilterModel()
68
66
  });
69
67
  const newState = _extends({}, state, {
70
68
  filter: _extends({}, state.filter, filteringResult)
@@ -133,7 +131,6 @@ export const useGridFilter = (apiRef, props) => {
133
131
  if (targetColumnField) {
134
132
  const filterModel = gridFilterModelSelector(apiRef);
135
133
  const filterItemsWithValue = filterModel.items.filter(item => {
136
- var _column$filterOperato;
137
134
  if (item.value !== undefined) {
138
135
  // Some filters like `isAnyOf` support array as `item.value`.
139
136
  // If array is empty, we want to remove it from the filter model.
@@ -143,8 +140,8 @@ export const useGridFilter = (apiRef, props) => {
143
140
  return true;
144
141
  }
145
142
  const column = apiRef.current.getColumn(item.field);
146
- const filterOperator = (_column$filterOperato = column.filterOperators) == null ? void 0 : _column$filterOperato.find(operator => operator.value === item.operator);
147
- const requiresFilterValue = typeof (filterOperator == null ? void 0 : filterOperator.requiresFilterValue) === 'undefined' ? true : filterOperator == null ? void 0 : filterOperator.requiresFilterValue;
143
+ const filterOperator = column.filterOperators?.find(operator => operator.value === item.operator);
144
+ const requiresFilterValue = typeof filterOperator?.requiresFilterValue === 'undefined' ? true : filterOperator?.requiresFilterValue;
148
145
 
149
146
  // Operators like `isEmpty` don't have and don't require `item.value`.
150
147
  // So we don't want to remove them from the filter model if `item.value === undefined`.
@@ -224,7 +221,6 @@ export const useGridFilter = (apiRef, props) => {
224
221
  * PRE-PROCESSING
225
222
  */
226
223
  const stateExportPreProcessing = React.useCallback((prevState, context) => {
227
- var _props$initialState2;
228
224
  const filterModelToExport = gridFilterModelSelector(apiRef);
229
225
  const shouldExportFilterModel =
230
226
  // Always export if the `exportOnlyDirtyModels` property is not activated
@@ -232,7 +228,7 @@ export const useGridFilter = (apiRef, props) => {
232
228
  // Always export if the model is controlled
233
229
  props.filterModel != null ||
234
230
  // Always export if the model has been initialized
235
- ((_props$initialState2 = props.initialState) == null || (_props$initialState2 = _props$initialState2.filter) == null ? void 0 : _props$initialState2.filterModel) != null ||
231
+ props.initialState?.filter?.filterModel != null ||
236
232
  // Export if the model is not equal to the default value
237
233
  !isDeepEqual(filterModelToExport, getDefaultGridFilterModel());
238
234
  if (!shouldExportFilterModel) {
@@ -243,10 +239,9 @@ export const useGridFilter = (apiRef, props) => {
243
239
  filterModel: filterModelToExport
244
240
  }
245
241
  });
246
- }, [apiRef, props.filterModel, (_props$initialState3 = props.initialState) == null || (_props$initialState3 = _props$initialState3.filter) == null ? void 0 : _props$initialState3.filterModel]);
242
+ }, [apiRef, props.filterModel, props.initialState?.filter?.filterModel]);
247
243
  const stateRestorePreProcessing = React.useCallback((params, context) => {
248
- var _context$stateToResto;
249
- const filterModel = (_context$stateToResto = context.stateToRestore.filter) == null ? void 0 : _context$stateToResto.filterModel;
244
+ const filterModel = context.stateToRestore.filter?.filterModel;
250
245
  if (filterModel == null) {
251
246
  return params;
252
247
  }
@@ -257,12 +252,11 @@ export const useGridFilter = (apiRef, props) => {
257
252
  }, [apiRef, props.disableMultipleColumnsFiltering]);
258
253
  const preferencePanelPreProcessing = React.useCallback((initialValue, value) => {
259
254
  if (value === GridPreferencePanelsValue.filters) {
260
- var _props$slotProps;
261
255
  const FilterPanel = props.slots.filterPanel;
262
- return /*#__PURE__*/_jsx(FilterPanel, _extends({}, (_props$slotProps = props.slotProps) == null ? void 0 : _props$slotProps.filterPanel));
256
+ return /*#__PURE__*/_jsx(FilterPanel, _extends({}, props.slotProps?.filterPanel));
263
257
  }
264
258
  return initialValue;
265
- }, [props.slots.filterPanel, (_props$slotProps2 = props.slotProps) == null ? void 0 : _props$slotProps2.filterPanel]);
259
+ }, [props.slots.filterPanel, props.slotProps?.filterPanel]);
266
260
  const {
267
261
  getRowId
268
262
  } = props;
@@ -44,7 +44,7 @@ export const useGridFocus = (apiRef, props) => {
44
44
  }, [apiRef]);
45
45
  const setCellFocus = React.useCallback((id, field) => {
46
46
  const focusedCell = gridFocusCellSelector(apiRef);
47
- if ((focusedCell == null ? void 0 : focusedCell.id) === id && (focusedCell == null ? void 0 : focusedCell.field) === field) {
47
+ if (focusedCell?.id === id && focusedCell?.field === field) {
48
48
  return;
49
49
  }
50
50
  apiRef.current.setState(state => {
@@ -252,8 +252,7 @@ export const useGridFocus = (apiRef, props) => {
252
252
  apiRef.current.setColumnGroupHeaderFocus(fields[0], depth, event);
253
253
  }, [apiRef]);
254
254
  const handleBlur = React.useCallback((_, event) => {
255
- var _event$relatedTarget;
256
- if ((_event$relatedTarget = event.relatedTarget) != null && _event$relatedTarget.className.includes(gridClasses.columnHeader)) {
255
+ if (event.relatedTarget?.className.includes(gridClasses.columnHeader)) {
257
256
  return;
258
257
  }
259
258
  logger.debug(`Clearing focus`);
@@ -286,11 +285,11 @@ export const useGridFocus = (apiRef, props) => {
286
285
  }
287
286
  return;
288
287
  }
289
- if ((cellParams == null ? void 0 : cellParams.id) === focusedCell.id && (cellParams == null ? void 0 : cellParams.field) === focusedCell.field) {
288
+ if (cellParams?.id === focusedCell.id && cellParams?.field === focusedCell.field) {
290
289
  return;
291
290
  }
292
291
  const cellElement = apiRef.current.getCellElement(focusedCell.id, focusedCell.field);
293
- if (cellElement != null && cellElement.contains(event.target)) {
292
+ if (cellElement?.contains(event.target)) {
294
293
  return;
295
294
  }
296
295
  if (cellParams) {
@@ -316,7 +315,7 @@ export const useGridFocus = (apiRef, props) => {
316
315
  return;
317
316
  }
318
317
  const cell = gridFocusCellSelector(apiRef);
319
- if ((cell == null ? void 0 : cell.id) !== params.id || (cell == null ? void 0 : cell.field) !== params.field) {
318
+ if (cell?.id !== params.id || cell?.field !== params.field) {
320
319
  apiRef.current.setCellFocus(params.id, params.field);
321
320
  }
322
321
  }, [apiRef]);
@@ -2,9 +2,6 @@ import { createSelector } from '../../../utils/createSelector';
2
2
  export const gridHeaderFilteringStateSelector = state => state.headerFiltering;
3
3
  export const gridHeaderFilteringEnabledSelector = createSelector(gridHeaderFilteringStateSelector,
4
4
  // No initialization in MIT, so we need to default to false to be used by `getTotalHeaderHeight`
5
- headerFilteringState => {
6
- var _headerFilteringState;
7
- return (_headerFilteringState = headerFilteringState == null ? void 0 : headerFilteringState.enabled) != null ? _headerFilteringState : false;
8
- });
5
+ headerFilteringState => headerFilteringState?.enabled ?? false);
9
6
  export const gridHeaderFilteringEditFieldSelector = createSelector(gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.editing);
10
7
  export const gridHeaderFilteringMenuSelector = createSelector(gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.menuOpen);