@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,43 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { gridClasses } from '@mui/x-data-grid';
|
|
4
|
-
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
5
|
-
import { GRID_DETAIL_PANEL_TOGGLE_FIELD, GRID_DETAIL_PANEL_TOGGLE_COL_DEF } from "./gridDetailPanelToggleColDef.js";
|
|
6
|
-
import { gridDetailPanelExpandedRowIdsSelector } from "./gridDetailPanelSelector.js";
|
|
7
|
-
export const useGridDetailPanelPreProcessors = (privateApiRef, props) => {
|
|
8
|
-
const addToggleColumn = React.useCallback(columnsState => {
|
|
9
|
-
if (props.getDetailPanelContent == null) {
|
|
10
|
-
// Remove the toggle column, when it exists
|
|
11
|
-
if (columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD]) {
|
|
12
|
-
delete columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD];
|
|
13
|
-
columnsState.orderedFields = columnsState.orderedFields.filter(field => field !== GRID_DETAIL_PANEL_TOGGLE_FIELD);
|
|
14
|
-
}
|
|
15
|
-
return columnsState;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Don't add the toggle column if there's already one
|
|
19
|
-
// The user might have manually added it to have it in a custom position
|
|
20
|
-
if (columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD]) {
|
|
21
|
-
return columnsState;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Otherwise, add the toggle column at the beginning
|
|
25
|
-
columnsState.orderedFields = [GRID_DETAIL_PANEL_TOGGLE_FIELD, ...columnsState.orderedFields];
|
|
26
|
-
columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD] = _extends({}, GRID_DETAIL_PANEL_TOGGLE_COL_DEF, {
|
|
27
|
-
headerName: privateApiRef.current.getLocaleText('detailPanelToggle')
|
|
28
|
-
});
|
|
29
|
-
return columnsState;
|
|
30
|
-
}, [privateApiRef, props.getDetailPanelContent]);
|
|
31
|
-
const addExpandedClassToRow = React.useCallback((classes, id) => {
|
|
32
|
-
if (props.getDetailPanelContent == null) {
|
|
33
|
-
return classes;
|
|
34
|
-
}
|
|
35
|
-
const expandedRowIds = gridDetailPanelExpandedRowIdsSelector(privateApiRef);
|
|
36
|
-
if (!expandedRowIds.has(id)) {
|
|
37
|
-
return classes;
|
|
38
|
-
}
|
|
39
|
-
return [...classes, gridClasses['row--detailPanelExpanded']];
|
|
40
|
-
}, [privateApiRef, props.getDetailPanelContent]);
|
|
41
|
-
useGridRegisterPipeProcessor(privateApiRef, 'hydrateColumns', addToggleColumn);
|
|
42
|
-
useGridRegisterPipeProcessor(privateApiRef, 'rowClassName', addExpandedClassToRow);
|
|
43
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "./columnPinning/index.js";
|
|
2
|
-
export * from "./columnReorder/index.js";
|
|
3
|
-
export * from "./rowReorder/index.js";
|
|
4
|
-
export * from "./treeData/index.js";
|
|
5
|
-
export * from "./detailPanel/index.js";
|
|
6
|
-
export * from "./rowPinning/index.js";
|
|
7
|
-
export type { GridDataSourceState } from './dataSource/models';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Only export the variable and types that should be publicly exposed and re-exported from `@mui/x-data-grid-pro`
|
|
2
|
-
export * from "./columnPinning/index.js";
|
|
3
|
-
export * from "./columnReorder/index.js";
|
|
4
|
-
export * from "./rowReorder/index.js";
|
|
5
|
-
export * from "./treeData/index.js";
|
|
6
|
-
export * from "./detailPanel/index.js";
|
|
7
|
-
export * from "./rowPinning/index.js";
|
|
8
|
-
export {};
|
|
@@ -1,9 +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 useGridColumns (state)
|
|
6
|
-
* @requires useGridDimensions (method) - can be after
|
|
7
|
-
* @requires useGridScroll (method
|
|
8
|
-
*/
|
|
9
|
-
export declare const useGridInfiniteLoader: (apiRef: RefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, "onRowsScrollEnd" | "pagination" | "paginationMode" | "rowsLoadingMode" | "scrollEndThreshold">) => void;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useGridSelector, useGridEventPriority, gridVisibleColumnDefinitionsSelector, useGridApiMethod, gridDimensionsSelector } from '@mui/x-data-grid';
|
|
3
|
-
import { useGridVisibleRows, useTimeout, gridHorizontalScrollbarHeightSelector } from '@mui/x-data-grid/internals';
|
|
4
|
-
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
|
-
import { styled } from '@mui/system';
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
const InfiniteLoadingTriggerElement = styled('div')({
|
|
8
|
-
position: 'sticky',
|
|
9
|
-
left: 0,
|
|
10
|
-
width: 0,
|
|
11
|
-
height: 0
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @requires useGridColumns (state)
|
|
16
|
-
* @requires useGridDimensions (method) - can be after
|
|
17
|
-
* @requires useGridScroll (method
|
|
18
|
-
*/
|
|
19
|
-
export const useGridInfiniteLoader = (apiRef, props) => {
|
|
20
|
-
const isReady = useGridSelector(apiRef, gridDimensionsSelector).isReady;
|
|
21
|
-
const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
22
|
-
const currentPage = useGridVisibleRows(apiRef, props);
|
|
23
|
-
const observer = React.useRef(null);
|
|
24
|
-
const updateTargetTimeout = useTimeout();
|
|
25
|
-
const triggerElement = React.useRef(null);
|
|
26
|
-
const isEnabled = props.rowsLoadingMode === 'client' && !!props.onRowsScrollEnd;
|
|
27
|
-
const handleLoadMoreRows = useEventCallback(([entry]) => {
|
|
28
|
-
const currentRatio = entry.intersectionRatio;
|
|
29
|
-
const isIntersecting = entry.isIntersecting;
|
|
30
|
-
if (isIntersecting && currentRatio === 1) {
|
|
31
|
-
const viewportPageSize = apiRef.current.getViewportPageSize();
|
|
32
|
-
const rowScrollEndParams = {
|
|
33
|
-
visibleColumns,
|
|
34
|
-
viewportPageSize,
|
|
35
|
-
visibleRowsCount: currentPage.rows.length
|
|
36
|
-
};
|
|
37
|
-
apiRef.current.publishEvent('rowsScrollEnd', rowScrollEndParams);
|
|
38
|
-
observer.current?.disconnect();
|
|
39
|
-
// do not observe this node anymore
|
|
40
|
-
triggerElement.current = null;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
React.useEffect(() => {
|
|
44
|
-
const virtualScroller = apiRef.current.virtualScrollerRef.current;
|
|
45
|
-
if (!isEnabled || !isReady || !virtualScroller) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
observer.current?.disconnect();
|
|
49
|
-
const horizontalScrollbarHeight = gridHorizontalScrollbarHeightSelector(apiRef);
|
|
50
|
-
const marginBottom = props.scrollEndThreshold - horizontalScrollbarHeight;
|
|
51
|
-
observer.current = new IntersectionObserver(handleLoadMoreRows, {
|
|
52
|
-
threshold: 1,
|
|
53
|
-
root: virtualScroller,
|
|
54
|
-
rootMargin: `0px 0px ${marginBottom}px 0px`
|
|
55
|
-
});
|
|
56
|
-
if (triggerElement.current) {
|
|
57
|
-
observer.current.observe(triggerElement.current);
|
|
58
|
-
}
|
|
59
|
-
}, [apiRef, isReady, handleLoadMoreRows, isEnabled, props.scrollEndThreshold]);
|
|
60
|
-
const updateTarget = node => {
|
|
61
|
-
if (triggerElement.current !== node) {
|
|
62
|
-
observer.current?.disconnect();
|
|
63
|
-
triggerElement.current = node;
|
|
64
|
-
if (triggerElement.current) {
|
|
65
|
-
observer.current?.observe(triggerElement.current);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const triggerRef = React.useCallback(node => {
|
|
70
|
-
// Prevent the infite loading working in combination with lazy loading
|
|
71
|
-
if (!isEnabled) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// If the user scrolls through the grid too fast it might happen that the observer is connected to the trigger element
|
|
76
|
-
// that will be intersecting the root inside the same render cycle (but not intersecting at the time of the connection).
|
|
77
|
-
// This will cause the observer to not call the callback with `isIntersecting` set to `true`.
|
|
78
|
-
// https://www.w3.org/TR/intersection-observer/#event-loop
|
|
79
|
-
// Delaying the connection to the next cycle helps since the observer will always call the callback the first time it is connected.
|
|
80
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/observe
|
|
81
|
-
// Related to
|
|
82
|
-
// https://github.com/mui/mui-x/issues/14116
|
|
83
|
-
updateTargetTimeout.start(0, () => updateTarget(node));
|
|
84
|
-
}, [isEnabled, updateTargetTimeout]);
|
|
85
|
-
const getInfiniteLoadingTriggerElement = React.useCallback(({
|
|
86
|
-
lastRowId
|
|
87
|
-
}) => {
|
|
88
|
-
if (!isEnabled) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
return /*#__PURE__*/_jsx(InfiniteLoadingTriggerElement, {
|
|
92
|
-
ref: triggerRef
|
|
93
|
-
// Force rerender on last row change to start observing the new trigger
|
|
94
|
-
,
|
|
95
|
-
|
|
96
|
-
role: "presentation"
|
|
97
|
-
}, `trigger-${lastRowId}`);
|
|
98
|
-
}, [isEnabled, triggerRef]);
|
|
99
|
-
const infiniteLoaderPrivateApi = {
|
|
100
|
-
getInfiniteLoadingTriggerElement
|
|
101
|
-
};
|
|
102
|
-
useGridApiMethod(apiRef, infiniteLoaderPrivateApi, 'private');
|
|
103
|
-
useGridEventPriority(apiRef, 'rowsScrollEnd', props.onRowsScrollEnd);
|
|
104
|
-
};
|
|
@@ -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 useGridLazyLoader: (privateApiRef: RefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, "onFetchRows" | "rowsLoadingMode" | "pagination" | "paginationMode" | "experimentalFeatures">) => void;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useGridEvent, useGridSelector, gridSortModelSelector, gridFilterModelSelector, gridRenderContextSelector, useGridEventPriority } from '@mui/x-data-grid';
|
|
3
|
-
import { getVisibleRows } from '@mui/x-data-grid/internals';
|
|
4
|
-
import { findSkeletonRowsSection } from "./utils.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @requires useGridRows (state)
|
|
8
|
-
* @requires useGridPagination (state)
|
|
9
|
-
* @requires useGridDimensions (method) - can be after
|
|
10
|
-
* @requires useGridScroll (method
|
|
11
|
-
*/
|
|
12
|
-
export const useGridLazyLoader = (privateApiRef, props) => {
|
|
13
|
-
const sortModel = useGridSelector(privateApiRef, gridSortModelSelector);
|
|
14
|
-
const filterModel = useGridSelector(privateApiRef, gridFilterModelSelector);
|
|
15
|
-
const renderedRowsIntervalCache = React.useRef({
|
|
16
|
-
firstRowToRender: 0,
|
|
17
|
-
lastRowToRender: 0
|
|
18
|
-
});
|
|
19
|
-
const isDisabled = props.rowsLoadingMode !== 'server';
|
|
20
|
-
const handleRenderedRowsIntervalChange = React.useCallback(params => {
|
|
21
|
-
if (isDisabled) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const fetchRowsParams = {
|
|
25
|
-
firstRowToRender: params.firstRowIndex,
|
|
26
|
-
lastRowToRender: params.lastRowIndex,
|
|
27
|
-
sortModel,
|
|
28
|
-
filterModel
|
|
29
|
-
};
|
|
30
|
-
if (renderedRowsIntervalCache.current.firstRowToRender === params.firstRowIndex && renderedRowsIntervalCache.current.lastRowToRender === params.lastRowIndex) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
renderedRowsIntervalCache.current = {
|
|
34
|
-
firstRowToRender: params.firstRowIndex,
|
|
35
|
-
lastRowToRender: params.lastRowIndex
|
|
36
|
-
};
|
|
37
|
-
if (sortModel.length === 0 && filterModel.items.length === 0) {
|
|
38
|
-
const currentVisibleRows = getVisibleRows(privateApiRef, {
|
|
39
|
-
pagination: props.pagination,
|
|
40
|
-
paginationMode: props.paginationMode
|
|
41
|
-
});
|
|
42
|
-
const skeletonRowsSection = findSkeletonRowsSection({
|
|
43
|
-
apiRef: privateApiRef,
|
|
44
|
-
visibleRows: currentVisibleRows.rows,
|
|
45
|
-
range: {
|
|
46
|
-
firstRowIndex: params.firstRowIndex,
|
|
47
|
-
lastRowIndex: params.lastRowIndex
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
if (!skeletonRowsSection) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
fetchRowsParams.firstRowToRender = skeletonRowsSection.firstRowIndex;
|
|
54
|
-
fetchRowsParams.lastRowToRender = skeletonRowsSection.lastRowIndex;
|
|
55
|
-
}
|
|
56
|
-
privateApiRef.current.publishEvent('fetchRows', fetchRowsParams);
|
|
57
|
-
}, [privateApiRef, isDisabled, props.pagination, props.paginationMode, sortModel, filterModel]);
|
|
58
|
-
const handleGridSortModelChange = React.useCallback(newSortModel => {
|
|
59
|
-
if (isDisabled) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
privateApiRef.current.requestPipeProcessorsApplication('hydrateRows');
|
|
63
|
-
const renderContext = gridRenderContextSelector(privateApiRef);
|
|
64
|
-
const fetchRowsParams = {
|
|
65
|
-
firstRowToRender: renderContext.firstRowIndex,
|
|
66
|
-
lastRowToRender: renderContext.lastRowIndex,
|
|
67
|
-
sortModel: newSortModel,
|
|
68
|
-
filterModel
|
|
69
|
-
};
|
|
70
|
-
privateApiRef.current.publishEvent('fetchRows', fetchRowsParams);
|
|
71
|
-
}, [privateApiRef, isDisabled, filterModel]);
|
|
72
|
-
const handleGridFilterModelChange = React.useCallback(newFilterModel => {
|
|
73
|
-
if (isDisabled) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
privateApiRef.current.requestPipeProcessorsApplication('hydrateRows');
|
|
77
|
-
const renderContext = gridRenderContextSelector(privateApiRef);
|
|
78
|
-
const fetchRowsParams = {
|
|
79
|
-
firstRowToRender: renderContext.firstRowIndex,
|
|
80
|
-
lastRowToRender: renderContext.lastRowIndex,
|
|
81
|
-
sortModel,
|
|
82
|
-
filterModel: newFilterModel
|
|
83
|
-
};
|
|
84
|
-
privateApiRef.current.publishEvent('fetchRows', fetchRowsParams);
|
|
85
|
-
}, [privateApiRef, isDisabled, sortModel]);
|
|
86
|
-
useGridEvent(privateApiRef, 'renderedRowsIntervalChange', handleRenderedRowsIntervalChange);
|
|
87
|
-
useGridEvent(privateApiRef, 'sortModelChange', handleGridSortModelChange);
|
|
88
|
-
useGridEvent(privateApiRef, 'filterModelChange', handleGridFilterModelChange);
|
|
89
|
-
useGridEventPriority(privateApiRef, 'fetchRows', props.onFetchRows);
|
|
90
|
-
};
|
|
@@ -1,5 +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
|
-
export declare const GRID_SKELETON_ROW_ROOT_ID = "auto-generated-skeleton-row-root";
|
|
5
|
-
export declare const useGridLazyLoaderPreProcessors: (privateApiRef: RefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, "rowCount" | "rowsLoadingMode" | "experimentalFeatures">) => void;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
4
|
-
import { GRID_ROOT_GROUP_ID } from '@mui/x-data-grid';
|
|
5
|
-
export const GRID_SKELETON_ROW_ROOT_ID = 'auto-generated-skeleton-row-root';
|
|
6
|
-
const getSkeletonRowId = index => `${GRID_SKELETON_ROW_ROOT_ID}-${index}`;
|
|
7
|
-
export const useGridLazyLoaderPreProcessors = (privateApiRef, props) => {
|
|
8
|
-
const addSkeletonRows = React.useCallback(groupingParams => {
|
|
9
|
-
const rootGroup = groupingParams.tree[GRID_ROOT_GROUP_ID];
|
|
10
|
-
if (props.rowsLoadingMode !== 'server' || !props.rowCount || rootGroup.children.length >= props.rowCount) {
|
|
11
|
-
return groupingParams;
|
|
12
|
-
}
|
|
13
|
-
const tree = _extends({}, groupingParams.tree);
|
|
14
|
-
const rootGroupChildren = [...rootGroup.children];
|
|
15
|
-
for (let i = 0; i < props.rowCount - rootGroup.children.length; i += 1) {
|
|
16
|
-
const skeletonId = getSkeletonRowId(i);
|
|
17
|
-
rootGroupChildren.push(skeletonId);
|
|
18
|
-
const skeletonRowNode = {
|
|
19
|
-
type: 'skeletonRow',
|
|
20
|
-
id: skeletonId,
|
|
21
|
-
parent: GRID_ROOT_GROUP_ID,
|
|
22
|
-
depth: 0
|
|
23
|
-
};
|
|
24
|
-
tree[skeletonId] = skeletonRowNode;
|
|
25
|
-
}
|
|
26
|
-
tree[GRID_ROOT_GROUP_ID] = _extends({}, rootGroup, {
|
|
27
|
-
children: rootGroupChildren
|
|
28
|
-
});
|
|
29
|
-
return _extends({}, groupingParams, {
|
|
30
|
-
tree
|
|
31
|
-
});
|
|
32
|
-
}, [props.rowCount, props.rowsLoadingMode]);
|
|
33
|
-
useGridRegisterPipeProcessor(privateApiRef, 'hydrateRows', addSkeletonRows);
|
|
34
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { GridRowEntry } from '@mui/x-data-grid';
|
|
3
|
-
import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
4
|
-
export declare const findSkeletonRowsSection: ({
|
|
5
|
-
apiRef,
|
|
6
|
-
visibleRows,
|
|
7
|
-
range
|
|
8
|
-
}: {
|
|
9
|
-
apiRef: RefObject<GridPrivateApiPro>;
|
|
10
|
-
visibleRows: GridRowEntry[];
|
|
11
|
-
range: {
|
|
12
|
-
firstRowIndex: number;
|
|
13
|
-
lastRowIndex: number;
|
|
14
|
-
};
|
|
15
|
-
}) => {
|
|
16
|
-
firstRowIndex: number;
|
|
17
|
-
lastRowIndex: number;
|
|
18
|
-
} | undefined;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { gridRowNodeSelector } from '@mui/x-data-grid';
|
|
2
|
-
export const findSkeletonRowsSection = ({
|
|
3
|
-
apiRef,
|
|
4
|
-
visibleRows,
|
|
5
|
-
range
|
|
6
|
-
}) => {
|
|
7
|
-
let {
|
|
8
|
-
firstRowIndex,
|
|
9
|
-
lastRowIndex
|
|
10
|
-
} = range;
|
|
11
|
-
const visibleRowsSection = visibleRows.slice(range.firstRowIndex, range.lastRowIndex);
|
|
12
|
-
let startIndex = 0;
|
|
13
|
-
let endIndex = visibleRowsSection.length - 1;
|
|
14
|
-
let isSkeletonSectionFound = false;
|
|
15
|
-
while (!isSkeletonSectionFound && firstRowIndex < lastRowIndex) {
|
|
16
|
-
const isStartingWithASkeletonRow = gridRowNodeSelector(apiRef, visibleRowsSection[startIndex].id)?.type === 'skeletonRow';
|
|
17
|
-
const isEndingWithASkeletonRow = gridRowNodeSelector(apiRef, visibleRowsSection[endIndex].id)?.type === 'skeletonRow';
|
|
18
|
-
if (isStartingWithASkeletonRow && isEndingWithASkeletonRow) {
|
|
19
|
-
isSkeletonSectionFound = true;
|
|
20
|
-
}
|
|
21
|
-
if (!isStartingWithASkeletonRow) {
|
|
22
|
-
startIndex += 1;
|
|
23
|
-
firstRowIndex += 1;
|
|
24
|
-
}
|
|
25
|
-
if (!isEndingWithASkeletonRow) {
|
|
26
|
-
endIndex -= 1;
|
|
27
|
-
lastRowIndex -= 1;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return isSkeletonSectionFound ? {
|
|
31
|
-
firstRowIndex,
|
|
32
|
-
lastRowIndex
|
|
33
|
-
} : undefined;
|
|
34
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { GridRowId, GridRowIdToModelLookup, GridRowsProp, GridValidRowModel } from '@mui/x-data-grid';
|
|
2
|
-
export interface GridPinnedRowsProp<R extends GridValidRowModel = GridValidRowModel> {
|
|
3
|
-
top?: GridRowsProp<R>;
|
|
4
|
-
bottom?: GridRowsProp<R>;
|
|
5
|
-
}
|
|
6
|
-
export interface GridRowPinningApi {
|
|
7
|
-
/**
|
|
8
|
-
* Changes the pinned rows.
|
|
9
|
-
* @param {GridPinnedRowsProp} pinnedRows An object containing the rows to pin.
|
|
10
|
-
*/
|
|
11
|
-
unstable_setPinnedRows: (pinnedRows?: GridPinnedRowsProp) => void;
|
|
12
|
-
}
|
|
13
|
-
export interface GridRowPinningInternalCache {
|
|
14
|
-
topIds: GridRowId[];
|
|
15
|
-
bottomIds: GridRowId[];
|
|
16
|
-
idLookup: GridRowIdToModelLookup;
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector } from '@mui/x-data-grid/internals';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector } from '@mui/x-data-grid/internals';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./gridRowPinningInterface.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./gridRowPinningInterface.js";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { GridStateInitializer } from '@mui/x-data-grid/internals';
|
|
3
|
-
import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
4
|
-
import { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
|
|
5
|
-
export declare const rowPinningStateInitializer: GridStateInitializer<Pick<DataGridProProcessedProps, 'pinnedRows' | 'getRowId' | 'experimentalFeatures'>>;
|
|
6
|
-
export declare const useGridRowPinning: (apiRef: RefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, "pinnedRows" | "getRowId">) => void;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useGridApiMethod } from '@mui/x-data-grid';
|
|
4
|
-
import { getRowIdFromRowModel } from '@mui/x-data-grid/internals';
|
|
5
|
-
function createPinnedRowsInternalCache(pinnedRows, getRowId) {
|
|
6
|
-
const cache = {
|
|
7
|
-
topIds: [],
|
|
8
|
-
bottomIds: [],
|
|
9
|
-
idLookup: {}
|
|
10
|
-
};
|
|
11
|
-
pinnedRows?.top?.forEach(rowModel => {
|
|
12
|
-
const id = getRowIdFromRowModel(rowModel, getRowId);
|
|
13
|
-
cache.topIds.push(id);
|
|
14
|
-
cache.idLookup[id] = rowModel;
|
|
15
|
-
});
|
|
16
|
-
pinnedRows?.bottom?.forEach(rowModel => {
|
|
17
|
-
const id = getRowIdFromRowModel(rowModel, getRowId);
|
|
18
|
-
cache.bottomIds.push(id);
|
|
19
|
-
cache.idLookup[id] = rowModel;
|
|
20
|
-
});
|
|
21
|
-
return cache;
|
|
22
|
-
}
|
|
23
|
-
export const rowPinningStateInitializer = (state, props, apiRef) => {
|
|
24
|
-
apiRef.current.caches.pinnedRows = createPinnedRowsInternalCache(props.pinnedRows, props.getRowId);
|
|
25
|
-
return _extends({}, state, {
|
|
26
|
-
rows: _extends({}, state.rows, {
|
|
27
|
-
additionalRowGroups: _extends({}, state.rows?.additionalRowGroups, {
|
|
28
|
-
pinnedRows: {
|
|
29
|
-
top: [],
|
|
30
|
-
bottom: []
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
export const useGridRowPinning = (apiRef, props) => {
|
|
37
|
-
const setPinnedRows = React.useCallback(newPinnedRows => {
|
|
38
|
-
apiRef.current.caches.pinnedRows = createPinnedRowsInternalCache(newPinnedRows, props.getRowId);
|
|
39
|
-
apiRef.current.requestPipeProcessorsApplication('hydrateRows');
|
|
40
|
-
}, [apiRef, props.getRowId]);
|
|
41
|
-
useGridApiMethod(apiRef, {
|
|
42
|
-
unstable_setPinnedRows: setPinnedRows
|
|
43
|
-
}, 'public');
|
|
44
|
-
const isFirstRender = React.useRef(true);
|
|
45
|
-
React.useEffect(() => {
|
|
46
|
-
if (isFirstRender.current) {
|
|
47
|
-
isFirstRender.current = false;
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
apiRef.current.unstable_setPinnedRows(props.pinnedRows);
|
|
51
|
-
}, [apiRef, props.pinnedRows]);
|
|
52
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { GridHydrateRowsValue } from '@mui/x-data-grid/internals';
|
|
3
|
-
import { GridRowId, GridRowModel } from '@mui/x-data-grid';
|
|
4
|
-
import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
5
|
-
import type { GridPinnedRowsProp } from './gridRowPinningInterface';
|
|
6
|
-
type GridPinnedRowPosition = keyof GridPinnedRowsProp;
|
|
7
|
-
export declare function addPinnedRow({
|
|
8
|
-
groupingParams,
|
|
9
|
-
rowModel,
|
|
10
|
-
rowId,
|
|
11
|
-
position,
|
|
12
|
-
apiRef,
|
|
13
|
-
isAutoGenerated
|
|
14
|
-
}: {
|
|
15
|
-
groupingParams: GridHydrateRowsValue;
|
|
16
|
-
rowModel: GridRowModel;
|
|
17
|
-
rowId: GridRowId;
|
|
18
|
-
position: GridPinnedRowPosition;
|
|
19
|
-
apiRef: RefObject<GridPrivateApiPro>;
|
|
20
|
-
isAutoGenerated: boolean;
|
|
21
|
-
}): {
|
|
22
|
-
dataRowIdToModelLookup: {
|
|
23
|
-
[x: string]: import("@mui/x-data-grid").GridValidRowModel;
|
|
24
|
-
};
|
|
25
|
-
tree: {
|
|
26
|
-
[x: string]: import("@mui/x-data-grid").GridTreeNode;
|
|
27
|
-
[x: number]: import("@mui/x-data-grid").GridTreeNode;
|
|
28
|
-
};
|
|
29
|
-
treeDepths: {
|
|
30
|
-
[depth: number]: number;
|
|
31
|
-
};
|
|
32
|
-
dataRowIds: GridRowId[];
|
|
33
|
-
additionalRowGroups?: {
|
|
34
|
-
pinnedRows?: import("@mui/x-data-grid/internals").GridPinnedRowsState;
|
|
35
|
-
} | undefined;
|
|
36
|
-
};
|
|
37
|
-
export declare const useGridRowPinningPreProcessors: (apiRef: RefObject<GridPrivateApiPro>) => void;
|
|
38
|
-
export {};
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
4
|
-
import { GRID_ROOT_GROUP_ID } from '@mui/x-data-grid';
|
|
5
|
-
import { insertNodeInTree } from "../../../utils/tree/utils.js";
|
|
6
|
-
export function addPinnedRow({
|
|
7
|
-
groupingParams,
|
|
8
|
-
rowModel,
|
|
9
|
-
rowId,
|
|
10
|
-
position,
|
|
11
|
-
apiRef,
|
|
12
|
-
isAutoGenerated
|
|
13
|
-
}) {
|
|
14
|
-
const dataRowIdToModelLookup = _extends({}, groupingParams.dataRowIdToModelLookup);
|
|
15
|
-
const tree = _extends({}, groupingParams.tree);
|
|
16
|
-
const treeDepths = _extends({}, groupingParams.treeDepths);
|
|
17
|
-
|
|
18
|
-
// TODO: warn if id is already present in `props.rows`
|
|
19
|
-
|
|
20
|
-
const node = {
|
|
21
|
-
type: 'pinnedRow',
|
|
22
|
-
id: rowId,
|
|
23
|
-
depth: 0,
|
|
24
|
-
parent: GRID_ROOT_GROUP_ID,
|
|
25
|
-
isAutoGenerated
|
|
26
|
-
};
|
|
27
|
-
insertNodeInTree(node, tree, treeDepths, null);
|
|
28
|
-
if (!isAutoGenerated) {
|
|
29
|
-
dataRowIdToModelLookup[rowId] = rowModel;
|
|
30
|
-
}
|
|
31
|
-
// Do not push it to ids list so that pagination is not affected by pinned rows
|
|
32
|
-
|
|
33
|
-
apiRef.current.caches.rows.dataRowIdToModelLookup[rowId] = _extends({}, rowModel);
|
|
34
|
-
const previousPinnedRows = groupingParams.additionalRowGroups?.pinnedRows || {};
|
|
35
|
-
const newPinnedRow = {
|
|
36
|
-
id: rowId,
|
|
37
|
-
model: rowModel
|
|
38
|
-
};
|
|
39
|
-
if (groupingParams.additionalRowGroups?.pinnedRows?.[position]?.includes(newPinnedRow)) {
|
|
40
|
-
return _extends({}, groupingParams, {
|
|
41
|
-
dataRowIdToModelLookup,
|
|
42
|
-
tree,
|
|
43
|
-
treeDepths
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return _extends({}, groupingParams, {
|
|
47
|
-
dataRowIdToModelLookup,
|
|
48
|
-
tree,
|
|
49
|
-
treeDepths,
|
|
50
|
-
additionalRowGroups: _extends({}, groupingParams.additionalRowGroups, {
|
|
51
|
-
pinnedRows: _extends({}, previousPinnedRows, {
|
|
52
|
-
[position]: [...(previousPinnedRows[position] || []), newPinnedRow]
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
export const useGridRowPinningPreProcessors = apiRef => {
|
|
58
|
-
const prevPinnedRowsCacheRef = React.useRef(null);
|
|
59
|
-
const addPinnedRows = React.useCallback(groupingParams => {
|
|
60
|
-
const pinnedRowsCache = apiRef.current.caches.pinnedRows || {};
|
|
61
|
-
const prevPinnedRowsCache = prevPinnedRowsCacheRef.current;
|
|
62
|
-
prevPinnedRowsCacheRef.current = pinnedRowsCache;
|
|
63
|
-
let newGroupingParams = _extends({}, groupingParams, {
|
|
64
|
-
additionalRowGroups: _extends({}, groupingParams.additionalRowGroups, {
|
|
65
|
-
// reset pinned rows state
|
|
66
|
-
pinnedRows: {}
|
|
67
|
-
})
|
|
68
|
-
});
|
|
69
|
-
if (prevPinnedRowsCache) {
|
|
70
|
-
const pinnedRowCleanup = rowId => {
|
|
71
|
-
const node = newGroupingParams.tree[rowId];
|
|
72
|
-
if (node?.type === 'pinnedRow') {
|
|
73
|
-
delete newGroupingParams.tree[rowId];
|
|
74
|
-
delete newGroupingParams.dataRowIdToModelLookup[rowId];
|
|
75
|
-
delete apiRef.current.caches.rows.dataRowIdToModelLookup[rowId];
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
prevPinnedRowsCache.topIds?.forEach(pinnedRowCleanup);
|
|
79
|
-
prevPinnedRowsCache.bottomIds?.forEach(pinnedRowCleanup);
|
|
80
|
-
}
|
|
81
|
-
pinnedRowsCache.topIds?.forEach(rowId => {
|
|
82
|
-
newGroupingParams = addPinnedRow({
|
|
83
|
-
groupingParams: newGroupingParams,
|
|
84
|
-
rowModel: pinnedRowsCache.idLookup[rowId],
|
|
85
|
-
rowId,
|
|
86
|
-
position: 'top',
|
|
87
|
-
apiRef,
|
|
88
|
-
isAutoGenerated: false
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
pinnedRowsCache.bottomIds?.forEach(rowId => {
|
|
92
|
-
newGroupingParams = addPinnedRow({
|
|
93
|
-
groupingParams: newGroupingParams,
|
|
94
|
-
rowModel: pinnedRowsCache.idLookup[rowId],
|
|
95
|
-
rowId,
|
|
96
|
-
position: 'bottom',
|
|
97
|
-
apiRef,
|
|
98
|
-
isAutoGenerated: false
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// If row with the same `id` is present both in `rows` and `pinnedRows` - remove it from the root group children
|
|
103
|
-
if (pinnedRowsCache.bottomIds?.length || pinnedRowsCache.topIds?.length) {
|
|
104
|
-
const shouldKeepRow = rowId => {
|
|
105
|
-
if (newGroupingParams.tree[rowId] && newGroupingParams.tree[rowId].type === 'pinnedRow') {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
return true;
|
|
109
|
-
};
|
|
110
|
-
const rootGroupNode = newGroupingParams.tree[GRID_ROOT_GROUP_ID];
|
|
111
|
-
newGroupingParams.tree[GRID_ROOT_GROUP_ID] = _extends({}, rootGroupNode, {
|
|
112
|
-
children: rootGroupNode.children.filter(shouldKeepRow)
|
|
113
|
-
});
|
|
114
|
-
newGroupingParams.dataRowIds = newGroupingParams.dataRowIds.filter(shouldKeepRow);
|
|
115
|
-
}
|
|
116
|
-
return newGroupingParams;
|
|
117
|
-
}, [apiRef]);
|
|
118
|
-
useGridRegisterPipeProcessor(apiRef, 'hydrateRows', addPinnedRows);
|
|
119
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { GRID_STRING_COL_DEF } from '@mui/x-data-grid';
|
|
3
|
-
import { renderRowReorderCell } from "../../../components/GridRowReorderCell.js";
|
|
4
|
-
export const GRID_REORDER_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
5
|
-
type: 'custom',
|
|
6
|
-
field: '__reorder__',
|
|
7
|
-
sortable: false,
|
|
8
|
-
filterable: false,
|
|
9
|
-
width: 50,
|
|
10
|
-
align: 'center',
|
|
11
|
-
headerAlign: 'center',
|
|
12
|
-
disableColumnMenu: true,
|
|
13
|
-
disableExport: true,
|
|
14
|
-
disableReorder: true,
|
|
15
|
-
resizable: false,
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
aggregable: false,
|
|
18
|
-
renderHeader: () => ' ',
|
|
19
|
-
renderCell: renderRowReorderCell
|
|
20
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./gridRowReorderColDef.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./gridRowReorderColDef.js";
|