@formepdf/react 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.
- package/dist/components.d.ts +200 -0
- package/dist/components.js +221 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -0
- package/dist/render.d.ts +12 -0
- package/dist/render.js +15 -0
- package/dist/serialize.d.ts +12 -0
- package/dist/serialize.js +715 -0
- package/dist/stylesheet.d.ts +4 -0
- package/dist/stylesheet.js +5 -0
- package/dist/types.d.ts +324 -0
- package/dist/types.js +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { DocumentProps, PageProps, ViewProps, TextProps, ImageProps, TableProps, RowProps, CellProps, FixedProps, SvgProps } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Root document container. Must be the top-level element in every Forme document.
|
|
4
|
+
*
|
|
5
|
+
* All other Forme components must be descendants of `<Document>`.
|
|
6
|
+
*
|
|
7
|
+
* @param props.title - PDF metadata title
|
|
8
|
+
* @param props.author - PDF metadata author
|
|
9
|
+
* @param props.subject - PDF metadata subject
|
|
10
|
+
* @param props.creator - PDF metadata creator application
|
|
11
|
+
* @param props.children - Page or content elements
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Document title="Invoice" author="Acme Corp">
|
|
16
|
+
* <Text>Hello World</Text>
|
|
17
|
+
* </Document>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function Document(_props: DocumentProps): null;
|
|
21
|
+
/**
|
|
22
|
+
* A page boundary with explicit size and margin configuration.
|
|
23
|
+
*
|
|
24
|
+
* When used, content inside each `<Page>` is laid out independently.
|
|
25
|
+
* Without `<Page>`, content uses the document's default page config.
|
|
26
|
+
*
|
|
27
|
+
* @param props.size - Page size: `"A4"`, `"Letter"`, `"Legal"`, `"A3"`, `"A5"`, `"Tabloid"`, or `{ width, height }` in points
|
|
28
|
+
* @param props.margin - Page margins as a uniform number or `{ top, right, bottom, left }`
|
|
29
|
+
* @param props.children - Content elements for this page
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <Document>
|
|
34
|
+
* <Page size="Letter" margin={72}>
|
|
35
|
+
* <Text>US Letter page with 1-inch margins</Text>
|
|
36
|
+
* </Page>
|
|
37
|
+
* </Document>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function Page(_props: PageProps): null;
|
|
41
|
+
/**
|
|
42
|
+
* A flex container, analogous to an HTML `<div>`.
|
|
43
|
+
*
|
|
44
|
+
* Defaults to `flexDirection: "column"`. Supports all flex properties
|
|
45
|
+
* including `flexWrap`, `gap`, `justifyContent`, and `alignItems`.
|
|
46
|
+
*
|
|
47
|
+
* @param props.style - CSS-like style properties
|
|
48
|
+
* @param props.wrap - Whether this container can break across pages (default: true). Set to `false` to keep children together.
|
|
49
|
+
* @param props.children - Child elements
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <View style={{ flexDirection: 'row', gap: 12, padding: 8 }}>
|
|
54
|
+
* <Text>Left</Text>
|
|
55
|
+
* <Text>Right</Text>
|
|
56
|
+
* </View>
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function View(_props: ViewProps): null;
|
|
60
|
+
/**
|
|
61
|
+
* A text node. Children are flattened to a single string.
|
|
62
|
+
*
|
|
63
|
+
* Supports font properties, text alignment, color, and text transforms.
|
|
64
|
+
* Nested `<Text>` children have their content concatenated.
|
|
65
|
+
*
|
|
66
|
+
* @param props.style - Typography and color styles
|
|
67
|
+
* @param props.children - Text content (strings, numbers, or nested `<Text>`)
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* <Text style={{ fontSize: 24, fontWeight: 'bold', color: '#333' }}>
|
|
72
|
+
* Invoice Total: $1,234.00
|
|
73
|
+
* </Text>
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function Text(_props: TextProps): null;
|
|
77
|
+
/**
|
|
78
|
+
* An image element. Supports JPEG and PNG via base64 data URIs or file paths.
|
|
79
|
+
*
|
|
80
|
+
* If only `width` or `height` is specified, the other dimension is calculated
|
|
81
|
+
* from the image's aspect ratio.
|
|
82
|
+
*
|
|
83
|
+
* @param props.src - Image source: base64 data URI (`data:image/png;base64,...`) or file path
|
|
84
|
+
* @param props.width - Display width in points
|
|
85
|
+
* @param props.height - Display height in points
|
|
86
|
+
* @param props.style - Additional style properties
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```tsx
|
|
90
|
+
* <Image src="data:image/png;base64,..." width={200} />
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function Image(_props: ImageProps): null;
|
|
94
|
+
/**
|
|
95
|
+
* A table container. Children should be `<Row>` elements.
|
|
96
|
+
*
|
|
97
|
+
* Tables support automatic page breaks between rows and repeat header rows
|
|
98
|
+
* on continuation pages.
|
|
99
|
+
*
|
|
100
|
+
* @param props.columns - Column width definitions: `{ fraction: 0.5 }`, `{ fixed: 100 }`, or `"auto"`
|
|
101
|
+
* @param props.style - Style properties for the table container
|
|
102
|
+
* @param props.children - `<Row>` elements
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```tsx
|
|
106
|
+
* <Table columns={[{ width: { fraction: 0.6 } }, { width: { fraction: 0.4 } }]}>
|
|
107
|
+
* <Row header>
|
|
108
|
+
* <Cell><Text>Name</Text></Cell>
|
|
109
|
+
* <Cell><Text>Price</Text></Cell>
|
|
110
|
+
* </Row>
|
|
111
|
+
* <Row>
|
|
112
|
+
* <Cell><Text>Widget</Text></Cell>
|
|
113
|
+
* <Cell><Text>$10.00</Text></Cell>
|
|
114
|
+
* </Row>
|
|
115
|
+
* </Table>
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function Table(_props: TableProps): null;
|
|
119
|
+
/**
|
|
120
|
+
* A table row. Must be a direct child of `<Table>`.
|
|
121
|
+
*
|
|
122
|
+
* Header rows (`header={true}`) are automatically repeated at the top of
|
|
123
|
+
* each continuation page when a table spans multiple pages.
|
|
124
|
+
*
|
|
125
|
+
* @param props.header - Whether this is a header row that repeats on page breaks
|
|
126
|
+
* @param props.style - Style properties (e.g., `backgroundColor` for alternating rows)
|
|
127
|
+
* @param props.children - `<Cell>` elements
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```tsx
|
|
131
|
+
* <Row header style={{ backgroundColor: '#333' }}>
|
|
132
|
+
* <Cell><Text style={{ color: '#fff' }}>Header</Text></Cell>
|
|
133
|
+
* </Row>
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export declare function Row(_props: RowProps): null;
|
|
137
|
+
/**
|
|
138
|
+
* A table cell inside a `<Row>`.
|
|
139
|
+
*
|
|
140
|
+
* @param props.colSpan - Number of columns this cell spans (default: 1)
|
|
141
|
+
* @param props.rowSpan - Number of rows this cell spans (default: 1)
|
|
142
|
+
* @param props.style - Style properties (padding, background, etc.)
|
|
143
|
+
* @param props.children - Cell content (any Forme elements)
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```tsx
|
|
147
|
+
* <Cell colSpan={2} style={{ padding: 8, backgroundColor: '#f5f5f5' }}>
|
|
148
|
+
* <Text>Spanning two columns</Text>
|
|
149
|
+
* </Cell>
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare function Cell(_props: CellProps): null;
|
|
153
|
+
/**
|
|
154
|
+
* A fixed element that repeats on every page as a header or footer.
|
|
155
|
+
*
|
|
156
|
+
* Fixed elements reduce the available content area on each page.
|
|
157
|
+
* Use `{{pageNumber}}` and `{{totalPages}}` placeholders in text content
|
|
158
|
+
* for automatic page numbering.
|
|
159
|
+
*
|
|
160
|
+
* @param props.position - `"header"` (top of page) or `"footer"` (bottom of page)
|
|
161
|
+
* @param props.style - Style properties
|
|
162
|
+
* @param props.children - Content to repeat on each page
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```tsx
|
|
166
|
+
* <Fixed position="footer">
|
|
167
|
+
* <Text style={{ textAlign: 'center', fontSize: 10 }}>
|
|
168
|
+
* Page {'{{pageNumber}}'} of {'{{totalPages}}'}
|
|
169
|
+
* </Text>
|
|
170
|
+
* </Fixed>
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export declare function Fixed(_props: FixedProps): null;
|
|
174
|
+
/**
|
|
175
|
+
* An SVG element. Renders basic SVG shapes (rect, circle, ellipse, line, path, polygon, polyline) to PDF.
|
|
176
|
+
*
|
|
177
|
+
* @param props.width - Display width in points
|
|
178
|
+
* @param props.height - Display height in points
|
|
179
|
+
* @param props.viewBox - SVG viewBox string (e.g., "0 0 100 100")
|
|
180
|
+
* @param props.content - SVG markup string (the inner content, not the outer <svg> tag)
|
|
181
|
+
* @param props.style - Additional style properties (margin, etc.)
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```tsx
|
|
185
|
+
* <Svg width={100} height={100} viewBox="0 0 100 100"
|
|
186
|
+
* content='<rect x="10" y="10" width="80" height="80" fill="blue"/>' />
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export declare function Svg(_props: SvgProps): null;
|
|
190
|
+
/**
|
|
191
|
+
* An explicit page break. Content after this element starts on a new page.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```tsx
|
|
195
|
+
* <Text>Page 1 content</Text>
|
|
196
|
+
* <PageBreak />
|
|
197
|
+
* <Text>Page 2 content</Text>
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
export declare function PageBreak(_props: object): null;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Root document container. Must be the top-level element in every Forme document.
|
|
3
|
+
*
|
|
4
|
+
* All other Forme components must be descendants of `<Document>`.
|
|
5
|
+
*
|
|
6
|
+
* @param props.title - PDF metadata title
|
|
7
|
+
* @param props.author - PDF metadata author
|
|
8
|
+
* @param props.subject - PDF metadata subject
|
|
9
|
+
* @param props.creator - PDF metadata creator application
|
|
10
|
+
* @param props.children - Page or content elements
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <Document title="Invoice" author="Acme Corp">
|
|
15
|
+
* <Text>Hello World</Text>
|
|
16
|
+
* </Document>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function Document(_props) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A page boundary with explicit size and margin configuration.
|
|
24
|
+
*
|
|
25
|
+
* When used, content inside each `<Page>` is laid out independently.
|
|
26
|
+
* Without `<Page>`, content uses the document's default page config.
|
|
27
|
+
*
|
|
28
|
+
* @param props.size - Page size: `"A4"`, `"Letter"`, `"Legal"`, `"A3"`, `"A5"`, `"Tabloid"`, or `{ width, height }` in points
|
|
29
|
+
* @param props.margin - Page margins as a uniform number or `{ top, right, bottom, left }`
|
|
30
|
+
* @param props.children - Content elements for this page
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <Document>
|
|
35
|
+
* <Page size="Letter" margin={72}>
|
|
36
|
+
* <Text>US Letter page with 1-inch margins</Text>
|
|
37
|
+
* </Page>
|
|
38
|
+
* </Document>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function Page(_props) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A flex container, analogous to an HTML `<div>`.
|
|
46
|
+
*
|
|
47
|
+
* Defaults to `flexDirection: "column"`. Supports all flex properties
|
|
48
|
+
* including `flexWrap`, `gap`, `justifyContent`, and `alignItems`.
|
|
49
|
+
*
|
|
50
|
+
* @param props.style - CSS-like style properties
|
|
51
|
+
* @param props.wrap - Whether this container can break across pages (default: true). Set to `false` to keep children together.
|
|
52
|
+
* @param props.children - Child elements
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <View style={{ flexDirection: 'row', gap: 12, padding: 8 }}>
|
|
57
|
+
* <Text>Left</Text>
|
|
58
|
+
* <Text>Right</Text>
|
|
59
|
+
* </View>
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function View(_props) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A text node. Children are flattened to a single string.
|
|
67
|
+
*
|
|
68
|
+
* Supports font properties, text alignment, color, and text transforms.
|
|
69
|
+
* Nested `<Text>` children have their content concatenated.
|
|
70
|
+
*
|
|
71
|
+
* @param props.style - Typography and color styles
|
|
72
|
+
* @param props.children - Text content (strings, numbers, or nested `<Text>`)
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```tsx
|
|
76
|
+
* <Text style={{ fontSize: 24, fontWeight: 'bold', color: '#333' }}>
|
|
77
|
+
* Invoice Total: $1,234.00
|
|
78
|
+
* </Text>
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export function Text(_props) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* An image element. Supports JPEG and PNG via base64 data URIs or file paths.
|
|
86
|
+
*
|
|
87
|
+
* If only `width` or `height` is specified, the other dimension is calculated
|
|
88
|
+
* from the image's aspect ratio.
|
|
89
|
+
*
|
|
90
|
+
* @param props.src - Image source: base64 data URI (`data:image/png;base64,...`) or file path
|
|
91
|
+
* @param props.width - Display width in points
|
|
92
|
+
* @param props.height - Display height in points
|
|
93
|
+
* @param props.style - Additional style properties
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```tsx
|
|
97
|
+
* <Image src="data:image/png;base64,..." width={200} />
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export function Image(_props) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A table container. Children should be `<Row>` elements.
|
|
105
|
+
*
|
|
106
|
+
* Tables support automatic page breaks between rows and repeat header rows
|
|
107
|
+
* on continuation pages.
|
|
108
|
+
*
|
|
109
|
+
* @param props.columns - Column width definitions: `{ fraction: 0.5 }`, `{ fixed: 100 }`, or `"auto"`
|
|
110
|
+
* @param props.style - Style properties for the table container
|
|
111
|
+
* @param props.children - `<Row>` elements
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```tsx
|
|
115
|
+
* <Table columns={[{ width: { fraction: 0.6 } }, { width: { fraction: 0.4 } }]}>
|
|
116
|
+
* <Row header>
|
|
117
|
+
* <Cell><Text>Name</Text></Cell>
|
|
118
|
+
* <Cell><Text>Price</Text></Cell>
|
|
119
|
+
* </Row>
|
|
120
|
+
* <Row>
|
|
121
|
+
* <Cell><Text>Widget</Text></Cell>
|
|
122
|
+
* <Cell><Text>$10.00</Text></Cell>
|
|
123
|
+
* </Row>
|
|
124
|
+
* </Table>
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export function Table(_props) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A table row. Must be a direct child of `<Table>`.
|
|
132
|
+
*
|
|
133
|
+
* Header rows (`header={true}`) are automatically repeated at the top of
|
|
134
|
+
* each continuation page when a table spans multiple pages.
|
|
135
|
+
*
|
|
136
|
+
* @param props.header - Whether this is a header row that repeats on page breaks
|
|
137
|
+
* @param props.style - Style properties (e.g., `backgroundColor` for alternating rows)
|
|
138
|
+
* @param props.children - `<Cell>` elements
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```tsx
|
|
142
|
+
* <Row header style={{ backgroundColor: '#333' }}>
|
|
143
|
+
* <Cell><Text style={{ color: '#fff' }}>Header</Text></Cell>
|
|
144
|
+
* </Row>
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export function Row(_props) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* A table cell inside a `<Row>`.
|
|
152
|
+
*
|
|
153
|
+
* @param props.colSpan - Number of columns this cell spans (default: 1)
|
|
154
|
+
* @param props.rowSpan - Number of rows this cell spans (default: 1)
|
|
155
|
+
* @param props.style - Style properties (padding, background, etc.)
|
|
156
|
+
* @param props.children - Cell content (any Forme elements)
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```tsx
|
|
160
|
+
* <Cell colSpan={2} style={{ padding: 8, backgroundColor: '#f5f5f5' }}>
|
|
161
|
+
* <Text>Spanning two columns</Text>
|
|
162
|
+
* </Cell>
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export function Cell(_props) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A fixed element that repeats on every page as a header or footer.
|
|
170
|
+
*
|
|
171
|
+
* Fixed elements reduce the available content area on each page.
|
|
172
|
+
* Use `{{pageNumber}}` and `{{totalPages}}` placeholders in text content
|
|
173
|
+
* for automatic page numbering.
|
|
174
|
+
*
|
|
175
|
+
* @param props.position - `"header"` (top of page) or `"footer"` (bottom of page)
|
|
176
|
+
* @param props.style - Style properties
|
|
177
|
+
* @param props.children - Content to repeat on each page
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```tsx
|
|
181
|
+
* <Fixed position="footer">
|
|
182
|
+
* <Text style={{ textAlign: 'center', fontSize: 10 }}>
|
|
183
|
+
* Page {'{{pageNumber}}'} of {'{{totalPages}}'}
|
|
184
|
+
* </Text>
|
|
185
|
+
* </Fixed>
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export function Fixed(_props) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* An SVG element. Renders basic SVG shapes (rect, circle, ellipse, line, path, polygon, polyline) to PDF.
|
|
193
|
+
*
|
|
194
|
+
* @param props.width - Display width in points
|
|
195
|
+
* @param props.height - Display height in points
|
|
196
|
+
* @param props.viewBox - SVG viewBox string (e.g., "0 0 100 100")
|
|
197
|
+
* @param props.content - SVG markup string (the inner content, not the outer <svg> tag)
|
|
198
|
+
* @param props.style - Additional style properties (margin, etc.)
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```tsx
|
|
202
|
+
* <Svg width={100} height={100} viewBox="0 0 100 100"
|
|
203
|
+
* content='<rect x="10" y="10" width="80" height="80" fill="blue"/>' />
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
export function Svg(_props) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* An explicit page break. Content after this element starts on a new page.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```tsx
|
|
214
|
+
* <Text>Page 1 content</Text>
|
|
215
|
+
* <PageBreak />
|
|
216
|
+
* <Text>Page 2 content</Text>
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
export function PageBreak(_props) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Document, Page, View, Text, Image, Table, Row, Cell, Fixed, Svg, PageBreak } from './components.js';
|
|
2
|
+
export { serialize, mapStyle, mapDimension, parseColor, expandEdges, expandCorners } from './serialize.js';
|
|
3
|
+
export { StyleSheet } from './stylesheet.js';
|
|
4
|
+
export { render, renderToObject } from './render.js';
|
|
5
|
+
export type { Style, Edges, Corners, EdgeColors, DocumentProps, PageProps, ViewProps, TextProps, ImageProps, ColumnDef, TableProps, RowProps, CellProps, FixedProps, SvgProps, TextRun, FormeDocument, FormeNode, FormeNodeKind, FormeStyle, FormePageConfig, FormePageSize, FormeEdges, FormeMetadata, FormeColumnDef, FormeColumnWidth, FormeDimension, FormeColor, FormeEdgeValues, FormeCornerValues, } from './types.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Components
|
|
2
|
+
export { Document, Page, View, Text, Image, Table, Row, Cell, Fixed, Svg, PageBreak } from './components.js';
|
|
3
|
+
// Serialization
|
|
4
|
+
export { serialize, mapStyle, mapDimension, parseColor, expandEdges, expandCorners } from './serialize.js';
|
|
5
|
+
// StyleSheet
|
|
6
|
+
export { StyleSheet } from './stylesheet.js';
|
|
7
|
+
// Render functions
|
|
8
|
+
export { render, renderToObject } from './render.js';
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { FormeDocument } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Render a React element tree to a Forme JSON string.
|
|
5
|
+
* The top-level element must be a <Document>.
|
|
6
|
+
*/
|
|
7
|
+
export declare function render(element: ReactElement): string;
|
|
8
|
+
/**
|
|
9
|
+
* Render a React element tree to a Forme document object.
|
|
10
|
+
* The top-level element must be a <Document>.
|
|
11
|
+
*/
|
|
12
|
+
export declare function renderToObject(element: ReactElement): FormeDocument;
|
package/dist/render.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { serialize } from './serialize.js';
|
|
2
|
+
/**
|
|
3
|
+
* Render a React element tree to a Forme JSON string.
|
|
4
|
+
* The top-level element must be a <Document>.
|
|
5
|
+
*/
|
|
6
|
+
export function render(element) {
|
|
7
|
+
return JSON.stringify(serialize(element));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Render a React element tree to a Forme document object.
|
|
11
|
+
* The top-level element must be a <Document>.
|
|
12
|
+
*/
|
|
13
|
+
export function renderToObject(element) {
|
|
14
|
+
return serialize(element);
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import type { Style, Edges, Corners, FormeDocument, FormeStyle, FormeEdges, FormeDimension, FormeColor, FormeCornerValues } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Serialize a React element tree into a Forme JSON document object.
|
|
5
|
+
* The top-level element must be a <Document>.
|
|
6
|
+
*/
|
|
7
|
+
export declare function serialize(element: ReactElement): FormeDocument;
|
|
8
|
+
export declare function mapStyle(style?: Style): FormeStyle;
|
|
9
|
+
export declare function mapDimension(val: number | string): FormeDimension;
|
|
10
|
+
export declare function parseColor(hex: string): FormeColor;
|
|
11
|
+
export declare function expandEdges(val: number | Edges): FormeEdges;
|
|
12
|
+
export declare function expandCorners(val: number | Corners): FormeCornerValues;
|