datastake-daf 0.6.417 → 0.6.418

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.
@@ -13343,9 +13343,9 @@ function PdfView(_ref2) {
13343
13343
  if (!allRefsReady) return;
13344
13344
  let _pages = [1];
13345
13345
  let currentPage = 1;
13346
- let remainingHeight = USABLE_HEIGHT;
13346
+ let accumulatedHeightOnPage = 0;
13347
13347
 
13348
- // Reset all margins first
13348
+ // Reset all styles first
13349
13349
  keys.forEach(k => {
13350
13350
  const {
13351
13351
  ref
@@ -13354,6 +13354,7 @@ function PdfView(_ref2) {
13354
13354
  ref.current.style.marginTop = '0px';
13355
13355
  ref.current.style.marginBottom = '0px';
13356
13356
  ref.current.style.paddingBottom = '0px';
13357
+ ref.current.style.paddingTop = '0px';
13357
13358
  }
13358
13359
  });
13359
13360
  keys.forEach((k, i) => {
@@ -13364,53 +13365,48 @@ function PdfView(_ref2) {
13364
13365
  if (!ref || !ref.current) return;
13365
13366
  const isFirst = i === 0;
13366
13367
  const isLast = i === keys.length - 1;
13367
- const startOfPageMargin = HEADER_HEIGHT + TOP_PADDING;
13368
13368
 
13369
- // First section of first page gets header spacing
13369
+ // For first section on first page
13370
13370
  if (isFirst) {
13371
- ref.current.style.marginTop = "".concat(startOfPageMargin, "px");
13372
- remainingHeight = USABLE_HEIGHT;
13373
- }
13374
-
13375
- // Calculate space needed for this section (including spacing if not first on page)
13376
- const sectionTotalHeight = height + (isFirst || remainingHeight === USABLE_HEIGHT ? 0 : SECTION_SPACING);
13371
+ ref.current.style.paddingTop = "".concat(HEADER_HEIGHT + TOP_PADDING, "px");
13372
+ accumulatedHeightOnPage = height;
13373
+ } else {
13374
+ // Calculate what the new accumulated height would be with this section
13375
+ const potentialAccumulated = accumulatedHeightOnPage + SECTION_SPACING + height;
13376
+
13377
+ // Check if we need a page break
13378
+ const needsPageBreak = potentialAccumulated > SPLIT_THRESHOLD || accumulatedHeightOnPage + SECTION_SPACING + height > USABLE_HEIGHT;
13379
+ if (needsPageBreak) {
13380
+ // Calculate remaining space and add it as margin to previous section
13381
+ const remainingSpace = USABLE_HEIGHT - accumulatedHeightOnPage;
13382
+ const previousKey = keys[i - 1];
13383
+ if (sectionsConfig[previousKey]) {
13384
+ const {
13385
+ ref: prevRef
13386
+ } = sectionsConfig[previousKey];
13387
+ if (prevRef && prevRef.current) {
13388
+ // Add margin bottom to fill the rest of the page + space for header
13389
+ prevRef.current.style.marginBottom = "".concat(remainingSpace + HEADER_HEIGHT + BOTTOM_PADDING, "px");
13390
+ }
13391
+ }
13377
13392
 
13378
- // Check if adding this section would exceed the remaining height
13379
- const wouldExceedPage = sectionTotalHeight > remainingHeight;
13393
+ // Start new page
13394
+ currentPage += 1;
13395
+ _pages.push(currentPage);
13380
13396
 
13381
- // Check if the accumulated height on current page + this section exceeds 65% threshold
13382
- const currentPageUsed = USABLE_HEIGHT - remainingHeight;
13383
- const totalWithThisSection = currentPageUsed + sectionTotalHeight;
13384
- const wouldExceedThreshold = totalWithThisSection > SPLIT_THRESHOLD;
13385
- if (!isFirst && (wouldExceedPage || wouldExceedThreshold)) {
13386
- // Move to next page
13387
- const previousKey = keys[i - 1];
13388
- if (sectionsConfig[previousKey]) {
13389
- const {
13390
- ref: prevRef
13391
- } = sectionsConfig[previousKey];
13392
- if (prevRef && prevRef.current) {
13393
- // Add margin to push to next page
13394
- prevRef.current.style.marginBottom = "".concat(remainingHeight * 0.4 + HEADER_HEIGHT, "px");
13395
- }
13396
- }
13397
+ // Add top padding for new page (header + top padding)
13398
+ ref.current.style.paddingTop = "".concat(HEADER_HEIGHT + TOP_PADDING, "px");
13397
13399
 
13398
- // Start new page - position after header and top padding
13399
- currentPage += 1;
13400
- _pages.push(currentPage);
13401
- ref.current.style.marginTop = "".concat(startOfPageMargin, "px");
13402
- remainingHeight = USABLE_HEIGHT - height;
13403
- } else {
13404
- // Section fits on current page
13405
- if (!isFirst && remainingHeight !== USABLE_HEIGHT) {
13406
- ref.current.style.marginTop = "".concat(SECTION_SPACING, "px");
13407
- remainingHeight -= height + SECTION_SPACING;
13400
+ // Reset accumulated height for new page
13401
+ accumulatedHeightOnPage = height;
13408
13402
  } else {
13409
- remainingHeight -= height;
13403
+ // Section fits on current page
13404
+ ref.current.style.marginTop = "".concat(SECTION_SPACING, "px");
13405
+ accumulatedHeightOnPage = potentialAccumulated;
13410
13406
  }
13411
13407
  }
13412
13408
 
13413
- // Add padding to last section
13409
+ // Add bottom padding to last section
13414
13410
  if (isLast) {
13415
13411
  ref.current.style.paddingBottom = "".concat(BOTTOM_PADDING, "px");
13416
13412
  }
@@ -13452,7 +13448,7 @@ function PdfView(_ref2) {
13452
13448
  style: {
13453
13449
  top: (page - 1) * PAGE_HEIGHT,
13454
13450
  width: '100%',
13455
- height: HEADER_HEIGHT - 24,
13451
+ height: HEADER_HEIGHT,
13456
13452
  position: 'absolute',
13457
13453
  left: 0,
13458
13454
  zIndex: 1000000
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.417",
3
+ "version": "0.6.418",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -71,15 +71,16 @@ export default function PdfView({
71
71
 
72
72
  let _pages = [1];
73
73
  let currentPage = 1;
74
- let remainingHeight = USABLE_HEIGHT;
74
+ let accumulatedHeightOnPage = 0;
75
75
 
76
- // Reset all margins first
76
+ // Reset all styles first
77
77
  keys.forEach(k => {
78
78
  const { ref } = sectionsConfig[k];
79
79
  if (ref.current) {
80
80
  ref.current.style.marginTop = '0px';
81
81
  ref.current.style.marginBottom = '0px';
82
82
  ref.current.style.paddingBottom = '0px';
83
+ ref.current.style.paddingTop = '0px';
83
84
  }
84
85
  });
85
86
 
@@ -89,52 +90,49 @@ export default function PdfView({
89
90
 
90
91
  const isFirst = i === 0;
91
92
  const isLast = i === keys.length - 1;
92
- const startOfPageMargin = HEADER_HEIGHT + TOP_PADDING;
93
93
 
94
- // First section of first page gets header spacing
94
+ // For first section on first page
95
95
  if (isFirst) {
96
- ref.current.style.marginTop = `${startOfPageMargin}px`;
97
- remainingHeight = USABLE_HEIGHT;
98
- }
99
-
100
- // Calculate space needed for this section (including spacing if not first on page)
101
- const sectionTotalHeight = height + (isFirst || remainingHeight === USABLE_HEIGHT ? 0 : SECTION_SPACING);
102
-
103
- // Check if adding this section would exceed the remaining height
104
- const wouldExceedPage = sectionTotalHeight > remainingHeight;
105
-
106
- // Check if the accumulated height on current page + this section exceeds 65% threshold
107
- const currentPageUsed = USABLE_HEIGHT - remainingHeight;
108
- const totalWithThisSection = currentPageUsed + sectionTotalHeight;
109
- const wouldExceedThreshold = totalWithThisSection > SPLIT_THRESHOLD;
110
-
111
- if (!isFirst && (wouldExceedPage || wouldExceedThreshold)) {
112
- // Move to next page
113
- const previousKey = keys[i - 1];
114
- if (sectionsConfig[previousKey]) {
115
- const { ref: prevRef } = sectionsConfig[previousKey];
116
- if (prevRef && prevRef.current) {
117
- // Add margin to push to next page
118
- prevRef.current.style.marginBottom = `${(remainingHeight * 0.4) + HEADER_HEIGHT}px`;
96
+ ref.current.style.paddingTop = `${HEADER_HEIGHT + TOP_PADDING}px`;
97
+ accumulatedHeightOnPage = height;
98
+ } else {
99
+ // Calculate what the new accumulated height would be with this section
100
+ const potentialAccumulated = accumulatedHeightOnPage + SECTION_SPACING + height;
101
+
102
+ // Check if we need a page break
103
+ const needsPageBreak = potentialAccumulated > SPLIT_THRESHOLD ||
104
+ (accumulatedHeightOnPage + SECTION_SPACING + height) > USABLE_HEIGHT;
105
+
106
+ if (needsPageBreak) {
107
+ // Calculate remaining space and add it as margin to previous section
108
+ const remainingSpace = USABLE_HEIGHT - accumulatedHeightOnPage;
109
+ const previousKey = keys[i - 1];
110
+
111
+ if (sectionsConfig[previousKey]) {
112
+ const { ref: prevRef } = sectionsConfig[previousKey];
113
+ if (prevRef && prevRef.current) {
114
+ // Add margin bottom to fill the rest of the page + space for header
115
+ prevRef.current.style.marginBottom = `${remainingSpace + HEADER_HEIGHT + BOTTOM_PADDING}px`;
116
+ }
119
117
  }
120
- }
121
118
 
122
- // Start new page - position after header and top padding
123
- currentPage += 1;
124
- _pages.push(currentPage);
125
- ref.current.style.marginTop = `${startOfPageMargin}px`;
126
- remainingHeight = USABLE_HEIGHT - height;
127
- } else {
128
- // Section fits on current page
129
- if (!isFirst && remainingHeight !== USABLE_HEIGHT) {
130
- ref.current.style.marginTop = `${SECTION_SPACING}px`;
131
- remainingHeight -= (height + SECTION_SPACING);
119
+ // Start new page
120
+ currentPage += 1;
121
+ _pages.push(currentPage);
122
+
123
+ // Add top padding for new page (header + top padding)
124
+ ref.current.style.paddingTop = `${HEADER_HEIGHT + TOP_PADDING}px`;
125
+
126
+ // Reset accumulated height for new page
127
+ accumulatedHeightOnPage = height;
132
128
  } else {
133
- remainingHeight -= height;
129
+ // Section fits on current page
130
+ ref.current.style.marginTop = `${SECTION_SPACING}px`;
131
+ accumulatedHeightOnPage = potentialAccumulated;
134
132
  }
135
133
  }
136
134
 
137
- // Add padding to last section
135
+ // Add bottom padding to last section
138
136
  if (isLast) {
139
137
  ref.current.style.paddingBottom = `${BOTTOM_PADDING}px`;
140
138
  }
@@ -181,7 +179,7 @@ export default function PdfView({
181
179
  style={{
182
180
  top: ((page - 1) * PAGE_HEIGHT),
183
181
  width: '100%',
184
- height: HEADER_HEIGHT - 24,
182
+ height: HEADER_HEIGHT,
185
183
  position: 'absolute',
186
184
  left: 0,
187
185
  zIndex: 1000000