datastake-daf 0.6.430 → 0.6.431
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
|
@@ -13302,10 +13302,11 @@ DAFFooter.propTypes = {
|
|
|
13302
13302
|
isViewMode: PropTypes__default["default"].bool
|
|
13303
13303
|
};
|
|
13304
13304
|
|
|
13305
|
-
const PAGE_HEIGHT =
|
|
13306
|
-
// margin-top: 20, bottom: 20;
|
|
13305
|
+
const PAGE_HEIGHT = 1200; // Full page height
|
|
13307
13306
|
const FOOTER_HEIGHT = 70;
|
|
13308
13307
|
const HEADER_HEIGHT = 100;
|
|
13308
|
+
const SECTION_GAP = 24; // Spacing between sections on the same page
|
|
13309
|
+
|
|
13309
13310
|
const Row = _ref => {
|
|
13310
13311
|
let {
|
|
13311
13312
|
widgets,
|
|
@@ -13351,55 +13352,64 @@ function PdfView(_ref2) {
|
|
|
13351
13352
|
const [sectionsConfig, setSectionsConfig] = React.useState({});
|
|
13352
13353
|
const [pages, setPages] = React.useState([1]);
|
|
13353
13354
|
const doSizing = React.useCallback(() => {
|
|
13354
|
-
const keys = Object.keys(sectionsConfig);
|
|
13355
|
-
|
|
13356
|
-
let
|
|
13355
|
+
const keys = Object.keys(sectionsConfig).sort((a, b) => Number(a) - Number(b));
|
|
13356
|
+
const pageContentHeight = PAGE_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT;
|
|
13357
|
+
let computedPages = [1];
|
|
13358
|
+
let currentPage = 1;
|
|
13359
|
+
let usedHeightOnPage = 0; // Height used within the current page's content area (excludes header/footer)
|
|
13360
|
+
|
|
13357
13361
|
if (keys.length === config.length) {
|
|
13358
|
-
|
|
13362
|
+
// Reset margins before recalculating
|
|
13359
13363
|
keys.forEach(k => {
|
|
13360
13364
|
const {
|
|
13361
13365
|
ref
|
|
13362
13366
|
} = sectionsConfig[k];
|
|
13363
|
-
ref.current
|
|
13364
|
-
|
|
13367
|
+
if (ref && ref.current) {
|
|
13368
|
+
ref.current.style.marginTop = '0px';
|
|
13369
|
+
ref.current.style.marginBottom = '0px';
|
|
13370
|
+
}
|
|
13365
13371
|
});
|
|
13366
13372
|
keys.forEach((k, i) => {
|
|
13367
13373
|
const {
|
|
13368
13374
|
height,
|
|
13369
13375
|
ref
|
|
13370
13376
|
} = sectionsConfig[k];
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
const
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
ref: topRef
|
|
13387
|
-
} = sectionsConfig[keys[i - 1]];
|
|
13388
|
-
console.log({
|
|
13389
|
-
dif
|
|
13390
|
-
});
|
|
13391
|
-
topRef.current.style.marginBottom = "".concat(250, "px");
|
|
13392
|
-
incrHeight = height + 24 + HEADER_HEIGHT;
|
|
13393
|
-
// console.log('margin', dif);
|
|
13377
|
+
const isFirstOnPage = usedHeightOnPage === 0;
|
|
13378
|
+
const gapAbove = isFirstOnPage ? 0 : SECTION_GAP;
|
|
13379
|
+
|
|
13380
|
+
// If adding this section would overflow the current page, move it to the next page
|
|
13381
|
+
if (usedHeightOnPage + gapAbove + height > pageContentHeight && i > 0) {
|
|
13382
|
+
const prevKey = keys[i - 1];
|
|
13383
|
+
const {
|
|
13384
|
+
ref: prevRef
|
|
13385
|
+
} = sectionsConfig[prevKey];
|
|
13386
|
+
const remainingOnPage = Math.max(0, pageContentHeight - usedHeightOnPage);
|
|
13387
|
+
|
|
13388
|
+
// Push the next section to start at the top of the next page (after the header)
|
|
13389
|
+
if (prevRef && prevRef.current) {
|
|
13390
|
+
// Only fill the remaining content area; the next section will add HEADER_HEIGHT as its top margin
|
|
13391
|
+
prevRef.current.style.marginBottom = "".concat(remainingOnPage, "px");
|
|
13394
13392
|
}
|
|
13393
|
+
|
|
13394
|
+
// Start new page
|
|
13395
|
+
currentPage += 1;
|
|
13396
|
+
computedPages.push(currentPage);
|
|
13397
|
+
usedHeightOnPage = 0;
|
|
13398
|
+
}
|
|
13399
|
+
|
|
13400
|
+
// Apply top margin: header spacing if first on page, otherwise standard section gap
|
|
13401
|
+
if (usedHeightOnPage === 0) {
|
|
13402
|
+
ref.current.style.marginTop = "".concat(HEADER_HEIGHT, "px");
|
|
13395
13403
|
} else {
|
|
13396
|
-
|
|
13404
|
+
ref.current.style.marginTop = "".concat(SECTION_GAP, "px");
|
|
13397
13405
|
}
|
|
13398
|
-
|
|
13406
|
+
|
|
13407
|
+
// Accumulate height used on the page
|
|
13408
|
+
usedHeightOnPage += (usedHeightOnPage === 0 ? 0 : SECTION_GAP) + height;
|
|
13399
13409
|
});
|
|
13400
|
-
setPages(
|
|
13410
|
+
setPages(computedPages);
|
|
13401
13411
|
}
|
|
13402
|
-
}, [sectionsConfig]);
|
|
13412
|
+
}, [sectionsConfig, config.length]);
|
|
13403
13413
|
React.useEffect(() => {
|
|
13404
13414
|
doSizing();
|
|
13405
13415
|
}, [doSizing]);
|
|
@@ -13438,7 +13448,8 @@ function PdfView(_ref2) {
|
|
|
13438
13448
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
13439
13449
|
className: contClassName,
|
|
13440
13450
|
style: {
|
|
13441
|
-
position: 'relative'
|
|
13451
|
+
position: 'relative',
|
|
13452
|
+
minHeight: pages.length * PAGE_HEIGHT
|
|
13442
13453
|
},
|
|
13443
13454
|
children: [renderDashboard(), pages.map(page => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
13444
13455
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
package/package.json
CHANGED
|
@@ -3,10 +3,10 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { formatClassname } from "../../../../../helpers/ClassesHelper";
|
|
5
5
|
|
|
6
|
-
const PAGE_HEIGHT =
|
|
7
|
-
// margin-top: 20, bottom: 20;
|
|
6
|
+
const PAGE_HEIGHT = 1200; // Full page height
|
|
8
7
|
const FOOTER_HEIGHT = 70;
|
|
9
8
|
const HEADER_HEIGHT = 100;
|
|
9
|
+
const SECTION_GAP = 24; // Spacing between sections on the same page
|
|
10
10
|
|
|
11
11
|
const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
|
|
12
12
|
const ref = useRef();
|
|
@@ -51,54 +51,60 @@ export default function PdfView({
|
|
|
51
51
|
const [pages, setPages] = useState([1]);
|
|
52
52
|
|
|
53
53
|
const doSizing = useCallback(() => {
|
|
54
|
-
const keys = Object.keys(sectionsConfig);
|
|
55
|
-
|
|
56
|
-
let _page = 1;
|
|
54
|
+
const keys = Object.keys(sectionsConfig).sort((a, b) => Number(a) - Number(b));
|
|
55
|
+
const pageContentHeight = PAGE_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT;
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
let computedPages = [1];
|
|
58
|
+
let currentPage = 1;
|
|
59
|
+
let usedHeightOnPage = 0; // Height used within the current page's content area (excludes header/footer)
|
|
60
60
|
|
|
61
|
+
if (keys.length === config.length) {
|
|
62
|
+
// Reset margins before recalculating
|
|
61
63
|
keys.forEach(k => {
|
|
62
64
|
const { ref } = sectionsConfig[k];
|
|
63
|
-
ref.current
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
if (ref && ref.current) {
|
|
66
|
+
ref.current.style.marginTop = '0px';
|
|
67
|
+
ref.current.style.marginBottom = '0px';
|
|
68
|
+
}
|
|
69
|
+
});
|
|
66
70
|
|
|
67
71
|
keys.forEach((k, i) => {
|
|
68
72
|
const { height, ref } = sectionsConfig[k];
|
|
73
|
+
const isFirstOnPage = usedHeightOnPage === 0;
|
|
74
|
+
const gapAbove = isFirstOnPage ? 0 : SECTION_GAP;
|
|
75
|
+
|
|
76
|
+
// If adding this section would overflow the current page, move it to the next page
|
|
77
|
+
if (usedHeightOnPage + gapAbove + height > pageContentHeight && i > 0) {
|
|
78
|
+
const prevKey = keys[i - 1];
|
|
79
|
+
const { ref: prevRef } = sectionsConfig[prevKey];
|
|
80
|
+
const remainingOnPage = Math.max(0, pageContentHeight - usedHeightOnPage);
|
|
81
|
+
|
|
82
|
+
// Push the next section to start at the top of the next page (after the header)
|
|
83
|
+
if (prevRef && prevRef.current) {
|
|
84
|
+
// Only fill the remaining content area; the next section will add HEADER_HEIGHT as its top margin
|
|
85
|
+
prevRef.current.style.marginBottom = `${remainingOnPage}px`;
|
|
86
|
+
}
|
|
69
87
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const newHeight = incrHeight + height;
|
|
76
|
-
|
|
77
|
-
if (i === keys.length - 1) {
|
|
78
|
-
ref.current.style.paddingBottom = '30px';
|
|
88
|
+
// Start new page
|
|
89
|
+
currentPage += 1;
|
|
90
|
+
computedPages.push(currentPage);
|
|
91
|
+
usedHeightOnPage = 0;
|
|
79
92
|
}
|
|
80
93
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
ref.current.style.marginTop =
|
|
84
|
-
_page += 1;
|
|
85
|
-
_pages.push(_page);
|
|
86
|
-
|
|
87
|
-
if (sectionsConfig[keys[i - 1]]) {
|
|
88
|
-
const { ref: topRef } = sectionsConfig[keys[i - 1]];
|
|
89
|
-
console.log({dif})
|
|
90
|
-
topRef.current.style.marginBottom = `${250}px`;
|
|
91
|
-
incrHeight = height + 24 + HEADER_HEIGHT;
|
|
92
|
-
// console.log('margin', dif);
|
|
93
|
-
}
|
|
94
|
+
// Apply top margin: header spacing if first on page, otherwise standard section gap
|
|
95
|
+
if (usedHeightOnPage === 0) {
|
|
96
|
+
ref.current.style.marginTop = `${HEADER_HEIGHT}px`;
|
|
94
97
|
} else {
|
|
95
|
-
|
|
98
|
+
ref.current.style.marginTop = `${SECTION_GAP}px`;
|
|
96
99
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
|
|
101
|
+
// Accumulate height used on the page
|
|
102
|
+
usedHeightOnPage += (usedHeightOnPage === 0 ? 0 : SECTION_GAP) + height;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
setPages(computedPages);
|
|
100
106
|
}
|
|
101
|
-
}, [sectionsConfig]);
|
|
107
|
+
}, [sectionsConfig, config.length]);
|
|
102
108
|
|
|
103
109
|
useEffect(() => {
|
|
104
110
|
doSizing();
|
|
@@ -139,7 +145,7 @@ export default function PdfView({
|
|
|
139
145
|
// <section>
|
|
140
146
|
|
|
141
147
|
return (
|
|
142
|
-
<div className={contClassName} style={{ position: 'relative' }}>
|
|
148
|
+
<div className={contClassName} style={{ position: 'relative', minHeight: pages.length * PAGE_HEIGHT }}>
|
|
143
149
|
{renderDashboard()}
|
|
144
150
|
{pages.map((page) => (
|
|
145
151
|
<>
|