@mui/x-data-grid 5.11.1 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/CHANGELOG.md +95 -18
  2. package/DataGrid/DataGrid.js +26 -1
  3. package/README.md +2 -2
  4. package/components/GridRow.d.ts +1 -1
  5. package/components/GridRow.js +51 -12
  6. package/components/cell/GridActionsCellItem.d.ts +1 -1
  7. package/components/cell/GridCell.d.ts +2 -1
  8. package/components/cell/GridCell.js +12 -7
  9. package/components/columnHeaders/GridColumnHeaderItem.js +4 -3
  10. package/components/containers/GridRootStyles.js +4 -2
  11. package/components/menu/GridMenu.js +9 -2
  12. package/components/panel/GridColumnsPanel.js +10 -2
  13. package/components/panel/GridPanelWrapper.d.ts +1 -1
  14. package/components/panel/GridPanelWrapper.js +3 -3
  15. package/components/panel/filterPanel/GridFilterForm.d.ts +61 -4
  16. package/components/panel/filterPanel/GridFilterForm.js +88 -8
  17. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
  18. package/components/panel/filterPanel/GridFilterPanel.d.ts +8 -5
  19. package/components/panel/filterPanel/GridFilterPanel.js +24 -6
  20. package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
  21. package/constants/gridClasses.d.ts +4 -0
  22. package/constants/gridClasses.js +1 -1
  23. package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -0
  24. package/hooks/features/columns/useGridColumns.js +12 -14
  25. package/hooks/features/editRows/useGridCellEditing.new.js +11 -4
  26. package/hooks/features/editRows/useGridRowEditing.new.js +10 -4
  27. package/hooks/features/events/useGridEvents.d.ts +1 -1
  28. package/hooks/features/events/useGridEvents.js +2 -0
  29. package/hooks/features/filter/gridFilterUtils.d.ts +9 -1
  30. package/hooks/features/filter/gridFilterUtils.js +1 -2
  31. package/hooks/features/filter/useGridFilter.js +5 -5
  32. package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
  33. package/hooks/features/rows/useGridRowsMeta.js +107 -43
  34. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -0
  35. package/hooks/features/virtualization/useGridVirtualScroller.js +27 -7
  36. package/index.js +1 -1
  37. package/internals/index.d.ts +1 -0
  38. package/legacy/DataGrid/DataGrid.js +26 -1
  39. package/legacy/components/GridRow.js +56 -12
  40. package/legacy/components/cell/GridCell.js +12 -7
  41. package/legacy/components/columnHeaders/GridColumnHeaderItem.js +6 -3
  42. package/legacy/components/containers/GridRootStyles.js +3 -2
  43. package/legacy/components/menu/GridMenu.js +9 -2
  44. package/legacy/components/panel/GridColumnsPanel.js +12 -2
  45. package/legacy/components/panel/GridPanelWrapper.js +3 -3
  46. package/legacy/components/panel/filterPanel/GridFilterForm.js +89 -8
  47. package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
  48. package/legacy/components/panel/filterPanel/GridFilterPanel.js +25 -6
  49. package/legacy/constants/gridClasses.js +1 -1
  50. package/legacy/hooks/features/columns/useGridColumns.js +12 -14
  51. package/legacy/hooks/features/editRows/useGridCellEditing.new.js +14 -7
  52. package/legacy/hooks/features/editRows/useGridRowEditing.new.js +10 -4
  53. package/legacy/hooks/features/events/useGridEvents.js +2 -0
  54. package/legacy/hooks/features/filter/gridFilterUtils.js +1 -2
  55. package/legacy/hooks/features/filter/useGridFilter.js +5 -5
  56. package/legacy/hooks/features/rows/useGridRowsMeta.js +104 -41
  57. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +46 -22
  58. package/legacy/index.js +1 -1
  59. package/legacy/locales/heIL.js +9 -9
  60. package/legacy/locales/nbNO.js +127 -0
  61. package/legacy/locales/trTR.js +7 -7
  62. package/legacy/models/events/gridEvents.js +2 -0
  63. package/legacy/models/gridApiCaches.js +1 -0
  64. package/legacy/models/params/gridMenuParams.js +1 -0
  65. package/legacy/models/params/index.js +2 -1
  66. package/locales/heIL.js +9 -9
  67. package/locales/nbNO.d.ts +2 -0
  68. package/locales/nbNO.js +115 -0
  69. package/locales/trTR.js +7 -7
  70. package/models/api/gridCoreApi.d.ts +2 -6
  71. package/models/api/gridRowsMetaApi.d.ts +24 -0
  72. package/models/colDef/gridColDef.d.ts +3 -3
  73. package/models/events/gridEventLookup.d.ts +13 -1
  74. package/models/events/gridEvents.d.ts +3 -1
  75. package/models/events/gridEvents.js +2 -0
  76. package/models/gridApiCaches.d.ts +6 -0
  77. package/models/gridApiCaches.js +1 -0
  78. package/models/params/gridMenuParams.d.ts +7 -0
  79. package/models/params/gridMenuParams.js +1 -0
  80. package/models/params/gridRowParams.d.ts +1 -1
  81. package/models/params/index.d.ts +1 -0
  82. package/models/params/index.js +2 -1
  83. package/models/props/DataGridProps.d.ts +23 -1
  84. package/modern/DataGrid/DataGrid.js +26 -1
  85. package/modern/components/GridRow.js +51 -12
  86. package/modern/components/cell/GridCell.js +12 -7
  87. package/modern/components/columnHeaders/GridColumnHeaderItem.js +4 -3
  88. package/modern/components/containers/GridRootStyles.js +4 -2
  89. package/modern/components/menu/GridMenu.js +9 -2
  90. package/modern/components/panel/GridColumnsPanel.js +10 -2
  91. package/modern/components/panel/GridPanelWrapper.js +3 -3
  92. package/modern/components/panel/filterPanel/GridFilterForm.js +88 -8
  93. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
  94. package/modern/components/panel/filterPanel/GridFilterPanel.js +24 -6
  95. package/modern/constants/gridClasses.js +1 -1
  96. package/modern/hooks/features/columns/useGridColumns.js +11 -13
  97. package/modern/hooks/features/editRows/useGridCellEditing.new.js +10 -3
  98. package/modern/hooks/features/editRows/useGridRowEditing.new.js +9 -3
  99. package/modern/hooks/features/events/useGridEvents.js +2 -0
  100. package/modern/hooks/features/filter/gridFilterUtils.js +1 -2
  101. package/modern/hooks/features/filter/useGridFilter.js +5 -5
  102. package/modern/hooks/features/rows/useGridRowsMeta.js +105 -37
  103. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +27 -7
  104. package/modern/index.js +1 -1
  105. package/modern/locales/heIL.js +9 -9
  106. package/modern/locales/nbNO.js +115 -0
  107. package/modern/locales/trTR.js +7 -7
  108. package/modern/models/events/gridEvents.js +2 -0
  109. package/modern/models/gridApiCaches.js +1 -0
  110. package/modern/models/params/gridMenuParams.js +1 -0
  111. package/modern/models/params/index.js +2 -1
  112. package/node/DataGrid/DataGrid.js +26 -1
  113. package/node/components/GridRow.js +53 -12
  114. package/node/components/cell/GridCell.js +12 -7
  115. package/node/components/columnHeaders/GridColumnHeaderItem.js +4 -3
  116. package/node/components/containers/GridRootStyles.js +4 -2
  117. package/node/components/menu/GridMenu.js +10 -2
  118. package/node/components/panel/GridColumnsPanel.js +10 -2
  119. package/node/components/panel/GridPanelWrapper.js +5 -3
  120. package/node/components/panel/filterPanel/GridFilterForm.js +91 -9
  121. package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
  122. package/node/components/panel/filterPanel/GridFilterPanel.js +26 -6
  123. package/node/constants/gridClasses.js +1 -1
  124. package/node/hooks/features/columns/useGridColumns.js +12 -14
  125. package/node/hooks/features/editRows/useGridCellEditing.new.js +11 -4
  126. package/node/hooks/features/editRows/useGridRowEditing.new.js +10 -4
  127. package/node/hooks/features/events/useGridEvents.js +2 -0
  128. package/node/hooks/features/filter/gridFilterUtils.js +2 -1
  129. package/node/hooks/features/filter/useGridFilter.js +4 -4
  130. package/node/hooks/features/rows/useGridRowsMeta.js +107 -43
  131. package/node/hooks/features/virtualization/useGridVirtualScroller.js +27 -7
  132. package/node/index.js +1 -1
  133. package/node/locales/heIL.js +9 -9
  134. package/node/locales/nbNO.js +125 -0
  135. package/node/locales/trTR.js +7 -7
  136. package/node/models/events/gridEvents.js +2 -0
  137. package/node/models/gridApiCaches.js +5 -0
  138. package/node/models/params/gridMenuParams.js +5 -0
  139. package/node/models/params/index.js +13 -0
  140. package/package.json +4 -4
@@ -0,0 +1,115 @@
1
+ import { nbNO as nbNOCore } from '@mui/material/locale';
2
+ import { getGridLocalization } from '../utils/getGridLocalization';
3
+ const nbNOGrid = {
4
+ // Root
5
+ noRowsLabel: 'Ingen rader',
6
+ noResultsOverlayLabel: 'Fant ingen resultat.',
7
+ errorOverlayDefaultLabel: 'Det skjedde en feil.',
8
+ // Density selector toolbar button text
9
+ toolbarDensity: 'Tetthet',
10
+ toolbarDensityLabel: 'Tetthet',
11
+ toolbarDensityCompact: 'Kompakt',
12
+ toolbarDensityStandard: 'Standard',
13
+ toolbarDensityComfortable: 'Komfortabelt',
14
+ // Columns selector toolbar button text
15
+ toolbarColumns: 'Kolonner',
16
+ toolbarColumnsLabel: 'Velg kolonner',
17
+ // Filters toolbar button text
18
+ toolbarFilters: 'Filter',
19
+ toolbarFiltersLabel: 'Vis filter',
20
+ toolbarFiltersTooltipHide: 'Skjul fitler',
21
+ toolbarFiltersTooltipShow: 'Vis filter',
22
+ toolbarFiltersTooltipActive: count => count !== 1 ? `${count} aktive filter` : `${count} aktivt filter`,
23
+ // Quick filter toolbar field
24
+ toolbarQuickFilterPlaceholder: 'Søk...',
25
+ toolbarQuickFilterLabel: 'Søk',
26
+ toolbarQuickFilterDeleteIconLabel: 'Slett',
27
+ // Export selector toolbar button text
28
+ toolbarExport: 'Eksporter',
29
+ toolbarExportLabel: 'Eksporter',
30
+ toolbarExportCSV: 'Last ned som CSV',
31
+ toolbarExportPrint: 'Skriv ut',
32
+ toolbarExportExcel: 'Last ned som Excel',
33
+ // Columns panel text
34
+ columnsPanelTextFieldLabel: 'Finn kolonne',
35
+ columnsPanelTextFieldPlaceholder: 'Kolonne tittel',
36
+ columnsPanelDragIconLabel: 'Reorganiser kolonne',
37
+ columnsPanelShowAllButton: 'Vis alle',
38
+ columnsPanelHideAllButton: 'Skjul alle',
39
+ // Filter panel text
40
+ filterPanelAddFilter: 'Legg til filter',
41
+ filterPanelDeleteIconLabel: 'Slett',
42
+ filterPanelLinkOperator: 'Logisk operator',
43
+ filterPanelOperators: 'Operatører',
44
+ // TODO v6: rename to filterPanelOperator
45
+ filterPanelOperatorAnd: 'Og',
46
+ filterPanelOperatorOr: 'Eller',
47
+ filterPanelColumns: 'Kolonner',
48
+ filterPanelInputLabel: 'Verdi',
49
+ filterPanelInputPlaceholder: 'Filter verdi',
50
+ // Filter operators text
51
+ filterOperatorContains: 'inneholder',
52
+ filterOperatorEquals: 'er lik',
53
+ filterOperatorStartsWith: 'starter med',
54
+ filterOperatorEndsWith: 'slutter med',
55
+ filterOperatorIs: 'er',
56
+ filterOperatorNot: 'er ikke',
57
+ filterOperatorAfter: 'er etter',
58
+ filterOperatorOnOrAfter: 'er på eller etter',
59
+ filterOperatorBefore: 'er før',
60
+ filterOperatorOnOrBefore: 'er på eller før',
61
+ filterOperatorIsEmpty: 'er tom',
62
+ filterOperatorIsNotEmpty: 'er ikke tom',
63
+ filterOperatorIsAnyOf: 'er en av',
64
+ // Filter values text
65
+ filterValueAny: 'noen',
66
+ filterValueTrue: 'sant',
67
+ filterValueFalse: 'usant',
68
+ // Column menu text
69
+ columnMenuLabel: 'Meny',
70
+ columnMenuShowColumns: 'Vis kolonner',
71
+ columnMenuFilter: 'Filter',
72
+ columnMenuHideColumn: 'Skjul',
73
+ columnMenuUnsort: 'Usorter',
74
+ columnMenuSortAsc: 'Sorter ØKENDE',
75
+ columnMenuSortDesc: 'Sorter SYNKENDE',
76
+ // Column header text
77
+ columnHeaderFiltersTooltipActive: count => count !== 1 ? `${count} aktive filter` : `${count} aktivt filter`,
78
+ columnHeaderFiltersLabel: 'Vis filter',
79
+ columnHeaderSortIconLabel: 'Sorter',
80
+ // Rows selected footer text
81
+ footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} rader valgt` : `${count.toLocaleString()} rad valgt`,
82
+ // Total row amount footer text
83
+ footerTotalRows: 'Totalt antall rader:',
84
+ // Total visible row amount footer text
85
+ footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} av ${totalCount.toLocaleString()}`,
86
+ // Checkbox selection text
87
+ checkboxSelectionHeaderName: 'Avmerkingsboks valgt',
88
+ checkboxSelectionSelectAllRows: 'Velg alle rader',
89
+ checkboxSelectionUnselectAllRows: 'Velg bort alle rader',
90
+ checkboxSelectionSelectRow: 'Velg rad',
91
+ checkboxSelectionUnselectRow: 'Velg bort rad',
92
+ // Boolean cell text
93
+ booleanCellTrueLabel: 'sant',
94
+ booleanCellFalseLabel: 'usant',
95
+ // Actions cell more text
96
+ actionsCellMore: 'mer',
97
+ // Column pinning text
98
+ pinToLeft: 'Fest til venstre',
99
+ pinToRight: 'Fest til høyre',
100
+ unpin: 'Løsne',
101
+ // Tree Data
102
+ treeDataGroupingHeaderName: 'Grupper',
103
+ treeDataExpand: 'se barn',
104
+ treeDataCollapse: 'skjul barn',
105
+ // Grouping columns
106
+ groupingColumnHeaderName: 'Grupper',
107
+ groupColumn: name => `Grupper på ${name}`,
108
+ unGroupColumn: name => `Stopp å grupper på ${name}`,
109
+ // Master/detail
110
+ expandDetailPanel: 'Utvid',
111
+ collapseDetailPanel: 'Kollaps',
112
+ // Row reordering text
113
+ rowReorderingHeaderName: 'Rad reorganisering'
114
+ };
115
+ export const nbNO = getGridLocalization(nbNOGrid, nbNOCore);
package/locales/trTR.js CHANGED
@@ -21,15 +21,15 @@ const trTRGrid = {
21
21
  toolbarFiltersTooltipShow: 'Filtreleri göster',
22
22
  toolbarFiltersTooltipActive: count => `${count} aktif filtre`,
23
23
  // Quick filter toolbar field
24
- // toolbarQuickFilterPlaceholder: 'Search...',
25
- // toolbarQuickFilterLabel: 'Search',
26
- // toolbarQuickFilterDeleteIconLabel: 'Clear',
24
+ toolbarQuickFilterPlaceholder: 'Ara...',
25
+ toolbarQuickFilterLabel: 'Ara',
26
+ toolbarQuickFilterDeleteIconLabel: 'Temizle',
27
27
  // Export selector toolbar button text
28
28
  toolbarExport: 'Dışa aktar',
29
29
  toolbarExportLabel: 'Dışa aktar',
30
30
  toolbarExportCSV: 'CSV olarak aktar',
31
31
  toolbarExportPrint: 'Yazdır',
32
- // toolbarExportExcel: 'Download as Excel',
32
+ toolbarExportExcel: 'Excel olarak aktar',
33
33
  // Columns panel text
34
34
  columnsPanelTextFieldLabel: 'Sütun ara',
35
35
  columnsPanelTextFieldPlaceholder: 'Sütun adı',
@@ -62,9 +62,9 @@ const trTRGrid = {
62
62
  filterOperatorIsNotEmpty: 'dolu',
63
63
  filterOperatorIsAnyOf: 'herhangi biri',
64
64
  // Filter values text
65
- // filterValueAny: 'any',
66
- // filterValueTrue: 'true',
67
- // filterValueFalse: 'false',
65
+ filterValueAny: 'herhangi',
66
+ filterValueTrue: 'doğru',
67
+ filterValueFalse: 'yanlış',
68
68
  // Column menu text
69
69
  columnMenuLabel: 'Menü',
70
70
  columnMenuShowColumns: 'Sütunları göster',
@@ -1,10 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { GridEventPublisher, GridEventListener, GridEventsStr } from '../events';
3
3
  import { EventManager, EventListenerOptions } from '../../utils/EventManager';
4
- import { GridRowsInternalCache } from '../../hooks/features/rows/gridRowsState';
5
- interface Caches {
6
- rows: GridRowsInternalCache;
7
- }
4
+ import { GridApiCaches } from '../gridApiCaches';
8
5
  /**
9
6
  * The core API interface that is available in the grid `apiRef`.
10
7
  */
@@ -53,7 +50,7 @@ export interface GridCoreApi {
53
50
  * The caches used by hooks and state initializers.
54
51
  * @ignore - do not document.
55
52
  */
56
- unstable_caches: Caches;
53
+ unstable_caches: GridApiCaches;
57
54
  /**
58
55
  * Registers a handler for an event.
59
56
  * @param {string} event The name of the event.
@@ -80,4 +77,3 @@ export interface GridCoreApi {
80
77
  */
81
78
  instanceId: number;
82
79
  }
83
- export {};
@@ -24,4 +24,28 @@ export interface GridRowsMetaApi {
24
24
  * @ignore - do not document.
25
25
  */
26
26
  unstable_setRowHeight: (id: GridRowId, height: number) => void;
27
+ /**
28
+ * Stores the row height measurement and triggers an hydration, if needed.
29
+ * @param {GridRowId} id The id of the row.
30
+ * @param {number} height The new height.
31
+ * @ignore - do not document.
32
+ */
33
+ unstable_storeRowHeightMeasurement: (id: GridRowId, height: number) => void;
34
+ /**
35
+ * Determines if the height of a row is "auto".
36
+ * @ignore - do not document.
37
+ */
38
+ unstable_rowHasAutoHeight: (id: GridRowId) => boolean;
39
+ /**
40
+ * Returns the index of the last row measured.
41
+ * The value considers only the rows reachable by scroll, e.g. first row has index=0 in all pages.
42
+ * @ignore - do not document.
43
+ */
44
+ unstable_getLastMeasuredRowIndex: () => number;
45
+ /**
46
+ * Updates the index of the last row measured.
47
+ * @param {number} index The row index.
48
+ * @ignore - do not document.
49
+ */
50
+ unstable_setLastMeasuredRowIndex: (index: number) => void;
27
51
  }
@@ -233,7 +233,7 @@ export interface GridColDef<R extends GridValidRowModel = any, V = any, F = V> {
233
233
  */
234
234
  colSpan?: number | ((params: GridCellParams<V, R, F>) => number | undefined);
235
235
  }
236
- export interface GridActionsColDef extends GridColDef {
236
+ export interface GridActionsColDef<R extends GridValidRowModel = any, V = any, F = V> extends GridColDef<R, V, F> {
237
237
  /**
238
238
  * Type allows to merge this object with a default definition [[GridColDef]].
239
239
  * @default 'actions'
@@ -244,9 +244,9 @@ export interface GridActionsColDef extends GridColDef {
244
244
  * @param {GridRowParams} params The params for each row.
245
245
  * @returns {React.ReactElement<GridActionsCellItemProps>[]} An array of [[GridActionsCell]] elements.
246
246
  */
247
- getActions: (params: GridRowParams) => React.ReactElement<GridActionsCellItemProps>[];
247
+ getActions: (params: GridRowParams<R>) => React.ReactElement<GridActionsCellItemProps>[];
248
248
  }
249
- export declare type GridEnrichedColDef<R extends GridValidRowModel = any, V = any, F = V> = GridColDef<R, V, F> | GridActionsColDef;
249
+ export declare type GridEnrichedColDef<R extends GridValidRowModel = any, V = any, F = V> = GridColDef<R, V, F> | GridActionsColDef<R, V, F>;
250
250
  export declare type GridColumns<R extends GridValidRowModel = any> = GridEnrichedColDef<R>[];
251
251
  export declare type GridColTypeDef<V = any, F = V> = Omit<GridColDef<V, any, F>, 'field'> & {
252
252
  extendType?: GridNativeColTypes;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { GridCellEditCommitParams, GridColumnHeaderParams, GridColumnOrderChangeParams, GridColumnResizeParams, GridColumnVisibilityChangeParams, GridEditCellPropsParams, GridHeaderSelectionCheckboxParams, GridPreferencePanelParams, GridRowParams, GridRowSelectionCheckboxParams, GridScrollParams } from '../params';
2
+ import type { GridCellEditCommitParams, GridColumnHeaderParams, GridColumnOrderChangeParams, GridColumnResizeParams, GridColumnVisibilityChangeParams, GridEditCellPropsParams, GridHeaderSelectionCheckboxParams, GridMenuParams, GridPreferencePanelParams, GridRowParams, GridRowSelectionCheckboxParams, GridScrollParams } from '../params';
3
3
  import { GridCellEditStartParams, GridCellEditStopParams } from '../params/gridEditCellParams';
4
4
  import { GridCellParams } from '../params/gridCellParams';
5
5
  import type { GridFilterModel } from '../gridFilterModel';
@@ -552,4 +552,16 @@ export interface GridEventLookup extends GridRowEventLookup, GridColumnHeaderEve
552
552
  preferencePanelOpen: {
553
553
  params: GridPreferencePanelParams;
554
554
  };
555
+ /**
556
+ * Fired when the menu is opened.
557
+ */
558
+ menuOpen: {
559
+ params: GridMenuParams;
560
+ };
561
+ /**
562
+ * Fired when the grid menu is closed.
563
+ */
564
+ menuClose: {
565
+ params: GridMenuParams;
566
+ };
555
567
  }
@@ -80,7 +80,9 @@ declare enum GridEvents {
80
80
  virtualScrollerWheel = "virtualScrollerWheel",
81
81
  virtualScrollerTouchMove = "virtualScrollerTouchMove",
82
82
  preferencePanelClose = "preferencePanelClose",
83
- preferencePanelOpen = "preferencePanelOpen"
83
+ preferencePanelOpen = "preferencePanelOpen",
84
+ menuOpen = "menuOpen",
85
+ menuClose = "menuClose"
84
86
  }
85
87
  export declare type GridEventsStr = keyof GridEventLookup;
86
88
  export { GridEvents };
@@ -82,6 +82,8 @@ var GridEvents;
82
82
  GridEvents["virtualScrollerTouchMove"] = "virtualScrollerTouchMove";
83
83
  GridEvents["preferencePanelClose"] = "preferencePanelClose";
84
84
  GridEvents["preferencePanelOpen"] = "preferencePanelOpen";
85
+ GridEvents["menuOpen"] = "menuOpen";
86
+ GridEvents["menuClose"] = "menuClose";
85
87
  })(GridEvents || (GridEvents = {}));
86
88
 
87
89
  export { GridEvents };
@@ -0,0 +1,6 @@
1
+ import { GridRowsInternalCache } from '../hooks/features/rows/gridRowsState';
2
+ import { GridColumnsInternalCache } from '../hooks/features/columns/gridColumnsInterfaces';
3
+ export interface GridApiCaches {
4
+ rows: GridRowsInternalCache;
5
+ columns: GridColumnsInternalCache;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export interface GridMenuParams {
3
+ /**
4
+ * The element that opens the menu.
5
+ */
6
+ target: React.ReactNode;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -57,7 +57,7 @@ export interface GridRowHeightParams extends GridRowEntry {
57
57
  /**
58
58
  * The getRowHeight return value.
59
59
  */
60
- export declare type GridRowHeightReturnValue = number | null | undefined;
60
+ export declare type GridRowHeightReturnValue = number | null | undefined | 'auto';
61
61
  declare enum GridRowEditStartReasons {
62
62
  enterKeyDown = "enterKeyDown",
63
63
  cellDoubleClick = "cellDoubleClick",
@@ -11,3 +11,4 @@ export * from './gridValueOptionsParams';
11
11
  export * from './gridCellParams';
12
12
  export * from './gridSortModelParams';
13
13
  export * from './gridPreferencePanelParams';
14
+ export * from './gridMenuParams';
@@ -10,4 +10,5 @@ export * from './gridHeaderSelectionCheckboxParams';
10
10
  export * from './gridValueOptionsParams';
11
11
  export * from './gridCellParams';
12
12
  export * from './gridSortModelParams';
13
- export * from './gridPreferencePanelParams';
13
+ export * from './gridPreferencePanelParams';
14
+ export * from './gridMenuParams';
@@ -346,9 +346,17 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
346
346
  /**
347
347
  * Function that sets the row height per row.
348
348
  * @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
349
- * @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied.
349
+ * @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied. If "auto" then the row height is calculated based on the content.
350
350
  */
351
351
  getRowHeight?: (params: GridRowHeightParams) => GridRowHeightReturnValue;
352
+ /**
353
+ * Function that returns the estimated height for a row.
354
+ * Only works if dynamic row height is used.
355
+ * Once the row height is measured this value is discarded.
356
+ * @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
357
+ * @returns {number | null} The estimated row height value. If `null` or `undefined` then the default row height, based on the density, is applied.
358
+ */
359
+ getEstimatedRowHeight?: (params: GridRowHeightParams) => number | null;
352
360
  /**
353
361
  * Function that allows to specify the spacing between rows.
354
362
  * @param {GridRowSpacingParams} params With all properties from [[GridRowSpacingParams]].
@@ -578,6 +586,20 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
578
586
  * @param {GridCallbackDetails} details Additional details for this callback.
579
587
  */
580
588
  onPreferencePanelOpen?: GridEventListener<'preferencePanelOpen'>;
589
+ /**
590
+ * Callback fired when the menu is opened.
591
+ * @param {GridMenuParams} params With all properties from [[GridMenuParams]].
592
+ * @param {MuiEvent<{}>} event The event object.
593
+ * @param {GridCallbackDetails} details Additional details for this callback.
594
+ */
595
+ onMenuOpen?: GridEventListener<'menuOpen'>;
596
+ /**
597
+ * Callback fired when the menu is closed.
598
+ * @param {GridMenuParams} params With all properties from [[GridMenuParams]].
599
+ * @param {MuiEvent<{}>} event The event object.
600
+ * @param {GridCallbackDetails} details Additional details for this callback.
601
+ */
602
+ onMenuClose?: GridEventListener<'menuClose'>;
581
603
  /**
582
604
  * Set the edit rows model of the grid.
583
605
  */
@@ -229,6 +229,15 @@ DataGridRaw.propTypes = {
229
229
  */
230
230
  getDetailPanelContent: PropTypes.func,
231
231
 
232
+ /**
233
+ * Function that returns the estimated height for a row.
234
+ * Only works if dynamic row height is used.
235
+ * Once the row height is measured this value is discarded.
236
+ * @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
237
+ * @returns {number | null} The estimated row height value. If `null` or `undefined` then the default row height, based on the density, is applied.
238
+ */
239
+ getEstimatedRowHeight: PropTypes.func,
240
+
232
241
  /**
233
242
  * Function that applies CSS classes dynamically on rows.
234
243
  * @param {GridRowClassNameParams} params With all properties from [[GridRowClassNameParams]].
@@ -239,7 +248,7 @@ DataGridRaw.propTypes = {
239
248
  /**
240
249
  * Function that sets the row height per row.
241
250
  * @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
242
- * @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied.
251
+ * @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied. If "auto" then the row height is calculated based on the content.
243
252
  */
244
253
  getRowHeight: PropTypes.func,
245
254
 
@@ -506,6 +515,22 @@ DataGridRaw.propTypes = {
506
515
  */
507
516
  onFilterModelChange: PropTypes.func,
508
517
 
518
+ /**
519
+ * Callback fired when the menu is closed.
520
+ * @param {GridMenuParams} params With all properties from [[GridMenuParams]].
521
+ * @param {MuiEvent<{}>} event The event object.
522
+ * @param {GridCallbackDetails} details Additional details for this callback.
523
+ */
524
+ onMenuClose: PropTypes.func,
525
+
526
+ /**
527
+ * Callback fired when the menu is opened.
528
+ * @param {GridMenuParams} params With all properties from [[GridMenuParams]].
529
+ * @param {MuiEvent<{}>} event The event object.
530
+ * @param {GridCallbackDetails} details Additional details for this callback.
531
+ */
532
+ onMenuOpen: PropTypes.func,
533
+
509
534
  /**
510
535
  * Callback fired when the current page has changed.
511
536
  * @param {number} page Index of the page displayed on the Grid.
@@ -20,6 +20,8 @@ import { findParentElementFromClassName } from '../utils/domUtils';
20
20
  import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../colDef/gridCheckboxSelectionColDef';
21
21
  import { GRID_ACTIONS_COLUMN_TYPE } from '../colDef/gridActionsColDef';
22
22
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../constants/gridDetailPanelToggleField';
23
+ import { gridSortModelSelector } from '../hooks/features/sorting/gridSortingSelector';
24
+ import { gridRowTreeDepthSelector } from '../hooks/features/rows/gridRowsSelector';
23
25
  import { jsx as _jsx } from "react/jsx-runtime";
24
26
  import { jsxs as _jsxs } from "react/jsx-runtime";
25
27
 
@@ -29,25 +31,24 @@ const useUtilityClasses = ownerState => {
29
31
  editing,
30
32
  selected,
31
33
  isLastVisible,
34
+ rowHeight,
32
35
  classes
33
36
  } = ownerState;
34
37
  const slots = {
35
- root: ['row', selected && 'selected', editable && 'row--editable', editing && 'row--editing', isLastVisible && 'row--lastVisible']
38
+ root: ['row', selected && 'selected', editable && 'row--editable', editing && 'row--editing', isLastVisible && 'row--lastVisible', rowHeight === 'auto' && 'row--dynamicHeight']
36
39
  };
37
40
  return composeClasses(slots, getDataGridUtilityClass, classes);
38
41
  };
39
42
 
40
43
  const EmptyCell = ({
41
- width,
42
- height
44
+ width
43
45
  }) => {
44
- if (!width || !height) {
46
+ if (!width) {
45
47
  return null;
46
48
  }
47
49
 
48
50
  const style = {
49
- width,
50
- height
51
+ width
51
52
  };
52
53
  return /*#__PURE__*/_jsx("div", {
53
54
  className: "MuiDataGrid-cell",
@@ -82,9 +83,12 @@ function GridRow(props) {
82
83
  const ariaRowIndex = index + 2; // 1 for the header row and 1 as it's 1-based
83
84
 
84
85
  const apiRef = useGridApiContext();
86
+ const ref = React.useRef(null);
85
87
  const rootProps = useGridRootProps();
86
88
  const currentPage = useGridVisibleRows(apiRef, rootProps);
87
89
  const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
90
+ const sortModel = useGridSelector(apiRef, gridSortModelSelector);
91
+ const treeDepth = useGridSelector(apiRef, gridRowTreeDepthSelector);
88
92
  const {
89
93
  hasScrollX,
90
94
  hasScrollY
@@ -97,9 +101,41 @@ function GridRow(props) {
97
101
  isLastVisible,
98
102
  classes: rootProps.classes,
99
103
  editing: apiRef.current.getRowMode(rowId) === GridRowModes.Edit,
100
- editable: rootProps.editMode === GridEditModes.Row
104
+ editable: rootProps.editMode === GridEditModes.Row,
105
+ rowHeight
101
106
  };
102
107
  const classes = useUtilityClasses(ownerState);
108
+ React.useLayoutEffect(() => {
109
+ if (rowHeight === 'auto' && ref.current && typeof ResizeObserver === 'undefined') {
110
+ // Fallback for IE
111
+ apiRef.current.unstable_storeRowHeightMeasurement(rowId, ref.current.clientHeight);
112
+ }
113
+ });
114
+ React.useLayoutEffect(() => {
115
+ if (currentPage.range) {
116
+ // The index prop is relative to the rows from all pages. As example, the index prop of the
117
+ // first row is 5 if pageSize=5 and page=1. However, the index used by the virtualization
118
+ // doesn't care about pagination and considers the rows from the current page only, so the
119
+ // first row always has index=0. We need to subtract the index of the first row to make it
120
+ // compatible with the index used by the virtualization.
121
+ apiRef.current.unstable_setLastMeasuredRowIndex(index - currentPage.range.firstRowIndex);
122
+ }
123
+
124
+ const rootElement = ref.current;
125
+ const hasFixedHeight = rowHeight !== 'auto';
126
+
127
+ if (!rootElement || hasFixedHeight || typeof ResizeObserver === 'undefined') {
128
+ return undefined;
129
+ }
130
+
131
+ const resizeObserver = new ResizeObserver(entries => {
132
+ const [entry] = entries;
133
+ const height = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
134
+ apiRef.current.unstable_storeRowHeightMeasurement(rowId, height);
135
+ });
136
+ resizeObserver.observe(rootElement);
137
+ return () => resizeObserver.disconnect();
138
+ }, [apiRef, currentPage.range, index, rowHeight, rowId]);
103
139
  const publish = React.useCallback((eventName, propHandler) => event => {
104
140
  // Ignore portal
105
141
  // The target is not an element when triggered by a Select inside the cell
@@ -157,7 +193,8 @@ function GridRow(props) {
157
193
  }, [apiRef, onClick, publish, rowId]);
158
194
 
159
195
  const style = _extends({}, styleProp, {
160
- maxHeight: rowHeight,
196
+ maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
197
+ // max-height doesn't support "auto"
161
198
  minHeight: rowHeight
162
199
  });
163
200
 
@@ -197,6 +234,7 @@ function GridRow(props) {
197
234
  const showRightBorder = !isLastColumn ? rootProps.showCellRightBorder : !removeLastBorderRight && rootProps.disableExtendRowFullWidth;
198
235
  const cellParams = apiRef.current.getCellParams(rowId, column.field);
199
236
  const classNames = [];
237
+ const disableDragEvents = rootProps.disableColumnReorder && column.disableReorder || !rootProps.rowReordering && !!sortModel.length && treeDepth > 1 && Object.keys(editRowsState).length > 0;
200
238
 
201
239
  if (column.cellClassName) {
202
240
  classNames.push(clsx(typeof column.cellClassName === 'function' ? column.cellClassName(cellParams) : column.cellClassName));
@@ -261,7 +299,8 @@ function GridRow(props) {
261
299
  hasFocus: hasFocus,
262
300
  tabIndex: tabIndex,
263
301
  className: clsx(classNames),
264
- colSpan: colSpan
302
+ colSpan: colSpan,
303
+ disableDragEvents: disableDragEvents
265
304
  }, rootProps.componentsProps?.cell, {
266
305
  children: content
267
306
  }), column.field));
@@ -270,6 +309,7 @@ function GridRow(props) {
270
309
 
271
310
  const emptyCellWidth = containerWidth - columnsTotalWidth;
272
311
  return /*#__PURE__*/_jsxs("div", _extends({
312
+ ref: ref,
273
313
  "data-id": rowId,
274
314
  "data-rowindex": index,
275
315
  role: "row",
@@ -283,8 +323,7 @@ function GridRow(props) {
283
323
  onMouseLeave: publish('rowMouseLeave', onMouseLeave)
284
324
  }, other, {
285
325
  children: [cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
286
- width: emptyCellWidth,
287
- height: rowHeight
326
+ width: emptyCellWidth
288
327
  })]
289
328
  }));
290
329
  }
@@ -309,7 +348,7 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
309
348
  lastColumnToRender: PropTypes.number.isRequired,
310
349
  renderedColumns: PropTypes.arrayOf(PropTypes.object).isRequired,
311
350
  row: PropTypes.any.isRequired,
312
- rowHeight: PropTypes.number.isRequired,
351
+ rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
313
352
  rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
314
353
  selected: PropTypes.bool.isRequired,
315
354
  visibleColumns: PropTypes.arrayOf(PropTypes.object).isRequired
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["align", "children", "colIndex", "colDef", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onKeyDown", "onDragEnter", "onDragOver"];
3
+ const _excluded = ["align", "children", "colIndex", "colDef", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onKeyDown", "onDragEnter", "onDragOver"];
4
4
 
5
5
  /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
6
6
  import * as React from 'react';
@@ -65,6 +65,7 @@ function GridCell(props) {
65
65
  className,
66
66
  showRightBorder,
67
67
  colSpan,
68
+ disableDragEvents,
68
69
  onClick,
69
70
  onDoubleClick,
70
71
  onMouseDown,
@@ -117,7 +118,8 @@ function GridCell(props) {
117
118
  minWidth: width,
118
119
  maxWidth: width,
119
120
  minHeight: height,
120
- maxHeight: height
121
+ maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
122
+
121
123
  };
122
124
  React.useLayoutEffect(() => {
123
125
  if (!hasFocus || cellMode === GridCellModes.Edit) {
@@ -182,6 +184,10 @@ function GridCell(props) {
182
184
  return children;
183
185
  };
184
186
 
187
+ const draggableEventHandlers = disableDragEvents ? null : {
188
+ onDragEnter: publish('cellDragEnter', onDragEnter),
189
+ onDragOver: publish('cellDragOver', onDragOver)
190
+ };
185
191
  return /*#__PURE__*/_jsx("div", _extends({
186
192
  ref: cellRef,
187
193
  className: clsx(className, classes.root),
@@ -196,10 +202,8 @@ function GridCell(props) {
196
202
  onDoubleClick: publish('cellDoubleClick', onDoubleClick),
197
203
  onMouseDown: publish('cellMouseDown', onMouseDown),
198
204
  onMouseUp: publishMouseUp('cellMouseUp'),
199
- onKeyDown: publish('cellKeyDown', onKeyDown),
200
- onDragEnter: publish('cellDragEnter', onDragEnter),
201
- onDragOver: publish('cellDragOver', onDragOver)
202
- }, other, {
205
+ onKeyDown: publish('cellKeyDown', onKeyDown)
206
+ }, draggableEventHandlers, other, {
203
207
  onFocus: handleFocus,
204
208
  children: renderChildren()
205
209
  }));
@@ -216,10 +220,11 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
216
220
  className: PropTypes.string,
217
221
  colIndex: PropTypes.number.isRequired,
218
222
  colSpan: PropTypes.number,
223
+ disableDragEvents: PropTypes.bool,
219
224
  field: PropTypes.string.isRequired,
220
225
  formattedValue: PropTypes.any,
221
226
  hasFocus: PropTypes.bool,
222
- height: PropTypes.number.isRequired,
227
+ height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
223
228
  isEditable: PropTypes.bool,
224
229
  onClick: PropTypes.func,
225
230
  onDoubleClick: PropTypes.func,
@@ -68,6 +68,7 @@ function GridColumnHeaderItem(props) {
68
68
  hasScrollX: false,
69
69
  hasScrollY: false
70
70
  };
71
+ const isDraggable = React.useMemo(() => !rootProps.disableColumnReorder && !disableReorder && !column.disableReorder, [rootProps.disableColumnReorder, disableReorder, column.disableReorder]);
71
72
  let headerComponent = null;
72
73
 
73
74
  if (column.renderHeader) {
@@ -98,12 +99,12 @@ function GridColumnHeaderItem(props) {
98
99
  onFocus: publish('columnHeaderFocus'),
99
100
  onBlur: publish('columnHeaderBlur')
100
101
  };
101
- const draggableEventHandlers = {
102
+ const draggableEventHandlers = isDraggable ? {
102
103
  onDragStart: publish('columnHeaderDragStart'),
103
104
  onDragEnter: publish('columnHeaderDragEnter'),
104
105
  onDragOver: publish('columnHeaderDragOver'),
105
106
  onDragEnd: publish('columnHeaderDragEnd')
106
- };
107
+ } : null;
107
108
  const removeLastBorderRight = isLastColumn && hasScrollX && !hasScrollY;
108
109
  const showRightBorder = !isLastColumn ? rootProps.showColumnRightBorder : !removeLastBorderRight && !extendRowFullWidth;
109
110
 
@@ -180,7 +181,7 @@ function GridColumnHeaderItem(props) {
180
181
  }, mouseEventsHandlers, {
181
182
  children: [/*#__PURE__*/_jsxs("div", _extends({
182
183
  className: classes.draggableContainer,
183
- draggable: !rootProps.disableColumnReorder && !disableReorder && !column.disableReorder
184
+ draggable: isDraggable
184
185
  }, draggableEventHandlers, {
185
186
  children: [/*#__PURE__*/_jsxs("div", {
186
187
  className: classes.titleContainer,