@mui/x-data-grid-premium 8.0.0-alpha.9 → 8.0.0-beta.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 +1446 -0
- package/DataGridPremium/DataGrid.d.ts +1 -1
- package/DataGridPremium/DataGridPremium.d.ts +6 -6
- package/DataGridPremium/DataGridPremium.js +61 -35
- package/DataGridPremium/index.d.ts +3 -3
- package/DataGridPremium/useDataGridPremiumComponent.d.ts +3 -3
- package/DataGridPremium/useDataGridPremiumComponent.js +5 -4
- package/DataGridPremium/useDataGridPremiumProps.d.ts +2 -2
- package/DataGridPremium/useDataGridPremiumProps.js +2 -2
- package/README.md +1 -1
- package/components/GridAggregationHeader.d.ts +3 -3
- package/components/GridAggregationHeader.js +13 -12
- package/components/GridAggregationRowOverlay.d.ts +3 -0
- package/components/GridAggregationRowOverlay.js +44 -0
- package/components/GridBottomContainer.d.ts +3 -0
- package/components/GridBottomContainer.js +51 -0
- package/components/GridColumnMenuAggregationItem.d.ts +2 -2
- package/components/GridColumnMenuAggregationItem.js +36 -46
- package/components/GridColumnMenuRowGroupItem.d.ts +1 -1
- package/components/GridColumnMenuRowUngroupItem.d.ts +1 -1
- package/components/GridDataSourceGroupingCriteriaCell.d.ts +2 -2
- package/components/GridDataSourceGroupingCriteriaCell.js +8 -12
- package/components/GridExcelExportMenuItem.d.ts +3 -3
- package/components/GridFooterCell.d.ts +2 -2
- package/components/GridFooterCell.js +5 -6
- package/components/GridGroupingColumnFooterCell.d.ts +1 -1
- package/components/GridGroupingColumnFooterCell.js +2 -1
- package/components/GridGroupingColumnLeafCell.d.ts +1 -1
- package/components/GridGroupingColumnLeafCell.js +3 -9
- package/components/GridGroupingCriteriaCell.d.ts +2 -2
- package/components/GridGroupingCriteriaCell.js +3 -8
- package/components/GridPremiumColumnMenu.d.ts +26 -26
- package/components/GridPremiumToolbar.d.ts +3 -0
- package/components/GridPremiumToolbar.js +31 -0
- package/components/export/ExportExcel.d.ts +29 -0
- package/components/export/ExportExcel.js +216 -0
- package/components/export/index.d.ts +1 -0
- package/components/export/index.js +16 -0
- package/components/index.d.ts +6 -5
- package/components/index.js +13 -1
- package/components/promptControl/GridToolbarPromptControl.d.ts +22 -22
- package/components/promptControl/GridToolbarPromptControl.js +33 -20
- package/components/promptControl/RecordButton.d.ts +9 -9
- package/components/promptControl/index.d.ts +1 -1
- package/components/reexports.d.ts +1 -1
- package/constants/dataGridPremiumDefaultSlotsComponents.d.ts +1 -1
- package/constants/dataGridPremiumDefaultSlotsComponents.js +5 -1
- package/esm/DataGridPremium/DataGrid.d.ts +8 -0
- package/esm/DataGridPremium/DataGridPremium.d.ts +16 -0
- package/esm/DataGridPremium/DataGridPremium.js +61 -35
- package/esm/DataGridPremium/index.d.ts +3 -0
- package/esm/DataGridPremium/useDataGridPremiumComponent.d.ts +4 -0
- package/esm/DataGridPremium/useDataGridPremiumComponent.js +6 -5
- package/esm/DataGridPremium/useDataGridPremiumProps.d.ts +6 -0
- package/esm/DataGridPremium/useDataGridPremiumProps.js +2 -2
- package/esm/components/GridAggregationHeader.d.ts +7 -0
- package/esm/components/GridAggregationHeader.js +13 -12
- package/esm/components/GridAggregationRowOverlay.d.ts +3 -0
- package/esm/components/GridAggregationRowOverlay.js +37 -0
- package/esm/components/GridBottomContainer.d.ts +3 -0
- package/esm/components/GridBottomContainer.js +43 -0
- package/esm/components/GridColumnMenuAggregationItem.d.ts +7 -0
- package/esm/components/GridColumnMenuAggregationItem.js +36 -46
- package/esm/components/GridColumnMenuRowGroupItem.d.ts +3 -0
- package/esm/components/GridColumnMenuRowUngroupItem.d.ts +3 -0
- package/esm/components/GridDataSourceGroupingCriteriaCell.d.ts +7 -0
- package/esm/components/GridDataSourceGroupingCriteriaCell.js +9 -13
- package/esm/components/GridExcelExportMenuItem.d.ts +9 -0
- package/esm/components/GridFooterCell.d.ts +9 -0
- package/esm/components/GridFooterCell.js +5 -6
- package/esm/components/GridGroupingColumnFooterCell.d.ts +4 -0
- package/esm/components/GridGroupingColumnFooterCell.js +2 -1
- package/esm/components/GridGroupingColumnLeafCell.d.ts +4 -0
- package/esm/components/GridGroupingColumnLeafCell.js +3 -8
- package/esm/components/GridGroupingCriteriaCell.d.ts +7 -0
- package/esm/components/GridGroupingCriteriaCell.js +3 -8
- package/esm/components/GridPremiumColumnMenu.d.ts +33 -0
- package/esm/components/GridPremiumToolbar.d.ts +3 -0
- package/esm/components/GridPremiumToolbar.js +23 -0
- package/esm/components/export/ExportExcel.d.ts +29 -0
- package/esm/components/export/ExportExcel.js +209 -0
- package/esm/components/export/index.d.ts +1 -0
- package/esm/components/export/index.js +1 -0
- package/esm/components/index.d.ts +6 -0
- package/esm/components/index.js +2 -1
- package/esm/components/promptControl/GridToolbarPromptControl.d.ts +26 -0
- package/esm/components/promptControl/GridToolbarPromptControl.js +33 -20
- package/esm/components/promptControl/RecordButton.d.ts +16 -0
- package/esm/components/promptControl/index.d.ts +1 -0
- package/esm/components/reexports.d.ts +1 -0
- package/esm/constants/dataGridPremiumDefaultSlotsComponents.d.ts +2 -0
- package/esm/constants/dataGridPremiumDefaultSlotsComponents.js +5 -1
- package/esm/hooks/features/aggregation/createAggregationLookup.d.ts +17 -0
- package/esm/hooks/features/aggregation/createAggregationLookup.js +3 -3
- package/esm/hooks/features/aggregation/gridAggregationFunctions.d.ts +8 -0
- package/esm/hooks/features/aggregation/gridAggregationInterfaces.d.ts +129 -0
- package/esm/hooks/features/aggregation/gridAggregationSelectors.d.ts +13 -0
- package/esm/hooks/features/aggregation/gridAggregationSelectors.js +2 -2
- package/esm/hooks/features/aggregation/gridAggregationUtils.d.ts +62 -0
- package/esm/hooks/features/aggregation/gridAggregationUtils.js +1 -1
- package/esm/hooks/features/aggregation/index.d.ts +4 -0
- package/esm/hooks/features/aggregation/useGridAggregation.d.ts +6 -0
- package/esm/hooks/features/aggregation/useGridAggregation.js +6 -8
- package/esm/hooks/features/aggregation/useGridAggregationPreProcessors.d.ts +4 -0
- package/esm/hooks/features/aggregation/useGridAggregationPreProcessors.js +7 -6
- package/esm/hooks/features/aggregation/wrapColumnWithAggregation.d.ts +81 -0
- package/esm/hooks/features/aggregation/wrapColumnWithAggregation.js +6 -5
- package/esm/hooks/features/cellSelection/gridCellSelectionInterfaces.d.ts +40 -0
- package/esm/hooks/features/cellSelection/gridCellSelectionSelector.d.ts +2 -0
- package/esm/hooks/features/cellSelection/gridCellSelectionSelector.js +2 -1
- package/esm/hooks/features/cellSelection/index.d.ts +1 -0
- package/esm/hooks/features/cellSelection/useGridCellSelection.d.ts +6 -0
- package/esm/hooks/features/cellSelection/useGridCellSelection.js +15 -13
- package/esm/hooks/features/clipboard/useGridClipboardImport.d.ts +4 -0
- package/esm/hooks/features/clipboard/useGridClipboardImport.js +5 -5
- package/esm/hooks/features/dataSource/models.d.ts +54 -0
- package/esm/hooks/features/dataSource/useGridDataSourcePremium.d.ts +4 -0
- package/esm/hooks/features/dataSource/useGridDataSourcePremium.js +13 -7
- package/esm/hooks/features/export/gridExcelExportInterface.d.ts +71 -0
- package/esm/hooks/features/export/index.d.ts +2 -0
- package/esm/hooks/features/export/index.js +1 -1
- package/esm/hooks/features/export/serializer/excelSerializer.d.ts +40 -0
- package/esm/hooks/features/export/serializer/excelSerializer.js +69 -180
- package/esm/hooks/features/export/serializer/setupExcelExportWebWorker.d.ts +2 -0
- package/esm/hooks/features/export/serializer/setupExcelExportWebWorker.js +53 -0
- package/esm/hooks/features/export/serializer/utils.d.ts +36 -0
- package/esm/hooks/features/export/serializer/utils.js +93 -0
- package/esm/hooks/features/export/useGridExcelExport.d.ts +11 -0
- package/esm/hooks/features/export/useGridExcelExport.js +11 -5
- package/esm/hooks/features/index.d.ts +5 -0
- package/esm/hooks/features/promptControl/api.d.ts +2 -0
- package/esm/hooks/features/promptControl/index.d.ts +2 -0
- package/esm/hooks/features/promptControl/types.d.ts +25 -0
- package/esm/hooks/features/rowGrouping/createGroupingColDef.d.ts +57 -0
- package/esm/hooks/features/rowGrouping/createGroupingColDef.js +5 -5
- package/esm/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +44 -0
- package/esm/hooks/features/rowGrouping/gridRowGroupingSelector.d.ts +3 -0
- package/esm/hooks/features/rowGrouping/gridRowGroupingSelector.js +2 -2
- package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +54 -0
- package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -3
- package/esm/hooks/features/rowGrouping/index.d.ts +3 -0
- package/esm/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.d.ts +4 -0
- package/esm/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +3 -3
- package/esm/hooks/features/rowGrouping/useGridRowGrouping.d.ts +11 -0
- package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +4 -5
- package/esm/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +4 -0
- package/esm/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +5 -5
- package/esm/hooks/features/rows/index.d.ts +1 -0
- package/esm/hooks/features/rows/useGridRowAriaAttributes.d.ts +1 -0
- package/esm/hooks/index.d.ts +2 -0
- package/esm/hooks/utils/index.d.ts +1 -0
- package/esm/hooks/utils/useGridApiContext.d.ts +4 -0
- package/esm/hooks/utils/useGridApiRef.d.ts +4 -0
- package/esm/hooks/utils/useGridAriaAttributes.d.ts +2 -0
- package/esm/hooks/utils/useGridPrivateApiContext.d.ts +2 -0
- package/esm/hooks/utils/useGridRootProps.d.ts +2 -0
- package/esm/hooks/utils/useKeepGroupedColumnsHidden.d.ts +12 -0
- package/esm/hooks/utils/useKeepGroupedColumnsHidden.js +2 -2
- package/esm/index.d.ts +23 -0
- package/esm/index.js +6 -5
- package/esm/locales.d.ts +1 -0
- package/esm/material/icons.d.ts +15 -0
- package/esm/material/index.d.ts +8 -0
- package/esm/models/dataGridPremiumProps.d.ts +162 -0
- package/esm/models/gridApiPremium.d.ts +14 -0
- package/esm/models/gridGroupingValueGetter.d.ts +4 -0
- package/esm/models/gridPastedValueParser.d.ts +4 -0
- package/esm/models/gridPremiumIconSlotsComponent.d.ts +28 -0
- package/esm/models/gridPremiumSlotsComponent.d.ts +7 -0
- package/esm/models/gridStatePremium.d.ts +18 -0
- package/esm/models/index.d.ts +4 -0
- package/esm/package.json +1 -0
- package/esm/setupExcelExportWebWorker.d.ts +1 -0
- package/esm/setupExcelExportWebWorker.js +1 -0
- package/esm/themeAugmentation/index.d.ts +2 -0
- package/esm/themeAugmentation/overrides.d.ts +7 -0
- package/esm/themeAugmentation/props.d.ts +15 -0
- package/esm/typeOverloads/index.d.ts +2 -0
- package/esm/typeOverloads/modules.d.ts +97 -0
- package/esm/typeOverloads/reexports.d.ts +17 -0
- package/esm/utils/releaseInfo.d.ts +1 -0
- package/esm/utils/releaseInfo.js +1 -1
- package/hooks/features/aggregation/createAggregationLookup.d.ts +16 -10
- package/hooks/features/aggregation/createAggregationLookup.js +2 -2
- package/hooks/features/aggregation/gridAggregationFunctions.d.ts +7 -7
- package/hooks/features/aggregation/gridAggregationInterfaces.d.ts +81 -82
- package/hooks/features/aggregation/gridAggregationSelectors.d.ts +3 -3
- package/hooks/features/aggregation/gridAggregationSelectors.js +1 -2
- package/hooks/features/aggregation/gridAggregationUtils.d.ts +42 -25
- package/hooks/features/aggregation/gridAggregationUtils.js +1 -1
- package/hooks/features/aggregation/index.d.ts +4 -4
- package/hooks/features/aggregation/useGridAggregation.d.ts +3 -3
- package/hooks/features/aggregation/useGridAggregation.js +6 -8
- package/hooks/features/aggregation/useGridAggregationPreProcessors.d.ts +3 -3
- package/hooks/features/aggregation/useGridAggregationPreProcessors.js +7 -6
- package/hooks/features/aggregation/wrapColumnWithAggregation.d.ts +67 -62
- package/hooks/features/aggregation/wrapColumnWithAggregation.js +6 -5
- package/hooks/features/cellSelection/gridCellSelectionInterfaces.d.ts +34 -34
- package/hooks/features/cellSelection/gridCellSelectionSelector.d.ts +2 -2
- package/hooks/features/cellSelection/gridCellSelectionSelector.js +2 -2
- package/hooks/features/cellSelection/index.d.ts +1 -1
- package/hooks/features/cellSelection/useGridCellSelection.d.ts +3 -3
- package/hooks/features/cellSelection/useGridCellSelection.js +13 -11
- package/hooks/features/clipboard/useGridClipboardImport.d.ts +2 -2
- package/hooks/features/clipboard/useGridClipboardImport.js +4 -4
- package/hooks/features/dataSource/models.d.ts +41 -34
- package/hooks/features/dataSource/useGridDataSourcePremium.d.ts +3 -3
- package/hooks/features/dataSource/useGridDataSourcePremium.js +13 -7
- package/hooks/features/export/gridExcelExportInterface.d.ts +52 -52
- package/hooks/features/export/index.d.ts +2 -2
- package/hooks/features/export/index.js +2 -2
- package/hooks/features/export/serializer/excelSerializer.d.ts +23 -51
- package/hooks/features/export/serializer/excelSerializer.js +74 -187
- package/hooks/features/export/serializer/setupExcelExportWebWorker.d.ts +2 -0
- package/hooks/features/export/serializer/setupExcelExportWebWorker.js +59 -0
- package/hooks/features/export/serializer/utils.d.ts +36 -0
- package/hooks/features/export/serializer/utils.js +106 -0
- package/hooks/features/export/useGridExcelExport.d.ts +3 -3
- package/hooks/features/export/useGridExcelExport.js +10 -3
- package/hooks/features/index.d.ts +5 -5
- package/hooks/features/promptControl/api.d.ts +2 -2
- package/hooks/features/promptControl/index.d.ts +2 -2
- package/hooks/features/promptControl/types.d.ts +15 -15
- package/hooks/features/rowGrouping/createGroupingColDef.d.ts +44 -32
- package/hooks/features/rowGrouping/createGroupingColDef.js +4 -4
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +32 -32
- package/hooks/features/rowGrouping/gridRowGroupingSelector.d.ts +2 -2
- package/hooks/features/rowGrouping/gridRowGroupingSelector.js +2 -2
- package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +30 -22
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -2
- package/hooks/features/rowGrouping/index.d.ts +3 -3
- package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.d.ts +3 -3
- package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +3 -3
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +3 -3
- package/hooks/features/rowGrouping/useGridRowGrouping.js +4 -5
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +3 -3
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +5 -5
- package/hooks/features/rows/index.d.ts +1 -1
- package/hooks/features/rows/useGridRowAriaAttributes.d.ts +1 -1
- package/hooks/index.d.ts +2 -2
- package/hooks/utils/index.d.ts +1 -1
- package/hooks/utils/useGridApiContext.d.ts +4 -2
- package/hooks/utils/useGridApiRef.d.ts +4 -2
- package/hooks/utils/useGridAriaAttributes.d.ts +1 -1
- package/hooks/utils/useGridPrivateApiContext.d.ts +2 -2
- package/hooks/utils/useGridRootProps.d.ts +2 -2
- package/hooks/utils/useKeepGroupedColumnsHidden.d.ts +4 -4
- package/hooks/utils/useKeepGroupedColumnsHidden.js +2 -2
- package/index.d.ts +9 -17
- package/index.js +2 -11
- package/locales.d.ts +1 -1
- package/material/icons.d.ts +6 -6
- package/material/index.d.ts +6 -6
- package/models/dataGridPremiumProps.d.ts +140 -135
- package/models/gridApiPremium.d.ts +4 -6
- package/models/gridGroupingValueGetter.d.ts +2 -2
- package/models/gridPastedValueParser.d.ts +2 -2
- package/models/gridPremiumIconSlotsComponent.d.ts +26 -26
- package/models/gridPremiumSlotsComponent.d.ts +2 -3
- package/models/gridStatePremium.d.ts +7 -7
- package/models/index.d.ts +4 -4
- package/modern/DataGridPremium/DataGrid.d.ts +8 -0
- package/modern/DataGridPremium/DataGridPremium.d.ts +16 -0
- package/modern/DataGridPremium/DataGridPremium.js +61 -35
- package/modern/DataGridPremium/index.d.ts +3 -0
- package/modern/DataGridPremium/useDataGridPremiumComponent.d.ts +4 -0
- package/modern/DataGridPremium/useDataGridPremiumComponent.js +6 -5
- package/modern/DataGridPremium/useDataGridPremiumProps.d.ts +6 -0
- package/modern/DataGridPremium/useDataGridPremiumProps.js +2 -2
- package/modern/components/GridAggregationHeader.d.ts +7 -0
- package/modern/components/GridAggregationHeader.js +13 -12
- package/modern/components/GridAggregationRowOverlay.d.ts +3 -0
- package/modern/components/GridAggregationRowOverlay.js +37 -0
- package/modern/components/GridBottomContainer.d.ts +3 -0
- package/modern/components/GridBottomContainer.js +43 -0
- package/modern/components/GridColumnMenuAggregationItem.d.ts +7 -0
- package/modern/components/GridColumnMenuAggregationItem.js +36 -46
- package/modern/components/GridColumnMenuRowGroupItem.d.ts +3 -0
- package/modern/components/GridColumnMenuRowUngroupItem.d.ts +3 -0
- package/modern/components/GridDataSourceGroupingCriteriaCell.d.ts +7 -0
- package/modern/components/GridDataSourceGroupingCriteriaCell.js +9 -13
- package/modern/components/GridExcelExportMenuItem.d.ts +9 -0
- package/modern/components/GridFooterCell.d.ts +9 -0
- package/modern/components/GridFooterCell.js +5 -6
- package/modern/components/GridGroupingColumnFooterCell.d.ts +4 -0
- package/modern/components/GridGroupingColumnFooterCell.js +2 -1
- package/modern/components/GridGroupingColumnLeafCell.d.ts +4 -0
- package/modern/components/GridGroupingColumnLeafCell.js +3 -8
- package/modern/components/GridGroupingCriteriaCell.d.ts +7 -0
- package/modern/components/GridGroupingCriteriaCell.js +3 -8
- package/modern/components/GridPremiumColumnMenu.d.ts +33 -0
- package/modern/components/GridPremiumToolbar.d.ts +3 -0
- package/modern/components/GridPremiumToolbar.js +23 -0
- package/modern/components/export/ExportExcel.d.ts +29 -0
- package/modern/components/export/ExportExcel.js +209 -0
- package/modern/components/export/index.d.ts +1 -0
- package/modern/components/export/index.js +1 -0
- package/modern/components/index.d.ts +6 -0
- package/modern/components/index.js +2 -1
- package/modern/components/promptControl/GridToolbarPromptControl.d.ts +26 -0
- package/modern/components/promptControl/GridToolbarPromptControl.js +33 -20
- package/modern/components/promptControl/RecordButton.d.ts +16 -0
- package/modern/components/promptControl/index.d.ts +1 -0
- package/modern/components/reexports.d.ts +1 -0
- package/modern/constants/dataGridPremiumDefaultSlotsComponents.d.ts +2 -0
- package/modern/constants/dataGridPremiumDefaultSlotsComponents.js +5 -1
- package/modern/hooks/features/aggregation/createAggregationLookup.d.ts +17 -0
- package/modern/hooks/features/aggregation/createAggregationLookup.js +3 -3
- package/modern/hooks/features/aggregation/gridAggregationFunctions.d.ts +8 -0
- package/modern/hooks/features/aggregation/gridAggregationInterfaces.d.ts +129 -0
- package/modern/hooks/features/aggregation/gridAggregationSelectors.d.ts +13 -0
- package/modern/hooks/features/aggregation/gridAggregationSelectors.js +2 -2
- package/modern/hooks/features/aggregation/gridAggregationUtils.d.ts +62 -0
- package/modern/hooks/features/aggregation/gridAggregationUtils.js +1 -1
- package/modern/hooks/features/aggregation/index.d.ts +4 -0
- package/modern/hooks/features/aggregation/useGridAggregation.d.ts +6 -0
- package/modern/hooks/features/aggregation/useGridAggregation.js +6 -8
- package/modern/hooks/features/aggregation/useGridAggregationPreProcessors.d.ts +4 -0
- package/modern/hooks/features/aggregation/useGridAggregationPreProcessors.js +7 -6
- package/modern/hooks/features/aggregation/wrapColumnWithAggregation.d.ts +81 -0
- package/modern/hooks/features/aggregation/wrapColumnWithAggregation.js +6 -5
- package/modern/hooks/features/cellSelection/gridCellSelectionInterfaces.d.ts +40 -0
- package/modern/hooks/features/cellSelection/gridCellSelectionSelector.d.ts +2 -0
- package/modern/hooks/features/cellSelection/gridCellSelectionSelector.js +2 -1
- package/modern/hooks/features/cellSelection/index.d.ts +1 -0
- package/modern/hooks/features/cellSelection/useGridCellSelection.d.ts +6 -0
- package/modern/hooks/features/cellSelection/useGridCellSelection.js +15 -13
- package/modern/hooks/features/clipboard/useGridClipboardImport.d.ts +4 -0
- package/modern/hooks/features/clipboard/useGridClipboardImport.js +5 -5
- package/modern/hooks/features/dataSource/models.d.ts +54 -0
- package/modern/hooks/features/dataSource/useGridDataSourcePremium.d.ts +4 -0
- package/modern/hooks/features/dataSource/useGridDataSourcePremium.js +13 -7
- package/modern/hooks/features/export/gridExcelExportInterface.d.ts +71 -0
- package/modern/hooks/features/export/index.d.ts +2 -0
- package/modern/hooks/features/export/index.js +1 -1
- package/modern/hooks/features/export/serializer/excelSerializer.d.ts +40 -0
- package/modern/hooks/features/export/serializer/excelSerializer.js +69 -180
- package/modern/hooks/features/export/serializer/setupExcelExportWebWorker.d.ts +2 -0
- package/modern/hooks/features/export/serializer/setupExcelExportWebWorker.js +53 -0
- package/modern/hooks/features/export/serializer/utils.d.ts +36 -0
- package/modern/hooks/features/export/serializer/utils.js +93 -0
- package/modern/hooks/features/export/useGridExcelExport.d.ts +11 -0
- package/modern/hooks/features/export/useGridExcelExport.js +11 -5
- package/modern/hooks/features/index.d.ts +5 -0
- package/modern/hooks/features/promptControl/api.d.ts +2 -0
- package/modern/hooks/features/promptControl/index.d.ts +2 -0
- package/modern/hooks/features/promptControl/types.d.ts +25 -0
- package/modern/hooks/features/rowGrouping/createGroupingColDef.d.ts +57 -0
- package/modern/hooks/features/rowGrouping/createGroupingColDef.js +5 -5
- package/modern/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +44 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingSelector.d.ts +3 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingSelector.js +2 -2
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +54 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -3
- package/modern/hooks/features/rowGrouping/index.d.ts +3 -0
- package/modern/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.d.ts +4 -0
- package/modern/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +3 -3
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.d.ts +11 -0
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +4 -5
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +4 -0
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +5 -5
- package/modern/hooks/features/rows/index.d.ts +1 -0
- package/modern/hooks/features/rows/useGridRowAriaAttributes.d.ts +1 -0
- package/modern/hooks/index.d.ts +2 -0
- package/modern/hooks/utils/index.d.ts +1 -0
- package/modern/hooks/utils/useGridApiContext.d.ts +4 -0
- package/modern/hooks/utils/useGridApiRef.d.ts +4 -0
- package/modern/hooks/utils/useGridAriaAttributes.d.ts +2 -0
- package/modern/hooks/utils/useGridPrivateApiContext.d.ts +2 -0
- package/modern/hooks/utils/useGridRootProps.d.ts +2 -0
- package/modern/hooks/utils/useKeepGroupedColumnsHidden.d.ts +12 -0
- package/modern/hooks/utils/useKeepGroupedColumnsHidden.js +2 -2
- package/modern/index.d.ts +23 -0
- package/modern/index.js +1 -7
- package/modern/locales.d.ts +1 -0
- package/modern/material/icons.d.ts +15 -0
- package/modern/material/index.d.ts +8 -0
- package/modern/models/dataGridPremiumProps.d.ts +162 -0
- package/modern/models/gridApiPremium.d.ts +14 -0
- package/modern/models/gridGroupingValueGetter.d.ts +4 -0
- package/modern/models/gridPastedValueParser.d.ts +4 -0
- package/modern/models/gridPremiumIconSlotsComponent.d.ts +28 -0
- package/modern/models/gridPremiumSlotsComponent.d.ts +7 -0
- package/modern/models/gridStatePremium.d.ts +18 -0
- package/modern/models/index.d.ts +4 -0
- package/modern/package.json +1 -0
- package/modern/setupExcelExportWebWorker.d.ts +1 -0
- package/modern/setupExcelExportWebWorker.js +1 -0
- package/modern/themeAugmentation/index.d.ts +2 -0
- package/modern/themeAugmentation/overrides.d.ts +7 -0
- package/modern/themeAugmentation/props.d.ts +15 -0
- package/modern/typeOverloads/index.d.ts +2 -0
- package/modern/typeOverloads/modules.d.ts +97 -0
- package/modern/typeOverloads/reexports.d.ts +17 -0
- package/modern/utils/releaseInfo.d.ts +1 -0
- package/modern/utils/releaseInfo.js +1 -1
- package/package.json +42 -9
- package/setupExcelExportWebWorker.d.ts +1 -0
- package/setupExcelExportWebWorker.js +12 -0
- package/themeAugmentation/index.d.ts +2 -2
- package/themeAugmentation/overrides.d.ts +3 -4
- package/themeAugmentation/props.d.ts +9 -11
- package/tsconfig.build.tsbuildinfo +1 -0
- package/typeOverloads/index.d.ts +1 -1
- package/typeOverloads/modules.d.ts +75 -82
- package/typeOverloads/reexports.d.ts +5 -5
- package/utils/releaseInfo.d.ts +1 -1
- package/utils/releaseInfo.js +1 -1
- package/DataGridPremium/package.json +0 -6
- package/components/package.json +0 -6
- package/esm/hooks/features/dataSource/cache.js +0 -3
- package/hooks/features/dataSource/cache.d.ts +0 -2
- package/hooks/features/dataSource/cache.js +0 -9
- package/hooks/package.json +0 -6
- package/material/package.json +0 -6
- package/models/package.json +0 -6
- package/modern/hooks/features/dataSource/cache.js +0 -3
- package/themeAugmentation/package.json +0 -6
- package/typeOverloads/package.json +0 -6
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useGridApiEventHandler as addEventHandler, useGridApiMethod, GRID_ROOT_GROUP_ID } from '@mui/x-data-grid-pro';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { useGridDataSourceBasePro, useGridRegisterStrategyProcessor, useGridRegisterPipeProcessor } from '@mui/x-data-grid-pro/internals';
|
|
5
|
+
function getKeyPremium(params) {
|
|
6
|
+
return JSON.stringify([params.filterModel, params.sortModel, params.groupKeys, params.groupFields, params.start, params.end, params.aggregationModel]);
|
|
7
|
+
}
|
|
6
8
|
const options = {
|
|
7
9
|
cacheOptions: {
|
|
8
10
|
getKey: getKeyPremium
|
|
@@ -12,8 +14,9 @@ export const useGridDataSourcePremium = (apiRef, props) => {
|
|
|
12
14
|
const {
|
|
13
15
|
api,
|
|
14
16
|
strategyProcessor,
|
|
15
|
-
events
|
|
16
|
-
|
|
17
|
+
events,
|
|
18
|
+
setStrategyAvailability
|
|
19
|
+
} = useGridDataSourceBasePro(apiRef, props, options);
|
|
17
20
|
const aggregateRowRef = React.useRef({});
|
|
18
21
|
const processDataSourceRows = React.useCallback(({
|
|
19
22
|
params,
|
|
@@ -35,11 +38,11 @@ export const useGridDataSourcePremium = (apiRef, props) => {
|
|
|
35
38
|
}, [apiRef]);
|
|
36
39
|
const resolveGroupAggregation = React.useCallback((groupId, field) => {
|
|
37
40
|
if (groupId === GRID_ROOT_GROUP_ID) {
|
|
38
|
-
return props.
|
|
41
|
+
return props.dataSource?.getAggregatedValue?.(aggregateRowRef.current, field);
|
|
39
42
|
}
|
|
40
43
|
const row = apiRef.current.getRow(groupId);
|
|
41
|
-
return props.
|
|
42
|
-
}, [apiRef, props.
|
|
44
|
+
return props.dataSource?.getAggregatedValue?.(row, field);
|
|
45
|
+
}, [apiRef, props.dataSource]);
|
|
43
46
|
const privateApi = _extends({}, api.private, {
|
|
44
47
|
resolveGroupAggregation
|
|
45
48
|
});
|
|
@@ -50,4 +53,7 @@ export const useGridDataSourcePremium = (apiRef, props) => {
|
|
|
50
53
|
Object.entries(events).forEach(([event, handler]) => {
|
|
51
54
|
addEventHandler(apiRef, event, handler);
|
|
52
55
|
});
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
setStrategyAvailability();
|
|
58
|
+
}, [setStrategyAvailability]);
|
|
53
59
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type * as Excel from 'exceljs';
|
|
2
|
+
import { GridFileExportOptions, GridExportFormat as GridExportFormatCommunity, GridExportExtension as GridExportExtensionCommunity } from '@mui/x-data-grid-pro';
|
|
3
|
+
export type GridExportFormat = GridExportFormatCommunity | 'excel';
|
|
4
|
+
export type GridExportExtension = GridExportExtensionCommunity | 'xlsx';
|
|
5
|
+
export interface GridExceljsProcessInput {
|
|
6
|
+
workbook: Excel.Workbook;
|
|
7
|
+
worksheet: Excel.Worksheet;
|
|
8
|
+
}
|
|
9
|
+
export interface ColumnsStylesInterface {
|
|
10
|
+
[field: string]: Partial<Excel.Style>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The options to apply on the Excel export.
|
|
14
|
+
* @demos
|
|
15
|
+
* - [Excel export](/x/react-data-grid/export/#excel-export)
|
|
16
|
+
*/
|
|
17
|
+
export interface GridExcelExportOptions extends GridFileExportOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Function to return the Worker instance to be called.
|
|
20
|
+
* @returns {() => Worker} A Worker instance.
|
|
21
|
+
*/
|
|
22
|
+
worker?: () => Worker;
|
|
23
|
+
/**
|
|
24
|
+
* Name given to the worksheet containing the columns valueOptions.
|
|
25
|
+
* valueOptions are added to this worksheet if they are provided as an array.
|
|
26
|
+
*/
|
|
27
|
+
valueOptionsSheetName?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Method called before adding the rows to the workbook.
|
|
30
|
+
* Not supported when `worker` is set.
|
|
31
|
+
* To use with web workers, use the option in `setupExcelExportWebWorker`.
|
|
32
|
+
* @param {GridExceljsProcessInput} processInput object containing the workbook and the worksheet.
|
|
33
|
+
* @returns {Promise<void>} A promise which resolves after processing the input.
|
|
34
|
+
* */
|
|
35
|
+
exceljsPreProcess?: (processInput: GridExceljsProcessInput) => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Method called after adding the rows to the workbook.
|
|
38
|
+
* Not supported when `worker` is set.
|
|
39
|
+
* To use with web workers, use the option in `setupExcelExportWebWorker`.
|
|
40
|
+
* @param {GridExceljsProcessInput} processInput object containing the workbook and the worksheet.
|
|
41
|
+
* @returns {Promise<void>} A promise which resolves after processing the input.
|
|
42
|
+
* */
|
|
43
|
+
exceljsPostProcess?: (processInput: GridExceljsProcessInput) => Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Object mapping column field to Exceljs style
|
|
46
|
+
* */
|
|
47
|
+
columnsStyles?: ColumnsStylesInterface;
|
|
48
|
+
/**
|
|
49
|
+
* If `true`, the headers of the column groups will be added into the file.
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
includeColumnGroupsHeaders?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The excel export API interface that is available in the grid [[apiRef]].
|
|
56
|
+
*/
|
|
57
|
+
export interface GridExcelExportApi {
|
|
58
|
+
/**
|
|
59
|
+
* Returns the grid data as an exceljs workbook.
|
|
60
|
+
* This method is used internally by `exportDataAsExcel`.
|
|
61
|
+
* @param {GridExcelExportOptions} options The options to apply on the export.
|
|
62
|
+
* @returns {Promise<Excel.Workbook>} The data in a exceljs workbook object.
|
|
63
|
+
*/
|
|
64
|
+
getDataAsExcel: (options?: GridExcelExportOptions) => Promise<Excel.Workbook> | null;
|
|
65
|
+
/**
|
|
66
|
+
* Downloads and exports an Excel file of the grid's data.
|
|
67
|
+
* @param {GridExcelExportOptions} options The options to apply on the export.
|
|
68
|
+
* @returns {Promise<void>} A promise which resolves after exporting to Excel.
|
|
69
|
+
*/
|
|
70
|
+
exportDataAsExcel: (options?: GridExcelExportOptions) => Promise<void>;
|
|
71
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./gridExcelExportInterface.js";
|
|
2
|
-
export { setupExcelExportWebWorker } from "./serializer/
|
|
2
|
+
export { setupExcelExportWebWorker } from "./serializer/setupExcelExportWebWorker.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type * as Excel from 'exceljs';
|
|
2
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
3
|
+
import { GridRowId, GridColDef } from '@mui/x-data-grid-pro';
|
|
4
|
+
import { GridStateColDef } from '@mui/x-data-grid/internals';
|
|
5
|
+
import { ColumnsStylesInterface, GridExcelExportOptions } from "../gridExcelExportInterface.js";
|
|
6
|
+
import { GridPrivateApiPremium } from "../../../../models/gridApiPremium.js";
|
|
7
|
+
import { SerializedColumns, SerializedRow, ValueOptionsData } from "./utils.js";
|
|
8
|
+
export type { ExcelExportInitEvent } from './utils';
|
|
9
|
+
/**
|
|
10
|
+
* FIXME: This function mutates the colspan info, but colspan info assumes that the columns
|
|
11
|
+
* passed to it are always consistent. In this case, the exported columns may differ from the
|
|
12
|
+
* actual rendered columns.
|
|
13
|
+
* The caller of this function MUST call `resetColSpan()` before and after usage.
|
|
14
|
+
*/
|
|
15
|
+
export declare const serializeRowUnsafe: (id: GridRowId, columns: GridStateColDef[], apiRef: RefObject<GridPrivateApiPremium>, defaultValueOptionsFormulae: {
|
|
16
|
+
[field: string]: {
|
|
17
|
+
address: string;
|
|
18
|
+
};
|
|
19
|
+
}, options: Pick<BuildExcelOptions, "escapeFormulas">) => SerializedRow;
|
|
20
|
+
export declare const serializeColumn: (column: GridColDef, columnsStyles: ColumnsStylesInterface) => {
|
|
21
|
+
key: string;
|
|
22
|
+
headerText: string;
|
|
23
|
+
width: number;
|
|
24
|
+
style: {
|
|
25
|
+
numFmt?: string | undefined;
|
|
26
|
+
font?: Partial<Excel.Font> | undefined;
|
|
27
|
+
alignment?: Partial<Excel.Alignment> | undefined;
|
|
28
|
+
protection?: Partial<Excel.Protection> | undefined;
|
|
29
|
+
border?: Partial<Excel.Borders> | undefined;
|
|
30
|
+
fill?: Excel.Fill | undefined;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export declare function serializeColumns(columns: GridStateColDef[], styles: ColumnsStylesInterface): SerializedColumns;
|
|
34
|
+
export declare function getDataForValueOptionsSheet(columns: GridStateColDef[], valueOptionsSheetName: string, api: GridPrivateApiPremium): Promise<ValueOptionsData>;
|
|
35
|
+
interface BuildExcelOptions extends Pick<GridExcelExportOptions, 'exceljsPreProcess' | 'exceljsPostProcess'>, Pick<Required<GridExcelExportOptions>, 'valueOptionsSheetName' | 'includeHeaders' | 'includeColumnGroupsHeaders' | 'escapeFormulas'> {
|
|
36
|
+
columns: GridStateColDef[];
|
|
37
|
+
rowIds: GridRowId[];
|
|
38
|
+
columnsStyles?: ColumnsStylesInterface;
|
|
39
|
+
}
|
|
40
|
+
export declare function buildExcel(options: BuildExcelOptions, apiRef: RefObject<GridPrivateApiPremium>): Promise<Excel.Workbook>;
|
|
@@ -2,27 +2,32 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { GRID_DATE_COL_DEF, GRID_DATETIME_COL_DEF } from '@mui/x-data-grid-pro';
|
|
3
3
|
import { isObject, isSingleSelectColDef, gridHasColSpanSelector } from '@mui/x-data-grid/internals';
|
|
4
4
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return excelJsModule.default ?? excelJsModule;
|
|
8
|
-
};
|
|
9
|
-
const getFormattedValueOptions = (colDef, row, valueOptions, api) => {
|
|
5
|
+
import { addColumnGroupingHeaders, addSerializedRowToWorksheet, createValueOptionsSheetIfNeeded, getExcelJs } from "./utils.js";
|
|
6
|
+
const getFormattedValueOptions = (colDef, row, valueOptions, api, callback) => {
|
|
10
7
|
if (!colDef.valueOptions) {
|
|
11
|
-
return
|
|
8
|
+
return;
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const valueFormatter = colDef.valueFormatter;
|
|
11
|
+
for (let i = 0; i < valueOptions.length; i += 1) {
|
|
12
|
+
const option = valueOptions[i];
|
|
13
|
+
let value;
|
|
14
|
+
if (valueFormatter) {
|
|
16
15
|
if (typeof option === 'object') {
|
|
17
|
-
|
|
16
|
+
value = option.label;
|
|
17
|
+
} else {
|
|
18
|
+
value = String(colDef.valueFormatter(option, row, colDef, {
|
|
19
|
+
current: api
|
|
20
|
+
}));
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
} else {
|
|
23
|
+
value = typeof option === 'object' ? option.label : option;
|
|
24
|
+
}
|
|
25
|
+
callback(value, i);
|
|
23
26
|
}
|
|
24
|
-
return valueOptionsFormatted.map(option => typeof option === 'object' ? option.label : option);
|
|
25
27
|
};
|
|
28
|
+
const commaRegex = /,/g;
|
|
29
|
+
const commaReplacement = 'CHAR(44)';
|
|
30
|
+
|
|
26
31
|
/**
|
|
27
32
|
* FIXME: This function mutates the colspan info, but colspan info assumes that the columns
|
|
28
33
|
* passed to it are always consistent. In this case, the exported columns may differ from the
|
|
@@ -30,11 +35,15 @@ const getFormattedValueOptions = (colDef, row, valueOptions, api) => {
|
|
|
30
35
|
* The caller of this function MUST call `resetColSpan()` before and after usage.
|
|
31
36
|
*/
|
|
32
37
|
export const serializeRowUnsafe = (id, columns, apiRef, defaultValueOptionsFormulae, options) => {
|
|
33
|
-
const
|
|
38
|
+
const serializedRow = {};
|
|
34
39
|
const dataValidation = {};
|
|
35
40
|
const mergedCells = [];
|
|
36
|
-
const
|
|
37
|
-
const
|
|
41
|
+
const row = apiRef.current.getRow(id);
|
|
42
|
+
const rowNode = apiRef.current.getRowNode(id);
|
|
43
|
+
if (!row || !rowNode) {
|
|
44
|
+
throw new Error(`No row with id #${id} found`);
|
|
45
|
+
}
|
|
46
|
+
const outlineLevel = rowNode.depth;
|
|
38
47
|
const hasColSpan = gridHasColSpanSelector(apiRef);
|
|
39
48
|
if (hasColSpan) {
|
|
40
49
|
// `colSpan` is only calculated for rendered rows, so we need to calculate it during export for every row
|
|
@@ -56,25 +65,32 @@ export const serializeRowUnsafe = (id, columns, apiRef, defaultValueOptionsFormu
|
|
|
56
65
|
rightIndex: colIndex + colSpanInfo.cellProps.colSpan
|
|
57
66
|
});
|
|
58
67
|
}
|
|
59
|
-
const cellParams = apiRef.current.getCellParams(id, column.field);
|
|
60
68
|
let cellValue;
|
|
61
|
-
switch (
|
|
69
|
+
switch (column.type) {
|
|
62
70
|
case 'singleSelect':
|
|
63
71
|
{
|
|
64
|
-
const castColumn =
|
|
72
|
+
const castColumn = column;
|
|
65
73
|
if (typeof castColumn.valueOptions === 'function') {
|
|
66
74
|
// If value option depends on the row, set specific options to the cell
|
|
67
75
|
// This dataValidation is buggy with LibreOffice and does not allow to have coma
|
|
68
76
|
const valueOptions = castColumn.valueOptions({
|
|
69
77
|
id,
|
|
70
78
|
row,
|
|
71
|
-
field:
|
|
79
|
+
field: column.field
|
|
80
|
+
});
|
|
81
|
+
let formulae = '"';
|
|
82
|
+
getFormattedValueOptions(castColumn, row, valueOptions, apiRef.current, (value, index) => {
|
|
83
|
+
const formatted = value.toString().replace(commaRegex, commaReplacement);
|
|
84
|
+
formulae += formatted;
|
|
85
|
+
if (index < valueOptions.length - 1) {
|
|
86
|
+
formulae += ',';
|
|
87
|
+
}
|
|
72
88
|
});
|
|
73
|
-
|
|
89
|
+
formulae += '"';
|
|
74
90
|
dataValidation[castColumn.field] = {
|
|
75
91
|
type: 'list',
|
|
76
92
|
allowBlank: true,
|
|
77
|
-
formulae: [
|
|
93
|
+
formulae: [formulae]
|
|
78
94
|
};
|
|
79
95
|
} else {
|
|
80
96
|
const address = defaultValueOptionsFormulae[column.field].address;
|
|
@@ -86,22 +102,22 @@ export const serializeRowUnsafe = (id, columns, apiRef, defaultValueOptionsFormu
|
|
|
86
102
|
formulae: [address]
|
|
87
103
|
};
|
|
88
104
|
}
|
|
89
|
-
const formattedValue = apiRef.current.
|
|
105
|
+
const formattedValue = apiRef.current.getRowFormattedValue(row, castColumn);
|
|
90
106
|
if (process.env.NODE_ENV !== 'production') {
|
|
91
|
-
if (String(
|
|
107
|
+
if (String(formattedValue) === '[object Object]') {
|
|
92
108
|
warnOnce(['MUI X: When the value of a field is an object or a `renderCell` is provided, the Excel export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
|
|
93
109
|
}
|
|
94
110
|
}
|
|
95
111
|
if (isObject(formattedValue)) {
|
|
96
|
-
|
|
112
|
+
serializedRow[castColumn.field] = formattedValue?.label;
|
|
97
113
|
} else {
|
|
98
|
-
|
|
114
|
+
serializedRow[castColumn.field] = formattedValue;
|
|
99
115
|
}
|
|
100
116
|
break;
|
|
101
117
|
}
|
|
102
118
|
case 'boolean':
|
|
103
119
|
case 'number':
|
|
104
|
-
cellValue = apiRef.current.
|
|
120
|
+
cellValue = apiRef.current.getRowValue(row, column);
|
|
105
121
|
break;
|
|
106
122
|
case 'date':
|
|
107
123
|
case 'dateTime':
|
|
@@ -109,21 +125,21 @@ export const serializeRowUnsafe = (id, columns, apiRef, defaultValueOptionsFormu
|
|
|
109
125
|
// Excel does not do any timezone conversion, so we create a date using UTC instead of local timezone
|
|
110
126
|
// Solution from: https://github.com/exceljs/exceljs/issues/486#issuecomment-432557582
|
|
111
127
|
// About Date.UTC(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC#exemples
|
|
112
|
-
const value = apiRef.current.
|
|
128
|
+
const value = apiRef.current.getRowValue(row, column);
|
|
113
129
|
// value may be `undefined` in auto-generated grouping rows
|
|
114
130
|
if (!value) {
|
|
115
131
|
break;
|
|
116
132
|
}
|
|
117
133
|
const utcDate = new Date(Date.UTC(value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds()));
|
|
118
|
-
|
|
134
|
+
serializedRow[column.field] = utcDate;
|
|
119
135
|
break;
|
|
120
136
|
}
|
|
121
137
|
case 'actions':
|
|
122
138
|
break;
|
|
123
139
|
default:
|
|
124
|
-
cellValue = apiRef.current.
|
|
140
|
+
cellValue = apiRef.current.getRowFormattedValue(row, column);
|
|
125
141
|
if (process.env.NODE_ENV !== 'production') {
|
|
126
|
-
if (String(
|
|
142
|
+
if (String(cellValue) === '[object Object]') {
|
|
127
143
|
warnOnce(['MUI X: When the value of a field is an object or a `renderCell` is provided, the Excel export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
|
|
128
144
|
}
|
|
129
145
|
}
|
|
@@ -136,11 +152,11 @@ export const serializeRowUnsafe = (id, columns, apiRef, defaultValueOptionsFormu
|
|
|
136
152
|
}
|
|
137
153
|
}
|
|
138
154
|
if (typeof cellValue !== 'undefined') {
|
|
139
|
-
|
|
155
|
+
serializedRow[column.field] = cellValue;
|
|
140
156
|
}
|
|
141
157
|
});
|
|
142
158
|
return {
|
|
143
|
-
row,
|
|
159
|
+
row: serializedRow,
|
|
144
160
|
dataValidation,
|
|
145
161
|
outlineLevel,
|
|
146
162
|
mergedCells
|
|
@@ -169,120 +185,39 @@ export const serializeColumn = (column, columnsStyles) => {
|
|
|
169
185
|
style: _extends({}, type && defaultColumnsStyles?.[type], columnsStyles?.[field])
|
|
170
186
|
};
|
|
171
187
|
};
|
|
172
|
-
const addColumnGroupingHeaders = (worksheet, columns, columnGroupPaths, columnGroupDetails) => {
|
|
173
|
-
const maxDepth = Math.max(...columns.map(({
|
|
174
|
-
key
|
|
175
|
-
}) => columnGroupPaths[key]?.length ?? 0));
|
|
176
|
-
if (maxDepth === 0) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
for (let rowIndex = 0; rowIndex < maxDepth; rowIndex += 1) {
|
|
180
|
-
const row = columns.map(({
|
|
181
|
-
key
|
|
182
|
-
}) => {
|
|
183
|
-
const groupingPath = columnGroupPaths[key];
|
|
184
|
-
if (groupingPath.length <= rowIndex) {
|
|
185
|
-
return {
|
|
186
|
-
groupId: null,
|
|
187
|
-
parents: groupingPath
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
return _extends({}, columnGroupDetails[groupingPath[rowIndex]], {
|
|
191
|
-
parents: groupingPath.slice(0, rowIndex)
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
const newRow = worksheet.addRow(row.map(group => group.groupId === null ? null : group?.headerName ?? group.groupId));
|
|
195
|
-
|
|
196
|
-
// use `rowCount`, since worksheet can have additional rows added in `exceljsPreProcess`
|
|
197
|
-
const lastRowIndex = newRow.worksheet.rowCount;
|
|
198
|
-
let leftIndex = 0;
|
|
199
|
-
let rightIndex = 1;
|
|
200
|
-
while (rightIndex < columns.length) {
|
|
201
|
-
const {
|
|
202
|
-
groupId: leftGroupId,
|
|
203
|
-
parents: leftParents
|
|
204
|
-
} = row[leftIndex];
|
|
205
|
-
const {
|
|
206
|
-
groupId: rightGroupId,
|
|
207
|
-
parents: rightParents
|
|
208
|
-
} = row[rightIndex];
|
|
209
|
-
const areInSameGroup = leftGroupId === rightGroupId && leftParents.length === rightParents.length && leftParents.every((leftParent, index) => rightParents[index] === leftParent);
|
|
210
|
-
if (areInSameGroup) {
|
|
211
|
-
rightIndex += 1;
|
|
212
|
-
} else {
|
|
213
|
-
if (rightIndex - leftIndex > 1) {
|
|
214
|
-
worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
|
|
215
|
-
}
|
|
216
|
-
leftIndex = rightIndex;
|
|
217
|
-
rightIndex += 1;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
if (rightIndex - leftIndex > 1) {
|
|
221
|
-
worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
188
|
export function serializeColumns(columns, styles) {
|
|
226
189
|
return columns.map(column => serializeColumn(column, styles));
|
|
227
190
|
}
|
|
228
191
|
export async function getDataForValueOptionsSheet(columns, valueOptionsSheetName, api) {
|
|
229
|
-
const candidateColumns = columns.filter(column => isSingleSelectColDef(column) && Array.isArray(column.valueOptions));
|
|
230
|
-
|
|
231
192
|
// Creates a temp worksheet to obtain the column letters
|
|
232
193
|
const excelJS = await getExcelJs();
|
|
233
194
|
const workbook = new excelJS.Workbook();
|
|
234
195
|
const worksheet = workbook.addWorksheet('Sheet1');
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
|
|
196
|
+
const record = {};
|
|
197
|
+
const worksheetColumns = [];
|
|
198
|
+
for (let i = 0; i < columns.length; i += 1) {
|
|
199
|
+
const column = columns[i];
|
|
200
|
+
const isCandidateColumn = isSingleSelectColDef(column) && Array.isArray(column.valueOptions);
|
|
201
|
+
if (!isCandidateColumn) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
worksheetColumns.push({
|
|
205
|
+
key: column.field
|
|
206
|
+
});
|
|
207
|
+
worksheet.columns = worksheetColumns;
|
|
241
208
|
const header = column.headerName ?? column.field;
|
|
242
|
-
const values = [header
|
|
209
|
+
const values = [header];
|
|
210
|
+
getFormattedValueOptions(column, {}, column.valueOptions, api, value => {
|
|
211
|
+
values.push(value);
|
|
212
|
+
});
|
|
243
213
|
const letter = worksheet.getColumn(column.field).letter;
|
|
244
214
|
const address = `${valueOptionsSheetName}!$${letter}$2:$${letter}$${values.length}`;
|
|
245
|
-
|
|
215
|
+
record[column.field] = {
|
|
246
216
|
values,
|
|
247
217
|
address
|
|
248
218
|
};
|
|
249
|
-
return acc;
|
|
250
|
-
}, {});
|
|
251
|
-
}
|
|
252
|
-
function addSerializedRowToWorksheet(serializedRow, worksheet) {
|
|
253
|
-
const {
|
|
254
|
-
row,
|
|
255
|
-
dataValidation,
|
|
256
|
-
outlineLevel,
|
|
257
|
-
mergedCells
|
|
258
|
-
} = serializedRow;
|
|
259
|
-
const newRow = worksheet.addRow(row);
|
|
260
|
-
Object.keys(dataValidation).forEach(field => {
|
|
261
|
-
newRow.getCell(field).dataValidation = _extends({}, dataValidation[field]);
|
|
262
|
-
});
|
|
263
|
-
if (outlineLevel) {
|
|
264
|
-
newRow.outlineLevel = outlineLevel;
|
|
265
219
|
}
|
|
266
|
-
|
|
267
|
-
// use `rowCount`, since worksheet can have additional rows added in `exceljsPreProcess`
|
|
268
|
-
const lastRowIndex = newRow.worksheet.rowCount;
|
|
269
|
-
mergedCells.forEach(mergedCell => {
|
|
270
|
-
worksheet.mergeCells(lastRowIndex, mergedCell.leftIndex, lastRowIndex, mergedCell.rightIndex);
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
async function createValueOptionsSheetIfNeeded(valueOptionsData, sheetName, workbook) {
|
|
274
|
-
if (Object.keys(valueOptionsData).length === 0) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
const valueOptionsWorksheet = workbook.addWorksheet(sheetName);
|
|
278
|
-
valueOptionsWorksheet.columns = Object.keys(valueOptionsData).map(key => ({
|
|
279
|
-
key
|
|
280
|
-
}));
|
|
281
|
-
Object.entries(valueOptionsData).forEach(([field, {
|
|
282
|
-
values
|
|
283
|
-
}]) => {
|
|
284
|
-
valueOptionsWorksheet.getColumn(field).values = values;
|
|
285
|
-
});
|
|
220
|
+
return record;
|
|
286
221
|
}
|
|
287
222
|
export async function buildExcel(options, apiRef) {
|
|
288
223
|
const {
|
|
@@ -331,50 +266,4 @@ export async function buildExcel(options, apiRef) {
|
|
|
331
266
|
});
|
|
332
267
|
}
|
|
333
268
|
return workbook;
|
|
334
|
-
}
|
|
335
|
-
export function setupExcelExportWebWorker(workerOptions = {}) {
|
|
336
|
-
// eslint-disable-next-line no-restricted-globals
|
|
337
|
-
addEventListener('message', async event => {
|
|
338
|
-
const {
|
|
339
|
-
serializedColumns,
|
|
340
|
-
serializedRows,
|
|
341
|
-
options,
|
|
342
|
-
valueOptionsSheetName,
|
|
343
|
-
valueOptionsData,
|
|
344
|
-
columnGroupDetails,
|
|
345
|
-
columnGroupPaths
|
|
346
|
-
} = event.data;
|
|
347
|
-
const {
|
|
348
|
-
exceljsPostProcess,
|
|
349
|
-
exceljsPreProcess
|
|
350
|
-
} = workerOptions;
|
|
351
|
-
const excelJS = await getExcelJs();
|
|
352
|
-
const workbook = new excelJS.Workbook();
|
|
353
|
-
const worksheet = workbook.addWorksheet('Sheet1');
|
|
354
|
-
worksheet.columns = serializedColumns;
|
|
355
|
-
if (exceljsPreProcess) {
|
|
356
|
-
await exceljsPreProcess({
|
|
357
|
-
workbook,
|
|
358
|
-
worksheet
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
if (options.includeColumnGroupsHeaders) {
|
|
362
|
-
addColumnGroupingHeaders(worksheet, serializedColumns, columnGroupPaths, columnGroupDetails);
|
|
363
|
-
}
|
|
364
|
-
const includeHeaders = options.includeHeaders ?? true;
|
|
365
|
-
if (includeHeaders) {
|
|
366
|
-
worksheet.addRow(serializedColumns.map(column => column.headerText));
|
|
367
|
-
}
|
|
368
|
-
createValueOptionsSheetIfNeeded(valueOptionsData, valueOptionsSheetName, workbook);
|
|
369
|
-
serializedRows.forEach(serializedRow => {
|
|
370
|
-
addSerializedRowToWorksheet(serializedRow, worksheet);
|
|
371
|
-
});
|
|
372
|
-
if (exceljsPostProcess) {
|
|
373
|
-
await exceljsPostProcess({
|
|
374
|
-
workbook,
|
|
375
|
-
worksheet
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
postMessage(await workbook.xlsx.writeBuffer());
|
|
379
|
-
});
|
|
380
269
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { addColumnGroupingHeaders, addSerializedRowToWorksheet, createValueOptionsSheetIfNeeded, getExcelJs } from "./utils.js";
|
|
2
|
+
export function setupExcelExportWebWorker(workerOptions = {}) {
|
|
3
|
+
// eslint-disable-next-line no-restricted-globals
|
|
4
|
+
addEventListener('message', async event => {
|
|
5
|
+
const {
|
|
6
|
+
namespace,
|
|
7
|
+
serializedColumns,
|
|
8
|
+
serializedRows,
|
|
9
|
+
options,
|
|
10
|
+
valueOptionsSheetName,
|
|
11
|
+
valueOptionsData,
|
|
12
|
+
columnGroupDetails,
|
|
13
|
+
columnGroupPaths
|
|
14
|
+
} = event.data;
|
|
15
|
+
|
|
16
|
+
// workers share the pub-sub channel namespace. Use this property to filter out messages.
|
|
17
|
+
if (namespace !== 'mui-x-data-grid-export') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const {
|
|
21
|
+
exceljsPostProcess,
|
|
22
|
+
exceljsPreProcess
|
|
23
|
+
} = workerOptions;
|
|
24
|
+
const excelJS = await getExcelJs();
|
|
25
|
+
const workbook = new excelJS.Workbook();
|
|
26
|
+
const worksheet = workbook.addWorksheet('Sheet1');
|
|
27
|
+
worksheet.columns = serializedColumns;
|
|
28
|
+
if (exceljsPreProcess) {
|
|
29
|
+
await exceljsPreProcess({
|
|
30
|
+
workbook,
|
|
31
|
+
worksheet
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (options.includeColumnGroupsHeaders) {
|
|
35
|
+
addColumnGroupingHeaders(worksheet, serializedColumns, columnGroupPaths, columnGroupDetails);
|
|
36
|
+
}
|
|
37
|
+
const includeHeaders = options.includeHeaders ?? true;
|
|
38
|
+
if (includeHeaders) {
|
|
39
|
+
worksheet.addRow(serializedColumns.map(column => column.headerText));
|
|
40
|
+
}
|
|
41
|
+
createValueOptionsSheetIfNeeded(valueOptionsData, valueOptionsSheetName, workbook);
|
|
42
|
+
serializedRows.forEach(serializedRow => {
|
|
43
|
+
addSerializedRowToWorksheet(serializedRow, worksheet);
|
|
44
|
+
});
|
|
45
|
+
if (exceljsPostProcess) {
|
|
46
|
+
await exceljsPostProcess({
|
|
47
|
+
workbook,
|
|
48
|
+
worksheet
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
postMessage(await workbook.xlsx.writeBuffer());
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type * as Excel from 'exceljs';
|
|
2
|
+
import type { GridColumnGroupLookup } from '@mui/x-data-grid/internals';
|
|
3
|
+
import type { GridExcelExportOptions } from '../gridExcelExportInterface';
|
|
4
|
+
export declare const getExcelJs: () => Promise<typeof Excel>;
|
|
5
|
+
export interface SerializedRow {
|
|
6
|
+
row: Record<string, undefined | number | boolean | string | Date>;
|
|
7
|
+
dataValidation: Record<string, Excel.DataValidation>;
|
|
8
|
+
outlineLevel: number;
|
|
9
|
+
mergedCells: {
|
|
10
|
+
leftIndex: number;
|
|
11
|
+
rightIndex: number;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
export declare const addColumnGroupingHeaders: (worksheet: Excel.Worksheet, columns: SerializedColumns, columnGroupPaths: Record<string, string[]>, columnGroupDetails: GridColumnGroupLookup) => void;
|
|
15
|
+
export type SerializedColumns = Array<{
|
|
16
|
+
key: string;
|
|
17
|
+
width: number;
|
|
18
|
+
style: Partial<Excel.Style>;
|
|
19
|
+
headerText: string;
|
|
20
|
+
}>;
|
|
21
|
+
export type ValueOptionsData = Record<string, {
|
|
22
|
+
values: (string | number)[];
|
|
23
|
+
address: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function addSerializedRowToWorksheet(serializedRow: SerializedRow, worksheet: Excel.Worksheet): void;
|
|
26
|
+
export declare function createValueOptionsSheetIfNeeded(valueOptionsData: ValueOptionsData, sheetName: string, workbook: Excel.Workbook): Promise<void>;
|
|
27
|
+
export interface ExcelExportInitEvent {
|
|
28
|
+
namespace?: string;
|
|
29
|
+
serializedColumns: SerializedColumns;
|
|
30
|
+
serializedRows: SerializedRow[];
|
|
31
|
+
valueOptionsSheetName: string;
|
|
32
|
+
columnGroupPaths: Record<string, string[]>;
|
|
33
|
+
columnGroupDetails: GridColumnGroupLookup;
|
|
34
|
+
valueOptionsData: ValueOptionsData;
|
|
35
|
+
options: Omit<GridExcelExportOptions, 'exceljsPreProcess' | 'exceljsPostProcess' | 'columnsStyles' | 'valueOptionsSheetName'>;
|
|
36
|
+
}
|