@mui/x-data-grid 7.0.0-beta.7 → 7.1.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 (203) hide show
  1. package/CHANGELOG.md +266 -12
  2. package/DataGrid/DataGrid.js +18 -17
  3. package/DataGrid/useDataGridProps.js +4 -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 +8 -7
  26. package/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -2
  27. package/components/columnHeaders/GridColumnHeaderTitle.js +2 -3
  28. package/components/columnHeaders/GridGenericColumnHeaderItem.js +4 -2
  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 +21 -7
  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.d.ts +1 -1
  81. package/hooks/features/dimensions/useGridDimensions.js +6 -7
  82. package/hooks/features/editing/useGridCellEditing.js +4 -6
  83. package/hooks/features/editing/useGridEditing.js +1 -2
  84. package/hooks/features/editing/useGridRowEditing.js +17 -10
  85. package/hooks/features/export/serializers/csvSerializer.d.ts +2 -0
  86. package/hooks/features/export/serializers/csvSerializer.js +25 -16
  87. package/hooks/features/export/useGridCsvExport.js +9 -10
  88. package/hooks/features/export/useGridPrintExport.js +9 -15
  89. package/hooks/features/export/utils.js +2 -3
  90. package/hooks/features/filter/gridFilterSelector.js +15 -22
  91. package/hooks/features/filter/gridFilterUtils.js +10 -16
  92. package/hooks/features/filter/useGridFilter.js +9 -15
  93. package/hooks/features/focus/useGridFocus.js +5 -6
  94. package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +1 -4
  95. package/hooks/features/headerFiltering/useGridHeaderFiltering.js +12 -17
  96. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -2
  97. package/hooks/features/pagination/gridPaginationSelector.js +1 -2
  98. package/hooks/features/pagination/useGridPagination.js +2 -3
  99. package/hooks/features/pagination/useGridPaginationModel.js +6 -11
  100. package/hooks/features/pagination/useGridRowCount.js +3 -6
  101. package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +7 -12
  102. package/hooks/features/rowSelection/useGridRowSelection.js +11 -16
  103. package/hooks/features/rows/gridRowsSelector.js +11 -19
  104. package/hooks/features/rows/gridRowsUtils.js +7 -9
  105. package/hooks/features/rows/useGridParamsApi.js +1 -1
  106. package/hooks/features/rows/useGridRows.js +4 -13
  107. package/hooks/features/rows/useGridRowsMeta.js +7 -13
  108. package/hooks/features/scroll/useGridScroll.js +2 -3
  109. package/hooks/features/sorting/gridSortingSelector.js +4 -7
  110. package/hooks/features/sorting/useGridSorting.js +8 -14
  111. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
  112. package/hooks/features/virtualization/useGridVirtualScroller.js +220 -71
  113. package/hooks/utils/useGridApiEventHandler.js +5 -10
  114. package/hooks/utils/useGridNativeEventListener.js +1 -2
  115. package/index.js +1 -1
  116. package/internals/index.d.ts +2 -0
  117. package/internals/index.js +1 -0
  118. package/internals/utils/useProps.js +1 -2
  119. package/joy/joySlots.js +7 -13
  120. package/models/api/gridRowsMetaApi.d.ts +1 -1
  121. package/models/api/index.d.ts +1 -1
  122. package/models/api/index.js +0 -1
  123. package/models/events/gridEventLookup.d.ts +7 -0
  124. package/models/gridExport.d.ts +6 -0
  125. package/models/gridStateCommunity.d.ts +1 -0
  126. package/models/props/DataGridProps.d.ts +26 -25
  127. package/modern/DataGrid/DataGrid.js +18 -17
  128. package/modern/DataGrid/useDataGridProps.js +4 -5
  129. package/modern/components/GridPagination.js +11 -2
  130. package/modern/components/cell/GridActionsCell.js +1 -1
  131. package/modern/components/cell/GridActionsCellItem.js +4 -0
  132. package/modern/components/cell/GridBooleanCell.js +3 -2
  133. package/modern/components/columnHeaders/GridColumnHeaderItem.js +3 -1
  134. package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  135. package/modern/components/containers/GridRoot.js +3 -3
  136. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  137. package/modern/components/panel/filterPanel/GridFilterInputDate.js +1 -1
  138. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
  139. package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  140. package/modern/components/toolbar/GridToolbarDensitySelector.js +5 -5
  141. package/modern/components/toolbar/GridToolbarQuickFilter.js +17 -2
  142. package/modern/hooks/features/clipboard/useGridClipboard.js +4 -2
  143. package/modern/hooks/features/columnResize/useGridColumnResize.js +1 -1
  144. package/modern/hooks/features/columns/gridColumnsUtils.js +0 -19
  145. package/modern/hooks/features/density/densitySelector.js +8 -2
  146. package/modern/hooks/features/density/useGridDensity.js +21 -29
  147. package/modern/hooks/features/dimensions/useGridDimensions.js +3 -2
  148. package/modern/hooks/features/editing/useGridCellEditing.js +1 -1
  149. package/modern/hooks/features/editing/useGridRowEditing.js +14 -5
  150. package/modern/hooks/features/export/serializers/csvSerializer.js +23 -12
  151. package/modern/hooks/features/export/useGridCsvExport.js +2 -1
  152. package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
  153. package/modern/hooks/features/rowSelection/useGridRowSelection.js +3 -2
  154. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +211 -57
  155. package/modern/index.js +1 -1
  156. package/modern/internals/index.js +1 -0
  157. package/modern/models/api/index.js +0 -1
  158. package/modern/utils/createSelector.js +1 -1
  159. package/modern/utils/domUtils.js +1 -1
  160. package/modern/utils/keyboardUtils.js +1 -1
  161. package/modern/utils/throttle.js +19 -0
  162. package/node/DataGrid/DataGrid.js +18 -17
  163. package/node/DataGrid/useDataGridProps.js +4 -5
  164. package/node/components/GridPagination.js +9 -1
  165. package/node/components/cell/GridActionsCell.js +1 -1
  166. package/node/components/cell/GridActionsCellItem.js +4 -0
  167. package/node/components/cell/GridBooleanCell.js +3 -2
  168. package/node/components/columnHeaders/GridColumnHeaderItem.js +3 -1
  169. package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  170. package/node/components/containers/GridRoot.js +2 -2
  171. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  172. package/node/components/panel/filterPanel/GridFilterInputDate.js +1 -1
  173. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
  174. package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  175. package/node/components/toolbar/GridToolbarDensitySelector.js +4 -4
  176. package/node/components/toolbar/GridToolbarQuickFilter.js +17 -2
  177. package/node/hooks/features/clipboard/useGridClipboard.js +4 -2
  178. package/node/hooks/features/columnResize/useGridColumnResize.js +1 -1
  179. package/node/hooks/features/columns/gridColumnsUtils.js +0 -20
  180. package/node/hooks/features/density/densitySelector.js +9 -3
  181. package/node/hooks/features/density/useGridDensity.js +22 -30
  182. package/node/hooks/features/dimensions/useGridDimensions.js +2 -1
  183. package/node/hooks/features/editing/useGridCellEditing.js +1 -1
  184. package/node/hooks/features/editing/useGridRowEditing.js +14 -5
  185. package/node/hooks/features/export/serializers/csvSerializer.js +23 -12
  186. package/node/hooks/features/export/useGridCsvExport.js +2 -1
  187. package/node/hooks/features/filter/gridFilterUtils.js +1 -1
  188. package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -1
  189. package/node/hooks/features/virtualization/useGridVirtualScroller.js +211 -57
  190. package/node/index.js +1 -1
  191. package/node/internals/index.js +12 -0
  192. package/node/models/api/index.js +0 -11
  193. package/node/utils/createSelector.js +1 -1
  194. package/node/utils/domUtils.js +1 -1
  195. package/node/utils/keyboardUtils.js +1 -1
  196. package/node/utils/throttle.js +25 -0
  197. package/package.json +4 -4
  198. package/utils/createSelector.js +9 -9
  199. package/utils/domUtils.js +4 -7
  200. package/utils/getGridLocalization.js +9 -12
  201. package/utils/keyboardUtils.js +1 -1
  202. package/utils/throttle.d.ts +4 -0
  203. package/utils/throttle.js +19 -0
@@ -1,43 +1,35 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
+ import useEventCallback from '@mui/utils/useEventCallback';
3
4
  import { useGridLogger } from '../../utils/useGridLogger';
4
5
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
5
6
  import { gridDensitySelector } from './densitySelector';
6
- import { isDeepEqual } from '../../../utils/utils';
7
- export const COMPACT_DENSITY_FACTOR = 0.7;
8
- export const COMFORTABLE_DENSITY_FACTOR = 1.3;
9
- const DENSITY_FACTORS = {
10
- compact: COMPACT_DENSITY_FACTOR,
11
- comfortable: COMFORTABLE_DENSITY_FACTOR,
12
- standard: 1
13
- };
14
7
  export const densityStateInitializer = (state, props) => _extends({}, state, {
15
- density: {
16
- value: props.density,
17
- factor: DENSITY_FACTORS[props.density]
18
- }
8
+ density: props.initialState?.density ?? props.density ?? 'standard'
19
9
  });
20
10
  export const useGridDensity = (apiRef, props) => {
21
11
  const logger = useGridLogger(apiRef, 'useDensity');
22
- const setDensity = React.useCallback(newDensity => {
12
+ apiRef.current.registerControlState({
13
+ stateId: 'density',
14
+ propModel: props.density,
15
+ propOnChange: props.onDensityChange,
16
+ stateSelector: gridDensitySelector,
17
+ changeEvent: 'densityChange'
18
+ });
19
+ const setDensity = useEventCallback(newDensity => {
20
+ const currentDensity = gridDensitySelector(apiRef.current.state);
21
+ if (currentDensity === newDensity) {
22
+ return;
23
+ }
23
24
  logger.debug(`Set grid density to ${newDensity}`);
24
- apiRef.current.setState(state => {
25
- const currentDensityState = gridDensitySelector(state);
26
- const newDensityState = {
27
- value: newDensity,
28
- factor: DENSITY_FACTORS[newDensity]
29
- };
30
- if (isDeepEqual(currentDensityState, newDensityState)) {
31
- return state;
32
- }
33
- return _extends({}, state, {
34
- density: newDensityState
35
- });
36
- });
37
- apiRef.current.forceUpdate();
38
- }, [logger, apiRef]);
25
+ apiRef.current.setState(state => _extends({}, state, {
26
+ density: newDensity
27
+ }));
28
+ });
39
29
  React.useEffect(() => {
40
- apiRef.current.setDensity(props.density);
30
+ if (props.density) {
31
+ apiRef.current.setDensity(props.density);
32
+ }
41
33
  }, [apiRef, props.density]);
42
34
  const densityApi = {
43
35
  setDensity
@@ -3,7 +3,7 @@ import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
4
  import { GridDimensions } from './gridDimensionsApi';
5
5
  import { GridStateInitializer } from '../../utils/useGridInitializeState';
6
- type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'getRowHeight' | 'rowHeight' | 'columnHeaderHeight'>;
6
+ type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'getRowHeight' | 'rowHeight' | 'resizeThrottleMs' | 'columnHeaderHeight'>;
7
7
  export type GridDimensionsState = GridDimensions;
8
8
  export declare const dimensionsStateInitializer: GridStateInitializer<RootProps>;
9
9
  export declare function useGridDimensions(apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: RootProps): void;
@@ -1,8 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { unstable_debounce as debounce, unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallback as useEventCallback, unstable_ownerWindow as ownerWindow } from '@mui/utils';
3
+ import { unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallback as useEventCallback, unstable_ownerWindow as ownerWindow } from '@mui/utils';
4
4
  import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
5
5
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
6
+ import { throttle } from '../../../utils/throttle';
6
7
  import { useGridLogger } from '../../utils/useGridLogger';
7
8
  import { gridColumnsTotalWidthSelector, gridVisiblePinnedColumnDefinitionsSelector } from '../columns';
8
9
  import { gridDimensionsSelector } from './gridDimensionsSelectors';
@@ -57,7 +58,7 @@ export function useGridDimensions(apiRef, props) {
57
58
  const leftPinnedWidth = pinnedColumns.left.reduce((w, col) => w + col.computedWidth, 0);
58
59
  const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
59
60
  const [savedSize, setSavedSize] = React.useState();
60
- const debouncedSetSavedSize = React.useMemo(() => debounce(setSavedSize, 60), []);
61
+ const debouncedSetSavedSize = React.useMemo(() => throttle(setSavedSize, props.resizeThrottleMs), [props.resizeThrottleMs]);
61
62
  const previousSize = React.useRef();
62
63
  const getRootDimensions = () => apiRef.current.state.dimensions;
63
64
  const setDimensions = useEventCallback(dimensions => {
@@ -66,7 +67,6 @@ export function useGridDimensions(apiRef, props) {
66
67
  }));
67
68
  });
68
69
  const resize = React.useCallback(() => {
69
- var _previousSize$current, _previousSize$current2;
70
70
  const element = apiRef.current.mainElementRef.current;
71
71
  if (!element) {
72
72
  return;
@@ -74,8 +74,8 @@ export function useGridDimensions(apiRef, props) {
74
74
  const computedStyle = ownerWindow(element).getComputedStyle(element);
75
75
  const height = parseFloat(computedStyle.height) || 0;
76
76
  const width = parseFloat(computedStyle.width) || 0;
77
- const hasHeightChanged = height !== ((_previousSize$current = previousSize.current) == null ? void 0 : _previousSize$current.height);
78
- const hasWidthChanged = width !== ((_previousSize$current2 = previousSize.current) == null ? void 0 : _previousSize$current2.width);
77
+ const hasHeightChanged = height !== previousSize.current?.height;
78
+ const hasWidthChanged = width !== previousSize.current?.width;
79
79
  if (!previousSize.current || hasHeightChanged || hasWidthChanged) {
80
80
  const size = {
81
81
  width,
@@ -106,7 +106,6 @@ export function useGridDimensions(apiRef, props) {
106
106
  return Math.min(maximumPageSizeWithoutScrollBar, currentPage.rows.length);
107
107
  }, [apiRef, props.pagination, props.paginationMode, props.getRowHeight, rowHeight]);
108
108
  const updateDimensions = React.useCallback(() => {
109
- var _apiRef$current$updat, _apiRef$current;
110
109
  const rootElement = apiRef.current.rootElementRef.current;
111
110
  const pinnedRowsHeight = calculatePinnedRowsHeight(apiRef);
112
111
  const scrollbarSize = measureScrollbarSize(rootElement, columnsTotalWidth, props.scrollbarSize);
@@ -191,7 +190,7 @@ export function useGridDimensions(apiRef, props) {
191
190
  if (newDimensions.viewportInnerSize.width !== prevDimensions.viewportInnerSize.width || newDimensions.viewportInnerSize.height !== prevDimensions.viewportInnerSize.height) {
192
191
  apiRef.current.publishEvent('viewportInnerSizeChange', newDimensions.viewportInnerSize);
193
192
  }
194
- (_apiRef$current$updat = (_apiRef$current = apiRef.current).updateRenderContext) == null || _apiRef$current$updat.call(_apiRef$current);
193
+ apiRef.current.updateRenderContext?.();
195
194
  }, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, rowHeight, headerHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
196
195
  const apiPublic = {
197
196
  resize,
@@ -14,7 +14,7 @@ import { buildWarning } from '../../../utils/warning';
14
14
  import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
15
15
  import { deepClone } from '../../../utils/utils';
16
16
  import { GridCellEditStartReasons, GridCellEditStopReasons } from '../../../models/params/gridEditCellParams';
17
- 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');
17
+ 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');
18
18
  export const useGridCellEditing = (apiRef, props) => {
19
19
  const [cellModesModel, setCellModesModel] = React.useState({});
20
20
  const cellModesModelRef = React.useRef(cellModesModel);
@@ -339,7 +339,6 @@ export const useGridCellEditing = (apiRef, props) => {
339
339
  }
340
340
  });
341
341
  const setCellEditingEditCellValue = React.useCallback(async params => {
342
- var _editingState$id;
343
342
  const {
344
343
  id,
345
344
  field,
@@ -389,7 +388,7 @@ export const useGridCellEditing = (apiRef, props) => {
389
388
  newProps.value = column.preProcessEditCellProps ? editingState[id][field].value : parsedValue;
390
389
  updateOrDeleteFieldState(id, field, newProps);
391
390
  editingState = gridEditRowsStateSelector(apiRef.current.state);
392
- return !((_editingState$id = editingState[id]) != null && (_editingState$id = _editingState$id[field]) != null && _editingState$id.error);
391
+ return !editingState[id]?.[field]?.error;
393
392
  }, [apiRef, throwIfNotEditable, throwIfNotInMode, updateOrDeleteFieldState]);
394
393
  const getRowWithUpdatedValuesFromCellEditing = React.useCallback((id, field) => {
395
394
  const column = apiRef.current.getColumn(field);
@@ -432,9 +431,8 @@ export const useGridCellEditing = (apiRef, props) => {
432
431
 
433
432
  Object.entries(cellModesModel).forEach(([id, fields]) => {
434
433
  Object.entries(fields).forEach(([field, params]) => {
435
- var _copyOfPrevCellModes$, _idToIdLookup$id;
436
- const prevMode = ((_copyOfPrevCellModes$ = copyOfPrevCellModes[id]) == null || (_copyOfPrevCellModes$ = _copyOfPrevCellModes$[field]) == null ? void 0 : _copyOfPrevCellModes$.mode) || GridCellModes.View;
437
- const originalId = (_idToIdLookup$id = idToIdLookup[id]) != null ? _idToIdLookup$id : id;
434
+ const prevMode = copyOfPrevCellModes[id]?.[field]?.mode || GridCellModes.View;
435
+ const originalId = idToIdLookup[id] ?? id;
438
436
  if (params.mode === GridCellModes.Edit && prevMode === GridCellModes.View) {
439
437
  updateStateToStartCellEditMode(_extends({
440
438
  id: originalId,
@@ -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);
@@ -45,6 +45,10 @@ export const useGridRowEditing = (apiRef, props) => {
45
45
  throw new Error(`MUI X: The row with id=${id} is not in ${mode} mode.`);
46
46
  }
47
47
  }, [apiRef]);
48
+ const hasFieldsWithErrors = React.useCallback(rowId => {
49
+ const editingState = gridEditRowsStateSelector(apiRef.current.state);
50
+ return Object.values(editingState[rowId]).some(fieldProps => fieldProps.error);
51
+ }, [apiRef]);
48
52
  const handleCellDoubleClick = React.useCallback((params, event) => {
49
53
  if (!params.isEditable) {
50
54
  return;
@@ -76,8 +80,7 @@ export const useGridRowEditing = (apiRef, props) => {
76
80
  // focus we check if the next cell that received focus is from a different row.
77
81
  nextFocusedCell.current = null;
78
82
  focusTimeout.current = setTimeout(() => {
79
- var _nextFocusedCell$curr;
80
- if (((_nextFocusedCell$curr = nextFocusedCell.current) == null ? void 0 : _nextFocusedCell$curr.id) !== params.id) {
83
+ if (nextFocusedCell.current?.id !== params.id) {
81
84
  // The row might have been deleted during the click
82
85
  if (!apiRef.current.getRow(params.id)) {
83
86
  return;
@@ -87,6 +90,9 @@ export const useGridRowEditing = (apiRef, props) => {
87
90
  if (apiRef.current.getRowMode(params.id) === GridRowModes.View) {
88
91
  return;
89
92
  }
93
+ if (hasFieldsWithErrors(params.id)) {
94
+ return;
95
+ }
90
96
  const rowParams = apiRef.current.getRowParams(params.id);
91
97
  const newParams = _extends({}, rowParams, {
92
98
  field: params.field,
@@ -95,7 +101,7 @@ export const useGridRowEditing = (apiRef, props) => {
95
101
  apiRef.current.publishEvent('rowEditStop', newParams, event);
96
102
  }
97
103
  });
98
- }, [apiRef]);
104
+ }, [apiRef, hasFieldsWithErrors]);
99
105
  React.useEffect(() => {
100
106
  return () => {
101
107
  clearTimeout(focusTimeout.current);
@@ -141,6 +147,9 @@ export const useGridRowEditing = (apiRef, props) => {
141
147
  }
142
148
  }
143
149
  if (reason) {
150
+ if (reason !== GridRowEditStopReasons.escapeKeyDown && hasFieldsWithErrors(params.id)) {
151
+ return;
152
+ }
144
153
  const newParams = _extends({}, apiRef.current.getRowParams(params.id), {
145
154
  reason,
146
155
  field: params.field
@@ -175,7 +184,7 @@ export const useGridRowEditing = (apiRef, props) => {
175
184
  apiRef.current.publishEvent('rowEditStart', newParams, event);
176
185
  }
177
186
  }
178
- }, [apiRef]);
187
+ }, [apiRef, hasFieldsWithErrors]);
179
188
  const handleRowEditStart = React.useCallback(params => {
180
189
  const {
181
190
  id,
@@ -359,8 +368,7 @@ export const useGridRowEditing = (apiRef, props) => {
359
368
  prevRowModesModel.current[id].mode = GridRowModes.Edit;
360
369
  return;
361
370
  }
362
- const hasSomeFieldWithError = Object.values(editingState[id]).some(fieldProps => fieldProps.error);
363
- if (hasSomeFieldWithError) {
371
+ if (hasFieldsWithErrors(id)) {
364
372
  prevRowModesModel.current[id].mode = GridRowModes.Edit;
365
373
  // Revert the mode in the rowModesModel prop back to "edit"
366
374
  updateRowInRowModesModel(id, {
@@ -541,9 +549,8 @@ export const useGridRowEditing = (apiRef, props) => {
541
549
  prevRowModesModel.current = deepClone(rowModesModel); // Do a deep-clone because the attributes might be changed later
542
550
 
543
551
  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;
552
+ const prevMode = copyOfPrevRowModesModel[id]?.mode || GridRowModes.View;
553
+ const originalId = idToIdLookup[id] ?? id;
547
554
  if (params.mode === GridRowModes.Edit && prevMode === GridRowModes.View) {
548
555
  updateStateToStartRowEditMode(_extends({
549
556
  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.