@rnichi11/react-column-pdf-layout 4.4.4-rnichi.0 → 4.5.0
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.d.ts +1 -1
- package/lib/index.js +40 -31
- package/package.json +3 -3
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference path="../globals.d.ts" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { Style, SafeStyle, Transform } from '@react-pdf
|
|
3
|
+
import { Style, SafeStyle, Transform } from '@rnichi11/react-column-pdf-stylesheet';
|
|
4
4
|
import { YogaNode } from 'yoga-layout/load';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import * as P from '@react-pdf/primitives';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { upperFirst, capitalize, parseFloat as parseFloat$1, without, pick, compose, evolve, mapValues, matchPercent, castArray, isNil, omit, asyncCompose } from '@react-pdf/fns';
|
|
2
2
|
import * as P from '@react-pdf/primitives';
|
|
3
|
-
import resolveStyle, { transformColor, flatten } from '@react-pdf
|
|
3
|
+
import resolveStyle, { transformColor, flatten } from '@rnichi11/react-column-pdf-stylesheet';
|
|
4
4
|
import layoutEngine, { fontSubstitution, wordHyphenation, scriptItemizer, textDecoration, justification, linebreaker, bidi, fromFragments } from '@rnichi11/react-column-pdf-textkit';
|
|
5
5
|
import * as Yoga from 'yoga-layout/load';
|
|
6
6
|
import { loadYoga as loadYoga$1 } from 'yoga-layout/load';
|
|
@@ -2987,6 +2987,7 @@ const allFixed = (nodes) => nodes.every(isFixed);
|
|
|
2987
2987
|
const isDynamic = (node) => node.props && 'render' in node.props;
|
|
2988
2988
|
const relayoutPage = compose(resolveTextLayout, resolvePageDimensions, resolveInheritance);
|
|
2989
2989
|
const relayoutDynamicPage = compose(resolveTextLayout, resolvePageDimensions, resolveInheritance, resolvePageStyles);
|
|
2990
|
+
const relayoutDynamicPageForIndices = compose(resolveTextLayout, resolvePageDimensions, resolveInheritance);
|
|
2990
2991
|
const warnUnavailableSpace = (node) => {
|
|
2991
2992
|
console.warn(`Node of type ${node.type} can't wrap between pages and it's bigger than available page height`);
|
|
2992
2993
|
};
|
|
@@ -3032,31 +3033,9 @@ const splitNodes = (height, contentArea, nodes, fontStore, containerWidth) => {
|
|
|
3032
3033
|
nextChildren.push(next, ...futureNodes);
|
|
3033
3034
|
break;
|
|
3034
3035
|
}
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
if (child.children.length > 0 && currentChild.children.length === 0) {
|
|
3039
|
-
// But if the current page is empty then we can just include the parent on the current page
|
|
3040
|
-
if (currentChildren.length === 0) {
|
|
3041
|
-
currentChildren.push(child, ...futureFixedNodes);
|
|
3042
|
-
nextChildren.push(...futureNodes);
|
|
3043
|
-
}
|
|
3044
|
-
else {
|
|
3045
|
-
const box = Object.assign({}, child.box, {
|
|
3046
|
-
top: child.box.top - height,
|
|
3047
|
-
});
|
|
3048
|
-
const next = Object.assign({}, child, { box });
|
|
3049
|
-
currentChildren.push(...futureFixedNodes);
|
|
3050
|
-
nextChildren.push(next, ...futureNodes);
|
|
3051
|
-
}
|
|
3052
|
-
break;
|
|
3053
|
-
}
|
|
3054
|
-
if (currentChild)
|
|
3055
|
-
currentChildren.push(currentChild);
|
|
3056
|
-
if (nextChild)
|
|
3057
|
-
nextChildren.push(nextChild);
|
|
3058
|
-
continue;
|
|
3059
|
-
}
|
|
3036
|
+
// Handle multi-column containers before generic split logic.
|
|
3037
|
+
// `child.box.height` here comes from pre-column layout and can overestimate
|
|
3038
|
+
// required height, which would trigger premature page splits.
|
|
3060
3039
|
if (isView(child) &&
|
|
3061
3040
|
(child.props?.columns ?? 1) > 1 &&
|
|
3062
3041
|
fontStore) {
|
|
@@ -3091,16 +3070,41 @@ const splitNodes = (height, contentArea, nodes, fontStore, containerWidth) => {
|
|
|
3091
3070
|
children: overflowChildren,
|
|
3092
3071
|
box: { ...viewChild.box, top: 0 },
|
|
3093
3072
|
});
|
|
3094
|
-
|
|
3073
|
+
// Keep fixed siblings (eg fixed footers/headers) on current page too.
|
|
3074
|
+
currentChildren.push(currentViewWithCols, ...futureFixedNodes);
|
|
3095
3075
|
nextChildren.push(nextViewWithOverflow, ...futureNodes);
|
|
3096
3076
|
break;
|
|
3097
3077
|
}
|
|
3098
3078
|
const childToPush = transformViewToColumns(viewChild, height - nodeTop, contentArea, fontStore, containerWidth);
|
|
3099
3079
|
currentChildren.push(childToPush);
|
|
3080
|
+
continue;
|
|
3100
3081
|
}
|
|
3101
|
-
|
|
3102
|
-
|
|
3082
|
+
if (shouldSplit) {
|
|
3083
|
+
const [currentChild, nextChild] = split(child, height, contentArea, fontStore, undefined, containerWidth);
|
|
3084
|
+
// All children are moved to the next page, it doesn't make sense to show the parent on the current page
|
|
3085
|
+
if (child.children.length > 0 && currentChild.children.length === 0) {
|
|
3086
|
+
// But if the current page is empty then we can just include the parent on the current page
|
|
3087
|
+
if (currentChildren.length === 0) {
|
|
3088
|
+
currentChildren.push(child, ...futureFixedNodes);
|
|
3089
|
+
nextChildren.push(...futureNodes);
|
|
3090
|
+
}
|
|
3091
|
+
else {
|
|
3092
|
+
const box = Object.assign({}, child.box, {
|
|
3093
|
+
top: child.box.top - height,
|
|
3094
|
+
});
|
|
3095
|
+
const next = Object.assign({}, child, { box });
|
|
3096
|
+
currentChildren.push(...futureFixedNodes);
|
|
3097
|
+
nextChildren.push(next, ...futureNodes);
|
|
3098
|
+
}
|
|
3099
|
+
break;
|
|
3100
|
+
}
|
|
3101
|
+
if (currentChild)
|
|
3102
|
+
currentChildren.push(currentChild);
|
|
3103
|
+
if (nextChild)
|
|
3104
|
+
nextChildren.push(nextChild);
|
|
3105
|
+
continue;
|
|
3103
3106
|
}
|
|
3107
|
+
currentChildren.push(child);
|
|
3104
3108
|
}
|
|
3105
3109
|
return [currentChildren, nextChildren];
|
|
3106
3110
|
};
|
|
@@ -3199,9 +3203,12 @@ const resolveDynamicNodes = (props, node) => {
|
|
|
3199
3203
|
const lines = isNodeDynamic ? null : node.lines;
|
|
3200
3204
|
return Object.assign({}, node, { box, lines, children });
|
|
3201
3205
|
};
|
|
3202
|
-
const resolveDynamicPage = (props, page, fontStore, yoga) => {
|
|
3206
|
+
const resolveDynamicPage = (props, page, fontStore, yoga, options) => {
|
|
3203
3207
|
if (shouldResolveDynamicNodes(page)) {
|
|
3204
3208
|
const resolvedPage = resolveDynamicNodes(props, page);
|
|
3209
|
+
if (options?.resolveStyles === false) {
|
|
3210
|
+
return relayoutDynamicPageForIndices(resolvedPage, fontStore, yoga);
|
|
3211
|
+
}
|
|
3205
3212
|
return relayoutDynamicPage(resolvedPage, fontStore, yoga);
|
|
3206
3213
|
}
|
|
3207
3214
|
return page;
|
|
@@ -3237,7 +3244,9 @@ const resolvePageIndices = (fontStore, yoga, page, pageNumber, pages) => {
|
|
|
3237
3244
|
subPageNumber: page.subPageNumber + 1,
|
|
3238
3245
|
subPageTotalPages: page.subPageTotalPages,
|
|
3239
3246
|
};
|
|
3240
|
-
return resolveDynamicPage(props, page, fontStore, yoga
|
|
3247
|
+
return resolveDynamicPage(props, page, fontStore, yoga, {
|
|
3248
|
+
resolveStyles: false,
|
|
3249
|
+
});
|
|
3241
3250
|
};
|
|
3242
3251
|
const assocSubPageData = (subpages) => {
|
|
3243
3252
|
return subpages.map((page, i) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnichi11/react-column-pdf-layout",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Multi-column layout engine for react-column-pdf",
|
|
6
6
|
"author": "rnichi1",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"@react-pdf/fns": "3.1.2",
|
|
24
24
|
"@react-pdf/image": "^3.0.4",
|
|
25
25
|
"@react-pdf/primitives": "^4.1.1",
|
|
26
|
-
"@react-pdf
|
|
26
|
+
"@rnichi11/react-column-pdf-stylesheet": "^6.2.0",
|
|
27
27
|
"@rnichi11/react-column-pdf-textkit": "6.1.1",
|
|
28
|
-
"@react-pdf/types": "^2.9.
|
|
28
|
+
"@react-pdf/types": "^2.9.3",
|
|
29
29
|
"emoji-regex-xs": "^1.0.0",
|
|
30
30
|
"queue": "^6.0.1",
|
|
31
31
|
"yoga-layout": "^3.2.1"
|