@mui/x-data-grid 5.15.2 → 5.17.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 +177 -2
- package/DataGrid/DataGrid.js +3 -1
- 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.d.ts +2 -1
- package/components/GridRow.js +136 -85
- 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/GridBooleanCell.js +2 -1
- package/components/cell/GridEditBooleanCell.js +2 -1
- package/components/cell/GridEditDateCell.js +3 -2
- package/components/cell/GridEditInputCell.js +2 -1
- package/components/cell/GridEditSingleSelectCell.js +11 -2
- package/components/cell/GridSkeletonCell.d.ts +12 -0
- package/components/cell/GridSkeletonCell.js +60 -0
- package/components/cell/index.d.ts +1 -0
- package/components/cell/index.js +2 -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/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/components/containers/GridOverlay.js +7 -1
- package/components/containers/GridRoot.js +3 -3
- package/components/containers/GridRootStyles.js +16 -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/GridColumnsPanel.d.ts +6 -1
- package/components/panel/GridColumnsPanel.js +38 -6
- 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/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +24 -0
- package/constants/gridClasses.js +1 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -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/export/useGridPrintExport.js +3 -3
- package/hooks/features/filter/gridFilterSelector.d.ts +3 -3
- package/hooks/features/filter/gridFilterUtils.d.ts +1 -1
- package/hooks/features/filter/gridFilterUtils.js +55 -54
- package/hooks/features/filter/useGridFilter.js +1 -1
- 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/useGridParamsApi.js +1 -1
- package/hooks/features/rows/useGridRows.js +65 -8
- package/hooks/features/rows/useGridRowsMeta.js +36 -16
- package/hooks/features/selection/gridSelectionSelector.d.ts +1 -1
- package/hooks/features/sorting/gridSortingSelector.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
- 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 +2 -0
- package/internals/index.js +2 -0
- package/legacy/DataGrid/DataGrid.js +3 -1
- 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 +138 -85
- package/legacy/components/base/GridBody.js +8 -5
- package/legacy/components/base/GridOverlays.js +4 -7
- package/legacy/components/cell/GridBooleanCell.js +2 -1
- package/legacy/components/cell/GridEditBooleanCell.js +2 -1
- package/legacy/components/cell/GridEditDateCell.js +3 -2
- package/legacy/components/cell/GridEditInputCell.js +2 -1
- package/legacy/components/cell/GridEditSingleSelectCell.js +11 -2
- package/legacy/components/cell/GridSkeletonCell.js +57 -0
- package/legacy/components/cell/index.js +2 -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/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/legacy/components/containers/GridOverlay.js +7 -1
- package/legacy/components/containers/GridRoot.js +3 -3
- package/legacy/components/containers/GridRootStyles.js +14 -5
- package/legacy/components/menu/GridMenu.js +1 -0
- package/legacy/components/panel/GridColumnsPanel.js +41 -6
- 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/defaultGridSlotsComponents.js +2 -1
- 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/export/useGridPrintExport.js +3 -3
- package/legacy/hooks/features/filter/gridFilterUtils.js +61 -56
- package/legacy/hooks/features/filter/useGridFilter.js +1 -1
- package/legacy/hooks/features/index.js +1 -0
- package/legacy/hooks/features/rows/useGridParamsApi.js +1 -1
- package/legacy/hooks/features/rows/useGridRows.js +73 -8
- package/legacy/hooks/features/rows/useGridRowsMeta.js +45 -18
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +31 -13
- package/legacy/hooks/utils/useGridNativeEventListener.js +2 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +2 -0
- package/legacy/models/api/gridColumnGroupingApi.js +1 -0
- package/legacy/models/events/gridEvents.js +2 -0
- package/legacy/models/gridColumnGrouping.js +6 -0
- package/legacy/models/index.js +2 -1
- package/legacy/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
- package/legacy/models/params/index.js +2 -1
- package/legacy/utils/utils.js +18 -0
- 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/api/gridParamsApi.d.ts +1 -1
- package/models/api/gridRowApi.d.ts +6 -0
- package/models/api/gridRowsMetaApi.d.ts +6 -1
- package/models/colDef/gridColDef.d.ts +15 -1
- package/models/events/gridEventLookup.d.ts +7 -1
- package/models/events/gridEvents.d.ts +3 -1
- package/models/events/gridEvents.js +2 -0
- package/models/gridColumnGrouping.d.ts +67 -0
- package/models/gridColumnGrouping.js +6 -0
- package/models/gridRows.d.ts +5 -5
- package/models/gridSlotsComponent.d.ts +5 -0
- package/models/gridStateCommunity.d.ts +2 -1
- package/models/index.d.ts +1 -0
- package/models/index.js +2 -1
- package/models/params/gridCellParams.d.ts +7 -2
- package/models/params/gridMenuParams.d.ts +1 -2
- package/models/params/gridRenderedRowsIntervalChangeParams.d.ts +10 -0
- package/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +2 -1
- package/models/props/DataGridProps.d.ts +7 -1
- package/modern/DataGrid/DataGrid.js +3 -1
- 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 +133 -84
- package/modern/components/base/GridBody.js +8 -5
- package/modern/components/base/GridOverlays.js +4 -7
- package/modern/components/cell/GridBooleanCell.js +2 -1
- package/modern/components/cell/GridEditBooleanCell.js +2 -1
- package/modern/components/cell/GridEditDateCell.js +3 -2
- package/modern/components/cell/GridEditInputCell.js +2 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +11 -2
- package/modern/components/cell/GridSkeletonCell.js +60 -0
- package/modern/components/cell/index.js +2 -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/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/modern/components/containers/GridOverlay.js +7 -1
- package/modern/components/containers/GridRoot.js +3 -3
- package/modern/components/containers/GridRootStyles.js +16 -2
- package/modern/components/menu/GridMenu.js +1 -0
- package/modern/components/panel/GridColumnsPanel.js +38 -6
- 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/defaultGridSlotsComponents.js +2 -1
- 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/export/useGridPrintExport.js +3 -3
- package/modern/hooks/features/filter/gridFilterUtils.js +54 -53
- package/modern/hooks/features/filter/useGridFilter.js +1 -1
- package/modern/hooks/features/index.js +1 -0
- package/modern/hooks/features/rows/useGridParamsApi.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +65 -8
- package/modern/hooks/features/rows/useGridRowsMeta.js +36 -16
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
- package/modern/hooks/utils/useGridNativeEventListener.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -0
- package/modern/models/api/gridColumnGroupingApi.js +1 -0
- package/modern/models/events/gridEvents.js +2 -0
- package/modern/models/gridColumnGrouping.js +6 -0
- package/modern/models/index.js +2 -1
- package/modern/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
- package/modern/models/params/index.js +2 -1
- package/modern/utils/utils.js +16 -0
- package/node/DataGrid/DataGrid.js +3 -1
- 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 +136 -77
- package/node/components/base/GridBody.js +7 -4
- package/node/components/base/GridOverlays.js +3 -6
- package/node/components/cell/GridBooleanCell.js +2 -1
- package/node/components/cell/GridEditBooleanCell.js +2 -1
- package/node/components/cell/GridEditDateCell.js +3 -2
- package/node/components/cell/GridEditInputCell.js +2 -1
- package/node/components/cell/GridEditSingleSelectCell.js +11 -2
- package/node/components/cell/GridSkeletonCell.js +81 -0
- package/node/components/cell/index.js +13 -0
- 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/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/node/components/containers/GridOverlay.js +7 -1
- package/node/components/containers/GridRoot.js +4 -4
- package/node/components/containers/GridRootStyles.js +16 -2
- package/node/components/menu/GridMenu.js +1 -0
- package/node/components/panel/GridColumnsPanel.js +36 -5
- 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/defaultGridSlotsComponents.js +1 -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/export/useGridPrintExport.js +2 -2
- package/node/hooks/features/filter/gridFilterUtils.js +55 -55
- package/node/hooks/features/filter/useGridFilter.js +1 -1
- package/node/hooks/features/index.js +13 -0
- package/node/hooks/features/rows/useGridParamsApi.js +1 -1
- package/node/hooks/features/rows/useGridRows.js +60 -7
- package/node/hooks/features/rows/useGridRowsMeta.js +35 -15
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
- package/node/hooks/utils/useGridNativeEventListener.js +2 -2
- package/node/index.js +1 -1
- package/node/internals/index.js +22 -0
- package/node/models/api/gridColumnGroupingApi.js +5 -0
- package/node/models/events/gridEvents.js +2 -0
- package/node/models/gridColumnGrouping.js +13 -0
- package/node/models/index.js +13 -0
- package/node/models/params/gridRenderedRowsIntervalChangeParams.js +5 -0
- package/node/models/params/index.js +13 -0
- package/node/utils/utils.js +18 -0
- package/package.json +3 -3
- package/utils/utils.d.ts +1 -0
- package/utils/utils.js +16 -0
|
@@ -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 };
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import clsx from 'clsx';
|
|
5
4
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
6
5
|
import { unstable_useId as useId } from '@mui/material/utils';
|
|
7
6
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
8
7
|
import { GridColumnHeaderSortIcon } from './GridColumnHeaderSortIcon';
|
|
9
|
-
import { GridColumnHeaderTitle } from './GridColumnHeaderTitle';
|
|
10
|
-
import { GridColumnHeaderSeparator } from './GridColumnHeaderSeparator';
|
|
11
8
|
import { ColumnHeaderMenuIcon } from './ColumnHeaderMenuIcon';
|
|
12
9
|
import { GridColumnHeaderMenu } from '../menu/columnMenu/GridColumnHeaderMenu';
|
|
13
10
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
14
11
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
12
|
+
import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
|
|
15
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
15
|
|
|
@@ -69,12 +67,21 @@ function GridColumnHeaderItem(props) {
|
|
|
69
67
|
hasScrollY: false
|
|
70
68
|
};
|
|
71
69
|
const isDraggable = React.useMemo(() => !rootProps.disableColumnReorder && !disableReorder && !column.disableReorder, [rootProps.disableColumnReorder, disableReorder, column.disableReorder]);
|
|
72
|
-
let headerComponent
|
|
70
|
+
let headerComponent;
|
|
73
71
|
|
|
74
72
|
if (column.renderHeader) {
|
|
75
73
|
headerComponent = column.renderHeader(apiRef.current.getColumnHeaderParams(column.field));
|
|
76
74
|
}
|
|
77
75
|
|
|
76
|
+
const removeLastBorderRight = isLastColumn && hasScrollX && !hasScrollY;
|
|
77
|
+
const showRightBorder = !isLastColumn ? rootProps.showColumnRightBorder : !removeLastBorderRight && !extendRowFullWidth;
|
|
78
|
+
|
|
79
|
+
const ownerState = _extends({}, props, {
|
|
80
|
+
classes: rootProps.classes,
|
|
81
|
+
showRightBorder
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const classes = useUtilityClasses(ownerState);
|
|
78
85
|
const publish = React.useCallback(eventName => event => {
|
|
79
86
|
// Ignore portal
|
|
80
87
|
// See https://github.com/mui/mui-x/issues/1721
|
|
@@ -84,7 +91,7 @@ function GridColumnHeaderItem(props) {
|
|
|
84
91
|
|
|
85
92
|
apiRef.current.publishEvent(eventName, apiRef.current.getColumnHeaderParams(column.field), event);
|
|
86
93
|
}, [apiRef, column.field]);
|
|
87
|
-
const mouseEventsHandlers = {
|
|
94
|
+
const mouseEventsHandlers = React.useMemo(() => ({
|
|
88
95
|
onClick: publish('columnHeaderClick'),
|
|
89
96
|
onDoubleClick: publish('columnHeaderDoubleClick'),
|
|
90
97
|
onMouseOver: publish('columnHeaderOver'),
|
|
@@ -98,29 +105,16 @@ function GridColumnHeaderItem(props) {
|
|
|
98
105
|
onKeyDown: publish('columnHeaderKeyDown'),
|
|
99
106
|
onFocus: publish('columnHeaderFocus'),
|
|
100
107
|
onBlur: publish('columnHeaderBlur')
|
|
101
|
-
};
|
|
102
|
-
const draggableEventHandlers = isDraggable ? {
|
|
108
|
+
}), [publish]);
|
|
109
|
+
const draggableEventHandlers = React.useMemo(() => isDraggable ? {
|
|
103
110
|
onDragStart: publish('columnHeaderDragStart'),
|
|
104
111
|
onDragEnter: publish('columnHeaderDragEnter'),
|
|
105
112
|
onDragOver: publish('columnHeaderDragOver'),
|
|
106
113
|
onDragEnd: publish('columnHeaderDragEnd')
|
|
107
|
-
} :
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const ownerState = _extends({}, props, {
|
|
112
|
-
classes: rootProps.classes,
|
|
113
|
-
showRightBorder
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const classes = useUtilityClasses(ownerState);
|
|
117
|
-
const width = column.computedWidth;
|
|
118
|
-
let ariaSort = 'none';
|
|
119
|
-
|
|
120
|
-
if (sortDirection != null) {
|
|
121
|
-
ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
|
|
122
|
-
}
|
|
123
|
-
|
|
114
|
+
} : {}, [isDraggable, publish]);
|
|
115
|
+
const columnHeaderSeparatorProps = React.useMemo(() => ({
|
|
116
|
+
onMouseDown: publish('columnSeparatorMouseDown')
|
|
117
|
+
}), [publish]);
|
|
124
118
|
React.useEffect(() => {
|
|
125
119
|
if (!showColumnMenuIcon) {
|
|
126
120
|
setShowColumnMenuIcon(columnMenuOpen);
|
|
@@ -138,6 +132,17 @@ function GridColumnHeaderItem(props) {
|
|
|
138
132
|
iconButtonRef: iconButtonRef
|
|
139
133
|
});
|
|
140
134
|
|
|
135
|
+
const columnMenu = /*#__PURE__*/_jsx(GridColumnHeaderMenu, {
|
|
136
|
+
columnMenuId: columnMenuId,
|
|
137
|
+
columnMenuButtonId: columnMenuButtonId,
|
|
138
|
+
field: column.field,
|
|
139
|
+
open: columnMenuOpen,
|
|
140
|
+
target: iconButtonRef.current,
|
|
141
|
+
ContentComponent: rootProps.components.ColumnMenu,
|
|
142
|
+
contentComponentProps: rootProps.componentsProps?.columnMenu,
|
|
143
|
+
onExited: handleExited
|
|
144
|
+
});
|
|
145
|
+
|
|
141
146
|
const sortingOrder = column.sortingOrder ?? rootProps.sortingOrder;
|
|
142
147
|
|
|
143
148
|
const columnTitleIconButtons = /*#__PURE__*/_jsxs(React.Fragment, {
|
|
@@ -166,53 +171,32 @@ function GridColumnHeaderItem(props) {
|
|
|
166
171
|
colDef: column
|
|
167
172
|
}) : column.headerClassName;
|
|
168
173
|
const label = column.headerName ?? column.field;
|
|
169
|
-
return /*#__PURE__*/
|
|
174
|
+
return /*#__PURE__*/_jsx(GridGenericColumnHeaderItem, _extends({
|
|
170
175
|
ref: headerCellRef,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
role: "columnheader",
|
|
176
|
+
classes: classes,
|
|
177
|
+
columnMenuOpen: columnMenuOpen,
|
|
178
|
+
colIndex: colIndex,
|
|
179
|
+
height: headerHeight,
|
|
180
|
+
isResizing: isResizing,
|
|
181
|
+
sortDirection: sortDirection,
|
|
182
|
+
hasFocus: hasFocus,
|
|
179
183
|
tabIndex: tabIndex,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
})
|
|
197
|
-
}), columnTitleIconButtons]
|
|
198
|
-
}), columnMenuIconButton]
|
|
199
|
-
})), /*#__PURE__*/_jsx(GridColumnHeaderSeparator, {
|
|
200
|
-
resizable: !rootProps.disableColumnResize && !!column.resizable,
|
|
201
|
-
resizing: isResizing,
|
|
202
|
-
height: headerHeight,
|
|
203
|
-
onMouseDown: publish('columnSeparatorMouseDown'),
|
|
204
|
-
side: separatorSide
|
|
205
|
-
}), /*#__PURE__*/_jsx(GridColumnHeaderMenu, {
|
|
206
|
-
columnMenuId: columnMenuId,
|
|
207
|
-
columnMenuButtonId: columnMenuButtonId,
|
|
208
|
-
field: column.field,
|
|
209
|
-
open: columnMenuOpen,
|
|
210
|
-
target: iconButtonRef.current,
|
|
211
|
-
ContentComponent: rootProps.components.ColumnMenu,
|
|
212
|
-
contentComponentProps: rootProps.componentsProps?.columnMenu,
|
|
213
|
-
onExited: handleExited
|
|
214
|
-
})]
|
|
215
|
-
}));
|
|
184
|
+
separatorSide: separatorSide,
|
|
185
|
+
isDraggable: isDraggable,
|
|
186
|
+
headerComponent: headerComponent,
|
|
187
|
+
description: column.description,
|
|
188
|
+
elementId: column.field,
|
|
189
|
+
width: column.computedWidth,
|
|
190
|
+
columnMenuIconButton: columnMenuIconButton,
|
|
191
|
+
columnTitleIconButtons: columnTitleIconButtons,
|
|
192
|
+
headerClassName: headerClassName,
|
|
193
|
+
label: label,
|
|
194
|
+
resizable: !rootProps.disableColumnResize && !!column.resizable,
|
|
195
|
+
"data-field": column.field,
|
|
196
|
+
columnMenu: columnMenu,
|
|
197
|
+
draggableContainerProps: draggableEventHandlers,
|
|
198
|
+
columnHeaderSeparatorProps: columnHeaderSeparatorProps
|
|
199
|
+
}, mouseEventsHandlers));
|
|
216
200
|
}
|
|
217
201
|
|
|
218
202
|
process.env.NODE_ENV !== "production" ? GridColumnHeaderItem.propTypes = {
|
|
@@ -30,7 +30,8 @@ const GridColumnHeadersInnerRoot = styled('div', {
|
|
|
30
30
|
}, styles.columnHeadersInner]
|
|
31
31
|
})(() => ({
|
|
32
32
|
display: 'flex',
|
|
33
|
-
alignItems: '
|
|
33
|
+
alignItems: 'flex-start',
|
|
34
|
+
flexDirection: 'column',
|
|
34
35
|
[`&.${gridClasses.columnHeaderDropZone} .${gridClasses.columnHeaderDraggableContainer}`]: {
|
|
35
36
|
cursor: 'move'
|
|
36
37
|
},
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["classes", "columnMenuOpen", "colIndex", "height", "isResizing", "sortDirection", "hasFocus", "tabIndex", "separatorSide", "isDraggable", "headerComponent", "description", "elementId", "width", "columnMenuIconButton", "columnMenu", "columnTitleIconButtons", "headerClassName", "label", "resizable", "draggableContainerProps", "columnHeaderSeparatorProps", "disableHeaderSeparator"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { useForkRef } from '@mui/material/utils';
|
|
7
|
+
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
8
|
+
import { GridColumnHeaderTitle } from './GridColumnHeaderTitle';
|
|
9
|
+
import { GridColumnHeaderSeparator } from './GridColumnHeaderSeparator';
|
|
10
|
+
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridGenericColumnHeaderItem(props, ref) {
|
|
14
|
+
const {
|
|
15
|
+
classes,
|
|
16
|
+
columnMenuOpen,
|
|
17
|
+
colIndex,
|
|
18
|
+
height,
|
|
19
|
+
isResizing,
|
|
20
|
+
sortDirection,
|
|
21
|
+
hasFocus,
|
|
22
|
+
tabIndex,
|
|
23
|
+
separatorSide,
|
|
24
|
+
isDraggable,
|
|
25
|
+
headerComponent,
|
|
26
|
+
description,
|
|
27
|
+
width,
|
|
28
|
+
columnMenuIconButton = null,
|
|
29
|
+
columnMenu = null,
|
|
30
|
+
columnTitleIconButtons = null,
|
|
31
|
+
headerClassName,
|
|
32
|
+
label,
|
|
33
|
+
resizable,
|
|
34
|
+
draggableContainerProps,
|
|
35
|
+
columnHeaderSeparatorProps,
|
|
36
|
+
disableHeaderSeparator
|
|
37
|
+
} = props,
|
|
38
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
39
|
+
|
|
40
|
+
const apiRef = useGridApiContext();
|
|
41
|
+
const rootProps = useGridRootProps();
|
|
42
|
+
const headerCellRef = React.useRef(null);
|
|
43
|
+
const [showColumnMenuIcon, setShowColumnMenuIcon] = React.useState(columnMenuOpen);
|
|
44
|
+
const handleRef = useForkRef(headerCellRef, ref);
|
|
45
|
+
let ariaSort = 'none';
|
|
46
|
+
|
|
47
|
+
if (sortDirection != null) {
|
|
48
|
+
ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
if (!showColumnMenuIcon) {
|
|
53
|
+
setShowColumnMenuIcon(columnMenuOpen);
|
|
54
|
+
}
|
|
55
|
+
}, [showColumnMenuIcon, columnMenuOpen]);
|
|
56
|
+
React.useLayoutEffect(() => {
|
|
57
|
+
const columnMenuState = apiRef.current.state.columnMenu;
|
|
58
|
+
|
|
59
|
+
if (hasFocus && !columnMenuState.open) {
|
|
60
|
+
const focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
|
|
61
|
+
const elementToFocus = focusableElement || headerCellRef.current;
|
|
62
|
+
elementToFocus?.focus();
|
|
63
|
+
apiRef.current.columnHeadersContainerElementRef.current.scrollLeft = 0;
|
|
64
|
+
}
|
|
65
|
+
}, [apiRef, hasFocus]);
|
|
66
|
+
return /*#__PURE__*/_jsxs("div", _extends({
|
|
67
|
+
ref: handleRef,
|
|
68
|
+
className: clsx(classes.root, headerClassName),
|
|
69
|
+
style: {
|
|
70
|
+
height,
|
|
71
|
+
width,
|
|
72
|
+
minWidth: width,
|
|
73
|
+
maxWidth: width
|
|
74
|
+
},
|
|
75
|
+
role: "columnheader",
|
|
76
|
+
tabIndex: tabIndex,
|
|
77
|
+
"aria-colindex": colIndex + 1,
|
|
78
|
+
"aria-sort": ariaSort,
|
|
79
|
+
"aria-label": headerComponent == null ? label : undefined
|
|
80
|
+
}, other, {
|
|
81
|
+
children: [/*#__PURE__*/_jsxs("div", _extends({
|
|
82
|
+
className: classes.draggableContainer,
|
|
83
|
+
draggable: isDraggable
|
|
84
|
+
}, draggableContainerProps, {
|
|
85
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
86
|
+
className: classes.titleContainer,
|
|
87
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
88
|
+
className: classes.titleContainerContent,
|
|
89
|
+
children: headerComponent !== undefined ? headerComponent : /*#__PURE__*/_jsx(GridColumnHeaderTitle, {
|
|
90
|
+
label: label,
|
|
91
|
+
description: description,
|
|
92
|
+
columnWidth: width
|
|
93
|
+
})
|
|
94
|
+
}), columnTitleIconButtons]
|
|
95
|
+
}), columnMenuIconButton]
|
|
96
|
+
})), !disableHeaderSeparator && /*#__PURE__*/_jsx(GridColumnHeaderSeparator, _extends({
|
|
97
|
+
resizable: !rootProps.disableColumnResize && !!resizable,
|
|
98
|
+
resizing: isResizing,
|
|
99
|
+
height: height,
|
|
100
|
+
side: separatorSide
|
|
101
|
+
}, columnHeaderSeparatorProps)), columnMenu]
|
|
102
|
+
}));
|
|
103
|
+
});
|
|
104
|
+
export { GridGenericColumnHeaderItem };
|
|
@@ -183,7 +183,8 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
183
183
|
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
|
-
* The cell value
|
|
186
|
+
* The cell value.
|
|
187
|
+
* If the column has `valueGetter`, use `params.row` to directly access the fields.
|
|
187
188
|
*/
|
|
188
189
|
value: PropTypes.any
|
|
189
190
|
} : void 0;
|
|
@@ -27,8 +27,14 @@ const GridOverlayRoot = styled('div', {
|
|
|
27
27
|
})(({
|
|
28
28
|
theme
|
|
29
29
|
}) => ({
|
|
30
|
-
|
|
30
|
+
position: 'absolute',
|
|
31
|
+
top: 0,
|
|
32
|
+
zIndex: 4,
|
|
33
|
+
// should be above pinned columns, pinned rows and detail panel
|
|
34
|
+
width: '100%',
|
|
31
35
|
height: '100%',
|
|
36
|
+
pointerEvents: 'none',
|
|
37
|
+
display: 'flex',
|
|
32
38
|
alignSelf: 'center',
|
|
33
39
|
alignItems: 'center',
|
|
34
40
|
justifyContent: 'center',
|
|
@@ -12,8 +12,8 @@ import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
|
12
12
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
13
13
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
14
14
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
15
|
+
import { gridDensityHeaderGroupingMaxDepthSelector, gridDensityValueSelector } from '../../hooks/features/density/densitySelector';
|
|
15
16
|
import { gridPinnedRowsCountSelector, gridRowCountSelector } from '../../hooks/features/rows/gridRowsSelector';
|
|
16
|
-
import { gridDensityValueSelector } from '../../hooks/features/density/densitySelector';
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
|
|
19
19
|
const useUtilityClasses = ownerState => {
|
|
@@ -41,6 +41,7 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
41
41
|
const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
42
42
|
const totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
|
|
43
43
|
const densityValue = useGridSelector(apiRef, gridDensityValueSelector);
|
|
44
|
+
const headerGroupingMaxDepth = useGridSelector(apiRef, gridDensityHeaderGroupingMaxDepthSelector);
|
|
44
45
|
const rootContainerRef = React.useRef(null);
|
|
45
46
|
const handleRef = useForkRef(rootContainerRef, ref);
|
|
46
47
|
const pinnedRowsCount = useGridSelector(apiRef, gridPinnedRowsCountSelector);
|
|
@@ -71,8 +72,7 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
71
72
|
className: clsx(className, classes.root),
|
|
72
73
|
role: "grid",
|
|
73
74
|
"aria-colcount": visibleColumns.length,
|
|
74
|
-
"aria-rowcount":
|
|
75
|
-
,
|
|
75
|
+
"aria-rowcount": headerGroupingMaxDepth + 1 + pinnedRowsCount + totalRowCount,
|
|
76
76
|
"aria-multiselectable": !rootProps.disableMultipleSelection,
|
|
77
77
|
"aria-label": rootProps['aria-label'],
|
|
78
78
|
"aria-labelledby": rootProps['aria-labelledby']
|
|
@@ -35,6 +35,8 @@ export const GridRootStyles = styled('div', {
|
|
|
35
35
|
[`& .${gridClasses.cellContent}`]: styles.cellContent
|
|
36
36
|
}, {
|
|
37
37
|
[`& .${gridClasses.cellCheckbox}`]: styles.cellCheckbox
|
|
38
|
+
}, {
|
|
39
|
+
[`& .${gridClasses.cellSkeleton}`]: styles.cellSkeleton
|
|
38
40
|
}, {
|
|
39
41
|
[`& .${gridClasses.checkboxInput}`]: styles.checkboxInput
|
|
40
42
|
}, {
|
|
@@ -175,13 +177,24 @@ export const GridRootStyles = styled('div', {
|
|
|
175
177
|
minWidth: 0,
|
|
176
178
|
flex: 1,
|
|
177
179
|
whiteSpace: 'nowrap',
|
|
178
|
-
|
|
180
|
+
overflow: 'hidden'
|
|
179
181
|
},
|
|
180
182
|
[`& .${gridClasses.columnHeaderTitleContainerContent}`]: {
|
|
181
183
|
overflow: 'hidden',
|
|
182
184
|
display: 'flex',
|
|
183
185
|
alignItems: 'center'
|
|
184
186
|
},
|
|
187
|
+
[`& .${gridClasses['columnHeader--filledGroup']} .${gridClasses.columnHeaderTitleContainer}`]: {
|
|
188
|
+
borderBottom: `solid ${borderColor} 1px`,
|
|
189
|
+
boxSizing: 'border-box'
|
|
190
|
+
},
|
|
191
|
+
[`& .${gridClasses['columnHeader--filledGroup']}.${gridClasses['columnHeader--showColumnBorder']} .${gridClasses.columnHeaderTitleContainer}`]: {
|
|
192
|
+
borderBottom: `none`
|
|
193
|
+
},
|
|
194
|
+
[`& .${gridClasses['columnHeader--filledGroup']}.${gridClasses['columnHeader--showColumnBorder']}`]: {
|
|
195
|
+
borderBottom: `solid ${borderColor} 1px`,
|
|
196
|
+
boxSizing: 'border-box'
|
|
197
|
+
},
|
|
185
198
|
[`& .${gridClasses.sortIcon}, & .${gridClasses.filterIcon}`]: {
|
|
186
199
|
fontSize: 'inherit'
|
|
187
200
|
},
|
|
@@ -361,7 +374,8 @@ export const GridRootStyles = styled('div', {
|
|
|
361
374
|
},
|
|
362
375
|
[`& .${gridClasses.columnHeaderDraggableContainer}`]: {
|
|
363
376
|
display: 'flex',
|
|
364
|
-
width: '100%'
|
|
377
|
+
width: '100%',
|
|
378
|
+
height: '100%'
|
|
365
379
|
},
|
|
366
380
|
[`& .${gridClasses.rowReorderCellPlaceholder}`]: {
|
|
367
381
|
display: 'none'
|
|
@@ -119,6 +119,7 @@ process.env.NODE_ENV !== "production" ? GridMenu.propTypes = {
|
|
|
119
119
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
120
120
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
121
121
|
// ----------------------------------------------------------------------
|
|
122
|
+
children: PropTypes.node,
|
|
122
123
|
onClickAway: PropTypes.func.isRequired,
|
|
123
124
|
onExited: PropTypes.func,
|
|
124
125
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["sort"];
|
|
2
4
|
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
3
6
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
4
7
|
import IconButton from '@mui/material/IconButton';
|
|
5
8
|
import { switchClasses } from '@mui/material/Switch';
|
|
@@ -54,7 +57,9 @@ const GridColumnsPanelRowRoot = styled('div', {
|
|
|
54
57
|
const GridIconButtonRoot = styled(IconButton)({
|
|
55
58
|
justifyContent: 'flex-end'
|
|
56
59
|
});
|
|
57
|
-
|
|
60
|
+
const collator = new Intl.Collator();
|
|
61
|
+
|
|
62
|
+
function GridColumnsPanel(props) {
|
|
58
63
|
const apiRef = useGridApiContext();
|
|
59
64
|
const searchInputRef = React.useRef(null);
|
|
60
65
|
const columns = useGridSelector(apiRef, gridColumnDefinitionsSelector);
|
|
@@ -66,6 +71,24 @@ export function GridColumnsPanel(props) {
|
|
|
66
71
|
};
|
|
67
72
|
const classes = useUtilityClasses(ownerState);
|
|
68
73
|
|
|
74
|
+
const {
|
|
75
|
+
sort
|
|
76
|
+
} = props,
|
|
77
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
78
|
+
|
|
79
|
+
const sortedColumns = React.useMemo(() => {
|
|
80
|
+
switch (sort) {
|
|
81
|
+
case 'asc':
|
|
82
|
+
return [...columns].sort((a, b) => collator.compare(a.headerName || a.field, b.headerName || b.field));
|
|
83
|
+
|
|
84
|
+
case 'desc':
|
|
85
|
+
return [...columns].sort((a, b) => -collator.compare(a.headerName || a.field, b.headerName || b.field));
|
|
86
|
+
|
|
87
|
+
default:
|
|
88
|
+
return columns;
|
|
89
|
+
}
|
|
90
|
+
}, [columns, sort]);
|
|
91
|
+
|
|
69
92
|
const toggleColumn = event => {
|
|
70
93
|
const {
|
|
71
94
|
name: field
|
|
@@ -99,16 +122,16 @@ export function GridColumnsPanel(props) {
|
|
|
99
122
|
}, []);
|
|
100
123
|
const currentColumns = React.useMemo(() => {
|
|
101
124
|
if (!searchValue) {
|
|
102
|
-
return
|
|
125
|
+
return sortedColumns;
|
|
103
126
|
}
|
|
104
127
|
|
|
105
128
|
const searchValueToCheck = searchValue.toLowerCase();
|
|
106
|
-
return
|
|
107
|
-
}, [
|
|
129
|
+
return sortedColumns.filter(column => (column.headerName || column.field).toLowerCase().indexOf(searchValueToCheck) > -1);
|
|
130
|
+
}, [sortedColumns, searchValue]);
|
|
108
131
|
React.useEffect(() => {
|
|
109
132
|
searchInputRef.current.focus();
|
|
110
133
|
}, []);
|
|
111
|
-
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({},
|
|
134
|
+
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
|
|
112
135
|
children: [/*#__PURE__*/_jsx(GridPanelHeader, {
|
|
113
136
|
children: /*#__PURE__*/_jsx(rootProps.components.BaseTextField, _extends({
|
|
114
137
|
label: apiRef.current.getLocaleText('columnsPanelTextFieldLabel'),
|
|
@@ -155,4 +178,13 @@ export function GridColumnsPanel(props) {
|
|
|
155
178
|
}))]
|
|
156
179
|
})]
|
|
157
180
|
}));
|
|
158
|
-
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
184
|
+
// ----------------------------- Warning --------------------------------
|
|
185
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
186
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
187
|
+
// ----------------------------------------------------------------------
|
|
188
|
+
sort: PropTypes.oneOf(['asc', 'desc'])
|
|
189
|
+
} : void 0;
|
|
190
|
+
export { GridColumnsPanel };
|
|
@@ -96,6 +96,7 @@ process.env.NODE_ENV !== "production" ? GridPanel.propTypes = {
|
|
|
96
96
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
97
97
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
98
98
|
// ----------------------------------------------------------------------
|
|
99
|
+
children: PropTypes.node,
|
|
99
100
|
|
|
100
101
|
/**
|
|
101
102
|
* Override or extend the styles applied to the component.
|
|
@@ -345,6 +345,11 @@ process.env.NODE_ENV !== "production" ? GridFilterForm.propTypes = {
|
|
|
345
345
|
*/
|
|
346
346
|
applyMultiFilterOperatorChanges: PropTypes.func.isRequired,
|
|
347
347
|
|
|
348
|
+
/**
|
|
349
|
+
* @ignore - do not document.
|
|
350
|
+
*/
|
|
351
|
+
children: PropTypes.node,
|
|
352
|
+
|
|
348
353
|
/**
|
|
349
354
|
* Props passed to the column input component.
|
|
350
355
|
* @default {}
|
|
@@ -120,6 +120,11 @@ process.env.NODE_ENV !== "production" ? GridFilterPanel.propTypes = {
|
|
|
120
120
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
121
121
|
// ----------------------------------------------------------------------
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* @ignore - do not document.
|
|
125
|
+
*/
|
|
126
|
+
children: PropTypes.node,
|
|
127
|
+
|
|
123
128
|
/**
|
|
124
129
|
* Changes how the options in the columns selector should be ordered.
|
|
125
130
|
* If not specified, the order is derived from the `columns` prop.
|
|
@@ -7,7 +7,7 @@ import MUISwitch from '@mui/material/Switch';
|
|
|
7
7
|
import MUIButton from '@mui/material/Button';
|
|
8
8
|
import MUITooltip from '@mui/material/Tooltip';
|
|
9
9
|
import MUIPopper from '@mui/material/Popper';
|
|
10
|
-
import { GridArrowDownwardIcon, GridArrowUpwardIcon, GridCell, GridCheckIcon, GridCloseIcon, GridColumnIcon, GridColumnMenu, GridColumnsPanel, GridFilterAltIcon, GridFilterListIcon, GridFilterPanel, GridFooter, GridHeader, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridPreferencesPanel, GridRow, GridSaveAltIcon, GridSeparatorIcon, GridTableRowsIcon, GridTripleDotsVerticalIcon, GridViewHeadlineIcon, GridViewStreamIcon, GridMoreVertIcon, GridExpandMoreIcon, GridKeyboardArrowRight, GridAddIcon, GridRemoveIcon, GridDragIcon, GridColumnHeaderFilterIconButton, GridSearchIcon } from '../components';
|
|
10
|
+
import { GridArrowDownwardIcon, GridArrowUpwardIcon, GridCell, GridSkeletonCell, GridCheckIcon, GridCloseIcon, GridColumnIcon, GridColumnMenu, GridColumnsPanel, GridFilterAltIcon, GridFilterListIcon, GridFilterPanel, GridFooter, GridHeader, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridPreferencesPanel, GridRow, GridSaveAltIcon, GridSeparatorIcon, GridTableRowsIcon, GridTripleDotsVerticalIcon, GridViewHeadlineIcon, GridViewStreamIcon, GridMoreVertIcon, GridExpandMoreIcon, GridKeyboardArrowRight, GridAddIcon, GridRemoveIcon, GridDragIcon, GridColumnHeaderFilterIconButton, GridSearchIcon } from '../components';
|
|
11
11
|
import { GridColumnUnsortedIcon } from '../components/columnHeaders/GridColumnUnsortedIcon';
|
|
12
12
|
import { ErrorOverlay } from '../components/ErrorOverlay';
|
|
13
13
|
import { GridNoResultsOverlay } from '../components/GridNoResultsOverlay';
|
|
@@ -52,6 +52,7 @@ export const DATA_GRID_DEFAULT_SLOTS_COMPONENTS = _extends({}, DEFAULT_GRID_ICON
|
|
|
52
52
|
BaseTooltip: MUITooltip,
|
|
53
53
|
BasePopper: MUIPopper,
|
|
54
54
|
Cell: GridCell,
|
|
55
|
+
SkeletonCell: GridSkeletonCell,
|
|
55
56
|
ColumnHeaderFilterIconButton: GridColumnHeaderFilterIconButton,
|
|
56
57
|
ColumnMenu: GridColumnMenu,
|
|
57
58
|
ErrorOverlay,
|