datastake-daf 0.6.259 → 0.6.261
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
|
@@ -15460,9 +15460,9 @@ const PdfForm = _ref3 => {
|
|
|
15460
15460
|
debugEnvironment();
|
|
15461
15461
|
}
|
|
15462
15462
|
|
|
15463
|
-
//
|
|
15464
|
-
const baseHeight = isPuppeteer ?
|
|
15465
|
-
const indentHeight = level * (isPuppeteer ?
|
|
15463
|
+
// More accurate base heights that align better with PdfView's ResizeObserver measurements
|
|
15464
|
+
const baseHeight = isPuppeteer ? 48 : 38; // More accurate base heights to match actual rendering
|
|
15465
|
+
const indentHeight = level * (isPuppeteer ? 4 : 3.5); // More accurate indent space
|
|
15466
15466
|
let totalHeight = baseHeight + indentHeight;
|
|
15467
15467
|
|
|
15468
15468
|
// Reasonable type-based adjustments based on actual rendered heights
|
|
@@ -15478,20 +15478,23 @@ const PdfForm = _ref3 => {
|
|
|
15478
15478
|
totalHeight += isPuppeteer ? 50 : 40; // Ajax content with loading states
|
|
15479
15479
|
}
|
|
15480
15480
|
|
|
15481
|
-
// More accurate content height estimation
|
|
15481
|
+
// More accurate content height estimation that better matches actual DOM measurements
|
|
15482
15482
|
if (value && typeof value === 'string') {
|
|
15483
15483
|
const cleanValue = value.trim();
|
|
15484
|
-
if (cleanValue.length >
|
|
15485
|
-
// Long text:
|
|
15486
|
-
const estimatedLines = Math.ceil(cleanValue.length /
|
|
15487
|
-
const lineHeight = isPuppeteer ?
|
|
15484
|
+
if (cleanValue.length > 150) {
|
|
15485
|
+
// Long text: be more generous with line estimates
|
|
15486
|
+
const estimatedLines = Math.ceil(cleanValue.length / 45); // Shorter assumed line length
|
|
15487
|
+
const lineHeight = isPuppeteer ? 20 : 18; // Slightly taller line height
|
|
15488
15488
|
totalHeight += estimatedLines * lineHeight;
|
|
15489
|
-
} else if (cleanValue.length >
|
|
15490
|
-
// Medium text: likely spans
|
|
15491
|
-
totalHeight += isPuppeteer ?
|
|
15489
|
+
} else if (cleanValue.length > 60) {
|
|
15490
|
+
// Medium text: likely spans 2-3 lines
|
|
15491
|
+
totalHeight += isPuppeteer ? 35 : 28;
|
|
15492
|
+
} else if (cleanValue.length > 15) {
|
|
15493
|
+
// Short-medium text: single to double line
|
|
15494
|
+
totalHeight += isPuppeteer ? 18 : 14;
|
|
15492
15495
|
} else if (cleanValue.length > 0) {
|
|
15493
|
-
//
|
|
15494
|
-
totalHeight += isPuppeteer ?
|
|
15496
|
+
// Very short text: single line with padding
|
|
15497
|
+
totalHeight += isPuppeteer ? 12 : 10;
|
|
15495
15498
|
}
|
|
15496
15499
|
}
|
|
15497
15500
|
|
|
@@ -15517,8 +15520,8 @@ const PdfForm = _ref3 => {
|
|
|
15517
15520
|
childrenHeight += estimateTreeNodeHeight(childKey, childConfig, childValue, level + 1);
|
|
15518
15521
|
});
|
|
15519
15522
|
|
|
15520
|
-
//
|
|
15521
|
-
totalHeight += childrenHeight * (isPuppeteer ? 1.
|
|
15523
|
+
// More accurate multiplier that accounts for spacing and margins in actual DOM
|
|
15524
|
+
totalHeight += childrenHeight * (isPuppeteer ? 1.25 : 1.15);
|
|
15522
15525
|
}
|
|
15523
15526
|
|
|
15524
15527
|
// Handle array/repeated content with accurate estimates
|
|
@@ -15540,9 +15543,12 @@ const PdfForm = _ref3 => {
|
|
|
15540
15543
|
const createHeightConstrainedSections = (sectionKey, section) => {
|
|
15541
15544
|
const isPuppeteer = isPuppeteerEnvironment();
|
|
15542
15545
|
|
|
15543
|
-
// Align
|
|
15544
|
-
|
|
15545
|
-
|
|
15546
|
+
// Align with PdfView but use a more conservative limit to prevent large margin calculations
|
|
15547
|
+
// PdfView uses PAGE_HEIGHT - 30 - FOOTER_HEIGHT - HEADER_HEIGHT = 1387px
|
|
15548
|
+
// We'll use 85% of that to ensure sections fit comfortably and don't trigger large margins
|
|
15549
|
+
const PDFVIEW_MAX_HEIGHT = PAGE_HEIGHT - 30 - FOOTER_HEIGHT - HEADER_HEIGHT; // 1387px
|
|
15550
|
+
const MAX_SECTION_HEIGHT = Math.floor(PDFVIEW_MAX_HEIGHT * 0.85); // ~1179px - more conservative
|
|
15551
|
+
const MIN_SECTION_HEIGHT = 300; // Slightly larger minimum to ensure meaningful content
|
|
15546
15552
|
const subSections = [];
|
|
15547
15553
|
|
|
15548
15554
|
// Get all top-level items in the section with detailed analysis
|
|
@@ -15562,13 +15568,23 @@ const PdfForm = _ref3 => {
|
|
|
15562
15568
|
// If the entire section fits, don't split it
|
|
15563
15569
|
const totalSectionHeight = topLevelItems.reduce((sum, item) => sum + item.estimatedHeight, 0);
|
|
15564
15570
|
|
|
15565
|
-
// Add
|
|
15566
|
-
if (typeof window !== 'undefined' && window.console
|
|
15571
|
+
// Add detailed debugging for height calculations
|
|
15572
|
+
if (typeof window !== 'undefined' && window.console) {
|
|
15567
15573
|
console.log("Section ".concat(sectionKey, ":"), {
|
|
15568
|
-
|
|
15569
|
-
|
|
15574
|
+
totalEstimatedHeight: totalSectionHeight,
|
|
15575
|
+
maxAllowedHeight: MAX_SECTION_HEIGHT,
|
|
15576
|
+
pdfViewMaxHeight: PDFVIEW_MAX_HEIGHT,
|
|
15577
|
+
utilizationPercentage: Math.round(totalSectionHeight / MAX_SECTION_HEIGHT * 100) + '%',
|
|
15570
15578
|
shouldSplit: totalSectionHeight > MAX_SECTION_HEIGHT,
|
|
15571
|
-
itemCount: topLevelItems.length
|
|
15579
|
+
itemCount: topLevelItems.length,
|
|
15580
|
+
itemSummary: topLevelItems.map(item => {
|
|
15581
|
+
var _item$config;
|
|
15582
|
+
return {
|
|
15583
|
+
key: item.key,
|
|
15584
|
+
height: item.estimatedHeight,
|
|
15585
|
+
type: (_item$config = item.config) === null || _item$config === void 0 ? void 0 : _item$config.type
|
|
15586
|
+
};
|
|
15587
|
+
})
|
|
15572
15588
|
});
|
|
15573
15589
|
}
|
|
15574
15590
|
if (totalSectionHeight <= MAX_SECTION_HEIGHT) {
|
|
@@ -15586,7 +15602,7 @@ const PdfForm = _ref3 => {
|
|
|
15586
15602
|
delete currentSubSection[key];
|
|
15587
15603
|
}
|
|
15588
15604
|
});
|
|
15589
|
-
let currentHeight = isPuppeteer ?
|
|
15605
|
+
let currentHeight = isPuppeteer ? 120 : 100; // More accurate base height including section headers and margins
|
|
15590
15606
|
let subSectionIndex = 0;
|
|
15591
15607
|
topLevelItems.forEach((item, index) => {
|
|
15592
15608
|
const {
|
|
@@ -15596,11 +15612,11 @@ const PdfForm = _ref3 => {
|
|
|
15596
15612
|
canSplit
|
|
15597
15613
|
} = item;
|
|
15598
15614
|
|
|
15599
|
-
// More
|
|
15600
|
-
const SPLIT_THRESHOLD = 0.
|
|
15615
|
+
// More conservative splitting thresholds to work better with PdfView
|
|
15616
|
+
const SPLIT_THRESHOLD = 0.65; // Split if item takes up more than 65% of available space
|
|
15601
15617
|
|
|
15602
|
-
// If a single item is
|
|
15603
|
-
if (estimatedHeight > MAX_SECTION_HEIGHT * SPLIT_THRESHOLD && canSplit && estimatedHeight > MIN_SECTION_HEIGHT *
|
|
15618
|
+
// If a single item is large and can be split, consider splitting it
|
|
15619
|
+
if (estimatedHeight > MAX_SECTION_HEIGHT * SPLIT_THRESHOLD && canSplit && estimatedHeight > MIN_SECTION_HEIGHT * 1.5) {
|
|
15604
15620
|
// Split this large item into smaller parts
|
|
15605
15621
|
const childSplits = splitLargeItem(key, config, data === null || data === void 0 ? void 0 : data[key], MAX_SECTION_HEIGHT * 0.6);
|
|
15606
15622
|
childSplits.forEach((splitItem, splitIndex) => {
|
|
@@ -15620,7 +15636,7 @@ const PdfForm = _ref3 => {
|
|
|
15620
15636
|
position: section.position + subSectionIndex + 1,
|
|
15621
15637
|
subTitle: section.subTitle
|
|
15622
15638
|
};
|
|
15623
|
-
currentHeight = isPuppeteer ?
|
|
15639
|
+
currentHeight = isPuppeteer ? 120 : 100;
|
|
15624
15640
|
subSectionIndex++;
|
|
15625
15641
|
}
|
|
15626
15642
|
|
|
@@ -15632,7 +15648,11 @@ const PdfForm = _ref3 => {
|
|
|
15632
15648
|
// Regular processing for items that fit or shouldn't be split
|
|
15633
15649
|
// More lenient threshold - only split if really necessary and ensures meaningful sections
|
|
15634
15650
|
const remainingItems = topLevelItems.length - index - 1;
|
|
15635
|
-
const shouldSplitSection = currentHeight + estimatedHeight > MAX_SECTION_HEIGHT && currentHeight > MIN_SECTION_HEIGHT
|
|
15651
|
+
const shouldSplitSection = currentHeight + estimatedHeight > MAX_SECTION_HEIGHT && currentHeight > MIN_SECTION_HEIGHT * 0.8 &&
|
|
15652
|
+
// More lenient minimum
|
|
15653
|
+
Object.keys(currentSubSection).length > 3 &&
|
|
15654
|
+
// Fewer items required
|
|
15655
|
+
remainingItems > 0; // Ensure there are items left for next section
|
|
15636
15656
|
|
|
15637
15657
|
if (shouldSplitSection) {
|
|
15638
15658
|
// Save current sub-section
|
|
@@ -15649,7 +15669,7 @@ const PdfForm = _ref3 => {
|
|
|
15649
15669
|
position: section.position + subSectionIndex + 1,
|
|
15650
15670
|
subTitle: section.subTitle
|
|
15651
15671
|
};
|
|
15652
|
-
currentHeight = isPuppeteer ?
|
|
15672
|
+
currentHeight = isPuppeteer ? 120 : 100;
|
|
15653
15673
|
subSectionIndex++;
|
|
15654
15674
|
}
|
|
15655
15675
|
|
|
@@ -15670,10 +15690,12 @@ const PdfForm = _ref3 => {
|
|
|
15670
15690
|
subSections.push(finalSubSection);
|
|
15671
15691
|
|
|
15672
15692
|
// Debug final section creation
|
|
15673
|
-
if (typeof window !== 'undefined' && window.console
|
|
15693
|
+
if (typeof window !== 'undefined' && window.console) {
|
|
15674
15694
|
console.log("Final section ".concat(finalSubSection.key, ":"), {
|
|
15675
15695
|
itemCount: finalSectionKeys.length,
|
|
15676
|
-
estimatedHeight: currentHeight
|
|
15696
|
+
estimatedHeight: currentHeight,
|
|
15697
|
+
utilizationPercentage: Math.round(currentHeight / MAX_SECTION_HEIGHT * 100) + '%',
|
|
15698
|
+
isWithinLimits: currentHeight <= MAX_SECTION_HEIGHT
|
|
15677
15699
|
});
|
|
15678
15700
|
}
|
|
15679
15701
|
}
|
|
@@ -15716,7 +15738,8 @@ const PdfForm = _ref3 => {
|
|
|
15716
15738
|
|
|
15717
15739
|
// If total children height is not that large, don't split
|
|
15718
15740
|
const totalChildrenHeight = childItems.reduce((sum, child) => sum + child.estimatedHeight, 0);
|
|
15719
|
-
if (totalChildrenHeight <= maxHeight * 1.
|
|
15741
|
+
if (totalChildrenHeight <= maxHeight * 1.1) {
|
|
15742
|
+
// More conservative threshold
|
|
15720
15743
|
return [{
|
|
15721
15744
|
key: parentKey,
|
|
15722
15745
|
config: parentConfig,
|
|
@@ -15729,7 +15752,7 @@ const PdfForm = _ref3 => {
|
|
|
15729
15752
|
config: _objectSpread2(_objectSpread2({}, parentConfig), {}, {
|
|
15730
15753
|
inputs: {}
|
|
15731
15754
|
}),
|
|
15732
|
-
estimatedHeight:
|
|
15755
|
+
estimatedHeight: 60 // More accurate base height for parent structure with styling
|
|
15733
15756
|
};
|
|
15734
15757
|
let splitIndex = 0;
|
|
15735
15758
|
const minItemsPerSplit = 2; // Ensure at least 2 items per split to avoid tiny sections
|
|
@@ -15757,7 +15780,7 @@ const PdfForm = _ref3 => {
|
|
|
15757
15780
|
// Keep original label without part indicator
|
|
15758
15781
|
inputs: {}
|
|
15759
15782
|
}),
|
|
15760
|
-
estimatedHeight:
|
|
15783
|
+
estimatedHeight: 60
|
|
15761
15784
|
};
|
|
15762
15785
|
}
|
|
15763
15786
|
|
|
@@ -15940,6 +15963,7 @@ function Widget(_ref) {
|
|
|
15940
15963
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
15941
15964
|
className: "flex flex-row widget-header-items",
|
|
15942
15965
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
15966
|
+
className: "content-wrapper",
|
|
15943
15967
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
15944
15968
|
className: "title cont",
|
|
15945
15969
|
children: /*#__PURE__*/jsxRuntime.jsx("h1", {
|
package/package.json
CHANGED
|
@@ -133,6 +133,18 @@
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
.content-wrapper {
|
|
137
|
+
display: flex;
|
|
138
|
+
flex-direction: column;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.content-wrapper h1,
|
|
143
|
+
.content-wrapper .description {
|
|
144
|
+
text-align: start;
|
|
145
|
+
margin: 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
136
148
|
.widget-body {
|
|
137
149
|
flex: 1;
|
|
138
150
|
padding: 0px var(--size-lg) var(--size-lg) var(--size-lg);
|
|
@@ -81,12 +81,12 @@ export default function Widget({
|
|
|
81
81
|
{!noTitle && (
|
|
82
82
|
<div className="widget-header flex-column">
|
|
83
83
|
<div className="flex flex-row widget-header-items">
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
</div>
|
|
88
|
-
{description && <Paragraph className="description">{description}</Paragraph>}
|
|
84
|
+
<div className="content-wrapper">
|
|
85
|
+
<div className="title cont">
|
|
86
|
+
<h1>{title}</h1>
|
|
89
87
|
</div>
|
|
88
|
+
{description && <Paragraph className="description">{description}</Paragraph>}
|
|
89
|
+
</div>
|
|
90
90
|
|
|
91
91
|
{tooltip && (
|
|
92
92
|
<div className="cont icon-cont">
|
|
@@ -565,9 +565,9 @@ const PdfForm = ({
|
|
|
565
565
|
debugEnvironment();
|
|
566
566
|
}
|
|
567
567
|
|
|
568
|
-
//
|
|
569
|
-
const baseHeight = isPuppeteer ?
|
|
570
|
-
const indentHeight = level * (isPuppeteer ?
|
|
568
|
+
// More accurate base heights that align better with PdfView's ResizeObserver measurements
|
|
569
|
+
const baseHeight = isPuppeteer ? 48 : 38; // More accurate base heights to match actual rendering
|
|
570
|
+
const indentHeight = level * (isPuppeteer ? 4 : 3.5); // More accurate indent space
|
|
571
571
|
let totalHeight = baseHeight + indentHeight;
|
|
572
572
|
|
|
573
573
|
// Reasonable type-based adjustments based on actual rendered heights
|
|
@@ -583,20 +583,23 @@ const PdfForm = ({
|
|
|
583
583
|
totalHeight += isPuppeteer ? 50 : 40; // Ajax content with loading states
|
|
584
584
|
}
|
|
585
585
|
|
|
586
|
-
// More accurate content height estimation
|
|
586
|
+
// More accurate content height estimation that better matches actual DOM measurements
|
|
587
587
|
if (value && typeof value === 'string') {
|
|
588
588
|
const cleanValue = value.trim();
|
|
589
|
-
if (cleanValue.length >
|
|
590
|
-
// Long text:
|
|
591
|
-
const estimatedLines = Math.ceil(cleanValue.length /
|
|
592
|
-
const lineHeight = isPuppeteer ?
|
|
589
|
+
if (cleanValue.length > 150) {
|
|
590
|
+
// Long text: be more generous with line estimates
|
|
591
|
+
const estimatedLines = Math.ceil(cleanValue.length / 45); // Shorter assumed line length
|
|
592
|
+
const lineHeight = isPuppeteer ? 20 : 18; // Slightly taller line height
|
|
593
593
|
totalHeight += estimatedLines * lineHeight;
|
|
594
|
-
} else if (cleanValue.length >
|
|
595
|
-
// Medium text: likely spans
|
|
596
|
-
totalHeight += isPuppeteer ?
|
|
594
|
+
} else if (cleanValue.length > 60) {
|
|
595
|
+
// Medium text: likely spans 2-3 lines
|
|
596
|
+
totalHeight += isPuppeteer ? 35 : 28;
|
|
597
|
+
} else if (cleanValue.length > 15) {
|
|
598
|
+
// Short-medium text: single to double line
|
|
599
|
+
totalHeight += isPuppeteer ? 18 : 14;
|
|
597
600
|
} else if (cleanValue.length > 0) {
|
|
598
|
-
//
|
|
599
|
-
totalHeight += isPuppeteer ?
|
|
601
|
+
// Very short text: single line with padding
|
|
602
|
+
totalHeight += isPuppeteer ? 12 : 10;
|
|
600
603
|
}
|
|
601
604
|
}
|
|
602
605
|
|
|
@@ -624,8 +627,8 @@ const PdfForm = ({
|
|
|
624
627
|
childrenHeight += estimateTreeNodeHeight(childKey, childConfig, childValue, level + 1);
|
|
625
628
|
});
|
|
626
629
|
|
|
627
|
-
//
|
|
628
|
-
totalHeight += childrenHeight * (isPuppeteer ? 1.
|
|
630
|
+
// More accurate multiplier that accounts for spacing and margins in actual DOM
|
|
631
|
+
totalHeight += childrenHeight * (isPuppeteer ? 1.25 : 1.15);
|
|
629
632
|
}
|
|
630
633
|
|
|
631
634
|
// Handle array/repeated content with accurate estimates
|
|
@@ -648,9 +651,12 @@ const PdfForm = ({
|
|
|
648
651
|
const createHeightConstrainedSections = (sectionKey, section) => {
|
|
649
652
|
const isPuppeteer = isPuppeteerEnvironment();
|
|
650
653
|
|
|
651
|
-
// Align
|
|
652
|
-
|
|
653
|
-
|
|
654
|
+
// Align with PdfView but use a more conservative limit to prevent large margin calculations
|
|
655
|
+
// PdfView uses PAGE_HEIGHT - 30 - FOOTER_HEIGHT - HEADER_HEIGHT = 1387px
|
|
656
|
+
// We'll use 85% of that to ensure sections fit comfortably and don't trigger large margins
|
|
657
|
+
const PDFVIEW_MAX_HEIGHT = PAGE_HEIGHT - 30 - FOOTER_HEIGHT - HEADER_HEIGHT; // 1387px
|
|
658
|
+
const MAX_SECTION_HEIGHT = Math.floor(PDFVIEW_MAX_HEIGHT * 0.85); // ~1179px - more conservative
|
|
659
|
+
const MIN_SECTION_HEIGHT = 300; // Slightly larger minimum to ensure meaningful content
|
|
654
660
|
const subSections = [];
|
|
655
661
|
|
|
656
662
|
// Get all top-level items in the section with detailed analysis
|
|
@@ -667,13 +673,20 @@ const PdfForm = ({
|
|
|
667
673
|
// If the entire section fits, don't split it
|
|
668
674
|
const totalSectionHeight = topLevelItems.reduce((sum, item) => sum + item.estimatedHeight, 0);
|
|
669
675
|
|
|
670
|
-
// Add
|
|
671
|
-
if (typeof window !== 'undefined' && window.console
|
|
676
|
+
// Add detailed debugging for height calculations
|
|
677
|
+
if (typeof window !== 'undefined' && window.console) {
|
|
672
678
|
console.log(`Section ${sectionKey}:`, {
|
|
673
|
-
|
|
674
|
-
|
|
679
|
+
totalEstimatedHeight: totalSectionHeight,
|
|
680
|
+
maxAllowedHeight: MAX_SECTION_HEIGHT,
|
|
681
|
+
pdfViewMaxHeight: PDFVIEW_MAX_HEIGHT,
|
|
682
|
+
utilizationPercentage: Math.round((totalSectionHeight / MAX_SECTION_HEIGHT) * 100) + '%',
|
|
675
683
|
shouldSplit: totalSectionHeight > MAX_SECTION_HEIGHT,
|
|
676
|
-
itemCount: topLevelItems.length
|
|
684
|
+
itemCount: topLevelItems.length,
|
|
685
|
+
itemSummary: topLevelItems.map(item => ({
|
|
686
|
+
key: item.key,
|
|
687
|
+
height: item.estimatedHeight,
|
|
688
|
+
type: item.config?.type
|
|
689
|
+
}))
|
|
677
690
|
});
|
|
678
691
|
}
|
|
679
692
|
|
|
@@ -696,17 +709,17 @@ const PdfForm = ({
|
|
|
696
709
|
}
|
|
697
710
|
});
|
|
698
711
|
|
|
699
|
-
let currentHeight = isPuppeteer ?
|
|
712
|
+
let currentHeight = isPuppeteer ? 120 : 100; // More accurate base height including section headers and margins
|
|
700
713
|
let subSectionIndex = 0;
|
|
701
714
|
|
|
702
715
|
topLevelItems.forEach((item, index) => {
|
|
703
716
|
const { key, config, estimatedHeight, canSplit } = item;
|
|
704
717
|
|
|
705
|
-
// More
|
|
706
|
-
const SPLIT_THRESHOLD = 0.
|
|
718
|
+
// More conservative splitting thresholds to work better with PdfView
|
|
719
|
+
const SPLIT_THRESHOLD = 0.65; // Split if item takes up more than 65% of available space
|
|
707
720
|
|
|
708
|
-
// If a single item is
|
|
709
|
-
if (estimatedHeight > MAX_SECTION_HEIGHT * SPLIT_THRESHOLD && canSplit && estimatedHeight > MIN_SECTION_HEIGHT *
|
|
721
|
+
// If a single item is large and can be split, consider splitting it
|
|
722
|
+
if (estimatedHeight > MAX_SECTION_HEIGHT * SPLIT_THRESHOLD && canSplit && estimatedHeight > MIN_SECTION_HEIGHT * 1.5) {
|
|
710
723
|
// Split this large item into smaller parts
|
|
711
724
|
const childSplits = splitLargeItem(key, config, data?.[key], MAX_SECTION_HEIGHT * 0.6);
|
|
712
725
|
|
|
@@ -730,7 +743,7 @@ const PdfForm = ({
|
|
|
730
743
|
position: section.position + subSectionIndex + 1,
|
|
731
744
|
subTitle: section.subTitle
|
|
732
745
|
};
|
|
733
|
-
currentHeight = isPuppeteer ?
|
|
746
|
+
currentHeight = isPuppeteer ? 120 : 100;
|
|
734
747
|
subSectionIndex++;
|
|
735
748
|
}
|
|
736
749
|
|
|
@@ -743,8 +756,8 @@ const PdfForm = ({
|
|
|
743
756
|
// More lenient threshold - only split if really necessary and ensures meaningful sections
|
|
744
757
|
const remainingItems = topLevelItems.length - index - 1;
|
|
745
758
|
const shouldSplitSection = (currentHeight + estimatedHeight > MAX_SECTION_HEIGHT) &&
|
|
746
|
-
(currentHeight > MIN_SECTION_HEIGHT) &&
|
|
747
|
-
(Object.keys(currentSubSection).length >
|
|
759
|
+
(currentHeight > MIN_SECTION_HEIGHT * 0.8) && // More lenient minimum
|
|
760
|
+
(Object.keys(currentSubSection).length > 3) && // Fewer items required
|
|
748
761
|
(remainingItems > 0); // Ensure there are items left for next section
|
|
749
762
|
|
|
750
763
|
if (shouldSplitSection) {
|
|
@@ -763,7 +776,7 @@ const PdfForm = ({
|
|
|
763
776
|
position: section.position + subSectionIndex + 1,
|
|
764
777
|
subTitle: section.subTitle
|
|
765
778
|
};
|
|
766
|
-
currentHeight = isPuppeteer ?
|
|
779
|
+
currentHeight = isPuppeteer ? 120 : 100;
|
|
767
780
|
subSectionIndex++;
|
|
768
781
|
}
|
|
769
782
|
|
|
@@ -788,10 +801,12 @@ const PdfForm = ({
|
|
|
788
801
|
subSections.push(finalSubSection);
|
|
789
802
|
|
|
790
803
|
// Debug final section creation
|
|
791
|
-
if (typeof window !== 'undefined' && window.console
|
|
804
|
+
if (typeof window !== 'undefined' && window.console) {
|
|
792
805
|
console.log(`Final section ${finalSubSection.key}:`, {
|
|
793
806
|
itemCount: finalSectionKeys.length,
|
|
794
|
-
estimatedHeight: currentHeight
|
|
807
|
+
estimatedHeight: currentHeight,
|
|
808
|
+
utilizationPercentage: Math.round((currentHeight / MAX_SECTION_HEIGHT) * 100) + '%',
|
|
809
|
+
isWithinLimits: currentHeight <= MAX_SECTION_HEIGHT
|
|
795
810
|
});
|
|
796
811
|
}
|
|
797
812
|
}
|
|
@@ -832,7 +847,7 @@ const PdfForm = ({
|
|
|
832
847
|
|
|
833
848
|
// If total children height is not that large, don't split
|
|
834
849
|
const totalChildrenHeight = childItems.reduce((sum, child) => sum + child.estimatedHeight, 0);
|
|
835
|
-
if (totalChildrenHeight <= maxHeight * 1.
|
|
850
|
+
if (totalChildrenHeight <= maxHeight * 1.1) { // More conservative threshold
|
|
836
851
|
return [{ key: parentKey, config: parentConfig, estimatedHeight: estimateTreeNodeHeight(parentKey, parentConfig, parentValue) }];
|
|
837
852
|
}
|
|
838
853
|
|
|
@@ -843,7 +858,7 @@ const PdfForm = ({
|
|
|
843
858
|
...parentConfig,
|
|
844
859
|
inputs: {}
|
|
845
860
|
},
|
|
846
|
-
estimatedHeight:
|
|
861
|
+
estimatedHeight: 60 // More accurate base height for parent structure with styling
|
|
847
862
|
};
|
|
848
863
|
let splitIndex = 0;
|
|
849
864
|
const minItemsPerSplit = 2; // Ensure at least 2 items per split to avoid tiny sections
|
|
@@ -874,7 +889,7 @@ const PdfForm = ({
|
|
|
874
889
|
label: parentConfig.label, // Keep original label without part indicator
|
|
875
890
|
inputs: {}
|
|
876
891
|
},
|
|
877
|
-
estimatedHeight:
|
|
892
|
+
estimatedHeight: 60
|
|
878
893
|
};
|
|
879
894
|
}
|
|
880
895
|
|