@mui/x-data-grid 5.15.3 → 5.17.1
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 +150 -1
- package/DataGrid/DataGrid.js +2 -0
- package/DataGrid/useDataGridComponent.js +5 -0
- package/components/DataGridColumnHeaders.js +4 -3
- 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 +3 -3
- package/components/cell/GridBooleanCell.js +2 -1
- package/components/cell/GridCell.js +9 -1
- package/components/cell/GridEditBooleanCell.js +2 -1
- package/components/cell/GridEditDateCell.js +2 -1
- package/components/cell/GridEditInputCell.js +2 -1
- package/components/cell/GridEditSingleSelectCell.js +2 -1
- 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/GridRoot.js +3 -3
- package/components/containers/GridRootStyles.js +16 -2
- package/components/panel/GridColumnsPanel.d.ts +6 -1
- package/components/panel/GridColumnsPanel.js +38 -6
- package/components/panel/GridPanel.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/focus/useGridFocus.js +13 -3
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +1 -0
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -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/useGridVisibleRows.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +3 -1
- package/internals/index.js +3 -1
- package/legacy/DataGrid/DataGrid.js +2 -0
- package/legacy/DataGrid/useDataGridComponent.js +5 -0
- package/legacy/components/DataGridColumnHeaders.js +4 -3
- package/legacy/components/GridRow.js +138 -85
- package/legacy/components/base/GridBody.js +8 -5
- package/legacy/components/base/GridOverlays.js +3 -3
- package/legacy/components/cell/GridBooleanCell.js +2 -1
- package/legacy/components/cell/GridCell.js +11 -1
- package/legacy/components/cell/GridEditBooleanCell.js +2 -1
- package/legacy/components/cell/GridEditDateCell.js +2 -1
- package/legacy/components/cell/GridEditInputCell.js +2 -1
- package/legacy/components/cell/GridEditSingleSelectCell.js +2 -1
- 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/GridRoot.js +3 -3
- package/legacy/components/containers/GridRootStyles.js +14 -5
- package/legacy/components/panel/GridColumnsPanel.js +41 -6
- 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/focus/useGridFocus.js +13 -3
- package/legacy/hooks/features/index.js +1 -0
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -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/index.js +1 -1
- package/legacy/internals/index.js +3 -1
- 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/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 +6 -0
- package/modern/DataGrid/DataGrid.js +2 -0
- package/modern/DataGrid/useDataGridComponent.js +5 -0
- package/modern/components/DataGridColumnHeaders.js +4 -3
- package/modern/components/GridRow.js +133 -84
- package/modern/components/base/GridBody.js +8 -5
- package/modern/components/base/GridOverlays.js +3 -3
- package/modern/components/cell/GridBooleanCell.js +2 -1
- package/modern/components/cell/GridCell.js +9 -1
- package/modern/components/cell/GridEditBooleanCell.js +2 -1
- package/modern/components/cell/GridEditDateCell.js +2 -1
- package/modern/components/cell/GridEditInputCell.js +2 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +2 -1
- 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/GridRoot.js +3 -3
- package/modern/components/containers/GridRootStyles.js +16 -2
- package/modern/components/panel/GridColumnsPanel.js +38 -6
- 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/focus/useGridFocus.js +13 -3
- package/modern/hooks/features/index.js +1 -0
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -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/index.js +1 -1
- package/modern/internals/index.js +3 -1
- 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 +2 -0
- package/node/DataGrid/useDataGridComponent.js +7 -0
- package/node/components/DataGridColumnHeaders.js +4 -3
- package/node/components/GridRow.js +136 -77
- package/node/components/base/GridBody.js +7 -4
- package/node/components/base/GridOverlays.js +2 -2
- package/node/components/cell/GridBooleanCell.js +2 -1
- package/node/components/cell/GridCell.js +9 -1
- package/node/components/cell/GridEditBooleanCell.js +2 -1
- package/node/components/cell/GridEditDateCell.js +2 -1
- package/node/components/cell/GridEditInputCell.js +2 -1
- package/node/components/cell/GridEditSingleSelectCell.js +2 -1
- 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/GridRoot.js +4 -4
- package/node/components/containers/GridRootStyles.js +16 -2
- package/node/components/panel/GridColumnsPanel.js +36 -5
- 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/focus/useGridFocus.js +13 -3
- package/node/hooks/features/index.js +13 -0
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -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/index.js +1 -1
- package/node/internals/index.js +28 -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
|
@@ -21,6 +21,12 @@ var _densitySelector = require("./densitySelector");
|
|
|
21
21
|
|
|
22
22
|
var _utils = require("../../../utils/utils");
|
|
23
23
|
|
|
24
|
+
var _useGridSelector = require("../../utils/useGridSelector");
|
|
25
|
+
|
|
26
|
+
var _columns = require("../columns");
|
|
27
|
+
|
|
28
|
+
var _useGridColumnGrouping = require("../columnGrouping/useGridColumnGrouping");
|
|
29
|
+
|
|
24
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
31
|
|
|
26
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -31,13 +37,14 @@ const COMFORTABLE_DENSITY_FACTOR = 1.3; // TODO v6: revise keeping headerHeight
|
|
|
31
37
|
|
|
32
38
|
exports.COMFORTABLE_DENSITY_FACTOR = COMFORTABLE_DENSITY_FACTOR;
|
|
33
39
|
|
|
34
|
-
const getUpdatedDensityState = (newDensity, newHeaderHeight, newRowHeight) => {
|
|
40
|
+
const getUpdatedDensityState = (newDensity, newHeaderHeight, newRowHeight, newMaxDepth) => {
|
|
35
41
|
switch (newDensity) {
|
|
36
42
|
case _gridDensity.GridDensityTypes.Compact:
|
|
37
43
|
return {
|
|
38
44
|
value: newDensity,
|
|
39
45
|
headerHeight: Math.floor(newHeaderHeight * COMPACT_DENSITY_FACTOR),
|
|
40
46
|
rowHeight: Math.floor(newRowHeight * COMPACT_DENSITY_FACTOR),
|
|
47
|
+
headerGroupingMaxDepth: newMaxDepth,
|
|
41
48
|
factor: COMPACT_DENSITY_FACTOR
|
|
42
49
|
};
|
|
43
50
|
|
|
@@ -46,6 +53,7 @@ const getUpdatedDensityState = (newDensity, newHeaderHeight, newRowHeight) => {
|
|
|
46
53
|
value: newDensity,
|
|
47
54
|
headerHeight: Math.floor(newHeaderHeight * COMFORTABLE_DENSITY_FACTOR),
|
|
48
55
|
rowHeight: Math.floor(newRowHeight * COMFORTABLE_DENSITY_FACTOR),
|
|
56
|
+
headerGroupingMaxDepth: newMaxDepth,
|
|
49
57
|
factor: COMFORTABLE_DENSITY_FACTOR
|
|
50
58
|
};
|
|
51
59
|
|
|
@@ -54,24 +62,55 @@ const getUpdatedDensityState = (newDensity, newHeaderHeight, newRowHeight) => {
|
|
|
54
62
|
value: newDensity,
|
|
55
63
|
headerHeight: newHeaderHeight,
|
|
56
64
|
rowHeight: newRowHeight,
|
|
65
|
+
headerGroupingMaxDepth: newMaxDepth,
|
|
57
66
|
factor: 1
|
|
58
67
|
};
|
|
59
68
|
}
|
|
60
69
|
};
|
|
61
70
|
|
|
62
|
-
const densityStateInitializer = (state, props) =>
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
const densityStateInitializer = (state, props) => {
|
|
72
|
+
// TODO: think about improving this initialization. Could it be done in the useColumn initializer?
|
|
73
|
+
// TODO: manage to remove ts-ignore
|
|
74
|
+
let maxDepth;
|
|
75
|
+
|
|
76
|
+
if (props.columnGroupingModel == null || Object.keys(props.columnGroupingModel).length === 0) {
|
|
77
|
+
maxDepth = 0;
|
|
78
|
+
} else {
|
|
79
|
+
const unwrappedGroupingColumnModel = (0, _useGridColumnGrouping.unwrapGroupingColumnModel)(props.columnGroupingModel);
|
|
80
|
+
const columnsState = state.columns;
|
|
81
|
+
const visibleColumns = columnsState.all.filter(field => columnsState.columnVisibilityModel[field] !== false);
|
|
82
|
+
|
|
83
|
+
if (visibleColumns.length === 0) {
|
|
84
|
+
maxDepth = 0;
|
|
85
|
+
} else {
|
|
86
|
+
maxDepth = Math.max(...visibleColumns.map(field => {
|
|
87
|
+
var _unwrappedGroupingCol, _unwrappedGroupingCol2;
|
|
88
|
+
|
|
89
|
+
return (_unwrappedGroupingCol = (_unwrappedGroupingCol2 = unwrappedGroupingColumnModel[field]) == null ? void 0 : _unwrappedGroupingCol2.length) != null ? _unwrappedGroupingCol : 0;
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return (0, _extends2.default)({}, state, {
|
|
95
|
+
density: getUpdatedDensityState(props.density, props.headerHeight, props.rowHeight, maxDepth)
|
|
96
|
+
});
|
|
97
|
+
};
|
|
65
98
|
|
|
66
99
|
exports.densityStateInitializer = densityStateInitializer;
|
|
67
100
|
|
|
68
101
|
const useGridDensity = (apiRef, props) => {
|
|
102
|
+
const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, _columns.gridVisibleColumnDefinitionsSelector);
|
|
103
|
+
const maxDepth = visibleColumns.length > 0 ? Math.max(...visibleColumns.map(column => {
|
|
104
|
+
var _column$groupPath$len, _column$groupPath;
|
|
105
|
+
|
|
106
|
+
return (_column$groupPath$len = (_column$groupPath = column.groupPath) == null ? void 0 : _column$groupPath.length) != null ? _column$groupPath$len : 0;
|
|
107
|
+
})) : 0;
|
|
69
108
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useDensity');
|
|
70
|
-
const setDensity = React.useCallback((newDensity, newHeaderHeight = props.headerHeight, newRowHeight = props.rowHeight) => {
|
|
109
|
+
const setDensity = React.useCallback((newDensity, newHeaderHeight = props.headerHeight, newRowHeight = props.rowHeight, newMaxDepth = maxDepth) => {
|
|
71
110
|
logger.debug(`Set grid density to ${newDensity}`);
|
|
72
111
|
apiRef.current.setState(state => {
|
|
73
112
|
const currentDensityState = (0, _densitySelector.gridDensitySelector)(state);
|
|
74
|
-
const newDensityState = getUpdatedDensityState(newDensity, newHeaderHeight, newRowHeight);
|
|
113
|
+
const newDensityState = getUpdatedDensityState(newDensity, newHeaderHeight, newRowHeight, newMaxDepth);
|
|
75
114
|
|
|
76
115
|
if ((0, _utils.isDeepEqual)(currentDensityState, newDensityState)) {
|
|
77
116
|
return state;
|
|
@@ -82,10 +121,10 @@ const useGridDensity = (apiRef, props) => {
|
|
|
82
121
|
});
|
|
83
122
|
});
|
|
84
123
|
apiRef.current.forceUpdate();
|
|
85
|
-
}, [logger, apiRef, props.headerHeight, props.rowHeight]);
|
|
124
|
+
}, [logger, apiRef, props.headerHeight, props.rowHeight, maxDepth]);
|
|
86
125
|
React.useEffect(() => {
|
|
87
|
-
apiRef.current.setDensity(props.density, props.headerHeight, props.rowHeight);
|
|
88
|
-
}, [apiRef, props.density, props.rowHeight, props.headerHeight]);
|
|
126
|
+
apiRef.current.setDensity(props.density, props.headerHeight, props.rowHeight, maxDepth);
|
|
127
|
+
}, [apiRef, props.density, props.rowHeight, props.headerHeight, maxDepth]);
|
|
89
128
|
const densityApi = {
|
|
90
129
|
setDensity
|
|
91
130
|
};
|
|
@@ -64,7 +64,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
64
64
|
const rootDimensionsRef = React.useRef(null);
|
|
65
65
|
const fullDimensionsRef = React.useRef(null);
|
|
66
66
|
const rowsMeta = (0, _utils2.useGridSelector)(apiRef, _gridRowsMetaSelector.gridRowsMetaSelector);
|
|
67
|
-
const
|
|
67
|
+
const totalHeaderHeight = (0, _utils2.useGridSelector)(apiRef, _density.gridDensityTotalHeaderHeightSelector);
|
|
68
68
|
const updateGridDimensionsRef = React.useCallback(() => {
|
|
69
69
|
var _apiRef$current$rootE;
|
|
70
70
|
|
|
@@ -109,7 +109,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
109
109
|
} else {
|
|
110
110
|
viewportOuterSize = {
|
|
111
111
|
width: rootDimensionsRef.current.width,
|
|
112
|
-
height: rootDimensionsRef.current.height -
|
|
112
|
+
height: rootDimensionsRef.current.height - totalHeaderHeight
|
|
113
113
|
};
|
|
114
114
|
const scrollInformation = hasScroll({
|
|
115
115
|
content: {
|
|
@@ -143,7 +143,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
143
143
|
if (newFullDimensions.viewportInnerSize.width !== (prevDimensions == null ? void 0 : prevDimensions.viewportInnerSize.width) || newFullDimensions.viewportInnerSize.height !== (prevDimensions == null ? void 0 : prevDimensions.viewportInnerSize.height)) {
|
|
144
144
|
apiRef.current.publishEvent('viewportInnerSizeChange', newFullDimensions.viewportInnerSize);
|
|
145
145
|
}
|
|
146
|
-
}, [apiRef, props.scrollbarSize, props.autoHeight,
|
|
146
|
+
}, [apiRef, props.scrollbarSize, props.autoHeight, totalHeaderHeight, rowsMeta.currentPageTotalHeight]);
|
|
147
147
|
const resize = React.useCallback(() => {
|
|
148
148
|
updateGridDimensionsRef();
|
|
149
149
|
apiRef.current.publishEvent('debouncedResize', rootDimensionsRef.current);
|
|
@@ -104,7 +104,7 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
const
|
|
107
|
+
const totalHeaderHeight = (0, _densitySelector.gridDensityTotalHeaderHeightSelector)(apiRef);
|
|
108
108
|
const rowsMeta = (0, _gridRowsMetaSelector.gridRowsMetaSelector)(apiRef.current.state);
|
|
109
109
|
const gridRootElement = apiRef.current.rootElementRef.current;
|
|
110
110
|
const gridClone = gridRootElement.cloneNode(true);
|
|
@@ -138,7 +138,7 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
138
138
|
} // Expand container height to accommodate all rows
|
|
139
139
|
|
|
140
140
|
|
|
141
|
-
gridClone.style.height = `${rowsMeta.currentPageTotalHeight +
|
|
141
|
+
gridClone.style.height = `${rowsMeta.currentPageTotalHeight + totalHeaderHeight + gridToolbarElementHeight + gridFooterElementHeight}px`; // Remove all loaded elements from the current host
|
|
142
142
|
|
|
143
143
|
printDoc.body.innerHTML = '';
|
|
144
144
|
printDoc.body.appendChild(gridClone);
|
|
@@ -88,76 +88,75 @@ exports.sanitizeFilterModel = sanitizeFilterModel;
|
|
|
88
88
|
const mergeStateWithFilterModel = (filterModel, disableMultipleColumnsFiltering, apiRef) => filteringState => (0, _extends2.default)({}, filteringState, {
|
|
89
89
|
filterModel: sanitizeFilterModel(filterModel, disableMultipleColumnsFiltering, apiRef)
|
|
90
90
|
});
|
|
91
|
-
/**
|
|
92
|
-
* Generates a method to easily check if a row is matching the current filter model.
|
|
93
|
-
* @param {GridFilterModel} filterModel The model with which we want to filter the rows.
|
|
94
|
-
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
95
|
-
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
91
|
|
|
99
92
|
exports.mergeStateWithFilterModel = mergeStateWithFilterModel;
|
|
100
93
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const getFilterCallbackFromItem = filterItem => {
|
|
107
|
-
if (!filterItem.columnField || !filterItem.operatorValue) {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
94
|
+
const getFilterCallbackFromItem = (filterItem, apiRef) => {
|
|
95
|
+
if (!filterItem.columnField || !filterItem.operatorValue) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
110
98
|
|
|
111
|
-
|
|
99
|
+
const column = apiRef.current.getColumn(filterItem.columnField);
|
|
112
100
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
if (!column) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
116
104
|
|
|
117
|
-
|
|
105
|
+
let parsedValue;
|
|
118
106
|
|
|
119
|
-
|
|
120
|
-
|
|
107
|
+
if (column.valueParser) {
|
|
108
|
+
var _filterItem$value;
|
|
121
109
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
110
|
+
const parser = column.valueParser;
|
|
111
|
+
parsedValue = Array.isArray(filterItem.value) ? (_filterItem$value = filterItem.value) == null ? void 0 : _filterItem$value.map(x => parser(x)) : parser(filterItem.value);
|
|
112
|
+
} else {
|
|
113
|
+
parsedValue = filterItem.value;
|
|
114
|
+
}
|
|
127
115
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
116
|
+
const newFilterItem = (0, _extends2.default)({}, filterItem, {
|
|
117
|
+
value: parsedValue
|
|
118
|
+
});
|
|
119
|
+
const filterOperators = column.filterOperators;
|
|
132
120
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
121
|
+
if (!(filterOperators != null && filterOperators.length)) {
|
|
122
|
+
throw new Error(`MUI: No filter operators found for column '${column.field}'.`);
|
|
123
|
+
}
|
|
136
124
|
|
|
137
|
-
|
|
125
|
+
const filterOperator = filterOperators.find(operator => operator.value === newFilterItem.operatorValue);
|
|
138
126
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
127
|
+
if (!filterOperator) {
|
|
128
|
+
throw new Error(`MUI: No filter operator found for column '${column.field}' and operator value '${newFilterItem.operatorValue}'.`);
|
|
129
|
+
}
|
|
142
130
|
|
|
143
|
-
|
|
131
|
+
const applyFilterOnRow = filterOperator.getApplyFilterFn(newFilterItem, column);
|
|
144
132
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
133
|
+
if (typeof applyFilterOnRow !== 'function') {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
148
136
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
137
|
+
const fn = rowId => {
|
|
138
|
+
const cellParams = apiRef.current.getCellParams(rowId, newFilterItem.columnField);
|
|
139
|
+
return applyFilterOnRow(cellParams);
|
|
140
|
+
};
|
|
153
141
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
};
|
|
142
|
+
return {
|
|
143
|
+
fn,
|
|
144
|
+
item: newFilterItem
|
|
158
145
|
};
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Generates a method to easily check if a row is matching the current filter model.
|
|
149
|
+
* @param {GridFilterModel} filterModel The model with which we want to filter the rows.
|
|
150
|
+
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
151
|
+
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
152
|
+
*/
|
|
159
153
|
|
|
160
|
-
|
|
154
|
+
|
|
155
|
+
const buildAggregatedFilterItemsApplier = (filterModel, apiRef) => {
|
|
156
|
+
const {
|
|
157
|
+
items
|
|
158
|
+
} = filterModel;
|
|
159
|
+
const appliers = items.map(item => getFilterCallbackFromItem(item, apiRef)).filter(callback => !!callback);
|
|
161
160
|
|
|
162
161
|
if (appliers.length === 0) {
|
|
163
162
|
return null;
|
|
@@ -249,9 +248,10 @@ const buildAggregatedFilterApplier = (filterModel, apiRef) => {
|
|
|
249
248
|
|
|
250
249
|
exports.buildAggregatedFilterApplier = buildAggregatedFilterApplier;
|
|
251
250
|
|
|
252
|
-
const passFilterLogic = (allFilterItemResults, allQuickFilterResults, filterModel) => {
|
|
251
|
+
const passFilterLogic = (allFilterItemResults, allQuickFilterResults, filterModel, apiRef) => {
|
|
253
252
|
var _filterModel$quickFil, _filterModel$linkOper;
|
|
254
253
|
|
|
254
|
+
const cleanedFilterItems = filterModel.items.filter(item => getFilterCallbackFromItem(item, apiRef) !== null);
|
|
255
255
|
const cleanedAllFilterItemResults = allFilterItemResults.filter(result => result != null);
|
|
256
256
|
const cleanedAllQuickFilterResults = allQuickFilterResults.filter(result => result != null); // Defaultize operators
|
|
257
257
|
|
|
@@ -265,13 +265,13 @@ const passFilterLogic = (allFilterItemResults, allQuickFilterResults, filterMode
|
|
|
265
265
|
};
|
|
266
266
|
|
|
267
267
|
if (linkOperator === _models.GridLinkOperator.And) {
|
|
268
|
-
const passesAllFilters =
|
|
268
|
+
const passesAllFilters = cleanedFilterItems.every(filterItemPredicate);
|
|
269
269
|
|
|
270
270
|
if (!passesAllFilters) {
|
|
271
271
|
return false;
|
|
272
272
|
}
|
|
273
273
|
} else {
|
|
274
|
-
const passesSomeFilters =
|
|
274
|
+
const passesSomeFilters = cleanedFilterItems.some(filterItemPredicate);
|
|
275
275
|
|
|
276
276
|
if (!passesSomeFilters) {
|
|
277
277
|
return false;
|
|
@@ -304,7 +304,7 @@ const useGridFilter = (apiRef, props) => {
|
|
|
304
304
|
passingFilterItems,
|
|
305
305
|
passingQuickFilterValues
|
|
306
306
|
} = params.isRowMatchingFilters(rowId);
|
|
307
|
-
isRowPassing = (0, _gridFilterUtils.passFilterLogic)([passingFilterItems], [passingQuickFilterValues], params.filterModel);
|
|
307
|
+
isRowPassing = (0, _gridFilterUtils.passFilterLogic)([passingFilterItems], [passingQuickFilterValues], params.filterModel, apiRef);
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
filteredRowsLookup[rowId] = isRowPassing;
|
|
@@ -158,8 +158,18 @@ const useGridFocus = (apiRef, props) => {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
rowIndexToFocus = (0, _utils2.clamp)(rowIndexToFocus, 0, currentPage.rows.length - 1);
|
|
161
|
-
columnIndexToFocus = (0, _utils2.clamp)(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
162
161
|
const rowToFocus = currentPage.rows[rowIndexToFocus];
|
|
162
|
+
const colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
|
|
163
|
+
|
|
164
|
+
if (colSpanInfo && colSpanInfo.spannedByColSpan) {
|
|
165
|
+
if (direction === 'left' || direction === 'below') {
|
|
166
|
+
columnIndexToFocus = colSpanInfo.leftVisibleCellIndex;
|
|
167
|
+
} else if (direction === 'right') {
|
|
168
|
+
columnIndexToFocus = colSpanInfo.rightVisibleCellIndex;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
columnIndexToFocus = (0, _utils2.clamp)(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
163
173
|
const columnToFocus = visibleColumns[columnIndexToFocus];
|
|
164
174
|
apiRef.current.setCellFocus(rowToFocus.id, columnToFocus.field);
|
|
165
175
|
}, [apiRef, props.pagination, props.paginationMode]);
|
|
@@ -195,7 +205,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
195
205
|
}
|
|
196
206
|
}));
|
|
197
207
|
}, [logger, apiRef]);
|
|
198
|
-
const
|
|
208
|
+
const handleCellMouseDown = React.useCallback(params => {
|
|
199
209
|
lastClickedCell.current = params;
|
|
200
210
|
}, []);
|
|
201
211
|
const handleDocumentClick = React.useCallback(event => {
|
|
@@ -278,7 +288,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
278
288
|
}, [apiRef, handleDocumentClick]);
|
|
279
289
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderBlur', handleBlur);
|
|
280
290
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellDoubleClick', handleCellDoubleClick);
|
|
281
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, '
|
|
291
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellMouseDown', handleCellMouseDown);
|
|
282
292
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
283
293
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellModeChange', handleCellModeChange);
|
|
284
294
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
|
|
@@ -30,6 +30,19 @@ Object.keys(_columns).forEach(function (key) {
|
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
+
var _columnGrouping = require("./columnGrouping");
|
|
34
|
+
|
|
35
|
+
Object.keys(_columnGrouping).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _columnGrouping[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _columnGrouping[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
33
46
|
var _density = require("./density");
|
|
34
47
|
|
|
35
48
|
Object.keys(_density).forEach(function (key) {
|
|
@@ -56,6 +56,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
56
56
|
* @param {number} colIndex Index of the column to focus
|
|
57
57
|
* @param {number} rowIndex index of the row to focus
|
|
58
58
|
* @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
|
|
59
|
+
* TODO replace with apiRef.current.unstable_moveFocusToRelativeCell()
|
|
59
60
|
*/
|
|
60
61
|
|
|
61
62
|
const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left') => {
|
|
@@ -112,6 +113,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
112
113
|
case 'ArrowDown':
|
|
113
114
|
case 'Enter':
|
|
114
115
|
{
|
|
116
|
+
// TODO v6: Remove Enter case because `cellNavigationKeyDown` is not fired by the new editing API
|
|
115
117
|
// "Enter" is only triggered by the row / cell editing feature
|
|
116
118
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
117
119
|
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
|
|
@@ -131,14 +131,14 @@ const useGridRows = (apiRef, props) => {
|
|
|
131
131
|
} // we remove duplicate updates. A server can batch updates, and send several updates for the same row in one fn call.
|
|
132
132
|
|
|
133
133
|
|
|
134
|
-
const
|
|
134
|
+
const uniqueUpdates = new Map();
|
|
135
135
|
updates.forEach(update => {
|
|
136
136
|
const id = (0, _gridRowsUtils.getRowIdFromRowModel)(update, props.getRowId, 'A row was provided without id when calling updateRows():');
|
|
137
137
|
|
|
138
|
-
if (
|
|
139
|
-
|
|
138
|
+
if (uniqueUpdates.has(id)) {
|
|
139
|
+
uniqueUpdates.set(id, (0, _extends2.default)({}, uniqueUpdates.get(id), update));
|
|
140
140
|
} else {
|
|
141
|
-
|
|
141
|
+
uniqueUpdates.set(id, update);
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
144
|
const deletedRowIds = [];
|
|
@@ -150,7 +150,7 @@ const useGridRows = (apiRef, props) => {
|
|
|
150
150
|
idToIdLookup: (0, _extends2.default)({}, prevCache.idToIdLookup),
|
|
151
151
|
ids: [...prevCache.ids]
|
|
152
152
|
};
|
|
153
|
-
|
|
153
|
+
uniqueUpdates.forEach((partialRow, id) => {
|
|
154
154
|
// eslint-disable-next-line no-underscore-dangle
|
|
155
155
|
if (partialRow._action === 'delete') {
|
|
156
156
|
delete newCache.idRowsLookup[id];
|
|
@@ -267,8 +267,60 @@ const useGridRows = (apiRef, props) => {
|
|
|
267
267
|
ids: updatedRows
|
|
268
268
|
})
|
|
269
269
|
}));
|
|
270
|
-
apiRef.current.
|
|
270
|
+
apiRef.current.publishEvent('rowsSet');
|
|
271
271
|
}, [apiRef, logger]);
|
|
272
|
+
const replaceRows = React.useCallback((firstRowToRender, newRows) => {
|
|
273
|
+
if (props.signature === _useGridApiEventHandler.GridSignature.DataGrid && newRows.length > 1) {
|
|
274
|
+
throw new Error(["MUI: You can't replace rows using `apiRef.current.unstable_replaceRows` on the DataGrid.", 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n'));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (newRows.length === 0) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const allRows = (0, _gridRowsSelector.gridRowIdsSelector)(apiRef);
|
|
282
|
+
const updatedRows = [...allRows];
|
|
283
|
+
const idRowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
284
|
+
const idToIdLookup = (0, _gridRowsSelector.gridRowsIdToIdLookupSelector)(apiRef);
|
|
285
|
+
const tree = (0, _gridRowsSelector.gridRowTreeSelector)(apiRef);
|
|
286
|
+
const updatedIdRowsLookup = (0, _extends2.default)({}, idRowsLookup);
|
|
287
|
+
const updatedIdToIdLookup = (0, _extends2.default)({}, idToIdLookup);
|
|
288
|
+
const updatedTree = (0, _extends2.default)({}, tree);
|
|
289
|
+
const newRowEntries = newRows.map(newRowModel => {
|
|
290
|
+
const rowId = (0, _gridRowsUtils.getRowIdFromRowModel)(newRowModel, props.getRowId, 'A row was provided without id when calling replaceRows().');
|
|
291
|
+
return {
|
|
292
|
+
id: rowId,
|
|
293
|
+
model: newRowModel
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
newRowEntries.forEach((row, index) => {
|
|
297
|
+
const [replacedRowId] = updatedRows.splice(firstRowToRender + index, 1, row.id);
|
|
298
|
+
delete updatedIdRowsLookup[replacedRowId];
|
|
299
|
+
delete updatedIdToIdLookup[replacedRowId];
|
|
300
|
+
delete updatedTree[replacedRowId];
|
|
301
|
+
});
|
|
302
|
+
newRowEntries.forEach(row => {
|
|
303
|
+
const rowTreeNodeConfig = {
|
|
304
|
+
id: row.id,
|
|
305
|
+
parent: null,
|
|
306
|
+
depth: 0,
|
|
307
|
+
groupingKey: null,
|
|
308
|
+
groupingField: null
|
|
309
|
+
};
|
|
310
|
+
updatedIdRowsLookup[row.id] = row.model;
|
|
311
|
+
updatedIdToIdLookup[row.id] = row.id;
|
|
312
|
+
updatedTree[row.id] = rowTreeNodeConfig;
|
|
313
|
+
});
|
|
314
|
+
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
315
|
+
rows: (0, _extends2.default)({}, state.rows, {
|
|
316
|
+
idRowsLookup: updatedIdRowsLookup,
|
|
317
|
+
idToIdLookup: updatedIdToIdLookup,
|
|
318
|
+
tree: updatedTree,
|
|
319
|
+
ids: updatedRows
|
|
320
|
+
})
|
|
321
|
+
}));
|
|
322
|
+
apiRef.current.publishEvent('rowsSet');
|
|
323
|
+
}, [apiRef, props.signature, props.getRowId]);
|
|
272
324
|
const rowApi = {
|
|
273
325
|
getRow,
|
|
274
326
|
getRowModels,
|
|
@@ -280,7 +332,8 @@ const useGridRows = (apiRef, props) => {
|
|
|
280
332
|
setRowChildrenExpansion,
|
|
281
333
|
getRowNode,
|
|
282
334
|
getRowIndexRelativeToVisibleRows,
|
|
283
|
-
getRowGroupChildren
|
|
335
|
+
getRowGroupChildren,
|
|
336
|
+
unstable_replaceRows: replaceRows
|
|
284
337
|
};
|
|
285
338
|
/**
|
|
286
339
|
* EVENTS
|
|
@@ -75,7 +75,7 @@ const useGridRowsMeta = (apiRef, props) => {
|
|
|
75
75
|
if (!rowsHeightLookup.current[row.id]) {
|
|
76
76
|
rowsHeightLookup.current[row.id] = {
|
|
77
77
|
sizes: {
|
|
78
|
-
|
|
78
|
+
baseCenter: rowHeightFromDensity
|
|
79
79
|
},
|
|
80
80
|
isResized: false,
|
|
81
81
|
autoHeight: false,
|
|
@@ -90,7 +90,7 @@ const useGridRowsMeta = (apiRef, props) => {
|
|
|
90
90
|
sizes
|
|
91
91
|
} = rowsHeightLookup.current[row.id];
|
|
92
92
|
let baseRowHeight = rowHeightFromDensity;
|
|
93
|
-
const existingBaseRowHeight = sizes.
|
|
93
|
+
const existingBaseRowHeight = sizes.baseCenter;
|
|
94
94
|
|
|
95
95
|
if (isResized) {
|
|
96
96
|
// Do not recalculate resized row height and use the value from the lookup
|
|
@@ -121,12 +121,19 @@ const useGridRowsMeta = (apiRef, props) => {
|
|
|
121
121
|
}
|
|
122
122
|
} else {
|
|
123
123
|
rowsHeightLookup.current[row.id].needsFirstMeasurement = false;
|
|
124
|
-
}
|
|
124
|
+
}
|
|
125
125
|
|
|
126
|
+
const existingBaseSizes = Object.entries(sizes).reduce((acc, [key, size]) => {
|
|
127
|
+
if (/^base[A-Z]/.test(key)) {
|
|
128
|
+
acc[key] = size;
|
|
129
|
+
}
|
|
126
130
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
return acc;
|
|
132
|
+
}, {}); // We use an object to make simple to check if a height is already added or not
|
|
133
|
+
|
|
134
|
+
const initialHeights = (0, _extends2.default)({}, existingBaseSizes, {
|
|
135
|
+
baseCenter: baseRowHeight
|
|
136
|
+
});
|
|
130
137
|
|
|
131
138
|
if (getRowSpacing) {
|
|
132
139
|
var _spacing$top, _spacing$bottom;
|
|
@@ -149,9 +156,17 @@ const useGridRowsMeta = (apiRef, props) => {
|
|
|
149
156
|
const positions = [];
|
|
150
157
|
const currentPageTotalHeight = currentPage.rows.reduce((acc, row) => {
|
|
151
158
|
positions.push(acc);
|
|
159
|
+
let maximumBaseSize = 0;
|
|
160
|
+
let otherSizes = 0;
|
|
152
161
|
const processedSizes = calculateRowProcessedSizes(row);
|
|
153
|
-
|
|
154
|
-
|
|
162
|
+
Object.entries(processedSizes).forEach(([size, value]) => {
|
|
163
|
+
if (/^base[A-Z]/.test(size)) {
|
|
164
|
+
maximumBaseSize = value > maximumBaseSize ? value : maximumBaseSize;
|
|
165
|
+
} else {
|
|
166
|
+
otherSizes += value;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return acc + maximumBaseSize + otherSizes;
|
|
155
170
|
}, 0);
|
|
156
171
|
pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.forEach(row => {
|
|
157
172
|
calculateRowProcessedSizes(row);
|
|
@@ -177,7 +192,7 @@ const useGridRowsMeta = (apiRef, props) => {
|
|
|
177
192
|
}, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight, pinnedRows]);
|
|
178
193
|
const getRowHeight = React.useCallback(rowId => {
|
|
179
194
|
const height = rowsHeightLookup.current[rowId];
|
|
180
|
-
return height ? height.sizes.
|
|
195
|
+
return height ? height.sizes.baseCenter : rowHeightFromDensity;
|
|
181
196
|
}, [rowHeightFromDensity]);
|
|
182
197
|
|
|
183
198
|
const getRowInternalSizes = rowId => {
|
|
@@ -187,21 +202,21 @@ const useGridRowsMeta = (apiRef, props) => {
|
|
|
187
202
|
};
|
|
188
203
|
|
|
189
204
|
const setRowHeight = React.useCallback((id, height) => {
|
|
190
|
-
rowsHeightLookup.current[id].sizes.
|
|
205
|
+
rowsHeightLookup.current[id].sizes.baseCenter = height;
|
|
191
206
|
rowsHeightLookup.current[id].isResized = true;
|
|
192
207
|
rowsHeightLookup.current[id].needsFirstMeasurement = false;
|
|
193
208
|
hydrateRowsMeta();
|
|
194
209
|
}, [hydrateRowsMeta]);
|
|
195
210
|
const debouncedHydrateRowsMeta = React.useMemo(() => (0, _utils.debounce)(hydrateRowsMeta), [hydrateRowsMeta]);
|
|
196
|
-
const storeMeasuredRowHeight = React.useCallback((id, height) => {
|
|
211
|
+
const storeMeasuredRowHeight = React.useCallback((id, height, position) => {
|
|
197
212
|
if (!rowsHeightLookup.current[id] || !rowsHeightLookup.current[id].autoHeight) {
|
|
198
213
|
return;
|
|
199
214
|
} // Only trigger hydration if the value is different, otherwise we trigger a loop
|
|
200
215
|
|
|
201
216
|
|
|
202
|
-
const needsHydration = rowsHeightLookup.current[id].sizes
|
|
217
|
+
const needsHydration = rowsHeightLookup.current[id].sizes[`base${(0, _utils.capitalize)(position)}`] !== height;
|
|
203
218
|
rowsHeightLookup.current[id].needsFirstMeasurement = false;
|
|
204
|
-
rowsHeightLookup.current[id].sizes
|
|
219
|
+
rowsHeightLookup.current[id].sizes[`base${(0, _utils.capitalize)(position)}`] = height;
|
|
205
220
|
|
|
206
221
|
if (needsHydration) {
|
|
207
222
|
debouncedHydrateRowsMeta();
|
|
@@ -219,7 +234,11 @@ const useGridRowsMeta = (apiRef, props) => {
|
|
|
219
234
|
if (hasRowWithAutoHeight.current && index > lastMeasuredRowIndex.current) {
|
|
220
235
|
lastMeasuredRowIndex.current = index;
|
|
221
236
|
}
|
|
222
|
-
}, []);
|
|
237
|
+
}, []);
|
|
238
|
+
const resetRowHeights = React.useCallback(() => {
|
|
239
|
+
rowsHeightLookup.current = {};
|
|
240
|
+
hydrateRowsMeta();
|
|
241
|
+
}, [hydrateRowsMeta]); // The effect is used to build the rows meta data - currentPageTotalHeight and positions.
|
|
223
242
|
// Because of variable row height this is needed for the virtualization
|
|
224
243
|
|
|
225
244
|
React.useEffect(() => {
|
|
@@ -233,7 +252,8 @@ const useGridRowsMeta = (apiRef, props) => {
|
|
|
233
252
|
unstable_getRowHeight: getRowHeight,
|
|
234
253
|
unstable_getRowInternalSizes: getRowInternalSizes,
|
|
235
254
|
unstable_setRowHeight: setRowHeight,
|
|
236
|
-
unstable_storeRowHeightMeasurement: storeMeasuredRowHeight
|
|
255
|
+
unstable_storeRowHeightMeasurement: storeMeasuredRowHeight,
|
|
256
|
+
resetRowHeights
|
|
237
257
|
};
|
|
238
258
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, rowsMetaApi, 'GridRowsMetaApi');
|
|
239
259
|
};
|