@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,334 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import Divider from '@mui/material/Divider';
|
|
5
|
+
import { GridEvents, gridRowIdsSelector, gridRowTreeSelector, useGridApiEventHandler, useGridApiMethod, gridColumnLookupSelector, gridFilteredDescendantCountLookupSelector, useFirstRender } from '@mui/x-data-grid';
|
|
6
|
+
import { useGridRegisterPreProcessor, useGridRegisterSortingMethod, useGridRegisterFilteringMethod, isDeepEqual } from '@mui/x-data-grid/internals';
|
|
7
|
+
import { buildRowTree } from '../../../utils/tree/buildRowTree';
|
|
8
|
+
import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from './gridRowGroupingSelector';
|
|
9
|
+
import { filterRowTreeFromGroupingColumns, getRowGroupingFieldFromGroupingCriteria, GROUPING_COLUMNS_FEATURE_NAME, isGroupingColumn, mergeStateWithRowGroupingModel } from './gridRowGroupingUtils';
|
|
10
|
+
import { sortRowTree } from '../../../utils/tree/sortRowTree';
|
|
11
|
+
import { GridRowGroupableColumnMenuItems } from '../../../components/GridRowGroupableColumnMenuItems';
|
|
12
|
+
import { GridRowGroupingColumnMenuItems } from '../../../components/GridRowGroupingColumnMenuItems';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
export var rowGroupingStateInitializer = function rowGroupingStateInitializer(state, props) {
|
|
15
|
+
var _ref, _props$rowGroupingMod, _props$initialState, _props$initialState$r;
|
|
16
|
+
|
|
17
|
+
return _extends({}, state, {
|
|
18
|
+
rowGrouping: {
|
|
19
|
+
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 : []
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Only available in DataGridPro
|
|
25
|
+
* @requires useGridColumns (state, method) - can be after, async only
|
|
26
|
+
* @requires useGridRows (state, method) - can be after, async only
|
|
27
|
+
* @requires useGridParamsApi (method) - can be after, async only
|
|
28
|
+
* TODO: Move the the Premium plan once available and remove the `experimentalFeatures.rowGrouping` flag
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
export var useGridRowGrouping = function useGridRowGrouping(apiRef, props) {
|
|
32
|
+
apiRef.current.unstable_updateControlState({
|
|
33
|
+
stateId: 'rowGrouping',
|
|
34
|
+
propModel: props.rowGroupingModel,
|
|
35
|
+
propOnChange: props.onRowGroupingModelChange,
|
|
36
|
+
stateSelector: gridRowGroupingModelSelector,
|
|
37
|
+
changeEvent: GridEvents.rowGroupingModelChange
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* ROW GROUPING
|
|
41
|
+
*/
|
|
42
|
+
// 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.
|
|
43
|
+
|
|
44
|
+
var sanitizedModelOnLastRowPreProcessing = React.useRef([]);
|
|
45
|
+
var updateRowGrouping = React.useCallback(function () {
|
|
46
|
+
var groupRows = function groupRows(params) {
|
|
47
|
+
var rowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
48
|
+
var columnsLookup = gridColumnLookupSelector(apiRef);
|
|
49
|
+
sanitizedModelOnLastRowPreProcessing.current = rowGroupingModel;
|
|
50
|
+
|
|
51
|
+
if (props.disableRowGrouping || rowGroupingModel.length === 0) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var distinctValues = Object.fromEntries(rowGroupingModel.map(function (groupingField) {
|
|
56
|
+
return [groupingField, {
|
|
57
|
+
lookup: {},
|
|
58
|
+
list: []
|
|
59
|
+
}];
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
var getCellGroupingCriteria = function getCellGroupingCriteria(_ref2) {
|
|
63
|
+
var row = _ref2.row,
|
|
64
|
+
id = _ref2.id,
|
|
65
|
+
colDef = _ref2.colDef;
|
|
66
|
+
var key;
|
|
67
|
+
|
|
68
|
+
if (colDef.groupingValueGetter) {
|
|
69
|
+
var groupingValueGetterParams = {
|
|
70
|
+
colDef: colDef,
|
|
71
|
+
field: colDef.field,
|
|
72
|
+
value: row[colDef.field],
|
|
73
|
+
id: id,
|
|
74
|
+
row: row,
|
|
75
|
+
rowNode: {
|
|
76
|
+
isAutoGenerated: false,
|
|
77
|
+
id: id
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
key = colDef.groupingValueGetter(groupingValueGetterParams);
|
|
81
|
+
} else {
|
|
82
|
+
key = row[colDef.field];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
key: key,
|
|
87
|
+
field: colDef.field
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
params.ids.forEach(function (rowId) {
|
|
92
|
+
var row = params.idRowsLookup[rowId];
|
|
93
|
+
rowGroupingModel.forEach(function (groupingCriteria) {
|
|
94
|
+
var _getCellGroupingCrite = getCellGroupingCriteria({
|
|
95
|
+
row: row,
|
|
96
|
+
id: rowId,
|
|
97
|
+
colDef: columnsLookup[groupingCriteria]
|
|
98
|
+
}),
|
|
99
|
+
key = _getCellGroupingCrite.key;
|
|
100
|
+
|
|
101
|
+
var groupingFieldsDistinctKeys = distinctValues[groupingCriteria];
|
|
102
|
+
|
|
103
|
+
if (key != null && !groupingFieldsDistinctKeys.lookup[key.toString()]) {
|
|
104
|
+
groupingFieldsDistinctKeys.lookup[key.toString()] = true;
|
|
105
|
+
groupingFieldsDistinctKeys.list.push(key);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
var rows = params.ids.map(function (rowId) {
|
|
110
|
+
var row = params.idRowsLookup[rowId];
|
|
111
|
+
var parentPath = rowGroupingModel.map(function (groupingField) {
|
|
112
|
+
return getCellGroupingCriteria({
|
|
113
|
+
row: row,
|
|
114
|
+
id: rowId,
|
|
115
|
+
colDef: columnsLookup[groupingField]
|
|
116
|
+
});
|
|
117
|
+
}).filter(function (cell) {
|
|
118
|
+
return cell.key != null;
|
|
119
|
+
});
|
|
120
|
+
var leafGroupingCriteria = {
|
|
121
|
+
key: rowId.toString(),
|
|
122
|
+
field: null
|
|
123
|
+
};
|
|
124
|
+
return {
|
|
125
|
+
path: [].concat(_toConsumableArray(parentPath), [leafGroupingCriteria]),
|
|
126
|
+
id: rowId
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
return buildRowTree(_extends({}, params, {
|
|
130
|
+
rows: rows,
|
|
131
|
+
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
132
|
+
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
133
|
+
groupingName: GROUPING_COLUMNS_FEATURE_NAME
|
|
134
|
+
}));
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return apiRef.current.unstable_registerRowGroupsBuilder('rowGrouping', groupRows);
|
|
138
|
+
}, [apiRef, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault, props.disableRowGrouping]);
|
|
139
|
+
useFirstRender(function () {
|
|
140
|
+
updateRowGrouping();
|
|
141
|
+
});
|
|
142
|
+
var isFirstRender = React.useRef(true);
|
|
143
|
+
React.useEffect(function () {
|
|
144
|
+
if (isFirstRender.current) {
|
|
145
|
+
isFirstRender.current = false;
|
|
146
|
+
return function () {};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return updateRowGrouping();
|
|
150
|
+
}, [updateRowGrouping]);
|
|
151
|
+
/**
|
|
152
|
+
* PRE-PROCESSING
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
var addColumnMenuButtons = React.useCallback(function (initialValue, columns) {
|
|
156
|
+
if (props.disableRowGrouping) {
|
|
157
|
+
return initialValue;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
var menuItems;
|
|
161
|
+
|
|
162
|
+
if (isGroupingColumn(columns.field)) {
|
|
163
|
+
menuItems = /*#__PURE__*/_jsx(GridRowGroupingColumnMenuItems, {});
|
|
164
|
+
} else if (columns.groupable) {
|
|
165
|
+
menuItems = /*#__PURE__*/_jsx(GridRowGroupableColumnMenuItems, {});
|
|
166
|
+
} else {
|
|
167
|
+
menuItems = null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (menuItems == null) {
|
|
171
|
+
return initialValue;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return [].concat(_toConsumableArray(initialValue), [/*#__PURE__*/_jsx(Divider, {}), menuItems]);
|
|
175
|
+
}, [props.disableRowGrouping]);
|
|
176
|
+
var filteringMethod = React.useCallback(function (params) {
|
|
177
|
+
var rowTree = gridRowTreeSelector(apiRef);
|
|
178
|
+
return filterRowTreeFromGroupingColumns({
|
|
179
|
+
rowTree: rowTree,
|
|
180
|
+
isRowMatchingFilters: params.isRowMatchingFilters
|
|
181
|
+
});
|
|
182
|
+
}, [apiRef]);
|
|
183
|
+
var sortingMethod = React.useCallback(function (params) {
|
|
184
|
+
var rowTree = gridRowTreeSelector(apiRef);
|
|
185
|
+
var rowIds = gridRowIdsSelector(apiRef);
|
|
186
|
+
return sortRowTree({
|
|
187
|
+
rowTree: rowTree,
|
|
188
|
+
rowIds: rowIds,
|
|
189
|
+
sortRowList: params.sortRowList,
|
|
190
|
+
disableChildrenSorting: false
|
|
191
|
+
});
|
|
192
|
+
}, [apiRef]);
|
|
193
|
+
useGridRegisterPreProcessor(apiRef, 'columnMenu', addColumnMenuButtons);
|
|
194
|
+
useGridRegisterFilteringMethod(apiRef, GROUPING_COLUMNS_FEATURE_NAME, filteringMethod);
|
|
195
|
+
useGridRegisterSortingMethod(apiRef, GROUPING_COLUMNS_FEATURE_NAME, sortingMethod);
|
|
196
|
+
/**
|
|
197
|
+
* API METHODS
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
var setRowGroupingModel = React.useCallback(function (model) {
|
|
201
|
+
var currentModel = gridRowGroupingModelSelector(apiRef);
|
|
202
|
+
|
|
203
|
+
if (currentModel !== model) {
|
|
204
|
+
apiRef.current.setState(mergeStateWithRowGroupingModel(model));
|
|
205
|
+
updateRowGrouping();
|
|
206
|
+
apiRef.current.forceUpdate();
|
|
207
|
+
}
|
|
208
|
+
}, [apiRef, updateRowGrouping]);
|
|
209
|
+
var addRowGroupingCriteria = React.useCallback(function (field, groupingIndex) {
|
|
210
|
+
var currentModel = gridRowGroupingModelSelector(apiRef);
|
|
211
|
+
|
|
212
|
+
if (currentModel.includes(field)) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
var cleanGroupingIndex = groupingIndex != null ? groupingIndex : currentModel.length;
|
|
217
|
+
var updatedModel = [].concat(_toConsumableArray(currentModel.slice(0, cleanGroupingIndex)), [field], _toConsumableArray(currentModel.slice(cleanGroupingIndex)));
|
|
218
|
+
apiRef.current.setRowGroupingModel(updatedModel);
|
|
219
|
+
}, [apiRef]);
|
|
220
|
+
var removeRowGroupingCriteria = React.useCallback(function (field) {
|
|
221
|
+
var currentModel = gridRowGroupingModelSelector(apiRef);
|
|
222
|
+
|
|
223
|
+
if (!currentModel.includes(field)) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
apiRef.current.setRowGroupingModel(currentModel.filter(function (el) {
|
|
228
|
+
return el !== field;
|
|
229
|
+
}));
|
|
230
|
+
}, [apiRef]);
|
|
231
|
+
var setRowGroupingCriteriaIndex = React.useCallback(function (field, targetIndex) {
|
|
232
|
+
var currentModel = gridRowGroupingModelSelector(apiRef);
|
|
233
|
+
var currentTargetIndex = currentModel.indexOf(field);
|
|
234
|
+
|
|
235
|
+
if (currentTargetIndex === -1) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
var updatedModel = _toConsumableArray(currentModel);
|
|
240
|
+
|
|
241
|
+
updatedModel.splice(targetIndex, 0, updatedModel.splice(currentTargetIndex, 1)[0]);
|
|
242
|
+
apiRef.current.setRowGroupingModel(updatedModel);
|
|
243
|
+
}, [apiRef]);
|
|
244
|
+
var rowGroupingApi = {
|
|
245
|
+
setRowGroupingModel: setRowGroupingModel,
|
|
246
|
+
addRowGroupingCriteria: addRowGroupingCriteria,
|
|
247
|
+
removeRowGroupingCriteria: removeRowGroupingCriteria,
|
|
248
|
+
setRowGroupingCriteriaIndex: setRowGroupingCriteriaIndex
|
|
249
|
+
};
|
|
250
|
+
useGridApiMethod(apiRef, rowGroupingApi, 'GridRowGroupingApi');
|
|
251
|
+
/**
|
|
252
|
+
* PRE-PROCESSING
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
var stateExportPreProcessing = React.useCallback(function (prevState) {
|
|
256
|
+
if (props.disableRowGrouping) {
|
|
257
|
+
return prevState;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
var rowGroupingModelToExport = gridRowGroupingModelSelector(apiRef);
|
|
261
|
+
|
|
262
|
+
if (rowGroupingModelToExport.length === 0) {
|
|
263
|
+
return prevState;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return _extends({}, prevState, {
|
|
267
|
+
rowGrouping: {
|
|
268
|
+
model: rowGroupingModelToExport
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}, [apiRef, props.disableRowGrouping]);
|
|
272
|
+
var stateRestorePreProcessing = React.useCallback(function (params, context) {
|
|
273
|
+
var _context$stateToResto;
|
|
274
|
+
|
|
275
|
+
if (props.disableRowGrouping) {
|
|
276
|
+
return params;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
var rowGroupingModel = (_context$stateToResto = context.stateToRestore.rowGrouping) == null ? void 0 : _context$stateToResto.model;
|
|
280
|
+
|
|
281
|
+
if (rowGroupingModel != null) {
|
|
282
|
+
apiRef.current.setState(mergeStateWithRowGroupingModel(rowGroupingModel));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return params;
|
|
286
|
+
}, [apiRef, props.disableRowGrouping]);
|
|
287
|
+
useGridRegisterPreProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
288
|
+
useGridRegisterPreProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
289
|
+
/**
|
|
290
|
+
* EVENTS
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
var handleCellKeyDown = React.useCallback(function (params, event) {
|
|
294
|
+
var cellParams = apiRef.current.getCellParams(params.id, params.field);
|
|
295
|
+
|
|
296
|
+
if (isGroupingColumn(cellParams.field) && event.key === ' ' && !event.shiftKey) {
|
|
297
|
+
var _gridFilteredDescenda;
|
|
298
|
+
|
|
299
|
+
event.stopPropagation();
|
|
300
|
+
event.preventDefault();
|
|
301
|
+
var filteredDescendantCount = (_gridFilteredDescenda = gridFilteredDescendantCountLookupSelector(apiRef)[params.id]) != null ? _gridFilteredDescenda : 0;
|
|
302
|
+
var isOnGroupingCell = props.rowGroupingColumnMode === 'single' || getRowGroupingFieldFromGroupingCriteria(params.rowNode.groupingField) === params.field;
|
|
303
|
+
|
|
304
|
+
if (!isOnGroupingCell || filteredDescendantCount === 0) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
apiRef.current.setRowChildrenExpansion(params.id, !params.rowNode.childrenExpanded);
|
|
309
|
+
}
|
|
310
|
+
}, [apiRef, props.rowGroupingColumnMode]);
|
|
311
|
+
var checkGroupingColumnsModelDiff = React.useCallback(function () {
|
|
312
|
+
var rowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
313
|
+
var lastGroupingColumnsModelApplied = sanitizedModelOnLastRowPreProcessing.current;
|
|
314
|
+
|
|
315
|
+
if (!isDeepEqual(lastGroupingColumnsModelApplied, rowGroupingModel)) {
|
|
316
|
+
sanitizedModelOnLastRowPreProcessing.current = rowGroupingModel; // Refresh the column pre-processing
|
|
317
|
+
|
|
318
|
+
apiRef.current.updateColumns([]);
|
|
319
|
+
updateRowGrouping();
|
|
320
|
+
}
|
|
321
|
+
}, [apiRef, updateRowGrouping]);
|
|
322
|
+
useGridApiEventHandler(apiRef, GridEvents.cellKeyDown, handleCellKeyDown);
|
|
323
|
+
useGridApiEventHandler(apiRef, GridEvents.columnsChange, checkGroupingColumnsModelDiff);
|
|
324
|
+
useGridApiEventHandler(apiRef, GridEvents.rowGroupingModelChange, checkGroupingColumnsModelDiff);
|
|
325
|
+
/**
|
|
326
|
+
* EFFECTS
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
React.useEffect(function () {
|
|
330
|
+
if (props.rowGroupingModel !== undefined) {
|
|
331
|
+
apiRef.current.setRowGroupingModel(props.rowGroupingModel);
|
|
332
|
+
}
|
|
333
|
+
}, [apiRef, props.rowGroupingModel]);
|
|
334
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
|
|
4
|
+
import { gridRowGroupingModelSelector } from './gridRowGroupingSelector';
|
|
5
|
+
import { createGroupingColDefForAllGroupingCriteria, createGroupingColDefForOneGroupingCriteria } from './createGroupingColDef';
|
|
6
|
+
import { getColDefOverrides, isGroupingColumn } from './gridRowGroupingUtils';
|
|
7
|
+
export var useGridRowGroupingPreProcessors = function useGridRowGroupingPreProcessors(apiRef, props) {
|
|
8
|
+
var getGroupingColDefs = React.useCallback(function (columnsState) {
|
|
9
|
+
if (props.disableRowGrouping) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
var groupingColDefProp = props.groupingColDef; // We can't use `gridGroupingRowsSanitizedModelSelector` here because the new columns are not in the state yet
|
|
14
|
+
|
|
15
|
+
var rowGroupingModel = gridRowGroupingModelSelector(apiRef).filter(function (field) {
|
|
16
|
+
return !!columnsState.lookup[field];
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (rowGroupingModel.length === 0) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
switch (props.rowGroupingColumnMode) {
|
|
24
|
+
case 'single':
|
|
25
|
+
{
|
|
26
|
+
return [createGroupingColDefForAllGroupingCriteria({
|
|
27
|
+
apiRef: apiRef,
|
|
28
|
+
rowGroupingModel: rowGroupingModel,
|
|
29
|
+
colDefOverride: getColDefOverrides(groupingColDefProp, rowGroupingModel),
|
|
30
|
+
columnsLookup: columnsState.lookup
|
|
31
|
+
})];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
case 'multiple':
|
|
35
|
+
{
|
|
36
|
+
return rowGroupingModel.map(function (groupingCriteria) {
|
|
37
|
+
return createGroupingColDefForOneGroupingCriteria({
|
|
38
|
+
groupingCriteria: groupingCriteria,
|
|
39
|
+
colDefOverride: getColDefOverrides(groupingColDefProp, [groupingCriteria]),
|
|
40
|
+
groupedByColDef: columnsState.lookup[groupingCriteria],
|
|
41
|
+
columnsLookup: columnsState.lookup
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
default:
|
|
47
|
+
{
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}, [apiRef, props.groupingColDef, props.rowGroupingColumnMode, props.disableRowGrouping]);
|
|
52
|
+
var updateGroupingColumn = React.useCallback(function (columnsState) {
|
|
53
|
+
var groupingColDefs = getGroupingColDefs(columnsState);
|
|
54
|
+
var newColumnFields = [];
|
|
55
|
+
var newColumnsLookup = {}; // We only keep the non-grouping columns
|
|
56
|
+
|
|
57
|
+
columnsState.all.forEach(function (field) {
|
|
58
|
+
if (!isGroupingColumn(field)) {
|
|
59
|
+
newColumnFields.push(field);
|
|
60
|
+
newColumnsLookup[field] = columnsState.lookup[field];
|
|
61
|
+
}
|
|
62
|
+
}); // We add the grouping column
|
|
63
|
+
|
|
64
|
+
groupingColDefs.forEach(function (groupingColDef) {
|
|
65
|
+
var matchingGroupingColDef = columnsState.lookup[groupingColDef.field];
|
|
66
|
+
|
|
67
|
+
if (matchingGroupingColDef) {
|
|
68
|
+
groupingColDef.width = matchingGroupingColDef.width;
|
|
69
|
+
groupingColDef.flex = matchingGroupingColDef.flex;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
newColumnsLookup[groupingColDef.field] = groupingColDef;
|
|
73
|
+
});
|
|
74
|
+
var startIndex = newColumnFields[0] === '__check__' ? 1 : 0;
|
|
75
|
+
newColumnFields = [].concat(_toConsumableArray(newColumnFields.slice(0, startIndex)), _toConsumableArray(groupingColDefs.map(function (colDef) {
|
|
76
|
+
return colDef.field;
|
|
77
|
+
})), _toConsumableArray(newColumnFields.slice(startIndex)));
|
|
78
|
+
columnsState.all = newColumnFields;
|
|
79
|
+
columnsState.lookup = newColumnsLookup;
|
|
80
|
+
return columnsState;
|
|
81
|
+
}, [getGroupingColDefs]);
|
|
82
|
+
useGridRegisterPreProcessor(apiRef, 'hydrateColumns', updateGroupingColumn);
|
|
83
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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 var 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: function valueGetter(params) {
|
|
16
|
+
return params.rowNode.groupingKey;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
export var GRID_TREE_DATA_GROUPING_FIELD = '__tree_data_group__';
|
|
20
|
+
export var GRID_TREE_DATA_GROUPING_COL_DEF_FORCED_PROPERTIES = {
|
|
21
|
+
field: GRID_TREE_DATA_GROUPING_FIELD,
|
|
22
|
+
editable: false,
|
|
23
|
+
groupable: false
|
|
24
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A node is visible if one of the following criteria is met:
|
|
3
|
+
* - One of its children is passing the filter
|
|
4
|
+
* - It is passing the filter
|
|
5
|
+
*/
|
|
6
|
+
export var filterRowTreeFromTreeData = function filterRowTreeFromTreeData(params) {
|
|
7
|
+
var rowTree = params.rowTree,
|
|
8
|
+
disableChildrenFiltering = params.disableChildrenFiltering,
|
|
9
|
+
isRowMatchingFilters = params.isRowMatchingFilters;
|
|
10
|
+
var visibleRowsLookup = {};
|
|
11
|
+
var filteredRowsLookup = {};
|
|
12
|
+
var filteredDescendantCountLookup = {};
|
|
13
|
+
|
|
14
|
+
var filterTreeNode = function filterTreeNode(node, isParentMatchingFilters, areAncestorsExpanded) {
|
|
15
|
+
var _node$children;
|
|
16
|
+
|
|
17
|
+
var shouldSkipFilters = disableChildrenFiltering && node.depth > 0;
|
|
18
|
+
var isMatchingFilters;
|
|
19
|
+
|
|
20
|
+
if (shouldSkipFilters) {
|
|
21
|
+
isMatchingFilters = null;
|
|
22
|
+
} else if (!isRowMatchingFilters) {
|
|
23
|
+
isMatchingFilters = true;
|
|
24
|
+
} else {
|
|
25
|
+
isMatchingFilters = isRowMatchingFilters(node.id);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var filteredDescendantCount = 0;
|
|
29
|
+
(_node$children = node.children) == null ? void 0 : _node$children.forEach(function (childId) {
|
|
30
|
+
var _isMatchingFilters;
|
|
31
|
+
|
|
32
|
+
var childNode = rowTree[childId];
|
|
33
|
+
var childSubTreeSize = filterTreeNode(childNode, (_isMatchingFilters = isMatchingFilters) != null ? _isMatchingFilters : isParentMatchingFilters, areAncestorsExpanded && !!node.childrenExpanded);
|
|
34
|
+
filteredDescendantCount += childSubTreeSize;
|
|
35
|
+
});
|
|
36
|
+
var shouldPassFilters;
|
|
37
|
+
|
|
38
|
+
switch (isMatchingFilters) {
|
|
39
|
+
case true:
|
|
40
|
+
{
|
|
41
|
+
shouldPassFilters = true;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
case false:
|
|
46
|
+
{
|
|
47
|
+
shouldPassFilters = filteredDescendantCount > 0;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
default:
|
|
52
|
+
{
|
|
53
|
+
shouldPassFilters = isParentMatchingFilters;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
visibleRowsLookup[node.id] = shouldPassFilters && areAncestorsExpanded;
|
|
59
|
+
filteredRowsLookup[node.id] = shouldPassFilters;
|
|
60
|
+
|
|
61
|
+
if (!shouldPassFilters) {
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
filteredDescendantCountLookup[node.id] = filteredDescendantCount;
|
|
66
|
+
return filteredDescendantCount + 1;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
var nodes = Object.values(rowTree);
|
|
70
|
+
|
|
71
|
+
for (var i = 0; i < nodes.length; i += 1) {
|
|
72
|
+
var node = nodes[i];
|
|
73
|
+
|
|
74
|
+
if (node.depth === 0) {
|
|
75
|
+
filterTreeNode(node, true, true);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
visibleRowsLookup: visibleRowsLookup,
|
|
81
|
+
filteredRowsLookup: filteredRowsLookup,
|
|
82
|
+
filteredDescendantCountLookup: filteredDescendantCountLookup
|
|
83
|
+
};
|
|
84
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GRID_TREE_DATA_GROUPING_FIELD } from './gridTreeDataGroupColDef';
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useGridApiEventHandler, GridEvents, gridRowIdsSelector, gridRowTreeSelector, gridFilteredDescendantCountLookupSelector, useFirstRender } from '@mui/x-data-grid';
|
|
4
|
+
import { useGridRegisterSortingMethod, useGridRegisterFilteringMethod } from '@mui/x-data-grid/internals';
|
|
5
|
+
import { buildRowTree } from '../../../utils/tree/buildRowTree';
|
|
6
|
+
import { sortRowTree } from '../../../utils/tree/sortRowTree';
|
|
7
|
+
import { filterRowTreeFromTreeData } from './gridTreeDataUtils';
|
|
8
|
+
export var TREE_DATA_GROUPING_NAME = 'tree-data';
|
|
9
|
+
/**
|
|
10
|
+
* Only available in DataGridPro
|
|
11
|
+
* @requires useGridPreProcessing (method)
|
|
12
|
+
* @requires useGridRowGroupsPreProcessing (method)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export var useGridTreeData = function useGridTreeData(apiRef, props) {
|
|
16
|
+
/**
|
|
17
|
+
* ROW GROUPING
|
|
18
|
+
*/
|
|
19
|
+
var updateRowGrouping = React.useCallback(function () {
|
|
20
|
+
if (!props.treeData) {
|
|
21
|
+
return apiRef.current.unstable_registerRowGroupsBuilder('treeData', null);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var groupRows = function groupRows(params) {
|
|
25
|
+
if (!props.getTreeDataPath) {
|
|
26
|
+
throw new Error('MUI: No getTreeDataPath given.');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var rows = params.ids.map(function (rowId) {
|
|
30
|
+
return {
|
|
31
|
+
id: rowId,
|
|
32
|
+
path: props.getTreeDataPath(params.idRowsLookup[rowId]).map(function (key) {
|
|
33
|
+
return {
|
|
34
|
+
key: key,
|
|
35
|
+
field: null
|
|
36
|
+
};
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
}).sort(function (a, b) {
|
|
40
|
+
return a.path.length - b.path.length;
|
|
41
|
+
});
|
|
42
|
+
return buildRowTree(_extends({
|
|
43
|
+
rows: rows
|
|
44
|
+
}, params, {
|
|
45
|
+
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
46
|
+
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
47
|
+
groupingName: TREE_DATA_GROUPING_NAME,
|
|
48
|
+
onDuplicatePath: function onDuplicatePath(firstId, secondId, path) {
|
|
49
|
+
throw new Error(['MUI: The path returned by `getTreeDataPath` should be unique.', "The rows with id #".concat(firstId, " and #").concat(secondId, " have the same."), "Path: ".concat(JSON.stringify(path.map(function (step) {
|
|
50
|
+
return step.key;
|
|
51
|
+
})), ".")].join('\n'));
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return apiRef.current.unstable_registerRowGroupsBuilder('treeData', groupRows);
|
|
57
|
+
}, [apiRef, props.getTreeDataPath, props.treeData, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault]);
|
|
58
|
+
useFirstRender(function () {
|
|
59
|
+
updateRowGrouping();
|
|
60
|
+
});
|
|
61
|
+
var isFirstRender = React.useRef(true);
|
|
62
|
+
React.useEffect(function () {
|
|
63
|
+
if (isFirstRender.current) {
|
|
64
|
+
isFirstRender.current = false;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
updateRowGrouping();
|
|
69
|
+
}, [updateRowGrouping]);
|
|
70
|
+
/**
|
|
71
|
+
* PRE-PROCESSING
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
var filteringMethod = React.useCallback(function (params) {
|
|
75
|
+
var rowTree = gridRowTreeSelector(apiRef);
|
|
76
|
+
return filterRowTreeFromTreeData({
|
|
77
|
+
rowTree: rowTree,
|
|
78
|
+
isRowMatchingFilters: params.isRowMatchingFilters,
|
|
79
|
+
disableChildrenFiltering: props.disableChildrenFiltering
|
|
80
|
+
});
|
|
81
|
+
}, [apiRef, props.disableChildrenFiltering]);
|
|
82
|
+
var sortingMethod = React.useCallback(function (params) {
|
|
83
|
+
var rowTree = gridRowTreeSelector(apiRef);
|
|
84
|
+
var rowIds = gridRowIdsSelector(apiRef);
|
|
85
|
+
return sortRowTree({
|
|
86
|
+
rowTree: rowTree,
|
|
87
|
+
rowIds: rowIds,
|
|
88
|
+
sortRowList: params.sortRowList,
|
|
89
|
+
disableChildrenSorting: props.disableChildrenSorting
|
|
90
|
+
});
|
|
91
|
+
}, [apiRef, props.disableChildrenSorting]);
|
|
92
|
+
useGridRegisterFilteringMethod(apiRef, TREE_DATA_GROUPING_NAME, filteringMethod);
|
|
93
|
+
useGridRegisterSortingMethod(apiRef, TREE_DATA_GROUPING_NAME, sortingMethod);
|
|
94
|
+
/**
|
|
95
|
+
* EVENTS
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
var handleCellKeyDown = React.useCallback(function (params, event) {
|
|
99
|
+
var cellParams = apiRef.current.getCellParams(params.id, params.field);
|
|
100
|
+
|
|
101
|
+
if (cellParams.colDef.type === 'treeDataGroup' && event.key === ' ' && !event.shiftKey) {
|
|
102
|
+
var _gridFilteredDescenda;
|
|
103
|
+
|
|
104
|
+
event.stopPropagation();
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
var filteredDescendantCount = (_gridFilteredDescenda = gridFilteredDescendantCountLookupSelector(apiRef)[params.id]) != null ? _gridFilteredDescenda : 0;
|
|
107
|
+
|
|
108
|
+
if (filteredDescendantCount === 0) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
apiRef.current.setRowChildrenExpansion(params.id, !params.rowNode.childrenExpanded);
|
|
113
|
+
}
|
|
114
|
+
}, [apiRef]);
|
|
115
|
+
useGridApiEventHandler(apiRef, GridEvents.cellKeyDown, handleCellKeyDown);
|
|
116
|
+
};
|