@mui/x-data-grid 8.0.0-alpha.1 → 8.0.0-alpha.3
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 +330 -7
- package/DataGrid/DataGrid.js +9 -17
- package/components/GridPagination.js +2 -1
- package/components/base/GridOverlays.d.ts +4 -3
- package/components/base/GridOverlays.js +2 -24
- package/components/base/index.d.ts +0 -1
- package/components/base/index.js +1 -2
- package/components/cell/GridCell.js +7 -10
- package/components/columnSelection/GridCellCheckboxRenderer.js +2 -3
- package/components/columnSelection/GridHeaderCheckbox.js +6 -4
- package/components/toolbar/GridToolbarColumnsButton.js +3 -4
- package/components/toolbar/GridToolbarDensitySelector.js +3 -4
- package/components/toolbar/GridToolbarExportContainer.js +3 -4
- package/components/toolbar/GridToolbarFilterButton.d.ts +2 -0
- package/components/toolbar/GridToolbarFilterButton.js +7 -6
- package/components/toolbar/GridToolbarQuickFilter.js +1 -0
- package/components/virtualization/GridVirtualScroller.js +5 -3
- package/constants/dataGridPropsDefaultValues.js +2 -4
- package/constants/localeTextConstants.js +0 -1
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +25 -9
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +5 -1
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +3 -6
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
- package/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/hooks/features/dimensions/gridDimensionsApi.d.ts +0 -4
- package/hooks/features/dimensions/useGridDimensions.js +3 -19
- package/hooks/features/editing/useGridCellEditing.js +3 -3
- package/hooks/features/editing/useGridRowEditing.js +3 -3
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +1 -0
- package/hooks/features/listView/gridListViewSelectors.d.ts +3 -1
- package/hooks/features/listView/gridListViewSelectors.js +3 -1
- package/hooks/features/listView/index.d.ts +1 -0
- package/hooks/features/listView/index.js +1 -0
- package/hooks/features/overlays/useGridOverlays.d.ts +7 -4
- package/hooks/features/overlays/useGridOverlays.js +19 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +0 -9
- package/hooks/features/rowSelection/utils.js +2 -2
- package/hooks/features/rows/gridRowsInterfaces.d.ts +1 -8
- package/hooks/features/rows/gridRowsSelector.d.ts +0 -1
- package/hooks/features/rows/gridRowsSelector.js +0 -1
- package/hooks/features/rows/gridRowsUtils.js +0 -9
- package/hooks/features/rows/index.d.ts +1 -1
- package/hooks/features/rows/index.js +1 -1
- package/hooks/features/rows/useGridRows.js +12 -14
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +55 -15
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/locales/arSD.js +0 -1
- package/locales/beBY.js +0 -1
- package/locales/bgBG.js +0 -1
- package/locales/csCZ.js +0 -1
- package/locales/daDK.js +0 -1
- package/locales/deDE.js +10 -13
- package/locales/elGR.js +0 -1
- package/locales/esES.js +10 -13
- package/locales/faIR.js +0 -1
- package/locales/fiFI.js +0 -1
- package/locales/frFR.js +0 -1
- package/locales/heIL.js +14 -17
- package/locales/hrHR.js +0 -1
- package/locales/huHU.js +0 -1
- package/locales/isIS.js +0 -1
- package/locales/itIT.js +0 -1
- package/locales/jaJP.js +0 -1
- package/locales/koKR.js +0 -1
- package/locales/nbNO.js +0 -1
- package/locales/nlNL.js +0 -1
- package/locales/nnNO.js +0 -1
- package/locales/plPL.js +0 -1
- package/locales/ptBR.js +10 -13
- package/locales/ptPT.js +10 -13
- package/locales/roRO.js +0 -1
- package/locales/ruRU.js +0 -1
- package/locales/skSK.js +0 -1
- package/locales/svSE.js +0 -1
- package/locales/trTR.js +12 -15
- package/locales/ukUA.js +0 -1
- package/locales/urPK.js +0 -1
- package/locales/viVN.js +0 -1
- package/locales/zhCN.js +10 -13
- package/locales/zhHK.js +0 -1
- package/locales/zhTW.js +0 -1
- package/models/api/gridCoreApi.d.ts +1 -1
- package/models/api/gridLocaleTextApi.d.ts +0 -1
- package/models/colDef/gridColDef.d.ts +24 -24
- package/models/events/gridEventLookup.d.ts +1 -0
- package/models/gridDataSource.d.ts +1 -1
- package/models/props/DataGridProps.d.ts +9 -17
- package/modern/DataGrid/DataGrid.js +9 -17
- package/modern/components/GridPagination.js +2 -1
- package/modern/components/base/GridOverlays.js +2 -24
- package/modern/components/base/index.js +1 -2
- package/modern/components/cell/GridCell.js +7 -10
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -3
- package/modern/components/columnSelection/GridHeaderCheckbox.js +6 -4
- package/modern/components/toolbar/GridToolbarColumnsButton.js +3 -4
- package/modern/components/toolbar/GridToolbarDensitySelector.js +3 -4
- package/modern/components/toolbar/GridToolbarExportContainer.js +3 -4
- package/modern/components/toolbar/GridToolbarFilterButton.js +7 -6
- package/modern/components/toolbar/GridToolbarQuickFilter.js +1 -0
- package/modern/components/virtualization/GridVirtualScroller.js +5 -3
- package/modern/constants/dataGridPropsDefaultValues.js +2 -4
- package/modern/constants/localeTextConstants.js +0 -1
- package/modern/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +5 -1
- package/modern/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
- package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/modern/hooks/features/dimensions/useGridDimensions.js +3 -19
- package/modern/hooks/features/editing/useGridCellEditing.js +3 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +3 -3
- package/modern/hooks/features/index.js +1 -0
- package/modern/hooks/features/listView/gridListViewSelectors.js +3 -1
- package/modern/hooks/features/listView/index.js +1 -0
- package/modern/hooks/features/overlays/useGridOverlays.js +19 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +0 -9
- package/modern/hooks/features/rowSelection/utils.js +2 -2
- package/modern/hooks/features/rows/gridRowsSelector.js +0 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +0 -9
- package/modern/hooks/features/rows/index.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +12 -14
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +55 -15
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -1
- package/modern/locales/arSD.js +0 -1
- package/modern/locales/beBY.js +0 -1
- package/modern/locales/bgBG.js +0 -1
- package/modern/locales/csCZ.js +0 -1
- package/modern/locales/daDK.js +0 -1
- package/modern/locales/deDE.js +10 -13
- package/modern/locales/elGR.js +0 -1
- package/modern/locales/esES.js +10 -13
- package/modern/locales/faIR.js +0 -1
- package/modern/locales/fiFI.js +0 -1
- package/modern/locales/frFR.js +0 -1
- package/modern/locales/heIL.js +14 -17
- package/modern/locales/hrHR.js +0 -1
- package/modern/locales/huHU.js +0 -1
- package/modern/locales/isIS.js +0 -1
- package/modern/locales/itIT.js +0 -1
- package/modern/locales/jaJP.js +0 -1
- package/modern/locales/koKR.js +0 -1
- package/modern/locales/nbNO.js +0 -1
- package/modern/locales/nlNL.js +0 -1
- package/modern/locales/nnNO.js +0 -1
- package/modern/locales/plPL.js +0 -1
- package/modern/locales/ptBR.js +10 -13
- package/modern/locales/ptPT.js +10 -13
- package/modern/locales/roRO.js +0 -1
- package/modern/locales/ruRU.js +0 -1
- package/modern/locales/skSK.js +0 -1
- package/modern/locales/svSE.js +0 -1
- package/modern/locales/trTR.js +12 -15
- package/modern/locales/ukUA.js +0 -1
- package/modern/locales/urPK.js +0 -1
- package/modern/locales/viVN.js +0 -1
- package/modern/locales/zhCN.js +10 -13
- package/modern/locales/zhHK.js +0 -1
- package/modern/locales/zhTW.js +0 -1
- package/node/DataGrid/DataGrid.js +9 -17
- package/node/components/GridPagination.js +2 -1
- package/node/components/base/GridOverlays.js +2 -24
- package/node/components/base/index.js +0 -11
- package/node/components/cell/GridCell.js +7 -10
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +2 -3
- package/node/components/columnSelection/GridHeaderCheckbox.js +6 -4
- package/node/components/toolbar/GridToolbarColumnsButton.js +3 -4
- package/node/components/toolbar/GridToolbarDensitySelector.js +3 -4
- package/node/components/toolbar/GridToolbarExportContainer.js +3 -4
- package/node/components/toolbar/GridToolbarFilterButton.js +7 -6
- package/node/components/toolbar/GridToolbarQuickFilter.js +1 -0
- package/node/components/virtualization/GridVirtualScroller.js +5 -3
- package/node/constants/dataGridPropsDefaultValues.js +2 -4
- package/node/constants/localeTextConstants.js +0 -1
- package/node/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +7 -1
- package/node/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
- package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/node/hooks/features/dimensions/useGridDimensions.js +2 -18
- package/node/hooks/features/editing/useGridCellEditing.js +2 -2
- package/node/hooks/features/editing/useGridRowEditing.js +2 -2
- package/node/hooks/features/index.js +11 -0
- package/node/hooks/features/listView/gridListViewSelectors.js +3 -1
- package/node/hooks/features/listView/index.js +16 -0
- package/node/hooks/features/overlays/useGridOverlays.js +21 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +0 -9
- package/node/hooks/features/rowSelection/utils.js +2 -2
- package/node/hooks/features/rows/gridRowsSelector.js +1 -2
- package/node/hooks/features/rows/gridRowsUtils.js +0 -9
- package/node/hooks/features/rows/index.js +0 -7
- package/node/hooks/features/rows/useGridRows.js +11 -13
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +55 -15
- package/node/index.js +1 -1
- package/node/internals/index.js +7 -0
- package/node/locales/arSD.js +0 -1
- package/node/locales/beBY.js +0 -1
- package/node/locales/bgBG.js +0 -1
- package/node/locales/csCZ.js +0 -1
- package/node/locales/daDK.js +0 -1
- package/node/locales/deDE.js +10 -13
- package/node/locales/elGR.js +0 -1
- package/node/locales/esES.js +10 -13
- package/node/locales/faIR.js +0 -1
- package/node/locales/fiFI.js +0 -1
- package/node/locales/frFR.js +0 -1
- package/node/locales/heIL.js +14 -17
- package/node/locales/hrHR.js +0 -1
- package/node/locales/huHU.js +0 -1
- package/node/locales/isIS.js +0 -1
- package/node/locales/itIT.js +0 -1
- package/node/locales/jaJP.js +0 -1
- package/node/locales/koKR.js +0 -1
- package/node/locales/nbNO.js +0 -1
- package/node/locales/nlNL.js +0 -1
- package/node/locales/nnNO.js +0 -1
- package/node/locales/plPL.js +0 -1
- package/node/locales/ptBR.js +10 -13
- package/node/locales/ptPT.js +10 -13
- package/node/locales/roRO.js +0 -1
- package/node/locales/ruRU.js +0 -1
- package/node/locales/skSK.js +0 -1
- package/node/locales/svSE.js +0 -1
- package/node/locales/trTR.js +12 -15
- package/node/locales/ukUA.js +0 -1
- package/node/locales/urPK.js +0 -1
- package/node/locales/viVN.js +0 -1
- package/node/locales/zhCN.js +10 -13
- package/node/locales/zhHK.js +0 -1
- package/node/locales/zhTW.js +0 -1
- package/package.json +2 -2
|
@@ -9,13 +9,15 @@ exports.useGridStrategyProcessing = exports.GRID_STRATEGIES_PROCESSORS = exports
|
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var _toPropertyKey2 = _interopRequireDefault(require("@babel/runtime/helpers/toPropertyKey"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _gridStrategyProcessingApi = require("./gridStrategyProcessingApi");
|
|
12
13
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
13
14
|
const GRID_DEFAULT_STRATEGY = exports.GRID_DEFAULT_STRATEGY = 'none';
|
|
14
15
|
const GRID_STRATEGIES_PROCESSORS = exports.GRID_STRATEGIES_PROCESSORS = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
dataSourceRowsUpdate: _gridStrategyProcessingApi.GridStrategyGroup.DataSource,
|
|
17
|
+
rowTreeCreation: _gridStrategyProcessingApi.GridStrategyGroup.RowTree,
|
|
18
|
+
filtering: _gridStrategyProcessingApi.GridStrategyGroup.RowTree,
|
|
19
|
+
sorting: _gridStrategyProcessingApi.GridStrategyGroup.RowTree,
|
|
20
|
+
visibleRowsLookupCreation: _gridStrategyProcessingApi.GridStrategyGroup.RowTree
|
|
19
21
|
};
|
|
20
22
|
/**
|
|
21
23
|
* Implements a variant of the Strategy Pattern (see https://en.wikipedia.org/wiki/Strategy_pattern)
|
|
@@ -52,10 +54,7 @@ const GRID_STRATEGIES_PROCESSORS = exports.GRID_STRATEGIES_PROCESSORS = {
|
|
|
52
54
|
* =====================================================================================================================
|
|
53
55
|
*
|
|
54
56
|
* Each processor name is part of a strategy group which can only have one active strategy at the time.
|
|
55
|
-
*
|
|
56
|
-
* - row tree creation algorithm.
|
|
57
|
-
* - sorting algorithm.
|
|
58
|
-
* - filtering algorithm.
|
|
57
|
+
* There are two active groups named `rowTree` and `dataSource`.
|
|
59
58
|
*/
|
|
60
59
|
const useGridStrategyProcessing = apiRef => {
|
|
61
60
|
const availableStrategies = React.useRef(new Map());
|
|
@@ -500,7 +500,8 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
500
500
|
const widthByField = extractColumnWidths(apiRef, options, columns);
|
|
501
501
|
const newColumns = columns.map(column => (0, _extends2.default)({}, column, {
|
|
502
502
|
width: widthByField[column.field],
|
|
503
|
-
computedWidth: widthByField[column.field]
|
|
503
|
+
computedWidth: widthByField[column.field],
|
|
504
|
+
flex: 0
|
|
504
505
|
}));
|
|
505
506
|
if (options.expand) {
|
|
506
507
|
const visibleColumns = state.orderedFields.map(field => state.lookup[field]).filter(c => state.columnVisibilityModel[c.field] !== false);
|
|
@@ -76,28 +76,13 @@ function useGridDimensions(apiRef, props) {
|
|
|
76
76
|
const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
|
|
77
77
|
const [savedSize, setSavedSize] = React.useState();
|
|
78
78
|
const debouncedSetSavedSize = React.useMemo(() => (0, _throttle.throttle)(setSavedSize, props.resizeThrottleMs), [props.resizeThrottleMs]);
|
|
79
|
-
|
|
79
|
+
React.useEffect(() => debouncedSetSavedSize.clear, [debouncedSetSavedSize]);
|
|
80
80
|
const getRootDimensions = () => apiRef.current.state.dimensions;
|
|
81
81
|
const setDimensions = (0, _utils.unstable_useEventCallback)(dimensions => {
|
|
82
82
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
83
83
|
dimensions
|
|
84
84
|
}));
|
|
85
85
|
});
|
|
86
|
-
const resize = React.useCallback(() => {
|
|
87
|
-
const element = apiRef.current.mainElementRef.current;
|
|
88
|
-
if (!element) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const computedStyle = (0, _utils.unstable_ownerWindow)(element).getComputedStyle(element);
|
|
92
|
-
const newSize = {
|
|
93
|
-
width: parseFloat(computedStyle.width) || 0,
|
|
94
|
-
height: parseFloat(computedStyle.height) || 0
|
|
95
|
-
};
|
|
96
|
-
if (!previousSize.current || !areElementSizesEqual(previousSize.current, newSize)) {
|
|
97
|
-
apiRef.current.publishEvent('resize', newSize);
|
|
98
|
-
previousSize.current = newSize;
|
|
99
|
-
}
|
|
100
|
-
}, [apiRef]);
|
|
101
86
|
const getViewportPageSize = React.useCallback(() => {
|
|
102
87
|
const dimensions = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state);
|
|
103
88
|
if (!dimensions.isReady) {
|
|
@@ -208,7 +193,6 @@ function useGridDimensions(apiRef, props) {
|
|
|
208
193
|
apiRef.current.updateRenderContext?.();
|
|
209
194
|
}, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, rowHeight, headerHeight, groupHeaderHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
|
|
210
195
|
const apiPublic = {
|
|
211
|
-
resize,
|
|
212
196
|
getRootDimensions
|
|
213
197
|
};
|
|
214
198
|
const apiPrivate = {
|
|
@@ -248,7 +232,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
248
232
|
rootDimensionsRef.current = size;
|
|
249
233
|
|
|
250
234
|
// jsdom has no layout capabilities
|
|
251
|
-
const isJSDOM = /jsdom/.test(window.navigator.userAgent);
|
|
235
|
+
const isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent);
|
|
252
236
|
if (size.height === 0 && !errorShown.current && !props.autoHeight && !isJSDOM) {
|
|
253
237
|
logger.error(['The parent DOM element of the Data Grid has an empty height.', 'Please make sure that this element has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
|
|
254
238
|
errorShown.current = true;
|
|
@@ -450,7 +450,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
450
450
|
|
|
451
451
|
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
452
452
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
453
|
-
const
|
|
453
|
+
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
454
454
|
|
|
455
455
|
// Update the ref here because updateStateToStopCellEditMode may change it later
|
|
456
456
|
const copyOfPrevCellModes = prevCellModesModel.current;
|
|
@@ -459,7 +459,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
459
459
|
Object.entries(cellModesModel).forEach(([id, fields]) => {
|
|
460
460
|
Object.entries(fields).forEach(([field, params]) => {
|
|
461
461
|
const prevMode = copyOfPrevCellModes[id]?.[field]?.mode || _gridEditRowModel.GridCellModes.View;
|
|
462
|
-
const originalId =
|
|
462
|
+
const originalId = apiRef.current.getRowId(rowsLookup[id]) ?? id;
|
|
463
463
|
if (params.mode === _gridEditRowModel.GridCellModes.Edit && prevMode === _gridEditRowModel.GridCellModes.View) {
|
|
464
464
|
updateStateToStartCellEditMode((0, _extends2.default)({
|
|
465
465
|
id: originalId,
|
|
@@ -579,7 +579,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
579
579
|
|
|
580
580
|
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
581
581
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
582
|
-
const
|
|
582
|
+
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
583
583
|
|
|
584
584
|
// Update the ref here because updateStateToStopRowEditMode may change it later
|
|
585
585
|
const copyOfPrevRowModesModel = prevRowModesModel.current;
|
|
@@ -591,7 +591,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
591
591
|
mode: _gridEditRowModel.GridRowModes.View
|
|
592
592
|
};
|
|
593
593
|
const prevMode = copyOfPrevRowModesModel[id]?.mode || _gridEditRowModel.GridRowModes.View;
|
|
594
|
-
const originalId =
|
|
594
|
+
const originalId = apiRef.current.getRowId(rowsLookup[id]) ?? id;
|
|
595
595
|
if (params.mode === _gridEditRowModel.GridRowModes.Edit && prevMode === _gridEditRowModel.GridRowModes.View) {
|
|
596
596
|
updateStateToStartRowEditMode((0, _extends2.default)({
|
|
597
597
|
id: originalId
|
|
@@ -91,6 +91,17 @@ Object.keys(_focus).forEach(function (key) {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
|
+
var _listView = require("./listView");
|
|
95
|
+
Object.keys(_listView).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _listView[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _listView[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
94
105
|
var _pagination = require("./pagination");
|
|
95
106
|
Object.keys(_pagination).forEach(function (key) {
|
|
96
107
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.gridListColumnSelector = void 0;
|
|
7
7
|
/**
|
|
8
|
-
* Get
|
|
8
|
+
* Get the list column definition
|
|
9
|
+
* @category List View
|
|
10
|
+
* @ignore - Do not document
|
|
9
11
|
*/
|
|
10
12
|
const gridListColumnSelector = state => state.listViewColumn;
|
|
11
13
|
exports.gridListColumnSelector = gridListColumnSelector;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _gridListViewSelectors = require("./gridListViewSelectors");
|
|
7
|
+
Object.keys(_gridListViewSelectors).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _gridListViewSelectors[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _gridListViewSelectors[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.useGridOverlays = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
7
11
|
var _utils = require("../../utils");
|
|
8
12
|
var _useGridApiContext = require("../../utils/useGridApiContext");
|
|
9
13
|
var _useGridRootProps = require("../../utils/useGridRootProps");
|
|
10
14
|
var _filter = require("../filter");
|
|
11
15
|
var _rows = require("../rows");
|
|
16
|
+
var _GridOverlays = require("../../../components/base/GridOverlays");
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
18
|
/**
|
|
13
19
|
* Uses the grid state to determine which overlay to display.
|
|
14
20
|
* Returns the active overlay type and the active loading overlay variant.
|
|
@@ -34,9 +40,23 @@ const useGridOverlays = () => {
|
|
|
34
40
|
overlayType = 'loadingOverlay';
|
|
35
41
|
loadingOverlayVariant = rootProps.slotProps?.loadingOverlay?.[noRows ? 'noRowsVariant' : 'variant'] || null;
|
|
36
42
|
}
|
|
37
|
-
|
|
43
|
+
const overlaysProps = {
|
|
38
44
|
overlayType,
|
|
39
45
|
loadingOverlayVariant
|
|
40
46
|
};
|
|
47
|
+
const getOverlay = () => {
|
|
48
|
+
if (!overlayType) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const Overlay = rootProps.slots?.[overlayType];
|
|
52
|
+
const overlayProps = rootProps.slotProps?.[overlayType];
|
|
53
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridOverlays.GridOverlayWrapper, (0, _extends2.default)({}, overlaysProps, {
|
|
54
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Overlay, (0, _extends2.default)({}, overlayProps))
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
getOverlay,
|
|
59
|
+
overlaysProps
|
|
60
|
+
};
|
|
41
61
|
};
|
|
42
62
|
exports.useGridOverlays = useGridOverlays;
|
|
@@ -257,11 +257,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
257
257
|
/*
|
|
258
258
|
* EVENTS
|
|
259
259
|
*/
|
|
260
|
-
const isFirstRender = React.useRef(true);
|
|
261
260
|
const removeOutdatedSelection = React.useCallback((sortModelUpdated = false) => {
|
|
262
|
-
if (isFirstRender.current) {
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
261
|
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
266
262
|
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
267
263
|
const filteredRowsLookup = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
|
|
@@ -489,10 +485,5 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
489
485
|
React.useEffect(() => {
|
|
490
486
|
runIfRowSelectionIsEnabled(removeOutdatedSelection);
|
|
491
487
|
}, [removeOutdatedSelection, runIfRowSelectionIsEnabled]);
|
|
492
|
-
React.useEffect(() => {
|
|
493
|
-
if (isFirstRender.current) {
|
|
494
|
-
isFirstRender.current = false;
|
|
495
|
-
}
|
|
496
|
-
}, []);
|
|
497
488
|
};
|
|
498
489
|
exports.useGridRowSelection = useGridRowSelection;
|
|
@@ -14,8 +14,8 @@ var _gridRowSelectionSelector = require("./gridRowSelectionSelector");
|
|
|
14
14
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
15
15
|
var _createSelector = require("../../../utils/createSelector");
|
|
16
16
|
const ROW_SELECTION_PROPAGATION_DEFAULT = exports.ROW_SELECTION_PROPAGATION_DEFAULT = {
|
|
17
|
-
parents:
|
|
18
|
-
descendants:
|
|
17
|
+
parents: true,
|
|
18
|
+
descendants: true
|
|
19
19
|
};
|
|
20
20
|
function getGridRowGroupSelectableDescendants(apiRef, groupId) {
|
|
21
21
|
const rowTree = (0, _gridRowsSelector.gridRowTreeSelector)(apiRef);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.gridTopLevelRowCountSelector = exports.gridRowsLookupSelector = exports.gridRowsLoadingSelector = exports.
|
|
6
|
+
exports.gridTopLevelRowCountSelector = exports.gridRowsLookupSelector = exports.gridRowsLoadingSelector = exports.gridRowTreeSelector = exports.gridRowTreeDepthsSelector = exports.gridRowMaximumTreeDepthSelector = exports.gridRowGroupsToFetchSelector = exports.gridRowGroupingNameSelector = exports.gridRowCountSelector = exports.gridPinnedRowsSelector = exports.gridPinnedRowsCountSelector = exports.gridDataRowIdsSelector = exports.gridAdditionalRowGroupsSelector = void 0;
|
|
7
7
|
var _createSelector = require("../../../utils/createSelector");
|
|
8
8
|
const gridRowsStateSelector = state => state.rows;
|
|
9
9
|
const gridRowCountSelector = exports.gridRowCountSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.totalRowCount);
|
|
@@ -12,7 +12,6 @@ const gridTopLevelRowCountSelector = exports.gridTopLevelRowCountSelector = (0,
|
|
|
12
12
|
|
|
13
13
|
// TODO rows v6: Rename
|
|
14
14
|
const gridRowsLookupSelector = exports.gridRowsLookupSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.dataRowIdToModelLookup);
|
|
15
|
-
const gridRowsDataRowIdToIdLookupSelector = exports.gridRowsDataRowIdToIdLookupSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.dataRowIdToIdLookup);
|
|
16
15
|
const gridRowTreeSelector = exports.gridRowTreeSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.tree);
|
|
17
16
|
const gridRowGroupsToFetchSelector = exports.gridRowGroupsToFetchSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.groupsToFetch);
|
|
18
17
|
const gridRowGroupingNameSelector = exports.gridRowGroupingNameSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.groupingName);
|
|
@@ -55,12 +55,10 @@ const createRowsInternalCache = ({
|
|
|
55
55
|
rows: []
|
|
56
56
|
};
|
|
57
57
|
const dataRowIdToModelLookup = {};
|
|
58
|
-
const dataRowIdToIdLookup = {};
|
|
59
58
|
for (let i = 0; i < rows.length; i += 1) {
|
|
60
59
|
const model = rows[i];
|
|
61
60
|
const id = getRowIdFromRowModel(model, getRowId);
|
|
62
61
|
dataRowIdToModelLookup[id] = model;
|
|
63
|
-
dataRowIdToIdLookup[id] = id;
|
|
64
62
|
updates.rows.push(id);
|
|
65
63
|
}
|
|
66
64
|
return {
|
|
@@ -68,7 +66,6 @@ const createRowsInternalCache = ({
|
|
|
68
66
|
loadingPropBeforePartialUpdates: loading,
|
|
69
67
|
rowCountPropBeforePartialUpdates: rowCount,
|
|
70
68
|
updates,
|
|
71
|
-
dataRowIdToIdLookup,
|
|
72
69
|
dataRowIdToModelLookup
|
|
73
70
|
};
|
|
74
71
|
};
|
|
@@ -102,7 +99,6 @@ const getRowsStateFromCache = ({
|
|
|
102
99
|
previousTree,
|
|
103
100
|
previousTreeDepths,
|
|
104
101
|
updates: cache.updates,
|
|
105
|
-
dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
|
|
106
102
|
dataRowIdToModelLookup: cache.dataRowIdToModelLookup,
|
|
107
103
|
previousGroupsToFetch
|
|
108
104
|
});
|
|
@@ -111,7 +107,6 @@ const getRowsStateFromCache = ({
|
|
|
111
107
|
const groupingParamsWithHydrateRows = apiRef.current.unstable_applyPipeProcessors('hydrateRows', {
|
|
112
108
|
tree: unProcessedTree,
|
|
113
109
|
treeDepths: unProcessedTreeDepths,
|
|
114
|
-
dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
|
|
115
110
|
dataRowIds: unProcessedDataRowIds,
|
|
116
111
|
dataRowIdToModelLookup: cache.dataRowIdToModelLookup
|
|
117
112
|
});
|
|
@@ -196,7 +191,6 @@ const updateCacheWithNewRows = ({
|
|
|
196
191
|
groupKeys
|
|
197
192
|
};
|
|
198
193
|
const dataRowIdToModelLookup = (0, _extends2.default)({}, previousCache.dataRowIdToModelLookup);
|
|
199
|
-
const dataRowIdToIdLookup = (0, _extends2.default)({}, previousCache.dataRowIdToIdLookup);
|
|
200
194
|
const alreadyAppliedActionsToRemove = {
|
|
201
195
|
insert: {},
|
|
202
196
|
modify: {},
|
|
@@ -229,7 +223,6 @@ const updateCacheWithNewRows = ({
|
|
|
229
223
|
// Remove the data row from the lookups and add it to the "delete" update.
|
|
230
224
|
partialUpdates.actions.remove.push(id);
|
|
231
225
|
delete dataRowIdToModelLookup[id];
|
|
232
|
-
delete dataRowIdToIdLookup[id];
|
|
233
226
|
return;
|
|
234
227
|
}
|
|
235
228
|
const oldRow = dataRowIdToModelLookup[id];
|
|
@@ -269,7 +262,6 @@ const updateCacheWithNewRows = ({
|
|
|
269
262
|
|
|
270
263
|
// Update the data row lookups.
|
|
271
264
|
dataRowIdToModelLookup[id] = partialRow;
|
|
272
|
-
dataRowIdToIdLookup[id] = id;
|
|
273
265
|
});
|
|
274
266
|
const actionTypeWithActionsToRemove = Object.keys(alreadyAppliedActionsToRemove);
|
|
275
267
|
for (let i = 0; i < actionTypeWithActionsToRemove.length; i += 1) {
|
|
@@ -281,7 +273,6 @@ const updateCacheWithNewRows = ({
|
|
|
281
273
|
}
|
|
282
274
|
return {
|
|
283
275
|
dataRowIdToModelLookup,
|
|
284
|
-
dataRowIdToIdLookup,
|
|
285
276
|
updates: partialUpdates,
|
|
286
277
|
rowsBeforePartialUpdates: previousCache.rowsBeforePartialUpdates,
|
|
287
278
|
loadingPropBeforePartialUpdates: previousCache.loadingPropBeforePartialUpdates,
|
|
@@ -8,7 +8,6 @@ var _exportNames = {
|
|
|
8
8
|
gridRowsLoadingSelector: true,
|
|
9
9
|
gridTopLevelRowCountSelector: true,
|
|
10
10
|
gridRowsLookupSelector: true,
|
|
11
|
-
gridRowsDataRowIdToIdLookupSelector: true,
|
|
12
11
|
gridRowTreeSelector: true,
|
|
13
12
|
gridRowGroupingNameSelector: true,
|
|
14
13
|
gridRowTreeDepthsSelector: true,
|
|
@@ -66,12 +65,6 @@ Object.defineProperty(exports, "gridRowTreeSelector", {
|
|
|
66
65
|
return _gridRowsSelector.gridRowTreeSelector;
|
|
67
66
|
}
|
|
68
67
|
});
|
|
69
|
-
Object.defineProperty(exports, "gridRowsDataRowIdToIdLookupSelector", {
|
|
70
|
-
enumerable: true,
|
|
71
|
-
get: function () {
|
|
72
|
-
return _gridRowsSelector.gridRowsDataRowIdToIdLookupSelector;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
68
|
Object.defineProperty(exports, "gridRowsLoadingSelector", {
|
|
76
69
|
enumerable: true,
|
|
77
70
|
get: function () {
|
|
@@ -19,6 +19,7 @@ var _gridSortingSelector = require("../sorting/gridSortingSelector");
|
|
|
19
19
|
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
20
20
|
var _gridRowsUtils = require("./gridRowsUtils");
|
|
21
21
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
22
|
+
var _strategyProcessing = require("../../core/strategyProcessing");
|
|
22
23
|
const rowsStateInitializer = (state, props, apiRef) => {
|
|
23
24
|
const isDataSourceAvailable = !!props.unstable_dataSource;
|
|
24
25
|
apiRef.current.caches.rows = (0, _gridRowsUtils.createRowsInternalCache)({
|
|
@@ -281,7 +282,6 @@ const useGridRows = (apiRef, props) => {
|
|
|
281
282
|
}
|
|
282
283
|
const tree = (0, _extends2.default)({}, (0, _gridRowsSelector.gridRowTreeSelector)(apiRef));
|
|
283
284
|
const dataRowIdToModelLookup = (0, _extends2.default)({}, (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef));
|
|
284
|
-
const dataRowIdToIdLookup = (0, _extends2.default)({}, (0, _gridRowsSelector.gridRowsDataRowIdToIdLookupSelector)(apiRef));
|
|
285
285
|
const rootGroup = tree[_gridRowsUtils.GRID_ROOT_GROUP_ID];
|
|
286
286
|
const rootGroupChildren = [...rootGroup.children];
|
|
287
287
|
const seenIds = new Set();
|
|
@@ -291,7 +291,6 @@ const useGridRows = (apiRef, props) => {
|
|
|
291
291
|
const [removedRowId] = rootGroupChildren.splice(firstRowToRender + i, 1, rowId);
|
|
292
292
|
if (!seenIds.has(removedRowId)) {
|
|
293
293
|
delete dataRowIdToModelLookup[removedRowId];
|
|
294
|
-
delete dataRowIdToIdLookup[removedRowId];
|
|
295
294
|
delete tree[removedRowId];
|
|
296
295
|
}
|
|
297
296
|
const rowTreeNodeConfig = {
|
|
@@ -302,7 +301,6 @@ const useGridRows = (apiRef, props) => {
|
|
|
302
301
|
groupingKey: null
|
|
303
302
|
};
|
|
304
303
|
dataRowIdToModelLookup[rowId] = rowModel;
|
|
305
|
-
dataRowIdToIdLookup[rowId] = rowId;
|
|
306
304
|
tree[rowId] = rowTreeNodeConfig;
|
|
307
305
|
seenIds.add(rowId);
|
|
308
306
|
}
|
|
@@ -313,17 +311,17 @@ const useGridRows = (apiRef, props) => {
|
|
|
313
311
|
// Removes potential remaining skeleton rows from the dataRowIds.
|
|
314
312
|
const dataRowIds = rootGroupChildren.filter(childId => tree[childId]?.type === 'leaf');
|
|
315
313
|
apiRef.current.caches.rows.dataRowIdToModelLookup = dataRowIdToModelLookup;
|
|
316
|
-
apiRef.current.caches.rows.dataRowIdToIdLookup = dataRowIdToIdLookup;
|
|
317
314
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
318
315
|
rows: (0, _extends2.default)({}, state.rows, {
|
|
316
|
+
loading: props.loading,
|
|
317
|
+
totalRowCount: Math.max(props.rowCount || 0, rootGroupChildren.length),
|
|
319
318
|
dataRowIdToModelLookup,
|
|
320
|
-
dataRowIdToIdLookup,
|
|
321
319
|
dataRowIds,
|
|
322
320
|
tree
|
|
323
321
|
})
|
|
324
322
|
}));
|
|
325
323
|
apiRef.current.publishEvent('rowsSet');
|
|
326
|
-
}, [apiRef, props.signature, props.getRowId]);
|
|
324
|
+
}, [apiRef, props.signature, props.getRowId, props.loading, props.rowCount]);
|
|
327
325
|
const rowApi = {
|
|
328
326
|
getRow,
|
|
329
327
|
setLoading,
|
|
@@ -390,7 +388,7 @@ const useGridRows = (apiRef, props) => {
|
|
|
390
388
|
const handleStrategyActivityChange = React.useCallback(() => {
|
|
391
389
|
// `rowTreeCreation` is the only processor ran when `strategyAvailabilityChange` is fired.
|
|
392
390
|
// All the other processors listen to `rowsSet` which will be published by the `groupRows` method below.
|
|
393
|
-
if (apiRef.current.getActiveStrategy(
|
|
391
|
+
if (apiRef.current.getActiveStrategy(_strategyProcessing.GridStrategyGroup.RowTree) !== (0, _gridRowsSelector.gridRowGroupingNameSelector)(apiRef)) {
|
|
394
392
|
groupRows();
|
|
395
393
|
}
|
|
396
394
|
}, [apiRef, groupRows]);
|
|
@@ -406,8 +404,7 @@ const useGridRows = (apiRef, props) => {
|
|
|
406
404
|
tree: (0, _gridRowsSelector.gridRowTreeSelector)(state, apiRef.current.instanceId),
|
|
407
405
|
treeDepths: (0, _gridRowsSelector.gridRowTreeDepthsSelector)(state, apiRef.current.instanceId),
|
|
408
406
|
dataRowIds: (0, _gridRowsSelector.gridDataRowIdsSelector)(state, apiRef.current.instanceId),
|
|
409
|
-
dataRowIdToModelLookup: (0, _gridRowsSelector.gridRowsLookupSelector)(state, apiRef.current.instanceId)
|
|
410
|
-
dataRowIdToIdLookup: (0, _gridRowsSelector.gridRowsDataRowIdToIdLookupSelector)(state, apiRef.current.instanceId)
|
|
407
|
+
dataRowIdToModelLookup: (0, _gridRowsSelector.gridRowsLookupSelector)(state, apiRef.current.instanceId)
|
|
411
408
|
});
|
|
412
409
|
return (0, _extends2.default)({}, state, {
|
|
413
410
|
rows: (0, _extends2.default)({}, state.rows, response, {
|
|
@@ -439,7 +436,8 @@ const useGridRows = (apiRef, props) => {
|
|
|
439
436
|
isRowCountPropUpdated = true;
|
|
440
437
|
lastRowCount.current = props.rowCount;
|
|
441
438
|
}
|
|
442
|
-
const
|
|
439
|
+
const currentRows = props.unstable_dataSource ? Array.from(apiRef.current.getRowModels().values()) : props.rows;
|
|
440
|
+
const areNewRowsAlreadyInState = apiRef.current.caches.rows.rowsBeforePartialUpdates === currentRows;
|
|
443
441
|
const isNewLoadingAlreadyInState = apiRef.current.caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
444
442
|
const isNewRowCountAlreadyInState = apiRef.current.caches.rows.rowCountPropBeforePartialUpdates === props.rowCount;
|
|
445
443
|
|
|
@@ -469,16 +467,16 @@ const useGridRows = (apiRef, props) => {
|
|
|
469
467
|
return;
|
|
470
468
|
}
|
|
471
469
|
}
|
|
472
|
-
logger.debug(`Updating all rows, new length ${
|
|
470
|
+
logger.debug(`Updating all rows, new length ${currentRows?.length}`);
|
|
473
471
|
throttledRowsChange({
|
|
474
472
|
cache: (0, _gridRowsUtils.createRowsInternalCache)({
|
|
475
|
-
rows:
|
|
473
|
+
rows: currentRows,
|
|
476
474
|
getRowId: props.getRowId,
|
|
477
475
|
loading: props.loading,
|
|
478
476
|
rowCount: props.rowCount
|
|
479
477
|
}),
|
|
480
478
|
throttle: false
|
|
481
479
|
});
|
|
482
|
-
}, [props.rows, props.rowCount, props.getRowId, props.loading, logger, throttledRowsChange, apiRef]);
|
|
480
|
+
}, [props.rows, props.rowCount, props.getRowId, props.loading, props.unstable_dataSource, logger, throttledRowsChange, apiRef]);
|
|
483
481
|
};
|
|
484
482
|
exports.useGridRows = useGridRows;
|
|
@@ -15,8 +15,8 @@ var ReactDOM = _interopRequireWildcard(require("react-dom"));
|
|
|
15
15
|
var _utils = require("@mui/utils");
|
|
16
16
|
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
17
17
|
var _useTimeout = _interopRequireDefault(require("@mui/utils/useTimeout"));
|
|
18
|
-
var _useResizeObserver = require("@mui/x-internals/useResizeObserver");
|
|
19
18
|
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
19
|
+
var _reactMajor = _interopRequireDefault(require("@mui/x-internals/reactMajor"));
|
|
20
20
|
var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
|
|
21
21
|
var _useGridRootProps = require("../../utils/useGridRootProps");
|
|
22
22
|
var _useGridSelector = require("../../utils/useGridSelector");
|
|
@@ -59,7 +59,7 @@ const createScrollCache = (isRtl, rowBufferPx, columnBufferPx, verticalBuffer, h
|
|
|
59
59
|
let isJSDOM = false;
|
|
60
60
|
try {
|
|
61
61
|
if (typeof window !== 'undefined') {
|
|
62
|
-
isJSDOM = /jsdom/.test(window.navigator.userAgent);
|
|
62
|
+
isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent);
|
|
63
63
|
}
|
|
64
64
|
} catch (_) {
|
|
65
65
|
/* ignore */
|
|
@@ -97,7 +97,44 @@ const useGridVirtualScroller = () => {
|
|
|
97
97
|
const contentHeight = dimensions.contentSize.height;
|
|
98
98
|
const columnsTotalWidth = dimensions.columnsTotalWidth;
|
|
99
99
|
const hasColSpan = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridHasColSpanSelector);
|
|
100
|
-
|
|
100
|
+
const mainRefCallback = React.useCallback(node => {
|
|
101
|
+
mainRef.current = node;
|
|
102
|
+
if (!node) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
const initialRect = node.getBoundingClientRect();
|
|
106
|
+
let lastSize = {
|
|
107
|
+
width: initialRect.width,
|
|
108
|
+
height: initialRect.height
|
|
109
|
+
};
|
|
110
|
+
apiRef.current.publishEvent('resize', lastSize);
|
|
111
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
const observer = new ResizeObserver(entries => {
|
|
115
|
+
const entry = entries[0];
|
|
116
|
+
if (!entry) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const newSize = {
|
|
120
|
+
width: entry.contentRect.width,
|
|
121
|
+
height: entry.contentRect.height
|
|
122
|
+
};
|
|
123
|
+
if (newSize.width === lastSize.width && newSize.height === lastSize.height) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
apiRef.current.publishEvent('resize', newSize);
|
|
127
|
+
lastSize = newSize;
|
|
128
|
+
});
|
|
129
|
+
observer.observe(node);
|
|
130
|
+
if (_reactMajor.default >= 19) {
|
|
131
|
+
return () => {
|
|
132
|
+
mainRef.current = null;
|
|
133
|
+
observer.disconnect();
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
}, [apiRef, mainRef]);
|
|
101
138
|
|
|
102
139
|
/*
|
|
103
140
|
* Scroll context logic
|
|
@@ -148,9 +185,13 @@ const useGridVirtualScroller = () => {
|
|
|
148
185
|
previousContextScrollPosition.current = scrollPosition.current;
|
|
149
186
|
}, [apiRef, dimensions.isReady]);
|
|
150
187
|
const triggerUpdateRenderContext = (0, _utils.unstable_useEventCallback)(() => {
|
|
188
|
+
const scroller = scrollerRef.current;
|
|
189
|
+
if (!scroller) {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
151
192
|
const newScroll = {
|
|
152
|
-
top:
|
|
153
|
-
left:
|
|
193
|
+
top: scroller.scrollTop,
|
|
194
|
+
left: scroller.scrollLeft
|
|
154
195
|
};
|
|
155
196
|
const dx = newScroll.left - scrollPosition.current.left;
|
|
156
197
|
const dy = newScroll.top - scrollPosition.current.top;
|
|
@@ -400,10 +441,6 @@ const useGridVirtualScroller = () => {
|
|
|
400
441
|
React.useEffect(() => {
|
|
401
442
|
apiRef.current.publishEvent('virtualScrollerContentSizeChange');
|
|
402
443
|
}, [apiRef, contentSize]);
|
|
403
|
-
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
404
|
-
// FIXME: Is this really necessary?
|
|
405
|
-
apiRef.current.resize();
|
|
406
|
-
}, [apiRef, rowsMeta.currentPageTotalHeight]);
|
|
407
444
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
408
445
|
// TODO a scroll reset should not be necessary
|
|
409
446
|
if (enabledForColumns) {
|
|
@@ -439,7 +476,7 @@ const useGridVirtualScroller = () => {
|
|
|
439
476
|
setPanels,
|
|
440
477
|
getRows,
|
|
441
478
|
getContainerProps: () => ({
|
|
442
|
-
ref:
|
|
479
|
+
ref: mainRefCallback
|
|
443
480
|
}),
|
|
444
481
|
getScrollerProps: () => ({
|
|
445
482
|
ref: scrollerRef,
|
|
@@ -497,7 +534,8 @@ function inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns) {
|
|
|
497
534
|
pinnedColumns: (0, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector)(apiRef),
|
|
498
535
|
visibleColumns,
|
|
499
536
|
hiddenCellsOriginMap,
|
|
500
|
-
listView: rootProps.unstable_listView ?? false
|
|
537
|
+
listView: rootProps.unstable_listView ?? false,
|
|
538
|
+
virtualizeColumnsWithAutoRowHeight: rootProps.virtualizeColumnsWithAutoRowHeight
|
|
501
539
|
};
|
|
502
540
|
}
|
|
503
541
|
function computeRenderContext(inputs, scrollPosition, scrollCache) {
|
|
@@ -545,11 +583,13 @@ function computeRenderContext(inputs, scrollPosition, scrollCache) {
|
|
|
545
583
|
positions: inputs.rowsMeta.positions,
|
|
546
584
|
lastSize: inputs.lastRowHeight
|
|
547
585
|
});
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
586
|
+
if (!inputs.virtualizeColumnsWithAutoRowHeight) {
|
|
587
|
+
for (let i = firstRowToRender; i < lastRowToRender && !hasRowWithAutoHeight; i += 1) {
|
|
588
|
+
const row = inputs.rows[i];
|
|
589
|
+
hasRowWithAutoHeight = inputs.apiRef.current.rowHasAutoHeight(row.id);
|
|
590
|
+
}
|
|
551
591
|
}
|
|
552
|
-
if (!hasRowWithAutoHeight) {
|
|
592
|
+
if (!hasRowWithAutoHeight || inputs.virtualizeColumnsWithAutoRowHeight) {
|
|
553
593
|
firstColumnIndex = binarySearch(realLeft, inputs.columnPositions, {
|
|
554
594
|
atStart: true,
|
|
555
595
|
lastPosition: inputs.columnsTotalWidth
|
package/node/index.js
CHANGED
package/node/internals/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var _exportNames = {
|
|
|
14
14
|
getValueOptions: true,
|
|
15
15
|
isSingleSelectColDef: true,
|
|
16
16
|
useGridRegisterPipeProcessor: true,
|
|
17
|
+
GridStrategyGroup: true,
|
|
17
18
|
useGridRegisterStrategyProcessor: true,
|
|
18
19
|
GRID_DEFAULT_STRATEGY: true,
|
|
19
20
|
useGridInitialization: true,
|
|
@@ -141,6 +142,12 @@ Object.defineProperty(exports, "GridHeaders", {
|
|
|
141
142
|
return _GridHeaders.GridHeaders;
|
|
142
143
|
}
|
|
143
144
|
});
|
|
145
|
+
Object.defineProperty(exports, "GridStrategyGroup", {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function () {
|
|
148
|
+
return _strategyProcessing.GridStrategyGroup;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
144
151
|
Object.defineProperty(exports, "GridVirtualScroller", {
|
|
145
152
|
enumerable: true,
|
|
146
153
|
get: function () {
|
package/node/locales/arSD.js
CHANGED
|
@@ -34,7 +34,6 @@ const arSDGrid = {
|
|
|
34
34
|
// toolbarPromptControlWithRecordingPlaceholder: 'Type or record a prompt…',
|
|
35
35
|
// toolbarPromptControlRecordingPlaceholder: 'Listening for prompt…',
|
|
36
36
|
// toolbarPromptControlLabel: 'Prompt input',
|
|
37
|
-
// toolbarPromptControlDeleteIconLabel: 'Clear',
|
|
38
37
|
// toolbarPromptControlRecordButtonDefaultLabel: 'Record',
|
|
39
38
|
// toolbarPromptControlRecordButtonActiveLabel: 'Stop recording',
|
|
40
39
|
// toolbarPromptControlSendActionLabel: 'Send',
|
package/node/locales/beBY.js
CHANGED
|
@@ -48,7 +48,6 @@ const beBYGrid = {
|
|
|
48
48
|
// toolbarPromptControlWithRecordingPlaceholder: 'Type or record a prompt…',
|
|
49
49
|
// toolbarPromptControlRecordingPlaceholder: 'Listening for prompt…',
|
|
50
50
|
// toolbarPromptControlLabel: 'Prompt input',
|
|
51
|
-
// toolbarPromptControlDeleteIconLabel: 'Clear',
|
|
52
51
|
// toolbarPromptControlRecordButtonDefaultLabel: 'Record',
|
|
53
52
|
// toolbarPromptControlRecordButtonActiveLabel: 'Stop recording',
|
|
54
53
|
// toolbarPromptControlSendActionLabel: 'Send',
|
package/node/locales/bgBG.js
CHANGED
|
@@ -34,7 +34,6 @@ const bgBGGrid = {
|
|
|
34
34
|
// toolbarPromptControlWithRecordingPlaceholder: 'Type or record a prompt…',
|
|
35
35
|
// toolbarPromptControlRecordingPlaceholder: 'Listening for prompt…',
|
|
36
36
|
// toolbarPromptControlLabel: 'Prompt input',
|
|
37
|
-
// toolbarPromptControlDeleteIconLabel: 'Clear',
|
|
38
37
|
// toolbarPromptControlRecordButtonDefaultLabel: 'Record',
|
|
39
38
|
// toolbarPromptControlRecordButtonActiveLabel: 'Stop recording',
|
|
40
39
|
// toolbarPromptControlSendActionLabel: 'Send',
|