@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
@@ -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
  }) => {
@@ -61,7 +61,8 @@ function useGridParamsApi(apiRef) {
61
61
  tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
62
62
  value,
63
63
  formattedValue: value,
64
- isEditable: false
64
+ isEditable: false,
65
+ api: {}
65
66
  };
66
67
  if (colDef && colDef.valueFormatter) {
67
68
  params.formattedValue = colDef.valueFormatter(value, row, colDef, apiRef);
@@ -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;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useGridSelector = exports.objectShallowCompare = void 0;
6
+ exports.useGridSelectorV8 = exports.useGridSelector = exports.objectShallowCompare = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompare");
9
9
  var _useLazyRef = require("./useLazyRef");
@@ -14,12 +14,21 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
14
14
  function isOutputSelector(selector) {
15
15
  return selector.acceptsApiRef;
16
16
  }
17
+ // TODO v8: Remove this function
17
18
  function applySelector(apiRef, selector) {
18
19
  if (isOutputSelector(selector)) {
19
20
  return selector(apiRef);
20
21
  }
21
22
  return selector(apiRef.current.state);
22
23
  }
24
+
25
+ // TODO v8: Rename this function to `applySelector`
26
+ function applySelectorV8(apiRef, selector, args, instanceId) {
27
+ if (isOutputSelector(selector)) {
28
+ return selector(apiRef, args);
29
+ }
30
+ return selector(apiRef.current.state, instanceId);
31
+ }
23
32
  const defaultCompare = Object.is;
24
33
  const objectShallowCompare = exports.objectShallowCompare = _fastObjectShallowCompare.fastObjectShallowCompare;
25
34
  const createRefs = () => ({
@@ -27,6 +36,8 @@ const createRefs = () => ({
27
36
  equals: null,
28
37
  selector: null
29
38
  });
39
+
40
+ // TODO v8: Remove this function
30
41
  const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
31
42
  if (process.env.NODE_ENV !== 'production') {
32
43
  if (!apiRef.current.state) {
@@ -52,4 +63,32 @@ const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
52
63
  });
53
64
  return state;
54
65
  };
55
- exports.useGridSelector = useGridSelector;
66
+
67
+ // TODO v8: Rename this function to `useGridSelector`
68
+ exports.useGridSelector = useGridSelector;
69
+ const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = defaultCompare) => {
70
+ if (process.env.NODE_ENV !== 'production') {
71
+ if (!apiRef.current.state) {
72
+ (0, _warning.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.']);
73
+ }
74
+ }
75
+ const refs = (0, _useLazyRef.useLazyRef)(createRefs);
76
+ const didInit = refs.current.selector !== null;
77
+ const [state, setState] = React.useState(
78
+ // We don't use an initialization function to avoid allocations
79
+ didInit ? null : applySelectorV8(apiRef, selector, args, apiRef.current.instanceId));
80
+ refs.current.state = state;
81
+ refs.current.equals = equals;
82
+ refs.current.selector = selector;
83
+ (0, _useOnMount.useOnMount)(() => {
84
+ return apiRef.current.store.subscribe(() => {
85
+ const newState = applySelectorV8(apiRef, refs.current.selector, args, apiRef.current.instanceId);
86
+ if (!refs.current.equals(refs.current.state, newState)) {
87
+ refs.current.state = newState;
88
+ setState(newState);
89
+ }
90
+ });
91
+ });
92
+ return state;
93
+ };
94
+ exports.useGridSelectorV8 = useGridSelectorV8;
package/node/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
@@ -85,7 +85,10 @@ var _exportNames = {
85
85
  getColumnsToExport: true,
86
86
  defaultGetRowsToExport: true,
87
87
  createSelector: true,
88
+ createSelectorV8: true,
88
89
  createSelectorMemoized: true,
90
+ createSelectorMemoizedV8: true,
91
+ useGridSelectorV8: true,
89
92
  findParentElementFromClassName: true,
90
93
  getActiveElement: true,
91
94
  isEventTargetInPortal: true,
@@ -197,6 +200,18 @@ Object.defineProperty(exports, "createSelectorMemoized", {
197
200
  return _createSelector.createSelectorMemoized;
198
201
  }
199
202
  });
203
+ Object.defineProperty(exports, "createSelectorMemoizedV8", {
204
+ enumerable: true,
205
+ get: function () {
206
+ return _createSelector.createSelectorMemoizedV8;
207
+ }
208
+ });
209
+ Object.defineProperty(exports, "createSelectorV8", {
210
+ enumerable: true,
211
+ get: function () {
212
+ return _createSelector.createSelectorV8;
213
+ }
214
+ });
200
215
  Object.defineProperty(exports, "defaultGetRowsToExport", {
201
216
  enumerable: true,
202
217
  get: function () {
@@ -605,6 +620,12 @@ Object.defineProperty(exports, "useGridScroll", {
605
620
  return _useGridScroll.useGridScroll;
606
621
  }
607
622
  });
623
+ Object.defineProperty(exports, "useGridSelectorV8", {
624
+ enumerable: true,
625
+ get: function () {
626
+ return _useGridSelector.useGridSelectorV8;
627
+ }
628
+ });
608
629
  Object.defineProperty(exports, "useGridSorting", {
609
630
  enumerable: true,
610
631
  get: function () {
@@ -748,6 +769,7 @@ Object.keys(_createControllablePromise).forEach(function (key) {
748
769
  });
749
770
  });
750
771
  var _createSelector = require("../utils/createSelector");
772
+ var _useGridSelector = require("../hooks/utils/useGridSelector");
751
773
  var _domUtils = require("../utils/domUtils");
752
774
  var _keyboardUtils = require("../utils/keyboardUtils");
753
775
  var _utils2 = require("../utils/utils");
@@ -44,11 +44,10 @@ const csCZGrid = {
44
44
  toolbarExportPrint: 'Vytisknout',
45
45
  toolbarExportExcel: 'Stáhnout jako Excel',
46
46
  // Columns management text
47
- // columnsManagementSearchTitle: 'Search',
48
- // columnsManagementNoColumns: 'No columns',
49
- // columnsManagementShowHideAllText: 'Show/Hide All',
50
- // columnsManagementReset: 'Reset',
51
-
47
+ columnsManagementSearchTitle: 'Hledat sloupce',
48
+ columnsManagementNoColumns: 'Žádné sloupce',
49
+ columnsManagementShowHideAllText: 'Zobrazit/skrýt vše',
50
+ columnsManagementReset: 'Resetovat',
52
51
  // Filter panel text
53
52
  filterPanelAddFilter: 'Přidat filtr',
54
53
  filterPanelRemoveAll: 'Odstranit vše',
@@ -36,11 +36,10 @@ const heILGrid = {
36
36
  toolbarExportPrint: 'הדפסה',
37
37
  toolbarExportExcel: 'ייצוא ל- Excel',
38
38
  // Columns management text
39
- // columnsManagementSearchTitle: 'Search',
40
- // columnsManagementNoColumns: 'No columns',
41
- // columnsManagementShowHideAllText: 'Show/Hide All',
42
- // columnsManagementReset: 'Reset',
43
-
39
+ columnsManagementSearchTitle: 'חיפוש',
40
+ columnsManagementNoColumns: 'אין עמודות',
41
+ columnsManagementShowHideAllText: 'הצג/הסתר הכל',
42
+ columnsManagementReset: 'אתחול',
44
43
  // Filter panel text
45
44
  filterPanelAddFilter: 'הוסף מסנן',
46
45
  filterPanelRemoveAll: 'מחק הכל',
@@ -3,9 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createSelectorMemoized = exports.createSelector = void 0;
6
+ exports.createSelectorV8 = exports.createSelectorMemoizedV8 = exports.createSelectorMemoized = exports.createSelector = void 0;
7
7
  var _reselect = require("reselect");
8
8
  var _warning = require("../internals/utils/warning");
9
+ // TODO v8: Remove this type
10
+
11
+ // TODO v8: Rename this type to `OutputSelector`
12
+
13
+ // TODO v8: Remove this type
14
+
15
+ // TODO v8: Rename this type to `SelectorArgs`
16
+
17
+ // TODO v8: Remove this type
18
+
19
+ // TODO v8: Rename this type to `CreateSelectorFunction`
20
+
9
21
  const cache = new WeakMap();
10
22
  function checkIsAPIRef(value) {
11
23
  return 'current' in value && 'instanceId' in value.current;
@@ -13,6 +25,8 @@ function checkIsAPIRef(value) {
13
25
  const DEFAULT_INSTANCE_ID = {
14
26
  id: 'default'
15
27
  };
28
+
29
+ // TODO v8: Remove this function
16
30
  const createSelector = (a, b, c, d, e, f, ...other) => {
17
31
  if (other.length > 0) {
18
32
  throw new Error('Unsupported number of selectors');
@@ -77,7 +91,76 @@ const createSelector = (a, b, c, d, e, f, ...other) => {
77
91
  selector.acceptsApiRef = true;
78
92
  return selector;
79
93
  };
94
+
95
+ // TODO v8: Rename this function to `createSelector`
80
96
  exports.createSelector = createSelector;
97
+ const createSelectorV8 = (a, b, c, d, e, f, ...other) => {
98
+ if (other.length > 0) {
99
+ throw new Error('Unsupported number of selectors');
100
+ }
101
+ let selector;
102
+ if (a && b && c && d && e && f) {
103
+ selector = (stateOrApiRef, args, instanceIdParam) => {
104
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
105
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
106
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
107
+ const va = a(state, args, instanceId);
108
+ const vb = b(state, args, instanceId);
109
+ const vc = c(state, args, instanceId);
110
+ const vd = d(state, args, instanceId);
111
+ const ve = e(state, args, instanceId);
112
+ return f(va, vb, vc, vd, ve, args);
113
+ };
114
+ } else if (a && b && c && d && e) {
115
+ selector = (stateOrApiRef, args, instanceIdParam) => {
116
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
117
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
118
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
119
+ const va = a(state, args, instanceId);
120
+ const vb = b(state, args, instanceId);
121
+ const vc = c(state, args, instanceId);
122
+ const vd = d(state, args, instanceId);
123
+ return e(va, vb, vc, vd, args);
124
+ };
125
+ } else if (a && b && c && d) {
126
+ selector = (stateOrApiRef, args, instanceIdParam) => {
127
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
128
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
129
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
130
+ const va = a(state, args, instanceId);
131
+ const vb = b(state, args, instanceId);
132
+ const vc = c(state, args, instanceId);
133
+ return d(va, vb, vc, args);
134
+ };
135
+ } else if (a && b && c) {
136
+ selector = (stateOrApiRef, args, instanceIdParam) => {
137
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
138
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
139
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
140
+ const va = a(state, args, instanceId);
141
+ const vb = b(state, args, instanceId);
142
+ return c(va, vb, args);
143
+ };
144
+ } else if (a && b) {
145
+ selector = (stateOrApiRef, args, instanceIdParam) => {
146
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
147
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
148
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
149
+ const va = a(state, args, instanceId);
150
+ return b(va, args);
151
+ };
152
+ } else {
153
+ throw new Error('Missing arguments');
154
+ }
155
+
156
+ // We use this property to detect if the selector was created with createSelector
157
+ // or it's only a simple function the receives the state and returns part of it.
158
+ selector.acceptsApiRef = true;
159
+ return selector;
160
+ };
161
+
162
+ // TODO v8: Remove this function
163
+ exports.createSelectorV8 = createSelectorV8;
81
164
  const createSelectorMemoized = (...args) => {
82
165
  const selector = (stateOrApiRef, instanceId) => {
83
166
  const isAPIRef = checkIsAPIRef(stateOrApiRef);
@@ -109,4 +192,38 @@ const createSelectorMemoized = (...args) => {
109
192
  selector.acceptsApiRef = true;
110
193
  return selector;
111
194
  };
112
- exports.createSelectorMemoized = createSelectorMemoized;
195
+
196
+ // TODO v8: Rename this function to `createSelectorMemoized`
197
+ exports.createSelectorMemoized = createSelectorMemoized;
198
+ const createSelectorMemoizedV8 = (...args) => {
199
+ const selector = (stateOrApiRef, selectorArgs, instanceId) => {
200
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
201
+ const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
202
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
203
+ if (process.env.NODE_ENV !== 'production') {
204
+ if (cacheKey.id === 'default') {
205
+ (0, _warning.warnOnce)(['MUI X: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, for example `mySelector(apiRef)`, or pass the instance ID explicitly, for example `mySelector(state, apiRef.current.instanceId)`.']);
206
+ }
207
+ }
208
+ const cacheArgsInit = cache.get(cacheKey);
209
+ const cacheArgs = cacheArgsInit ?? new Map();
210
+ const cacheFn = cacheArgs?.get(args);
211
+ if (cacheArgs && cacheFn) {
212
+ // We pass the cache key because the called selector might have as
213
+ // dependency another selector created with this `createSelector`.
214
+ return cacheFn(state, selectorArgs, cacheKey);
215
+ }
216
+ const fn = (0, _reselect.createSelector)(...args);
217
+ if (!cacheArgsInit) {
218
+ cache.set(cacheKey, cacheArgs);
219
+ }
220
+ cacheArgs.set(args, fn);
221
+ return fn(state, selectorArgs, cacheKey);
222
+ };
223
+
224
+ // We use this property to detect if the selector was created with createSelector
225
+ // or it's only a simple function the receives the state and returns part of it.
226
+ selector.acceptsApiRef = true;
227
+ return selector;
228
+ };
229
+ exports.createSelectorMemoizedV8 = createSelectorMemoizedV8;
@@ -3,21 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isNavigationKey = exports.isMultipleKey = exports.isKeyboardEvent = exports.isHideMenuKey = exports.isEscapeKey = exports.isCellExitEditModeKeys = exports.isCellEnterEditModeKeys = exports.isCellEditCommitKeys = exports.GRID_MULTIPLE_SELECTION_KEYS = exports.GRID_CELL_EXIT_EDIT_MODE_KEYS = exports.GRID_CELL_EDIT_COMMIT_KEYS = void 0;
6
+ exports.isNavigationKey = exports.isMultipleKey = exports.isKeyboardEvent = exports.isHideMenuKey = exports.isCellExitEditModeKeys = exports.isCellEnterEditModeKeys = exports.isCellEditCommitKeys = exports.GRID_MULTIPLE_SELECTION_KEYS = exports.GRID_CELL_EXIT_EDIT_MODE_KEYS = exports.GRID_CELL_EDIT_COMMIT_KEYS = void 0;
7
7
  exports.isPasteShortcut = isPasteShortcut;
8
8
  exports.isPrintableKey = isPrintableKey;
9
- exports.isTabKey = void 0;
10
- /**
11
- * @deprecated there is no meaninfuly logic abstracted, use event.key directly.
12
- */
13
- const isEscapeKey = key => key === 'Escape';
14
-
15
- /**
16
- * @deprecated there is no meaninfuly logic abstracted, use event.key directly.
17
- */
18
- exports.isEscapeKey = isEscapeKey;
19
- const isTabKey = key => key === 'Tab';
20
-
21
9
  // Non printable keys have a name, for example "ArrowRight", see the whole list:
22
10
  // https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
23
11
  // So event.key.length === 1 is often enough.
@@ -25,7 +13,6 @@ const isTabKey = key => key === 'Tab';
25
13
  // However, we also need to ignore shortcuts, for example: select all:
26
14
  // - Windows: Ctrl+A, event.ctrlKey is true
27
15
  // - macOS: ⌘ Command+A, event.metaKey is true
28
- exports.isTabKey = isTabKey;
29
16
  function isPrintableKey(event) {
30
17
  return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
31
18
  }
@@ -44,7 +31,7 @@ const isNavigationKey = key => key.indexOf('Arrow') === 0 || key.indexOf('Page')
44
31
  exports.isNavigationKey = isNavigationKey;
45
32
  const isKeyboardEvent = event => !!event.key;
46
33
  exports.isKeyboardEvent = isKeyboardEvent;
47
- const isHideMenuKey = key => isTabKey(key) || isEscapeKey(key);
34
+ const isHideMenuKey = key => key === 'Tab' || key === 'Escape';
48
35
 
49
36
  // In theory, on macOS, ctrl + v doesn't trigger a paste, so the function should return false.
50
37
  // However, maybe it's overkill to fix, so let's be lazy.