ats-form-react-pdf-layout 4.4.7 → 4.4.9
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 +42 -11
- 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;
|
|
@@ -2650,6 +2656,30 @@ const splitNodes = (height, contentArea, nodes) => {
|
|
|
2650
2656
|
break;
|
|
2651
2657
|
}
|
|
2652
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
|
+
}
|
|
2671
|
+
// Element fits on a full page but not in remaining space - move to next page to keep together
|
|
2672
|
+
// This handles the case where wrap is true (default) but we still want to avoid splitting
|
|
2673
|
+
// if the element would fit entirely on the next page
|
|
2674
|
+
const remainingSpace = height - nodeTop;
|
|
2675
|
+
const wouldBarelyFitOnCurrentPage = remainingSpace < nodeHeight * 0.3; // Less than 30% fits
|
|
2676
|
+
if (fitsInsidePage && shouldSplit && wouldBarelyFitOnCurrentPage && currentChildren.length > 0) {
|
|
2677
|
+
const box = Object.assign({}, child.box, { top: child.box.top - height });
|
|
2678
|
+
const next = Object.assign({}, child, { box });
|
|
2679
|
+
currentChildren.push(...futureFixedNodes);
|
|
2680
|
+
nextChildren.push(next, ...futureNodes);
|
|
2681
|
+
break;
|
|
2682
|
+
}
|
|
2653
2683
|
if (shouldBreak$1) {
|
|
2654
2684
|
const box = Object.assign({}, child.box, { top: child.box.top - height });
|
|
2655
2685
|
const props = Object.assign({}, child.props, {
|
|
@@ -2663,20 +2693,21 @@ const splitNodes = (height, contentArea, nodes) => {
|
|
|
2663
2693
|
}
|
|
2664
2694
|
if (shouldSplit || firstBreakableViewChild) {
|
|
2665
2695
|
const [currentChild, nextChild] = split(child, height, contentArea);
|
|
2666
|
-
//
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2696
|
+
// Check if all non-fixed children are moved to the next page
|
|
2697
|
+
const currentNonFixedChildren = currentChild.children
|
|
2698
|
+
? currentChild.children.filter((c) => !isFixed(c))
|
|
2699
|
+
: [];
|
|
2700
|
+
const hasNonFixedChildren = child.children
|
|
2701
|
+
? child.children.filter((c) => !isFixed(c)).length > 0
|
|
2702
|
+
: false;
|
|
2703
|
+
// All meaningful children are moved to the next page, move the parent too
|
|
2704
|
+
if (hasNonFixedChildren && currentNonFixedChildren.length === 0) {
|
|
2705
|
+
const box = Object.assign({}, child.box, {
|
|
2706
|
+
top: child.box.top - height,
|
|
2675
2707
|
});
|
|
2676
|
-
const next = Object.assign({},
|
|
2708
|
+
const next = Object.assign({}, child, { box });
|
|
2677
2709
|
currentChildren.push(...futureFixedNodes);
|
|
2678
2710
|
nextChildren.push(next, ...futureNodes);
|
|
2679
|
-
// }
|
|
2680
2711
|
break;
|
|
2681
2712
|
}
|
|
2682
2713
|
if (currentChild)
|