@mui/x-data-grid 7.13.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 (91) hide show
  1. package/CHANGELOG.md +151 -2
  2. package/components/cell/GridActionsCell.js +3 -3
  3. package/components/cell/GridCell.js +11 -12
  4. package/components/cell/GridEditSingleSelectCell.js +2 -3
  5. package/components/menu/columnMenu/GridColumnMenuContainer.js +2 -2
  6. package/components/panel/GridPanel.d.ts +1 -1
  7. package/components/panel/GridPanel.js +1 -2
  8. package/components/panel/filterPanel/GridFilterForm.js +9 -4
  9. package/components/toolbar/GridToolbarDensitySelector.js +2 -2
  10. package/components/toolbar/GridToolbarExportContainer.js +2 -2
  11. package/components/toolbar/GridToolbarQuickFilter.js +5 -3
  12. package/hooks/core/gridCoreSelector.d.ts +1 -1
  13. package/hooks/core/gridCoreSelector.js +1 -1
  14. package/hooks/core/useGridInitialization.js +2 -2
  15. package/hooks/core/{useGridTheme.d.ts → useGridIsRtl.d.ts} +1 -1
  16. package/hooks/core/{useGridTheme.js → useGridIsRtl.js} +7 -7
  17. package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -3
  18. package/hooks/features/columnResize/useGridColumnResize.js +5 -5
  19. package/hooks/features/columns/gridColumnsSelector.js +3 -3
  20. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +19 -20
  21. package/hooks/features/rows/useGridParamsApi.js +2 -1
  22. package/hooks/features/scroll/useGridScroll.js +4 -4
  23. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -2
  24. package/hooks/features/virtualization/useGridVirtualScroller.js +13 -13
  25. package/hooks/utils/useGridSelector.d.ts +4 -1
  26. package/hooks/utils/useGridSelector.js +38 -0
  27. package/index.js +1 -1
  28. package/internals/index.d.ts +2 -1
  29. package/internals/index.js +2 -1
  30. package/locales/csCZ.js +4 -5
  31. package/locales/heIL.js +4 -5
  32. package/models/gridDataSource.d.ts +6 -6
  33. package/models/gridStateCommunity.d.ts +1 -2
  34. package/models/params/gridCellParams.d.ts +4 -0
  35. package/modern/components/cell/GridActionsCell.js +3 -3
  36. package/modern/components/cell/GridCell.js +11 -12
  37. package/modern/components/cell/GridEditSingleSelectCell.js +2 -3
  38. package/modern/components/menu/columnMenu/GridColumnMenuContainer.js +2 -2
  39. package/modern/components/panel/GridPanel.js +1 -2
  40. package/modern/components/panel/filterPanel/GridFilterForm.js +9 -4
  41. package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
  42. package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
  43. package/modern/components/toolbar/GridToolbarQuickFilter.js +5 -3
  44. package/modern/hooks/core/gridCoreSelector.js +1 -1
  45. package/modern/hooks/core/useGridInitialization.js +2 -2
  46. package/modern/hooks/core/{useGridTheme.js → useGridIsRtl.js} +7 -7
  47. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -3
  48. package/modern/hooks/features/columnResize/useGridColumnResize.js +5 -5
  49. package/modern/hooks/features/columns/gridColumnsSelector.js +3 -3
  50. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +19 -20
  51. package/modern/hooks/features/rows/useGridParamsApi.js +2 -1
  52. package/modern/hooks/features/scroll/useGridScroll.js +4 -4
  53. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +13 -13
  54. package/modern/hooks/utils/useGridSelector.js +38 -0
  55. package/modern/index.js +1 -1
  56. package/modern/internals/index.js +2 -1
  57. package/modern/locales/csCZ.js +4 -5
  58. package/modern/locales/heIL.js +4 -5
  59. package/modern/utils/createSelector.js +116 -0
  60. package/modern/utils/keyboardUtils.js +1 -11
  61. package/node/components/cell/GridActionsCell.js +3 -3
  62. package/node/components/cell/GridCell.js +11 -12
  63. package/node/components/cell/GridEditSingleSelectCell.js +2 -3
  64. package/node/components/menu/columnMenu/GridColumnMenuContainer.js +1 -1
  65. package/node/components/panel/GridPanel.js +1 -2
  66. package/node/components/panel/filterPanel/GridFilterForm.js +9 -4
  67. package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
  68. package/node/components/toolbar/GridToolbarExportContainer.js +1 -1
  69. package/node/components/toolbar/GridToolbarQuickFilter.js +5 -3
  70. package/node/hooks/core/gridCoreSelector.js +3 -3
  71. package/node/hooks/core/useGridInitialization.js +2 -2
  72. package/node/hooks/core/{useGridTheme.js → useGridIsRtl.js} +9 -9
  73. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -2
  74. package/node/hooks/features/columnResize/useGridColumnResize.js +5 -5
  75. package/node/hooks/features/columns/gridColumnsSelector.js +2 -2
  76. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +19 -20
  77. package/node/hooks/features/rows/useGridParamsApi.js +2 -1
  78. package/node/hooks/features/scroll/useGridScroll.js +4 -4
  79. package/node/hooks/features/virtualization/useGridVirtualScroller.js +13 -13
  80. package/node/hooks/utils/useGridSelector.js +41 -2
  81. package/node/index.js +1 -1
  82. package/node/internals/index.js +22 -0
  83. package/node/locales/csCZ.js +4 -5
  84. package/node/locales/heIL.js +4 -5
  85. package/node/utils/createSelector.js +119 -2
  86. package/node/utils/keyboardUtils.js +2 -15
  87. package/package.json +6 -6
  88. package/utils/createSelector.d.ts +19 -0
  89. package/utils/createSelector.js +116 -0
  90. package/utils/keyboardUtils.d.ts +1 -9
  91. package/utils/keyboardUtils.js +1 -11
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
6
6
  import * as React from 'react';
7
7
  import MenuList from '@mui/material/MenuList';
8
8
  import { styled } from '@mui/material/styles';
9
- import { isHideMenuKey, isTabKey } from '../../../utils/keyboardUtils';
9
+ import { isHideMenuKey } from '../../../utils/keyboardUtils';
10
10
  import { gridClasses } from '../../../constants/gridClasses';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  const StyledMenuList = styled(MenuList)(() => ({
@@ -23,7 +23,7 @@ const GridColumnMenuContainer = /*#__PURE__*/React.forwardRef(function GridColum
23
23
  } = props,
24
24
  other = _objectWithoutPropertiesLoose(props, _excluded);
25
25
  const handleListKeyDown = React.useCallback(event => {
26
- if (isTabKey(event.key)) {
26
+ if (event.key === 'Tab') {
27
27
  event.preventDefault();
28
28
  }
29
29
  if (isHideMenuKey(event.key)) {
@@ -10,7 +10,6 @@ import ClickAwayListener from '@mui/material/ClickAwayListener';
10
10
  import Paper from '@mui/material/Paper';
11
11
  import Popper from '@mui/material/Popper';
12
12
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
13
- import { isEscapeKey } from '../../utils/keyboardUtils';
14
13
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
15
14
  import { jsx as _jsx } from "react/jsx-runtime";
16
15
  export const gridPanelClasses = generateUtilityClasses('MuiDataGrid', ['panel', 'paper']);
@@ -51,7 +50,7 @@ const GridPanel = /*#__PURE__*/React.forwardRef((props, ref) => {
51
50
  apiRef.current.hidePreferences();
52
51
  }, [apiRef]);
53
52
  const handleKeyDown = React.useCallback(event => {
54
- if (isEscapeKey(event.key)) {
53
+ if (event.key === 'Escape') {
55
54
  apiRef.current.hidePreferences();
56
55
  }
57
56
  }, [apiRef]);
@@ -281,10 +281,15 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
281
281
  variant: "standard",
282
282
  as: rootProps.slots.baseFormControl
283
283
  }, baseFormControlProps, logicOperatorInputProps, {
284
- sx: _extends({
285
- display: hasLogicOperatorColumn ? 'flex' : 'none',
286
- visibility: showMultiFilterOperators ? 'visible' : 'hidden'
287
- }, baseFormControlProps.sx || {}, logicOperatorInputProps.sx || {}),
284
+ sx: [hasLogicOperatorColumn ? {
285
+ display: 'flex'
286
+ } : {
287
+ display: 'none'
288
+ }, showMultiFilterOperators ? {
289
+ visibility: 'visible'
290
+ } : {
291
+ visibility: 'hidden'
292
+ }, baseFormControlProps.sx, logicOperatorInputProps.sx],
288
293
  className: clsx(classes.logicOperatorInput, baseFormControlProps.className, logicOperatorInputProps.className),
289
294
  ownerState: rootProps,
290
295
  children: /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
@@ -6,7 +6,7 @@ import MenuList from '@mui/material/MenuList';
6
6
  import MenuItem from '@mui/material/MenuItem';
7
7
  import ListItemIcon from '@mui/material/ListItemIcon';
8
8
  import { gridDensitySelector } from '../../hooks/features/density/densitySelector';
9
- import { isHideMenuKey, isTabKey } from '../../utils/keyboardUtils';
9
+ import { isHideMenuKey } from '../../utils/keyboardUtils';
10
10
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
11
11
  import { useGridSelector } from '../../hooks/utils/useGridSelector';
12
12
  import { GridMenu } from '../menu/GridMenu';
@@ -62,7 +62,7 @@ const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function GridTo
62
62
  setOpen(false);
63
63
  };
64
64
  const handleListKeyDown = event => {
65
- if (isTabKey(event.key)) {
65
+ if (event.key === 'Tab') {
66
66
  event.preventDefault();
67
67
  }
68
68
  if (isHideMenuKey(event.key)) {
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { unstable_useId as useId, unstable_useForkRef as useForkRef } from '@mui/utils';
5
5
  import MenuList from '@mui/material/MenuList';
6
- import { isHideMenuKey, isTabKey } from '../../utils/keyboardUtils';
6
+ import { isHideMenuKey } from '../../utils/keyboardUtils';
7
7
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
8
8
  import { GridMenu } from '../menu/GridMenu';
9
9
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
@@ -29,7 +29,7 @@ const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function GridTo
29
29
  };
30
30
  const handleMenuClose = () => setOpen(false);
31
31
  const handleListKeyDown = event => {
32
- if (isTabKey(event.key)) {
32
+ if (event.key === 'Tab') {
33
33
  event.preventDefault();
34
34
  }
35
35
  if (isHideMenuKey(event.key)) {
@@ -105,9 +105,11 @@ function GridToolbarQuickFilter(props) {
105
105
  endAdornment: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
106
106
  "aria-label": apiRef.current.getLocaleText('toolbarQuickFilterDeleteIconLabel'),
107
107
  size: "small",
108
- sx: {
109
- visibility: searchValue ? 'visible' : 'hidden'
110
- },
108
+ sx: [searchValue ? {
109
+ visibility: 'visible'
110
+ } : {
111
+ visibility: 'hidden'
112
+ }],
111
113
  onClick: handleSearchReset
112
114
  }, rootProps.slotProps?.baseIconButton, {
113
115
  children: /*#__PURE__*/_jsx(rootProps.slots.quickFilterClearIcon, {
@@ -2,4 +2,4 @@
2
2
  * Get the theme state
3
3
  * @category Core
4
4
  */
5
- export const gridThemeSelector = state => state.theme;
5
+ export const gridIsRtlSelector = state => state.isRtl;
@@ -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
  }) => {
@@ -51,7 +51,8 @@ export function useGridParamsApi(apiRef) {
51
51
  tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
52
52
  value,
53
53
  formattedValue: value,
54
- isEditable: false
54
+ isEditable: false,
55
+ api: {}
55
56
  };
56
57
  if (colDef && colDef.valueFormatter) {
57
58
  params.formattedValue = colDef.valueFormatter(value, row, colDef, apiRef);
@@ -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;
@@ -6,12 +6,21 @@ import { warnOnce } from '../../internals/utils/warning';
6
6
  function isOutputSelector(selector) {
7
7
  return selector.acceptsApiRef;
8
8
  }
9
+ // TODO v8: Remove this function
9
10
  function applySelector(apiRef, selector) {
10
11
  if (isOutputSelector(selector)) {
11
12
  return selector(apiRef);
12
13
  }
13
14
  return selector(apiRef.current.state);
14
15
  }
16
+
17
+ // TODO v8: Rename this function to `applySelector`
18
+ function applySelectorV8(apiRef, selector, args, instanceId) {
19
+ if (isOutputSelector(selector)) {
20
+ return selector(apiRef, args);
21
+ }
22
+ return selector(apiRef.current.state, instanceId);
23
+ }
15
24
  const defaultCompare = Object.is;
16
25
  export const objectShallowCompare = fastObjectShallowCompare;
17
26
  const createRefs = () => ({
@@ -19,6 +28,8 @@ const createRefs = () => ({
19
28
  equals: null,
20
29
  selector: null
21
30
  });
31
+
32
+ // TODO v8: Remove this function
22
33
  export const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
23
34
  if (process.env.NODE_ENV !== 'production') {
24
35
  if (!apiRef.current.state) {
@@ -43,4 +54,31 @@ export const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
43
54
  });
44
55
  });
45
56
  return state;
57
+ };
58
+
59
+ // TODO v8: Rename this function to `useGridSelector`
60
+ export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = defaultCompare) => {
61
+ if (process.env.NODE_ENV !== 'production') {
62
+ if (!apiRef.current.state) {
63
+ warnOnce(['MUI X: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
64
+ }
65
+ }
66
+ const refs = useLazyRef(createRefs);
67
+ const didInit = refs.current.selector !== null;
68
+ const [state, setState] = React.useState(
69
+ // We don't use an initialization function to avoid allocations
70
+ didInit ? null : applySelectorV8(apiRef, selector, args, apiRef.current.instanceId));
71
+ refs.current.state = state;
72
+ refs.current.equals = equals;
73
+ refs.current.selector = selector;
74
+ useOnMount(() => {
75
+ return apiRef.current.store.subscribe(() => {
76
+ const newState = applySelectorV8(apiRef, refs.current.selector, args, apiRef.current.instanceId);
77
+ if (!refs.current.equals(refs.current.state, newState)) {
78
+ refs.current.state = newState;
79
+ setState(newState);
80
+ }
81
+ });
82
+ });
83
+ return state;
46
84
  };
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.13.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
@@ -57,7 +57,8 @@ export { useGridVisibleRows, getVisibleRows } from '../hooks/utils/useGridVisibl
57
57
  export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
58
58
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
59
59
  export * from '../utils/createControllablePromise';
60
- export { createSelector, createSelectorMemoized } from '../utils/createSelector';
60
+ export { createSelector, createSelectorV8, createSelectorMemoized, createSelectorMemoizedV8 } from '../utils/createSelector';
61
+ export { useGridSelectorV8 } from '../hooks/utils/useGridSelector';
61
62
  export { gridRowGroupsToFetchSelector } from '../hooks/features/rows/gridRowsSelector';
62
63
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from '../utils/domUtils';
63
64
  export { isNavigationKey, isPasteShortcut } from '../utils/keyboardUtils';
@@ -38,11 +38,10 @@ const csCZGrid = {
38
38
  toolbarExportPrint: 'Vytisknout',
39
39
  toolbarExportExcel: 'Stáhnout jako Excel',
40
40
  // Columns management text
41
- // columnsManagementSearchTitle: 'Search',
42
- // columnsManagementNoColumns: 'No columns',
43
- // columnsManagementShowHideAllText: 'Show/Hide All',
44
- // columnsManagementReset: 'Reset',
45
-
41
+ columnsManagementSearchTitle: 'Hledat sloupce',
42
+ columnsManagementNoColumns: 'Žádné sloupce',
43
+ columnsManagementShowHideAllText: 'Zobrazit/skrýt vše',
44
+ columnsManagementReset: 'Resetovat',
46
45
  // Filter panel text
47
46
  filterPanelAddFilter: 'Přidat filtr',
48
47
  filterPanelRemoveAll: 'Odstranit vše',