@mui/x-data-grid 7.0.0-beta.1 → 7.0.0-beta.3

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 (125) hide show
  1. package/CHANGELOG.md +223 -1
  2. package/DataGrid/DataGrid.d.ts +1 -1
  3. package/DataGrid/DataGrid.js +1 -7
  4. package/DataGrid/useDataGridProps.js +3 -1
  5. package/components/GridPagination.d.ts +1 -1
  6. package/components/GridPagination.js +12 -2
  7. package/components/GridRow.d.ts +3 -1
  8. package/components/GridRow.js +16 -6
  9. package/components/GridScrollbarFillerCell.js +0 -3
  10. package/components/base/GridFooterPlaceholder.js +1 -1
  11. package/components/cell/GridActionsCell.js +3 -3
  12. package/components/cell/GridActionsCellItem.d.ts +13 -1
  13. package/components/cell/GridActionsCellItem.js +27 -15
  14. package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  15. package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
  16. package/components/columnsManagement/utils.d.ts +1 -1
  17. package/components/containers/GridRootStyles.js +9 -4
  18. package/components/panel/GridPanel.d.ts +1 -1
  19. package/components/panel/filterPanel/GridFilterInputBoolean.js +7 -5
  20. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +7 -5
  21. package/components/panel/filterPanel/GridFilterInputValue.js +4 -3
  22. package/components/panel/filterPanel/GridFilterPanel.js +1 -1
  23. package/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
  24. package/constants/gridClasses.d.ts +5 -0
  25. package/constants/gridClasses.js +1 -1
  26. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +5 -5
  27. package/hooks/features/columnHeaders/useGridColumnHeaders.js +46 -48
  28. package/hooks/features/rows/gridRowsUtils.js +1 -1
  29. package/hooks/features/rows/useGridRows.js +2 -2
  30. package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +9 -0
  31. package/hooks/features/virtualization/gridVirtualizationSelectors.js +7 -0
  32. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -1
  33. package/hooks/features/virtualization/useGridVirtualScroller.js +28 -26
  34. package/hooks/features/virtualization/useGridVirtualization.d.ts +8 -0
  35. package/hooks/features/virtualization/useGridVirtualization.js +6 -1
  36. package/index.js +1 -1
  37. package/internals/utils/propValidation.js +1 -1
  38. package/joy/joySlots.js +2 -2
  39. package/legacy/DataGrid/DataGrid.js +1 -7
  40. package/legacy/DataGrid/useDataGridProps.js +3 -1
  41. package/legacy/components/GridPagination.js +10 -2
  42. package/legacy/components/GridRow.js +16 -6
  43. package/legacy/components/GridScrollbarFillerCell.js +1 -3
  44. package/legacy/components/base/GridFooterPlaceholder.js +1 -1
  45. package/legacy/components/cell/GridActionsCell.js +3 -3
  46. package/legacy/components/cell/GridActionsCellItem.js +30 -17
  47. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  48. package/legacy/components/containers/GridRootStyles.js +8 -5
  49. package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +7 -4
  50. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +8 -5
  51. package/legacy/components/panel/filterPanel/GridFilterInputValue.js +4 -2
  52. package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -1
  53. package/legacy/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
  54. package/legacy/constants/gridClasses.js +1 -1
  55. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +60 -63
  56. package/legacy/hooks/features/rows/gridRowsUtils.js +1 -1
  57. package/legacy/hooks/features/rows/useGridRows.js +2 -2
  58. package/legacy/hooks/features/virtualization/gridVirtualizationSelectors.js +9 -0
  59. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +28 -26
  60. package/legacy/hooks/features/virtualization/useGridVirtualization.js +6 -1
  61. package/legacy/index.js +1 -1
  62. package/legacy/internals/utils/propValidation.js +1 -1
  63. package/legacy/joy/joySlots.js +2 -2
  64. package/legacy/locales/daDK.js +12 -12
  65. package/locales/daDK.js +12 -12
  66. package/models/api/gridApiCommon.d.ts +1 -1
  67. package/models/api/gridFilterApi.d.ts +1 -1
  68. package/models/api/gridLocaleTextApi.d.ts +3 -3
  69. package/models/events/gridEventLookup.d.ts +2 -9
  70. package/models/gridSlotsComponent.d.ts +34 -36
  71. package/models/gridSlotsComponentsProps.d.ts +73 -54
  72. package/models/props/DataGridProps.d.ts +2 -8
  73. package/modern/DataGrid/DataGrid.js +1 -7
  74. package/modern/DataGrid/useDataGridProps.js +3 -1
  75. package/modern/components/GridPagination.js +12 -2
  76. package/modern/components/GridRow.js +15 -6
  77. package/modern/components/GridScrollbarFillerCell.js +0 -3
  78. package/modern/components/base/GridFooterPlaceholder.js +1 -1
  79. package/modern/components/cell/GridActionsCell.js +3 -3
  80. package/modern/components/cell/GridActionsCellItem.js +27 -15
  81. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  82. package/modern/components/containers/GridRootStyles.js +9 -4
  83. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +7 -5
  84. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +7 -5
  85. package/modern/components/panel/filterPanel/GridFilterInputValue.js +4 -3
  86. package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
  87. package/modern/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
  88. package/modern/constants/gridClasses.js +1 -1
  89. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +46 -48
  90. package/modern/hooks/features/rows/gridRowsUtils.js +1 -1
  91. package/modern/hooks/features/rows/useGridRows.js +2 -2
  92. package/modern/hooks/features/virtualization/gridVirtualizationSelectors.js +7 -0
  93. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +27 -24
  94. package/modern/hooks/features/virtualization/useGridVirtualization.js +6 -1
  95. package/modern/index.js +1 -1
  96. package/modern/internals/utils/propValidation.js +1 -1
  97. package/modern/joy/joySlots.js +2 -2
  98. package/modern/locales/daDK.js +12 -12
  99. package/node/DataGrid/DataGrid.js +1 -7
  100. package/node/DataGrid/useDataGridProps.js +3 -1
  101. package/node/components/GridPagination.js +12 -2
  102. package/node/components/GridRow.js +15 -6
  103. package/node/components/GridScrollbarFillerCell.js +0 -3
  104. package/node/components/base/GridFooterPlaceholder.js +1 -1
  105. package/node/components/cell/GridActionsCell.js +3 -3
  106. package/node/components/cell/GridActionsCellItem.js +27 -15
  107. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  108. package/node/components/containers/GridRootStyles.js +9 -4
  109. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +7 -5
  110. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +7 -5
  111. package/node/components/panel/filterPanel/GridFilterInputValue.js +4 -3
  112. package/node/components/panel/filterPanel/GridFilterPanel.js +1 -1
  113. package/node/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
  114. package/node/constants/gridClasses.js +1 -1
  115. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +45 -47
  116. package/node/hooks/features/rows/gridRowsUtils.js +2 -2
  117. package/node/hooks/features/rows/useGridRows.js +2 -2
  118. package/node/hooks/features/virtualization/gridVirtualizationSelectors.js +8 -1
  119. package/node/hooks/features/virtualization/useGridVirtualScroller.js +26 -23
  120. package/node/hooks/features/virtualization/useGridVirtualization.js +7 -2
  121. package/node/index.js +1 -1
  122. package/node/internals/utils/propValidation.js +1 -1
  123. package/node/joy/joySlots.js +2 -2
  124. package/node/locales/daDK.js +12 -12
  125. package/package.json +4 -4
@@ -20,7 +20,7 @@ import { selectedIdsLookupSelector } from '../rowSelection/gridRowSelectionSelec
20
20
  import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
21
21
  import { getFirstNonSpannedColumnToRender } from '../columns/gridColumnsUtils';
22
22
  import { getMinimalContentHeight } from '../rows/gridRowsUtils';
23
- import { gridRenderContextSelector, gridVirtualizationEnabledSelector, gridVirtualizationColumnEnabledSelector } from './gridVirtualizationSelectors';
23
+ import { gridOffsetsSelector, gridRenderContextSelector, gridVirtualizationEnabledSelector, gridVirtualizationColumnEnabledSelector } from './gridVirtualizationSelectors';
24
24
  import { EMPTY_RENDER_CONTEXT } from './useGridVirtualization';
25
25
  import { jsx as _jsx } from "react/jsx-runtime";
26
26
  export const EMPTY_DETAIL_PANELS = Object.freeze(new Map());
@@ -37,7 +37,6 @@ export const useGridVirtualScroller = () => {
37
37
  const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
38
38
  const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
39
39
  const theme = useTheme();
40
- const columnPositions = useGridSelector(apiRef, gridColumnPositionsSelector);
41
40
  const cellFocus = useGridSelector(apiRef, gridFocusCellSelector);
42
41
  const cellTabIndex = useGridSelector(apiRef, gridTabIndexCellSelector);
43
42
  const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
@@ -46,7 +45,6 @@ export const useGridVirtualScroller = () => {
46
45
  const gridRootRef = apiRef.current.rootElementRef;
47
46
  const mainRef = apiRef.current.mainElementRef;
48
47
  const scrollerRef = apiRef.current.virtualScrollerRef;
49
- const renderZoneRef = React.useRef(null);
50
48
  const scrollbarVerticalRef = React.useRef(null);
51
49
  const scrollbarHorizontalRef = React.useRef(null);
52
50
  const contentHeight = dimensions.contentSize.height;
@@ -54,6 +52,7 @@ export const useGridVirtualScroller = () => {
54
52
  useResizeObserver(mainRef, () => apiRef.current.resize());
55
53
  const previousContext = React.useRef(EMPTY_RENDER_CONTEXT);
56
54
  const previousRowContext = React.useRef(EMPTY_RENDER_CONTEXT);
55
+ const offsets = useGridSelector(apiRef, gridOffsetsSelector);
57
56
  const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
58
57
  const scrollPosition = React.useRef({
59
58
  top: 0,
@@ -73,23 +72,17 @@ export const useGridVirtualScroller = () => {
73
72
  }
74
73
  return -1;
75
74
  }, [cellFocus, visibleColumns]);
76
- React.useEffect(() => {
77
- var _gridRootRef$current, _gridRootRef$current2;
78
- const direction = theme.direction === 'ltr' ? 1 : -1;
79
- const top = gridRowsMetaSelector(apiRef.current.state).positions[renderContext.firstRowIndex];
80
- const left = direction * columnPositions[renderContext.firstColumnIndex] - columnPositions[pinnedColumns.left.length];
81
- (_gridRootRef$current = gridRootRef.current) == null || _gridRootRef$current.style.setProperty('--DataGrid-offsetTop', `${top}px`);
82
- (_gridRootRef$current2 = gridRootRef.current) == null || _gridRootRef$current2.style.setProperty('--DataGrid-offsetLeft', `${left}px`);
83
- }, [apiRef, gridRootRef, theme.direction, columnPositions, pinnedColumns.left.length, renderContext]);
84
75
  const updateRenderContext = React.useCallback((nextRenderContext, rawRenderContext) => {
85
76
  if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
86
77
  return;
87
78
  }
88
79
  const didRowsIntervalChange = nextRenderContext.firstRowIndex !== previousRowContext.current.firstRowIndex || nextRenderContext.lastRowIndex !== previousRowContext.current.lastRowIndex;
80
+ const nextOffsets = computeOffsets(apiRef, nextRenderContext, theme.direction, pinnedColumns.left.length);
89
81
  apiRef.current.setState(state => {
90
82
  return _extends({}, state, {
91
83
  virtualization: _extends({}, state.virtualization, {
92
- renderContext: nextRenderContext
84
+ renderContext: nextRenderContext,
85
+ offsets: nextOffsets
93
86
  })
94
87
  });
95
88
  });
@@ -103,7 +96,7 @@ export const useGridVirtualScroller = () => {
103
96
  }
104
97
  previousContext.current = rawRenderContext;
105
98
  prevTotalWidth.current = dimensions.columnsTotalWidth;
106
- }, [apiRef, dimensions.isReady, dimensions.columnsTotalWidth]);
99
+ }, [apiRef, pinnedColumns.left.length, theme.direction, dimensions.isReady, dimensions.columnsTotalWidth]);
107
100
  const triggerUpdateRenderContext = () => {
108
101
  const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
109
102
  const [nextRenderContext, rawRenderContext] = computeRenderContext(inputs, scrollPosition);
@@ -247,6 +240,14 @@ export const useGridVirtualScroller = () => {
247
240
  id,
248
241
  model
249
242
  } = renderedRows[i];
243
+ const rowIndexInPage = ((currentPage == null || (_currentPage$range = currentPage.range) == null ? void 0 : _currentPage$range.firstRowIndex) || 0) + firstRowToRender + i;
244
+ let index = rowIndexOffset + rowIndexInPage;
245
+ if (isRowWithFocusedCellNotInRange && (cellFocus == null ? void 0 : cellFocus.id) === id) {
246
+ index = indexOfRowWithFocusedCell;
247
+ isRowWithFocusedCellRendered = true;
248
+ } else if (isRowWithFocusedCellRendered) {
249
+ index -= 1;
250
+ }
250
251
  const isRowNotVisible = isRowWithFocusedCellNotInRange && cellFocus.id === id;
251
252
  const baseRowHeight = !apiRef.current.rowHasAutoHeight(id) ? apiRef.current.unstable_getRowHeight(id) : 'auto';
252
253
  let isSelected;
@@ -257,7 +258,7 @@ export const useGridVirtualScroller = () => {
257
258
  }
258
259
  let isFirstVisible = false;
259
260
  if (params.position === undefined) {
260
- isFirstVisible = i === 0;
261
+ isFirstVisible = rowIndexInPage === 0;
261
262
  }
262
263
  let isLastVisible = false;
263
264
  if (isLastSection) {
@@ -279,13 +280,6 @@ export const useGridVirtualScroller = () => {
279
280
  const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
280
281
  tabbableCell = cellParams.cellMode === 'view' ? cellTabIndex.field : null;
281
282
  }
282
- let index = rowIndexOffset + ((currentPage == null || (_currentPage$range = currentPage.range) == null ? void 0 : _currentPage$range.firstRowIndex) || 0) + firstRowToRender + i;
283
- if (isRowWithFocusedCellNotInRange && (cellFocus == null ? void 0 : cellFocus.id) === id) {
284
- index = indexOfRowWithFocusedCell;
285
- isRowWithFocusedCellRendered = true;
286
- } else if (isRowWithFocusedCellRendered) {
287
- index -= 1;
288
- }
289
283
  rows.push( /*#__PURE__*/_jsx(rootProps.slots.row, _extends({
290
284
  row: model,
291
285
  rowId: id,
@@ -300,6 +294,7 @@ export const useGridVirtualScroller = () => {
300
294
  firstColumnToRender: firstColumnToRender,
301
295
  lastColumnToRender: lastColumnToRender,
302
296
  selected: isSelected,
297
+ offsets: offsets,
303
298
  dimensions: dimensions,
304
299
  isFirstVisible: isFirstVisible,
305
300
  isLastVisible: isLastVisible,
@@ -347,10 +342,6 @@ export const useGridVirtualScroller = () => {
347
342
  // TODO a scroll reset should not be necessary
348
343
  scrollerRef.current.scrollLeft = 0;
349
344
  scrollerRef.current.scrollTop = 0;
350
- } else {
351
- var _gridRootRef$current3, _gridRootRef$current4;
352
- (_gridRootRef$current3 = gridRootRef.current) == null || _gridRootRef$current3.style.setProperty('--DataGrid-offsetTop', '0px');
353
- (_gridRootRef$current4 = gridRootRef.current) == null || _gridRootRef$current4.style.setProperty('--DataGrid-offsetLeft', '0px');
354
345
  }
355
346
  }, [enabled, gridRootRef, scrollerRef]);
356
347
  useRunOnce(outerSize.width !== 0, () => {
@@ -387,7 +378,6 @@ export const useGridVirtualScroller = () => {
387
378
  role: 'presentation'
388
379
  }),
389
380
  getRenderZoneProps: () => ({
390
- ref: renderZoneRef,
391
381
  role: 'rowgroup'
392
382
  }),
393
383
  getScrollbarVerticalProps: () => ({
@@ -600,4 +590,16 @@ export function areRenderContextsEqual(context1, context2) {
600
590
  return true;
601
591
  }
602
592
  return context1.firstRowIndex === context2.firstRowIndex && context1.lastRowIndex === context2.lastRowIndex && context1.firstColumnIndex === context2.firstColumnIndex && context1.lastColumnIndex === context2.lastColumnIndex;
593
+ }
594
+ function computeOffsets(apiRef, renderContext, direction, pinnedLeftLength) {
595
+ var _rowPositions$renderC, _columnPositions$rend, _columnPositions$pinn;
596
+ const factor = direction === 'ltr' ? 1 : -1;
597
+ const rowPositions = gridRowsMetaSelector(apiRef.current.state).positions;
598
+ const columnPositions = gridColumnPositionsSelector(apiRef);
599
+ const top = (_rowPositions$renderC = rowPositions[renderContext.firstRowIndex]) != null ? _rowPositions$renderC : 0;
600
+ const left = factor * ((_columnPositions$rend = columnPositions[renderContext.firstColumnIndex]) != null ? _columnPositions$rend : 0) - ((_columnPositions$pinn = columnPositions[pinnedLeftLength]) != null ? _columnPositions$pinn : 0);
601
+ return {
602
+ top,
603
+ left
604
+ };
603
605
  }
@@ -8,6 +8,14 @@ export type GridVirtualizationState = {
8
8
  enabled: boolean;
9
9
  enabledForColumns: boolean;
10
10
  renderContext: GridRenderContext;
11
+ offsets: {
12
+ top: number;
13
+ left: number;
14
+ };
15
+ };
16
+ export declare const EMPTY_OFFSETS: {
17
+ top: number;
18
+ left: number;
11
19
  };
12
20
  export declare const EMPTY_RENDER_CONTEXT: {
13
21
  firstRowIndex: number;
@@ -1,6 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
4
+ export const EMPTY_OFFSETS = {
5
+ top: 0,
6
+ left: 0
7
+ };
4
8
  export const EMPTY_RENDER_CONTEXT = {
5
9
  firstRowIndex: 0,
6
10
  lastRowIndex: 0,
@@ -11,7 +15,8 @@ export const virtualizationStateInitializer = (state, props) => {
11
15
  const virtualization = {
12
16
  enabled: !props.disableVirtualization,
13
17
  enabledForColumns: true,
14
- renderContext: EMPTY_RENDER_CONTEXT
18
+ renderContext: EMPTY_RENDER_CONTEXT,
19
+ offsets: EMPTY_OFFSETS
15
20
  };
16
21
  return _extends({}, state, {
17
22
  virtualization
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.0.0-beta.1
2
+ * @mui/x-data-grid v7.0.0-beta.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,4 +1,4 @@
1
- export const propValidatorsDataGrid = [props => props.autoPageSize && props.autoHeight && ['MUI X: `<DataGrid autoPageSize={true} autoHeight={true} />` are not valid props.', 'You can not use both the `autoPageSize` and `autoHeight` props at the same time because `autoHeight` scales the height of the Data Grid according to the `pageSize`.', '', 'Please remove one of these two props.'].join('\n') || undefined];
1
+ export const propValidatorsDataGrid = [props => props.autoPageSize && props.autoHeight && ['MUI X: `<DataGrid autoPageSize={true} autoHeight={true} />` are not valid props.', 'You cannot use both the `autoPageSize` and `autoHeight` props at the same time because `autoHeight` scales the height of the Data Grid according to the `pageSize`.', '', 'Please remove one of these two props.'].join('\n') || undefined];
2
2
  const warnedOnceMap = new Set();
3
3
  const warnOnce = message => {
4
4
  if (!warnedOnceMap.has(message)) {
package/joy/joySlots.js CHANGED
@@ -404,8 +404,8 @@ const joySlots = _extends({}, joyIconSlots, {
404
404
  baseSelect: Select,
405
405
  baseSelectOption: Option,
406
406
  baseInputLabel: InputLabel,
407
- baseFormControl: JoyFormControl,
408
- baseTooltip: JoyTooltip,
407
+ baseFormControl: JoyFormControl /* FIXME: typing error */,
408
+ baseTooltip: JoyTooltip /* FIXME: typing error */,
409
409
  pagination: Pagination,
410
410
  loadingOverlay: LoadingOverlay
411
411
  });
@@ -310,7 +310,7 @@ DataGridRaw.propTypes = {
310
310
  loading: PropTypes.bool,
311
311
  /**
312
312
  * Set the locale text of the Data Grid.
313
- * You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/constants/localeTextConstants.ts) in the GitHub repository.
313
+ * You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/x-data-grid/src/constants/localeTextConstants.ts) in the GitHub repository.
314
314
  */
315
315
  localeText: PropTypes.object,
316
316
  /**
@@ -498,12 +498,6 @@ DataGridRaw.propTypes = {
498
498
  * @param {GridCallbackDetails} details Additional details for this callback.
499
499
  */
500
500
  onRowDoubleClick: PropTypes.func,
501
- /**
502
- * Callback fired when the row changes are committed.
503
- * @param {GridRowId} id The row id.
504
- * @param {MuiEvent<MuiBaseEvent>} event The event that caused this prop to be called.
505
- */
506
- onRowEditCommit: PropTypes.func,
507
501
  /**
508
502
  * Callback fired when the row turns to edit mode.
509
503
  * @param {GridRowParams} params With all properties from [[GridRowParams]].
@@ -74,7 +74,9 @@ export var DATA_GRID_PROPS_DEFAULT_VALUES = {
74
74
  };
75
75
  var defaultSlots = DATA_GRID_DEFAULT_SLOTS_COMPONENTS;
76
76
  export var useDataGridProps = function useDataGridProps(inProps) {
77
- var themedProps = useProps(useThemeProps({
77
+ var themedProps = useProps(
78
+ // eslint-disable-next-line material-ui/mui-name-matches-component-name
79
+ useThemeProps({
78
80
  props: inProps,
79
81
  name: 'MuiDataGrid'
80
82
  }));
@@ -21,6 +21,9 @@ var GridPaginationRoot = styled(TablePagination)(function (_ref) {
21
21
  display: 'inline-flex'
22
22
  }));
23
23
  });
24
+
25
+ // A mutable version of a readonly array.
26
+
24
27
  export var GridPagination = /*#__PURE__*/React.forwardRef(function GridPagination(props, ref) {
25
28
  var apiRef = useGridApiContext();
26
29
  var rootProps = useGridRootProps();
@@ -31,7 +34,8 @@ export var GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginatio
31
34
  return (_ref3 = (_rootProps$rowCount = rootProps.rowCount) != null ? _rootProps$rowCount : visibleTopLevelRowCount) != null ? _ref3 : 0;
32
35
  }, [rootProps.rowCount, visibleTopLevelRowCount]);
33
36
  var lastPage = React.useMemo(function () {
34
- return Math.floor(rowCount / (paginationModel.pageSize || 1));
37
+ var calculatedValue = Math.ceil(rowCount / (paginationModel.pageSize || 1)) - 1;
38
+ return Math.max(0, calculatedValue);
35
39
  }, [rowCount, paginationModel.pageSize]);
36
40
  var handlePageSizeChange = React.useCallback(function (event) {
37
41
  var pageSize = Number(event.target.value);
@@ -68,7 +72,11 @@ export var GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginatio
68
72
  ref: ref,
69
73
  component: "div",
70
74
  count: rowCount,
71
- page: paginationModel.page <= lastPage ? paginationModel.page : lastPage,
75
+ page: paginationModel.page <= lastPage ? paginationModel.page : lastPage
76
+ // TODO: Remove the cast once the type is fixed in Material UI and that the min Material UI version
77
+ // for x-data-grid is past the fix.
78
+ // Note that Material UI will not mutate the array, so this is safe.
79
+ ,
72
80
  rowsPerPageOptions: pageSizeOptions,
73
81
  rowsPerPage: paginationModel.pageSize,
74
82
  onPageChange: handlePageChange,
@@ -2,7 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "renderedColumns", "pinnedColumns", "dimensions", "firstColumnToRender", "lastColumnToRender", "isFirstVisible", "isLastVisible", "focusedCellColumnIndexNotInRange", "isNotVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver"];
5
+ var _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "renderedColumns", "pinnedColumns", "offsets", "dimensions", "firstColumnToRender", "lastColumnToRender", "isFirstVisible", "isLastVisible", "focusedCellColumnIndexNotInRange", "isNotVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
@@ -37,9 +37,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
37
37
  rowHeight = ownerState.rowHeight,
38
38
  classes = ownerState.classes;
39
39
  var slots = {
40
- root: ['row', selected && 'selected', editable && 'row--editable', editing && 'row--editing', isFirstVisible && 'row--firstVisible', isLastVisible && 'row--lastVisible', rowHeight === 'auto' && 'row--dynamicHeight'],
41
- pinnedLeft: ['pinnedLeft'],
42
- pinnedRight: ['pinnedRight']
40
+ root: ['row', selected && 'selected', editable && 'row--editable', editing && 'row--editing', isFirstVisible && 'row--firstVisible', isLastVisible && 'row--lastVisible', rowHeight === 'auto' && 'row--dynamicHeight']
43
41
  };
44
42
  return composeClasses(slots, getDataGridUtilityClass, classes);
45
43
  };
@@ -67,6 +65,7 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
67
65
  visibleColumns = props.visibleColumns,
68
66
  renderedColumns = props.renderedColumns,
69
67
  pinnedColumns = props.pinnedColumns,
68
+ offsets = props.offsets,
70
69
  dimensions = props.dimensions,
71
70
  firstColumnToRender = props.firstColumnToRender,
72
71
  lastColumnToRender = props.lastColumnToRender,
@@ -273,13 +272,14 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
273
272
  break;
274
273
  }
275
274
  if ((rowNode == null ? void 0 : rowNode.type) === 'skeletonRow') {
275
+ var _column$align;
276
276
  var _width = cellColSpanInfo.cellProps.width;
277
277
  var contentWidth = Math.round(randomNumber());
278
278
  return /*#__PURE__*/_jsx(slots.skeletonCell, {
279
279
  width: _width,
280
280
  contentWidth: contentWidth,
281
281
  field: column.field,
282
- align: column.align
282
+ align: (_column$align = column.align) != null ? _column$align : 'left'
283
283
  }, column.field);
284
284
  }
285
285
  var _cellColSpanInfo$cell = cellColSpanInfo.cellProps,
@@ -366,7 +366,13 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
366
366
  "aria-selected": selected,
367
367
  style: style
368
368
  }, eventHandlers, other, {
369
- children: [leftCells, cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
369
+ children: [leftCells, /*#__PURE__*/_jsx("div", {
370
+ role: "presentation",
371
+ className: gridClasses.cellOffsetLeft,
372
+ style: {
373
+ width: offsets.left
374
+ }
375
+ }), cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
370
376
  width: emptyCellWidth
371
377
  }), rightCells.length > 0 && /*#__PURE__*/_jsx("div", {
372
378
  role: "presentation",
@@ -434,6 +440,10 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
434
440
  isLastVisible: PropTypes.bool.isRequired,
435
441
  isNotVisible: PropTypes.bool,
436
442
  lastColumnToRender: PropTypes.number.isRequired,
443
+ offsets: PropTypes.shape({
444
+ left: PropTypes.number.isRequired,
445
+ top: PropTypes.number.isRequired
446
+ }).isRequired,
437
447
  onClick: PropTypes.func,
438
448
  onDoubleClick: PropTypes.func,
439
449
  onMouseEnter: PropTypes.func,
@@ -10,7 +10,7 @@ var classes = {
10
10
  borderTop: getClassName('scrollbarFiller--borderTop'),
11
11
  pinnedRight: getClassName('scrollbarFiller--pinnedRight')
12
12
  };
13
- var Style = styled('div')(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
13
+ var Style = styled('div')(_defineProperty(_defineProperty(_defineProperty({
14
14
  minWidth: 'calc(var(--DataGrid-hasScrollY) * var(--DataGrid-scrollbarSize))',
15
15
  alignSelf: 'stretch'
16
16
  }, "&.".concat(classes.borderTop), {
@@ -20,8 +20,6 @@ var Style = styled('div')(_defineProperty(_defineProperty(_defineProperty(_defin
20
20
  }), "&.".concat(classes.pinnedRight, ":not(.").concat(classes.header, ")"), {
21
21
  position: 'sticky',
22
22
  right: 0
23
- }), "&:not(.".concat(classes.header, "):not(.").concat(classes.pinnedRight, ")"), {
24
- transform: 'translate3d(var(--DataGrid-offsetLeft), 0, 0)'
25
23
  }));
26
24
  function GridScrollbarFillerCell(_ref) {
27
25
  var header = _ref.header,
@@ -8,5 +8,5 @@ export function GridFooterPlaceholder() {
8
8
  if (rootProps.hideFooter) {
9
9
  return null;
10
10
  }
11
- return /*#__PURE__*/_jsx(rootProps.slots.footer, _extends({}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.footer));
11
+ return /*#__PURE__*/_jsx(rootProps.slots.footer, _extends({}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.footer /* FIXME: typing error */));
12
12
  }
@@ -169,7 +169,7 @@ function GridActionsCell(props) {
169
169
  if (event.key === 'Tab') {
170
170
  event.preventDefault();
171
171
  }
172
- if (['Tab', 'Enter', 'Escape'].includes(event.key)) {
172
+ if (['Tab', 'Escape'].includes(event.key)) {
173
173
  hideMenu();
174
174
  }
175
175
  };
@@ -208,7 +208,6 @@ function GridActionsCell(props) {
208
208
  target: buttonRef.current,
209
209
  position: position,
210
210
  onClose: hideMenu,
211
- onClick: hideMenu,
212
211
  children: /*#__PURE__*/_jsx(MenuList, {
213
212
  id: menuId,
214
213
  className: gridClasses.menuList,
@@ -218,7 +217,8 @@ function GridActionsCell(props) {
218
217
  autoFocusItem: true,
219
218
  children: menuButtons.map(function (button, index) {
220
219
  return /*#__PURE__*/React.cloneElement(button, {
221
- key: index
220
+ key: index,
221
+ closeMenu: hideMenu
222
222
  });
223
223
  })
224
224
  })
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["label", "icon", "showInMenu", "onClick"];
3
+ var _excluded = ["label", "icon", "showInMenu", "onClick"],
4
+ _excluded2 = ["label", "icon", "showInMenu", "onClick", "closeMenuOnClick", "closeMenu"];
4
5
  import * as React from 'react';
5
6
  import PropTypes from 'prop-types';
6
7
  import MenuItem from '@mui/material/MenuItem';
@@ -9,36 +10,48 @@ import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
11
12
  var GridActionsCellItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
12
- var label = props.label,
13
- icon = props.icon,
14
- showInMenu = props.showInMenu,
15
- onClick = props.onClick,
16
- other = _objectWithoutProperties(props, _excluded);
17
13
  var rootProps = useGridRootProps();
18
- var handleClick = function handleClick(event) {
19
- if (onClick) {
20
- onClick(event);
21
- }
22
- };
23
- if (!showInMenu) {
14
+ if (!props.showInMenu) {
24
15
  var _rootProps$slotProps;
16
+ var _label = props.label,
17
+ _icon = props.icon,
18
+ _showInMenu = props.showInMenu,
19
+ _onClick = props.onClick,
20
+ _other = _objectWithoutProperties(props, _excluded);
21
+ var _handleClick = function _handleClick(event) {
22
+ _onClick == null || _onClick(event);
23
+ };
25
24
  return /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
26
25
  ref: ref,
27
26
  size: "small",
28
27
  role: "menuitem",
29
- "aria-label": label
30
- }, other, {
31
- onClick: handleClick
28
+ "aria-label": _label
29
+ }, _other, {
30
+ onClick: _handleClick
32
31
  }, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseIconButton, {
33
- children: /*#__PURE__*/React.cloneElement(icon, {
32
+ children: /*#__PURE__*/React.cloneElement(_icon, {
34
33
  fontSize: 'small'
35
34
  })
36
35
  }));
37
36
  }
37
+ var label = props.label,
38
+ icon = props.icon,
39
+ showInMenu = props.showInMenu,
40
+ onClick = props.onClick,
41
+ _props$closeMenuOnCli = props.closeMenuOnClick,
42
+ closeMenuOnClick = _props$closeMenuOnCli === void 0 ? true : _props$closeMenuOnCli,
43
+ closeMenu = props.closeMenu,
44
+ other = _objectWithoutProperties(props, _excluded2);
45
+ var handleClick = function handleClick(event) {
46
+ onClick == null || onClick(event);
47
+ if (closeMenuOnClick) {
48
+ closeMenu == null || closeMenu();
49
+ }
50
+ };
38
51
  return /*#__PURE__*/_jsxs(MenuItem, _extends({
39
52
  ref: ref
40
53
  }, other, {
41
- onClick: onClick,
54
+ onClick: handleClick,
42
55
  children: [icon && /*#__PURE__*/_jsx(ListItemIcon, {
43
56
  children: icon
44
57
  }), label]
@@ -88,7 +88,7 @@ var GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCell
88
88
  },
89
89
  onKeyDown: handleKeyDown,
90
90
  disabled: !isSelectable,
91
- touchRippleRef: rippleRef
91
+ touchRippleRef: rippleRef /* FIXME: typing error */
92
92
  }, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseCheckbox, other));
93
93
  });
94
94
  process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
@@ -66,8 +66,6 @@ export var GridRootStyles = styled('div', {
66
66
  '--DataGrid-width': '0px',
67
67
  '--DataGrid-hasScrollX': '0',
68
68
  '--DataGrid-hasScrollY': '0',
69
- '--DataGrid-offsetTop': '0px',
70
- '--DataGrid-offsetLeft': '0px',
71
69
  '--DataGrid-scrollbarSize': '10px',
72
70
  '--DataGrid-rowWidth': '0px',
73
71
  '--DataGrid-columnsTotalWidth': '0px',
@@ -99,11 +97,15 @@ export var GridRootStyles = styled('div', {
99
97
  borderTopRightRadius: 'var(--unstable_DataGrid-radius)'
100
98
  }), "&.".concat(c.autoHeight), {
101
99
  height: 'auto'
102
- }), "&.".concat(c.autosizing), _defineProperty(_defineProperty({}, "& .".concat(c.columnHeaderTitleContainerContent, " > *"), {
100
+ }), "&.".concat(c.autosizing), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "& .".concat(c.columnHeaderTitleContainerContent, " > *"), {
103
101
  overflow: 'visible !important'
104
102
  }), "& .".concat(c.cell, " > *"), {
105
103
  overflow: 'visible !important',
106
104
  whiteSpace: 'nowrap'
105
+ }), "& .".concat(c.groupingCriteriaCell), {
106
+ width: 'unset'
107
+ }), "& .".concat(c.treeDataGroupingCell), {
108
+ width: 'unset'
107
109
  })), "& .".concat(c.columnHeader, ", & .").concat(c.cell), {
108
110
  WebkitTapHighlightColor: 'transparent',
109
111
  lineHeight: null,
@@ -333,8 +335,9 @@ export var GridRootStyles = styled('div', {
333
335
  backgroundColor: pinnedSelectedBackground
334
336
  }), '&:hover', _defineProperty({}, "& .".concat(c['cell--pinnedLeft'], ", & .").concat(c['cell--pinnedRight']), {
335
337
  backgroundColor: pinnedSelectedHoverBackground
336
- })))), "& .".concat(c.cell, ":not(.").concat(c['cell--pinnedLeft'], "):not(.").concat(c['cell--pinnedRight'], ")"), {
337
- transform: 'translate3d(var(--DataGrid-offsetLeft), 0, 0)'
338
+ })))), "& .".concat(c.cellOffsetLeft), {
339
+ flex: '0 0 auto',
340
+ display: 'inline-block'
338
341
  }), "& .".concat(c.columnHeaderDraggableContainer), {
339
342
  display: 'flex',
340
343
  width: '100%',
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
4
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
- var _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "clearButton", "tabIndex", "label", "InputLabelProps"];
5
+ var _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "clearButton", "tabIndex", "label", "variant", "InputLabelProps"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { refType, unstable_useId as useId } from '@mui/utils';
@@ -27,6 +27,8 @@ function GridFilterInputBoolean(props) {
27
27
  clearButton = props.clearButton,
28
28
  tabIndex = props.tabIndex,
29
29
  labelProp = props.label,
30
+ _props$variant = props.variant,
31
+ variant = _props$variant === void 0 ? 'standard' : _props$variant,
30
32
  InputLabelProps = props.InputLabelProps,
31
33
  others = _objectWithoutProperties(props, _excluded);
32
34
  var _React$useState = React.useState(item.value || ''),
@@ -56,7 +58,7 @@ function GridFilterInputBoolean(props) {
56
58
  children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseInputLabel, {
57
59
  id: labelId,
58
60
  shrink: true,
59
- variant: "standard",
61
+ variant: variant,
60
62
  children: label
61
63
  })), /*#__PURE__*/_jsxs(rootProps.slots.baseSelect, _extends({
62
64
  labelId: labelId,
@@ -64,14 +66,15 @@ function GridFilterInputBoolean(props) {
64
66
  label: label,
65
67
  value: filterValueState,
66
68
  onChange: onFilterChange,
67
- variant: "standard",
69
+ variant: variant,
70
+ notched: variant === 'outlined' ? true : undefined,
68
71
  native: isSelectNative,
69
72
  displayEmpty: true,
70
73
  inputProps: {
71
74
  ref: focusElementRef,
72
75
  tabIndex: tabIndex
73
76
  }
74
- }, others, baseSelectProps, {
77
+ }, others /* FIXME: typing error */, baseSelectProps, {
75
78
  children: [/*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
76
79
  native: isSelectNative,
77
80
  value: "",
@@ -2,7 +2,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
- var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "placeholder", "tabIndex", "label", "isFilterActive", "clearButton", "InputLabelProps"];
5
+ var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "placeholder", "tabIndex", "label", "variant", "isFilterActive", "clearButton", "InputLabelProps"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { unstable_useId as useId } from '@mui/utils';
@@ -50,6 +50,8 @@ function GridFilterInputSingleSelect(props) {
50
50
  placeholder = props.placeholder,
51
51
  tabIndex = props.tabIndex,
52
52
  labelProp = props.label,
53
+ _props$variant = props.variant,
54
+ variant = _props$variant === void 0 ? 'standard' : _props$variant,
53
55
  isFilterActive = props.isFilterActive,
54
56
  clearButton = props.clearButton,
55
57
  InputLabelProps = props.InputLabelProps,
@@ -91,7 +93,7 @@ function GridFilterInputSingleSelect(props) {
91
93
  id: labelId,
92
94
  htmlFor: id,
93
95
  shrink: true,
94
- variant: "standard",
96
+ variant: variant,
95
97
  children: label
96
98
  })), /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
97
99
  id: id,
@@ -99,15 +101,16 @@ function GridFilterInputSingleSelect(props) {
99
101
  labelId: labelId,
100
102
  value: filterValue,
101
103
  onChange: onFilterChange,
102
- variant: "standard",
104
+ variant: variant,
103
105
  type: type || 'text',
104
106
  inputProps: {
105
107
  tabIndex: tabIndex,
106
108
  ref: focusElementRef,
107
109
  placeholder: placeholder != null ? placeholder : apiRef.current.getLocaleText('filterPanelInputPlaceholder')
108
110
  },
109
- native: isSelectNative
110
- }, others, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseSelect, {
111
+ native: isSelectNative,
112
+ notched: variant === 'outlined' ? true : undefined
113
+ }, others /* FIXME: typing error */, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseSelect, {
111
114
  children: renderSingleSelectOptions({
112
115
  column: resolvedColumn,
113
116
  OptionComponent: rootProps.slots.baseSelectOption,
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "disabled", "isFilterActive", "clearButton", "InputProps"];
4
+ var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "disabled", "isFilterActive", "clearButton", "InputProps", "variant"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { unstable_useId as useId } from '@mui/utils';
@@ -20,6 +20,8 @@ function GridFilterInputValue(props) {
20
20
  isFilterActive = props.isFilterActive,
21
21
  clearButton = props.clearButton,
22
22
  InputProps = props.InputProps,
23
+ _props$variant = props.variant,
24
+ variant = _props$variant === void 0 ? 'standard' : _props$variant,
23
25
  others = _objectWithoutProperties(props, _excluded);
24
26
  var filterTimeout = useTimeout();
25
27
  var _React$useState = React.useState((_item$value = item.value) != null ? _item$value : ''),
@@ -58,7 +60,7 @@ function GridFilterInputValue(props) {
58
60
  placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder'),
59
61
  value: filterValueState,
60
62
  onChange: onFilterChange,
61
- variant: "standard",
63
+ variant: variant,
62
64
  type: type || 'text',
63
65
  InputProps: _extends({}, applying || clearButton ? {
64
66
  endAdornment: applying ? /*#__PURE__*/_jsx(rootProps.slots.loadIcon, {