datastake-daf 0.6.424 → 0.6.425

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.
@@ -13303,11 +13303,9 @@ DAFFooter.propTypes = {
13303
13303
  };
13304
13304
 
13305
13305
  const PAGE_HEIGHT = 1587;
13306
+ // margin-top: 20, bottom: 20;
13306
13307
  const FOOTER_HEIGHT = 70;
13307
13308
  const HEADER_HEIGHT = 100;
13308
- const CONTENT_HEIGHT_PER_PAGE = 1200; // Maximum content height per page
13309
- const PAGE_TOP_MARGIN = 30; // Margin at the top of content on new pages
13310
-
13311
13309
  const Row = _ref => {
13312
13310
  let {
13313
13311
  widgets,
@@ -13357,68 +13355,48 @@ function PdfView(_ref2) {
13357
13355
  let _pages = [1];
13358
13356
  let _page = 1;
13359
13357
  if (keys.length === config.length) {
13360
- // Reset all margins and padding first
13358
+ let incrHeight = 0;
13361
13359
  keys.forEach(k => {
13362
13360
  const {
13363
13361
  ref
13364
13362
  } = sectionsConfig[k];
13365
- ref.current.style.marginTop = '0px';
13366
13363
  ref.current.style.marginBottom = '0px';
13367
- ref.current.style.paddingBottom = '0px';
13364
+ // ref.current.style.marginTop = '15px';
13368
13365
  });
13369
- let currentPageHeight = 0; // Track height accumulated on current page
13370
- const sectionGap = 24; // Gap between sections
13371
-
13372
13366
  keys.forEach((k, i) => {
13373
13367
  const {
13374
13368
  height,
13375
13369
  ref
13376
13370
  } = sectionsConfig[k];
13377
- const isFirstSection = i === 0;
13378
- const isLastSection = i === keys.length - 1;
13379
-
13380
- // First section on first page needs header space
13381
- if (isFirstSection) {
13371
+ if (i === 0) {
13382
13372
  ref.current.style.marginTop = "".concat(HEADER_HEIGHT, "px");
13383
- currentPageHeight = 0; // Content height tracking starts fresh
13373
+ incrHeight += HEADER_HEIGHT;
13384
13374
  }
13385
-
13386
- // Check if this section would exceed the page content limit
13387
- const willExceedPageLimit = currentPageHeight + height > CONTENT_HEIGHT_PER_PAGE;
13388
- if (willExceedPageLimit && !isFirstSection) {
13389
- // Need to break to a new page
13375
+ const newHeight = incrHeight + height;
13376
+ if (i === keys.length - 1) {
13377
+ ref.current.style.paddingBottom = '30px';
13378
+ }
13379
+ if (newHeight > PAGE_HEIGHT - 30 - FOOTER_HEIGHT - HEADER_HEIGHT) {
13380
+ const dif = Math.abs(PAGE_HEIGHT - incrHeight);
13381
+ ref.current.style.marginTop = '30px';
13390
13382
  _page += 1;
13391
13383
  _pages.push(_page);
13392
-
13393
- // Calculate remaining space on current page
13394
- const remainingSpace = PAGE_HEIGHT - currentPageHeight - HEADER_HEIGHT - FOOTER_HEIGHT;
13395
-
13396
- // Add margin to previous section to push current section to next page
13397
13384
  if (sectionsConfig[keys[i - 1]]) {
13398
13385
  const {
13399
- ref: prevRef
13386
+ ref: topRef
13400
13387
  } = sectionsConfig[keys[i - 1]];
13401
- prevRef.current.style.marginBottom = "".concat(remainingSpace, "px");
13388
+ topRef.current.style.marginBottom = "".concat(dif + HEADER_HEIGHT - 24, "px");
13389
+ incrHeight = height + 24 + HEADER_HEIGHT;
13390
+ // console.log('margin', dif);
13402
13391
  }
13403
-
13404
- // Position this section at the top of the new page
13405
- ref.current.style.marginTop = "".concat(HEADER_HEIGHT + PAGE_TOP_MARGIN, "px");
13406
-
13407
- // Reset page height counter for new page
13408
- currentPageHeight = height + sectionGap;
13409
13392
  } else {
13410
- // Section fits on current page
13411
- currentPageHeight += height + sectionGap;
13412
- }
13413
-
13414
- // Add padding to last section
13415
- if (isLastSection) {
13416
- ref.current.style.paddingBottom = "".concat(PAGE_TOP_MARGIN, "px");
13393
+ incrHeight = newHeight + 24;
13417
13394
  }
13395
+ // console.groupEnd();
13418
13396
  });
13419
13397
  setPages(_pages);
13420
13398
  }
13421
- }, [sectionsConfig, config.length]);
13399
+ }, [sectionsConfig]);
13422
13400
  React.useEffect(() => {
13423
13401
  doSizing();
13424
13402
  }, [doSizing]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.424",
3
+ "version": "0.6.425",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -189,15 +189,5 @@ export const Primary = {
189
189
  },
190
190
  ],
191
191
  },
192
- render: (args) => (
193
- <div style={{
194
- height: '100vh',
195
- overflowY: 'auto',
196
- background: "#f8f8f8",
197
- padding: "20px",
198
- }}
199
- >
200
- <PdfView {...args} />
201
- </div>
202
- ),
203
- };
192
+ }
193
+
@@ -4,10 +4,9 @@ import { useCallback, useEffect, useRef, useState } from "react";
4
4
  import { formatClassname } from "../../../../../helpers/ClassesHelper";
5
5
 
6
6
  const PAGE_HEIGHT = 1587;
7
+ // margin-top: 20, bottom: 20;
7
8
  const FOOTER_HEIGHT = 70;
8
9
  const HEADER_HEIGHT = 100;
9
- const CONTENT_HEIGHT_PER_PAGE = 1200; // Maximum content height per page
10
- const PAGE_TOP_MARGIN = 30; // Margin at the top of content on new pages
11
10
 
12
11
  const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
13
12
  const ref = useRef();
@@ -57,64 +56,48 @@ export default function PdfView({
57
56
  let _page = 1;
58
57
 
59
58
  if (keys.length === config.length) {
60
- // Reset all margins and padding first
59
+ let incrHeight = 0;
60
+
61
61
  keys.forEach(k => {
62
62
  const { ref } = sectionsConfig[k];
63
- ref.current.style.marginTop = '0px';
64
63
  ref.current.style.marginBottom = '0px';
65
- ref.current.style.paddingBottom = '0px';
66
- });
67
-
68
- let currentPageHeight = 0; // Track height accumulated on current page
69
- const sectionGap = 24; // Gap between sections
64
+ // ref.current.style.marginTop = '15px';
65
+ })
70
66
 
71
67
  keys.forEach((k, i) => {
72
68
  const { height, ref } = sectionsConfig[k];
73
- const isFirstSection = i === 0;
74
- const isLastSection = i === keys.length - 1;
75
69
 
76
- // First section on first page needs header space
77
- if (isFirstSection) {
70
+ if (i === 0) {
78
71
  ref.current.style.marginTop = `${HEADER_HEIGHT}px`;
79
- currentPageHeight = 0; // Content height tracking starts fresh
72
+ incrHeight += HEADER_HEIGHT;
80
73
  }
81
74
 
82
- // Check if this section would exceed the page content limit
83
- const willExceedPageLimit = currentPageHeight + height > CONTENT_HEIGHT_PER_PAGE;
75
+ const newHeight = incrHeight + height;
76
+
77
+ if (i === keys.length - 1) {
78
+ ref.current.style.paddingBottom = '30px';
79
+ }
84
80
 
85
- if (willExceedPageLimit && !isFirstSection) {
86
- // Need to break to a new page
81
+ if (newHeight > PAGE_HEIGHT - 30 - FOOTER_HEIGHT - HEADER_HEIGHT) {
82
+ const dif = Math.abs(PAGE_HEIGHT - incrHeight);
83
+ ref.current.style.marginTop = '30px';
87
84
  _page += 1;
88
85
  _pages.push(_page);
89
86
 
90
- // Calculate remaining space on current page
91
- const remainingSpace = PAGE_HEIGHT - currentPageHeight - HEADER_HEIGHT - FOOTER_HEIGHT;
92
-
93
- // Add margin to previous section to push current section to next page
94
87
  if (sectionsConfig[keys[i - 1]]) {
95
- const { ref: prevRef } = sectionsConfig[keys[i - 1]];
96
- prevRef.current.style.marginBottom = `${remainingSpace}px`;
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);
97
92
  }
98
-
99
- // Position this section at the top of the new page
100
- ref.current.style.marginTop = `${HEADER_HEIGHT + PAGE_TOP_MARGIN}px`;
101
-
102
- // Reset page height counter for new page
103
- currentPageHeight = height + sectionGap;
104
93
  } else {
105
- // Section fits on current page
106
- currentPageHeight += height + sectionGap;
107
- }
108
-
109
- // Add padding to last section
110
- if (isLastSection) {
111
- ref.current.style.paddingBottom = `${PAGE_TOP_MARGIN}px`;
94
+ incrHeight = newHeight + 24;
112
95
  }
113
- });
114
-
96
+ // console.groupEnd();
97
+ })
115
98
  setPages(_pages);
116
99
  }
117
- }, [sectionsConfig, config.length]);
100
+ }, [sectionsConfig]);
118
101
 
119
102
  useEffect(() => {
120
103
  doSizing();