@mui/x-data-grid 5.15.1 → 5.16.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.
- package/CHANGELOG.md +142 -0
- package/DataGrid/DataGrid.js +4 -2
- package/DataGrid/useDataGridComponent.js +5 -0
- package/README.md +2 -1
- package/components/DataGridColumnHeaders.js +4 -3
- package/components/ErrorBoundary.d.ts +1 -0
- package/components/GridAutoSizer.js +7 -0
- package/components/GridRow.js +5 -3
- package/components/base/GridBody.js +8 -5
- package/components/base/GridOverlays.js +4 -7
- package/components/cell/GridActionsCellItem.d.ts +2 -2
- package/components/cell/GridEditDateCell.js +1 -1
- package/components/cell/GridEditSingleSelectCell.js +9 -1
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +14 -0
- package/components/columnHeaders/GridColumnGroupHeader.js +122 -0
- package/components/columnHeaders/GridColumnHeaderItem.js +55 -71
- package/components/columnHeaders/GridColumnHeadersInner.js +2 -1
- package/components/columnHeaders/GridGenericColumnHeaderItem.d.ts +32 -0
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +104 -0
- package/components/containers/GridOverlay.js +7 -1
- package/components/containers/GridRoot.js +3 -3
- package/components/containers/GridRootStyles.js +14 -2
- package/components/menu/GridMenu.d.ts +3 -2
- package/components/menu/GridMenu.js +1 -0
- package/components/menu/columnMenu/GridColumnHeaderMenu.d.ts +1 -1
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/GridPanel.js +1 -0
- package/components/panel/filterPanel/GridFilterForm.d.ts +4 -0
- package/components/panel/filterPanel/GridFilterForm.js +5 -0
- package/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterPanel.d.ts +4 -0
- package/components/panel/filterPanel/GridFilterPanel.js +5 -0
- package/components/toolbar/GridToolbarColumnsButton.d.ts +1 -1
- package/components/toolbar/GridToolbarDensitySelector.d.ts +1 -1
- package/components/toolbar/GridToolbarExportContainer.d.ts +1 -1
- package/constants/gridClasses.d.ts +16 -0
- package/constants/gridClasses.js +1 -1
- package/hooks/features/columnGrouping/gridColumnGroupsInterfaces.d.ts +7 -0
- package/hooks/features/columnGrouping/gridColumnGroupsInterfaces.js +1 -0
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +7 -0
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +8 -0
- package/hooks/features/columnGrouping/index.d.ts +2 -0
- package/hooks/features/columnGrouping/index.js +2 -0
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +24 -0
- package/hooks/features/columnGrouping/useGridColumnGrouping.js +153 -0
- package/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.d.ts +4 -0
- package/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +35 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +7 -6
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +204 -9
- package/hooks/features/density/densitySelector.d.ts +2 -0
- package/hooks/features/density/densitySelector.js +3 -1
- package/hooks/features/density/densityState.d.ts +1 -0
- package/hooks/features/density/useGridDensity.d.ts +1 -1
- package/hooks/features/density/useGridDensity.js +45 -9
- package/hooks/features/dimensions/useGridDimensions.js +4 -4
- package/hooks/features/editRows/useGridCellEditing.new.js +15 -7
- package/hooks/features/editRows/useGridRowEditing.new.js +9 -2
- package/hooks/features/export/useGridPrintExport.js +3 -3
- package/hooks/features/filter/gridFilterSelector.d.ts +3 -3
- package/hooks/features/filter/gridFilterState.d.ts +12 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +8 -5
- package/hooks/features/filter/gridFilterUtils.js +74 -43
- package/hooks/features/filter/useGridFilter.js +16 -3
- package/hooks/features/focus/useGridFocus.js +11 -6
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +1 -0
- package/hooks/features/pagination/gridPaginationSelector.d.ts +1 -1
- package/hooks/features/rows/gridRowsSelector.d.ts +1 -1
- package/hooks/features/rows/useGridRows.js +5 -2
- package/hooks/features/selection/gridSelectionSelector.d.ts +1 -1
- package/hooks/features/sorting/gridSortingSelector.d.ts +1 -1
- package/hooks/features/statePersistence/gridStatePersistenceInterface.d.ts +3 -0
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
- package/hooks/utils/useGridNativeEventListener.js +2 -2
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +3 -0
- package/internals/index.js +3 -0
- package/legacy/DataGrid/DataGrid.js +4 -2
- package/legacy/DataGrid/useDataGridComponent.js +5 -0
- package/legacy/components/DataGridColumnHeaders.js +4 -3
- package/legacy/components/GridAutoSizer.js +7 -0
- package/legacy/components/GridRow.js +4 -3
- package/legacy/components/base/GridBody.js +8 -5
- package/legacy/components/base/GridOverlays.js +4 -7
- package/legacy/components/cell/GridEditDateCell.js +1 -1
- package/legacy/components/cell/GridEditSingleSelectCell.js +9 -1
- package/legacy/components/columnHeaders/GridColumnGroupHeader.js +120 -0
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +78 -88
- package/legacy/components/columnHeaders/GridColumnHeadersInner.js +2 -1
- package/legacy/components/columnHeaders/GridGenericColumnHeaderItem.js +112 -0
- package/legacy/components/containers/GridOverlay.js +7 -1
- package/legacy/components/containers/GridRoot.js +3 -3
- package/legacy/components/containers/GridRootStyles.js +11 -2
- package/legacy/components/menu/GridMenu.js +1 -0
- package/legacy/components/panel/GridPanel.js +1 -0
- package/legacy/components/panel/filterPanel/GridFilterForm.js +5 -0
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +5 -0
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/hooks/features/columnGrouping/gridColumnGroupsInterfaces.js +1 -0
- package/legacy/hooks/features/columnGrouping/gridColumnGroupsSelector.js +12 -0
- package/legacy/hooks/features/columnGrouping/index.js +2 -0
- package/legacy/hooks/features/columnGrouping/useGridColumnGrouping.js +151 -0
- package/legacy/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +35 -0
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +213 -12
- package/legacy/hooks/features/density/densitySelector.js +6 -0
- package/legacy/hooks/features/density/useGridDensity.js +44 -6
- package/legacy/hooks/features/dimensions/useGridDimensions.js +4 -4
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +16 -8
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +9 -2
- package/legacy/hooks/features/export/useGridPrintExport.js +3 -3
- package/legacy/hooks/features/filter/gridFilterUtils.js +84 -55
- package/legacy/hooks/features/filter/useGridFilter.js +16 -3
- package/legacy/hooks/features/focus/useGridFocus.js +11 -6
- package/legacy/hooks/features/index.js +1 -0
- package/legacy/hooks/features/rows/useGridRows.js +5 -2
- package/legacy/hooks/utils/useGridNativeEventListener.js +2 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +3 -0
- package/legacy/models/api/gridColumnGroupingApi.js +1 -0
- package/legacy/models/gridColumnGrouping.js +6 -0
- package/legacy/models/index.js +2 -1
- package/models/api/gridApiCommon.d.ts +2 -1
- package/models/api/gridColumnGroupingApi.d.ts +19 -0
- package/models/api/gridColumnGroupingApi.js +1 -0
- package/models/api/gridDensityApi.d.ts +2 -1
- package/models/colDef/gridColDef.d.ts +15 -1
- package/models/gridColumnGrouping.d.ts +67 -0
- package/models/gridColumnGrouping.js +6 -0
- package/models/gridRows.d.ts +5 -5
- package/models/gridStateCommunity.d.ts +2 -1
- package/models/index.d.ts +1 -0
- package/models/index.js +2 -1
- package/models/params/gridMenuParams.d.ts +1 -2
- package/models/props/DataGridProps.d.ts +10 -4
- package/modern/DataGrid/DataGrid.js +4 -2
- package/modern/DataGrid/useDataGridComponent.js +5 -0
- package/modern/components/DataGridColumnHeaders.js +4 -3
- package/modern/components/GridAutoSizer.js +7 -0
- package/modern/components/GridRow.js +5 -3
- package/modern/components/base/GridBody.js +8 -5
- package/modern/components/base/GridOverlays.js +4 -7
- package/modern/components/cell/GridEditDateCell.js +1 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +9 -1
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +120 -0
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +53 -69
- package/modern/components/columnHeaders/GridColumnHeadersInner.js +2 -1
- package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +104 -0
- package/modern/components/containers/GridOverlay.js +7 -1
- package/modern/components/containers/GridRoot.js +3 -3
- package/modern/components/containers/GridRootStyles.js +14 -2
- package/modern/components/menu/GridMenu.js +1 -0
- package/modern/components/panel/GridPanel.js +1 -0
- package/modern/components/panel/filterPanel/GridFilterForm.js +5 -0
- package/modern/components/panel/filterPanel/GridFilterPanel.js +5 -0
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/columnGrouping/gridColumnGroupsInterfaces.js +1 -0
- package/modern/hooks/features/columnGrouping/gridColumnGroupsSelector.js +8 -0
- package/modern/hooks/features/columnGrouping/index.js +2 -0
- package/modern/hooks/features/columnGrouping/useGridColumnGrouping.js +145 -0
- package/modern/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +29 -0
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +186 -9
- package/modern/hooks/features/density/densitySelector.js +3 -1
- package/modern/hooks/features/density/useGridDensity.js +37 -9
- package/modern/hooks/features/dimensions/useGridDimensions.js +4 -4
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +15 -7
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +9 -2
- package/modern/hooks/features/export/useGridPrintExport.js +3 -3
- package/modern/hooks/features/filter/gridFilterUtils.js +73 -42
- package/modern/hooks/features/filter/useGridFilter.js +16 -3
- package/modern/hooks/features/focus/useGridFocus.js +11 -6
- package/modern/hooks/features/index.js +1 -0
- package/modern/hooks/features/rows/useGridRows.js +5 -2
- package/modern/hooks/utils/useGridNativeEventListener.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/index.js +3 -0
- package/modern/models/api/gridColumnGroupingApi.js +1 -0
- package/modern/models/gridColumnGrouping.js +6 -0
- package/modern/models/index.js +2 -1
- package/node/DataGrid/DataGrid.js +4 -2
- package/node/DataGrid/useDataGridComponent.js +7 -0
- package/node/components/DataGridColumnHeaders.js +4 -3
- package/node/components/GridAutoSizer.js +7 -0
- package/node/components/GridRow.js +6 -3
- package/node/components/base/GridBody.js +7 -4
- package/node/components/base/GridOverlays.js +3 -6
- package/node/components/cell/GridEditDateCell.js +1 -1
- package/node/components/cell/GridEditSingleSelectCell.js +9 -1
- package/node/components/columnHeaders/GridColumnGroupHeader.js +141 -0
- package/node/components/columnHeaders/GridColumnHeaderItem.js +53 -72
- package/node/components/columnHeaders/GridColumnHeadersInner.js +2 -1
- package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +126 -0
- package/node/components/containers/GridOverlay.js +7 -1
- package/node/components/containers/GridRoot.js +4 -4
- package/node/components/containers/GridRootStyles.js +14 -2
- package/node/components/menu/GridMenu.js +1 -0
- package/node/components/panel/GridPanel.js +1 -0
- package/node/components/panel/filterPanel/GridFilterForm.js +5 -0
- package/node/components/panel/filterPanel/GridFilterPanel.js +5 -0
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/features/columnGrouping/gridColumnGroupsInterfaces.js +5 -0
- package/node/hooks/features/columnGrouping/gridColumnGroupsSelector.js +18 -0
- package/node/hooks/features/columnGrouping/index.js +18 -0
- package/node/hooks/features/columnGrouping/useGridColumnGrouping.js +182 -0
- package/node/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +55 -0
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +207 -8
- package/node/hooks/features/density/densitySelector.js +6 -2
- package/node/hooks/features/density/useGridDensity.js +48 -9
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/node/hooks/features/editRows/useGridCellEditing.new.js +15 -7
- package/node/hooks/features/editRows/useGridRowEditing.new.js +9 -2
- package/node/hooks/features/export/useGridPrintExport.js +2 -2
- package/node/hooks/features/filter/gridFilterUtils.js +81 -47
- package/node/hooks/features/filter/useGridFilter.js +15 -2
- package/node/hooks/features/focus/useGridFocus.js +11 -6
- package/node/hooks/features/index.js +13 -0
- package/node/hooks/features/rows/useGridRows.js +5 -2
- package/node/hooks/utils/useGridNativeEventListener.js +2 -2
- package/node/index.js +1 -1
- package/node/internals/index.js +30 -0
- package/node/models/api/gridColumnGroupingApi.js +5 -0
- package/node/models/gridColumnGrouping.js +13 -0
- package/node/models/index.js +13 -0
- package/package.json +3 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GridColumnGroupLookup } from '../../hooks/features/columnGrouping/gridColumnGroupsInterfaces';
|
|
2
|
+
import { GridColumnGroup } from '../gridColumnGrouping';
|
|
3
|
+
/**
|
|
4
|
+
* The column grouping API interface that is available in the grid [[apiRef]].
|
|
5
|
+
*/
|
|
6
|
+
export interface GridColumnGroupingApi {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the id of the groups leading to the requested column.
|
|
9
|
+
* The array is ordered by increasing depth (the last element is the direct parent of the column).
|
|
10
|
+
* @param {string} field The field of of the column requested.
|
|
11
|
+
* @returns {string[]} The id of the groups leading to the requested column.
|
|
12
|
+
*/
|
|
13
|
+
unstable_getColumnGroupPath: (field: string) => GridColumnGroup['groupId'][];
|
|
14
|
+
/**
|
|
15
|
+
* Returns the column group lookup.
|
|
16
|
+
* @returns {GridColumnGroupLookup} The column group lookup.
|
|
17
|
+
*/
|
|
18
|
+
unstable_getAllGroupDetails: () => GridColumnGroupLookup;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -14,6 +14,7 @@ export interface GridDensityApi {
|
|
|
14
14
|
* @param {string} density Can be: `"compact"`, `"standard"`, `"comfortable"`.
|
|
15
15
|
* @param {number} headerHeight The new header height.
|
|
16
16
|
* @param {number} rowHeight The new row height.
|
|
17
|
+
* @param {number} maxDepth The depth of maximal depth column header grouping tree.
|
|
17
18
|
*/
|
|
18
|
-
setDensity: (density: GridDensity, headerHeight?: number, rowHeight?: number) => void;
|
|
19
|
+
setDensity: (density: GridDensity, headerHeight?: number, rowHeight?: number, maxDepth?: number) => void;
|
|
19
20
|
}
|
|
@@ -12,6 +12,7 @@ import { GridActionsCellItemProps } from '../../components/cell/GridActionsCellI
|
|
|
12
12
|
import { GridEditCellProps } from '../gridEditRowModel';
|
|
13
13
|
import type { GridValidRowModel } from '../gridRows';
|
|
14
14
|
import { GridApiCommunity } from '../api/gridApiCommunity';
|
|
15
|
+
import type { GridColumnGroup } from '../gridColumnGrouping';
|
|
15
16
|
/**
|
|
16
17
|
* Alignment used in position elements in Cells.
|
|
17
18
|
*/
|
|
@@ -61,7 +62,13 @@ export interface GridColDef<R extends GridValidRowModel = any, V = any, F = V> {
|
|
|
61
62
|
maxWidth?: number;
|
|
62
63
|
/**
|
|
63
64
|
* If `true`, hide the column.
|
|
64
|
-
* @deprecated Use the `
|
|
65
|
+
* @deprecated Use the `initialState` prop to hide columns:
|
|
66
|
+
* ```jsx
|
|
67
|
+
* // Hide `id` column, the other columns will remain visible
|
|
68
|
+
* <DataGrid initialState={{ columns: { columnVisibilityModel: { id: false } } }} />
|
|
69
|
+
* ```
|
|
70
|
+
* Or use `columnVisibilityModel` prop to fully control column visibility.
|
|
71
|
+
* @link https://mui.com/x/react-data-grid/column-visibility/
|
|
65
72
|
* @default false
|
|
66
73
|
*/
|
|
67
74
|
hide?: boolean;
|
|
@@ -257,6 +264,13 @@ export declare type GridStateColDef<R extends GridValidRowModel = any, V = any,
|
|
|
257
264
|
* If `true`, it means that at least one of the dimension's property of this column has been modified since the last time the column prop has changed.
|
|
258
265
|
*/
|
|
259
266
|
hasBeenResized?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* The id of the groups leading to the column.
|
|
269
|
+
* The array is ordered by increasing depth (the last element is the direct parent of the column).
|
|
270
|
+
* If not defined, the column is in no group (equivalent to a path equal to `[]`).
|
|
271
|
+
* This parameter is computed from the `columnGroupingModel` prop.
|
|
272
|
+
*/
|
|
273
|
+
groupPath?: GridColumnGroup['groupId'][];
|
|
260
274
|
};
|
|
261
275
|
/**
|
|
262
276
|
* Meta Info about columns.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { GridColDef } from './colDef';
|
|
3
|
+
export interface GridLeafColumn {
|
|
4
|
+
field: GridColDef['field'];
|
|
5
|
+
}
|
|
6
|
+
export declare type GridColumnNode = GridColumnGroup | GridLeafColumn;
|
|
7
|
+
export declare function isLeaf(node: GridColumnNode): node is GridLeafColumn;
|
|
8
|
+
/**
|
|
9
|
+
* A function used to process headerClassName params.
|
|
10
|
+
*/
|
|
11
|
+
export declare type GridColumnGroupHeaderClassFn = (params: GridColumnGroupHeaderParams) => string;
|
|
12
|
+
/**
|
|
13
|
+
* The union type representing the [[GridColDef]] column header class type.
|
|
14
|
+
*/
|
|
15
|
+
export declare type GridColumnGroupHeaderClassNamePropType = string | GridColumnGroupHeaderClassFn;
|
|
16
|
+
export interface GridColumnGroupHeaderParams extends Pick<GridColumnGroup, 'headerName' | 'description'> {
|
|
17
|
+
/**
|
|
18
|
+
* A unique string identifying the group.
|
|
19
|
+
*/
|
|
20
|
+
groupId: GridColumnGroup['groupId'] | null;
|
|
21
|
+
/**
|
|
22
|
+
* The number parent the group have.
|
|
23
|
+
*/
|
|
24
|
+
depth: number;
|
|
25
|
+
/**
|
|
26
|
+
* The maximal depth among visible columns.
|
|
27
|
+
*/
|
|
28
|
+
maxDepth: number;
|
|
29
|
+
/**
|
|
30
|
+
* The column fields included in the group (including nested ones).
|
|
31
|
+
*/
|
|
32
|
+
fields: string[];
|
|
33
|
+
/**
|
|
34
|
+
* The column index (0 based).
|
|
35
|
+
*/
|
|
36
|
+
colIndex: number;
|
|
37
|
+
/**
|
|
38
|
+
* Indicate if the group is the last one for the given depth.
|
|
39
|
+
*/
|
|
40
|
+
isLastColumn: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface GridColumnGroup extends Pick<GridColDef, 'headerName' | 'description' | 'headerAlign'> {
|
|
43
|
+
/**
|
|
44
|
+
* A unique string identifying the group.
|
|
45
|
+
*/
|
|
46
|
+
groupId: string;
|
|
47
|
+
/**
|
|
48
|
+
* The groups and columns included in this group.
|
|
49
|
+
*/
|
|
50
|
+
children: GridColumnNode[];
|
|
51
|
+
/**
|
|
52
|
+
* If `true`, allows reordering columns outside of the group.
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
freeReordering?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Allows to render a component in the column group header cell.
|
|
58
|
+
* @param {GridColumnGroupHeaderParams} params Object containing parameters for the renderer.
|
|
59
|
+
* @returns {React.ReactNode} The element to be rendered.
|
|
60
|
+
*/
|
|
61
|
+
renderHeaderGroup?: (params: GridColumnGroupHeaderParams) => React.ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* Class name that will be added in the column group header cell.
|
|
64
|
+
*/
|
|
65
|
+
headerClassName?: GridColumnGroupHeaderClassNamePropType;
|
|
66
|
+
}
|
|
67
|
+
export declare type GridColumnGroupingModel = GridColumnGroup[];
|
package/models/gridRows.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { GridKeyValue } from './colDef/gridColDef';
|
|
|
2
2
|
export declare type GridValidRowModel = {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
};
|
|
5
|
-
export declare type GridRowsProp<R =
|
|
5
|
+
export declare type GridRowsProp<R = GridValidRowModel> = Readonly<GridRowModel<R>[]>;
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated prefer GridRowModel.
|
|
8
8
|
*/
|
|
@@ -10,7 +10,7 @@ export declare type GridRowData = GridValidRowModel;
|
|
|
10
10
|
/**
|
|
11
11
|
* The key value object representing the data of a row.
|
|
12
12
|
*/
|
|
13
|
-
export declare type GridRowModel<R extends GridValidRowModel =
|
|
13
|
+
export declare type GridRowModel<R extends GridValidRowModel = GridValidRowModel> = R;
|
|
14
14
|
export declare type GridUpdateAction = 'delete';
|
|
15
15
|
export interface GridRowModelUpdate extends GridRowModel {
|
|
16
16
|
_action?: GridUpdateAction;
|
|
@@ -81,12 +81,12 @@ export interface GridRowsMeta {
|
|
|
81
81
|
positions: number[];
|
|
82
82
|
}
|
|
83
83
|
export declare type GridRowTreeConfig = Record<GridRowId, GridRowTreeNodeConfig>;
|
|
84
|
-
export declare type GridRowsLookup<R extends GridValidRowModel =
|
|
84
|
+
export declare type GridRowsLookup<R extends GridValidRowModel = GridValidRowModel> = Record<GridRowId, R>;
|
|
85
85
|
/**
|
|
86
86
|
* The type of Id supported by the grid.
|
|
87
87
|
*/
|
|
88
88
|
export declare type GridRowId = string | number;
|
|
89
|
-
export interface GridRowEntry<R extends GridValidRowModel =
|
|
89
|
+
export interface GridRowEntry<R extends GridValidRowModel = GridValidRowModel> {
|
|
90
90
|
/**
|
|
91
91
|
* The row id.
|
|
92
92
|
*/
|
|
@@ -99,4 +99,4 @@ export interface GridRowEntry<R extends GridValidRowModel = any> {
|
|
|
99
99
|
/**
|
|
100
100
|
* The function to retrieve the id of a [[GridRowModel]].
|
|
101
101
|
*/
|
|
102
|
-
export declare type GridRowIdGetter<R extends GridValidRowModel =
|
|
102
|
+
export declare type GridRowIdGetter<R extends GridValidRowModel = GridValidRowModel> = (row: R) => GridRowId;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GridColumnMenuState, GridColumnsInitialState, GridColumnsState, GridDensityState, GridFilterInitialState, GridFilterState, GridFocusState, GridPaginationInitialState, GridPaginationState, GridPreferencePanelInitialState, GridPreferencePanelState, GridRowsState, GridSortingInitialState, GridSortingState, GridTabIndexState } from '../hooks';
|
|
1
|
+
import type { GridColumnMenuState, GridColumnsInitialState, GridColumnsState, GridColumnsGroupingState, GridDensityState, GridFilterInitialState, GridFilterState, GridFocusState, GridPaginationInitialState, GridPaginationState, GridPreferencePanelInitialState, GridPreferencePanelState, GridRowsState, GridSortingInitialState, GridSortingState, GridTabIndexState } from '../hooks';
|
|
2
2
|
import type { GridRowsMetaState } from '../hooks/features/rows/gridRowsMetaState';
|
|
3
3
|
import type { GridEditRowsModel } from './gridEditRowModel';
|
|
4
4
|
import type { GridSelectionModel } from './gridSelectionModel';
|
|
@@ -11,6 +11,7 @@ export interface GridStateCommunity {
|
|
|
11
11
|
editRows: GridEditRowsModel;
|
|
12
12
|
pagination: GridPaginationState;
|
|
13
13
|
columns: GridColumnsState;
|
|
14
|
+
columnGrouping: GridColumnsGroupingState;
|
|
14
15
|
columnMenu: GridColumnMenuState;
|
|
15
16
|
sorting: GridSortingState;
|
|
16
17
|
focus: GridFocusState;
|
package/models/index.d.ts
CHANGED
|
@@ -22,5 +22,6 @@ export * from './logger';
|
|
|
22
22
|
export * from './muiEvent';
|
|
23
23
|
export * from './events';
|
|
24
24
|
export * from './gridSortModel';
|
|
25
|
+
export * from './gridColumnGrouping';
|
|
25
26
|
export type { GridExportOptions, GridFileExportOptions, GridGetRowsToExportParams, GridCsvGetRowsToExportParams, GridCsvExportOptions, GridPrintExportOptions, } from './gridExport';
|
|
26
27
|
export * from './gridFilterOperator';
|
package/models/index.js
CHANGED
|
@@ -21,7 +21,8 @@ export * from './gridDensity';
|
|
|
21
21
|
export * from './logger';
|
|
22
22
|
export * from './muiEvent';
|
|
23
23
|
export * from './events';
|
|
24
|
-
export * from './gridSortModel';
|
|
24
|
+
export * from './gridSortModel';
|
|
25
|
+
export * from './gridColumnGrouping'; // Do not export GridExportFormat and GridExportExtension which are override in pro package
|
|
25
26
|
|
|
26
27
|
export * from './gridFilterOperator';
|
|
27
28
|
export {};
|
|
@@ -23,6 +23,7 @@ import { GridInitialStateCommunity } from '../gridStateCommunity';
|
|
|
23
23
|
import { GridSlotsComponentsProps } from '../gridSlotsComponentsProps';
|
|
24
24
|
import { GridColumnVisibilityModel } from '../../hooks/features/columns/gridColumnsInterfaces';
|
|
25
25
|
import { GridCellModesModel, GridRowModesModel } from '../api/gridEditingApi';
|
|
26
|
+
import { GridColumnGroupingModel } from '../gridColumnGrouping';
|
|
26
27
|
export interface GridExperimentalFeatures {
|
|
27
28
|
/**
|
|
28
29
|
* Will be part of the premium-plan when fully ready.
|
|
@@ -32,6 +33,10 @@ export interface GridExperimentalFeatures {
|
|
|
32
33
|
* Enables the new API for cell editing and row editing.
|
|
33
34
|
*/
|
|
34
35
|
newEditingApi: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Enables the column grouping.
|
|
38
|
+
*/
|
|
39
|
+
columnGrouping: boolean;
|
|
35
40
|
/**
|
|
36
41
|
* Emits a warning if the cell receives focus without also syncing the focus state.
|
|
37
42
|
* Only works if NODE_ENV=test.
|
|
@@ -234,7 +239,7 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
234
239
|
logger: Logger;
|
|
235
240
|
/**
|
|
236
241
|
* Allows to pass the logging level or false to turn off logging.
|
|
237
|
-
* @default "
|
|
242
|
+
* @default "error" ("warn" in dev mode)
|
|
238
243
|
*/
|
|
239
244
|
logLevel: keyof Logger | false;
|
|
240
245
|
/**
|
|
@@ -310,13 +315,13 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
310
315
|
/**
|
|
311
316
|
* The ref object that allows grid manipulation. Can be instantiated with [[useGridApiRef()]].
|
|
312
317
|
* TODO: Remove `@internal` when opening `apiRef` to Community plan
|
|
313
|
-
* @
|
|
318
|
+
* @ignore - do not document.
|
|
314
319
|
*/
|
|
315
320
|
apiRef?: React.MutableRefObject<GridApiCommunity>;
|
|
316
321
|
/**
|
|
317
322
|
* Signal to the underlying logic what version of the public component API
|
|
318
323
|
* of the data grid is exposed [[GridSignature]].
|
|
319
|
-
* @
|
|
324
|
+
* @ignore - do not document.
|
|
320
325
|
*/
|
|
321
326
|
signature?: string;
|
|
322
327
|
/**
|
|
@@ -551,7 +556,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
551
556
|
* @param {GridState} state The new state.
|
|
552
557
|
* @param {MuiEvent<{}>} event The event object.
|
|
553
558
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
554
|
-
* @
|
|
559
|
+
* @ignore - do not document.
|
|
555
560
|
*/
|
|
556
561
|
onStateChange?: GridEventListener<'stateChange'>;
|
|
557
562
|
/**
|
|
@@ -741,4 +746,5 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
741
746
|
* @param {any} error The error thrown.
|
|
742
747
|
*/
|
|
743
748
|
onProcessRowUpdateError?: (error: any) => void;
|
|
749
|
+
columnGroupingModel?: GridColumnGroupingModel;
|
|
744
750
|
}
|
|
@@ -79,6 +79,7 @@ DataGridRaw.propTypes = {
|
|
|
79
79
|
* @default 3
|
|
80
80
|
*/
|
|
81
81
|
columnBuffer: PropTypes.number,
|
|
82
|
+
columnGroupingModel: PropTypes.arrayOf(PropTypes.object),
|
|
82
83
|
|
|
83
84
|
/**
|
|
84
85
|
* Set of columns of type [[GridColumns]].
|
|
@@ -194,6 +195,7 @@ DataGridRaw.propTypes = {
|
|
|
194
195
|
* For each feature, if the flag is not explicitly set to `true`, the feature will be fully disabled and any property / method call will not have any effect.
|
|
195
196
|
*/
|
|
196
197
|
experimentalFeatures: PropTypes.shape({
|
|
198
|
+
columnGrouping: PropTypes.bool,
|
|
197
199
|
newEditingApi: PropTypes.bool,
|
|
198
200
|
preventCommitWhileValidating: PropTypes.bool,
|
|
199
201
|
warnIfFocusStateIsNotSynced: PropTypes.bool
|
|
@@ -347,7 +349,7 @@ DataGridRaw.propTypes = {
|
|
|
347
349
|
|
|
348
350
|
/**
|
|
349
351
|
* Allows to pass the logging level or false to turn off logging.
|
|
350
|
-
* @default "
|
|
352
|
+
* @default "error" ("warn" in dev mode)
|
|
351
353
|
*/
|
|
352
354
|
logLevel: PropTypes.oneOf(['debug', 'error', 'info', 'warn', false]),
|
|
353
355
|
|
|
@@ -645,7 +647,7 @@ DataGridRaw.propTypes = {
|
|
|
645
647
|
* @param {GridState} state The new state.
|
|
646
648
|
* @param {MuiEvent<{}>} event The event object.
|
|
647
649
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
648
|
-
* @
|
|
650
|
+
* @ignore - do not document.
|
|
649
651
|
*/
|
|
650
652
|
onStateChange: PropTypes.func,
|
|
651
653
|
|
|
@@ -25,12 +25,15 @@ import { useGridDimensions } from '../hooks/features/dimensions/useGridDimension
|
|
|
25
25
|
import { rowsMetaStateInitializer, useGridRowsMeta } from '../hooks/features/rows/useGridRowsMeta';
|
|
26
26
|
import { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
|
|
27
27
|
import { useGridColumnSpanning } from '../hooks/features/columns/useGridColumnSpanning';
|
|
28
|
+
import { useGridColumnGrouping, columnGroupsStateInitializer } from '../hooks/features/columnGrouping/useGridColumnGrouping';
|
|
29
|
+
import { useGridColumnGroupingPreProcessors } from '../hooks/features/columnGrouping/useGridColumnGroupingPreProcessors';
|
|
28
30
|
export const useDataGridComponent = props => {
|
|
29
31
|
const apiRef = useGridInitialization(undefined, props);
|
|
30
32
|
/**
|
|
31
33
|
* Register all pre-processors called during state initialization here.
|
|
32
34
|
*/
|
|
33
35
|
|
|
36
|
+
useGridColumnGroupingPreProcessors(apiRef, props);
|
|
34
37
|
useGridSelectionPreProcessors(apiRef, props);
|
|
35
38
|
useGridRowsPreProcessors(apiRef);
|
|
36
39
|
/**
|
|
@@ -39,6 +42,7 @@ export const useDataGridComponent = props => {
|
|
|
39
42
|
|
|
40
43
|
useGridInitializeState(selectionStateInitializer, apiRef, props);
|
|
41
44
|
useGridInitializeState(columnsStateInitializer, apiRef, props);
|
|
45
|
+
useGridInitializeState(columnGroupsStateInitializer, apiRef, props);
|
|
42
46
|
useGridInitializeState(rowsStateInitializer, apiRef, props);
|
|
43
47
|
useGridInitializeState(props.experimentalFeatures?.newEditingApi ? editingStateInitializer_new : editingStateInitializer_old, apiRef, props);
|
|
44
48
|
useGridInitializeState(focusStateInitializer, apiRef, props);
|
|
@@ -55,6 +59,7 @@ export const useDataGridComponent = props => {
|
|
|
55
59
|
useGridRows(apiRef, props);
|
|
56
60
|
useGridParamsApi(apiRef);
|
|
57
61
|
useGridColumnSpanning(apiRef);
|
|
62
|
+
useGridColumnGrouping(apiRef, props);
|
|
58
63
|
const useGridEditing = props.experimentalFeatures?.newEditingApi ? useGridEditing_new : useGridEditing_old;
|
|
59
64
|
useGridEditing(apiRef, props);
|
|
60
65
|
useGridFocus(apiRef, props);
|
|
@@ -18,7 +18,8 @@ export const DataGridColumnHeaders = /*#__PURE__*/React.forwardRef(function Grid
|
|
|
18
18
|
isDragging,
|
|
19
19
|
getRootProps,
|
|
20
20
|
getInnerProps,
|
|
21
|
-
|
|
21
|
+
getColumnHeaders,
|
|
22
|
+
getColumnGroupHeaders
|
|
22
23
|
} = useGridColumnHeaders({
|
|
23
24
|
innerRef
|
|
24
25
|
});
|
|
@@ -27,10 +28,10 @@ export const DataGridColumnHeaders = /*#__PURE__*/React.forwardRef(function Grid
|
|
|
27
28
|
}, getRootProps(other), {
|
|
28
29
|
children: [/*#__PURE__*/_jsx(GridScrollArea, {
|
|
29
30
|
scrollDirection: "left"
|
|
30
|
-
}), /*#__PURE__*/
|
|
31
|
+
}), /*#__PURE__*/_jsxs(GridColumnHeadersInner, _extends({
|
|
31
32
|
isDragging: isDragging
|
|
32
33
|
}, getInnerProps(), {
|
|
33
|
-
children:
|
|
34
|
+
children: [getColumnGroupHeaders(), getColumnHeaders()]
|
|
34
35
|
})), /*#__PURE__*/_jsx(GridScrollArea, {
|
|
35
36
|
scrollDirection: "right"
|
|
36
37
|
})]
|
|
@@ -104,6 +104,13 @@ process.env.NODE_ENV !== "production" ? GridAutoSizer.propTypes = {
|
|
|
104
104
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
105
105
|
// ----------------------------------------------------------------------
|
|
106
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Function responsible for rendering children.
|
|
109
|
+
* @param {AutoSizerSize} size The grid's size.
|
|
110
|
+
* @returns {React.ReactNode} The children to render.
|
|
111
|
+
*/
|
|
112
|
+
children: PropTypes.func.isRequired,
|
|
113
|
+
|
|
107
114
|
/**
|
|
108
115
|
* Default height to use for initial render; useful for SSR.
|
|
109
116
|
* @default null
|
|
@@ -22,6 +22,7 @@ import { GRID_ACTIONS_COLUMN_TYPE } from '../colDef/gridActionsColDef';
|
|
|
22
22
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../constants/gridDetailPanelToggleField';
|
|
23
23
|
import { gridSortModelSelector } from '../hooks/features/sorting/gridSortingSelector';
|
|
24
24
|
import { gridRowTreeDepthSelector } from '../hooks/features/rows/gridRowsSelector';
|
|
25
|
+
import { gridDensityHeaderGroupingMaxDepthSelector } from '../hooks/features/density/densitySelector';
|
|
25
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
27
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
28
|
|
|
@@ -80,8 +81,6 @@ function GridRow(props) {
|
|
|
80
81
|
} = props,
|
|
81
82
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
82
83
|
|
|
83
|
-
const ariaRowIndex = index + 2; // 1 for the header row and 1 as it's 1-based
|
|
84
|
-
|
|
85
84
|
const apiRef = useGridApiContext();
|
|
86
85
|
const ref = React.useRef(null);
|
|
87
86
|
const rootProps = useGridRootProps();
|
|
@@ -89,6 +88,9 @@ function GridRow(props) {
|
|
|
89
88
|
const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
90
89
|
const sortModel = useGridSelector(apiRef, gridSortModelSelector);
|
|
91
90
|
const treeDepth = useGridSelector(apiRef, gridRowTreeDepthSelector);
|
|
91
|
+
const headerGroupingMaxDepth = useGridSelector(apiRef, gridDensityHeaderGroupingMaxDepthSelector);
|
|
92
|
+
const ariaRowIndex = index + headerGroupingMaxDepth + 2; // 1 for the header row and 1 as it's 1-based
|
|
93
|
+
|
|
92
94
|
const {
|
|
93
95
|
hasScrollX,
|
|
94
96
|
hasScrollY
|
|
@@ -351,7 +353,7 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
351
353
|
isLastVisible: PropTypes.bool,
|
|
352
354
|
lastColumnToRender: PropTypes.number.isRequired,
|
|
353
355
|
renderedColumns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
354
|
-
row: PropTypes.
|
|
356
|
+
row: PropTypes.object.isRequired,
|
|
355
357
|
rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
|
|
356
358
|
rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
357
359
|
selected: PropTypes.bool.isRequired,
|
|
@@ -6,7 +6,7 @@ import { GridAutoSizer } from '../GridAutoSizer';
|
|
|
6
6
|
import { GridOverlays } from './GridOverlays';
|
|
7
7
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
8
8
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
9
|
-
import {
|
|
9
|
+
import { gridDensityTotalHeaderHeightSelector } from '../../hooks/features/density/densitySelector';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
|
|
@@ -18,14 +18,17 @@ function GridBody(props) {
|
|
|
18
18
|
} = props;
|
|
19
19
|
const apiRef = useGridApiContext();
|
|
20
20
|
const rootProps = useGridRootProps();
|
|
21
|
-
const
|
|
21
|
+
const totalHeaderHeight = useGridSelector(apiRef, gridDensityTotalHeaderHeightSelector);
|
|
22
22
|
const [isVirtualizationDisabled, setIsVirtualizationDisabled] = React.useState(rootProps.disableVirtualization);
|
|
23
23
|
const disableVirtualization = React.useCallback(() => {
|
|
24
24
|
setIsVirtualizationDisabled(true);
|
|
25
25
|
}, []);
|
|
26
26
|
const enableVirtualization = React.useCallback(() => {
|
|
27
27
|
setIsVirtualizationDisabled(false);
|
|
28
|
-
}, []);
|
|
28
|
+
}, []);
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
setIsVirtualizationDisabled(rootProps.disableVirtualization);
|
|
31
|
+
}, [rootProps.disableVirtualization]); // The `useGridApiMethod` hook can't be used here, because it only installs the
|
|
29
32
|
// method if it doesn't exist yet. Once installed, it's never updated again.
|
|
30
33
|
// This break the methods above, since their closure comes from the first time
|
|
31
34
|
// they were installed. Which means that calling `setIsVirtualizationDisabled`
|
|
@@ -60,8 +63,8 @@ function GridBody(props) {
|
|
|
60
63
|
width: size.width,
|
|
61
64
|
// If `autoHeight` is on, there will be no height value.
|
|
62
65
|
// In this case, let the container to grow whatever it needs.
|
|
63
|
-
height: size.height ? size.height -
|
|
64
|
-
marginTop:
|
|
66
|
+
height: size.height ? size.height - totalHeaderHeight : 'auto',
|
|
67
|
+
marginTop: totalHeaderHeight
|
|
65
68
|
};
|
|
66
69
|
return /*#__PURE__*/_jsx(VirtualScrollerComponent, {
|
|
67
70
|
ref: windowRef,
|
|
@@ -6,13 +6,13 @@ import { gridVisibleRowCountSelector } from '../../hooks/features/filter/gridFil
|
|
|
6
6
|
import { gridRowCountSelector, gridRowsLoadingSelector } from '../../hooks/features/rows/gridRowsSelector';
|
|
7
7
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
8
8
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
9
|
-
import {
|
|
9
|
+
import { gridDensityTotalHeaderHeightSelector } from '../../hooks/features/density/densitySelector';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
function GridOverlayWrapper(props) {
|
|
13
13
|
const apiRef = useGridApiContext();
|
|
14
14
|
const rootProps = useGridRootProps();
|
|
15
|
-
const
|
|
15
|
+
const totalHeaderHeight = useGridSelector(apiRef, gridDensityTotalHeaderHeightSelector);
|
|
16
16
|
const [viewportInnerSize, setViewportInnerSize] = React.useState(() => apiRef.current.getRootDimensions()?.viewportInnerSize ?? null);
|
|
17
17
|
const handleViewportSizeChange = React.useCallback(() => {
|
|
18
18
|
setViewportInnerSize(apiRef.current.getRootDimensions()?.viewportInnerSize ?? null);
|
|
@@ -35,11 +35,8 @@ function GridOverlayWrapper(props) {
|
|
|
35
35
|
height,
|
|
36
36
|
width: viewportInnerSize?.width ?? 0,
|
|
37
37
|
position: 'absolute',
|
|
38
|
-
top:
|
|
39
|
-
bottom: height === 'auto' ? 0 : undefined
|
|
40
|
-
zIndex: 4,
|
|
41
|
-
// should be above pinned columns, pinned rows and detail panel
|
|
42
|
-
pointerEvents: 'none'
|
|
38
|
+
top: totalHeaderHeight,
|
|
39
|
+
bottom: height === 'auto' ? 0 : undefined
|
|
43
40
|
}
|
|
44
41
|
}, props));
|
|
45
42
|
}
|
|
@@ -81,7 +81,7 @@ function GridEditDateCell(props) {
|
|
|
81
81
|
const [date, time] = newFormattedDate.split('T');
|
|
82
82
|
const [year, month, day] = date.split('-');
|
|
83
83
|
newParsedDate = new Date();
|
|
84
|
-
newParsedDate.setFullYear(year, Number(month) - 1, day);
|
|
84
|
+
newParsedDate.setFullYear(Number(year), Number(month) - 1, Number(day));
|
|
85
85
|
newParsedDate.setHours(0, 0, 0, 0);
|
|
86
86
|
|
|
87
87
|
if (time) {
|
|
@@ -23,6 +23,10 @@ const renderSingleSelectOptions = (option, OptionComponent) => {
|
|
|
23
23
|
}, key);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
function isKeyboardEvent(event) {
|
|
27
|
+
return !!event.key;
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
function GridEditSingleSelectCell(props) {
|
|
27
31
|
const rootProps = useGridRootProps();
|
|
28
32
|
|
|
@@ -136,7 +140,11 @@ function GridEditSingleSelectCell(props) {
|
|
|
136
140
|
}
|
|
137
141
|
};
|
|
138
142
|
|
|
139
|
-
const handleOpen =
|
|
143
|
+
const handleOpen = event => {
|
|
144
|
+
if (isKeyboardEvent(event) && event.key === 'Enter') {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
140
148
|
setOpen(true);
|
|
141
149
|
};
|
|
142
150
|
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { unstable_useId as useId } from '@mui/utils';
|
|
4
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
5
|
+
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
6
|
+
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
7
|
+
import { gridColumnGroupsLookupSelector } from '../../hooks/features/columnGrouping/gridColumnGroupsSelector';
|
|
8
|
+
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
9
|
+
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
10
|
+
import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
|
|
13
|
+
const useUtilityClasses = ownerState => {
|
|
14
|
+
const {
|
|
15
|
+
classes,
|
|
16
|
+
headerAlign,
|
|
17
|
+
isDragging,
|
|
18
|
+
showRightBorder,
|
|
19
|
+
showColumnBorder,
|
|
20
|
+
groupId
|
|
21
|
+
} = ownerState;
|
|
22
|
+
const slots = {
|
|
23
|
+
root: ['columnHeader', headerAlign === 'left' && 'columnHeader--alignLeft', headerAlign === 'center' && 'columnHeader--alignCenter', headerAlign === 'right' && 'columnHeader--alignRight', isDragging && 'columnHeader--moving', showRightBorder && 'withBorder', showColumnBorder && 'columnHeader--showColumnBorder', groupId === null ? 'columnHeader--emptyGroup' : 'columnHeader--filledGroup'],
|
|
24
|
+
draggableContainer: ['columnHeaderDraggableContainer'],
|
|
25
|
+
titleContainer: ['columnHeaderTitleContainer'],
|
|
26
|
+
titleContainerContent: ['columnHeaderTitleContainerContent']
|
|
27
|
+
};
|
|
28
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function GridColumnGroupHeader(props) {
|
|
32
|
+
const {
|
|
33
|
+
groupId,
|
|
34
|
+
width,
|
|
35
|
+
depth,
|
|
36
|
+
maxDepth,
|
|
37
|
+
fields,
|
|
38
|
+
height,
|
|
39
|
+
colIndex,
|
|
40
|
+
isLastColumn,
|
|
41
|
+
extendRowFullWidth
|
|
42
|
+
} = props;
|
|
43
|
+
const rootProps = useGridRootProps();
|
|
44
|
+
const apiRef = useGridApiContext();
|
|
45
|
+
const columnGroupsLookup = useGridSelector(apiRef, gridColumnGroupsLookupSelector);
|
|
46
|
+
const {
|
|
47
|
+
hasScrollX,
|
|
48
|
+
hasScrollY
|
|
49
|
+
} = apiRef.current.getRootDimensions() ?? {
|
|
50
|
+
hasScrollX: false,
|
|
51
|
+
hasScrollY: false
|
|
52
|
+
};
|
|
53
|
+
const group = groupId ? columnGroupsLookup[groupId] : {};
|
|
54
|
+
const {
|
|
55
|
+
headerName = groupId ?? '',
|
|
56
|
+
description = '',
|
|
57
|
+
headerAlign = undefined
|
|
58
|
+
} = group;
|
|
59
|
+
let headerComponent;
|
|
60
|
+
const render = groupId && columnGroupsLookup[groupId]?.renderHeaderGroup;
|
|
61
|
+
const renderParams = {
|
|
62
|
+
groupId,
|
|
63
|
+
headerName,
|
|
64
|
+
description,
|
|
65
|
+
depth,
|
|
66
|
+
maxDepth,
|
|
67
|
+
fields,
|
|
68
|
+
colIndex,
|
|
69
|
+
isLastColumn
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
if (groupId && render) {
|
|
73
|
+
headerComponent = render(renderParams);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const removeLastBorderRight = isLastColumn && hasScrollX && !hasScrollY;
|
|
77
|
+
const showRightBorder = !isLastColumn ? rootProps.showColumnRightBorder : !removeLastBorderRight && !extendRowFullWidth;
|
|
78
|
+
const showColumnBorder = rootProps.showColumnRightBorder;
|
|
79
|
+
|
|
80
|
+
const ownerState = _extends({}, props, {
|
|
81
|
+
classes: rootProps.classes,
|
|
82
|
+
showRightBorder,
|
|
83
|
+
showColumnBorder,
|
|
84
|
+
headerAlign,
|
|
85
|
+
depth,
|
|
86
|
+
isDragging: false
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const label = headerName ?? groupId;
|
|
90
|
+
const id = useId();
|
|
91
|
+
const elementId = groupId === null ? `empty-group-cell-${id}` : groupId;
|
|
92
|
+
const classes = useUtilityClasses(ownerState);
|
|
93
|
+
const headerClassName = typeof group.headerClassName === 'function' ? group.headerClassName(renderParams) : group.headerClassName;
|
|
94
|
+
return /*#__PURE__*/_jsx(GridGenericColumnHeaderItem, {
|
|
95
|
+
classes: classes,
|
|
96
|
+
columnMenuOpen: false,
|
|
97
|
+
colIndex: colIndex,
|
|
98
|
+
height: height,
|
|
99
|
+
isResizing: false,
|
|
100
|
+
sortDirection: null,
|
|
101
|
+
hasFocus: false,
|
|
102
|
+
tabIndex: -1,
|
|
103
|
+
isDraggable: false,
|
|
104
|
+
headerComponent: headerComponent,
|
|
105
|
+
headerClassName: headerClassName,
|
|
106
|
+
description: description,
|
|
107
|
+
elementId: elementId,
|
|
108
|
+
width: width,
|
|
109
|
+
columnMenuIconButton: null,
|
|
110
|
+
columnTitleIconButtons: null,
|
|
111
|
+
resizable: false,
|
|
112
|
+
label: label,
|
|
113
|
+
"aria-colspan": fields.length // The fields are wrapped between |-...-| to avoid confusion between fields "id" and "id2" when using selector data-fields~=
|
|
114
|
+
,
|
|
115
|
+
"data-fields": `|-${fields.join('-|-')}-|`,
|
|
116
|
+
disableHeaderSeparator: true
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { GridColumnGroupHeader };
|