@mui/x-data-grid-pro 5.5.1 → 5.7.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 +229 -0
- package/DataGridPro/DataGridPro.d.ts +3 -0
- package/DataGridPro/DataGridPro.js +915 -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 +84 -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/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 +37 -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 +27 -0
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +139 -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 +204 -0
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +4 -0
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +203 -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 +15 -0
- package/hooks/features/treeData/gridTreeDataUtils.js +88 -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 +6 -0
- package/hooks/features/treeData/useGridTreeData.js +29 -0
- package/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +4 -0
- package/hooks/features/treeData/useGridTreeDataPreProcessors.js +138 -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 +915 -0
- package/legacy/DataGridPro/index.js +2 -0
- package/legacy/DataGridPro/useDataGridProComponent.js +84 -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/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 +147 -0
- package/legacy/hooks/features/rowGrouping/index.js +3 -0
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +210 -0
- package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +217 -0
- package/legacy/hooks/features/treeData/gridTreeDataGroupColDef.js +24 -0
- package/legacy/hooks/features/treeData/gridTreeDataUtils.js +86 -0
- package/legacy/hooks/features/treeData/index.js +1 -0
- package/legacy/hooks/features/treeData/useGridTreeData.js +29 -0
- package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +153 -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/releaseInfo.js +15 -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 +915 -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/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 +137 -0
- package/modern/hooks/features/rowGrouping/index.js +3 -0
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +196 -0
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +203 -0
- package/modern/hooks/features/treeData/gridTreeDataGroupColDef.js +22 -0
- package/modern/hooks/features/treeData/gridTreeDataUtils.js +84 -0
- package/modern/hooks/features/treeData/index.js +1 -0
- package/modern/hooks/features/treeData/useGridTreeData.js +27 -0
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +136 -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/releaseInfo.js +15 -0
- package/modern/utils/tree/buildRowTree.js +167 -0
- package/modern/utils/tree/sortRowTree.js +60 -0
- package/node/DataGridPro/DataGridPro.js +939 -0
- package/node/DataGridPro/index.js +30 -0
- package/node/DataGridPro/useDataGridProComponent.js +106 -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/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 +172 -0
- package/node/hooks/features/rowGrouping/index.js +51 -0
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +232 -0
- package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +227 -0
- package/node/hooks/features/treeData/gridTreeDataGroupColDef.js +35 -0
- package/node/hooks/features/treeData/gridTreeDataUtils.js +98 -0
- package/node/hooks/features/treeData/index.js +13 -0
- package/node/hooks/features/treeData/useGridTreeData.js +43 -0
- package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +164 -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/releaseInfo.js +25 -0
- package/node/utils/tree/buildRowTree.js +185 -0
- package/node/utils/tree/sortRowTree.js +69 -0
- package/package.json +11 -12
- package/themeAugmentation/index.d.ts +2 -2
- package/themeAugmentation/index.js +3 -0
- package/themeAugmentation/overrides.d.ts +8 -8
- package/themeAugmentation/overrides.js +1 -0
- package/themeAugmentation/package.json +6 -0
- package/themeAugmentation/props.d.ts +19 -19
- package/themeAugmentation/props.js +1 -0
- package/typeOverloads/modules.d.ts +41 -0
- package/typeOverloads/modules.js +1 -0
- package/typeOverloads/reexports.d.ts +22 -0
- package/typeOverloads/reexports.js +6 -0
- package/utils/domUtils.d.ts +3 -0
- package/utils/domUtils.js +19 -0
- package/utils/releaseInfo.d.ts +1 -0
- package/utils/releaseInfo.js +15 -0
- package/utils/tree/buildRowTree.d.ts +47 -0
- package/utils/tree/buildRowTree.js +179 -0
- package/utils/tree/sortRowTree.d.ts +10 -0
- package/utils/tree/sortRowTree.js +60 -0
- package/LICENSE +0 -12
- package/index-cjs.js +0 -15
- package/index-esm.js +0 -15
- package/x-data-grid-pro.d.ts +0 -5495
|
@@ -0,0 +1,310 @@
|
|
|
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
|
+
var 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 (var i = 0; i < event.changedTouches.length; i += 1) {
|
|
34
|
+
var 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
|
+
var 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 var columnResizeStateInitializer = function columnResizeStateInitializer(state) {
|
|
78
|
+
return _extends({}, state, {
|
|
79
|
+
columnResize: {
|
|
80
|
+
resizingColumnField: ''
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Only available in DataGridPro
|
|
86
|
+
* @requires useGridColumns (method, event)
|
|
87
|
+
* TODO: improve experience for last column
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
export var useGridColumnResize = function useGridColumnResize(apiRef, props) {
|
|
91
|
+
var logger = useGridLogger(apiRef, 'useGridColumnResize');
|
|
92
|
+
var colDefRef = React.useRef();
|
|
93
|
+
var colElementRef = React.useRef();
|
|
94
|
+
var colCellElementsRef = React.useRef(); // To improve accessibility, the separator has padding on both sides.
|
|
95
|
+
// Clicking inside the padding area should be treated as a click in the separator.
|
|
96
|
+
// This ref stores the offset between the click and the separator.
|
|
97
|
+
|
|
98
|
+
var initialOffsetToSeparator = React.useRef();
|
|
99
|
+
var separatorSide = React.useRef();
|
|
100
|
+
var stopResizeEventTimeout = React.useRef();
|
|
101
|
+
var touchId = React.useRef();
|
|
102
|
+
|
|
103
|
+
var updateWidth = function updateWidth(newWidth) {
|
|
104
|
+
logger.debug("Updating width to ".concat(newWidth, " for col ").concat(colDefRef.current.field));
|
|
105
|
+
colDefRef.current.computedWidth = newWidth;
|
|
106
|
+
colDefRef.current.width = newWidth;
|
|
107
|
+
colDefRef.current.flex = undefined;
|
|
108
|
+
colElementRef.current.style.width = "".concat(newWidth, "px");
|
|
109
|
+
colElementRef.current.style.minWidth = "".concat(newWidth, "px");
|
|
110
|
+
colElementRef.current.style.maxWidth = "".concat(newWidth, "px");
|
|
111
|
+
colCellElementsRef.current.forEach(function (element) {
|
|
112
|
+
var div = element;
|
|
113
|
+
div.style.width = "".concat(newWidth, "px");
|
|
114
|
+
div.style.minWidth = "".concat(newWidth, "px");
|
|
115
|
+
div.style.maxWidth = "".concat(newWidth, "px");
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
var handleResizeMouseUp = useEventCallback(function (nativeEvent) {
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
121
|
+
stopListening();
|
|
122
|
+
apiRef.current.updateColumn(colDefRef.current);
|
|
123
|
+
clearTimeout(stopResizeEventTimeout.current);
|
|
124
|
+
stopResizeEventTimeout.current = setTimeout(function () {
|
|
125
|
+
apiRef.current.publishEvent(GridEvents.columnResizeStop, null, nativeEvent);
|
|
126
|
+
|
|
127
|
+
if (colDefRef.current) {
|
|
128
|
+
var _colDefRef$current;
|
|
129
|
+
|
|
130
|
+
apiRef.current.publishEvent(GridEvents.columnWidthChange, {
|
|
131
|
+
element: colElementRef.current,
|
|
132
|
+
colDef: colDefRef.current,
|
|
133
|
+
width: (_colDefRef$current = colDefRef.current) == null ? void 0 : _colDefRef$current.computedWidth
|
|
134
|
+
}, nativeEvent);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
logger.debug("Updating col ".concat(colDefRef.current.field, " with new width: ").concat(colDefRef.current.width));
|
|
138
|
+
});
|
|
139
|
+
var handleResizeMouseMove = useEventCallback(function (nativeEvent) {
|
|
140
|
+
// Cancel move in case some other element consumed a mouseup event and it was not fired.
|
|
141
|
+
if (nativeEvent.buttons === 0) {
|
|
142
|
+
handleResizeMouseUp(nativeEvent);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var newWidth = computeNewWidth(initialOffsetToSeparator.current, nativeEvent.clientX, colElementRef.current.getBoundingClientRect(), separatorSide.current);
|
|
147
|
+
newWidth = clamp(newWidth, colDefRef.current.minWidth, colDefRef.current.maxWidth);
|
|
148
|
+
updateWidth(newWidth);
|
|
149
|
+
var params = {
|
|
150
|
+
element: colElementRef.current,
|
|
151
|
+
colDef: colDefRef.current,
|
|
152
|
+
width: newWidth
|
|
153
|
+
};
|
|
154
|
+
apiRef.current.publishEvent(GridEvents.columnResize, params, nativeEvent);
|
|
155
|
+
});
|
|
156
|
+
var handleColumnResizeMouseDown = useEventCallback(function (_ref, event) {
|
|
157
|
+
var _apiRef$current$colum;
|
|
158
|
+
|
|
159
|
+
var colDef = _ref.colDef;
|
|
160
|
+
|
|
161
|
+
// Only handle left clicks
|
|
162
|
+
if (event.button !== 0) {
|
|
163
|
+
return;
|
|
164
|
+
} // Skip if the column isn't resizable
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
if (!event.currentTarget.classList.contains(gridClasses['columnSeparator--resizable'])) {
|
|
168
|
+
return;
|
|
169
|
+
} // Avoid text selection
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
logger.debug("Start Resize on col ".concat(colDef.field));
|
|
174
|
+
apiRef.current.publishEvent(GridEvents.columnResizeStart, {
|
|
175
|
+
field: colDef.field
|
|
176
|
+
}, event);
|
|
177
|
+
colDefRef.current = colDef;
|
|
178
|
+
colElementRef.current = (_apiRef$current$colum = apiRef.current.columnHeadersContainerElementRef) == null ? void 0 : _apiRef$current$colum.current.querySelector("[data-field=\"".concat(colDef.field, "\"]"));
|
|
179
|
+
colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current);
|
|
180
|
+
var doc = ownerDocument(apiRef.current.rootElementRef.current);
|
|
181
|
+
doc.body.style.cursor = 'col-resize';
|
|
182
|
+
separatorSide.current = getSeparatorSide(event.currentTarget);
|
|
183
|
+
initialOffsetToSeparator.current = computeOffsetToSeparator(event.clientX, colElementRef.current.getBoundingClientRect(), separatorSide.current);
|
|
184
|
+
doc.addEventListener('mousemove', handleResizeMouseMove);
|
|
185
|
+
doc.addEventListener('mouseup', handleResizeMouseUp);
|
|
186
|
+
});
|
|
187
|
+
var handleTouchEnd = useEventCallback(function (nativeEvent) {
|
|
188
|
+
var finger = trackFinger(nativeEvent, touchId.current);
|
|
189
|
+
|
|
190
|
+
if (!finger) {
|
|
191
|
+
return;
|
|
192
|
+
} // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
stopListening();
|
|
196
|
+
apiRef.current.updateColumn(colDefRef.current);
|
|
197
|
+
clearTimeout(stopResizeEventTimeout.current);
|
|
198
|
+
stopResizeEventTimeout.current = setTimeout(function () {
|
|
199
|
+
apiRef.current.publishEvent(GridEvents.columnResizeStop, null, nativeEvent);
|
|
200
|
+
});
|
|
201
|
+
logger.debug("Updating col ".concat(colDefRef.current.field, " with new width: ").concat(colDefRef.current.width));
|
|
202
|
+
});
|
|
203
|
+
var handleTouchMove = useEventCallback(function (nativeEvent) {
|
|
204
|
+
var finger = trackFinger(nativeEvent, touchId.current);
|
|
205
|
+
|
|
206
|
+
if (!finger) {
|
|
207
|
+
return;
|
|
208
|
+
} // Cancel move in case some other element consumed a touchmove event and it was not fired.
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
if (nativeEvent.type === 'mousemove' && nativeEvent.buttons === 0) {
|
|
212
|
+
handleTouchEnd(nativeEvent);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
var newWidth = computeNewWidth(initialOffsetToSeparator.current, finger.x, colElementRef.current.getBoundingClientRect(), separatorSide.current);
|
|
217
|
+
newWidth = clamp(newWidth, colDefRef.current.minWidth, colDefRef.current.maxWidth);
|
|
218
|
+
updateWidth(newWidth);
|
|
219
|
+
var params = {
|
|
220
|
+
element: colElementRef.current,
|
|
221
|
+
colDef: colDefRef.current,
|
|
222
|
+
width: newWidth
|
|
223
|
+
};
|
|
224
|
+
apiRef.current.publishEvent(GridEvents.columnResize, params, nativeEvent);
|
|
225
|
+
});
|
|
226
|
+
var handleTouchStart = useEventCallback(function (event) {
|
|
227
|
+
var _apiRef$current$colum2;
|
|
228
|
+
|
|
229
|
+
var cellSeparator = findParentElementFromClassName(event.target, gridClasses['columnSeparator--resizable']); // Let the event bubble if the target is not a col separator
|
|
230
|
+
|
|
231
|
+
if (!cellSeparator) {
|
|
232
|
+
return;
|
|
233
|
+
} // If touch-action: none; is not supported we need to prevent the scroll manually.
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
if (!doesSupportTouchActionNone()) {
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
var touch = event.changedTouches[0];
|
|
241
|
+
|
|
242
|
+
if (touch != null) {
|
|
243
|
+
// A number that uniquely identifies the current finger in the touch session.
|
|
244
|
+
touchId.current = touch.identifier;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
colElementRef.current = findParentElementFromClassName(event.target, gridClasses.columnHeader);
|
|
248
|
+
var field = getFieldFromHeaderElem(colElementRef.current);
|
|
249
|
+
var colDef = apiRef.current.getColumn(field);
|
|
250
|
+
logger.debug("Start Resize on col ".concat(colDef.field));
|
|
251
|
+
apiRef.current.publishEvent(GridEvents.columnResizeStart, {
|
|
252
|
+
field: field
|
|
253
|
+
}, event);
|
|
254
|
+
colDefRef.current = colDef;
|
|
255
|
+
colElementRef.current = findHeaderElementFromField((_apiRef$current$colum2 = apiRef.current.columnHeadersElementRef) == null ? void 0 : _apiRef$current$colum2.current, colDef.field);
|
|
256
|
+
colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current);
|
|
257
|
+
separatorSide.current = getSeparatorSide(event.target);
|
|
258
|
+
initialOffsetToSeparator.current = computeOffsetToSeparator(touch.clientX, colElementRef.current.getBoundingClientRect(), separatorSide.current);
|
|
259
|
+
var doc = ownerDocument(event.currentTarget);
|
|
260
|
+
doc.addEventListener('touchmove', handleTouchMove);
|
|
261
|
+
doc.addEventListener('touchend', handleTouchEnd);
|
|
262
|
+
});
|
|
263
|
+
var stopListening = React.useCallback(function () {
|
|
264
|
+
var doc = ownerDocument(apiRef.current.rootElementRef.current);
|
|
265
|
+
doc.body.style.removeProperty('cursor');
|
|
266
|
+
doc.removeEventListener('mousemove', handleResizeMouseMove);
|
|
267
|
+
doc.removeEventListener('mouseup', handleResizeMouseUp);
|
|
268
|
+
doc.removeEventListener('touchmove', handleTouchMove);
|
|
269
|
+
doc.removeEventListener('touchend', handleTouchEnd);
|
|
270
|
+
}, [apiRef, handleResizeMouseMove, handleResizeMouseUp, handleTouchMove, handleTouchEnd]);
|
|
271
|
+
var handleResizeStart = React.useCallback(function (_ref2) {
|
|
272
|
+
var field = _ref2.field;
|
|
273
|
+
apiRef.current.setState(function (state) {
|
|
274
|
+
return _extends({}, state, {
|
|
275
|
+
columnResize: _extends({}, state.columnResize, {
|
|
276
|
+
resizingColumnField: field
|
|
277
|
+
})
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
apiRef.current.forceUpdate();
|
|
281
|
+
}, [apiRef]);
|
|
282
|
+
var handleResizeStop = React.useCallback(function () {
|
|
283
|
+
apiRef.current.setState(function (state) {
|
|
284
|
+
return _extends({}, state, {
|
|
285
|
+
columnResize: _extends({}, state.columnResize, {
|
|
286
|
+
resizingColumnField: ''
|
|
287
|
+
})
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
apiRef.current.forceUpdate();
|
|
291
|
+
}, [apiRef]);
|
|
292
|
+
React.useEffect(function () {
|
|
293
|
+
return function () {
|
|
294
|
+
clearTimeout(stopResizeEventTimeout.current);
|
|
295
|
+
stopListening();
|
|
296
|
+
};
|
|
297
|
+
}, [apiRef, handleTouchStart, stopListening]);
|
|
298
|
+
useGridNativeEventListener(apiRef, function () {
|
|
299
|
+
var _apiRef$current$colum3;
|
|
300
|
+
|
|
301
|
+
return (_apiRef$current$colum3 = apiRef.current.columnHeadersElementRef) == null ? void 0 : _apiRef$current$colum3.current;
|
|
302
|
+
}, 'touchstart', handleTouchStart, {
|
|
303
|
+
passive: doesSupportTouchActionNone()
|
|
304
|
+
});
|
|
305
|
+
useGridApiEventHandler(apiRef, GridEvents.columnSeparatorMouseDown, handleColumnResizeMouseDown);
|
|
306
|
+
useGridApiEventHandler(apiRef, GridEvents.columnResizeStart, handleResizeStart);
|
|
307
|
+
useGridApiEventHandler(apiRef, GridEvents.columnResizeStop, handleResizeStop);
|
|
308
|
+
useGridApiOptionHandler(apiRef, GridEvents.columnResize, props.onColumnResize);
|
|
309
|
+
useGridApiOptionHandler(apiRef, GridEvents.columnWidthChange, props.onColumnWidthChange);
|
|
310
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var gridDetailPanelExpandedRowIdsSelector = function gridDetailPanelExpandedRowIdsSelector(state) {
|
|
2
|
+
return state.detailPanel.expandedRowIds;
|
|
3
|
+
};
|
|
4
|
+
export var gridDetailPanelExpandedRowsContentCacheSelector = function gridDetailPanelExpandedRowsContentCacheSelector(state) {
|
|
5
|
+
return state.detailPanel.contentCache;
|
|
6
|
+
};
|
|
7
|
+
export var gridDetailPanelExpandedRowsHeightCacheSelector = function gridDetailPanelExpandedRowsHeightCacheSelector(state) {
|
|
8
|
+
return state.detailPanel.heightCache;
|
|
9
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
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 var GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
|
|
8
|
+
export var 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: function valueGetter(params) {
|
|
22
|
+
var expandedRowIds = gridDetailPanelExpandedRowIdsSelector(params.api.state);
|
|
23
|
+
return expandedRowIds.includes(params.id);
|
|
24
|
+
},
|
|
25
|
+
renderCell: function renderCell(params) {
|
|
26
|
+
return /*#__PURE__*/_jsx(GridDetailPanelToggleCell, _extends({}, params));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { GridEvents, useGridSelector, useGridApiEventHandler, useGridApiMethod } from '@mui/x-data-grid';
|
|
5
|
+
import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
|
|
6
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from './gridDetailPanelToggleColDef';
|
|
7
|
+
import { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector } from './gridDetailPanelSelector';
|
|
8
|
+
export var detailPanelStateInitializer = function detailPanelStateInitializer(state, props) {
|
|
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
|
+
export var useGridDetailPanel = function useGridDetailPanel(apiRef, props) {
|
|
18
|
+
var expandedRowIds = useGridSelector(apiRef, gridDetailPanelExpandedRowIdsSelector);
|
|
19
|
+
var contentCache = useGridSelector(apiRef, gridDetailPanelExpandedRowsContentCacheSelector);
|
|
20
|
+
var handleCellClick = React.useCallback(function (params, event) {
|
|
21
|
+
if (params.field !== GRID_DETAIL_PANEL_TOGGLE_FIELD || props.getDetailPanelContent == null) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var content = contentCache[params.id];
|
|
26
|
+
|
|
27
|
+
if (! /*#__PURE__*/React.isValidElement(content)) {
|
|
28
|
+
return;
|
|
29
|
+
} // Ignore if the user didn't click specifically in the "i" button
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
if (event.target === event.currentTarget) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
apiRef.current.toggleDetailPanel(params.id);
|
|
37
|
+
}, [apiRef, contentCache, props.getDetailPanelContent]);
|
|
38
|
+
var handleCellKeyDown = React.useCallback(function (params, event) {
|
|
39
|
+
if (!event.ctrlKey || event.key !== 'Enter' || props.getDetailPanelContent == null) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
apiRef.current.toggleDetailPanel(params.id);
|
|
44
|
+
}, [apiRef, props.getDetailPanelContent]);
|
|
45
|
+
useGridApiEventHandler(apiRef, GridEvents.cellClick, handleCellClick);
|
|
46
|
+
useGridApiEventHandler(apiRef, GridEvents.cellKeyDown, handleCellKeyDown);
|
|
47
|
+
var addDetailHeight = React.useCallback(function (initialValue, row) {
|
|
48
|
+
var _heightCache$row$id;
|
|
49
|
+
|
|
50
|
+
if (expandedRowIds.length === 0 || !expandedRowIds.includes(row.id)) {
|
|
51
|
+
return _extends({}, initialValue, {
|
|
52
|
+
detail: 0
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var heightCache = gridDetailPanelExpandedRowsHeightCacheSelector(apiRef.current.state);
|
|
57
|
+
return _extends({}, initialValue, {
|
|
58
|
+
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)
|
|
59
|
+
|
|
60
|
+
});
|
|
61
|
+
}, [apiRef, expandedRowIds]);
|
|
62
|
+
useGridRegisterPreProcessor(apiRef, 'rowHeight', addDetailHeight);
|
|
63
|
+
apiRef.current.unstable_updateControlState({
|
|
64
|
+
stateId: 'detailPanels',
|
|
65
|
+
propModel: props.detailPanelExpandedRowIds,
|
|
66
|
+
propOnChange: props.onDetailPanelExpandedRowIdsChange,
|
|
67
|
+
stateSelector: gridDetailPanelExpandedRowIdsSelector,
|
|
68
|
+
changeEvent: GridEvents.detailPanelsExpandedRowIdsChange
|
|
69
|
+
});
|
|
70
|
+
var toggleDetailPanel = React.useCallback(function (id) {
|
|
71
|
+
if (props.getDetailPanelContent == null) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var content = contentCache[id];
|
|
76
|
+
|
|
77
|
+
if (! /*#__PURE__*/React.isValidElement(content)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var ids = apiRef.current.getExpandedDetailPanels();
|
|
82
|
+
apiRef.current.setExpandedDetailPanels(ids.includes(id) ? ids.filter(function (rowId) {
|
|
83
|
+
return rowId !== id;
|
|
84
|
+
}) : [].concat(_toConsumableArray(ids), [id]));
|
|
85
|
+
}, [apiRef, contentCache, props.getDetailPanelContent]);
|
|
86
|
+
var getExpandedDetailPanels = React.useCallback(function () {
|
|
87
|
+
return gridDetailPanelExpandedRowIdsSelector(apiRef.current.state);
|
|
88
|
+
}, [apiRef]);
|
|
89
|
+
var setExpandedDetailPanels = React.useCallback(function (ids) {
|
|
90
|
+
apiRef.current.setState(function (state) {
|
|
91
|
+
return _extends({}, state, {
|
|
92
|
+
detailPanel: _extends({}, state.detailPanel, {
|
|
93
|
+
expandedRowIds: ids
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
apiRef.current.forceUpdate();
|
|
98
|
+
}, [apiRef]);
|
|
99
|
+
var detailPanelApi = {
|
|
100
|
+
toggleDetailPanel: toggleDetailPanel,
|
|
101
|
+
getExpandedDetailPanels: getExpandedDetailPanels,
|
|
102
|
+
setExpandedDetailPanels: setExpandedDetailPanels
|
|
103
|
+
};
|
|
104
|
+
useGridApiMethod(apiRef, detailPanelApi, 'detailPanelApi');
|
|
105
|
+
React.useEffect(function () {
|
|
106
|
+
if (props.detailPanelExpandedRowIds) {
|
|
107
|
+
var currentModel = gridDetailPanelExpandedRowIdsSelector(apiRef.current.state);
|
|
108
|
+
|
|
109
|
+
if (currentModel !== props.detailPanelExpandedRowIds) {
|
|
110
|
+
apiRef.current.setExpandedDetailPanels(props.detailPanelExpandedRowIds);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, [apiRef, props.detailPanelExpandedRowIds]);
|
|
114
|
+
};
|
|
@@ -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
|
+
var rowIds = gridRowIdsSelector(apiRef);
|
|
13
|
+
var contentCache = rowIds.reduce(function (acc, id) {
|
|
14
|
+
var params = apiRef.current.getRowParams(id);
|
|
15
|
+
acc[id] = getDetailPanelContent(params);
|
|
16
|
+
return acc;
|
|
17
|
+
}, {});
|
|
18
|
+
var heightCache = rowIds.reduce(function (acc, id) {
|
|
19
|
+
if (contentCache[id] == null) {
|
|
20
|
+
return acc;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var params = apiRef.current.getRowParams(id);
|
|
24
|
+
acc[id] = getDetailPanelHeight(params);
|
|
25
|
+
return acc;
|
|
26
|
+
}, {});
|
|
27
|
+
return {
|
|
28
|
+
contentCache: contentCache,
|
|
29
|
+
heightCache: heightCache
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export var useGridDetailPanelCache = function useGridDetailPanelCache(apiRef, props) {
|
|
34
|
+
var updateCaches = React.useCallback(function () {
|
|
35
|
+
apiRef.current.setState(function (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
|
+
var isFirstRender = React.useRef(true);
|
|
44
|
+
|
|
45
|
+
if (isFirstRender.current) {
|
|
46
|
+
isFirstRender.current = false;
|
|
47
|
+
updateCaches();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
React.useEffect(function () {
|
|
51
|
+
if (isFirstRender.current) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
updateCaches();
|
|
56
|
+
}, [updateCaches]);
|
|
57
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
|
|
4
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD, GRID_DETAIL_PANEL_TOGGLE_COL_DEF } from './gridDetailPanelToggleColDef';
|
|
5
|
+
export var useGridDetailPanelPreProcessors = function useGridDetailPanelPreProcessors(apiRef, props) {
|
|
6
|
+
var addToggleColumn = React.useCallback(function (columnsState) {
|
|
7
|
+
if (props.getDetailPanelContent == null) {
|
|
8
|
+
// Remove the toggle column, when it exists
|
|
9
|
+
if (columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD]) {
|
|
10
|
+
delete columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD];
|
|
11
|
+
columnsState.all = columnsState.all.filter(function (field) {
|
|
12
|
+
return field !== GRID_DETAIL_PANEL_TOGGLE_FIELD;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return columnsState;
|
|
17
|
+
} // Don't add the toggle column if there's already one
|
|
18
|
+
// The user might have manually added it to have it in a custom position
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if (columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD]) {
|
|
22
|
+
return columnsState;
|
|
23
|
+
} // Othewise, add the toggle column at the beginning
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
columnsState.all = [GRID_DETAIL_PANEL_TOGGLE_FIELD].concat(_toConsumableArray(columnsState.all));
|
|
27
|
+
columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD] = GRID_DETAIL_PANEL_TOGGLE_COL_DEF;
|
|
28
|
+
return columnsState;
|
|
29
|
+
}, [props.getDetailPanelContent]);
|
|
30
|
+
useGridRegisterPreProcessor(apiRef, 'hydrateColumns', addToggleColumn);
|
|
31
|
+
};
|
|
@@ -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,51 @@
|
|
|
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 var useGridInfiniteLoader = function useGridInfiniteLoader(apiRef, props) {
|
|
12
|
+
var visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
13
|
+
var currentPage = useGridVisibleRows(apiRef, props);
|
|
14
|
+
var rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
|
|
15
|
+
var contentHeight = Math.max(rowsMeta.currentPageTotalHeight, 1);
|
|
16
|
+
var isInScrollBottomArea = React.useRef(false);
|
|
17
|
+
var handleRowsScrollEnd = React.useCallback(function (scrollPosition) {
|
|
18
|
+
var dimensions = apiRef.current.getRootDimensions();
|
|
19
|
+
|
|
20
|
+
if (!dimensions) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var scrollPositionBottom = scrollPosition.top + dimensions.viewportOuterSize.height;
|
|
25
|
+
var 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
|
+
var rowScrollEndParam = {
|
|
33
|
+
visibleColumns: visibleColumns,
|
|
34
|
+
viewportPageSize: 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
|
+
var handleGridScroll = React.useCallback(function (_ref) {
|
|
42
|
+
var left = _ref.left,
|
|
43
|
+
top = _ref.top;
|
|
44
|
+
handleRowsScrollEnd({
|
|
45
|
+
left: left,
|
|
46
|
+
top: top
|
|
47
|
+
});
|
|
48
|
+
}, [handleRowsScrollEnd]);
|
|
49
|
+
useGridApiEventHandler(apiRef, GridEvents.rowsScroll, handleGridScroll);
|
|
50
|
+
useGridApiOptionHandler(apiRef, GridEvents.rowsScrollEnd, props.onRowsScrollEnd);
|
|
51
|
+
};
|