@pdfme/jsx 6.1.1-dev.8 → 6.1.2-dev.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,11 +28,81 @@ 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
- - `Table widths` are percentages passed to pdfme `headWidthPercentages`, for example
32
- `widths={[70, 30]}`.
105
+ - `Table columnWeights` are relative column width weights, not millimeter widths. They are
106
+ normalized to pdfme `headWidthPercentages`, for example `columnWeights={[70, 30]}`.
107
+ Missing or invalid weights default to `1`, so pass one weight per column when you need exact
108
+ ratios. Earlier beta builds used `widths`; use `columnWeights` going forward.
@@ -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';