datastake-daf 0.6.407 → 0.6.409
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/dist/components/index.js +18 -8058
- package/package.json +1 -3
- package/rollup.config.js +0 -7
- package/src/@daf/core/components/Dashboard/PdfView/index.jsx +1 -1
- package/src/@daf/core/components/EditForm/components/DataLink/ajaxSelectDataLink.js +1 -1
- package/src/index.js +0 -4
- package/src/@daf/core/components/Pdf/ElementAsImage.jsx +0 -39
- package/src/@daf/core/components/Pdf/PdfView/PdfView.stories.js +0 -66
- package/src/@daf/core/components/Pdf/PdfView/index.jsx +0 -116
- package/src/@daf/core/components/Pdf/PdfViewerWrapper.jsx +0 -14
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datastake-daf",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.409",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@ant-design/icons": "^5.2.5",
|
|
6
6
|
"@antv/g2": "^5.1.1",
|
|
7
7
|
"@antv/g2plot": "^2.4.32",
|
|
8
8
|
"@elfalem/leaflet-curve": "^0.9.2",
|
|
9
|
-
"@react-pdf/renderer": "^4.3.1",
|
|
10
9
|
"@testing-library/jest-dom": "^5.16.5",
|
|
11
10
|
"@testing-library/react": "^13.4.0",
|
|
12
11
|
"@testing-library/user-event": "^13.5.0",
|
|
@@ -20,7 +19,6 @@
|
|
|
20
19
|
"dayjs": "^1.11.12",
|
|
21
20
|
"deepmerge": "^4.3.1",
|
|
22
21
|
"dot-object": "^2.1.5",
|
|
23
|
-
"html2canvas": "^1.4.1",
|
|
24
22
|
"leaflet": "^1.0.3",
|
|
25
23
|
"leaflet-editable": "^1.3.0",
|
|
26
24
|
"leaflet-geosearch": "^3.1.0",
|
package/rollup.config.js
CHANGED
|
@@ -40,13 +40,6 @@ const external = [
|
|
|
40
40
|
"@xyflow/react",
|
|
41
41
|
"zustand/shallow",
|
|
42
42
|
"@elfalem/leaflet-curve",
|
|
43
|
-
// PDF rendering related packages (externalize to avoid bundling CJS/UMD issues)
|
|
44
|
-
"@react-pdf/renderer",
|
|
45
|
-
"@react-pdf/textkit",
|
|
46
|
-
"hyphen",
|
|
47
|
-
"hyphen/patterns/en-us.js",
|
|
48
|
-
"unicode-properties",
|
|
49
|
-
"bidi-js",
|
|
50
43
|
];
|
|
51
44
|
|
|
52
45
|
// Four builds, components, utils, hooks, context
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { formatClassname } from "../../../../../helpers/ClassesHelper";
|
|
5
5
|
|
|
6
|
-
const PAGE_HEIGHT =
|
|
6
|
+
const PAGE_HEIGHT = 3508;
|
|
7
7
|
// margin-top: 20, bottom: 20;
|
|
8
8
|
const FOOTER_HEIGHT = 70;
|
|
9
9
|
const HEADER_HEIGHT = 100;
|
|
@@ -245,7 +245,7 @@ export function AjaxSelectMain({
|
|
|
245
245
|
? method.split(/\(/)[0]
|
|
246
246
|
: method,
|
|
247
247
|
mapper: JSON.parse(mapper),
|
|
248
|
-
filters: { ...filterValues, preSelected, ...filters
|
|
248
|
+
filters: { ...filters, ...filterValues, preSelected, }, // changed this from ..filterValues, preSelected, ...filters to ..filters, ...filterValues, preSelected,
|
|
249
249
|
},
|
|
250
250
|
{
|
|
251
251
|
headers: {
|
package/src/index.js
CHANGED
|
@@ -169,7 +169,3 @@ export { InformationChannelProvider } from "./@daf/core/components/Screens/Infor
|
|
|
169
169
|
// UI
|
|
170
170
|
export { default as SDGIcons } from "./@daf/core/components/UI/SDGIcon/index.jsx";
|
|
171
171
|
export { default as CountryFlag } from "./@daf/core/components/UI/CountryFlag/index.jsx"
|
|
172
|
-
|
|
173
|
-
// Pdf
|
|
174
|
-
export { default as DafPdfView } from "./@daf/core/components/Pdf/PdfView/index.jsx";
|
|
175
|
-
export { default as PdfViewerWrapper } from "./@daf/core/components/Pdf/PdfViewerWrapper.jsx";
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import html2canvas from 'html2canvas';
|
|
4
|
-
import { Image } from '@react-pdf/renderer';
|
|
5
|
-
|
|
6
|
-
export const ElementAsImage = ({ element, width = "100%", scale = 3 }) => {
|
|
7
|
-
const [dataUrl, setDataUrl] = useState(null);
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
const container = document.createElement('div');
|
|
11
|
-
container.style.position = 'absolute';
|
|
12
|
-
container.style.top = '-9999px';
|
|
13
|
-
container.style.width = width;
|
|
14
|
-
document.body.appendChild(container);
|
|
15
|
-
|
|
16
|
-
const root = createRoot(container);
|
|
17
|
-
root.render(element);
|
|
18
|
-
|
|
19
|
-
setTimeout(() => {
|
|
20
|
-
html2canvas(container, { scale, useCORS: true }).then(canvas => {
|
|
21
|
-
setDataUrl(canvas.toDataURL('image/png'));
|
|
22
|
-
root.unmount();
|
|
23
|
-
container.remove();
|
|
24
|
-
});
|
|
25
|
-
}, 100);
|
|
26
|
-
|
|
27
|
-
}, [element, width, scale]);
|
|
28
|
-
|
|
29
|
-
if (!dataUrl) return null;
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<Image
|
|
33
|
-
src={dataUrl}
|
|
34
|
-
style={{ width, objectFit: 'contain' }} // use the same width as container
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
ElementAsImage.displayName = 'ElementAsImage';
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import PdfView from './index.jsx';
|
|
2
|
-
import ThemeLayout from '../../ThemeLayout';
|
|
3
|
-
import PdfViewerWrapper from '../PdfViewerWrapper.jsx';
|
|
4
|
-
import { ElementAsImage } from '../ElementAsImage.jsx';
|
|
5
|
-
import ImageWidget from '../../Dashboard/Widget/WidgetImage/index.jsx';
|
|
6
|
-
import KeyIndicatorsWidget from '../../Dashboard/Widget/KeyIndicators/index.jsx';
|
|
7
|
-
import DashboardLayout from '../../Dashboard/DashboardLayout/index.jsx';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
title: 'Core/Pdf/PdfView',
|
|
11
|
-
component: PdfView,
|
|
12
|
-
tags: ['autodocs'],
|
|
13
|
-
decorators: [
|
|
14
|
-
(Story) => (
|
|
15
|
-
<ThemeLayout>
|
|
16
|
-
<Story />
|
|
17
|
-
</ThemeLayout>
|
|
18
|
-
),
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const config = [
|
|
23
|
-
{
|
|
24
|
-
render: () => (
|
|
25
|
-
<KeyIndicatorsWidget
|
|
26
|
-
title="Key Indicators"
|
|
27
|
-
config={[
|
|
28
|
-
{ label: "Item 1", render: () => <span>Value 1</span> },
|
|
29
|
-
{ label: "Item 2", render: () => <span>Value 2</span> },
|
|
30
|
-
{ label: "Item 3", render: () => <span>Value 3</span> },
|
|
31
|
-
{ label: "Item 4", render: () => <span>Value 4</span> },
|
|
32
|
-
{ label: "Item 5", render: () => <span>Value 5</span> },
|
|
33
|
-
]}
|
|
34
|
-
/>
|
|
35
|
-
)
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
render: () => (
|
|
39
|
-
<ImageWidget
|
|
40
|
-
title="Widget 1"
|
|
41
|
-
image="https://picsum.photos/200/300"
|
|
42
|
-
description="This is a description of the image widget."
|
|
43
|
-
isPdf={true}
|
|
44
|
-
/>
|
|
45
|
-
)
|
|
46
|
-
},
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
export const Primary = {
|
|
51
|
-
name: 'PdfView',
|
|
52
|
-
args: {
|
|
53
|
-
title: 'PdfView',
|
|
54
|
-
imgSrc: 'https://picsum.photos/200/300',
|
|
55
|
-
userId: '12345',
|
|
56
|
-
accountId: '12345',
|
|
57
|
-
documentId: '12345',
|
|
58
|
-
downloadId: '12345',
|
|
59
|
-
config: config,
|
|
60
|
-
},
|
|
61
|
-
render: (args) => (
|
|
62
|
-
<PdfViewerWrapper>
|
|
63
|
-
<PdfView {...args} />
|
|
64
|
-
</PdfViewerWrapper>
|
|
65
|
-
),
|
|
66
|
-
};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Document, Page, Text, View, Image, StyleSheet } from '@react-pdf/renderer';
|
|
3
|
-
import moment from 'moment';
|
|
4
|
-
import { ElementAsImage } from '../ElementAsImage.jsx';
|
|
5
|
-
import DashboardLayout from '../../Dashboard/DashboardLayout/index.jsx';
|
|
6
|
-
|
|
7
|
-
const FOOTER_HEIGHT = 50;
|
|
8
|
-
const HEADER_HEIGHT = 70;
|
|
9
|
-
|
|
10
|
-
const styles = StyleSheet.create({
|
|
11
|
-
page: {
|
|
12
|
-
position: 'relative',
|
|
13
|
-
paddingTop: HEADER_HEIGHT,
|
|
14
|
-
paddingBottom: FOOTER_HEIGHT,
|
|
15
|
-
backgroundColor: "#F9FAFB",
|
|
16
|
-
// paddingHorizontal: 24,
|
|
17
|
-
},
|
|
18
|
-
header: {
|
|
19
|
-
position: 'absolute',
|
|
20
|
-
top: 0,
|
|
21
|
-
left: 0,
|
|
22
|
-
height: HEADER_HEIGHT,
|
|
23
|
-
width: '100%',
|
|
24
|
-
flexDirection: 'row',
|
|
25
|
-
justifyContent: 'space-between',
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
paddingHorizontal: 24,
|
|
28
|
-
backgroundColor: '#384250',
|
|
29
|
-
},
|
|
30
|
-
headerTitle: {
|
|
31
|
-
fontSize: 24,
|
|
32
|
-
fontWeight: 700,
|
|
33
|
-
color: 'white',
|
|
34
|
-
},
|
|
35
|
-
headerImage: {
|
|
36
|
-
height: 40,
|
|
37
|
-
width: 80,
|
|
38
|
-
},
|
|
39
|
-
footer: {
|
|
40
|
-
position: 'absolute',
|
|
41
|
-
bottom: 0,
|
|
42
|
-
left: 0,
|
|
43
|
-
height: FOOTER_HEIGHT,
|
|
44
|
-
width: '100%',
|
|
45
|
-
flexDirection: 'row',
|
|
46
|
-
justifyContent: 'space-between',
|
|
47
|
-
alignItems: 'center',
|
|
48
|
-
borderTopWidth: 0.5,
|
|
49
|
-
borderTopColor: '#ccc',
|
|
50
|
-
paddingHorizontal: 24,
|
|
51
|
-
fontSize: 10,
|
|
52
|
-
color: '#7f92a9'
|
|
53
|
-
},
|
|
54
|
-
content: {
|
|
55
|
-
// marginTop: HEADER_HEIGHT + 10,
|
|
56
|
-
// marginBottom: FOOTER_HEIGHT + 10,
|
|
57
|
-
flexGrow: 1,
|
|
58
|
-
alignSelf: 'stretch',
|
|
59
|
-
},
|
|
60
|
-
widgetContainer: {
|
|
61
|
-
marginBottom: -8,
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
function PdfView({ title, imgSrc, userId, accountId, documentId, downloadId, config }) {
|
|
66
|
-
return (
|
|
67
|
-
<Document>
|
|
68
|
-
<Page size="A4" style={styles.page}>
|
|
69
|
-
{/* HEADER */}
|
|
70
|
-
<View style={styles.header} fixed>
|
|
71
|
-
<Text style={styles.headerTitle}>{title}</Text>
|
|
72
|
-
{imgSrc && <Image src={imgSrc} style={styles.headerImage} />}
|
|
73
|
-
</View>
|
|
74
|
-
|
|
75
|
-
{/* CONTENT (auto-breaks across pages) */}
|
|
76
|
-
<View style={styles.content}>
|
|
77
|
-
{config.map((widget, i) => (
|
|
78
|
-
<View key={`widget-${i}`} style={styles.widgetContainer} wrap={false}>
|
|
79
|
-
<ElementAsImage
|
|
80
|
-
element={
|
|
81
|
-
<DashboardLayout>
|
|
82
|
-
<section>
|
|
83
|
-
{widget.render()}
|
|
84
|
-
</section>
|
|
85
|
-
</DashboardLayout>
|
|
86
|
-
}
|
|
87
|
-
/>
|
|
88
|
-
</View>
|
|
89
|
-
))}
|
|
90
|
-
</View>
|
|
91
|
-
|
|
92
|
-
{/* FOOTER */}
|
|
93
|
-
<View style={styles.footer} fixed>
|
|
94
|
-
<Text>{moment().format('DD MMM YYYY')}</Text>
|
|
95
|
-
<View style={{ flexDirection: 'column' }}>
|
|
96
|
-
<View style={{ flexDirection: 'row', gap: 6 }}>
|
|
97
|
-
<Text>User ID: <Text style={{ fontWeight: 'bold' }}>{userId}</Text></Text>
|
|
98
|
-
<Text>Account ID: <Text style={{ fontWeight: 'bold' }}>{accountId}</Text></Text>
|
|
99
|
-
<Text>Document ID: <Text style={{ fontWeight: 'bold' }}>{documentId}</Text></Text>
|
|
100
|
-
<Text>Download ID: <Text style={{ fontWeight: 'bold' }}>{downloadId}</Text></Text>
|
|
101
|
-
</View>
|
|
102
|
-
</View>
|
|
103
|
-
<Text
|
|
104
|
-
render={({ pageNumber, totalPages }) =>
|
|
105
|
-
`${pageNumber}`
|
|
106
|
-
}
|
|
107
|
-
/>
|
|
108
|
-
</View>
|
|
109
|
-
</Page>
|
|
110
|
-
</Document>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export default PdfView;
|
|
115
|
-
|
|
116
|
-
PdfView.displayName = 'PdfView';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PDFViewer } from '@react-pdf/renderer';
|
|
3
|
-
|
|
4
|
-
const PdfViewerWrapper = ({ children }) => (
|
|
5
|
-
<div style={{ width: '100%', height: '90vh' }}>
|
|
6
|
-
<PDFViewer width="100%" height="1200">{children}</PDFViewer>
|
|
7
|
-
</div>
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
PdfViewerWrapper.displayName = 'PdfViewerWrapper';
|
|
11
|
-
|
|
12
|
-
export default PdfViewerWrapper;
|
|
13
|
-
|
|
14
|
-
PdfViewerWrapper.displayName = 'PdfViewerWrapper';
|