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.
package/dist/components/index.js
CHANGED
|
@@ -13343,9 +13343,9 @@ function PdfView(_ref2) {
|
|
|
13343
13343
|
if (!allRefsReady) return;
|
|
13344
13344
|
let _pages = [1];
|
|
13345
13345
|
let currentPage = 1;
|
|
13346
|
-
let
|
|
13346
|
+
let accumulatedHeightOnPage = 0;
|
|
13347
13347
|
|
|
13348
|
-
// Reset all
|
|
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
|
-
//
|
|
13369
|
+
// For first section on first page
|
|
13370
13370
|
if (isFirst) {
|
|
13371
|
-
ref.current.style.
|
|
13372
|
-
|
|
13373
|
-
}
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
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
|
-
|
|
13379
|
-
|
|
13393
|
+
// Start new page
|
|
13394
|
+
currentPage += 1;
|
|
13395
|
+
_pages.push(currentPage);
|
|
13380
13396
|
|
|
13381
|
-
|
|
13382
|
-
|
|
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
|
-
|
|
13399
|
-
|
|
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
|
-
|
|
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
|
|
13451
|
+
height: HEADER_HEIGHT,
|
|
13456
13452
|
position: 'absolute',
|
|
13457
13453
|
left: 0,
|
|
13458
13454
|
zIndex: 1000000
|
package/package.json
CHANGED
|
@@ -71,15 +71,16 @@ export default function PdfView({
|
|
|
71
71
|
|
|
72
72
|
let _pages = [1];
|
|
73
73
|
let currentPage = 1;
|
|
74
|
-
let
|
|
74
|
+
let accumulatedHeightOnPage = 0;
|
|
75
75
|
|
|
76
|
-
// Reset all
|
|
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
|
-
//
|
|
94
|
+
// For first section on first page
|
|
95
95
|
if (isFirst) {
|
|
96
|
-
ref.current.style.
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
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
|
|
182
|
+
height: HEADER_HEIGHT,
|
|
185
183
|
position: 'absolute',
|
|
186
184
|
left: 0,
|
|
187
185
|
zIndex: 1000000
|