ats-form-react-pdf-layout 4.4.6 → 4.4.8
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/lib/index.js +24 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1210,6 +1210,9 @@ const NON_WRAP_TYPES = [P.Svg, P.Note, P.Image, P.Canvas];
|
|
|
1210
1210
|
const canCauseBlankSpace = (node, prevNode, currentChildren) => {
|
|
1211
1211
|
if (!('preventBlankSpace' in node.props))
|
|
1212
1212
|
return false;
|
|
1213
|
+
// Don't override explicit wrap: false - respect user's intent to move to next page
|
|
1214
|
+
if ('wrap' in node.props && node.props.wrap === false)
|
|
1215
|
+
return false;
|
|
1213
1216
|
const prevNodeHasHeightOne = prevNode?.box?.height === 1;
|
|
1214
1217
|
const childrenIsEmpty = currentChildren?.length === 0;
|
|
1215
1218
|
// padding/margin case
|
|
@@ -1227,6 +1230,9 @@ const getWrap = (node, prevNode, currentChildren) => {
|
|
|
1227
1230
|
return false;
|
|
1228
1231
|
if (!node.props)
|
|
1229
1232
|
return true;
|
|
1233
|
+
// Check wrap prop first - if explicitly set to false, respect that
|
|
1234
|
+
if ('wrap' in node.props && node.props.wrap === false)
|
|
1235
|
+
return false;
|
|
1230
1236
|
if (canCauseBlankSpace(node, prevNode, currentChildren))
|
|
1231
1237
|
return true;
|
|
1232
1238
|
return 'wrap' in node.props ? node.props.wrap : true;
|
|
@@ -1337,7 +1343,11 @@ const shouldBreak = (child, futureElements, height, previousElements) => {
|
|
|
1337
1343
|
if ('fixed' in child.props)
|
|
1338
1344
|
return false;
|
|
1339
1345
|
const shouldSplit = height < child.box.top + child.box.height;
|
|
1340
|
-
|
|
1346
|
+
// Get the previous sibling from the previous elements for consistent wrap calculation
|
|
1347
|
+
const prevNode = previousElements.length > 0
|
|
1348
|
+
? previousElements[previousElements.length - 1]
|
|
1349
|
+
: child;
|
|
1350
|
+
const canWrap = getWrap(child, prevNode, previousElements);
|
|
1341
1351
|
// Calculate the y coordinate where the desired presence of the child ends
|
|
1342
1352
|
const endOfPresence = getEndOfPresence(child, futureElements);
|
|
1343
1353
|
// If the child is already at the top of the page, breaking won't improve its presence
|
|
@@ -2581,7 +2591,7 @@ const breakableViewChild = (children, height, path = '', currentChildren) => {
|
|
|
2581
2591
|
for (let i = 0; i < children.length; i += 1) {
|
|
2582
2592
|
if (children[i].type !== 'VIEW')
|
|
2583
2593
|
continue;
|
|
2584
|
-
if (shouldBreak(children[i], children.slice(i + 1
|
|
2594
|
+
if (shouldBreak(children[i], children.slice(i + 1), height, currentChildren)) {
|
|
2585
2595
|
return {
|
|
2586
2596
|
child: children[i],
|
|
2587
2597
|
path: `${path}/${i}`,
|
|
@@ -2646,6 +2656,18 @@ const splitNodes = (height, contentArea, nodes) => {
|
|
|
2646
2656
|
break;
|
|
2647
2657
|
}
|
|
2648
2658
|
}
|
|
2659
|
+
// Element fits on a full page but not in remaining space and cannot wrap - move to next page
|
|
2660
|
+
if (fitsInsidePage && shouldSplit && !canWrap) {
|
|
2661
|
+
const box = Object.assign({}, child.box, { top: child.box.top - height });
|
|
2662
|
+
const props = Object.assign({}, child.props, {
|
|
2663
|
+
wrap: true,
|
|
2664
|
+
break: false,
|
|
2665
|
+
});
|
|
2666
|
+
const next = Object.assign({}, child, { box, props });
|
|
2667
|
+
currentChildren.push(...futureFixedNodes);
|
|
2668
|
+
nextChildren.push(next, ...futureNodes);
|
|
2669
|
+
break;
|
|
2670
|
+
}
|
|
2649
2671
|
if (shouldBreak$1) {
|
|
2650
2672
|
const box = Object.assign({}, child.box, { top: child.box.top - height });
|
|
2651
2673
|
const props = Object.assign({}, child.props, {
|