@pdfme/jsx 6.1.1-dev.17 → 6.1.1-dev.18

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 CHANGED
@@ -33,8 +33,14 @@ it provides its own `jsx-runtime` and `jsx-dev-runtime`.
33
33
  - `MultiVariableText` uses `text` or children as the template string and stores `values` as the
34
34
  JSON input. Variable names are inferred from `{name}` placeholders and can also be passed with
35
35
  `variables`.
36
+ - `Image` uses `src` as its initial content and is intended to be self-closing.
37
+ - `Svg` uses `svg` or children as its initial content.
38
+ - With `name`, `Image` and `Svg` become input-backed schemas; without `name`, they are read-only
39
+ content.
40
+ - `Rectangle`, `Ellipse`, and `Line` are static visual schemas for backgrounds, dividers, and simple
41
+ shapes.
36
42
  - `PageBreak` is supported only along a `Page` / `Stack` / `Box` layout path. It is rejected inside
37
- `Row`, `Text`, `MultiVariableText`, `List`, and `Table`.
43
+ `Row`, leaf schemas, `List`, and `Table`.
38
44
  - All `Page` nodes in one `renderToTemplate` call must use the same page size, orientation, and
39
45
  margin because a pdfme blank `basePdf` has one shared size and padding.
40
46
  - `Table widths` are percentages passed to pdfme `headWidthPercentages`, for example
@@ -1,4 +1,4 @@
1
- import type { BoxProps, ListProps, MultiVariableTextProps, PageBreakProps, PageProps, RowProps, SpacerProps, StackProps, TableProps, TextProps } from './types.js';
1
+ import type { BoxProps, EllipseProps, ImageProps, LineProps, ListProps, MultiVariableTextProps, PageBreakProps, PageProps, RectangleProps, RowProps, SpacerProps, StackProps, SvgProps, TableProps, TextProps } from './types.js';
2
2
  export declare const Page: (props: PageProps) => import("./types.js").PdfJsxElement<"page">;
3
3
  export declare const Stack: (props: StackProps) => import("./types.js").PdfJsxElement<"stack">;
4
4
  export declare const Row: (props: RowProps) => import("./types.js").PdfJsxElement<"row">;
@@ -6,6 +6,11 @@ export declare const Box: (props: BoxProps) => import("./types.js").PdfJsxElemen
6
6
  export declare const Spacer: (props: SpacerProps) => import("./types.js").PdfJsxElement<"spacer">;
7
7
  export declare const Text: (props: TextProps) => import("./types.js").PdfJsxElement<"text">;
8
8
  export declare const MultiVariableText: (props: MultiVariableTextProps) => import("./types.js").PdfJsxElement<"multiVariableText">;
9
+ export declare const Image: (props: ImageProps) => import("./types.js").PdfJsxElement<"image">;
10
+ export declare const Svg: (props: SvgProps) => import("./types.js").PdfJsxElement<"svg">;
11
+ export declare const Rectangle: (props: RectangleProps) => import("./types.js").PdfJsxElement<"rectangle">;
12
+ export declare const Ellipse: (props: EllipseProps) => import("./types.js").PdfJsxElement<"ellipse">;
13
+ export declare const Line: (props: LineProps) => import("./types.js").PdfJsxElement<"line">;
9
14
  export declare const List: (props: ListProps) => import("./types.js").PdfJsxElement<"list">;
10
15
  export declare const Table: (props: TableProps) => import("./types.js").PdfJsxElement<"table">;
11
16
  export declare const PageBreak: (props?: PageBreakProps) => import("./types.js").PdfJsxElement<"pagebreak">;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { Box, List, MultiVariableText, Page, PageBreak, Row, Spacer, Stack, Table, Text, } from './components.js';
1
+ export { Box, Ellipse, Image, Line, List, MultiVariableText, Page, PageBreak, Rectangle, Row, Spacer, Stack, Svg, Table, Text, } from './components.js';
2
2
  export { renderToTemplate } from './render.js';
3
- export type { BoxProps, BoxSides, CellStyle, ListItem, ListProps, MultiVariableTextProps, MultiVariableTextValues, PageBreakProps, PageOrientation, PageProps, PageSize, PageSizePreset, PdfJsxChild, PdfJsxElement, RenderOptions, RenderResult, RowProps, SpacerProps, StackProps, TableProps, TextProps, } from './types.js';
3
+ export type { BoxProps, BoxSides, CellStyle, EllipseProps, ImageProps, LineProps, ListItem, ListProps, MultiVariableTextProps, MultiVariableTextValues, PageBreakProps, PageOrientation, PageProps, PageSize, PageSizePreset, PdfJsxChild, PdfJsxElement, RectangleProps, RenderOptions, RenderResult, RowProps, SpacerProps, StackProps, SvgProps, TableProps, TextProps, } from './types.js';
package/dist/index.js CHANGED
@@ -10,6 +10,11 @@ var Box = makeBuiltin("box");
10
10
  var Spacer = makeBuiltin("spacer");
11
11
  var Text = makeBuiltin("text");
12
12
  var MultiVariableText = makeBuiltin("multiVariableText");
13
+ var Image = makeBuiltin("image");
14
+ var Svg = makeBuiltin("svg");
15
+ var Rectangle = makeBuiltin("rectangle");
16
+ var Ellipse = makeBuiltin("ellipse");
17
+ var Line = makeBuiltin("line");
13
18
  var List = makeBuiltin("list");
14
19
  var Table = makeBuiltin("table");
15
20
  var PageBreak = (props) => createElementNode("pagebreak", props);
@@ -19,6 +24,10 @@ var DEFAULT_FONT_SIZE = 10;
19
24
  var DEFAULT_LINE_HEIGHT = 1;
20
25
  var DEFAULT_CHARACTER_SPACING = 0;
21
26
  var DEFAULT_FONT_COLOR = "#000000";
27
+ var DEFAULT_VISUAL_HEIGHT = 40;
28
+ var DEFAULT_LINE_THICKNESS = .5;
29
+ var DEFAULT_LINE_COLOR = "#000000";
30
+ var DEFAULT_SHAPE_BORDER_COLOR = "#000000";
22
31
  var DEFAULT_DYNAMIC_FONT_SIZE = {
23
32
  min: 4,
24
33
  max: 72,
@@ -181,6 +190,14 @@ var renderElement = async (element, frame, parentMode, ctx) => {
181
190
  ...element.props,
182
191
  children: element.children
183
192
  }, frame, ctx);
193
+ case "image": return renderImage(element.props, frame, ctx);
194
+ case "svg": return renderSvg({
195
+ ...element.props,
196
+ children: element.children
197
+ }, frame, ctx);
198
+ case "rectangle": return renderShape("rectangle", element.props, frame, ctx);
199
+ case "ellipse": return renderShape("ellipse", element.props, frame, ctx);
200
+ case "line": return renderLine(element.props, frame, ctx);
184
201
  case "list": return renderList({
185
202
  ...element.props,
186
203
  children: element.children
@@ -357,6 +374,113 @@ var renderMultiVariableText = async (props, frame, ctx) => {
357
374
  height: schema.height
358
375
  };
359
376
  };
377
+ var renderImage = (props, frame, ctx) => {
378
+ const width = props.width ?? frame.width;
379
+ const height = props.height ?? DEFAULT_VISUAL_HEIGHT;
380
+ const name = resolveName(ctx, "image", props.name);
381
+ const readOnly = props.readOnly ?? props.name == null;
382
+ const content = props.src ?? "";
383
+ const schema = {
384
+ name,
385
+ type: "image",
386
+ content,
387
+ position: {
388
+ x: frame.x,
389
+ y: frame.y
390
+ },
391
+ width,
392
+ height,
393
+ rotate: props.rotate ?? 0,
394
+ opacity: props.opacity ?? 1,
395
+ readOnly,
396
+ required: props.required
397
+ };
398
+ if (!readOnly) ctx.inputs[name] = content;
399
+ ctx.schemas.push(schema);
400
+ return {
401
+ width,
402
+ height
403
+ };
404
+ };
405
+ var renderSvg = (props, frame, ctx) => {
406
+ const width = props.width ?? frame.width;
407
+ const height = props.height ?? DEFAULT_VISUAL_HEIGHT;
408
+ const name = resolveName(ctx, "svg", props.name);
409
+ const readOnly = props.readOnly ?? props.name == null;
410
+ const content = props.svg ?? childrenToString(props.children);
411
+ const schema = {
412
+ name,
413
+ type: "svg",
414
+ content,
415
+ position: {
416
+ x: frame.x,
417
+ y: frame.y
418
+ },
419
+ width,
420
+ height,
421
+ rotate: props.rotate ?? 0,
422
+ opacity: props.opacity ?? 1,
423
+ readOnly,
424
+ required: props.required
425
+ };
426
+ if (!readOnly) ctx.inputs[name] = content;
427
+ ctx.schemas.push(schema);
428
+ return {
429
+ width,
430
+ height
431
+ };
432
+ };
433
+ var renderShape = (type, props, frame, ctx) => {
434
+ const width = props.width ?? frame.width;
435
+ const height = props.height ?? DEFAULT_VISUAL_HEIGHT;
436
+ const fill = props.fill ?? "";
437
+ const borderWidth = props.borderWidth ?? (props.borderColor || !fill ? 1 : 0);
438
+ const schema = {
439
+ name: resolveName(ctx, type, props.name),
440
+ type,
441
+ position: {
442
+ x: frame.x,
443
+ y: frame.y
444
+ },
445
+ width,
446
+ height,
447
+ rotate: props.rotate ?? 0,
448
+ opacity: props.opacity ?? 1,
449
+ readOnly: true,
450
+ borderWidth,
451
+ borderColor: props.borderColor ?? (borderWidth > 0 ? DEFAULT_SHAPE_BORDER_COLOR : ""),
452
+ color: fill,
453
+ radius: type === "rectangle" ? props.radius ?? 0 : 0
454
+ };
455
+ ctx.schemas.push(schema);
456
+ return {
457
+ width,
458
+ height
459
+ };
460
+ };
461
+ var renderLine = (props, frame, ctx) => {
462
+ const width = props.width ?? frame.width;
463
+ const height = props.height ?? DEFAULT_LINE_THICKNESS;
464
+ const schema = {
465
+ name: resolveName(ctx, "line", props.name),
466
+ type: "line",
467
+ position: {
468
+ x: frame.x,
469
+ y: frame.y
470
+ },
471
+ width,
472
+ height,
473
+ rotate: props.rotate ?? 0,
474
+ opacity: props.opacity ?? 1,
475
+ readOnly: true,
476
+ color: props.color ?? DEFAULT_LINE_COLOR
477
+ };
478
+ ctx.schemas.push(schema);
479
+ return {
480
+ width,
481
+ height
482
+ };
483
+ };
360
484
  var renderList = (props, frame, ctx) => {
361
485
  const fontSize = props.size ?? DEFAULT_FONT_SIZE;
362
486
  const lineHeight = props.lineHeight ?? DEFAULT_LINE_HEIGHT;
@@ -600,6 +724,6 @@ var validatePageBreakPlacement = (node, parentKind = void 0, canBreak = false) =
600
724
  }
601
725
  };
602
726
  //#endregion
603
- export { Box, List, MultiVariableText, Page, PageBreak, Row, Spacer, Stack, Table, Text, renderToTemplate };
727
+ export { Box, Ellipse, Image, Line, List, MultiVariableText, Page, PageBreak, Rectangle, Row, Spacer, Stack, Svg, Table, Text, renderToTemplate };
604
728
 
605
729
  //# sourceMappingURL=index.js.map
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 ListProps,\n MultiVariableTextProps,\n PageBreakProps,\n PageProps,\n RowProps,\n SpacerProps,\n StackProps,\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 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 ListSchema,\n MultiVariableTextSchema,\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 ListProps,\n MultiVariableTextProps,\n MultiVariableTextValues,\n PageProps,\n PdfJsxChild,\n PdfJsxElement,\n RenderOptions,\n RenderResult,\n RowProps,\n SpacerProps,\n StackProps,\n TableProps,\n TextProps,\n} from './types.js';\n\ntype Rect = { x: number; y: number; width: number; height: number };\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_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 }, 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: 'stack' | 'row',\n opts: { gap: 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\n for (let i = 0; i < items.length; i += 1) {\n const child = items[i];\n const width = mode === 'row' ? (widths?.[i] ?? 0) : frame.width;\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\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\n const advance = mode === 'stack' ? size.height : width;\n cursor += advance + (i < items.length - 1 ? opts.gap : 0);\n crossMax = Math.max(crossMax, mode === 'stack' ? size.width : size.height);\n }\n\n return mode === 'stack'\n ? { width: crossMax, height: cursor }\n : { width: cursor, height: crossMax };\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 if (typeof item === 'string' || typeof item === 'number') {\n flexCount += 1;\n return undefined;\n }\n const width = (item.props as { width?: number }).width;\n if (typeof width === 'number') {\n fixedWidth += width;\n return width;\n }\n flexCount += 1;\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 renderElement = async (\n element: PdfJsxElement,\n frame: Rect,\n parentMode: 'stack' | 'row',\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 '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 },\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 },\n ctx,\n );\n\nconst renderBox = async (\n props: BoxProps,\n children: PdfJsxChild[],\n frame: Rect,\n _parentMode: 'stack' | 'row',\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(children, innerFrame, 'stack', { gap: 0 }, ctx);\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 name = resolveName(ctx, 'text', props.name);\n const readOnly = props.readOnly ?? props.name == null;\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: props.textFormat ?? 'plain',\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 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.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AW,CAAC;AAE3C,IAAM,+BACJ,OACA,eACA,gBACG;AACH,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxC,MAAM,QAAQ,MAAM,IAAI;EACxB,MAAM,WAAW,gBAAgB,MAAM,MAAM,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 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 };\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 }, 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: 'stack' | 'row',\n opts: { gap: 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\n for (let i = 0; i < items.length; i += 1) {\n const child = items[i];\n const width = mode === 'row' ? (widths?.[i] ?? 0) : frame.width;\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\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\n const advance = mode === 'stack' ? size.height : width;\n cursor += advance + (i < items.length - 1 ? opts.gap : 0);\n crossMax = Math.max(crossMax, mode === 'stack' ? size.width : size.height);\n }\n\n return mode === 'stack'\n ? { width: crossMax, height: cursor }\n : { width: cursor, height: crossMax };\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 if (typeof item === 'string' || typeof item === 'number') {\n flexCount += 1;\n return undefined;\n }\n const width = (item.props as { width?: number }).width;\n if (typeof width === 'number') {\n fixedWidth += width;\n return width;\n }\n flexCount += 1;\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 renderElement = async (\n element: PdfJsxElement,\n frame: Rect,\n parentMode: 'stack' | 'row',\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 },\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 },\n ctx,\n );\n\nconst renderBox = async (\n props: BoxProps,\n children: PdfJsxChild[],\n frame: Rect,\n _parentMode: 'stack' | 'row',\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(children, innerFrame, 'stack', { gap: 0 }, ctx);\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 name = resolveName(ctx, 'text', props.name);\n const readOnly = props.readOnly ?? props.name == null;\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: props.textFormat ?? 'plain',\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 valid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AI,UAAU,IAAI,KAAK;AAChC,KAAI,UAAU,IAAI,KAAK;AACvB,QAAO;;AAGT,IAAM,sBAAsB,UAAkB,eAC5C,KAAK,IAAI,GAAG,MAAM,WAAW,WAAW,CAAC;AAE3C,IAAM,+BACJ,OACA,eACA,gBACG;AACH,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxC,MAAM,QAAQ,MAAM,IAAI;EACxB,MAAM,WAAW,gBAAgB,MAAM,MAAM,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"}
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { BasePdf, Font, PageOrientation, PageSize, Schema, Template } from '@pdfme/common';
2
- import type { ALIGNMENT, LIST_STYLE, ListItem as SchemaListItem, CellStyle as SchemaCellStyle, TableSchema, TextSchema, MultiVariableTextSchema } from '@pdfme/schemas/types';
2
+ import type { ALIGNMENT, ImageSchema, LIST_STYLE, ListItem as SchemaListItem, LineSchema, CellStyle as SchemaCellStyle, ShapeSchema, SVGSchema, TableSchema, TextSchema, MultiVariableTextSchema } from '@pdfme/schemas/types';
3
3
  export type { PageOrientation, PageSize, PageSizePreset } from '@pdfme/common';
4
- export type BuiltinKind = 'page' | 'stack' | 'row' | 'box' | 'spacer' | 'text' | 'multiVariableText' | 'list' | 'table' | 'pagebreak';
4
+ export type BuiltinKind = 'page' | 'stack' | 'row' | 'box' | 'spacer' | 'text' | 'multiVariableText' | 'image' | 'svg' | 'rectangle' | 'ellipse' | 'line' | 'list' | 'table' | 'pagebreak';
5
5
  export type PdfJsxElement<K extends BuiltinKind = BuiltinKind> = {
6
6
  kind: K;
7
7
  props: Record<string, unknown>;
@@ -97,6 +97,23 @@ export type MultiVariableTextProps = CommonProps & MultiVariableTextSchemaProps
97
97
  borderWidth?: number;
98
98
  dynamicFontSize?: Partial<NonNullable<MultiVariableTextSchema['dynamicFontSize']>>;
99
99
  };
100
+ type ImageSchemaProps = Partial<Pick<ImageSchema, 'name' | 'width' | 'height' | 'readOnly' | 'required'>>;
101
+ export type ImageProps = CommonProps & ImageSchemaProps & {
102
+ src?: string;
103
+ };
104
+ type SvgSchemaProps = Partial<Pick<SVGSchema, 'name' | 'width' | 'height' | 'readOnly' | 'required'>>;
105
+ export type SvgProps = SvgSchemaProps & {
106
+ svg?: string;
107
+ children?: PdfJsxChild;
108
+ } & CommonProps;
109
+ type ShapeSchemaProps = Partial<Pick<ShapeSchema, 'name' | 'width' | 'height' | 'borderWidth' | 'borderColor' | 'radius'>>;
110
+ export type RectangleProps = CommonProps & ShapeSchemaProps & {
111
+ fill?: ShapeSchema['color'];
112
+ };
113
+ export type EllipseProps = CommonProps & Omit<ShapeSchemaProps, 'radius'> & {
114
+ fill?: ShapeSchema['color'];
115
+ };
116
+ export type LineProps = CommonProps & Partial<Pick<LineSchema, 'name' | 'width' | 'height' | 'color'>>;
100
117
  export type ListItem = string | {
101
118
  text: SchemaListItem['text'];
102
119
  level?: SchemaListItem['level'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/jsx",
3
- "version": "6.1.1-dev.17",
3
+ "version": "6.1.1-dev.18",
4
4
  "description": "Author pdfme templates with JSX stacking layout primitives.",
5
5
  "keywords": [
6
6
  "jsx",