datastake-daf 0.6.251 → 0.6.253
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
|
@@ -15422,226 +15422,6 @@ const PdfForm = _ref3 => {
|
|
|
15422
15422
|
return organizedSections;
|
|
15423
15423
|
};
|
|
15424
15424
|
const organizedForm = React.useMemo(() => organizeFormByHeaders(form), [form]);
|
|
15425
|
-
|
|
15426
|
-
// Constants for height calculations (same as PdfView)
|
|
15427
|
-
const PAGE_HEIGHT = 1587;
|
|
15428
|
-
const FOOTER_HEIGHT = 70;
|
|
15429
|
-
const HEADER_HEIGHT = 100;
|
|
15430
|
-
|
|
15431
|
-
// Helper function to estimate tree node height based on content and type
|
|
15432
|
-
const estimateTreeNodeHeight = function (key, config, value) {
|
|
15433
|
-
let level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
15434
|
-
const baseHeight = 28; // Base height per tree node
|
|
15435
|
-
const indentHeight = level * 2; // Additional height per level
|
|
15436
|
-
let totalHeight = baseHeight + indentHeight;
|
|
15437
|
-
|
|
15438
|
-
// Adjust height based on node type
|
|
15439
|
-
if ((config === null || config === void 0 ? void 0 : config.type) === 'header') {
|
|
15440
|
-
totalHeight += 15; // Headers need more space
|
|
15441
|
-
} else if ((config === null || config === void 0 ? void 0 : config.type) === 'textarea') {
|
|
15442
|
-
totalHeight += 40; // Textareas are taller
|
|
15443
|
-
} else if ((config === null || config === void 0 ? void 0 : config.type) === 'dataLink' || (config === null || config === void 0 ? void 0 : config.type) === 'dataLinkGroup') {
|
|
15444
|
-
totalHeight += 20; // Data links often have more content
|
|
15445
|
-
}
|
|
15446
|
-
|
|
15447
|
-
// Add height for value content if it exists
|
|
15448
|
-
if (value && typeof value === 'string' && value.length > 50) {
|
|
15449
|
-
totalHeight += Math.ceil(value.length / 50) * 15; // Multi-line content
|
|
15450
|
-
}
|
|
15451
|
-
|
|
15452
|
-
// Add height for children recursively
|
|
15453
|
-
if (config !== null && config !== void 0 && config.inputs) {
|
|
15454
|
-
const childKeys = Object.keys(config.inputs).filter(childKey => {
|
|
15455
|
-
const childConfig = config.inputs[childKey];
|
|
15456
|
-
// Check showIf condition
|
|
15457
|
-
if (childConfig !== null && childConfig !== void 0 && childConfig.showIf && !evaluateShowIfCondition(childConfig.showIf, data)) {
|
|
15458
|
-
return false;
|
|
15459
|
-
}
|
|
15460
|
-
return true;
|
|
15461
|
-
}).sort((a, b) => {
|
|
15462
|
-
var _config$inputs$a3, _config$inputs$b3;
|
|
15463
|
-
const positionA = ((_config$inputs$a3 = config.inputs[a]) === null || _config$inputs$a3 === void 0 ? void 0 : _config$inputs$a3.position) || 0;
|
|
15464
|
-
const positionB = ((_config$inputs$b3 = config.inputs[b]) === null || _config$inputs$b3 === void 0 ? void 0 : _config$inputs$b3.position) || 0;
|
|
15465
|
-
return positionA - positionB;
|
|
15466
|
-
});
|
|
15467
|
-
childKeys.forEach(childKey => {
|
|
15468
|
-
const childConfig = config.inputs[childKey];
|
|
15469
|
-
const childValue = (value === null || value === void 0 ? void 0 : value[childKey]) || (data === null || data === void 0 ? void 0 : data[childKey]);
|
|
15470
|
-
totalHeight += estimateTreeNodeHeight(childKey, childConfig, childValue, level + 1);
|
|
15471
|
-
});
|
|
15472
|
-
}
|
|
15473
|
-
|
|
15474
|
-
// Handle array/repeated content
|
|
15475
|
-
if (Array.isArray(value)) {
|
|
15476
|
-
value.forEach(itemValue => {
|
|
15477
|
-
totalHeight += estimateTreeNodeHeight(key, config, itemValue, level);
|
|
15478
|
-
});
|
|
15479
|
-
}
|
|
15480
|
-
return totalHeight;
|
|
15481
|
-
};
|
|
15482
|
-
|
|
15483
|
-
// Helper function to split section based on height constraints (goes deep if needed)
|
|
15484
|
-
const createHeightConstrainedSections = (sectionKey, section) => {
|
|
15485
|
-
const MAX_SECTION_HEIGHT = PAGE_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT - 150; // Conservative buffer
|
|
15486
|
-
const subSections = [];
|
|
15487
|
-
|
|
15488
|
-
// Get all top-level items in the section with detailed analysis
|
|
15489
|
-
const topLevelItems = Object.keys(section).filter(key => !(key === 'id' || key === 'label' || key === 'position' || key === 'subTitle')).map(key => {
|
|
15490
|
-
var _section$key;
|
|
15491
|
-
return {
|
|
15492
|
-
key,
|
|
15493
|
-
config: section[key],
|
|
15494
|
-
estimatedHeight: estimateTreeNodeHeight(key, section[key], data === null || data === void 0 ? void 0 : data[key]),
|
|
15495
|
-
canSplit: ((_section$key = section[key]) === null || _section$key === void 0 ? void 0 : _section$key.inputs) && Object.keys(section[key].inputs).length > 1 // Can this item be further split?
|
|
15496
|
-
};
|
|
15497
|
-
}).sort((a, b) => {
|
|
15498
|
-
var _a$config, _b$config;
|
|
15499
|
-
return (((_a$config = a.config) === null || _a$config === void 0 ? void 0 : _a$config.position) || 0) - (((_b$config = b.config) === null || _b$config === void 0 ? void 0 : _b$config.position) || 0);
|
|
15500
|
-
});
|
|
15501
|
-
let currentSubSection = _objectSpread2({}, section);
|
|
15502
|
-
|
|
15503
|
-
// Remove all items from the base section structure
|
|
15504
|
-
Object.keys(section).forEach(key => {
|
|
15505
|
-
if (!(key === 'id' || key === 'label' || key === 'position' || key === 'subTitle')) {
|
|
15506
|
-
delete currentSubSection[key];
|
|
15507
|
-
}
|
|
15508
|
-
});
|
|
15509
|
-
let currentHeight = 80; // Base height for section header
|
|
15510
|
-
let subSectionIndex = 0;
|
|
15511
|
-
topLevelItems.forEach((item, index) => {
|
|
15512
|
-
const {
|
|
15513
|
-
key,
|
|
15514
|
-
config,
|
|
15515
|
-
estimatedHeight,
|
|
15516
|
-
canSplit
|
|
15517
|
-
} = item;
|
|
15518
|
-
|
|
15519
|
-
// If a single item is too large and can be split, split it at the child level
|
|
15520
|
-
if (estimatedHeight > MAX_SECTION_HEIGHT * 0.8 && canSplit) {
|
|
15521
|
-
// Split this large item into smaller parts
|
|
15522
|
-
const childSplits = splitLargeItem(key, config, data === null || data === void 0 ? void 0 : data[key], MAX_SECTION_HEIGHT * 0.6);
|
|
15523
|
-
childSplits.forEach((splitItem, splitIndex) => {
|
|
15524
|
-
// Check if current subsection has room
|
|
15525
|
-
if (currentHeight + splitItem.estimatedHeight > MAX_SECTION_HEIGHT && Object.keys(currentSubSection).length > 4) {
|
|
15526
|
-
// Save current sub-section
|
|
15527
|
-
subSections.push({
|
|
15528
|
-
key: "".concat(sectionKey, "_part_").concat(subSectionIndex),
|
|
15529
|
-
section: _objectSpread2({}, currentSubSection),
|
|
15530
|
-
title: section.label
|
|
15531
|
-
});
|
|
15532
|
-
|
|
15533
|
-
// Start new sub-section
|
|
15534
|
-
currentSubSection = {
|
|
15535
|
-
id: section.id,
|
|
15536
|
-
label: section.label,
|
|
15537
|
-
position: section.position + subSectionIndex + 1,
|
|
15538
|
-
subTitle: section.subTitle
|
|
15539
|
-
};
|
|
15540
|
-
currentHeight = 80;
|
|
15541
|
-
subSectionIndex++;
|
|
15542
|
-
}
|
|
15543
|
-
|
|
15544
|
-
// Add split item to current sub-section
|
|
15545
|
-
currentSubSection[splitItem.key] = splitItem.config;
|
|
15546
|
-
currentHeight += splitItem.estimatedHeight;
|
|
15547
|
-
});
|
|
15548
|
-
} else {
|
|
15549
|
-
// Regular processing for items that fit or can't be split
|
|
15550
|
-
// Check if adding this item would exceed height limit
|
|
15551
|
-
if (currentHeight + estimatedHeight > MAX_SECTION_HEIGHT && Object.keys(currentSubSection).length > 4) {
|
|
15552
|
-
// Save current sub-section
|
|
15553
|
-
subSections.push({
|
|
15554
|
-
key: "".concat(sectionKey, "_part_").concat(subSectionIndex),
|
|
15555
|
-
section: _objectSpread2({}, currentSubSection),
|
|
15556
|
-
title: section.label
|
|
15557
|
-
});
|
|
15558
|
-
|
|
15559
|
-
// Start new sub-section
|
|
15560
|
-
currentSubSection = {
|
|
15561
|
-
id: section.id,
|
|
15562
|
-
label: section.label,
|
|
15563
|
-
position: section.position + subSectionIndex + 1,
|
|
15564
|
-
subTitle: section.subTitle
|
|
15565
|
-
};
|
|
15566
|
-
currentHeight = 80;
|
|
15567
|
-
subSectionIndex++;
|
|
15568
|
-
}
|
|
15569
|
-
|
|
15570
|
-
// Add item to current sub-section
|
|
15571
|
-
currentSubSection[key] = config;
|
|
15572
|
-
currentHeight += estimatedHeight;
|
|
15573
|
-
}
|
|
15574
|
-
});
|
|
15575
|
-
|
|
15576
|
-
// Add the final sub-section if it has content
|
|
15577
|
-
if (Object.keys(currentSubSection).length > 4) {
|
|
15578
|
-
subSections.push({
|
|
15579
|
-
key: subSectionIndex === 0 ? sectionKey : "".concat(sectionKey, "_part_").concat(subSectionIndex),
|
|
15580
|
-
section: currentSubSection,
|
|
15581
|
-
title: section.label
|
|
15582
|
-
});
|
|
15583
|
-
}
|
|
15584
|
-
return subSections.length > 0 ? subSections : [{
|
|
15585
|
-
key: sectionKey,
|
|
15586
|
-
section: section,
|
|
15587
|
-
title: section.label
|
|
15588
|
-
}];
|
|
15589
|
-
};
|
|
15590
|
-
|
|
15591
|
-
// Helper function to split large items at the child level
|
|
15592
|
-
const splitLargeItem = (parentKey, parentConfig, parentValue, maxHeight) => {
|
|
15593
|
-
if (!(parentConfig !== null && parentConfig !== void 0 && parentConfig.inputs)) {
|
|
15594
|
-
return [{
|
|
15595
|
-
key: parentKey,
|
|
15596
|
-
config: parentConfig,
|
|
15597
|
-
estimatedHeight: estimateTreeNodeHeight(parentKey, parentConfig, parentValue)
|
|
15598
|
-
}];
|
|
15599
|
-
}
|
|
15600
|
-
const childItems = Object.keys(parentConfig.inputs).filter(childKey => {
|
|
15601
|
-
const childConfig = parentConfig.inputs[childKey];
|
|
15602
|
-
return !(childConfig !== null && childConfig !== void 0 && childConfig.showIf) || evaluateShowIfCondition(childConfig.showIf, data);
|
|
15603
|
-
}).map(childKey => ({
|
|
15604
|
-
key: childKey,
|
|
15605
|
-
config: parentConfig.inputs[childKey],
|
|
15606
|
-
estimatedHeight: estimateTreeNodeHeight(childKey, parentConfig.inputs[childKey], parentValue === null || parentValue === void 0 ? void 0 : parentValue[childKey])
|
|
15607
|
-
})).sort((a, b) => {
|
|
15608
|
-
var _a$config2, _b$config2;
|
|
15609
|
-
return (((_a$config2 = a.config) === null || _a$config2 === void 0 ? void 0 : _a$config2.position) || 0) - (((_b$config2 = b.config) === null || _b$config2 === void 0 ? void 0 : _b$config2.position) || 0);
|
|
15610
|
-
});
|
|
15611
|
-
const splits = [];
|
|
15612
|
-
let currentSplit = {
|
|
15613
|
-
key: "".concat(parentKey, "_part_0"),
|
|
15614
|
-
config: _objectSpread2(_objectSpread2({}, parentConfig), {}, {
|
|
15615
|
-
inputs: {}
|
|
15616
|
-
}),
|
|
15617
|
-
estimatedHeight: 40 // Base height for parent structure
|
|
15618
|
-
};
|
|
15619
|
-
let splitIndex = 0;
|
|
15620
|
-
childItems.forEach(child => {
|
|
15621
|
-
if (currentSplit.estimatedHeight + child.estimatedHeight > maxHeight && Object.keys(currentSplit.config.inputs).length > 0) {
|
|
15622
|
-
splits.push(currentSplit);
|
|
15623
|
-
splitIndex++;
|
|
15624
|
-
currentSplit = {
|
|
15625
|
-
key: "".concat(parentKey, "_part_").concat(splitIndex),
|
|
15626
|
-
config: _objectSpread2(_objectSpread2({}, parentConfig), {}, {
|
|
15627
|
-
label: parentConfig.label,
|
|
15628
|
-
inputs: {}
|
|
15629
|
-
}),
|
|
15630
|
-
estimatedHeight: 40
|
|
15631
|
-
};
|
|
15632
|
-
}
|
|
15633
|
-
currentSplit.config.inputs[child.key] = child.config;
|
|
15634
|
-
currentSplit.estimatedHeight += child.estimatedHeight;
|
|
15635
|
-
});
|
|
15636
|
-
if (Object.keys(currentSplit.config.inputs).length > 0) {
|
|
15637
|
-
splits.push(currentSplit);
|
|
15638
|
-
}
|
|
15639
|
-
return splits.length > 0 ? splits : [{
|
|
15640
|
-
key: parentKey,
|
|
15641
|
-
config: parentConfig,
|
|
15642
|
-
estimatedHeight: estimateTreeNodeHeight(parentKey, parentConfig, parentValue)
|
|
15643
|
-
}];
|
|
15644
|
-
};
|
|
15645
15425
|
const pdfConfig = React.useMemo(() => {
|
|
15646
15426
|
const sections = [];
|
|
15647
15427
|
Object.keys(organizedForm).forEach(sectionKey => {
|
|
@@ -15649,40 +15429,28 @@ const PdfForm = _ref3 => {
|
|
|
15649
15429
|
if (typeof section !== 'object' || !section.label) {
|
|
15650
15430
|
return;
|
|
15651
15431
|
}
|
|
15652
|
-
|
|
15653
|
-
|
|
15654
|
-
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
|
|
15661
|
-
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
|
|
15669
|
-
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
source: source,
|
|
15675
|
-
version: version,
|
|
15676
|
-
getApiBaseUrl: getApiBaseUrl,
|
|
15677
|
-
getAppHeader: getAppHeader,
|
|
15678
|
-
app: app
|
|
15679
|
-
})
|
|
15680
|
-
}, key),
|
|
15681
|
-
style: {
|
|
15682
|
-
marginBottom: '20px',
|
|
15683
|
-
padding: '0 20px'
|
|
15684
|
-
}
|
|
15685
|
-
});
|
|
15432
|
+
sections.push({
|
|
15433
|
+
render: () => /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
15434
|
+
className: "pdf-form-section",
|
|
15435
|
+
children: /*#__PURE__*/jsxRuntime.jsx(PdfFormContent, {
|
|
15436
|
+
form: {
|
|
15437
|
+
[sectionKey]: section
|
|
15438
|
+
},
|
|
15439
|
+
data: data,
|
|
15440
|
+
t: t,
|
|
15441
|
+
user: user,
|
|
15442
|
+
title: formName,
|
|
15443
|
+
source: source,
|
|
15444
|
+
version: version,
|
|
15445
|
+
getApiBaseUrl: getApiBaseUrl,
|
|
15446
|
+
getAppHeader: getAppHeader,
|
|
15447
|
+
app: app
|
|
15448
|
+
})
|
|
15449
|
+
}, sectionKey),
|
|
15450
|
+
style: {
|
|
15451
|
+
marginBottom: '20px',
|
|
15452
|
+
padding: '0 20px'
|
|
15453
|
+
}
|
|
15686
15454
|
});
|
|
15687
15455
|
});
|
|
15688
15456
|
return sections;
|
|
@@ -20737,29 +20505,12 @@ const DAFSteps = _ref => {
|
|
|
20737
20505
|
let {
|
|
20738
20506
|
direction = "vertical",
|
|
20739
20507
|
current = 0,
|
|
20740
|
-
items = []
|
|
20741
|
-
scrollThreshold = 4
|
|
20508
|
+
items = []
|
|
20742
20509
|
} = _ref;
|
|
20743
|
-
|
|
20744
|
-
|
|
20745
|
-
|
|
20746
|
-
|
|
20747
|
-
overflowX: "hidden"
|
|
20748
|
-
} : {
|
|
20749
|
-
maxWidth: "100%",
|
|
20750
|
-
overflowX: "auto",
|
|
20751
|
-
overflowY: "hidden",
|
|
20752
|
-
whiteSpace: "nowrap"
|
|
20753
|
-
}), {}, {
|
|
20754
|
-
padding: "8px",
|
|
20755
|
-
marginRight: direction === "vertical" ? "-8px" : "0",
|
|
20756
|
-
paddingRight: direction === "vertical" ? "16px" : "8px"
|
|
20757
|
-
}) : {};
|
|
20758
|
-
return /*#__PURE__*/jsxRuntime.jsx(Widget, {
|
|
20759
|
-
title: "Life Cycle",
|
|
20760
|
-
className: "with-border-header",
|
|
20761
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
20762
|
-
style: scrollableStyles,
|
|
20510
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
20511
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Widget, {
|
|
20512
|
+
title: "Life Cycle",
|
|
20513
|
+
className: "with-border-header",
|
|
20763
20514
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Steps, {
|
|
20764
20515
|
direction: direction,
|
|
20765
20516
|
current: current,
|
|
@@ -20774,14 +20525,12 @@ DAFSteps.propTypes = {
|
|
|
20774
20525
|
items: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
20775
20526
|
title: PropTypes__default["default"].string.isRequired,
|
|
20776
20527
|
description: PropTypes__default["default"].string
|
|
20777
|
-
}))
|
|
20778
|
-
scrollThreshold: PropTypes__default["default"].number
|
|
20528
|
+
}))
|
|
20779
20529
|
};
|
|
20780
20530
|
DAFSteps.defaultProps = {
|
|
20781
20531
|
direction: "vertical",
|
|
20782
20532
|
current: 0,
|
|
20783
|
-
items: []
|
|
20784
|
-
scrollThreshold: 4
|
|
20533
|
+
items: []
|
|
20785
20534
|
};
|
|
20786
20535
|
|
|
20787
20536
|
/**
|
package/package.json
CHANGED
|
@@ -17,11 +17,6 @@ VerticalSteps.args = {
|
|
|
17
17
|
{ title: "Step 1", description: "This is the first step" },
|
|
18
18
|
{ title: "Step 2", description: "This is the second step" },
|
|
19
19
|
{ title: "Step 3", description: "This is the third step" },
|
|
20
|
-
{ title: "Step 3", description: "This is the third step" },
|
|
21
|
-
{ title: "Step 3", description: "This is the third step" },
|
|
22
|
-
{ title: "Step 3", description: "This is the third step" },
|
|
23
|
-
{ title: "Step 3", description: "This is the third step" },
|
|
24
|
-
{ title: "Step 3", description: "This is the third step" },
|
|
25
20
|
],
|
|
26
21
|
};
|
|
27
22
|
|
|
@@ -3,35 +3,16 @@ import { Steps } from "antd";
|
|
|
3
3
|
import Widget from "../../Dashboard/Widget/index.jsx";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
|
|
6
|
-
const DAFSteps = ({ direction = "vertical", current = 0, items = []
|
|
7
|
-
const shouldScroll = items.length > scrollThreshold;
|
|
8
|
-
|
|
9
|
-
const scrollableStyles = shouldScroll ? {
|
|
10
|
-
...(direction === "vertical" ? {
|
|
11
|
-
maxHeight: "300px",
|
|
12
|
-
overflowY: "auto",
|
|
13
|
-
overflowX: "hidden"
|
|
14
|
-
} : {
|
|
15
|
-
maxWidth: "100%",
|
|
16
|
-
overflowX: "auto",
|
|
17
|
-
overflowY: "hidden",
|
|
18
|
-
whiteSpace: "nowrap"
|
|
19
|
-
}),
|
|
20
|
-
padding: "8px",
|
|
21
|
-
marginRight: direction === "vertical" ? "-8px" : "0",
|
|
22
|
-
paddingRight: direction === "vertical" ? "16px" : "8px"
|
|
23
|
-
} : {};
|
|
24
|
-
|
|
6
|
+
const DAFSteps = ({ direction = "vertical", current = 0, items = [] }) => {
|
|
25
7
|
return (
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/>
|
|
33
|
-
</div>
|
|
8
|
+
<><Widget title="Life Cycle" className="with-border-header">
|
|
9
|
+
<Steps
|
|
10
|
+
direction={direction}
|
|
11
|
+
current={current}
|
|
12
|
+
items={items}
|
|
13
|
+
/>
|
|
34
14
|
</Widget>
|
|
15
|
+
</>
|
|
35
16
|
);
|
|
36
17
|
};
|
|
37
18
|
|
|
@@ -44,14 +25,12 @@ DAFSteps.propTypes = {
|
|
|
44
25
|
description: PropTypes.string,
|
|
45
26
|
})
|
|
46
27
|
),
|
|
47
|
-
scrollThreshold: PropTypes.number,
|
|
48
28
|
};
|
|
49
29
|
|
|
50
30
|
DAFSteps.defaultProps = {
|
|
51
31
|
direction: "vertical",
|
|
52
32
|
current: 0,
|
|
53
33
|
items: [],
|
|
54
|
-
scrollThreshold: 4,
|
|
55
34
|
};
|
|
56
35
|
|
|
57
36
|
export default DAFSteps;
|
|
@@ -525,227 +525,6 @@ const PdfForm = ({
|
|
|
525
525
|
|
|
526
526
|
const organizedForm = useMemo(() => organizeFormByHeaders(form), [form]);
|
|
527
527
|
|
|
528
|
-
// Constants for height calculations (same as PdfView)
|
|
529
|
-
const PAGE_HEIGHT = 1587;
|
|
530
|
-
const FOOTER_HEIGHT = 70;
|
|
531
|
-
const HEADER_HEIGHT = 100;
|
|
532
|
-
|
|
533
|
-
// Helper function to estimate tree node height based on content and type
|
|
534
|
-
const estimateTreeNodeHeight = (key, config, value, level = 0) => {
|
|
535
|
-
const baseHeight = 28; // Base height per tree node
|
|
536
|
-
const indentHeight = level * 2; // Additional height per level
|
|
537
|
-
let totalHeight = baseHeight + indentHeight;
|
|
538
|
-
|
|
539
|
-
// Adjust height based on node type
|
|
540
|
-
if (config?.type === 'header') {
|
|
541
|
-
totalHeight += 15; // Headers need more space
|
|
542
|
-
} else if (config?.type === 'textarea') {
|
|
543
|
-
totalHeight += 40; // Textareas are taller
|
|
544
|
-
} else if (config?.type === 'dataLink' || config?.type === 'dataLinkGroup') {
|
|
545
|
-
totalHeight += 20; // Data links often have more content
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
// Add height for value content if it exists
|
|
549
|
-
if (value && typeof value === 'string' && value.length > 50) {
|
|
550
|
-
totalHeight += Math.ceil(value.length / 50) * 15; // Multi-line content
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
// Add height for children recursively
|
|
554
|
-
if (config?.inputs) {
|
|
555
|
-
const childKeys = Object.keys(config.inputs)
|
|
556
|
-
.filter(childKey => {
|
|
557
|
-
const childConfig = config.inputs[childKey];
|
|
558
|
-
// Check showIf condition
|
|
559
|
-
if (childConfig?.showIf && !evaluateShowIfCondition(childConfig.showIf, data)) {
|
|
560
|
-
return false;
|
|
561
|
-
}
|
|
562
|
-
return true;
|
|
563
|
-
})
|
|
564
|
-
.sort((a, b) => {
|
|
565
|
-
const positionA = config.inputs[a]?.position || 0;
|
|
566
|
-
const positionB = config.inputs[b]?.position || 0;
|
|
567
|
-
return positionA - positionB;
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
childKeys.forEach(childKey => {
|
|
571
|
-
const childConfig = config.inputs[childKey];
|
|
572
|
-
const childValue = value?.[childKey] || data?.[childKey];
|
|
573
|
-
totalHeight += estimateTreeNodeHeight(childKey, childConfig, childValue, level + 1);
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
// Handle array/repeated content
|
|
578
|
-
if (Array.isArray(value)) {
|
|
579
|
-
value.forEach(itemValue => {
|
|
580
|
-
totalHeight += estimateTreeNodeHeight(key, config, itemValue, level);
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
return totalHeight;
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
// Helper function to split section based on height constraints (goes deep if needed)
|
|
588
|
-
const createHeightConstrainedSections = (sectionKey, section) => {
|
|
589
|
-
const MAX_SECTION_HEIGHT = PAGE_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT - 150; // Conservative buffer
|
|
590
|
-
const subSections = [];
|
|
591
|
-
|
|
592
|
-
// Get all top-level items in the section with detailed analysis
|
|
593
|
-
const topLevelItems = Object.keys(section)
|
|
594
|
-
.filter(key => !(key === 'id' || key === 'label' || key === 'position' || key === 'subTitle'))
|
|
595
|
-
.map(key => ({
|
|
596
|
-
key,
|
|
597
|
-
config: section[key],
|
|
598
|
-
estimatedHeight: estimateTreeNodeHeight(key, section[key], data?.[key]),
|
|
599
|
-
canSplit: section[key]?.inputs && Object.keys(section[key].inputs).length > 1 // Can this item be further split?
|
|
600
|
-
}))
|
|
601
|
-
.sort((a, b) => (a.config?.position || 0) - (b.config?.position || 0));
|
|
602
|
-
|
|
603
|
-
let currentSubSection = {
|
|
604
|
-
...section,
|
|
605
|
-
};
|
|
606
|
-
|
|
607
|
-
// Remove all items from the base section structure
|
|
608
|
-
Object.keys(section).forEach(key => {
|
|
609
|
-
if (!(key === 'id' || key === 'label' || key === 'position' || key === 'subTitle')) {
|
|
610
|
-
delete currentSubSection[key];
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
let currentHeight = 80; // Base height for section header
|
|
615
|
-
let subSectionIndex = 0;
|
|
616
|
-
|
|
617
|
-
topLevelItems.forEach((item, index) => {
|
|
618
|
-
const { key, config, estimatedHeight, canSplit } = item;
|
|
619
|
-
|
|
620
|
-
// If a single item is too large and can be split, split it at the child level
|
|
621
|
-
if (estimatedHeight > MAX_SECTION_HEIGHT * 0.8 && canSplit) {
|
|
622
|
-
// Split this large item into smaller parts
|
|
623
|
-
const childSplits = splitLargeItem(key, config, data?.[key], MAX_SECTION_HEIGHT * 0.6);
|
|
624
|
-
|
|
625
|
-
childSplits.forEach((splitItem, splitIndex) => {
|
|
626
|
-
// Check if current subsection has room
|
|
627
|
-
if (currentHeight + splitItem.estimatedHeight > MAX_SECTION_HEIGHT && Object.keys(currentSubSection).length > 4) {
|
|
628
|
-
// Save current sub-section
|
|
629
|
-
subSections.push({
|
|
630
|
-
key: `${sectionKey}_part_${subSectionIndex}`,
|
|
631
|
-
section: { ...currentSubSection },
|
|
632
|
-
title: section.label
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
// Start new sub-section
|
|
636
|
-
currentSubSection = {
|
|
637
|
-
id: section.id,
|
|
638
|
-
label: section.label,
|
|
639
|
-
position: section.position + subSectionIndex + 1,
|
|
640
|
-
subTitle: section.subTitle
|
|
641
|
-
};
|
|
642
|
-
currentHeight = 80;
|
|
643
|
-
subSectionIndex++;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
// Add split item to current sub-section
|
|
647
|
-
currentSubSection[splitItem.key] = splitItem.config;
|
|
648
|
-
currentHeight += splitItem.estimatedHeight;
|
|
649
|
-
});
|
|
650
|
-
} else {
|
|
651
|
-
// Regular processing for items that fit or can't be split
|
|
652
|
-
// Check if adding this item would exceed height limit
|
|
653
|
-
if (currentHeight + estimatedHeight > MAX_SECTION_HEIGHT && Object.keys(currentSubSection).length > 4) {
|
|
654
|
-
// Save current sub-section
|
|
655
|
-
subSections.push({
|
|
656
|
-
key: `${sectionKey}_part_${subSectionIndex}`,
|
|
657
|
-
section: { ...currentSubSection },
|
|
658
|
-
title: section.label
|
|
659
|
-
});
|
|
660
|
-
|
|
661
|
-
// Start new sub-section
|
|
662
|
-
currentSubSection = {
|
|
663
|
-
id: section.id,
|
|
664
|
-
label: section.label,
|
|
665
|
-
position: section.position + subSectionIndex + 1,
|
|
666
|
-
subTitle: section.subTitle
|
|
667
|
-
};
|
|
668
|
-
currentHeight = 80;
|
|
669
|
-
subSectionIndex++;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
// Add item to current sub-section
|
|
673
|
-
currentSubSection[key] = config;
|
|
674
|
-
currentHeight += estimatedHeight;
|
|
675
|
-
}
|
|
676
|
-
});
|
|
677
|
-
|
|
678
|
-
// Add the final sub-section if it has content
|
|
679
|
-
if (Object.keys(currentSubSection).length > 4) {
|
|
680
|
-
subSections.push({
|
|
681
|
-
key: subSectionIndex === 0 ? sectionKey : `${sectionKey}_part_${subSectionIndex}`,
|
|
682
|
-
section: currentSubSection,
|
|
683
|
-
title: section.label
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
return subSections.length > 0 ? subSections : [{
|
|
688
|
-
key: sectionKey,
|
|
689
|
-
section: section,
|
|
690
|
-
title: section.label
|
|
691
|
-
}];
|
|
692
|
-
};
|
|
693
|
-
|
|
694
|
-
// Helper function to split large items at the child level
|
|
695
|
-
const splitLargeItem = (parentKey, parentConfig, parentValue, maxHeight) => {
|
|
696
|
-
if (!parentConfig?.inputs) {
|
|
697
|
-
return [{ key: parentKey, config: parentConfig, estimatedHeight: estimateTreeNodeHeight(parentKey, parentConfig, parentValue) }];
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
const childItems = Object.keys(parentConfig.inputs)
|
|
701
|
-
.filter(childKey => {
|
|
702
|
-
const childConfig = parentConfig.inputs[childKey];
|
|
703
|
-
return !childConfig?.showIf || evaluateShowIfCondition(childConfig.showIf, data);
|
|
704
|
-
})
|
|
705
|
-
.map(childKey => ({
|
|
706
|
-
key: childKey,
|
|
707
|
-
config: parentConfig.inputs[childKey],
|
|
708
|
-
estimatedHeight: estimateTreeNodeHeight(childKey, parentConfig.inputs[childKey], parentValue?.[childKey])
|
|
709
|
-
}))
|
|
710
|
-
.sort((a, b) => (a.config?.position || 0) - (b.config?.position || 0));
|
|
711
|
-
|
|
712
|
-
const splits = [];
|
|
713
|
-
let currentSplit = {
|
|
714
|
-
key: `${parentKey}_part_0`,
|
|
715
|
-
config: {
|
|
716
|
-
...parentConfig,
|
|
717
|
-
inputs: {}
|
|
718
|
-
},
|
|
719
|
-
estimatedHeight: 40 // Base height for parent structure
|
|
720
|
-
};
|
|
721
|
-
let splitIndex = 0;
|
|
722
|
-
|
|
723
|
-
childItems.forEach(child => {
|
|
724
|
-
if (currentSplit.estimatedHeight + child.estimatedHeight > maxHeight && Object.keys(currentSplit.config.inputs).length > 0) {
|
|
725
|
-
splits.push(currentSplit);
|
|
726
|
-
splitIndex++;
|
|
727
|
-
currentSplit = {
|
|
728
|
-
key: `${parentKey}_part_${splitIndex}`,
|
|
729
|
-
config: {
|
|
730
|
-
...parentConfig,
|
|
731
|
-
label: parentConfig.label,
|
|
732
|
-
inputs: {}
|
|
733
|
-
},
|
|
734
|
-
estimatedHeight: 40
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
currentSplit.config.inputs[child.key] = child.config;
|
|
739
|
-
currentSplit.estimatedHeight += child.estimatedHeight;
|
|
740
|
-
});
|
|
741
|
-
|
|
742
|
-
if (Object.keys(currentSplit.config.inputs).length > 0) {
|
|
743
|
-
splits.push(currentSplit);
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
return splits.length > 0 ? splits : [{ key: parentKey, config: parentConfig, estimatedHeight: estimateTreeNodeHeight(parentKey, parentConfig, parentValue) }];
|
|
747
|
-
};
|
|
748
|
-
|
|
749
528
|
const pdfConfig = useMemo(() => {
|
|
750
529
|
const sections = [];
|
|
751
530
|
|
|
@@ -756,32 +535,27 @@ const PdfForm = ({
|
|
|
756
535
|
return;
|
|
757
536
|
}
|
|
758
537
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
style: {
|
|
781
|
-
marginBottom: '20px',
|
|
782
|
-
padding: '0 20px'
|
|
783
|
-
}
|
|
784
|
-
});
|
|
538
|
+
sections.push({
|
|
539
|
+
render: () => (
|
|
540
|
+
<div key={sectionKey} className="pdf-form-section">
|
|
541
|
+
<PdfFormContent
|
|
542
|
+
form={{ [sectionKey]: section }}
|
|
543
|
+
data={data}
|
|
544
|
+
t={t}
|
|
545
|
+
user={user}
|
|
546
|
+
title={formName}
|
|
547
|
+
source={source}
|
|
548
|
+
version={version}
|
|
549
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
550
|
+
getAppHeader={getAppHeader}
|
|
551
|
+
app={app}
|
|
552
|
+
/>
|
|
553
|
+
</div>
|
|
554
|
+
),
|
|
555
|
+
style: {
|
|
556
|
+
marginBottom: '20px',
|
|
557
|
+
padding: '0 20px'
|
|
558
|
+
}
|
|
785
559
|
});
|
|
786
560
|
});
|
|
787
561
|
|