@mui/x-data-grid-premium 5.11.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 +4052 -0
- package/DataGridPremium/DataGridPremium.d.ts +9 -0
- package/DataGridPremium/DataGridPremium.js +986 -0
- package/DataGridPremium/index.d.ts +2 -0
- package/DataGridPremium/index.js +2 -0
- package/DataGridPremium/package.json +6 -0
- package/DataGridPremium/useDataGridPremiumComponent.d.ts +4 -0
- package/DataGridPremium/useDataGridPremiumComponent.js +78 -0
- package/DataGridPremium/useDataGridPremiumProps.d.ts +6 -0
- package/DataGridPremium/useDataGridPremiumProps.js +37 -0
- package/LICENSE +12 -0
- package/README.md +31 -0
- package/components/GridExcelExportMenuItem.d.ts +9 -0
- package/components/GridExcelExportMenuItem.js +32 -0
- package/components/GridGroupingColumnLeafCell.d.ts +4 -0
- package/components/GridGroupingColumnLeafCell.js +22 -0
- package/components/GridGroupingCriteriaCell.d.ts +7 -0
- package/components/GridGroupingCriteriaCell.js +78 -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/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/package.json +6 -0
- package/hooks/features/export/gridExcelExportInterface.d.ts +58 -0
- package/hooks/features/export/gridExcelExportInterface.js +1 -0
- package/hooks/features/export/index.d.ts +1 -0
- package/hooks/features/export/index.js +1 -0
- package/hooks/features/export/serializer/excelSerializer.d.ts +14 -0
- package/hooks/features/export/serializer/excelSerializer.js +218 -0
- package/hooks/features/export/useGridExcelExport.d.ts +10 -0
- package/hooks/features/export/useGridExcelExport.js +77 -0
- package/hooks/features/index.d.ts +2 -0
- package/hooks/features/index.js +3 -0
- package/hooks/features/rowGrouping/createGroupingColDef.d.ts +42 -0
- package/hooks/features/rowGrouping/createGroupingColDef.js +318 -0
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +37 -0
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/hooks/features/rowGrouping/gridRowGroupingSelector.d.ts +4 -0
- package/hooks/features/rowGrouping/gridRowGroupingSelector.js +5 -0
- package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +27 -0
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +139 -0
- package/hooks/features/rowGrouping/index.d.ts +3 -0
- package/hooks/features/rowGrouping/index.js +3 -0
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +11 -0
- package/hooks/features/rowGrouping/useGridRowGrouping.js +200 -0
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +4 -0
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +201 -0
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +3 -0
- package/hooks/package.json +6 -0
- package/hooks/utils/index.d.ts +1 -0
- package/hooks/utils/index.js +1 -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/hooks/utils/useKeepGroupedColumnsHidden.d.ts +12 -0
- package/hooks/utils/useKeepGroupedColumnsHidden.js +50 -0
- package/index.d.ts +22 -0
- package/index.js +25 -0
- package/legacy/DataGridPremium/DataGridPremium.js +986 -0
- package/legacy/DataGridPremium/index.js +2 -0
- package/legacy/DataGridPremium/useDataGridPremiumComponent.js +78 -0
- package/legacy/DataGridPremium/useDataGridPremiumProps.js +46 -0
- package/legacy/components/GridExcelExportMenuItem.js +30 -0
- package/legacy/components/GridGroupingColumnLeafCell.js +20 -0
- package/legacy/components/GridGroupingCriteriaCell.js +74 -0
- package/legacy/components/GridRowGroupableColumnMenuItems.js +61 -0
- package/legacy/components/GridRowGroupingColumnMenuItems.js +56 -0
- package/legacy/components/index.js +1 -0
- package/legacy/hooks/features/export/gridExcelExportInterface.js +1 -0
- package/legacy/hooks/features/export/index.js +1 -0
- package/legacy/hooks/features/export/serializer/excelSerializer.js +260 -0
- package/legacy/hooks/features/export/useGridExcelExport.js +111 -0
- package/legacy/hooks/features/index.js +3 -0
- package/legacy/hooks/features/rowGrouping/createGroupingColDef.js +319 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingSelector.js +13 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +147 -0
- package/legacy/hooks/features/rowGrouping/index.js +3 -0
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +206 -0
- package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +215 -0
- package/legacy/hooks/index.js +3 -0
- package/legacy/hooks/utils/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/hooks/utils/useKeepGroupedColumnsHidden.js +50 -0
- package/legacy/index.js +25 -0
- package/legacy/models/dataGridPremiumProps.js +1 -0
- package/legacy/models/gridApiPremium.js +1 -0
- package/legacy/models/gridGroupingValueGetterParams.js +1 -0
- package/legacy/models/gridStatePremium.js +1 -0
- package/legacy/models/index.js +1 -0
- package/legacy/typeOverloads/index.js +1 -0
- package/legacy/typeOverloads/modules.js +33 -0
- package/legacy/typeOverloads/reexports.js +6 -0
- package/legacy/utils/releaseInfo.js +15 -0
- package/models/dataGridPremiumProps.d.ts +64 -0
- package/models/dataGridPremiumProps.js +1 -0
- package/models/gridApiPremium.d.ts +13 -0
- package/models/gridApiPremium.js +1 -0
- package/models/gridGroupingValueGetterParams.d.ts +31 -0
- package/models/gridGroupingValueGetterParams.js +1 -0
- package/models/gridStatePremium.d.ts +14 -0
- package/models/gridStatePremium.js +1 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/package.json +6 -0
- package/modern/DataGridPremium/DataGridPremium.js +986 -0
- package/modern/DataGridPremium/index.js +2 -0
- package/modern/DataGridPremium/useDataGridPremiumComponent.js +76 -0
- package/modern/DataGridPremium/useDataGridPremiumProps.js +37 -0
- package/modern/components/GridExcelExportMenuItem.js +32 -0
- package/modern/components/GridGroupingColumnLeafCell.js +20 -0
- package/modern/components/GridGroupingCriteriaCell.js +76 -0
- package/modern/components/GridRowGroupableColumnMenuItems.js +61 -0
- package/modern/components/GridRowGroupingColumnMenuItems.js +56 -0
- package/modern/components/index.js +1 -0
- package/modern/hooks/features/export/gridExcelExportInterface.js +1 -0
- package/modern/hooks/features/export/index.js +1 -0
- package/modern/hooks/features/export/serializer/excelSerializer.js +216 -0
- package/modern/hooks/features/export/useGridExcelExport.js +73 -0
- package/modern/hooks/features/index.js +3 -0
- package/modern/hooks/features/rowGrouping/createGroupingColDef.js +302 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingSelector.js +5 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +137 -0
- package/modern/hooks/features/rowGrouping/index.js +3 -0
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +192 -0
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +201 -0
- package/modern/hooks/index.js +3 -0
- package/modern/hooks/utils/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/hooks/utils/useKeepGroupedColumnsHidden.js +46 -0
- package/modern/index.js +25 -0
- package/modern/models/dataGridPremiumProps.js +1 -0
- package/modern/models/gridApiPremium.js +1 -0
- package/modern/models/gridGroupingValueGetterParams.js +1 -0
- package/modern/models/gridStatePremium.js +1 -0
- package/modern/models/index.js +1 -0
- package/modern/typeOverloads/index.js +1 -0
- package/modern/typeOverloads/modules.js +33 -0
- package/modern/typeOverloads/reexports.js +6 -0
- package/modern/utils/releaseInfo.js +15 -0
- package/node/DataGridPremium/DataGridPremium.js +1009 -0
- package/node/DataGridPremium/index.js +30 -0
- package/node/DataGridPremium/useDataGridPremiumComponent.js +91 -0
- package/node/DataGridPremium/useDataGridPremiumProps.js +57 -0
- package/node/components/GridExcelExportMenuItem.js +49 -0
- package/node/components/GridGroupingColumnLeafCell.js +38 -0
- package/node/components/GridGroupingCriteriaCell.js +99 -0
- package/node/components/GridRowGroupableColumnMenuItems.js +82 -0
- package/node/components/GridRowGroupingColumnMenuItems.js +78 -0
- package/node/components/index.js +18 -0
- package/node/hooks/features/export/gridExcelExportInterface.js +5 -0
- package/node/hooks/features/export/index.js +18 -0
- package/node/hooks/features/export/serializer/excelSerializer.js +233 -0
- package/node/hooks/features/export/useGridExcelExport.js +95 -0
- package/node/hooks/features/index.js +31 -0
- package/node/hooks/features/rowGrouping/createGroupingColDef.js +341 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +5 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingSelector.js +18 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +172 -0
- package/node/hooks/features/rowGrouping/index.js +51 -0
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +228 -0
- package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +223 -0
- package/node/hooks/index.js +31 -0
- package/node/hooks/utils/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/hooks/utils/useKeepGroupedColumnsHidden.js +66 -0
- package/node/index.js +272 -0
- package/node/models/dataGridPremiumProps.js +5 -0
- package/node/models/gridApiPremium.js +5 -0
- package/node/models/gridGroupingValueGetterParams.js +5 -0
- package/node/models/gridStatePremium.js +5 -0
- package/node/models/index.js +18 -0
- package/node/typeOverloads/index.js +3 -0
- package/node/typeOverloads/modules.js +34 -0
- package/node/typeOverloads/reexports.js +29 -0
- package/node/utils/releaseInfo.js +25 -0
- package/package.json +63 -0
- package/typeOverloads/index.d.ts +1 -0
- package/typeOverloads/index.js +1 -0
- package/typeOverloads/modules.d.ts +0 -0
- package/typeOverloads/modules.js +33 -0
- package/typeOverloads/package.json +6 -0
- package/typeOverloads/reexports.d.ts +22 -0
- package/typeOverloads/reexports.js +6 -0
- package/utils/releaseInfo.d.ts +1 -0
- package/utils/releaseInfo.js +15 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing_new, useGridEditing_old, editingStateInitializer_old, editingStateInitializer_new, useGridRows, useGridRowsPreProcessors, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridSelectionPreProcessors, columnMenuStateInitializer, densityStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, selectionStateInitializer, useGridColumnReorder, columnReorderStateInitializer, useGridColumnResize, columnResizeStateInitializer, useGridTreeData, useGridTreeDataPreProcessors, useGridColumnPinning, columnPinningStateInitializer, useGridColumnPinningPreProcessors, useGridDetailPanel, detailPanelStateInitializer, useGridDetailPanelCache, useGridDetailPanelPreProcessors, useGridInfiniteLoader, useGridColumnSpanning, useGridRowReorder, useGridRowReorderPreProcessors } from '@mui/x-data-grid-pro/internals';
|
|
2
|
+
// Premium-only features
|
|
3
|
+
import { useGridRowGrouping, rowGroupingStateInitializer } from '../hooks/features/rowGrouping/useGridRowGrouping';
|
|
4
|
+
import { useGridRowGroupingPreProcessors } from '../hooks/features/rowGrouping/useGridRowGroupingPreProcessors';
|
|
5
|
+
import { useGridExcelExport } from '../hooks/features/export/useGridExcelExport';
|
|
6
|
+
export var useDataGridPremiumComponent = function useDataGridPremiumComponent(inputApiRef, props) {
|
|
7
|
+
var _props$experimentalFe, _props$experimentalFe2;
|
|
8
|
+
|
|
9
|
+
var apiRef = useGridInitialization(inputApiRef, props);
|
|
10
|
+
/**
|
|
11
|
+
* Register all pre-processors called during state initialization here.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
useGridSelectionPreProcessors(apiRef, props);
|
|
15
|
+
useGridRowReorderPreProcessors(apiRef, props);
|
|
16
|
+
useGridRowGroupingPreProcessors(apiRef, props);
|
|
17
|
+
useGridTreeDataPreProcessors(apiRef, props);
|
|
18
|
+
useGridDetailPanelPreProcessors(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
|
|
19
|
+
// Because it changes the order of the columns.
|
|
20
|
+
|
|
21
|
+
useGridColumnPinningPreProcessors(apiRef, props);
|
|
22
|
+
useGridRowsPreProcessors(apiRef);
|
|
23
|
+
/**
|
|
24
|
+
* Register all state initializers here.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
useGridInitializeState(rowGroupingStateInitializer, apiRef, props);
|
|
28
|
+
useGridInitializeState(selectionStateInitializer, apiRef, props);
|
|
29
|
+
useGridInitializeState(detailPanelStateInitializer, apiRef, props);
|
|
30
|
+
useGridInitializeState(columnPinningStateInitializer, apiRef, props);
|
|
31
|
+
useGridInitializeState(columnsStateInitializer, apiRef, props);
|
|
32
|
+
useGridInitializeState(rowsStateInitializer, apiRef, props);
|
|
33
|
+
useGridInitializeState((_props$experimentalFe = props.experimentalFeatures) != null && _props$experimentalFe.newEditingApi ? editingStateInitializer_new : editingStateInitializer_old, apiRef, props);
|
|
34
|
+
useGridInitializeState(focusStateInitializer, apiRef, props);
|
|
35
|
+
useGridInitializeState(sortingStateInitializer, apiRef, props);
|
|
36
|
+
useGridInitializeState(preferencePanelStateInitializer, apiRef, props);
|
|
37
|
+
useGridInitializeState(filterStateInitializer, apiRef, props);
|
|
38
|
+
useGridInitializeState(densityStateInitializer, apiRef, props);
|
|
39
|
+
useGridInitializeState(columnReorderStateInitializer, apiRef, props);
|
|
40
|
+
useGridInitializeState(columnResizeStateInitializer, apiRef, props);
|
|
41
|
+
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
42
|
+
useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
|
|
43
|
+
useGridInitializeState(columnMenuStateInitializer, apiRef, props);
|
|
44
|
+
useGridRowGrouping(apiRef, props);
|
|
45
|
+
useGridTreeData(apiRef);
|
|
46
|
+
useGridKeyboardNavigation(apiRef, props);
|
|
47
|
+
useGridSelection(apiRef, props);
|
|
48
|
+
useGridDetailPanel(apiRef, props);
|
|
49
|
+
useGridColumnPinning(apiRef, props);
|
|
50
|
+
useGridColumns(apiRef, props);
|
|
51
|
+
useGridRows(apiRef, props);
|
|
52
|
+
useGridParamsApi(apiRef);
|
|
53
|
+
useGridColumnSpanning(apiRef);
|
|
54
|
+
useGridDetailPanelCache(apiRef, props);
|
|
55
|
+
var useGridEditing = (_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.newEditingApi ? useGridEditing_new : useGridEditing_old;
|
|
56
|
+
useGridEditing(apiRef, props);
|
|
57
|
+
useGridFocus(apiRef, props);
|
|
58
|
+
useGridPreferencesPanel(apiRef);
|
|
59
|
+
useGridFilter(apiRef, props);
|
|
60
|
+
useGridSorting(apiRef, props);
|
|
61
|
+
useGridDensity(apiRef, props);
|
|
62
|
+
useGridColumnReorder(apiRef, props);
|
|
63
|
+
useGridColumnResize(apiRef, props);
|
|
64
|
+
useGridPagination(apiRef, props);
|
|
65
|
+
useGridRowsMeta(apiRef, props);
|
|
66
|
+
useGridRowReorder(apiRef, props);
|
|
67
|
+
useGridScroll(apiRef, props);
|
|
68
|
+
useGridInfiniteLoader(apiRef, props);
|
|
69
|
+
useGridColumnMenu(apiRef);
|
|
70
|
+
useGridCsvExport(apiRef);
|
|
71
|
+
useGridPrintExport(apiRef, props);
|
|
72
|
+
useGridExcelExport(apiRef);
|
|
73
|
+
useGridClipboard(apiRef);
|
|
74
|
+
useGridDimensions(apiRef, props);
|
|
75
|
+
useGridEvents(apiRef, props);
|
|
76
|
+
useGridStatePersistence(apiRef);
|
|
77
|
+
return apiRef;
|
|
78
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useThemeProps } from '@mui/material/styles';
|
|
5
|
+
import { DATA_GRID_PRO_PROPS_DEFAULT_VALUES, DATA_GRID_DEFAULT_SLOTS_COMPONENTS, GRID_DEFAULT_LOCALE_TEXT } from '@mui/x-data-grid-pro';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The default values of `DataGridPremiumPropsWithDefaultValue` to inject in the props of DataGridPremium.
|
|
9
|
+
*/
|
|
10
|
+
export var DATA_GRID_PREMIUM_PROPS_DEFAULT_VALUES = _extends({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, {
|
|
11
|
+
disableRowGrouping: false,
|
|
12
|
+
rowGroupingColumnMode: 'single'
|
|
13
|
+
});
|
|
14
|
+
export var useDataGridPremiumProps = function useDataGridPremiumProps(inProps) {
|
|
15
|
+
var themedProps = useThemeProps({
|
|
16
|
+
props: inProps,
|
|
17
|
+
name: 'MuiDataGrid'
|
|
18
|
+
});
|
|
19
|
+
var localeText = React.useMemo(function () {
|
|
20
|
+
return _extends({}, GRID_DEFAULT_LOCALE_TEXT, themedProps.localeText);
|
|
21
|
+
}, [themedProps.localeText]);
|
|
22
|
+
var components = React.useMemo(function () {
|
|
23
|
+
var overrides = themedProps.components;
|
|
24
|
+
|
|
25
|
+
if (!overrides) {
|
|
26
|
+
return _extends({}, DATA_GRID_DEFAULT_SLOTS_COMPONENTS);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var mergedComponents = {};
|
|
30
|
+
Object.entries(DATA_GRID_DEFAULT_SLOTS_COMPONENTS).forEach(function (_ref) {
|
|
31
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
32
|
+
key = _ref2[0],
|
|
33
|
+
defaultComponent = _ref2[1];
|
|
34
|
+
|
|
35
|
+
mergedComponents[key] = overrides[key] === undefined ? defaultComponent : overrides[key];
|
|
36
|
+
});
|
|
37
|
+
return mergedComponents;
|
|
38
|
+
}, [themedProps.components]);
|
|
39
|
+
return React.useMemo(function () {
|
|
40
|
+
return _extends({}, DATA_GRID_PREMIUM_PROPS_DEFAULT_VALUES, themedProps, {
|
|
41
|
+
localeText: localeText,
|
|
42
|
+
components: components,
|
|
43
|
+
signature: 'DataGridPremium'
|
|
44
|
+
});
|
|
45
|
+
}, [themedProps, localeText, components]);
|
|
46
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
4
|
+
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
var GridExcelExportMenuItem = function GridExcelExportMenuItem(props) {
|
|
8
|
+
var apiRef = useGridApiContext();
|
|
9
|
+
var hideMenu = props.hideMenu,
|
|
10
|
+
options = props.options;
|
|
11
|
+
return /*#__PURE__*/_jsx(MenuItem, {
|
|
12
|
+
onClick: function onClick() {
|
|
13
|
+
apiRef.current.exportDataAsExcel(options);
|
|
14
|
+
hideMenu == null ? void 0 : hideMenu();
|
|
15
|
+
},
|
|
16
|
+
children: apiRef.current.getLocaleText('toolbarExportExcel')
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
process.env.NODE_ENV !== "production" ? GridExcelExportMenuItem.propTypes = {
|
|
21
|
+
// ----------------------------- Warning --------------------------------
|
|
22
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
23
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
24
|
+
// ----------------------------------------------------------------------
|
|
25
|
+
hideMenu: PropTypes.func,
|
|
26
|
+
options: PropTypes.shape({
|
|
27
|
+
disableToolbarButton: PropTypes.bool
|
|
28
|
+
})
|
|
29
|
+
} : void 0;
|
|
30
|
+
export { GridExcelExportMenuItem };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
var GridGroupingColumnLeafCell = function GridGroupingColumnLeafCell(props) {
|
|
7
|
+
var _props$formattedValue;
|
|
8
|
+
|
|
9
|
+
var rowNode = props.rowNode;
|
|
10
|
+
var rootProps = useGridRootProps();
|
|
11
|
+
var marginLeft = rootProps.rowGroupingColumnMode === 'multiple' ? 1 : rowNode.depth * 2;
|
|
12
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
13
|
+
sx: {
|
|
14
|
+
ml: marginLeft
|
|
15
|
+
},
|
|
16
|
+
children: (_props$formattedValue = props.formattedValue) != null ? _props$formattedValue : props.value
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { GridGroupingColumnLeafCell };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
3
|
+
import IconButton from '@mui/material/IconButton';
|
|
4
|
+
import Box from '@mui/material/Box';
|
|
5
|
+
import { useGridSelector, gridFilteredDescendantCountLookupSelector, getDataGridUtilityClass } from '@mui/x-data-grid-pro';
|
|
6
|
+
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
7
|
+
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
12
|
+
var classes = ownerState.classes;
|
|
13
|
+
var slots = {
|
|
14
|
+
root: ['groupingCriteriaCell'],
|
|
15
|
+
toggle: ['groupingCriteriaCellToggle']
|
|
16
|
+
};
|
|
17
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export var GridGroupingCriteriaCell = function GridGroupingCriteriaCell(props) {
|
|
21
|
+
var _filteredDescendantCo;
|
|
22
|
+
|
|
23
|
+
var id = props.id,
|
|
24
|
+
field = props.field,
|
|
25
|
+
rowNode = props.rowNode,
|
|
26
|
+
hideDescendantCount = props.hideDescendantCount,
|
|
27
|
+
formattedValue = props.formattedValue;
|
|
28
|
+
var rootProps = useGridRootProps();
|
|
29
|
+
var apiRef = useGridApiContext();
|
|
30
|
+
var ownerState = {
|
|
31
|
+
classes: rootProps.classes
|
|
32
|
+
};
|
|
33
|
+
var classes = useUtilityClasses(ownerState);
|
|
34
|
+
var filteredDescendantCountLookup = useGridSelector(apiRef, gridFilteredDescendantCountLookupSelector);
|
|
35
|
+
var filteredDescendantCount = (_filteredDescendantCo = filteredDescendantCountLookup[rowNode.id]) != null ? _filteredDescendantCo : 0;
|
|
36
|
+
var Icon = rowNode.childrenExpanded ? rootProps.components.GroupingCriteriaCollapseIcon : rootProps.components.GroupingCriteriaExpandIcon;
|
|
37
|
+
|
|
38
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
39
|
+
if (event.key === ' ') {
|
|
40
|
+
event.stopPropagation();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
apiRef.current.publishEvent('cellKeyDown', props, event);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var handleClick = function handleClick(event) {
|
|
47
|
+
apiRef.current.setRowChildrenExpansion(id, !rowNode.childrenExpanded);
|
|
48
|
+
apiRef.current.setCellFocus(id, field);
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var marginLeft = rootProps.rowGroupingColumnMode === 'multiple' ? 0 : rowNode.depth * 2;
|
|
53
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
54
|
+
className: classes.root,
|
|
55
|
+
sx: {
|
|
56
|
+
ml: marginLeft
|
|
57
|
+
},
|
|
58
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
59
|
+
className: classes.toggle,
|
|
60
|
+
children: filteredDescendantCount > 0 && /*#__PURE__*/_jsx(IconButton, {
|
|
61
|
+
size: "small",
|
|
62
|
+
onClick: handleClick,
|
|
63
|
+
onKeyDown: handleKeyDown,
|
|
64
|
+
tabIndex: -1,
|
|
65
|
+
"aria-label": rowNode.childrenExpanded ? apiRef.current.getLocaleText('treeDataCollapse') : apiRef.current.getLocaleText('treeDataExpand'),
|
|
66
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
67
|
+
fontSize: "inherit"
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
71
|
+
children: [formattedValue === undefined ? rowNode.groupingKey : formattedValue, !hideDescendantCount && filteredDescendantCount > 0 ? " (".concat(filteredDescendantCount, ")") : '']
|
|
72
|
+
})]
|
|
73
|
+
});
|
|
74
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
4
|
+
import { gridColumnLookupSelector, useGridSelector } from '@mui/x-data-grid-pro';
|
|
5
|
+
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
6
|
+
import { gridRowGroupingSanitizedModelSelector } from '../hooks/features/rowGrouping/gridRowGroupingSelector';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
var GridRowGroupableColumnMenuItems = function GridRowGroupableColumnMenuItems(props) {
|
|
10
|
+
var _columnsLookup$column;
|
|
11
|
+
|
|
12
|
+
var column = props.column,
|
|
13
|
+
onClick = props.onClick;
|
|
14
|
+
var apiRef = useGridApiContext();
|
|
15
|
+
var rowGroupingModel = useGridSelector(apiRef, gridRowGroupingSanitizedModelSelector);
|
|
16
|
+
var columnsLookup = useGridSelector(apiRef, gridColumnLookupSelector);
|
|
17
|
+
|
|
18
|
+
if (!(column != null && column.groupable)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var ungroupColumn = function ungroupColumn(event) {
|
|
23
|
+
apiRef.current.removeRowGroupingCriteria(column.field);
|
|
24
|
+
|
|
25
|
+
if (onClick) {
|
|
26
|
+
onClick(event);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var groupColumn = function groupColumn(event) {
|
|
31
|
+
apiRef.current.addRowGroupingCriteria(column.field);
|
|
32
|
+
|
|
33
|
+
if (onClick) {
|
|
34
|
+
onClick(event);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var name = (_columnsLookup$column = columnsLookup[column.field].headerName) != null ? _columnsLookup$column : column.field;
|
|
39
|
+
|
|
40
|
+
if (rowGroupingModel.includes(column.field)) {
|
|
41
|
+
return /*#__PURE__*/_jsx(MenuItem, {
|
|
42
|
+
onClick: ungroupColumn,
|
|
43
|
+
children: apiRef.current.getLocaleText('unGroupColumn')(name)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/_jsx(MenuItem, {
|
|
48
|
+
onClick: groupColumn,
|
|
49
|
+
children: apiRef.current.getLocaleText('groupColumn')(name)
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
process.env.NODE_ENV !== "production" ? GridRowGroupableColumnMenuItems.propTypes = {
|
|
54
|
+
// ----------------------------- Warning --------------------------------
|
|
55
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
56
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
57
|
+
// ----------------------------------------------------------------------
|
|
58
|
+
column: PropTypes.object,
|
|
59
|
+
onClick: PropTypes.func
|
|
60
|
+
} : void 0;
|
|
61
|
+
export { GridRowGroupableColumnMenuItems };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
4
|
+
import { useGridSelector, gridColumnLookupSelector } from '@mui/x-data-grid-pro';
|
|
5
|
+
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
6
|
+
import { gridRowGroupingSanitizedModelSelector } from '../hooks/features/rowGrouping/gridRowGroupingSelector';
|
|
7
|
+
import { getRowGroupingCriteriaFromGroupingField, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, isGroupingColumn } from '../hooks/features/rowGrouping/gridRowGroupingUtils';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
var GridRowGroupingColumnMenuItems = function GridRowGroupingColumnMenuItems(props) {
|
|
11
|
+
var column = props.column,
|
|
12
|
+
onClick = props.onClick;
|
|
13
|
+
var apiRef = useGridApiContext();
|
|
14
|
+
var rowGroupingModel = useGridSelector(apiRef, gridRowGroupingSanitizedModelSelector);
|
|
15
|
+
var columnsLookup = useGridSelector(apiRef, gridColumnLookupSelector);
|
|
16
|
+
|
|
17
|
+
var renderUnGroupingMenuItem = function renderUnGroupingMenuItem(field) {
|
|
18
|
+
var _columnsLookup$field$;
|
|
19
|
+
|
|
20
|
+
var ungroupColumn = function ungroupColumn(event) {
|
|
21
|
+
apiRef.current.removeRowGroupingCriteria(field);
|
|
22
|
+
|
|
23
|
+
if (onClick) {
|
|
24
|
+
onClick(event);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var name = (_columnsLookup$field$ = columnsLookup[field].headerName) != null ? _columnsLookup$field$ : field;
|
|
29
|
+
return /*#__PURE__*/_jsx(MenuItem, {
|
|
30
|
+
onClick: ungroupColumn,
|
|
31
|
+
children: apiRef.current.getLocaleText('unGroupColumn')(name)
|
|
32
|
+
}, field);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
if (!column || !isGroupingColumn(column.field)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (column.field === GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD) {
|
|
40
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
41
|
+
children: rowGroupingModel.map(renderUnGroupingMenuItem)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return renderUnGroupingMenuItem(getRowGroupingCriteriaFromGroupingField(column.field));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
process.env.NODE_ENV !== "production" ? GridRowGroupingColumnMenuItems.propTypes = {
|
|
49
|
+
// ----------------------------- Warning --------------------------------
|
|
50
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
51
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
52
|
+
// ----------------------------------------------------------------------
|
|
53
|
+
column: PropTypes.object,
|
|
54
|
+
onClick: PropTypes.func
|
|
55
|
+
} : void 0;
|
|
56
|
+
export { GridRowGroupingColumnMenuItems };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GridExcelExportMenuItem';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridExcelExportInterface';
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
6
|
+
|
|
7
|
+
var _defaultColumnsStyles;
|
|
8
|
+
|
|
9
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
+
import { GRID_DATE_COL_DEF, GRID_DATETIME_COL_DEF } from '@mui/x-data-grid-pro';
|
|
11
|
+
import { buildWarning } from '@mui/x-data-grid/internals';
|
|
12
|
+
|
|
13
|
+
var getExcelJs = function getExcelJs() {
|
|
14
|
+
return import('exceljs');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var warnInvalidFormattedValue = buildWarning(['MUI: 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.']);
|
|
18
|
+
|
|
19
|
+
var getFormattedValueOptions = function getFormattedValueOptions(colDef, valueOptions, api) {
|
|
20
|
+
if (!colDef.valueOptions) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var valueOptionsFormatted = valueOptions;
|
|
25
|
+
|
|
26
|
+
if (colDef.valueFormatter) {
|
|
27
|
+
valueOptionsFormatted = valueOptionsFormatted.map(function (option) {
|
|
28
|
+
if (_typeof(option) === 'object') {
|
|
29
|
+
return option;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var params = {
|
|
33
|
+
field: colDef.field,
|
|
34
|
+
api: api,
|
|
35
|
+
value: option
|
|
36
|
+
};
|
|
37
|
+
return String(colDef.valueFormatter(params));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return valueOptionsFormatted.map(function (option) {
|
|
42
|
+
return _typeof(option) === 'object' ? option.label : option;
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var serializeRow = function serializeRow(id, columns, api, defaultValueOptionsFormulae) {
|
|
47
|
+
var row = {};
|
|
48
|
+
var dataValidation = {};
|
|
49
|
+
var firstCellParams = api.getCellParams(id, columns[0].field);
|
|
50
|
+
var outlineLevel = firstCellParams.rowNode.depth;
|
|
51
|
+
columns.forEach(function (column) {
|
|
52
|
+
var cellParams = api.getCellParams(id, column.field);
|
|
53
|
+
|
|
54
|
+
switch (cellParams.colDef.type) {
|
|
55
|
+
case 'singleSelect':
|
|
56
|
+
{
|
|
57
|
+
var _formattedValue$label;
|
|
58
|
+
|
|
59
|
+
if (typeof cellParams.colDef.valueOptions === 'function') {
|
|
60
|
+
// If value option depends on the row, set specific options to the cell
|
|
61
|
+
// This dataValidation is buggy with LibreOffice and does not allow to have coma
|
|
62
|
+
var valueOptions = cellParams.colDef.valueOptions({
|
|
63
|
+
id: id,
|
|
64
|
+
row: row,
|
|
65
|
+
field: cellParams.field
|
|
66
|
+
});
|
|
67
|
+
var formattedValueOptions = getFormattedValueOptions(cellParams.colDef, valueOptions, api);
|
|
68
|
+
dataValidation[column.field] = {
|
|
69
|
+
type: 'list',
|
|
70
|
+
allowBlank: true,
|
|
71
|
+
formulae: ["\"".concat(formattedValueOptions.map(function (x) {
|
|
72
|
+
return x.toString().replaceAll(',', 'CHAR(44)');
|
|
73
|
+
}).join(','), "\"")]
|
|
74
|
+
};
|
|
75
|
+
} else {
|
|
76
|
+
// If value option is defined for the column, refer to another sheet
|
|
77
|
+
dataValidation[column.field] = {
|
|
78
|
+
type: 'list',
|
|
79
|
+
allowBlank: true,
|
|
80
|
+
formulae: [defaultValueOptionsFormulae[column.field]]
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var formattedValue = api.getCellParams(id, column.field).formattedValue;
|
|
85
|
+
|
|
86
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
87
|
+
if (String(cellParams.formattedValue) === '[object Object]') {
|
|
88
|
+
warnInvalidFormattedValue();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
row[column.field] = (_formattedValue$label = formattedValue == null ? void 0 : formattedValue.label) != null ? _formattedValue$label : formattedValue;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
case 'boolean':
|
|
97
|
+
case 'number':
|
|
98
|
+
row[column.field] = api.getCellParams(id, column.field).value;
|
|
99
|
+
break;
|
|
100
|
+
|
|
101
|
+
case 'date':
|
|
102
|
+
case 'dateTime':
|
|
103
|
+
{
|
|
104
|
+
// Excel does not do any timezone conversion, so we create a date using UTC instead of local timezone
|
|
105
|
+
// Solution from: https://github.com/exceljs/exceljs/issues/486#issuecomment-432557582
|
|
106
|
+
// About Date.UTC(): https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC#exemples
|
|
107
|
+
var date = api.getCellParams(id, column.field).value; // value may be `undefined` in auto-generated grouping rows
|
|
108
|
+
|
|
109
|
+
if (!date) {
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
|
|
114
|
+
row[column.field] = utcDate;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
case 'actions':
|
|
119
|
+
break;
|
|
120
|
+
|
|
121
|
+
default:
|
|
122
|
+
row[column.field] = api.getCellParams(id, column.field).formattedValue;
|
|
123
|
+
|
|
124
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
125
|
+
if (String(cellParams.formattedValue) === '[object Object]') {
|
|
126
|
+
warnInvalidFormattedValue();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
row: row,
|
|
135
|
+
dataValidation: dataValidation,
|
|
136
|
+
outlineLevel: outlineLevel
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
var defaultColumnsStyles = (_defaultColumnsStyles = {}, _defineProperty(_defaultColumnsStyles, GRID_DATE_COL_DEF.type, {
|
|
141
|
+
numFmt: 'dd.mm.yyyy'
|
|
142
|
+
}), _defineProperty(_defaultColumnsStyles, GRID_DATETIME_COL_DEF.type, {
|
|
143
|
+
numFmt: 'dd.mm.yyyy hh:mm'
|
|
144
|
+
}), _defaultColumnsStyles);
|
|
145
|
+
|
|
146
|
+
var serializeColumn = function serializeColumn(column, columnsStyles) {
|
|
147
|
+
var field = column.field,
|
|
148
|
+
type = column.type;
|
|
149
|
+
return {
|
|
150
|
+
key: field,
|
|
151
|
+
// Excel width must stay between 0 and 255 (https://support.microsoft.com/en-us/office/change-the-column-width-and-row-height-72f5e3cc-994d-43e8-ae58-9774a0905f46)
|
|
152
|
+
// From the example of column width behavior (https://docs.microsoft.com/en-US/office/troubleshoot/excel/determine-column-widths#example-of-column-width-behavior)
|
|
153
|
+
// a value of 10 corresponds to 75px. This is an approximation, because column width depends on the the font-size
|
|
154
|
+
width: Math.min(255, column.width ? column.width / 7.5 : 8.43),
|
|
155
|
+
style: _extends({}, type && (defaultColumnsStyles == null ? void 0 : defaultColumnsStyles[type]), columnsStyles == null ? void 0 : columnsStyles[field])
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export function buildExcel(_x, _x2) {
|
|
160
|
+
return _buildExcel.apply(this, arguments);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function _buildExcel() {
|
|
164
|
+
_buildExcel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options, api) {
|
|
165
|
+
var columns, rowIds, includeHeaders, valueOptionsSheetName, exceljsPreProcess, exceljsPostProcess, _options$columnsStyle, columnsStyles, excelJS, workbook, worksheet, columnsWithArrayValueOptions, defaultValueOptionsFormulae, valueOptionsWorksheet;
|
|
166
|
+
|
|
167
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
168
|
+
while (1) {
|
|
169
|
+
switch (_context.prev = _context.next) {
|
|
170
|
+
case 0:
|
|
171
|
+
columns = options.columns, rowIds = options.rowIds, includeHeaders = options.includeHeaders, valueOptionsSheetName = options.valueOptionsSheetName, exceljsPreProcess = options.exceljsPreProcess, exceljsPostProcess = options.exceljsPostProcess, _options$columnsStyle = options.columnsStyles, columnsStyles = _options$columnsStyle === void 0 ? {} : _options$columnsStyle;
|
|
172
|
+
_context.next = 3;
|
|
173
|
+
return getExcelJs();
|
|
174
|
+
|
|
175
|
+
case 3:
|
|
176
|
+
excelJS = _context.sent;
|
|
177
|
+
workbook = new excelJS.Workbook();
|
|
178
|
+
worksheet = workbook.addWorksheet('Sheet1');
|
|
179
|
+
worksheet.columns = columns.map(function (column) {
|
|
180
|
+
return serializeColumn(column, columnsStyles);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
if (!exceljsPreProcess) {
|
|
184
|
+
_context.next = 10;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
_context.next = 10;
|
|
189
|
+
return exceljsPreProcess({
|
|
190
|
+
workbook: workbook,
|
|
191
|
+
worksheet: worksheet
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
case 10:
|
|
195
|
+
if (includeHeaders) {
|
|
196
|
+
worksheet.addRow(columns.map(function (column) {
|
|
197
|
+
return column.headerName || column.field;
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
columnsWithArrayValueOptions = columns.filter(function (column) {
|
|
202
|
+
return column.type === 'singleSelect' && column.valueOptions && typeof column.valueOptions !== 'function';
|
|
203
|
+
});
|
|
204
|
+
defaultValueOptionsFormulae = {};
|
|
205
|
+
|
|
206
|
+
if (columnsWithArrayValueOptions.length) {
|
|
207
|
+
valueOptionsWorksheet = workbook.addWorksheet(valueOptionsSheetName);
|
|
208
|
+
valueOptionsWorksheet.columns = columnsWithArrayValueOptions.map(function (_ref) {
|
|
209
|
+
var field = _ref.field;
|
|
210
|
+
return {
|
|
211
|
+
key: field
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
columnsWithArrayValueOptions.forEach(function (column) {
|
|
215
|
+
var formattedValueOptions = getFormattedValueOptions(column, column.valueOptions, api);
|
|
216
|
+
valueOptionsWorksheet.getColumn(column.field).values = [column.headerName || column.field].concat(_toConsumableArray(formattedValueOptions));
|
|
217
|
+
var columnLetter = valueOptionsWorksheet.getColumn(column.field).letter;
|
|
218
|
+
defaultValueOptionsFormulae[column.field] = "".concat(valueOptionsSheetName, "!$").concat(columnLetter, "$2:$").concat(columnLetter, "$").concat(1 + formattedValueOptions.length);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
rowIds.forEach(function (id) {
|
|
223
|
+
var _serializeRow = serializeRow(id, columns, api, defaultValueOptionsFormulae),
|
|
224
|
+
row = _serializeRow.row,
|
|
225
|
+
dataValidation = _serializeRow.dataValidation,
|
|
226
|
+
outlineLevel = _serializeRow.outlineLevel;
|
|
227
|
+
|
|
228
|
+
var newRow = worksheet.addRow(row);
|
|
229
|
+
Object.keys(dataValidation).forEach(function (field) {
|
|
230
|
+
newRow.getCell(field).dataValidation = _extends({}, dataValidation[field]);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
if (outlineLevel) {
|
|
234
|
+
newRow.outlineLevel = outlineLevel;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
if (!exceljsPostProcess) {
|
|
239
|
+
_context.next = 18;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
_context.next = 18;
|
|
244
|
+
return exceljsPostProcess({
|
|
245
|
+
workbook: workbook,
|
|
246
|
+
worksheet: worksheet
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
case 18:
|
|
250
|
+
return _context.abrupt("return", workbook);
|
|
251
|
+
|
|
252
|
+
case 19:
|
|
253
|
+
case "end":
|
|
254
|
+
return _context.stop();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}, _callee);
|
|
258
|
+
}));
|
|
259
|
+
return _buildExcel.apply(this, arguments);
|
|
260
|
+
}
|