@mui/x-data-grid-pro 5.5.1 → 5.6.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 +116 -0
- package/DataGridPro/DataGridPro.d.ts +3 -0
- package/DataGridPro/DataGridPro.js +896 -0
- package/DataGridPro/index.d.ts +2 -0
- package/DataGridPro/index.js +2 -0
- package/DataGridPro/package.json +6 -0
- package/DataGridPro/useDataGridProComponent.d.ts +4 -0
- package/DataGridPro/useDataGridProComponent.js +72 -0
- package/DataGridPro/useDataGridProProps.d.ts +6 -0
- package/DataGridPro/useDataGridProProps.js +49 -0
- package/components/DataGridProColumnHeaders.d.ts +6 -0
- package/components/DataGridProColumnHeaders.js +165 -0
- package/components/DataGridProVirtualScroller.d.ts +8 -0
- package/components/DataGridProVirtualScroller.js +281 -0
- package/components/GridColumnPinningMenuItems.d.ts +11 -0
- package/components/GridColumnPinningMenuItems.js +71 -0
- package/components/GridDetailPanelToggleCell.d.ts +7 -0
- package/components/GridDetailPanelToggleCell.js +124 -0
- package/components/GridGroupingColumnLeafCell.d.ts +4 -0
- package/components/GridGroupingColumnLeafCell.js +22 -0
- package/components/GridGroupingCriteriaCell.d.ts +10 -0
- package/components/GridGroupingCriteriaCell.js +150 -0
- package/components/GridRowGroupableColumnMenuItems.d.ts +11 -0
- package/components/GridRowGroupableColumnMenuItems.js +63 -0
- package/components/GridRowGroupingColumnMenuItems.d.ts +11 -0
- package/components/GridRowGroupingColumnMenuItems.js +58 -0
- package/components/GridTreeDataGroupingCell.d.ts +10 -0
- package/components/GridTreeDataGroupingCell.js +159 -0
- package/components/Watermark.d.ts +2 -0
- package/components/Watermark.js +43 -0
- package/components/index.d.ts +2 -0
- package/components/index.js +3 -0
- package/components/package.json +6 -0
- package/hooks/features/columnPinning/gridColumnPinningInterface.d.ts +42 -0
- package/hooks/features/columnPinning/gridColumnPinningInterface.js +11 -0
- package/hooks/features/columnPinning/gridColumnPinningSelector.d.ts +2 -0
- package/hooks/features/columnPinning/gridColumnPinningSelector.js +1 -0
- package/hooks/features/columnPinning/index.d.ts +2 -0
- package/hooks/features/columnPinning/index.js +2 -0
- package/hooks/features/columnPinning/useGridColumnPinning.d.ts +6 -0
- package/hooks/features/columnPinning/useGridColumnPinning.js +274 -0
- package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.d.ts +4 -0
- package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +45 -0
- package/hooks/features/columnReorder/columnReorderInterfaces.d.ts +6 -0
- package/hooks/features/columnReorder/columnReorderInterfaces.js +1 -0
- package/hooks/features/columnReorder/columnReorderSelector.d.ts +3 -0
- package/hooks/features/columnReorder/columnReorderSelector.js +3 -0
- package/hooks/features/columnReorder/index.d.ts +2 -0
- package/hooks/features/columnReorder/index.js +2 -0
- package/hooks/features/columnReorder/useGridColumnReorder.d.ts +8 -0
- package/hooks/features/columnReorder/useGridColumnReorder.js +166 -0
- package/hooks/features/columnResize/columnResizeSelector.d.ts +3 -0
- package/hooks/features/columnResize/columnResizeSelector.js +3 -0
- package/hooks/features/columnResize/columnResizeState.d.ts +3 -0
- package/hooks/features/columnResize/columnResizeState.js +1 -0
- package/hooks/features/columnResize/index.d.ts +2 -0
- package/hooks/features/columnResize/index.js +2 -0
- package/hooks/features/columnResize/useGridColumnResize.d.ts +9 -0
- package/hooks/features/columnResize/useGridColumnResize.js +305 -0
- package/hooks/features/detailPanel/gridDetailPanelInterface.d.ts +28 -0
- package/hooks/features/detailPanel/gridDetailPanelInterface.js +1 -0
- package/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +5 -0
- package/hooks/features/detailPanel/gridDetailPanelSelector.js +3 -0
- package/hooks/features/detailPanel/gridDetailPanelToggleColDef.d.ts +3 -0
- package/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +26 -0
- package/hooks/features/detailPanel/index.d.ts +3 -0
- package/hooks/features/detailPanel/index.js +3 -0
- package/hooks/features/detailPanel/useGridDetailPanel.d.ts +4 -0
- package/hooks/features/detailPanel/useGridDetailPanel.js +109 -0
- package/hooks/features/detailPanel/useGridDetailPanelCache.d.ts +4 -0
- package/hooks/features/detailPanel/useGridDetailPanelCache.js +57 -0
- package/hooks/features/detailPanel/useGridDetailPanelPreProcessors.d.ts +4 -0
- package/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +28 -0
- package/hooks/features/index.d.ts +6 -0
- package/hooks/features/index.js +7 -0
- package/hooks/features/infiniteLoader/useGridInfiniteLoader.d.ts +10 -0
- package/hooks/features/infiniteLoader/useGridInfiniteLoader.js +52 -0
- package/hooks/features/rowGrouping/createGroupingColDef.d.ts +43 -0
- package/hooks/features/rowGrouping/createGroupingColDef.js +318 -0
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +31 -0
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/hooks/features/rowGrouping/gridRowGroupingSelector.d.ts +4 -0
- package/hooks/features/rowGrouping/gridRowGroupingSelector.js +5 -0
- package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +24 -0
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +124 -0
- package/hooks/features/rowGrouping/index.d.ts +3 -0
- package/hooks/features/rowGrouping/index.js +3 -0
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +13 -0
- package/hooks/features/rowGrouping/useGridRowGrouping.js +325 -0
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +4 -0
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +76 -0
- package/hooks/features/treeData/gridTreeDataGroupColDef.d.ts +7 -0
- package/hooks/features/treeData/gridTreeDataGroupColDef.js +22 -0
- package/hooks/features/treeData/gridTreeDataUtils.d.ts +14 -0
- package/hooks/features/treeData/gridTreeDataUtils.js +86 -0
- package/hooks/features/treeData/index.d.ts +1 -0
- package/hooks/features/treeData/index.js +1 -0
- package/hooks/features/treeData/useGridTreeData.d.ts +10 -0
- package/hooks/features/treeData/useGridTreeData.js +108 -0
- package/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +4 -0
- package/hooks/features/treeData/useGridTreeDataPreProcessors.js +69 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/package.json +6 -0
- package/hooks/utils/useGridApiContext.d.ts +4 -0
- package/hooks/utils/useGridApiContext.js +2 -0
- package/hooks/utils/useGridApiRef.d.ts +4 -0
- package/hooks/utils/useGridApiRef.js +2 -0
- package/hooks/utils/useGridRootProps.d.ts +2 -0
- package/hooks/utils/useGridRootProps.js +2 -0
- package/index.d.ts +15 -0
- package/index.js +19 -0
- package/legacy/DataGridPro/DataGridPro.js +896 -0
- package/legacy/DataGridPro/index.js +2 -0
- package/legacy/DataGridPro/useDataGridProComponent.js +72 -0
- package/legacy/DataGridPro/useDataGridProProps.js +53 -0
- package/legacy/components/DataGridProColumnHeaders.js +173 -0
- package/legacy/components/DataGridProVirtualScroller.js +297 -0
- package/legacy/components/GridColumnPinningMenuItems.js +71 -0
- package/legacy/components/GridDetailPanelToggleCell.js +120 -0
- package/legacy/components/GridGroupingColumnLeafCell.js +20 -0
- package/legacy/components/GridGroupingCriteriaCell.js +146 -0
- package/legacy/components/GridRowGroupableColumnMenuItems.js +61 -0
- package/legacy/components/GridRowGroupingColumnMenuItems.js +56 -0
- package/legacy/components/GridTreeDataGroupingCell.js +155 -0
- package/legacy/components/Watermark.js +43 -0
- package/legacy/components/index.js +3 -0
- package/legacy/hooks/features/columnPinning/gridColumnPinningInterface.js +11 -0
- package/legacy/hooks/features/columnPinning/gridColumnPinningSelector.js +3 -0
- package/legacy/hooks/features/columnPinning/index.js +2 -0
- package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +298 -0
- package/legacy/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +48 -0
- package/legacy/hooks/features/columnReorder/columnReorderInterfaces.js +1 -0
- package/legacy/hooks/features/columnReorder/columnReorderSelector.js +7 -0
- package/legacy/hooks/features/columnReorder/index.js +2 -0
- package/legacy/hooks/features/columnReorder/useGridColumnReorder.js +172 -0
- package/legacy/hooks/features/columnResize/columnResizeSelector.js +7 -0
- package/legacy/hooks/features/columnResize/columnResizeState.js +1 -0
- package/legacy/hooks/features/columnResize/index.js +2 -0
- package/legacy/hooks/features/columnResize/useGridColumnResize.js +310 -0
- package/legacy/hooks/features/detailPanel/gridDetailPanelInterface.js +1 -0
- package/legacy/hooks/features/detailPanel/gridDetailPanelSelector.js +9 -0
- package/legacy/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +28 -0
- package/legacy/hooks/features/detailPanel/index.js +3 -0
- package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +114 -0
- package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +57 -0
- package/legacy/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +31 -0
- package/legacy/hooks/features/index.js +7 -0
- package/legacy/hooks/features/infiniteLoader/useGridInfiniteLoader.js +51 -0
- package/legacy/hooks/features/rowGrouping/createGroupingColDef.js +319 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingSelector.js +13 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +130 -0
- package/legacy/hooks/features/rowGrouping/index.js +3 -0
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +334 -0
- package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +83 -0
- package/legacy/hooks/features/treeData/gridTreeDataGroupColDef.js +24 -0
- package/legacy/hooks/features/treeData/gridTreeDataUtils.js +84 -0
- package/legacy/hooks/features/treeData/index.js +1 -0
- package/legacy/hooks/features/treeData/useGridTreeData.js +116 -0
- package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +72 -0
- package/legacy/hooks/index.js +1 -0
- package/legacy/hooks/utils/useGridApiContext.js +2 -0
- package/legacy/hooks/utils/useGridApiRef.js +2 -0
- package/legacy/hooks/utils/useGridRootProps.js +2 -0
- package/legacy/index.js +19 -0
- package/legacy/models/dataGridProProps.js +1 -0
- package/legacy/models/gridApiPro.js +1 -0
- package/legacy/models/gridGroupingColDefOverride.js +1 -0
- package/legacy/models/gridGroupingValueGetterParams.js +1 -0
- package/legacy/models/gridRowScrollEndParams.js +1 -0
- package/legacy/models/gridStatePro.js +1 -0
- package/legacy/models/index.js +4 -0
- package/legacy/themeAugmentation/index.js +3 -0
- package/legacy/themeAugmentation/overrides.js +1 -0
- package/legacy/themeAugmentation/props.js +1 -0
- package/legacy/typeOverloads/modules.js +1 -0
- package/legacy/typeOverloads/reexports.js +6 -0
- package/legacy/utils/domUtils.js +19 -0
- package/legacy/utils/tree/buildRowTree.js +188 -0
- package/legacy/utils/tree/sortRowTree.js +63 -0
- package/models/dataGridProProps.d.ts +174 -0
- package/models/dataGridProProps.js +1 -0
- package/models/gridApiPro.d.ts +12 -0
- package/models/gridApiPro.js +1 -0
- package/models/gridGroupingColDefOverride.d.ts +30 -0
- package/models/gridGroupingColDefOverride.js +1 -0
- package/models/gridGroupingValueGetterParams.d.ts +31 -0
- package/models/gridGroupingValueGetterParams.js +1 -0
- package/models/gridRowScrollEndParams.d.ts +18 -0
- package/models/gridRowScrollEndParams.js +1 -0
- package/models/gridStatePro.d.ts +20 -0
- package/models/gridStatePro.js +1 -0
- package/models/index.d.ts +4 -0
- package/models/index.js +4 -0
- package/models/package.json +6 -0
- package/modern/DataGridPro/DataGridPro.js +896 -0
- package/modern/DataGridPro/index.js +2 -0
- package/modern/DataGridPro/useDataGridProComponent.js +72 -0
- package/modern/DataGridPro/useDataGridProProps.js +45 -0
- package/modern/components/DataGridProColumnHeaders.js +163 -0
- package/modern/components/DataGridProVirtualScroller.js +279 -0
- package/modern/components/GridColumnPinningMenuItems.js +71 -0
- package/modern/components/GridDetailPanelToggleCell.js +124 -0
- package/modern/components/GridGroupingColumnLeafCell.js +20 -0
- package/modern/components/GridGroupingCriteriaCell.js +148 -0
- package/modern/components/GridRowGroupableColumnMenuItems.js +61 -0
- package/modern/components/GridRowGroupingColumnMenuItems.js +56 -0
- package/modern/components/GridTreeDataGroupingCell.js +157 -0
- package/modern/components/Watermark.js +43 -0
- package/modern/components/index.js +3 -0
- package/modern/hooks/features/columnPinning/gridColumnPinningInterface.js +11 -0
- package/modern/hooks/features/columnPinning/gridColumnPinningSelector.js +1 -0
- package/modern/hooks/features/columnPinning/index.js +2 -0
- package/modern/hooks/features/columnPinning/useGridColumnPinning.js +268 -0
- package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +45 -0
- package/modern/hooks/features/columnReorder/columnReorderInterfaces.js +1 -0
- package/modern/hooks/features/columnReorder/columnReorderSelector.js +3 -0
- package/modern/hooks/features/columnReorder/index.js +2 -0
- package/modern/hooks/features/columnReorder/useGridColumnReorder.js +166 -0
- package/modern/hooks/features/columnResize/columnResizeSelector.js +3 -0
- package/modern/hooks/features/columnResize/columnResizeState.js +1 -0
- package/modern/hooks/features/columnResize/index.js +2 -0
- package/modern/hooks/features/columnResize/useGridColumnResize.js +295 -0
- package/modern/hooks/features/detailPanel/gridDetailPanelInterface.js +1 -0
- package/modern/hooks/features/detailPanel/gridDetailPanelSelector.js +3 -0
- package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +26 -0
- package/modern/hooks/features/detailPanel/index.js +3 -0
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +105 -0
- package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +57 -0
- package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +28 -0
- package/modern/hooks/features/index.js +7 -0
- package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.js +52 -0
- package/modern/hooks/features/rowGrouping/createGroupingColDef.js +302 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingSelector.js +5 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +122 -0
- package/modern/hooks/features/rowGrouping/index.js +3 -0
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +317 -0
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +76 -0
- package/modern/hooks/features/treeData/gridTreeDataGroupColDef.js +22 -0
- package/modern/hooks/features/treeData/gridTreeDataUtils.js +82 -0
- package/modern/hooks/features/treeData/index.js +1 -0
- package/modern/hooks/features/treeData/useGridTreeData.js +106 -0
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +67 -0
- package/modern/hooks/index.js +1 -0
- package/modern/hooks/utils/useGridApiContext.js +2 -0
- package/modern/hooks/utils/useGridApiRef.js +2 -0
- package/modern/hooks/utils/useGridRootProps.js +2 -0
- package/modern/index.js +19 -0
- package/modern/models/dataGridProProps.js +1 -0
- package/modern/models/gridApiPro.js +1 -0
- package/modern/models/gridGroupingColDefOverride.js +1 -0
- package/modern/models/gridGroupingValueGetterParams.js +1 -0
- package/modern/models/gridRowScrollEndParams.js +1 -0
- package/modern/models/gridStatePro.js +1 -0
- package/modern/models/index.js +4 -0
- package/modern/themeAugmentation/index.js +3 -0
- package/modern/themeAugmentation/overrides.js +1 -0
- package/modern/themeAugmentation/props.js +1 -0
- package/modern/typeOverloads/modules.js +1 -0
- package/modern/typeOverloads/reexports.js +6 -0
- package/modern/utils/domUtils.js +19 -0
- package/modern/utils/tree/buildRowTree.js +167 -0
- package/modern/utils/tree/sortRowTree.js +60 -0
- package/node/DataGridPro/DataGridPro.js +921 -0
- package/node/DataGridPro/index.js +30 -0
- package/node/DataGridPro/useDataGridProComponent.js +94 -0
- package/node/DataGridPro/useDataGridProProps.js +69 -0
- package/node/components/DataGridProColumnHeaders.js +189 -0
- package/node/components/DataGridProVirtualScroller.js +308 -0
- package/node/components/GridColumnPinningMenuItems.js +88 -0
- package/node/components/GridDetailPanelToggleCell.js +145 -0
- package/node/components/GridGroupingColumnLeafCell.js +38 -0
- package/node/components/GridGroupingCriteriaCell.js +170 -0
- package/node/components/GridRowGroupableColumnMenuItems.js +82 -0
- package/node/components/GridRowGroupingColumnMenuItems.js +78 -0
- package/node/components/GridTreeDataGroupingCell.js +180 -0
- package/node/components/Watermark.js +56 -0
- package/node/components/index.js +31 -0
- package/node/hooks/features/columnPinning/gridColumnPinningInterface.js +17 -0
- package/node/hooks/features/columnPinning/gridColumnPinningSelector.js +10 -0
- package/node/hooks/features/columnPinning/index.js +31 -0
- package/node/hooks/features/columnPinning/useGridColumnPinning.js +297 -0
- package/node/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +66 -0
- package/node/hooks/features/columnReorder/columnReorderInterfaces.js +5 -0
- package/node/hooks/features/columnReorder/columnReorderSelector.js +14 -0
- package/node/hooks/features/columnReorder/index.js +18 -0
- package/node/hooks/features/columnReorder/useGridColumnReorder.js +187 -0
- package/node/hooks/features/columnResize/columnResizeSelector.js +14 -0
- package/node/hooks/features/columnResize/columnResizeState.js +5 -0
- package/node/hooks/features/columnResize/index.js +31 -0
- package/node/hooks/features/columnResize/useGridColumnResize.js +326 -0
- package/node/hooks/features/detailPanel/gridDetailPanelInterface.js +5 -0
- package/node/hooks/features/detailPanel/gridDetailPanelSelector.js +18 -0
- package/node/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +47 -0
- package/node/hooks/features/detailPanel/index.js +44 -0
- package/node/hooks/features/detailPanel/useGridDetailPanel.js +130 -0
- package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +74 -0
- package/node/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +44 -0
- package/node/hooks/features/index.js +83 -0
- package/node/hooks/features/infiniteLoader/useGridInfiniteLoader.js +67 -0
- package/node/hooks/features/rowGrouping/createGroupingColDef.js +341 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +5 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingSelector.js +18 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +153 -0
- package/node/hooks/features/rowGrouping/index.js +51 -0
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +355 -0
- package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +94 -0
- package/node/hooks/features/treeData/gridTreeDataGroupColDef.js +35 -0
- package/node/hooks/features/treeData/gridTreeDataUtils.js +95 -0
- package/node/hooks/features/treeData/index.js +13 -0
- package/node/hooks/features/treeData/useGridTreeData.js +132 -0
- package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +92 -0
- package/node/hooks/index.js +18 -0
- package/node/hooks/utils/useGridApiContext.js +11 -0
- package/node/hooks/utils/useGridApiRef.js +11 -0
- package/node/hooks/utils/useGridRootProps.js +11 -0
- package/node/index.js +200 -0
- package/node/models/dataGridProProps.js +5 -0
- package/node/models/gridApiPro.js +5 -0
- package/node/models/gridGroupingColDefOverride.js +5 -0
- package/node/models/gridGroupingValueGetterParams.js +5 -0
- package/node/models/gridRowScrollEndParams.js +5 -0
- package/node/models/gridStatePro.js +5 -0
- package/node/models/index.js +44 -0
- package/node/themeAugmentation/index.js +31 -0
- package/node/themeAugmentation/overrides.js +5 -0
- package/node/themeAugmentation/props.js +5 -0
- package/node/typeOverloads/modules.js +5 -0
- package/node/typeOverloads/reexports.js +29 -0
- package/node/utils/domUtils.js +32 -0
- package/node/utils/tree/buildRowTree.js +185 -0
- package/node/utils/tree/sortRowTree.js +69 -0
- package/package.json +10 -12
- package/themeAugmentation/index.d.ts +2 -2
- package/themeAugmentation/index.js +3 -0
- package/themeAugmentation/overrides.d.ts +8 -8
- package/themeAugmentation/overrides.js +1 -0
- package/themeAugmentation/package.json +6 -0
- package/themeAugmentation/props.d.ts +19 -19
- package/themeAugmentation/props.js +1 -0
- package/typeOverloads/modules.d.ts +41 -0
- package/typeOverloads/modules.js +1 -0
- package/typeOverloads/reexports.d.ts +22 -0
- package/typeOverloads/reexports.js +6 -0
- package/utils/domUtils.d.ts +3 -0
- package/utils/domUtils.js +19 -0
- package/utils/tree/buildRowTree.d.ts +47 -0
- package/utils/tree/buildRowTree.js +179 -0
- package/utils/tree/sortRowTree.d.ts +10 -0
- package/utils/tree/sortRowTree.js +60 -0
- package/LICENSE +0 -12
- package/index-cjs.js +0 -15
- package/index-esm.js +0 -15
- package/x-data-grid-pro.d.ts +0 -5495
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GridStatePro } from '../../../models/gridStatePro';
|
|
2
|
+
export declare const gridRowGroupingStateSelector: (state: GridStatePro) => import("./gridRowGroupingInterfaces").GridRowGroupingState;
|
|
3
|
+
export declare const gridRowGroupingModelSelector: import("@mui/x-data-grid").OutputSelector<GridStatePro, import("./gridRowGroupingInterfaces").GridRowGroupingModel>;
|
|
4
|
+
export declare const gridRowGroupingSanitizedModelSelector: import("@mui/x-data-grid").OutputSelector<GridStatePro, string[]>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { gridColumnLookupSelector } from '@mui/x-data-grid';
|
|
2
|
+
import { createSelector } from '@mui/x-data-grid/internals';
|
|
3
|
+
export const gridRowGroupingStateSelector = state => state.rowGrouping;
|
|
4
|
+
export const gridRowGroupingModelSelector = createSelector(gridRowGroupingStateSelector, rowGrouping => rowGrouping.model);
|
|
5
|
+
export const gridRowGroupingSanitizedModelSelector = createSelector(gridRowGroupingModelSelector, gridColumnLookupSelector, (model, columnsLookup) => model.filter(field => !!columnsLookup[field] && columnsLookup[field].groupable));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GridRowTreeConfig, GridFilterState } from '@mui/x-data-grid';
|
|
2
|
+
import { GridAggregatedFilterItemApplier } from '@mui/x-data-grid/internals';
|
|
3
|
+
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
4
|
+
import { GridRowGroupingModel } from './gridRowGroupingInterfaces';
|
|
5
|
+
import { GridStatePro } from '../../../models/gridStatePro';
|
|
6
|
+
export declare const GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = "__row_group_by_columns_group__";
|
|
7
|
+
export declare const GROUPING_COLUMNS_FEATURE_NAME = "grouping-columns";
|
|
8
|
+
export declare const getRowGroupingFieldFromGroupingCriteria: (groupingCriteria: string | null) => string;
|
|
9
|
+
export declare const getRowGroupingCriteriaFromGroupingField: (groupingColDefField: string) => string | null;
|
|
10
|
+
export declare const isGroupingColumn: (field: string) => boolean;
|
|
11
|
+
interface FilterRowTreeFromTreeDataParams {
|
|
12
|
+
rowTree: GridRowTreeConfig;
|
|
13
|
+
isRowMatchingFilters: GridAggregatedFilterItemApplier | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A leaf is visible if it passed the filter
|
|
17
|
+
* A group is visible if all the following criteria are met:
|
|
18
|
+
* - One of its children is passing the filter
|
|
19
|
+
* - It is passing the filter
|
|
20
|
+
*/
|
|
21
|
+
export declare const filterRowTreeFromGroupingColumns: (params: FilterRowTreeFromTreeDataParams) => Omit<GridFilterState, 'filterModel'>;
|
|
22
|
+
export declare const getColDefOverrides: (groupingColDefProp: DataGridProProcessedProps['groupingColDef'], fields: string[]) => import("../../..").GridGroupingColDefOverride | null | undefined;
|
|
23
|
+
export declare const mergeStateWithRowGroupingModel: (rowGroupingModel: GridRowGroupingModel) => (state: GridStatePro) => GridStatePro;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
export const GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = '__row_group_by_columns_group__';
|
|
3
|
+
export const GROUPING_COLUMNS_FEATURE_NAME = 'grouping-columns';
|
|
4
|
+
export const getRowGroupingFieldFromGroupingCriteria = groupingCriteria => {
|
|
5
|
+
if (groupingCriteria === null) {
|
|
6
|
+
return GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return `__row_group_by_columns_group_${groupingCriteria}__`;
|
|
10
|
+
};
|
|
11
|
+
export const getRowGroupingCriteriaFromGroupingField = groupingColDefField => {
|
|
12
|
+
const match = groupingColDefField.match(/^__row_group_by_columns_group_(.*)__$/);
|
|
13
|
+
|
|
14
|
+
if (!match) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return match[1];
|
|
19
|
+
};
|
|
20
|
+
export const isGroupingColumn = field => field === GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD || getRowGroupingCriteriaFromGroupingField(field) !== null;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* When filtering a group, we only want to filter according to the items related to this grouping column.
|
|
24
|
+
*/
|
|
25
|
+
const shouldApplyFilterItemOnGroup = (item, node) => {
|
|
26
|
+
if (item.columnField === GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const groupingCriteriaField = getRowGroupingCriteriaFromGroupingField(item.columnField);
|
|
31
|
+
return groupingCriteriaField === node.groupingField;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* A leaf is visible if it passed the filter
|
|
35
|
+
* A group is visible if all the following criteria are met:
|
|
36
|
+
* - One of its children is passing the filter
|
|
37
|
+
* - It is passing the filter
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
export const filterRowTreeFromGroupingColumns = params => {
|
|
42
|
+
const {
|
|
43
|
+
rowTree,
|
|
44
|
+
isRowMatchingFilters
|
|
45
|
+
} = params;
|
|
46
|
+
const visibleRowsLookup = {};
|
|
47
|
+
const filteredRowsLookup = {};
|
|
48
|
+
const filteredDescendantCountLookup = {};
|
|
49
|
+
|
|
50
|
+
const filterTreeNode = (node, areAncestorsPassingChildren, areAncestorsExpanded) => {
|
|
51
|
+
var _node$children, _node$children2;
|
|
52
|
+
|
|
53
|
+
let isMatchingFilters;
|
|
54
|
+
|
|
55
|
+
if (!isRowMatchingFilters) {
|
|
56
|
+
isMatchingFilters = true;
|
|
57
|
+
} else {
|
|
58
|
+
const shouldApplyItem = node.isAutoGenerated ? item => shouldApplyFilterItemOnGroup(item, node) : undefined;
|
|
59
|
+
isMatchingFilters = isRowMatchingFilters(node.id, shouldApplyItem);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let filteredDescendantCount = 0;
|
|
63
|
+
(_node$children = node.children) == null ? void 0 : _node$children.forEach(childId => {
|
|
64
|
+
const childNode = rowTree[childId];
|
|
65
|
+
const childSubTreeSize = filterTreeNode(childNode, areAncestorsPassingChildren && isMatchingFilters, areAncestorsExpanded && !!node.childrenExpanded);
|
|
66
|
+
filteredDescendantCount += childSubTreeSize;
|
|
67
|
+
});
|
|
68
|
+
let shouldPassFilters;
|
|
69
|
+
|
|
70
|
+
if (!areAncestorsPassingChildren) {
|
|
71
|
+
shouldPassFilters = false;
|
|
72
|
+
} else if ((_node$children2 = node.children) != null && _node$children2.length) {
|
|
73
|
+
shouldPassFilters = isMatchingFilters && filteredDescendantCount > 0;
|
|
74
|
+
} else {
|
|
75
|
+
shouldPassFilters = isMatchingFilters;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
visibleRowsLookup[node.id] = shouldPassFilters && areAncestorsExpanded;
|
|
79
|
+
filteredRowsLookup[node.id] = shouldPassFilters;
|
|
80
|
+
|
|
81
|
+
if (!shouldPassFilters) {
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
filteredDescendantCountLookup[node.id] = filteredDescendantCount;
|
|
86
|
+
|
|
87
|
+
if (!node.children) {
|
|
88
|
+
return filteredDescendantCount + 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return filteredDescendantCount;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const nodes = Object.values(rowTree);
|
|
95
|
+
|
|
96
|
+
for (let i = 0; i < nodes.length; i += 1) {
|
|
97
|
+
const node = nodes[i];
|
|
98
|
+
|
|
99
|
+
if (node.depth === 0) {
|
|
100
|
+
filterTreeNode(node, true, true);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
visibleRowsLookup,
|
|
106
|
+
filteredRowsLookup,
|
|
107
|
+
filteredDescendantCountLookup
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export const getColDefOverrides = (groupingColDefProp, fields) => {
|
|
111
|
+
if (typeof groupingColDefProp === 'function') {
|
|
112
|
+
return groupingColDefProp({
|
|
113
|
+
groupingName: GROUPING_COLUMNS_FEATURE_NAME,
|
|
114
|
+
fields
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return groupingColDefProp;
|
|
119
|
+
};
|
|
120
|
+
export const mergeStateWithRowGroupingModel = rowGroupingModel => state => _extends({}, state, {
|
|
121
|
+
rowGrouping: _extends({}, state.rowGrouping, {
|
|
122
|
+
model: rowGroupingModel
|
|
123
|
+
})
|
|
124
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridStateInitializer } from '@mui/x-data-grid/internals';
|
|
3
|
+
import { GridApiPro } from '../../../models/gridApiPro';
|
|
4
|
+
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
5
|
+
export declare const rowGroupingStateInitializer: GridStateInitializer<Pick<DataGridProProcessedProps, 'rowGroupingModel' | 'initialState'>>;
|
|
6
|
+
/**
|
|
7
|
+
* Only available in DataGridPro
|
|
8
|
+
* @requires useGridColumns (state, method) - can be after, async only
|
|
9
|
+
* @requires useGridRows (state, method) - can be after, async only
|
|
10
|
+
* @requires useGridParamsApi (method) - can be after, async only
|
|
11
|
+
* TODO: Move the the Premium plan once available and remove the `experimentalFeatures.rowGrouping` flag
|
|
12
|
+
*/
|
|
13
|
+
export declare const useGridRowGrouping: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'initialState' | 'rowGroupingModel' | 'onRowGroupingModelChange' | 'defaultGroupingExpansionDepth' | 'isGroupExpandedByDefault' | 'groupingColDef' | 'rowGroupingColumnMode' | 'disableRowGrouping'>) => void;
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Divider from '@mui/material/Divider';
|
|
4
|
+
import { GridEvents, gridRowIdsSelector, gridRowTreeSelector, useGridApiEventHandler, useGridApiMethod, gridColumnLookupSelector, gridFilteredDescendantCountLookupSelector, useFirstRender } from '@mui/x-data-grid';
|
|
5
|
+
import { useGridRegisterPreProcessor, useGridRegisterSortingMethod, useGridRegisterFilteringMethod, isDeepEqual } from '@mui/x-data-grid/internals';
|
|
6
|
+
import { buildRowTree } from '../../../utils/tree/buildRowTree';
|
|
7
|
+
import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from './gridRowGroupingSelector';
|
|
8
|
+
import { filterRowTreeFromGroupingColumns, getRowGroupingFieldFromGroupingCriteria, GROUPING_COLUMNS_FEATURE_NAME, isGroupingColumn, mergeStateWithRowGroupingModel } from './gridRowGroupingUtils';
|
|
9
|
+
import { sortRowTree } from '../../../utils/tree/sortRowTree';
|
|
10
|
+
import { GridRowGroupableColumnMenuItems } from '../../../components/GridRowGroupableColumnMenuItems';
|
|
11
|
+
import { GridRowGroupingColumnMenuItems } from '../../../components/GridRowGroupingColumnMenuItems';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
export const rowGroupingStateInitializer = (state, props) => {
|
|
14
|
+
var _ref, _props$rowGroupingMod, _props$initialState, _props$initialState$r;
|
|
15
|
+
|
|
16
|
+
return _extends({}, state, {
|
|
17
|
+
rowGrouping: {
|
|
18
|
+
model: (_ref = (_props$rowGroupingMod = props.rowGroupingModel) != null ? _props$rowGroupingMod : (_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$r = _props$initialState.rowGrouping) == null ? void 0 : _props$initialState$r.model) != null ? _ref : []
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Only available in DataGridPro
|
|
24
|
+
* @requires useGridColumns (state, method) - can be after, async only
|
|
25
|
+
* @requires useGridRows (state, method) - can be after, async only
|
|
26
|
+
* @requires useGridParamsApi (method) - can be after, async only
|
|
27
|
+
* TODO: Move the the Premium plan once available and remove the `experimentalFeatures.rowGrouping` flag
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export const useGridRowGrouping = (apiRef, props) => {
|
|
31
|
+
apiRef.current.unstable_updateControlState({
|
|
32
|
+
stateId: 'rowGrouping',
|
|
33
|
+
propModel: props.rowGroupingModel,
|
|
34
|
+
propOnChange: props.onRowGroupingModelChange,
|
|
35
|
+
stateSelector: gridRowGroupingModelSelector,
|
|
36
|
+
changeEvent: GridEvents.rowGroupingModelChange
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* ROW GROUPING
|
|
40
|
+
*/
|
|
41
|
+
// Tracks the model on the last pre-processing to check if we need to re-build the grouping columns when the grid upserts a column.
|
|
42
|
+
|
|
43
|
+
const sanitizedModelOnLastRowPreProcessing = React.useRef([]);
|
|
44
|
+
const updateRowGrouping = React.useCallback(() => {
|
|
45
|
+
const groupRows = params => {
|
|
46
|
+
const rowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
47
|
+
const columnsLookup = gridColumnLookupSelector(apiRef);
|
|
48
|
+
sanitizedModelOnLastRowPreProcessing.current = rowGroupingModel;
|
|
49
|
+
|
|
50
|
+
if (props.disableRowGrouping || rowGroupingModel.length === 0) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const distinctValues = Object.fromEntries(rowGroupingModel.map(groupingField => [groupingField, {
|
|
55
|
+
lookup: {},
|
|
56
|
+
list: []
|
|
57
|
+
}]));
|
|
58
|
+
|
|
59
|
+
const getCellGroupingCriteria = ({
|
|
60
|
+
row,
|
|
61
|
+
id,
|
|
62
|
+
colDef
|
|
63
|
+
}) => {
|
|
64
|
+
let key;
|
|
65
|
+
|
|
66
|
+
if (colDef.groupingValueGetter) {
|
|
67
|
+
const groupingValueGetterParams = {
|
|
68
|
+
colDef,
|
|
69
|
+
field: colDef.field,
|
|
70
|
+
value: row[colDef.field],
|
|
71
|
+
id,
|
|
72
|
+
row,
|
|
73
|
+
rowNode: {
|
|
74
|
+
isAutoGenerated: false,
|
|
75
|
+
id
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
key = colDef.groupingValueGetter(groupingValueGetterParams);
|
|
79
|
+
} else {
|
|
80
|
+
key = row[colDef.field];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
key,
|
|
85
|
+
field: colDef.field
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
params.ids.forEach(rowId => {
|
|
90
|
+
const row = params.idRowsLookup[rowId];
|
|
91
|
+
rowGroupingModel.forEach(groupingCriteria => {
|
|
92
|
+
const {
|
|
93
|
+
key
|
|
94
|
+
} = getCellGroupingCriteria({
|
|
95
|
+
row,
|
|
96
|
+
id: rowId,
|
|
97
|
+
colDef: columnsLookup[groupingCriteria]
|
|
98
|
+
});
|
|
99
|
+
const groupingFieldsDistinctKeys = distinctValues[groupingCriteria];
|
|
100
|
+
|
|
101
|
+
if (key != null && !groupingFieldsDistinctKeys.lookup[key.toString()]) {
|
|
102
|
+
groupingFieldsDistinctKeys.lookup[key.toString()] = true;
|
|
103
|
+
groupingFieldsDistinctKeys.list.push(key);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
const rows = params.ids.map(rowId => {
|
|
108
|
+
const row = params.idRowsLookup[rowId];
|
|
109
|
+
const parentPath = rowGroupingModel.map(groupingField => getCellGroupingCriteria({
|
|
110
|
+
row,
|
|
111
|
+
id: rowId,
|
|
112
|
+
colDef: columnsLookup[groupingField]
|
|
113
|
+
})).filter(cell => cell.key != null);
|
|
114
|
+
const leafGroupingCriteria = {
|
|
115
|
+
key: rowId.toString(),
|
|
116
|
+
field: null
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
path: [...parentPath, leafGroupingCriteria],
|
|
120
|
+
id: rowId
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
return buildRowTree(_extends({}, params, {
|
|
124
|
+
rows,
|
|
125
|
+
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
126
|
+
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
127
|
+
groupingName: GROUPING_COLUMNS_FEATURE_NAME
|
|
128
|
+
}));
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return apiRef.current.unstable_registerRowGroupsBuilder('rowGrouping', groupRows);
|
|
132
|
+
}, [apiRef, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault, props.disableRowGrouping]);
|
|
133
|
+
useFirstRender(() => {
|
|
134
|
+
updateRowGrouping();
|
|
135
|
+
});
|
|
136
|
+
const isFirstRender = React.useRef(true);
|
|
137
|
+
React.useEffect(() => {
|
|
138
|
+
if (isFirstRender.current) {
|
|
139
|
+
isFirstRender.current = false;
|
|
140
|
+
return () => {};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return updateRowGrouping();
|
|
144
|
+
}, [updateRowGrouping]);
|
|
145
|
+
/**
|
|
146
|
+
* PRE-PROCESSING
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
const addColumnMenuButtons = React.useCallback((initialValue, columns) => {
|
|
150
|
+
if (props.disableRowGrouping) {
|
|
151
|
+
return initialValue;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
let menuItems;
|
|
155
|
+
|
|
156
|
+
if (isGroupingColumn(columns.field)) {
|
|
157
|
+
menuItems = /*#__PURE__*/_jsx(GridRowGroupingColumnMenuItems, {});
|
|
158
|
+
} else if (columns.groupable) {
|
|
159
|
+
menuItems = /*#__PURE__*/_jsx(GridRowGroupableColumnMenuItems, {});
|
|
160
|
+
} else {
|
|
161
|
+
menuItems = null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (menuItems == null) {
|
|
165
|
+
return initialValue;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return [...initialValue, /*#__PURE__*/_jsx(Divider, {}), menuItems];
|
|
169
|
+
}, [props.disableRowGrouping]);
|
|
170
|
+
const filteringMethod = React.useCallback(params => {
|
|
171
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
172
|
+
return filterRowTreeFromGroupingColumns({
|
|
173
|
+
rowTree,
|
|
174
|
+
isRowMatchingFilters: params.isRowMatchingFilters
|
|
175
|
+
});
|
|
176
|
+
}, [apiRef]);
|
|
177
|
+
const sortingMethod = React.useCallback(params => {
|
|
178
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
179
|
+
const rowIds = gridRowIdsSelector(apiRef);
|
|
180
|
+
return sortRowTree({
|
|
181
|
+
rowTree,
|
|
182
|
+
rowIds,
|
|
183
|
+
sortRowList: params.sortRowList,
|
|
184
|
+
disableChildrenSorting: false
|
|
185
|
+
});
|
|
186
|
+
}, [apiRef]);
|
|
187
|
+
useGridRegisterPreProcessor(apiRef, 'columnMenu', addColumnMenuButtons);
|
|
188
|
+
useGridRegisterFilteringMethod(apiRef, GROUPING_COLUMNS_FEATURE_NAME, filteringMethod);
|
|
189
|
+
useGridRegisterSortingMethod(apiRef, GROUPING_COLUMNS_FEATURE_NAME, sortingMethod);
|
|
190
|
+
/**
|
|
191
|
+
* API METHODS
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
const setRowGroupingModel = React.useCallback(model => {
|
|
195
|
+
const currentModel = gridRowGroupingModelSelector(apiRef);
|
|
196
|
+
|
|
197
|
+
if (currentModel !== model) {
|
|
198
|
+
apiRef.current.setState(mergeStateWithRowGroupingModel(model));
|
|
199
|
+
updateRowGrouping();
|
|
200
|
+
apiRef.current.forceUpdate();
|
|
201
|
+
}
|
|
202
|
+
}, [apiRef, updateRowGrouping]);
|
|
203
|
+
const addRowGroupingCriteria = React.useCallback((field, groupingIndex) => {
|
|
204
|
+
const currentModel = gridRowGroupingModelSelector(apiRef);
|
|
205
|
+
|
|
206
|
+
if (currentModel.includes(field)) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const cleanGroupingIndex = groupingIndex != null ? groupingIndex : currentModel.length;
|
|
211
|
+
const updatedModel = [...currentModel.slice(0, cleanGroupingIndex), field, ...currentModel.slice(cleanGroupingIndex)];
|
|
212
|
+
apiRef.current.setRowGroupingModel(updatedModel);
|
|
213
|
+
}, [apiRef]);
|
|
214
|
+
const removeRowGroupingCriteria = React.useCallback(field => {
|
|
215
|
+
const currentModel = gridRowGroupingModelSelector(apiRef);
|
|
216
|
+
|
|
217
|
+
if (!currentModel.includes(field)) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
apiRef.current.setRowGroupingModel(currentModel.filter(el => el !== field));
|
|
222
|
+
}, [apiRef]);
|
|
223
|
+
const setRowGroupingCriteriaIndex = React.useCallback((field, targetIndex) => {
|
|
224
|
+
const currentModel = gridRowGroupingModelSelector(apiRef);
|
|
225
|
+
const currentTargetIndex = currentModel.indexOf(field);
|
|
226
|
+
|
|
227
|
+
if (currentTargetIndex === -1) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const updatedModel = [...currentModel];
|
|
232
|
+
updatedModel.splice(targetIndex, 0, updatedModel.splice(currentTargetIndex, 1)[0]);
|
|
233
|
+
apiRef.current.setRowGroupingModel(updatedModel);
|
|
234
|
+
}, [apiRef]);
|
|
235
|
+
const rowGroupingApi = {
|
|
236
|
+
setRowGroupingModel,
|
|
237
|
+
addRowGroupingCriteria,
|
|
238
|
+
removeRowGroupingCriteria,
|
|
239
|
+
setRowGroupingCriteriaIndex
|
|
240
|
+
};
|
|
241
|
+
useGridApiMethod(apiRef, rowGroupingApi, 'GridRowGroupingApi');
|
|
242
|
+
/**
|
|
243
|
+
* PRE-PROCESSING
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
247
|
+
if (props.disableRowGrouping) {
|
|
248
|
+
return prevState;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const rowGroupingModelToExport = gridRowGroupingModelSelector(apiRef);
|
|
252
|
+
|
|
253
|
+
if (rowGroupingModelToExport.length === 0) {
|
|
254
|
+
return prevState;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return _extends({}, prevState, {
|
|
258
|
+
rowGrouping: {
|
|
259
|
+
model: rowGroupingModelToExport
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}, [apiRef, props.disableRowGrouping]);
|
|
263
|
+
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
264
|
+
var _context$stateToResto;
|
|
265
|
+
|
|
266
|
+
if (props.disableRowGrouping) {
|
|
267
|
+
return params;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const rowGroupingModel = (_context$stateToResto = context.stateToRestore.rowGrouping) == null ? void 0 : _context$stateToResto.model;
|
|
271
|
+
|
|
272
|
+
if (rowGroupingModel != null) {
|
|
273
|
+
apiRef.current.setState(mergeStateWithRowGroupingModel(rowGroupingModel));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return params;
|
|
277
|
+
}, [apiRef, props.disableRowGrouping]);
|
|
278
|
+
useGridRegisterPreProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
279
|
+
useGridRegisterPreProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
280
|
+
/**
|
|
281
|
+
* EVENTS
|
|
282
|
+
*/
|
|
283
|
+
|
|
284
|
+
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
285
|
+
const cellParams = apiRef.current.getCellParams(params.id, params.field);
|
|
286
|
+
|
|
287
|
+
if (isGroupingColumn(cellParams.field) && event.key === ' ' && !event.shiftKey) {
|
|
288
|
+
var _gridFilteredDescenda;
|
|
289
|
+
|
|
290
|
+
event.stopPropagation();
|
|
291
|
+
event.preventDefault();
|
|
292
|
+
const filteredDescendantCount = (_gridFilteredDescenda = gridFilteredDescendantCountLookupSelector(apiRef)[params.id]) != null ? _gridFilteredDescenda : 0;
|
|
293
|
+
const isOnGroupingCell = props.rowGroupingColumnMode === 'single' || getRowGroupingFieldFromGroupingCriteria(params.rowNode.groupingField) === params.field;
|
|
294
|
+
|
|
295
|
+
if (!isOnGroupingCell || filteredDescendantCount === 0) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
apiRef.current.setRowChildrenExpansion(params.id, !params.rowNode.childrenExpanded);
|
|
300
|
+
}
|
|
301
|
+
}, [apiRef, props.rowGroupingColumnMode]);
|
|
302
|
+
const checkGroupingColumnsModelDiff = React.useCallback(() => {
|
|
303
|
+
const rowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
304
|
+
const lastGroupingColumnsModelApplied = sanitizedModelOnLastRowPreProcessing.current;
|
|
305
|
+
|
|
306
|
+
if (!isDeepEqual(lastGroupingColumnsModelApplied, rowGroupingModel)) {
|
|
307
|
+
sanitizedModelOnLastRowPreProcessing.current = rowGroupingModel; // Refresh the column pre-processing
|
|
308
|
+
|
|
309
|
+
apiRef.current.updateColumns([]);
|
|
310
|
+
updateRowGrouping();
|
|
311
|
+
}
|
|
312
|
+
}, [apiRef, updateRowGrouping]);
|
|
313
|
+
useGridApiEventHandler(apiRef, GridEvents.cellKeyDown, handleCellKeyDown);
|
|
314
|
+
useGridApiEventHandler(apiRef, GridEvents.columnsChange, checkGroupingColumnsModelDiff);
|
|
315
|
+
useGridApiEventHandler(apiRef, GridEvents.rowGroupingModelChange, checkGroupingColumnsModelDiff);
|
|
316
|
+
/**
|
|
317
|
+
* EFFECTS
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
React.useEffect(() => {
|
|
321
|
+
if (props.rowGroupingModel !== undefined) {
|
|
322
|
+
apiRef.current.setRowGroupingModel(props.rowGroupingModel);
|
|
323
|
+
}
|
|
324
|
+
}, [apiRef, props.rowGroupingModel]);
|
|
325
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
3
|
+
import { GridApiPro } from '../../../models/gridApiPro';
|
|
4
|
+
export declare const useGridRowGroupingPreProcessors: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'disableRowGrouping' | 'groupingColDef' | 'rowGroupingColumnMode'>) => void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
|
|
3
|
+
import { gridRowGroupingModelSelector } from './gridRowGroupingSelector';
|
|
4
|
+
import { createGroupingColDefForAllGroupingCriteria, createGroupingColDefForOneGroupingCriteria } from './createGroupingColDef';
|
|
5
|
+
import { getColDefOverrides, isGroupingColumn } from './gridRowGroupingUtils';
|
|
6
|
+
export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
7
|
+
const getGroupingColDefs = React.useCallback(columnsState => {
|
|
8
|
+
if (props.disableRowGrouping) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const groupingColDefProp = props.groupingColDef; // We can't use `gridGroupingRowsSanitizedModelSelector` here because the new columns are not in the state yet
|
|
13
|
+
|
|
14
|
+
const rowGroupingModel = gridRowGroupingModelSelector(apiRef).filter(field => !!columnsState.lookup[field]);
|
|
15
|
+
|
|
16
|
+
if (rowGroupingModel.length === 0) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
switch (props.rowGroupingColumnMode) {
|
|
21
|
+
case 'single':
|
|
22
|
+
{
|
|
23
|
+
return [createGroupingColDefForAllGroupingCriteria({
|
|
24
|
+
apiRef,
|
|
25
|
+
rowGroupingModel,
|
|
26
|
+
colDefOverride: getColDefOverrides(groupingColDefProp, rowGroupingModel),
|
|
27
|
+
columnsLookup: columnsState.lookup
|
|
28
|
+
})];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
case 'multiple':
|
|
32
|
+
{
|
|
33
|
+
return rowGroupingModel.map(groupingCriteria => createGroupingColDefForOneGroupingCriteria({
|
|
34
|
+
groupingCriteria,
|
|
35
|
+
colDefOverride: getColDefOverrides(groupingColDefProp, [groupingCriteria]),
|
|
36
|
+
groupedByColDef: columnsState.lookup[groupingCriteria],
|
|
37
|
+
columnsLookup: columnsState.lookup
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
default:
|
|
42
|
+
{
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, [apiRef, props.groupingColDef, props.rowGroupingColumnMode, props.disableRowGrouping]);
|
|
47
|
+
const updateGroupingColumn = React.useCallback(columnsState => {
|
|
48
|
+
const groupingColDefs = getGroupingColDefs(columnsState);
|
|
49
|
+
let newColumnFields = [];
|
|
50
|
+
const newColumnsLookup = {}; // We only keep the non-grouping columns
|
|
51
|
+
|
|
52
|
+
columnsState.all.forEach(field => {
|
|
53
|
+
if (!isGroupingColumn(field)) {
|
|
54
|
+
newColumnFields.push(field);
|
|
55
|
+
newColumnsLookup[field] = columnsState.lookup[field];
|
|
56
|
+
}
|
|
57
|
+
}); // We add the grouping column
|
|
58
|
+
|
|
59
|
+
groupingColDefs.forEach(groupingColDef => {
|
|
60
|
+
const matchingGroupingColDef = columnsState.lookup[groupingColDef.field];
|
|
61
|
+
|
|
62
|
+
if (matchingGroupingColDef) {
|
|
63
|
+
groupingColDef.width = matchingGroupingColDef.width;
|
|
64
|
+
groupingColDef.flex = matchingGroupingColDef.flex;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
newColumnsLookup[groupingColDef.field] = groupingColDef;
|
|
68
|
+
});
|
|
69
|
+
const startIndex = newColumnFields[0] === '__check__' ? 1 : 0;
|
|
70
|
+
newColumnFields = [...newColumnFields.slice(0, startIndex), ...groupingColDefs.map(colDef => colDef.field), ...newColumnFields.slice(startIndex)];
|
|
71
|
+
columnsState.all = newColumnFields;
|
|
72
|
+
columnsState.lookup = newColumnsLookup;
|
|
73
|
+
return columnsState;
|
|
74
|
+
}, [getGroupingColDefs]);
|
|
75
|
+
useGridRegisterPreProcessor(apiRef, 'hydrateColumns', updateGroupingColumn);
|
|
76
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GridColDef } from '@mui/x-data-grid';
|
|
2
|
+
/**
|
|
3
|
+
* TODO: Add sorting and filtering on the value and the filteredDescendantCount
|
|
4
|
+
*/
|
|
5
|
+
export declare const GRID_TREE_DATA_GROUPING_COL_DEF: Omit<GridColDef, 'field' | 'editable'>;
|
|
6
|
+
export declare const GRID_TREE_DATA_GROUPING_FIELD = "__tree_data_group__";
|
|
7
|
+
export declare const GRID_TREE_DATA_GROUPING_COL_DEF_FORCED_PROPERTIES: Pick<GridColDef, 'field' | 'editable' | 'groupable'>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { GRID_STRING_COL_DEF } from '@mui/x-data-grid';
|
|
3
|
+
/**
|
|
4
|
+
* TODO: Add sorting and filtering on the value and the filteredDescendantCount
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const GRID_TREE_DATA_GROUPING_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
8
|
+
type: 'treeDataGroup',
|
|
9
|
+
sortable: false,
|
|
10
|
+
filterable: false,
|
|
11
|
+
disableColumnMenu: true,
|
|
12
|
+
disableReorder: true,
|
|
13
|
+
align: 'left',
|
|
14
|
+
width: 200,
|
|
15
|
+
valueGetter: params => params.rowNode.groupingKey
|
|
16
|
+
});
|
|
17
|
+
export const GRID_TREE_DATA_GROUPING_FIELD = '__tree_data_group__';
|
|
18
|
+
export const GRID_TREE_DATA_GROUPING_COL_DEF_FORCED_PROPERTIES = {
|
|
19
|
+
field: GRID_TREE_DATA_GROUPING_FIELD,
|
|
20
|
+
editable: false,
|
|
21
|
+
groupable: false
|
|
22
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GridRowTreeConfig, GridFilterState } from '@mui/x-data-grid';
|
|
2
|
+
import { GridAggregatedFilterItemApplier } from '@mui/x-data-grid/internals';
|
|
3
|
+
interface FilterRowTreeFromTreeDataParams {
|
|
4
|
+
rowTree: GridRowTreeConfig;
|
|
5
|
+
disableChildrenFiltering: boolean;
|
|
6
|
+
isRowMatchingFilters: GridAggregatedFilterItemApplier | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A node is visible if one of the following criteria is met:
|
|
10
|
+
* - One of its children is passing the filter
|
|
11
|
+
* - It is passing the filter
|
|
12
|
+
*/
|
|
13
|
+
export declare const filterRowTreeFromTreeData: (params: FilterRowTreeFromTreeDataParams) => Omit<GridFilterState, 'filterModel'>;
|
|
14
|
+
export {};
|