@mui/x-data-grid-pro 8.0.0-beta.3 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +388 -96
- package/DataGridPro/DataGridPro.js +8 -7
- package/DataGridPro/useDataGridProComponent.d.ts +2 -2
- package/DataGridPro/useDataGridProComponent.js +2 -3
- package/components/GridDetailPanel.js +1 -2
- package/components/headerFiltering/GridHeaderFilterMenu.js +2 -2
- package/esm/DataGridPro/DataGridPro.js +9 -8
- package/esm/DataGridPro/useDataGridProComponent.d.ts +2 -2
- package/esm/DataGridPro/useDataGridProComponent.js +2 -3
- package/esm/components/GridDetailPanel.js +1 -2
- package/esm/components/headerFiltering/GridHeaderFilterMenu.js +2 -2
- package/esm/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +3 -6
- package/esm/hooks/features/dataSource/useGridDataSourceBasePro.js +36 -8
- package/esm/hooks/features/dataSource/utils.d.ts +3 -2
- package/esm/hooks/features/dataSource/utils.js +13 -1
- package/esm/hooks/features/detailPanel/useGridDetailPanel.js +4 -3
- package/esm/hooks/features/lazyLoader/useGridLazyLoader.d.ts +1 -1
- package/esm/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +1 -1
- package/esm/hooks/features/rowPinning/useGridRowPinning.d.ts +1 -1
- package/esm/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.js +38 -1
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +1 -0
- package/esm/internals/index.js +1 -0
- package/esm/material/icons.d.ts +3 -6
- package/esm/material/icons.js +1 -1
- package/esm/material/index.d.ts +2 -2
- package/esm/models/dataGridProProps.d.ts +3 -3
- package/esm/models/gridProIconSlotsComponent.d.ts +6 -3
- package/esm/package.json +1 -1
- package/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +3 -6
- package/hooks/features/dataSource/useGridDataSourceBasePro.js +34 -6
- package/hooks/features/dataSource/utils.d.ts +3 -2
- package/hooks/features/dataSource/utils.js +15 -2
- package/hooks/features/detailPanel/useGridDetailPanel.js +4 -3
- package/hooks/features/lazyLoader/useGridLazyLoader.d.ts +1 -1
- package/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +1 -1
- package/hooks/features/rowPinning/useGridRowPinning.d.ts +1 -1
- package/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.js +37 -0
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +15 -7
- package/material/icons.d.ts +3 -6
- package/material/icons.js +3 -3
- package/material/index.d.ts +2 -2
- package/models/dataGridProProps.d.ts +3 -3
- package/models/gridProIconSlotsComponent.d.ts +6 -3
- package/package.json +8 -14
- package/esm/utils/releaseInfo.d.ts +0 -1
- package/esm/utils/releaseInfo.js +0 -13
- package/modern/DataGridPro/DataGrid.d.ts +0 -8
- package/modern/DataGridPro/DataGrid.js +0 -19
- package/modern/DataGridPro/DataGridPro.d.ts +0 -16
- package/modern/DataGridPro/DataGridPro.js +0 -1020
- package/modern/DataGridPro/index.d.ts +0 -3
- package/modern/DataGridPro/index.js +0 -3
- package/modern/DataGridPro/useDataGridProComponent.d.ts +0 -4
- package/modern/DataGridPro/useDataGridProComponent.js +0 -105
- package/modern/DataGridPro/useDataGridProProps.d.ts +0 -7
- package/modern/DataGridPro/useDataGridProProps.js +0 -54
- package/modern/components/GridColumnHeaders.d.ts +0 -5
- package/modern/components/GridColumnHeaders.js +0 -92
- package/modern/components/GridColumnMenuPinningItem.d.ts +0 -7
- package/modern/components/GridColumnMenuPinningItem.js +0 -77
- package/modern/components/GridDataSourceTreeDataGroupingCell.d.ts +0 -12
- package/modern/components/GridDataSourceTreeDataGroupingCell.js +0 -107
- package/modern/components/GridDetailPanel.d.ts +0 -14
- package/modern/components/GridDetailPanel.js +0 -53
- package/modern/components/GridDetailPanelToggleCell.d.ts +0 -7
- package/modern/components/GridDetailPanelToggleCell.js +0 -121
- package/modern/components/GridDetailPanels.d.ts +0 -3
- package/modern/components/GridDetailPanels.js +0 -67
- package/modern/components/GridPinnedRows.d.ts +0 -6
- package/modern/components/GridPinnedRows.js +0 -40
- package/modern/components/GridProColumnMenu.d.ts +0 -24
- package/modern/components/GridProColumnMenu.js +0 -21
- package/modern/components/GridRowReorderCell.d.ts +0 -8
- package/modern/components/GridRowReorderCell.js +0 -140
- package/modern/components/GridTreeDataGroupingCell.d.ts +0 -15
- package/modern/components/GridTreeDataGroupingCell.js +0 -133
- package/modern/components/headerFiltering/GridHeaderFilterCell.d.ts +0 -26
- package/modern/components/headerFiltering/GridHeaderFilterCell.js +0 -362
- package/modern/components/headerFiltering/GridHeaderFilterClearButton.d.ts +0 -6
- package/modern/components/headerFiltering/GridHeaderFilterClearButton.js +0 -17
- package/modern/components/headerFiltering/GridHeaderFilterMenu.d.ts +0 -30
- package/modern/components/headerFiltering/GridHeaderFilterMenu.js +0 -137
- package/modern/components/headerFiltering/GridHeaderFilterMenuContainer.d.ts +0 -17
- package/modern/components/headerFiltering/GridHeaderFilterMenuContainer.js +0 -138
- package/modern/components/headerFiltering/index.d.ts +0 -3
- package/modern/components/headerFiltering/index.js +0 -3
- package/modern/components/index.d.ts +0 -6
- package/modern/components/index.js +0 -7
- package/modern/components/reexports.d.ts +0 -1
- package/modern/components/reexports.js +0 -1
- package/modern/constants/dataGridProDefaultSlotsComponents.d.ts +0 -2
- package/modern/constants/dataGridProDefaultSlotsComponents.js +0 -17
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +0 -12
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +0 -143
- package/modern/hooks/features/columnPinning/gridColumnPinningInterface.d.ts +0 -40
- package/modern/hooks/features/columnPinning/gridColumnPinningInterface.js +0 -1
- package/modern/hooks/features/columnPinning/index.d.ts +0 -1
- package/modern/hooks/features/columnPinning/index.js +0 -1
- package/modern/hooks/features/columnPinning/useGridColumnPinning.d.ts +0 -6
- package/modern/hooks/features/columnPinning/useGridColumnPinning.js +0 -228
- package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.d.ts +0 -4
- package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +0 -105
- package/modern/hooks/features/columnReorder/columnReorderInterfaces.d.ts +0 -6
- package/modern/hooks/features/columnReorder/columnReorderInterfaces.js +0 -1
- package/modern/hooks/features/columnReorder/columnReorderSelector.d.ts +0 -3
- package/modern/hooks/features/columnReorder/columnReorderSelector.js +0 -3
- package/modern/hooks/features/columnReorder/index.d.ts +0 -2
- package/modern/hooks/features/columnReorder/index.js +0 -2
- package/modern/hooks/features/columnReorder/useGridColumnReorder.d.ts +0 -9
- package/modern/hooks/features/columnReorder/useGridColumnReorder.js +0 -242
- package/modern/hooks/features/dataSource/gridDataSourceSelector.d.ts +0 -7
- package/modern/hooks/features/dataSource/gridDataSourceSelector.js +0 -6
- package/modern/hooks/features/dataSource/models.d.ts +0 -75
- package/modern/hooks/features/dataSource/models.js +0 -1
- package/modern/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +0 -33
- package/modern/hooks/features/dataSource/useGridDataSourceBasePro.js +0 -179
- package/modern/hooks/features/dataSource/useGridDataSourcePro.d.ts +0 -6
- package/modern/hooks/features/dataSource/useGridDataSourcePro.js +0 -35
- package/modern/hooks/features/dataSource/utils.d.ts +0 -29
- package/modern/hooks/features/dataSource/utils.js +0 -82
- package/modern/hooks/features/detailPanel/gridDetailPanelInterface.d.ts +0 -41
- package/modern/hooks/features/detailPanel/gridDetailPanelInterface.js +0 -1
- package/modern/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +0 -14
- package/modern/hooks/features/detailPanel/gridDetailPanelSelector.js +0 -5
- package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.d.ts +0 -4
- package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +0 -34
- package/modern/hooks/features/detailPanel/index.d.ts +0 -3
- package/modern/hooks/features/detailPanel/index.js +0 -3
- package/modern/hooks/features/detailPanel/useGridDetailPanel.d.ts +0 -6
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +0 -191
- package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.d.ts +0 -4
- package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +0 -43
- package/modern/hooks/features/index.d.ts +0 -7
- package/modern/hooks/features/index.js +0 -8
- package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.d.ts +0 -9
- package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.js +0 -104
- package/modern/hooks/features/lazyLoader/useGridLazyLoader.d.ts +0 -10
- package/modern/hooks/features/lazyLoader/useGridLazyLoader.js +0 -90
- package/modern/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +0 -5
- package/modern/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.js +0 -34
- package/modern/hooks/features/lazyLoader/utils.d.ts +0 -18
- package/modern/hooks/features/lazyLoader/utils.js +0 -34
- package/modern/hooks/features/rowPinning/gridRowPinningInterface.d.ts +0 -17
- package/modern/hooks/features/rowPinning/gridRowPinningInterface.js +0 -1
- package/modern/hooks/features/rowPinning/gridRowPinningSelector.d.ts +0 -1
- package/modern/hooks/features/rowPinning/gridRowPinningSelector.js +0 -1
- package/modern/hooks/features/rowPinning/index.d.ts +0 -1
- package/modern/hooks/features/rowPinning/index.js +0 -1
- package/modern/hooks/features/rowPinning/useGridRowPinning.d.ts +0 -6
- package/modern/hooks/features/rowPinning/useGridRowPinning.js +0 -52
- package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.d.ts +0 -38
- package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +0 -119
- package/modern/hooks/features/rowReorder/gridRowReorderColDef.d.ts +0 -2
- package/modern/hooks/features/rowReorder/gridRowReorderColDef.js +0 -20
- package/modern/hooks/features/rowReorder/index.d.ts +0 -1
- package/modern/hooks/features/rowReorder/index.js +0 -1
- package/modern/hooks/features/rowReorder/useGridRowReorder.d.ts +0 -8
- package/modern/hooks/features/rowReorder/useGridRowReorder.js +0 -141
- package/modern/hooks/features/rowReorder/useGridRowReorderPreProcessors.d.ts +0 -4
- package/modern/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +0 -46
- package/modern/hooks/features/rows/index.d.ts +0 -1
- package/modern/hooks/features/rows/index.js +0 -1
- package/modern/hooks/features/rows/useGridRowAriaAttributes.d.ts +0 -3
- package/modern/hooks/features/rows/useGridRowAriaAttributes.js +0 -37
- package/modern/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.d.ts +0 -10
- package/modern/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.js +0 -325
- package/modern/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.d.ts +0 -4
- package/modern/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +0 -148
- package/modern/hooks/features/serverSideTreeData/utils.d.ts +0 -7
- package/modern/hooks/features/serverSideTreeData/utils.js +0 -18
- package/modern/hooks/features/treeData/gridTreeDataGroupColDef.d.ts +0 -8
- package/modern/hooks/features/treeData/gridTreeDataGroupColDef.js +0 -27
- package/modern/hooks/features/treeData/gridTreeDataUtils.d.ts +0 -22
- package/modern/hooks/features/treeData/gridTreeDataUtils.js +0 -95
- package/modern/hooks/features/treeData/index.d.ts +0 -1
- package/modern/hooks/features/treeData/index.js +0 -1
- package/modern/hooks/features/treeData/useGridTreeData.d.ts +0 -4
- package/modern/hooks/features/treeData/useGridTreeData.js +0 -22
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +0 -4
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +0 -148
- package/modern/hooks/index.d.ts +0 -1
- package/modern/hooks/index.js +0 -1
- package/modern/hooks/utils/useGridApiContext.d.ts +0 -4
- package/modern/hooks/utils/useGridApiContext.js +0 -2
- package/modern/hooks/utils/useGridApiRef.d.ts +0 -4
- package/modern/hooks/utils/useGridApiRef.js +0 -2
- package/modern/hooks/utils/useGridAriaAttributes.d.ts +0 -2
- package/modern/hooks/utils/useGridAriaAttributes.js +0 -11
- package/modern/hooks/utils/useGridPrivateApiContext.d.ts +0 -2
- package/modern/hooks/utils/useGridPrivateApiContext.js +0 -2
- package/modern/hooks/utils/useGridRootProps.d.ts +0 -2
- package/modern/hooks/utils/useGridRootProps.js +0 -2
- package/modern/index.d.ts +0 -22
- package/modern/index.js +0 -25
- package/modern/internals/index.d.ts +0 -33
- package/modern/internals/index.js +0 -38
- package/modern/internals/propValidation.d.ts +0 -3
- package/modern/internals/propValidation.js +0 -2
- package/modern/locales.d.ts +0 -1
- package/modern/locales.js +0 -1
- package/modern/material/icons.d.ts +0 -6
- package/modern/material/icons.js +0 -17
- package/modern/material/index.d.ts +0 -5
- package/modern/material/index.js +0 -8
- package/modern/models/dataGridProProps.d.ts +0 -222
- package/modern/models/dataGridProProps.js +0 -1
- package/modern/models/gridApiPro.d.ts +0 -11
- package/modern/models/gridApiPro.js +0 -1
- package/modern/models/gridFetchRowsParams.d.ts +0 -22
- package/modern/models/gridFetchRowsParams.js +0 -1
- package/modern/models/gridGroupingColDefOverride.d.ts +0 -30
- package/modern/models/gridGroupingColDefOverride.js +0 -1
- package/modern/models/gridProIconSlotsComponent.d.ts +0 -13
- package/modern/models/gridProIconSlotsComponent.js +0 -1
- package/modern/models/gridProSlotProps.d.ts +0 -8
- package/modern/models/gridProSlotProps.js +0 -1
- package/modern/models/gridProSlotsComponent.d.ts +0 -18
- package/modern/models/gridProSlotsComponent.js +0 -1
- package/modern/models/gridRowOrderChangeParams.d.ts +0 -18
- package/modern/models/gridRowOrderChangeParams.js +0 -1
- package/modern/models/gridRowScrollEndParams.d.ts +0 -18
- package/modern/models/gridRowScrollEndParams.js +0 -1
- package/modern/models/gridStatePro.d.ts +0 -19
- package/modern/models/gridStatePro.js +0 -1
- package/modern/models/index.d.ts +0 -7
- package/modern/models/index.js +0 -7
- package/modern/package.json +0 -1
- package/modern/themeAugmentation/index.d.ts +0 -2
- package/modern/themeAugmentation/index.js +0 -4
- package/modern/themeAugmentation/overrides.d.ts +0 -7
- package/modern/themeAugmentation/overrides.js +0 -1
- package/modern/themeAugmentation/props.d.ts +0 -15
- package/modern/themeAugmentation/props.js +0 -1
- package/modern/typeOverloads/index.d.ts +0 -1
- package/modern/typeOverloads/index.js +0 -1
- package/modern/typeOverloads/modules.d.ts +0 -70
- package/modern/typeOverloads/modules.js +0 -1
- package/modern/typeOverloads/reexports.d.ts +0 -17
- package/modern/typeOverloads/reexports.js +0 -15
- package/modern/utils/index.d.ts +0 -1
- package/modern/utils/index.js +0 -1
- package/modern/utils/releaseInfo.d.ts +0 -1
- package/modern/utils/releaseInfo.js +0 -13
- package/modern/utils/tree/createRowTree.d.ts +0 -17
- package/modern/utils/tree/createRowTree.js +0 -37
- package/modern/utils/tree/index.d.ts +0 -1
- package/modern/utils/tree/index.js +0 -1
- package/modern/utils/tree/insertDataRowInTree.d.ts +0 -69
- package/modern/utils/tree/insertDataRowInTree.js +0 -141
- package/modern/utils/tree/models.d.ts +0 -14
- package/modern/utils/tree/models.js +0 -1
- package/modern/utils/tree/removeDataRowFromTree.d.ts +0 -45
- package/modern/utils/tree/removeDataRowFromTree.js +0 -94
- package/modern/utils/tree/sortRowTree.d.ts +0 -15
- package/modern/utils/tree/sortRowTree.js +0 -114
- package/modern/utils/tree/updateRowTree.d.ts +0 -20
- package/modern/utils/tree/updateRowTree.js +0 -88
- package/modern/utils/tree/utils.d.ts +0 -54
- package/modern/utils/tree/utils.js +0 -197
- package/tsconfig.build.tsbuildinfo +0 -1
- package/utils/releaseInfo.d.ts +0 -1
- package/utils/releaseInfo.js +0 -20
- /package/esm/{locales.d.ts → locales/index.d.ts} +0 -0
- /package/esm/{locales.js → locales/index.js} +0 -0
- /package/{locales.d.ts → locales/index.d.ts} +0 -0
- /package/{locales.js → locales/index.js} +0 -0
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
3
|
-
import { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
|
|
4
|
-
/**
|
|
5
|
-
* Only available in DataGridPro
|
|
6
|
-
* @requires useGridRows (method)
|
|
7
|
-
*/
|
|
8
|
-
export declare const useGridRowReorder: (apiRef: RefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, "rowReordering" | "onRowOrderChange" | "classes">) => void;
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import composeClasses from '@mui/utils/composeClasses';
|
|
3
|
-
import { useGridLogger, useGridEvent, getDataGridUtilityClass, useGridSelector, gridSortModelSelector, gridRowMaximumTreeDepthSelector, useGridEventPriority, gridRowNodeSelector } from '@mui/x-data-grid';
|
|
4
|
-
import { gridEditRowsStateSelector, gridSortedRowIndexLookupSelector } from '@mui/x-data-grid/internals';
|
|
5
|
-
import { GRID_REORDER_COL_DEF } from "./gridRowReorderColDef.js";
|
|
6
|
-
var Direction = /*#__PURE__*/function (Direction) {
|
|
7
|
-
Direction[Direction["UP"] = 0] = "UP";
|
|
8
|
-
Direction[Direction["DOWN"] = 1] = "DOWN";
|
|
9
|
-
return Direction;
|
|
10
|
-
}(Direction || {});
|
|
11
|
-
let previousMousePosition = null;
|
|
12
|
-
let previousReorderState = {
|
|
13
|
-
previousTargetId: null,
|
|
14
|
-
dragDirection: null
|
|
15
|
-
};
|
|
16
|
-
const useUtilityClasses = ownerState => {
|
|
17
|
-
const {
|
|
18
|
-
classes
|
|
19
|
-
} = ownerState;
|
|
20
|
-
const slots = {
|
|
21
|
-
rowDragging: ['row--dragging']
|
|
22
|
-
};
|
|
23
|
-
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Only available in DataGridPro
|
|
28
|
-
* @requires useGridRows (method)
|
|
29
|
-
*/
|
|
30
|
-
export const useGridRowReorder = (apiRef, props) => {
|
|
31
|
-
const logger = useGridLogger(apiRef, 'useGridRowReorder');
|
|
32
|
-
const sortModel = useGridSelector(apiRef, gridSortModelSelector);
|
|
33
|
-
const treeDepth = useGridSelector(apiRef, gridRowMaximumTreeDepthSelector);
|
|
34
|
-
const dragRowNode = React.useRef(null);
|
|
35
|
-
const originRowIndex = React.useRef(null);
|
|
36
|
-
const removeDnDStylesTimeout = React.useRef(undefined);
|
|
37
|
-
const ownerState = {
|
|
38
|
-
classes: props.classes
|
|
39
|
-
};
|
|
40
|
-
const classes = useUtilityClasses(ownerState);
|
|
41
|
-
const [dragRowId, setDragRowId] = React.useState('');
|
|
42
|
-
const sortedRowIndexLookup = useGridSelector(apiRef, gridSortedRowIndexLookupSelector);
|
|
43
|
-
React.useEffect(() => {
|
|
44
|
-
return () => {
|
|
45
|
-
clearTimeout(removeDnDStylesTimeout.current);
|
|
46
|
-
};
|
|
47
|
-
}, []);
|
|
48
|
-
|
|
49
|
-
// TODO: remove sortModel check once row reorder is sorting compatible
|
|
50
|
-
// remove treeDepth once row reorder is tree compatible
|
|
51
|
-
const isRowReorderDisabled = React.useMemo(() => {
|
|
52
|
-
return !props.rowReordering || !!sortModel.length || treeDepth !== 1;
|
|
53
|
-
}, [props.rowReordering, sortModel, treeDepth]);
|
|
54
|
-
const handleDragStart = React.useCallback((params, event) => {
|
|
55
|
-
// Call the gridEditRowsStateSelector directly to avoid infnite loop
|
|
56
|
-
const editRowsState = gridEditRowsStateSelector(apiRef);
|
|
57
|
-
if (isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
logger.debug(`Start dragging row ${params.id}`);
|
|
61
|
-
// Prevent drag events propagation.
|
|
62
|
-
// For more information check here https://github.com/mui/mui-x/issues/2680.
|
|
63
|
-
event.stopPropagation();
|
|
64
|
-
dragRowNode.current = event.currentTarget;
|
|
65
|
-
dragRowNode.current.classList.add(classes.rowDragging);
|
|
66
|
-
setDragRowId(params.id);
|
|
67
|
-
removeDnDStylesTimeout.current = setTimeout(() => {
|
|
68
|
-
dragRowNode.current.classList.remove(classes.rowDragging);
|
|
69
|
-
});
|
|
70
|
-
originRowIndex.current = sortedRowIndexLookup[params.id];
|
|
71
|
-
apiRef.current.setCellFocus(params.id, GRID_REORDER_COL_DEF.field);
|
|
72
|
-
}, [apiRef, isRowReorderDisabled, logger, classes.rowDragging, sortedRowIndexLookup]);
|
|
73
|
-
const handleDragOver = React.useCallback((params, event) => {
|
|
74
|
-
if (dragRowId === '') {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const rowNode = gridRowNodeSelector(apiRef, params.id);
|
|
78
|
-
if (!rowNode || rowNode.type === 'footer' || rowNode.type === 'pinnedRow') {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
logger.debug(`Dragging over row ${params.id}`);
|
|
82
|
-
event.preventDefault();
|
|
83
|
-
// Prevent drag events propagation.
|
|
84
|
-
// For more information check here https://github.com/mui/mui-x/issues/2680.
|
|
85
|
-
event.stopPropagation();
|
|
86
|
-
const mouseMovementDiff = previousMousePosition ? previousMousePosition.y - event.clientY : event.clientY;
|
|
87
|
-
if (params.id !== dragRowId) {
|
|
88
|
-
const targetRowIndex = sortedRowIndexLookup[params.id];
|
|
89
|
-
const dragDirection = mouseMovementDiff > 0 ? Direction.DOWN : Direction.UP;
|
|
90
|
-
const currentReorderState = {
|
|
91
|
-
dragDirection,
|
|
92
|
-
previousTargetId: params.id
|
|
93
|
-
};
|
|
94
|
-
const isStateChanged = currentReorderState.dragDirection !== previousReorderState.dragDirection || currentReorderState.previousTargetId !== previousReorderState.previousTargetId;
|
|
95
|
-
if (previousReorderState.dragDirection === null || Math.abs(mouseMovementDiff) >= 1 && isStateChanged) {
|
|
96
|
-
apiRef.current.setRowIndex(dragRowId, targetRowIndex);
|
|
97
|
-
previousReorderState = currentReorderState;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
previousMousePosition = {
|
|
101
|
-
x: event.clientX,
|
|
102
|
-
y: event.clientY
|
|
103
|
-
};
|
|
104
|
-
}, [dragRowId, apiRef, logger, sortedRowIndexLookup]);
|
|
105
|
-
const handleDragEnd = React.useCallback((params, event) => {
|
|
106
|
-
// Call the gridEditRowsStateSelector directly to avoid infnite loop
|
|
107
|
-
const editRowsState = gridEditRowsStateSelector(apiRef);
|
|
108
|
-
if (dragRowId === '' || isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
logger.debug('End dragging row');
|
|
112
|
-
event.preventDefault();
|
|
113
|
-
// Prevent drag events propagation.
|
|
114
|
-
// For more information check here https://github.com/mui/mui-x/issues/2680.
|
|
115
|
-
event.stopPropagation();
|
|
116
|
-
clearTimeout(removeDnDStylesTimeout.current);
|
|
117
|
-
dragRowNode.current = null;
|
|
118
|
-
previousReorderState.dragDirection = null;
|
|
119
|
-
|
|
120
|
-
// Check if the row was dropped outside the grid.
|
|
121
|
-
if (event.dataTransfer.dropEffect === 'none') {
|
|
122
|
-
// Accessing params.field may contain the wrong field as header elements are reused
|
|
123
|
-
apiRef.current.setRowIndex(dragRowId, originRowIndex.current);
|
|
124
|
-
originRowIndex.current = null;
|
|
125
|
-
} else {
|
|
126
|
-
// Emit the rowOrderChange event only once when the reordering stops.
|
|
127
|
-
const rowOrderChangeParams = {
|
|
128
|
-
row: apiRef.current.getRow(dragRowId),
|
|
129
|
-
targetIndex: sortedRowIndexLookup[params.id],
|
|
130
|
-
oldIndex: originRowIndex.current
|
|
131
|
-
};
|
|
132
|
-
apiRef.current.publishEvent('rowOrderChange', rowOrderChangeParams);
|
|
133
|
-
}
|
|
134
|
-
setDragRowId('');
|
|
135
|
-
}, [apiRef, dragRowId, isRowReorderDisabled, logger, sortedRowIndexLookup]);
|
|
136
|
-
useGridEvent(apiRef, 'rowDragStart', handleDragStart);
|
|
137
|
-
useGridEvent(apiRef, 'rowDragOver', handleDragOver);
|
|
138
|
-
useGridEvent(apiRef, 'rowDragEnd', handleDragEnd);
|
|
139
|
-
useGridEvent(apiRef, 'cellDragOver', handleDragOver);
|
|
140
|
-
useGridEventPriority(apiRef, 'rowOrderChange', props.onRowOrderChange);
|
|
141
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
|
|
3
|
-
import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
4
|
-
export declare const useGridRowReorderPreProcessors: (privateApiRef: RefObject<GridPrivateApiPro>, props: DataGridProProcessedProps) => void;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import composeClasses from '@mui/utils/composeClasses';
|
|
4
|
-
import { getDataGridUtilityClass } from '@mui/x-data-grid';
|
|
5
|
-
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
6
|
-
import { GRID_REORDER_COL_DEF } from "./gridRowReorderColDef.js";
|
|
7
|
-
const useUtilityClasses = ownerState => {
|
|
8
|
-
const {
|
|
9
|
-
classes
|
|
10
|
-
} = ownerState;
|
|
11
|
-
return React.useMemo(() => {
|
|
12
|
-
const slots = {
|
|
13
|
-
rowReorderCellContainer: ['rowReorderCellContainer'],
|
|
14
|
-
columnHeaderReorder: ['columnHeaderReorder']
|
|
15
|
-
};
|
|
16
|
-
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
17
|
-
}, [classes]);
|
|
18
|
-
};
|
|
19
|
-
export const useGridRowReorderPreProcessors = (privateApiRef, props) => {
|
|
20
|
-
const ownerState = {
|
|
21
|
-
classes: props.classes
|
|
22
|
-
};
|
|
23
|
-
const classes = useUtilityClasses(ownerState);
|
|
24
|
-
const updateReorderColumn = React.useCallback(columnsState => {
|
|
25
|
-
const reorderColumn = _extends({}, GRID_REORDER_COL_DEF, {
|
|
26
|
-
cellClassName: classes.rowReorderCellContainer,
|
|
27
|
-
headerClassName: classes.columnHeaderReorder,
|
|
28
|
-
headerName: privateApiRef.current.getLocaleText('rowReorderingHeaderName')
|
|
29
|
-
});
|
|
30
|
-
const shouldHaveReorderColumn = props.rowReordering;
|
|
31
|
-
const haveReorderColumn = columnsState.lookup[reorderColumn.field] != null;
|
|
32
|
-
if (shouldHaveReorderColumn && haveReorderColumn) {
|
|
33
|
-
columnsState.lookup[reorderColumn.field] = _extends({}, reorderColumn, columnsState.lookup[reorderColumn.field]);
|
|
34
|
-
return columnsState;
|
|
35
|
-
}
|
|
36
|
-
if (shouldHaveReorderColumn && !haveReorderColumn) {
|
|
37
|
-
columnsState.lookup[reorderColumn.field] = reorderColumn;
|
|
38
|
-
columnsState.orderedFields = [reorderColumn.field, ...columnsState.orderedFields];
|
|
39
|
-
} else if (!shouldHaveReorderColumn && haveReorderColumn) {
|
|
40
|
-
delete columnsState.lookup[reorderColumn.field];
|
|
41
|
-
columnsState.orderedFields = columnsState.orderedFields.filter(field => field !== reorderColumn.field);
|
|
42
|
-
}
|
|
43
|
-
return columnsState;
|
|
44
|
-
}, [privateApiRef, classes, props.rowReordering]);
|
|
45
|
-
useGridRegisterPipeProcessor(privateApiRef, 'hydrateColumns', updateReorderColumn);
|
|
46
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useGridRowAriaAttributes.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useGridRowAriaAttributes.js";
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useGridSelector, gridFilteredTopLevelRowCountSelector, GRID_ROOT_GROUP_ID } from '@mui/x-data-grid';
|
|
3
|
-
import { useGridRowAriaAttributes as useGridRowAriaAttributesCommunity, gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector } from '@mui/x-data-grid/internals';
|
|
4
|
-
import { useGridPrivateApiContext } from "../../utils/useGridPrivateApiContext.js";
|
|
5
|
-
import { useGridRootProps } from "../../utils/useGridRootProps.js";
|
|
6
|
-
export const useGridRowAriaAttributes = addTreeDataAttributes => {
|
|
7
|
-
const apiRef = useGridPrivateApiContext();
|
|
8
|
-
const props = useGridRootProps();
|
|
9
|
-
const getRowAriaAttributesCommunity = useGridRowAriaAttributesCommunity();
|
|
10
|
-
const filteredTopLevelRowCount = useGridSelector(apiRef, gridFilteredTopLevelRowCountSelector);
|
|
11
|
-
const filteredChildrenCountLookup = useGridSelector(apiRef, gridFilteredChildrenCountLookupSelector);
|
|
12
|
-
const sortedVisibleRowPositionsLookup = useGridSelector(apiRef, gridExpandedSortedRowTreeLevelPositionLookupSelector);
|
|
13
|
-
return React.useCallback((rowNode, index) => {
|
|
14
|
-
const ariaAttributes = getRowAriaAttributesCommunity(rowNode, index);
|
|
15
|
-
if (rowNode === null || !(props.treeData || addTreeDataAttributes)) {
|
|
16
|
-
return ariaAttributes;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// pinned and footer rows are not part of the rowgroup and should not get the set specific aria attributes
|
|
20
|
-
if (rowNode.type === 'footer' || rowNode.type === 'pinnedRow') {
|
|
21
|
-
return ariaAttributes;
|
|
22
|
-
}
|
|
23
|
-
ariaAttributes['aria-level'] = rowNode.depth + 1;
|
|
24
|
-
const filteredChildrenCount = filteredChildrenCountLookup[rowNode.id] ?? 0;
|
|
25
|
-
// aria-expanded should only be added to the rows that contain children
|
|
26
|
-
if (rowNode.type === 'group' && filteredChildrenCount > 0) {
|
|
27
|
-
ariaAttributes['aria-expanded'] = Boolean(rowNode.childrenExpanded);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// if the parent is null, set size and position cannot be determined
|
|
31
|
-
if (rowNode.parent !== null) {
|
|
32
|
-
ariaAttributes['aria-setsize'] = rowNode.parent === GRID_ROOT_GROUP_ID ? filteredTopLevelRowCount : filteredChildrenCountLookup[rowNode.parent];
|
|
33
|
-
ariaAttributes['aria-posinset'] = sortedVisibleRowPositionsLookup[rowNode.id];
|
|
34
|
-
}
|
|
35
|
-
return ariaAttributes;
|
|
36
|
-
}, [props.treeData, addTreeDataAttributes, filteredTopLevelRowCount, filteredChildrenCountLookup, sortedVisibleRowPositionsLookup, getRowAriaAttributesCommunity]);
|
|
37
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
3
|
-
import { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
|
|
4
|
-
/**
|
|
5
|
-
* @requires useGridRows (state)
|
|
6
|
-
* @requires useGridPagination (state)
|
|
7
|
-
* @requires useGridDimensions (method) - can be after
|
|
8
|
-
* @requires useGridScroll (method
|
|
9
|
-
*/
|
|
10
|
-
export declare const useGridDataSourceLazyLoader: (privateApiRef: RefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, "pagination" | "paginationMode" | "dataSource" | "lazyLoading" | "lazyLoadingRequestThrottleMs" | "scrollEndThreshold">) => void;
|
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { throttle } from '@mui/x-internals/throttle';
|
|
4
|
-
import { unstable_debounce as debounce } from '@mui/utils';
|
|
5
|
-
import { useGridEvent, gridSortModelSelector, gridFilterModelSelector, GRID_ROOT_GROUP_ID, gridPaginationModelSelector, gridDimensionsSelector, gridFilteredSortedRowIdsSelector } from '@mui/x-data-grid';
|
|
6
|
-
import { getVisibleRows, gridRenderContextSelector, GridStrategyGroup, useGridRegisterStrategyProcessor, runIf, DataSourceRowsUpdateStrategy } from '@mui/x-data-grid/internals';
|
|
7
|
-
import { findSkeletonRowsSection } from "../lazyLoader/utils.js";
|
|
8
|
-
import { GRID_SKELETON_ROW_ROOT_ID } from "../lazyLoader/useGridLazyLoaderPreProcessors.js";
|
|
9
|
-
var LoadingTrigger = /*#__PURE__*/function (LoadingTrigger) {
|
|
10
|
-
LoadingTrigger[LoadingTrigger["VIEWPORT"] = 0] = "VIEWPORT";
|
|
11
|
-
LoadingTrigger[LoadingTrigger["SCROLL_END"] = 1] = "SCROLL_END";
|
|
12
|
-
return LoadingTrigger;
|
|
13
|
-
}(LoadingTrigger || {});
|
|
14
|
-
const INTERVAL_CACHE_INITIAL_STATE = {
|
|
15
|
-
firstRowToRender: 0,
|
|
16
|
-
lastRowToRender: 0
|
|
17
|
-
};
|
|
18
|
-
const getSkeletonRowId = index => `${GRID_SKELETON_ROW_ROOT_ID}-${index}`;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @requires useGridRows (state)
|
|
22
|
-
* @requires useGridPagination (state)
|
|
23
|
-
* @requires useGridDimensions (method) - can be after
|
|
24
|
-
* @requires useGridScroll (method
|
|
25
|
-
*/
|
|
26
|
-
export const useGridDataSourceLazyLoader = (privateApiRef, props) => {
|
|
27
|
-
const setStrategyAvailability = React.useCallback(() => {
|
|
28
|
-
privateApiRef.current.setStrategyAvailability(GridStrategyGroup.DataSource, DataSourceRowsUpdateStrategy.LazyLoading, props.dataSource && props.lazyLoading ? () => true : () => false);
|
|
29
|
-
}, [privateApiRef, props.lazyLoading, props.dataSource]);
|
|
30
|
-
const [lazyLoadingRowsUpdateStrategyActive, setLazyLoadingRowsUpdateStrategyActive] = React.useState(false);
|
|
31
|
-
const renderedRowsIntervalCache = React.useRef(INTERVAL_CACHE_INITIAL_STATE);
|
|
32
|
-
const previousLastRowIndex = React.useRef(0);
|
|
33
|
-
const loadingTrigger = React.useRef(null);
|
|
34
|
-
const rowsStale = React.useRef(false);
|
|
35
|
-
const fetchRows = React.useCallback(params => {
|
|
36
|
-
privateApiRef.current.dataSource.fetchRows(GRID_ROOT_GROUP_ID, params);
|
|
37
|
-
}, [privateApiRef]);
|
|
38
|
-
const debouncedFetchRows = React.useMemo(() => debounce(fetchRows, 0), [fetchRows]);
|
|
39
|
-
|
|
40
|
-
// Adjust the render context range to fit the pagination model's page size
|
|
41
|
-
// First row index should be decreased to the start of the page, end row index should be increased to the end of the page
|
|
42
|
-
const adjustRowParams = React.useCallback(params => {
|
|
43
|
-
if (typeof params.start !== 'number') {
|
|
44
|
-
return params;
|
|
45
|
-
}
|
|
46
|
-
const paginationModel = gridPaginationModelSelector(privateApiRef);
|
|
47
|
-
return _extends({}, params, {
|
|
48
|
-
start: params.start - params.start % paginationModel.pageSize,
|
|
49
|
-
end: params.end + paginationModel.pageSize - params.end % paginationModel.pageSize - 1
|
|
50
|
-
});
|
|
51
|
-
}, [privateApiRef]);
|
|
52
|
-
const resetGrid = React.useCallback(() => {
|
|
53
|
-
privateApiRef.current.setLoading(true);
|
|
54
|
-
privateApiRef.current.dataSource.cache.clear();
|
|
55
|
-
rowsStale.current = true;
|
|
56
|
-
previousLastRowIndex.current = 0;
|
|
57
|
-
const paginationModel = gridPaginationModelSelector(privateApiRef);
|
|
58
|
-
const sortModel = gridSortModelSelector(privateApiRef);
|
|
59
|
-
const filterModel = gridFilterModelSelector(privateApiRef);
|
|
60
|
-
const getRowsParams = {
|
|
61
|
-
start: 0,
|
|
62
|
-
end: paginationModel.pageSize - 1,
|
|
63
|
-
sortModel,
|
|
64
|
-
filterModel
|
|
65
|
-
};
|
|
66
|
-
fetchRows(getRowsParams);
|
|
67
|
-
}, [privateApiRef, fetchRows]);
|
|
68
|
-
const ensureValidRowCount = React.useCallback((previousLoadingTrigger, newLoadingTrigger) => {
|
|
69
|
-
// switching from lazy loading to infinite loading should always reset the grid
|
|
70
|
-
// since there is no guarantee that the new data will be placed correctly
|
|
71
|
-
// there might be some skeleton rows in between the data or the data has changed (row count became unknown)
|
|
72
|
-
if (previousLoadingTrigger === LoadingTrigger.VIEWPORT && newLoadingTrigger === LoadingTrigger.SCROLL_END) {
|
|
73
|
-
resetGrid();
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// switching from infinite loading to lazy loading should reset the grid only if the known row count
|
|
78
|
-
// is smaller than the amount of rows rendered
|
|
79
|
-
const tree = privateApiRef.current.state.rows.tree;
|
|
80
|
-
const rootGroup = tree[GRID_ROOT_GROUP_ID];
|
|
81
|
-
const rootGroupChildren = [...rootGroup.children];
|
|
82
|
-
const pageRowCount = privateApiRef.current.state.pagination.rowCount;
|
|
83
|
-
const rootChildrenCount = rootGroupChildren.length;
|
|
84
|
-
if (rootChildrenCount > pageRowCount) {
|
|
85
|
-
resetGrid();
|
|
86
|
-
}
|
|
87
|
-
}, [privateApiRef, resetGrid]);
|
|
88
|
-
const addSkeletonRows = React.useCallback(() => {
|
|
89
|
-
const tree = privateApiRef.current.state.rows.tree;
|
|
90
|
-
const dataRowIdToModelLookup = privateApiRef.current.state.rows.dataRowIdToModelLookup;
|
|
91
|
-
const rootGroup = tree[GRID_ROOT_GROUP_ID];
|
|
92
|
-
const rootGroupChildren = [...rootGroup.children];
|
|
93
|
-
const pageRowCount = privateApiRef.current.state.pagination.rowCount;
|
|
94
|
-
const rootChildrenCount = rootGroupChildren.length;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Do nothing if
|
|
98
|
-
* - children count is 0
|
|
99
|
-
*/
|
|
100
|
-
if (rootChildrenCount === 0) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const pageToSkip = adjustRowParams({
|
|
104
|
-
start: renderedRowsIntervalCache.current.firstRowToRender,
|
|
105
|
-
end: renderedRowsIntervalCache.current.lastRowToRender
|
|
106
|
-
});
|
|
107
|
-
let hasChanged = false;
|
|
108
|
-
const isInitialPage = renderedRowsIntervalCache.current.firstRowToRender === 0 && renderedRowsIntervalCache.current.lastRowToRender === 0;
|
|
109
|
-
for (let i = 0; i < rootChildrenCount; i += 1) {
|
|
110
|
-
if (isInitialPage) {
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
// replace the rows not in the viewport with skeleton rows
|
|
114
|
-
if (pageToSkip.start <= i && i <= pageToSkip.end || tree[rootGroupChildren[i]]?.type === 'skeletonRow') {
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
const skeletonId = getSkeletonRowId(i); // to avoid duplicate keys on rebuild
|
|
118
|
-
const removedRow = rootGroupChildren[i];
|
|
119
|
-
rootGroupChildren[i] = skeletonId;
|
|
120
|
-
const skeletonRowNode = {
|
|
121
|
-
type: 'skeletonRow',
|
|
122
|
-
id: skeletonId,
|
|
123
|
-
parent: GRID_ROOT_GROUP_ID,
|
|
124
|
-
depth: 0
|
|
125
|
-
};
|
|
126
|
-
tree[skeletonId] = skeletonRowNode;
|
|
127
|
-
delete tree[removedRow];
|
|
128
|
-
delete dataRowIdToModelLookup[removedRow];
|
|
129
|
-
hasChanged = true;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Should only happen with VIEWPORT loading trigger
|
|
133
|
-
if (loadingTrigger.current === LoadingTrigger.VIEWPORT) {
|
|
134
|
-
// fill the grid with skeleton rows
|
|
135
|
-
for (let i = 0; i < pageRowCount - rootChildrenCount; i += 1) {
|
|
136
|
-
const skeletonId = getSkeletonRowId(i + rootChildrenCount); // to avoid duplicate keys on rebuild
|
|
137
|
-
rootGroupChildren.push(skeletonId);
|
|
138
|
-
const skeletonRowNode = {
|
|
139
|
-
type: 'skeletonRow',
|
|
140
|
-
id: skeletonId,
|
|
141
|
-
parent: GRID_ROOT_GROUP_ID,
|
|
142
|
-
depth: 0
|
|
143
|
-
};
|
|
144
|
-
tree[skeletonId] = skeletonRowNode;
|
|
145
|
-
hasChanged = true;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (!hasChanged) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
tree[GRID_ROOT_GROUP_ID] = _extends({}, rootGroup, {
|
|
152
|
-
children: rootGroupChildren
|
|
153
|
-
});
|
|
154
|
-
privateApiRef.current.setState(state => _extends({}, state, {
|
|
155
|
-
rows: _extends({}, state.rows, {
|
|
156
|
-
tree,
|
|
157
|
-
dataRowIdToModelLookup
|
|
158
|
-
})
|
|
159
|
-
}), 'addSkeletonRows');
|
|
160
|
-
}, [privateApiRef, adjustRowParams]);
|
|
161
|
-
const updateLoadingTrigger = React.useCallback(rowCount => {
|
|
162
|
-
const newLoadingTrigger = rowCount === -1 ? LoadingTrigger.SCROLL_END : LoadingTrigger.VIEWPORT;
|
|
163
|
-
if (loadingTrigger.current !== null) {
|
|
164
|
-
ensureValidRowCount(loadingTrigger.current, newLoadingTrigger);
|
|
165
|
-
}
|
|
166
|
-
if (loadingTrigger.current !== newLoadingTrigger) {
|
|
167
|
-
loadingTrigger.current = newLoadingTrigger;
|
|
168
|
-
}
|
|
169
|
-
}, [ensureValidRowCount]);
|
|
170
|
-
const handleDataUpdate = React.useCallback(params => {
|
|
171
|
-
if ('error' in params) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const {
|
|
175
|
-
response,
|
|
176
|
-
fetchParams
|
|
177
|
-
} = params;
|
|
178
|
-
const pageRowCount = privateApiRef.current.state.pagination.rowCount;
|
|
179
|
-
if (response.rowCount !== undefined || pageRowCount === undefined) {
|
|
180
|
-
privateApiRef.current.setRowCount(response.rowCount === undefined ? -1 : response.rowCount);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// scroll to the top if the rows are stale and the new request is for the first page
|
|
184
|
-
if (rowsStale.current && params.fetchParams.start === 0) {
|
|
185
|
-
privateApiRef.current.scroll({
|
|
186
|
-
top: 0
|
|
187
|
-
});
|
|
188
|
-
// the rows can safely be replaced. skeleton rows will be added later
|
|
189
|
-
privateApiRef.current.setRows(response.rows);
|
|
190
|
-
} else {
|
|
191
|
-
const filteredSortedRowIds = gridFilteredSortedRowIdsSelector(privateApiRef);
|
|
192
|
-
const startingIndex = typeof fetchParams.start === 'string' ? Math.max(filteredSortedRowIds.indexOf(fetchParams.start), 0) : fetchParams.start;
|
|
193
|
-
privateApiRef.current.unstable_replaceRows(startingIndex, response.rows);
|
|
194
|
-
}
|
|
195
|
-
rowsStale.current = false;
|
|
196
|
-
if (loadingTrigger.current === null) {
|
|
197
|
-
updateLoadingTrigger(privateApiRef.current.state.pagination.rowCount);
|
|
198
|
-
}
|
|
199
|
-
addSkeletonRows();
|
|
200
|
-
privateApiRef.current.setLoading(false);
|
|
201
|
-
privateApiRef.current.unstable_applyPipeProcessors('processDataSourceRows', {
|
|
202
|
-
params: params.fetchParams,
|
|
203
|
-
response
|
|
204
|
-
}, false);
|
|
205
|
-
privateApiRef.current.requestPipeProcessorsApplication('hydrateRows');
|
|
206
|
-
}, [privateApiRef, updateLoadingTrigger, addSkeletonRows]);
|
|
207
|
-
const handleRowCountChange = React.useCallback(() => {
|
|
208
|
-
if (rowsStale.current || loadingTrigger.current === null) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
updateLoadingTrigger(privateApiRef.current.state.pagination.rowCount);
|
|
212
|
-
addSkeletonRows();
|
|
213
|
-
privateApiRef.current.requestPipeProcessorsApplication('hydrateRows');
|
|
214
|
-
}, [privateApiRef, updateLoadingTrigger, addSkeletonRows]);
|
|
215
|
-
const handleScrolling = React.useCallback(newScrollPosition => {
|
|
216
|
-
if (rowsStale.current || loadingTrigger.current !== LoadingTrigger.SCROLL_END) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
const renderContext = gridRenderContextSelector(privateApiRef);
|
|
220
|
-
if (previousLastRowIndex.current >= renderContext.lastRowIndex) {
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const dimensions = gridDimensionsSelector(privateApiRef);
|
|
224
|
-
const position = newScrollPosition.top + dimensions.viewportInnerSize.height;
|
|
225
|
-
const target = dimensions.contentSize.height - props.scrollEndThreshold;
|
|
226
|
-
if (position >= target) {
|
|
227
|
-
previousLastRowIndex.current = renderContext.lastRowIndex;
|
|
228
|
-
const paginationModel = gridPaginationModelSelector(privateApiRef);
|
|
229
|
-
const sortModel = gridSortModelSelector(privateApiRef);
|
|
230
|
-
const filterModel = gridFilterModelSelector(privateApiRef);
|
|
231
|
-
const getRowsParams = {
|
|
232
|
-
start: renderContext.lastRowIndex,
|
|
233
|
-
end: renderContext.lastRowIndex + paginationModel.pageSize - 1,
|
|
234
|
-
sortModel,
|
|
235
|
-
filterModel
|
|
236
|
-
};
|
|
237
|
-
privateApiRef.current.setLoading(true);
|
|
238
|
-
fetchRows(adjustRowParams(getRowsParams));
|
|
239
|
-
}
|
|
240
|
-
}, [privateApiRef, props.scrollEndThreshold, adjustRowParams, fetchRows]);
|
|
241
|
-
const handleRenderedRowsIntervalChange = React.useCallback(params => {
|
|
242
|
-
if (rowsStale.current) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
const sortModel = gridSortModelSelector(privateApiRef);
|
|
246
|
-
const filterModel = gridFilterModelSelector(privateApiRef);
|
|
247
|
-
const getRowsParams = {
|
|
248
|
-
start: params.firstRowIndex,
|
|
249
|
-
end: params.lastRowIndex,
|
|
250
|
-
sortModel,
|
|
251
|
-
filterModel
|
|
252
|
-
};
|
|
253
|
-
if (renderedRowsIntervalCache.current.firstRowToRender === params.firstRowIndex && renderedRowsIntervalCache.current.lastRowToRender === params.lastRowIndex) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
renderedRowsIntervalCache.current = {
|
|
257
|
-
firstRowToRender: params.firstRowIndex,
|
|
258
|
-
lastRowToRender: params.lastRowIndex
|
|
259
|
-
};
|
|
260
|
-
const currentVisibleRows = getVisibleRows(privateApiRef);
|
|
261
|
-
const skeletonRowsSection = findSkeletonRowsSection({
|
|
262
|
-
apiRef: privateApiRef,
|
|
263
|
-
visibleRows: currentVisibleRows.rows,
|
|
264
|
-
range: {
|
|
265
|
-
firstRowIndex: params.firstRowIndex,
|
|
266
|
-
lastRowIndex: params.lastRowIndex
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
if (!skeletonRowsSection) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
getRowsParams.start = skeletonRowsSection.firstRowIndex;
|
|
273
|
-
getRowsParams.end = skeletonRowsSection.lastRowIndex;
|
|
274
|
-
fetchRows(adjustRowParams(getRowsParams));
|
|
275
|
-
}, [privateApiRef, adjustRowParams, fetchRows]);
|
|
276
|
-
const throttledHandleRenderedRowsIntervalChange = React.useMemo(() => throttle(handleRenderedRowsIntervalChange, props.lazyLoadingRequestThrottleMs), [props.lazyLoadingRequestThrottleMs, handleRenderedRowsIntervalChange]);
|
|
277
|
-
React.useEffect(() => {
|
|
278
|
-
return () => {
|
|
279
|
-
throttledHandleRenderedRowsIntervalChange.clear();
|
|
280
|
-
};
|
|
281
|
-
}, [throttledHandleRenderedRowsIntervalChange]);
|
|
282
|
-
const handleGridSortModelChange = React.useCallback(newSortModel => {
|
|
283
|
-
rowsStale.current = true;
|
|
284
|
-
throttledHandleRenderedRowsIntervalChange.clear();
|
|
285
|
-
previousLastRowIndex.current = 0;
|
|
286
|
-
const paginationModel = gridPaginationModelSelector(privateApiRef);
|
|
287
|
-
const filterModel = gridFilterModelSelector(privateApiRef);
|
|
288
|
-
const getRowsParams = {
|
|
289
|
-
start: 0,
|
|
290
|
-
end: paginationModel.pageSize - 1,
|
|
291
|
-
sortModel: newSortModel,
|
|
292
|
-
filterModel
|
|
293
|
-
};
|
|
294
|
-
privateApiRef.current.setLoading(true);
|
|
295
|
-
debouncedFetchRows(getRowsParams);
|
|
296
|
-
}, [privateApiRef, debouncedFetchRows, throttledHandleRenderedRowsIntervalChange]);
|
|
297
|
-
const handleGridFilterModelChange = React.useCallback(newFilterModel => {
|
|
298
|
-
rowsStale.current = true;
|
|
299
|
-
throttledHandleRenderedRowsIntervalChange.clear();
|
|
300
|
-
previousLastRowIndex.current = 0;
|
|
301
|
-
const paginationModel = gridPaginationModelSelector(privateApiRef);
|
|
302
|
-
const sortModel = gridSortModelSelector(privateApiRef);
|
|
303
|
-
const getRowsParams = {
|
|
304
|
-
start: 0,
|
|
305
|
-
end: paginationModel.pageSize - 1,
|
|
306
|
-
sortModel,
|
|
307
|
-
filterModel: newFilterModel
|
|
308
|
-
};
|
|
309
|
-
privateApiRef.current.setLoading(true);
|
|
310
|
-
debouncedFetchRows(getRowsParams);
|
|
311
|
-
}, [privateApiRef, debouncedFetchRows, throttledHandleRenderedRowsIntervalChange]);
|
|
312
|
-
const handleStrategyActivityChange = React.useCallback(() => {
|
|
313
|
-
setLazyLoadingRowsUpdateStrategyActive(privateApiRef.current.getActiveStrategy(GridStrategyGroup.DataSource) === DataSourceRowsUpdateStrategy.LazyLoading);
|
|
314
|
-
}, [privateApiRef]);
|
|
315
|
-
useGridRegisterStrategyProcessor(privateApiRef, DataSourceRowsUpdateStrategy.LazyLoading, 'dataSourceRowsUpdate', handleDataUpdate);
|
|
316
|
-
useGridEvent(privateApiRef, 'strategyAvailabilityChange', handleStrategyActivityChange);
|
|
317
|
-
useGridEvent(privateApiRef, 'rowCountChange', runIf(lazyLoadingRowsUpdateStrategyActive, handleRowCountChange));
|
|
318
|
-
useGridEvent(privateApiRef, 'scrollPositionChange', runIf(lazyLoadingRowsUpdateStrategyActive, handleScrolling));
|
|
319
|
-
useGridEvent(privateApiRef, 'renderedRowsIntervalChange', runIf(lazyLoadingRowsUpdateStrategyActive, throttledHandleRenderedRowsIntervalChange));
|
|
320
|
-
useGridEvent(privateApiRef, 'sortModelChange', runIf(lazyLoadingRowsUpdateStrategyActive, handleGridSortModelChange));
|
|
321
|
-
useGridEvent(privateApiRef, 'filterModelChange', runIf(lazyLoadingRowsUpdateStrategyActive, handleGridFilterModelChange));
|
|
322
|
-
React.useEffect(() => {
|
|
323
|
-
setStrategyAvailability();
|
|
324
|
-
}, [setStrategyAvailability]);
|
|
325
|
-
};
|
package/modern/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
|
|
3
|
-
import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
4
|
-
export declare const useGridDataSourceTreeDataPreProcessors: (privateApiRef: RefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, "treeData" | "groupingColDef" | "disableChildrenSorting" | "disableChildrenFiltering" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "dataSource">) => void;
|