@mui/x-data-grid 5.11.1 → 5.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +199 -20
- package/DataGrid/DataGrid.js +26 -1
- package/README.md +2 -2
- package/colDef/gridCheckboxSelectionColDef.d.ts +1 -0
- package/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/colDef/gridDateOperators.d.ts +1 -1
- package/colDef/gridNumericColDef.js +1 -1
- package/components/GridRow.d.ts +1 -1
- package/components/GridRow.js +51 -12
- package/components/cell/GridActionsCellItem.d.ts +1 -1
- package/components/cell/GridCell.d.ts +2 -1
- package/components/cell/GridCell.js +12 -7
- package/components/columnHeaders/GridColumnHeaderItem.js +9 -6
- package/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/components/containers/GridRootStyles.js +8 -3
- package/components/menu/GridMenu.js +9 -2
- package/components/panel/GridColumnsPanel.js +12 -7
- package/components/panel/GridPanelWrapper.d.ts +1 -1
- package/components/panel/GridPanelWrapper.js +3 -3
- package/components/panel/filterPanel/GridFilterForm.d.ts +61 -4
- package/components/panel/filterPanel/GridFilterForm.js +88 -8
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/components/panel/filterPanel/GridFilterPanel.d.ts +8 -5
- package/components/panel/filterPanel/GridFilterPanel.js +26 -11
- package/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
- package/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/components/toolbar/GridToolbarQuickFilter.d.ts +7 -0
- package/components/toolbar/GridToolbarQuickFilter.js +57 -4
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +4 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +1 -0
- package/hooks/core/useGridStateInitialization.js +19 -6
- package/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -0
- package/hooks/features/columns/useGridColumnSpanning.d.ts +1 -1
- package/hooks/features/columns/useGridColumnSpanning.js +1 -1
- package/hooks/features/columns/useGridColumns.d.ts +1 -1
- package/hooks/features/columns/useGridColumns.js +13 -15
- package/hooks/features/dimensions/gridDimensionsApi.d.ts +5 -0
- package/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/hooks/features/editRows/useGridCellEditing.new.js +11 -4
- package/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +10 -4
- package/hooks/features/events/useGridEvents.d.ts +1 -1
- package/hooks/features/events/useGridEvents.js +2 -0
- package/hooks/features/filter/gridFilterSelector.d.ts +5 -0
- package/hooks/features/filter/gridFilterSelector.js +6 -0
- package/hooks/features/filter/gridFilterState.d.ts +1 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +10 -2
- package/hooks/features/filter/gridFilterUtils.js +3 -6
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.js +29 -12
- package/hooks/features/pagination/useGridPage.js +1 -1
- package/hooks/features/pagination/useGridPageSize.js +1 -1
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +133 -67
- package/hooks/features/selection/useGridSelection.js +1 -1
- package/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/sorting/useGridSorting.js +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +2 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +65 -11
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/legacy/DataGrid/DataGrid.js +26 -1
- package/legacy/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/legacy/colDef/gridNumericColDef.js +1 -1
- package/legacy/components/GridRow.js +56 -12
- package/legacy/components/cell/GridCell.js +12 -7
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +11 -6
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/legacy/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/legacy/components/containers/GridRootStyles.js +10 -7
- package/legacy/components/menu/GridMenu.js +9 -2
- package/legacy/components/panel/GridColumnsPanel.js +14 -7
- package/legacy/components/panel/GridPanelWrapper.js +3 -3
- package/legacy/components/panel/filterPanel/GridFilterForm.js +89 -8
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +28 -12
- package/legacy/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/legacy/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/legacy/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/legacy/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/legacy/components/toolbar/GridToolbarQuickFilter.js +67 -6
- package/legacy/constants/defaultGridSlotsComponents.js +2 -1
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +1 -0
- package/legacy/hooks/core/useGridStateInitialization.js +18 -6
- package/legacy/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +1 -1
- package/legacy/hooks/features/columns/useGridColumns.js +13 -15
- package/legacy/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +14 -7
- package/legacy/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +10 -4
- package/legacy/hooks/features/events/useGridEvents.js +2 -0
- package/legacy/hooks/features/filter/gridFilterSelector.js +8 -0
- package/legacy/hooks/features/filter/gridFilterUtils.js +4 -7
- package/legacy/hooks/features/filter/useGridFilter.js +33 -12
- package/legacy/hooks/features/pagination/useGridPage.js +1 -1
- package/legacy/hooks/features/pagination/useGridPageSize.js +1 -1
- package/legacy/hooks/features/rows/useGridRowsMeta.js +133 -66
- package/legacy/hooks/features/selection/useGridSelection.js +1 -1
- package/legacy/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
- package/legacy/hooks/features/sorting/useGridSorting.js +1 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +84 -26
- package/legacy/index.js +1 -1
- package/legacy/locales/arSD.js +1 -0
- package/legacy/locales/bgBG.js +1 -0
- package/legacy/locales/csCZ.js +1 -0
- package/legacy/locales/daDK.js +1 -0
- package/legacy/locales/deDE.js +1 -0
- package/legacy/locales/elGR.js +1 -0
- package/legacy/locales/esES.js +1 -0
- package/legacy/locales/faIR.js +1 -0
- package/legacy/locales/fiFI.js +1 -0
- package/legacy/locales/frFR.js +1 -0
- package/legacy/locales/heIL.js +10 -9
- package/legacy/locales/huHU.js +1 -0
- package/legacy/locales/itIT.js +1 -0
- package/legacy/locales/jaJP.js +29 -24
- package/legacy/locales/koKR.js +1 -0
- package/legacy/locales/nbNO.js +128 -0
- package/legacy/locales/nlNL.js +1 -0
- package/legacy/locales/plPL.js +1 -0
- package/legacy/locales/ptBR.js +1 -0
- package/legacy/locales/ruRU.js +7 -6
- package/legacy/locales/skSK.js +1 -0
- package/legacy/locales/trTR.js +8 -7
- package/legacy/locales/ukUA.js +1 -0
- package/legacy/locales/viVN.js +1 -0
- package/legacy/locales/zhCN.js +1 -0
- package/legacy/models/events/gridEvents.js +2 -0
- package/legacy/models/gridApiCaches.js +1 -0
- package/legacy/models/params/gridMenuParams.js +1 -0
- package/legacy/models/params/index.js +2 -1
- package/locales/arSD.js +1 -0
- package/locales/bgBG.js +1 -0
- package/locales/csCZ.js +1 -0
- package/locales/daDK.js +1 -0
- package/locales/deDE.js +1 -0
- package/locales/elGR.js +1 -0
- package/locales/esES.js +1 -0
- package/locales/faIR.js +1 -0
- package/locales/fiFI.js +1 -0
- package/locales/frFR.js +1 -0
- package/locales/heIL.js +10 -9
- package/locales/huHU.js +1 -0
- package/locales/itIT.js +1 -0
- package/locales/jaJP.js +25 -24
- package/locales/koKR.js +1 -0
- package/locales/nbNO.d.ts +2 -0
- package/locales/nbNO.js +116 -0
- package/locales/nlNL.js +1 -0
- package/locales/plPL.js +1 -0
- package/locales/ptBR.js +1 -0
- package/locales/ruRU.js +7 -6
- package/locales/skSK.js +1 -0
- package/locales/trTR.js +8 -7
- package/locales/ukUA.js +1 -0
- package/locales/viVN.js +1 -0
- package/locales/zhCN.js +1 -0
- package/models/api/gridCallbackDetails.d.ts +6 -1
- package/models/api/gridCoreApi.d.ts +2 -6
- package/models/api/gridFilterApi.d.ts +8 -1
- package/models/api/gridLocaleTextApi.d.ts +1 -0
- package/models/api/gridRowsMetaApi.d.ts +24 -0
- package/models/api/gridStateApi.d.ts +14 -3
- package/models/colDef/gridColDef.d.ts +4 -4
- package/models/events/gridEventLookup.d.ts +16 -1
- package/models/events/gridEvents.d.ts +3 -1
- package/models/events/gridEvents.js +2 -0
- package/models/gridApiCaches.d.ts +6 -0
- package/models/gridApiCaches.js +1 -0
- package/models/gridIconSlotsComponent.d.ts +5 -0
- package/models/params/gridMenuParams.d.ts +7 -0
- package/models/params/gridMenuParams.js +1 -0
- package/models/params/gridRowParams.d.ts +1 -1
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +2 -1
- package/models/props/DataGridProps.d.ts +24 -2
- package/modern/DataGrid/DataGrid.js +26 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/modern/colDef/gridNumericColDef.js +1 -1
- package/modern/components/GridRow.js +51 -12
- package/modern/components/cell/GridCell.js +12 -7
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +9 -6
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/modern/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/modern/components/containers/GridRootStyles.js +8 -3
- package/modern/components/menu/GridMenu.js +9 -2
- package/modern/components/panel/GridColumnsPanel.js +12 -7
- package/modern/components/panel/GridPanelWrapper.js +3 -3
- package/modern/components/panel/filterPanel/GridFilterForm.js +88 -8
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/modern/components/panel/filterPanel/GridFilterPanel.js +26 -11
- package/modern/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/modern/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/modern/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/modern/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/modern/components/toolbar/GridToolbarQuickFilter.js +57 -4
- package/modern/constants/defaultGridSlotsComponents.js +2 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +1 -0
- package/modern/hooks/core/useGridStateInitialization.js +19 -6
- package/modern/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
- package/modern/hooks/features/columns/useGridColumnSpanning.js +1 -1
- package/modern/hooks/features/columns/useGridColumns.js +12 -14
- package/modern/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +10 -3
- package/modern/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +9 -3
- package/modern/hooks/features/events/useGridEvents.js +2 -0
- package/modern/hooks/features/filter/gridFilterSelector.js +6 -0
- package/modern/hooks/features/filter/gridFilterUtils.js +3 -6
- package/modern/hooks/features/filter/useGridFilter.js +29 -12
- package/modern/hooks/features/pagination/useGridPage.js +1 -1
- package/modern/hooks/features/pagination/useGridPageSize.js +1 -1
- package/modern/hooks/features/rows/useGridRowsMeta.js +129 -59
- package/modern/hooks/features/selection/useGridSelection.js +1 -1
- package/modern/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
- package/modern/hooks/features/sorting/useGridSorting.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +65 -11
- package/modern/index.js +1 -1
- package/modern/locales/arSD.js +1 -0
- package/modern/locales/bgBG.js +1 -0
- package/modern/locales/csCZ.js +1 -0
- package/modern/locales/daDK.js +1 -0
- package/modern/locales/deDE.js +1 -0
- package/modern/locales/elGR.js +1 -0
- package/modern/locales/esES.js +1 -0
- package/modern/locales/faIR.js +1 -0
- package/modern/locales/fiFI.js +1 -0
- package/modern/locales/frFR.js +1 -0
- package/modern/locales/heIL.js +10 -9
- package/modern/locales/huHU.js +1 -0
- package/modern/locales/itIT.js +1 -0
- package/modern/locales/jaJP.js +25 -24
- package/modern/locales/koKR.js +1 -0
- package/modern/locales/nbNO.js +116 -0
- package/modern/locales/nlNL.js +1 -0
- package/modern/locales/plPL.js +1 -0
- package/modern/locales/ptBR.js +1 -0
- package/modern/locales/ruRU.js +7 -6
- package/modern/locales/skSK.js +1 -0
- package/modern/locales/trTR.js +8 -7
- package/modern/locales/ukUA.js +1 -0
- package/modern/locales/viVN.js +1 -0
- package/modern/locales/zhCN.js +1 -0
- package/modern/models/events/gridEvents.js +2 -0
- package/modern/models/gridApiCaches.js +1 -0
- package/modern/models/params/gridMenuParams.js +1 -0
- package/modern/models/params/index.js +2 -1
- package/node/DataGrid/DataGrid.js +26 -1
- package/node/colDef/gridCheckboxSelectionColDef.js +4 -2
- package/node/colDef/gridNumericColDef.js +1 -1
- package/node/components/GridRow.js +53 -12
- package/node/components/cell/GridCell.js +12 -7
- package/node/components/columnHeaders/GridColumnHeaderItem.js +9 -6
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/node/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/node/components/containers/GridRootStyles.js +8 -3
- package/node/components/menu/GridMenu.js +10 -2
- package/node/components/panel/GridColumnsPanel.js +12 -7
- package/node/components/panel/GridPanelWrapper.js +5 -3
- package/node/components/panel/filterPanel/GridFilterForm.js +91 -9
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/node/components/panel/filterPanel/GridFilterPanel.js +28 -11
- package/node/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/node/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/node/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/node/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/node/components/toolbar/GridToolbarQuickFilter.js +61 -4
- package/node/constants/defaultGridSlotsComponents.js +2 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +1 -0
- package/node/hooks/core/useGridStateInitialization.js +19 -6
- package/node/hooks/features/columnMenu/useGridColumnMenu.js +23 -0
- package/node/hooks/features/columns/useGridColumnSpanning.js +11 -16
- package/node/hooks/features/columns/useGridColumns.js +13 -15
- package/node/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/node/hooks/features/editRows/useGridCellEditing.new.js +11 -4
- package/node/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/node/hooks/features/editRows/useGridRowEditing.new.js +10 -4
- package/node/hooks/features/events/useGridEvents.js +2 -0
- package/node/hooks/features/filter/gridFilterSelector.js +9 -2
- package/node/hooks/features/filter/gridFilterUtils.js +4 -5
- package/node/hooks/features/filter/useGridFilter.js +28 -11
- package/node/hooks/features/pagination/useGridPage.js +1 -1
- package/node/hooks/features/pagination/useGridPageSize.js +1 -1
- package/node/hooks/features/rows/useGridRowsMeta.js +136 -69
- package/node/hooks/features/selection/useGridSelection.js +1 -1
- package/node/hooks/features/selection/useGridSelectionPreProcessors.js +7 -5
- package/node/hooks/features/sorting/useGridSorting.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +65 -12
- package/node/index.js +1 -1
- package/node/locales/arSD.js +1 -0
- package/node/locales/bgBG.js +1 -0
- package/node/locales/csCZ.js +1 -0
- package/node/locales/daDK.js +1 -0
- package/node/locales/deDE.js +1 -0
- package/node/locales/elGR.js +1 -0
- package/node/locales/esES.js +1 -0
- package/node/locales/faIR.js +1 -0
- package/node/locales/fiFI.js +1 -0
- package/node/locales/frFR.js +1 -0
- package/node/locales/heIL.js +10 -9
- package/node/locales/huHU.js +1 -0
- package/node/locales/itIT.js +1 -0
- package/node/locales/jaJP.js +25 -24
- package/node/locales/koKR.js +1 -0
- package/node/locales/nbNO.js +126 -0
- package/node/locales/nlNL.js +1 -0
- package/node/locales/plPL.js +1 -0
- package/node/locales/ptBR.js +1 -0
- package/node/locales/ruRU.js +7 -6
- package/node/locales/skSK.js +1 -0
- package/node/locales/trTR.js +8 -7
- package/node/locales/ukUA.js +1 -0
- package/node/locales/viVN.js +1 -0
- package/node/locales/zhCN.js +1 -0
- package/node/models/events/gridEvents.js +2 -0
- package/node/models/gridApiCaches.js +5 -0
- package/node/models/params/gridMenuParams.js +5 -0
- package/node/models/params/index.js +13 -0
- package/package.json +6 -5
|
@@ -19,7 +19,7 @@ import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
|
19
19
|
import { getFirstNonSpannedColumnToRender } from '../columns/gridColumnsUtils'; // Uses binary search to avoid looping through all possible positions
|
|
20
20
|
|
|
21
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
-
export function
|
|
22
|
+
export function binarySearch(offset, positions, sliceStart = 0, sliceEnd = positions.length) {
|
|
23
23
|
if (positions.length <= 0) {
|
|
24
24
|
return -1;
|
|
25
25
|
}
|
|
@@ -30,8 +30,20 @@ export function getIndexFromScroll(offset, positions, sliceStart = 0, sliceEnd =
|
|
|
30
30
|
|
|
31
31
|
const pivot = sliceStart + Math.floor((sliceEnd - sliceStart) / 2);
|
|
32
32
|
const itemOffset = positions[pivot];
|
|
33
|
-
return offset <= itemOffset ?
|
|
33
|
+
return offset <= itemOffset ? binarySearch(offset, positions, sliceStart, pivot) : binarySearch(offset, positions, pivot + 1, sliceEnd);
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
function exponentialSearch(offset, positions, index) {
|
|
37
|
+
let interval = 1;
|
|
38
|
+
|
|
39
|
+
while (index < positions.length && positions[index] < offset) {
|
|
40
|
+
index += interval;
|
|
41
|
+
interval *= 2;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return binarySearch(offset, positions, Math.floor(index / 2), Math.min(index, positions.length));
|
|
45
|
+
}
|
|
46
|
+
|
|
35
47
|
export const getRenderableIndexes = ({
|
|
36
48
|
firstIndex,
|
|
37
49
|
lastIndex,
|
|
@@ -73,6 +85,22 @@ export const useGridVirtualScroller = props => {
|
|
|
73
85
|
});
|
|
74
86
|
const [containerWidth, setContainerWidth] = React.useState(null);
|
|
75
87
|
const prevTotalWidth = React.useRef(columnsTotalWidth);
|
|
88
|
+
const getNearestIndexToRender = React.useCallback(offset => {
|
|
89
|
+
const lastMeasuredIndex = Math.max(0, apiRef.current.unstable_getLastMeasuredRowIndex());
|
|
90
|
+
const allRowsMeasured = lastMeasuredIndex === Infinity;
|
|
91
|
+
|
|
92
|
+
if (allRowsMeasured || rowsMeta.positions[lastMeasuredIndex] >= offset) {
|
|
93
|
+
// If all rows were measured (when no row has "auto" as height) or all rows before the offset
|
|
94
|
+
// were measured, then use a binary search because it's faster.
|
|
95
|
+
return binarySearch(offset, rowsMeta.positions);
|
|
96
|
+
} // Otherwise, use an exponential search.
|
|
97
|
+
// If rows have "auto" as height, their positions will be based on estimated heights.
|
|
98
|
+
// In this case, we can skip several steps until we find a position higher than the offset.
|
|
99
|
+
// Inspired by https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/utils/CellSizeAndPositionManager.js
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
return exponentialSearch(offset, rowsMeta.positions, lastMeasuredIndex);
|
|
103
|
+
}, [apiRef, rowsMeta.positions]);
|
|
76
104
|
const computeRenderContext = React.useCallback(() => {
|
|
77
105
|
if (disableVirtualization) {
|
|
78
106
|
return {
|
|
@@ -86,18 +114,39 @@ export const useGridVirtualScroller = props => {
|
|
|
86
114
|
const {
|
|
87
115
|
top,
|
|
88
116
|
left
|
|
89
|
-
} = scrollPosition.current;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
const
|
|
117
|
+
} = scrollPosition.current; // Clamp the value because the search may return an index out of bounds.
|
|
118
|
+
// In the last index, this is not needed because Array.slice doesn't include it.
|
|
119
|
+
|
|
120
|
+
const firstRowIndex = Math.min(getNearestIndexToRender(top), rowsMeta.positions.length - 1);
|
|
121
|
+
const lastRowIndex = rootProps.autoHeight ? firstRowIndex + currentPage.rows.length : getNearestIndexToRender(top + rootRef.current.clientHeight);
|
|
122
|
+
let hasRowWithAutoHeight = false;
|
|
123
|
+
let firstColumnIndex = 0;
|
|
124
|
+
let lastColumnIndex = columnPositions.length;
|
|
125
|
+
const [firstRowToRender, lastRowToRender] = getRenderableIndexes({
|
|
126
|
+
firstIndex: firstRowIndex,
|
|
127
|
+
lastIndex: lastRowIndex,
|
|
128
|
+
minFirstIndex: 0,
|
|
129
|
+
maxLastIndex: currentPage.rows.length,
|
|
130
|
+
buffer: rootProps.rowBuffer
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
for (let i = firstRowToRender; i < lastRowToRender && !hasRowWithAutoHeight; i += 1) {
|
|
134
|
+
const row = currentPage.rows[i];
|
|
135
|
+
hasRowWithAutoHeight = apiRef.current.unstable_rowHasAutoHeight(row.id);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!hasRowWithAutoHeight) {
|
|
139
|
+
firstColumnIndex = binarySearch(left, columnPositions);
|
|
140
|
+
lastColumnIndex = binarySearch(left + containerWidth, columnPositions);
|
|
141
|
+
}
|
|
142
|
+
|
|
94
143
|
return {
|
|
95
144
|
firstRowIndex,
|
|
96
145
|
lastRowIndex,
|
|
97
146
|
firstColumnIndex,
|
|
98
147
|
lastColumnIndex
|
|
99
148
|
};
|
|
100
|
-
}, [disableVirtualization, rowsMeta.positions, rootProps.autoHeight, currentPage.rows
|
|
149
|
+
}, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerWidth]);
|
|
101
150
|
React.useEffect(() => {
|
|
102
151
|
if (disableVirtualization) {
|
|
103
152
|
renderZoneRef.current.style.transform = `translate3d(0px, 0px, 0px)`;
|
|
@@ -228,7 +277,8 @@ export const useGridVirtualScroller = props => {
|
|
|
228
277
|
renderContext: nextRenderContext,
|
|
229
278
|
minFirstColumn = renderZoneMinColumnIndex,
|
|
230
279
|
maxLastColumn = renderZoneMaxColumnIndex,
|
|
231
|
-
availableSpace = containerWidth
|
|
280
|
+
availableSpace = containerWidth,
|
|
281
|
+
ignoreAutoHeight
|
|
232
282
|
} = params;
|
|
233
283
|
|
|
234
284
|
if (!currentPage.range || !nextRenderContext || availableSpace == null) {
|
|
@@ -281,7 +331,7 @@ export const useGridVirtualScroller = props => {
|
|
|
281
331
|
model
|
|
282
332
|
} = renderedRows[i];
|
|
283
333
|
const lastVisibleRowIndex = firstRowToRender + i === currentPage.rows.length - 1;
|
|
284
|
-
const
|
|
334
|
+
const baseRowHeight = !apiRef.current.unstable_rowHasAutoHeight(id) || ignoreAutoHeight ? apiRef.current.unstable_getRowHeight(id) : 'auto';
|
|
285
335
|
let isSelected;
|
|
286
336
|
|
|
287
337
|
if (selectedRowsLookup[id] == null) {
|
|
@@ -295,7 +345,7 @@ export const useGridVirtualScroller = props => {
|
|
|
295
345
|
rows.push( /*#__PURE__*/_jsx(rootProps.components.Row, _extends({
|
|
296
346
|
row: model,
|
|
297
347
|
rowId: id,
|
|
298
|
-
rowHeight:
|
|
348
|
+
rowHeight: baseRowHeight,
|
|
299
349
|
cellFocus: cellFocus // TODO move to inside the row
|
|
300
350
|
,
|
|
301
351
|
cellTabIndex: cellTabIndex // TODO move to inside the row
|
|
@@ -354,6 +404,10 @@ export const useGridVirtualScroller = props => {
|
|
|
354
404
|
rootStyle.overflowX = 'hidden';
|
|
355
405
|
}
|
|
356
406
|
|
|
407
|
+
if (rootProps.autoHeight) {
|
|
408
|
+
rootStyle.overflowY = 'hidden';
|
|
409
|
+
}
|
|
410
|
+
|
|
357
411
|
const getRenderContext = React.useCallback(() => {
|
|
358
412
|
return prevRenderContext.current;
|
|
359
413
|
}, []);
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -52,3 +52,4 @@ export { clamp, isDeepEqual } from '../utils/utils';
|
|
|
52
52
|
export { buildWarning } from '../utils/warning';
|
|
53
53
|
export { exportAs } from '../utils/exportAs';
|
|
54
54
|
export type { GridApiCommunity } from '../models/api/gridApiCommunity';
|
|
55
|
+
export type { GridApiCaches } from '../models/gridApiCaches';
|
|
@@ -231,6 +231,15 @@ DataGridRaw.propTypes = {
|
|
|
231
231
|
*/
|
|
232
232
|
getDetailPanelContent: PropTypes.func,
|
|
233
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Function that returns the estimated height for a row.
|
|
236
|
+
* Only works if dynamic row height is used.
|
|
237
|
+
* Once the row height is measured this value is discarded.
|
|
238
|
+
* @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
|
|
239
|
+
* @returns {number | null} The estimated row height value. If `null` or `undefined` then the default row height, based on the density, is applied.
|
|
240
|
+
*/
|
|
241
|
+
getEstimatedRowHeight: PropTypes.func,
|
|
242
|
+
|
|
234
243
|
/**
|
|
235
244
|
* Function that applies CSS classes dynamically on rows.
|
|
236
245
|
* @param {GridRowClassNameParams} params With all properties from [[GridRowClassNameParams]].
|
|
@@ -241,7 +250,7 @@ DataGridRaw.propTypes = {
|
|
|
241
250
|
/**
|
|
242
251
|
* Function that sets the row height per row.
|
|
243
252
|
* @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
|
|
244
|
-
* @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied.
|
|
253
|
+
* @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied. If "auto" then the row height is calculated based on the content.
|
|
245
254
|
*/
|
|
246
255
|
getRowHeight: PropTypes.func,
|
|
247
256
|
|
|
@@ -508,6 +517,22 @@ DataGridRaw.propTypes = {
|
|
|
508
517
|
*/
|
|
509
518
|
onFilterModelChange: PropTypes.func,
|
|
510
519
|
|
|
520
|
+
/**
|
|
521
|
+
* Callback fired when the menu is closed.
|
|
522
|
+
* @param {GridMenuParams} params With all properties from [[GridMenuParams]].
|
|
523
|
+
* @param {MuiEvent<{}>} event The event object.
|
|
524
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
525
|
+
*/
|
|
526
|
+
onMenuClose: PropTypes.func,
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Callback fired when the menu is opened.
|
|
530
|
+
* @param {GridMenuParams} params With all properties from [[GridMenuParams]].
|
|
531
|
+
* @param {MuiEvent<{}>} event The event object.
|
|
532
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
533
|
+
*/
|
|
534
|
+
onMenuOpen: PropTypes.func,
|
|
535
|
+
|
|
511
536
|
/**
|
|
512
537
|
* Callback fired when the current page has changed.
|
|
513
538
|
* @param {number} page Index of the page displayed on the Grid.
|
|
@@ -5,8 +5,9 @@ import { GridHeaderCheckbox } from '../components/columnSelection/GridHeaderChec
|
|
|
5
5
|
import { selectedIdsLookupSelector } from '../hooks/features/selection/gridSelectionSelector';
|
|
6
6
|
import { GRID_BOOLEAN_COL_DEF } from './gridBooleanColDef';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export var GRID_CHECKBOX_SELECTION_FIELD = '__check__';
|
|
8
9
|
export var GRID_CHECKBOX_SELECTION_COL_DEF = _extends({}, GRID_BOOLEAN_COL_DEF, {
|
|
9
|
-
field:
|
|
10
|
+
field: GRID_CHECKBOX_SELECTION_FIELD,
|
|
10
11
|
type: 'checkboxSelection',
|
|
11
12
|
width: 50,
|
|
12
13
|
resizable: false,
|
|
@@ -13,7 +13,7 @@ export var GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
13
13
|
},
|
|
14
14
|
valueFormatter: function valueFormatter(_ref) {
|
|
15
15
|
var value = _ref.value;
|
|
16
|
-
return
|
|
16
|
+
return isNumber(value) ? value.toLocaleString() : value || '';
|
|
17
17
|
},
|
|
18
18
|
filterOperators: getGridNumericOperators(),
|
|
19
19
|
getApplyQuickFilterFn: getGridNumericQuickFilterFn
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
4
|
var _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"];
|
|
4
5
|
|
|
@@ -20,6 +21,8 @@ import { findParentElementFromClassName } from '../utils/domUtils';
|
|
|
20
21
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../colDef/gridCheckboxSelectionColDef';
|
|
21
22
|
import { GRID_ACTIONS_COLUMN_TYPE } from '../colDef/gridActionsColDef';
|
|
22
23
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../constants/gridDetailPanelToggleField';
|
|
24
|
+
import { gridSortModelSelector } from '../hooks/features/sorting/gridSortingSelector';
|
|
25
|
+
import { gridRowTreeDepthSelector } from '../hooks/features/rows/gridRowsSelector';
|
|
23
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
27
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
28
|
|
|
@@ -28,24 +31,23 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
28
31
|
editing = ownerState.editing,
|
|
29
32
|
selected = ownerState.selected,
|
|
30
33
|
isLastVisible = ownerState.isLastVisible,
|
|
34
|
+
rowHeight = ownerState.rowHeight,
|
|
31
35
|
classes = ownerState.classes;
|
|
32
36
|
var slots = {
|
|
33
|
-
root: ['row', selected && 'selected', editable && 'row--editable', editing && 'row--editing', isLastVisible && 'row--lastVisible']
|
|
37
|
+
root: ['row', selected && 'selected', editable && 'row--editable', editing && 'row--editing', isLastVisible && 'row--lastVisible', rowHeight === 'auto' && 'row--dynamicHeight']
|
|
34
38
|
};
|
|
35
39
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
36
40
|
};
|
|
37
41
|
|
|
38
42
|
var EmptyCell = function EmptyCell(_ref) {
|
|
39
|
-
var width = _ref.width
|
|
40
|
-
height = _ref.height;
|
|
43
|
+
var width = _ref.width;
|
|
41
44
|
|
|
42
|
-
if (!width
|
|
45
|
+
if (!width) {
|
|
43
46
|
return null;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
var style = {
|
|
47
|
-
width: width
|
|
48
|
-
height: height
|
|
50
|
+
width: width
|
|
49
51
|
};
|
|
50
52
|
return /*#__PURE__*/_jsx("div", {
|
|
51
53
|
className: "MuiDataGrid-cell",
|
|
@@ -82,9 +84,12 @@ function GridRow(props) {
|
|
|
82
84
|
var ariaRowIndex = index + 2; // 1 for the header row and 1 as it's 1-based
|
|
83
85
|
|
|
84
86
|
var apiRef = useGridApiContext();
|
|
87
|
+
var ref = React.useRef(null);
|
|
85
88
|
var rootProps = useGridRootProps();
|
|
86
89
|
var currentPage = useGridVisibleRows(apiRef, rootProps);
|
|
87
90
|
var columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
91
|
+
var sortModel = useGridSelector(apiRef, gridSortModelSelector);
|
|
92
|
+
var treeDepth = useGridSelector(apiRef, gridRowTreeDepthSelector);
|
|
88
93
|
|
|
89
94
|
var _ref2 = (_apiRef$current$getRo = apiRef.current.getRootDimensions()) != null ? _apiRef$current$getRo : {
|
|
90
95
|
hasScrollX: false,
|
|
@@ -98,9 +103,45 @@ function GridRow(props) {
|
|
|
98
103
|
isLastVisible: isLastVisible,
|
|
99
104
|
classes: rootProps.classes,
|
|
100
105
|
editing: apiRef.current.getRowMode(rowId) === GridRowModes.Edit,
|
|
101
|
-
editable: rootProps.editMode === GridEditModes.Row
|
|
106
|
+
editable: rootProps.editMode === GridEditModes.Row,
|
|
107
|
+
rowHeight: rowHeight
|
|
102
108
|
};
|
|
103
109
|
var classes = useUtilityClasses(ownerState);
|
|
110
|
+
React.useLayoutEffect(function () {
|
|
111
|
+
if (rowHeight === 'auto' && ref.current && typeof ResizeObserver === 'undefined') {
|
|
112
|
+
// Fallback for IE
|
|
113
|
+
apiRef.current.unstable_storeRowHeightMeasurement(rowId, ref.current.clientHeight);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
React.useLayoutEffect(function () {
|
|
117
|
+
if (currentPage.range) {
|
|
118
|
+
// The index prop is relative to the rows from all pages. As example, the index prop of the
|
|
119
|
+
// first row is 5 if pageSize=5 and page=1. However, the index used by the virtualization
|
|
120
|
+
// doesn't care about pagination and considers the rows from the current page only, so the
|
|
121
|
+
// first row always has index=0. We need to subtract the index of the first row to make it
|
|
122
|
+
// compatible with the index used by the virtualization.
|
|
123
|
+
apiRef.current.unstable_setLastMeasuredRowIndex(index - currentPage.range.firstRowIndex);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
var rootElement = ref.current;
|
|
127
|
+
var hasFixedHeight = rowHeight !== 'auto';
|
|
128
|
+
|
|
129
|
+
if (!rootElement || hasFixedHeight || typeof ResizeObserver === 'undefined') {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
var resizeObserver = new ResizeObserver(function (entries) {
|
|
134
|
+
var _entries = _slicedToArray(entries, 1),
|
|
135
|
+
entry = _entries[0];
|
|
136
|
+
|
|
137
|
+
var height = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
|
|
138
|
+
apiRef.current.unstable_storeRowHeightMeasurement(rowId, height);
|
|
139
|
+
});
|
|
140
|
+
resizeObserver.observe(rootElement);
|
|
141
|
+
return function () {
|
|
142
|
+
return resizeObserver.disconnect();
|
|
143
|
+
};
|
|
144
|
+
}, [apiRef, currentPage.range, index, rowHeight, rowId]);
|
|
104
145
|
var publish = React.useCallback(function (eventName, propHandler) {
|
|
105
146
|
return function (event) {
|
|
106
147
|
// Ignore portal
|
|
@@ -160,7 +201,8 @@ function GridRow(props) {
|
|
|
160
201
|
}, [apiRef, onClick, publish, rowId]);
|
|
161
202
|
|
|
162
203
|
var style = _extends({}, styleProp, {
|
|
163
|
-
maxHeight: rowHeight,
|
|
204
|
+
maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
|
|
205
|
+
// max-height doesn't support "auto"
|
|
164
206
|
minHeight: rowHeight
|
|
165
207
|
});
|
|
166
208
|
|
|
@@ -201,6 +243,7 @@ function GridRow(props) {
|
|
|
201
243
|
var showRightBorder = !isLastColumn ? rootProps.showCellRightBorder : !removeLastBorderRight && rootProps.disableExtendRowFullWidth;
|
|
202
244
|
var cellParams = apiRef.current.getCellParams(rowId, column.field);
|
|
203
245
|
var classNames = [];
|
|
246
|
+
var disableDragEvents = rootProps.disableColumnReorder && column.disableReorder || !rootProps.rowReordering && !!sortModel.length && treeDepth > 1 && Object.keys(editRowsState).length > 0;
|
|
204
247
|
|
|
205
248
|
if (column.cellClassName) {
|
|
206
249
|
classNames.push(clsx(typeof column.cellClassName === 'function' ? column.cellClassName(cellParams) : column.cellClassName));
|
|
@@ -270,7 +313,8 @@ function GridRow(props) {
|
|
|
270
313
|
hasFocus: hasFocus,
|
|
271
314
|
tabIndex: tabIndex,
|
|
272
315
|
className: clsx(classNames),
|
|
273
|
-
colSpan: colSpan
|
|
316
|
+
colSpan: colSpan,
|
|
317
|
+
disableDragEvents: disableDragEvents
|
|
274
318
|
}, (_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.cell, {
|
|
275
319
|
children: content
|
|
276
320
|
}), column.field));
|
|
@@ -279,6 +323,7 @@ function GridRow(props) {
|
|
|
279
323
|
|
|
280
324
|
var emptyCellWidth = containerWidth - columnsTotalWidth;
|
|
281
325
|
return /*#__PURE__*/_jsxs("div", _extends({
|
|
326
|
+
ref: ref,
|
|
282
327
|
"data-id": rowId,
|
|
283
328
|
"data-rowindex": index,
|
|
284
329
|
role: "row",
|
|
@@ -292,8 +337,7 @@ function GridRow(props) {
|
|
|
292
337
|
onMouseLeave: publish('rowMouseLeave', onMouseLeave)
|
|
293
338
|
}, other, {
|
|
294
339
|
children: [cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
|
|
295
|
-
width: emptyCellWidth
|
|
296
|
-
height: rowHeight
|
|
340
|
+
width: emptyCellWidth
|
|
297
341
|
})]
|
|
298
342
|
}));
|
|
299
343
|
}
|
|
@@ -318,7 +362,7 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
318
362
|
lastColumnToRender: PropTypes.number.isRequired,
|
|
319
363
|
renderedColumns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
320
364
|
row: PropTypes.any.isRequired,
|
|
321
|
-
rowHeight: PropTypes.number.isRequired,
|
|
365
|
+
rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
|
|
322
366
|
rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
323
367
|
selected: PropTypes.bool.isRequired,
|
|
324
368
|
visibleColumns: PropTypes.arrayOf(PropTypes.object).isRequired
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["align", "children", "colIndex", "colDef", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onKeyDown", "onDragEnter", "onDragOver"];
|
|
3
|
+
var _excluded = ["align", "children", "colIndex", "colDef", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onKeyDown", "onDragEnter", "onDragOver"];
|
|
4
4
|
|
|
5
5
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
6
6
|
import * as React from 'react';
|
|
@@ -67,6 +67,7 @@ function GridCell(props) {
|
|
|
67
67
|
extendRowFullWidth = props.extendRowFullWidth,
|
|
68
68
|
row = props.row,
|
|
69
69
|
colSpan = props.colSpan,
|
|
70
|
+
disableDragEvents = props.disableDragEvents,
|
|
70
71
|
onClick = props.onClick,
|
|
71
72
|
onDoubleClick = props.onDoubleClick,
|
|
72
73
|
onMouseDown = props.onMouseDown,
|
|
@@ -122,7 +123,8 @@ function GridCell(props) {
|
|
|
122
123
|
minWidth: width,
|
|
123
124
|
maxWidth: width,
|
|
124
125
|
minHeight: height,
|
|
125
|
-
maxHeight: height
|
|
126
|
+
maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
|
|
127
|
+
|
|
126
128
|
};
|
|
127
129
|
React.useLayoutEffect(function () {
|
|
128
130
|
if (!hasFocus || cellMode === GridCellModes.Edit) {
|
|
@@ -187,6 +189,10 @@ function GridCell(props) {
|
|
|
187
189
|
return children;
|
|
188
190
|
};
|
|
189
191
|
|
|
192
|
+
var draggableEventHandlers = disableDragEvents ? null : {
|
|
193
|
+
onDragEnter: publish('cellDragEnter', onDragEnter),
|
|
194
|
+
onDragOver: publish('cellDragOver', onDragOver)
|
|
195
|
+
};
|
|
190
196
|
return /*#__PURE__*/_jsx("div", _extends({
|
|
191
197
|
ref: cellRef,
|
|
192
198
|
className: clsx(className, classes.root),
|
|
@@ -201,10 +207,8 @@ function GridCell(props) {
|
|
|
201
207
|
onDoubleClick: publish('cellDoubleClick', onDoubleClick),
|
|
202
208
|
onMouseDown: publish('cellMouseDown', onMouseDown),
|
|
203
209
|
onMouseUp: publishMouseUp('cellMouseUp'),
|
|
204
|
-
onKeyDown: publish('cellKeyDown', onKeyDown)
|
|
205
|
-
|
|
206
|
-
onDragOver: publish('cellDragOver', onDragOver)
|
|
207
|
-
}, other, {
|
|
210
|
+
onKeyDown: publish('cellKeyDown', onKeyDown)
|
|
211
|
+
}, draggableEventHandlers, other, {
|
|
208
212
|
onFocus: handleFocus,
|
|
209
213
|
children: renderChildren()
|
|
210
214
|
}));
|
|
@@ -221,10 +225,11 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
|
|
|
221
225
|
className: PropTypes.string,
|
|
222
226
|
colIndex: PropTypes.number.isRequired,
|
|
223
227
|
colSpan: PropTypes.number,
|
|
228
|
+
disableDragEvents: PropTypes.bool,
|
|
224
229
|
field: PropTypes.string.isRequired,
|
|
225
230
|
formattedValue: PropTypes.any,
|
|
226
231
|
hasFocus: PropTypes.bool,
|
|
227
|
-
height: PropTypes.number.isRequired,
|
|
232
|
+
height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
|
|
228
233
|
isEditable: PropTypes.bool,
|
|
229
234
|
onClick: PropTypes.func,
|
|
230
235
|
onDoubleClick: PropTypes.func,
|
|
@@ -72,6 +72,9 @@ function GridColumnHeaderItem(props) {
|
|
|
72
72
|
hasScrollX = _ref.hasScrollX,
|
|
73
73
|
hasScrollY = _ref.hasScrollY;
|
|
74
74
|
|
|
75
|
+
var isDraggable = React.useMemo(function () {
|
|
76
|
+
return !rootProps.disableColumnReorder && !disableReorder && !column.disableReorder;
|
|
77
|
+
}, [rootProps.disableColumnReorder, disableReorder, column.disableReorder]);
|
|
75
78
|
var headerComponent = null;
|
|
76
79
|
|
|
77
80
|
if (column.renderHeader) {
|
|
@@ -104,12 +107,12 @@ function GridColumnHeaderItem(props) {
|
|
|
104
107
|
onFocus: publish('columnHeaderFocus'),
|
|
105
108
|
onBlur: publish('columnHeaderBlur')
|
|
106
109
|
};
|
|
107
|
-
var draggableEventHandlers = {
|
|
110
|
+
var draggableEventHandlers = isDraggable ? {
|
|
108
111
|
onDragStart: publish('columnHeaderDragStart'),
|
|
109
112
|
onDragEnter: publish('columnHeaderDragEnter'),
|
|
110
113
|
onDragOver: publish('columnHeaderDragOver'),
|
|
111
114
|
onDragEnd: publish('columnHeaderDragEnd')
|
|
112
|
-
};
|
|
115
|
+
} : null;
|
|
113
116
|
var removeLastBorderRight = isLastColumn && hasScrollX && !hasScrollY;
|
|
114
117
|
var showRightBorder = !isLastColumn ? rootProps.showColumnRightBorder : !removeLastBorderRight && !extendRowFullWidth;
|
|
115
118
|
|
|
@@ -170,6 +173,7 @@ function GridColumnHeaderItem(props) {
|
|
|
170
173
|
field: column.field,
|
|
171
174
|
colDef: column
|
|
172
175
|
}) : column.headerClassName;
|
|
176
|
+
var label = (_column$headerName = column.headerName) != null ? _column$headerName : column.field;
|
|
173
177
|
return /*#__PURE__*/_jsxs("div", _extends({
|
|
174
178
|
ref: headerCellRef,
|
|
175
179
|
className: clsx(classes.root, headerClassName),
|
|
@@ -182,18 +186,19 @@ function GridColumnHeaderItem(props) {
|
|
|
182
186
|
role: "columnheader",
|
|
183
187
|
tabIndex: tabIndex,
|
|
184
188
|
"aria-colindex": colIndex + 1,
|
|
185
|
-
"aria-sort": ariaSort
|
|
189
|
+
"aria-sort": ariaSort,
|
|
190
|
+
"aria-label": column.renderHeader && headerComponent == null ? label : undefined
|
|
186
191
|
}, mouseEventsHandlers, {
|
|
187
192
|
children: [/*#__PURE__*/_jsxs("div", _extends({
|
|
188
193
|
className: classes.draggableContainer,
|
|
189
|
-
draggable:
|
|
194
|
+
draggable: isDraggable
|
|
190
195
|
}, draggableEventHandlers, {
|
|
191
196
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
192
197
|
className: classes.titleContainer,
|
|
193
198
|
children: [/*#__PURE__*/_jsx("div", {
|
|
194
199
|
className: classes.titleContainerContent,
|
|
195
|
-
children: headerComponent
|
|
196
|
-
label:
|
|
200
|
+
children: column.renderHeader ? headerComponent : /*#__PURE__*/_jsx(GridColumnHeaderTitle, {
|
|
201
|
+
label: label,
|
|
197
202
|
description: column.description,
|
|
198
203
|
columnWidth: width
|
|
199
204
|
})
|
|
@@ -10,7 +10,7 @@ export var GridRootStyles = styled('div', {
|
|
|
10
10
|
_defineProperty({}, "& .".concat(gridClasses['cell--withRenderer']), styles['cell--withRenderer']), _defineProperty({}, "& .".concat(gridClasses.cell), styles.cell), _defineProperty({}, "& .".concat(gridClasses.cellContent), styles.cellContent), _defineProperty({}, "& .".concat(gridClasses.cellCheckbox), styles.cellCheckbox), _defineProperty({}, "& .".concat(gridClasses.checkboxInput), styles.checkboxInput), _defineProperty({}, "& .".concat(gridClasses['columnHeader--alignCenter']), styles['columnHeader--alignCenter']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--alignLeft']), styles['columnHeader--alignLeft']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--alignRight']), styles['columnHeader--alignRight']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--dragging']), styles['columnHeader--dragging']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--moving']), styles['columnHeader--moving']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--numeric']), styles['columnHeader--numeric']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--sortable']), styles['columnHeader--sortable']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--sorted']), styles['columnHeader--sorted']), _defineProperty({}, "& .".concat(gridClasses.columnHeader), styles.columnHeader), _defineProperty({}, "& .".concat(gridClasses.columnHeaderCheckbox), styles.columnHeaderCheckbox), _defineProperty({}, "& .".concat(gridClasses.columnHeaderDraggableContainer), styles.columnHeaderDraggableContainer), _defineProperty({}, "& .".concat(gridClasses.columnHeaderTitleContainer), styles.columnHeaderTitleContainer), _defineProperty({}, "& .".concat(gridClasses['columnSeparator--resizable']), styles['columnSeparator--resizable']), _defineProperty({}, "& .".concat(gridClasses['columnSeparator--resizing']), styles['columnSeparator--resizing']), _defineProperty({}, "& .".concat(gridClasses.columnSeparator), styles.columnSeparator), _defineProperty({}, "& .".concat(gridClasses.filterIcon), styles.filterIcon), _defineProperty({}, "& .".concat(gridClasses.iconSeparator), styles.iconSeparator), _defineProperty({}, "& .".concat(gridClasses.menuIcon), styles.menuIcon), _defineProperty({}, "& .".concat(gridClasses.menuIconButton), styles.menuIconButton), _defineProperty({}, "& .".concat(gridClasses.menuOpen), styles.menuOpen), _defineProperty({}, "& .".concat(gridClasses.menuList), styles.menuList), _defineProperty({}, "& .".concat(gridClasses['row--editable']), styles['row--editable']), _defineProperty({}, "& .".concat(gridClasses['row--editing']), styles['row--editing']), _defineProperty({}, "& .".concat(gridClasses['row--dragging']), styles['row--dragging']), _defineProperty({}, "& .".concat(gridClasses.row), styles.row), _defineProperty({}, "& .".concat(gridClasses.rowReorderCellPlaceholder), styles.rowReorderCellPlaceholder), _defineProperty({}, "& .".concat(gridClasses.rowReorderCell), styles.rowReorderCell), _defineProperty({}, "& .".concat(gridClasses['rowReorderCell--draggable']), styles['rowReorderCell--draggable']), _defineProperty({}, "& .".concat(gridClasses.sortIcon), styles.sortIcon), _defineProperty({}, "& .".concat(gridClasses.withBorder), styles.withBorder), _defineProperty({}, "& .".concat(gridClasses.treeDataGroupingCell), styles.treeDataGroupingCell), _defineProperty({}, "& .".concat(gridClasses.treeDataGroupingCellToggle), styles.treeDataGroupingCellToggle), _defineProperty({}, "& .".concat(gridClasses.detailPanelToggleCell), styles.detailPanelToggleCell), _defineProperty({}, "& .".concat(gridClasses['detailPanelToggleCell--expanded']), styles['detailPanelToggleCell--expanded']), styles.root];
|
|
11
11
|
}
|
|
12
12
|
})(function (_ref46) {
|
|
13
|
-
var _$concat3, _extends2;
|
|
13
|
+
var _$concat2, _$concat3, _extends2;
|
|
14
14
|
|
|
15
15
|
var theme = _ref46.theme;
|
|
16
16
|
var borderColor = theme.palette.mode === 'light' ? lighten(alpha(theme.palette.divider, 1), 0.88) : darken(alpha(theme.palette.divider, 1), 0.68);
|
|
@@ -68,7 +68,7 @@ export var GridRootStyles = styled('div', {
|
|
|
68
68
|
minWidth: 0,
|
|
69
69
|
flex: 1,
|
|
70
70
|
whiteSpace: 'nowrap',
|
|
71
|
-
|
|
71
|
+
overflowX: 'hidden'
|
|
72
72
|
}), _defineProperty(_extends2, "& .".concat(gridClasses.columnHeaderTitleContainerContent), {
|
|
73
73
|
overflow: 'hidden',
|
|
74
74
|
display: 'flex',
|
|
@@ -100,7 +100,7 @@ export var GridRootStyles = styled('div', {
|
|
|
100
100
|
left: -12
|
|
101
101
|
}), _defineProperty(_extends2, "& .".concat(gridClasses['columnSeparator--sideRight']), {
|
|
102
102
|
right: -12
|
|
103
|
-
}), _defineProperty(_extends2, "& .".concat(gridClasses['columnSeparator--resizable']),
|
|
103
|
+
}), _defineProperty(_extends2, "& .".concat(gridClasses['columnSeparator--resizable']), (_$concat2 = {
|
|
104
104
|
cursor: 'col-resize',
|
|
105
105
|
touchAction: 'none',
|
|
106
106
|
'&:hover': {
|
|
@@ -110,9 +110,11 @@ export var GridRootStyles = styled('div', {
|
|
|
110
110
|
color: borderColor
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
}, "&.".concat(gridClasses['columnSeparator--resizing']), {
|
|
113
|
+
}, _defineProperty(_$concat2, "&.".concat(gridClasses['columnSeparator--resizing']), {
|
|
114
114
|
color: theme.palette.text.primary
|
|
115
|
-
})
|
|
115
|
+
}), _defineProperty(_$concat2, '& svg', {
|
|
116
|
+
pointerEvents: 'none'
|
|
117
|
+
}), _$concat2)), _defineProperty(_extends2, "& .".concat(gridClasses.iconSeparator), {
|
|
116
118
|
color: 'inherit'
|
|
117
119
|
}), _defineProperty(_extends2, "& .".concat(gridClasses.menuIcon), {
|
|
118
120
|
width: 0,
|
|
@@ -155,9 +157,10 @@ export var GridRootStyles = styled('div', {
|
|
|
155
157
|
}), _defineProperty(_extends2, "& .".concat(gridClasses.cell), {
|
|
156
158
|
display: 'flex',
|
|
157
159
|
alignItems: 'center',
|
|
158
|
-
overflow: 'hidden',
|
|
159
|
-
whiteSpace: 'nowrap',
|
|
160
160
|
borderBottom: "1px solid ".concat(borderColor)
|
|
161
|
+
}), _defineProperty(_extends2, "& .".concat(gridClasses.row, ":not(.").concat(gridClasses['row--dynamicHeight'], ") > .").concat(gridClasses.cell), {
|
|
162
|
+
overflow: 'hidden',
|
|
163
|
+
whiteSpace: 'nowrap'
|
|
161
164
|
}), _defineProperty(_extends2, "& .".concat(gridClasses.cellContent), {
|
|
162
165
|
overflow: 'hidden',
|
|
163
166
|
textOverflow: 'ellipsis'
|
|
@@ -14,6 +14,7 @@ import { styled } from '@mui/material/styles';
|
|
|
14
14
|
import { HTMLElementType } from '@mui/utils';
|
|
15
15
|
import { getDataGridUtilityClass, gridClasses } from '../../constants/gridClasses';
|
|
16
16
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
17
|
+
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
|
|
19
20
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
@@ -55,6 +56,7 @@ var GridMenu = function GridMenu(props) {
|
|
|
55
56
|
onExited = props.onExited,
|
|
56
57
|
other = _objectWithoutProperties(props, _excluded);
|
|
57
58
|
|
|
59
|
+
var apiRef = useGridApiContext();
|
|
58
60
|
var prevTarget = React.useRef(target);
|
|
59
61
|
var prevOpen = React.useRef(open);
|
|
60
62
|
var rootProps = useGridRootProps();
|
|
@@ -65,11 +67,16 @@ var GridMenu = function GridMenu(props) {
|
|
|
65
67
|
React.useEffect(function () {
|
|
66
68
|
if (prevOpen.current && prevTarget.current) {
|
|
67
69
|
prevTarget.current.focus();
|
|
68
|
-
}
|
|
70
|
+
} // Emit menuOpen or menuClose events
|
|
71
|
+
|
|
69
72
|
|
|
73
|
+
var eventName = open ? 'menuOpen' : 'menuClose';
|
|
74
|
+
apiRef.current.publishEvent(eventName, {
|
|
75
|
+
target: target
|
|
76
|
+
});
|
|
70
77
|
prevOpen.current = open;
|
|
71
78
|
prevTarget.current = target;
|
|
72
|
-
}, [open, target]);
|
|
79
|
+
}, [apiRef, open, target]);
|
|
73
80
|
|
|
74
81
|
var handleExited = function handleExited(popperOnExited) {
|
|
75
82
|
return function (node) {
|
|
@@ -86,8 +86,18 @@ export function GridColumnsPanel(props) {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
var toggleAllColumns = React.useCallback(function (isVisible) {
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
|
|
90
|
+
if (isVisible) {
|
|
91
|
+
return apiRef.current.setColumnVisibilityModel({});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.map(function (col) {
|
|
95
|
+
return [col.field, false];
|
|
96
|
+
})));
|
|
97
|
+
} // TODO v6: Remove
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
return apiRef.current.updateColumns(columns.map(function (col) {
|
|
91
101
|
if (col.hideable !== false) {
|
|
92
102
|
return {
|
|
93
103
|
field: col.field,
|
|
@@ -139,7 +149,6 @@ export function GridColumnsPanel(props) {
|
|
|
139
149
|
checked: columnVisibilityModel[column.field] !== false,
|
|
140
150
|
onClick: toggleColumn,
|
|
141
151
|
name: column.field,
|
|
142
|
-
color: "primary",
|
|
143
152
|
size: "small"
|
|
144
153
|
}, (_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.baseSwitch)),
|
|
145
154
|
label: column.headerName || column.field
|
|
@@ -158,15 +167,13 @@ export function GridColumnsPanel(props) {
|
|
|
158
167
|
children: [/*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
|
|
159
168
|
onClick: function onClick() {
|
|
160
169
|
return toggleAllColumns(false);
|
|
161
|
-
}
|
|
162
|
-
color: "primary"
|
|
170
|
+
}
|
|
163
171
|
}, (_rootProps$components3 = rootProps.componentsProps) == null ? void 0 : _rootProps$components3.baseButton, {
|
|
164
172
|
children: apiRef.current.getLocaleText('columnsPanelHideAllButton')
|
|
165
173
|
})), /*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
|
|
166
174
|
onClick: function onClick() {
|
|
167
175
|
return toggleAllColumns(true);
|
|
168
|
-
}
|
|
169
|
-
color: "primary"
|
|
176
|
+
}
|
|
170
177
|
}, (_rootProps$components4 = rootProps.componentsProps) == null ? void 0 : _rootProps$components4.baseButton, {
|
|
171
178
|
children: apiRef.current.getLocaleText('columnsPanelShowAllButton')
|
|
172
179
|
}))]
|