@mui/x-data-grid 7.0.0-beta.0 → 7.0.0-beta.2

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 (162) hide show
  1. package/CHANGELOG.md +406 -1
  2. package/DataGrid/DataGrid.d.ts +1 -1
  3. package/DataGrid/DataGrid.js +1 -1
  4. package/DataGrid/useDataGridComponent.js +1 -1
  5. package/DataGrid/useDataGridProps.js +3 -1
  6. package/colDef/gridBooleanColDef.js +3 -6
  7. package/colDef/gridCheckboxSelectionColDef.js +4 -3
  8. package/colDef/gridDateColDef.d.ts +3 -4
  9. package/colDef/gridDateColDef.js +10 -16
  10. package/colDef/gridNumericColDef.js +1 -3
  11. package/colDef/gridSingleSelectColDef.js +7 -12
  12. package/components/GridPagination.d.ts +1 -1
  13. package/components/GridPagination.js +12 -2
  14. package/components/GridRow.js +7 -5
  15. package/components/GridScrollbarFillerCell.js +0 -3
  16. package/components/base/GridFooterPlaceholder.js +1 -1
  17. package/components/cell/GridActionsCell.js +3 -3
  18. package/components/cell/GridActionsCellItem.d.ts +13 -1
  19. package/components/cell/GridActionsCellItem.js +27 -15
  20. package/components/cell/GridEditInputCell.js +1 -1
  21. package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  22. package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
  23. package/components/columnsManagement/GridColumnsManagement.d.ts +7 -0
  24. package/components/columnsManagement/GridColumnsManagement.js +26 -21
  25. package/components/columnsManagement/utils.d.ts +1 -1
  26. package/components/containers/GridRootStyles.js +10 -2
  27. package/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  28. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
  29. package/components/panel/filterPanel/GridFilterPanel.js +1 -1
  30. package/constants/gridClasses.d.ts +5 -0
  31. package/constants/gridClasses.js +1 -1
  32. package/hooks/features/columns/useGridColumnSpanning.js +3 -1
  33. package/hooks/features/editing/useGridCellEditing.js +2 -5
  34. package/hooks/features/editing/useGridRowEditing.js +2 -5
  35. package/hooks/features/filter/gridFilterUtils.js +1 -1
  36. package/hooks/features/rows/gridRowsUtils.js +1 -1
  37. package/hooks/features/rows/useGridParamsApi.d.ts +1 -2
  38. package/hooks/features/rows/useGridParamsApi.js +14 -49
  39. package/hooks/features/rows/useGridRows.js +2 -2
  40. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -1
  41. package/hooks/features/virtualization/useGridVirtualScroller.js +9 -10
  42. package/index.js +1 -1
  43. package/internals/utils/propValidation.js +1 -1
  44. package/joy/joySlots.js +2 -2
  45. package/legacy/DataGrid/DataGrid.js +1 -1
  46. package/legacy/DataGrid/useDataGridComponent.js +1 -1
  47. package/legacy/DataGrid/useDataGridProps.js +3 -1
  48. package/legacy/colDef/gridBooleanColDef.js +3 -5
  49. package/legacy/colDef/gridCheckboxSelectionColDef.js +4 -3
  50. package/legacy/colDef/gridDateColDef.js +10 -14
  51. package/legacy/colDef/gridNumericColDef.js +1 -2
  52. package/legacy/colDef/gridSingleSelectColDef.js +7 -10
  53. package/legacy/components/GridPagination.js +10 -2
  54. package/legacy/components/GridRow.js +7 -5
  55. package/legacy/components/GridScrollbarFillerCell.js +1 -3
  56. package/legacy/components/base/GridFooterPlaceholder.js +1 -1
  57. package/legacy/components/cell/GridActionsCell.js +3 -3
  58. package/legacy/components/cell/GridActionsCellItem.js +30 -17
  59. package/legacy/components/cell/GridEditInputCell.js +1 -1
  60. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  61. package/legacy/components/columnsManagement/GridColumnsManagement.js +38 -31
  62. package/legacy/components/containers/GridRootStyles.js +9 -3
  63. package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  64. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
  65. package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -1
  66. package/legacy/constants/gridClasses.js +1 -1
  67. package/legacy/hooks/features/columns/useGridColumnSpanning.js +3 -1
  68. package/legacy/hooks/features/editing/useGridCellEditing.js +2 -5
  69. package/legacy/hooks/features/editing/useGridRowEditing.js +2 -5
  70. package/legacy/hooks/features/filter/gridFilterUtils.js +2 -2
  71. package/legacy/hooks/features/rows/gridRowsUtils.js +1 -1
  72. package/legacy/hooks/features/rows/useGridParamsApi.js +14 -47
  73. package/legacy/hooks/features/rows/useGridRows.js +2 -2
  74. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +9 -10
  75. package/legacy/index.js +1 -1
  76. package/legacy/internals/utils/propValidation.js +1 -1
  77. package/legacy/joy/joySlots.js +2 -2
  78. package/legacy/locales/daDK.js +12 -12
  79. package/legacy/locales/heIL.js +7 -8
  80. package/locales/daDK.js +12 -12
  81. package/locales/heIL.js +7 -8
  82. package/models/api/gridApiCommon.d.ts +1 -1
  83. package/models/api/gridFilterApi.d.ts +1 -1
  84. package/models/api/gridLocaleTextApi.d.ts +3 -3
  85. package/models/colDef/gridColDef.d.ts +11 -17
  86. package/models/colDef/index.d.ts +1 -1
  87. package/models/events/gridEventLookup.d.ts +1 -1
  88. package/models/gridSlotsComponent.d.ts +34 -36
  89. package/models/gridSlotsComponentsProps.d.ts +73 -54
  90. package/models/params/gridCellParams.d.ts +0 -26
  91. package/models/props/DataGridProps.d.ts +2 -2
  92. package/modern/DataGrid/DataGrid.js +1 -1
  93. package/modern/DataGrid/useDataGridComponent.js +1 -1
  94. package/modern/DataGrid/useDataGridProps.js +3 -1
  95. package/modern/colDef/gridBooleanColDef.js +3 -6
  96. package/modern/colDef/gridCheckboxSelectionColDef.js +4 -3
  97. package/modern/colDef/gridDateColDef.js +10 -16
  98. package/modern/colDef/gridNumericColDef.js +1 -3
  99. package/modern/colDef/gridSingleSelectColDef.js +7 -12
  100. package/modern/components/GridPagination.js +12 -2
  101. package/modern/components/GridRow.js +6 -5
  102. package/modern/components/GridScrollbarFillerCell.js +0 -3
  103. package/modern/components/base/GridFooterPlaceholder.js +1 -1
  104. package/modern/components/cell/GridActionsCell.js +3 -3
  105. package/modern/components/cell/GridActionsCellItem.js +27 -15
  106. package/modern/components/cell/GridEditInputCell.js +1 -1
  107. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  108. package/modern/components/columnsManagement/GridColumnsManagement.js +26 -21
  109. package/modern/components/containers/GridRootStyles.js +10 -2
  110. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  111. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
  112. package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
  113. package/modern/constants/gridClasses.js +1 -1
  114. package/modern/hooks/features/columns/useGridColumnSpanning.js +3 -1
  115. package/modern/hooks/features/editing/useGridCellEditing.js +2 -5
  116. package/modern/hooks/features/editing/useGridRowEditing.js +2 -5
  117. package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
  118. package/modern/hooks/features/rows/gridRowsUtils.js +1 -1
  119. package/modern/hooks/features/rows/useGridParamsApi.js +14 -47
  120. package/modern/hooks/features/rows/useGridRows.js +2 -2
  121. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +9 -10
  122. package/modern/index.js +1 -1
  123. package/modern/internals/utils/propValidation.js +1 -1
  124. package/modern/joy/joySlots.js +2 -2
  125. package/modern/locales/daDK.js +12 -12
  126. package/modern/locales/heIL.js +7 -8
  127. package/node/DataGrid/DataGrid.js +1 -1
  128. package/node/DataGrid/useDataGridComponent.js +1 -1
  129. package/node/DataGrid/useDataGridProps.js +3 -1
  130. package/node/colDef/gridBooleanColDef.js +3 -6
  131. package/node/colDef/gridCheckboxSelectionColDef.js +4 -3
  132. package/node/colDef/gridDateColDef.js +13 -19
  133. package/node/colDef/gridNumericColDef.js +1 -3
  134. package/node/colDef/gridSingleSelectColDef.js +7 -12
  135. package/node/components/GridPagination.js +12 -2
  136. package/node/components/GridRow.js +6 -5
  137. package/node/components/GridScrollbarFillerCell.js +0 -3
  138. package/node/components/base/GridFooterPlaceholder.js +1 -1
  139. package/node/components/cell/GridActionsCell.js +3 -3
  140. package/node/components/cell/GridActionsCellItem.js +27 -15
  141. package/node/components/cell/GridEditInputCell.js +1 -1
  142. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  143. package/node/components/columnsManagement/GridColumnsManagement.js +26 -21
  144. package/node/components/containers/GridRootStyles.js +10 -2
  145. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  146. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
  147. package/node/components/panel/filterPanel/GridFilterPanel.js +1 -1
  148. package/node/constants/gridClasses.js +1 -1
  149. package/node/hooks/features/columns/useGridColumnSpanning.js +3 -1
  150. package/node/hooks/features/editing/useGridCellEditing.js +2 -5
  151. package/node/hooks/features/editing/useGridRowEditing.js +2 -5
  152. package/node/hooks/features/filter/gridFilterUtils.js +1 -1
  153. package/node/hooks/features/rows/gridRowsUtils.js +2 -2
  154. package/node/hooks/features/rows/useGridParamsApi.js +14 -47
  155. package/node/hooks/features/rows/useGridRows.js +2 -2
  156. package/node/hooks/features/virtualization/useGridVirtualScroller.js +9 -10
  157. package/node/index.js +1 -1
  158. package/node/internals/utils/propValidation.js +1 -1
  159. package/node/joy/joySlots.js +2 -2
  160. package/node/locales/daDK.js +12 -12
  161. package/node/locales/heIL.js +7 -8
  162. package/package.json +5 -5
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { getGridCellElement, getGridColumnHeaderElement, getGridRowElement } from '../../../utils/domUtils';
3
- import { GRID_ID_AUTOGENERATED } from './gridRowsUtils';
4
3
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
5
4
  import { gridFocusCellSelector, gridTabIndexCellSelector } from '../focus/gridFocusStateSelector';
6
5
  export class MissingRowIdError extends Error {}
@@ -13,10 +12,7 @@ export class MissingRowIdError extends Error {}
13
12
  * TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
14
13
  * TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
15
14
  */
16
- export function useGridParamsApi(apiRef, props) {
17
- const {
18
- getRowId
19
- } = props;
15
+ export function useGridParamsApi(apiRef) {
20
16
  const getColumnHeaderParams = React.useCallback(field => ({
21
17
  field,
22
18
  colDef: apiRef.current.getColumn(field)
@@ -33,28 +29,6 @@ export function useGridParamsApi(apiRef, props) {
33
29
  };
34
30
  return params;
35
31
  }, [apiRef]);
36
- const getBaseCellParams = React.useCallback((id, field) => {
37
- const row = apiRef.current.getRow(id);
38
- const rowNode = apiRef.current.getRowNode(id);
39
- if (!row || !rowNode) {
40
- throw new MissingRowIdError(`No row with id #${id} found`);
41
- }
42
- const cellFocus = gridFocusCellSelector(apiRef);
43
- const cellTabIndex = gridTabIndexCellSelector(apiRef);
44
- const params = {
45
- id,
46
- field,
47
- row,
48
- rowNode,
49
- value: row[field],
50
- colDef: apiRef.current.getColumn(field),
51
- cellMode: apiRef.current.getCellMode(id, field),
52
- api: apiRef.current,
53
- hasFocus: cellFocus !== null && cellFocus.field === field && cellFocus.id === id,
54
- tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1
55
- };
56
- return params;
57
- }, [apiRef]);
58
32
  const getCellParams = React.useCallback((id, field) => {
59
33
  const colDef = apiRef.current.getColumn(field);
60
34
  const value = apiRef.current.getCellValue(id, field);
@@ -79,12 +53,7 @@ export function useGridParamsApi(apiRef, props) {
79
53
  isEditable: false
80
54
  };
81
55
  if (colDef && colDef.valueFormatter) {
82
- params.formattedValue = colDef.valueFormatter({
83
- id,
84
- field: params.field,
85
- value: params.value,
86
- api: apiRef.current
87
- });
56
+ params.formattedValue = colDef.valueFormatter(value, row, colDef, apiRef);
88
57
  }
89
58
  params.isEditable = colDef && apiRef.current.isCellEditable(params);
90
59
  return params;
@@ -98,32 +67,28 @@ export function useGridParamsApi(apiRef, props) {
98
67
  }
99
68
  return rowModel[field];
100
69
  }
101
- return colDef.valueGetter(getBaseCellParams(id, field));
102
- }, [apiRef, getBaseCellParams]);
70
+ const row = apiRef.current.getRow(id);
71
+ if (!row) {
72
+ throw new MissingRowIdError(`No row with id #${id} found`);
73
+ }
74
+ const value = row[colDef.field];
75
+ return colDef.valueGetter(value, row, colDef, apiRef);
76
+ }, [apiRef]);
103
77
  const getRowValue = React.useCallback((row, colDef) => {
104
- var _getRowId;
105
- const id = GRID_ID_AUTOGENERATED in row ? row[GRID_ID_AUTOGENERATED] : (_getRowId = getRowId == null ? void 0 : getRowId(row)) != null ? _getRowId : row.id;
106
78
  const field = colDef.field;
107
79
  if (!colDef || !colDef.valueGetter) {
108
80
  return row[field];
109
81
  }
110
- return colDef.valueGetter(getBaseCellParams(id, field));
111
- }, [getBaseCellParams, getRowId]);
82
+ const value = row[colDef.field];
83
+ return colDef.valueGetter(value, row, colDef, apiRef);
84
+ }, [apiRef]);
112
85
  const getRowFormattedValue = React.useCallback((row, colDef) => {
113
- var _ref;
114
86
  const value = getRowValue(row, colDef);
115
87
  if (!colDef || !colDef.valueFormatter) {
116
88
  return value;
117
89
  }
118
- const id = (_ref = getRowId ? getRowId(row) : row.id) != null ? _ref : row[GRID_ID_AUTOGENERATED];
119
- const field = colDef.field;
120
- return colDef.valueFormatter({
121
- id,
122
- field,
123
- value,
124
- api: apiRef.current
125
- });
126
- }, [apiRef, getRowId, getRowValue]);
90
+ return colDef.valueFormatter(value, row, colDef, apiRef);
91
+ }, [apiRef, getRowValue]);
127
92
  const getColumnHeaderElement = React.useCallback(field => {
128
93
  if (!apiRef.current.rootElementRef.current) {
129
94
  return null;
@@ -121,7 +121,7 @@ export const useGridRows = (apiRef, props) => {
121
121
  }, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange, apiRef]);
122
122
  const updateRows = React.useCallback(updates => {
123
123
  if (props.signature === GridSignature.DataGrid && updates.length > 1) {
124
- throw new Error(["MUI X: You can't update several rows at once in `apiRef.current.updateRows` on the DataGrid.", 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n'));
124
+ throw new Error(['MUI X: You cannot update several rows at once in `apiRef.current.updateRows` on the DataGrid.', 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n'));
125
125
  }
126
126
  const nonPinnedRowsUpdates = [];
127
127
  updates.forEach(update => {
@@ -252,7 +252,7 @@ export const useGridRows = (apiRef, props) => {
252
252
  }, [apiRef, logger]);
253
253
  const replaceRows = React.useCallback((firstRowToRender, newRows) => {
254
254
  if (props.signature === GridSignature.DataGrid && newRows.length > 1) {
255
- throw new Error(["MUI X: You can't replace rows using `apiRef.current.unstable_replaceRows` on the DataGrid.", 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n'));
255
+ throw new Error(['MUI X: You cannot replace rows using `apiRef.current.unstable_replaceRows` on the DataGrid.', 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n'));
256
256
  }
257
257
  if (newRows.length === 0) {
258
258
  return;
@@ -27,7 +27,6 @@ export declare const useGridVirtualScroller: () => {
27
27
  role: string;
28
28
  };
29
29
  getRenderZoneProps: () => {
30
- ref: React.RefObject<HTMLDivElement>;
31
30
  role: string;
32
31
  };
33
32
  getScrollbarVerticalProps: () => {
@@ -46,7 +46,6 @@ export const useGridVirtualScroller = () => {
46
46
  const gridRootRef = apiRef.current.rootElementRef;
47
47
  const mainRef = apiRef.current.mainElementRef;
48
48
  const scrollerRef = apiRef.current.virtualScrollerRef;
49
- const renderZoneRef = React.useRef(null);
50
49
  const scrollbarVerticalRef = React.useRef(null);
51
50
  const scrollbarHorizontalRef = React.useRef(null);
52
51
  const contentHeight = dimensions.contentSize.height;
@@ -247,6 +246,14 @@ export const useGridVirtualScroller = () => {
247
246
  id,
248
247
  model
249
248
  } = renderedRows[i];
249
+ const rowIndexInPage = ((currentPage == null || (_currentPage$range = currentPage.range) == null ? void 0 : _currentPage$range.firstRowIndex) || 0) + firstRowToRender + i;
250
+ let index = rowIndexOffset + rowIndexInPage;
251
+ if (isRowWithFocusedCellNotInRange && (cellFocus == null ? void 0 : cellFocus.id) === id) {
252
+ index = indexOfRowWithFocusedCell;
253
+ isRowWithFocusedCellRendered = true;
254
+ } else if (isRowWithFocusedCellRendered) {
255
+ index -= 1;
256
+ }
250
257
  const isRowNotVisible = isRowWithFocusedCellNotInRange && cellFocus.id === id;
251
258
  const baseRowHeight = !apiRef.current.rowHasAutoHeight(id) ? apiRef.current.unstable_getRowHeight(id) : 'auto';
252
259
  let isSelected;
@@ -257,7 +264,7 @@ export const useGridVirtualScroller = () => {
257
264
  }
258
265
  let isFirstVisible = false;
259
266
  if (params.position === undefined) {
260
- isFirstVisible = i === 0;
267
+ isFirstVisible = rowIndexInPage === 0;
261
268
  }
262
269
  let isLastVisible = false;
263
270
  if (isLastSection) {
@@ -279,13 +286,6 @@ export const useGridVirtualScroller = () => {
279
286
  const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
280
287
  tabbableCell = cellParams.cellMode === 'view' ? cellTabIndex.field : null;
281
288
  }
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
289
  rows.push( /*#__PURE__*/_jsx(rootProps.slots.row, _extends({
290
290
  row: model,
291
291
  rowId: id,
@@ -387,7 +387,6 @@ export const useGridVirtualScroller = () => {
387
387
  role: 'presentation'
388
388
  }),
389
389
  getRenderZoneProps: () => ({
390
- ref: renderZoneRef,
391
390
  role: 'rowgroup'
392
391
  }),
393
392
  getScrollbarVerticalProps: () => ({
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.0.0-beta.0
2
+ * @mui/x-data-grid v7.0.0-beta.2
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
  /**
@@ -57,7 +57,7 @@ export var useDataGridComponent = function useDataGridComponent(inputApiRef, pro
57
57
  useGridRowSelection(apiRef, props);
58
58
  useGridColumns(apiRef, props);
59
59
  useGridRows(apiRef, props);
60
- useGridParamsApi(apiRef, props);
60
+ useGridParamsApi(apiRef);
61
61
  useGridColumnSpanning(apiRef);
62
62
  useGridColumnGrouping(apiRef, props);
63
63
  useGridEditing(apiRef, props);
@@ -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
  }));
@@ -4,11 +4,9 @@ import { renderBooleanCell } from '../components/cell/GridBooleanCell';
4
4
  import { renderEditBooleanCell } from '../components/cell/GridEditBooleanCell';
5
5
  import { gridNumberComparator } from '../hooks/features/sorting/gridSortingUtils';
6
6
  import { getGridBooleanOperators } from './gridBooleanOperators';
7
- function gridBooleanFormatter(_ref) {
8
- var value = _ref.value,
9
- api = _ref.api;
10
- return value ? api.getLocaleText('booleanCellTrueLabel') : api.getLocaleText('booleanCellFalseLabel');
11
- }
7
+ var gridBooleanFormatter = function gridBooleanFormatter(value, row, column, apiRef) {
8
+ return value ? apiRef.current.getLocaleText('booleanCellTrueLabel') : apiRef.current.getLocaleText('booleanCellFalseLabel');
9
+ };
12
10
  var stringToBoolean = function stringToBoolean(value) {
13
11
  switch (value.toLowerCase().trim()) {
14
12
  case 'true':
@@ -19,9 +19,10 @@ export var GRID_CHECKBOX_SELECTION_COL_DEF = _extends({}, GRID_BOOLEAN_COL_DEF,
19
19
  disableReorder: true,
20
20
  disableExport: true,
21
21
  getApplyQuickFilterFn: undefined,
22
- valueGetter: function valueGetter(params) {
23
- var selectionLookup = selectedIdsLookupSelector(params.api.state, params.api.instanceId);
24
- return selectionLookup[params.id] !== undefined;
22
+ valueGetter: function valueGetter(value, row, column, apiRef) {
23
+ var selectionLookup = selectedIdsLookupSelector(apiRef);
24
+ var rowId = apiRef.current.getRowId(row);
25
+ return selectionLookup[rowId] !== undefined;
25
26
  },
26
27
  renderHeader: function renderHeader(params) {
27
28
  return /*#__PURE__*/_jsx(GridHeaderCheckbox, _extends({}, params));
@@ -12,36 +12,32 @@ function throwIfNotDateObject(_ref) {
12
12
  throw new Error(["MUI X: `".concat(columnType, "` column type only accepts `Date` objects as values."), 'Use `valueGetter` to transform the value into a `Date` object.', "Row ID: ".concat(rowId, ", field: \"").concat(field, "\".")].join('\n'));
13
13
  }
14
14
  }
15
- export function gridDateFormatter(_ref2) {
16
- var value = _ref2.value,
17
- field = _ref2.field,
18
- id = _ref2.id;
15
+ export var gridDateFormatter = function gridDateFormatter(value, row, column, apiRef) {
19
16
  if (!value) {
20
17
  return '';
21
18
  }
19
+ var rowId = apiRef.current.getRowId(row);
22
20
  throwIfNotDateObject({
23
21
  value: value,
24
22
  columnType: 'date',
25
- rowId: id,
26
- field: field
23
+ rowId: rowId,
24
+ field: column.field
27
25
  });
28
26
  return value.toLocaleDateString();
29
- }
30
- export function gridDateTimeFormatter(_ref3) {
31
- var value = _ref3.value,
32
- field = _ref3.field,
33
- id = _ref3.id;
27
+ };
28
+ export var gridDateTimeFormatter = function gridDateTimeFormatter(value, row, column, apiRef) {
34
29
  if (!value) {
35
30
  return '';
36
31
  }
32
+ var rowId = apiRef.current.getRowId(row);
37
33
  throwIfNotDateObject({
38
34
  value: value,
39
35
  columnType: 'dateTime',
40
- rowId: id,
41
- field: field
36
+ rowId: rowId,
37
+ field: column.field
42
38
  });
43
39
  return value.toLocaleString();
44
- }
40
+ };
45
41
  export var GRID_DATE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
46
42
  type: 'date',
47
43
  sortComparator: gridDateComparator,
@@ -11,8 +11,7 @@ export var GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
11
11
  valueParser: function valueParser(value) {
12
12
  return value === '' ? null : Number(value);
13
13
  },
14
- valueFormatter: function valueFormatter(_ref) {
15
- var value = _ref.value;
14
+ valueFormatter: function valueFormatter(value) {
16
15
  return isNumber(value) ? value.toLocaleString() : value || '';
17
16
  },
18
17
  filterOperators: getGridNumericOperators(),
@@ -18,18 +18,15 @@ export var GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
18
18
  type: 'singleSelect',
19
19
  getOptionLabel: defaultGetOptionLabel,
20
20
  getOptionValue: defaultGetOptionValue,
21
- valueFormatter: function valueFormatter(params) {
22
- var id = params.id,
23
- field = params.field,
24
- value = params.value,
25
- api = params.api;
26
- var colDef = params.api.getColumn(field);
21
+ valueFormatter: function valueFormatter(value, row, colDef, apiRef) {
22
+ // const { id, field, value, api } = params;
23
+ var rowId = apiRef.current.getRowId(row);
27
24
  if (!isSingleSelectColDef(colDef)) {
28
25
  return '';
29
26
  }
30
27
  var valueOptions = getValueOptions(colDef, {
31
- id: id,
32
- row: id ? api.getRow(id) : null
28
+ id: rowId,
29
+ row: row
33
30
  });
34
31
  if (value == null) {
35
32
  return '';
@@ -48,8 +45,8 @@ export var GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
48
45
  renderEditCell: renderEditSingleSelectCell,
49
46
  filterOperators: getGridSingleSelectOperators(),
50
47
  // @ts-ignore
51
- pastedValueParser: function pastedValueParser(value, params) {
52
- var colDef = params.colDef;
48
+ pastedValueParser: function pastedValueParser(value, row, column) {
49
+ var colDef = column;
53
50
  var valueOptions = getValueOptions(colDef) || [];
54
51
  var getOptionValue = colDef.getOptionValue;
55
52
  var valueOption = valueOptions.find(function (option) {
@@ -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,
@@ -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
  };
@@ -273,13 +271,14 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
273
271
  break;
274
272
  }
275
273
  if ((rowNode == null ? void 0 : rowNode.type) === 'skeletonRow') {
274
+ var _column$align;
276
275
  var _width = cellColSpanInfo.cellProps.width;
277
276
  var contentWidth = Math.round(randomNumber());
278
277
  return /*#__PURE__*/_jsx(slots.skeletonCell, {
279
278
  width: _width,
280
279
  contentWidth: contentWidth,
281
280
  field: column.field,
282
- align: column.align
281
+ align: (_column$align = column.align) != null ? _column$align : 'left'
283
282
  }, column.field);
284
283
  }
285
284
  var _cellColSpanInfo$cell = cellColSpanInfo.cellProps,
@@ -366,7 +365,10 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
366
365
  "aria-selected": selected,
367
366
  style: style
368
367
  }, eventHandlers, other, {
369
- children: [leftCells, cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
368
+ children: [leftCells, /*#__PURE__*/_jsx("div", {
369
+ className: gridClasses.cellOffsetLeft,
370
+ role: "presentation"
371
+ }), cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
370
372
  width: emptyCellWidth
371
373
  }), rightCells.length > 0 && /*#__PURE__*/_jsx("div", {
372
374
  role: "presentation",
@@ -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]
@@ -80,7 +80,7 @@ var GridEditInputCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
80
80
  column = apiRef.current.getColumn(field);
81
81
  parsedValue = newValue;
82
82
  if (column.valueParser) {
83
- parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field));
83
+ parsedValue = column.valueParser(newValue, apiRef.current.getRow(id), column, apiRef);
84
84
  }
85
85
  setValueState(parsedValue);
86
86
  apiRef.current.setEditCellValue({
@@ -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 = {