datastake-daf 0.6.149 → 0.6.151

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 (122) hide show
  1. package/dist/components/index.js +112 -335
  2. package/package.json +1 -1
  3. package/src/@daf/core/components/Dashboard/PdfView/index.jsx +59 -102
  4. package/src/@daf/core/components/Dashboard/Widget/ExpandableMapWidget/ExpandableMapWidget.stories.js +1693 -0
  5. package/src/@daf/core/components/Dashboard/Widget/ExpandableMapWidget/hook.js +44 -0
  6. package/src/@daf/core/components/Dashboard/Widget/ExpandableMapWidget/index.js +55 -0
  7. package/src/@daf/core/components/Dashboard/Widget/index.jsx +2 -1
  8. package/.vscode/settings.json +0 -13
  9. package/public/assets/images/SVG/403.svg +0 -20
  10. package/public/assets/images/SVG/404.svg +0 -11
  11. package/public/assets/images/SVG/CADD.svg +0 -27
  12. package/public/assets/images/SVG/InDevelopment.svg +0 -24
  13. package/public/assets/images/SVG/PME.svg +0 -21
  14. package/public/assets/images/SVG/comment-alt.svg +0 -3
  15. package/public/assets/images/SVG/comment.svg +0 -3
  16. package/public/assets/images/SVG/coordinator.svg +0 -3
  17. package/public/assets/images/SVG/implementer.svg +0 -3
  18. package/public/assets/images/SVG/logo-horizontal.svg +0 -1
  19. package/public/assets/images/SVG/partner-building.svg +0 -3
  20. package/public/assets/images/SVG/partner.svg +0 -5
  21. package/public/assets/images/SVG/unavailable-info.svg +0 -16
  22. package/public/assets/images/SVG/vault.svg +0 -6
  23. package/public/assets/images/app-navigation/mmt-logo.svg +0 -32
  24. package/public/assets/images/app-navigation/tazama-logo.svg +0 -31
  25. package/public/assets/images/app-navigation/tif-logo.svg +0 -33
  26. package/public/assets/images/applications/arm-prev.png +0 -0
  27. package/public/assets/images/applications/asm-icon.svg +0 -29
  28. package/public/assets/images/applications/kota-logo.svg +0 -4
  29. package/public/assets/images/applications/mmt-logo-2.svg +0 -5
  30. package/public/assets/images/applications/mmt-logo.svg +0 -6
  31. package/public/assets/images/applications/mmt-prev.png +0 -0
  32. package/public/assets/images/applications/sbgi_logo.png +0 -0
  33. package/public/assets/images/applications/tazama-home-img.jpeg +0 -0
  34. package/public/assets/images/applications/tazama-logo.svg +0 -9
  35. package/public/assets/images/applications/tif-app.png +0 -0
  36. package/public/assets/images/applications/tif-logo.svg +0 -9
  37. package/public/assets/images/auth-bg-2.svg +0 -296
  38. package/public/assets/images/auth-bg.svg +0 -303
  39. package/public/assets/images/countries/fr.png +0 -0
  40. package/public/assets/images/countries/gb.png +0 -0
  41. package/public/assets/images/countries/sp.png +0 -0
  42. package/public/assets/images/dashboard/amp-dashboard/empty.png +0 -0
  43. package/public/assets/images/dashboard/map-icons/amp.svg +0 -28
  44. package/public/assets/images/dashboard/map-icons/amp_focused.svg +0 -28
  45. package/public/assets/images/dashboard/map-icons/amp_location_pin.svg +0 -4
  46. package/public/assets/images/dashboard/map-icons/datachain-icon.svg +0 -21
  47. package/public/assets/images/dashboard/map-icons/ellipse.svg +0 -3
  48. package/public/assets/images/dashboard/map-icons/lir-icon.svg +0 -3
  49. package/public/assets/images/dashboard/map-icons/major-incident-events-icon.svg +0 -3
  50. package/public/assets/images/dashboard/map-icons/minesites-location-icon.svg +0 -21
  51. package/public/assets/images/dashboard/map-icons/minor-incident-events-icon.svg +0 -3
  52. package/public/assets/images/dashboard/map-icons/moderate-incident-events-icon.svg +0 -3
  53. package/public/assets/images/dashboard/map-icons/other-events-icon.svg +0 -3
  54. package/public/assets/images/dashboard/map-icons/other-location-icon.svg +0 -21
  55. package/public/assets/images/dashboard/map-icons/risk-mitigation-events-icon.svg +0 -3
  56. package/public/assets/images/dashboard/map-icons/sca_location_pin.svg +0 -4
  57. package/public/assets/images/dashboard/map-icons/villages-location-icon.svg +0 -21
  58. package/public/assets/images/dashboard/mine-site.svg +0 -7
  59. package/public/assets/images/dashboard/programs/key-data.svg +0 -12
  60. package/public/assets/images/dashboard/programs/key-projects.svg +0 -12
  61. package/public/assets/images/dashboard/scl-icons/close-icon.svg +0 -4
  62. package/public/assets/images/dashboard/scl-icons/dot.svg +0 -3
  63. package/public/assets/images/dashboard/scl-icons/empty-gallery.svg +0 -5
  64. package/public/assets/images/dashboard/scl-icons/location-icon.svg +0 -14
  65. package/public/assets/images/dashboard/scl-icons/town-dot.svg +0 -3
  66. package/public/assets/images/dashboard/scl-icons/town-icon.svg +0 -4
  67. package/public/assets/images/dashboard/scl-icons/village-icon.svg +0 -6
  68. package/public/assets/images/dashboard/tif-products/cobalt-bg.png +0 -0
  69. package/public/assets/images/dashboard/tif-products/cobalt-logo.png +0 -0
  70. package/public/assets/images/dashboard/tif-products/gold-bg.png +0 -0
  71. package/public/assets/images/dashboard/tif-products/gold-logo.png +0 -0
  72. package/public/assets/images/datastake-logo.svg +0 -20
  73. package/public/assets/images/datastake-white.svg +0 -20
  74. package/public/assets/images/empty-box.svg +0 -5
  75. package/public/assets/images/find-information/business-entity.svg +0 -4
  76. package/public/assets/images/find-information/civil-society.svg +0 -4
  77. package/public/assets/images/find-information/government.svg +0 -4
  78. package/public/assets/images/find-information/graphs.png +0 -0
  79. package/public/assets/images/find-information/individual.svg +0 -11
  80. package/public/assets/images/find-information/non-stated-arm-group.svg +0 -4
  81. package/public/assets/images/find-information/other-organisation.svg +0 -4
  82. package/public/assets/images/find-information/state-security.svg +0 -4
  83. package/public/assets/images/info-channels/investor.svg +0 -4
  84. package/public/assets/images/info-channels/mine.svg +0 -4
  85. package/public/assets/images/info-channels/source.png +0 -0
  86. package/public/assets/images/kota-bg.jpg +0 -0
  87. package/public/assets/images/kota-logo-small.svg +0 -2
  88. package/public/assets/images/kota-logo.svg +0 -2
  89. package/public/assets/images/logo-new-white-icon.svg +0 -5
  90. package/public/assets/images/logo-new-white.svg +0 -8
  91. package/public/assets/images/logo-white.svg +0 -67
  92. package/public/assets/images/map/assessed.png +0 -0
  93. package/public/assets/images/map/connected.png +0 -0
  94. package/public/assets/images/map/disabled.png +0 -0
  95. package/public/assets/images/map/identified.png +0 -0
  96. package/public/assets/images/map/position.png +0 -0
  97. package/public/assets/images/map/treasure-map.png +0 -0
  98. package/public/assets/images/project-share-info/due-dilligence.svg +0 -3
  99. package/public/assets/images/project-share-info/event.svg +0 -3
  100. package/public/assets/images/project-share-info/location.svg +0 -3
  101. package/public/assets/images/project-share-info/network.svg +0 -3
  102. package/public/assets/images/project-share-info/stakeholder.svg +0 -10
  103. package/public/assets/images/tif/antelope-mine-people.png +0 -0
  104. package/public/assets/images/tif/gesagu-people.png +0 -0
  105. package/public/assets/images/tif/ironstep-people.png +0 -0
  106. package/public/assets/images/tif-bg.png +0 -0
  107. package/public/assets/images/tif-logo-small.svg +0 -3
  108. package/public/assets/images/tif-logo.svg +0 -9
  109. package/public/assets/images/verified-user-tif.png +0 -0
  110. package/public/assets/images/verified-user.svg +0 -100
  111. package/public/favicons/android-chrome-192x192.png +0 -0
  112. package/public/favicons/android-chrome-512x512.png +0 -0
  113. package/public/favicons/apple-touch-icon.png +0 -0
  114. package/public/favicons/favicon-16x16.png +0 -0
  115. package/public/favicons/favicon-32x32.png +0 -0
  116. package/public/favicons/favicon.ico +0 -0
  117. package/public/favicons/tazama/android-chrome-192x192.png +0 -0
  118. package/public/favicons/tazama/android-chrome-512x512.png +0 -0
  119. package/public/favicons/tazama/apple-touch-icon.png +0 -0
  120. package/public/favicons/tazama/favicon-16x16.png +0 -0
  121. package/public/favicons/tazama/favicon-32x32.png +0 -0
  122. package/public/favicons/tazama/favicon.ico +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.149",
3
+ "version": "0.6.151",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -1,12 +1,18 @@
1
+ // Dashboard/PdfView/index.jsx
1
2
  import moment from "moment";
2
3
  import PropTypes from 'prop-types';
3
4
  import { useCallback, useEffect, useRef, useState } from "react";
4
5
  import { formatClassname } from "../../../../../helpers/ClassesHelper";
5
6
 
6
- const PAGE_HEIGHT = 1587;
7
- // margin-top: 20, bottom: 20;
7
+ const PAGE_HEIGHT = 1587; // Total height of a virtual PDF page
8
8
  const FOOTER_HEIGHT = 70;
9
9
  const HEADER_HEIGHT = 100;
10
+ const ROW_SPACING = 24; // Spacing between content rows
11
+ const CONTENT_BOTTOM_PADDING = 30; // Extra padding at the very bottom of the last section of the document
12
+
13
+ // This is the actual height available for the *flowing content* after Puppeteer
14
+ // applies its margins for the header and footer.
15
+ const USABLE_FLOW_HEIGHT_PER_PAGE = PAGE_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT;
10
16
 
11
17
  const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
12
18
  const ref = useRef();
@@ -19,16 +25,22 @@ const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
19
25
  }
20
26
  });
21
27
 
22
- observer.observe(ref.current);
28
+ if (ref.current) {
29
+ observer.observe(ref.current);
30
+ }
23
31
 
24
- return () => observer.disconnect();
32
+ return () => {
33
+ if (ref.current) {
34
+ observer.disconnect();
35
+ }
36
+ };
25
37
  }, []);
26
38
 
27
39
  useEffect(() => {
28
40
  if (height) {
29
41
  onChangeHeight(i, { height, ref });
30
42
  }
31
- }, [height])
43
+ }, [height, i, onChangeHeight]);
32
44
 
33
45
  return (
34
46
  <section ref={ref} style={widgets.style}>
@@ -40,6 +52,8 @@ const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
40
52
  export default function PdfView({
41
53
  config = [],
42
54
  customClassName,
55
+ // No longer needed to directly render title/imgSrc/etc within PdfView as Puppeteer handles it
56
+ // but kept in props for completeness if other parts of the app use them.
43
57
  title = 'Title',
44
58
  imgSrc = '',
45
59
  userId = 'IDD-0000000',
@@ -48,56 +62,54 @@ export default function PdfView({
48
62
  downloadId = 'DWL-00000123',
49
63
  }) {
50
64
  const [sectionsConfig, setSectionsConfig] = useState({});
51
- const [pages, setPages] = useState([1]);
65
+ const [pagesCount, setPagesCount] = useState(1); // Track total pages for Puppeteer footer
52
66
 
53
67
  const doSizing = useCallback(() => {
54
- const keys = Object.keys(sectionsConfig);
55
- let _pages = [1];
56
- let _page = 1;
57
-
68
+ // Ensure keys are processed in order
69
+ const keys = Object.keys(sectionsConfig).sort((a,b) => parseInt(a) - parseInt(b));
58
70
  if (keys.length === config.length) {
59
- let incrHeight = 0;
71
+ let currentPageContentHeight = 0;
72
+ let currentPage = 1;
60
73
 
74
+ // Reset all page-break styles before recalculating
61
75
  keys.forEach(k => {
62
76
  const { ref } = sectionsConfig[k];
63
- ref.current.style.marginBottom = '0px';
64
- // ref.current.style.marginTop = '15px';
65
- })
77
+ if (ref.current) {
78
+ ref.current.style.pageBreakBefore = 'auto'; // Reset to default
79
+ ref.current.style.marginTop = '0px'; // Clear any previous dynamic margins
80
+ ref.current.style.paddingBottom = '0px'; // Clear any previous dynamic paddings
81
+ }
82
+ });
66
83
 
67
84
  keys.forEach((k, i) => {
68
85
  const { height, ref } = sectionsConfig[k];
86
+ if (!ref.current) return;
69
87
 
70
- if (i === 0) {
71
- ref.current.style.marginTop = `${HEADER_HEIGHT}px`;
72
- incrHeight += HEADER_HEIGHT;
73
- }
74
-
75
- const newHeight = incrHeight + height;
88
+ let spaceNeededForThisSection = height;
76
89
 
77
- if (i === keys.length - 1) {
78
- ref.current.style.paddingBottom = '30px';
90
+ // Add ROW_SPACING *after* each section, except the very last one.
91
+ if (i < keys.length - 1) {
92
+ spaceNeededForThisSection += ROW_SPACING;
93
+ } else {
94
+ // Add CONTENT_BOTTOM_PADDING after the very last section of the document.
95
+ spaceNeededForThisSection += CONTENT_BOTTOM_PADDING;
79
96
  }
80
97
 
81
- if (newHeight > PAGE_HEIGHT - 30 - FOOTER_HEIGHT - HEADER_HEIGHT) {
82
- const dif = Math.abs(PAGE_HEIGHT - incrHeight);
83
- ref.current.style.marginTop = '30px';
84
- _page += 1;
85
- _pages.push(_page);
86
-
87
- if (sectionsConfig[keys[i - 1]]) {
88
- const { ref: topRef } = sectionsConfig[keys[i - 1]];
89
- topRef.current.style.marginBottom = `${dif + HEADER_HEIGHT - 24}px`;
90
- incrHeight = height + 24 + HEADER_HEIGHT;
91
- // console.log('margin', dif);
92
- }
98
+ // If placing this section on the current page would exceed the usable content area,
99
+ // mark it to start on a new page.
100
+ if (currentPageContentHeight + spaceNeededForThisSection > USABLE_FLOW_HEIGHT_PER_PAGE) {
101
+ ref.current.style.pageBreakBefore = 'always';
102
+ currentPage++;
103
+ // Reset current page content height to just what this new section takes.
104
+ currentPageContentHeight = spaceNeededForThisSection;
93
105
  } else {
94
- incrHeight = newHeight + 24;
106
+ // This section fits on the current page.
107
+ currentPageContentHeight += spaceNeededForThisSection;
95
108
  }
96
- // console.groupEnd();
97
- })
98
- setPages(_pages);
109
+ });
110
+ setPagesCount(currentPage);
99
111
  }
100
- }, [sectionsConfig]);
112
+ }, [sectionsConfig, config.length]);
101
113
 
102
114
  useEffect(() => {
103
115
  doSizing();
@@ -128,70 +140,14 @@ export default function PdfView({
128
140
  );
129
141
  }, [config, onChangeHeight]);
130
142
 
131
- // <div className="daf-analysis">
132
- // <Header title={t('Dashboard Title')} />
133
-
134
- // <div className="content">
135
- // <div className="view-content">
136
- // <div className="daf-analysis-layout">
137
- // <div className='sections-cont w-pt'>
138
- // <section>
139
-
140
143
  return (
141
144
  <div className={contClassName} style={{ position: 'relative' }}>
142
- {renderDashboard()}
143
- {pages.map((page) => (
144
- <>
145
- <div
146
- style={{ top: ((page - 1) * PAGE_HEIGHT), width: '100%', height: HEADER_HEIGHT - 24, position: 'absolute', left: 0, zIndex: 1000000 }}
147
- key={`headers-${page}`}
148
- className="flex-row dashboard-header"
149
- >
150
- <div className="flex flex-column justify-center flex-1">
151
- <h2>{title}</h2>
152
- </div>
153
- <div className="flex flex-column justify-center">
154
- <img src={imgSrc} alt="logo" />
155
- </div>
156
- </div>
157
- <div
158
- style={{ top: (page * PAGE_HEIGHT) - FOOTER_HEIGHT, width: '100%', height: FOOTER_HEIGHT, position: 'absolute', left: 0, zIndex: 1000000 }}
159
- key={`footers-${page}`}
160
- className="dashboard-footer flex-row"
161
- >
162
- <div className="flex flex-column justify-center">
163
- <h5>{moment().format('DD MMM YYYY')}</h5>
164
- </div>
165
- <div className="flex flex-column justify-center">
166
- <div className="flex gap-2">
167
- <h5>
168
- User ID:
169
- {' '}
170
- <strong>{userId}</strong>
171
- </h5>
172
- <h5>
173
- Account ID:
174
- {' '}
175
- <strong>{accountId}</strong>
176
- </h5>
177
- <h5>
178
- Document ID:
179
- {' '}
180
- <strong>{documentId}</strong>
181
- </h5>
182
- <h5>
183
- Download ID:
184
- {' '}
185
- <strong>{downloadId}</strong>
186
- </h5>
187
- </div>
188
- </div>
189
- <div className="flex flex-column justify-center">
190
- <h5>{page}</h5>
191
- </div>
192
- </div>
193
- </>
194
- ))}
145
+ {/* Container for content, Puppeteer reads data-page-count from this */}
146
+ <div id="pdf-content-root" data-page-count={pagesCount}>
147
+ {renderDashboard()}
148
+ </div>
149
+ {/* The absolute positioned headers and footers are removed from here.
150
+ Puppeteer's headerTemplate and footerTemplate will now handle them. */}
195
151
  </div>
196
152
  );
197
153
  }
@@ -204,4 +160,5 @@ PdfView.propTypes = {
204
160
  userId: PropTypes.string,
205
161
  accountId: PropTypes.string,
206
162
  documentId: PropTypes.string,
207
- }
163
+ downloadId: PropTypes.string,
164
+ }