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