@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,30 +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
- const id = GRID_ID_AUTOGENERATED in row ? row[GRID_ID_AUTOGENERATED] : getRowId?.(row) ?? row.id;
105
78
  const field = colDef.field;
106
79
  if (!colDef || !colDef.valueGetter) {
107
80
  return row[field];
108
81
  }
109
- return colDef.valueGetter(getBaseCellParams(id, field));
110
- }, [getBaseCellParams, getRowId]);
82
+ const value = row[colDef.field];
83
+ return colDef.valueGetter(value, row, colDef, apiRef);
84
+ }, [apiRef]);
111
85
  const getRowFormattedValue = React.useCallback((row, colDef) => {
112
86
  const value = getRowValue(row, colDef);
113
87
  if (!colDef || !colDef.valueFormatter) {
114
88
  return value;
115
89
  }
116
- const id = (getRowId ? getRowId(row) : row.id) ?? row[GRID_ID_AUTOGENERATED];
117
- const field = colDef.field;
118
- return colDef.valueFormatter({
119
- id,
120
- field,
121
- value,
122
- api: apiRef.current
123
- });
124
- }, [apiRef, getRowId, getRowValue]);
90
+ return colDef.valueFormatter(value, row, colDef, apiRef);
91
+ }, [apiRef, getRowValue]);
125
92
  const getColumnHeaderElement = React.useCallback(field => {
126
93
  if (!apiRef.current.rootElementRef.current) {
127
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 => {
@@ -246,7 +246,7 @@ export const useGridRows = (apiRef, props) => {
246
246
  }, [apiRef, logger]);
247
247
  const replaceRows = React.useCallback((firstRowToRender, newRows) => {
248
248
  if (props.signature === GridSignature.DataGrid && newRows.length > 1) {
249
- 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'));
249
+ 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'));
250
250
  }
251
251
  if (newRows.length === 0) {
252
252
  return;
@@ -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;
@@ -244,6 +243,14 @@ export const useGridVirtualScroller = () => {
244
243
  id,
245
244
  model
246
245
  } = renderedRows[i];
246
+ const rowIndexInPage = (currentPage?.range?.firstRowIndex || 0) + firstRowToRender + i;
247
+ let index = rowIndexOffset + rowIndexInPage;
248
+ if (isRowWithFocusedCellNotInRange && cellFocus?.id === id) {
249
+ index = indexOfRowWithFocusedCell;
250
+ isRowWithFocusedCellRendered = true;
251
+ } else if (isRowWithFocusedCellRendered) {
252
+ index -= 1;
253
+ }
247
254
  const isRowNotVisible = isRowWithFocusedCellNotInRange && cellFocus.id === id;
248
255
  const baseRowHeight = !apiRef.current.rowHasAutoHeight(id) ? apiRef.current.unstable_getRowHeight(id) : 'auto';
249
256
  let isSelected;
@@ -254,7 +261,7 @@ export const useGridVirtualScroller = () => {
254
261
  }
255
262
  let isFirstVisible = false;
256
263
  if (params.position === undefined) {
257
- isFirstVisible = i === 0;
264
+ isFirstVisible = rowIndexInPage === 0;
258
265
  }
259
266
  let isLastVisible = false;
260
267
  if (isLastSection) {
@@ -276,13 +283,6 @@ export const useGridVirtualScroller = () => {
276
283
  const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
277
284
  tabbableCell = cellParams.cellMode === 'view' ? cellTabIndex.field : null;
278
285
  }
279
- let index = rowIndexOffset + (currentPage?.range?.firstRowIndex || 0) + firstRowToRender + i;
280
- if (isRowWithFocusedCellNotInRange && cellFocus?.id === id) {
281
- index = indexOfRowWithFocusedCell;
282
- isRowWithFocusedCellRendered = true;
283
- } else if (isRowWithFocusedCellRendered) {
284
- index -= 1;
285
- }
286
286
  rows.push( /*#__PURE__*/_jsx(rootProps.slots.row, _extends({
287
287
  row: model,
288
288
  rowId: id,
@@ -383,7 +383,6 @@ export const useGridVirtualScroller = () => {
383
383
  role: 'presentation'
384
384
  }),
385
385
  getRenderZoneProps: () => ({
386
- ref: renderZoneRef,
387
386
  role: 'rowgroup'
388
387
  }),
389
388
  getScrollbarVerticalProps: () => ({
package/modern/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)) {
@@ -398,8 +398,8 @@ const joySlots = _extends({}, joyIconSlots, {
398
398
  baseSelect: Select,
399
399
  baseSelectOption: Option,
400
400
  baseInputLabel: InputLabel,
401
- baseFormControl: JoyFormControl,
402
- baseTooltip: JoyTooltip,
401
+ baseFormControl: JoyFormControl /* FIXME: typing error */,
402
+ baseTooltip: JoyTooltip /* FIXME: typing error */,
403
403
  pagination: Pagination,
404
404
  loadingOverlay: LoadingOverlay
405
405
  });
@@ -11,8 +11,8 @@ const daDKGrid = {
11
11
  toolbarDensityStandard: 'Standard',
12
12
  toolbarDensityComfortable: 'Luftig',
13
13
  // Columns selector toolbar button text
14
- toolbarColumns: 'Kolonne',
15
- toolbarColumnsLabel: 'Vælg kolonne',
14
+ toolbarColumns: 'Kolonner',
15
+ toolbarColumnsLabel: 'Vælg kolonner',
16
16
  // Filters toolbar button text
17
17
  toolbarFilters: 'Filtre',
18
18
  toolbarFiltersLabel: 'Vis filtre',
@@ -39,12 +39,12 @@ const daDKGrid = {
39
39
  filterPanelRemoveAll: 'Fjern alle',
40
40
  filterPanelDeleteIconLabel: 'Slet',
41
41
  filterPanelLogicOperator: 'Logisk operator',
42
- filterPanelOperator: 'Operatorer',
42
+ filterPanelOperator: 'Operator',
43
43
  filterPanelOperatorAnd: 'Og',
44
44
  filterPanelOperatorOr: 'Eller',
45
- filterPanelColumns: 'Kolonne',
45
+ filterPanelColumns: 'Kolonner',
46
46
  filterPanelInputLabel: 'Værdi',
47
- filterPanelInputPlaceholder: 'Filter værdi',
47
+ filterPanelInputPlaceholder: 'Filterværdi',
48
48
  // Filter operators text
49
49
  filterOperatorContains: 'indeholder',
50
50
  filterOperatorEquals: 'lig med',
@@ -91,10 +91,10 @@ const daDKGrid = {
91
91
  filterValueFalse: 'negativ',
92
92
  // Column menu text
93
93
  columnMenuLabel: 'Menu',
94
- columnMenuShowColumns: 'Vis Kolonner',
94
+ columnMenuShowColumns: 'Vis kolonner',
95
95
  columnMenuManageColumns: 'Administrer kolonner',
96
- columnMenuFilter: 'Filtre',
97
- columnMenuHideColumn: 'Skjul',
96
+ columnMenuFilter: 'Filtrer',
97
+ columnMenuHideColumn: 'Skjul kolonne',
98
98
  columnMenuUnsort: 'Fjern sortering',
99
99
  columnMenuSortAsc: 'Sorter stigende',
100
100
  columnMenuSortDesc: 'Sorter faldende',
@@ -124,13 +124,13 @@ const daDKGrid = {
124
124
  pinToRight: 'Fastgør til højre',
125
125
  unpin: 'Frigiv',
126
126
  // Tree Data
127
- treeDataGroupingHeaderName: 'Gruppering',
127
+ treeDataGroupingHeaderName: 'Gruppe',
128
128
  treeDataExpand: 'Vis underelementer',
129
129
  treeDataCollapse: 'Skjul underelementer',
130
130
  // Grouping columns
131
- groupingColumnHeaderName: 'Gruppér',
131
+ groupingColumnHeaderName: 'Gruppe',
132
132
  groupColumn: name => `Gruppér efter ${name}`,
133
- unGroupColumn: name => `Fjern gruppéring efter ${name}`,
133
+ unGroupColumn: name => `Fjern gruppering efter ${name}`,
134
134
  // Master/detail
135
135
  detailPanelToggle: 'Udvid/kollaps detaljepanel',
136
136
  expandDetailPanel: 'Udvid',
@@ -138,7 +138,7 @@ const daDKGrid = {
138
138
  // Row reordering text
139
139
  rowReorderingHeaderName: 'Omarrangering af rækker',
140
140
  // Aggregation
141
- aggregationMenuItemHeader: 'Aggregation',
141
+ aggregationMenuItemHeader: 'Aggregering',
142
142
  aggregationFunctionLabelSum: 'sum',
143
143
  aggregationFunctionLabelAvg: 'gns',
144
144
  aggregationFunctionLabelMin: 'min',
@@ -59,13 +59,12 @@ const heILGrid = {
59
59
  filterOperatorIsEmpty: 'ריק',
60
60
  filterOperatorIsNotEmpty: 'אינו ריק',
61
61
  filterOperatorIsAnyOf: 'הוא אחד מ-',
62
- // 'filterOperator=': '=',
63
- // 'filterOperator!=': '!=',
64
- // 'filterOperator>': '>',
65
- // 'filterOperator>=': '>=',
66
- // 'filterOperator<': '<',
67
- // 'filterOperator<=': '<=',
68
-
62
+ 'filterOperator=': '=',
63
+ 'filterOperator!=': '!=',
64
+ 'filterOperator>': '>',
65
+ 'filterOperator>=': '>=',
66
+ 'filterOperator<': '<',
67
+ 'filterOperator<=': '<=',
69
68
  // Header filter operators text
70
69
  headerFilterOperatorContains: 'מכיל',
71
70
  headerFilterOperatorEquals: 'שווה',
@@ -133,7 +132,7 @@ const heILGrid = {
133
132
  groupColumn: name => `קבץ לפי ${name}`,
134
133
  unGroupColumn: name => `הפסק לקבץ לפי ${name}`,
135
134
  // Master/detail
136
- // detailPanelToggle: 'Detail panel toggle',
135
+ detailPanelToggle: 'הצג/הסתר פרטים',
137
136
  expandDetailPanel: 'הרחב',
138
137
  collapseDetailPanel: 'כווץ',
139
138
  // Row reordering text
@@ -313,7 +313,7 @@ DataGridRaw.propTypes = {
313
313
  loading: _propTypes.default.bool,
314
314
  /**
315
315
  * Set the locale text of the Data Grid.
316
- * 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.
316
+ * 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.
317
317
  */
318
318
  localeText: _propTypes.default.object,
319
319
  /**
@@ -63,7 +63,7 @@ const useDataGridComponent = (inputApiRef, props) => {
63
63
  (0, _useGridRowSelection.useGridRowSelection)(apiRef, props);
64
64
  (0, _useGridColumns.useGridColumns)(apiRef, props);
65
65
  (0, _useGridRows.useGridRows)(apiRef, props);
66
- (0, _useGridParamsApi.useGridParamsApi)(apiRef, props);
66
+ (0, _useGridParamsApi.useGridParamsApi)(apiRef);
67
67
  (0, _useGridColumnSpanning.useGridColumnSpanning)(apiRef);
68
68
  (0, _useGridColumnGrouping.useGridColumnGrouping)(apiRef, props);
69
69
  (0, _useGridEditing.useGridEditing)(apiRef, props);
@@ -83,7 +83,9 @@ const DATA_GRID_PROPS_DEFAULT_VALUES = exports.DATA_GRID_PROPS_DEFAULT_VALUES =
83
83
  };
84
84
  const defaultSlots = _defaultGridSlotsComponents.DATA_GRID_DEFAULT_SLOTS_COMPONENTS;
85
85
  const useDataGridProps = inProps => {
86
- const themedProps = (0, _utils.useProps)((0, _styles.useThemeProps)({
86
+ const themedProps = (0, _utils.useProps)(
87
+ // eslint-disable-next-line material-ui/mui-name-matches-component-name
88
+ (0, _styles.useThemeProps)({
87
89
  props: inProps,
88
90
  name: 'MuiDataGrid'
89
91
  }));
@@ -11,12 +11,9 @@ var _GridBooleanCell = require("../components/cell/GridBooleanCell");
11
11
  var _GridEditBooleanCell = require("../components/cell/GridEditBooleanCell");
12
12
  var _gridSortingUtils = require("../hooks/features/sorting/gridSortingUtils");
13
13
  var _gridBooleanOperators = require("./gridBooleanOperators");
14
- function gridBooleanFormatter({
15
- value,
16
- api
17
- }) {
18
- return value ? api.getLocaleText('booleanCellTrueLabel') : api.getLocaleText('booleanCellFalseLabel');
19
- }
14
+ const gridBooleanFormatter = (value, row, column, apiRef) => {
15
+ return value ? apiRef.current.getLocaleText('booleanCellTrueLabel') : apiRef.current.getLocaleText('booleanCellFalseLabel');
16
+ };
20
17
  const stringToBoolean = value => {
21
18
  switch (value.toLowerCase().trim()) {
22
19
  case 'true':
@@ -28,9 +28,10 @@ const GRID_CHECKBOX_SELECTION_COL_DEF = exports.GRID_CHECKBOX_SELECTION_COL_DEF
28
28
  disableReorder: true,
29
29
  disableExport: true,
30
30
  getApplyQuickFilterFn: undefined,
31
- valueGetter: params => {
32
- const selectionLookup = (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(params.api.state, params.api.instanceId);
33
- return selectionLookup[params.id] !== undefined;
31
+ valueGetter: (value, row, column, apiRef) => {
32
+ const selectionLookup = (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef);
33
+ const rowId = apiRef.current.getRowId(row);
34
+ return selectionLookup[rowId] !== undefined;
34
35
  },
35
36
  renderHeader: params => /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridHeaderCheckbox.GridHeaderCheckbox, (0, _extends2.default)({}, params)),
36
37
  renderCell: params => /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridCellCheckboxRenderer.GridCellCheckboxRenderer, (0, _extends2.default)({}, params))
@@ -4,9 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.GRID_DATE_COL_DEF = exports.GRID_DATETIME_COL_DEF = void 0;
8
- exports.gridDateFormatter = gridDateFormatter;
9
- exports.gridDateTimeFormatter = gridDateTimeFormatter;
7
+ exports.gridDateTimeFormatter = exports.gridDateFormatter = exports.GRID_DATE_COL_DEF = exports.GRID_DATETIME_COL_DEF = void 0;
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
9
  var _gridSortingUtils = require("../hooks/features/sorting/gridSortingUtils");
12
10
  var _gridDateOperators = require("./gridDateOperators");
@@ -22,38 +20,34 @@ function throwIfNotDateObject({
22
20
  throw new Error([`MUI X: \`${columnType}\` column type only accepts \`Date\` objects as values.`, 'Use `valueGetter` to transform the value into a `Date` object.', `Row ID: ${rowId}, field: "${field}".`].join('\n'));
23
21
  }
24
22
  }
25
- function gridDateFormatter({
26
- value,
27
- field,
28
- id
29
- }) {
23
+ const gridDateFormatter = (value, row, column, apiRef) => {
30
24
  if (!value) {
31
25
  return '';
32
26
  }
27
+ const rowId = apiRef.current.getRowId(row);
33
28
  throwIfNotDateObject({
34
29
  value,
35
30
  columnType: 'date',
36
- rowId: id,
37
- field
31
+ rowId,
32
+ field: column.field
38
33
  });
39
34
  return value.toLocaleDateString();
40
- }
41
- function gridDateTimeFormatter({
42
- value,
43
- field,
44
- id
45
- }) {
35
+ };
36
+ exports.gridDateFormatter = gridDateFormatter;
37
+ const gridDateTimeFormatter = (value, row, column, apiRef) => {
46
38
  if (!value) {
47
39
  return '';
48
40
  }
41
+ const rowId = apiRef.current.getRowId(row);
49
42
  throwIfNotDateObject({
50
43
  value,
51
44
  columnType: 'dateTime',
52
- rowId: id,
53
- field
45
+ rowId,
46
+ field: column.field
54
47
  });
55
48
  return value.toLocaleString();
56
- }
49
+ };
50
+ exports.gridDateTimeFormatter = gridDateTimeFormatter;
57
51
  const GRID_DATE_COL_DEF = exports.GRID_DATE_COL_DEF = (0, _extends2.default)({}, _gridStringColDef.GRID_STRING_COL_DEF, {
58
52
  type: 'date',
59
53
  sortComparator: _gridSortingUtils.gridDateComparator,
@@ -16,9 +16,7 @@ const GRID_NUMERIC_COL_DEF = exports.GRID_NUMERIC_COL_DEF = (0, _extends2.defaul
16
16
  headerAlign: 'right',
17
17
  sortComparator: _gridSortingUtils.gridNumberComparator,
18
18
  valueParser: value => value === '' ? null : Number(value),
19
- valueFormatter: ({
20
- value
21
- }) => (0, _utils.isNumber)(value) ? value.toLocaleString() : value || '',
19
+ valueFormatter: value => (0, _utils.isNumber)(value) ? value.toLocaleString() : value || '',
22
20
  filterOperators: (0, _gridNumericOperators.getGridNumericOperators)(),
23
21
  getApplyQuickFilterFn: _gridNumericOperators.getGridNumericQuickFilterFn
24
22
  });
@@ -24,20 +24,15 @@ const GRID_SINGLE_SELECT_COL_DEF = exports.GRID_SINGLE_SELECT_COL_DEF = (0, _ext
24
24
  type: 'singleSelect',
25
25
  getOptionLabel: defaultGetOptionLabel,
26
26
  getOptionValue: defaultGetOptionValue,
27
- valueFormatter(params) {
28
- const {
29
- id,
30
- field,
31
- value,
32
- api
33
- } = params;
34
- const colDef = params.api.getColumn(field);
27
+ valueFormatter(value, row, colDef, apiRef) {
28
+ // const { id, field, value, api } = params;
29
+ const rowId = apiRef.current.getRowId(row);
35
30
  if (!(0, _filterPanelUtils.isSingleSelectColDef)(colDef)) {
36
31
  return '';
37
32
  }
38
33
  const valueOptions = (0, _filterPanelUtils.getValueOptions)(colDef, {
39
- id,
40
- row: id ? api.getRow(id) : null
34
+ id: rowId,
35
+ row
41
36
  });
42
37
  if (value == null) {
43
38
  return '';
@@ -54,8 +49,8 @@ const GRID_SINGLE_SELECT_COL_DEF = exports.GRID_SINGLE_SELECT_COL_DEF = (0, _ext
54
49
  renderEditCell: _GridEditSingleSelectCell.renderEditSingleSelectCell,
55
50
  filterOperators: (0, _gridSingleSelectOperators.getGridSingleSelectOperators)(),
56
51
  // @ts-ignore
57
- pastedValueParser: (value, params) => {
58
- const colDef = params.colDef;
52
+ pastedValueParser: (value, row, column) => {
53
+ const colDef = column;
59
54
  const valueOptions = (0, _filterPanelUtils.getValueOptions)(colDef) || [];
60
55
  const getOptionValue = colDef.getOptionValue;
61
56
  const valueOption = valueOptions.find(option => {
@@ -33,13 +33,19 @@ const GridPaginationRoot = (0, _styles.styled)(_TablePagination.default)(({
33
33
  }
34
34
  }
35
35
  }));
36
+
37
+ // A mutable version of a readonly array.
38
+
36
39
  const GridPagination = exports.GridPagination = /*#__PURE__*/React.forwardRef(function GridPagination(props, ref) {
37
40
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
38
41
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
39
42
  const paginationModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginationModelSelector);
40
43
  const visibleTopLevelRowCount = (0, _useGridSelector.useGridSelector)(apiRef, _filter.gridFilteredTopLevelRowCountSelector);
41
44
  const rowCount = React.useMemo(() => rootProps.rowCount ?? visibleTopLevelRowCount ?? 0, [rootProps.rowCount, visibleTopLevelRowCount]);
42
- const lastPage = React.useMemo(() => Math.floor(rowCount / (paginationModel.pageSize || 1)), [rowCount, paginationModel.pageSize]);
45
+ const lastPage = React.useMemo(() => {
46
+ const calculatedValue = Math.ceil(rowCount / (paginationModel.pageSize || 1)) - 1;
47
+ return Math.max(0, calculatedValue);
48
+ }, [rowCount, paginationModel.pageSize]);
43
49
  const handlePageSizeChange = React.useCallback(event => {
44
50
  const pageSize = Number(event.target.value);
45
51
  apiRef.current.setPageSize(pageSize);
@@ -74,7 +80,11 @@ const GridPagination = exports.GridPagination = /*#__PURE__*/React.forwardRef(fu
74
80
  ref: ref,
75
81
  component: "div",
76
82
  count: rowCount,
77
- page: paginationModel.page <= lastPage ? paginationModel.page : lastPage,
83
+ page: paginationModel.page <= lastPage ? paginationModel.page : lastPage
84
+ // TODO: Remove the cast once the type is fixed in Material UI and that the min Material UI version
85
+ // for x-data-grid is past the fix.
86
+ // Note that Material UI will not mutate the array, so this is safe.
87
+ ,
78
88
  rowsPerPageOptions: pageSizeOptions,
79
89
  rowsPerPage: paginationModel.pageSize,
80
90
  onPageChange: handlePageChange,
@@ -45,9 +45,7 @@ const useUtilityClasses = ownerState => {
45
45
  classes
46
46
  } = ownerState;
47
47
  const slots = {
48
- root: ['row', selected && 'selected', editable && 'row--editable', editing && 'row--editing', isFirstVisible && 'row--firstVisible', isLastVisible && 'row--lastVisible', rowHeight === 'auto' && 'row--dynamicHeight'],
49
- pinnedLeft: ['pinnedLeft'],
50
- pinnedRight: ['pinnedRight']
48
+ root: ['row', selected && 'selected', editable && 'row--editable', editing && 'row--editing', isFirstVisible && 'row--firstVisible', isLastVisible && 'row--lastVisible', rowHeight === 'auto' && 'row--dynamicHeight']
51
49
  };
52
50
  return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
53
51
  };
@@ -281,7 +279,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
281
279
  width: width,
282
280
  contentWidth: contentWidth,
283
281
  field: column.field,
284
- align: column.align
282
+ align: column.align ?? 'left'
285
283
  }, column.field);
286
284
  }
287
285
  const {
@@ -369,7 +367,10 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
369
367
  "aria-selected": selected,
370
368
  style: style
371
369
  }, eventHandlers, other, {
372
- children: [leftCells, cells, emptyCellWidth > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(EmptyCell, {
370
+ children: [leftCells, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
371
+ className: _gridClasses.gridClasses.cellOffsetLeft,
372
+ role: "presentation"
373
+ }), cells, emptyCellWidth > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(EmptyCell, {
373
374
  width: emptyCellWidth
374
375
  }), rightCells.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
375
376
  role: "presentation",
@@ -30,9 +30,6 @@ const Style = (0, _styles.styled)('div')({
30
30
  [`&.${classes.pinnedRight}:not(.${classes.header})`]: {
31
31
  position: 'sticky',
32
32
  right: 0
33
- },
34
- [`&:not(.${classes.header}):not(.${classes.pinnedRight})`]: {
35
- transform: 'translate3d(var(--DataGrid-offsetLeft), 0, 0)'
36
33
  }
37
34
  });
38
35
  function GridScrollbarFillerCell({
@@ -16,5 +16,5 @@ function GridFooterPlaceholder() {
16
16
  if (rootProps.hideFooter) {
17
17
  return null;
18
18
  }
19
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.footer, (0, _extends2.default)({}, rootProps.slotProps?.footer));
19
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.footer, (0, _extends2.default)({}, rootProps.slotProps?.footer /* FIXME: typing error */));
20
20
  }
@@ -145,7 +145,7 @@ function GridActionsCell(props) {
145
145
  if (event.key === 'Tab') {
146
146
  event.preventDefault();
147
147
  }
148
- if (['Tab', 'Enter', 'Escape'].includes(event.key)) {
148
+ if (['Tab', 'Escape'].includes(event.key)) {
149
149
  hideMenu();
150
150
  }
151
151
  };
@@ -182,7 +182,6 @@ function GridActionsCell(props) {
182
182
  target: buttonRef.current,
183
183
  position: position,
184
184
  onClose: hideMenu,
185
- onClick: hideMenu,
186
185
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuList.default, {
187
186
  id: menuId,
188
187
  className: _gridClasses.gridClasses.menuList,
@@ -191,7 +190,8 @@ function GridActionsCell(props) {
191
190
  variant: "menu",
192
191
  autoFocusItem: true,
193
192
  children: menuButtons.map((button, index) => /*#__PURE__*/React.cloneElement(button, {
194
- key: index
193
+ key: index,
194
+ closeMenu: hideMenu
195
195
  }))
196
196
  })
197
197
  })]