@mui/x-data-grid 5.17.17 → 5.17.19

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 (37) hide show
  1. package/CHANGELOG.md +60 -3
  2. package/components/columnHeaders/GridColumnHeaders.js +1 -0
  3. package/hooks/features/clipboard/useGridClipboard.js +19 -3
  4. package/hooks/features/export/useGridPrintExport.js +31 -17
  5. package/hooks/features/virtualization/useGridVirtualScroller.js +19 -10
  6. package/index.js +1 -1
  7. package/internals/index.d.ts +1 -1
  8. package/internals/index.js +1 -1
  9. package/legacy/components/columnHeaders/GridColumnHeaders.js +1 -0
  10. package/legacy/hooks/features/clipboard/useGridClipboard.js +19 -3
  11. package/legacy/hooks/features/export/useGridPrintExport.js +33 -20
  12. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +21 -12
  13. package/legacy/index.js +1 -1
  14. package/legacy/internals/index.js +1 -1
  15. package/legacy/locales/esES.js +27 -27
  16. package/legacy/utils/utils.js +1 -1
  17. package/locales/esES.js +27 -27
  18. package/models/api/gridParamsApi.d.ts +1 -1
  19. package/modern/components/columnHeaders/GridColumnHeaders.js +1 -0
  20. package/modern/hooks/features/clipboard/useGridClipboard.js +17 -1
  21. package/modern/hooks/features/export/useGridPrintExport.js +30 -16
  22. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +19 -10
  23. package/modern/index.js +1 -1
  24. package/modern/internals/index.js +1 -1
  25. package/modern/locales/esES.js +27 -27
  26. package/modern/utils/utils.js +1 -1
  27. package/node/components/columnHeaders/GridColumnHeaders.js +1 -0
  28. package/node/hooks/features/clipboard/useGridClipboard.js +19 -3
  29. package/node/hooks/features/export/useGridPrintExport.js +31 -17
  30. package/node/hooks/features/virtualization/useGridVirtualScroller.js +19 -10
  31. package/node/index.js +1 -1
  32. package/node/internals/index.js +6 -0
  33. package/node/locales/esES.js +27 -27
  34. package/node/utils/utils.js +1 -1
  35. package/package.json +1 -1
  36. package/utils/utils.d.ts +1 -1
  37. package/utils/utils.js +1 -1
package/CHANGELOG.md CHANGED
@@ -3,16 +3,73 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 5.17.19
7
+
8
+ _Jan 16, 2023_
9
+
10
+ We'd like to offer a big thanks to the 4 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🌍 Improve Spanish (es-ES) and add Belarusian (be-BY) and Urdu (ur-PK) locales
13
+ - 🐞 Bugfixes
14
+
15
+ ### `@mui/x-data-grid@v5.17.19` / `@mui/x-data-grid-pro@v5.17.19` / `@mui/x-data-grid-premium@v5.17.19`
16
+
17
+ #### Changes
18
+
19
+ - [DataGrid] Improve print support (#7407) @cherniavskii
20
+ - [DataGrid] Improve Spanish (es-ES) locale (#7438) @Anderssxn
21
+ - [DataGridPremium] Fix Excel export not working with date strings (#7478) @cherniavskii
22
+ - [DataGridPro] Fix missing column headers border with top-pinned rows (#7399) @cherniavskii
23
+
24
+ ### `@mui/x-date-pickers@v5.0.14` / `@mui/x-date-pickers-pro@v5.0.14`
25
+
26
+ #### Changes
27
+
28
+ - [pickers] Add Belarusian (be-BY) locale (#7450) @volhalink
29
+ - [pickers] Add Urdu (ur-PK) locale (#7449) @MBilalShafi
30
+
31
+ ## 5.17.18
32
+
33
+ _Jan 5, 2023_
34
+
35
+ We'd like to offer a big thanks to the 3 contributors who made this release possible. Here are some highlights ✨:
36
+
37
+ - 🐞 Bugfixes
38
+
39
+ ### `@mui/x-data-grid@v5.17.18` / `@mui/x-data-grid-pro@v5.17.18` / `@mui/x-data-grid-premium@v5.17.18`
40
+
41
+ #### Changes
42
+
43
+ - [DataGrid] Fix rows not rendering properly after height change (#7376) @cherniavskii
44
+ - [DataGrid] Fix selected text in cell input not being copied in Firefox (#7330) @cherniavskii
45
+ - [DataGridPremium] Export row grouping column menu components (#7308) @cherniavskii
46
+
47
+ ### `@mui/x-date-pickers@v5.0.13` / `@mui/x-date-pickers-pro@v5.0.13`
48
+
49
+ #### Changes
50
+
51
+ - [pickers] Fix the product license reference name (#7367)
52
+
53
+ ### Docs
54
+
55
+ - [docs] Redirect translated pages (#7370) @cherniavskii
56
+
57
+ ### Core
58
+
59
+ - [core] Fix release date (#7314) @DanailH
60
+ - [core] Fix the product license reference name (#7367) @oliviertassinari
61
+ - [core] Upgrade monorepo (#7344) @cherniavskii
62
+
6
63
  ## 5.17.17
7
64
 
8
- _Dec 23, 2022_
65
+ _Dec 24, 2022_
9
66
 
10
67
  We'd like to offer a big thanks to the 4 contributors who made this release possible. Here are some highlights ✨:
11
68
 
12
69
  - 🌍 Improve Russian (ru-RU) and Korean (ko-KR) locales
13
70
  - 🐞 Bugfixes
14
71
 
15
- ### `@mui/x-data-grid@5.17.17` / `@mui/x-data-grid-pro@5.17.17` / `@mui/x-data-grid-premium@5.17.17`
72
+ ### `@mui/x-data-grid@v5.17.17` / `@mui/x-data-grid-pro@v5.17.17` / `@mui/x-data-grid-premium@v5.17.17`
16
73
 
17
74
  #### Changes
18
75
 
@@ -20,7 +77,7 @@ We'd like to offer a big thanks to the 4 contributors who made this release poss
20
77
  - [DataGridPro] Use row ID as `key` of the detail panels (#7311) @m4theushw
21
78
  - [DataGridPremium] Fix `exceljs` import with parcel (#7285) @alexfauquette
22
79
 
23
- ### `@mui/x-date-pickers@5.0.12` / `@mui/x-date-pickers-pro@5.0.12`
80
+ ### `@mui/x-date-pickers@v5.0.12` / `@mui/x-date-pickers-pro@v5.0.12`
24
81
 
25
82
  #### Changes
26
83
 
@@ -35,6 +35,7 @@ const GridColumnHeadersRoot = styled('div', {
35
35
  overflow: 'hidden',
36
36
  display: 'flex',
37
37
  alignItems: 'center',
38
+ boxSizing: 'border-box',
38
39
  borderBottom: `1px solid ${borderColor}`,
39
40
  borderTopLeftRadius: theme.shape.borderRadius,
40
41
  borderTopRightRadius: theme.shape.borderRadius
@@ -20,6 +20,24 @@ function writeToClipboardPolyfill(data) {
20
20
  document.body.removeChild(span);
21
21
  }
22
22
  }
23
+
24
+ function hasNativeSelection(element) {
25
+ var _window$getSelection;
26
+
27
+ if (((_window$getSelection = window.getSelection()) == null ? void 0 : _window$getSelection.toString()) !== '') {
28
+ return true;
29
+ }
30
+
31
+ if (!element) {
32
+ return false;
33
+ }
34
+
35
+ if ((element.selectionEnd || 0) - (element.selectionStart || 0) > 0) {
36
+ return true;
37
+ }
38
+
39
+ return false;
40
+ }
23
41
  /**
24
42
  * @requires useGridCsvExport (method)
25
43
  * @requires useGridSelection (method)
@@ -46,8 +64,6 @@ export const useGridClipboard = apiRef => {
46
64
  }
47
65
  }, [apiRef]);
48
66
  const handleKeydown = React.useCallback(event => {
49
- var _window$getSelection;
50
-
51
67
  const isModifierKeyPressed = event.ctrlKey || event.metaKey || event.altKey; // event.key === 'c' is not enough as alt+c can lead to ©, ç, or other characters on macOS.
52
68
  // event.code === 'KeyC' is not enough as event.code assume a QWERTY keyboard layout which would
53
69
  // be wrong with a Dvorak keyboard (as if pressing J).
@@ -57,7 +73,7 @@ export const useGridClipboard = apiRef => {
57
73
  } // Do nothing if there's a native selection
58
74
 
59
75
 
60
- if (((_window$getSelection = window.getSelection()) == null ? void 0 : _window$getSelection.toString()) !== '') {
76
+ if (hasNativeSelection(event.target)) {
61
77
  return;
62
78
  }
63
79
 
@@ -13,6 +13,14 @@ import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
13
13
  import { GridPrintExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
 
16
+ function raf() {
17
+ return new Promise(resolve => {
18
+ requestAnimationFrame(() => {
19
+ resolve();
20
+ });
21
+ });
22
+ }
23
+
16
24
  /**
17
25
  * @requires useGridColumns (state)
18
26
  * @requires useGridFilter (state)
@@ -30,6 +38,7 @@ export const useGridPrintExport = (apiRef, props) => {
30
38
  // the new state needs to be in place before the grid can be sized correctly
31
39
 
32
40
  const updateGridColumnsForPrint = React.useCallback((fields, allColumns) => new Promise(resolve => {
41
+ // TODO remove unused Promise
33
42
  if (!fields && !allColumns) {
34
43
  resolve();
35
44
  return;
@@ -49,12 +58,10 @@ export const useGridPrintExport = (apiRef, props) => {
49
58
  });
50
59
  apiRef.current.setColumnVisibilityModel(newColumnVisibilityModel);
51
60
  resolve();
52
- }), [apiRef]);
61
+ }), [apiRef]); // TODO move outside of this scope and remove React.useCallback
62
+
53
63
  const buildPrintWindow = React.useCallback(title => {
54
64
  const iframeEl = document.createElement('iframe');
55
- iframeEl.id = 'grid-print-window'; // Without this 'onload' event won't fire in some browsers
56
-
57
- iframeEl.src = window.location.href;
58
65
  iframeEl.style.position = 'absolute';
59
66
  iframeEl.style.width = '0px';
60
67
  iframeEl.style.height = '0px';
@@ -62,18 +69,15 @@ export const useGridPrintExport = (apiRef, props) => {
62
69
  return iframeEl;
63
70
  }, []);
64
71
  const handlePrintWindowLoad = React.useCallback((printWindow, options) => {
65
- var _printWindow$contentW, _querySelector, _querySelector2;
72
+ var _querySelector, _querySelector2;
66
73
 
67
74
  const normalizeOptions = _extends({
68
75
  copyStyles: true,
69
76
  hideToolbar: false,
70
77
  hideFooter: false
71
- }, options); // Some agents, such as IE11 and Enzyme (as of 2 Jun 2020) continuously call the
72
- // `onload` callback. This ensures that it is only called once.
78
+ }, options);
73
79
 
74
-
75
- printWindow.onload = null;
76
- const printDoc = printWindow.contentDocument || ((_printWindow$contentW = printWindow.contentWindow) == null ? void 0 : _printWindow$contentW.document);
80
+ const printDoc = printWindow.contentDocument;
77
81
 
78
82
  if (!printDoc) {
79
83
  return;
@@ -113,10 +117,12 @@ export const useGridPrintExport = (apiRef, props) => {
113
117
  } // Expand container height to accommodate all rows
114
118
 
115
119
 
116
- gridClone.style.height = `${rowsMeta.currentPageTotalHeight + totalHeaderHeight + gridToolbarElementHeight + gridFooterElementHeight}px`; // Remove all loaded elements from the current host
120
+ gridClone.style.height = `${rowsMeta.currentPageTotalHeight + totalHeaderHeight + gridToolbarElementHeight + gridFooterElementHeight}px`; // printDoc.body.appendChild(gridClone); should be enough but a clone isolation bug in Safari
121
+ // prevents us to do it
117
122
 
118
- printDoc.body.innerHTML = '';
119
- printDoc.body.appendChild(gridClone);
123
+ const container = document.createElement('div');
124
+ container.appendChild(gridClone);
125
+ printDoc.body.innerHTML = container.innerHTML;
120
126
  const defaultPageStyle = typeof normalizeOptions.pageStyle === 'function' ? normalizeOptions.pageStyle() : normalizeOptions.pageStyle;
121
127
 
122
128
  if (typeof defaultPageStyle === 'string') {
@@ -210,17 +216,25 @@ export const useGridPrintExport = (apiRef, props) => {
210
216
 
211
217
  await updateGridColumnsForPrint(options == null ? void 0 : options.fields, options == null ? void 0 : options.allColumns);
212
218
  apiRef.current.unstable_disableVirtualization();
219
+ await raf(); // wait for the state changes to take action
220
+
213
221
  const printWindow = buildPrintWindow(options == null ? void 0 : options.fileName);
214
- doc.current.body.appendChild(printWindow);
215
222
 
216
223
  if (process.env.NODE_ENV === 'test') {
217
- // In test env, run the all pipeline without waiting for loading
224
+ doc.current.body.appendChild(printWindow); // In test env, run the all pipeline without waiting for loading
225
+
218
226
  handlePrintWindowLoad(printWindow, options);
219
227
  handlePrintWindowAfterPrint(printWindow);
220
228
  } else {
221
- printWindow.onload = () => handlePrintWindowLoad(printWindow, options);
229
+ printWindow.onload = () => {
230
+ handlePrintWindowLoad(printWindow, options);
231
+
232
+ printWindow.contentWindow.onafterprint = () => {
233
+ handlePrintWindowAfterPrint(printWindow);
234
+ };
235
+ };
222
236
 
223
- printWindow.contentWindow.onafterprint = () => handlePrintWindowAfterPrint(printWindow);
237
+ doc.current.body.appendChild(printWindow);
224
238
  }
225
239
  }, [props, logger, apiRef, buildPrintWindow, handlePrintWindowLoad, handlePrintWindowAfterPrint, updateGridColumnsForPrint]);
226
240
  const printExportApi = {
@@ -85,7 +85,10 @@ export const useGridVirtualScroller = props => {
85
85
  top: 0,
86
86
  left: 0
87
87
  });
88
- const [containerWidth, setContainerWidth] = React.useState(null);
88
+ const [containerDimensions, setContainerDimensions] = React.useState({
89
+ width: null,
90
+ height: null
91
+ });
89
92
  const prevTotalWidth = React.useRef(columnsTotalWidth);
90
93
  const getNearestIndexToRender = React.useCallback(offset => {
91
94
  var _currentPage$range, _currentPage$range2;
@@ -129,7 +132,7 @@ export const useGridVirtualScroller = props => {
129
132
  // In the last index, this is not needed because Array.slice doesn't include it.
130
133
 
131
134
  const firstRowIndex = Math.min(getNearestIndexToRender(top), rowsMeta.positions.length - 1);
132
- const lastRowIndex = rootProps.autoHeight ? firstRowIndex + currentPage.rows.length : getNearestIndexToRender(top + rootRef.current.clientHeight);
135
+ const lastRowIndex = rootProps.autoHeight ? firstRowIndex + currentPage.rows.length : getNearestIndexToRender(top + containerDimensions.height);
133
136
  let hasRowWithAutoHeight = false;
134
137
  let firstColumnIndex = 0;
135
138
  let lastColumnIndex = columnPositions.length;
@@ -148,7 +151,7 @@ export const useGridVirtualScroller = props => {
148
151
 
149
152
  if (!hasRowWithAutoHeight) {
150
153
  firstColumnIndex = binarySearch(left, columnPositions);
151
- lastColumnIndex = binarySearch(left + containerWidth, columnPositions);
154
+ lastColumnIndex = binarySearch(left + containerDimensions.width, columnPositions);
152
155
  }
153
156
 
154
157
  return {
@@ -157,7 +160,7 @@ export const useGridVirtualScroller = props => {
157
160
  firstColumnIndex,
158
161
  lastColumnIndex
159
162
  };
160
- }, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerWidth]);
163
+ }, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerDimensions]);
161
164
  useEnhancedEffect(() => {
162
165
  if (disableVirtualization) {
163
166
  renderZoneRef.current.style.transform = `translate3d(0px, 0px, 0px)`;
@@ -168,10 +171,16 @@ export const useGridVirtualScroller = props => {
168
171
  }
169
172
  }, [disableVirtualization]);
170
173
  useEnhancedEffect(() => {
171
- setContainerWidth(rootRef.current.clientWidth);
174
+ setContainerDimensions({
175
+ width: rootRef.current.clientWidth,
176
+ height: rootRef.current.clientHeight
177
+ });
172
178
  }, [rowsMeta.currentPageTotalHeight]);
173
179
  const handleResize = React.useCallback(params => {
174
- setContainerWidth(params.width);
180
+ setContainerDimensions({
181
+ width: params.width,
182
+ height: params.height
183
+ });
175
184
  }, []);
176
185
  useGridApiEventHandler(apiRef, 'resize', handleResize);
177
186
  const updateRenderZonePosition = React.useCallback(nextRenderContext => {
@@ -229,7 +238,7 @@ export const useGridVirtualScroller = props => {
229
238
  prevRenderContext.current = nextRenderContext;
230
239
  }, [apiRef, setRenderContext, prevRenderContext, currentPage.rows.length, rootProps.rowBuffer]);
231
240
  useEnhancedEffect(() => {
232
- if (containerWidth == null) {
241
+ if (containerDimensions.width == null) {
233
242
  return;
234
243
  }
235
244
 
@@ -245,7 +254,7 @@ export const useGridVirtualScroller = props => {
245
254
  renderContext: initialRenderContext
246
255
  };
247
256
  apiRef.current.publishEvent('rowsScroll', params);
248
- }, [apiRef, computeRenderContext, containerWidth, updateRenderContext]);
257
+ }, [apiRef, computeRenderContext, containerDimensions.width, updateRenderContext]);
249
258
 
250
259
  const handleScroll = event => {
251
260
  const {
@@ -297,7 +306,7 @@ export const useGridVirtualScroller = props => {
297
306
  renderContext: nextRenderContext,
298
307
  minFirstColumn = renderZoneMinColumnIndex,
299
308
  maxLastColumn = renderZoneMaxColumnIndex,
300
- availableSpace = containerWidth,
309
+ availableSpace = containerDimensions.width,
301
310
  rowIndexOffset = 0,
302
311
  position = 'center'
303
312
  } = params;
@@ -403,7 +412,7 @@ export const useGridVirtualScroller = props => {
403
412
  return rows;
404
413
  };
405
414
 
406
- const needsHorizontalScrollbar = containerWidth && columnsTotalWidth > containerWidth;
415
+ const needsHorizontalScrollbar = containerDimensions.width && columnsTotalWidth > containerDimensions.width;
407
416
  const contentSize = React.useMemo(() => {
408
417
  // In cases where the columns exceed the available width,
409
418
  // the horizontal scrollbar should be shown even when there're no rows.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.17
1
+ /** @license MUI X v5.17.19
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -54,7 +54,7 @@ export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/ex
54
54
  export { createSelector, unstable_resetCreateSelectorCache } from '../utils/createSelector';
55
55
  export { findParentElementFromClassName } from '../utils/domUtils';
56
56
  export { isNavigationKey } from '../utils/keyboardUtils';
57
- export { clamp, isDeepEqual, isNumber, isFunction } from '../utils/utils';
57
+ export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
58
58
  export { buildWarning } from '../utils/warning';
59
59
  export { exportAs } from '../utils/exportAs';
60
60
  export type { GridApiCommunity } from '../models/api/gridApiCommunity';
@@ -45,6 +45,6 @@ export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/ex
45
45
  export { createSelector, unstable_resetCreateSelectorCache } from '../utils/createSelector';
46
46
  export { findParentElementFromClassName } from '../utils/domUtils';
47
47
  export { isNavigationKey } from '../utils/keyboardUtils';
48
- export { clamp, isDeepEqual, isNumber, isFunction } from '../utils/utils';
48
+ export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
49
49
  export { buildWarning } from '../utils/warning';
50
50
  export { exportAs } from '../utils/exportAs';
@@ -34,6 +34,7 @@ var GridColumnHeadersRoot = styled('div', {
34
34
  overflow: 'hidden',
35
35
  display: 'flex',
36
36
  alignItems: 'center',
37
+ boxSizing: 'border-box',
37
38
  borderBottom: "1px solid ".concat(borderColor),
38
39
  borderTopLeftRadius: theme.shape.borderRadius,
39
40
  borderTopRightRadius: theme.shape.borderRadius
@@ -20,6 +20,24 @@ function writeToClipboardPolyfill(data) {
20
20
  document.body.removeChild(span);
21
21
  }
22
22
  }
23
+
24
+ function hasNativeSelection(element) {
25
+ var _window$getSelection;
26
+
27
+ if (((_window$getSelection = window.getSelection()) == null ? void 0 : _window$getSelection.toString()) !== '') {
28
+ return true;
29
+ }
30
+
31
+ if (!element) {
32
+ return false;
33
+ }
34
+
35
+ if ((element.selectionEnd || 0) - (element.selectionStart || 0) > 0) {
36
+ return true;
37
+ }
38
+
39
+ return false;
40
+ }
23
41
  /**
24
42
  * @requires useGridCsvExport (method)
25
43
  * @requires useGridSelection (method)
@@ -48,8 +66,6 @@ export var useGridClipboard = function useGridClipboard(apiRef) {
48
66
  }
49
67
  }, [apiRef]);
50
68
  var handleKeydown = React.useCallback(function (event) {
51
- var _window$getSelection;
52
-
53
69
  var isModifierKeyPressed = event.ctrlKey || event.metaKey || event.altKey; // event.key === 'c' is not enough as alt+c can lead to ©, ç, or other characters on macOS.
54
70
  // event.code === 'KeyC' is not enough as event.code assume a QWERTY keyboard layout which would
55
71
  // be wrong with a Dvorak keyboard (as if pressing J).
@@ -59,7 +75,7 @@ export var useGridClipboard = function useGridClipboard(apiRef) {
59
75
  } // Do nothing if there's a native selection
60
76
 
61
77
 
62
- if (((_window$getSelection = window.getSelection()) == null ? void 0 : _window$getSelection.toString()) !== '') {
78
+ if (hasNativeSelection(event.target)) {
63
79
  return;
64
80
  }
65
81
 
@@ -16,6 +16,14 @@ import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
16
16
  import { GridPrintExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
17
17
  import { jsx as _jsx } from "react/jsx-runtime";
18
18
 
19
+ function raf() {
20
+ return new Promise(function (resolve) {
21
+ requestAnimationFrame(function () {
22
+ resolve();
23
+ });
24
+ });
25
+ }
26
+
19
27
  /**
20
28
  * @requires useGridColumns (state)
21
29
  * @requires useGridFilter (state)
@@ -34,6 +42,7 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
34
42
 
35
43
  var updateGridColumnsForPrint = React.useCallback(function (fields, allColumns) {
36
44
  return new Promise(function (resolve) {
45
+ // TODO remove unused Promise
37
46
  if (!fields && !allColumns) {
38
47
  resolve();
39
48
  return;
@@ -56,12 +65,10 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
56
65
  apiRef.current.setColumnVisibilityModel(newColumnVisibilityModel);
57
66
  resolve();
58
67
  });
59
- }, [apiRef]);
68
+ }, [apiRef]); // TODO move outside of this scope and remove React.useCallback
69
+
60
70
  var buildPrintWindow = React.useCallback(function (title) {
61
71
  var iframeEl = document.createElement('iframe');
62
- iframeEl.id = 'grid-print-window'; // Without this 'onload' event won't fire in some browsers
63
-
64
- iframeEl.src = window.location.href;
65
72
  iframeEl.style.position = 'absolute';
66
73
  iframeEl.style.width = '0px';
67
74
  iframeEl.style.height = '0px';
@@ -69,18 +76,15 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
69
76
  return iframeEl;
70
77
  }, []);
71
78
  var handlePrintWindowLoad = React.useCallback(function (printWindow, options) {
72
- var _printWindow$contentW, _querySelector, _querySelector2;
79
+ var _querySelector, _querySelector2;
73
80
 
74
81
  var normalizeOptions = _extends({
75
82
  copyStyles: true,
76
83
  hideToolbar: false,
77
84
  hideFooter: false
78
- }, options); // Some agents, such as IE11 and Enzyme (as of 2 Jun 2020) continuously call the
79
- // `onload` callback. This ensures that it is only called once.
85
+ }, options);
80
86
 
81
-
82
- printWindow.onload = null;
83
- var printDoc = printWindow.contentDocument || ((_printWindow$contentW = printWindow.contentWindow) == null ? void 0 : _printWindow$contentW.document);
87
+ var printDoc = printWindow.contentDocument;
84
88
 
85
89
  if (!printDoc) {
86
90
  return;
@@ -120,10 +124,12 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
120
124
  } // Expand container height to accommodate all rows
121
125
 
122
126
 
123
- gridClone.style.height = "".concat(rowsMeta.currentPageTotalHeight + totalHeaderHeight + gridToolbarElementHeight + gridFooterElementHeight, "px"); // Remove all loaded elements from the current host
127
+ gridClone.style.height = "".concat(rowsMeta.currentPageTotalHeight + totalHeaderHeight + gridToolbarElementHeight + gridFooterElementHeight, "px"); // printDoc.body.appendChild(gridClone); should be enough but a clone isolation bug in Safari
128
+ // prevents us to do it
124
129
 
125
- printDoc.body.innerHTML = '';
126
- printDoc.body.appendChild(gridClone);
130
+ var container = document.createElement('div');
131
+ container.appendChild(gridClone);
132
+ printDoc.body.innerHTML = container.innerHTML;
127
133
  var defaultPageStyle = typeof normalizeOptions.pageStyle === 'function' ? normalizeOptions.pageStyle() : normalizeOptions.pageStyle;
128
134
 
129
135
  if (typeof defaultPageStyle === 'string') {
@@ -232,24 +238,31 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
232
238
 
233
239
  case 8:
234
240
  apiRef.current.unstable_disableVirtualization();
241
+ _context.next = 11;
242
+ return raf();
243
+
244
+ case 11:
245
+ // wait for the state changes to take action
235
246
  printWindow = buildPrintWindow(options == null ? void 0 : options.fileName);
236
- doc.current.body.appendChild(printWindow);
237
247
 
238
248
  if (process.env.NODE_ENV === 'test') {
239
- // In test env, run the all pipeline without waiting for loading
249
+ doc.current.body.appendChild(printWindow); // In test env, run the all pipeline without waiting for loading
250
+
240
251
  handlePrintWindowLoad(printWindow, options);
241
252
  handlePrintWindowAfterPrint(printWindow);
242
253
  } else {
243
254
  printWindow.onload = function () {
244
- return handlePrintWindowLoad(printWindow, options);
245
- };
255
+ handlePrintWindowLoad(printWindow, options);
246
256
 
247
- printWindow.contentWindow.onafterprint = function () {
248
- return handlePrintWindowAfterPrint(printWindow);
257
+ printWindow.contentWindow.onafterprint = function () {
258
+ handlePrintWindowAfterPrint(printWindow);
259
+ };
249
260
  };
261
+
262
+ doc.current.body.appendChild(printWindow);
250
263
  }
251
264
 
252
- case 12:
265
+ case 13:
253
266
  case "end":
254
267
  return _context.stop();
255
268
  }
@@ -94,10 +94,13 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
94
94
  left: 0
95
95
  });
96
96
 
97
- var _React$useState3 = React.useState(null),
97
+ var _React$useState3 = React.useState({
98
+ width: null,
99
+ height: null
100
+ }),
98
101
  _React$useState4 = _slicedToArray(_React$useState3, 2),
99
- containerWidth = _React$useState4[0],
100
- setContainerWidth = _React$useState4[1];
102
+ containerDimensions = _React$useState4[0],
103
+ setContainerDimensions = _React$useState4[1];
101
104
 
102
105
  var prevTotalWidth = React.useRef(columnsTotalWidth);
103
106
  var getNearestIndexToRender = React.useCallback(function (offset) {
@@ -141,7 +144,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
141
144
  // In the last index, this is not needed because Array.slice doesn't include it.
142
145
 
143
146
  var firstRowIndex = Math.min(getNearestIndexToRender(top), rowsMeta.positions.length - 1);
144
- var lastRowIndex = rootProps.autoHeight ? firstRowIndex + currentPage.rows.length : getNearestIndexToRender(top + rootRef.current.clientHeight);
147
+ var lastRowIndex = rootProps.autoHeight ? firstRowIndex + currentPage.rows.length : getNearestIndexToRender(top + containerDimensions.height);
145
148
  var hasRowWithAutoHeight = false;
146
149
  var firstColumnIndex = 0;
147
150
  var lastColumnIndex = columnPositions.length;
@@ -164,7 +167,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
164
167
 
165
168
  if (!hasRowWithAutoHeight) {
166
169
  firstColumnIndex = binarySearch(left, columnPositions);
167
- lastColumnIndex = binarySearch(left + containerWidth, columnPositions);
170
+ lastColumnIndex = binarySearch(left + containerDimensions.width, columnPositions);
168
171
  }
169
172
 
170
173
  return {
@@ -173,7 +176,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
173
176
  firstColumnIndex: firstColumnIndex,
174
177
  lastColumnIndex: lastColumnIndex
175
178
  };
176
- }, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerWidth]);
179
+ }, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerDimensions]);
177
180
  useEnhancedEffect(function () {
178
181
  if (disableVirtualization) {
179
182
  renderZoneRef.current.style.transform = "translate3d(0px, 0px, 0px)";
@@ -184,10 +187,16 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
184
187
  }
185
188
  }, [disableVirtualization]);
186
189
  useEnhancedEffect(function () {
187
- setContainerWidth(rootRef.current.clientWidth);
190
+ setContainerDimensions({
191
+ width: rootRef.current.clientWidth,
192
+ height: rootRef.current.clientHeight
193
+ });
188
194
  }, [rowsMeta.currentPageTotalHeight]);
189
195
  var handleResize = React.useCallback(function (params) {
190
- setContainerWidth(params.width);
196
+ setContainerDimensions({
197
+ width: params.width,
198
+ height: params.height
199
+ });
191
200
  }, []);
192
201
  useGridApiEventHandler(apiRef, 'resize', handleResize);
193
202
  var updateRenderZonePosition = React.useCallback(function (nextRenderContext) {
@@ -257,7 +266,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
257
266
  prevRenderContext.current = nextRenderContext;
258
267
  }, [apiRef, setRenderContext, prevRenderContext, currentPage.rows.length, rootProps.rowBuffer]);
259
268
  useEnhancedEffect(function () {
260
- if (containerWidth == null) {
269
+ if (containerDimensions.width == null) {
261
270
  return;
262
271
  }
263
272
 
@@ -272,7 +281,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
272
281
  renderContext: initialRenderContext
273
282
  };
274
283
  apiRef.current.publishEvent('rowsScroll', params);
275
- }, [apiRef, computeRenderContext, containerWidth, updateRenderContext]);
284
+ }, [apiRef, computeRenderContext, containerDimensions.width, updateRenderContext]);
276
285
 
277
286
  var handleScroll = function handleScroll(event) {
278
287
  var _event$currentTarget = event.currentTarget,
@@ -326,7 +335,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
326
335
  _params$maxLastColumn = params.maxLastColumn,
327
336
  maxLastColumn = _params$maxLastColumn === void 0 ? renderZoneMaxColumnIndex : _params$maxLastColumn,
328
337
  _params$availableSpac = params.availableSpace,
329
- availableSpace = _params$availableSpac === void 0 ? containerWidth : _params$availableSpac,
338
+ availableSpace = _params$availableSpac === void 0 ? containerDimensions.width : _params$availableSpac,
330
339
  _params$rowIndexOffse = params.rowIndexOffset,
331
340
  rowIndexOffset = _params$rowIndexOffse === void 0 ? 0 : _params$rowIndexOffse,
332
341
  _params$position = params.position,
@@ -441,7 +450,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
441
450
  return rows;
442
451
  };
443
452
 
444
- var needsHorizontalScrollbar = containerWidth && columnsTotalWidth > containerWidth;
453
+ var needsHorizontalScrollbar = containerDimensions.width && columnsTotalWidth > containerDimensions.width;
445
454
  var contentSize = React.useMemo(function () {
446
455
  // In cases where the columns exceed the available width,
447
456
  // the horizontal scrollbar should be shown even when there're no rows.
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.17
1
+ /** @license MUI X v5.17.19
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -45,6 +45,6 @@ export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/ex
45
45
  export { createSelector, unstable_resetCreateSelectorCache } from '../utils/createSelector';
46
46
  export { findParentElementFromClassName } from '../utils/domUtils';
47
47
  export { isNavigationKey } from '../utils/keyboardUtils';
48
- export { clamp, isDeepEqual, isNumber, isFunction } from '../utils/utils';
48
+ export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
49
49
  export { buildWarning } from '../utils/warning';
50
50
  export { exportAs } from '../utils/exportAs';