@mui/x-data-grid-pro 5.4.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +321 -113
- package/DataGridPro/DataGridPro.d.ts +3 -0
- package/DataGridPro/DataGridPro.js +896 -0
- package/DataGridPro/index.d.ts +2 -0
- package/DataGridPro/index.js +2 -0
- package/DataGridPro/package.json +6 -0
- package/DataGridPro/useDataGridProComponent.d.ts +4 -0
- package/DataGridPro/useDataGridProComponent.js +72 -0
- package/DataGridPro/useDataGridProProps.d.ts +6 -0
- package/DataGridPro/useDataGridProProps.js +49 -0
- package/components/DataGridProColumnHeaders.d.ts +6 -0
- package/components/DataGridProColumnHeaders.js +165 -0
- package/components/DataGridProVirtualScroller.d.ts +8 -0
- package/components/DataGridProVirtualScroller.js +281 -0
- package/components/GridColumnPinningMenuItems.d.ts +11 -0
- package/components/GridColumnPinningMenuItems.js +71 -0
- package/components/GridDetailPanelToggleCell.d.ts +7 -0
- package/components/GridDetailPanelToggleCell.js +124 -0
- package/components/GridGroupingColumnLeafCell.d.ts +4 -0
- package/components/GridGroupingColumnLeafCell.js +22 -0
- package/components/GridGroupingCriteriaCell.d.ts +10 -0
- package/components/GridGroupingCriteriaCell.js +150 -0
- package/components/GridRowGroupableColumnMenuItems.d.ts +11 -0
- package/components/GridRowGroupableColumnMenuItems.js +63 -0
- package/components/GridRowGroupingColumnMenuItems.d.ts +11 -0
- package/components/GridRowGroupingColumnMenuItems.js +58 -0
- package/components/GridTreeDataGroupingCell.d.ts +10 -0
- package/components/GridTreeDataGroupingCell.js +159 -0
- package/components/Watermark.d.ts +2 -0
- package/components/Watermark.js +43 -0
- package/components/index.d.ts +2 -0
- package/components/index.js +3 -0
- package/components/package.json +6 -0
- package/hooks/features/columnPinning/gridColumnPinningInterface.d.ts +42 -0
- package/hooks/features/columnPinning/gridColumnPinningInterface.js +11 -0
- package/hooks/features/columnPinning/gridColumnPinningSelector.d.ts +2 -0
- package/hooks/features/columnPinning/gridColumnPinningSelector.js +1 -0
- package/hooks/features/columnPinning/index.d.ts +2 -0
- package/hooks/features/columnPinning/index.js +2 -0
- package/hooks/features/columnPinning/useGridColumnPinning.d.ts +6 -0
- package/hooks/features/columnPinning/useGridColumnPinning.js +274 -0
- package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.d.ts +4 -0
- package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +45 -0
- package/hooks/features/columnReorder/columnReorderInterfaces.d.ts +6 -0
- package/hooks/features/columnReorder/columnReorderInterfaces.js +1 -0
- package/hooks/features/columnReorder/columnReorderSelector.d.ts +3 -0
- package/hooks/features/columnReorder/columnReorderSelector.js +3 -0
- package/hooks/features/columnReorder/index.d.ts +2 -0
- package/hooks/features/columnReorder/index.js +2 -0
- package/hooks/features/columnReorder/useGridColumnReorder.d.ts +8 -0
- package/hooks/features/columnReorder/useGridColumnReorder.js +166 -0
- package/hooks/features/columnResize/columnResizeSelector.d.ts +3 -0
- package/hooks/features/columnResize/columnResizeSelector.js +3 -0
- package/hooks/features/columnResize/columnResizeState.d.ts +3 -0
- package/hooks/features/columnResize/columnResizeState.js +1 -0
- package/hooks/features/columnResize/index.d.ts +2 -0
- package/hooks/features/columnResize/index.js +2 -0
- package/hooks/features/columnResize/useGridColumnResize.d.ts +9 -0
- package/hooks/features/columnResize/useGridColumnResize.js +305 -0
- package/hooks/features/detailPanel/gridDetailPanelInterface.d.ts +28 -0
- package/hooks/features/detailPanel/gridDetailPanelInterface.js +1 -0
- package/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +5 -0
- package/hooks/features/detailPanel/gridDetailPanelSelector.js +3 -0
- package/hooks/features/detailPanel/gridDetailPanelToggleColDef.d.ts +3 -0
- package/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +26 -0
- package/hooks/features/detailPanel/index.d.ts +3 -0
- package/hooks/features/detailPanel/index.js +3 -0
- package/hooks/features/detailPanel/useGridDetailPanel.d.ts +4 -0
- package/hooks/features/detailPanel/useGridDetailPanel.js +109 -0
- package/hooks/features/detailPanel/useGridDetailPanelCache.d.ts +4 -0
- package/hooks/features/detailPanel/useGridDetailPanelCache.js +57 -0
- package/hooks/features/detailPanel/useGridDetailPanelPreProcessors.d.ts +4 -0
- package/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +28 -0
- package/hooks/features/index.d.ts +6 -0
- package/hooks/features/index.js +7 -0
- package/hooks/features/infiniteLoader/useGridInfiniteLoader.d.ts +10 -0
- package/hooks/features/infiniteLoader/useGridInfiniteLoader.js +52 -0
- package/hooks/features/rowGrouping/createGroupingColDef.d.ts +43 -0
- package/hooks/features/rowGrouping/createGroupingColDef.js +318 -0
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +31 -0
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/hooks/features/rowGrouping/gridRowGroupingSelector.d.ts +4 -0
- package/hooks/features/rowGrouping/gridRowGroupingSelector.js +5 -0
- package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +24 -0
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +124 -0
- package/hooks/features/rowGrouping/index.d.ts +3 -0
- package/hooks/features/rowGrouping/index.js +3 -0
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +13 -0
- package/hooks/features/rowGrouping/useGridRowGrouping.js +325 -0
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +4 -0
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +76 -0
- package/hooks/features/treeData/gridTreeDataGroupColDef.d.ts +7 -0
- package/hooks/features/treeData/gridTreeDataGroupColDef.js +22 -0
- package/hooks/features/treeData/gridTreeDataUtils.d.ts +14 -0
- package/hooks/features/treeData/gridTreeDataUtils.js +86 -0
- package/hooks/features/treeData/index.d.ts +1 -0
- package/hooks/features/treeData/index.js +1 -0
- package/hooks/features/treeData/useGridTreeData.d.ts +10 -0
- package/hooks/features/treeData/useGridTreeData.js +108 -0
- package/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +4 -0
- package/hooks/features/treeData/useGridTreeDataPreProcessors.js +69 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/package.json +6 -0
- package/hooks/utils/useGridApiContext.d.ts +4 -0
- package/hooks/utils/useGridApiContext.js +2 -0
- package/hooks/utils/useGridApiRef.d.ts +4 -0
- package/hooks/utils/useGridApiRef.js +2 -0
- package/hooks/utils/useGridRootProps.d.ts +2 -0
- package/hooks/utils/useGridRootProps.js +2 -0
- package/index.d.ts +15 -0
- package/index.js +19 -0
- package/legacy/DataGridPro/DataGridPro.js +896 -0
- package/legacy/DataGridPro/index.js +2 -0
- package/legacy/DataGridPro/useDataGridProComponent.js +72 -0
- package/legacy/DataGridPro/useDataGridProProps.js +53 -0
- package/legacy/components/DataGridProColumnHeaders.js +173 -0
- package/legacy/components/DataGridProVirtualScroller.js +297 -0
- package/legacy/components/GridColumnPinningMenuItems.js +71 -0
- package/legacy/components/GridDetailPanelToggleCell.js +120 -0
- package/legacy/components/GridGroupingColumnLeafCell.js +20 -0
- package/legacy/components/GridGroupingCriteriaCell.js +146 -0
- package/legacy/components/GridRowGroupableColumnMenuItems.js +61 -0
- package/legacy/components/GridRowGroupingColumnMenuItems.js +56 -0
- package/legacy/components/GridTreeDataGroupingCell.js +155 -0
- package/legacy/components/Watermark.js +43 -0
- package/legacy/components/index.js +3 -0
- package/legacy/hooks/features/columnPinning/gridColumnPinningInterface.js +11 -0
- package/legacy/hooks/features/columnPinning/gridColumnPinningSelector.js +3 -0
- package/legacy/hooks/features/columnPinning/index.js +2 -0
- package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +298 -0
- package/legacy/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +48 -0
- package/legacy/hooks/features/columnReorder/columnReorderInterfaces.js +1 -0
- package/legacy/hooks/features/columnReorder/columnReorderSelector.js +7 -0
- package/legacy/hooks/features/columnReorder/index.js +2 -0
- package/legacy/hooks/features/columnReorder/useGridColumnReorder.js +172 -0
- package/legacy/hooks/features/columnResize/columnResizeSelector.js +7 -0
- package/legacy/hooks/features/columnResize/columnResizeState.js +1 -0
- package/legacy/hooks/features/columnResize/index.js +2 -0
- package/legacy/hooks/features/columnResize/useGridColumnResize.js +310 -0
- package/legacy/hooks/features/detailPanel/gridDetailPanelInterface.js +1 -0
- package/legacy/hooks/features/detailPanel/gridDetailPanelSelector.js +9 -0
- package/legacy/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +28 -0
- package/legacy/hooks/features/detailPanel/index.js +3 -0
- package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +114 -0
- package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +57 -0
- package/legacy/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +31 -0
- package/legacy/hooks/features/index.js +7 -0
- package/legacy/hooks/features/infiniteLoader/useGridInfiniteLoader.js +51 -0
- package/legacy/hooks/features/rowGrouping/createGroupingColDef.js +319 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingSelector.js +13 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +130 -0
- package/legacy/hooks/features/rowGrouping/index.js +3 -0
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +334 -0
- package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +83 -0
- package/legacy/hooks/features/treeData/gridTreeDataGroupColDef.js +24 -0
- package/legacy/hooks/features/treeData/gridTreeDataUtils.js +84 -0
- package/legacy/hooks/features/treeData/index.js +1 -0
- package/legacy/hooks/features/treeData/useGridTreeData.js +116 -0
- package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +72 -0
- package/legacy/hooks/index.js +1 -0
- package/legacy/hooks/utils/useGridApiContext.js +2 -0
- package/legacy/hooks/utils/useGridApiRef.js +2 -0
- package/legacy/hooks/utils/useGridRootProps.js +2 -0
- package/legacy/index.js +19 -0
- package/legacy/models/dataGridProProps.js +1 -0
- package/legacy/models/gridApiPro.js +1 -0
- package/legacy/models/gridGroupingColDefOverride.js +1 -0
- package/legacy/models/gridGroupingValueGetterParams.js +1 -0
- package/legacy/models/gridRowScrollEndParams.js +1 -0
- package/legacy/models/gridStatePro.js +1 -0
- package/legacy/models/index.js +4 -0
- package/legacy/themeAugmentation/index.js +3 -0
- package/legacy/themeAugmentation/overrides.js +1 -0
- package/legacy/themeAugmentation/props.js +1 -0
- package/legacy/typeOverloads/modules.js +1 -0
- package/legacy/typeOverloads/reexports.js +6 -0
- package/legacy/utils/domUtils.js +19 -0
- package/legacy/utils/tree/buildRowTree.js +188 -0
- package/legacy/utils/tree/sortRowTree.js +63 -0
- package/models/dataGridProProps.d.ts +174 -0
- package/models/dataGridProProps.js +1 -0
- package/models/gridApiPro.d.ts +12 -0
- package/models/gridApiPro.js +1 -0
- package/models/gridGroupingColDefOverride.d.ts +30 -0
- package/models/gridGroupingColDefOverride.js +1 -0
- package/models/gridGroupingValueGetterParams.d.ts +31 -0
- package/models/gridGroupingValueGetterParams.js +1 -0
- package/models/gridRowScrollEndParams.d.ts +18 -0
- package/models/gridRowScrollEndParams.js +1 -0
- package/models/gridStatePro.d.ts +20 -0
- package/models/gridStatePro.js +1 -0
- package/models/index.d.ts +4 -0
- package/models/index.js +4 -0
- package/models/package.json +6 -0
- package/modern/DataGridPro/DataGridPro.js +896 -0
- package/modern/DataGridPro/index.js +2 -0
- package/modern/DataGridPro/useDataGridProComponent.js +72 -0
- package/modern/DataGridPro/useDataGridProProps.js +45 -0
- package/modern/components/DataGridProColumnHeaders.js +163 -0
- package/modern/components/DataGridProVirtualScroller.js +279 -0
- package/modern/components/GridColumnPinningMenuItems.js +71 -0
- package/modern/components/GridDetailPanelToggleCell.js +124 -0
- package/modern/components/GridGroupingColumnLeafCell.js +20 -0
- package/modern/components/GridGroupingCriteriaCell.js +148 -0
- package/modern/components/GridRowGroupableColumnMenuItems.js +61 -0
- package/modern/components/GridRowGroupingColumnMenuItems.js +56 -0
- package/modern/components/GridTreeDataGroupingCell.js +157 -0
- package/modern/components/Watermark.js +43 -0
- package/modern/components/index.js +3 -0
- package/modern/hooks/features/columnPinning/gridColumnPinningInterface.js +11 -0
- package/modern/hooks/features/columnPinning/gridColumnPinningSelector.js +1 -0
- package/modern/hooks/features/columnPinning/index.js +2 -0
- package/modern/hooks/features/columnPinning/useGridColumnPinning.js +268 -0
- package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +45 -0
- package/modern/hooks/features/columnReorder/columnReorderInterfaces.js +1 -0
- package/modern/hooks/features/columnReorder/columnReorderSelector.js +3 -0
- package/modern/hooks/features/columnReorder/index.js +2 -0
- package/modern/hooks/features/columnReorder/useGridColumnReorder.js +166 -0
- package/modern/hooks/features/columnResize/columnResizeSelector.js +3 -0
- package/modern/hooks/features/columnResize/columnResizeState.js +1 -0
- package/modern/hooks/features/columnResize/index.js +2 -0
- package/modern/hooks/features/columnResize/useGridColumnResize.js +295 -0
- package/modern/hooks/features/detailPanel/gridDetailPanelInterface.js +1 -0
- package/modern/hooks/features/detailPanel/gridDetailPanelSelector.js +3 -0
- package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +26 -0
- package/modern/hooks/features/detailPanel/index.js +3 -0
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +105 -0
- package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +57 -0
- package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +28 -0
- package/modern/hooks/features/index.js +7 -0
- package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.js +52 -0
- package/modern/hooks/features/rowGrouping/createGroupingColDef.js +302 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingSelector.js +5 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +122 -0
- package/modern/hooks/features/rowGrouping/index.js +3 -0
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +317 -0
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +76 -0
- package/modern/hooks/features/treeData/gridTreeDataGroupColDef.js +22 -0
- package/modern/hooks/features/treeData/gridTreeDataUtils.js +82 -0
- package/modern/hooks/features/treeData/index.js +1 -0
- package/modern/hooks/features/treeData/useGridTreeData.js +106 -0
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +67 -0
- package/modern/hooks/index.js +1 -0
- package/modern/hooks/utils/useGridApiContext.js +2 -0
- package/modern/hooks/utils/useGridApiRef.js +2 -0
- package/modern/hooks/utils/useGridRootProps.js +2 -0
- package/modern/index.js +19 -0
- package/modern/models/dataGridProProps.js +1 -0
- package/modern/models/gridApiPro.js +1 -0
- package/modern/models/gridGroupingColDefOverride.js +1 -0
- package/modern/models/gridGroupingValueGetterParams.js +1 -0
- package/modern/models/gridRowScrollEndParams.js +1 -0
- package/modern/models/gridStatePro.js +1 -0
- package/modern/models/index.js +4 -0
- package/modern/themeAugmentation/index.js +3 -0
- package/modern/themeAugmentation/overrides.js +1 -0
- package/modern/themeAugmentation/props.js +1 -0
- package/modern/typeOverloads/modules.js +1 -0
- package/modern/typeOverloads/reexports.js +6 -0
- package/modern/utils/domUtils.js +19 -0
- package/modern/utils/tree/buildRowTree.js +167 -0
- package/modern/utils/tree/sortRowTree.js +60 -0
- package/node/DataGridPro/DataGridPro.js +921 -0
- package/node/DataGridPro/index.js +30 -0
- package/node/DataGridPro/useDataGridProComponent.js +94 -0
- package/node/DataGridPro/useDataGridProProps.js +69 -0
- package/node/components/DataGridProColumnHeaders.js +189 -0
- package/node/components/DataGridProVirtualScroller.js +308 -0
- package/node/components/GridColumnPinningMenuItems.js +88 -0
- package/node/components/GridDetailPanelToggleCell.js +145 -0
- package/node/components/GridGroupingColumnLeafCell.js +38 -0
- package/node/components/GridGroupingCriteriaCell.js +170 -0
- package/node/components/GridRowGroupableColumnMenuItems.js +82 -0
- package/node/components/GridRowGroupingColumnMenuItems.js +78 -0
- package/node/components/GridTreeDataGroupingCell.js +180 -0
- package/node/components/Watermark.js +56 -0
- package/node/components/index.js +31 -0
- package/node/hooks/features/columnPinning/gridColumnPinningInterface.js +17 -0
- package/node/hooks/features/columnPinning/gridColumnPinningSelector.js +10 -0
- package/node/hooks/features/columnPinning/index.js +31 -0
- package/node/hooks/features/columnPinning/useGridColumnPinning.js +297 -0
- package/node/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +66 -0
- package/node/hooks/features/columnReorder/columnReorderInterfaces.js +5 -0
- package/node/hooks/features/columnReorder/columnReorderSelector.js +14 -0
- package/node/hooks/features/columnReorder/index.js +18 -0
- package/node/hooks/features/columnReorder/useGridColumnReorder.js +187 -0
- package/node/hooks/features/columnResize/columnResizeSelector.js +14 -0
- package/node/hooks/features/columnResize/columnResizeState.js +5 -0
- package/node/hooks/features/columnResize/index.js +31 -0
- package/node/hooks/features/columnResize/useGridColumnResize.js +326 -0
- package/node/hooks/features/detailPanel/gridDetailPanelInterface.js +5 -0
- package/node/hooks/features/detailPanel/gridDetailPanelSelector.js +18 -0
- package/node/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +47 -0
- package/node/hooks/features/detailPanel/index.js +44 -0
- package/node/hooks/features/detailPanel/useGridDetailPanel.js +130 -0
- package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +74 -0
- package/node/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +44 -0
- package/node/hooks/features/index.js +83 -0
- package/node/hooks/features/infiniteLoader/useGridInfiniteLoader.js +67 -0
- package/node/hooks/features/rowGrouping/createGroupingColDef.js +341 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +5 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingSelector.js +18 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +153 -0
- package/node/hooks/features/rowGrouping/index.js +51 -0
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +355 -0
- package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +94 -0
- package/node/hooks/features/treeData/gridTreeDataGroupColDef.js +35 -0
- package/node/hooks/features/treeData/gridTreeDataUtils.js +95 -0
- package/node/hooks/features/treeData/index.js +13 -0
- package/node/hooks/features/treeData/useGridTreeData.js +132 -0
- package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +92 -0
- package/node/hooks/index.js +18 -0
- package/node/hooks/utils/useGridApiContext.js +11 -0
- package/node/hooks/utils/useGridApiRef.js +11 -0
- package/node/hooks/utils/useGridRootProps.js +11 -0
- package/node/index.js +200 -0
- package/node/models/dataGridProProps.js +5 -0
- package/node/models/gridApiPro.js +5 -0
- package/node/models/gridGroupingColDefOverride.js +5 -0
- package/node/models/gridGroupingValueGetterParams.js +5 -0
- package/node/models/gridRowScrollEndParams.js +5 -0
- package/node/models/gridStatePro.js +5 -0
- package/node/models/index.js +44 -0
- package/node/themeAugmentation/index.js +31 -0
- package/node/themeAugmentation/overrides.js +5 -0
- package/node/themeAugmentation/props.js +5 -0
- package/node/typeOverloads/modules.js +5 -0
- package/node/typeOverloads/reexports.js +29 -0
- package/node/utils/domUtils.js +32 -0
- package/node/utils/tree/buildRowTree.js +185 -0
- package/node/utils/tree/sortRowTree.js +69 -0
- package/package.json +12 -14
- package/themeAugmentation/index.d.ts +2 -2
- package/themeAugmentation/index.js +3 -0
- package/themeAugmentation/overrides.d.ts +8 -8
- package/themeAugmentation/overrides.js +1 -0
- package/themeAugmentation/package.json +6 -0
- package/themeAugmentation/props.d.ts +19 -19
- package/themeAugmentation/props.js +1 -0
- package/typeOverloads/modules.d.ts +41 -0
- package/typeOverloads/modules.js +1 -0
- package/typeOverloads/reexports.d.ts +22 -0
- package/typeOverloads/reexports.js +6 -0
- package/utils/domUtils.d.ts +3 -0
- package/utils/domUtils.js +19 -0
- package/utils/tree/buildRowTree.d.ts +47 -0
- package/utils/tree/buildRowTree.js +179 -0
- package/utils/tree/sortRowTree.d.ts +10 -0
- package/utils/tree/sortRowTree.js +60 -0
- package/LICENSE +0 -12
- package/index-cjs.js +0 -15
- package/index-esm.js +0 -15
- package/x-data-grid-pro.d.ts +0 -5251
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
4
|
+
import IconButton from '@mui/material/IconButton';
|
|
5
|
+
import Box from '@mui/material/Box';
|
|
6
|
+
import { useGridSelector, gridFilteredDescendantCountLookupSelector, getDataGridUtilityClass, GridEvents } from '@mui/x-data-grid';
|
|
7
|
+
import { isNavigationKey } from '@mui/x-data-grid/internals';
|
|
8
|
+
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
9
|
+
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
|
|
13
|
+
const useUtilityClasses = ownerState => {
|
|
14
|
+
const {
|
|
15
|
+
classes
|
|
16
|
+
} = ownerState;
|
|
17
|
+
const slots = {
|
|
18
|
+
root: ['treeDataGroupingCell'],
|
|
19
|
+
toggle: ['treeDataGroupingCellToggle']
|
|
20
|
+
};
|
|
21
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const GridTreeDataGroupingCell = props => {
|
|
25
|
+
var _filteredDescendantCo;
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
id,
|
|
29
|
+
field,
|
|
30
|
+
formattedValue,
|
|
31
|
+
rowNode,
|
|
32
|
+
hideDescendantCount
|
|
33
|
+
} = props;
|
|
34
|
+
const rootProps = useGridRootProps();
|
|
35
|
+
const apiRef = useGridApiContext();
|
|
36
|
+
const ownerState = {
|
|
37
|
+
classes: rootProps.classes
|
|
38
|
+
};
|
|
39
|
+
const classes = useUtilityClasses(ownerState);
|
|
40
|
+
const filteredDescendantCountLookup = useGridSelector(apiRef, gridFilteredDescendantCountLookupSelector);
|
|
41
|
+
const filteredDescendantCount = (_filteredDescendantCo = filteredDescendantCountLookup[rowNode.id]) != null ? _filteredDescendantCo : 0;
|
|
42
|
+
const Icon = rowNode.childrenExpanded ? rootProps.components.TreeDataCollapseIcon : rootProps.components.TreeDataExpandIcon;
|
|
43
|
+
|
|
44
|
+
const handleKeyDown = event => {
|
|
45
|
+
if (event.key === ' ') {
|
|
46
|
+
event.stopPropagation();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (isNavigationKey(event.key) && !event.shiftKey) {
|
|
50
|
+
apiRef.current.publishEvent(GridEvents.cellNavigationKeyDown, props, event);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const handleClick = event => {
|
|
55
|
+
apiRef.current.setRowChildrenExpansion(id, !rowNode.childrenExpanded);
|
|
56
|
+
apiRef.current.setCellFocus(id, field);
|
|
57
|
+
event.stopPropagation(); // TODO remove event.stopPropagation
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
61
|
+
className: classes.root,
|
|
62
|
+
sx: {
|
|
63
|
+
ml: rowNode.depth * 2
|
|
64
|
+
},
|
|
65
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
66
|
+
className: classes.toggle,
|
|
67
|
+
children: filteredDescendantCount > 0 && /*#__PURE__*/_jsx(IconButton, {
|
|
68
|
+
size: "small",
|
|
69
|
+
onClick: handleClick,
|
|
70
|
+
onKeyDown: handleKeyDown,
|
|
71
|
+
tabIndex: -1,
|
|
72
|
+
"aria-label": rowNode.childrenExpanded ? apiRef.current.getLocaleText('treeDataCollapse') : apiRef.current.getLocaleText('treeDataExpand'),
|
|
73
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
74
|
+
fontSize: "inherit"
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
78
|
+
children: [formattedValue === undefined ? rowNode.groupingKey : formattedValue, !hideDescendantCount && filteredDescendantCount > 0 ? ` (${filteredDescendantCount})` : '']
|
|
79
|
+
})]
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
|
|
84
|
+
// ----------------------------- Warning --------------------------------
|
|
85
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
86
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
87
|
+
// ----------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* GridApi that let you manipulate the grid.
|
|
91
|
+
*/
|
|
92
|
+
api: PropTypes.object.isRequired,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The mode of the cell.
|
|
96
|
+
*/
|
|
97
|
+
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The column of the row that the current cell belongs to.
|
|
101
|
+
*/
|
|
102
|
+
colDef: PropTypes.object.isRequired,
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The column field of the cell that triggered the event.
|
|
106
|
+
*/
|
|
107
|
+
field: PropTypes.string.isRequired,
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The cell value formatted with the column valueFormatter.
|
|
111
|
+
*/
|
|
112
|
+
formattedValue: PropTypes.any.isRequired,
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Get the cell value of a row and field.
|
|
116
|
+
* @param {GridRowId} id The row id.
|
|
117
|
+
* @param {string} field The field.
|
|
118
|
+
* @returns {GridCellValue} The cell value.
|
|
119
|
+
* @deprecated Use `params.row` to directly access the fields you want instead.
|
|
120
|
+
*/
|
|
121
|
+
getValue: PropTypes.func.isRequired,
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* If true, the cell is the active element.
|
|
125
|
+
*/
|
|
126
|
+
hasFocus: PropTypes.bool.isRequired,
|
|
127
|
+
hideDescendantCount: PropTypes.bool,
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The grid row id.
|
|
131
|
+
*/
|
|
132
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* If true, the cell is editable.
|
|
136
|
+
*/
|
|
137
|
+
isEditable: PropTypes.bool,
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The row model of the row that the current cell belongs to.
|
|
141
|
+
*/
|
|
142
|
+
row: PropTypes.any.isRequired,
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The node of the row that the current cell belongs to.
|
|
146
|
+
*/
|
|
147
|
+
rowNode: PropTypes.object.isRequired,
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* the tabIndex value.
|
|
151
|
+
*/
|
|
152
|
+
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The cell value, but if the column has valueGetter, use getValue.
|
|
156
|
+
*/
|
|
157
|
+
value: PropTypes.any.isRequired
|
|
158
|
+
} : void 0;
|
|
159
|
+
export { GridTreeDataGroupingCell };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useLicenseVerifier, LicenseStatus } from '@mui/x-license-pro';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
function getLicenseErrorMessage(licenseStatus) {
|
|
6
|
+
switch (licenseStatus) {
|
|
7
|
+
case LicenseStatus.Expired:
|
|
8
|
+
return 'MUI X: License key expired';
|
|
9
|
+
|
|
10
|
+
case LicenseStatus.Invalid:
|
|
11
|
+
return 'MUI X: Invalid license key';
|
|
12
|
+
|
|
13
|
+
case LicenseStatus.NotFound:
|
|
14
|
+
return 'MUI X: Missing license key';
|
|
15
|
+
|
|
16
|
+
default:
|
|
17
|
+
throw new Error('MUI: Unhandled MUI X license status.');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function Watermark() {
|
|
22
|
+
const licenseStatus = useLicenseVerifier();
|
|
23
|
+
|
|
24
|
+
if (licenseStatus === LicenseStatus.Valid) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return /*#__PURE__*/_jsx("div", {
|
|
29
|
+
style: {
|
|
30
|
+
position: 'absolute',
|
|
31
|
+
pointerEvents: 'none',
|
|
32
|
+
color: '#8282829e',
|
|
33
|
+
zIndex: 100000,
|
|
34
|
+
width: '100%',
|
|
35
|
+
textAlign: 'center',
|
|
36
|
+
bottom: '50%',
|
|
37
|
+
right: 0,
|
|
38
|
+
letterSpacing: 5,
|
|
39
|
+
fontSize: 24
|
|
40
|
+
},
|
|
41
|
+
children: getLicenseErrorMessage(licenseStatus)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface GridPinnedColumns {
|
|
2
|
+
left?: string[];
|
|
3
|
+
right?: string[];
|
|
4
|
+
}
|
|
5
|
+
export declare type GridColumnPinningState = GridPinnedColumns;
|
|
6
|
+
declare enum GridPinnedPosition {
|
|
7
|
+
left = "left",
|
|
8
|
+
right = "right"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The column pinning API interface that is available in the grid [[apiRef]].
|
|
12
|
+
*/
|
|
13
|
+
export interface GridColumnPinningApi {
|
|
14
|
+
/**
|
|
15
|
+
* Pins a column to the left or right side of the grid.
|
|
16
|
+
* @param {string} field The column field to pin.
|
|
17
|
+
* @param {GridPinnedPosition} side Which side to pin the column.
|
|
18
|
+
*/
|
|
19
|
+
pinColumn: (field: string, side: GridPinnedPosition) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Unpins a column.
|
|
22
|
+
* @param {string} field The column field to unpin.
|
|
23
|
+
*/
|
|
24
|
+
unpinColumn: (field: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Returns which columns are pinned.
|
|
27
|
+
* @returns {GridPinnedColumns} An object containing the pinned columns.
|
|
28
|
+
*/
|
|
29
|
+
getPinnedColumns: () => GridPinnedColumns;
|
|
30
|
+
/**
|
|
31
|
+
* Changes the pinned columns.
|
|
32
|
+
* @param {GridPinnedColumns} pinnedColumns An object containing the columns to pin.
|
|
33
|
+
*/
|
|
34
|
+
setPinnedColumns: (pinnedColumns: GridPinnedColumns) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Returns which side a column is pinned to.
|
|
37
|
+
* @param {string} field The column field to check.
|
|
38
|
+
* @returns {string | false} Which side the column is pinned or `false` if not pinned.
|
|
39
|
+
*/
|
|
40
|
+
isColumnPinned: (field: string) => GridPinnedPosition | false;
|
|
41
|
+
}
|
|
42
|
+
export { GridPinnedPosition };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var GridPinnedPosition;
|
|
2
|
+
/**
|
|
3
|
+
* The column pinning API interface that is available in the grid [[apiRef]].
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
(function (GridPinnedPosition) {
|
|
7
|
+
GridPinnedPosition["left"] = "left";
|
|
8
|
+
GridPinnedPosition["right"] = "right";
|
|
9
|
+
})(GridPinnedPosition || (GridPinnedPosition = {}));
|
|
10
|
+
|
|
11
|
+
export { GridPinnedPosition };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const gridPinnedColumnsSelector = state => state.pinnedColumns;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridStateInitializer } from '@mui/x-data-grid/internals';
|
|
3
|
+
import { GridApiPro } from '../../../models/gridApiPro';
|
|
4
|
+
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
5
|
+
export declare const columnPinningStateInitializer: GridStateInitializer<Pick<DataGridProProcessedProps, 'pinnedColumns' | 'initialState' | 'disableColumnPinning'>>;
|
|
6
|
+
export declare const useGridColumnPinning: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'initialState' | 'disableColumnPinning' | 'pinnedColumns' | 'onPinnedColumnsChange'>) => void;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import MuiDivider from '@mui/material/Divider';
|
|
4
|
+
import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, gridVisibleColumnFieldsSelector, gridClasses, GridEvents, useGridApiMethod, useGridApiEventHandler } from '@mui/x-data-grid';
|
|
5
|
+
import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
|
|
6
|
+
import { GridColumnPinningMenuItems } from '../../../components/GridColumnPinningMenuItems';
|
|
7
|
+
import { GridPinnedPosition } from './gridColumnPinningInterface';
|
|
8
|
+
import { gridPinnedColumnsSelector } from './gridColumnPinningSelector';
|
|
9
|
+
import { filterColumns } from '../../../components/DataGridProVirtualScroller';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
|
|
12
|
+
const Divider = () => /*#__PURE__*/_jsx(MuiDivider, {
|
|
13
|
+
onClick: event => event.stopPropagation()
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const columnPinningStateInitializer = (state, props) => {
|
|
17
|
+
var _props$initialState;
|
|
18
|
+
|
|
19
|
+
let model;
|
|
20
|
+
|
|
21
|
+
if (props.disableColumnPinning) {
|
|
22
|
+
model = {};
|
|
23
|
+
} else if (props.pinnedColumns) {
|
|
24
|
+
model = props.pinnedColumns;
|
|
25
|
+
} else if ((_props$initialState = props.initialState) != null && _props$initialState.pinnedColumns) {
|
|
26
|
+
var _props$initialState2;
|
|
27
|
+
|
|
28
|
+
model = (_props$initialState2 = props.initialState) == null ? void 0 : _props$initialState2.pinnedColumns;
|
|
29
|
+
} else {
|
|
30
|
+
model = {};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return _extends({}, state, {
|
|
34
|
+
pinnedColumns: model
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const mergeStateWithPinnedColumns = pinnedColumns => state => _extends({}, state, {
|
|
39
|
+
pinnedColumns
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const useGridColumnPinning = (apiRef, props) => {
|
|
43
|
+
const pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector); // Each visible row (not to be confused with a filter result) is composed of a central .MuiDataGrid-row element
|
|
44
|
+
// and up to two additional .MuiDataGrid-row's, one for the columns pinned to the left and another
|
|
45
|
+
// for those on the right side. When hovering any of these elements, the :hover styles are applied only to
|
|
46
|
+
// the row element that was actually hovered, not its additional siblings. To make it look like a contiguous row,
|
|
47
|
+
// this method adds/removes the .Mui-hovered class to all of the row elements inside one visible row.
|
|
48
|
+
|
|
49
|
+
const updateHoveredClassOnSiblingRows = React.useCallback(event => {
|
|
50
|
+
var _pinnedColumns$left$l, _pinnedColumns$left, _pinnedColumns$right$, _pinnedColumns$right;
|
|
51
|
+
|
|
52
|
+
if (props.disableColumnPinning) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!Array.isArray(pinnedColumns.left) && !Array.isArray(pinnedColumns.right)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const nbLeftPinnedColumns = (_pinnedColumns$left$l = (_pinnedColumns$left = pinnedColumns.left) == null ? void 0 : _pinnedColumns$left.length) != null ? _pinnedColumns$left$l : 0;
|
|
61
|
+
const nbRightPinnedColumns = (_pinnedColumns$right$ = (_pinnedColumns$right = pinnedColumns.right) == null ? void 0 : _pinnedColumns$right.length) != null ? _pinnedColumns$right$ : 0;
|
|
62
|
+
|
|
63
|
+
if (nbLeftPinnedColumns + nbRightPinnedColumns === 0) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const index = event.currentTarget.dataset.rowindex;
|
|
68
|
+
const rowElements = apiRef.current.windowRef.current.querySelectorAll(`.${gridClasses.row}[data-rowindex="${index}"]`);
|
|
69
|
+
rowElements.forEach(row => {
|
|
70
|
+
// Ignore rows from other grid inside the hovered row
|
|
71
|
+
if (row.closest(`.${gridClasses.virtualScroller}`) === apiRef.current.windowRef.current) {
|
|
72
|
+
if (event.type === 'mouseenter') {
|
|
73
|
+
row.classList.add('Mui-hovered');
|
|
74
|
+
} else {
|
|
75
|
+
row.classList.remove('Mui-hovered');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}, [apiRef, pinnedColumns.left, pinnedColumns.right, props.disableColumnPinning]);
|
|
80
|
+
const handleMouseEnter = React.useCallback((params, event) => {
|
|
81
|
+
updateHoveredClassOnSiblingRows(event);
|
|
82
|
+
}, [updateHoveredClassOnSiblingRows]);
|
|
83
|
+
const handleMouseLeave = React.useCallback((params, event) => {
|
|
84
|
+
updateHoveredClassOnSiblingRows(event);
|
|
85
|
+
}, [updateHoveredClassOnSiblingRows]);
|
|
86
|
+
useGridApiEventHandler(apiRef, GridEvents.rowMouseEnter, handleMouseEnter);
|
|
87
|
+
useGridApiEventHandler(apiRef, GridEvents.rowMouseLeave, handleMouseLeave);
|
|
88
|
+
/**
|
|
89
|
+
* PRE-PROCESSING
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
const calculateScrollLeft = React.useCallback((initialValue, params) => {
|
|
93
|
+
if (props.disableColumnPinning) {
|
|
94
|
+
return initialValue;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const visibleColumnFields = gridVisibleColumnFieldsSelector(apiRef);
|
|
98
|
+
const [leftPinnedColumns, rightPinnedColumns] = filterColumns(pinnedColumns, visibleColumnFields);
|
|
99
|
+
|
|
100
|
+
if (!params.colIndex || leftPinnedColumns.length === 0 && rightPinnedColumns.length === 0) {
|
|
101
|
+
return initialValue;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
|
|
105
|
+
const columnsTotalWidth = gridColumnsTotalWidthSelector(apiRef);
|
|
106
|
+
const columnPositions = gridColumnPositionsSelector(apiRef);
|
|
107
|
+
const clientWidth = apiRef.current.windowRef.current.clientWidth;
|
|
108
|
+
const scrollLeft = apiRef.current.windowRef.current.scrollLeft;
|
|
109
|
+
const offsetWidth = visibleColumns[params.colIndex].computedWidth;
|
|
110
|
+
const offsetLeft = columnPositions[params.colIndex];
|
|
111
|
+
const leftPinnedColumnsWidth = columnPositions[leftPinnedColumns.length];
|
|
112
|
+
const rightPinnedColumnsWidth = columnsTotalWidth - columnPositions[columnPositions.length - rightPinnedColumns.length];
|
|
113
|
+
const elementBottom = offsetLeft + offsetWidth;
|
|
114
|
+
|
|
115
|
+
if (elementBottom - (clientWidth - rightPinnedColumnsWidth) > scrollLeft) {
|
|
116
|
+
const left = elementBottom - (clientWidth - rightPinnedColumnsWidth);
|
|
117
|
+
return _extends({}, initialValue, {
|
|
118
|
+
left
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (offsetLeft < scrollLeft + leftPinnedColumnsWidth) {
|
|
123
|
+
const left = offsetLeft - leftPinnedColumnsWidth;
|
|
124
|
+
return _extends({}, initialValue, {
|
|
125
|
+
left
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return initialValue;
|
|
130
|
+
}, [apiRef, pinnedColumns, props.disableColumnPinning]);
|
|
131
|
+
const addColumnMenuButtons = React.useCallback((initialValue, column) => {
|
|
132
|
+
if (props.disableColumnPinning) {
|
|
133
|
+
return initialValue;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (column.pinnable === false) {
|
|
137
|
+
return initialValue;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return [...initialValue, /*#__PURE__*/_jsx(Divider, {}), /*#__PURE__*/_jsx(GridColumnPinningMenuItems, {})];
|
|
141
|
+
}, [props.disableColumnPinning]);
|
|
142
|
+
const checkIfCanBeReordered = React.useCallback((initialValue, {
|
|
143
|
+
targetIndex
|
|
144
|
+
}) => {
|
|
145
|
+
const visibleColumnFields = gridVisibleColumnFieldsSelector(apiRef);
|
|
146
|
+
const [leftPinnedColumns, rightPinnedColumns] = filterColumns(pinnedColumns, visibleColumnFields);
|
|
147
|
+
|
|
148
|
+
if (leftPinnedColumns.length === 0 && rightPinnedColumns.length === 0) {
|
|
149
|
+
return initialValue;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (leftPinnedColumns.length > 0 && targetIndex < leftPinnedColumns.length) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (rightPinnedColumns.length > 0) {
|
|
157
|
+
const visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
|
|
158
|
+
const firstRightPinnedColumnIndex = visibleColumns.length - rightPinnedColumns.length;
|
|
159
|
+
return targetIndex >= firstRightPinnedColumnIndex ? false : initialValue;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return initialValue;
|
|
163
|
+
}, [apiRef, pinnedColumns]);
|
|
164
|
+
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
165
|
+
const pinnedColumnsToExport = gridPinnedColumnsSelector(apiRef.current.state);
|
|
166
|
+
|
|
167
|
+
if ((!pinnedColumnsToExport.left || pinnedColumnsToExport.left.length === 0) && (!pinnedColumnsToExport.right || pinnedColumnsToExport.right.length === 0)) {
|
|
168
|
+
return prevState;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return _extends({}, prevState, {
|
|
172
|
+
pinnedColumns: pinnedColumnsToExport
|
|
173
|
+
});
|
|
174
|
+
}, [apiRef]);
|
|
175
|
+
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
176
|
+
const newPinnedColumns = context.stateToRestore.pinnedColumns;
|
|
177
|
+
|
|
178
|
+
if (newPinnedColumns != null) {
|
|
179
|
+
apiRef.current.setState(mergeStateWithPinnedColumns(newPinnedColumns));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return params;
|
|
183
|
+
}, [apiRef]);
|
|
184
|
+
useGridRegisterPreProcessor(apiRef, 'scrollToIndexes', calculateScrollLeft);
|
|
185
|
+
useGridRegisterPreProcessor(apiRef, 'columnMenu', addColumnMenuButtons);
|
|
186
|
+
useGridRegisterPreProcessor(apiRef, 'canBeReordered', checkIfCanBeReordered);
|
|
187
|
+
useGridRegisterPreProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
188
|
+
useGridRegisterPreProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
189
|
+
apiRef.current.unstable_updateControlState({
|
|
190
|
+
stateId: 'pinnedColumns',
|
|
191
|
+
propModel: props.pinnedColumns,
|
|
192
|
+
propOnChange: props.onPinnedColumnsChange,
|
|
193
|
+
stateSelector: gridPinnedColumnsSelector,
|
|
194
|
+
changeEvent: GridEvents.pinnedColumnsChange
|
|
195
|
+
});
|
|
196
|
+
const checkIfEnabled = React.useCallback(methodName => {
|
|
197
|
+
if (props.disableColumnPinning) {
|
|
198
|
+
throw new Error(`MUI: You cannot call \`apiRef.current.${methodName}\` when \`disableColumnPinning\` is true.`);
|
|
199
|
+
}
|
|
200
|
+
}, [props.disableColumnPinning]);
|
|
201
|
+
const pinColumn = React.useCallback((field, side) => {
|
|
202
|
+
checkIfEnabled('pinColumn');
|
|
203
|
+
|
|
204
|
+
if (apiRef.current.isColumnPinned(field) === side) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
apiRef.current.setState(state => {
|
|
209
|
+
const otherSide = side === GridPinnedPosition.right ? GridPinnedPosition.left : GridPinnedPosition.right;
|
|
210
|
+
|
|
211
|
+
const newPinnedColumns = _extends({}, state.pinnedColumns, {
|
|
212
|
+
[side]: [...(state.pinnedColumns[side] || []), field],
|
|
213
|
+
[otherSide]: (state.pinnedColumns[otherSide] || []).filter(column => column !== field)
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
return _extends({}, state, {
|
|
217
|
+
pinnedColumns: newPinnedColumns
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
apiRef.current.forceUpdate();
|
|
221
|
+
}, [apiRef, checkIfEnabled]);
|
|
222
|
+
const unpinColumn = React.useCallback(field => {
|
|
223
|
+
checkIfEnabled('unpinColumn');
|
|
224
|
+
apiRef.current.setState(state => {
|
|
225
|
+
const newPinnedColumns = _extends({}, state.pinnedColumns, {
|
|
226
|
+
left: (state.pinnedColumns.left || []).filter(column => column !== field),
|
|
227
|
+
right: (state.pinnedColumns.right || []).filter(column => column !== field)
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
return _extends({}, state, {
|
|
231
|
+
pinnedColumns: newPinnedColumns
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
apiRef.current.forceUpdate();
|
|
235
|
+
}, [apiRef, checkIfEnabled]);
|
|
236
|
+
const getPinnedColumns = React.useCallback(() => {
|
|
237
|
+
checkIfEnabled('getPinnedColumns');
|
|
238
|
+
return gridPinnedColumnsSelector(apiRef.current.state);
|
|
239
|
+
}, [apiRef, checkIfEnabled]);
|
|
240
|
+
const setPinnedColumns = React.useCallback(newPinnedColumns => {
|
|
241
|
+
checkIfEnabled('setPinnedColumns');
|
|
242
|
+
apiRef.current.setState(mergeStateWithPinnedColumns(newPinnedColumns));
|
|
243
|
+
apiRef.current.forceUpdate();
|
|
244
|
+
}, [apiRef, checkIfEnabled]);
|
|
245
|
+
const isColumnPinned = React.useCallback(field => {
|
|
246
|
+
checkIfEnabled('isColumnPinned');
|
|
247
|
+
const leftPinnedColumns = pinnedColumns.left || [];
|
|
248
|
+
|
|
249
|
+
if (leftPinnedColumns.includes(field)) {
|
|
250
|
+
return GridPinnedPosition.left;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const rightPinnedColumns = pinnedColumns.right || [];
|
|
254
|
+
|
|
255
|
+
if (rightPinnedColumns.includes(field)) {
|
|
256
|
+
return GridPinnedPosition.right;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return false;
|
|
260
|
+
}, [pinnedColumns.left, pinnedColumns.right, checkIfEnabled]);
|
|
261
|
+
const columnPinningApi = {
|
|
262
|
+
pinColumn,
|
|
263
|
+
unpinColumn,
|
|
264
|
+
getPinnedColumns,
|
|
265
|
+
setPinnedColumns,
|
|
266
|
+
isColumnPinned
|
|
267
|
+
};
|
|
268
|
+
useGridApiMethod(apiRef, columnPinningApi, 'columnPinningApi');
|
|
269
|
+
React.useEffect(() => {
|
|
270
|
+
if (props.pinnedColumns) {
|
|
271
|
+
apiRef.current.setPinnedColumns(props.pinnedColumns);
|
|
272
|
+
}
|
|
273
|
+
}, [apiRef, props.pinnedColumns]);
|
|
274
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
3
|
+
import { GridApiPro } from '../../../models/gridApiPro';
|
|
4
|
+
export declare const useGridColumnPinningPreProcessors: (apiRef: React.MutableRefObject<GridApiPro>, props: DataGridProProcessedProps) => void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
|
|
4
|
+
import { gridPinnedColumnsSelector } from './gridColumnPinningSelector';
|
|
5
|
+
import { columnPinningStateInitializer } from './useGridColumnPinning';
|
|
6
|
+
import { filterColumns } from '../../../components/DataGridProVirtualScroller';
|
|
7
|
+
export const useGridColumnPinningPreProcessors = (apiRef, props) => {
|
|
8
|
+
const {
|
|
9
|
+
disableColumnPinning,
|
|
10
|
+
pinnedColumns: pinnedColumnsProp,
|
|
11
|
+
initialState
|
|
12
|
+
} = props;
|
|
13
|
+
let pinnedColumns = gridPinnedColumnsSelector(apiRef.current.state);
|
|
14
|
+
|
|
15
|
+
if (pinnedColumns == null) {
|
|
16
|
+
// Since the state is not ready yet lets use the initializer to get which
|
|
17
|
+
// columns should be pinned initially.
|
|
18
|
+
const initializedState = columnPinningStateInitializer(apiRef.current.state, {
|
|
19
|
+
disableColumnPinning,
|
|
20
|
+
pinnedColumns: pinnedColumnsProp,
|
|
21
|
+
initialState
|
|
22
|
+
}, apiRef);
|
|
23
|
+
pinnedColumns = gridPinnedColumnsSelector(initializedState);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const reorderPinnedColumns = React.useCallback(columnsState => {
|
|
27
|
+
if (columnsState.all.length === 0 || disableColumnPinning) {
|
|
28
|
+
return columnsState;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const [leftPinnedColumns, rightPinnedColumns] = filterColumns(pinnedColumns, columnsState.all);
|
|
32
|
+
|
|
33
|
+
if (leftPinnedColumns.length === 0 && rightPinnedColumns.length === 0) {
|
|
34
|
+
return columnsState;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const centerColumns = columnsState.all.filter(field => {
|
|
38
|
+
return !leftPinnedColumns.includes(field) && !rightPinnedColumns.includes(field);
|
|
39
|
+
});
|
|
40
|
+
return _extends({}, columnsState, {
|
|
41
|
+
all: [...leftPinnedColumns, ...centerColumns, ...rightPinnedColumns]
|
|
42
|
+
});
|
|
43
|
+
}, [disableColumnPinning, pinnedColumns]);
|
|
44
|
+
useGridRegisterPreProcessor(apiRef, 'hydrateColumns', reorderPinnedColumns);
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GridStatePro } from '../../../models/gridStatePro';
|
|
2
|
+
export declare const gridColumnReorderSelector: (state: GridStatePro) => import("./columnReorderInterfaces").GridColumnReorderState;
|
|
3
|
+
export declare const gridColumnReorderDragColSelector: import("@mui/x-data-grid").OutputSelector<GridStatePro, string>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridApiPro } from '../../../models/gridApiPro';
|
|
3
|
+
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
4
|
+
/**
|
|
5
|
+
* Only available in DataGridPro
|
|
6
|
+
* @requires useGridColumns (method)
|
|
7
|
+
*/
|
|
8
|
+
export declare const useGridColumnReorder: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'disableColumnReorder' | 'classes'>) => void;
|