@mui/x-data-grid 7.14.0 → 7.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/components/cell/GridActionsCell.js +3 -3
  3. package/components/panel/GridPanel.d.ts +1 -1
  4. package/hooks/core/gridCoreSelector.d.ts +1 -1
  5. package/hooks/core/gridCoreSelector.js +1 -1
  6. package/hooks/core/useGridInitialization.js +2 -2
  7. package/hooks/core/{useGridTheme.d.ts → useGridIsRtl.d.ts} +1 -1
  8. package/hooks/core/{useGridTheme.js → useGridIsRtl.js} +7 -7
  9. package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -3
  10. package/hooks/features/columnResize/useGridColumnResize.js +5 -5
  11. package/hooks/features/columns/gridColumnsSelector.js +3 -3
  12. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +19 -20
  13. package/hooks/features/scroll/useGridScroll.js +4 -4
  14. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -2
  15. package/hooks/features/virtualization/useGridVirtualScroller.js +13 -13
  16. package/index.js +1 -1
  17. package/models/gridStateCommunity.d.ts +1 -2
  18. package/modern/components/cell/GridActionsCell.js +3 -3
  19. package/modern/hooks/core/gridCoreSelector.js +1 -1
  20. package/modern/hooks/core/useGridInitialization.js +2 -2
  21. package/modern/hooks/core/{useGridTheme.js → useGridIsRtl.js} +7 -7
  22. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -3
  23. package/modern/hooks/features/columnResize/useGridColumnResize.js +5 -5
  24. package/modern/hooks/features/columns/gridColumnsSelector.js +3 -3
  25. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +19 -20
  26. package/modern/hooks/features/scroll/useGridScroll.js +4 -4
  27. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +13 -13
  28. package/modern/index.js +1 -1
  29. package/node/components/cell/GridActionsCell.js +3 -3
  30. package/node/hooks/core/gridCoreSelector.js +3 -3
  31. package/node/hooks/core/useGridInitialization.js +2 -2
  32. package/node/hooks/core/{useGridTheme.js → useGridIsRtl.js} +9 -9
  33. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -2
  34. package/node/hooks/features/columnResize/useGridColumnResize.js +5 -5
  35. package/node/hooks/features/columns/gridColumnsSelector.js +2 -2
  36. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +19 -20
  37. package/node/hooks/features/scroll/useGridScroll.js +4 -4
  38. package/node/hooks/features/virtualization/useGridVirtualScroller.js +13 -13
  39. package/node/index.js +1 -1
  40. package/package.json +5 -5
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useGridKeyboardNavigation = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- var _styles = require("@mui/material/styles");
8
+ var _RtlProvider = require("@mui/system/RtlProvider");
9
9
  var _gridColumnsSelector = require("../columns/gridColumnsSelector");
10
10
  var _useGridLogger = require("../../utils/useGridLogger");
11
11
  var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
@@ -32,13 +32,13 @@ const getLeftColumnIndex = ({
32
32
  currentColIndex,
33
33
  firstColIndex,
34
34
  lastColIndex,
35
- direction
35
+ isRtl
36
36
  }) => {
37
- if (direction === 'rtl') {
37
+ if (isRtl) {
38
38
  if (currentColIndex < lastColIndex) {
39
39
  return currentColIndex + 1;
40
40
  }
41
- } else if (direction === 'ltr') {
41
+ } else if (!isRtl) {
42
42
  if (currentColIndex > firstColIndex) {
43
43
  return currentColIndex - 1;
44
44
  }
@@ -49,13 +49,13 @@ const getRightColumnIndex = ({
49
49
  currentColIndex,
50
50
  firstColIndex,
51
51
  lastColIndex,
52
- direction
52
+ isRtl
53
53
  }) => {
54
- if (direction === 'rtl') {
54
+ if (isRtl) {
55
55
  if (currentColIndex > firstColIndex) {
56
56
  return currentColIndex - 1;
57
57
  }
58
- } else if (direction === 'ltr') {
58
+ } else if (!isRtl) {
59
59
  if (currentColIndex < lastColIndex) {
60
60
  return currentColIndex + 1;
61
61
  }
@@ -75,7 +75,7 @@ const getRightColumnIndex = ({
75
75
  const useGridKeyboardNavigation = (apiRef, props) => {
76
76
  const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridKeyboardNavigation');
77
77
  const initialCurrentPageRows = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props).rows;
78
- const theme = (0, _styles.useTheme)();
78
+ const isRtl = (0, _RtlProvider.useRtl)();
79
79
  const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
80
80
  const headerFilteringEnabled = props.signature !== 'DataGrid' && props.headerFilters;
81
81
 
@@ -169,7 +169,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
169
169
  currentColIndex: colIndexBefore,
170
170
  firstColIndex,
171
171
  lastColIndex,
172
- direction: theme.direction
172
+ isRtl
173
173
  });
174
174
  if (rightColIndex !== null) {
175
175
  goToHeader(rightColIndex, event);
@@ -182,7 +182,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
182
182
  currentColIndex: colIndexBefore,
183
183
  firstColIndex,
184
184
  lastColIndex,
185
- direction: theme.direction
185
+ isRtl
186
186
  });
187
187
  if (leftColIndex !== null) {
188
188
  goToHeader(leftColIndex, event);
@@ -233,7 +233,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
233
233
  if (shouldPreventDefault) {
234
234
  event.preventDefault();
235
235
  }
236
- }, [apiRef, currentPageRows.length, headerFilteringEnabled, goToHeaderFilter, goToCell, getRowIdFromIndex, theme.direction, goToHeader, goToGroupHeader]);
236
+ }, [apiRef, currentPageRows.length, headerFilteringEnabled, goToHeaderFilter, goToCell, getRowIdFromIndex, isRtl, goToHeader, goToGroupHeader]);
237
237
  const handleHeaderFilterKeyDown = React.useCallback((params, event) => {
238
238
  const isEditing = (0, _gridHeaderFilteringSelectors.gridHeaderFilteringEditFieldSelector)(apiRef) === params.field;
239
239
  const isHeaderMenuOpen = (0, _gridHeaderFilteringSelectors.gridHeaderFilteringMenuSelector)(apiRef) === params.field;
@@ -262,7 +262,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
262
262
  currentColIndex: colIndexBefore,
263
263
  firstColIndex,
264
264
  lastColIndex,
265
- direction: theme.direction
265
+ isRtl
266
266
  });
267
267
  if (rightColIndex !== null) {
268
268
  goToHeaderFilter(rightColIndex, event);
@@ -275,7 +275,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
275
275
  currentColIndex: colIndexBefore,
276
276
  firstColIndex,
277
277
  lastColIndex,
278
- direction: theme.direction
278
+ isRtl
279
279
  });
280
280
  if (leftColIndex !== null) {
281
281
  goToHeaderFilter(leftColIndex, event);
@@ -319,7 +319,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
319
319
  if (shouldPreventDefault) {
320
320
  event.preventDefault();
321
321
  }
322
- }, [apiRef, currentPageRows.length, goToHeaderFilter, theme.direction, goToHeader, goToCell, getRowIdFromIndex]);
322
+ }, [apiRef, currentPageRows.length, goToHeaderFilter, isRtl, goToHeader, goToCell, getRowIdFromIndex]);
323
323
  const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
324
324
  const focusedColumnGroup = (0, _focus.gridFocusColumnGroupHeaderSelector)(apiRef);
325
325
  if (focusedColumnGroup === null) {
@@ -427,7 +427,6 @@ const useGridKeyboardNavigation = (apiRef, props) => {
427
427
  if (currentPageRows.length === 0) {
428
428
  return;
429
429
  }
430
- const direction = theme.direction;
431
430
  const viewportPageSize = apiRef.current.getViewportPageSize();
432
431
  const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
433
432
  const rowIndexBefore = currentPageRows.findIndex(row => row.id === params.id);
@@ -462,10 +461,10 @@ const useGridKeyboardNavigation = (apiRef, props) => {
462
461
  currentColIndex: colIndexBefore,
463
462
  firstColIndex,
464
463
  lastColIndex,
465
- direction
464
+ isRtl
466
465
  });
467
466
  if (rightColIndex !== null) {
468
- goToCell(rightColIndex, getRowIdFromIndex(rowIndexBefore), direction === 'rtl' ? 'left' : 'right');
467
+ goToCell(rightColIndex, getRowIdFromIndex(rowIndexBefore), isRtl ? 'left' : 'right');
469
468
  }
470
469
  break;
471
470
  }
@@ -475,10 +474,10 @@ const useGridKeyboardNavigation = (apiRef, props) => {
475
474
  currentColIndex: colIndexBefore,
476
475
  firstColIndex,
477
476
  lastColIndex,
478
- direction
477
+ isRtl
479
478
  });
480
479
  if (leftColIndex !== null) {
481
- goToCell(leftColIndex, getRowIdFromIndex(rowIndexBefore), direction === 'rtl' ? 'right' : 'left');
480
+ goToCell(leftColIndex, getRowIdFromIndex(rowIndexBefore), isRtl ? 'right' : 'left');
482
481
  }
483
482
  break;
484
483
  }
@@ -553,7 +552,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
553
552
  if (shouldPreventDefault) {
554
553
  event.preventDefault();
555
554
  }
556
- }, [apiRef, currentPageRows, theme.direction, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader]);
555
+ }, [apiRef, currentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader]);
557
556
  const checkIfCanStartEditing = React.useCallback((initialValue, {
558
557
  event
559
558
  }) => {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useGridScroll = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- var _styles = require("@mui/material/styles");
8
+ var _RtlProvider = require("@mui/system/RtlProvider");
9
9
  var _useGridLogger = require("../../utils/useGridLogger");
10
10
  var _gridColumnsSelector = require("../columns/gridColumnsSelector");
11
11
  var _useGridSelector = require("../../utils/useGridSelector");
@@ -50,7 +50,7 @@ function scrollIntoView(dimensions) {
50
50
  * @requires useGridColumnSpanning (method)
51
51
  */
52
52
  const useGridScroll = (apiRef, props) => {
53
- const theme = (0, _styles.useTheme)();
53
+ const isRtl = (0, _RtlProvider.useRtl)();
54
54
  const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridScroll');
55
55
  const colRef = apiRef.current.columnHeadersContainerRef;
56
56
  const virtualScrollerRef = apiRef.current.virtualScrollerRef;
@@ -108,7 +108,7 @@ const useGridScroll = (apiRef, props) => {
108
108
  }, [logger, apiRef, virtualScrollerRef, props.pagination, visibleSortedRows]);
109
109
  const scroll = React.useCallback(params => {
110
110
  if (virtualScrollerRef.current && params.left !== undefined && colRef.current) {
111
- const direction = theme.direction === 'rtl' ? -1 : 1;
111
+ const direction = isRtl ? -1 : 1;
112
112
  colRef.current.scrollLeft = params.left;
113
113
  virtualScrollerRef.current.scrollLeft = direction * params.left;
114
114
  logger.debug(`Scrolling left: ${params.left}`);
@@ -118,7 +118,7 @@ const useGridScroll = (apiRef, props) => {
118
118
  logger.debug(`Scrolling top: ${params.top}`);
119
119
  }
120
120
  logger.debug(`Scrolling, updating container, and viewport`);
121
- }, [virtualScrollerRef, theme.direction, colRef, logger]);
121
+ }, [virtualScrollerRef, isRtl, colRef, logger]);
122
122
  const getScrollPosition = React.useCallback(() => {
123
123
  if (!virtualScrollerRef?.current) {
124
124
  return {
@@ -15,7 +15,7 @@ var _utils = require("@mui/utils");
15
15
  var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
16
16
  var _useTimeout = _interopRequireDefault(require("@mui/utils/useTimeout"));
17
17
  var _useResizeObserver = require("@mui/x-internals/useResizeObserver");
18
- var _styles = require("@mui/material/styles");
18
+ var _RtlProvider = require("@mui/system/RtlProvider");
19
19
  var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
20
20
  var _useGridRootProps = require("../../utils/useGridRootProps");
21
21
  var _useGridSelector = require("../../utils/useGridSelector");
@@ -51,9 +51,9 @@ const EMPTY_SCROLL_POSITION = {
51
51
  left: 0
52
52
  };
53
53
  const EMPTY_DETAIL_PANELS = exports.EMPTY_DETAIL_PANELS = Object.freeze(new Map());
54
- const createScrollCache = (mode, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) => ({
54
+ const createScrollCache = (isRtl, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) => ({
55
55
  direction: ScrollDirection.NONE,
56
- buffer: bufferForDirection(mode, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
56
+ buffer: bufferForDirection(isRtl, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
57
57
  });
58
58
  let isJSDOM = false;
59
59
  try {
@@ -75,7 +75,7 @@ const useGridVirtualScroller = () => {
75
75
  const pinnedColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector);
76
76
  const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
77
77
  const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
78
- const theme = (0, _styles.useTheme)();
78
+ const isRtl = (0, _RtlProvider.useRtl)();
79
79
  const cellFocus = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusStateSelector.gridFocusCellSelector);
80
80
  const cellTabIndex = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusStateSelector.gridTabIndexCellSelector);
81
81
  const rowsMeta = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsMetaSelector.gridRowsMetaSelector);
@@ -112,7 +112,7 @@ const useGridVirtualScroller = () => {
112
112
  const renderContext = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridRenderContextSelector);
113
113
  const scrollTimeout = (0, _useTimeout.default)();
114
114
  const frozenContext = React.useRef(undefined);
115
- const scrollCache = (0, _useLazyRef.default)(() => createScrollCache(theme.direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
115
+ const scrollCache = (0, _useLazyRef.default)(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
116
116
  const focusedCell = {
117
117
  rowIndex: React.useMemo(() => cellFocus ? currentPage.rows.findIndex(row => row.id === cellFocus.id) : -1, [cellFocus, currentPage.rows]),
118
118
  columnIndex: React.useMemo(() => cellFocus ? visibleColumns.findIndex(column => column.field === cellFocus.field) : -1, [cellFocus, visibleColumns])
@@ -177,7 +177,7 @@ const useGridVirtualScroller = () => {
177
177
  }
178
178
  }
179
179
  scrollCache.direction = direction;
180
- scrollCache.buffer = bufferForDirection(theme.direction, direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
180
+ scrollCache.buffer = bufferForDirection(isRtl, direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
181
181
  const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
182
182
  const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
183
183
 
@@ -205,12 +205,12 @@ const useGridVirtualScroller = () => {
205
205
  if (scrollTop < 0) {
206
206
  return;
207
207
  }
208
- if (theme.direction === 'ltr') {
208
+ if (!isRtl) {
209
209
  if (scrollLeft < 0) {
210
210
  return;
211
211
  }
212
212
  }
213
- if (theme.direction === 'rtl') {
213
+ if (isRtl) {
214
214
  if (scrollLeft > 0) {
215
215
  return;
216
216
  }
@@ -337,7 +337,7 @@ const useGridVirtualScroller = () => {
337
337
  if (!isPinnedSection && frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
338
338
  currentRenderContext = frozenContext.current;
339
339
  }
340
- const offsetLeft = computeOffsetLeft(columnPositions, currentRenderContext, theme.direction, pinnedColumns.left.length);
340
+ const offsetLeft = computeOffsetLeft(columnPositions, currentRenderContext, isRtl, pinnedColumns.left.length);
341
341
  const showBottomBorder = isLastVisibleInSection && params.position === 'top';
342
342
  rows.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.row, (0, _extends2.default)({
343
343
  row: model,
@@ -658,8 +658,8 @@ function areRenderContextsEqual(context1, context2) {
658
658
  }
659
659
  return context1.firstRowIndex === context2.firstRowIndex && context1.lastRowIndex === context2.lastRowIndex && context1.firstColumnIndex === context2.firstColumnIndex && context1.lastColumnIndex === context2.lastColumnIndex;
660
660
  }
661
- function computeOffsetLeft(columnPositions, renderContext, direction, pinnedLeftLength) {
662
- const factor = direction === 'ltr' ? 1 : -1;
661
+ function computeOffsetLeft(columnPositions, renderContext, isRtl, pinnedLeftLength) {
662
+ const factor = isRtl ? -1 : 1;
663
663
  const left = factor * (columnPositions[renderContext.firstColumnIndex] ?? 0) - (columnPositions[pinnedLeftLength] ?? 0);
664
664
  return Math.abs(left);
665
665
  }
@@ -683,8 +683,8 @@ function directionForDelta(dx, dy) {
683
683
  }
684
684
  /* eslint-enable */
685
685
  }
686
- function bufferForDirection(mode, direction, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) {
687
- if (mode === 'rtl') {
686
+ function bufferForDirection(isRtl, direction, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) {
687
+ if (isRtl) {
688
688
  switch (direction) {
689
689
  case ScrollDirection.LEFT:
690
690
  direction = ScrollDirection.RIGHT;
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.14.0
2
+ * @mui/x-data-grid v7.15.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "7.14.0",
3
+ "version": "7.15.0",
4
4
  "description": "The Community plan edition of the Data Grid components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -37,18 +37,18 @@
37
37
  "directory": "packages/x-data-grid"
38
38
  },
39
39
  "dependencies": {
40
- "@babel/runtime": "^7.25.0",
41
- "@mui/system": "^5.16.7",
40
+ "@babel/runtime": "^7.25.4",
42
41
  "@mui/utils": "^5.16.6",
43
42
  "clsx": "^2.1.1",
44
43
  "prop-types": "^15.8.1",
45
44
  "reselect": "^4.1.8",
46
- "@mui/x-internals": "7.14.0"
45
+ "@mui/x-internals": "7.15.0"
47
46
  },
48
47
  "peerDependencies": {
49
48
  "@emotion/react": "^11.9.0",
50
49
  "@emotion/styled": "^11.8.1",
51
- "@mui/material": "^5.15.14",
50
+ "@mui/material": "^5.15.14 || ^6.0.0",
51
+ "@mui/system": "^5.15.14 || ^6.0.0",
52
52
  "react": "^17.0.0 || ^18.0.0",
53
53
  "react-dom": "^17.0.0 || ^18.0.0"
54
54
  },