@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,295 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ownerDocument, useEventCallback } from '@mui/material/utils';
|
|
4
|
+
import { GridEvents, gridClasses, GridColumnHeaderSeparatorSides, useGridApiEventHandler, useGridApiOptionHandler, useGridNativeEventListener, useGridLogger } from '@mui/x-data-grid';
|
|
5
|
+
import { clamp, findParentElementFromClassName } from '@mui/x-data-grid/internals';
|
|
6
|
+
import { findGridCellElementsFromCol, getFieldFromHeaderElem, findHeaderElementFromField } from '../../../utils/domUtils';
|
|
7
|
+
// TODO: remove support for Safari < 13.
|
|
8
|
+
// https://caniuse.com/#search=touch-action
|
|
9
|
+
//
|
|
10
|
+
// Safari, on iOS, supports touch action since v13.
|
|
11
|
+
// Over 80% of the iOS phones are compatible
|
|
12
|
+
// in August 2020.
|
|
13
|
+
// Utilizing the CSS.supports method to check if touch-action is supported.
|
|
14
|
+
// Since CSS.supports is supported on all but Edge@12 and IE and touch-action
|
|
15
|
+
// is supported on both Edge@12 and IE if CSS.supports is not available that means that
|
|
16
|
+
// touch-action will be supported
|
|
17
|
+
let cachedSupportsTouchActionNone = false;
|
|
18
|
+
|
|
19
|
+
function doesSupportTouchActionNone() {
|
|
20
|
+
if (cachedSupportsTouchActionNone === undefined) {
|
|
21
|
+
if (typeof CSS !== 'undefined' && typeof CSS.supports === 'function') {
|
|
22
|
+
cachedSupportsTouchActionNone = CSS.supports('touch-action', 'none');
|
|
23
|
+
} else {
|
|
24
|
+
cachedSupportsTouchActionNone = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return cachedSupportsTouchActionNone;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function trackFinger(event, currentTouchId) {
|
|
32
|
+
if (currentTouchId !== undefined && event.changedTouches) {
|
|
33
|
+
for (let i = 0; i < event.changedTouches.length; i += 1) {
|
|
34
|
+
const touch = event.changedTouches[i];
|
|
35
|
+
|
|
36
|
+
if (touch.identifier === currentTouchId) {
|
|
37
|
+
return {
|
|
38
|
+
x: touch.clientX,
|
|
39
|
+
y: touch.clientY
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
x: event.clientX,
|
|
49
|
+
y: event.clientY
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function computeNewWidth(initialOffsetToSeparator, clickX, columnBounds, separatorSide) {
|
|
54
|
+
let newWidth = initialOffsetToSeparator;
|
|
55
|
+
|
|
56
|
+
if (separatorSide === GridColumnHeaderSeparatorSides.Right) {
|
|
57
|
+
newWidth += clickX - columnBounds.left;
|
|
58
|
+
} else {
|
|
59
|
+
newWidth += columnBounds.right - clickX;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return newWidth;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function computeOffsetToSeparator(clickX, columnBounds, separatorSide) {
|
|
66
|
+
if (separatorSide === GridColumnHeaderSeparatorSides.Left) {
|
|
67
|
+
return clickX - columnBounds.left;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return columnBounds.right - clickX;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getSeparatorSide(element) {
|
|
74
|
+
return element.classList.contains(gridClasses['columnSeparator--sideRight']) ? GridColumnHeaderSeparatorSides.Right : GridColumnHeaderSeparatorSides.Left;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const columnResizeStateInitializer = state => _extends({}, state, {
|
|
78
|
+
columnResize: {
|
|
79
|
+
resizingColumnField: ''
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* Only available in DataGridPro
|
|
84
|
+
* @requires useGridColumns (method, event)
|
|
85
|
+
* TODO: improve experience for last column
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
export const useGridColumnResize = (apiRef, props) => {
|
|
89
|
+
const logger = useGridLogger(apiRef, 'useGridColumnResize');
|
|
90
|
+
const colDefRef = React.useRef();
|
|
91
|
+
const colElementRef = React.useRef();
|
|
92
|
+
const colCellElementsRef = React.useRef(); // To improve accessibility, the separator has padding on both sides.
|
|
93
|
+
// Clicking inside the padding area should be treated as a click in the separator.
|
|
94
|
+
// This ref stores the offset between the click and the separator.
|
|
95
|
+
|
|
96
|
+
const initialOffsetToSeparator = React.useRef();
|
|
97
|
+
const separatorSide = React.useRef();
|
|
98
|
+
const stopResizeEventTimeout = React.useRef();
|
|
99
|
+
const touchId = React.useRef();
|
|
100
|
+
|
|
101
|
+
const updateWidth = newWidth => {
|
|
102
|
+
logger.debug(`Updating width to ${newWidth} for col ${colDefRef.current.field}`);
|
|
103
|
+
colDefRef.current.computedWidth = newWidth;
|
|
104
|
+
colDefRef.current.width = newWidth;
|
|
105
|
+
colDefRef.current.flex = undefined;
|
|
106
|
+
colElementRef.current.style.width = `${newWidth}px`;
|
|
107
|
+
colElementRef.current.style.minWidth = `${newWidth}px`;
|
|
108
|
+
colElementRef.current.style.maxWidth = `${newWidth}px`;
|
|
109
|
+
colCellElementsRef.current.forEach(element => {
|
|
110
|
+
const div = element;
|
|
111
|
+
div.style.width = `${newWidth}px`;
|
|
112
|
+
div.style.minWidth = `${newWidth}px`;
|
|
113
|
+
div.style.maxWidth = `${newWidth}px`;
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const handleResizeMouseUp = useEventCallback(nativeEvent => {
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
119
|
+
stopListening();
|
|
120
|
+
apiRef.current.updateColumn(colDefRef.current);
|
|
121
|
+
clearTimeout(stopResizeEventTimeout.current);
|
|
122
|
+
stopResizeEventTimeout.current = setTimeout(() => {
|
|
123
|
+
apiRef.current.publishEvent(GridEvents.columnResizeStop, null, nativeEvent);
|
|
124
|
+
|
|
125
|
+
if (colDefRef.current) {
|
|
126
|
+
apiRef.current.publishEvent(GridEvents.columnWidthChange, {
|
|
127
|
+
element: colElementRef.current,
|
|
128
|
+
colDef: colDefRef.current,
|
|
129
|
+
width: colDefRef.current?.computedWidth
|
|
130
|
+
}, nativeEvent);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
logger.debug(`Updating col ${colDefRef.current.field} with new width: ${colDefRef.current.width}`);
|
|
134
|
+
});
|
|
135
|
+
const handleResizeMouseMove = useEventCallback(nativeEvent => {
|
|
136
|
+
// Cancel move in case some other element consumed a mouseup event and it was not fired.
|
|
137
|
+
if (nativeEvent.buttons === 0) {
|
|
138
|
+
handleResizeMouseUp(nativeEvent);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let newWidth = computeNewWidth(initialOffsetToSeparator.current, nativeEvent.clientX, colElementRef.current.getBoundingClientRect(), separatorSide.current);
|
|
143
|
+
newWidth = clamp(newWidth, colDefRef.current.minWidth, colDefRef.current.maxWidth);
|
|
144
|
+
updateWidth(newWidth);
|
|
145
|
+
const params = {
|
|
146
|
+
element: colElementRef.current,
|
|
147
|
+
colDef: colDefRef.current,
|
|
148
|
+
width: newWidth
|
|
149
|
+
};
|
|
150
|
+
apiRef.current.publishEvent(GridEvents.columnResize, params, nativeEvent);
|
|
151
|
+
});
|
|
152
|
+
const handleColumnResizeMouseDown = useEventCallback(({
|
|
153
|
+
colDef
|
|
154
|
+
}, event) => {
|
|
155
|
+
// Only handle left clicks
|
|
156
|
+
if (event.button !== 0) {
|
|
157
|
+
return;
|
|
158
|
+
} // Skip if the column isn't resizable
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
if (!event.currentTarget.classList.contains(gridClasses['columnSeparator--resizable'])) {
|
|
162
|
+
return;
|
|
163
|
+
} // Avoid text selection
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
logger.debug(`Start Resize on col ${colDef.field}`);
|
|
168
|
+
apiRef.current.publishEvent(GridEvents.columnResizeStart, {
|
|
169
|
+
field: colDef.field
|
|
170
|
+
}, event);
|
|
171
|
+
colDefRef.current = colDef;
|
|
172
|
+
colElementRef.current = apiRef.current.columnHeadersContainerElementRef?.current.querySelector(`[data-field="${colDef.field}"]`);
|
|
173
|
+
colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current);
|
|
174
|
+
const doc = ownerDocument(apiRef.current.rootElementRef.current);
|
|
175
|
+
doc.body.style.cursor = 'col-resize';
|
|
176
|
+
separatorSide.current = getSeparatorSide(event.currentTarget);
|
|
177
|
+
initialOffsetToSeparator.current = computeOffsetToSeparator(event.clientX, colElementRef.current.getBoundingClientRect(), separatorSide.current);
|
|
178
|
+
doc.addEventListener('mousemove', handleResizeMouseMove);
|
|
179
|
+
doc.addEventListener('mouseup', handleResizeMouseUp);
|
|
180
|
+
});
|
|
181
|
+
const handleTouchEnd = useEventCallback(nativeEvent => {
|
|
182
|
+
const finger = trackFinger(nativeEvent, touchId.current);
|
|
183
|
+
|
|
184
|
+
if (!finger) {
|
|
185
|
+
return;
|
|
186
|
+
} // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
stopListening();
|
|
190
|
+
apiRef.current.updateColumn(colDefRef.current);
|
|
191
|
+
clearTimeout(stopResizeEventTimeout.current);
|
|
192
|
+
stopResizeEventTimeout.current = setTimeout(() => {
|
|
193
|
+
apiRef.current.publishEvent(GridEvents.columnResizeStop, null, nativeEvent);
|
|
194
|
+
});
|
|
195
|
+
logger.debug(`Updating col ${colDefRef.current.field} with new width: ${colDefRef.current.width}`);
|
|
196
|
+
});
|
|
197
|
+
const handleTouchMove = useEventCallback(nativeEvent => {
|
|
198
|
+
const finger = trackFinger(nativeEvent, touchId.current);
|
|
199
|
+
|
|
200
|
+
if (!finger) {
|
|
201
|
+
return;
|
|
202
|
+
} // Cancel move in case some other element consumed a touchmove event and it was not fired.
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
if (nativeEvent.type === 'mousemove' && nativeEvent.buttons === 0) {
|
|
206
|
+
handleTouchEnd(nativeEvent);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
let newWidth = computeNewWidth(initialOffsetToSeparator.current, finger.x, colElementRef.current.getBoundingClientRect(), separatorSide.current);
|
|
211
|
+
newWidth = clamp(newWidth, colDefRef.current.minWidth, colDefRef.current.maxWidth);
|
|
212
|
+
updateWidth(newWidth);
|
|
213
|
+
const params = {
|
|
214
|
+
element: colElementRef.current,
|
|
215
|
+
colDef: colDefRef.current,
|
|
216
|
+
width: newWidth
|
|
217
|
+
};
|
|
218
|
+
apiRef.current.publishEvent(GridEvents.columnResize, params, nativeEvent);
|
|
219
|
+
});
|
|
220
|
+
const handleTouchStart = useEventCallback(event => {
|
|
221
|
+
const cellSeparator = findParentElementFromClassName(event.target, gridClasses['columnSeparator--resizable']); // Let the event bubble if the target is not a col separator
|
|
222
|
+
|
|
223
|
+
if (!cellSeparator) {
|
|
224
|
+
return;
|
|
225
|
+
} // If touch-action: none; is not supported we need to prevent the scroll manually.
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
if (!doesSupportTouchActionNone()) {
|
|
229
|
+
event.preventDefault();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const touch = event.changedTouches[0];
|
|
233
|
+
|
|
234
|
+
if (touch != null) {
|
|
235
|
+
// A number that uniquely identifies the current finger in the touch session.
|
|
236
|
+
touchId.current = touch.identifier;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
colElementRef.current = findParentElementFromClassName(event.target, gridClasses.columnHeader);
|
|
240
|
+
const field = getFieldFromHeaderElem(colElementRef.current);
|
|
241
|
+
const colDef = apiRef.current.getColumn(field);
|
|
242
|
+
logger.debug(`Start Resize on col ${colDef.field}`);
|
|
243
|
+
apiRef.current.publishEvent(GridEvents.columnResizeStart, {
|
|
244
|
+
field
|
|
245
|
+
}, event);
|
|
246
|
+
colDefRef.current = colDef;
|
|
247
|
+
colElementRef.current = findHeaderElementFromField(apiRef.current.columnHeadersElementRef?.current, colDef.field);
|
|
248
|
+
colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current);
|
|
249
|
+
separatorSide.current = getSeparatorSide(event.target);
|
|
250
|
+
initialOffsetToSeparator.current = computeOffsetToSeparator(touch.clientX, colElementRef.current.getBoundingClientRect(), separatorSide.current);
|
|
251
|
+
const doc = ownerDocument(event.currentTarget);
|
|
252
|
+
doc.addEventListener('touchmove', handleTouchMove);
|
|
253
|
+
doc.addEventListener('touchend', handleTouchEnd);
|
|
254
|
+
});
|
|
255
|
+
const stopListening = React.useCallback(() => {
|
|
256
|
+
const doc = ownerDocument(apiRef.current.rootElementRef.current);
|
|
257
|
+
doc.body.style.removeProperty('cursor');
|
|
258
|
+
doc.removeEventListener('mousemove', handleResizeMouseMove);
|
|
259
|
+
doc.removeEventListener('mouseup', handleResizeMouseUp);
|
|
260
|
+
doc.removeEventListener('touchmove', handleTouchMove);
|
|
261
|
+
doc.removeEventListener('touchend', handleTouchEnd);
|
|
262
|
+
}, [apiRef, handleResizeMouseMove, handleResizeMouseUp, handleTouchMove, handleTouchEnd]);
|
|
263
|
+
const handleResizeStart = React.useCallback(({
|
|
264
|
+
field
|
|
265
|
+
}) => {
|
|
266
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
267
|
+
columnResize: _extends({}, state.columnResize, {
|
|
268
|
+
resizingColumnField: field
|
|
269
|
+
})
|
|
270
|
+
}));
|
|
271
|
+
apiRef.current.forceUpdate();
|
|
272
|
+
}, [apiRef]);
|
|
273
|
+
const handleResizeStop = React.useCallback(() => {
|
|
274
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
275
|
+
columnResize: _extends({}, state.columnResize, {
|
|
276
|
+
resizingColumnField: ''
|
|
277
|
+
})
|
|
278
|
+
}));
|
|
279
|
+
apiRef.current.forceUpdate();
|
|
280
|
+
}, [apiRef]);
|
|
281
|
+
React.useEffect(() => {
|
|
282
|
+
return () => {
|
|
283
|
+
clearTimeout(stopResizeEventTimeout.current);
|
|
284
|
+
stopListening();
|
|
285
|
+
};
|
|
286
|
+
}, [apiRef, handleTouchStart, stopListening]);
|
|
287
|
+
useGridNativeEventListener(apiRef, () => apiRef.current.columnHeadersElementRef?.current, 'touchstart', handleTouchStart, {
|
|
288
|
+
passive: doesSupportTouchActionNone()
|
|
289
|
+
});
|
|
290
|
+
useGridApiEventHandler(apiRef, GridEvents.columnSeparatorMouseDown, handleColumnResizeMouseDown);
|
|
291
|
+
useGridApiEventHandler(apiRef, GridEvents.columnResizeStart, handleResizeStart);
|
|
292
|
+
useGridApiEventHandler(apiRef, GridEvents.columnResizeStop, handleResizeStop);
|
|
293
|
+
useGridApiOptionHandler(apiRef, GridEvents.columnResize, props.onColumnResize);
|
|
294
|
+
useGridApiOptionHandler(apiRef, GridEvents.columnWidthChange, props.onColumnWidthChange);
|
|
295
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const gridDetailPanelExpandedRowIdsSelector = state => state.detailPanel.expandedRowIds;
|
|
2
|
+
export const gridDetailPanelExpandedRowsContentCacheSelector = state => state.detailPanel.contentCache;
|
|
3
|
+
export const gridDetailPanelExpandedRowsHeightCacheSelector = state => state.detailPanel.heightCache;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { GRID_STRING_COL_DEF } from '@mui/x-data-grid';
|
|
4
|
+
import { GridDetailPanelToggleCell } from '../../../components/GridDetailPanelToggleCell';
|
|
5
|
+
import { gridDetailPanelExpandedRowIdsSelector } from './gridDetailPanelSelector';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export const GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
|
|
8
|
+
export const GRID_DETAIL_PANEL_TOGGLE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
9
|
+
field: GRID_DETAIL_PANEL_TOGGLE_FIELD,
|
|
10
|
+
headerName: '',
|
|
11
|
+
type: 'detailPanelToggle',
|
|
12
|
+
editable: false,
|
|
13
|
+
sortable: false,
|
|
14
|
+
filterable: false,
|
|
15
|
+
resizable: false,
|
|
16
|
+
disableColumnMenu: true,
|
|
17
|
+
disableReorder: true,
|
|
18
|
+
disableExport: true,
|
|
19
|
+
align: 'left',
|
|
20
|
+
width: 40,
|
|
21
|
+
valueGetter: params => {
|
|
22
|
+
const expandedRowIds = gridDetailPanelExpandedRowIdsSelector(params.api.state);
|
|
23
|
+
return expandedRowIds.includes(params.id);
|
|
24
|
+
},
|
|
25
|
+
renderCell: params => /*#__PURE__*/_jsx(GridDetailPanelToggleCell, _extends({}, params))
|
|
26
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
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 { 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 detailPanelStateInitializer = (state, props) => {
|
|
8
|
+
return _extends({}, state, {
|
|
9
|
+
detailPanel: {
|
|
10
|
+
expandedRowIds: props.detailPanelExpandedRowIds ?? props.initialState?.detailPanel?.expandedRowIds ?? []
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
export const useGridDetailPanel = (apiRef, props) => {
|
|
15
|
+
const expandedRowIds = useGridSelector(apiRef, gridDetailPanelExpandedRowIdsSelector);
|
|
16
|
+
const contentCache = useGridSelector(apiRef, gridDetailPanelExpandedRowsContentCacheSelector);
|
|
17
|
+
const handleCellClick = React.useCallback((params, event) => {
|
|
18
|
+
if (params.field !== GRID_DETAIL_PANEL_TOGGLE_FIELD || props.getDetailPanelContent == null) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const content = contentCache[params.id];
|
|
23
|
+
|
|
24
|
+
if (! /*#__PURE__*/React.isValidElement(content)) {
|
|
25
|
+
return;
|
|
26
|
+
} // Ignore if the user didn't click specifically in the "i" button
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if (event.target === event.currentTarget) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
apiRef.current.toggleDetailPanel(params.id);
|
|
34
|
+
}, [apiRef, contentCache, props.getDetailPanelContent]);
|
|
35
|
+
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
36
|
+
if (!event.ctrlKey || event.key !== 'Enter' || props.getDetailPanelContent == null) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
apiRef.current.toggleDetailPanel(params.id);
|
|
41
|
+
}, [apiRef, props.getDetailPanelContent]);
|
|
42
|
+
useGridApiEventHandler(apiRef, GridEvents.cellClick, handleCellClick);
|
|
43
|
+
useGridApiEventHandler(apiRef, GridEvents.cellKeyDown, handleCellKeyDown);
|
|
44
|
+
const addDetailHeight = React.useCallback((initialValue, row) => {
|
|
45
|
+
if (expandedRowIds.length === 0 || !expandedRowIds.includes(row.id)) {
|
|
46
|
+
return _extends({}, initialValue, {
|
|
47
|
+
detail: 0
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const heightCache = gridDetailPanelExpandedRowsHeightCacheSelector(apiRef.current.state);
|
|
52
|
+
return _extends({}, initialValue, {
|
|
53
|
+
detail: heightCache[row.id] ?? 0 // Fallback to zero because the cache might not be ready yet (e.g. page was changed)
|
|
54
|
+
|
|
55
|
+
});
|
|
56
|
+
}, [apiRef, expandedRowIds]);
|
|
57
|
+
useGridRegisterPreProcessor(apiRef, 'rowHeight', addDetailHeight);
|
|
58
|
+
apiRef.current.unstable_updateControlState({
|
|
59
|
+
stateId: 'detailPanels',
|
|
60
|
+
propModel: props.detailPanelExpandedRowIds,
|
|
61
|
+
propOnChange: props.onDetailPanelExpandedRowIdsChange,
|
|
62
|
+
stateSelector: gridDetailPanelExpandedRowIdsSelector,
|
|
63
|
+
changeEvent: GridEvents.detailPanelsExpandedRowIdsChange
|
|
64
|
+
});
|
|
65
|
+
const toggleDetailPanel = React.useCallback(id => {
|
|
66
|
+
if (props.getDetailPanelContent == null) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const content = contentCache[id];
|
|
71
|
+
|
|
72
|
+
if (! /*#__PURE__*/React.isValidElement(content)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const ids = apiRef.current.getExpandedDetailPanels();
|
|
77
|
+
apiRef.current.setExpandedDetailPanels(ids.includes(id) ? ids.filter(rowId => rowId !== id) : [...ids, id]);
|
|
78
|
+
}, [apiRef, contentCache, props.getDetailPanelContent]);
|
|
79
|
+
const getExpandedDetailPanels = React.useCallback(() => gridDetailPanelExpandedRowIdsSelector(apiRef.current.state), [apiRef]);
|
|
80
|
+
const setExpandedDetailPanels = React.useCallback(ids => {
|
|
81
|
+
apiRef.current.setState(state => {
|
|
82
|
+
return _extends({}, state, {
|
|
83
|
+
detailPanel: _extends({}, state.detailPanel, {
|
|
84
|
+
expandedRowIds: ids
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
apiRef.current.forceUpdate();
|
|
89
|
+
}, [apiRef]);
|
|
90
|
+
const detailPanelApi = {
|
|
91
|
+
toggleDetailPanel,
|
|
92
|
+
getExpandedDetailPanels,
|
|
93
|
+
setExpandedDetailPanels
|
|
94
|
+
};
|
|
95
|
+
useGridApiMethod(apiRef, detailPanelApi, 'detailPanelApi');
|
|
96
|
+
React.useEffect(() => {
|
|
97
|
+
if (props.detailPanelExpandedRowIds) {
|
|
98
|
+
const currentModel = gridDetailPanelExpandedRowIdsSelector(apiRef.current.state);
|
|
99
|
+
|
|
100
|
+
if (currentModel !== props.detailPanelExpandedRowIds) {
|
|
101
|
+
apiRef.current.setExpandedDetailPanels(props.detailPanelExpandedRowIds);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, [apiRef, props.detailPanelExpandedRowIds]);
|
|
105
|
+
};
|
|
@@ -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,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,52 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useGridSelector, GridEvents, useGridApiEventHandler, useGridApiOptionHandler, gridVisibleColumnDefinitionsSelector, gridRowsMetaSelector } from '@mui/x-data-grid';
|
|
3
|
+
import { useGridVisibleRows } 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 = useGridVisibleRows(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
|
+
};
|