@pdfme/jsx 6.1.1-dev.21 → 6.1.1-dev.22
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/README.md +16 -0
- package/dist/index.js +84 -50
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,9 +42,25 @@ it provides its own `jsx-runtime` and `jsx-dev-runtime`.
|
|
|
42
42
|
shapes.
|
|
43
43
|
- Layout children can use `margin`. `Stack` and `Row` support `alignItems` for simple cross-axis
|
|
44
44
|
alignment without trying to implement full CSS/Flexbox.
|
|
45
|
+
- `Stack` and `Row` support `justifyContent="start" | "center" | "end" | "space-between"` for
|
|
46
|
+
main-axis spacing. `Stack` uses this most predictably with an explicit `height`; `Row` uses it most
|
|
47
|
+
predictably with an explicit `width`.
|
|
45
48
|
- `Stack` defaults to `alignItems="stretch"` to preserve full-width stacking. Use an explicit child
|
|
46
49
|
`width` when you want `alignItems="center"` or `"end"` to visibly move that child.
|
|
47
50
|
- `Row` defaults to `alignItems="start"` and intentionally does not support cross-axis stretch yet.
|
|
51
|
+
- Row children can use `flexGrow` or `flex` as a grow weight. If `width` is also set, it is used as
|
|
52
|
+
the basis before remaining width is distributed.
|
|
53
|
+
`flex` is only a short alias for `flexGrow`, not the CSS `flex` shorthand.
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<Row width={120}>
|
|
57
|
+
<Text width={20} flex={1}>A</Text>
|
|
58
|
+
<Text width={20} flex={3}>B</Text>
|
|
59
|
+
</Row>
|
|
60
|
+
// A width: 40, B width: 80
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- `flexGrow={0}` without `width` produces a zero-width Row child.
|
|
48
64
|
- `PageBreak` is supported only along a `Page` / `Stack` / `Box` layout path. It is rejected inside
|
|
49
65
|
`Row`, leaf schemas, `List`, and `Table`.
|
|
50
66
|
- All `Page` nodes in one `renderToTemplate` call must use the same page size, orientation, and
|
package/dist/index.js
CHANGED
|
@@ -67,7 +67,8 @@ var renderToTemplate = async (node, options = {}) => {
|
|
|
67
67
|
};
|
|
68
68
|
await layoutChildren(page.children, frame, "stack", {
|
|
69
69
|
gap: 0,
|
|
70
|
-
alignItems: "stretch"
|
|
70
|
+
alignItems: "stretch",
|
|
71
|
+
justifyContent: "start"
|
|
71
72
|
}, ctx);
|
|
72
73
|
pageSchemas.push(ctx.schemas);
|
|
73
74
|
}
|
|
@@ -133,7 +134,7 @@ var layoutChildren = async (children, frame, mode, opts, ctx) => {
|
|
|
133
134
|
const widths = mode === "row" ? resolveRowWidths(items, frame.width, opts.gap) : void 0;
|
|
134
135
|
let cursor = 0;
|
|
135
136
|
let crossMax = 0;
|
|
136
|
-
const
|
|
137
|
+
const layoutItems = [];
|
|
137
138
|
for (let i = 0; i < items.length; i += 1) {
|
|
138
139
|
const child = items[i];
|
|
139
140
|
const margin = getChildMargin(child);
|
|
@@ -155,68 +156,91 @@ var layoutChildren = async (children, frame, mode, opts, ctx) => {
|
|
|
155
156
|
const schemaStart = ctx.schemas.length;
|
|
156
157
|
const size = typeof child === "string" || typeof child === "number" ? await renderText({ children: String(child) }, childFrame, ctx) : await renderElement(child, childFrame, mode, ctx);
|
|
157
158
|
const schemaEnd = ctx.schemas.length;
|
|
159
|
+
const mainSize = mode === "stack" ? margin.top + size.height + margin.bottom : margin.left + width + margin.right;
|
|
160
|
+
const outerHeight = margin.top + size.height + margin.bottom;
|
|
161
|
+
layoutItems.push({
|
|
162
|
+
schemaStart,
|
|
163
|
+
schemaEnd,
|
|
164
|
+
outerHeight
|
|
165
|
+
});
|
|
158
166
|
if (mode === "stack") {
|
|
159
167
|
const outerWidth = margin.left + size.width + margin.right;
|
|
160
168
|
const dx = resolveAlignOffset(frame.width, outerWidth, opts.alignItems);
|
|
161
169
|
if (dx !== 0) shiftSchemas(ctx.schemas, schemaStart, schemaEnd, dx, 0);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
schemaEnd,
|
|
165
|
-
outerHeight: margin.top + size.height + margin.bottom
|
|
166
|
-
});
|
|
167
|
-
const advance = mode === "stack" ? margin.top + size.height + margin.bottom : margin.left + width + margin.right;
|
|
168
|
-
cursor += advance + (i < items.length - 1 ? opts.gap : 0);
|
|
170
|
+
}
|
|
171
|
+
cursor += mainSize + (i < items.length - 1 ? opts.gap : 0);
|
|
169
172
|
crossMax = Math.max(crossMax, mode === "stack" ? margin.left + size.width + margin.right : margin.top + size.height + margin.bottom);
|
|
170
173
|
}
|
|
174
|
+
const contentMainSize = cursor;
|
|
175
|
+
const containerMainSize = opts.mainSize ?? contentMainSize;
|
|
176
|
+
applyJustifyContent(ctx.schemas, layoutItems, mode, contentMainSize, containerMainSize, opts);
|
|
171
177
|
if (mode === "row") {
|
|
172
178
|
const rowHeight = opts.crossSize ?? crossMax;
|
|
173
|
-
for (const item of
|
|
179
|
+
for (const item of layoutItems) {
|
|
174
180
|
const dy = resolveAlignOffset(rowHeight, item.outerHeight, opts.alignItems);
|
|
175
181
|
if (dy !== 0) shiftSchemas(ctx.schemas, item.schemaStart, item.schemaEnd, 0, dy);
|
|
176
182
|
}
|
|
177
183
|
return {
|
|
178
|
-
width:
|
|
184
|
+
width: containerMainSize,
|
|
179
185
|
height: rowHeight
|
|
180
186
|
};
|
|
181
187
|
}
|
|
182
188
|
return {
|
|
183
189
|
width: crossMax,
|
|
184
|
-
height:
|
|
190
|
+
height: containerMainSize
|
|
185
191
|
};
|
|
186
192
|
};
|
|
187
193
|
var resolveRowWidths = (items, frameWidth, gap) => {
|
|
188
|
-
let
|
|
189
|
-
let
|
|
190
|
-
const
|
|
194
|
+
let usedWidth = 0;
|
|
195
|
+
let totalGrow = 0;
|
|
196
|
+
const parts = items.map((item) => {
|
|
191
197
|
const margin = getChildMargin(item);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
flexCount += 1;
|
|
203
|
-
fixedWidth += margin.left + margin.right;
|
|
198
|
+
const width = getChildWidth(item);
|
|
199
|
+
const grow = getChildFlexGrow(item) ?? (width == null ? 1 : 0);
|
|
200
|
+
const basis = width ?? 0;
|
|
201
|
+
usedWidth += basis + margin.left + margin.right;
|
|
202
|
+
totalGrow += grow;
|
|
203
|
+
return {
|
|
204
|
+
basis,
|
|
205
|
+
grow
|
|
206
|
+
};
|
|
204
207
|
});
|
|
205
|
-
const remaining = Math.max(0, frameWidth -
|
|
206
|
-
const
|
|
207
|
-
return
|
|
208
|
+
const remaining = Math.max(0, frameWidth - usedWidth - Math.max(0, items.length - 1) * gap);
|
|
209
|
+
const flexUnit = totalGrow > 0 ? remaining / totalGrow : 0;
|
|
210
|
+
return parts.map(({ basis, grow }) => basis + grow * flexUnit);
|
|
208
211
|
};
|
|
209
212
|
var getChildMargin = (child) => {
|
|
210
213
|
if (typeof child === "string" || typeof child === "number") return resolveBoxSides();
|
|
211
214
|
return resolveBoxSides(child.props.margin);
|
|
212
215
|
};
|
|
216
|
+
var getChildWidth = (child) => {
|
|
217
|
+
if (typeof child === "string" || typeof child === "number") return void 0;
|
|
218
|
+
const width = child.props.width;
|
|
219
|
+
return typeof width === "number" ? width : void 0;
|
|
220
|
+
};
|
|
221
|
+
var getChildFlexGrow = (child) => {
|
|
222
|
+
if (typeof child === "string" || typeof child === "number") return void 0;
|
|
223
|
+
const props = child.props;
|
|
224
|
+
const flexGrow = props.flexGrow ?? props.flex;
|
|
225
|
+
return typeof flexGrow === "number" ? Math.max(0, flexGrow) : void 0;
|
|
226
|
+
};
|
|
213
227
|
var resolveStackChildWidth = (child, frameWidth, margin) => {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (typeof width === "number") return width;
|
|
217
|
-
}
|
|
228
|
+
const width = getChildWidth(child);
|
|
229
|
+
if (width != null) return width;
|
|
218
230
|
return Math.max(0, frameWidth - margin.left - margin.right);
|
|
219
231
|
};
|
|
232
|
+
var applyJustifyContent = (schemas, items, mode, contentMainSize, containerMainSize, opts) => {
|
|
233
|
+
const extraSpace = Math.max(0, containerMainSize - contentMainSize);
|
|
234
|
+
if (extraSpace === 0 || opts.justifyContent === "start") return;
|
|
235
|
+
const extraGap = opts.justifyContent === "space-between" && items.length > 1 ? extraSpace / (items.length - 1) : 0;
|
|
236
|
+
const startOffset = opts.justifyContent === "center" ? extraSpace / 2 : opts.justifyContent === "end" ? extraSpace : 0;
|
|
237
|
+
let runningExtraGap = 0;
|
|
238
|
+
for (const item of items) {
|
|
239
|
+
const offset = startOffset + runningExtraGap;
|
|
240
|
+
if (offset !== 0) shiftSchemas(schemas, item.schemaStart, item.schemaEnd, mode === "row" ? offset : 0, mode === "stack" ? offset : 0);
|
|
241
|
+
runningExtraGap += extraGap;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
220
244
|
var resolveAlignOffset = (containerSize, itemSize, alignItems) => {
|
|
221
245
|
if (alignItems === "center") return Math.max(0, (containerSize - itemSize) / 2);
|
|
222
246
|
if (alignItems === "end") return Math.max(0, containerSize - itemSize);
|
|
@@ -233,32 +257,36 @@ var shiftSchemas = (schemas, start, end, dx, dy) => {
|
|
|
233
257
|
}
|
|
234
258
|
};
|
|
235
259
|
var renderElement = async (element, frame, parentMode, ctx) => {
|
|
260
|
+
const props = parentMode === "row" && getChildFlexGrow(element) != null ? {
|
|
261
|
+
...element.props,
|
|
262
|
+
width: frame.width
|
|
263
|
+
} : element.props;
|
|
236
264
|
switch (element.kind) {
|
|
237
|
-
case "stack": return renderStack(
|
|
238
|
-
case "row": return renderRow(
|
|
239
|
-
case "box": return renderBox(
|
|
240
|
-
case "spacer": return Promise.resolve(renderSpacer(
|
|
265
|
+
case "stack": return renderStack(props, element.children, frame, ctx);
|
|
266
|
+
case "row": return renderRow(props, element.children, frame, ctx);
|
|
267
|
+
case "box": return renderBox(props, element.children, frame, parentMode, ctx);
|
|
268
|
+
case "spacer": return Promise.resolve(renderSpacer(props));
|
|
241
269
|
case "text": return renderText({
|
|
242
|
-
...
|
|
270
|
+
...props,
|
|
243
271
|
children: element.children
|
|
244
272
|
}, frame, ctx);
|
|
245
273
|
case "multiVariableText": return renderMultiVariableText({
|
|
246
|
-
...
|
|
274
|
+
...props,
|
|
247
275
|
children: element.children
|
|
248
276
|
}, frame, ctx);
|
|
249
|
-
case "image": return renderImage(
|
|
277
|
+
case "image": return renderImage(props, frame, ctx);
|
|
250
278
|
case "svg": return renderSvg({
|
|
251
|
-
...
|
|
279
|
+
...props,
|
|
252
280
|
children: element.children
|
|
253
281
|
}, frame, ctx);
|
|
254
|
-
case "rectangle": return renderShape("rectangle",
|
|
255
|
-
case "ellipse": return renderShape("ellipse",
|
|
256
|
-
case "line": return renderLine(
|
|
282
|
+
case "rectangle": return renderShape("rectangle", props, frame, ctx);
|
|
283
|
+
case "ellipse": return renderShape("ellipse", props, frame, ctx);
|
|
284
|
+
case "line": return renderLine(props, frame, ctx);
|
|
257
285
|
case "list": return renderList({
|
|
258
|
-
...
|
|
286
|
+
...props,
|
|
259
287
|
children: element.children
|
|
260
288
|
}, frame, ctx);
|
|
261
|
-
case "table": return renderTable(
|
|
289
|
+
case "table": return renderTable(props, frame, ctx);
|
|
262
290
|
default: return {
|
|
263
291
|
width: 0,
|
|
264
292
|
height: 0
|
|
@@ -267,10 +295,13 @@ var renderElement = async (element, frame, parentMode, ctx) => {
|
|
|
267
295
|
};
|
|
268
296
|
var renderStack = (props, children, frame, ctx) => layoutChildren(children, {
|
|
269
297
|
...frame,
|
|
270
|
-
width: props.width ?? frame.width
|
|
298
|
+
width: props.width ?? frame.width,
|
|
299
|
+
height: props.height ?? frame.height
|
|
271
300
|
}, "stack", {
|
|
272
301
|
gap: props.gap ?? 0,
|
|
273
|
-
alignItems: props.alignItems ?? "stretch"
|
|
302
|
+
alignItems: props.alignItems ?? "stretch",
|
|
303
|
+
justifyContent: props.justifyContent ?? "start",
|
|
304
|
+
mainSize: props.height
|
|
274
305
|
}, ctx);
|
|
275
306
|
var renderRow = (props, children, frame, ctx) => layoutChildren(children, {
|
|
276
307
|
...frame,
|
|
@@ -279,6 +310,8 @@ var renderRow = (props, children, frame, ctx) => layoutChildren(children, {
|
|
|
279
310
|
}, "row", {
|
|
280
311
|
gap: props.gap ?? 0,
|
|
281
312
|
alignItems: props.alignItems ?? "start",
|
|
313
|
+
justifyContent: props.justifyContent ?? "start",
|
|
314
|
+
mainSize: props.width,
|
|
282
315
|
crossSize: props.height
|
|
283
316
|
}, ctx);
|
|
284
317
|
var renderBox = async (props, children, frame, _parentMode, ctx) => {
|
|
@@ -310,7 +343,8 @@ var renderBox = async (props, children, frame, _parentMode, ctx) => {
|
|
|
310
343
|
height: (props.height ?? frame.height) - padding.top - padding.bottom
|
|
311
344
|
}, "stack", {
|
|
312
345
|
gap: 0,
|
|
313
|
-
alignItems: "stretch"
|
|
346
|
+
alignItems: "stretch",
|
|
347
|
+
justifyContent: "start"
|
|
314
348
|
}, ctx);
|
|
315
349
|
const height = props.height ?? childSize.height + padding.top + padding.bottom;
|
|
316
350
|
if (needsRect) ctx.schemas[beforeCount] = {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/components.ts","../src/render.ts"],"sourcesContent":["import { createElementNode } from './node.js';\nimport type {\n BoxProps,\n EllipseProps,\n ImageProps,\n LineProps,\n ListProps,\n MultiVariableTextProps,\n PageBreakProps,\n PageProps,\n RectangleProps,\n RowProps,\n SpacerProps,\n StackProps,\n SvgProps,\n TableProps,\n TextProps,\n} from './types.js';\n\nconst makeBuiltin =\n <Props extends Record<string, unknown>, K extends Parameters<typeof createElementNode>[0]>(\n kind: K,\n ) =>\n (props: Props): ReturnType<typeof createElementNode<K>> =>\n createElementNode(kind, props);\n\nexport const Page = makeBuiltin<PageProps, 'page'>('page');\nexport const Stack = makeBuiltin<StackProps, 'stack'>('stack');\nexport const Row = makeBuiltin<RowProps, 'row'>('row');\nexport const Box = makeBuiltin<BoxProps, 'box'>('box');\nexport const Spacer = makeBuiltin<SpacerProps, 'spacer'>('spacer');\nexport const Text = makeBuiltin<TextProps, 'text'>('text');\nexport const MultiVariableText = makeBuiltin<MultiVariableTextProps, 'multiVariableText'>(\n 'multiVariableText',\n);\nexport const Image = makeBuiltin<ImageProps, 'image'>('image');\nexport const Svg = makeBuiltin<SvgProps, 'svg'>('svg');\nexport const Rectangle = makeBuiltin<RectangleProps, 'rectangle'>('rectangle');\nexport const Ellipse = makeBuiltin<EllipseProps, 'ellipse'>('ellipse');\nexport const Line = makeBuiltin<LineProps, 'line'>('line');\nexport const List = makeBuiltin<ListProps, 'list'>('list');\nexport const Table = makeBuiltin<TableProps, 'table'>('table');\nexport const PageBreak = (props?: PageBreakProps) => createElementNode('pagebreak', props);\n","import { getDefaultFont, pt2mm, resolvePageSize } from '@pdfme/common';\nimport type { Font, Schema, Template } from '@pdfme/common';\nimport type {\n CellStyle as SchemaCellStyle,\n ImageSchema,\n LineSchema,\n ListSchema,\n MultiVariableTextSchema,\n ShapeSchema,\n SVGSchema,\n TableSchema,\n TextSchema,\n} from '@pdfme/schemas/types';\nimport {\n escapeInlineMarkdown,\n getVariableNames,\n measureTextHeight,\n visitVariables,\n} from '@pdfme/schemas/utils';\nimport { cloneElementWithChildren, isPdfJsxElement, isPdfJsxFragment } from './node.js';\nimport type {\n BoxProps,\n BoxSides,\n CellStyle,\n EllipseProps,\n ImageProps,\n LineProps,\n LayoutAlignItems,\n ListProps,\n MultiVariableTextProps,\n MultiVariableTextValues,\n PageProps,\n PdfJsxChild,\n PdfJsxElement,\n RectangleProps,\n RenderOptions,\n RenderResult,\n RowProps,\n SpacerProps,\n StackProps,\n SvgProps,\n TableProps,\n TextProps,\n} from './types.js';\n\ntype Rect = { x: number; y: number; width: number; height: number };\ntype Box = ReturnType<typeof resolveBoxSides>;\ntype LayoutMode = 'stack' | 'row';\n\ntype RenderCtx = {\n schemas: Schema[];\n inputs: Record<string, string>;\n usedNames: Set<string>;\n nameCounters: Record<string, number>;\n defaultFont?: string;\n font: Font;\n _cache: Map<string | number, unknown>;\n};\n\nconst DEFAULT_FONT_SIZE = 10;\nconst DEFAULT_LINE_HEIGHT = 1;\nconst DEFAULT_CHARACTER_SPACING = 0;\nconst DEFAULT_FONT_COLOR = '#000000';\nconst DEFAULT_VISUAL_HEIGHT = 40;\nconst DEFAULT_LINE_THICKNESS = 0.5;\nconst DEFAULT_LINE_COLOR = '#000000';\nconst DEFAULT_SHAPE_BORDER_COLOR = '#000000';\nconst DEFAULT_DYNAMIC_FONT_SIZE = {\n min: 4,\n max: 72,\n fit: 'vertical',\n} as const satisfies NonNullable<TextSchema['dynamicFontSize']>;\n\nexport const renderToTemplate = async (\n node: PdfJsxChild,\n options: RenderOptions = {},\n): Promise<RenderResult> => {\n validatePageBreakPlacement(node);\n const expanded = expandPageBreaks(node);\n const pages = flattenChildren(expanded).filter(\n (child): child is PdfJsxElement<'page'> => isPdfJsxElement(child) && child.kind === 'page',\n );\n\n if (pages.length === 0) {\n throw new Error('@pdfme/jsx: renderToTemplate root must contain at least one <Page>.');\n }\n\n const firstPageProps = pages[0]?.props as PageProps;\n const firstMargin = resolveBoxSides(firstPageProps.margin);\n const pageSize = resolvePageSize(firstPageProps.size, firstPageProps.orientation);\n validateConsistentPageProps(pages, pageSize, firstMargin);\n const inputs: Record<string, string> = {};\n const usedNames = new Set<string>();\n const nameCounters: Record<string, number> = {};\n const font = options.font ?? getDefaultFont();\n const _cache = new Map<string | number, unknown>();\n const pageSchemas: Schema[][] = [];\n\n for (const page of pages) {\n const props = page.props as PageProps;\n const margin = resolveBoxSides(props.margin);\n const frame = {\n x: margin.left,\n y: margin.top,\n width: pageSize.width - margin.left - margin.right,\n height: pageSize.height - margin.top - margin.bottom,\n };\n const ctx: RenderCtx = {\n schemas: [],\n inputs,\n usedNames,\n nameCounters,\n defaultFont: props.font,\n font,\n _cache,\n };\n await layoutChildren(page.children, frame, 'stack', { gap: 0, alignItems: 'stretch' }, ctx);\n pageSchemas.push(ctx.schemas);\n }\n\n const template: Template = {\n basePdf: options.basePdf ?? {\n width: pageSize.width,\n height: pageSize.height,\n padding: [firstMargin.top, firstMargin.right, firstMargin.bottom, firstMargin.left],\n },\n schemas: pageSchemas,\n };\n\n return { template, inputs: [inputs] };\n};\n\nconst flattenChildren = (\n children: PdfJsxChild | PdfJsxChild[],\n): (PdfJsxElement | string | number)[] => {\n if (children == null || children === false || children === true) return [];\n if (typeof children === 'string' || typeof children === 'number') return [children];\n if (Array.isArray(children)) return children.flatMap((child) => flattenChildren(child));\n if (isPdfJsxFragment(children)) return flattenChildren(children.children);\n if (isPdfJsxElement(children)) return [children];\n return [];\n};\n\nconst childrenToString = (children: PdfJsxChild | PdfJsxChild[]): string =>\n flattenChildren(children)\n .map((child) => {\n if (typeof child === 'string' || typeof child === 'number') return String(child);\n return childrenToString(child.children);\n })\n .join('');\n\nconst splitChildrenByPageBreak = (children: PdfJsxChild | PdfJsxChild[]): PdfJsxChild[][] => {\n const segments: PdfJsxChild[][] = [[]];\n\n for (const child of flattenForSplitting(children)) {\n if (isPdfJsxElement(child) && child.kind === 'pagebreak') {\n segments.push([]);\n continue;\n }\n\n if (\n isPdfJsxElement(child) &&\n (child.kind === 'page' || child.kind === 'stack' || child.kind === 'box')\n ) {\n const childSegments = splitChildrenByPageBreak(child.children);\n if (childSegments.length === 1) {\n segments[segments.length - 1]?.push(child);\n continue;\n }\n\n segments[segments.length - 1]?.push(cloneElementWithChildren(child, childSegments[0] ?? []));\n for (let i = 1; i < childSegments.length; i += 1) {\n segments.push([cloneElementWithChildren(child, childSegments[i] ?? [])]);\n }\n continue;\n }\n\n segments[segments.length - 1]?.push(child);\n }\n\n return segments;\n};\n\nconst flattenForSplitting = (children: PdfJsxChild | PdfJsxChild[]): PdfJsxChild[] => {\n if (children == null || children === false || children === true) return [];\n if (Array.isArray(children)) return children.flatMap((child) => flattenForSplitting(child));\n if (isPdfJsxFragment(children)) return flattenForSplitting(children.children);\n return [children];\n};\n\nconst expandPageBreaks = (node: PdfJsxChild): PdfJsxChild[] =>\n splitChildrenByPageBreak(node).flat();\n\nconst layoutChildren = async (\n children: PdfJsxChild | PdfJsxChild[],\n frame: Rect,\n mode: LayoutMode,\n opts: { gap: number; alignItems: LayoutAlignItems; crossSize?: number },\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> => {\n const items = flattenChildren(children);\n const widths = mode === 'row' ? resolveRowWidths(items, frame.width, opts.gap) : undefined;\n let cursor = 0;\n let crossMax = 0;\n const rowItems: { schemaStart: number; schemaEnd: number; outerHeight: number }[] = [];\n\n for (let i = 0; i < items.length; i += 1) {\n const child = items[i];\n const margin = getChildMargin(child);\n const width =\n mode === 'row' ? (widths?.[i] ?? 0) : resolveStackChildWidth(child, frame.width, margin);\n const childFrame =\n mode === 'stack'\n ? { x: frame.x, y: frame.y + cursor, width, height: Math.max(0, frame.height - cursor) }\n : { x: frame.x + cursor, y: frame.y, width, height: frame.height };\n childFrame.x += margin.left;\n childFrame.y += margin.top;\n childFrame.height = Math.max(0, childFrame.height - margin.top - margin.bottom);\n\n const schemaStart = ctx.schemas.length;\n const size =\n typeof child === 'string' || typeof child === 'number'\n ? await renderText({ children: String(child) }, childFrame, ctx)\n : await renderElement(child, childFrame, mode, ctx);\n const schemaEnd = ctx.schemas.length;\n\n if (mode === 'stack') {\n const outerWidth = margin.left + size.width + margin.right;\n const dx = resolveAlignOffset(frame.width, outerWidth, opts.alignItems);\n if (dx !== 0) shiftSchemas(ctx.schemas, schemaStart, schemaEnd, dx, 0);\n } else {\n rowItems.push({\n schemaStart,\n schemaEnd,\n outerHeight: margin.top + size.height + margin.bottom,\n });\n }\n\n const advance =\n mode === 'stack'\n ? margin.top + size.height + margin.bottom\n : margin.left + width + margin.right;\n cursor += advance + (i < items.length - 1 ? opts.gap : 0);\n crossMax = Math.max(\n crossMax,\n mode === 'stack'\n ? margin.left + size.width + margin.right\n : margin.top + size.height + margin.bottom,\n );\n }\n\n if (mode === 'row') {\n const rowHeight = opts.crossSize ?? crossMax;\n for (const item of rowItems) {\n const dy = resolveAlignOffset(rowHeight, item.outerHeight, opts.alignItems);\n if (dy !== 0) shiftSchemas(ctx.schemas, item.schemaStart, item.schemaEnd, 0, dy);\n }\n return { width: cursor, height: rowHeight };\n }\n\n return { width: crossMax, height: cursor };\n};\n\nconst resolveRowWidths = (\n items: (PdfJsxElement | string | number)[],\n frameWidth: number,\n gap: number,\n): number[] => {\n let fixedWidth = 0;\n let flexCount = 0;\n const widths = items.map((item) => {\n const margin = getChildMargin(item);\n if (typeof item === 'string' || typeof item === 'number') {\n flexCount += 1;\n fixedWidth += margin.left + margin.right;\n return undefined;\n }\n const width = (item.props as { width?: number }).width;\n if (typeof width === 'number') {\n fixedWidth += width + margin.left + margin.right;\n return width;\n }\n flexCount += 1;\n fixedWidth += margin.left + margin.right;\n return undefined;\n });\n\n const remaining = Math.max(0, frameWidth - fixedWidth - Math.max(0, items.length - 1) * gap);\n const flexWidth = flexCount > 0 ? remaining / flexCount : 0;\n return widths.map((width) => width ?? flexWidth);\n};\n\nconst getChildMargin = (child: PdfJsxElement | string | number): Box => {\n if (typeof child === 'string' || typeof child === 'number') return resolveBoxSides();\n return resolveBoxSides((child.props as { margin?: number | BoxSides }).margin);\n};\n\nconst resolveStackChildWidth = (\n child: PdfJsxElement | string | number,\n frameWidth: number,\n margin: Box,\n) => {\n if (typeof child !== 'string' && typeof child !== 'number') {\n const width = (child.props as { width?: number }).width;\n if (typeof width === 'number') return width;\n }\n return Math.max(0, frameWidth - margin.left - margin.right);\n};\n\nconst resolveAlignOffset = (\n containerSize: number,\n itemSize: number,\n alignItems: LayoutAlignItems,\n) => {\n // Overflowing children stay pinned to start instead of being pulled outside the frame.\n if (alignItems === 'center') return Math.max(0, (containerSize - itemSize) / 2);\n if (alignItems === 'end') return Math.max(0, containerSize - itemSize);\n return 0;\n};\n\nconst shiftSchemas = (schemas: Schema[], start: number, end: number, dx: number, dy: number) => {\n for (let i = start; i < end; i += 1) {\n const schema = schemas[i];\n if (!schema) continue;\n schema.position = {\n x: schema.position.x + dx,\n y: schema.position.y + dy,\n };\n }\n};\n\nconst renderElement = async (\n element: PdfJsxElement,\n frame: Rect,\n parentMode: LayoutMode,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> => {\n switch (element.kind) {\n case 'stack':\n return renderStack(element.props as StackProps, element.children, frame, ctx);\n case 'row':\n return renderRow(element.props as RowProps, element.children, frame, ctx);\n case 'box':\n return renderBox(element.props as BoxProps, element.children, frame, parentMode, ctx);\n case 'spacer':\n return Promise.resolve(renderSpacer(element.props as SpacerProps));\n case 'text':\n return renderText(\n { ...(element.props as TextProps), children: element.children },\n frame,\n ctx,\n );\n case 'multiVariableText':\n return renderMultiVariableText(\n { ...(element.props as MultiVariableTextProps), children: element.children },\n frame,\n ctx,\n );\n case 'image':\n return renderImage(element.props as ImageProps, frame, ctx);\n case 'svg':\n return renderSvg({ ...(element.props as SvgProps), children: element.children }, frame, ctx);\n case 'rectangle':\n return renderShape('rectangle', element.props as RectangleProps, frame, ctx);\n case 'ellipse':\n return renderShape('ellipse', element.props as EllipseProps, frame, ctx);\n case 'line':\n return renderLine(element.props as LineProps, frame, ctx);\n case 'list':\n return renderList(\n { ...(element.props as ListProps), children: element.children },\n frame,\n ctx,\n );\n case 'table':\n return renderTable(element.props as TableProps, frame, ctx);\n default:\n return { width: 0, height: 0 };\n }\n};\n\nconst renderStack = (\n props: StackProps,\n children: PdfJsxChild[],\n frame: Rect,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> =>\n layoutChildren(\n children,\n { ...frame, width: props.width ?? frame.width },\n 'stack',\n {\n gap: props.gap ?? 0,\n alignItems: props.alignItems ?? 'stretch',\n },\n ctx,\n );\n\nconst renderRow = (\n props: RowProps,\n children: PdfJsxChild[],\n frame: Rect,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> =>\n layoutChildren(\n children,\n { ...frame, width: props.width ?? frame.width, height: props.height ?? frame.height },\n 'row',\n { gap: props.gap ?? 0, alignItems: props.alignItems ?? 'start', crossSize: props.height },\n ctx,\n );\n\nconst renderBox = async (\n props: BoxProps,\n children: PdfJsxChild[],\n frame: Rect,\n _parentMode: LayoutMode,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> => {\n const width = props.width ?? frame.width;\n const padding = resolveBoxSides(props.padding);\n const needsRect = Boolean(props.background || props.borderColor || props.borderWidth);\n const beforeCount = ctx.schemas.length;\n\n if (needsRect) {\n ctx.schemas.push({\n name: resolveName(ctx, 'box'),\n type: 'rectangle',\n position: { x: frame.x, y: frame.y },\n width,\n height: 0,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly: true,\n color: props.background ?? '',\n borderColor: props.borderColor ?? '',\n borderWidth: props.borderWidth ?? 0,\n radius: props.radius ?? 0,\n });\n }\n\n const innerFrame = {\n x: frame.x + padding.left,\n y: frame.y + padding.top,\n width: width - padding.left - padding.right,\n height: (props.height ?? frame.height) - padding.top - padding.bottom,\n };\n const childSize = await layoutChildren(\n children,\n innerFrame,\n 'stack',\n { gap: 0, alignItems: 'stretch' },\n ctx,\n );\n const height = props.height ?? childSize.height + padding.top + padding.bottom;\n\n if (needsRect) {\n ctx.schemas[beforeCount] = { ...ctx.schemas[beforeCount]!, height };\n }\n\n return { width, height };\n};\n\nconst renderSpacer = (props: SpacerProps): { width: number; height: number } => ({\n width: props.width ?? 0,\n height: props.height ?? 0,\n});\n\nconst renderText = async (\n props: TextProps,\n frame: Rect,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> => {\n const fontSize = props.size ?? DEFAULT_FONT_SIZE;\n const lineHeight = props.lineHeight ?? DEFAULT_LINE_HEIGHT;\n const width = props.width ?? frame.width;\n const value = childrenToString(props.children);\n const readOnly = props.readOnly ?? props.name == null;\n const textFormat = props.textFormat ?? 'plain';\n\n if (!readOnly && textFormat === 'inline-markdown') {\n throw new Error(\n '@pdfme/jsx: editable <Text> does not support textFormat=\"inline-markdown\". Use read-only <Text> or <MultiVariableText>.',\n );\n }\n const name = resolveName(ctx, 'text', props.name);\n\n const schema: TextSchema = {\n name,\n type: 'text',\n content: value,\n position: { x: frame.x, y: frame.y },\n width,\n height: props.height ?? 0,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n alignment: props.align ?? 'left',\n verticalAlignment: props.valign ?? 'top',\n fontSize,\n fontName: props.font ?? ctx.defaultFont,\n lineHeight,\n characterSpacing: props.spacing ?? DEFAULT_CHARACTER_SPACING,\n fontColor: props.color ?? DEFAULT_FONT_COLOR,\n backgroundColor: props.background ?? '',\n textFormat,\n overflow: props.overflow,\n strikethrough: props.strikethrough ?? false,\n underline: props.underline ?? false,\n };\n\n if (props.borderColor) schema.borderColor = props.borderColor;\n if (props.borderWidth != null) schema.borderWidth = props.borderWidth;\n if (props.dynamicFontSize) {\n schema.dynamicFontSize = {\n min: props.dynamicFontSize.min ?? DEFAULT_DYNAMIC_FONT_SIZE.min,\n max: props.dynamicFontSize.max ?? DEFAULT_DYNAMIC_FONT_SIZE.max,\n fit: props.dynamicFontSize.fit ?? DEFAULT_DYNAMIC_FONT_SIZE.fit,\n };\n }\n if (props.height == null) {\n schema.height = await measureTextHeight({ value, schema, font: ctx.font, _cache: ctx._cache });\n }\n if (!readOnly) ctx.inputs[name] = value;\n ctx.schemas.push(schema);\n\n return { width, height: schema.height };\n};\n\nconst renderMultiVariableText = async (\n props: MultiVariableTextProps,\n frame: Rect,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> => {\n const fontSize = props.size ?? DEFAULT_FONT_SIZE;\n const lineHeight = props.lineHeight ?? DEFAULT_LINE_HEIGHT;\n const width = props.width ?? frame.width;\n const templateText = props.text ?? childrenToString(props.children);\n const values = normalizeMultiVariableTextValues(props.values);\n const variables = resolveMultiVariableTextVariables(templateText, props.variables, values);\n const name = resolveName(ctx, 'multiVariableText', props.name);\n const readOnly = props.readOnly ?? props.name == null;\n const textFormat = props.textFormat ?? 'plain';\n const content = readOnly\n ? substituteMultiVariableText(templateText, values, textFormat === 'inline-markdown')\n : JSON.stringify(values);\n\n const schema: MultiVariableTextSchema = {\n name,\n type: 'multiVariableText',\n content,\n position: { x: frame.x, y: frame.y },\n width,\n height: props.height ?? 0,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n alignment: props.align ?? 'left',\n verticalAlignment: props.valign ?? 'top',\n fontSize,\n fontName: props.font ?? ctx.defaultFont,\n lineHeight,\n characterSpacing: props.spacing ?? DEFAULT_CHARACTER_SPACING,\n fontColor: props.color ?? DEFAULT_FONT_COLOR,\n backgroundColor: props.background ?? '',\n textFormat,\n overflow: props.overflow,\n strikethrough: props.strikethrough ?? false,\n underline: props.underline ?? false,\n text: templateText,\n variables,\n };\n\n if (props.borderColor) schema.borderColor = props.borderColor;\n if (props.borderWidth != null) schema.borderWidth = props.borderWidth;\n if (props.dynamicFontSize) {\n schema.dynamicFontSize = {\n min: props.dynamicFontSize.min ?? DEFAULT_DYNAMIC_FONT_SIZE.min,\n max: props.dynamicFontSize.max ?? DEFAULT_DYNAMIC_FONT_SIZE.max,\n fit: props.dynamicFontSize.fit ?? DEFAULT_DYNAMIC_FONT_SIZE.fit,\n };\n }\n if (props.height == null) {\n const measureValue = readOnly\n ? content\n : substituteMultiVariableText(templateText, values, textFormat === 'inline-markdown');\n schema.height = await measureTextHeight({\n value: measureValue,\n schema,\n font: ctx.font,\n _cache: ctx._cache,\n });\n }\n if (!readOnly) ctx.inputs[name] = content;\n ctx.schemas.push(schema);\n\n return { width, height: schema.height };\n};\n\nconst renderImage = (\n props: ImageProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const width = props.width ?? frame.width;\n const height = props.height ?? DEFAULT_VISUAL_HEIGHT;\n const name = resolveName(ctx, 'image', props.name);\n const readOnly = props.readOnly ?? props.name == null;\n const content = props.src ?? '';\n\n const schema: ImageSchema = {\n name,\n type: 'image',\n content,\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n };\n\n if (!readOnly) ctx.inputs[name] = content;\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst renderSvg = (\n props: SvgProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const width = props.width ?? frame.width;\n const height = props.height ?? DEFAULT_VISUAL_HEIGHT;\n const name = resolveName(ctx, 'svg', props.name);\n const readOnly = props.readOnly ?? props.name == null;\n const content = props.svg ?? childrenToString(props.children);\n\n const schema: SVGSchema = {\n name,\n type: 'svg',\n content,\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n };\n\n if (!readOnly) ctx.inputs[name] = content;\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst renderShape = (\n type: ShapeSchema['type'],\n props: RectangleProps | EllipseProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const width = props.width ?? frame.width;\n const height = props.height ?? DEFAULT_VISUAL_HEIGHT;\n const fill = props.fill ?? '';\n const borderWidth = props.borderWidth ?? (props.borderColor || !fill ? 1 : 0);\n\n const schema: ShapeSchema = {\n name: resolveName(ctx, type, props.name),\n type,\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly: true,\n borderWidth,\n borderColor: props.borderColor ?? (borderWidth > 0 ? DEFAULT_SHAPE_BORDER_COLOR : ''),\n color: fill,\n radius: type === 'rectangle' ? ((props as RectangleProps).radius ?? 0) : 0,\n };\n\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst renderLine = (\n props: LineProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const width = props.width ?? frame.width;\n const height = props.height ?? DEFAULT_LINE_THICKNESS;\n\n const schema: LineSchema = {\n name: resolveName(ctx, 'line', props.name),\n type: 'line',\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly: true,\n color: props.color ?? DEFAULT_LINE_COLOR,\n };\n\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst renderList = (\n props: ListProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const fontSize = props.size ?? DEFAULT_FONT_SIZE;\n const lineHeight = props.lineHeight ?? DEFAULT_LINE_HEIGHT;\n const items = normalizeListItems(props);\n const serialized = JSON.stringify(items.map(serializeListItem));\n const width = props.width ?? frame.width;\n const height =\n props.height ??\n Math.max(1, items.length) * estimateTextHeight(fontSize, lineHeight) +\n Math.max(0, items.length - 1) * (props.itemSpacing ?? 1);\n const name = resolveName(ctx, 'list', props.name);\n const readOnly = props.readOnly ?? props.name == null;\n\n const schema: ListSchema = {\n name,\n type: 'list',\n content: serialized,\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n alignment: props.align ?? 'left',\n verticalAlignment: 'top',\n fontSize,\n fontName: props.font ?? ctx.defaultFont,\n lineHeight,\n characterSpacing: props.spacing ?? DEFAULT_CHARACTER_SPACING,\n fontColor: props.color ?? DEFAULT_FONT_COLOR,\n backgroundColor: props.background ?? '',\n listStyle: props.listStyle ?? 'bullet',\n markerWidth: props.markerWidth ?? 6,\n markerGap: props.markerGap ?? 2,\n indentSize: props.indentSize ?? 6,\n itemSpacing: props.itemSpacing ?? 1,\n };\n\n if (!readOnly) ctx.inputs[name] = serialized;\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst renderTable = (\n props: TableProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const rows = (props.rows ?? props.data ?? []).map((row) => row.map(String));\n const width = props.width ?? frame.width;\n const showHead = props.showHead ?? true;\n const headerHeight = props.headerHeight ?? 9;\n const rowHeight = props.rowHeight ?? 6.5;\n const height =\n props.height ?? (showHead ? headerHeight : 0) + Math.max(1, rows.length) * rowHeight;\n const name = resolveName(ctx, 'table', props.name);\n const readOnly = props.readOnly ?? props.name == null;\n const value = JSON.stringify(rows);\n\n const schema: TableSchema = {\n name,\n type: 'table',\n content: value,\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n showHead,\n repeatHead: props.repeatHead ?? false,\n head: props.head,\n headWidthPercentages: normalizeColumnWidths(props.widths, props.head.length),\n tableStyles: {\n borderColor: props.tableStyles?.borderColor ?? '#000000',\n borderWidth: props.tableStyles?.borderWidth ?? 0.3,\n },\n headStyles: {\n ...defaultCellStyle(props.font ?? ctx.defaultFont, props.fontSize),\n fontColor: '#ffffff',\n backgroundColor: '#2980ba',\n ...normalizeCellStyle(props.headStyles),\n },\n bodyStyles: {\n ...defaultCellStyle(props.font ?? ctx.defaultFont, props.fontSize),\n alternateBackgroundColor: '#f5f5f5',\n ...normalizeCellStyle(props.bodyStyles),\n },\n columnStyles: props.columnStyles ?? {},\n };\n\n if (!readOnly) ctx.inputs[name] = value;\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst normalizeListItems = (props: ListProps): { text: string; level: number }[] => {\n if (props.items) {\n return props.items.map((item) =>\n typeof item === 'string'\n ? { text: item, level: 0 }\n : { text: item.text, level: item.level ?? 0 },\n );\n }\n return childrenToString(props.children)\n .split('\\n')\n .map((item) => item.trim())\n .filter(Boolean)\n .map((text) => ({ text, level: 0 }));\n};\n\nconst serializeListItem = (item: { text: string; level: number }) =>\n `${'\\t'.repeat(Math.max(0, item.level))}${item.text}`;\n\nconst normalizeMultiVariableTextValues = (\n values: MultiVariableTextValues | undefined,\n): Record<string, string> => {\n const normalized: Record<string, string> = {};\n Object.entries(values ?? {}).forEach(([key, value]) => {\n normalized[key] = value == null ? '' : String(value);\n });\n return normalized;\n};\n\nconst resolveMultiVariableTextVariables = (\n templateText: string,\n variables: string[] | undefined,\n values: Record<string, string>,\n) => {\n const result: string[] = [];\n const seen = new Set<string>();\n const add = (name: string) => {\n if (!seen.has(name)) {\n seen.add(name);\n result.push(name);\n }\n };\n\n variables?.forEach(add);\n getVariableNames(templateText).forEach(add);\n Object.keys(values).forEach(add);\n return result;\n};\n\nconst substituteMultiVariableText = (\n templateText: string,\n values: Record<string, string>,\n escapeMarkdown: boolean,\n) => {\n let result = '';\n let lastIndex = 0;\n\n visitVariables(templateText, ({ name, startIndex, endIndex }) => {\n result += templateText.slice(lastIndex, startIndex);\n const value = values[name];\n if (value != null) {\n result += escapeMarkdown ? escapeInlineMarkdown(value) : value;\n }\n lastIndex = endIndex + 1;\n });\n\n return result + templateText.slice(lastIndex);\n};\n\nconst normalizeColumnWidths = (widths: number[] | undefined, columnCount: number): number[] => {\n if (widths && widths.length > 0) return widths;\n if (columnCount <= 0) return [];\n return Array.from({ length: columnCount }, () => 100 / columnCount);\n};\n\nconst defaultCellStyle = (fontName: string | undefined, fontSize = 10): SchemaCellStyle => ({\n fontName,\n alignment: 'left',\n verticalAlignment: 'middle',\n fontSize,\n lineHeight: 1,\n characterSpacing: 0,\n fontColor: '#000000',\n backgroundColor: '#ffffff',\n borderColor: '#000000',\n borderWidth: { top: 0, right: 0, bottom: 0, left: 0 },\n padding: { top: 5, right: 5, bottom: 5, left: 5 },\n});\n\nconst normalizeCellStyle = (\n style: CellStyle | undefined,\n): Partial<SchemaCellStyle & { alternateBackgroundColor: string }> => {\n if (!style) return {};\n const { borderWidth, padding, ...rest } = style;\n return {\n ...rest,\n ...(borderWidth != null ? { borderWidth: resolveBoxSides(borderWidth) } : {}),\n ...(padding != null ? { padding: resolveBoxSides(padding) } : {}),\n };\n};\n\nconst resolveBoxSides = (value?: number | BoxSides) => {\n if (value == null) return { top: 0, right: 0, bottom: 0, left: 0 };\n if (typeof value === 'number') return { top: value, right: value, bottom: value, left: value };\n const x = value.x ?? 0;\n const y = value.y ?? 0;\n return {\n top: value.top ?? y,\n right: value.right ?? x,\n bottom: value.bottom ?? y,\n left: value.left ?? x,\n };\n};\n\nconst resolveName = (ctx: RenderCtx, prefix: string, userName?: string): string => {\n if (userName) {\n if (ctx.usedNames.has(userName)) {\n throw new Error(`@pdfme/jsx: duplicate schema name \"${userName}\"`);\n }\n ctx.usedNames.add(userName);\n return userName;\n }\n\n let name = '';\n do {\n ctx.nameCounters[prefix] = (ctx.nameCounters[prefix] ?? 0) + 1;\n name = `${prefix}_${ctx.nameCounters[prefix]}`;\n } while (ctx.usedNames.has(name));\n ctx.usedNames.add(name);\n return name;\n};\n\nconst estimateTextHeight = (fontSize: number, lineHeight: number) =>\n Math.max(4, pt2mm(fontSize * lineHeight));\n\nconst validateConsistentPageProps = (\n pages: PdfJsxElement<'page'>[],\n firstPageSize: { width: number; height: number },\n firstMargin: ReturnType<typeof resolveBoxSides>,\n) => {\n for (let i = 1; i < pages.length; i += 1) {\n const props = pages[i]?.props as PageProps;\n const pageSize = resolvePageSize(props.size, props.orientation);\n const margin = resolveBoxSides(props.margin);\n\n if (!isSameSize(pageSize, firstPageSize) || !isSameBoxSides(margin, firstMargin)) {\n throw new Error(\n '@pdfme/jsx: all <Page> nodes must use the same size, orientation, and margin. pdfme templates have one blank basePdf size and padding.',\n );\n }\n }\n};\n\nconst isSameSize = (\n first: { width: number; height: number },\n second: { width: number; height: number },\n) => first.width === second.width && first.height === second.height;\n\nconst isSameBoxSides = (\n first: ReturnType<typeof resolveBoxSides>,\n second: ReturnType<typeof resolveBoxSides>,\n) =>\n first.top === second.top &&\n first.right === second.right &&\n first.bottom === second.bottom &&\n first.left === second.left;\n\nconst PAGE_BREAK_PARENT_KINDS = new Set(['page', 'stack', 'box']);\n\nconst validatePageBreakPlacement = (\n node: PdfJsxChild | PdfJsxChild[],\n parentKind: string | undefined = undefined,\n canBreak = false,\n) => {\n for (const child of flattenForSplitting(node)) {\n if (!isPdfJsxElement(child)) continue;\n\n if (child.kind === 'pagebreak') {\n if (!canBreak || !parentKind || !PAGE_BREAK_PARENT_KINDS.has(parentKind)) {\n throw new Error(\n '@pdfme/jsx: <PageBreak> can only be used inside <Page>, <Stack>, or <Box>.',\n );\n }\n continue;\n }\n\n const childCanBreak =\n child.kind === 'page' ? true : canBreak && PAGE_BREAK_PARENT_KINDS.has(child.kind);\n validatePageBreakPlacement(child.children, child.kind, childCanBreak);\n }\n};\n"],"mappings":";;;;AAmBA,IAAM,eAEF,UAED,UACC,kBAAkB,MAAM,MAAM;AAElC,IAAa,OAAO,YAA+B,OAAO;AAC1D,IAAa,QAAQ,YAAiC,QAAQ;AAC9D,IAAa,MAAM,YAA6B,MAAM;AACtD,IAAa,MAAM,YAA6B,MAAM;AACtD,IAAa,SAAS,YAAmC,SAAS;AAClE,IAAa,OAAO,YAA+B,OAAO;AAC1D,IAAa,oBAAoB,YAC/B,oBACD;AACD,IAAa,QAAQ,YAAiC,QAAQ;AAC9D,IAAa,MAAM,YAA6B,MAAM;AACtD,IAAa,YAAY,YAAyC,YAAY;AAC9E,IAAa,UAAU,YAAqC,UAAU;AACtE,IAAa,OAAO,YAA+B,OAAO;AAC1D,IAAa,OAAO,YAA+B,OAAO;AAC1D,IAAa,QAAQ,YAAiC,QAAQ;AAC9D,IAAa,aAAa,UAA2B,kBAAkB,aAAa,MAAM;;;ACiB1F,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAC5B,IAAM,4BAA4B;AAClC,IAAM,qBAAqB;AAC3B,IAAM,wBAAwB;AAC9B,IAAM,yBAAyB;AAC/B,IAAM,qBAAqB;AAC3B,IAAM,6BAA6B;AACnC,IAAM,4BAA4B;CAChC,KAAK;CACL,KAAK;CACL,KAAK;CACN;AAED,IAAa,mBAAmB,OAC9B,MACA,UAAyB,EAAE,KACD;AAC1B,4BAA2B,KAAK;CAEhC,MAAM,QAAQ,gBADG,iBAAiB,KACJ,CAAS,CAAC,QACrC,UAA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AAM,MAAM,YAAY;EAC/D,MAAM,SAAS,gBAAgB,MAAM,OAAO;AAE5C,MAAI,CAAC,WAAW,UAAU,cAAc,IAAI,CAAC,eAAe,QAAQ,YAAY,CAC9E,OAAM,IAAI,MACR,yIACD;;;AAKP,IAAM,cACJ,OACA,WACG,MAAM,UAAU,OAAO,SAAS,MAAM,WAAW,OAAO;AAE7D,IAAM,kBACJ,OACA,WAEA,MAAM,QAAQ,OAAO,OACrB,MAAM,UAAU,OAAO,SACvB,MAAM,WAAW,OAAO,UACxB,MAAM,SAAS,OAAO;AAExB,IAAM,0BAA0B,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAM,CAAC;AAEjE,IAAM,8BACJ,MACA,aAAiC,KAAA,GACjC,WAAW,UACR;AACH,MAAK,MAAM,SAAS,oBAAoB,KAAK,EAAE;AAC7C,MAAI,CAAC,gBAAgB,MAAM,CAAE;AAE7B,MAAI,MAAM,SAAS,aAAa;AAC9B,OAAI,CAAC,YAAY,CAAC,cAAc,CAAC,wBAAwB,IAAI,WAAW,CACtE,OAAM,IAAI,MACR,6EACD;AAEH;;EAGF,MAAM,gBACJ,MAAM,SAAS,SAAS,OAAO,YAAY,wBAAwB,IAAI,MAAM,KAAK;AACpF,6BAA2B,MAAM,UAAU,MAAM,MAAM,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/components.ts","../src/render.ts"],"sourcesContent":["import { createElementNode } from './node.js';\nimport type {\n BoxProps,\n EllipseProps,\n ImageProps,\n LineProps,\n ListProps,\n MultiVariableTextProps,\n PageBreakProps,\n PageProps,\n RectangleProps,\n RowProps,\n SpacerProps,\n StackProps,\n SvgProps,\n TableProps,\n TextProps,\n} from './types.js';\n\nconst makeBuiltin =\n <Props extends Record<string, unknown>, K extends Parameters<typeof createElementNode>[0]>(\n kind: K,\n ) =>\n (props: Props): ReturnType<typeof createElementNode<K>> =>\n createElementNode(kind, props);\n\nexport const Page = makeBuiltin<PageProps, 'page'>('page');\nexport const Stack = makeBuiltin<StackProps, 'stack'>('stack');\nexport const Row = makeBuiltin<RowProps, 'row'>('row');\nexport const Box = makeBuiltin<BoxProps, 'box'>('box');\nexport const Spacer = makeBuiltin<SpacerProps, 'spacer'>('spacer');\nexport const Text = makeBuiltin<TextProps, 'text'>('text');\nexport const MultiVariableText = makeBuiltin<MultiVariableTextProps, 'multiVariableText'>(\n 'multiVariableText',\n);\nexport const Image = makeBuiltin<ImageProps, 'image'>('image');\nexport const Svg = makeBuiltin<SvgProps, 'svg'>('svg');\nexport const Rectangle = makeBuiltin<RectangleProps, 'rectangle'>('rectangle');\nexport const Ellipse = makeBuiltin<EllipseProps, 'ellipse'>('ellipse');\nexport const Line = makeBuiltin<LineProps, 'line'>('line');\nexport const List = makeBuiltin<ListProps, 'list'>('list');\nexport const Table = makeBuiltin<TableProps, 'table'>('table');\nexport const PageBreak = (props?: PageBreakProps) => createElementNode('pagebreak', props);\n","import { getDefaultFont, pt2mm, resolvePageSize } from '@pdfme/common';\nimport type { Font, Schema, Template } from '@pdfme/common';\nimport type {\n CellStyle as SchemaCellStyle,\n ImageSchema,\n LineSchema,\n ListSchema,\n MultiVariableTextSchema,\n ShapeSchema,\n SVGSchema,\n TableSchema,\n TextSchema,\n} from '@pdfme/schemas/types';\nimport {\n escapeInlineMarkdown,\n getVariableNames,\n measureTextHeight,\n visitVariables,\n} from '@pdfme/schemas/utils';\nimport { cloneElementWithChildren, isPdfJsxElement, isPdfJsxFragment } from './node.js';\nimport type {\n BoxProps,\n BoxSides,\n CellStyle,\n EllipseProps,\n ImageProps,\n LineProps,\n LayoutAlignItems,\n LayoutJustifyContent,\n ListProps,\n MultiVariableTextProps,\n MultiVariableTextValues,\n PageProps,\n PdfJsxChild,\n PdfJsxElement,\n RectangleProps,\n RenderOptions,\n RenderResult,\n RowProps,\n SpacerProps,\n StackProps,\n SvgProps,\n TableProps,\n TextProps,\n} from './types.js';\n\ntype Rect = { x: number; y: number; width: number; height: number };\ntype Box = ReturnType<typeof resolveBoxSides>;\ntype LayoutMode = 'stack' | 'row';\ntype LayoutItem = {\n schemaStart: number;\n schemaEnd: number;\n outerHeight: number;\n};\n\ntype RenderCtx = {\n schemas: Schema[];\n inputs: Record<string, string>;\n usedNames: Set<string>;\n nameCounters: Record<string, number>;\n defaultFont?: string;\n font: Font;\n _cache: Map<string | number, unknown>;\n};\n\nconst DEFAULT_FONT_SIZE = 10;\nconst DEFAULT_LINE_HEIGHT = 1;\nconst DEFAULT_CHARACTER_SPACING = 0;\nconst DEFAULT_FONT_COLOR = '#000000';\nconst DEFAULT_VISUAL_HEIGHT = 40;\nconst DEFAULT_LINE_THICKNESS = 0.5;\nconst DEFAULT_LINE_COLOR = '#000000';\nconst DEFAULT_SHAPE_BORDER_COLOR = '#000000';\nconst DEFAULT_DYNAMIC_FONT_SIZE = {\n min: 4,\n max: 72,\n fit: 'vertical',\n} as const satisfies NonNullable<TextSchema['dynamicFontSize']>;\n\nexport const renderToTemplate = async (\n node: PdfJsxChild,\n options: RenderOptions = {},\n): Promise<RenderResult> => {\n validatePageBreakPlacement(node);\n const expanded = expandPageBreaks(node);\n const pages = flattenChildren(expanded).filter(\n (child): child is PdfJsxElement<'page'> => isPdfJsxElement(child) && child.kind === 'page',\n );\n\n if (pages.length === 0) {\n throw new Error('@pdfme/jsx: renderToTemplate root must contain at least one <Page>.');\n }\n\n const firstPageProps = pages[0]?.props as PageProps;\n const firstMargin = resolveBoxSides(firstPageProps.margin);\n const pageSize = resolvePageSize(firstPageProps.size, firstPageProps.orientation);\n validateConsistentPageProps(pages, pageSize, firstMargin);\n const inputs: Record<string, string> = {};\n const usedNames = new Set<string>();\n const nameCounters: Record<string, number> = {};\n const font = options.font ?? getDefaultFont();\n const _cache = new Map<string | number, unknown>();\n const pageSchemas: Schema[][] = [];\n\n for (const page of pages) {\n const props = page.props as PageProps;\n const margin = resolveBoxSides(props.margin);\n const frame = {\n x: margin.left,\n y: margin.top,\n width: pageSize.width - margin.left - margin.right,\n height: pageSize.height - margin.top - margin.bottom,\n };\n const ctx: RenderCtx = {\n schemas: [],\n inputs,\n usedNames,\n nameCounters,\n defaultFont: props.font,\n font,\n _cache,\n };\n await layoutChildren(\n page.children,\n frame,\n 'stack',\n { gap: 0, alignItems: 'stretch', justifyContent: 'start' },\n ctx,\n );\n pageSchemas.push(ctx.schemas);\n }\n\n const template: Template = {\n basePdf: options.basePdf ?? {\n width: pageSize.width,\n height: pageSize.height,\n padding: [firstMargin.top, firstMargin.right, firstMargin.bottom, firstMargin.left],\n },\n schemas: pageSchemas,\n };\n\n return { template, inputs: [inputs] };\n};\n\nconst flattenChildren = (\n children: PdfJsxChild | PdfJsxChild[],\n): (PdfJsxElement | string | number)[] => {\n if (children == null || children === false || children === true) return [];\n if (typeof children === 'string' || typeof children === 'number') return [children];\n if (Array.isArray(children)) return children.flatMap((child) => flattenChildren(child));\n if (isPdfJsxFragment(children)) return flattenChildren(children.children);\n if (isPdfJsxElement(children)) return [children];\n return [];\n};\n\nconst childrenToString = (children: PdfJsxChild | PdfJsxChild[]): string =>\n flattenChildren(children)\n .map((child) => {\n if (typeof child === 'string' || typeof child === 'number') return String(child);\n return childrenToString(child.children);\n })\n .join('');\n\nconst splitChildrenByPageBreak = (children: PdfJsxChild | PdfJsxChild[]): PdfJsxChild[][] => {\n const segments: PdfJsxChild[][] = [[]];\n\n for (const child of flattenForSplitting(children)) {\n if (isPdfJsxElement(child) && child.kind === 'pagebreak') {\n segments.push([]);\n continue;\n }\n\n if (\n isPdfJsxElement(child) &&\n (child.kind === 'page' || child.kind === 'stack' || child.kind === 'box')\n ) {\n const childSegments = splitChildrenByPageBreak(child.children);\n if (childSegments.length === 1) {\n segments[segments.length - 1]?.push(child);\n continue;\n }\n\n segments[segments.length - 1]?.push(cloneElementWithChildren(child, childSegments[0] ?? []));\n for (let i = 1; i < childSegments.length; i += 1) {\n segments.push([cloneElementWithChildren(child, childSegments[i] ?? [])]);\n }\n continue;\n }\n\n segments[segments.length - 1]?.push(child);\n }\n\n return segments;\n};\n\nconst flattenForSplitting = (children: PdfJsxChild | PdfJsxChild[]): PdfJsxChild[] => {\n if (children == null || children === false || children === true) return [];\n if (Array.isArray(children)) return children.flatMap((child) => flattenForSplitting(child));\n if (isPdfJsxFragment(children)) return flattenForSplitting(children.children);\n return [children];\n};\n\nconst expandPageBreaks = (node: PdfJsxChild): PdfJsxChild[] =>\n splitChildrenByPageBreak(node).flat();\n\nconst layoutChildren = async (\n children: PdfJsxChild | PdfJsxChild[],\n frame: Rect,\n mode: LayoutMode,\n opts: {\n gap: number;\n alignItems: LayoutAlignItems;\n justifyContent: LayoutJustifyContent;\n mainSize?: number;\n crossSize?: number;\n },\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> => {\n const items = flattenChildren(children);\n const widths = mode === 'row' ? resolveRowWidths(items, frame.width, opts.gap) : undefined;\n let cursor = 0;\n let crossMax = 0;\n const layoutItems: LayoutItem[] = [];\n\n for (let i = 0; i < items.length; i += 1) {\n const child = items[i];\n const margin = getChildMargin(child);\n const width =\n mode === 'row' ? (widths?.[i] ?? 0) : resolveStackChildWidth(child, frame.width, margin);\n const childFrame =\n mode === 'stack'\n ? { x: frame.x, y: frame.y + cursor, width, height: Math.max(0, frame.height - cursor) }\n : { x: frame.x + cursor, y: frame.y, width, height: frame.height };\n childFrame.x += margin.left;\n childFrame.y += margin.top;\n childFrame.height = Math.max(0, childFrame.height - margin.top - margin.bottom);\n\n const schemaStart = ctx.schemas.length;\n const size =\n typeof child === 'string' || typeof child === 'number'\n ? await renderText({ children: String(child) }, childFrame, ctx)\n : await renderElement(child, childFrame, mode, ctx);\n const schemaEnd = ctx.schemas.length;\n\n const mainSize =\n mode === 'stack'\n ? margin.top + size.height + margin.bottom\n : margin.left + width + margin.right;\n const outerHeight = margin.top + size.height + margin.bottom;\n\n layoutItems.push({ schemaStart, schemaEnd, outerHeight });\n\n if (mode === 'stack') {\n const outerWidth = margin.left + size.width + margin.right;\n const dx = resolveAlignOffset(frame.width, outerWidth, opts.alignItems);\n if (dx !== 0) shiftSchemas(ctx.schemas, schemaStart, schemaEnd, dx, 0);\n }\n\n cursor += mainSize + (i < items.length - 1 ? opts.gap : 0);\n crossMax = Math.max(\n crossMax,\n mode === 'stack'\n ? margin.left + size.width + margin.right\n : margin.top + size.height + margin.bottom,\n );\n }\n\n const contentMainSize = cursor;\n const containerMainSize = opts.mainSize ?? contentMainSize;\n applyJustifyContent(ctx.schemas, layoutItems, mode, contentMainSize, containerMainSize, opts);\n\n if (mode === 'row') {\n const rowHeight = opts.crossSize ?? crossMax;\n for (const item of layoutItems) {\n const dy = resolveAlignOffset(rowHeight, item.outerHeight, opts.alignItems);\n if (dy !== 0) shiftSchemas(ctx.schemas, item.schemaStart, item.schemaEnd, 0, dy);\n }\n return { width: containerMainSize, height: rowHeight };\n }\n\n return { width: crossMax, height: containerMainSize };\n};\n\nconst resolveRowWidths = (\n items: (PdfJsxElement | string | number)[],\n frameWidth: number,\n gap: number,\n): number[] => {\n let usedWidth = 0;\n let totalGrow = 0;\n const parts = items.map((item) => {\n const margin = getChildMargin(item);\n const width = getChildWidth(item);\n const flexGrow = getChildFlexGrow(item);\n const grow = flexGrow ?? (width == null ? 1 : 0);\n const basis = width ?? 0;\n usedWidth += basis + margin.left + margin.right;\n totalGrow += grow;\n return { basis, grow };\n });\n\n const remaining = Math.max(0, frameWidth - usedWidth - Math.max(0, items.length - 1) * gap);\n const flexUnit = totalGrow > 0 ? remaining / totalGrow : 0;\n return parts.map(({ basis, grow }) => basis + grow * flexUnit);\n};\n\nconst getChildMargin = (child: PdfJsxElement | string | number): Box => {\n if (typeof child === 'string' || typeof child === 'number') return resolveBoxSides();\n return resolveBoxSides((child.props as { margin?: number | BoxSides }).margin);\n};\n\nconst getChildWidth = (child: PdfJsxElement | string | number): number | undefined => {\n if (typeof child === 'string' || typeof child === 'number') return undefined;\n const width = (child.props as { width?: number }).width;\n return typeof width === 'number' ? width : undefined;\n};\n\nconst getChildFlexGrow = (child: PdfJsxElement | string | number): number | undefined => {\n if (typeof child === 'string' || typeof child === 'number') return undefined;\n const props = child.props as { flex?: number; flexGrow?: number };\n const flexGrow = props.flexGrow ?? props.flex;\n return typeof flexGrow === 'number' ? Math.max(0, flexGrow) : undefined;\n};\n\nconst resolveStackChildWidth = (\n child: PdfJsxElement | string | number,\n frameWidth: number,\n margin: Box,\n) => {\n const width = getChildWidth(child);\n if (width != null) return width;\n return Math.max(0, frameWidth - margin.left - margin.right);\n};\n\nconst applyJustifyContent = (\n schemas: Schema[],\n items: LayoutItem[],\n mode: LayoutMode,\n contentMainSize: number,\n containerMainSize: number,\n opts: { justifyContent: LayoutJustifyContent },\n) => {\n // Overflowing content has no extra main-axis space to distribute.\n const extraSpace = Math.max(0, containerMainSize - contentMainSize);\n if (extraSpace === 0 || opts.justifyContent === 'start') return;\n\n const extraGap =\n opts.justifyContent === 'space-between' && items.length > 1\n ? extraSpace / (items.length - 1)\n : 0;\n const startOffset =\n opts.justifyContent === 'center'\n ? extraSpace / 2\n : opts.justifyContent === 'end'\n ? extraSpace\n : 0;\n\n let runningExtraGap = 0;\n for (const item of items) {\n const offset = startOffset + runningExtraGap;\n if (offset !== 0) {\n shiftSchemas(\n schemas,\n item.schemaStart,\n item.schemaEnd,\n mode === 'row' ? offset : 0,\n mode === 'stack' ? offset : 0,\n );\n }\n runningExtraGap += extraGap;\n }\n};\n\nconst resolveAlignOffset = (\n containerSize: number,\n itemSize: number,\n alignItems: LayoutAlignItems,\n) => {\n // Overflowing children stay pinned to start instead of being pulled outside the frame.\n if (alignItems === 'center') return Math.max(0, (containerSize - itemSize) / 2);\n if (alignItems === 'end') return Math.max(0, containerSize - itemSize);\n return 0;\n};\n\nconst shiftSchemas = (schemas: Schema[], start: number, end: number, dx: number, dy: number) => {\n for (let i = start; i < end; i += 1) {\n const schema = schemas[i];\n if (!schema) continue;\n schema.position = {\n x: schema.position.x + dx,\n y: schema.position.y + dy,\n };\n }\n};\n\nconst renderElement = async (\n element: PdfJsxElement,\n frame: Rect,\n parentMode: LayoutMode,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> => {\n const shouldUseResolvedRowWidth = parentMode === 'row' && getChildFlexGrow(element) != null;\n const props = shouldUseResolvedRowWidth\n ? { ...element.props, width: frame.width }\n : element.props;\n\n switch (element.kind) {\n case 'stack':\n return renderStack(props as StackProps, element.children, frame, ctx);\n case 'row':\n return renderRow(props as RowProps, element.children, frame, ctx);\n case 'box':\n return renderBox(props as BoxProps, element.children, frame, parentMode, ctx);\n case 'spacer':\n return Promise.resolve(renderSpacer(props as SpacerProps));\n case 'text':\n return renderText({ ...(props as TextProps), children: element.children }, frame, ctx);\n case 'multiVariableText':\n return renderMultiVariableText(\n { ...(props as MultiVariableTextProps), children: element.children },\n frame,\n ctx,\n );\n case 'image':\n return renderImage(props as ImageProps, frame, ctx);\n case 'svg':\n return renderSvg({ ...(props as SvgProps), children: element.children }, frame, ctx);\n case 'rectangle':\n return renderShape('rectangle', props as RectangleProps, frame, ctx);\n case 'ellipse':\n return renderShape('ellipse', props as EllipseProps, frame, ctx);\n case 'line':\n return renderLine(props as LineProps, frame, ctx);\n case 'list':\n return renderList({ ...(props as ListProps), children: element.children }, frame, ctx);\n case 'table':\n return renderTable(props as TableProps, frame, ctx);\n default:\n return { width: 0, height: 0 };\n }\n};\n\nconst renderStack = (\n props: StackProps,\n children: PdfJsxChild[],\n frame: Rect,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> =>\n layoutChildren(\n children,\n { ...frame, width: props.width ?? frame.width, height: props.height ?? frame.height },\n 'stack',\n {\n gap: props.gap ?? 0,\n alignItems: props.alignItems ?? 'stretch',\n justifyContent: props.justifyContent ?? 'start',\n mainSize: props.height,\n },\n ctx,\n );\n\nconst renderRow = (\n props: RowProps,\n children: PdfJsxChild[],\n frame: Rect,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> =>\n layoutChildren(\n children,\n { ...frame, width: props.width ?? frame.width, height: props.height ?? frame.height },\n 'row',\n {\n gap: props.gap ?? 0,\n alignItems: props.alignItems ?? 'start',\n justifyContent: props.justifyContent ?? 'start',\n mainSize: props.width,\n crossSize: props.height,\n },\n ctx,\n );\n\nconst renderBox = async (\n props: BoxProps,\n children: PdfJsxChild[],\n frame: Rect,\n _parentMode: LayoutMode,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> => {\n const width = props.width ?? frame.width;\n const padding = resolveBoxSides(props.padding);\n const needsRect = Boolean(props.background || props.borderColor || props.borderWidth);\n const beforeCount = ctx.schemas.length;\n\n if (needsRect) {\n ctx.schemas.push({\n name: resolveName(ctx, 'box'),\n type: 'rectangle',\n position: { x: frame.x, y: frame.y },\n width,\n height: 0,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly: true,\n color: props.background ?? '',\n borderColor: props.borderColor ?? '',\n borderWidth: props.borderWidth ?? 0,\n radius: props.radius ?? 0,\n });\n }\n\n const innerFrame = {\n x: frame.x + padding.left,\n y: frame.y + padding.top,\n width: width - padding.left - padding.right,\n height: (props.height ?? frame.height) - padding.top - padding.bottom,\n };\n const childSize = await layoutChildren(\n children,\n innerFrame,\n 'stack',\n { gap: 0, alignItems: 'stretch', justifyContent: 'start' },\n ctx,\n );\n const height = props.height ?? childSize.height + padding.top + padding.bottom;\n\n if (needsRect) {\n ctx.schemas[beforeCount] = { ...ctx.schemas[beforeCount]!, height };\n }\n\n return { width, height };\n};\n\nconst renderSpacer = (props: SpacerProps): { width: number; height: number } => ({\n width: props.width ?? 0,\n height: props.height ?? 0,\n});\n\nconst renderText = async (\n props: TextProps,\n frame: Rect,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> => {\n const fontSize = props.size ?? DEFAULT_FONT_SIZE;\n const lineHeight = props.lineHeight ?? DEFAULT_LINE_HEIGHT;\n const width = props.width ?? frame.width;\n const value = childrenToString(props.children);\n const readOnly = props.readOnly ?? props.name == null;\n const textFormat = props.textFormat ?? 'plain';\n\n if (!readOnly && textFormat === 'inline-markdown') {\n throw new Error(\n '@pdfme/jsx: editable <Text> does not support textFormat=\"inline-markdown\". Use read-only <Text> or <MultiVariableText>.',\n );\n }\n const name = resolveName(ctx, 'text', props.name);\n\n const schema: TextSchema = {\n name,\n type: 'text',\n content: value,\n position: { x: frame.x, y: frame.y },\n width,\n height: props.height ?? 0,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n alignment: props.align ?? 'left',\n verticalAlignment: props.valign ?? 'top',\n fontSize,\n fontName: props.font ?? ctx.defaultFont,\n lineHeight,\n characterSpacing: props.spacing ?? DEFAULT_CHARACTER_SPACING,\n fontColor: props.color ?? DEFAULT_FONT_COLOR,\n backgroundColor: props.background ?? '',\n textFormat,\n overflow: props.overflow,\n strikethrough: props.strikethrough ?? false,\n underline: props.underline ?? false,\n };\n\n if (props.borderColor) schema.borderColor = props.borderColor;\n if (props.borderWidth != null) schema.borderWidth = props.borderWidth;\n if (props.dynamicFontSize) {\n schema.dynamicFontSize = {\n min: props.dynamicFontSize.min ?? DEFAULT_DYNAMIC_FONT_SIZE.min,\n max: props.dynamicFontSize.max ?? DEFAULT_DYNAMIC_FONT_SIZE.max,\n fit: props.dynamicFontSize.fit ?? DEFAULT_DYNAMIC_FONT_SIZE.fit,\n };\n }\n if (props.height == null) {\n schema.height = await measureTextHeight({ value, schema, font: ctx.font, _cache: ctx._cache });\n }\n if (!readOnly) ctx.inputs[name] = value;\n ctx.schemas.push(schema);\n\n return { width, height: schema.height };\n};\n\nconst renderMultiVariableText = async (\n props: MultiVariableTextProps,\n frame: Rect,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> => {\n const fontSize = props.size ?? DEFAULT_FONT_SIZE;\n const lineHeight = props.lineHeight ?? DEFAULT_LINE_HEIGHT;\n const width = props.width ?? frame.width;\n const templateText = props.text ?? childrenToString(props.children);\n const values = normalizeMultiVariableTextValues(props.values);\n const variables = resolveMultiVariableTextVariables(templateText, props.variables, values);\n const name = resolveName(ctx, 'multiVariableText', props.name);\n const readOnly = props.readOnly ?? props.name == null;\n const textFormat = props.textFormat ?? 'plain';\n const content = readOnly\n ? substituteMultiVariableText(templateText, values, textFormat === 'inline-markdown')\n : JSON.stringify(values);\n\n const schema: MultiVariableTextSchema = {\n name,\n type: 'multiVariableText',\n content,\n position: { x: frame.x, y: frame.y },\n width,\n height: props.height ?? 0,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n alignment: props.align ?? 'left',\n verticalAlignment: props.valign ?? 'top',\n fontSize,\n fontName: props.font ?? ctx.defaultFont,\n lineHeight,\n characterSpacing: props.spacing ?? DEFAULT_CHARACTER_SPACING,\n fontColor: props.color ?? DEFAULT_FONT_COLOR,\n backgroundColor: props.background ?? '',\n textFormat,\n overflow: props.overflow,\n strikethrough: props.strikethrough ?? false,\n underline: props.underline ?? false,\n text: templateText,\n variables,\n };\n\n if (props.borderColor) schema.borderColor = props.borderColor;\n if (props.borderWidth != null) schema.borderWidth = props.borderWidth;\n if (props.dynamicFontSize) {\n schema.dynamicFontSize = {\n min: props.dynamicFontSize.min ?? DEFAULT_DYNAMIC_FONT_SIZE.min,\n max: props.dynamicFontSize.max ?? DEFAULT_DYNAMIC_FONT_SIZE.max,\n fit: props.dynamicFontSize.fit ?? DEFAULT_DYNAMIC_FONT_SIZE.fit,\n };\n }\n if (props.height == null) {\n const measureValue = readOnly\n ? content\n : substituteMultiVariableText(templateText, values, textFormat === 'inline-markdown');\n schema.height = await measureTextHeight({\n value: measureValue,\n schema,\n font: ctx.font,\n _cache: ctx._cache,\n });\n }\n if (!readOnly) ctx.inputs[name] = content;\n ctx.schemas.push(schema);\n\n return { width, height: schema.height };\n};\n\nconst renderImage = (\n props: ImageProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const width = props.width ?? frame.width;\n const height = props.height ?? DEFAULT_VISUAL_HEIGHT;\n const name = resolveName(ctx, 'image', props.name);\n const readOnly = props.readOnly ?? props.name == null;\n const content = props.src ?? '';\n\n const schema: ImageSchema = {\n name,\n type: 'image',\n content,\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n };\n\n if (!readOnly) ctx.inputs[name] = content;\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst renderSvg = (\n props: SvgProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const width = props.width ?? frame.width;\n const height = props.height ?? DEFAULT_VISUAL_HEIGHT;\n const name = resolveName(ctx, 'svg', props.name);\n const readOnly = props.readOnly ?? props.name == null;\n const content = props.svg ?? childrenToString(props.children);\n\n const schema: SVGSchema = {\n name,\n type: 'svg',\n content,\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n };\n\n if (!readOnly) ctx.inputs[name] = content;\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst renderShape = (\n type: ShapeSchema['type'],\n props: RectangleProps | EllipseProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const width = props.width ?? frame.width;\n const height = props.height ?? DEFAULT_VISUAL_HEIGHT;\n const fill = props.fill ?? '';\n const borderWidth = props.borderWidth ?? (props.borderColor || !fill ? 1 : 0);\n\n const schema: ShapeSchema = {\n name: resolveName(ctx, type, props.name),\n type,\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly: true,\n borderWidth,\n borderColor: props.borderColor ?? (borderWidth > 0 ? DEFAULT_SHAPE_BORDER_COLOR : ''),\n color: fill,\n radius: type === 'rectangle' ? ((props as RectangleProps).radius ?? 0) : 0,\n };\n\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst renderLine = (\n props: LineProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const width = props.width ?? frame.width;\n const height = props.height ?? DEFAULT_LINE_THICKNESS;\n\n const schema: LineSchema = {\n name: resolveName(ctx, 'line', props.name),\n type: 'line',\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly: true,\n color: props.color ?? DEFAULT_LINE_COLOR,\n };\n\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst renderList = (\n props: ListProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const fontSize = props.size ?? DEFAULT_FONT_SIZE;\n const lineHeight = props.lineHeight ?? DEFAULT_LINE_HEIGHT;\n const items = normalizeListItems(props);\n const serialized = JSON.stringify(items.map(serializeListItem));\n const width = props.width ?? frame.width;\n const height =\n props.height ??\n Math.max(1, items.length) * estimateTextHeight(fontSize, lineHeight) +\n Math.max(0, items.length - 1) * (props.itemSpacing ?? 1);\n const name = resolveName(ctx, 'list', props.name);\n const readOnly = props.readOnly ?? props.name == null;\n\n const schema: ListSchema = {\n name,\n type: 'list',\n content: serialized,\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n alignment: props.align ?? 'left',\n verticalAlignment: 'top',\n fontSize,\n fontName: props.font ?? ctx.defaultFont,\n lineHeight,\n characterSpacing: props.spacing ?? DEFAULT_CHARACTER_SPACING,\n fontColor: props.color ?? DEFAULT_FONT_COLOR,\n backgroundColor: props.background ?? '',\n listStyle: props.listStyle ?? 'bullet',\n markerWidth: props.markerWidth ?? 6,\n markerGap: props.markerGap ?? 2,\n indentSize: props.indentSize ?? 6,\n itemSpacing: props.itemSpacing ?? 1,\n };\n\n if (!readOnly) ctx.inputs[name] = serialized;\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst renderTable = (\n props: TableProps,\n frame: Rect,\n ctx: RenderCtx,\n): { width: number; height: number } => {\n const rows = (props.rows ?? props.data ?? []).map((row) => row.map(String));\n const width = props.width ?? frame.width;\n const showHead = props.showHead ?? true;\n const headerHeight = props.headerHeight ?? 9;\n const rowHeight = props.rowHeight ?? 6.5;\n const height =\n props.height ?? (showHead ? headerHeight : 0) + Math.max(1, rows.length) * rowHeight;\n const name = resolveName(ctx, 'table', props.name);\n const readOnly = props.readOnly ?? props.name == null;\n const value = JSON.stringify(rows);\n\n const schema: TableSchema = {\n name,\n type: 'table',\n content: value,\n position: { x: frame.x, y: frame.y },\n width,\n height,\n rotate: props.rotate ?? 0,\n opacity: props.opacity ?? 1,\n readOnly,\n required: props.required,\n showHead,\n repeatHead: props.repeatHead ?? false,\n head: props.head,\n headWidthPercentages: normalizeColumnWidths(props.widths, props.head.length),\n tableStyles: {\n borderColor: props.tableStyles?.borderColor ?? '#000000',\n borderWidth: props.tableStyles?.borderWidth ?? 0.3,\n },\n headStyles: {\n ...defaultCellStyle(props.font ?? ctx.defaultFont, props.fontSize),\n fontColor: '#ffffff',\n backgroundColor: '#2980ba',\n ...normalizeCellStyle(props.headStyles),\n },\n bodyStyles: {\n ...defaultCellStyle(props.font ?? ctx.defaultFont, props.fontSize),\n alternateBackgroundColor: '#f5f5f5',\n ...normalizeCellStyle(props.bodyStyles),\n },\n columnStyles: props.columnStyles ?? {},\n };\n\n if (!readOnly) ctx.inputs[name] = value;\n ctx.schemas.push(schema);\n\n return { width, height };\n};\n\nconst normalizeListItems = (props: ListProps): { text: string; level: number }[] => {\n if (props.items) {\n return props.items.map((item) =>\n typeof item === 'string'\n ? { text: item, level: 0 }\n : { text: item.text, level: item.level ?? 0 },\n );\n }\n return childrenToString(props.children)\n .split('\\n')\n .map((item) => item.trim())\n .filter(Boolean)\n .map((text) => ({ text, level: 0 }));\n};\n\nconst serializeListItem = (item: { text: string; level: number }) =>\n `${'\\t'.repeat(Math.max(0, item.level))}${item.text}`;\n\nconst normalizeMultiVariableTextValues = (\n values: MultiVariableTextValues | undefined,\n): Record<string, string> => {\n const normalized: Record<string, string> = {};\n Object.entries(values ?? {}).forEach(([key, value]) => {\n normalized[key] = value == null ? '' : String(value);\n });\n return normalized;\n};\n\nconst resolveMultiVariableTextVariables = (\n templateText: string,\n variables: string[] | undefined,\n values: Record<string, string>,\n) => {\n const result: string[] = [];\n const seen = new Set<string>();\n const add = (name: string) => {\n if (!seen.has(name)) {\n seen.add(name);\n result.push(name);\n }\n };\n\n variables?.forEach(add);\n getVariableNames(templateText).forEach(add);\n Object.keys(values).forEach(add);\n return result;\n};\n\nconst substituteMultiVariableText = (\n templateText: string,\n values: Record<string, string>,\n escapeMarkdown: boolean,\n) => {\n let result = '';\n let lastIndex = 0;\n\n visitVariables(templateText, ({ name, startIndex, endIndex }) => {\n result += templateText.slice(lastIndex, startIndex);\n const value = values[name];\n if (value != null) {\n result += escapeMarkdown ? escapeInlineMarkdown(value) : value;\n }\n lastIndex = endIndex + 1;\n });\n\n return result + templateText.slice(lastIndex);\n};\n\nconst normalizeColumnWidths = (widths: number[] | undefined, columnCount: number): number[] => {\n if (widths && widths.length > 0) return widths;\n if (columnCount <= 0) return [];\n return Array.from({ length: columnCount }, () => 100 / columnCount);\n};\n\nconst defaultCellStyle = (fontName: string | undefined, fontSize = 10): SchemaCellStyle => ({\n fontName,\n alignment: 'left',\n verticalAlignment: 'middle',\n fontSize,\n lineHeight: 1,\n characterSpacing: 0,\n fontColor: '#000000',\n backgroundColor: '#ffffff',\n borderColor: '#000000',\n borderWidth: { top: 0, right: 0, bottom: 0, left: 0 },\n padding: { top: 5, right: 5, bottom: 5, left: 5 },\n});\n\nconst normalizeCellStyle = (\n style: CellStyle | undefined,\n): Partial<SchemaCellStyle & { alternateBackgroundColor: string }> => {\n if (!style) return {};\n const { borderWidth, padding, ...rest } = style;\n return {\n ...rest,\n ...(borderWidth != null ? { borderWidth: resolveBoxSides(borderWidth) } : {}),\n ...(padding != null ? { padding: resolveBoxSides(padding) } : {}),\n };\n};\n\nconst resolveBoxSides = (value?: number | BoxSides) => {\n if (value == null) return { top: 0, right: 0, bottom: 0, left: 0 };\n if (typeof value === 'number') return { top: value, right: value, bottom: value, left: value };\n const x = value.x ?? 0;\n const y = value.y ?? 0;\n return {\n top: value.top ?? y,\n right: value.right ?? x,\n bottom: value.bottom ?? y,\n left: value.left ?? x,\n };\n};\n\nconst resolveName = (ctx: RenderCtx, prefix: string, userName?: string): string => {\n if (userName) {\n if (ctx.usedNames.has(userName)) {\n throw new Error(`@pdfme/jsx: duplicate schema name \"${userName}\"`);\n }\n ctx.usedNames.add(userName);\n return userName;\n }\n\n let name = '';\n do {\n ctx.nameCounters[prefix] = (ctx.nameCounters[prefix] ?? 0) + 1;\n name = `${prefix}_${ctx.nameCounters[prefix]}`;\n } while (ctx.usedNames.has(name));\n ctx.usedNames.add(name);\n return name;\n};\n\nconst estimateTextHeight = (fontSize: number, lineHeight: number) =>\n Math.max(4, pt2mm(fontSize * lineHeight));\n\nconst validateConsistentPageProps = (\n pages: PdfJsxElement<'page'>[],\n firstPageSize: { width: number; height: number },\n firstMargin: ReturnType<typeof resolveBoxSides>,\n) => {\n for (let i = 1; i < pages.length; i += 1) {\n const props = pages[i]?.props as PageProps;\n const pageSize = resolvePageSize(props.size, props.orientation);\n const margin = resolveBoxSides(props.margin);\n\n if (!isSameSize(pageSize, firstPageSize) || !isSameBoxSides(margin, firstMargin)) {\n throw new Error(\n '@pdfme/jsx: all <Page> nodes must use the same size, orientation, and margin. pdfme templates have one blank basePdf size and padding.',\n );\n }\n }\n};\n\nconst isSameSize = (\n first: { width: number; height: number },\n second: { width: number; height: number },\n) => first.width === second.width && first.height === second.height;\n\nconst isSameBoxSides = (\n first: ReturnType<typeof resolveBoxSides>,\n second: ReturnType<typeof resolveBoxSides>,\n) =>\n first.top === second.top &&\n first.right === second.right &&\n first.bottom === second.bottom &&\n first.left === second.left;\n\nconst PAGE_BREAK_PARENT_KINDS = new Set(['page', 'stack', 'box']);\n\nconst validatePageBreakPlacement = (\n node: PdfJsxChild | PdfJsxChild[],\n parentKind: string | undefined = undefined,\n canBreak = false,\n) => {\n for (const child of flattenForSplitting(node)) {\n if (!isPdfJsxElement(child)) continue;\n\n if (child.kind === 'pagebreak') {\n if (!canBreak || !parentKind || !PAGE_BREAK_PARENT_KINDS.has(parentKind)) {\n throw new Error(\n '@pdfme/jsx: <PageBreak> can only be used inside <Page>, <Stack>, or <Box>.',\n );\n }\n continue;\n }\n\n const childCanBreak =\n child.kind === 'page' ? true : canBreak && PAGE_BREAK_PARENT_KINDS.has(child.kind);\n validatePageBreakPlacement(child.children, child.kind, childCanBreak);\n }\n};\n"],"mappings":";;;;AAmBA,IAAM,eAEF,UAED,UACC,kBAAkB,MAAM,MAAM;AAElC,IAAa,OAAO,YAA+B,OAAO;AAC1D,IAAa,QAAQ,YAAiC,QAAQ;AAC9D,IAAa,MAAM,YAA6B,MAAM;AACtD,IAAa,MAAM,YAA6B,MAAM;AACtD,IAAa,SAAS,YAAmC,SAAS;AAClE,IAAa,OAAO,YAA+B,OAAO;AAC1D,IAAa,oBAAoB,YAC/B,oBACD;AACD,IAAa,QAAQ,YAAiC,QAAQ;AAC9D,IAAa,MAAM,YAA6B,MAAM;AACtD,IAAa,YAAY,YAAyC,YAAY;AAC9E,IAAa,UAAU,YAAqC,UAAU;AACtE,IAAa,OAAO,YAA+B,OAAO;AAC1D,IAAa,OAAO,YAA+B,OAAO;AAC1D,IAAa,QAAQ,YAAiC,QAAQ;AAC9D,IAAa,aAAa,UAA2B,kBAAkB,aAAa,MAAM;;;ACuB1F,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAC5B,IAAM,4BAA4B;AAClC,IAAM,qBAAqB;AAC3B,IAAM,wBAAwB;AAC9B,IAAM,yBAAyB;AAC/B,IAAM,qBAAqB;AAC3B,IAAM,6BAA6B;AACnC,IAAM,4BAA4B;CAChC,KAAK;CACL,KAAK;CACL,KAAK;CACN;AAED,IAAa,mBAAmB,OAC9B,MACA,UAAyB,EAAE,KACD;AAC1B,4BAA2B,KAAK;CAEhC,MAAM,QAAQ,gBADG,iBAAiB,KACJ,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,YAAY,CAC9E,OAAM,IAAI,MACR,yIACD;;;AAKP,IAAM,cACJ,OACA,WACG,MAAM,UAAU,OAAO,SAAS,MAAM,WAAW,OAAO;AAE7D,IAAM,kBACJ,OACA,WAEA,MAAM,QAAQ,OAAO,OACrB,MAAM,UAAU,OAAO,SACvB,MAAM,WAAW,OAAO,UACxB,MAAM,SAAS,OAAO;AAExB,IAAM,0BAA0B,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAM,CAAC;AAEjE,IAAM,8BACJ,MACA,aAAiC,KAAA,GACjC,WAAW,UACR;AACH,MAAK,MAAM,SAAS,oBAAoB,KAAK,EAAE;AAC7C,MAAI,CAAC,gBAAgB,MAAM,CAAE;AAE7B,MAAI,MAAM,SAAS,aAAa;AAC9B,OAAI,CAAC,YAAY,CAAC,cAAc,CAAC,wBAAwB,IAAI,WAAW,CACtE,OAAM,IAAI,MACR,6EACD;AAEH;;EAGF,MAAM,gBACJ,MAAM,SAAS,SAAS,OAAO,YAAY,wBAAwB,IAAI,MAAM,KAAK;AACpF,6BAA2B,MAAM,UAAU,MAAM,MAAM,cAAc"}
|
package/dist/types.d.ts
CHANGED
|
@@ -33,8 +33,13 @@ export type BoxSides = {
|
|
|
33
33
|
y?: number;
|
|
34
34
|
};
|
|
35
35
|
export type LayoutAlignItems = 'start' | 'center' | 'end' | 'stretch';
|
|
36
|
+
export type LayoutJustifyContent = 'start' | 'center' | 'end' | 'space-between';
|
|
36
37
|
export type LayoutProps = {
|
|
37
38
|
margin?: number | BoxSides;
|
|
39
|
+
/** Row-only grow weight. Explicit width is used as the basis when present. */
|
|
40
|
+
flexGrow?: number;
|
|
41
|
+
/** Short alias for flexGrow. */
|
|
42
|
+
flex?: number;
|
|
38
43
|
};
|
|
39
44
|
export type CommonProps = LayoutProps & Partial<Pick<Schema, 'rotate' | 'opacity'>>;
|
|
40
45
|
export type PageProps = {
|
|
@@ -47,7 +52,9 @@ export type PageProps = {
|
|
|
47
52
|
export type StackProps = LayoutProps & {
|
|
48
53
|
gap?: number;
|
|
49
54
|
width?: number;
|
|
55
|
+
height?: number;
|
|
50
56
|
alignItems?: LayoutAlignItems;
|
|
57
|
+
justifyContent?: LayoutJustifyContent;
|
|
51
58
|
children?: PdfJsxChild;
|
|
52
59
|
};
|
|
53
60
|
export type RowProps = LayoutProps & {
|
|
@@ -55,6 +62,7 @@ export type RowProps = LayoutProps & {
|
|
|
55
62
|
width?: number;
|
|
56
63
|
height?: number;
|
|
57
64
|
alignItems?: Exclude<LayoutAlignItems, 'stretch'>;
|
|
65
|
+
justifyContent?: LayoutJustifyContent;
|
|
58
66
|
children?: PdfJsxChild;
|
|
59
67
|
};
|
|
60
68
|
export type BoxProps = CommonProps & {
|