turbo-html2pdf-react 0.1.0 → 0.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.
Files changed (2) hide show
  1. package/README.md +39 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # turbo-html2pdf-react
2
+
3
+ Author [**turbo-html2pdf**](https://www.npmjs.com/package/turbo-html2pdf) document
4
+ templates as **React components**. The components render **once, at authoring time**
5
+ (via `renderToStaticMarkup`) into a template *source string* — they are never on the
6
+ PDF render hot path. Attribute values are **expression strings** resolved later in
7
+ the Rust engine, not evaluated JavaScript.
8
+
9
+ ```tsx
10
+ import { compileTemplate, If, Each } from 'turbo-html2pdf-react'
11
+ import { compile } from 'turbo-html2pdf' // the engine (Node) — or turbo-html2pdf-wasm in the browser
12
+
13
+ function Invoice() {
14
+ return (
15
+ <>
16
+ <h1>Invoice {'{{ data.number }}'}</h1>
17
+ <Each of="data.rows" as="row">
18
+ <p>{'{{ row.description }}'} — {'{{ row.amount | currency }}'}</p>
19
+ </Each>
20
+ <If cond="data.paid"><div class="stamp">PAID</div></If>
21
+ </>
22
+ )
23
+ }
24
+
25
+ const source = compileTemplate(<Invoice />) // -> HTML + Jinja + t: directives (a string)
26
+ const program = compile(source) // hand it to the engine
27
+ const { pdf } = program.render({ data: { number: 42, rows: [], paid: true } })
28
+ ```
29
+
30
+ Components map to the paged-media DSL: `<If>`/`<ElseIf>`/`<Else>`, `<Switch>`/`<Case>`,
31
+ `<Each>`, `<Include>`, `<RunningHeader>`/`<RunningFooter>`, `<Footnote>`, `<Page/>` /
32
+ `<Pages/>`, plus `<Raw>` for literal markup.
33
+
34
+ This package only produces the template string; rendering is done by
35
+ **turbo-html2pdf** (Node) or **turbo-html2pdf-wasm** (browser). See the
36
+ [main README](https://github.com/miaskiewicz/turbo-html2pdf) and the
37
+ [DSL / API docs](https://github.com/miaskiewicz/turbo-html2pdf/tree/main/docs).
38
+
39
+ MIT.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "turbo-html2pdf-react",
3
- "version": "0.1.0",
4
- "description": "React authoring frontend for turbo-pdf: components that compile once to a Jinja + t: template source string.",
3
+ "version": "0.1.2",
4
+ "description": "Author turbo-html2pdf PDF templates as React components HTML/CSS + Jinja to PDF.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {