@weasyprint-tsx/ui 0.0.2 → 0.1.0

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 (3) hide show
  1. package/README.md +278 -0
  2. package/package.json +1 -1
  3. package/src/index.ts +8 -8
package/README.md ADDED
@@ -0,0 +1,278 @@
1
+ # @weasyprint-tsx/ui
2
+
3
+ Print-optimized Preact components for [weasyprint-tsx](../../README.md) documents.
4
+
5
+ ```ts
6
+ import { H1, H2, Page, UL, LI, Table, Entry, BlockBox, Block } from "@weasyprint-tsx/ui";
7
+ ```
8
+
9
+ ---
10
+
11
+ ## Page layout
12
+
13
+ ### `Page`
14
+
15
+ Wraps a page section. Maps to a `<section>` element.
16
+
17
+ ```tsx
18
+ <Page page="cover">
19
+ <H1>My Document</H1>
20
+ </Page>
21
+ ```
22
+
23
+ | Prop | Type | Description |
24
+ |------|------|-------------|
25
+ | `page` | `string` | Value for the CSS `page` property (named page rule) |
26
+
27
+ ---
28
+
29
+ ### `PageBreak`
30
+
31
+ Forces a page break at the current position.
32
+
33
+ ```tsx
34
+ <PageBreak />
35
+ ```
36
+
37
+ No props.
38
+
39
+ ---
40
+
41
+ ## Headings
42
+
43
+ ### `H1` – `H6`
44
+
45
+ Render `<h1>`–`<h6>` with optional marker and color overrides. Headings participate in CSS counters for automatic numbering if you set them up in your stylesheet.
46
+
47
+ ```tsx
48
+ <H1>Title</H1>
49
+ <H2 color="#1e40af" fontSize="14pt">Section</H2>
50
+ <H3 marker="§">Subsection</H3>
51
+ ```
52
+
53
+ | Prop | Type | Description |
54
+ |------|------|-------------|
55
+ | `marker` | `string` | Sets `data-marker` attribute (used by CSS `::before` counter content) |
56
+ | `color` | `string` | Inline text color |
57
+ | `fontSize` | `string` | Inline font size |
58
+ | `...rest` | `ComponentProps<"h1">` etc. | All standard HTML heading attributes |
59
+
60
+ ---
61
+
62
+ ### `Title`
63
+
64
+ Generic heading that accepts a `type` prop.
65
+
66
+ ```tsx
67
+ <Title type="h2" color="red">Dynamic heading</Title>
68
+ ```
69
+
70
+ | Prop | Type | Description |
71
+ |------|------|-------------|
72
+ | `type` | `"h1"` \| `"h2"` \| … \| `"h6"` | Which heading element to render |
73
+
74
+ ---
75
+
76
+ ### `ResetCounter`
77
+
78
+ Renders a hidden `<div>` that resets CSS counters. Use at the start of a section when you want numbered headings to restart.
79
+
80
+ ```tsx
81
+ <ResetCounter />
82
+ ```
83
+
84
+ No props.
85
+
86
+ ---
87
+
88
+ ## Lists
89
+
90
+ ### `UL`
91
+
92
+ Unordered list. Children should be `<LI>` elements.
93
+
94
+ ```tsx
95
+ <UL marker="→">
96
+ <LI>Item one</LI>
97
+ <LI>Item two</LI>
98
+ </UL>
99
+ ```
100
+
101
+ | Prop | Type | Default | Description |
102
+ |------|------|---------|-------------|
103
+ | `marker` | `string` | `"•"` | Bullet character |
104
+ | `gap` | `string \| number` | — | Gap between items |
105
+ | `pre` | `ComponentChildren` | — | Content rendered before the list (e.g. a label) |
106
+
107
+ ---
108
+
109
+ ### `OL`
110
+
111
+ Ordered list. Children should be `<LI>` elements.
112
+
113
+ ```tsx
114
+ <OL counterType="lower-roman" markerPost=".">
115
+ <LI>First</LI>
116
+ <LI>Second</LI>
117
+ </OL>
118
+ ```
119
+
120
+ | Prop | Type | Default | Description |
121
+ |------|------|---------|-------------|
122
+ | `start` | `number` | `1` | Starting counter value |
123
+ | `counterType` | `"decimal"` \| `"lower-alpha"` \| `"upper-alpha"` \| `"lower-roman"` \| `"upper-roman"` | `"decimal"` | Counter style |
124
+ | `markerPre` | `string` | — | String prepended to the counter (e.g. `"("`) |
125
+ | `markerPost` | `string` | `"."` | String appended to the counter |
126
+ | `gap` | `string \| number` | — | Gap between items |
127
+ | `pre` | `ComponentChildren` | — | Content rendered before the list |
128
+
129
+ ---
130
+
131
+ ### `LI`
132
+
133
+ List item, used inside `UL` or `OL`.
134
+
135
+ ```tsx
136
+ <LI>Plain item</LI>
137
+ <LI marker="★">Custom marker</LI>
138
+ ```
139
+
140
+ | Prop | Type | Description |
141
+ |------|------|-------------|
142
+ | `marker` | `string` | Override the list's default marker for this item |
143
+ | `count` | `number` | Override the displayed counter value (OL only) |
144
+
145
+ ---
146
+
147
+ ## Table
148
+
149
+ ### `Table`
150
+
151
+ Renders an HTML table. Children must be `<Entry>` components.
152
+
153
+ ```tsx
154
+ <Table orientation="col" headerBg="#1e40af" borderColor="#cbd5e1">
155
+ <Entry content={["Alice", "Engineer", "Berlin"]} />
156
+ <Entry content={["Bob", "Designer", "Paris"]} />
157
+ </Table>
158
+ ```
159
+
160
+ | Prop | Type | Default | Description |
161
+ |------|------|---------|-------------|
162
+ | `orientation` | `"col"` \| `"row"` | `"col"` | `"col"`: first Entry is the header row. `"row"`: first cell of each Entry is the row header. |
163
+ | `headerBg` | `string` | — | Background color for header cells |
164
+ | `cellBg` | `string` | — | Background color for data cells |
165
+ | `headerFontSize` | `string` | — | Font size for header cells |
166
+ | `cellFontSize` | `string` | — | Font size for data cells |
167
+ | `borderWidth` | `string` | `"1px"` | Border width |
168
+ | `borderColor` | `string` | `"#000"` | Border color |
169
+ | `contentClass` | `string` | — | Extra class applied to all data cells |
170
+ | `headerClass` | `string` | — | Extra class applied to all header cells |
171
+
172
+ ---
173
+
174
+ ### `Entry`
175
+
176
+ Data row or column for `Table`. Renders `null` — `Table` reads its props directly.
177
+
178
+ ```tsx
179
+ <Entry content={["Name", "Role", "Location"]} headerBg="#e2e8f0" />
180
+ ```
181
+
182
+ | Prop | Type | Description |
183
+ |------|------|-------------|
184
+ | `content` | `ComponentChild[]` | Array of cell values |
185
+ | `contentClass` | `string` | Extra class for this Entry's data cells |
186
+ | `headerBg` | `string` | Override header background for this Entry |
187
+ | `cellBg` | `string` | Override cell background for this Entry |
188
+ | `headerFontSize` | `string` | Override header font size |
189
+ | `cellFontSize` | `string` | Override cell font size |
190
+
191
+ ---
192
+
193
+ ## BlockBox / Block
194
+
195
+ Two-component system for multi-column / ratio-based layouts.
196
+
197
+ ### `BlockBox`
198
+
199
+ Container. Lays out `<Block>` children side by side.
200
+
201
+ ```tsx
202
+ <BlockBox gap="1cm" basis={50}>
203
+ <Block ratio={2}>Wide column</Block>
204
+ <Block ratio={1}>Narrow column</Block>
205
+ </BlockBox>
206
+ ```
207
+
208
+ | Prop | Type | Default | Description |
209
+ |------|------|---------|-------------|
210
+ | `gap` | `string` | `"0"` | Gap between blocks |
211
+ | `basis` | `number` | `100` | Flex basis percentage for equal-width fallback |
212
+ | `centered` | `boolean` | `false` | Center block contents horizontally |
213
+ | `align` | `"top"` \| `"middle"` \| `"bottom"` | `"top"` | Vertical alignment of blocks |
214
+
215
+ ### `Block`
216
+
217
+ A single column inside `BlockBox`.
218
+
219
+ | Prop | Type | Description |
220
+ |------|------|-------------|
221
+ | `ratio` | `number` | Relative width ratio compared to siblings |
222
+ | `centered` | `boolean` | Center this block's content |
223
+ | `align` | `"top"` \| `"middle"` \| `"bottom"` | Vertical alignment override |
224
+
225
+ ---
226
+
227
+ ## DotLine
228
+
229
+ A repeating dot pattern, useful for fill lines in tables of contents or forms.
230
+
231
+ ```tsx
232
+ <DotLine width="100%" />
233
+ <DotLine inline num={3} color="#94a3b8" />
234
+ ```
235
+
236
+ | Prop | Type | Default | Description |
237
+ |------|------|---------|-------------|
238
+ | `num` | `number` | `1` | Number of dot-line rows |
239
+ | `width` | `number \| string` | `"100%"` | Width of the dot line |
240
+ | `inline` | `boolean` | `false` | Render as inline element |
241
+ | `color` | `string` | — | Dot color |
242
+ | `lineHeight` | `string` | — | Line height of each dot row |
243
+
244
+ ---
245
+
246
+ ## CodeBlock
247
+
248
+ Syntax-highlighted code block using highlight.js.
249
+
250
+ ```tsx
251
+ <CodeBlock language="typescript" code={`const x: number = 42;`} />
252
+ ```
253
+
254
+ | Prop | Type | Description |
255
+ |------|------|-------------|
256
+ | `language` | `string` | highlight.js language identifier (e.g. `"typescript"`, `"python"`, `"bash"`) |
257
+ | `code` | `string` | Source code string |
258
+
259
+ Renders with `break-inside: avoid` to prevent page breaks mid-block.
260
+
261
+ ---
262
+
263
+ ## Equation
264
+
265
+ LaTeX equation rendering via KaTeX.
266
+
267
+ ```tsx
268
+ <Equation tex="E = mc^2" displayMode />
269
+ <Equation tex="\ce{H2O}" chemical />
270
+ <Equation tex="x &= a + b \\ y &= c + d" aligned displayMode />
271
+ ```
272
+
273
+ | Prop | Type | Default | Description |
274
+ |------|------|---------|-------------|
275
+ | `tex` | `string` | — | LaTeX source |
276
+ | `displayMode` | `boolean` | `false` | Render as block-level equation |
277
+ | `aligned` | `boolean` | `false` | Wrap in `\begin{aligned}…\end{aligned}` |
278
+ | `chemical` | `boolean` | `false` | Wrap in `\ce{…}` for chemical notation |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weasyprint-tsx/ui",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "exports": {
5
5
  ".": "./src/index.ts"
6
6
  },
package/src/index.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { Block, BlockBox } from "./src/BlockBox";
2
- export { CodeBlock } from "./src/CodeBlock";
3
- export { DotLine } from "./src/DotLine";
4
- export { Equation } from "./src/Equation";
5
- export { LI, OL, UL } from "./src/List";
6
- export { Page, PageBreak } from "./src/Page";
7
- export { Entry, Table } from "./src/Table";
8
- export { H1, H2, H3, H4, H5, H6, ResetCounter, Title } from "./src/Titles";
1
+ export { Block, BlockBox } from "./BlockBox";
2
+ export { CodeBlock } from "./CodeBlock";
3
+ export { DotLine } from "./DotLine";
4
+ export { Equation } from "./Equation";
5
+ export { LI, OL, UL } from "./List";
6
+ export { Page, PageBreak } from "./Page";
7
+ export { Entry, Table } from "./Table";
8
+ export { H1, H2, H3, H4, H5, H6, ResetCounter, Title } from "./Titles";
9
9