@pdfme/jsx 6.1.1-dev.8 → 6.1.2

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
@@ -4,13 +4,19 @@ Small JSX authoring layer for creating pdfme templates from stacking layout prim
4
4
 
5
5
  ```tsx
6
6
  /** @jsxImportSource @pdfme/jsx */
7
- import { Page, Stack, Text, renderToTemplate } from '@pdfme/jsx';
7
+ import { MultiVariableText, Page, Stack, Text, renderToTemplate } from '@pdfme/jsx';
8
8
 
9
9
  const { template, inputs } = await renderToTemplate(
10
10
  <Page margin={{ x: 12, y: 16 }}>
11
11
  <Stack gap={4}>
12
12
  <Text size={18}>Invoice</Text>
13
13
  <Text name="customerName">Alice</Text>
14
+ <MultiVariableText
15
+ name="message"
16
+ text="Hello **{name}**, status: `{status}`"
17
+ values={{ name: 'Alice **literal**', status: 'draft' }}
18
+ textFormat="inline-markdown"
19
+ />
14
20
  </Stack>
15
21
  </Page>,
16
22
  );
@@ -22,10 +28,78 @@ it provides its own `jsx-runtime` and `jsx-dev-runtime`.
22
28
 
23
29
  ## MVP constraints
24
30
 
25
- - `Text` height is measured with pdfme's text/rich text wrapping helpers when `height` is omitted.
26
- Pass an explicit `height` when you need a fixed field box.
31
+ - `Text` and `MultiVariableText` heights are measured with pdfme's text/rich text wrapping helpers
32
+ when `height` is omitted. Pass an explicit `height` when you need a fixed field box.
33
+ - `Text textFormat="inline-markdown"` is read-only only. Editable `Text` values use plain content.
34
+ - `MultiVariableText` uses `text` or children as the template string and stores `values` as the
35
+ JSON input. Variable names are inferred from `{name}` placeholders and can also be passed with
36
+ `variables`.
37
+ - `Image` uses `src` as its initial content and is intended to be self-closing.
38
+ - `Svg` uses `svg` or children as its initial content.
39
+ - With `name`, `Image` and `Svg` become input-backed schemas; without `name`, they are read-only
40
+ content.
41
+ - `Rectangle`, `Ellipse`, and `Line` are static visual schemas for backgrounds, dividers, and simple
42
+ shapes.
43
+ - `Static`, `Header`, and `Footer` can be used as direct children of the first `Page` to render
44
+ read-only header/footer style content into blank `basePdf.staticSchema`. Their children use page
45
+ coordinates, not page margin coordinates, and custom `basePdf` is not supported.
46
+ - `Header` is a shorthand for `<Static placement="top">`; `Footer` is a shorthand for
47
+ `<Static placement="bottom">`.
48
+
49
+ ```tsx
50
+ <Header>
51
+ <Text height={8}>Header</Text>
52
+ </Header>
53
+ <Footer>
54
+ <Text height={8}>Footer</Text>
55
+ </Footer>
56
+ ```
57
+
58
+ - Multiple `Static` blocks with the same placement are concatenated in declaration order. Top blocks
59
+ start at the top of the page; bottom blocks are stacked together in declaration order and anchored
60
+ to the page bottom, so the last bottom block sits at the page edge. If top and bottom static
61
+ content together exceed the page height, they may overlap.
62
+ - Static content currently accepts read-only `Stack`, `Row`, `Box`, `Spacer`, `Text`, `Image`, `Svg`,
63
+ `Rectangle`, `Ellipse`, and `Line` content. `MultiVariableText`, `List`, `Table`, input-backed
64
+ schemas, and `PageBreak` are rejected.
65
+ - `Absolute` can be used inside `Page`, top `Static`, or `Box` as a small manual placement escape
66
+ hatch. It uses the parent layout frame as its coordinate origin and does not advance the
67
+ surrounding stack/row flow. When `width` or `height` is omitted, it uses the remaining parent
68
+ frame size from `x` / `y`. Direct `Stack` / `Row` support is intentionally left for later; wrap
69
+ with an explicit-size `Box` when you need a local manual-placement frame inside flow content.
70
+
71
+ ```tsx
72
+ <Page margin={12}>
73
+ <Text height={8}>Body starts here</Text>
74
+ <Absolute x={120} y={0} width={60}>
75
+ <Text height={6}>Top-right note</Text>
76
+ </Absolute>
77
+ </Page>
78
+ ```
79
+
80
+ - Layout children can use `margin`. `Stack` and `Row` support `alignItems` for simple cross-axis
81
+ alignment without trying to implement full CSS/Flexbox.
82
+ - `Stack` and `Row` support `justifyContent="start" | "center" | "end" | "space-between"` for
83
+ main-axis spacing. `Stack` uses this most predictably with an explicit `height`; `Row` uses it most
84
+ predictably with an explicit `width`.
85
+ - `Stack` defaults to `alignItems="stretch"` to preserve full-width stacking. Use an explicit child
86
+ `width` when you want `alignItems="center"` or `"end"` to visibly move that child.
87
+ - `Row` defaults to `alignItems="start"` and intentionally does not support cross-axis stretch yet.
88
+ - Row children can use `flexGrow` or `flex` as a grow weight. If `width` is also set, it is used as
89
+ the basis before remaining width is distributed.
90
+ `flex` is only a short alias for `flexGrow`, not the CSS `flex` shorthand.
91
+
92
+ ```tsx
93
+ <Row width={120}>
94
+ <Text width={20} flex={1}>A</Text>
95
+ <Text width={20} flex={3}>B</Text>
96
+ </Row>
97
+ // A width: 40, B width: 80
98
+ ```
99
+
100
+ - `flexGrow={0}` without `width` produces a zero-width Row child.
27
101
  - `PageBreak` is supported only along a `Page` / `Stack` / `Box` layout path. It is rejected inside
28
- `Row`, `Text`, `List`, and `Table`.
102
+ `Row`, leaf schemas, `List`, and `Table`.
29
103
  - All `Page` nodes in one `renderToTemplate` call must use the same page size, orientation, and
30
104
  margin because a pdfme blank `basePdf` has one shared size and padding.
31
105
  - `Table widths` are percentages passed to pdfme `headWidthPercentages`, for example
@@ -1,10 +1,21 @@
1
- import type { BoxProps, ListProps, PageBreakProps, PageProps, RowProps, SpacerProps, StackProps, TableProps, TextProps } from './types.js';
1
+ import { createElementNode } from './node.js';
2
+ import type { AbsoluteProps, BoxProps, EllipseProps, FooterProps, HeaderProps, ImageProps, LineProps, ListProps, MultiVariableTextProps, PageBreakProps, PageProps, RectangleProps, RowProps, SpacerProps, StackProps, StaticProps, SvgProps, TableProps, TextProps } from './types.js';
2
3
  export declare const Page: (props: PageProps) => import("./types.js").PdfJsxElement<"page">;
4
+ export declare const Static: (props: StaticProps) => import("./types.js").PdfJsxElement<"static">;
5
+ export declare const Header: (props: HeaderProps) => ReturnType<typeof createElementNode<"static">>;
6
+ export declare const Footer: (props: FooterProps) => ReturnType<typeof createElementNode<"static">>;
7
+ export declare const Absolute: (props: AbsoluteProps) => import("./types.js").PdfJsxElement<"absolute">;
3
8
  export declare const Stack: (props: StackProps) => import("./types.js").PdfJsxElement<"stack">;
4
9
  export declare const Row: (props: RowProps) => import("./types.js").PdfJsxElement<"row">;
5
10
  export declare const Box: (props: BoxProps) => import("./types.js").PdfJsxElement<"box">;
6
11
  export declare const Spacer: (props: SpacerProps) => import("./types.js").PdfJsxElement<"spacer">;
7
12
  export declare const Text: (props: TextProps) => import("./types.js").PdfJsxElement<"text">;
13
+ export declare const MultiVariableText: (props: MultiVariableTextProps) => import("./types.js").PdfJsxElement<"multiVariableText">;
14
+ export declare const Image: (props: ImageProps) => import("./types.js").PdfJsxElement<"image">;
15
+ export declare const Svg: (props: SvgProps) => import("./types.js").PdfJsxElement<"svg">;
16
+ export declare const Rectangle: (props: RectangleProps) => import("./types.js").PdfJsxElement<"rectangle">;
17
+ export declare const Ellipse: (props: EllipseProps) => import("./types.js").PdfJsxElement<"ellipse">;
18
+ export declare const Line: (props: LineProps) => import("./types.js").PdfJsxElement<"line">;
8
19
  export declare const List: (props: ListProps) => import("./types.js").PdfJsxElement<"list">;
9
20
  export declare const Table: (props: TableProps) => import("./types.js").PdfJsxElement<"table">;
10
21
  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, Page, PageBreak, Row, Spacer, Stack, Table, Text } from './components.js';
1
+ export { Absolute, Box, Ellipse, Footer, Header, Image, Line, List, MultiVariableText, Page, PageBreak, Rectangle, Row, Spacer, Stack, Static, Svg, Table, Text, } from './components.js';
2
2
  export { renderToTemplate } from './render.js';
3
- export type { BoxProps, BoxSides, CellStyle, ListItem, ListProps, PageBreakProps, PageOrientation, PageProps, PageSize, PageSizePreset, PdfJsxChild, PdfJsxElement, RenderOptions, RenderResult, RowProps, SpacerProps, StackProps, TableProps, TextProps, } from './types.js';
3
+ export type { AbsoluteProps, BoxProps, BoxSides, CellStyle, EllipseProps, FooterProps, HeaderProps, ImageProps, LineProps, ListItem, ListProps, MultiVariableTextProps, MultiVariableTextValues, PageBreakProps, PageOrientation, PageProps, PageSize, PageSizePreset, PdfJsxChild, PdfJsxElement, RectangleProps, RenderOptions, RenderResult, RowProps, SpacerProps, StackProps, StaticPlacement, StaticProps, SvgProps, TableProps, TextProps, } from './types.js';
package/dist/index.js CHANGED
@@ -1,14 +1,30 @@
1
1
  import { a as isPdfJsxElement, n as cloneElementWithChildren, o as isPdfJsxFragment, r as createElementNode } from "./node-BeNL0xMl.js";
2
- import { getDefaultFont, pt2mm, resolvePageSize } from "@pdfme/common";
3
- import { measureTextHeight } from "@pdfme/schemas/utils";
2
+ import { getDefaultFont, isBlankPdf, pt2mm, resolvePageSize } from "@pdfme/common";
3
+ import { escapeInlineMarkdown, getVariableNames, measureTextHeight, visitVariables } from "@pdfme/schemas/utils";
4
4
  //#region src/components.ts
5
5
  var makeBuiltin = (kind) => (props) => createElementNode(kind, props);
6
6
  var Page = makeBuiltin("page");
7
+ var Static = makeBuiltin("static");
8
+ var Header = (props) => createElementNode("static", {
9
+ ...props,
10
+ placement: "top"
11
+ });
12
+ var Footer = (props) => createElementNode("static", {
13
+ ...props,
14
+ placement: "bottom"
15
+ });
16
+ var Absolute = makeBuiltin("absolute");
7
17
  var Stack = makeBuiltin("stack");
8
18
  var Row = makeBuiltin("row");
9
19
  var Box = makeBuiltin("box");
10
20
  var Spacer = makeBuiltin("spacer");
11
21
  var Text = makeBuiltin("text");
22
+ var MultiVariableText = makeBuiltin("multiVariableText");
23
+ var Image = makeBuiltin("image");
24
+ var Svg = makeBuiltin("svg");
25
+ var Rectangle = makeBuiltin("rectangle");
26
+ var Ellipse = makeBuiltin("ellipse");
27
+ var Line = makeBuiltin("line");
12
28
  var List = makeBuiltin("list");
13
29
  var Table = makeBuiltin("table");
14
30
  var PageBreak = (props) => createElementNode("pagebreak", props);
@@ -18,6 +34,10 @@ var DEFAULT_FONT_SIZE = 10;
18
34
  var DEFAULT_LINE_HEIGHT = 1;
19
35
  var DEFAULT_CHARACTER_SPACING = 0;
20
36
  var DEFAULT_FONT_COLOR = "#000000";
37
+ var DEFAULT_VISUAL_HEIGHT = 40;
38
+ var DEFAULT_LINE_THICKNESS = .5;
39
+ var DEFAULT_LINE_COLOR = "#000000";
40
+ var DEFAULT_SHAPE_BORDER_COLOR = "#000000";
21
41
  var DEFAULT_DYNAMIC_FONT_SIZE = {
22
42
  min: 4,
23
43
  max: 72,
@@ -25,19 +45,43 @@ var DEFAULT_DYNAMIC_FONT_SIZE = {
25
45
  };
26
46
  var renderToTemplate = async (node, options = {}) => {
27
47
  validatePageBreakPlacement(node);
28
- const pages = flattenChildren(expandPageBreaks(node)).filter((child) => isPdfJsxElement(child) && child.kind === "page");
48
+ const expanded = expandPageBreaks(node);
49
+ validateAbsolutePlacement(expanded);
50
+ validateNoTopLevelStatic(expanded);
51
+ const pages = flattenChildren(expanded).filter((child) => isPdfJsxElement(child) && child.kind === "page");
29
52
  if (pages.length === 0) throw new Error("@pdfme/jsx: renderToTemplate root must contain at least one <Page>.");
30
53
  const firstPageProps = pages[0]?.props;
31
54
  const firstMargin = resolveBoxSides(firstPageProps.margin);
32
55
  const pageSize = resolvePageSize(firstPageProps.size, firstPageProps.orientation);
33
56
  validateConsistentPageProps(pages, pageSize, firstMargin);
57
+ validateStaticPlacement(pages);
58
+ const { pages: bodyPages, blocks: staticBlocks } = extractStaticChildren(pages);
34
59
  const inputs = {};
35
60
  const usedNames = /* @__PURE__ */ new Set();
36
61
  const nameCounters = {};
37
62
  const font = options.font ?? getDefaultFont();
38
63
  const _cache = /* @__PURE__ */ new Map();
39
64
  const pageSchemas = [];
40
- for (const page of pages) {
65
+ const staticSchemas = [];
66
+ const hasStaticChildren = hasStaticBlocks(staticBlocks);
67
+ if (hasStaticChildren && options.basePdf != null && !isBlankPdf(options.basePdf)) throw new Error("@pdfme/jsx: <Static> is supported only with a blank basePdf.");
68
+ if (hasStaticChildren) await layoutStaticBlocks({
69
+ blocks: staticBlocks,
70
+ frame: {
71
+ x: 0,
72
+ y: 0,
73
+ width: pageSize.width,
74
+ height: pageSize.height
75
+ },
76
+ staticSchemas,
77
+ inputs,
78
+ usedNames,
79
+ nameCounters,
80
+ defaultFont: firstPageProps.font,
81
+ font,
82
+ _cache
83
+ });
84
+ for (const page of bodyPages) {
41
85
  const props = page.props;
42
86
  const margin = resolveBoxSides(props.margin);
43
87
  const frame = {
@@ -55,21 +99,29 @@ var renderToTemplate = async (node, options = {}) => {
55
99
  font,
56
100
  _cache
57
101
  };
58
- await layoutChildren(page.children, frame, "stack", { gap: 0 }, ctx);
102
+ await layoutChildren(page.children, frame, "stack", {
103
+ gap: 0,
104
+ alignItems: "stretch",
105
+ justifyContent: "start"
106
+ }, ctx);
59
107
  pageSchemas.push(ctx.schemas);
60
108
  }
109
+ const basePdf = options.basePdf ?? {
110
+ width: pageSize.width,
111
+ height: pageSize.height,
112
+ padding: [
113
+ firstMargin.top,
114
+ firstMargin.right,
115
+ firstMargin.bottom,
116
+ firstMargin.left
117
+ ]
118
+ };
61
119
  return {
62
120
  template: {
63
- basePdf: options.basePdf ?? {
64
- width: pageSize.width,
65
- height: pageSize.height,
66
- padding: [
67
- firstMargin.top,
68
- firstMargin.right,
69
- firstMargin.bottom,
70
- firstMargin.left
71
- ]
72
- },
121
+ basePdf: staticSchemas.length > 0 && isBlankPdf(basePdf) ? {
122
+ ...basePdf,
123
+ staticSchema: [...basePdf.staticSchema ?? [], ...staticSchemas]
124
+ } : basePdf,
73
125
  schemas: pageSchemas
74
126
  },
75
127
  inputs: [inputs]
@@ -115,14 +167,66 @@ var flattenForSplitting = (children) => {
115
167
  return [children];
116
168
  };
117
169
  var expandPageBreaks = (node) => splitChildrenByPageBreak(node).flat();
170
+ var extractStaticChildren = (pages) => {
171
+ const blocks = {
172
+ top: [],
173
+ bottom: []
174
+ };
175
+ return {
176
+ pages: pages.map((page, pageIndex) => {
177
+ const bodyChildren = [];
178
+ for (const child of flattenForSplitting(page.children)) {
179
+ if (isPdfJsxElement(child) && child.kind === "static") {
180
+ if (pageIndex === 0) blocks[getStaticPlacement(child)].push(child.children);
181
+ continue;
182
+ }
183
+ bodyChildren.push(child);
184
+ }
185
+ return cloneElementWithChildren(page, bodyChildren);
186
+ }),
187
+ blocks
188
+ };
189
+ };
190
+ var hasStaticBlocks = (blocks) => blocks.top.length > 0 || blocks.bottom.length > 0;
191
+ var layoutStaticBlocks = async (arg) => {
192
+ for (const placement of ["top", "bottom"]) {
193
+ const children = arg.blocks[placement];
194
+ if (children.length === 0) continue;
195
+ const schemas = [];
196
+ const ctx = {
197
+ schemas,
198
+ inputs: arg.inputs,
199
+ usedNames: arg.usedNames,
200
+ nameCounters: arg.nameCounters,
201
+ defaultFont: arg.defaultFont,
202
+ font: arg.font,
203
+ _cache: arg._cache
204
+ };
205
+ const size = await layoutChildren(children, arg.frame, "stack", {
206
+ gap: 0,
207
+ alignItems: "stretch",
208
+ justifyContent: "start"
209
+ }, ctx);
210
+ if (placement === "bottom") shiftSchemas(schemas, 0, schemas.length, 0, Math.max(0, arg.frame.height - size.height));
211
+ arg.staticSchemas.push(...schemas);
212
+ }
213
+ };
118
214
  var layoutChildren = async (children, frame, mode, opts, ctx) => {
119
215
  const items = flattenChildren(children);
120
- const widths = mode === "row" ? resolveRowWidths(items, frame.width, opts.gap) : void 0;
216
+ const flowItems = items.filter((item) => !isAbsoluteElement(item));
217
+ const widths = mode === "row" ? resolveRowWidths(flowItems, frame.width, opts.gap) : void 0;
121
218
  let cursor = 0;
122
219
  let crossMax = 0;
220
+ let flowIndex = 0;
221
+ const layoutItems = [];
123
222
  for (let i = 0; i < items.length; i += 1) {
124
223
  const child = items[i];
125
- const width = mode === "row" ? widths?.[i] ?? 0 : frame.width;
224
+ if (isAbsoluteElement(child)) {
225
+ await renderAbsolute(child.props, child.children, frame, ctx);
226
+ continue;
227
+ }
228
+ const margin = getChildMargin(child);
229
+ const width = mode === "row" ? widths?.[flowIndex] ?? 0 : resolveStackChildWidth(child, frame.width, margin);
126
230
  const childFrame = mode === "stack" ? {
127
231
  x: frame.x,
128
232
  y: frame.y + cursor,
@@ -134,68 +238,197 @@ var layoutChildren = async (children, frame, mode, opts, ctx) => {
134
238
  width,
135
239
  height: frame.height
136
240
  };
241
+ childFrame.x += margin.left;
242
+ childFrame.y += margin.top;
243
+ childFrame.height = Math.max(0, childFrame.height - margin.top - margin.bottom);
244
+ const schemaStart = ctx.schemas.length;
137
245
  const size = typeof child === "string" || typeof child === "number" ? await renderText({ children: String(child) }, childFrame, ctx) : await renderElement(child, childFrame, mode, ctx);
138
- const advance = mode === "stack" ? size.height : width;
139
- cursor += advance + (i < items.length - 1 ? opts.gap : 0);
140
- crossMax = Math.max(crossMax, mode === "stack" ? size.width : size.height);
246
+ const schemaEnd = ctx.schemas.length;
247
+ const mainSize = mode === "stack" ? margin.top + size.height + margin.bottom : margin.left + width + margin.right;
248
+ const outerHeight = margin.top + size.height + margin.bottom;
249
+ layoutItems.push({
250
+ schemaStart,
251
+ schemaEnd,
252
+ outerHeight
253
+ });
254
+ if (mode === "stack") {
255
+ const outerWidth = margin.left + size.width + margin.right;
256
+ const dx = resolveAlignOffset(frame.width, outerWidth, opts.alignItems);
257
+ if (dx !== 0) shiftSchemas(ctx.schemas, schemaStart, schemaEnd, dx, 0);
258
+ }
259
+ cursor += mainSize + (flowIndex < flowItems.length - 1 ? opts.gap : 0);
260
+ flowIndex += 1;
261
+ crossMax = Math.max(crossMax, mode === "stack" ? margin.left + size.width + margin.right : margin.top + size.height + margin.bottom);
262
+ }
263
+ const contentMainSize = cursor;
264
+ const containerMainSize = opts.mainSize ?? contentMainSize;
265
+ applyJustifyContent(ctx.schemas, layoutItems, mode, contentMainSize, containerMainSize, opts);
266
+ if (mode === "row") {
267
+ const rowHeight = opts.crossSize ?? crossMax;
268
+ for (const item of layoutItems) {
269
+ const dy = resolveAlignOffset(rowHeight, item.outerHeight, opts.alignItems);
270
+ if (dy !== 0) shiftSchemas(ctx.schemas, item.schemaStart, item.schemaEnd, 0, dy);
271
+ }
272
+ return {
273
+ width: containerMainSize,
274
+ height: rowHeight
275
+ };
141
276
  }
142
- return mode === "stack" ? {
277
+ return {
143
278
  width: crossMax,
144
- height: cursor
145
- } : {
146
- width: cursor,
147
- height: crossMax
279
+ height: containerMainSize
148
280
  };
149
281
  };
150
282
  var resolveRowWidths = (items, frameWidth, gap) => {
151
- let fixedWidth = 0;
152
- let flexCount = 0;
153
- const widths = items.map((item) => {
154
- if (typeof item === "string" || typeof item === "number") {
155
- flexCount += 1;
156
- return;
157
- }
158
- const width = item.props.width;
159
- if (typeof width === "number") {
160
- fixedWidth += width;
161
- return width;
162
- }
163
- flexCount += 1;
283
+ let usedWidth = 0;
284
+ let totalGrow = 0;
285
+ const parts = items.map((item) => {
286
+ const margin = getChildMargin(item);
287
+ const width = getChildWidth(item);
288
+ const grow = getChildFlexGrow(item) ?? (width == null ? 1 : 0);
289
+ const basis = width ?? 0;
290
+ usedWidth += basis + margin.left + margin.right;
291
+ totalGrow += grow;
292
+ return {
293
+ basis,
294
+ grow
295
+ };
164
296
  });
165
- const remaining = Math.max(0, frameWidth - fixedWidth - Math.max(0, items.length - 1) * gap);
166
- const flexWidth = flexCount > 0 ? remaining / flexCount : 0;
167
- return widths.map((width) => width ?? flexWidth);
297
+ const remaining = Math.max(0, frameWidth - usedWidth - Math.max(0, items.length - 1) * gap);
298
+ const flexUnit = totalGrow > 0 ? remaining / totalGrow : 0;
299
+ return parts.map(({ basis, grow }) => basis + grow * flexUnit);
300
+ };
301
+ var getChildMargin = (child) => {
302
+ if (typeof child === "string" || typeof child === "number") return resolveBoxSides();
303
+ return resolveBoxSides(child.props.margin);
304
+ };
305
+ var getChildWidth = (child) => {
306
+ if (typeof child === "string" || typeof child === "number") return void 0;
307
+ const width = child.props.width;
308
+ return typeof width === "number" ? width : void 0;
309
+ };
310
+ var getChildFlexGrow = (child) => {
311
+ if (typeof child === "string" || typeof child === "number") return void 0;
312
+ const props = child.props;
313
+ const flexGrow = props.flexGrow ?? props.flex;
314
+ return typeof flexGrow === "number" ? Math.max(0, flexGrow) : void 0;
315
+ };
316
+ var isAbsoluteElement = (child) => isPdfJsxElement(child) && child.kind === "absolute";
317
+ var getStaticPlacement = (element) => {
318
+ const placement = element.props.placement ?? "top";
319
+ if (placement !== "top" && placement !== "bottom") throw new Error("@pdfme/jsx: <Static> placement must be \"top\" or \"bottom\".");
320
+ return placement;
321
+ };
322
+ var resolveStackChildWidth = (child, frameWidth, margin) => {
323
+ const width = getChildWidth(child);
324
+ if (width != null) return width;
325
+ return Math.max(0, frameWidth - margin.left - margin.right);
326
+ };
327
+ var applyJustifyContent = (schemas, items, mode, contentMainSize, containerMainSize, opts) => {
328
+ const extraSpace = Math.max(0, containerMainSize - contentMainSize);
329
+ if (extraSpace === 0 || opts.justifyContent === "start") return;
330
+ const extraGap = opts.justifyContent === "space-between" && items.length > 1 ? extraSpace / (items.length - 1) : 0;
331
+ const startOffset = opts.justifyContent === "center" ? extraSpace / 2 : opts.justifyContent === "end" ? extraSpace : 0;
332
+ let runningExtraGap = 0;
333
+ for (const item of items) {
334
+ const offset = startOffset + runningExtraGap;
335
+ if (offset !== 0) shiftSchemas(schemas, item.schemaStart, item.schemaEnd, mode === "row" ? offset : 0, mode === "stack" ? offset : 0);
336
+ runningExtraGap += extraGap;
337
+ }
338
+ };
339
+ var resolveAlignOffset = (containerSize, itemSize, alignItems) => {
340
+ if (alignItems === "center") return Math.max(0, (containerSize - itemSize) / 2);
341
+ if (alignItems === "end") return Math.max(0, containerSize - itemSize);
342
+ return 0;
343
+ };
344
+ var shiftSchemas = (schemas, start, end, dx, dy) => {
345
+ for (let i = start; i < end; i += 1) {
346
+ const schema = schemas[i];
347
+ if (!schema) continue;
348
+ schema.position = {
349
+ x: schema.position.x + dx,
350
+ y: schema.position.y + dy
351
+ };
352
+ }
168
353
  };
169
354
  var renderElement = async (element, frame, parentMode, ctx) => {
355
+ const props = parentMode === "row" && getChildFlexGrow(element) != null ? {
356
+ ...element.props,
357
+ width: frame.width
358
+ } : element.props;
170
359
  switch (element.kind) {
171
- case "stack": return renderStack(element.props, element.children, frame, ctx);
172
- case "row": return renderRow(element.props, element.children, frame, ctx);
173
- case "box": return renderBox(element.props, element.children, frame, parentMode, ctx);
174
- case "spacer": return Promise.resolve(renderSpacer(element.props));
360
+ case "stack": return renderStack(props, element.children, frame, ctx);
361
+ case "row": return renderRow(props, element.children, frame, ctx);
362
+ case "box": return renderBox(props, element.children, frame, parentMode, ctx);
363
+ case "spacer": return Promise.resolve(renderSpacer(props));
175
364
  case "text": return renderText({
176
- ...element.props,
365
+ ...props,
177
366
  children: element.children
178
367
  }, frame, ctx);
368
+ case "multiVariableText": return renderMultiVariableText({
369
+ ...props,
370
+ children: element.children
371
+ }, frame, ctx);
372
+ case "image": return renderImage(props, frame, ctx);
373
+ case "svg": return renderSvg({
374
+ ...props,
375
+ children: element.children
376
+ }, frame, ctx);
377
+ case "rectangle": return renderShape("rectangle", props, frame, ctx);
378
+ case "ellipse": return renderShape("ellipse", props, frame, ctx);
379
+ case "line": return renderLine(props, frame, ctx);
179
380
  case "list": return renderList({
180
- ...element.props,
381
+ ...props,
181
382
  children: element.children
182
383
  }, frame, ctx);
183
- case "table": return renderTable(element.props, frame, ctx);
384
+ case "table": return renderTable(props, frame, ctx);
385
+ case "static": throw new Error("@pdfme/jsx: <Static> can only be used as a direct child of the first <Page>.");
386
+ case "absolute": return renderAbsolute(props, element.children, frame, ctx);
184
387
  default: return {
185
388
  width: 0,
186
389
  height: 0
187
390
  };
188
391
  }
189
392
  };
393
+ var renderAbsolute = async (props, children, frame, ctx) => {
394
+ const x = props.x ?? 0;
395
+ const y = props.y ?? 0;
396
+ await layoutChildren(children, {
397
+ x: frame.x + x,
398
+ y: frame.y + y,
399
+ width: props.width ?? Math.max(0, frame.width - x),
400
+ height: props.height ?? Math.max(0, frame.height - y)
401
+ }, "stack", {
402
+ gap: 0,
403
+ alignItems: "stretch",
404
+ justifyContent: "start"
405
+ }, ctx);
406
+ return {
407
+ width: 0,
408
+ height: 0
409
+ };
410
+ };
190
411
  var renderStack = (props, children, frame, ctx) => layoutChildren(children, {
191
412
  ...frame,
192
- width: props.width ?? frame.width
193
- }, "stack", { gap: props.gap ?? 0 }, ctx);
413
+ width: props.width ?? frame.width,
414
+ height: props.height ?? frame.height
415
+ }, "stack", {
416
+ gap: props.gap ?? 0,
417
+ alignItems: props.alignItems ?? "stretch",
418
+ justifyContent: props.justifyContent ?? "start",
419
+ mainSize: props.height
420
+ }, ctx);
194
421
  var renderRow = (props, children, frame, ctx) => layoutChildren(children, {
195
422
  ...frame,
196
423
  width: props.width ?? frame.width,
197
424
  height: props.height ?? frame.height
198
- }, "row", { gap: props.gap ?? 0 }, ctx);
425
+ }, "row", {
426
+ gap: props.gap ?? 0,
427
+ alignItems: props.alignItems ?? "start",
428
+ justifyContent: props.justifyContent ?? "start",
429
+ mainSize: props.width,
430
+ crossSize: props.height
431
+ }, ctx);
199
432
  var renderBox = async (props, children, frame, _parentMode, ctx) => {
200
433
  const width = props.width ?? frame.width;
201
434
  const padding = resolveBoxSides(props.padding);
@@ -223,7 +456,11 @@ var renderBox = async (props, children, frame, _parentMode, ctx) => {
223
456
  y: frame.y + padding.top,
224
457
  width: width - padding.left - padding.right,
225
458
  height: (props.height ?? frame.height) - padding.top - padding.bottom
226
- }, "stack", { gap: 0 }, ctx);
459
+ }, "stack", {
460
+ gap: 0,
461
+ alignItems: "stretch",
462
+ justifyContent: "start"
463
+ }, ctx);
227
464
  const height = props.height ?? childSize.height + padding.top + padding.bottom;
228
465
  if (needsRect) ctx.schemas[beforeCount] = {
229
466
  ...ctx.schemas[beforeCount],
@@ -243,8 +480,10 @@ var renderText = async (props, frame, ctx) => {
243
480
  const lineHeight = props.lineHeight ?? DEFAULT_LINE_HEIGHT;
244
481
  const width = props.width ?? frame.width;
245
482
  const value = childrenToString(props.children);
246
- const name = resolveName(ctx, "text", props.name);
247
483
  const readOnly = props.readOnly ?? props.name == null;
484
+ const textFormat = props.textFormat ?? "plain";
485
+ if (!readOnly && textFormat === "inline-markdown") throw new Error("@pdfme/jsx: editable <Text> does not support textFormat=\"inline-markdown\". Use read-only <Text> or <MultiVariableText>.");
486
+ const name = resolveName(ctx, "text", props.name);
248
487
  const schema = {
249
488
  name,
250
489
  type: "text",
@@ -267,13 +506,14 @@ var renderText = async (props, frame, ctx) => {
267
506
  characterSpacing: props.spacing ?? DEFAULT_CHARACTER_SPACING,
268
507
  fontColor: props.color ?? DEFAULT_FONT_COLOR,
269
508
  backgroundColor: props.background ?? "",
270
- textFormat: props.textFormat ?? "plain",
509
+ textFormat,
271
510
  overflow: props.overflow,
272
511
  strikethrough: props.strikethrough ?? false,
273
512
  underline: props.underline ?? false
274
513
  };
275
514
  if (props.borderColor) schema.borderColor = props.borderColor;
276
- if (props.borderWidth != null) schema.borderWidth = props.borderWidth;
515
+ if (props.borderWidth != null) schema.borderWidth = resolveBoxSides(props.borderWidth);
516
+ if (props.padding != null) schema.padding = resolveBoxSides(props.padding);
277
517
  if (props.dynamicFontSize) schema.dynamicFontSize = {
278
518
  min: props.dynamicFontSize.min ?? DEFAULT_DYNAMIC_FONT_SIZE.min,
279
519
  max: props.dynamicFontSize.max ?? DEFAULT_DYNAMIC_FONT_SIZE.max,
@@ -292,6 +532,174 @@ var renderText = async (props, frame, ctx) => {
292
532
  height: schema.height
293
533
  };
294
534
  };
535
+ var renderMultiVariableText = async (props, frame, ctx) => {
536
+ const fontSize = props.size ?? DEFAULT_FONT_SIZE;
537
+ const lineHeight = props.lineHeight ?? DEFAULT_LINE_HEIGHT;
538
+ const width = props.width ?? frame.width;
539
+ const templateText = props.text ?? childrenToString(props.children);
540
+ const values = normalizeMultiVariableTextValues(props.values);
541
+ const variables = resolveMultiVariableTextVariables(templateText, props.variables, values);
542
+ const name = resolveName(ctx, "multiVariableText", props.name);
543
+ const readOnly = props.readOnly ?? props.name == null;
544
+ const textFormat = props.textFormat ?? "plain";
545
+ const content = readOnly ? substituteMultiVariableText(templateText, values, textFormat === "inline-markdown") : JSON.stringify(values);
546
+ const schema = {
547
+ name,
548
+ type: "multiVariableText",
549
+ content,
550
+ position: {
551
+ x: frame.x,
552
+ y: frame.y
553
+ },
554
+ width,
555
+ height: props.height ?? 0,
556
+ rotate: props.rotate ?? 0,
557
+ opacity: props.opacity ?? 1,
558
+ readOnly,
559
+ required: props.required,
560
+ alignment: props.align ?? "left",
561
+ verticalAlignment: props.valign ?? "top",
562
+ fontSize,
563
+ fontName: props.font ?? ctx.defaultFont,
564
+ lineHeight,
565
+ characterSpacing: props.spacing ?? DEFAULT_CHARACTER_SPACING,
566
+ fontColor: props.color ?? DEFAULT_FONT_COLOR,
567
+ backgroundColor: props.background ?? "",
568
+ textFormat,
569
+ overflow: props.overflow,
570
+ strikethrough: props.strikethrough ?? false,
571
+ underline: props.underline ?? false,
572
+ text: templateText,
573
+ variables
574
+ };
575
+ if (props.borderColor) schema.borderColor = props.borderColor;
576
+ if (props.borderWidth != null) schema.borderWidth = resolveBoxSides(props.borderWidth);
577
+ if (props.padding != null) schema.padding = resolveBoxSides(props.padding);
578
+ if (props.dynamicFontSize) schema.dynamicFontSize = {
579
+ min: props.dynamicFontSize.min ?? DEFAULT_DYNAMIC_FONT_SIZE.min,
580
+ max: props.dynamicFontSize.max ?? DEFAULT_DYNAMIC_FONT_SIZE.max,
581
+ fit: props.dynamicFontSize.fit ?? DEFAULT_DYNAMIC_FONT_SIZE.fit
582
+ };
583
+ if (props.height == null) schema.height = await measureTextHeight({
584
+ value: readOnly ? content : substituteMultiVariableText(templateText, values, textFormat === "inline-markdown"),
585
+ schema,
586
+ font: ctx.font,
587
+ _cache: ctx._cache
588
+ });
589
+ if (!readOnly) ctx.inputs[name] = content;
590
+ ctx.schemas.push(schema);
591
+ return {
592
+ width,
593
+ height: schema.height
594
+ };
595
+ };
596
+ var renderImage = (props, frame, ctx) => {
597
+ const width = props.width ?? frame.width;
598
+ const height = props.height ?? DEFAULT_VISUAL_HEIGHT;
599
+ const name = resolveName(ctx, "image", props.name);
600
+ const readOnly = props.readOnly ?? props.name == null;
601
+ const content = props.src ?? "";
602
+ const schema = {
603
+ name,
604
+ type: "image",
605
+ content,
606
+ position: {
607
+ x: frame.x,
608
+ y: frame.y
609
+ },
610
+ width,
611
+ height,
612
+ rotate: props.rotate ?? 0,
613
+ opacity: props.opacity ?? 1,
614
+ readOnly,
615
+ required: props.required
616
+ };
617
+ if (!readOnly) ctx.inputs[name] = content;
618
+ ctx.schemas.push(schema);
619
+ return {
620
+ width,
621
+ height
622
+ };
623
+ };
624
+ var renderSvg = (props, frame, ctx) => {
625
+ const width = props.width ?? frame.width;
626
+ const height = props.height ?? DEFAULT_VISUAL_HEIGHT;
627
+ const name = resolveName(ctx, "svg", props.name);
628
+ const readOnly = props.readOnly ?? props.name == null;
629
+ const content = props.svg ?? childrenToString(props.children);
630
+ const schema = {
631
+ name,
632
+ type: "svg",
633
+ content,
634
+ position: {
635
+ x: frame.x,
636
+ y: frame.y
637
+ },
638
+ width,
639
+ height,
640
+ rotate: props.rotate ?? 0,
641
+ opacity: props.opacity ?? 1,
642
+ readOnly,
643
+ required: props.required
644
+ };
645
+ if (!readOnly) ctx.inputs[name] = content;
646
+ ctx.schemas.push(schema);
647
+ return {
648
+ width,
649
+ height
650
+ };
651
+ };
652
+ var renderShape = (type, props, frame, ctx) => {
653
+ const width = props.width ?? frame.width;
654
+ const height = props.height ?? DEFAULT_VISUAL_HEIGHT;
655
+ const fill = props.fill ?? "";
656
+ const borderWidth = props.borderWidth ?? (props.borderColor || !fill ? 1 : 0);
657
+ const schema = {
658
+ name: resolveName(ctx, type, props.name),
659
+ type,
660
+ position: {
661
+ x: frame.x,
662
+ y: frame.y
663
+ },
664
+ width,
665
+ height,
666
+ rotate: props.rotate ?? 0,
667
+ opacity: props.opacity ?? 1,
668
+ readOnly: true,
669
+ borderWidth,
670
+ borderColor: props.borderColor ?? (borderWidth > 0 ? DEFAULT_SHAPE_BORDER_COLOR : ""),
671
+ color: fill,
672
+ radius: type === "rectangle" ? props.radius ?? 0 : 0
673
+ };
674
+ ctx.schemas.push(schema);
675
+ return {
676
+ width,
677
+ height
678
+ };
679
+ };
680
+ var renderLine = (props, frame, ctx) => {
681
+ const width = props.width ?? frame.width;
682
+ const height = props.height ?? DEFAULT_LINE_THICKNESS;
683
+ const schema = {
684
+ name: resolveName(ctx, "line", props.name),
685
+ type: "line",
686
+ position: {
687
+ x: frame.x,
688
+ y: frame.y
689
+ },
690
+ width,
691
+ height,
692
+ rotate: props.rotate ?? 0,
693
+ opacity: props.opacity ?? 1,
694
+ readOnly: true,
695
+ color: props.color ?? DEFAULT_LINE_COLOR
696
+ };
697
+ ctx.schemas.push(schema);
698
+ return {
699
+ width,
700
+ height
701
+ };
702
+ };
295
703
  var renderList = (props, frame, ctx) => {
296
704
  const fontSize = props.size ?? DEFAULT_FONT_SIZE;
297
705
  const lineHeight = props.lineHeight ?? DEFAULT_LINE_HEIGHT;
@@ -402,6 +810,38 @@ var normalizeListItems = (props) => {
402
810
  }));
403
811
  };
404
812
  var serializeListItem = (item) => `${" ".repeat(Math.max(0, item.level))}${item.text}`;
813
+ var normalizeMultiVariableTextValues = (values) => {
814
+ const normalized = {};
815
+ Object.entries(values ?? {}).forEach(([key, value]) => {
816
+ normalized[key] = value == null ? "" : String(value);
817
+ });
818
+ return normalized;
819
+ };
820
+ var resolveMultiVariableTextVariables = (templateText, variables, values) => {
821
+ const result = [];
822
+ const seen = /* @__PURE__ */ new Set();
823
+ const add = (name) => {
824
+ if (!seen.has(name)) {
825
+ seen.add(name);
826
+ result.push(name);
827
+ }
828
+ };
829
+ variables?.forEach(add);
830
+ getVariableNames(templateText).forEach(add);
831
+ Object.keys(values).forEach(add);
832
+ return result;
833
+ };
834
+ var substituteMultiVariableText = (templateText, values, escapeMarkdown) => {
835
+ let result = "";
836
+ let lastIndex = 0;
837
+ visitVariables(templateText, ({ name, startIndex, endIndex }) => {
838
+ result += templateText.slice(lastIndex, startIndex);
839
+ const value = values[name];
840
+ if (value != null) result += escapeMarkdown ? escapeInlineMarkdown(value) : value;
841
+ lastIndex = endIndex + 1;
842
+ });
843
+ return result + templateText.slice(lastIndex);
844
+ };
405
845
  var normalizeColumnWidths = (widths, columnCount) => {
406
846
  if (widths && widths.length > 0) return widths;
407
847
  if (columnCount <= 0) return [];
@@ -491,6 +931,26 @@ var PAGE_BREAK_PARENT_KINDS = new Set([
491
931
  "stack",
492
932
  "box"
493
933
  ]);
934
+ var STATIC_CONTAINER_KINDS = new Set([
935
+ "absolute",
936
+ "stack",
937
+ "row",
938
+ "box"
939
+ ]);
940
+ var STATIC_LEAF_KINDS = new Set([
941
+ "spacer",
942
+ "text",
943
+ "image",
944
+ "svg",
945
+ "rectangle",
946
+ "ellipse",
947
+ "line"
948
+ ]);
949
+ var ABSOLUTE_PARENT_KINDS = new Set([
950
+ "page",
951
+ "static",
952
+ "box"
953
+ ]);
494
954
  var validatePageBreakPlacement = (node, parentKind = void 0, canBreak = false) => {
495
955
  for (const child of flattenForSplitting(node)) {
496
956
  if (!isPdfJsxElement(child)) continue;
@@ -502,7 +962,61 @@ var validatePageBreakPlacement = (node, parentKind = void 0, canBreak = false) =
502
962
  validatePageBreakPlacement(child.children, child.kind, childCanBreak);
503
963
  }
504
964
  };
965
+ var validateAbsolutePlacement = (node, parentKind = void 0) => {
966
+ for (const child of flattenForSplitting(node)) {
967
+ if (!isPdfJsxElement(child)) continue;
968
+ if (child.kind === "absolute" && (!parentKind || !ABSOLUTE_PARENT_KINDS.has(parentKind))) throw new Error("@pdfme/jsx: <Absolute> can only be used inside <Page>, <Static>, or <Box>.");
969
+ validateAbsolutePlacement(child.children, child.kind);
970
+ }
971
+ };
972
+ var validateStaticPlacement = (pages) => {
973
+ for (let pageIndex = 0; pageIndex < pages.length; pageIndex += 1) {
974
+ const page = pages[pageIndex];
975
+ for (const child of flattenForSplitting(page?.children ?? [])) {
976
+ if (isPdfJsxElement(child) && child.kind === "static") {
977
+ if (pageIndex !== 0) throw new Error("@pdfme/jsx: <Static> must appear before any <PageBreak> and can only be used inside the first <Page>.");
978
+ if (getStaticPlacement(child) === "bottom" && hasElementKind(child.children, "absolute")) throw new Error("@pdfme/jsx: <Absolute> is not supported inside bottom <Static>. Use top <Static> or <Page> for fixed page coordinates.");
979
+ validateStaticChildren(child.children);
980
+ continue;
981
+ }
982
+ validateNoNestedStatic(child);
983
+ }
984
+ }
985
+ };
986
+ var validateNoNestedStatic = (node) => {
987
+ if (!isPdfJsxElement(node)) return;
988
+ for (const child of flattenForSplitting(node.children)) {
989
+ if (isPdfJsxElement(child) && child.kind === "static") throw new Error("@pdfme/jsx: <Static> can only be used as a direct child of the first <Page>.");
990
+ validateNoNestedStatic(child);
991
+ }
992
+ };
993
+ var hasElementKind = (node, kind) => {
994
+ for (const child of flattenForSplitting(node)) {
995
+ if (!isPdfJsxElement(child)) continue;
996
+ if (child.kind === kind || hasElementKind(child.children, kind)) return true;
997
+ }
998
+ return false;
999
+ };
1000
+ var validateNoTopLevelStatic = (node) => {
1001
+ for (const child of flattenChildren(node)) if (isPdfJsxElement(child) && child.kind === "static") throw new Error("@pdfme/jsx: <Static> can only be used as a direct child of the first <Page>.");
1002
+ };
1003
+ var validateStaticChildren = (children) => {
1004
+ for (const child of flattenForSplitting(children)) {
1005
+ if (!isPdfJsxElement(child)) continue;
1006
+ if (STATIC_CONTAINER_KINDS.has(child.kind)) {
1007
+ validateStaticChildren(child.children);
1008
+ continue;
1009
+ }
1010
+ if (!STATIC_LEAF_KINDS.has(child.kind)) throw new Error(`@pdfme/jsx: <Static> does not support <${child.kind}> children. Supported: read-only Stack, Row, Box, Spacer, Text, Image, Svg, Rectangle, Ellipse, and Line.`);
1011
+ validateStaticLeafProps(child);
1012
+ }
1013
+ };
1014
+ var validateStaticLeafProps = (element) => {
1015
+ if (element.kind !== "text" && element.kind !== "image" && element.kind !== "svg") return;
1016
+ const props = element.props;
1017
+ if (props.readOnly === false || props.name != null && props.readOnly !== true) throw new Error("@pdfme/jsx: <Static> children must be read-only.");
1018
+ };
505
1019
  //#endregion
506
- export { Box, List, Page, PageBreak, Row, Spacer, Stack, Table, Text, renderToTemplate };
1020
+ export { Absolute, Box, Ellipse, Footer, Header, Image, Line, List, MultiVariableText, Page, PageBreak, Rectangle, Row, Spacer, Stack, Static, Svg, Table, Text, renderToTemplate };
507
1021
 
508
1022
  //# 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 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 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 TableSchema,\n TextSchema,\n} from '@pdfme/schemas/types';\nimport { measureTextHeight } from '@pdfme/schemas/utils';\nimport { cloneElementWithChildren, isPdfJsxElement, isPdfJsxFragment } from './node.js';\nimport type {\n BoxProps,\n BoxSides,\n CellStyle,\n ListProps,\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 '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 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 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":";;;;AAaA,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,OAAO,YAA+B,OAAO;AAC1D,IAAa,QAAQ,YAAiC,QAAQ;AAC9D,IAAa,aAAa,UAA2B,kBAAkB,aAAa,MAAM;;;ACW1F,IAAM,oBAAoB;AAC1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AAO,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 AbsoluteProps,\n BoxProps,\n EllipseProps,\n FooterProps,\n HeaderProps,\n ImageProps,\n LineProps,\n ListProps,\n MultiVariableTextProps,\n PageBreakProps,\n PageProps,\n RectangleProps,\n RowProps,\n SpacerProps,\n StackProps,\n StaticProps,\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 Static = makeBuiltin<StaticProps, 'static'>('static');\nexport const Header = (props: HeaderProps): ReturnType<typeof createElementNode<'static'>> =>\n createElementNode('static', { ...props, placement: 'top' });\nexport const Footer = (props: FooterProps): ReturnType<typeof createElementNode<'static'>> =>\n createElementNode('static', { ...props, placement: 'bottom' });\nexport const Absolute = makeBuiltin<AbsoluteProps, 'absolute'>('absolute');\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, isBlankPdf, 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 AbsoluteProps,\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 StaticPlacement,\n StaticProps,\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};\ntype StaticBlocks = Record<StaticPlacement, PdfJsxChild[]>;\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 validateAbsolutePlacement(expanded);\n validateNoTopLevelStatic(expanded);\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 validateStaticPlacement(pages);\n const { pages: bodyPages, blocks: staticBlocks } = extractStaticChildren(pages);\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 const staticSchemas: Schema[] = [];\n const hasStaticChildren = hasStaticBlocks(staticBlocks);\n\n if (hasStaticChildren && options.basePdf != null && !isBlankPdf(options.basePdf)) {\n throw new Error('@pdfme/jsx: <Static> is supported only with a blank basePdf.');\n }\n\n if (hasStaticChildren) {\n await layoutStaticBlocks({\n blocks: staticBlocks,\n frame: { x: 0, y: 0, width: pageSize.width, height: pageSize.height },\n staticSchemas,\n inputs,\n usedNames,\n nameCounters,\n defaultFont: firstPageProps.font,\n font,\n _cache,\n });\n }\n\n for (const page of bodyPages) {\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 basePdf = options.basePdf ?? {\n width: pageSize.width,\n height: pageSize.height,\n padding: [firstMargin.top, firstMargin.right, firstMargin.bottom, firstMargin.left],\n };\n\n const template: Template = {\n basePdf:\n staticSchemas.length > 0 && isBlankPdf(basePdf)\n ? {\n ...basePdf,\n staticSchema: [...(basePdf.staticSchema ?? []), ...staticSchemas],\n }\n : basePdf,\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 extractStaticChildren = (\n pages: PdfJsxElement<'page'>[],\n): { pages: PdfJsxElement<'page'>[]; blocks: StaticBlocks } => {\n const blocks: StaticBlocks = { top: [], bottom: [] };\n const bodyPages = pages.map((page, pageIndex) => {\n const bodyChildren: PdfJsxChild[] = [];\n for (const child of flattenForSplitting(page.children)) {\n if (isPdfJsxElement(child) && child.kind === 'static') {\n if (pageIndex === 0) {\n const placement = getStaticPlacement(child as PdfJsxElement<'static'>);\n blocks[placement].push(child.children);\n }\n continue;\n }\n bodyChildren.push(child);\n }\n return cloneElementWithChildren(page, bodyChildren) as PdfJsxElement<'page'>;\n });\n\n return { pages: bodyPages, blocks };\n};\n\nconst hasStaticBlocks = (blocks: StaticBlocks) => blocks.top.length > 0 || blocks.bottom.length > 0;\n\nconst layoutStaticBlocks = async (arg: {\n blocks: StaticBlocks;\n frame: Rect;\n staticSchemas: 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 for (const placement of ['top', 'bottom'] as const) {\n const children = arg.blocks[placement];\n if (children.length === 0) continue;\n\n const schemas: Schema[] = [];\n const ctx: RenderCtx = {\n schemas,\n inputs: arg.inputs,\n usedNames: arg.usedNames,\n nameCounters: arg.nameCounters,\n defaultFont: arg.defaultFont,\n font: arg.font,\n _cache: arg._cache,\n };\n const size = await layoutChildren(\n children,\n arg.frame,\n 'stack',\n {\n gap: 0,\n alignItems: 'stretch',\n justifyContent: 'start',\n },\n ctx,\n );\n\n if (placement === 'bottom') {\n shiftSchemas(schemas, 0, schemas.length, 0, Math.max(0, arg.frame.height - size.height));\n }\n arg.staticSchemas.push(...schemas);\n }\n};\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 flowItems = items.filter((item) => !isAbsoluteElement(item));\n const widths = mode === 'row' ? resolveRowWidths(flowItems, frame.width, opts.gap) : undefined;\n let cursor = 0;\n let crossMax = 0;\n let flowIndex = 0;\n const layoutItems: LayoutItem[] = [];\n\n for (let i = 0; i < items.length; i += 1) {\n const child = items[i];\n if (isAbsoluteElement(child)) {\n await renderAbsolute(child.props as AbsoluteProps, child.children, frame, ctx);\n continue;\n }\n\n const margin = getChildMargin(child);\n const width =\n mode === 'row'\n ? (widths?.[flowIndex] ?? 0)\n : 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 // flowIndex tracks the flow-only list so Absolute siblings do not affect gap accounting.\n cursor += mainSize + (flowIndex < flowItems.length - 1 ? opts.gap : 0);\n flowIndex += 1;\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 isAbsoluteElement = (\n child: PdfJsxElement | string | number,\n): child is PdfJsxElement<'absolute'> => isPdfJsxElement(child) && child.kind === 'absolute';\n\nconst getStaticPlacement = (element: PdfJsxElement<'static'>): StaticPlacement => {\n const placement = (element.props as StaticProps).placement ?? 'top';\n if (placement !== 'top' && placement !== 'bottom') {\n throw new Error('@pdfme/jsx: <Static> placement must be \"top\" or \"bottom\".');\n }\n return placement;\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 case 'static':\n throw new Error(\n '@pdfme/jsx: <Static> can only be used as a direct child of the first <Page>.',\n );\n case 'absolute':\n return renderAbsolute(props as AbsoluteProps, element.children, frame, ctx);\n default:\n return { width: 0, height: 0 };\n }\n};\n\nconst renderAbsolute = async (\n props: AbsoluteProps,\n children: PdfJsxChild[],\n frame: Rect,\n ctx: RenderCtx,\n): Promise<{ width: number; height: number }> => {\n const x = props.x ?? 0;\n const y = props.y ?? 0;\n const childFrame = {\n x: frame.x + x,\n y: frame.y + y,\n width: props.width ?? Math.max(0, frame.width - x),\n height: props.height ?? Math.max(0, frame.height - y),\n };\n\n await layoutChildren(\n children,\n childFrame,\n 'stack',\n { gap: 0, alignItems: 'stretch', justifyContent: 'start' },\n ctx,\n );\n return { width: 0, height: 0 };\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 = resolveBoxSides(props.borderWidth);\n if (props.padding != null) schema.padding = resolveBoxSides(props.padding);\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 = resolveBoxSides(props.borderWidth);\n if (props.padding != null) schema.padding = resolveBoxSides(props.padding);\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']);\nconst STATIC_CONTAINER_KINDS = new Set(['absolute', 'stack', 'row', 'box']);\nconst STATIC_LEAF_KINDS = new Set([\n 'spacer',\n 'text',\n 'image',\n 'svg',\n 'rectangle',\n 'ellipse',\n 'line',\n]);\nconst ABSOLUTE_PARENT_KINDS = new Set(['page', 'static', '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\nconst validateAbsolutePlacement = (\n node: PdfJsxChild | PdfJsxChild[],\n parentKind: string | undefined = undefined,\n) => {\n for (const child of flattenForSplitting(node)) {\n if (!isPdfJsxElement(child)) continue;\n\n if (child.kind === 'absolute' && (!parentKind || !ABSOLUTE_PARENT_KINDS.has(parentKind))) {\n throw new Error('@pdfme/jsx: <Absolute> can only be used inside <Page>, <Static>, or <Box>.');\n }\n\n validateAbsolutePlacement(child.children, child.kind);\n }\n};\n\nconst validateStaticPlacement = (pages: PdfJsxElement<'page'>[]) => {\n for (let pageIndex = 0; pageIndex < pages.length; pageIndex += 1) {\n const page = pages[pageIndex];\n for (const child of flattenForSplitting(page?.children ?? [])) {\n if (isPdfJsxElement(child) && child.kind === 'static') {\n if (pageIndex !== 0) {\n throw new Error(\n '@pdfme/jsx: <Static> must appear before any <PageBreak> and can only be used inside the first <Page>.',\n );\n }\n // Validate dynamic JavaScript callers before static children are extracted for layout.\n const placement = getStaticPlacement(child as PdfJsxElement<'static'>);\n if (placement === 'bottom' && hasElementKind(child.children, 'absolute')) {\n throw new Error(\n '@pdfme/jsx: <Absolute> is not supported inside bottom <Static>. Use top <Static> or <Page> for fixed page coordinates.',\n );\n }\n validateStaticChildren(child.children);\n continue;\n }\n validateNoNestedStatic(child);\n }\n }\n};\n\nconst validateNoNestedStatic = (node: PdfJsxChild) => {\n if (!isPdfJsxElement(node)) return;\n for (const child of flattenForSplitting(node.children)) {\n if (isPdfJsxElement(child) && child.kind === 'static') {\n throw new Error(\n '@pdfme/jsx: <Static> can only be used as a direct child of the first <Page>.',\n );\n }\n validateNoNestedStatic(child);\n }\n};\n\nconst hasElementKind = (node: PdfJsxChild | PdfJsxChild[], kind: string): boolean => {\n for (const child of flattenForSplitting(node)) {\n if (!isPdfJsxElement(child)) continue;\n if (child.kind === kind || hasElementKind(child.children, kind)) return true;\n }\n return false;\n};\n\nconst validateNoTopLevelStatic = (node: PdfJsxChild | PdfJsxChild[]) => {\n for (const child of flattenChildren(node)) {\n if (isPdfJsxElement(child) && child.kind === 'static') {\n throw new Error(\n '@pdfme/jsx: <Static> can only be used as a direct child of the first <Page>.',\n );\n }\n }\n};\n\nconst validateStaticChildren = (children: PdfJsxChild | PdfJsxChild[]) => {\n for (const child of flattenForSplitting(children)) {\n if (!isPdfJsxElement(child)) continue;\n\n if (STATIC_CONTAINER_KINDS.has(child.kind)) {\n validateStaticChildren(child.children);\n continue;\n }\n\n if (!STATIC_LEAF_KINDS.has(child.kind)) {\n throw new Error(\n `@pdfme/jsx: <Static> does not support <${child.kind}> children. Supported: read-only Stack, Row, Box, Spacer, Text, Image, Svg, Rectangle, Ellipse, and Line.`,\n );\n }\n\n validateStaticLeafProps(child);\n }\n};\n\nconst validateStaticLeafProps = (element: PdfJsxElement) => {\n if (element.kind !== 'text' && element.kind !== 'image' && element.kind !== 'svg') return;\n const props = element.props as { name?: unknown; readOnly?: unknown };\n if (props.readOnly === false || (props.name != null && props.readOnly !== true)) {\n throw new Error('@pdfme/jsx: <Static> children must be read-only.');\n }\n};\n"],"mappings":";;;;AAuBA,IAAM,eAEF,UAED,UACC,kBAAkB,MAAM,MAAM;AAElC,IAAa,OAAO,YAA+B,OAAO;AAC1D,IAAa,SAAS,YAAmC,SAAS;AAClE,IAAa,UAAU,UACrB,kBAAkB,UAAU;CAAE,GAAG;CAAO,WAAW;CAAO,CAAC;AAC7D,IAAa,UAAU,UACrB,kBAAkB,UAAU;CAAE,GAAG;CAAO,WAAW;CAAU,CAAC;AAChE,IAAa,WAAW,YAAuC,WAAW;AAC1E,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,UA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AK,CACvC,KAAI,gBAAgB,MAAM,IAAI,MAAM,SAAS,SAC3C,OAAM,IAAI,MACR,+EACD;;AAKP,IAAM,0BAA0B,aAA0C;AACxE,MAAK,MAAM,SAAS,oBAAoB,SAAS,EAAE;AACjD,MAAI,CAAC,gBAAgB,MAAM,CAAE;AAE7B,MAAI,uBAAuB,IAAI,MAAM,KAAK,EAAE;AAC1C,0BAAuB,MAAM,SAAS;AACtC;;AAGF,MAAI,CAAC,kBAAkB,IAAI,MAAM,KAAK,CACpC,OAAM,IAAI,MACR,0CAA0C,MAAM,KAAK,2GACtD;AAGH,0BAAwB,MAAM;;;AAIlC,IAAM,2BAA2B,YAA2B;AAC1D,KAAI,QAAQ,SAAS,UAAU,QAAQ,SAAS,WAAW,QAAQ,SAAS,MAAO;CACnF,MAAM,QAAQ,QAAQ;AACtB,KAAI,MAAM,aAAa,SAAU,MAAM,QAAQ,QAAQ,MAAM,aAAa,KACxE,OAAM,IAAI,MAAM,mDAAmD"}
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 } 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' | 'list' | 'table' | 'pagebreak';
4
+ export type BuiltinKind = 'page' | 'static' | 'absolute' | '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>;
@@ -32,7 +32,16 @@ export type BoxSides = {
32
32
  /** Vertical shorthand used when top/bottom are omitted. */
33
33
  y?: number;
34
34
  };
35
- export type CommonProps = Partial<Pick<Schema, 'rotate' | 'opacity'>>;
35
+ export type LayoutAlignItems = 'start' | 'center' | 'end' | 'stretch';
36
+ export type LayoutJustifyContent = 'start' | 'center' | 'end' | 'space-between';
37
+ export type LayoutProps = {
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;
43
+ };
44
+ export type CommonProps = LayoutProps & Partial<Pick<Schema, 'rotate' | 'opacity'>>;
36
45
  export type PageProps = {
37
46
  size?: PageSize;
38
47
  orientation?: PageOrientation;
@@ -40,15 +49,35 @@ export type PageProps = {
40
49
  font?: string;
41
50
  children?: PdfJsxChild;
42
51
  };
43
- export type StackProps = {
52
+ export type StaticPlacement = 'top' | 'bottom';
53
+ export type StaticProps = {
54
+ /** Page edge used to anchor this read-only static block. Defaults to top. */
55
+ placement?: StaticPlacement;
56
+ children?: PdfJsxChild;
57
+ };
58
+ export type HeaderProps = Omit<StaticProps, 'placement'>;
59
+ export type FooterProps = Omit<StaticProps, 'placement'>;
60
+ export type AbsoluteProps = {
61
+ x?: number;
62
+ y?: number;
63
+ width?: number;
64
+ height?: number;
65
+ children?: PdfJsxChild;
66
+ };
67
+ export type StackProps = LayoutProps & {
44
68
  gap?: number;
45
69
  width?: number;
70
+ height?: number;
71
+ alignItems?: LayoutAlignItems;
72
+ justifyContent?: LayoutJustifyContent;
46
73
  children?: PdfJsxChild;
47
74
  };
48
- export type RowProps = {
75
+ export type RowProps = LayoutProps & {
49
76
  gap?: number;
50
77
  width?: number;
51
78
  height?: number;
79
+ alignItems?: Exclude<LayoutAlignItems, 'stretch'>;
80
+ justifyContent?: LayoutJustifyContent;
52
81
  children?: PdfJsxChild;
53
82
  };
54
83
  export type BoxProps = CommonProps & {
@@ -61,7 +90,7 @@ export type BoxProps = CommonProps & {
61
90
  radius?: number;
62
91
  children?: PdfJsxChild;
63
92
  };
64
- export type SpacerProps = {
93
+ export type SpacerProps = LayoutProps & {
65
94
  width?: number;
66
95
  height?: number;
67
96
  };
@@ -76,9 +105,46 @@ export type TextProps = CommonProps & TextSchemaProps & {
76
105
  color?: TextSchema['fontColor'];
77
106
  background?: TextSchema['backgroundColor'];
78
107
  borderColor?: string;
79
- borderWidth?: number;
108
+ borderWidth?: number | BoxSides;
109
+ padding?: number | BoxSides;
80
110
  dynamicFontSize?: Partial<NonNullable<TextSchema['dynamicFontSize']>>;
81
111
  };
112
+ export type MultiVariableTextValues = Record<string, string | number | boolean | null | undefined>;
113
+ type MultiVariableTextSchemaProps = Partial<Pick<MultiVariableTextSchema, 'name' | 'width' | 'height' | 'lineHeight' | 'strikethrough' | 'underline' | 'readOnly' | 'required' | 'textFormat' | 'overflow'>>;
114
+ export type MultiVariableTextProps = CommonProps & MultiVariableTextSchemaProps & {
115
+ children?: PdfJsxChild;
116
+ text?: string;
117
+ variables?: string[];
118
+ values?: MultiVariableTextValues;
119
+ size?: MultiVariableTextSchema['fontSize'];
120
+ font?: MultiVariableTextSchema['fontName'];
121
+ align?: MultiVariableTextSchema['alignment'];
122
+ valign?: MultiVariableTextSchema['verticalAlignment'];
123
+ spacing?: MultiVariableTextSchema['characterSpacing'];
124
+ color?: MultiVariableTextSchema['fontColor'];
125
+ background?: MultiVariableTextSchema['backgroundColor'];
126
+ borderColor?: string;
127
+ borderWidth?: number | BoxSides;
128
+ padding?: number | BoxSides;
129
+ dynamicFontSize?: Partial<NonNullable<MultiVariableTextSchema['dynamicFontSize']>>;
130
+ };
131
+ type ImageSchemaProps = Partial<Pick<ImageSchema, 'name' | 'width' | 'height' | 'readOnly' | 'required'>>;
132
+ export type ImageProps = CommonProps & ImageSchemaProps & {
133
+ src?: string;
134
+ };
135
+ type SvgSchemaProps = Partial<Pick<SVGSchema, 'name' | 'width' | 'height' | 'readOnly' | 'required'>>;
136
+ export type SvgProps = SvgSchemaProps & {
137
+ svg?: string;
138
+ children?: PdfJsxChild;
139
+ } & CommonProps;
140
+ type ShapeSchemaProps = Partial<Pick<ShapeSchema, 'name' | 'width' | 'height' | 'borderWidth' | 'borderColor' | 'radius'>>;
141
+ export type RectangleProps = CommonProps & ShapeSchemaProps & {
142
+ fill?: ShapeSchema['color'];
143
+ };
144
+ export type EllipseProps = CommonProps & Omit<ShapeSchemaProps, 'radius'> & {
145
+ fill?: ShapeSchema['color'];
146
+ };
147
+ export type LineProps = CommonProps & Partial<Pick<LineSchema, 'name' | 'width' | 'height' | 'color'>>;
82
148
  export type ListItem = string | {
83
149
  text: SchemaListItem['text'];
84
150
  level?: SchemaListItem['level'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/jsx",
3
- "version": "6.1.1-dev.8",
3
+ "version": "6.1.2",
4
4
  "description": "Author pdfme templates with JSX stacking layout primitives.",
5
5
  "keywords": [
6
6
  "jsx",