@mui/x-data-grid 6.10.0 → 6.10.2

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 (93) hide show
  1. package/CHANGELOG.md +136 -3
  2. package/components/GridRow.d.ts +2 -0
  3. package/components/GridRow.js +50 -22
  4. package/components/cell/GridCell.d.ts +2 -2
  5. package/components/cell/GridCell.js +38 -14
  6. package/components/containers/GridRootStyles.js +1 -0
  7. package/components/panel/GridPanel.js +2 -2
  8. package/components/panel/filterPanel/GridFilterForm.js +2 -2
  9. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +2 -2
  10. package/hooks/features/columns/gridColumnsUtils.js +17 -7
  11. package/hooks/features/columns/useGridColumns.js +4 -4
  12. package/hooks/features/dimensions/useGridDimensions.js +1 -1
  13. package/hooks/features/editing/useGridCellEditing.js +4 -4
  14. package/hooks/features/export/serializers/csvSerializer.js +3 -5
  15. package/hooks/features/export/useGridPrintExport.js +10 -3
  16. package/hooks/features/export/utils.js +2 -2
  17. package/hooks/features/filter/gridFilterSelector.js +1 -1
  18. package/hooks/features/filter/gridFilterUtils.js +37 -10
  19. package/hooks/features/filter/useGridFilter.js +14 -9
  20. package/hooks/features/focus/useGridFocus.js +30 -1
  21. package/hooks/features/pagination/useGridPagination.js +6 -6
  22. package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  23. package/hooks/features/rows/gridRowsSelector.js +3 -3
  24. package/hooks/features/rows/gridRowsUtils.js +2 -2
  25. package/hooks/features/rows/useGridRowsMeta.js +2 -2
  26. package/hooks/features/sorting/useGridSorting.js +6 -6
  27. package/hooks/features/virtualization/useGridVirtualScroller.js +70 -6
  28. package/index.js +1 -1
  29. package/internals/index.d.ts +1 -1
  30. package/internals/index.js +1 -1
  31. package/joy/joySlots.js +2 -2
  32. package/legacy/components/GridRow.js +47 -21
  33. package/legacy/components/cell/GridCell.js +38 -14
  34. package/legacy/components/containers/GridRootStyles.js +1 -0
  35. package/legacy/components/panel/GridPanel.js +2 -2
  36. package/legacy/components/panel/filterPanel/GridFilterForm.js +2 -2
  37. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +2 -2
  38. package/legacy/hooks/features/columns/gridColumnsUtils.js +17 -7
  39. package/legacy/hooks/features/columns/useGridColumns.js +4 -4
  40. package/legacy/hooks/features/dimensions/useGridDimensions.js +1 -1
  41. package/legacy/hooks/features/editing/useGridCellEditing.js +4 -4
  42. package/legacy/hooks/features/export/serializers/csvSerializer.js +4 -6
  43. package/legacy/hooks/features/export/useGridPrintExport.js +16 -4
  44. package/legacy/hooks/features/export/utils.js +2 -2
  45. package/legacy/hooks/features/filter/gridFilterSelector.js +1 -1
  46. package/legacy/hooks/features/filter/gridFilterUtils.js +30 -10
  47. package/legacy/hooks/features/filter/useGridFilter.js +14 -11
  48. package/legacy/hooks/features/focus/useGridFocus.js +32 -1
  49. package/legacy/hooks/features/pagination/useGridPagination.js +6 -6
  50. package/legacy/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  51. package/legacy/hooks/features/rows/gridRowsSelector.js +3 -3
  52. package/legacy/hooks/features/rows/gridRowsUtils.js +2 -2
  53. package/legacy/hooks/features/rows/useGridRowsMeta.js +2 -2
  54. package/legacy/hooks/features/sorting/useGridSorting.js +6 -6
  55. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +74 -6
  56. package/legacy/index.js +1 -1
  57. package/legacy/internals/index.js +1 -1
  58. package/legacy/joy/joySlots.js +2 -2
  59. package/legacy/locales/fiFI.js +1 -1
  60. package/legacy/utils/getGridLocalization.js +2 -2
  61. package/locales/fiFI.js +1 -1
  62. package/modern/components/GridRow.js +50 -22
  63. package/modern/components/cell/GridCell.js +38 -14
  64. package/modern/components/containers/GridRootStyles.js +1 -0
  65. package/modern/hooks/features/columns/gridColumnsUtils.js +15 -5
  66. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -1
  67. package/modern/hooks/features/export/serializers/csvSerializer.js +3 -5
  68. package/modern/hooks/features/export/useGridPrintExport.js +8 -1
  69. package/modern/hooks/features/filter/gridFilterUtils.js +37 -10
  70. package/modern/hooks/features/filter/useGridFilter.js +8 -3
  71. package/modern/hooks/features/focus/useGridFocus.js +30 -1
  72. package/modern/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  73. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +69 -5
  74. package/modern/index.js +1 -1
  75. package/modern/internals/index.js +1 -1
  76. package/modern/locales/fiFI.js +1 -1
  77. package/node/components/GridRow.js +50 -22
  78. package/node/components/cell/GridCell.js +38 -14
  79. package/node/components/containers/GridRootStyles.js +1 -0
  80. package/node/hooks/features/columns/gridColumnsUtils.js +15 -5
  81. package/node/hooks/features/dimensions/useGridDimensions.js +1 -1
  82. package/node/hooks/features/export/serializers/csvSerializer.js +3 -5
  83. package/node/hooks/features/export/useGridPrintExport.js +8 -1
  84. package/node/hooks/features/filter/gridFilterUtils.js +37 -10
  85. package/node/hooks/features/filter/useGridFilter.js +8 -3
  86. package/node/hooks/features/focus/useGridFocus.js +29 -0
  87. package/node/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  88. package/node/hooks/features/virtualization/useGridVirtualScroller.js +69 -5
  89. package/node/index.js +1 -1
  90. package/node/internals/index.js +7 -0
  91. package/node/locales/fiFI.js +1 -1
  92. package/package.json +3 -3
  93. package/utils/getGridLocalization.js +2 -2
@@ -2,7 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "isLastVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"];
5
+ var _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "isLastVisible", "focusedCellColumnIndexNotInRange", "isNotVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
@@ -69,6 +69,8 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
69
69
  lastColumnToRender = props.lastColumnToRender,
70
70
  _props$isLastVisible = props.isLastVisible,
71
71
  isLastVisible = _props$isLastVisible === void 0 ? false : _props$isLastVisible,
72
+ focusedCellColumnIndexNotInRange = props.focusedCellColumnIndexNotInRange,
73
+ isNotVisible = props.isNotVisible,
72
74
  focusedCell = props.focusedCell,
73
75
  tabbableCell = props.tabbableCell,
74
76
  onClick = props.onClick,
@@ -180,7 +182,7 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
180
182
 
181
183
  // User clicked a button from the "actions" column type
182
184
  var column = apiRef.current.getColumn(field);
183
- if (column.type === GRID_ACTIONS_COLUMN_TYPE) {
185
+ if ((column == null ? void 0 : column.type) === GRID_ACTIONS_COLUMN_TYPE) {
184
186
  return;
185
187
  }
186
188
  }
@@ -195,6 +197,10 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
195
197
  var _editRowsState$rowId$, _editRowsState$rowId;
196
198
  var disableDragEvents = disableColumnReorder && column.disableReorder || !rowReordering && !!sortModel.length && treeDepth > 1 && Object.keys(editRowsState).length > 0;
197
199
  var editCellState = (_editRowsState$rowId$ = (_editRowsState$rowId = editRowsState[rowId]) == null ? void 0 : _editRowsState$rowId[column.field]) != null ? _editRowsState$rowId$ : null;
200
+ var cellIsNotVisible = false;
201
+ if (focusedCellColumnIndexNotInRange !== undefined && visibleColumns[focusedCellColumnIndexNotInRange].field === column.field) {
202
+ cellIsNotVisible = true;
203
+ }
198
204
  return /*#__PURE__*/_jsx(CellComponent, _extends({
199
205
  column: column,
200
206
  width: cellProps.width,
@@ -205,7 +211,8 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
205
211
  colIndex: cellProps.indexRelativeToAllColumns,
206
212
  colSpan: cellProps.colSpan,
207
213
  disableDragEvents: disableDragEvents,
208
- editCellState: editCellState
214
+ editCellState: editCellState,
215
+ isNotVisible: cellIsNotVisible
209
216
  }, slotProps == null ? void 0 : slotProps.cell), column.field);
210
217
  };
211
218
  var sizes = useGridSelector(apiRef, function () {
@@ -232,25 +239,35 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
232
239
  minHeight = maximumSize;
233
240
  }
234
241
  }
235
- var style = _extends({}, styleProp, {
236
- maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
237
- // max-height doesn't support "auto"
238
- minHeight: minHeight
239
- });
240
- if (sizes != null && sizes.spacingTop) {
241
- var property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
242
- style[property] = sizes.spacingTop;
243
- }
244
- if (sizes != null && sizes.spacingBottom) {
245
- var _property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
246
- var propertyValue = style[_property];
247
- // avoid overriding existing value
248
- if (typeof propertyValue !== 'number') {
249
- propertyValue = parseInt(propertyValue || '0', 10);
242
+ var style = React.useMemo(function () {
243
+ if (isNotVisible) {
244
+ return {
245
+ opacity: 0,
246
+ width: 0,
247
+ height: 0
248
+ };
250
249
  }
251
- propertyValue += sizes.spacingBottom;
252
- style[_property] = propertyValue;
253
- }
250
+ var rowStyle = _extends({}, styleProp, {
251
+ maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
252
+ // max-height doesn't support "auto"
253
+ minHeight: minHeight
254
+ });
255
+ if (sizes != null && sizes.spacingTop) {
256
+ var property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
257
+ rowStyle[property] = sizes.spacingTop;
258
+ }
259
+ if (sizes != null && sizes.spacingBottom) {
260
+ var _property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
261
+ var propertyValue = rowStyle[_property];
262
+ // avoid overriding existing value
263
+ if (typeof propertyValue !== 'number') {
264
+ propertyValue = parseInt(propertyValue || '0', 10);
265
+ }
266
+ propertyValue += sizes.spacingBottom;
267
+ rowStyle[_property] = propertyValue;
268
+ }
269
+ return rowStyle;
270
+ }, [isNotVisible, rowHeight, styleProp, minHeight, sizes, rootProps.rowSpacingType]);
254
271
  var rowClassNames = apiRef.current.unstable_applyPipeProcessors('rowClassName', [], rowId);
255
272
  if (typeof rootProps.getRowClassName === 'function') {
256
273
  var _currentPage$range;
@@ -272,6 +289,13 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
272
289
  for (var i = 0; i < renderedColumns.length; i += 1) {
273
290
  var column = renderedColumns[i];
274
291
  var indexRelativeToAllColumns = firstColumnToRender + i;
292
+ if (focusedCellColumnIndexNotInRange !== undefined && focusedCell) {
293
+ if (visibleColumns[focusedCellColumnIndexNotInRange].field === column.field) {
294
+ indexRelativeToAllColumns = focusedCellColumnIndexNotInRange;
295
+ } else {
296
+ indexRelativeToAllColumns -= 1;
297
+ }
298
+ }
275
299
  var cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
276
300
  if (cellColSpanInfo && !cellColSpanInfo.spannedByColSpan) {
277
301
  if (rowType !== 'skeletonRow') {
@@ -331,12 +355,14 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
331
355
  * If `null`, no cell in this row has focus.
332
356
  */
333
357
  focusedCell: PropTypes.string,
358
+ focusedCellColumnIndexNotInRange: PropTypes.number,
334
359
  /**
335
360
  * Index of the row in the whole sorted and filtered dataset.
336
361
  * If some rows above have expanded children, this index also take those children into account.
337
362
  */
338
363
  index: PropTypes.number.isRequired,
339
364
  isLastVisible: PropTypes.bool,
365
+ isNotVisible: PropTypes.bool,
340
366
  lastColumnToRender: PropTypes.number.isRequired,
341
367
  onClick: PropTypes.func,
342
368
  onDoubleClick: PropTypes.func,
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  var _excluded = ["changeReason", "unstable_updateValueOnRender"],
4
- _excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
5
- _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
4
+ _excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
5
+ _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
6
6
  _excluded4 = ["changeReason", "unstable_updateValueOnRender"];
7
7
  /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
8
8
  import * as React from 'react';
@@ -173,6 +173,7 @@ var GridCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
173
173
  row = props.row,
174
174
  colSpan = props.colSpan,
175
175
  disableDragEvents = props.disableDragEvents,
176
+ isNotVisible = props.isNotVisible,
176
177
  onClick = props.onClick,
177
178
  onDoubleClick = props.onDoubleClick,
178
179
  onMouseDown = props.onMouseDown,
@@ -228,13 +229,23 @@ var GridCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
228
229
  }
229
230
  };
230
231
  }, [apiRef, field, rowId]);
231
- var style = {
232
- minWidth: width,
233
- maxWidth: width,
234
- minHeight: height,
235
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
236
- };
232
+ var style = React.useMemo(function () {
233
+ if (isNotVisible) {
234
+ return {
235
+ padding: 0,
236
+ opacity: 0,
237
+ width: 0
238
+ };
239
+ }
240
+ var cellStyle = {
241
+ minWidth: width,
242
+ maxWidth: width,
243
+ minHeight: height,
244
+ maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
245
+ };
237
246
 
247
+ return cellStyle;
248
+ }, [width, height, isNotVisible]);
238
249
  React.useEffect(function () {
239
250
  if (!hasFocus || cellMode === GridCellModes.Edit) {
240
251
  return;
@@ -354,6 +365,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
354
365
  isValidating: PropTypes.bool,
355
366
  value: PropTypes.any
356
367
  }),
368
+ isNotVisible: PropTypes.bool,
357
369
  height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
358
370
  onClick: PropTypes.func,
359
371
  onDoubleClick: PropTypes.func,
@@ -383,6 +395,7 @@ var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
383
395
  row = props.row,
384
396
  colSpan = props.colSpan,
385
397
  disableDragEvents = props.disableDragEvents,
398
+ isNotVisible = props.isNotVisible,
386
399
  onClick = props.onClick,
387
400
  onDoubleClick = props.onDoubleClick,
388
401
  onMouseDown = props.onMouseDown,
@@ -480,13 +493,23 @@ var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
480
493
  }
481
494
  };
482
495
  }, [apiRef, field, rowId]);
483
- var style = {
484
- minWidth: width,
485
- maxWidth: width,
486
- minHeight: height,
487
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
488
- };
496
+ var style = React.useMemo(function () {
497
+ if (isNotVisible) {
498
+ return {
499
+ padding: 0,
500
+ opacity: 0,
501
+ width: 0
502
+ };
503
+ }
504
+ var cellStyle = {
505
+ minWidth: width,
506
+ maxWidth: width,
507
+ minHeight: height,
508
+ maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
509
+ };
489
510
 
511
+ return cellStyle;
512
+ }, [width, height, isNotVisible]);
490
513
  React.useEffect(function () {
491
514
  if (!hasFocus || cellMode === GridCellModes.Edit) {
492
515
  return;
@@ -602,6 +625,7 @@ process.env.NODE_ENV !== "production" ? GridCellV7.propTypes = {
602
625
  value: PropTypes.any
603
626
  }),
604
627
  height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
628
+ isNotVisible: PropTypes.bool,
605
629
  onClick: PropTypes.func,
606
630
  onDoubleClick: PropTypes.func,
607
631
  onDragEnter: PropTypes.func,
@@ -39,6 +39,7 @@ export var GridRootStyles = styled('div', {
39
39
  '--unstable_DataGrid-radius': typeof radius === 'number' ? "".concat(radius, "px") : radius,
40
40
  '--unstable_DataGrid-headWeight': theme.typography.fontWeightMedium,
41
41
  '--unstable_DataGrid-overlayBackground': theme.vars ? "rgba(".concat(theme.vars.palette.background.defaultChannel, " / ").concat(theme.vars.palette.action.disabledOpacity, ")") : alpha(theme.palette.background.default, theme.palette.action.disabledOpacity),
42
+ '--DataGrid-cellOffsetMultiplier': 2,
42
43
  flex: 1,
43
44
  boxSizing: 'border-box',
44
45
  position: 'relative',
@@ -86,8 +86,8 @@ var GridPanel = /*#__PURE__*/React.forwardRef(function (props, ref) {
86
86
  anchorEl = _React$useState4[0],
87
87
  setAnchorEl = _React$useState4[1];
88
88
  React.useEffect(function () {
89
- var _apiRef$current$rootE, _apiRef$current$rootE2;
90
- var columnHeadersElement = (_apiRef$current$rootE = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE2 = _apiRef$current$rootE.current) == null ? void 0 : _apiRef$current$rootE2.querySelector(".".concat(gridClasses.columnHeaders));
89
+ var _apiRef$current$rootE;
90
+ var columnHeadersElement = (_apiRef$current$rootE = apiRef.current.rootElementRef) == null || (_apiRef$current$rootE = _apiRef$current$rootE.current) == null ? void 0 : _apiRef$current$rootE.querySelector(".".concat(gridClasses.columnHeaders));
91
91
  if (columnHeadersElement) {
92
92
  setAnchorEl(columnHeadersElement);
93
93
  }
@@ -247,7 +247,7 @@ var GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(props
247
247
  focus: function focus() {
248
248
  if (currentOperator != null && currentOperator.InputComponent) {
249
249
  var _valueRef$current;
250
- valueRef == null ? void 0 : (_valueRef$current = valueRef.current) == null ? void 0 : _valueRef$current.focus();
250
+ valueRef == null || (_valueRef$current = valueRef.current) == null ? void 0 : _valueRef$current.focus();
251
251
  } else {
252
252
  filterSelectorRef.current.focus();
253
253
  }
@@ -348,7 +348,7 @@ var GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(props
348
348
  native: isBaseSelectNative,
349
349
  inputRef: filterSelectorRef
350
350
  }, (_rootProps$slotProps8 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps8.baseSelect, {
351
- children: currentColumn == null ? void 0 : (_currentColumn$filter2 = currentColumn.filterOperators) == null ? void 0 : _currentColumn$filter2.map(function (operator) {
351
+ children: currentColumn == null || (_currentColumn$filter2 = currentColumn.filterOperators) == null ? void 0 : _currentColumn$filter2.map(function (operator) {
352
352
  return /*#__PURE__*/_createElement(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
353
353
  native: isBaseSelectNative,
354
354
  key: operator.value,
@@ -43,7 +43,7 @@ var SingleSelectOperatorContainer = styled('div')(_defineProperty({
43
43
  margin: 'auto 0px 5px 5px'
44
44
  }));
45
45
  function GridFilterInputSingleSelect(props) {
46
- var _item$value, _rootProps$slotProps$, _rootProps$slotProps, _rootProps$slotProps$2, _resolvedColumn, _resolvedColumn2, _rootProps$slotProps2, _rootProps$slotProps3, _rootProps$slotProps4;
46
+ var _item$value, _rootProps$slotProps$, _rootProps$slotProps, _resolvedColumn, _resolvedColumn2, _rootProps$slotProps2, _rootProps$slotProps3, _rootProps$slotProps4;
47
47
  var item = props.item,
48
48
  applyValue = props.applyValue,
49
49
  type = props.type,
@@ -64,7 +64,7 @@ function GridFilterInputSingleSelect(props) {
64
64
  var id = useId();
65
65
  var labelId = useId();
66
66
  var rootProps = useGridRootProps();
67
- var isSelectNative = (_rootProps$slotProps$ = (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : (_rootProps$slotProps$2 = _rootProps$slotProps.baseSelect) == null ? void 0 : _rootProps$slotProps$2.native) != null ? _rootProps$slotProps$ : true;
67
+ var isSelectNative = (_rootProps$slotProps$ = (_rootProps$slotProps = rootProps.slotProps) == null || (_rootProps$slotProps = _rootProps$slotProps.baseSelect) == null ? void 0 : _rootProps$slotProps.native) != null ? _rootProps$slotProps$ : true;
68
68
  var resolvedColumn = null;
69
69
  if (item.field) {
70
70
  var column = apiRef.current.getColumn(item.field);
@@ -208,8 +208,15 @@ export var applyInitialState = function applyInitialState(columnsState, initialS
208
208
  });
209
209
  return newColumnsState;
210
210
  };
211
+ function getDefaultColTypeDef(columnTypes, type) {
212
+ var colDef = columnTypes[DEFAULT_GRID_COL_TYPE_KEY];
213
+ if (type && columnTypes[type]) {
214
+ colDef = columnTypes[type];
215
+ }
216
+ return colDef;
217
+ }
211
218
  export var createColumnsState = function createColumnsState(_ref5) {
212
- var _apiRef$current$getRo, _apiRef$current$getRo2, _apiRef$current, _apiRef$current$getRo3;
219
+ var _apiRef$current$getRo, _apiRef$current$getRo2, _apiRef$current;
213
220
  var apiRef = _ref5.apiRef,
214
221
  columnsToUpsert = _ref5.columnsToUpsert,
215
222
  initialState = _ref5.initialState,
@@ -248,11 +255,7 @@ export var createColumnsState = function createColumnsState(_ref5) {
248
255
  columnsToKeep[field] = true;
249
256
  var existingState = columnsState.lookup[field];
250
257
  if (existingState == null) {
251
- var colDef = columnTypes[DEFAULT_GRID_COL_TYPE_KEY];
252
- if (newColumn.type && columnTypes[newColumn.type]) {
253
- colDef = columnTypes[newColumn.type];
254
- }
255
- existingState = _extends({}, colDef, {
258
+ existingState = _extends({}, getDefaultColTypeDef(columnTypes, newColumn.type), {
256
259
  field: field,
257
260
  hasBeenResized: false
258
261
  });
@@ -260,6 +263,13 @@ export var createColumnsState = function createColumnsState(_ref5) {
260
263
  } else if (keepOnlyColumnsToUpsert) {
261
264
  columnsState.orderedFields.push(field);
262
265
  }
266
+
267
+ // If the column type has changed - merge the existing state with the default column type definition
268
+ if (existingState && existingState.type !== newColumn.type) {
269
+ existingState = _extends({}, existingState, getDefaultColTypeDef(columnTypes, newColumn.type), {
270
+ field: field
271
+ });
272
+ }
263
273
  var hasBeenResized = existingState.hasBeenResized;
264
274
  COLUMNS_DIMENSION_PROPERTIES.forEach(function (key) {
265
275
  if (newColumn[key] !== undefined) {
@@ -282,7 +292,7 @@ export var createColumnsState = function createColumnsState(_ref5) {
282
292
  }
283
293
  var columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsState);
284
294
  var columnsStateWithPortableColumns = applyInitialState(columnsStateWithPreProcessing, initialState);
285
- return hydrateColumnsWidth(columnsStateWithPortableColumns, (_apiRef$current$getRo = (_apiRef$current$getRo2 = (_apiRef$current = apiRef.current).getRootDimensions) == null ? void 0 : (_apiRef$current$getRo3 = _apiRef$current$getRo2.call(_apiRef$current)) == null ? void 0 : _apiRef$current$getRo3.viewportInnerSize.width) != null ? _apiRef$current$getRo : 0);
295
+ return hydrateColumnsWidth(columnsStateWithPortableColumns, (_apiRef$current$getRo = (_apiRef$current$getRo2 = (_apiRef$current = apiRef.current).getRootDimensions) == null || (_apiRef$current$getRo2 = _apiRef$current$getRo2.call(_apiRef$current)) == null ? void 0 : _apiRef$current$getRo2.viewportInnerSize.width) != null ? _apiRef$current$getRo : 0);
286
296
  };
287
297
  export var mergeColumnsState = function mergeColumnsState(columnsState) {
288
298
  return function (state) {
@@ -13,13 +13,13 @@ import { getGridDefaultColumnTypes } from '../../../colDef';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  var defaultColumnTypes = getGridDefaultColumnTypes();
15
15
  export var columnsStateInitializer = function columnsStateInitializer(state, props, apiRef) {
16
- var _props$initialState, _ref, _props$columnVisibili, _props$initialState2, _props$initialState2$;
16
+ var _props$initialState, _ref, _props$columnVisibili, _props$initialState2;
17
17
  var columnsState = createColumnsState({
18
18
  apiRef: apiRef,
19
19
  columnTypes: defaultColumnTypes,
20
20
  columnsToUpsert: props.columns,
21
21
  initialState: (_props$initialState = props.initialState) == null ? void 0 : _props$initialState.columns,
22
- columnVisibilityModel: (_ref = (_props$columnVisibili = props.columnVisibilityModel) != null ? _props$columnVisibili : (_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.columns) == null ? void 0 : _props$initialState2$.columnVisibilityModel) != null ? _ref : {},
22
+ columnVisibilityModel: (_ref = (_props$columnVisibili = props.columnVisibilityModel) != null ? _props$columnVisibili : (_props$initialState2 = props.initialState) == null || (_props$initialState2 = _props$initialState2.columns) == null ? void 0 : _props$initialState2.columnVisibilityModel) != null ? _ref : {},
23
23
  keepOnlyColumnsToUpsert: true
24
24
  });
25
25
  return _extends({}, state, {
@@ -173,7 +173,7 @@ export function useGridColumns(apiRef, props) {
173
173
  * PRE-PROCESSING
174
174
  */
175
175
  var stateExportPreProcessing = React.useCallback(function (prevState, context) {
176
- var _props$initialState$c, _props$initialState3, _props$initialState3$;
176
+ var _props$initialState$c, _props$initialState3;
177
177
  var columnsStateToExport = {};
178
178
  var columnVisibilityModelToExport = gridColumnVisibilityModelSelector(apiRef);
179
179
  var shouldExportColumnVisibilityModel =
@@ -183,7 +183,7 @@ export function useGridColumns(apiRef, props) {
183
183
  props.columnVisibilityModel != null ||
184
184
  // Always export if the model has been initialized
185
185
  // TODO v6 Do a nullish check instead to export even if the initial model equals "{}"
186
- Object.keys((_props$initialState$c = (_props$initialState3 = props.initialState) == null ? void 0 : (_props$initialState3$ = _props$initialState3.columns) == null ? void 0 : _props$initialState3$.columnVisibilityModel) != null ? _props$initialState$c : {}).length > 0 ||
186
+ Object.keys((_props$initialState$c = (_props$initialState3 = props.initialState) == null || (_props$initialState3 = _props$initialState3.columns) == null ? void 0 : _props$initialState3.columnVisibilityModel) != null ? _props$initialState$c : {}).length > 0 ||
187
187
  // Always export if the model is not empty
188
188
  Object.keys(columnVisibilityModelToExport).length > 0;
189
189
  if (shouldExportColumnVisibilityModel) {
@@ -81,7 +81,7 @@ export function useGridDimensions(apiRef, props) {
81
81
  } else {
82
82
  viewportOuterSize = {
83
83
  width: rootDimensionsRef.current.width,
84
- height: rootDimensionsRef.current.height - totalHeaderHeight
84
+ height: Math.max(rootDimensionsRef.current.height - totalHeaderHeight, 0)
85
85
  };
86
86
  var scrollInformation = hasScroll({
87
87
  content: {
@@ -345,7 +345,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
345
345
  }());
346
346
  var setCellEditingEditCellValue = React.useCallback( /*#__PURE__*/function () {
347
347
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
348
- var _editingState$id, _editingState$id$fiel2;
348
+ var _editingState$id;
349
349
  var id, field, value, debounceMs, skipValueParser, column, row, parsedValue, editingState, newProps, hasChanged;
350
350
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
351
351
  while (1) switch (_context2.prev = _context2.next) {
@@ -399,7 +399,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
399
399
  newProps.value = column.preProcessEditCellProps ? editingState[id][field].value : parsedValue;
400
400
  updateOrDeleteFieldState(id, field, newProps);
401
401
  editingState = gridEditRowsStateSelector(apiRef.current.state);
402
- return _context2.abrupt("return", !((_editingState$id = editingState[id]) != null && (_editingState$id$fiel2 = _editingState$id[field]) != null && _editingState$id$fiel2.error));
402
+ return _context2.abrupt("return", !((_editingState$id = editingState[id]) != null && (_editingState$id = _editingState$id[field]) != null && _editingState$id.error));
403
403
  case 24:
404
404
  case "end":
405
405
  return _context2.stop();
@@ -451,11 +451,11 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
451
451
  id = _ref4[0],
452
452
  fields = _ref4[1];
453
453
  Object.entries(fields).forEach(function (_ref5) {
454
- var _copyOfPrevCellModes$, _copyOfPrevCellModes$2, _idToIdLookup$id;
454
+ var _copyOfPrevCellModes$, _idToIdLookup$id;
455
455
  var _ref6 = _slicedToArray(_ref5, 2),
456
456
  field = _ref6[0],
457
457
  params = _ref6[1];
458
- var prevMode = ((_copyOfPrevCellModes$ = copyOfPrevCellModes[id]) == null ? void 0 : (_copyOfPrevCellModes$2 = _copyOfPrevCellModes$[field]) == null ? void 0 : _copyOfPrevCellModes$2.mode) || GridCellModes.View;
458
+ var prevMode = ((_copyOfPrevCellModes$ = copyOfPrevCellModes[id]) == null || (_copyOfPrevCellModes$ = _copyOfPrevCellModes$[field]) == null ? void 0 : _copyOfPrevCellModes$.mode) || GridCellModes.View;
459
459
  var originalId = (_idToIdLookup$id = idToIdLookup[id]) != null ? _idToIdLookup$id : id;
460
460
  if (params.mode === GridCellModes.Edit && prevMode === GridCellModes.View) {
461
461
  updateStateToStartCellEditMode(_extends({
@@ -4,15 +4,13 @@ import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../../colDef';
4
4
  import { buildWarning } from '../../../../utils/warning';
5
5
  function sanitizeCellValue(value, delimiterCharacter) {
6
6
  if (typeof value === 'string') {
7
- var formattedValue = value.replace(/"/g, '""');
8
-
9
7
  // Make sure value containing delimiter or line break won't be split into multiple rows
10
- if ([delimiterCharacter, '\n', '\r'].some(function (delimiter) {
11
- return formattedValue.includes(delimiter);
8
+ if ([delimiterCharacter, '\n', '\r', '"'].some(function (delimiter) {
9
+ return value.includes(delimiter);
12
10
  })) {
13
- return "\"".concat(formattedValue, "\"");
11
+ return "\"".concat(value.replace(/"/g, '""'), "\"");
14
12
  }
15
- return formattedValue;
13
+ return value;
16
14
  }
17
15
  return value;
18
16
  }
@@ -131,11 +131,12 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
131
131
  var _printDoc$body$classL;
132
132
  (_printDoc$body$classL = printDoc.body.classList).add.apply(_printDoc$body$classL, _toConsumableArray(normalizeOptions.bodyClassName.split(' ')));
133
133
  }
134
+ var stylesheetLoadPromises = [];
134
135
  if (normalizeOptions.copyStyles) {
135
136
  var rootCandidate = gridRootElement.getRootNode();
136
137
  var root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc.current;
137
138
  var headStyleElements = root.querySelectorAll("style, link[rel='stylesheet']");
138
- for (var i = 0; i < headStyleElements.length; i += 1) {
139
+ var _loop = function _loop() {
139
140
  var node = headStyleElements[i];
140
141
  if (node.tagName === 'STYLE') {
141
142
  var newHeadStyleElements = printDoc.createElement(node.tagName);
@@ -161,24 +162,35 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
161
162
  _newHeadStyleElements.setAttribute(attr.nodeName, attr.nodeValue || '');
162
163
  }
163
164
  }
165
+ stylesheetLoadPromises.push(new Promise(function (resolve) {
166
+ _newHeadStyleElements.addEventListener('load', function () {
167
+ return resolve();
168
+ });
169
+ }));
164
170
  printDoc.head.appendChild(_newHeadStyleElements);
165
171
  }
172
+ };
173
+ for (var i = 0; i < headStyleElements.length; i += 1) {
174
+ _loop();
166
175
  }
167
176
  }
168
177
 
169
178
  // Trigger print
170
179
  if (process.env.NODE_ENV !== 'test') {
171
- printWindow.contentWindow.print();
180
+ // wait for remote stylesheets to load
181
+ Promise.all(stylesheetLoadPromises).then(function () {
182
+ printWindow.contentWindow.print();
183
+ });
172
184
  }
173
185
  }, [apiRef, doc, props.columnHeaderHeight]);
174
186
  var handlePrintWindowAfterPrint = React.useCallback(function (printWindow) {
175
- var _previousGridState$cu, _previousGridState$cu2;
187
+ var _previousGridState$cu;
176
188
  // Remove the print iframe
177
189
  doc.current.body.removeChild(printWindow);
178
190
 
179
191
  // Revert grid to previous state
180
192
  apiRef.current.restoreState(previousGridState.current || {});
181
- if (!((_previousGridState$cu = previousGridState.current) != null && (_previousGridState$cu2 = _previousGridState$cu.columns) != null && _previousGridState$cu2.columnVisibilityModel)) {
193
+ if (!((_previousGridState$cu = previousGridState.current) != null && (_previousGridState$cu = _previousGridState$cu.columns) != null && _previousGridState$cu.columnVisibilityModel)) {
182
194
  // if the apiRef.current.exportState(); did not exported the column visibility, we update it
183
195
  apiRef.current.setColumnVisibilityModel(previousColumnVisibility.current);
184
196
  }
@@ -30,10 +30,10 @@ export var defaultGetRowsToExport = function defaultGetRowsToExport(_ref2) {
30
30
  return rowTree[id].type !== 'footer';
31
31
  });
32
32
  var pinnedRows = gridPinnedRowsSelector(apiRef);
33
- var topPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.map(function (row) {
33
+ var topPinnedRowsIds = (pinnedRows == null || (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.map(function (row) {
34
34
  return row.id;
35
35
  })) || [];
36
- var bottomPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.map(function (row) {
36
+ var bottomPinnedRowsIds = (pinnedRows == null || (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.map(function (row) {
37
37
  return row.id;
38
38
  })) || [];
39
39
  bodyRows.unshift.apply(bodyRows, _toConsumableArray(topPinnedRowsIds));
@@ -136,7 +136,7 @@ export var gridFilterActiveItemsSelector = createSelectorMemoized(gridFilterMode
136
136
  return false;
137
137
  }
138
138
  var column = columnLookup[item.field];
139
- if (!(column != null && column.filterOperators) || (column == null ? void 0 : (_column$filterOperato = column.filterOperators) == null ? void 0 : _column$filterOperato.length) === 0) {
139
+ if (!(column != null && column.filterOperators) || (column == null || (_column$filterOperato = column.filterOperators) == null ? void 0 : _column$filterOperato.length) === 0) {
140
140
  return false;
141
141
  }
142
142
  var filterOperator = column.filterOperators.find(function (operator) {
@@ -132,6 +132,7 @@ var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem, a
132
132
  }
133
133
  };
134
134
  };
135
+ var filterItemsApplierId = 1;
135
136
 
136
137
  /**
137
138
  * Generates a method to easily check if a row is matching the current filter model.
@@ -150,16 +151,35 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
150
151
  if (appliers.length === 0) {
151
152
  return null;
152
153
  }
153
- return function (row, shouldApplyFilter) {
154
- var resultPerItemId = {};
155
- for (var i = 0; i < appliers.length; i += 1) {
156
- var applier = appliers[i];
157
- if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
158
- resultPerItemId[applier.item.id] = applier.v7 ? applier.fn(row) : applier.fn(getRowId ? getRowId(row) : row.id);
159
- }
160
- }
161
- return resultPerItemId;
162
- };
154
+
155
+ // Original logic:
156
+ // return (row, shouldApplyFilter) => {
157
+ // const resultPerItemId: GridFilterItemResult = {};
158
+ //
159
+ // for (let i = 0; i < appliers.length; i += 1) {
160
+ // const applier = appliers[i];
161
+ // if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
162
+ // resultPerItemId[applier.item.id!] = applier.v7
163
+ // ? applier.fn(row)
164
+ // : applier.fn(getRowId ? getRowId(row) : row.id);
165
+ // }
166
+ // }
167
+ //
168
+ // return resultPerItemId;
169
+ // };
170
+
171
+ // We generate a new function with `eval()` to avoid expensive patterns for JS engines
172
+ // such as a dynamic object assignment, e.g. `{ [dynamicKey]: value }`.
173
+ var filterItemTemplate = "(function filterItem$$(row, shouldApplyFilter) {\n ".concat(appliers.map(function (applier, i) {
174
+ return "const shouldApply".concat(i, " = !shouldApplyFilter || shouldApplyFilter(").concat(JSON.stringify(applier.item.field), ");");
175
+ }).join('\n'), "\n\n const result$$ = {\n ").concat(appliers.map(function (applier, i) {
176
+ return "".concat(JSON.stringify(String(applier.item.id)), ":\n !shouldApply").concat(i, " ?\n false :\n ").concat(applier.v7 ? "appliers[".concat(i, "].fn(row)") : "appliers[".concat(i, "].fn(").concat(getRowId ? 'getRowId(row)' : 'row.id', ")"), ",\n ");
177
+ }).join('\n'), "};\n\n return result$$;\n })");
178
+
179
+ // eslint-disable-next-line no-eval
180
+ var filterItem = eval(filterItemTemplate.replaceAll('$$', String(filterItemsApplierId)));
181
+ filterItemsApplierId += 1;
182
+ return filterItem;
163
183
  };
164
184
 
165
185
  /**