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