datastake-daf 0.6.151 → 0.6.152

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.
@@ -12955,15 +12955,10 @@ DAFFooter.propTypes = {
12955
12955
  isViewMode: PropTypes__default["default"].bool
12956
12956
  };
12957
12957
 
12958
- const PAGE_HEIGHT = 1587; // Total height of a virtual PDF page
12958
+ const PAGE_HEIGHT = 1587;
12959
+ // margin-top: 20, bottom: 20;
12959
12960
  const FOOTER_HEIGHT = 70;
12960
12961
  const HEADER_HEIGHT = 100;
12961
- const ROW_SPACING = 24; // Spacing between content rows
12962
- const CONTENT_BOTTOM_PADDING = 30; // Extra padding at the very bottom of the last section of the document
12963
-
12964
- // This is the actual height available for the *flowing content* after Puppeteer
12965
- // applies its margins for the header and footer.
12966
- const USABLE_FLOW_HEIGHT_PER_PAGE = PAGE_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT;
12967
12962
  const Row = _ref => {
12968
12963
  let {
12969
12964
  widgets,
@@ -12978,14 +12973,8 @@ const Row = _ref => {
12978
12973
  setHeight(entry.contentRect.height);
12979
12974
  }
12980
12975
  });
12981
- if (ref.current) {
12982
- observer.observe(ref.current);
12983
- }
12984
- return () => {
12985
- if (ref.current) {
12986
- observer.disconnect();
12987
- }
12988
- };
12976
+ observer.observe(ref.current);
12977
+ return () => observer.disconnect();
12989
12978
  }, []);
12990
12979
  React.useEffect(() => {
12991
12980
  if (height) {
@@ -12994,7 +12983,7 @@ const Row = _ref => {
12994
12983
  ref
12995
12984
  });
12996
12985
  }
12997
- }, [height, i, onChangeHeight]);
12986
+ }, [height]);
12998
12987
  return /*#__PURE__*/jsxRuntime.jsx("section", {
12999
12988
  ref: ref,
13000
12989
  style: widgets.style,
@@ -13005,8 +12994,6 @@ function PdfView(_ref2) {
13005
12994
  let {
13006
12995
  config = [],
13007
12996
  customClassName,
13008
- // No longer needed to directly render title/imgSrc/etc within PdfView as Puppeteer handles it
13009
- // but kept in props for completeness if other parts of the app use them.
13010
12997
  title = 'Title',
13011
12998
  imgSrc = '',
13012
12999
  userId = 'IDD-0000000',
@@ -13015,57 +13002,54 @@ function PdfView(_ref2) {
13015
13002
  downloadId = 'DWL-00000123'
13016
13003
  } = _ref2;
13017
13004
  const [sectionsConfig, setSectionsConfig] = React.useState({});
13018
- const [pagesCount, setPagesCount] = React.useState(1); // Track total pages for Puppeteer footer
13019
-
13005
+ const [pages, setPages] = React.useState([1]);
13020
13006
  const doSizing = React.useCallback(() => {
13021
- // Ensure keys are processed in order
13022
- const keys = Object.keys(sectionsConfig).sort((a, b) => parseInt(a) - parseInt(b));
13007
+ const keys = Object.keys(sectionsConfig);
13008
+ let _pages = [1];
13009
+ let _page = 1;
13023
13010
  if (keys.length === config.length) {
13024
- let currentPageContentHeight = 0;
13025
- let currentPage = 1;
13026
-
13027
- // Reset all page-break styles before recalculating
13011
+ let incrHeight = 0;
13028
13012
  keys.forEach(k => {
13029
13013
  const {
13030
13014
  ref
13031
13015
  } = sectionsConfig[k];
13032
- if (ref.current) {
13033
- ref.current.style.pageBreakBefore = 'auto'; // Reset to default
13034
- ref.current.style.marginTop = '0px'; // Clear any previous dynamic margins
13035
- ref.current.style.paddingBottom = '0px'; // Clear any previous dynamic paddings
13036
- }
13016
+ ref.current.style.marginBottom = '0px';
13017
+ // ref.current.style.marginTop = '15px';
13037
13018
  });
13038
13019
  keys.forEach((k, i) => {
13039
13020
  const {
13040
13021
  height,
13041
13022
  ref
13042
13023
  } = sectionsConfig[k];
13043
- if (!ref.current) return;
13044
- let spaceNeededForThisSection = height;
13045
-
13046
- // Add ROW_SPACING *after* each section, except the very last one.
13047
- if (i < keys.length - 1) {
13048
- spaceNeededForThisSection += ROW_SPACING;
13049
- } else {
13050
- // Add CONTENT_BOTTOM_PADDING after the very last section of the document.
13051
- spaceNeededForThisSection += CONTENT_BOTTOM_PADDING;
13052
- }
13053
-
13054
- // If placing this section on the current page would exceed the usable content area,
13055
- // mark it to start on a new page.
13056
- if (currentPageContentHeight + spaceNeededForThisSection > USABLE_FLOW_HEIGHT_PER_PAGE) {
13057
- ref.current.style.pageBreakBefore = 'always';
13058
- currentPage++;
13059
- // Reset current page content height to just what this new section takes.
13060
- currentPageContentHeight = spaceNeededForThisSection;
13024
+ if (i === 0) {
13025
+ ref.current.style.marginTop = "".concat(HEADER_HEIGHT, "px");
13026
+ incrHeight += HEADER_HEIGHT;
13027
+ }
13028
+ const newHeight = incrHeight + height;
13029
+ if (i === keys.length - 1) {
13030
+ ref.current.style.paddingBottom = '30px';
13031
+ }
13032
+ if (newHeight > PAGE_HEIGHT - 30 - FOOTER_HEIGHT - HEADER_HEIGHT) {
13033
+ const dif = Math.abs(PAGE_HEIGHT - incrHeight);
13034
+ ref.current.style.marginTop = '30px';
13035
+ _page += 1;
13036
+ _pages.push(_page);
13037
+ if (sectionsConfig[keys[i - 1]]) {
13038
+ const {
13039
+ ref: topRef
13040
+ } = sectionsConfig[keys[i - 1]];
13041
+ topRef.current.style.marginBottom = "".concat(dif + HEADER_HEIGHT - 24, "px");
13042
+ incrHeight = height + 24 + HEADER_HEIGHT;
13043
+ // console.log('margin', dif);
13044
+ }
13061
13045
  } else {
13062
- // This section fits on the current page.
13063
- currentPageContentHeight += spaceNeededForThisSection;
13046
+ incrHeight = newHeight + 24;
13064
13047
  }
13048
+ // console.groupEnd();
13065
13049
  });
13066
- setPagesCount(currentPage);
13050
+ setPages(_pages);
13067
13051
  }
13068
- }, [sectionsConfig, config.length]);
13052
+ }, [sectionsConfig]);
13069
13053
  React.useEffect(() => {
13070
13054
  doSizing();
13071
13055
  }, [doSizing]);
@@ -13091,16 +13075,89 @@ function PdfView(_ref2) {
13091
13075
  })
13092
13076
  });
13093
13077
  }, [config, onChangeHeight]);
13094
- return /*#__PURE__*/jsxRuntime.jsx("div", {
13078
+
13079
+ // <div className="daf-analysis">
13080
+ // <Header title={t('Dashboard Title')} />
13081
+
13082
+ // <div className="content">
13083
+ // <div className="view-content">
13084
+ // <div className="daf-analysis-layout">
13085
+ // <div className='sections-cont w-pt'>
13086
+ // <section>
13087
+
13088
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
13095
13089
  className: contClassName,
13096
13090
  style: {
13097
13091
  position: 'relative'
13098
13092
  },
13099
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
13100
- id: "pdf-content-root",
13101
- "data-page-count": pagesCount,
13102
- children: renderDashboard()
13103
- })
13093
+ children: [renderDashboard(), pages.map(page => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
13094
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
13095
+ style: {
13096
+ top: (page - 1) * PAGE_HEIGHT,
13097
+ width: '100%',
13098
+ height: HEADER_HEIGHT - 24,
13099
+ position: 'absolute',
13100
+ left: 0,
13101
+ zIndex: 1000000
13102
+ },
13103
+ className: "flex-row dashboard-header",
13104
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
13105
+ className: "flex flex-column justify-center flex-1",
13106
+ children: /*#__PURE__*/jsxRuntime.jsx("h2", {
13107
+ children: title
13108
+ })
13109
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
13110
+ className: "flex flex-column justify-center",
13111
+ children: /*#__PURE__*/jsxRuntime.jsx("img", {
13112
+ src: imgSrc,
13113
+ alt: "logo"
13114
+ })
13115
+ })]
13116
+ }, "headers-".concat(page)), /*#__PURE__*/jsxRuntime.jsxs("div", {
13117
+ style: {
13118
+ top: page * PAGE_HEIGHT - FOOTER_HEIGHT,
13119
+ width: '100%',
13120
+ height: FOOTER_HEIGHT,
13121
+ position: 'absolute',
13122
+ left: 0,
13123
+ zIndex: 1000000
13124
+ },
13125
+ className: "dashboard-footer flex-row",
13126
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
13127
+ className: "flex flex-column justify-center",
13128
+ children: /*#__PURE__*/jsxRuntime.jsx("h5", {
13129
+ children: moment__default["default"]().format('DD MMM YYYY')
13130
+ })
13131
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
13132
+ className: "flex flex-column justify-center",
13133
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
13134
+ className: "flex gap-2",
13135
+ children: [/*#__PURE__*/jsxRuntime.jsxs("h5", {
13136
+ children: ["User ID:", ' ', /*#__PURE__*/jsxRuntime.jsx("strong", {
13137
+ children: userId
13138
+ })]
13139
+ }), /*#__PURE__*/jsxRuntime.jsxs("h5", {
13140
+ children: ["Account ID:", ' ', /*#__PURE__*/jsxRuntime.jsx("strong", {
13141
+ children: accountId
13142
+ })]
13143
+ }), /*#__PURE__*/jsxRuntime.jsxs("h5", {
13144
+ children: ["Document ID:", ' ', /*#__PURE__*/jsxRuntime.jsx("strong", {
13145
+ children: documentId
13146
+ })]
13147
+ }), /*#__PURE__*/jsxRuntime.jsxs("h5", {
13148
+ children: ["Download ID:", ' ', /*#__PURE__*/jsxRuntime.jsx("strong", {
13149
+ children: downloadId
13150
+ })]
13151
+ })]
13152
+ })
13153
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
13154
+ className: "flex flex-column justify-center",
13155
+ children: /*#__PURE__*/jsxRuntime.jsx("h5", {
13156
+ children: page
13157
+ })
13158
+ })]
13159
+ }, "footers-".concat(page))]
13160
+ }))]
13104
13161
  });
13105
13162
  }
13106
13163
  PdfView.propTypes = {
@@ -13110,8 +13167,7 @@ PdfView.propTypes = {
13110
13167
  imgSrc: PropTypes__default["default"].string,
13111
13168
  userId: PropTypes__default["default"].string,
13112
13169
  accountId: PropTypes__default["default"].string,
13113
- documentId: PropTypes__default["default"].string,
13114
- downloadId: PropTypes__default["default"].string
13170
+ documentId: PropTypes__default["default"].string
13115
13171
  };
13116
13172
 
13117
13173
  const ajaxSelectFieldData = async (value, config, getApiBaseUrl = () => {}, getAppHeader = () => {}, app, formValues = {}) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.151",
3
+ "version": "0.6.152",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -1,18 +1,12 @@
1
- // Dashboard/PdfView/index.jsx
2
1
  import moment from "moment";
3
2
  import PropTypes from 'prop-types';
4
3
  import { useCallback, useEffect, useRef, useState } from "react";
5
4
  import { formatClassname } from "../../../../../helpers/ClassesHelper";
6
5
 
7
- const PAGE_HEIGHT = 1587; // Total height of a virtual PDF page
6
+ const PAGE_HEIGHT = 1587;
7
+ // margin-top: 20, bottom: 20;
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;
16
10
 
17
11
  const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
18
12
  const ref = useRef();
@@ -25,22 +19,16 @@ const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
25
19
  }
26
20
  });
27
21
 
28
- if (ref.current) {
29
- observer.observe(ref.current);
30
- }
22
+ observer.observe(ref.current);
31
23
 
32
- return () => {
33
- if (ref.current) {
34
- observer.disconnect();
35
- }
36
- };
24
+ return () => observer.disconnect();
37
25
  }, []);
38
26
 
39
27
  useEffect(() => {
40
28
  if (height) {
41
29
  onChangeHeight(i, { height, ref });
42
30
  }
43
- }, [height, i, onChangeHeight]);
31
+ }, [height])
44
32
 
45
33
  return (
46
34
  <section ref={ref} style={widgets.style}>
@@ -52,8 +40,6 @@ const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
52
40
  export default function PdfView({
53
41
  config = [],
54
42
  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.
57
43
  title = 'Title',
58
44
  imgSrc = '',
59
45
  userId = 'IDD-0000000',
@@ -62,54 +48,56 @@ export default function PdfView({
62
48
  downloadId = 'DWL-00000123',
63
49
  }) {
64
50
  const [sectionsConfig, setSectionsConfig] = useState({});
65
- const [pagesCount, setPagesCount] = useState(1); // Track total pages for Puppeteer footer
51
+ const [pages, setPages] = useState([1]);
66
52
 
67
53
  const doSizing = useCallback(() => {
68
- // Ensure keys are processed in order
69
- const keys = Object.keys(sectionsConfig).sort((a,b) => parseInt(a) - parseInt(b));
54
+ const keys = Object.keys(sectionsConfig);
55
+ let _pages = [1];
56
+ let _page = 1;
57
+
70
58
  if (keys.length === config.length) {
71
- let currentPageContentHeight = 0;
72
- let currentPage = 1;
59
+ let incrHeight = 0;
73
60
 
74
- // Reset all page-break styles before recalculating
75
61
  keys.forEach(k => {
76
62
  const { ref } = sectionsConfig[k];
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
- });
63
+ ref.current.style.marginBottom = '0px';
64
+ // ref.current.style.marginTop = '15px';
65
+ })
83
66
 
84
67
  keys.forEach((k, i) => {
85
68
  const { height, ref } = sectionsConfig[k];
86
- if (!ref.current) return;
87
69
 
88
- let spaceNeededForThisSection = height;
70
+ if (i === 0) {
71
+ ref.current.style.marginTop = `${HEADER_HEIGHT}px`;
72
+ incrHeight += HEADER_HEIGHT;
73
+ }
89
74
 
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;
75
+ const newHeight = incrHeight + height;
76
+
77
+ if (i === keys.length - 1) {
78
+ ref.current.style.paddingBottom = '30px';
96
79
  }
97
80
 
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;
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
+ }
105
93
  } else {
106
- // This section fits on the current page.
107
- currentPageContentHeight += spaceNeededForThisSection;
94
+ incrHeight = newHeight + 24;
108
95
  }
109
- });
110
- setPagesCount(currentPage);
96
+ // console.groupEnd();
97
+ })
98
+ setPages(_pages);
111
99
  }
112
- }, [sectionsConfig, config.length]);
100
+ }, [sectionsConfig]);
113
101
 
114
102
  useEffect(() => {
115
103
  doSizing();
@@ -140,14 +128,70 @@ export default function PdfView({
140
128
  );
141
129
  }, [config, onChangeHeight]);
142
130
 
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
+
143
140
  return (
144
141
  <div className={contClassName} style={{ position: 'relative' }}>
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. */}
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
+ ))}
151
195
  </div>
152
196
  );
153
197
  }
@@ -160,5 +204,4 @@ PdfView.propTypes = {
160
204
  userId: PropTypes.string,
161
205
  accountId: PropTypes.string,
162
206
  documentId: PropTypes.string,
163
- downloadId: PropTypes.string,
164
- }
207
+ }