datastake-daf 0.6.411 → 0.6.413
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
|
@@ -13279,11 +13279,13 @@ const PAGE_HEIGHT = 1587;
|
|
|
13279
13279
|
const FOOTER_HEIGHT = 70;
|
|
13280
13280
|
const HEADER_HEIGHT = 100;
|
|
13281
13281
|
const SECTION_SPACING = 24; // Space between sections
|
|
13282
|
-
const
|
|
13283
|
-
const
|
|
13282
|
+
const FIRST_PAGE_TOP_PADDING = 30; // Padding after header on first page
|
|
13283
|
+
const NEW_PAGE_TOP_PADDING = 30; // Padding after header on new pages
|
|
13284
|
+
const LAST_SECTION_BOTTOM_PADDING = 30; // Padding after last section
|
|
13285
|
+
const PAGE_BOTTOM_MARGIN = 30; // Safety margin before footer
|
|
13284
13286
|
|
|
13285
|
-
// Available content height per page
|
|
13286
|
-
const AVAILABLE_HEIGHT = PAGE_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT -
|
|
13287
|
+
// Available content height per page (excluding header, footer, and safety margins)
|
|
13288
|
+
const AVAILABLE_HEIGHT = PAGE_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT - PAGE_BOTTOM_MARGIN;
|
|
13287
13289
|
const Row = _ref => {
|
|
13288
13290
|
let {
|
|
13289
13291
|
widgets,
|
|
@@ -13335,9 +13337,9 @@ function PdfView(_ref2) {
|
|
|
13335
13337
|
if (keys.length !== config.length) return;
|
|
13336
13338
|
let _pages = [1];
|
|
13337
13339
|
let currentPage = 1;
|
|
13338
|
-
let
|
|
13340
|
+
let currentPageContentHeight = 0; // Tracks content height on current page (excluding header)
|
|
13339
13341
|
|
|
13340
|
-
// Reset all
|
|
13342
|
+
// Reset all styles first
|
|
13341
13343
|
keys.forEach(k => {
|
|
13342
13344
|
const {
|
|
13343
13345
|
ref
|
|
@@ -13353,56 +13355,48 @@ function PdfView(_ref2) {
|
|
|
13353
13355
|
} = sectionsConfig[k];
|
|
13354
13356
|
const isFirstSection = i === 0;
|
|
13355
13357
|
const isLastSection = i === keys.length - 1;
|
|
13356
|
-
const
|
|
13358
|
+
const isFirstSectionOnPage = currentPageContentHeight === 0;
|
|
13357
13359
|
|
|
13358
|
-
//
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13360
|
+
// For first section of entire document
|
|
13361
|
+
if (isFirstSection) {
|
|
13362
|
+
ref.current.style.marginTop = "".concat(HEADER_HEIGHT + FIRST_PAGE_TOP_PADDING, "px");
|
|
13363
|
+
currentPageContentHeight = height + FIRST_PAGE_TOP_PADDING;
|
|
13364
|
+
if (isLastSection) {
|
|
13365
|
+
ref.current.style.paddingBottom = "".concat(LAST_SECTION_BOTTOM_PADDING, "px");
|
|
13366
|
+
currentPageContentHeight += LAST_SECTION_BOTTOM_PADDING;
|
|
13367
|
+
}
|
|
13368
|
+
return;
|
|
13364
13369
|
}
|
|
13365
13370
|
|
|
13366
|
-
//
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
// Add bottom margin to previous section to fill remaining space
|
|
13371
|
-
const remainingSpace = AVAILABLE_HEIGHT - currentPageHeight;
|
|
13372
|
-
const previousKey = keys[i - 1];
|
|
13373
|
-
if (sectionsConfig[previousKey]) {
|
|
13374
|
-
sectionsConfig[previousKey].ref.current.style.marginBottom = "".concat(remainingSpace + PAGE_BOTTOM_PADDING, "px");
|
|
13375
|
-
}
|
|
13371
|
+
// Calculate space needed for this section including spacing before it
|
|
13372
|
+
const spacingBefore = isFirstSectionOnPage ? NEW_PAGE_TOP_PADDING : SECTION_SPACING;
|
|
13373
|
+
const bottomPadding = isLastSection ? LAST_SECTION_BOTTOM_PADDING : 0;
|
|
13374
|
+
const totalSpaceNeeded = spacingBefore + height + bottomPadding;
|
|
13376
13375
|
|
|
13377
|
-
|
|
13376
|
+
// Check if we need to move to next page
|
|
13377
|
+
if (currentPageContentHeight + totalSpaceNeeded > AVAILABLE_HEIGHT) {
|
|
13378
|
+
// Move to new page
|
|
13378
13379
|
currentPage += 1;
|
|
13379
13380
|
_pages.push(currentPage);
|
|
13380
|
-
currentPageHeight = 0;
|
|
13381
13381
|
|
|
13382
|
-
//
|
|
13383
|
-
|
|
13382
|
+
// Calculate and apply bottom margin to fill previous page
|
|
13383
|
+
const usedSpace = currentPageContentHeight;
|
|
13384
|
+
const remainingSpace = AVAILABLE_HEIGHT - usedSpace;
|
|
13385
|
+
const previousKey = keys[i - 1];
|
|
13386
|
+
sectionsConfig[previousKey].ref.current.style.marginBottom = "".concat(remainingSpace + PAGE_BOTTOM_MARGIN, "px");
|
|
13384
13387
|
|
|
13385
|
-
//
|
|
13386
|
-
|
|
13388
|
+
// This section starts the new page
|
|
13389
|
+
ref.current.style.marginTop = "".concat(HEADER_HEIGHT + NEW_PAGE_TOP_PADDING, "px");
|
|
13390
|
+
currentPageContentHeight = height + NEW_PAGE_TOP_PADDING + bottomPadding;
|
|
13387
13391
|
} else {
|
|
13388
13392
|
// Section fits on current page
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
// First section gets header spacing
|
|
13392
|
-
ref.current.style.marginTop = "".concat(HEADER_HEIGHT + PAGE_TOP_PADDING, "px");
|
|
13393
|
-
} else if (isFirstOnPage) {
|
|
13394
|
-
// First section on a new page (after page break)
|
|
13395
|
-
ref.current.style.marginTop = "".concat(PAGE_TOP_PADDING, "px");
|
|
13396
|
-
} else {
|
|
13397
|
-
// Regular section spacing
|
|
13398
|
-
ref.current.style.marginTop = "".concat(SECTION_SPACING, "px");
|
|
13399
|
-
}
|
|
13400
|
-
currentPageHeight += sectionHeightWithSpacing;
|
|
13393
|
+
ref.current.style.marginTop = "".concat(spacingBefore, "px");
|
|
13394
|
+
currentPageContentHeight += totalSpaceNeeded;
|
|
13401
13395
|
}
|
|
13402
13396
|
|
|
13403
|
-
// Add padding to last section
|
|
13397
|
+
// Add bottom padding to last section
|
|
13404
13398
|
if (isLastSection) {
|
|
13405
|
-
ref.current.style.paddingBottom = "".concat(
|
|
13399
|
+
ref.current.style.paddingBottom = "".concat(LAST_SECTION_BOTTOM_PADDING, "px");
|
|
13406
13400
|
}
|
|
13407
13401
|
});
|
|
13408
13402
|
setPages(_pages);
|
package/package.json
CHANGED
|
@@ -7,11 +7,13 @@ const PAGE_HEIGHT = 1587;
|
|
|
7
7
|
const FOOTER_HEIGHT = 70;
|
|
8
8
|
const HEADER_HEIGHT = 100;
|
|
9
9
|
const SECTION_SPACING = 24; // Space between sections
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const FIRST_PAGE_TOP_PADDING = 30; // Padding after header on first page
|
|
11
|
+
const NEW_PAGE_TOP_PADDING = 30; // Padding after header on new pages
|
|
12
|
+
const LAST_SECTION_BOTTOM_PADDING = 30; // Padding after last section
|
|
13
|
+
const PAGE_BOTTOM_MARGIN = 30; // Safety margin before footer
|
|
12
14
|
|
|
13
|
-
// Available content height per page
|
|
14
|
-
const AVAILABLE_HEIGHT = PAGE_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT -
|
|
15
|
+
// Available content height per page (excluding header, footer, and safety margins)
|
|
16
|
+
const AVAILABLE_HEIGHT = PAGE_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT - PAGE_BOTTOM_MARGIN;
|
|
15
17
|
|
|
16
18
|
const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
|
|
17
19
|
const ref = useRef();
|
|
@@ -63,9 +65,9 @@ export default function PdfView({
|
|
|
63
65
|
|
|
64
66
|
let _pages = [1];
|
|
65
67
|
let currentPage = 1;
|
|
66
|
-
let
|
|
68
|
+
let currentPageContentHeight = 0; // Tracks content height on current page (excluding header)
|
|
67
69
|
|
|
68
|
-
// Reset all
|
|
70
|
+
// Reset all styles first
|
|
69
71
|
keys.forEach(k => {
|
|
70
72
|
const { ref } = sectionsConfig[k];
|
|
71
73
|
ref.current.style.marginTop = '0px';
|
|
@@ -77,57 +79,49 @@ export default function PdfView({
|
|
|
77
79
|
const { height, ref } = sectionsConfig[k];
|
|
78
80
|
const isFirstSection = i === 0;
|
|
79
81
|
const isLastSection = i === keys.length - 1;
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
// Calculate height needed for this section
|
|
83
|
-
let sectionHeightWithSpacing = height;
|
|
84
|
-
|
|
85
|
-
// Add spacing before section (except first on page)
|
|
86
|
-
if (!isFirstOnPage) {
|
|
87
|
-
sectionHeightWithSpacing += SECTION_SPACING;
|
|
88
|
-
}
|
|
82
|
+
const isFirstSectionOnPage = currentPageContentHeight === 0;
|
|
89
83
|
|
|
90
|
-
//
|
|
91
|
-
if (
|
|
92
|
-
|
|
84
|
+
// For first section of entire document
|
|
85
|
+
if (isFirstSection) {
|
|
86
|
+
ref.current.style.marginTop = `${HEADER_HEIGHT + FIRST_PAGE_TOP_PADDING}px`;
|
|
87
|
+
currentPageContentHeight = height + FIRST_PAGE_TOP_PADDING;
|
|
93
88
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (sectionsConfig[previousKey]) {
|
|
98
|
-
sectionsConfig[previousKey].ref.current.style.marginBottom = `${remainingSpace + PAGE_BOTTOM_PADDING}px`;
|
|
89
|
+
if (isLastSection) {
|
|
90
|
+
ref.current.style.paddingBottom = `${LAST_SECTION_BOTTOM_PADDING}px`;
|
|
91
|
+
currentPageContentHeight += LAST_SECTION_BOTTOM_PADDING;
|
|
99
92
|
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Calculate space needed for this section including spacing before it
|
|
97
|
+
const spacingBefore = isFirstSectionOnPage ? NEW_PAGE_TOP_PADDING : SECTION_SPACING;
|
|
98
|
+
const bottomPadding = isLastSection ? LAST_SECTION_BOTTOM_PADDING : 0;
|
|
99
|
+
const totalSpaceNeeded = spacingBefore + height + bottomPadding;
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
// Check if we need to move to next page
|
|
102
|
+
if (currentPageContentHeight + totalSpaceNeeded > AVAILABLE_HEIGHT) {
|
|
103
|
+
// Move to new page
|
|
102
104
|
currentPage += 1;
|
|
103
105
|
_pages.push(currentPage);
|
|
104
|
-
currentPageHeight = 0;
|
|
105
106
|
|
|
106
|
-
//
|
|
107
|
-
|
|
107
|
+
// Calculate and apply bottom margin to fill previous page
|
|
108
|
+
const usedSpace = currentPageContentHeight;
|
|
109
|
+
const remainingSpace = AVAILABLE_HEIGHT - usedSpace;
|
|
110
|
+
const previousKey = keys[i - 1];
|
|
111
|
+
sectionsConfig[previousKey].ref.current.style.marginBottom = `${remainingSpace + PAGE_BOTTOM_MARGIN}px`;
|
|
108
112
|
|
|
109
|
-
//
|
|
110
|
-
|
|
113
|
+
// This section starts the new page
|
|
114
|
+
ref.current.style.marginTop = `${HEADER_HEIGHT + NEW_PAGE_TOP_PADDING}px`;
|
|
115
|
+
currentPageContentHeight = height + NEW_PAGE_TOP_PADDING + bottomPadding;
|
|
111
116
|
} else {
|
|
112
117
|
// Section fits on current page
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// First section gets header spacing
|
|
116
|
-
ref.current.style.marginTop = `${HEADER_HEIGHT + PAGE_TOP_PADDING}px`;
|
|
117
|
-
} else if (isFirstOnPage) {
|
|
118
|
-
// First section on a new page (after page break)
|
|
119
|
-
ref.current.style.marginTop = `${PAGE_TOP_PADDING}px`;
|
|
120
|
-
} else {
|
|
121
|
-
// Regular section spacing
|
|
122
|
-
ref.current.style.marginTop = `${SECTION_SPACING}px`;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
currentPageHeight += sectionHeightWithSpacing;
|
|
118
|
+
ref.current.style.marginTop = `${spacingBefore}px`;
|
|
119
|
+
currentPageContentHeight += totalSpaceNeeded;
|
|
126
120
|
}
|
|
127
121
|
|
|
128
|
-
// Add padding to last section
|
|
122
|
+
// Add bottom padding to last section
|
|
129
123
|
if (isLastSection) {
|
|
130
|
-
ref.current.style.paddingBottom = `${
|
|
124
|
+
ref.current.style.paddingBottom = `${LAST_SECTION_BOTTOM_PADDING}px`;
|
|
131
125
|
}
|
|
132
126
|
});
|
|
133
127
|
|