ats-form-react-pdf-layout 4.4.4 → 4.4.6
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 +27 -5
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -2577,6 +2577,24 @@ const warnUnavailableSpace = (node) => {
|
|
|
2577
2577
|
// eslint-disable-next-line no-console
|
|
2578
2578
|
console.warn(`Node of type ${node.type} can't wrap between pages and it's bigger than available page height`);
|
|
2579
2579
|
};
|
|
2580
|
+
const breakableViewChild = (children, height, path = '', currentChildren) => {
|
|
2581
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
2582
|
+
if (children[i].type !== 'VIEW')
|
|
2583
|
+
continue;
|
|
2584
|
+
if (shouldBreak(children[i], children.slice(i + 1, height), height, currentChildren)) {
|
|
2585
|
+
return {
|
|
2586
|
+
child: children[i],
|
|
2587
|
+
path: `${path}/${i}`,
|
|
2588
|
+
};
|
|
2589
|
+
}
|
|
2590
|
+
if (children[i].children && children[i].children.length > 0) {
|
|
2591
|
+
const breakable = breakableViewChild(children[i].children, height, `${path}/${i}`, currentChildren);
|
|
2592
|
+
if (breakable)
|
|
2593
|
+
return breakable;
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
return null;
|
|
2597
|
+
};
|
|
2580
2598
|
const splitNodes = (height, contentArea, nodes) => {
|
|
2581
2599
|
const currentChildren = [];
|
|
2582
2600
|
const nextChildren = [];
|
|
@@ -2588,6 +2606,9 @@ const splitNodes = (height, contentArea, nodes) => {
|
|
|
2588
2606
|
const nodeHeight = child.box.height;
|
|
2589
2607
|
const isOutside = height <= nodeTop;
|
|
2590
2608
|
const shouldBreak$1 = shouldBreak(child, futureNodes, height, currentChildren);
|
|
2609
|
+
const firstBreakableViewChild = child.children &&
|
|
2610
|
+
child.children.length > 0 &&
|
|
2611
|
+
breakableViewChild(child.children, height, '', currentChildren);
|
|
2591
2612
|
const prevChild = nodes.length > 0 && i > 0 ? nodes[i - 1] : undefined;
|
|
2592
2613
|
const shouldSplit = height + SAFETY_THRESHOLD < nodeTop + nodeHeight;
|
|
2593
2614
|
const canWrap = getWrap(child, prevChild, currentChildren);
|
|
@@ -2608,6 +2629,7 @@ const splitNodes = (height, contentArea, nodes) => {
|
|
|
2608
2629
|
currentChildren.push(child);
|
|
2609
2630
|
nextChildren.push(...futureNodes);
|
|
2610
2631
|
warnUnavailableSpace(child);
|
|
2632
|
+
break;
|
|
2611
2633
|
}
|
|
2612
2634
|
else {
|
|
2613
2635
|
// We don't want to break non wrapable nodes, so we just let them be.
|
|
@@ -2621,8 +2643,8 @@ const splitNodes = (height, contentArea, nodes) => {
|
|
|
2621
2643
|
const next = Object.assign({}, child, { box, props });
|
|
2622
2644
|
currentChildren.push(...futureFixedNodes);
|
|
2623
2645
|
nextChildren.push(next, ...futureNodes);
|
|
2646
|
+
break;
|
|
2624
2647
|
}
|
|
2625
|
-
break;
|
|
2626
2648
|
}
|
|
2627
2649
|
if (shouldBreak$1) {
|
|
2628
2650
|
const box = Object.assign({}, child.box, { top: child.box.top - height });
|
|
@@ -2635,7 +2657,7 @@ const splitNodes = (height, contentArea, nodes) => {
|
|
|
2635
2657
|
nextChildren.push(next, ...futureNodes);
|
|
2636
2658
|
break;
|
|
2637
2659
|
}
|
|
2638
|
-
if (shouldSplit) {
|
|
2660
|
+
if (shouldSplit || firstBreakableViewChild) {
|
|
2639
2661
|
const [currentChild, nextChild] = split(child, height, contentArea);
|
|
2640
2662
|
// All children are moved to the next page, it doesn't make sense to show the parent on the current page
|
|
2641
2663
|
if (child.children.length > 0 && currentChild.children.length === 0) {
|
|
@@ -2644,10 +2666,10 @@ const splitNodes = (height, contentArea, nodes) => {
|
|
|
2644
2666
|
// currentChildren.push(child, ...futureFixedNodes);
|
|
2645
2667
|
// nextChildren.push(...futureNodes);
|
|
2646
2668
|
// } else {
|
|
2647
|
-
const box = Object.assign({},
|
|
2648
|
-
top:
|
|
2669
|
+
const box = Object.assign({}, nextChild.box, {
|
|
2670
|
+
top: nextChild.box.top - height,
|
|
2649
2671
|
});
|
|
2650
|
-
const next = Object.assign({},
|
|
2672
|
+
const next = Object.assign({}, nextChild, { box });
|
|
2651
2673
|
currentChildren.push(...futureFixedNodes);
|
|
2652
2674
|
nextChildren.push(next, ...futureNodes);
|
|
2653
2675
|
// }
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ats-form-react-pdf-layout",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Resolve document component's layout",
|
|
6
|
-
"author": "
|
|
7
|
-
"homepage": "https://github.com/
|
|
6
|
+
"author": "Atharva System",
|
|
7
|
+
"homepage": "https://github.com/Atharva-System/react-pdf#readme",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.js",
|
|
10
10
|
"types": "./lib/index.d.ts",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/
|
|
13
|
+
"url": "https://github.com/Atharva-System/react-pdf.git",
|
|
14
14
|
"directory": "packages/layout"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@react-pdf/fns": "3.1.2",
|
|
24
24
|
"@react-pdf/image": "^3.0.3",
|
|
25
25
|
"@react-pdf/primitives": "^4.1.1",
|
|
26
|
-
"ats-form-react-pdf-stylesheet": "^6.1.
|
|
26
|
+
"ats-form-react-pdf-stylesheet": "^6.1.4",
|
|
27
27
|
"@react-pdf/textkit": "^6.0.0",
|
|
28
28
|
"@react-pdf/types": "^2.9.1",
|
|
29
29
|
"emoji-regex-xs": "^1.0.0",
|