@mui/x-data-grid-pro 5.4.0 → 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 +321 -113
- 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 +12 -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 -5251
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { GridEvents, useGridSelector, useGridApiEventHandler, useGridApiMethod } from '@mui/x-data-grid';
|
|
4
|
+
import { useGridStateInit, useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
|
|
5
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from './gridDetailPanelToggleColDef';
|
|
6
|
+
import { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector } from './gridDetailPanelSelector';
|
|
7
|
+
export const useGridDetailPanel = (apiRef, props) => {
|
|
8
|
+
useGridStateInit(apiRef, state => {
|
|
9
|
+
var _ref, _props$detailPanelExp, _props$initialState, _props$initialState$d;
|
|
10
|
+
|
|
11
|
+
return _extends({}, state, {
|
|
12
|
+
detailPanel: {
|
|
13
|
+
expandedRowIds: (_ref = (_props$detailPanelExp = props.detailPanelExpandedRowIds) != null ? _props$detailPanelExp : (_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$d = _props$initialState.detailPanel) == null ? void 0 : _props$initialState$d.expandedRowIds) != null ? _ref : []
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
const expandedRowIds = useGridSelector(apiRef, gridDetailPanelExpandedRowIdsSelector);
|
|
18
|
+
const contentCache = useGridSelector(apiRef, gridDetailPanelExpandedRowsContentCacheSelector);
|
|
19
|
+
const handleCellClick = React.useCallback((params, event) => {
|
|
20
|
+
if (params.field !== GRID_DETAIL_PANEL_TOGGLE_FIELD || props.getDetailPanelContent == null) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const content = contentCache[params.id];
|
|
25
|
+
|
|
26
|
+
if (! /*#__PURE__*/React.isValidElement(content)) {
|
|
27
|
+
return;
|
|
28
|
+
} // Ignore if the user didn't click specifically in the "i" button
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if (event.target === event.currentTarget) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
apiRef.current.toggleDetailPanel(params.id);
|
|
36
|
+
}, [apiRef, contentCache, props.getDetailPanelContent]);
|
|
37
|
+
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
38
|
+
if (!event.ctrlKey || event.key !== 'Enter' || props.getDetailPanelContent == null) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
apiRef.current.toggleDetailPanel(params.id);
|
|
43
|
+
}, [apiRef, props.getDetailPanelContent]);
|
|
44
|
+
useGridApiEventHandler(apiRef, GridEvents.cellClick, handleCellClick);
|
|
45
|
+
useGridApiEventHandler(apiRef, GridEvents.cellKeyDown, handleCellKeyDown);
|
|
46
|
+
const addDetailHeight = React.useCallback((initialValue, row) => {
|
|
47
|
+
var _heightCache$row$id;
|
|
48
|
+
|
|
49
|
+
if (expandedRowIds.length === 0 || !expandedRowIds.includes(row.id)) {
|
|
50
|
+
return _extends({}, initialValue, {
|
|
51
|
+
detail: 0
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const heightCache = gridDetailPanelExpandedRowsHeightCacheSelector(apiRef.current.state);
|
|
56
|
+
return _extends({}, initialValue, {
|
|
57
|
+
detail: (_heightCache$row$id = heightCache[row.id]) != null ? _heightCache$row$id : 0 // Fallback to zero because the cache might not be ready yet (e.g. page was changed)
|
|
58
|
+
|
|
59
|
+
});
|
|
60
|
+
}, [apiRef, expandedRowIds]);
|
|
61
|
+
useGridRegisterPreProcessor(apiRef, 'rowHeight', addDetailHeight);
|
|
62
|
+
apiRef.current.unstable_updateControlState({
|
|
63
|
+
stateId: 'detailPanels',
|
|
64
|
+
propModel: props.detailPanelExpandedRowIds,
|
|
65
|
+
propOnChange: props.onDetailPanelExpandedRowIdsChange,
|
|
66
|
+
stateSelector: gridDetailPanelExpandedRowIdsSelector,
|
|
67
|
+
changeEvent: GridEvents.detailPanelsExpandedRowIdsChange
|
|
68
|
+
});
|
|
69
|
+
const toggleDetailPanel = React.useCallback(id => {
|
|
70
|
+
if (props.getDetailPanelContent == null) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const content = contentCache[id];
|
|
75
|
+
|
|
76
|
+
if (! /*#__PURE__*/React.isValidElement(content)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const ids = apiRef.current.getExpandedDetailPanels();
|
|
81
|
+
apiRef.current.setExpandedDetailPanels(ids.includes(id) ? ids.filter(rowId => rowId !== id) : [...ids, id]);
|
|
82
|
+
}, [apiRef, contentCache, props.getDetailPanelContent]);
|
|
83
|
+
const getExpandedDetailPanels = React.useCallback(() => gridDetailPanelExpandedRowIdsSelector(apiRef.current.state), [apiRef]);
|
|
84
|
+
const setExpandedDetailPanels = React.useCallback(ids => {
|
|
85
|
+
apiRef.current.setState(state => {
|
|
86
|
+
return _extends({}, state, {
|
|
87
|
+
detailPanel: _extends({}, state.detailPanel, {
|
|
88
|
+
expandedRowIds: ids
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
apiRef.current.forceUpdate();
|
|
93
|
+
}, [apiRef]);
|
|
94
|
+
const detailPanelApi = {
|
|
95
|
+
toggleDetailPanel,
|
|
96
|
+
getExpandedDetailPanels,
|
|
97
|
+
setExpandedDetailPanels
|
|
98
|
+
};
|
|
99
|
+
useGridApiMethod(apiRef, detailPanelApi, 'detailPanelApi');
|
|
100
|
+
React.useEffect(() => {
|
|
101
|
+
if (props.detailPanelExpandedRowIds) {
|
|
102
|
+
const currentModel = gridDetailPanelExpandedRowIdsSelector(apiRef.current.state);
|
|
103
|
+
|
|
104
|
+
if (currentModel !== props.detailPanelExpandedRowIds) {
|
|
105
|
+
apiRef.current.setExpandedDetailPanels(props.detailPanelExpandedRowIds);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}, [apiRef, props.detailPanelExpandedRowIds]);
|
|
109
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridApiPro } from '../../../models/gridApiPro';
|
|
3
|
+
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
4
|
+
export declare const useGridDetailPanelCache: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'getDetailPanelContent' | 'getDetailPanelHeight'>) => void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useGridApiEventHandler, gridRowIdsSelector, GridEvents } from '@mui/x-data-grid';
|
|
4
|
+
|
|
5
|
+
function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight) {
|
|
6
|
+
if (typeof getDetailPanelContent !== 'function') {
|
|
7
|
+
return {};
|
|
8
|
+
} // TODO change to lazy approach using a Proxy
|
|
9
|
+
// only call getDetailPanelContent when asked for an id
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const rowIds = gridRowIdsSelector(apiRef);
|
|
13
|
+
const contentCache = rowIds.reduce((acc, id) => {
|
|
14
|
+
const params = apiRef.current.getRowParams(id);
|
|
15
|
+
acc[id] = getDetailPanelContent(params);
|
|
16
|
+
return acc;
|
|
17
|
+
}, {});
|
|
18
|
+
const heightCache = rowIds.reduce((acc, id) => {
|
|
19
|
+
if (contentCache[id] == null) {
|
|
20
|
+
return acc;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const params = apiRef.current.getRowParams(id);
|
|
24
|
+
acc[id] = getDetailPanelHeight(params);
|
|
25
|
+
return acc;
|
|
26
|
+
}, {});
|
|
27
|
+
return {
|
|
28
|
+
contentCache,
|
|
29
|
+
heightCache
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const useGridDetailPanelCache = (apiRef, props) => {
|
|
34
|
+
const updateCaches = React.useCallback(() => {
|
|
35
|
+
apiRef.current.setState(state => {
|
|
36
|
+
return _extends({}, state, {
|
|
37
|
+
detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight))
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
apiRef.current.forceUpdate();
|
|
41
|
+
}, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
|
|
42
|
+
useGridApiEventHandler(apiRef, GridEvents.visibleRowsSet, updateCaches);
|
|
43
|
+
const isFirstRender = React.useRef(true);
|
|
44
|
+
|
|
45
|
+
if (isFirstRender.current) {
|
|
46
|
+
isFirstRender.current = false;
|
|
47
|
+
updateCaches();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
if (isFirstRender.current) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
updateCaches();
|
|
56
|
+
}, [updateCaches]);
|
|
57
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
3
|
+
import { GridApiPro } from '../../../models/gridApiPro';
|
|
4
|
+
export declare const useGridDetailPanelPreProcessors: (apiRef: React.MutableRefObject<GridApiPro>, props: DataGridProProcessedProps) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
|
|
3
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD, GRID_DETAIL_PANEL_TOGGLE_COL_DEF } from './gridDetailPanelToggleColDef';
|
|
4
|
+
export const useGridDetailPanelPreProcessors = (apiRef, props) => {
|
|
5
|
+
const addToggleColumn = React.useCallback(columnsState => {
|
|
6
|
+
if (props.getDetailPanelContent == null) {
|
|
7
|
+
// Remove the toggle column, when it exists
|
|
8
|
+
if (columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD]) {
|
|
9
|
+
delete columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD];
|
|
10
|
+
columnsState.all = columnsState.all.filter(field => field !== GRID_DETAIL_PANEL_TOGGLE_FIELD);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return columnsState;
|
|
14
|
+
} // Don't add the toggle column if there's already one
|
|
15
|
+
// The user might have manually added it to have it in a custom position
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
if (columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD]) {
|
|
19
|
+
return columnsState;
|
|
20
|
+
} // Othewise, add the toggle column at the beginning
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
columnsState.all = [GRID_DETAIL_PANEL_TOGGLE_FIELD, ...columnsState.all];
|
|
24
|
+
columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD] = GRID_DETAIL_PANEL_TOGGLE_COL_DEF;
|
|
25
|
+
return columnsState;
|
|
26
|
+
}, [props.getDetailPanelContent]);
|
|
27
|
+
useGridRegisterPreProcessor(apiRef, 'hydrateColumns', addToggleColumn);
|
|
28
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Only export the variable and types that should be publicly exposed and re-exported from `@mui/x-data-grid-pro`
|
|
2
|
+
export * from './columnPinning';
|
|
3
|
+
export * from './columnReorder';
|
|
4
|
+
export * from './columnResize';
|
|
5
|
+
export * from './rowGrouping';
|
|
6
|
+
export * from './treeData';
|
|
7
|
+
export * from './detailPanel';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridApiPro } from '../../../models/gridApiPro';
|
|
3
|
+
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
4
|
+
/**
|
|
5
|
+
* Only available in DataGridPro
|
|
6
|
+
* @requires useGridColumns (state)
|
|
7
|
+
* @requires useGridDimensions (method) - can be after
|
|
8
|
+
* @requires useGridScroll (method
|
|
9
|
+
*/
|
|
10
|
+
export declare const useGridInfiniteLoader: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'onRowsScrollEnd' | 'scrollEndThreshold' | 'pagination' | 'paginationMode'>) => void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useGridSelector, GridEvents, useGridApiEventHandler, useGridApiOptionHandler, gridVisibleColumnDefinitionsSelector, gridRowsMetaSelector } from '@mui/x-data-grid';
|
|
3
|
+
import { useCurrentPageRows } from '@mui/x-data-grid/internals';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Only available in DataGridPro
|
|
7
|
+
* @requires useGridColumns (state)
|
|
8
|
+
* @requires useGridDimensions (method) - can be after
|
|
9
|
+
* @requires useGridScroll (method
|
|
10
|
+
*/
|
|
11
|
+
export const useGridInfiniteLoader = (apiRef, props) => {
|
|
12
|
+
const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
13
|
+
const currentPage = useCurrentPageRows(apiRef, props);
|
|
14
|
+
const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
|
|
15
|
+
const contentHeight = Math.max(rowsMeta.currentPageTotalHeight, 1);
|
|
16
|
+
const isInScrollBottomArea = React.useRef(false);
|
|
17
|
+
const handleRowsScrollEnd = React.useCallback(scrollPosition => {
|
|
18
|
+
const dimensions = apiRef.current.getRootDimensions();
|
|
19
|
+
|
|
20
|
+
if (!dimensions) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const scrollPositionBottom = scrollPosition.top + dimensions.viewportOuterSize.height;
|
|
25
|
+
const viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
26
|
+
|
|
27
|
+
if (scrollPositionBottom < contentHeight - props.scrollEndThreshold) {
|
|
28
|
+
isInScrollBottomArea.current = false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (scrollPositionBottom >= contentHeight - props.scrollEndThreshold && !isInScrollBottomArea.current) {
|
|
32
|
+
const rowScrollEndParam = {
|
|
33
|
+
visibleColumns,
|
|
34
|
+
viewportPageSize,
|
|
35
|
+
virtualRowsCount: currentPage.rows.length
|
|
36
|
+
};
|
|
37
|
+
apiRef.current.publishEvent(GridEvents.rowsScrollEnd, rowScrollEndParam);
|
|
38
|
+
isInScrollBottomArea.current = true;
|
|
39
|
+
}
|
|
40
|
+
}, [contentHeight, props.scrollEndThreshold, visibleColumns, apiRef, currentPage.rows.length]);
|
|
41
|
+
const handleGridScroll = React.useCallback(({
|
|
42
|
+
left,
|
|
43
|
+
top
|
|
44
|
+
}) => {
|
|
45
|
+
handleRowsScrollEnd({
|
|
46
|
+
left,
|
|
47
|
+
top
|
|
48
|
+
});
|
|
49
|
+
}, [handleRowsScrollEnd]);
|
|
50
|
+
useGridApiEventHandler(apiRef, GridEvents.rowsScroll, handleGridScroll);
|
|
51
|
+
useGridApiOptionHandler(apiRef, GridEvents.rowsScrollEnd, props.onRowsScrollEnd);
|
|
52
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridColDef, GridStateColDef } from '@mui/x-data-grid';
|
|
3
|
+
import { GridColumnRawLookup } from '@mui/x-data-grid/internals';
|
|
4
|
+
import { GridGroupingColDefOverride } from '../../../models';
|
|
5
|
+
import { GridApiPro } from '../../../models/gridApiPro';
|
|
6
|
+
interface CreateGroupingColDefMonoCriteriaParams {
|
|
7
|
+
columnsLookup: GridColumnRawLookup;
|
|
8
|
+
/**
|
|
9
|
+
* The field from which we are grouping the rows.
|
|
10
|
+
*/
|
|
11
|
+
groupingCriteria: string;
|
|
12
|
+
/**
|
|
13
|
+
* The col def from which we are grouping the rows.
|
|
14
|
+
*/
|
|
15
|
+
groupedByColDef: GridColDef | GridStateColDef;
|
|
16
|
+
/**
|
|
17
|
+
* The col def properties the user wants to override.
|
|
18
|
+
* This value comes `prop.groupingColDef`.
|
|
19
|
+
*/
|
|
20
|
+
colDefOverride: GridGroupingColDefOverride | null | undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates the `GridColDef` for a grouping column that only takes care of a single grouping criteria
|
|
24
|
+
*/
|
|
25
|
+
export declare const createGroupingColDefForOneGroupingCriteria: ({ columnsLookup, groupedByColDef, groupingCriteria, colDefOverride, }: CreateGroupingColDefMonoCriteriaParams) => GridColDef;
|
|
26
|
+
interface CreateGroupingColDefSeveralCriteriaParams {
|
|
27
|
+
apiRef: React.MutableRefObject<GridApiPro>;
|
|
28
|
+
columnsLookup: GridColumnRawLookup;
|
|
29
|
+
/**
|
|
30
|
+
* The fields from which we are grouping the rows.
|
|
31
|
+
*/
|
|
32
|
+
rowGroupingModel: string[];
|
|
33
|
+
/**
|
|
34
|
+
* The col def properties the user wants to override.
|
|
35
|
+
* This value comes `prop.groupingColDef`.
|
|
36
|
+
*/
|
|
37
|
+
colDefOverride: GridGroupingColDefOverride | null | undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates the `GridColDef` for a grouping column that takes care of all the grouping criteria
|
|
41
|
+
*/
|
|
42
|
+
export declare const createGroupingColDefForAllGroupingCriteria: ({ apiRef, columnsLookup, rowGroupingModel, colDefOverride, }: CreateGroupingColDefSeveralCriteriaParams) => GridColDef;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["leafField", "mainGroupingCriteria", "hideDescendantCount"],
|
|
4
|
+
_excluded2 = ["leafField", "mainGroupingCriteria", "hideDescendantCount"];
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { GRID_STRING_COL_DEF } from '@mui/x-data-grid';
|
|
7
|
+
import { GridGroupingCriteriaCell } from '../../../components/GridGroupingCriteriaCell';
|
|
8
|
+
import { GridGroupingColumnLeafCell } from '../../../components/GridGroupingColumnLeafCell';
|
|
9
|
+
import { getRowGroupingFieldFromGroupingCriteria, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD } from './gridRowGroupingUtils';
|
|
10
|
+
import { gridRowGroupingSanitizedModelSelector } from './gridRowGroupingSelector';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
|
|
13
|
+
const GROUPING_COL_DEF_DEFAULT_PROPERTIES = _extends({}, GRID_STRING_COL_DEF, {
|
|
14
|
+
disableReorder: true
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const GROUPING_COL_DEF_FORCED_PROPERTIES = {
|
|
18
|
+
type: 'rowGroupByColumnsGroup',
|
|
19
|
+
editable: false,
|
|
20
|
+
groupable: false
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* When sorting two cells with different grouping criteria, we consider that the cell with the grouping criteria coming first in the model should be displayed below.
|
|
24
|
+
* This can occur when some rows don't have all the fields. In which case we want the rows with the missing field to be displayed above.
|
|
25
|
+
* TODO: Make this index comparator depth invariant, the logic should not be inverted when sorting in the "desc" direction (but the current return format of `sortComparator` does not support this behavior).
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const groupingFieldIndexComparator = (v1, v2, cellParams1, cellParams2) => {
|
|
29
|
+
const model = gridRowGroupingSanitizedModelSelector(cellParams1.api.state, cellParams1.api.instanceId);
|
|
30
|
+
const groupingField1 = cellParams1.rowNode.groupingField;
|
|
31
|
+
const groupingField2 = cellParams2.rowNode.groupingField;
|
|
32
|
+
|
|
33
|
+
if (groupingField1 === groupingField2) {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (groupingField1 == null) {
|
|
38
|
+
return -1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (groupingField2 == null) {
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (model.indexOf(groupingField1) < model.indexOf(groupingField2)) {
|
|
46
|
+
return -1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return 1;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const getLeafProperties = leafColDef => {
|
|
53
|
+
var _leafColDef$headerNam, _leafColDef$filterOpe;
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
headerName: (_leafColDef$headerNam = leafColDef.headerName) != null ? _leafColDef$headerNam : leafColDef.field,
|
|
57
|
+
sortable: leafColDef.sortable,
|
|
58
|
+
filterable: leafColDef.filterable,
|
|
59
|
+
filterOperators: (_leafColDef$filterOpe = leafColDef.filterOperators) == null ? void 0 : _leafColDef$filterOpe.map(operator => _extends({}, operator, {
|
|
60
|
+
getApplyFilterFn: (filterItem, column) => {
|
|
61
|
+
const originalFn = operator.getApplyFilterFn(filterItem, column);
|
|
62
|
+
|
|
63
|
+
if (!originalFn) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return params => {
|
|
68
|
+
// We only want to filter leaves
|
|
69
|
+
if (params.rowNode.groupingField != null) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return originalFn(params);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
})),
|
|
77
|
+
sortComparator: (v1, v2, cellParams1, cellParams2) => {
|
|
78
|
+
// We only want to sort the leaves
|
|
79
|
+
if (cellParams1.rowNode.groupingField === null && cellParams2.rowNode.groupingField === null) {
|
|
80
|
+
return leafColDef.sortComparator(v1, v2, cellParams1, cellParams2);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return groupingFieldIndexComparator(v1, v2, cellParams1, cellParams2);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const getGroupingCriteriaProperties = (groupedByColDef, applyHeaderName) => {
|
|
89
|
+
var _groupedByColDef$filt;
|
|
90
|
+
|
|
91
|
+
const properties = {
|
|
92
|
+
sortable: groupedByColDef.sortable,
|
|
93
|
+
filterable: groupedByColDef.filterable,
|
|
94
|
+
sortComparator: (v1, v2, cellParams1, cellParams2) => {
|
|
95
|
+
// We only want to sort the groups of the current grouping criteria
|
|
96
|
+
if (cellParams1.rowNode.groupingField === groupedByColDef.field && cellParams2.rowNode.groupingField === groupedByColDef.field) {
|
|
97
|
+
return groupedByColDef.sortComparator(v1, v2, cellParams1, cellParams2);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return groupingFieldIndexComparator(v1, v2, cellParams1, cellParams2);
|
|
101
|
+
},
|
|
102
|
+
filterOperators: (_groupedByColDef$filt = groupedByColDef.filterOperators) == null ? void 0 : _groupedByColDef$filt.map(operator => _extends({}, operator, {
|
|
103
|
+
getApplyFilterFn: (filterItem, column) => {
|
|
104
|
+
const originalFn = operator.getApplyFilterFn(filterItem, column);
|
|
105
|
+
|
|
106
|
+
if (!originalFn) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return params => {
|
|
111
|
+
// We only want to filter the groups of the current grouping criteria
|
|
112
|
+
if (params.rowNode.groupingField !== groupedByColDef.field) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return originalFn(params);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}))
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
if (applyHeaderName) {
|
|
123
|
+
var _groupedByColDef$head;
|
|
124
|
+
|
|
125
|
+
properties.headerName = (_groupedByColDef$head = groupedByColDef.headerName) != null ? _groupedByColDef$head : groupedByColDef.field;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return properties;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Creates the `GridColDef` for a grouping column that only takes care of a single grouping criteria
|
|
133
|
+
*/
|
|
134
|
+
export const createGroupingColDefForOneGroupingCriteria = ({
|
|
135
|
+
columnsLookup,
|
|
136
|
+
groupedByColDef,
|
|
137
|
+
groupingCriteria,
|
|
138
|
+
colDefOverride
|
|
139
|
+
}) => {
|
|
140
|
+
var _groupedByColDef$widt, _leafColDef$width;
|
|
141
|
+
|
|
142
|
+
const _ref = colDefOverride != null ? colDefOverride : {},
|
|
143
|
+
{
|
|
144
|
+
leafField,
|
|
145
|
+
mainGroupingCriteria,
|
|
146
|
+
hideDescendantCount
|
|
147
|
+
} = _ref,
|
|
148
|
+
colDefOverrideProperties = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
149
|
+
|
|
150
|
+
const leafColDef = leafField ? columnsLookup[leafField] : null; // The properties that do not depend on the presence of a `leafColDef` and that can be overridden by `colDefOverride`
|
|
151
|
+
|
|
152
|
+
const commonProperties = {
|
|
153
|
+
width: Math.max(((_groupedByColDef$widt = groupedByColDef.width) != null ? _groupedByColDef$widt : GRID_STRING_COL_DEF.width) + 40, (_leafColDef$width = leafColDef == null ? void 0 : leafColDef.width) != null ? _leafColDef$width : 0),
|
|
154
|
+
renderCell: params => {
|
|
155
|
+
// Render leaves
|
|
156
|
+
if (params.rowNode.groupingField == null) {
|
|
157
|
+
if (leafColDef) {
|
|
158
|
+
const leafParams = _extends({}, params.api.getCellParams(params.id, leafField), {
|
|
159
|
+
api: params.api
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
if (leafColDef.renderCell) {
|
|
163
|
+
return leafColDef.renderCell(leafParams);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return /*#__PURE__*/_jsx(GridGroupingColumnLeafCell, _extends({}, leafParams));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return '';
|
|
170
|
+
} // Render current grouping criteria groups
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
if (params.rowNode.groupingField === groupingCriteria) {
|
|
174
|
+
return /*#__PURE__*/_jsx(GridGroupingCriteriaCell, _extends({}, params, {
|
|
175
|
+
hideDescendantCount: hideDescendantCount
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return '';
|
|
180
|
+
},
|
|
181
|
+
valueGetter: params => {
|
|
182
|
+
if (!params.rowNode) {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (params.rowNode.groupingField == null) {
|
|
187
|
+
if (leafColDef) {
|
|
188
|
+
return params.api.getCellValue(params.id, leafField);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (params.rowNode.groupingField === groupingCriteria) {
|
|
195
|
+
return params.rowNode.groupingKey;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
}; // If we have a `mainGroupingCriteria` defined and matching the `groupingCriteria`
|
|
201
|
+
// Then we apply the sorting / filtering on the groups of this column's grouping criteria based on the properties of `groupedByColDef`.
|
|
202
|
+
// It can be useful to define a `leafField` for leaves rendering but still use the grouping criteria for the sorting / filtering
|
|
203
|
+
//
|
|
204
|
+
// If we have a `leafField` defined and matching an existing column
|
|
205
|
+
// Then we apply the sorting / filtering on the leaves based on the properties of `leavesColDef`
|
|
206
|
+
//
|
|
207
|
+
// By default, we apply the sorting / filtering on the groups of this column's grouping criteria based on the properties of `groupedColDef`.
|
|
208
|
+
|
|
209
|
+
let sourceProperties;
|
|
210
|
+
|
|
211
|
+
if (mainGroupingCriteria && mainGroupingCriteria === groupingCriteria) {
|
|
212
|
+
sourceProperties = getGroupingCriteriaProperties(groupedByColDef, true);
|
|
213
|
+
} else if (leafColDef) {
|
|
214
|
+
sourceProperties = getLeafProperties(leafColDef);
|
|
215
|
+
} else {
|
|
216
|
+
sourceProperties = getGroupingCriteriaProperties(groupedByColDef, true);
|
|
217
|
+
} // The properties that can't be overridden with `colDefOverride`
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
const forcedProperties = _extends({
|
|
221
|
+
field: getRowGroupingFieldFromGroupingCriteria(groupingCriteria)
|
|
222
|
+
}, GROUPING_COL_DEF_FORCED_PROPERTIES);
|
|
223
|
+
|
|
224
|
+
return _extends({}, GROUPING_COL_DEF_DEFAULT_PROPERTIES, commonProperties, sourceProperties, colDefOverrideProperties, forcedProperties);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Creates the `GridColDef` for a grouping column that takes care of all the grouping criteria
|
|
229
|
+
*/
|
|
230
|
+
export const createGroupingColDefForAllGroupingCriteria = ({
|
|
231
|
+
apiRef,
|
|
232
|
+
columnsLookup,
|
|
233
|
+
rowGroupingModel,
|
|
234
|
+
colDefOverride
|
|
235
|
+
}) => {
|
|
236
|
+
var _leafColDef$width2;
|
|
237
|
+
|
|
238
|
+
const _ref2 = colDefOverride != null ? colDefOverride : {},
|
|
239
|
+
{
|
|
240
|
+
leafField,
|
|
241
|
+
mainGroupingCriteria,
|
|
242
|
+
hideDescendantCount
|
|
243
|
+
} = _ref2,
|
|
244
|
+
colDefOverrideProperties = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
245
|
+
|
|
246
|
+
const leafColDef = leafField ? columnsLookup[leafField] : null; // The properties that do not depend on the presence of a `leafColDef` and that can be overridden by `colDefOverride`
|
|
247
|
+
|
|
248
|
+
const commonProperties = {
|
|
249
|
+
headerName: apiRef.current.getLocaleText('groupingColumnHeaderName'),
|
|
250
|
+
width: Math.max(...rowGroupingModel.map(field => {
|
|
251
|
+
var _columnsLookup$field$;
|
|
252
|
+
|
|
253
|
+
return ((_columnsLookup$field$ = columnsLookup[field].width) != null ? _columnsLookup$field$ : GRID_STRING_COL_DEF.width) + 40;
|
|
254
|
+
}), (_leafColDef$width2 = leafColDef == null ? void 0 : leafColDef.width) != null ? _leafColDef$width2 : 0),
|
|
255
|
+
renderCell: params => {
|
|
256
|
+
// Render the leaves
|
|
257
|
+
if (params.rowNode.groupingField == null) {
|
|
258
|
+
if (leafColDef) {
|
|
259
|
+
const leafParams = _extends({}, params.api.getCellParams(params.id, leafField), {
|
|
260
|
+
api: params.api
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
if (leafColDef.renderCell) {
|
|
264
|
+
return leafColDef.renderCell(leafParams);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return /*#__PURE__*/_jsx(GridGroupingColumnLeafCell, _extends({}, leafParams));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return '';
|
|
271
|
+
} // Render the groups
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
return /*#__PURE__*/_jsx(GridGroupingCriteriaCell, _extends({}, params, {
|
|
275
|
+
hideDescendantCount: hideDescendantCount
|
|
276
|
+
}));
|
|
277
|
+
},
|
|
278
|
+
valueGetter: params => {
|
|
279
|
+
if (!params.rowNode) {
|
|
280
|
+
return undefined;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (params.rowNode.groupingField == null) {
|
|
284
|
+
if (leafColDef) {
|
|
285
|
+
return params.api.getCellValue(params.id, leafField);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return undefined;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return params.rowNode.groupingKey;
|
|
292
|
+
}
|
|
293
|
+
}; // If we have a `mainGroupingCriteria` defined and matching one of the `orderedGroupedByFields`
|
|
294
|
+
// Then we apply the sorting / filtering on the groups of this column's grouping criteria based on the properties of `columnsLookup[mainGroupingCriteria]`.
|
|
295
|
+
// It can be useful to use another grouping criteria than the top level one for the sorting / filtering
|
|
296
|
+
//
|
|
297
|
+
// If we have a `leafField` defined and matching an existing column
|
|
298
|
+
// Then we apply the sorting / filtering on the leaves based on the properties of `leavesColDef`
|
|
299
|
+
//
|
|
300
|
+
// By default, we apply the sorting / filtering on the groups of the top level grouping criteria based on the properties of `columnsLookup[orderedGroupedByFields[0]]`.
|
|
301
|
+
|
|
302
|
+
let sourceProperties;
|
|
303
|
+
|
|
304
|
+
if (mainGroupingCriteria && rowGroupingModel.includes(mainGroupingCriteria)) {
|
|
305
|
+
sourceProperties = getGroupingCriteriaProperties(columnsLookup[mainGroupingCriteria], true);
|
|
306
|
+
} else if (leafColDef) {
|
|
307
|
+
sourceProperties = getLeafProperties(leafColDef);
|
|
308
|
+
} else {
|
|
309
|
+
sourceProperties = getGroupingCriteriaProperties(columnsLookup[rowGroupingModel[0]], rowGroupingModel.length === 1);
|
|
310
|
+
} // The properties that can't be overridden with `colDefOverride`
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
const forcedProperties = _extends({
|
|
314
|
+
field: GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD
|
|
315
|
+
}, GROUPING_COL_DEF_FORCED_PROPERTIES);
|
|
316
|
+
|
|
317
|
+
return _extends({}, GROUPING_COL_DEF_DEFAULT_PROPERTIES, commonProperties, sourceProperties, colDefOverrideProperties, forcedProperties);
|
|
318
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare type GridRowGroupingModel = string[];
|
|
2
|
+
export interface GridRowGroupingState {
|
|
3
|
+
model: GridRowGroupingModel;
|
|
4
|
+
}
|
|
5
|
+
export interface GridRowGroupingInitialState {
|
|
6
|
+
model?: GridRowGroupingModel;
|
|
7
|
+
}
|
|
8
|
+
export interface GridRowGroupingApi {
|
|
9
|
+
/**
|
|
10
|
+
* Sets the columns to use as grouping criteria.
|
|
11
|
+
* @param {GridRowGroupingModel} model The columns to use as grouping criteria.
|
|
12
|
+
*/
|
|
13
|
+
setRowGroupingModel: (model: GridRowGroupingModel) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Adds the field to the row grouping model.
|
|
16
|
+
* @param {string} groupingCriteriaField The field from which we want to group the rows.
|
|
17
|
+
* @param {number | undefined} groupingIndex The grouping index at which we want to insert the new grouping criteria. By default, it will be inserted at the end of the model.
|
|
18
|
+
*/
|
|
19
|
+
addRowGroupingCriteria: (groupingCriteriaField: string, groupingIndex?: number) => void;
|
|
20
|
+
/**
|
|
21
|
+
* sRemove the field from the row grouping model.
|
|
22
|
+
* @param {string} groupingCriteriaField The field from which we want to stop grouping the rows.
|
|
23
|
+
*/
|
|
24
|
+
removeRowGroupingCriteria: (groupingCriteriaField: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the grouping index of a grouping criteria.
|
|
27
|
+
* @param {string} groupingCriteriaField The field of the grouping criteria from which we want to change the grouping index.
|
|
28
|
+
* @param {number} groupingIndex The new grouping index of this grouping criteria.
|
|
29
|
+
*/
|
|
30
|
+
setRowGroupingCriteriaIndex: (groupingCriteriaField: string, groupingIndex: number) => void;
|
|
31
|
+
}
|