datastake-daf 0.6.408 → 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 +16 -8128
- package/dist/utils/index.js +0 -1
- 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/Dashboard/Widget/WidgetImage/index.jsx +2 -62
- package/src/@daf/core/components/Dashboard/Widget/index.jsx +0 -49
- package/src/@daf/core/components/EditForm/components/DataLink/ajaxSelectDataLink.js +0 -2
- package/src/@daf/core/components/EditForm/storyConfig2.js +12915 -314
- 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 -76
- package/src/@daf/core/components/Pdf/PdfView/index.jsx +0 -117
- package/src/@daf/core/components/Pdf/PdfViewerWrapper.jsx +0 -14
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,76 +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
|
-
import { View } from '@react-pdf/renderer';
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
title: 'Core/Pdf/PdfView',
|
|
12
|
-
component: PdfView,
|
|
13
|
-
tags: ['autodocs'],
|
|
14
|
-
decorators: [
|
|
15
|
-
(Story) => (
|
|
16
|
-
<ThemeLayout>
|
|
17
|
-
<Story />
|
|
18
|
-
</ThemeLayout>
|
|
19
|
-
),
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const config = [
|
|
24
|
-
// {
|
|
25
|
-
// render: () => (
|
|
26
|
-
// <KeyIndicatorsWidget
|
|
27
|
-
// title="Key Indicators"
|
|
28
|
-
// config={[
|
|
29
|
-
// { label: "Item 1", render: () => <span>Value 1</span> },
|
|
30
|
-
// { label: "Item 2", render: () => <span>Value 2</span> },
|
|
31
|
-
// { label: "Item 3", render: () => <span>Value 3</span> },
|
|
32
|
-
// { label: "Item 4", render: () => <span>Value 4</span> },
|
|
33
|
-
// { label: "Item 5", render: () => <span>Value 5</span> },
|
|
34
|
-
// ]}
|
|
35
|
-
// />
|
|
36
|
-
// )
|
|
37
|
-
// },
|
|
38
|
-
{
|
|
39
|
-
render: () => (
|
|
40
|
-
<ImageWidget
|
|
41
|
-
title="Widget 1"
|
|
42
|
-
image="https://picsum.photos/200/300"
|
|
43
|
-
description="This is a description of the image widget."
|
|
44
|
-
isPdf={true}
|
|
45
|
-
/>
|
|
46
|
-
)
|
|
47
|
-
},
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export const Primary = {
|
|
52
|
-
name: 'PdfView',
|
|
53
|
-
args: {
|
|
54
|
-
title: 'PdfView',
|
|
55
|
-
imgSrc: 'https://picsum.photos/200/300',
|
|
56
|
-
userId: '12345',
|
|
57
|
-
accountId: '12345',
|
|
58
|
-
documentId: '12345',
|
|
59
|
-
downloadId: '12345',
|
|
60
|
-
config: config,
|
|
61
|
-
},
|
|
62
|
-
render: (args) => (
|
|
63
|
-
<PdfViewerWrapper>
|
|
64
|
-
<PdfView {...args}>
|
|
65
|
-
<View>
|
|
66
|
-
<ImageWidget
|
|
67
|
-
title="Widget 1"
|
|
68
|
-
image="https://picsum.photos/200/300"
|
|
69
|
-
description="This is a description of the image widget.This is a description of the image widget."
|
|
70
|
-
isPdf={true}
|
|
71
|
-
/>
|
|
72
|
-
</View>
|
|
73
|
-
</PdfView>
|
|
74
|
-
</PdfViewerWrapper>
|
|
75
|
-
),
|
|
76
|
-
};
|
|
@@ -1,117 +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, children }) {
|
|
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
|
-
{children}
|
|
91
|
-
</View>
|
|
92
|
-
|
|
93
|
-
{/* FOOTER */}
|
|
94
|
-
<View style={styles.footer} fixed>
|
|
95
|
-
<Text>{moment().format('DD MMM YYYY')}</Text>
|
|
96
|
-
<View style={{ flexDirection: 'column' }}>
|
|
97
|
-
<View style={{ flexDirection: 'row', gap: 6 }}>
|
|
98
|
-
<Text>User ID: <Text style={{ fontWeight: 'bold' }}>{userId}</Text></Text>
|
|
99
|
-
<Text>Account ID: <Text style={{ fontWeight: 'bold' }}>{accountId}</Text></Text>
|
|
100
|
-
<Text>Document ID: <Text style={{ fontWeight: 'bold' }}>{documentId}</Text></Text>
|
|
101
|
-
<Text>Download ID: <Text style={{ fontWeight: 'bold' }}>{downloadId}</Text></Text>
|
|
102
|
-
</View>
|
|
103
|
-
</View>
|
|
104
|
-
<Text
|
|
105
|
-
render={({ pageNumber, totalPages }) =>
|
|
106
|
-
`${pageNumber}`
|
|
107
|
-
}
|
|
108
|
-
/>
|
|
109
|
-
</View>
|
|
110
|
-
</Page>
|
|
111
|
-
</Document>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export default PdfView;
|
|
116
|
-
|
|
117
|
-
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';
|