@mui/x-data-grid 5.17.17 → 5.17.18

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.
package/CHANGELOG.md CHANGED
@@ -3,16 +3,48 @@
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.18
7
+
8
+ _Jan 5, 2023_
9
+
10
+ We'd like to offer a big thanks to the 3 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🐞 Bugfixes
13
+
14
+ ### `@mui/x-data-grid@v5.17.18` / `@mui/x-data-grid-pro@v5.17.18` / `@mui/x-data-grid-premium@v5.17.18`
15
+
16
+ #### Changes
17
+
18
+ - [DataGrid] Fix rows not rendering properly after height change (#7376) @cherniavskii
19
+ - [DataGrid] Fix selected text in cell input not being copied in Firefox (#7330) @cherniavskii
20
+ - [DataGridPremium] Export row grouping column menu components (#7308) @cherniavskii
21
+
22
+ ### `@mui/x-date-pickers@v5.0.13` / `@mui/x-date-pickers-pro@v5.0.13`
23
+
24
+ #### Changes
25
+
26
+ - [pickers] Fix the product license reference name (#7367)
27
+
28
+ ### Docs
29
+
30
+ - [docs] Redirect translated pages (#7370) @cherniavskii
31
+
32
+ ### Core
33
+
34
+ - [core] Fix release date (#7314) @DanailH
35
+ - [core] Fix the product license reference name (#7367) @oliviertassinari
36
+ - [core] Upgrade monorepo (#7344) @cherniavskii
37
+
6
38
  ## 5.17.17
7
39
 
8
- _Dec 23, 2022_
40
+ _Dec 24, 2022_
9
41
 
10
42
  We'd like to offer a big thanks to the 4 contributors who made this release possible. Here are some highlights ✨:
11
43
 
12
44
  - 🌍 Improve Russian (ru-RU) and Korean (ko-KR) locales
13
45
  - 🐞 Bugfixes
14
46
 
15
- ### `@mui/x-data-grid@5.17.17` / `@mui/x-data-grid-pro@5.17.17` / `@mui/x-data-grid-premium@5.17.17`
47
+ ### `@mui/x-data-grid@v5.17.17` / `@mui/x-data-grid-pro@v5.17.17` / `@mui/x-data-grid-premium@v5.17.17`
16
48
 
17
49
  #### Changes
18
50
 
@@ -20,7 +52,7 @@ We'd like to offer a big thanks to the 4 contributors who made this release poss
20
52
  - [DataGridPro] Use row ID as `key` of the detail panels (#7311) @m4theushw
21
53
  - [DataGridPremium] Fix `exceljs` import with parcel (#7285) @alexfauquette
22
54
 
23
- ### `@mui/x-date-pickers@5.0.12` / `@mui/x-date-pickers-pro@5.0.12`
55
+ ### `@mui/x-date-pickers@v5.0.12` / `@mui/x-date-pickers-pro@v5.0.12`
24
56
 
25
57
  #### Changes
26
58
 
@@ -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
 
@@ -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.18
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.
@@ -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
 
@@ -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.18
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.
@@ -20,6 +20,22 @@ function writeToClipboardPolyfill(data) {
20
20
  document.body.removeChild(span);
21
21
  }
22
22
  }
23
+
24
+ function hasNativeSelection(element) {
25
+ if (window.getSelection()?.toString() !== '') {
26
+ return true;
27
+ }
28
+
29
+ if (!element) {
30
+ return false;
31
+ }
32
+
33
+ if ((element.selectionEnd || 0) - (element.selectionStart || 0) > 0) {
34
+ return true;
35
+ }
36
+
37
+ return false;
38
+ }
23
39
  /**
24
40
  * @requires useGridCsvExport (method)
25
41
  * @requires useGridSelection (method)
@@ -55,7 +71,7 @@ export const useGridClipboard = apiRef => {
55
71
  } // Do nothing if there's a native selection
56
72
 
57
73
 
58
- if (window.getSelection()?.toString() !== '') {
74
+ if (hasNativeSelection(event.target)) {
59
75
  return;
60
76
  }
61
77
 
@@ -83,7 +83,10 @@ export const useGridVirtualScroller = props => {
83
83
  top: 0,
84
84
  left: 0
85
85
  });
86
- const [containerWidth, setContainerWidth] = React.useState(null);
86
+ const [containerDimensions, setContainerDimensions] = React.useState({
87
+ width: null,
88
+ height: null
89
+ });
87
90
  const prevTotalWidth = React.useRef(columnsTotalWidth);
88
91
  const getNearestIndexToRender = React.useCallback(offset => {
89
92
  const lastMeasuredIndexRelativeToAllRows = apiRef.current.unstable_getLastMeasuredRowIndex();
@@ -125,7 +128,7 @@ export const useGridVirtualScroller = props => {
125
128
  // In the last index, this is not needed because Array.slice doesn't include it.
126
129
 
127
130
  const firstRowIndex = Math.min(getNearestIndexToRender(top), rowsMeta.positions.length - 1);
128
- const lastRowIndex = rootProps.autoHeight ? firstRowIndex + currentPage.rows.length : getNearestIndexToRender(top + rootRef.current.clientHeight);
131
+ const lastRowIndex = rootProps.autoHeight ? firstRowIndex + currentPage.rows.length : getNearestIndexToRender(top + containerDimensions.height);
129
132
  let hasRowWithAutoHeight = false;
130
133
  let firstColumnIndex = 0;
131
134
  let lastColumnIndex = columnPositions.length;
@@ -144,7 +147,7 @@ export const useGridVirtualScroller = props => {
144
147
 
145
148
  if (!hasRowWithAutoHeight) {
146
149
  firstColumnIndex = binarySearch(left, columnPositions);
147
- lastColumnIndex = binarySearch(left + containerWidth, columnPositions);
150
+ lastColumnIndex = binarySearch(left + containerDimensions.width, columnPositions);
148
151
  }
149
152
 
150
153
  return {
@@ -153,7 +156,7 @@ export const useGridVirtualScroller = props => {
153
156
  firstColumnIndex,
154
157
  lastColumnIndex
155
158
  };
156
- }, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerWidth]);
159
+ }, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerDimensions]);
157
160
  useEnhancedEffect(() => {
158
161
  if (disableVirtualization) {
159
162
  renderZoneRef.current.style.transform = `translate3d(0px, 0px, 0px)`;
@@ -164,10 +167,16 @@ export const useGridVirtualScroller = props => {
164
167
  }
165
168
  }, [disableVirtualization]);
166
169
  useEnhancedEffect(() => {
167
- setContainerWidth(rootRef.current.clientWidth);
170
+ setContainerDimensions({
171
+ width: rootRef.current.clientWidth,
172
+ height: rootRef.current.clientHeight
173
+ });
168
174
  }, [rowsMeta.currentPageTotalHeight]);
169
175
  const handleResize = React.useCallback(params => {
170
- setContainerWidth(params.width);
176
+ setContainerDimensions({
177
+ width: params.width,
178
+ height: params.height
179
+ });
171
180
  }, []);
172
181
  useGridApiEventHandler(apiRef, 'resize', handleResize);
173
182
  const updateRenderZonePosition = React.useCallback(nextRenderContext => {
@@ -225,7 +234,7 @@ export const useGridVirtualScroller = props => {
225
234
  prevRenderContext.current = nextRenderContext;
226
235
  }, [apiRef, setRenderContext, prevRenderContext, currentPage.rows.length, rootProps.rowBuffer]);
227
236
  useEnhancedEffect(() => {
228
- if (containerWidth == null) {
237
+ if (containerDimensions.width == null) {
229
238
  return;
230
239
  }
231
240
 
@@ -241,7 +250,7 @@ export const useGridVirtualScroller = props => {
241
250
  renderContext: initialRenderContext
242
251
  };
243
252
  apiRef.current.publishEvent('rowsScroll', params);
244
- }, [apiRef, computeRenderContext, containerWidth, updateRenderContext]);
253
+ }, [apiRef, computeRenderContext, containerDimensions.width, updateRenderContext]);
245
254
 
246
255
  const handleScroll = event => {
247
256
  const {
@@ -293,7 +302,7 @@ export const useGridVirtualScroller = props => {
293
302
  renderContext: nextRenderContext,
294
303
  minFirstColumn = renderZoneMinColumnIndex,
295
304
  maxLastColumn = renderZoneMaxColumnIndex,
296
- availableSpace = containerWidth,
305
+ availableSpace = containerDimensions.width,
297
306
  rowIndexOffset = 0,
298
307
  position = 'center'
299
308
  } = params;
@@ -397,7 +406,7 @@ export const useGridVirtualScroller = props => {
397
406
  return rows;
398
407
  };
399
408
 
400
- const needsHorizontalScrollbar = containerWidth && columnsTotalWidth > containerWidth;
409
+ const needsHorizontalScrollbar = containerDimensions.width && columnsTotalWidth > containerDimensions.width;
401
410
  const contentSize = React.useMemo(() => {
402
411
  // In cases where the columns exceed the available width,
403
412
  // the horizontal scrollbar should be shown even when there're no rows.
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.17
1
+ /** @license MUI X v5.17.18
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.
@@ -32,6 +32,24 @@ function writeToClipboardPolyfill(data) {
32
32
  document.body.removeChild(span);
33
33
  }
34
34
  }
35
+
36
+ function hasNativeSelection(element) {
37
+ var _window$getSelection;
38
+
39
+ if (((_window$getSelection = window.getSelection()) == null ? void 0 : _window$getSelection.toString()) !== '') {
40
+ return true;
41
+ }
42
+
43
+ if (!element) {
44
+ return false;
45
+ }
46
+
47
+ if ((element.selectionEnd || 0) - (element.selectionStart || 0) > 0) {
48
+ return true;
49
+ }
50
+
51
+ return false;
52
+ }
35
53
  /**
36
54
  * @requires useGridCsvExport (method)
37
55
  * @requires useGridSelection (method)
@@ -58,8 +76,6 @@ const useGridClipboard = apiRef => {
58
76
  }
59
77
  }, [apiRef]);
60
78
  const handleKeydown = React.useCallback(event => {
61
- var _window$getSelection;
62
-
63
79
  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.
64
80
  // event.code === 'KeyC' is not enough as event.code assume a QWERTY keyboard layout which would
65
81
  // be wrong with a Dvorak keyboard (as if pressing J).
@@ -69,7 +85,7 @@ const useGridClipboard = apiRef => {
69
85
  } // Do nothing if there's a native selection
70
86
 
71
87
 
72
- if (((_window$getSelection = window.getSelection()) == null ? void 0 : _window$getSelection.toString()) !== '') {
88
+ if (hasNativeSelection(event.target)) {
73
89
  return;
74
90
  }
75
91
 
@@ -122,7 +122,10 @@ const useGridVirtualScroller = props => {
122
122
  top: 0,
123
123
  left: 0
124
124
  });
125
- const [containerWidth, setContainerWidth] = React.useState(null);
125
+ const [containerDimensions, setContainerDimensions] = React.useState({
126
+ width: null,
127
+ height: null
128
+ });
126
129
  const prevTotalWidth = React.useRef(columnsTotalWidth);
127
130
  const getNearestIndexToRender = React.useCallback(offset => {
128
131
  var _currentPage$range, _currentPage$range2;
@@ -166,7 +169,7 @@ const useGridVirtualScroller = props => {
166
169
  // In the last index, this is not needed because Array.slice doesn't include it.
167
170
 
168
171
  const firstRowIndex = Math.min(getNearestIndexToRender(top), rowsMeta.positions.length - 1);
169
- const lastRowIndex = rootProps.autoHeight ? firstRowIndex + currentPage.rows.length : getNearestIndexToRender(top + rootRef.current.clientHeight);
172
+ const lastRowIndex = rootProps.autoHeight ? firstRowIndex + currentPage.rows.length : getNearestIndexToRender(top + containerDimensions.height);
170
173
  let hasRowWithAutoHeight = false;
171
174
  let firstColumnIndex = 0;
172
175
  let lastColumnIndex = columnPositions.length;
@@ -185,7 +188,7 @@ const useGridVirtualScroller = props => {
185
188
 
186
189
  if (!hasRowWithAutoHeight) {
187
190
  firstColumnIndex = binarySearch(left, columnPositions);
188
- lastColumnIndex = binarySearch(left + containerWidth, columnPositions);
191
+ lastColumnIndex = binarySearch(left + containerDimensions.width, columnPositions);
189
192
  }
190
193
 
191
194
  return {
@@ -194,7 +197,7 @@ const useGridVirtualScroller = props => {
194
197
  firstColumnIndex,
195
198
  lastColumnIndex
196
199
  };
197
- }, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerWidth]);
200
+ }, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerDimensions]);
198
201
  (0, _utils.unstable_useEnhancedEffect)(() => {
199
202
  if (disableVirtualization) {
200
203
  renderZoneRef.current.style.transform = `translate3d(0px, 0px, 0px)`;
@@ -205,10 +208,16 @@ const useGridVirtualScroller = props => {
205
208
  }
206
209
  }, [disableVirtualization]);
207
210
  (0, _utils.unstable_useEnhancedEffect)(() => {
208
- setContainerWidth(rootRef.current.clientWidth);
211
+ setContainerDimensions({
212
+ width: rootRef.current.clientWidth,
213
+ height: rootRef.current.clientHeight
214
+ });
209
215
  }, [rowsMeta.currentPageTotalHeight]);
210
216
  const handleResize = React.useCallback(params => {
211
- setContainerWidth(params.width);
217
+ setContainerDimensions({
218
+ width: params.width,
219
+ height: params.height
220
+ });
212
221
  }, []);
213
222
  (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'resize', handleResize);
214
223
  const updateRenderZonePosition = React.useCallback(nextRenderContext => {
@@ -266,7 +275,7 @@ const useGridVirtualScroller = props => {
266
275
  prevRenderContext.current = nextRenderContext;
267
276
  }, [apiRef, setRenderContext, prevRenderContext, currentPage.rows.length, rootProps.rowBuffer]);
268
277
  (0, _utils.unstable_useEnhancedEffect)(() => {
269
- if (containerWidth == null) {
278
+ if (containerDimensions.width == null) {
270
279
  return;
271
280
  }
272
281
 
@@ -282,7 +291,7 @@ const useGridVirtualScroller = props => {
282
291
  renderContext: initialRenderContext
283
292
  };
284
293
  apiRef.current.publishEvent('rowsScroll', params);
285
- }, [apiRef, computeRenderContext, containerWidth, updateRenderContext]);
294
+ }, [apiRef, computeRenderContext, containerDimensions.width, updateRenderContext]);
286
295
 
287
296
  const handleScroll = event => {
288
297
  const {
@@ -334,7 +343,7 @@ const useGridVirtualScroller = props => {
334
343
  renderContext: nextRenderContext,
335
344
  minFirstColumn = renderZoneMinColumnIndex,
336
345
  maxLastColumn = renderZoneMaxColumnIndex,
337
- availableSpace = containerWidth,
346
+ availableSpace = containerDimensions.width,
338
347
  rowIndexOffset = 0,
339
348
  position = 'center'
340
349
  } = params;
@@ -440,7 +449,7 @@ const useGridVirtualScroller = props => {
440
449
  return rows;
441
450
  };
442
451
 
443
- const needsHorizontalScrollbar = containerWidth && columnsTotalWidth > containerWidth;
452
+ const needsHorizontalScrollbar = containerDimensions.width && columnsTotalWidth > containerDimensions.width;
444
453
  const contentSize = React.useMemo(() => {
445
454
  // In cases where the columns exceed the available width,
446
455
  // the horizontal scrollbar should be shown even when there're no rows.
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.17
1
+ /** @license MUI X v5.17.18
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "5.17.17",
3
+ "version": "5.17.18",
4
4
  "description": "The community edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",