@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
@@ -1,5 +1,5 @@
1
1
  import { useGridRefs } from './useGridRefs';
2
- import { useGridTheme } from './useGridTheme';
2
+ import { useGridIsRtl } from './useGridIsRtl';
3
3
  import { useGridLoggerFactory } from './useGridLoggerFactory';
4
4
  import { useGridApiInitialization } from './useGridApiInitialization';
5
5
  import { useGridLocaleText } from './useGridLocaleText';
@@ -13,7 +13,7 @@ import { useGridStateInitialization } from './useGridStateInitialization';
13
13
  export const useGridInitialization = (inputApiRef, props) => {
14
14
  const privateApiRef = useGridApiInitialization(inputApiRef, props);
15
15
  useGridRefs(privateApiRef);
16
- useGridTheme(privateApiRef);
16
+ useGridIsRtl(privateApiRef);
17
17
  useGridLoggerFactory(privateApiRef, props);
18
18
  useGridStateInitialization(privateApiRef);
19
19
  useGridPipeProcessing(privateApiRef);
@@ -1,10 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { useTheme } from '@mui/material/styles';
4
- export const useGridTheme = apiRef => {
5
- const theme = useTheme();
6
- if (!apiRef.current.state.theme) {
7
- apiRef.current.state.theme = theme;
3
+ import { useRtl } from '@mui/system/RtlProvider';
4
+ export const useGridIsRtl = apiRef => {
5
+ const isRtl = useRtl();
6
+ if (apiRef.current.state.isRtl === undefined) {
7
+ apiRef.current.state.isRtl = isRtl;
8
8
  }
9
9
  const isFirstEffect = React.useRef(true);
10
10
  React.useEffect(() => {
@@ -12,8 +12,8 @@ export const useGridTheme = apiRef => {
12
12
  isFirstEffect.current = false;
13
13
  } else {
14
14
  apiRef.current.setState(state => _extends({}, state, {
15
- theme
15
+ isRtl
16
16
  }));
17
17
  }
18
- }, [apiRef, theme]);
18
+ }, [apiRef, isRtl]);
19
19
  };
@@ -1,7 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import clsx from 'clsx';
4
- import { styled, useTheme } from '@mui/material/styles';
4
+ import { styled } from '@mui/material/styles';
5
+ import { useRtl } from '@mui/system/RtlProvider';
5
6
  import { useGridSelector } from '../../utils';
6
7
  import { useGridRootProps } from '../../utils/useGridRootProps';
7
8
  import { useGridPrivateApiContext } from '../../utils/useGridPrivateApiContext';
@@ -44,7 +45,7 @@ export const useGridColumnHeaders = props => {
44
45
  const [dragCol, setDragCol] = React.useState('');
45
46
  const [resizeCol, setResizeCol] = React.useState('');
46
47
  const apiRef = useGridPrivateApiContext();
47
- const theme = useTheme();
48
+ const isRtl = useRtl();
48
49
  const rootProps = useGridRootProps();
49
50
  const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
50
51
  const hasVirtualization = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector);
@@ -53,7 +54,7 @@ export const useGridColumnHeaders = props => {
53
54
  const renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
54
55
  const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
55
56
  const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
56
- const offsetLeft = computeOffsetLeft(columnPositions, renderContext, theme.direction, pinnedColumns.left.length);
57
+ const offsetLeft = computeOffsetLeft(columnPositions, renderContext, isRtl, pinnedColumns.left.length);
57
58
  const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
58
59
  React.useEffect(() => {
59
60
  apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { unstable_ownerDocument as ownerDocument, unstable_useEventCallback as useEventCallback } from '@mui/utils';
4
4
  import useLazyRef from '@mui/utils/useLazyRef';
5
- import { useTheme } from '@mui/material/styles';
5
+ import { useRtl } from '@mui/system/RtlProvider';
6
6
  import { findGridCellElementsFromCol, findGridElement, findLeftPinnedCellsAfterCol, findRightPinnedCellsBeforeCol, getFieldFromHeaderElem, findHeaderElementFromField, getFieldsFromGroupHeaderElem, findGroupHeaderElementsFromField, findGridHeader, findGridCells, findParentElementFromClassName, findLeftPinnedHeadersAfterCol, findRightPinnedHeadersBeforeCol, escapeOperandAttributeSelector } from '../../../utils/domUtils';
7
7
  import { DEFAULT_GRID_AUTOSIZE_OPTIONS } from './gridColumnResizeApi';
8
8
  import { gridClasses } from '../../../constants/gridClasses';
@@ -52,9 +52,9 @@ function flipResizeDirection(side) {
52
52
  }
53
53
  return 'Right';
54
54
  }
55
- function getResizeDirection(separator, direction) {
55
+ function getResizeDirection(separator, isRtl) {
56
56
  const side = separator.classList.contains(gridClasses['columnSeparator--sideRight']) ? 'Right' : 'Left';
57
- if (direction === 'rtl') {
57
+ if (isRtl) {
58
58
  // Resizing logic should be mirrored in the RTL case
59
59
  return flipResizeDirection(side);
60
60
  }
@@ -177,7 +177,7 @@ function createResizeRefs() {
177
177
  * TODO: improve experience for last column
178
178
  */
179
179
  export const useGridColumnResize = (apiRef, props) => {
180
- const theme = useTheme();
180
+ const isRtl = useRtl();
181
181
  const logger = useGridLogger(apiRef, 'useGridColumnResize');
182
182
  const refs = useLazyRef(createResizeRefs).current;
183
183
 
@@ -317,7 +317,7 @@ export const useGridColumnResize = (apiRef, props) => {
317
317
  refs.rightPinnedCellsBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedCellsBeforeCol(apiRef.current, refs.columnHeaderElement);
318
318
  refs.leftPinnedHeadersAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedHeadersAfterCol(apiRef.current, refs.columnHeaderElement);
319
319
  refs.rightPinnedHeadersBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedHeadersBeforeCol(apiRef.current, refs.columnHeaderElement);
320
- resizeDirection.current = getResizeDirection(separator, theme.direction);
320
+ resizeDirection.current = getResizeDirection(separator, isRtl);
321
321
  initialOffsetToSeparator.current = computeOffsetToSeparator(xStart, refs.columnHeaderElement.getBoundingClientRect(), resizeDirection.current);
322
322
  };
323
323
  const handleResizeMouseUp = useEventCallback(finishResize);
@@ -1,6 +1,6 @@
1
1
  import { createSelector, createSelectorMemoized } from '../../../utils/createSelector';
2
2
  import { EMPTY_PINNED_COLUMN_FIELDS } from './gridColumnsInterfaces';
3
- import { gridThemeSelector } from '../../core/gridCoreSelector';
3
+ import { gridIsRtlSelector } from '../../core/gridCoreSelector';
4
4
 
5
5
  /**
6
6
  * Get the columns state
@@ -55,8 +55,8 @@ export const gridPinnedColumnsSelector = state => state.pinnedColumns;
55
55
  * Get the visible pinned columns.
56
56
  * @category Visible Columns
57
57
  */
58
- export const gridVisiblePinnedColumnDefinitionsSelector = createSelectorMemoized(gridColumnsStateSelector, gridPinnedColumnsSelector, gridVisibleColumnFieldsSelector, gridThemeSelector, (columnsState, model, visibleColumnFields, theme) => {
59
- const visiblePinnedFields = filterVisibleColumns(model, visibleColumnFields, theme.direction === 'rtl');
58
+ export const gridVisiblePinnedColumnDefinitionsSelector = createSelectorMemoized(gridColumnsStateSelector, gridPinnedColumnsSelector, gridVisibleColumnFieldsSelector, gridIsRtlSelector, (columnsState, model, visibleColumnFields, isRtl) => {
59
+ const visiblePinnedFields = filterVisibleColumns(model, visibleColumnFields, isRtl);
60
60
  const visiblePinnedColumns = {
61
61
  left: visiblePinnedFields.left.map(field => columnsState.lookup[field]),
62
62
  right: visiblePinnedFields.right.map(field => columnsState.lookup[field])
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { useTheme } from '@mui/material/styles';
2
+ import { useRtl } from '@mui/system/RtlProvider';
3
3
  import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
4
4
  import { useGridLogger } from '../../utils/useGridLogger';
5
5
  import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
@@ -24,13 +24,13 @@ const getLeftColumnIndex = ({
24
24
  currentColIndex,
25
25
  firstColIndex,
26
26
  lastColIndex,
27
- direction
27
+ isRtl
28
28
  }) => {
29
- if (direction === 'rtl') {
29
+ if (isRtl) {
30
30
  if (currentColIndex < lastColIndex) {
31
31
  return currentColIndex + 1;
32
32
  }
33
- } else if (direction === 'ltr') {
33
+ } else if (!isRtl) {
34
34
  if (currentColIndex > firstColIndex) {
35
35
  return currentColIndex - 1;
36
36
  }
@@ -41,13 +41,13 @@ const getRightColumnIndex = ({
41
41
  currentColIndex,
42
42
  firstColIndex,
43
43
  lastColIndex,
44
- direction
44
+ isRtl
45
45
  }) => {
46
- if (direction === 'rtl') {
46
+ if (isRtl) {
47
47
  if (currentColIndex > firstColIndex) {
48
48
  return currentColIndex - 1;
49
49
  }
50
- } else if (direction === 'ltr') {
50
+ } else if (!isRtl) {
51
51
  if (currentColIndex < lastColIndex) {
52
52
  return currentColIndex + 1;
53
53
  }
@@ -67,7 +67,7 @@ const getRightColumnIndex = ({
67
67
  export const useGridKeyboardNavigation = (apiRef, props) => {
68
68
  const logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
69
69
  const initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;
70
- const theme = useTheme();
70
+ const isRtl = useRtl();
71
71
  const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
72
72
  const headerFilteringEnabled = props.signature !== 'DataGrid' && props.headerFilters;
73
73
 
@@ -161,7 +161,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
161
161
  currentColIndex: colIndexBefore,
162
162
  firstColIndex,
163
163
  lastColIndex,
164
- direction: theme.direction
164
+ isRtl
165
165
  });
166
166
  if (rightColIndex !== null) {
167
167
  goToHeader(rightColIndex, event);
@@ -174,7 +174,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
174
174
  currentColIndex: colIndexBefore,
175
175
  firstColIndex,
176
176
  lastColIndex,
177
- direction: theme.direction
177
+ isRtl
178
178
  });
179
179
  if (leftColIndex !== null) {
180
180
  goToHeader(leftColIndex, event);
@@ -225,7 +225,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
225
225
  if (shouldPreventDefault) {
226
226
  event.preventDefault();
227
227
  }
228
- }, [apiRef, currentPageRows.length, headerFilteringEnabled, goToHeaderFilter, goToCell, getRowIdFromIndex, theme.direction, goToHeader, goToGroupHeader]);
228
+ }, [apiRef, currentPageRows.length, headerFilteringEnabled, goToHeaderFilter, goToCell, getRowIdFromIndex, isRtl, goToHeader, goToGroupHeader]);
229
229
  const handleHeaderFilterKeyDown = React.useCallback((params, event) => {
230
230
  const isEditing = gridHeaderFilteringEditFieldSelector(apiRef) === params.field;
231
231
  const isHeaderMenuOpen = gridHeaderFilteringMenuSelector(apiRef) === params.field;
@@ -254,7 +254,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
254
254
  currentColIndex: colIndexBefore,
255
255
  firstColIndex,
256
256
  lastColIndex,
257
- direction: theme.direction
257
+ isRtl
258
258
  });
259
259
  if (rightColIndex !== null) {
260
260
  goToHeaderFilter(rightColIndex, event);
@@ -267,7 +267,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
267
267
  currentColIndex: colIndexBefore,
268
268
  firstColIndex,
269
269
  lastColIndex,
270
- direction: theme.direction
270
+ isRtl
271
271
  });
272
272
  if (leftColIndex !== null) {
273
273
  goToHeaderFilter(leftColIndex, event);
@@ -311,7 +311,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
311
311
  if (shouldPreventDefault) {
312
312
  event.preventDefault();
313
313
  }
314
- }, [apiRef, currentPageRows.length, goToHeaderFilter, theme.direction, goToHeader, goToCell, getRowIdFromIndex]);
314
+ }, [apiRef, currentPageRows.length, goToHeaderFilter, isRtl, goToHeader, goToCell, getRowIdFromIndex]);
315
315
  const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
316
316
  const focusedColumnGroup = gridFocusColumnGroupHeaderSelector(apiRef);
317
317
  if (focusedColumnGroup === null) {
@@ -419,7 +419,6 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
419
419
  if (currentPageRows.length === 0) {
420
420
  return;
421
421
  }
422
- const direction = theme.direction;
423
422
  const viewportPageSize = apiRef.current.getViewportPageSize();
424
423
  const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
425
424
  const rowIndexBefore = currentPageRows.findIndex(row => row.id === params.id);
@@ -454,10 +453,10 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
454
453
  currentColIndex: colIndexBefore,
455
454
  firstColIndex,
456
455
  lastColIndex,
457
- direction
456
+ isRtl
458
457
  });
459
458
  if (rightColIndex !== null) {
460
- goToCell(rightColIndex, getRowIdFromIndex(rowIndexBefore), direction === 'rtl' ? 'left' : 'right');
459
+ goToCell(rightColIndex, getRowIdFromIndex(rowIndexBefore), isRtl ? 'left' : 'right');
461
460
  }
462
461
  break;
463
462
  }
@@ -467,10 +466,10 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
467
466
  currentColIndex: colIndexBefore,
468
467
  firstColIndex,
469
468
  lastColIndex,
470
- direction
469
+ isRtl
471
470
  });
472
471
  if (leftColIndex !== null) {
473
- goToCell(leftColIndex, getRowIdFromIndex(rowIndexBefore), direction === 'rtl' ? 'right' : 'left');
472
+ goToCell(leftColIndex, getRowIdFromIndex(rowIndexBefore), isRtl ? 'right' : 'left');
474
473
  }
475
474
  break;
476
475
  }
@@ -545,7 +544,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
545
544
  if (shouldPreventDefault) {
546
545
  event.preventDefault();
547
546
  }
548
- }, [apiRef, currentPageRows, theme.direction, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader]);
547
+ }, [apiRef, currentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader]);
549
548
  const checkIfCanStartEditing = React.useCallback((initialValue, {
550
549
  event
551
550
  }) => {
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { useTheme } from '@mui/material/styles';
2
+ import { useRtl } from '@mui/system/RtlProvider';
3
3
  import { useGridLogger } from '../../utils/useGridLogger';
4
4
  import { gridColumnPositionsSelector, gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
5
5
  import { useGridSelector } from '../../utils/useGridSelector';
@@ -43,7 +43,7 @@ function scrollIntoView(dimensions) {
43
43
  * @requires useGridColumnSpanning (method)
44
44
  */
45
45
  export const useGridScroll = (apiRef, props) => {
46
- const theme = useTheme();
46
+ const isRtl = useRtl();
47
47
  const logger = useGridLogger(apiRef, 'useGridScroll');
48
48
  const colRef = apiRef.current.columnHeadersContainerRef;
49
49
  const virtualScrollerRef = apiRef.current.virtualScrollerRef;
@@ -101,7 +101,7 @@ export const useGridScroll = (apiRef, props) => {
101
101
  }, [logger, apiRef, virtualScrollerRef, props.pagination, visibleSortedRows]);
102
102
  const scroll = React.useCallback(params => {
103
103
  if (virtualScrollerRef.current && params.left !== undefined && colRef.current) {
104
- const direction = theme.direction === 'rtl' ? -1 : 1;
104
+ const direction = isRtl ? -1 : 1;
105
105
  colRef.current.scrollLeft = params.left;
106
106
  virtualScrollerRef.current.scrollLeft = direction * params.left;
107
107
  logger.debug(`Scrolling left: ${params.left}`);
@@ -111,7 +111,7 @@ export const useGridScroll = (apiRef, props) => {
111
111
  logger.debug(`Scrolling top: ${params.top}`);
112
112
  }
113
113
  logger.debug(`Scrolling, updating container, and viewport`);
114
- }, [virtualScrollerRef, theme.direction, colRef, logger]);
114
+ }, [virtualScrollerRef, isRtl, colRef, logger]);
115
115
  const getScrollPosition = React.useCallback(() => {
116
116
  if (!virtualScrollerRef?.current) {
117
117
  return {
@@ -5,7 +5,7 @@ import { unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallb
5
5
  import useLazyRef from '@mui/utils/useLazyRef';
6
6
  import useTimeout from '@mui/utils/useTimeout';
7
7
  import { useResizeObserver } from '@mui/x-internals/useResizeObserver';
8
- import { useTheme } from '@mui/material/styles';
8
+ import { useRtl } from '@mui/system/RtlProvider';
9
9
  import { useGridPrivateApiContext } from '../../utils/useGridPrivateApiContext';
10
10
  import { useGridRootProps } from '../../utils/useGridRootProps';
11
11
  import { useGridSelector } from '../../utils/useGridSelector';
@@ -39,9 +39,9 @@ const EMPTY_SCROLL_POSITION = {
39
39
  left: 0
40
40
  };
41
41
  export const EMPTY_DETAIL_PANELS = Object.freeze(new Map());
42
- const createScrollCache = (mode, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) => ({
42
+ const createScrollCache = (isRtl, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) => ({
43
43
  direction: ScrollDirection.NONE,
44
- buffer: bufferForDirection(mode, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
44
+ buffer: bufferForDirection(isRtl, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
45
45
  });
46
46
  let isJSDOM = false;
47
47
  try {
@@ -63,7 +63,7 @@ export const useGridVirtualScroller = () => {
63
63
  const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
64
64
  const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
65
65
  const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
66
- const theme = useTheme();
66
+ const isRtl = useRtl();
67
67
  const cellFocus = useGridSelector(apiRef, gridFocusCellSelector);
68
68
  const cellTabIndex = useGridSelector(apiRef, gridTabIndexCellSelector);
69
69
  const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
@@ -100,7 +100,7 @@ export const useGridVirtualScroller = () => {
100
100
  const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
101
101
  const scrollTimeout = useTimeout();
102
102
  const frozenContext = React.useRef(undefined);
103
- const scrollCache = useLazyRef(() => createScrollCache(theme.direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
103
+ const scrollCache = useLazyRef(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
104
104
  const focusedCell = {
105
105
  rowIndex: React.useMemo(() => cellFocus ? currentPage.rows.findIndex(row => row.id === cellFocus.id) : -1, [cellFocus, currentPage.rows]),
106
106
  columnIndex: React.useMemo(() => cellFocus ? visibleColumns.findIndex(column => column.field === cellFocus.field) : -1, [cellFocus, visibleColumns])
@@ -165,7 +165,7 @@ export const useGridVirtualScroller = () => {
165
165
  }
166
166
  }
167
167
  scrollCache.direction = direction;
168
- scrollCache.buffer = bufferForDirection(theme.direction, direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
168
+ scrollCache.buffer = bufferForDirection(isRtl, direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
169
169
  const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
170
170
  const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
171
171
 
@@ -193,12 +193,12 @@ export const useGridVirtualScroller = () => {
193
193
  if (scrollTop < 0) {
194
194
  return;
195
195
  }
196
- if (theme.direction === 'ltr') {
196
+ if (!isRtl) {
197
197
  if (scrollLeft < 0) {
198
198
  return;
199
199
  }
200
200
  }
201
- if (theme.direction === 'rtl') {
201
+ if (isRtl) {
202
202
  if (scrollLeft > 0) {
203
203
  return;
204
204
  }
@@ -325,7 +325,7 @@ export const useGridVirtualScroller = () => {
325
325
  if (!isPinnedSection && frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
326
326
  currentRenderContext = frozenContext.current;
327
327
  }
328
- const offsetLeft = computeOffsetLeft(columnPositions, currentRenderContext, theme.direction, pinnedColumns.left.length);
328
+ const offsetLeft = computeOffsetLeft(columnPositions, currentRenderContext, isRtl, pinnedColumns.left.length);
329
329
  const showBottomBorder = isLastVisibleInSection && params.position === 'top';
330
330
  rows.push( /*#__PURE__*/_jsx(rootProps.slots.row, _extends({
331
331
  row: model,
@@ -645,8 +645,8 @@ export function areRenderContextsEqual(context1, context2) {
645
645
  }
646
646
  return context1.firstRowIndex === context2.firstRowIndex && context1.lastRowIndex === context2.lastRowIndex && context1.firstColumnIndex === context2.firstColumnIndex && context1.lastColumnIndex === context2.lastColumnIndex;
647
647
  }
648
- export function computeOffsetLeft(columnPositions, renderContext, direction, pinnedLeftLength) {
649
- const factor = direction === 'ltr' ? 1 : -1;
648
+ export function computeOffsetLeft(columnPositions, renderContext, isRtl, pinnedLeftLength) {
649
+ const factor = isRtl ? -1 : 1;
650
650
  const left = factor * (columnPositions[renderContext.firstColumnIndex] ?? 0) - (columnPositions[pinnedLeftLength] ?? 0);
651
651
  return Math.abs(left);
652
652
  }
@@ -670,8 +670,8 @@ function directionForDelta(dx, dy) {
670
670
  }
671
671
  /* eslint-enable */
672
672
  }
673
- function bufferForDirection(mode, direction, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) {
674
- if (mode === 'rtl') {
673
+ function bufferForDirection(isRtl, direction, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) {
674
+ if (isRtl) {
675
675
  switch (direction) {
676
676
  case ScrollDirection.LEFT:
677
677
  direction = ScrollDirection.RIGHT;
package/modern/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
@@ -11,7 +11,7 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
11
11
  var React = _interopRequireWildcard(require("react"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
  var _MenuList = _interopRequireDefault(require("@mui/material/MenuList"));
14
- var _styles = require("@mui/material/styles");
14
+ var _RtlProvider = require("@mui/system/RtlProvider");
15
15
  var _utils = require("@mui/utils");
16
16
  var _gridClasses = require("../../constants/gridClasses");
17
17
  var _GridMenu = require("../menu/GridMenu");
@@ -39,7 +39,7 @@ function GridActionsCell(props) {
39
39
  const buttonRef = React.useRef(null);
40
40
  const ignoreCallToFocus = React.useRef(false);
41
41
  const touchRippleRefs = React.useRef({});
42
- const theme = (0, _styles.useTheme)();
42
+ const isRtl = (0, _RtlProvider.useRtl)();
43
43
  const menuId = (0, _utils.unstable_useId)();
44
44
  const buttonId = (0, _utils.unstable_useId)();
45
45
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
@@ -120,7 +120,7 @@ function GridActionsCell(props) {
120
120
  }
121
121
 
122
122
  // for rtl mode we need to reverse the direction
123
- const rtlMod = theme.direction === 'rtl' ? -1 : 1;
123
+ const rtlMod = isRtl ? -1 : 1;
124
124
  const indexMod = (direction === 'left' ? -1 : 1) * rtlMod;
125
125
 
126
126
  // if the button that should receive focus is disabled go one more step
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.gridThemeSelector = void 0;
6
+ exports.gridIsRtlSelector = void 0;
7
7
  /**
8
8
  * Get the theme state
9
9
  * @category Core
10
10
  */
11
- const gridThemeSelector = state => state.theme;
12
- exports.gridThemeSelector = gridThemeSelector;
11
+ const gridIsRtlSelector = state => state.isRtl;
12
+ exports.gridIsRtlSelector = gridIsRtlSelector;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useGridInitialization = void 0;
7
7
  var _useGridRefs = require("./useGridRefs");
8
- var _useGridTheme = require("./useGridTheme");
8
+ var _useGridIsRtl = require("./useGridIsRtl");
9
9
  var _useGridLoggerFactory = require("./useGridLoggerFactory");
10
10
  var _useGridApiInitialization = require("./useGridApiInitialization");
11
11
  var _useGridLocaleText = require("./useGridLocaleText");
@@ -18,7 +18,7 @@ var _useGridStateInitialization = require("./useGridStateInitialization");
18
18
  const useGridInitialization = (inputApiRef, props) => {
19
19
  const privateApiRef = (0, _useGridApiInitialization.useGridApiInitialization)(inputApiRef, props);
20
20
  (0, _useGridRefs.useGridRefs)(privateApiRef);
21
- (0, _useGridTheme.useGridTheme)(privateApiRef);
21
+ (0, _useGridIsRtl.useGridIsRtl)(privateApiRef);
22
22
  (0, _useGridLoggerFactory.useGridLoggerFactory)(privateApiRef, props);
23
23
  (0, _useGridStateInitialization.useGridStateInitialization)(privateApiRef);
24
24
  (0, _pipeProcessing.useGridPipeProcessing)(privateApiRef);
@@ -4,16 +4,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useGridTheme = void 0;
7
+ exports.useGridIsRtl = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var React = _interopRequireWildcard(require("react"));
10
- var _styles = require("@mui/material/styles");
10
+ var _RtlProvider = require("@mui/system/RtlProvider");
11
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
- const useGridTheme = apiRef => {
14
- const theme = (0, _styles.useTheme)();
15
- if (!apiRef.current.state.theme) {
16
- apiRef.current.state.theme = theme;
13
+ const useGridIsRtl = apiRef => {
14
+ const isRtl = (0, _RtlProvider.useRtl)();
15
+ if (apiRef.current.state.isRtl === undefined) {
16
+ apiRef.current.state.isRtl = isRtl;
17
17
  }
18
18
  const isFirstEffect = React.useRef(true);
19
19
  React.useEffect(() => {
@@ -21,9 +21,9 @@ const useGridTheme = apiRef => {
21
21
  isFirstEffect.current = false;
22
22
  } else {
23
23
  apiRef.current.setState(state => (0, _extends2.default)({}, state, {
24
- theme
24
+ isRtl
25
25
  }));
26
26
  }
27
- }, [apiRef, theme]);
27
+ }, [apiRef, isRtl]);
28
28
  };
29
- exports.useGridTheme = useGridTheme;
29
+ exports.useGridIsRtl = useGridIsRtl;
@@ -9,6 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _clsx = _interopRequireDefault(require("clsx"));
11
11
  var _styles = require("@mui/material/styles");
12
+ var _RtlProvider = require("@mui/system/RtlProvider");
12
13
  var _utils = require("../../utils");
13
14
  var _useGridRootProps = require("../../utils/useGridRootProps");
14
15
  var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
@@ -53,7 +54,7 @@ const useGridColumnHeaders = props => {
53
54
  const [dragCol, setDragCol] = React.useState('');
54
55
  const [resizeCol, setResizeCol] = React.useState('');
55
56
  const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
56
- const theme = (0, _styles.useTheme)();
57
+ const isRtl = (0, _RtlProvider.useRtl)();
57
58
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
58
59
  const dimensions = (0, _utils.useGridSelector)(apiRef, _dimensions.gridDimensionsSelector);
59
60
  const hasVirtualization = (0, _utils.useGridSelector)(apiRef, _virtualization.gridVirtualizationColumnEnabledSelector);
@@ -62,7 +63,7 @@ const useGridColumnHeaders = props => {
62
63
  const renderContext = (0, _utils.useGridSelector)(apiRef, _virtualization.gridRenderContextColumnsSelector);
63
64
  const pinnedColumns = (0, _utils.useGridSelector)(apiRef, _columns.gridVisiblePinnedColumnDefinitionsSelector);
64
65
  const pinnedRows = (0, _utils.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsSelector);
65
- const offsetLeft = (0, _useGridVirtualScroller.computeOffsetLeft)(columnPositions, renderContext, theme.direction, pinnedColumns.left.length);
66
+ const offsetLeft = (0, _useGridVirtualScroller.computeOffsetLeft)(columnPositions, renderContext, isRtl, pinnedColumns.left.length);
66
67
  const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
67
68
  React.useEffect(() => {
68
69
  apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
@@ -9,7 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _utils = require("@mui/utils");
11
11
  var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
12
- var _styles = require("@mui/material/styles");
12
+ var _RtlProvider = require("@mui/system/RtlProvider");
13
13
  var _domUtils = require("../../../utils/domUtils");
14
14
  var _gridColumnResizeApi = require("./gridColumnResizeApi");
15
15
  var _gridClasses = require("../../../constants/gridClasses");
@@ -61,9 +61,9 @@ function flipResizeDirection(side) {
61
61
  }
62
62
  return 'Right';
63
63
  }
64
- function getResizeDirection(separator, direction) {
64
+ function getResizeDirection(separator, isRtl) {
65
65
  const side = separator.classList.contains(_gridClasses.gridClasses['columnSeparator--sideRight']) ? 'Right' : 'Left';
66
- if (direction === 'rtl') {
66
+ if (isRtl) {
67
67
  // Resizing logic should be mirrored in the RTL case
68
68
  return flipResizeDirection(side);
69
69
  }
@@ -187,7 +187,7 @@ function createResizeRefs() {
187
187
  * TODO: improve experience for last column
188
188
  */
189
189
  const useGridColumnResize = (apiRef, props) => {
190
- const theme = (0, _styles.useTheme)();
190
+ const isRtl = (0, _RtlProvider.useRtl)();
191
191
  const logger = (0, _utils2.useGridLogger)(apiRef, 'useGridColumnResize');
192
192
  const refs = (0, _useLazyRef.default)(createResizeRefs).current;
193
193
 
@@ -327,7 +327,7 @@ const useGridColumnResize = (apiRef, props) => {
327
327
  refs.rightPinnedCellsBefore = pinnedPosition !== _gridColumnsInterfaces.GridPinnedColumnPosition.RIGHT ? [] : (0, _domUtils.findRightPinnedCellsBeforeCol)(apiRef.current, refs.columnHeaderElement);
328
328
  refs.leftPinnedHeadersAfter = pinnedPosition !== _gridColumnsInterfaces.GridPinnedColumnPosition.LEFT ? [] : (0, _domUtils.findLeftPinnedHeadersAfterCol)(apiRef.current, refs.columnHeaderElement);
329
329
  refs.rightPinnedHeadersBefore = pinnedPosition !== _gridColumnsInterfaces.GridPinnedColumnPosition.RIGHT ? [] : (0, _domUtils.findRightPinnedHeadersBeforeCol)(apiRef.current, refs.columnHeaderElement);
330
- resizeDirection.current = getResizeDirection(separator, theme.direction);
330
+ resizeDirection.current = getResizeDirection(separator, isRtl);
331
331
  initialOffsetToSeparator.current = computeOffsetToSeparator(xStart, refs.columnHeaderElement.getBoundingClientRect(), resizeDirection.current);
332
332
  };
333
333
  const handleResizeMouseUp = (0, _utils.unstable_useEventCallback)(finishResize);
@@ -62,8 +62,8 @@ const gridPinnedColumnsSelector = state => state.pinnedColumns;
62
62
  * @category Visible Columns
63
63
  */
64
64
  exports.gridPinnedColumnsSelector = gridPinnedColumnsSelector;
65
- const gridVisiblePinnedColumnDefinitionsSelector = exports.gridVisiblePinnedColumnDefinitionsSelector = (0, _createSelector.createSelectorMemoized)(gridColumnsStateSelector, gridPinnedColumnsSelector, gridVisibleColumnFieldsSelector, _gridCoreSelector.gridThemeSelector, (columnsState, model, visibleColumnFields, theme) => {
66
- const visiblePinnedFields = filterVisibleColumns(model, visibleColumnFields, theme.direction === 'rtl');
65
+ const gridVisiblePinnedColumnDefinitionsSelector = exports.gridVisiblePinnedColumnDefinitionsSelector = (0, _createSelector.createSelectorMemoized)(gridColumnsStateSelector, gridPinnedColumnsSelector, gridVisibleColumnFieldsSelector, _gridCoreSelector.gridIsRtlSelector, (columnsState, model, visibleColumnFields, isRtl) => {
66
+ const visiblePinnedFields = filterVisibleColumns(model, visibleColumnFields, isRtl);
67
67
  const visiblePinnedColumns = {
68
68
  left: visiblePinnedFields.left.map(field => columnsState.lookup[field]),
69
69
  right: visiblePinnedFields.right.map(field => columnsState.lookup[field])