@mui/x-data-grid 7.20.0 → 7.21.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 (124) hide show
  1. package/CHANGELOG.md +120 -31
  2. package/DataGrid/DataGrid.js +1 -0
  3. package/DataGrid/index.d.ts +0 -1
  4. package/DataGrid/index.js +1 -2
  5. package/DataGrid/useDataGridComponent.js +4 -1
  6. package/DataGrid/useDataGridProps.d.ts +1 -5
  7. package/DataGrid/useDataGridProps.js +3 -62
  8. package/components/GridPagination.js +1 -0
  9. package/components/GridRow.js +25 -36
  10. package/components/base/GridOverlays.js +8 -0
  11. package/components/containers/GridRootStyles.js +1 -0
  12. package/components/menu/columnMenu/GridColumnMenu.js +32 -0
  13. package/components/toolbar/GridToolbarExport.d.ts +9 -3
  14. package/components/toolbar/GridToolbarExport.js +55 -3
  15. package/components/virtualization/GridVirtualScrollbar.js +4 -0
  16. package/components/virtualization/GridVirtualScroller.js +2 -2
  17. package/constants/dataGridPropsDefaultValues.d.ts +5 -0
  18. package/constants/dataGridPropsDefaultValues.js +60 -0
  19. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +2 -1
  20. package/hooks/features/clipboard/useGridClipboard.js +2 -1
  21. package/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
  22. package/hooks/features/columns/gridColumnsUtils.d.ts +1 -1
  23. package/hooks/features/columns/gridColumnsUtils.js +3 -0
  24. package/hooks/features/dimensions/useGridDimensions.js +4 -2
  25. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  26. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
  27. package/hooks/features/listView/gridListViewSelectors.d.ts +5 -0
  28. package/hooks/features/listView/gridListViewSelectors.js +4 -0
  29. package/hooks/features/listView/useGridListView.d.ts +10 -0
  30. package/hooks/features/listView/useGridListView.js +54 -0
  31. package/hooks/features/rowSelection/useGridRowSelection.js +11 -2
  32. package/hooks/features/rowSelection/utils.js +1 -1
  33. package/hooks/features/rows/gridRowsMetaInterfaces.d.ts +16 -0
  34. package/hooks/features/rows/gridRowsMetaInterfaces.js +1 -0
  35. package/hooks/features/rows/gridRowsUtils.d.ts +3 -0
  36. package/hooks/features/rows/gridRowsUtils.js +14 -1
  37. package/hooks/features/rows/useGridParamsApi.d.ts +2 -1
  38. package/hooks/features/rows/useGridParamsApi.js +4 -3
  39. package/hooks/features/rows/useGridRowsMeta.js +135 -154
  40. package/hooks/features/scroll/useGridScroll.d.ts +1 -1
  41. package/hooks/features/scroll/useGridScroll.js +3 -2
  42. package/hooks/features/virtualization/useGridVirtualScroller.js +23 -9
  43. package/hooks/utils/useGridApiMethod.js +2 -1
  44. package/index.d.ts +1 -0
  45. package/index.js +2 -1
  46. package/internals/index.d.ts +2 -1
  47. package/internals/index.js +2 -1
  48. package/models/api/gridRowsMetaApi.d.ts +15 -14
  49. package/models/colDef/gridColDef.d.ts +6 -0
  50. package/models/colDef/index.d.ts +1 -1
  51. package/models/gridApiCaches.d.ts +2 -0
  52. package/models/gridStateCommunity.d.ts +2 -0
  53. package/models/props/DataGridProps.d.ts +14 -3
  54. package/modern/DataGrid/DataGrid.js +1 -0
  55. package/modern/DataGrid/index.js +1 -2
  56. package/modern/DataGrid/useDataGridComponent.js +4 -1
  57. package/modern/DataGrid/useDataGridProps.js +3 -62
  58. package/modern/components/GridPagination.js +1 -0
  59. package/modern/components/GridRow.js +25 -36
  60. package/modern/components/base/GridOverlays.js +8 -0
  61. package/modern/components/containers/GridRootStyles.js +1 -0
  62. package/modern/components/menu/columnMenu/GridColumnMenu.js +32 -0
  63. package/modern/components/toolbar/GridToolbarExport.js +55 -3
  64. package/modern/components/virtualization/GridVirtualScrollbar.js +4 -0
  65. package/modern/components/virtualization/GridVirtualScroller.js +2 -2
  66. package/modern/constants/dataGridPropsDefaultValues.js +60 -0
  67. package/modern/hooks/features/clipboard/useGridClipboard.js +2 -1
  68. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
  69. package/modern/hooks/features/columns/gridColumnsUtils.js +3 -0
  70. package/modern/hooks/features/dimensions/useGridDimensions.js +4 -2
  71. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
  72. package/modern/hooks/features/listView/gridListViewSelectors.js +4 -0
  73. package/modern/hooks/features/listView/useGridListView.js +54 -0
  74. package/modern/hooks/features/rowSelection/useGridRowSelection.js +11 -2
  75. package/modern/hooks/features/rowSelection/utils.js +1 -1
  76. package/modern/hooks/features/rows/gridRowsMetaInterfaces.js +1 -0
  77. package/modern/hooks/features/rows/gridRowsUtils.js +14 -1
  78. package/modern/hooks/features/rows/useGridParamsApi.js +4 -3
  79. package/modern/hooks/features/rows/useGridRowsMeta.js +135 -154
  80. package/modern/hooks/features/scroll/useGridScroll.js +3 -2
  81. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +23 -9
  82. package/modern/hooks/utils/useGridApiMethod.js +2 -1
  83. package/modern/index.js +2 -1
  84. package/modern/internals/index.js +2 -1
  85. package/modern/utils/ResizeObserver.js +10 -0
  86. package/modern/utils/keyboardUtils.js +12 -4
  87. package/node/DataGrid/DataGrid.js +1 -0
  88. package/node/DataGrid/index.js +1 -12
  89. package/node/DataGrid/useDataGridComponent.js +4 -1
  90. package/node/DataGrid/useDataGridProps.js +6 -65
  91. package/node/components/GridPagination.js +1 -0
  92. package/node/components/GridRow.js +25 -36
  93. package/node/components/base/GridOverlays.js +8 -0
  94. package/node/components/containers/GridRootStyles.js +1 -0
  95. package/node/components/menu/columnMenu/GridColumnMenu.js +32 -0
  96. package/node/components/toolbar/GridToolbarExport.js +52 -0
  97. package/node/components/virtualization/GridVirtualScrollbar.js +4 -0
  98. package/node/components/virtualization/GridVirtualScroller.js +2 -2
  99. package/node/constants/dataGridPropsDefaultValues.js +66 -0
  100. package/node/hooks/features/clipboard/useGridClipboard.js +2 -1
  101. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
  102. package/node/hooks/features/columns/gridColumnsUtils.js +3 -0
  103. package/node/hooks/features/dimensions/useGridDimensions.js +3 -1
  104. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
  105. package/node/hooks/features/listView/gridListViewSelectors.js +11 -0
  106. package/node/hooks/features/listView/useGridListView.js +64 -0
  107. package/node/hooks/features/rowSelection/useGridRowSelection.js +11 -2
  108. package/node/hooks/features/rowSelection/utils.js +1 -1
  109. package/node/hooks/features/rows/gridRowsMetaInterfaces.js +5 -0
  110. package/node/hooks/features/rows/gridRowsUtils.js +16 -2
  111. package/node/hooks/features/rows/useGridParamsApi.js +4 -3
  112. package/node/hooks/features/rows/useGridRowsMeta.js +136 -154
  113. package/node/hooks/features/scroll/useGridScroll.js +3 -2
  114. package/node/hooks/features/virtualization/useGridVirtualScroller.js +23 -9
  115. package/node/hooks/utils/useGridApiMethod.js +3 -1
  116. package/node/index.js +13 -1
  117. package/node/internals/index.js +22 -0
  118. package/node/utils/ResizeObserver.js +16 -0
  119. package/node/utils/keyboardUtils.js +15 -5
  120. package/package.json +2 -2
  121. package/utils/ResizeObserver.d.ts +4 -0
  122. package/utils/ResizeObserver.js +10 -0
  123. package/utils/keyboardUtils.d.ts +1 -0
  124. package/utils/keyboardUtils.js +12 -4
@@ -25,6 +25,7 @@ import { getMinimalContentHeight } from "../rows/gridRowsUtils.js";
25
25
  import { gridRenderContextSelector, gridVirtualizationRowEnabledSelector, gridVirtualizationColumnEnabledSelector } from "./gridVirtualizationSelectors.js";
26
26
  import { EMPTY_RENDER_CONTEXT } from "./useGridVirtualization.js";
27
27
  import { gridRowSpanningHiddenCellsOriginMapSelector } from "../rows/gridRowSpanningSelectors.js";
28
+ import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
28
29
  import { jsx as _jsx } from "react/jsx-runtime";
29
30
  const MINIMUM_COLUMN_WIDTH = 50;
30
31
  var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
@@ -55,13 +56,20 @@ try {
55
56
  export const useGridVirtualScroller = () => {
56
57
  const apiRef = useGridPrivateApiContext();
57
58
  const rootProps = useGridRootProps();
58
- const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
59
+ const {
60
+ unstable_listView: listView
61
+ } = rootProps;
62
+ const visibleColumns = useGridSelector(apiRef, () => listView ? [gridListColumnSelector(apiRef.current.state)] : gridVisibleColumnDefinitionsSelector(apiRef));
59
63
  const enabledForRows = useGridSelector(apiRef, gridVirtualizationRowEnabledSelector) && !isJSDOM;
60
64
  const enabledForColumns = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector) && !isJSDOM;
61
65
  const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
62
66
  const outerSize = dimensions.viewportOuterSize;
63
67
  const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
64
- const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
68
+ const pinnedColumnDefinitions = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
69
+ const pinnedColumns = listView ? {
70
+ left: [],
71
+ right: []
72
+ } : pinnedColumnDefinitions;
65
73
  const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
66
74
  const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
67
75
  const isRtl = useRtl();
@@ -128,7 +136,7 @@ export const useGridVirtualScroller = () => {
128
136
  }
129
137
  previousContextScrollPosition.current = scrollPosition.current;
130
138
  }, [apiRef, dimensions.isReady]);
131
- const triggerUpdateRenderContext = () => {
139
+ const triggerUpdateRenderContext = useEventCallback(() => {
132
140
  const newScroll = {
133
141
  top: scrollerRef.current.scrollTop,
134
142
  left: scrollerRef.current.scrollLeft
@@ -176,7 +184,7 @@ export const useGridVirtualScroller = () => {
176
184
  });
177
185
  scrollTimeout.start(1000, triggerUpdateRenderContext);
178
186
  return nextRenderContext;
179
- };
187
+ });
180
188
  const forceUpdateRenderContext = () => {
181
189
  const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
182
190
  const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
@@ -362,11 +370,11 @@ export const useGridVirtualScroller = () => {
362
370
  });
363
371
  return rows;
364
372
  };
365
- const needsHorizontalScrollbar = outerSize.width && columnsTotalWidth >= outerSize.width;
373
+ const needsHorizontalScrollbar = outerSize.width && columnsTotalWidth > outerSize.width;
366
374
  const scrollerStyle = React.useMemo(() => ({
367
- overflowX: !needsHorizontalScrollbar ? 'hidden' : undefined,
375
+ overflowX: !needsHorizontalScrollbar || listView ? 'hidden' : undefined,
368
376
  overflowY: rootProps.autoHeight ? 'hidden' : undefined
369
- }), [needsHorizontalScrollbar, rootProps.autoHeight]);
377
+ }), [needsHorizontalScrollbar, rootProps.autoHeight, listView]);
370
378
  const contentSize = React.useMemo(() => {
371
379
  const size = {
372
380
  width: needsHorizontalScrollbar ? columnsTotalWidth : 'auto',
@@ -393,6 +401,11 @@ export const useGridVirtualScroller = () => {
393
401
  scrollerRef.current.scrollTop = 0;
394
402
  }
395
403
  }, [enabledForColumns, enabledForRows, gridRootRef, scrollerRef]);
404
+ useEnhancedEffect(() => {
405
+ if (listView) {
406
+ scrollerRef.current.scrollLeft = 0;
407
+ }
408
+ }, [listView, scrollerRef]);
396
409
  useRunOnce(outerSize.width !== 0, () => {
397
410
  const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
398
411
  const initialRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
@@ -447,7 +460,7 @@ export const useGridVirtualScroller = () => {
447
460
  function inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns) {
448
461
  const dimensions = gridDimensionsSelector(apiRef.current.state);
449
462
  const currentPage = getVisibleRows(apiRef, rootProps);
450
- const visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
463
+ const visibleColumns = rootProps.unstable_listView ? [gridListColumnSelector(apiRef.current.state)] : gridVisibleColumnDefinitionsSelector(apiRef);
451
464
  const hiddenCellsOriginMap = gridRowSpanningHiddenCellsOriginMapSelector(apiRef);
452
465
  const lastRowId = apiRef.current.state.rows.dataRowIds.at(-1);
453
466
  const lastColumn = visibleColumns.at(-1);
@@ -470,7 +483,8 @@ function inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns) {
470
483
  range: currentPage.range,
471
484
  pinnedColumns: gridVisiblePinnedColumnDefinitionsSelector(apiRef),
472
485
  visibleColumns,
473
- hiddenCellsOriginMap
486
+ hiddenCellsOriginMap,
487
+ listView: rootProps.unstable_listView ?? false
474
488
  };
475
489
  }
476
490
  function computeRenderContext(inputs, scrollPosition, scrollCache) {
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
2
3
  export function useGridApiMethod(privateApiRef, apiMethods, visibility) {
3
4
  const isFirstRender = React.useRef(true);
4
- React.useEffect(() => {
5
+ useEnhancedEffect(() => {
5
6
  isFirstRender.current = false;
6
7
  privateApiRef.current.register(visibility, apiMethods);
7
8
  }, [privateApiRef, visibility, apiMethods]);
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.20.0
2
+ * @mui/x-data-grid v7.21.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -11,6 +11,7 @@ export { useGridRootProps } from "./hooks/utils/useGridRootProps.js";
11
11
  export * from "./DataGrid/index.js";
12
12
  export * from "./components/index.js";
13
13
  export * from "./constants/index.js";
14
+ export * from "./constants/dataGridPropsDefaultValues.js";
14
15
  export * from "./hooks/index.js";
15
16
  export * from "./models/index.js";
16
17
  export * from "./context/index.js";
@@ -54,6 +54,7 @@ export { useGridVirtualScroller, EMPTY_DETAIL_PANELS } from "../hooks/features/v
54
54
  export * from "../hooks/features/virtualization/index.js";
55
55
  export { useGridColumnResize, columnResizeStateInitializer } from "../hooks/features/columnResize/useGridColumnResize.js";
56
56
  export { ROW_SELECTION_PROPAGATION_DEFAULT } from "../hooks/features/rowSelection/utils.js";
57
+ export { useGridListView, listViewStateInitializer } from "../hooks/features/listView/useGridListView.js";
57
58
  export { useTimeout } from "../hooks/utils/useTimeout.js";
58
59
  export { useGridVisibleRows, getVisibleRows } from "../hooks/utils/useGridVisibleRows.js";
59
60
  export { useGridInitializeState } from "../hooks/utils/useGridInitializeState.js";
@@ -63,7 +64,7 @@ export { createSelector, createSelectorV8, createSelectorMemoized, createSelecto
63
64
  export { useGridSelectorV8 } from "../hooks/utils/useGridSelector.js";
64
65
  export { gridRowGroupsToFetchSelector } from "../hooks/features/rows/gridRowsSelector.js";
65
66
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from "../utils/domUtils.js";
66
- export { isNavigationKey, isPasteShortcut } from "../utils/keyboardUtils.js";
67
+ export { isNavigationKey, isPasteShortcut, isCopyShortcut } from "../utils/keyboardUtils.js";
67
68
  export * from "../utils/utils.js";
68
69
  export { exportAs } from "../utils/exportAs.js";
69
70
  export * from "../utils/getPublicApiRef.js";
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /**
4
+ * HACK: Minimal shim to get jsdom to work.
5
+ */
6
+ export const ResizeObserver = typeof globalThis.ResizeObserver !== 'undefined' ? globalThis.ResizeObserver : class ResizeObserver {
7
+ observe() {}
8
+ unobserve() {}
9
+ disconnect() {}
10
+ };
@@ -22,8 +22,16 @@ export const isHideMenuKey = key => key === 'Tab' || key === 'Escape';
22
22
  // In theory, on macOS, ctrl + v doesn't trigger a paste, so the function should return false.
23
23
  // However, maybe it's overkill to fix, so let's be lazy.
24
24
  export function isPasteShortcut(event) {
25
- if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'v' && !event.shiftKey && !event.altKey) {
26
- return true;
27
- }
28
- return false;
25
+ return (event.ctrlKey || event.metaKey) &&
26
+ // We can't use event.code === 'KeyV' as event.code assumes a QWERTY keyboard layout,
27
+ // for example, it would be another letter on a Dvorak physical keyboard.
28
+ // We can't use event.key === 'v' as event.key is not stable with key modifiers and keyboard layouts,
29
+ // for example, it would be ה on a Hebrew keyboard layout.
30
+ // https://github.com/w3c/uievents/issues/377 could be a long-term solution
31
+ String.fromCharCode(event.keyCode) === 'V' && !event.shiftKey && !event.altKey;
32
+ }
33
+
34
+ // Checks if the keyboard event corresponds to the copy shortcut (CTRL+C or CMD+C) across different localization keyboards.
35
+ export function isCopyShortcut(event) {
36
+ return (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'C' && !event.shiftKey && !event.altKey;
29
37
  }
@@ -702,6 +702,7 @@ DataGridRaw.propTypes = {
702
702
  * Setting it to a lower value could be useful when using dynamic row height,
703
703
  * but might reduce performance when displaying a large number of rows.
704
704
  * @default 166
705
+ * @deprecated
705
706
  */
706
707
  rowPositionsDebounceMs: _propTypes.default.number,
707
708
  /**
@@ -3,19 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _exportNames = {
7
- DATA_GRID_PROPS_DEFAULT_VALUES: true
8
- };
9
- Object.defineProperty(exports, "DATA_GRID_PROPS_DEFAULT_VALUES", {
10
- enumerable: true,
11
- get: function () {
12
- return _useDataGridProps.DATA_GRID_PROPS_DEFAULT_VALUES;
13
- }
14
- });
15
6
  var _DataGrid = require("./DataGrid");
16
7
  Object.keys(_DataGrid).forEach(function (key) {
17
8
  if (key === "default" || key === "__esModule") return;
18
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
19
9
  if (key in exports && exports[key] === _DataGrid[key]) return;
20
10
  Object.defineProperty(exports, key, {
21
11
  enumerable: true,
@@ -23,5 +13,4 @@ Object.keys(_DataGrid).forEach(function (key) {
23
13
  return _DataGrid[key];
24
14
  }
25
15
  });
26
- });
27
- var _useDataGridProps = require("./useDataGridProps");
16
+ });
@@ -34,6 +34,7 @@ var _useGridColumnGrouping = require("../hooks/features/columnGrouping/useGridCo
34
34
  var _virtualization = require("../hooks/features/virtualization");
35
35
  var _useGridColumnResize = require("../hooks/features/columnResize/useGridColumnResize");
36
36
  var _useGridRowSpanning = require("../hooks/features/rows/useGridRowSpanning");
37
+ var _useGridListView = require("../hooks/features/listView/useGridListView");
37
38
  const useDataGridComponent = (inputApiRef, props) => {
38
39
  const apiRef = (0, _useGridInitialization.useGridInitialization)(inputApiRef, props);
39
40
 
@@ -63,12 +64,13 @@ const useDataGridComponent = (inputApiRef, props) => {
63
64
  (0, _useGridInitializeState.useGridInitializeState)(_useGridColumnMenu.columnMenuStateInitializer, apiRef, props);
64
65
  (0, _useGridInitializeState.useGridInitializeState)(_useGridColumnGrouping.columnGroupsStateInitializer, apiRef, props);
65
66
  (0, _useGridInitializeState.useGridInitializeState)(_virtualization.virtualizationStateInitializer, apiRef, props);
67
+ (0, _useGridInitializeState.useGridInitializeState)(_useGridListView.listViewStateInitializer, apiRef, props);
66
68
  (0, _useGridKeyboardNavigation.useGridKeyboardNavigation)(apiRef, props);
67
69
  (0, _useGridRowSelection.useGridRowSelection)(apiRef, props);
68
70
  (0, _useGridColumns.useGridColumns)(apiRef, props);
69
71
  (0, _useGridRows.useGridRows)(apiRef, props);
70
72
  (0, _useGridRowSpanning.useGridRowSpanning)(apiRef, props);
71
- (0, _useGridParamsApi.useGridParamsApi)(apiRef);
73
+ (0, _useGridParamsApi.useGridParamsApi)(apiRef, props);
72
74
  (0, _useGridColumnSpanning.useGridColumnSpanning)(apiRef);
73
75
  (0, _useGridColumnGrouping.useGridColumnGrouping)(apiRef, props);
74
76
  (0, _useGridEditing.useGridEditing)(apiRef, props);
@@ -89,6 +91,7 @@ const useDataGridComponent = (inputApiRef, props) => {
89
91
  (0, _useGridEvents.useGridEvents)(apiRef, props);
90
92
  (0, _useGridStatePersistence.useGridStatePersistence)(apiRef);
91
93
  (0, _virtualization.useGridVirtualization)(apiRef, props);
94
+ (0, _useGridListView.useGridListView)(apiRef, props);
92
95
  return apiRef;
93
96
  };
94
97
  exports.useDataGridComponent = useDataGridComponent;
@@ -5,14 +5,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.useDataGridProps = exports.DATA_GRID_PROPS_DEFAULT_VALUES = void 0;
8
+ exports.useDataGridProps = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _styles = require("@mui/material/styles");
12
12
  var _constants = require("../constants");
13
13
  var _defaultGridSlotsComponents = require("../constants/defaultGridSlotsComponents");
14
- var _models = require("../models");
15
14
  var _utils = require("../internals/utils");
15
+ var _dataGridPropsDefaultValues = require("../constants/dataGridPropsDefaultValues");
16
16
  const DATA_GRID_FORCED_PROPS = {
17
17
  disableMultipleColumnsFiltering: true,
18
18
  disableMultipleColumnsSorting: true,
@@ -22,67 +22,8 @@ const DATA_GRID_FORCED_PROPS = {
22
22
  checkboxSelectionVisibleOnly: false,
23
23
  disableColumnReorder: true,
24
24
  keepColumnPositionIfDraggedOutside: false,
25
- signature: 'DataGrid'
26
- };
27
-
28
- /**
29
- * The default values of `DataGridPropsWithDefaultValues` to inject in the props of DataGrid.
30
- */
31
- const DATA_GRID_PROPS_DEFAULT_VALUES = exports.DATA_GRID_PROPS_DEFAULT_VALUES = {
32
- autoHeight: false,
33
- autoPageSize: false,
34
- autosizeOnMount: false,
35
- checkboxSelection: false,
36
- checkboxSelectionVisibleOnly: false,
37
- clipboardCopyCellDelimiter: '\t',
38
- columnBufferPx: 150,
39
- columnHeaderHeight: 56,
40
- disableAutosize: false,
41
- disableColumnFilter: false,
42
- disableColumnMenu: false,
43
- disableColumnReorder: false,
44
- disableColumnResize: false,
45
- disableColumnSelector: false,
46
- disableColumnSorting: false,
47
- disableDensitySelector: false,
48
- disableEval: false,
49
- disableMultipleColumnsFiltering: false,
50
- disableMultipleColumnsSorting: false,
51
- disableMultipleRowSelection: false,
52
- disableRowSelectionOnClick: false,
53
- disableVirtualization: false,
54
- editMode: _models.GridEditModes.Cell,
55
- filterDebounceMs: 150,
56
- filterMode: 'client',
57
- hideFooter: false,
58
- hideFooterPagination: false,
59
- hideFooterRowCount: false,
60
- hideFooterSelectedRowCount: false,
61
- ignoreDiacritics: false,
62
- ignoreValueFormatterDuringExport: false,
63
- // TODO v8: Update to 'select'
64
- indeterminateCheckboxAction: 'deselect',
65
- keepColumnPositionIfDraggedOutside: false,
66
- keepNonExistentRowsSelected: false,
67
- loading: false,
68
- logger: console,
69
- logLevel: process.env.NODE_ENV === 'production' ? 'error' : 'warn',
70
- pageSizeOptions: [25, 50, 100],
71
- pagination: false,
72
- paginationMode: 'client',
73
- resizeThrottleMs: 60,
74
- rowBufferPx: 150,
75
- rowHeight: 52,
76
- rowPositionsDebounceMs: 166,
77
- rows: [],
78
- rowSelection: true,
79
- rowSpacingType: 'margin',
80
- showCellVerticalBorder: false,
81
- showColumnVerticalBorder: false,
82
- sortingMode: 'client',
83
- sortingOrder: ['asc', 'desc', null],
84
- throttleRowsMs: 0,
85
- unstable_rowSpanning: false
25
+ signature: 'DataGrid',
26
+ unstable_listView: false
86
27
  };
87
28
  const defaultSlots = _defaultGridSlotsComponents.DATA_GRID_DEFAULT_SLOTS_COMPONENTS;
88
29
  const useDataGridProps = inProps => {
@@ -98,9 +39,9 @@ const useDataGridProps = inProps => {
98
39
  slots: themedProps.slots
99
40
  }), [themedProps.slots]);
100
41
  const injectDefaultProps = React.useMemo(() => {
101
- return Object.keys(DATA_GRID_PROPS_DEFAULT_VALUES).reduce((acc, key) => {
42
+ return Object.keys(_dataGridPropsDefaultValues.DATA_GRID_PROPS_DEFAULT_VALUES).reduce((acc, key) => {
102
43
  // @ts-ignore
103
- acc[key] = themedProps[key] ?? DATA_GRID_PROPS_DEFAULT_VALUES[key];
44
+ acc[key] = themedProps[key] ?? _dataGridPropsDefaultValues.DATA_GRID_PROPS_DEFAULT_VALUES[key];
104
45
  return acc;
105
46
  }, {});
106
47
  }, [themedProps]);
@@ -21,6 +21,7 @@ const GridPaginationRoot = (0, _styles.styled)(_TablePagination.default)(({
21
21
  }) => ({
22
22
  maxHeight: 'calc(100% + 1px)',
23
23
  // border width
24
+ flexGrow: 1,
24
25
  [`& .${_TablePagination.tablePaginationClasses.selectLabel}`]: {
25
26
  display: 'none',
26
27
  [theme.breakpoints.up('sm')]: {
@@ -14,7 +14,6 @@ var _clsx = _interopRequireDefault(require("clsx"));
14
14
  var _utils = require("@mui/utils");
15
15
  var _fastMemo = require("@mui/x-internals/fastMemo");
16
16
  var _gridEditRowModel = require("../models/gridEditRowModel");
17
- var _useGridApiContext = require("../hooks/utils/useGridApiContext");
18
17
  var _gridClasses = require("../constants/gridClasses");
19
18
  var _composeGridClasses = require("../utils/composeGridClasses");
20
19
  var _useGridRootProps = require("../hooks/utils/useGridRootProps");
@@ -32,6 +31,7 @@ var _GridCell = require("./cell/GridCell");
32
31
  var _GridScrollbarFillerCell = require("./GridScrollbarFillerCell");
33
32
  var _getPinnedCellOffset = require("../internals/utils/getPinnedCellOffset");
34
33
  var _useGridConfiguration = require("../hooks/utils/useGridConfiguration");
34
+ var _useGridPrivateApiContext = require("../hooks/utils/useGridPrivateApiContext");
35
35
  var _jsxRuntime = require("react/jsx-runtime");
36
36
  const _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "pinnedColumns", "offsetTop", "offsetLeft", "dimensions", "renderContext", "focusedColumnIndex", "isFirstVisible", "isLastVisible", "isNotVisible", "showBottomBorder", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver"];
37
37
  function EmptyCell({
@@ -48,6 +48,13 @@ function EmptyCell({
48
48
  }
49
49
  });
50
50
  }
51
+ process.env.NODE_ENV !== "production" ? EmptyCell.propTypes = {
52
+ // ----------------------------- Warning --------------------------------
53
+ // | These PropTypes are generated from the TypeScript type definitions |
54
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
55
+ // ----------------------------------------------------------------------
56
+ width: _propTypes.default.number.isRequired
57
+ } : void 0;
51
58
  const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
52
59
  const {
53
60
  selected,
@@ -75,7 +82,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
75
82
  onMouseOver
76
83
  } = props,
77
84
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
78
- const apiRef = (0, _useGridApiContext.useGridApiContext)();
85
+ const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
79
86
  const configuration = (0, _useGridConfiguration.useGridConfiguration)();
80
87
  const ref = React.useRef(null);
81
88
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
@@ -99,30 +106,17 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
99
106
  const getRowAriaAttributes = configuration.hooks.useGridRowAriaAttributes();
100
107
  React.useLayoutEffect(() => {
101
108
  if (currentPage.range) {
102
- // The index prop is relative to the rows from all pages. As example, the index prop of the
103
- // first row is 5 if `paginationModel.pageSize=5` and `paginationModel.page=1`. However, the index used by the virtualization
104
- // doesn't care about pagination and considers the rows from the current page only, so the
105
- // first row always has index=0. We need to subtract the index of the first row to make it
106
- // compatible with the index used by the virtualization.
107
109
  const rowIndex = apiRef.current.getRowIndexRelativeToVisibleRows(rowId);
108
- // pinned rows are not part of the visible rows
109
- if (rowIndex != null) {
110
+ // Pinned rows are not part of the visible rows
111
+ if (rowIndex !== undefined) {
110
112
  apiRef.current.unstable_setLastMeasuredRowIndex(rowIndex);
111
113
  }
112
114
  }
113
- const rootElement = ref.current;
114
- const hasFixedHeight = rowHeight !== 'auto';
115
- if (!rootElement || hasFixedHeight || typeof ResizeObserver === 'undefined') {
116
- return undefined;
115
+ if (ref.current && rowHeight === 'auto') {
116
+ return apiRef.current.observeRowHeight(ref.current, rowId);
117
117
  }
118
- const resizeObserver = new ResizeObserver(entries => {
119
- const [entry] = entries;
120
- const height = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
121
- apiRef.current.unstable_storeRowHeightMeasurement(rowId, height);
122
- });
123
- resizeObserver.observe(rootElement);
124
- return () => resizeObserver.disconnect();
125
- }, [apiRef, currentPage.range, index, rowHeight, rowId]);
118
+ return undefined;
119
+ }, [apiRef, currentPage.range, rowHeight, rowId]);
126
120
  const publish = React.useCallback((eventName, propHandler) => event => {
127
121
  // Ignore portal
128
122
  if ((0, _domUtils.isEventTargetInPortal)(event)) {
@@ -179,15 +173,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
179
173
  disableColumnReorder
180
174
  } = rootProps;
181
175
  const rowReordering = rootProps.rowReordering;
182
- const sizes = (0, _useGridSelector.useGridSelector)(apiRef, () => (0, _extends2.default)({}, apiRef.current.unstable_getRowInternalSizes(rowId)), _useGridSelector.objectShallowCompare);
183
- let minHeight = rowHeight;
184
- if (minHeight === 'auto' && sizes) {
185
- const numberOfBaseSizes = 1;
186
- const maximumSize = sizes.baseCenter ?? 0;
187
- if (maximumSize > 0 && numberOfBaseSizes > 1) {
188
- minHeight = maximumSize;
189
- }
190
- }
176
+ const heightEntry = (0, _useGridSelector.useGridSelector)(apiRef, () => (0, _extends2.default)({}, apiRef.current.getRowHeightEntry(rowId)), _useGridSelector.objectShallowCompare);
191
177
  const style = React.useMemo(() => {
192
178
  if (isNotVisible) {
193
179
  return {
@@ -199,25 +185,25 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
199
185
  const rowStyle = (0, _extends2.default)({}, styleProp, {
200
186
  maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
201
187
  // max-height doesn't support "auto"
202
- minHeight,
188
+ minHeight: rowHeight,
203
189
  '--height': typeof rowHeight === 'number' ? `${rowHeight}px` : rowHeight
204
190
  });
205
- if (sizes?.spacingTop) {
191
+ if (heightEntry.spacingTop) {
206
192
  const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
207
- rowStyle[property] = sizes.spacingTop;
193
+ rowStyle[property] = heightEntry.spacingTop;
208
194
  }
209
- if (sizes?.spacingBottom) {
195
+ if (heightEntry.spacingBottom) {
210
196
  const property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
211
197
  let propertyValue = rowStyle[property];
212
198
  // avoid overriding existing value
213
199
  if (typeof propertyValue !== 'number') {
214
200
  propertyValue = parseInt(propertyValue || '0', 10);
215
201
  }
216
- propertyValue += sizes.spacingBottom;
202
+ propertyValue += heightEntry.spacingBottom;
217
203
  rowStyle[property] = propertyValue;
218
204
  }
219
205
  return rowStyle;
220
- }, [isNotVisible, rowHeight, styleProp, minHeight, sizes, rootProps.rowSpacingType]);
206
+ }, [isNotVisible, rowHeight, styleProp, heightEntry, rootProps.rowSpacingType]);
221
207
  const rowClassNames = apiRef.current.unstable_applyPipeProcessors('rowClassName', [], rowId);
222
208
  const ariaAttributes = rowNode ? getRowAriaAttributes(rowNode, index) : undefined;
223
209
  if (typeof rootProps.getRowClassName === 'function') {
@@ -295,6 +281,9 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
295
281
  for (let i = renderContext.firstColumnIndex; i < renderContext.lastColumnIndex; i += 1) {
296
282
  const column = visibleColumns[i];
297
283
  const indexInSection = i - pinnedColumns.left.length;
284
+ if (!column) {
285
+ continue;
286
+ }
298
287
  cells.push(getCell(column, indexInSection, i, middleColumnsLength));
299
288
  }
300
289
  if (hasVirtualFocusCellRight) {
@@ -82,6 +82,14 @@ function GridOverlayWrapper(props) {
82
82
  }, props))
83
83
  }));
84
84
  }
85
+ process.env.NODE_ENV !== "production" ? GridOverlayWrapper.propTypes = {
86
+ // ----------------------------- Warning --------------------------------
87
+ // | These PropTypes are generated from the TypeScript type definitions |
88
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
89
+ // ----------------------------------------------------------------------
90
+ loadingOverlayVariant: _propTypes.default.oneOf(['circular-progress', 'linear-progress', 'skeleton']),
91
+ overlayType: _propTypes.default.oneOf(['loadingOverlay', 'noResultsOverlay', 'noRowsOverlay'])
92
+ } : void 0;
85
93
  process.env.NODE_ENV !== "production" ? GridOverlays.propTypes = {
86
94
  // ----------------------------- Warning --------------------------------
87
95
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -520,6 +520,7 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
520
520
  },
521
521
  /* Cell styles */
522
522
  [`& .${_gridClasses.gridClasses.cell}`]: {
523
+ flex: '0 0 auto',
523
524
  height: 'var(--height)',
524
525
  width: 'var(--width)',
525
526
  lineHeight: 'calc(var(--height) - 1px)',
@@ -53,6 +53,38 @@ const GridGenericColumnMenu = exports.GridGenericColumnMenu = /*#__PURE__*/React
53
53
  children: orderedSlots.map(([Component, otherProps], index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, (0, _extends2.default)({}, otherProps), index))
54
54
  }));
55
55
  });
56
+ process.env.NODE_ENV !== "production" ? GridGenericColumnMenu.propTypes = {
57
+ // ----------------------------- Warning --------------------------------
58
+ // | These PropTypes are generated from the TypeScript type definitions |
59
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
60
+ // ----------------------------------------------------------------------
61
+ colDef: _propTypes.default.object.isRequired,
62
+ /**
63
+ * Initial `slotProps` - it is internal, to be overrriden by Pro or Premium packages
64
+ * @ignore - do not document.
65
+ */
66
+ defaultSlotProps: _propTypes.default.object.isRequired,
67
+ /**
68
+ * Initial `slots` - it is internal, to be overrriden by Pro or Premium packages
69
+ * @ignore - do not document.
70
+ */
71
+ defaultSlots: _propTypes.default.object.isRequired,
72
+ hideMenu: _propTypes.default.func.isRequired,
73
+ id: _propTypes.default.string,
74
+ labelledby: _propTypes.default.string,
75
+ open: _propTypes.default.bool.isRequired,
76
+ /**
77
+ * Could be used to pass new props or override props specific to a column menu component
78
+ * e.g. `displayOrder`
79
+ */
80
+ slotProps: _propTypes.default.object,
81
+ /**
82
+ * `slots` could be used to add new and (or) override default column menu items
83
+ * If you register a nee component you must pass it's `displayOrder` in `slotProps`
84
+ * or it will be placed in the end of the list
85
+ */
86
+ slots: _propTypes.default.object
87
+ } : void 0;
56
88
  const GridColumnMenu = exports.GridColumnMenu = /*#__PURE__*/React.forwardRef(function GridColumnMenu(props, ref) {
57
89
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridGenericColumnMenu, (0, _extends2.default)({}, props, {
58
90
  ref: ref,
@@ -35,6 +35,26 @@ function GridCsvExportMenuItem(props) {
35
35
  children: apiRef.current.getLocaleText('toolbarExportCSV')
36
36
  }));
37
37
  }
38
+ process.env.NODE_ENV !== "production" ? GridCsvExportMenuItem.propTypes = {
39
+ // ----------------------------- Warning --------------------------------
40
+ // | These PropTypes are generated from the TypeScript type definitions |
41
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
42
+ // ----------------------------------------------------------------------
43
+ hideMenu: _propTypes.default.func,
44
+ options: _propTypes.default.shape({
45
+ allColumns: _propTypes.default.bool,
46
+ delimiter: _propTypes.default.string,
47
+ disableToolbarButton: _propTypes.default.bool,
48
+ escapeFormulas: _propTypes.default.bool,
49
+ fields: _propTypes.default.arrayOf(_propTypes.default.string),
50
+ fileName: _propTypes.default.string,
51
+ getRowsToExport: _propTypes.default.func,
52
+ includeColumnGroupsHeaders: _propTypes.default.bool,
53
+ includeHeaders: _propTypes.default.bool,
54
+ shouldAppendQuotes: _propTypes.default.bool,
55
+ utf8WithBom: _propTypes.default.bool
56
+ })
57
+ } : void 0;
38
58
  function GridPrintExportMenuItem(props) {
39
59
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
40
60
  const {
@@ -51,6 +71,38 @@ function GridPrintExportMenuItem(props) {
51
71
  children: apiRef.current.getLocaleText('toolbarExportPrint')
52
72
  }));
53
73
  }
74
+ process.env.NODE_ENV !== "production" ? GridPrintExportMenuItem.propTypes = {
75
+ // ----------------------------- Warning --------------------------------
76
+ // | These PropTypes are generated from the TypeScript type definitions |
77
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
78
+ // ----------------------------------------------------------------------
79
+ hideMenu: _propTypes.default.func,
80
+ options: _propTypes.default.shape({
81
+ allColumns: _propTypes.default.bool,
82
+ bodyClassName: _propTypes.default.string,
83
+ copyStyles: _propTypes.default.bool,
84
+ disableToolbarButton: _propTypes.default.bool,
85
+ fields: _propTypes.default.arrayOf(_propTypes.default.string),
86
+ fileName: _propTypes.default.string,
87
+ getRowsToExport: _propTypes.default.func,
88
+ hideFooter: _propTypes.default.bool,
89
+ hideToolbar: _propTypes.default.bool,
90
+ includeCheckboxes: _propTypes.default.bool,
91
+ pageStyle: _propTypes.default.oneOfType([_propTypes.default.shape({
92
+ '__@hasInstance@646': _propTypes.default.func.isRequired,
93
+ '__@metadata@648': _propTypes.default.any,
94
+ apply: _propTypes.default.func.isRequired,
95
+ arguments: _propTypes.default.any.isRequired,
96
+ bind: _propTypes.default.func.isRequired,
97
+ call: _propTypes.default.func.isRequired,
98
+ caller: _propTypes.default.object.isRequired,
99
+ length: _propTypes.default.number.isRequired,
100
+ name: _propTypes.default.string.isRequired,
101
+ prototype: _propTypes.default.any.isRequired,
102
+ toString: _propTypes.default.func.isRequired
103
+ }), _propTypes.default.string])
104
+ })
105
+ } : void 0;
54
106
  const GridToolbarExport = exports.GridToolbarExport = /*#__PURE__*/React.forwardRef(function GridToolbarExport(props, ref) {
55
107
  const {
56
108
  csvOptions = {},
@@ -126,6 +126,10 @@ const GridVirtualScrollbar = exports.GridVirtualScrollbar = /*#__PURE__*/React.f
126
126
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Container, {
127
127
  ref: (0, _utils.unstable_useForkRef)(ref, scrollbarRef),
128
128
  className: classes.root,
129
+ style: props.position === 'vertical' && rootProps.unstable_listView ? {
130
+ height: '100%',
131
+ top: 0
132
+ } : undefined,
129
133
  tabIndex: -1,
130
134
  "aria-hidden": "true",
131
135
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
@@ -86,7 +86,7 @@ function GridVirtualScroller(props) {
86
86
  }, getScrollerProps(), {
87
87
  ownerState: rootProps,
88
88
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridTopContainer.GridTopContainer, {
89
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GridHeaders.GridHeaders, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.pinnedRows, {
89
+ children: [!rootProps.unstable_listView && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridHeaders.GridHeaders, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.pinnedRows, {
90
90
  position: "top",
91
91
  virtualScroller: virtualScroller
92
92
  })]
@@ -106,7 +106,7 @@ function GridVirtualScroller(props) {
106
106
  })]
107
107
  })), dimensions.hasScrollY && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridVirtualScrollbar.GridVirtualScrollbar, (0, _extends2.default)({
108
108
  position: "vertical"
109
- }, getScrollbarVerticalProps())), dimensions.hasScrollX && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridVirtualScrollbar.GridVirtualScrollbar, (0, _extends2.default)({
109
+ }, getScrollbarVerticalProps())), dimensions.hasScrollX && !rootProps.unstable_listView && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridVirtualScrollbar.GridVirtualScrollbar, (0, _extends2.default)({
110
110
  position: "horizontal"
111
111
  }, getScrollbarHorizontalProps())), props.children]
112
112
  }));