@redsift/dashboard 11.5.0 → 11.6.0-muiv5-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/_virtual/_rollupPluginBabelHelpers.js +93 -0
  2. package/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  3. package/components/ChartEmptyState/ChartEmptyState.d.ts +6 -0
  4. package/components/ChartEmptyState/ChartEmptyState.js +123 -0
  5. package/components/ChartEmptyState/ChartEmptyState.js.map +1 -0
  6. package/components/ChartEmptyState/styles.js +35 -0
  7. package/components/ChartEmptyState/styles.js.map +1 -0
  8. package/components/ChartEmptyState/types.d.ts +17 -0
  9. package/components/CrossfilterRegistry/CrossfilterRegistry.js +23 -0
  10. package/components/CrossfilterRegistry/CrossfilterRegistry.js.map +1 -0
  11. package/components/Dashboard/Dashboard.d.ts +6 -0
  12. package/components/Dashboard/Dashboard.js +46 -0
  13. package/components/Dashboard/Dashboard.js.map +1 -0
  14. package/components/Dashboard/context.d.ts +7 -0
  15. package/components/Dashboard/context.js +11 -0
  16. package/components/Dashboard/context.js.map +1 -0
  17. package/components/Dashboard/reducer.d.ts +5 -0
  18. package/components/Dashboard/reducer.js +61 -0
  19. package/components/Dashboard/reducer.js.map +1 -0
  20. package/components/Dashboard/types.d.ts +44 -0
  21. package/components/Dashboard/types.js +23 -0
  22. package/components/Dashboard/types.js.map +1 -0
  23. package/components/PdfExportButton/PdfDocument.js +173 -0
  24. package/components/PdfExportButton/PdfDocument.js.map +1 -0
  25. package/components/PdfExportButton/PdfExportButton.d.ts +6 -0
  26. package/components/PdfExportButton/PdfExportButton.js +110 -0
  27. package/components/PdfExportButton/PdfExportButton.js.map +1 -0
  28. package/components/PdfExportButton/styles.js +146 -0
  29. package/components/PdfExportButton/styles.js.map +1 -0
  30. package/components/PdfExportButton/types.d.ts +24 -0
  31. package/components/TimeSeriesBarChart/TimeSeriesBarChart.d.ts +6 -0
  32. package/components/TimeSeriesBarChart/TimeSeriesBarChart.js +365 -0
  33. package/components/TimeSeriesBarChart/TimeSeriesBarChart.js.map +1 -0
  34. package/components/TimeSeriesBarChart/styles.js +98 -0
  35. package/components/TimeSeriesBarChart/styles.js.map +1 -0
  36. package/components/TimeSeriesBarChart/types.d.ts +84 -0
  37. package/components/TimeSeriesBarChart/types.js +22 -0
  38. package/components/TimeSeriesBarChart/types.js.map +1 -0
  39. package/components/WithFilters/FilterableBarChart.js +152 -0
  40. package/components/WithFilters/FilterableBarChart.js.map +1 -0
  41. package/components/WithFilters/FilterableDataGrid.js +51 -0
  42. package/components/WithFilters/FilterableDataGrid.js.map +1 -0
  43. package/components/WithFilters/FilterablePieChart.js +160 -0
  44. package/components/WithFilters/FilterablePieChart.js.map +1 -0
  45. package/components/WithFilters/FilterableScatterPlot.js +252 -0
  46. package/components/WithFilters/FilterableScatterPlot.js.map +1 -0
  47. package/components/WithFilters/WithFilters.d.ts +6 -0
  48. package/components/WithFilters/WithFilters.js +36 -0
  49. package/components/WithFilters/WithFilters.js.map +1 -0
  50. package/components/WithFilters/types.d.ts +40 -0
  51. package/hooks/useCategoricalChartAsListbox.js +94 -0
  52. package/hooks/useCategoricalChartAsListbox.js.map +1 -0
  53. package/index.d.ts +14 -227
  54. package/index.js +11 -1956
  55. package/index.js.map +1 -1
  56. package/package.json +8 -8
  57. package/types.d.ts +16 -0
  58. package/utils/groupReducers/groupReduceCount.d.ts +6 -0
  59. package/utils/groupReducers/groupReduceCount.js +5 -0
  60. package/utils/groupReducers/groupReduceCount.js.map +1 -0
  61. package/utils/groupReducers/groupReduceSum.d.ts +7 -0
  62. package/utils/groupReducers/groupReduceSum.js +5 -0
  63. package/utils/groupReducers/groupReduceSum.js.map +1 -0
@@ -0,0 +1,173 @@
1
+ import React from 'react';
2
+ import { Document, Page, View, Image, Text } from '@react-pdf/renderer';
3
+ import { getPdfStyles } from './styles.js';
4
+
5
+ // istanbul ignore file
6
+ const DEFAULT_COLUMN_WIDTH = 100;
7
+ const getWidthColumn = (width, totalW, nrColumns) => {
8
+ // calculation width column where the 7px margin between the columns is included
9
+ return `${Math.round(width * 100 / (totalW - 7 * (nrColumns - 1)))}%`;
10
+ };
11
+ const PdfTableRow = _ref => {
12
+ let {
13
+ rowIndex,
14
+ rowData,
15
+ columns,
16
+ styles,
17
+ totalWidth
18
+ } = _ref;
19
+ return /*#__PURE__*/React.createElement(View, {
20
+ style: styles.tableRowContainer,
21
+ key: `row-${rowIndex}`
22
+ }, columns.map((column, index) => {
23
+ const {
24
+ field,
25
+ width
26
+ } = column;
27
+ let totalW = totalWidth;
28
+ let nrColumns = columns.length;
29
+
30
+ // The checkbox in the table will not be printed
31
+ if (field === '__check__') {
32
+ totalW = totalW - (width || 50);
33
+ nrColumns = nrColumns - 1;
34
+ return;
35
+ }
36
+ const widthColumn = getWidthColumn(width || DEFAULT_COLUMN_WIDTH, totalW, nrColumns);
37
+
38
+ // Empty value will print '-'
39
+ if (!rowData[field]) {
40
+ return /*#__PURE__*/React.createElement(View, {
41
+ style: {
42
+ width: widthColumn,
43
+ paddingVertical: 2,
44
+ marginRight: 7
45
+ },
46
+ key: `cell-${rowIndex}-${index}`
47
+ }, /*#__PURE__*/React.createElement(Text, {
48
+ style: styles.tableCellText
49
+ }, '-'));
50
+ }
51
+ return /*#__PURE__*/React.createElement(View, {
52
+ style: {
53
+ width: widthColumn,
54
+ paddingVertical: 2,
55
+ marginRight: 7
56
+ },
57
+ key: `cell-${rowIndex}-${index}`
58
+ }, /*#__PURE__*/React.createElement(Text, {
59
+ style: styles.tableCellText
60
+ }, Array.isArray(rowData[field]) ? rowData[field].join(', ') : rowData[field]));
61
+ }));
62
+ };
63
+ const PdfTable = _ref2 => {
64
+ let {
65
+ dataTable,
66
+ styles,
67
+ localeText
68
+ } = _ref2;
69
+ const {
70
+ data,
71
+ columns,
72
+ totalWidth
73
+ } = dataTable;
74
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
75
+ style: styles.tableHeaderContainer
76
+ }, columns.map(column => {
77
+ let totalW = totalWidth;
78
+ let nrColumns = columns.length;
79
+ const {
80
+ field,
81
+ headerName,
82
+ width
83
+ } = column;
84
+
85
+ // The checkbox in the table will not be printed
86
+ if (field === '__check__') {
87
+ totalW = totalW - (width || 50);
88
+ nrColumns = nrColumns - 1;
89
+ return;
90
+ }
91
+ const widthColumn = getWidthColumn(width || DEFAULT_COLUMN_WIDTH, totalW, nrColumns);
92
+ return /*#__PURE__*/React.createElement(View, {
93
+ style: {
94
+ width: widthColumn,
95
+ paddingVertical: 2,
96
+ marginRight: 7
97
+ },
98
+ key: `heading-${field}`
99
+ }, /*#__PURE__*/React.createElement(Text, {
100
+ style: styles.tableCellHeaderText
101
+ }, headerName));
102
+ })), /*#__PURE__*/React.createElement(View, null, data.map((row, index) => {
103
+ if (index < 1000) {
104
+ return /*#__PURE__*/React.createElement(PdfTableRow, {
105
+ key: index,
106
+ rowIndex: index,
107
+ rowData: data[index],
108
+ columns: columns,
109
+ styles: styles,
110
+ totalWidth: totalWidth
111
+ });
112
+ }
113
+ })), data.length >= 1000 ? /*#__PURE__*/React.createElement(View, {
114
+ style: styles.constraintsContainer
115
+ }, /*#__PURE__*/React.createElement(Text, {
116
+ style: styles.constraints
117
+ }, (localeText === null || localeText === void 0 ? void 0 : localeText.maxSizeDisclaimer) || 'Due to processing constraints this pdf is limited to the first 1000 rows of data.')) : null);
118
+ };
119
+ const Pagination = _ref3 => {
120
+ let {
121
+ styles
122
+ } = _ref3;
123
+ return /*#__PURE__*/React.createElement(Text, {
124
+ style: styles.pageNumber,
125
+ render: _ref4 => {
126
+ let {
127
+ pageNumber,
128
+ totalPages
129
+ } = _ref4;
130
+ return `${pageNumber}/${totalPages}`;
131
+ },
132
+ fixed: true
133
+ });
134
+ };
135
+ const PdfDocument = _ref5 => {
136
+ let {
137
+ dashboardImage,
138
+ introduction,
139
+ localeText,
140
+ logo,
141
+ dataTable,
142
+ primaryColor
143
+ } = _ref5;
144
+ const styles = getPdfStyles(primaryColor);
145
+ return /*#__PURE__*/React.createElement(Document, null, /*#__PURE__*/React.createElement(Page, {
146
+ size: "A4",
147
+ style: styles.page
148
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, logo ? /*#__PURE__*/React.createElement(View, {
149
+ style: styles.logoContainer
150
+ }, /*#__PURE__*/React.createElement(Image, {
151
+ src: logo,
152
+ style: styles.logo
153
+ })) : null, introduction ? /*#__PURE__*/React.createElement(View, {
154
+ style: styles.introductionContainer
155
+ }, /*#__PURE__*/React.createElement(Text, {
156
+ style: styles.introductionText
157
+ }, introduction)) : null, dashboardImage ? /*#__PURE__*/React.createElement(View, {
158
+ style: styles.dashboardImageContainer
159
+ }, /*#__PURE__*/React.createElement(Image, {
160
+ src: dashboardImage
161
+ })) : null, dataTable ? /*#__PURE__*/React.createElement(View, {
162
+ style: styles.tableContainer
163
+ }, /*#__PURE__*/React.createElement(PdfTable, {
164
+ dataTable: dataTable,
165
+ styles: styles,
166
+ localeText: localeText
167
+ })) : null, /*#__PURE__*/React.createElement(Pagination, {
168
+ styles: styles
169
+ }))));
170
+ };
171
+
172
+ export { PdfDocument };
173
+ //# sourceMappingURL=PdfDocument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdfDocument.js","sources":["../../../src/components/PdfExportButton/PdfDocument.tsx"],"sourcesContent":["// istanbul ignore file\n\nimport React from 'react';\nimport { Document, Image, Page, Text, View } from '@react-pdf/renderer';\nimport { GridValidRowModel } from '@mui/x-data-grid-pro';\nimport { PdfTableColumn, PdfTableRowProps, PdfTableProps, PdfDocumentProps, PdfStyles } from './types';\nimport { getPdfStyles } from './styles';\n\nconst DEFAULT_COLUMN_WIDTH = 100;\n\nconst getWidthColumn = (width: number, totalW: number, nrColumns: number) => {\n // calculation width column where the 7px margin between the columns is included\n return `${Math.round((width * 100) / (totalW - 7 * (nrColumns - 1)))}%`;\n};\n\nconst PdfTableRow = ({ rowIndex, rowData, columns, styles, totalWidth }: PdfTableRowProps) => {\n return (\n <View style={styles.tableRowContainer} key={`row-${rowIndex}`}>\n {columns.map((column: PdfTableColumn, index: number) => {\n const { field, width } = column;\n let totalW = totalWidth;\n let nrColumns = columns.length;\n\n // The checkbox in the table will not be printed\n if (field === '__check__') {\n totalW = totalW - (width || 50);\n nrColumns = nrColumns - 1;\n return;\n }\n const widthColumn = getWidthColumn(width || DEFAULT_COLUMN_WIDTH, totalW, nrColumns);\n\n // Empty value will print '-'\n if (!rowData[field]) {\n return (\n <View\n style={{\n width: widthColumn,\n paddingVertical: 2,\n marginRight: 7,\n }}\n key={`cell-${rowIndex}-${index}`}\n >\n <Text style={styles.tableCellText}>{'-'}</Text>\n </View>\n );\n }\n return (\n <View\n style={{\n width: widthColumn,\n paddingVertical: 2,\n marginRight: 7,\n }}\n key={`cell-${rowIndex}-${index}`}\n >\n <Text style={styles.tableCellText}>\n {Array.isArray(rowData[field]) ? rowData[field].join(', ') : rowData[field]}\n </Text>\n </View>\n );\n })}\n </View>\n );\n};\n\nconst PdfTable = ({ dataTable, styles, localeText }: PdfTableProps) => {\n const { data, columns, totalWidth } = dataTable;\n\n return (\n <>\n <View style={styles.tableHeaderContainer}>\n {columns.map((column: PdfTableColumn) => {\n let totalW = totalWidth;\n let nrColumns = columns.length;\n const { field, headerName, width } = column;\n\n // The checkbox in the table will not be printed\n if (field === '__check__') {\n totalW = totalW - (width || 50);\n nrColumns = nrColumns - 1;\n return;\n }\n const widthColumn = getWidthColumn(width || DEFAULT_COLUMN_WIDTH, totalW, nrColumns);\n\n return (\n <View\n style={{\n width: widthColumn,\n paddingVertical: 2,\n marginRight: 7,\n }}\n key={`heading-${field}`}\n >\n <Text style={styles.tableCellHeaderText}>{headerName}</Text>\n </View>\n );\n })}\n </View>\n <View>\n {data.map((row: GridValidRowModel, index: number) => {\n if (index < 1000) {\n return (\n <PdfTableRow\n key={index}\n rowIndex={index}\n rowData={data[index]}\n columns={columns}\n styles={styles}\n totalWidth={totalWidth}\n />\n );\n }\n })}\n </View>\n {data.length >= 1000 ? (\n <View style={styles.constraintsContainer}>\n <Text style={styles.constraints}>\n {localeText?.maxSizeDisclaimer ||\n 'Due to processing constraints this pdf is limited to the first 1000 rows of data.'}\n </Text>\n </View>\n ) : null}\n </>\n );\n};\n\nconst Pagination = ({ styles }: { styles: PdfStyles }) => {\n return (\n <Text style={styles.pageNumber} render={({ pageNumber, totalPages }) => `${pageNumber}/${totalPages}`} fixed />\n );\n};\n\nexport const PdfDocument = ({\n dashboardImage,\n introduction,\n localeText,\n logo,\n dataTable,\n primaryColor,\n}: PdfDocumentProps) => {\n const styles = getPdfStyles(primaryColor);\n\n return (\n <Document>\n <Page size=\"A4\" style={styles.page}>\n <>\n {logo ? (\n <View style={styles.logoContainer}>\n <Image src={logo} style={styles.logo} />\n </View>\n ) : null}\n {introduction ? (\n <View style={styles.introductionContainer}>\n <Text style={styles.introductionText}>{introduction}</Text>\n </View>\n ) : null}\n {dashboardImage ? (\n <View style={styles.dashboardImageContainer}>\n <Image src={dashboardImage as unknown as string} />\n </View>\n ) : null}\n {dataTable ? (\n <View style={styles.tableContainer}>\n <PdfTable dataTable={dataTable} styles={styles} localeText={localeText} />\n </View>\n ) : null}\n\n <Pagination styles={styles} />\n </>\n </Page>\n </Document>\n );\n};\n"],"names":["DEFAULT_COLUMN_WIDTH","getWidthColumn","width","totalW","nrColumns","Math","round","PdfTableRow","_ref","rowIndex","rowData","columns","styles","totalWidth","React","createElement","View","style","tableRowContainer","key","map","column","index","field","length","widthColumn","paddingVertical","marginRight","Text","tableCellText","Array","isArray","join","PdfTable","_ref2","dataTable","localeText","data","Fragment","tableHeaderContainer","headerName","tableCellHeaderText","row","constraintsContainer","constraints","maxSizeDisclaimer","Pagination","_ref3","pageNumber","render","_ref4","totalPages","fixed","PdfDocument","_ref5","dashboardImage","introduction","logo","primaryColor","getPdfStyles","Document","Page","size","page","logoContainer","Image","src","introductionContainer","introductionText","dashboardImageContainer","tableContainer"],"mappings":";;;;AAA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CAACC,IAAI,EAAA;IAACC,KAAK,EAAEL,MAAM,CAAC0D,cAAAA;AAAe,GAAA,eACjCxD,KAAA,CAAAC,aAAA,CAACkB,QAAQ,EAAA;AAACE,IAAAA,SAAS,EAAEA,SAAU;AAACvB,IAAAA,MAAM,EAAEA,MAAO;AAACwB,IAAAA,UAAU,EAAEA,UAAAA;GAAa,CACrE,CAAC,GACL,IAAI,eAERtB,KAAA,CAAAC,aAAA,CAAC+B,UAAU,EAAA;AAAClC,IAAAA,MAAM,EAAEA,MAAAA;GAAS,CAC7B,CACE,CACE,CAAC,CAAA;AAEf;;;;"}
@@ -0,0 +1,6 @@
1
+ import { Comp } from '@redsift/design-system';
2
+ import { PdfExportButtonProps } from './types.js';
3
+
4
+ declare const PdfExportButton: Comp<PdfExportButtonProps, HTMLButtonElement>;
5
+
6
+ export { PdfExportButton };
@@ -0,0 +1,110 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React, { forwardRef, useState, useContext, useEffect } from 'react';
3
+ import { gridFilteredSortedRowEntriesSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector } from '@mui/x-data-grid-pro';
4
+ import classNames from 'classnames';
5
+ import { saveAs } from 'file-saver';
6
+ import { pdf } from '@react-pdf/renderer';
7
+ import domToImage from 'dom-to-image';
8
+ import { Button, Spinner, RedsiftColorBlueD1 } from '@redsift/design-system';
9
+ import { PdfDocument } from './PdfDocument.js';
10
+ import { DashboardContext } from '../Dashboard/context.js';
11
+
12
+ const _excluded = ["children", "className", "componentRef", "fileName", "introduction", "localeText", "logo", "onClick", "primaryColor"];
13
+ const COMPONENT_NAME = 'PdfExportButton';
14
+ const CLASSNAME = 'redsift-pdf-export-button';
15
+ const getDashboardImage = async componentRef => {
16
+ var _componentRef$current, _componentRef$current2, _componentRef$current3, _componentRef$current4;
17
+ const filter = el => {
18
+ const classList = el.classList;
19
+ return !(classList !== null && classList !== void 0 && classList.contains('redsift-datagrid') || classList !== null && classList !== void 0 && classList.contains('redsift-button'));
20
+ };
21
+ const dashboardHeight = componentRef.current.getBoundingClientRect().height;
22
+ const datagridHeight = ((_componentRef$current = componentRef.current) === null || _componentRef$current === void 0 ? void 0 : (_componentRef$current2 = _componentRef$current.getElementsByClassName('redsift-datagrid')) === null || _componentRef$current2 === void 0 ? void 0 : (_componentRef$current3 = _componentRef$current2[0]) === null || _componentRef$current3 === void 0 ? void 0 : (_componentRef$current4 = _componentRef$current3.getBoundingClientRect()) === null || _componentRef$current4 === void 0 ? void 0 : _componentRef$current4.height) || 0;
23
+ return new Promise(resolve => {
24
+ domToImage.toPng(componentRef.current, {
25
+ filter,
26
+ height: dashboardHeight - datagridHeight
27
+ }).then(function (dataUrl) {
28
+ resolve(dataUrl);
29
+ }).catch(() => {
30
+ resolve('');
31
+ });
32
+ });
33
+ };
34
+ const PdfExportButton = /*#__PURE__*/forwardRef((props, ref) => {
35
+ const {
36
+ children,
37
+ className,
38
+ componentRef: propComponentRef,
39
+ fileName,
40
+ introduction,
41
+ localeText,
42
+ logo,
43
+ onClick,
44
+ primaryColor
45
+ } = props,
46
+ forwardedProps = _objectWithoutProperties(props, _excluded);
47
+ const [componentRef, setComponentRef] = useState(propComponentRef);
48
+ const [isLoading, setIsLoading] = useState(false);
49
+ const {
50
+ dashboardRef,
51
+ dataGridApiRef
52
+ } = useContext(DashboardContext);
53
+ useEffect(() => {
54
+ if (!componentRef || !componentRef.current) {
55
+ setComponentRef(dashboardRef);
56
+ }
57
+ }, [dashboardRef]);
58
+ const exportPdf = async () => {
59
+ if (onClick) {
60
+ onClick();
61
+ }
62
+ setIsLoading(true);
63
+ try {
64
+ const dashboardImage = await getDashboardImage(componentRef || dashboardRef);
65
+ let dataTable;
66
+ if (dataGridApiRef && dataGridApiRef.current && Object.keys(dataGridApiRef.current).length) {
67
+ dataTable = {
68
+ data: gridFilteredSortedRowEntriesSelector(dataGridApiRef.current.state, dataGridApiRef.current.instanceId).slice(0, 1000).map(_ref => {
69
+ let {
70
+ model
71
+ } = _ref;
72
+ return model;
73
+ }),
74
+ columns: gridVisibleColumnDefinitionsSelector(dataGridApiRef.current.state, dataGridApiRef.current.instanceId),
75
+ totalWidth: gridColumnsTotalWidthSelector(dataGridApiRef.current.state, dataGridApiRef.current.instanceId)
76
+ };
77
+ }
78
+ const doc = /*#__PURE__*/React.createElement(PdfDocument, {
79
+ localeText: localeText,
80
+ dashboardImage: dashboardImage,
81
+ introduction: introduction,
82
+ logo: logo,
83
+ primaryColor: primaryColor || RedsiftColorBlueD1,
84
+ dataTable: dataTable
85
+ });
86
+ const asPdf = pdf([]);
87
+ asPdf.updateContainer(doc);
88
+ const blob = await asPdf.toBlob();
89
+ saveAs(blob, fileName || 'redsift-dashboard.pdf');
90
+ } catch (e) {
91
+ console.log('error:', e);
92
+ }
93
+ setIsLoading(false);
94
+ };
95
+ return /*#__PURE__*/React.createElement(Button, _extends({
96
+ className: classNames(PdfExportButton.className, className),
97
+ onClick: exportPdf,
98
+ isDisabled: isLoading
99
+ }, forwardedProps, {
100
+ ref: ref
101
+ }), isLoading ? /*#__PURE__*/React.createElement(Spinner, {
102
+ size: "xsmall",
103
+ isColored: false
104
+ }) : null, " ", children);
105
+ });
106
+ PdfExportButton.className = CLASSNAME;
107
+ PdfExportButton.displayName = COMPONENT_NAME;
108
+
109
+ export { PdfExportButton };
110
+ //# sourceMappingURL=PdfExportButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdfExportButton.js","sources":["../../../src/components/PdfExportButton/PdfExportButton.tsx"],"sourcesContent":["// istanbul ignore file\n\nimport React, {\n forwardRef,\n JSXElementConstructor,\n ReactElement,\n RefObject,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport {\n gridFilteredSortedRowEntriesSelector,\n gridVisibleColumnDefinitionsSelector,\n gridColumnsTotalWidthSelector,\n} from '@mui/x-data-grid-pro';\nimport classNames from 'classnames';\nimport { saveAs } from 'file-saver';\nimport { pdf } from '@react-pdf/renderer';\nimport domToImage from 'dom-to-image';\n\nimport { Comp, Button, Spinner, RedsiftColorBlueD1 } from '@redsift/design-system';\n\nimport { PdfExportButtonProps } from './types';\nimport { PdfDocument } from './PdfDocument';\nimport { DashboardContext } from '../Dashboard';\n\nconst COMPONENT_NAME = 'PdfExportButton';\nconst CLASSNAME = 'redsift-pdf-export-button';\n\nconst getDashboardImage = async (componentRef: RefObject<HTMLElement>): Promise<string> => {\n const filter = (el: Node) => {\n const classList = (el as HTMLElement).classList;\n return !(classList?.contains('redsift-datagrid') || classList?.contains('redsift-button'));\n };\n\n const dashboardHeight = (componentRef.current as HTMLElement).getBoundingClientRect().height;\n const datagridHeight =\n (componentRef.current as HTMLElement)?.getElementsByClassName('redsift-datagrid')?.[0]?.getBoundingClientRect()\n ?.height || 0;\n\n return new Promise((resolve) => {\n domToImage\n .toPng(componentRef.current as HTMLElement, {\n filter,\n height: dashboardHeight - datagridHeight,\n })\n .then(function (dataUrl: string) {\n resolve(dataUrl);\n })\n .catch(() => {\n resolve('');\n });\n });\n};\n\nexport const PdfExportButton: Comp<PdfExportButtonProps, HTMLButtonElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n componentRef: propComponentRef,\n fileName,\n introduction,\n localeText,\n logo,\n onClick,\n primaryColor,\n ...forwardedProps\n } = props;\n const [componentRef, setComponentRef] = useState(propComponentRef);\n const [isLoading, setIsLoading] = useState(false);\n\n const { dashboardRef, dataGridApiRef } = useContext(DashboardContext);\n\n useEffect(() => {\n if (!componentRef || !componentRef.current) {\n setComponentRef(dashboardRef);\n }\n }, [dashboardRef]);\n\n const exportPdf = async () => {\n if (onClick) {\n onClick();\n }\n setIsLoading(true);\n try {\n const dashboardImage = await getDashboardImage(componentRef || dashboardRef!);\n\n let dataTable;\n if (dataGridApiRef && dataGridApiRef.current && Object.keys(dataGridApiRef.current).length) {\n dataTable = {\n data: gridFilteredSortedRowEntriesSelector(dataGridApiRef.current.state, dataGridApiRef.current.instanceId)\n .slice(0, 1000)\n .map(({ model }) => model),\n columns: gridVisibleColumnDefinitionsSelector(\n dataGridApiRef.current.state,\n dataGridApiRef.current.instanceId\n ),\n totalWidth: gridColumnsTotalWidthSelector(dataGridApiRef.current.state, dataGridApiRef.current.instanceId),\n };\n }\n\n const doc = (\n <PdfDocument\n localeText={localeText}\n dashboardImage={dashboardImage}\n introduction={introduction}\n logo={logo}\n primaryColor={primaryColor || RedsiftColorBlueD1}\n dataTable={dataTable}\n />\n );\n const asPdf = pdf([] as unknown as ReactElement<any, string | JSXElementConstructor<any>>);\n asPdf.updateContainer(doc);\n const blob = await asPdf.toBlob();\n saveAs(blob, fileName || 'redsift-dashboard.pdf');\n } catch (e) {\n console.log('error:', e);\n }\n setIsLoading(false);\n };\n\n return (\n <Button\n className={classNames(PdfExportButton.className, className)}\n onClick={exportPdf}\n isDisabled={isLoading}\n {...forwardedProps}\n ref={ref as RefObject<HTMLButtonElement>}\n >\n {isLoading ? <Spinner size=\"xsmall\" isColored={false} /> : null} {children}\n </Button>\n );\n});\nPdfExportButton.className = CLASSNAME;\nPdfExportButton.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getDashboardImage","componentRef","_componentRef$current","_componentRef$current2","_componentRef$current3","_componentRef$current4","filter","el","classList","contains","dashboardHeight","current","getBoundingClientRect","height","datagridHeight","getElementsByClassName","Promise","resolve","domToImage","toPng","then","dataUrl","catch","PdfExportButton","forwardRef","props","ref","children","className","propComponentRef","fileName","introduction","localeText","logo","onClick","primaryColor","forwardedProps","_objectWithoutProperties","_excluded","setComponentRef","useState","isLoading","setIsLoading","dashboardRef","dataGridApiRef","useContext","DashboardContext","useEffect","exportPdf","dashboardImage","dataTable","Object","keys","length","data","gridFilteredSortedRowEntriesSelector","state","instanceId","slice","map","_ref","model","columns","gridVisibleColumnDefinitionsSelector","totalWidth","gridColumnsTotalWidthSelector","doc","React","createElement","PdfDocument","RedsiftColorBlueD1","asPdf","pdf","updateContainer","blob","toB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B,KAAK,GAAGC,GAAG,CAAC,EAAuE,CAAC,CAAA;AAC1FD,MAAAA,KAAK,CAACE,eAAe,CAACP,GAAG,CAAC,CAAA;AAC1B,MAAA,MAAMQ,IAAI,GAAG,MAAMH,KAAK,CAACI,MAAM,EAAE,CAAA;AACjCC,MAAAA,MAAM,CAACF,IAAI,EAAE5C,QAAQ,IAAI,uBAAuB,CAAC,CAAA;KAClD,CAAC,OAAO+C,CAAC,EAAE;AACVC,MAAAA,OAAO,CAACC,GAAG,CAAC,QAAQ,EAAEF,CAAC,CAAC,CAAA;AAC1B,KAAA;IACAnC,YAAY,CAAC,KAAK,CAAC,CAAA;GACpB,CAAA;AAED,EAAA,oBACEyB,KAAA,CAAAC,aAAA,CAACY,MAAM,EAAAC,QAAA,CAAA;IACLrD,SAAS,EAAEsD,UAAU,CAAC3D,eAAe,CAACK,SAAS,EAAEA,SAAS,CAAE;AAC5DM,IAAAA,OAAO,EAAEc,SAAU;AACnBmC,IAAAA,UAAU,EAAE1C,SAAAA;AAAU,GAAA,EAClBL,cAAc,EAAA;AAClBV,IAAAA,GAAG,EAAEA,GAAAA;AAAoC,GAAA,CAAA,EAExCe,SAAS,gBAAG0B,KAAA,CAAAC,aAAA,CAACgB,OAAO,EAAA;AAACC,IAAAA,IAAI,EAAC,QAAQ;AAACC,IAAAA,SAAS,EAAE,KAAA;AAAM,GAAE,CAAC,GAAG,IAAI,EAAC,GAAC,EAAC3D,QAC5D,CAAC,CAAA;AAEb,CAAC,EAAC;AACFJ,eAAe,CAACK,SAAS,GAAG7B,SAAS,CAAA;AACrCwB,eAAe,CAACgE,WAAW,GAAGzF,cAAc;;;;"}
@@ -0,0 +1,146 @@
1
+ import { Font, StyleSheet } from '@react-pdf/renderer';
2
+
3
+ // istanbul ignore file
4
+ const BACKGROUND_COLOR = '#F8F8F8';
5
+ const GREY_1 = '#E2E6EA';
6
+ const GREY_2 = '#bff0fd';
7
+ const getPdfStyles = primaryColor => {
8
+ Font.register({
9
+ family: 'Source Code Pro',
10
+ fonts: [{
11
+ src: 'https://fonts.gstatic.com/s/sourcecodepro/v7/HI_SiYsKILxRpg3hIP6sJ7fM7PqlM-vT.ttf'
12
+ }]
13
+ });
14
+ Font.register({
15
+ family: 'Roboto',
16
+ fonts: [{
17
+ fontWeight: 700,
18
+ src: 'https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/fonts/roboto/Roboto-Regular.ttf'
19
+ }, {
20
+ fontWeight: 400,
21
+ src: 'https://cdnjs.cloudflare.com/ajax/libs/ink/3.1.10/fonts/Roboto/roboto-light-webfont.ttf'
22
+ }]
23
+ });
24
+ return StyleSheet.create({
25
+ page: {
26
+ borderTopStyle: 'solid',
27
+ borderTopWidth: 32,
28
+ borderTopColor: primaryColor,
29
+ borderBottomStyle: 'solid',
30
+ borderBottomWidth: 6,
31
+ borderBottomColor: primaryColor,
32
+ backgroundColor: BACKGROUND_COLOR,
33
+ paddingTop: 20,
34
+ paddingBottom: 40
35
+ },
36
+ logoContainer: {
37
+ margin: 0,
38
+ paddingBottom: 10,
39
+ alignItems: 'center',
40
+ width: '100%'
41
+ },
42
+ logo: {
43
+ width: 'auto',
44
+ height: 30
45
+ },
46
+ introductionContainer: {
47
+ lineHeight: 1.4,
48
+ textAlign: 'center',
49
+ marginHorizontal: 40,
50
+ marginVertical: 10
51
+ },
52
+ introductionText: {
53
+ fontSize: 8,
54
+ fontFamily: 'Roboto',
55
+ fontWeight: 400,
56
+ color: 'black'
57
+ },
58
+ pageNumber: {
59
+ fontFamily: 'Source Code Pro',
60
+ position: 'absolute',
61
+ fontSize: 6,
62
+ bottom: 5,
63
+ right: 20,
64
+ left: 0,
65
+ textAlign: 'right',
66
+ color: 'black'
67
+ },
68
+ pageContinue: {
69
+ fontSize: 8,
70
+ fontFamily: 'Roboto',
71
+ fontWeight: 400,
72
+ top: -10,
73
+ left: 20
74
+ },
75
+ tableContainer: {
76
+ backgroundColor: 'white',
77
+ marginHorizontal: 20,
78
+ marginVertical: 10,
79
+ paddingTop: 10,
80
+ paddingLeft: 10,
81
+ borderRightWidth: 1,
82
+ borderBottomWidth: 1,
83
+ borderRightColor: BACKGROUND_COLOR,
84
+ borderBottomColor: GREY_1,
85
+ width: 'auto'
86
+ },
87
+ tableRowContainer: {
88
+ flexDirection: 'row',
89
+ borderBottomColor: GREY_2,
90
+ alignItems: 'flex-start',
91
+ fontSize: 8,
92
+ marginLeft: 16,
93
+ marginRight: 24,
94
+ height: 'auto'
95
+ },
96
+ tableHeaderContainer: {
97
+ flexDirection: 'row',
98
+ alignItems: 'flex-start',
99
+ fontSize: 7,
100
+ fontFamily: 'Roboto',
101
+ fontWeight: 700,
102
+ marginLeft: 16,
103
+ marginRight: 24,
104
+ marginBottom: 12,
105
+ paddingTop: 12,
106
+ paddingBottom: 12,
107
+ borderBottomWidth: 2,
108
+ borderBottomColor: primaryColor
109
+ },
110
+ tableCellHeaderText: {
111
+ fontSize: 7,
112
+ fontFamily: 'Roboto',
113
+ fontWeight: 700,
114
+ color: 'black',
115
+ overflow: 'hidden'
116
+ },
117
+ tableCellText: {
118
+ fontSize: 6,
119
+ lineHeight: 1.5,
120
+ fontFamily: 'Roboto',
121
+ fontWeight: 400,
122
+ color: 'black',
123
+ overflow: 'hidden'
124
+ },
125
+ dashboardImageContainer: {
126
+ marginHorizontal: 20,
127
+ marginTop: 0,
128
+ marginBottom: 10
129
+ },
130
+ constraintsContainer: {
131
+ width: 'auto',
132
+ height: 'auto',
133
+ paddingVertical: 30,
134
+ textAlign: 'center'
135
+ },
136
+ constraints: {
137
+ fontSize: 6,
138
+ fontFamily: 'Roboto',
139
+ fontWeight: 700,
140
+ color: 'black'
141
+ }
142
+ });
143
+ };
144
+
145
+ export { getPdfStyles };
146
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sources":["../../../src/components/PdfExportButton/styles.ts"],"sourcesContent":["// istanbul ignore file\n\nimport { Font, StyleSheet } from '@react-pdf/renderer';\nconst BACKGROUND_COLOR = '#F8F8F8';\nconst GREY_1 = '#E2E6EA';\nconst GREY_2 = '#bff0fd';\n\nexport const getPdfStyles = (primaryColor: string) => {\n Font.register({\n family: 'Source Code Pro',\n fonts: [\n {\n src: 'https://fonts.gstatic.com/s/sourcecodepro/v7/HI_SiYsKILxRpg3hIP6sJ7fM7PqlM-vT.ttf',\n },\n ],\n });\n\n Font.register({\n family: 'Roboto',\n fonts: [\n {\n fontWeight: 700,\n src: 'https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/fonts/roboto/Roboto-Regular.ttf',\n },\n {\n fontWeight: 400,\n src: 'https://cdnjs.cloudflare.com/ajax/libs/ink/3.1.10/fonts/Roboto/roboto-light-webfont.ttf',\n },\n ],\n });\n\n return StyleSheet.create({\n page: {\n borderTopStyle: 'solid',\n borderTopWidth: 32,\n borderTopColor: primaryColor,\n borderBottomStyle: 'solid',\n borderBottomWidth: 6,\n borderBottomColor: primaryColor,\n backgroundColor: BACKGROUND_COLOR,\n paddingTop: 20,\n paddingBottom: 40,\n },\n logoContainer: {\n margin: 0,\n paddingBottom: 10,\n alignItems: 'center',\n width: '100%',\n },\n logo: {\n width: 'auto',\n height: 30,\n },\n introductionContainer: {\n lineHeight: 1.4,\n textAlign: 'center',\n marginHorizontal: 40,\n marginVertical: 10,\n },\n introductionText: {\n fontSize: 8,\n fontFamily: 'Roboto',\n fontWeight: 400,\n color: 'black',\n },\n pageNumber: {\n fontFamily: 'Source Code Pro',\n position: 'absolute',\n fontSize: 6,\n bottom: 5,\n right: 20,\n left: 0,\n textAlign: 'right',\n color: 'black',\n },\n pageContinue: {\n fontSize: 8,\n fontFamily: 'Roboto',\n fontWeight: 400,\n top: -10,\n left: 20,\n },\n tableContainer: {\n backgroundColor: 'white',\n marginHorizontal: 20,\n marginVertical: 10,\n paddingTop: 10,\n paddingLeft: 10,\n borderRightWidth: 1,\n borderBottomWidth: 1,\n borderRightColor: BACKGROUND_COLOR,\n borderBottomColor: GREY_1,\n width: 'auto',\n },\n tableRowContainer: {\n flexDirection: 'row',\n borderBottomColor: GREY_2,\n alignItems: 'flex-start',\n fontSize: 8,\n marginLeft: 16,\n marginRight: 24,\n height: 'auto',\n },\n tableHeaderContainer: {\n flexDirection: 'row',\n alignItems: 'flex-start',\n fontSize: 7,\n fontFamily: 'Roboto',\n fontWeight: 700,\n marginLeft: 16,\n marginRight: 24,\n marginBottom: 12,\n paddingTop: 12,\n paddingBottom: 12,\n borderBottomWidth: 2,\n borderBottomColor: primaryColor,\n },\n tableCellHeaderText: {\n fontSize: 7,\n fontFamily: 'Roboto',\n fontWeight: 700,\n color: 'black',\n overflow: 'hidden',\n },\n tableCellText: {\n fontSize: 6,\n lineHeight: 1.5,\n fontFamily: 'Roboto',\n fontWeight: 400,\n color: 'black',\n overflow: 'hidden',\n },\n dashboardImageContainer: {\n marginHorizontal: 20,\n marginTop: 0,\n marginBottom: 10,\n },\n constraintsContainer: {\n width: 'auto',\n height: 'auto',\n paddingVertical: 30,\n textAlign: 'center',\n },\n constraints: {\n fontSize: 6,\n fontFamily: 'Roboto',\n fontWeight: 700,\n color: 'black',\n },\n });\n};\n"],"names":["BACKGROUND_COLOR","GREY_1","GREY_2","getPdfStyles","primaryColor","Font","register","family","fonts","src","fontWeight","StyleSheet","create","page","borderTopStyle","borderTopWidth","borderTopColor","borderBottomStyle","borderBottomWidth","borderBottomColor","backgroundColor","paddingTop","paddingBottom","logoContainer","margin","alignItems","width","logo","height","introductionContainer","lineHeight","textAlign","marginHorizontal","marginVertical","introductionText","fontSize","fontFamily","color","pageNumber","position","bottom","right","left","pageContinue","top","tableContainer","paddingLeft","borderRightWidth","borderRightColor","tableRowContainer","flexDirection","marginLeft","marginRight","tableHeaderContainer","marginBottom","tableCellHeaderText","overflow","tableCellText","dashboardImageContainer","marginTop","constraintsContainer","paddingVertical","constraints"],"mappings":";;AAAA;AAGA,MAAMA,gBAAgB,GAAG,SAAS,CAAA;AAClC,MAAMC,MAAM,GAAG,SAAS,CAA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MAAM;AACdiC,MAAAA,eAAe,EAAE,EAAE;AACnB9B,MAAAA,SAAS,EAAE,QAAA;KACZ;AACD+B,IAAAA,WAAW,EAAE;AACX3B,MAAAA,QAAQ,EAAE,CAAC;AACXC,MAAAA,UAAU,EAAE,QAAQ;AACpB1B,MAAAA,UAAU,EAAE,GAAG;AACf2B,MAAAA,KAAK,EAAE,OAAA;AACT,KAAA;AACF,GAAC,CAAC,CAAA;AACJ;;;;"}
@@ -0,0 +1,24 @@
1
+ import { ButtonProps } from '@redsift/design-system';
2
+ import { RefObject } from 'react';
3
+
4
+ interface LocaleText {
5
+ maxSizeDisclaimer?: string;
6
+ }
7
+ interface PdfExportButtonProps extends ButtonProps {
8
+ /** Ref to the DOM component to export. By default, will be the ref to the parent Dashboard. */
9
+ componentRef?: RefObject<HTMLElement>;
10
+ /** Name of the exported PDF file. */
11
+ fileName?: string;
12
+ /** Text to display at the beginning of the PDF. */
13
+ introduction?: string;
14
+ /** Labels and texts. */
15
+ localeText?: LocaleText;
16
+ /** Image to put at the top of the PDF (SVG format not supported). */
17
+ logo?: string;
18
+ /** Function to be executed when button is clicked. */
19
+ onClick?: () => void;
20
+ /** Color used for the header and footer of the PDF. */
21
+ primaryColor?: string;
22
+ }
23
+
24
+ export { PdfExportButtonProps };
@@ -0,0 +1,6 @@
1
+ import { Comp } from '@redsift/design-system';
2
+ import { TimeSeriesBarChartProps } from './types.js';
3
+
4
+ declare const TimeSeriesBarChart: Comp<TimeSeriesBarChartProps, HTMLDivElement>;
5
+
6
+ export { TimeSeriesBarChart };