@formepdf/react 0.5.0 → 0.6.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/charts.d.ts +41 -0
- package/dist/charts.js +338 -0
- package/dist/components.d.ts +56 -1
- package/dist/components.js +61 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/serialize.js +236 -2
- package/dist/types.d.ts +264 -0
- package/package.json +1 -1
package/dist/charts.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { BarChartProps, LineChartProps, PieChartProps } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* A bar chart rendered as SVG + positioned Text labels.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <BarChart width={400} height={200}
|
|
9
|
+
* data={[{ label: 'Jan', value: 120 }, { label: 'Feb', value: 90 }]}
|
|
10
|
+
* color="#1a365d" showGrid showValues />
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function BarChart(props: BarChartProps): React.ReactElement;
|
|
14
|
+
/**
|
|
15
|
+
* A line chart rendered as SVG + positioned Text labels.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <LineChart width={400} height={200}
|
|
20
|
+
* data={[{ label: 'Jan', value: 120 }, { label: 'Feb', value: 90 }]}
|
|
21
|
+
* color="#2b6cb0" showDots showGrid showArea />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function LineChart(props: LineChartProps): React.ReactElement;
|
|
25
|
+
/**
|
|
26
|
+
* A pie chart (or donut chart) rendered as SVG + positioned Text labels.
|
|
27
|
+
*
|
|
28
|
+
* Requires SVG arc path commands (A/a) — supported since engine v0.6.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <PieChart width={200} height={200}
|
|
33
|
+
* data={[
|
|
34
|
+
* { label: 'A', value: 40, color: '#1a365d' },
|
|
35
|
+
* { label: 'B', value: 30, color: '#2b6cb0' },
|
|
36
|
+
* { label: 'C', value: 30, color: '#63b3ed' },
|
|
37
|
+
* ]}
|
|
38
|
+
* showLabels />
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function PieChart(props: PieChartProps): React.ReactElement;
|
package/dist/charts.js
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, Svg } from './components.js';
|
|
3
|
+
// ─── Helpers ────────────────────────────────────────────────────────
|
|
4
|
+
/** Round up to a "nice" axis maximum (1, 2, 5, 10, 20, 50, ...). */
|
|
5
|
+
function niceNumber(value) {
|
|
6
|
+
if (value <= 0)
|
|
7
|
+
return 1;
|
|
8
|
+
const exp = Math.floor(Math.log10(value));
|
|
9
|
+
const frac = value / Math.pow(10, exp);
|
|
10
|
+
let nice;
|
|
11
|
+
if (frac <= 1.0)
|
|
12
|
+
nice = 1;
|
|
13
|
+
else if (frac <= 2.0)
|
|
14
|
+
nice = 2;
|
|
15
|
+
else if (frac <= 5.0)
|
|
16
|
+
nice = 5;
|
|
17
|
+
else
|
|
18
|
+
nice = 10;
|
|
19
|
+
return nice * Math.pow(10, exp);
|
|
20
|
+
}
|
|
21
|
+
/** Format number compactly for axis labels. */
|
|
22
|
+
function formatNumber(value) {
|
|
23
|
+
if (value >= 1000000)
|
|
24
|
+
return (value / 1000000).toFixed(1).replace(/\.0$/, '') + 'M';
|
|
25
|
+
if (value >= 1000)
|
|
26
|
+
return (value / 1000).toFixed(1).replace(/\.0$/, '') + 'K';
|
|
27
|
+
if (Number.isInteger(value))
|
|
28
|
+
return String(value);
|
|
29
|
+
return value.toFixed(1);
|
|
30
|
+
}
|
|
31
|
+
/** Lighten a hex color toward white. amount=0 is original, amount=1 is white. */
|
|
32
|
+
function lightenColor(hex, amount) {
|
|
33
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
34
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
35
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
36
|
+
const lr = Math.round(r + (255 - r) * amount);
|
|
37
|
+
const lg = Math.round(g + (255 - g) * amount);
|
|
38
|
+
const lb = Math.round(b + (255 - b) * amount);
|
|
39
|
+
return '#' + [lr, lg, lb].map(c => c.toString(16).padStart(2, '0')).join('');
|
|
40
|
+
}
|
|
41
|
+
/** Escape XML special characters in text. */
|
|
42
|
+
function escapeXml(s) {
|
|
43
|
+
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
44
|
+
}
|
|
45
|
+
// Chart layout constants
|
|
46
|
+
const AXIS_LABEL_FONT = 8;
|
|
47
|
+
const LABEL_MARGIN = 4;
|
|
48
|
+
const Y_AXIS_WIDTH = 28;
|
|
49
|
+
const X_AXIS_HEIGHT = 20;
|
|
50
|
+
// ─── BarChart ───────────────────────────────────────────────────────
|
|
51
|
+
/**
|
|
52
|
+
* A bar chart rendered as SVG + positioned Text labels.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <BarChart width={400} height={200}
|
|
57
|
+
* data={[{ label: 'Jan', value: 120 }, { label: 'Feb', value: 90 }]}
|
|
58
|
+
* color="#1a365d" showGrid showValues />
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function BarChart(props) {
|
|
62
|
+
const { width, height, data, color = '#1a365d', barGap = 4, showGrid = false, showValues = false, yAxisTicks = 5, } = props;
|
|
63
|
+
if (data.length === 0) {
|
|
64
|
+
return React.createElement(View, { style: { width, height, ...props.style } });
|
|
65
|
+
}
|
|
66
|
+
const plotLeft = Y_AXIS_WIDTH;
|
|
67
|
+
const plotTop = 10;
|
|
68
|
+
const plotWidth = width - plotLeft - 10;
|
|
69
|
+
const plotHeight = height - plotTop - X_AXIS_HEIGHT;
|
|
70
|
+
const maxValue = niceNumber(Math.max(...data.map(d => d.value)));
|
|
71
|
+
// Build SVG content
|
|
72
|
+
let svg = '';
|
|
73
|
+
// Grid lines
|
|
74
|
+
if (showGrid) {
|
|
75
|
+
for (let t = 0; t <= yAxisTicks; t++) {
|
|
76
|
+
const y = plotTop + plotHeight - (t / yAxisTicks) * plotHeight;
|
|
77
|
+
svg += `<line x1="${plotLeft}" y1="${y}" x2="${plotLeft + plotWidth}" y2="${y}" stroke="#e2e8f0" stroke-width="0.5"/>`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// X axis
|
|
81
|
+
svg += `<line x1="${plotLeft}" y1="${plotTop + plotHeight}" x2="${plotLeft + plotWidth}" y2="${plotTop + plotHeight}" stroke="#a0aec0" stroke-width="1"/>`;
|
|
82
|
+
// Y axis
|
|
83
|
+
svg += `<line x1="${plotLeft}" y1="${plotTop}" x2="${plotLeft}" y2="${plotTop + plotHeight}" stroke="#a0aec0" stroke-width="1"/>`;
|
|
84
|
+
// Bars
|
|
85
|
+
const barWidth = (plotWidth - barGap * (data.length + 1)) / data.length;
|
|
86
|
+
for (let i = 0; i < data.length; i++) {
|
|
87
|
+
const barH = (data[i].value / maxValue) * plotHeight;
|
|
88
|
+
const x = plotLeft + barGap + i * (barWidth + barGap);
|
|
89
|
+
const y = plotTop + plotHeight - barH;
|
|
90
|
+
svg += `<rect x="${x}" y="${y}" width="${barWidth}" height="${barH}" fill="${escapeXml(color)}"/>`;
|
|
91
|
+
}
|
|
92
|
+
const viewBox = `0 0 ${width} ${height}`;
|
|
93
|
+
// Y-axis tick labels + X-axis labels as positioned Text
|
|
94
|
+
const labels = [];
|
|
95
|
+
for (let t = 0; t <= yAxisTicks; t++) {
|
|
96
|
+
const val = (t / yAxisTicks) * maxValue;
|
|
97
|
+
const y = plotTop + plotHeight - (t / yAxisTicks) * plotHeight - AXIS_LABEL_FONT / 2;
|
|
98
|
+
labels.push(React.createElement(Text, {
|
|
99
|
+
key: `y-${t}`,
|
|
100
|
+
style: {
|
|
101
|
+
position: 'absolute',
|
|
102
|
+
top: y,
|
|
103
|
+
left: 0,
|
|
104
|
+
width: Y_AXIS_WIDTH - LABEL_MARGIN,
|
|
105
|
+
fontSize: AXIS_LABEL_FONT,
|
|
106
|
+
textAlign: 'right',
|
|
107
|
+
color: '#4a5568',
|
|
108
|
+
},
|
|
109
|
+
}, formatNumber(val)));
|
|
110
|
+
}
|
|
111
|
+
for (let i = 0; i < data.length; i++) {
|
|
112
|
+
const x = plotLeft + barGap + i * (barWidth + barGap);
|
|
113
|
+
labels.push(React.createElement(Text, {
|
|
114
|
+
key: `x-${i}`,
|
|
115
|
+
style: {
|
|
116
|
+
position: 'absolute',
|
|
117
|
+
top: plotTop + plotHeight + LABEL_MARGIN,
|
|
118
|
+
left: x - barGap,
|
|
119
|
+
width: barWidth + barGap * 2,
|
|
120
|
+
fontSize: AXIS_LABEL_FONT,
|
|
121
|
+
textAlign: 'center',
|
|
122
|
+
color: '#4a5568',
|
|
123
|
+
},
|
|
124
|
+
}, data[i].label));
|
|
125
|
+
if (showValues) {
|
|
126
|
+
const barH = (data[i].value / maxValue) * plotHeight;
|
|
127
|
+
const valY = plotTop + plotHeight - barH - AXIS_LABEL_FONT - 2;
|
|
128
|
+
labels.push(React.createElement(Text, {
|
|
129
|
+
key: `v-${i}`,
|
|
130
|
+
style: {
|
|
131
|
+
position: 'absolute',
|
|
132
|
+
top: valY,
|
|
133
|
+
left: x,
|
|
134
|
+
width: barWidth,
|
|
135
|
+
fontSize: AXIS_LABEL_FONT,
|
|
136
|
+
textAlign: 'center',
|
|
137
|
+
color: '#2d3748',
|
|
138
|
+
},
|
|
139
|
+
}, formatNumber(data[i].value)));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return React.createElement(View, {
|
|
143
|
+
style: { width, height, position: 'relative', ...props.style },
|
|
144
|
+
}, React.createElement(Svg, { width, height, viewBox, content: svg }), ...labels);
|
|
145
|
+
}
|
|
146
|
+
// ─── LineChart ───────────────────────────────────────────────────────
|
|
147
|
+
/**
|
|
148
|
+
* A line chart rendered as SVG + positioned Text labels.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```tsx
|
|
152
|
+
* <LineChart width={400} height={200}
|
|
153
|
+
* data={[{ label: 'Jan', value: 120 }, { label: 'Feb', value: 90 }]}
|
|
154
|
+
* color="#2b6cb0" showDots showGrid showArea />
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export function LineChart(props) {
|
|
158
|
+
const { width, height, data, color = '#2b6cb0', strokeWidth = 2, showDots = false, showGrid = false, showArea = false, } = props;
|
|
159
|
+
if (data.length === 0) {
|
|
160
|
+
return React.createElement(View, { style: { width, height, ...props.style } });
|
|
161
|
+
}
|
|
162
|
+
const plotLeft = Y_AXIS_WIDTH;
|
|
163
|
+
const plotTop = 10;
|
|
164
|
+
const plotWidth = width - plotLeft - 10;
|
|
165
|
+
const plotHeight = height - plotTop - X_AXIS_HEIGHT;
|
|
166
|
+
const maxValue = niceNumber(Math.max(...data.map(d => d.value)));
|
|
167
|
+
const yAxisTicks = 5;
|
|
168
|
+
const pointX = (i) => plotLeft + (i / (data.length - 1 || 1)) * plotWidth;
|
|
169
|
+
const pointY = (v) => plotTop + plotHeight - (v / maxValue) * plotHeight;
|
|
170
|
+
let svg = '';
|
|
171
|
+
// Grid lines
|
|
172
|
+
if (showGrid) {
|
|
173
|
+
for (let t = 0; t <= yAxisTicks; t++) {
|
|
174
|
+
const y = plotTop + plotHeight - (t / yAxisTicks) * plotHeight;
|
|
175
|
+
svg += `<line x1="${plotLeft}" y1="${y}" x2="${plotLeft + plotWidth}" y2="${y}" stroke="#e2e8f0" stroke-width="0.5"/>`;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Axes
|
|
179
|
+
svg += `<line x1="${plotLeft}" y1="${plotTop + plotHeight}" x2="${plotLeft + plotWidth}" y2="${plotTop + plotHeight}" stroke="#a0aec0" stroke-width="1"/>`;
|
|
180
|
+
svg += `<line x1="${plotLeft}" y1="${plotTop}" x2="${plotLeft}" y2="${plotTop + plotHeight}" stroke="#a0aec0" stroke-width="1"/>`;
|
|
181
|
+
// Area fill
|
|
182
|
+
if (showArea && data.length > 1) {
|
|
183
|
+
const areaColor = lightenColor(color, 0.7);
|
|
184
|
+
let pathD = `M ${pointX(0)} ${pointY(data[0].value)}`;
|
|
185
|
+
for (let i = 1; i < data.length; i++) {
|
|
186
|
+
pathD += ` L ${pointX(i)} ${pointY(data[i].value)}`;
|
|
187
|
+
}
|
|
188
|
+
pathD += ` L ${pointX(data.length - 1)} ${plotTop + plotHeight}`;
|
|
189
|
+
pathD += ` L ${pointX(0)} ${plotTop + plotHeight} Z`;
|
|
190
|
+
svg += `<path d="${pathD}" fill="${escapeXml(areaColor)}" stroke="none"/>`;
|
|
191
|
+
}
|
|
192
|
+
// Line
|
|
193
|
+
if (data.length > 1) {
|
|
194
|
+
let pathD = `M ${pointX(0)} ${pointY(data[0].value)}`;
|
|
195
|
+
for (let i = 1; i < data.length; i++) {
|
|
196
|
+
pathD += ` L ${pointX(i)} ${pointY(data[i].value)}`;
|
|
197
|
+
}
|
|
198
|
+
svg += `<path d="${pathD}" fill="none" stroke="${escapeXml(color)}" stroke-width="${strokeWidth}"/>`;
|
|
199
|
+
}
|
|
200
|
+
// Dots
|
|
201
|
+
if (showDots) {
|
|
202
|
+
for (let i = 0; i < data.length; i++) {
|
|
203
|
+
const x = pointX(i);
|
|
204
|
+
const y = pointY(data[i].value);
|
|
205
|
+
svg += `<circle cx="${x}" cy="${y}" r="3" fill="${escapeXml(color)}"/>`;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const viewBox = `0 0 ${width} ${height}`;
|
|
209
|
+
const labels = [];
|
|
210
|
+
// Y-axis labels
|
|
211
|
+
for (let t = 0; t <= yAxisTicks; t++) {
|
|
212
|
+
const val = (t / yAxisTicks) * maxValue;
|
|
213
|
+
const y = plotTop + plotHeight - (t / yAxisTicks) * plotHeight - AXIS_LABEL_FONT / 2;
|
|
214
|
+
labels.push(React.createElement(Text, {
|
|
215
|
+
key: `y-${t}`,
|
|
216
|
+
style: {
|
|
217
|
+
position: 'absolute',
|
|
218
|
+
top: y,
|
|
219
|
+
left: 0,
|
|
220
|
+
width: Y_AXIS_WIDTH - LABEL_MARGIN,
|
|
221
|
+
fontSize: AXIS_LABEL_FONT,
|
|
222
|
+
textAlign: 'right',
|
|
223
|
+
color: '#4a5568',
|
|
224
|
+
},
|
|
225
|
+
}, formatNumber(val)));
|
|
226
|
+
}
|
|
227
|
+
// X-axis labels
|
|
228
|
+
for (let i = 0; i < data.length; i++) {
|
|
229
|
+
const x = pointX(i);
|
|
230
|
+
const labelWidth = plotWidth / data.length;
|
|
231
|
+
labels.push(React.createElement(Text, {
|
|
232
|
+
key: `x-${i}`,
|
|
233
|
+
style: {
|
|
234
|
+
position: 'absolute',
|
|
235
|
+
top: plotTop + plotHeight + LABEL_MARGIN,
|
|
236
|
+
left: x - labelWidth / 2,
|
|
237
|
+
width: labelWidth,
|
|
238
|
+
fontSize: AXIS_LABEL_FONT,
|
|
239
|
+
textAlign: 'center',
|
|
240
|
+
color: '#4a5568',
|
|
241
|
+
},
|
|
242
|
+
}, data[i].label));
|
|
243
|
+
}
|
|
244
|
+
return React.createElement(View, {
|
|
245
|
+
style: { width, height, position: 'relative', ...props.style },
|
|
246
|
+
}, React.createElement(Svg, { width, height, viewBox, content: svg }), ...labels);
|
|
247
|
+
}
|
|
248
|
+
// ─── PieChart ───────────────────────────────────────────────────────
|
|
249
|
+
/**
|
|
250
|
+
* A pie chart (or donut chart) rendered as SVG + positioned Text labels.
|
|
251
|
+
*
|
|
252
|
+
* Requires SVG arc path commands (A/a) — supported since engine v0.6.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```tsx
|
|
256
|
+
* <PieChart width={200} height={200}
|
|
257
|
+
* data={[
|
|
258
|
+
* { label: 'A', value: 40, color: '#1a365d' },
|
|
259
|
+
* { label: 'B', value: 30, color: '#2b6cb0' },
|
|
260
|
+
* { label: 'C', value: 30, color: '#63b3ed' },
|
|
261
|
+
* ]}
|
|
262
|
+
* showLabels />
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export function PieChart(props) {
|
|
266
|
+
const { width, height, data, showLabels = false, innerRadius = 0, } = props;
|
|
267
|
+
const total = data.reduce((sum, d) => sum + d.value, 0);
|
|
268
|
+
if (data.length === 0 || total <= 0) {
|
|
269
|
+
return React.createElement(View, { style: { width, height, ...props.style } });
|
|
270
|
+
}
|
|
271
|
+
const cx = width / 2;
|
|
272
|
+
const cy = height / 2;
|
|
273
|
+
const labelMargin = showLabels ? 30 : 0;
|
|
274
|
+
const outerR = Math.min(width - labelMargin * 2, height - labelMargin * 2) / 2;
|
|
275
|
+
let svg = '';
|
|
276
|
+
let startAngle = -Math.PI / 2; // Start from top
|
|
277
|
+
const labels = [];
|
|
278
|
+
for (let i = 0; i < data.length; i++) {
|
|
279
|
+
const slice = data[i];
|
|
280
|
+
const sliceAngle = (slice.value / total) * Math.PI * 2;
|
|
281
|
+
const endAngle = startAngle + sliceAngle;
|
|
282
|
+
// For full circle (single slice), use two arcs
|
|
283
|
+
if (data.length === 1) {
|
|
284
|
+
// Full circle — draw as ellipse-like two half arcs
|
|
285
|
+
if (innerRadius > 0) {
|
|
286
|
+
// Donut: outer arc + inner arc
|
|
287
|
+
svg += `<path d="M ${cx} ${cy - outerR} A ${outerR} ${outerR} 0 1 1 ${cx} ${cy + outerR} A ${outerR} ${outerR} 0 1 1 ${cx} ${cy - outerR} Z M ${cx} ${cy - innerRadius} A ${innerRadius} ${innerRadius} 0 1 0 ${cx} ${cy + innerRadius} A ${innerRadius} ${innerRadius} 0 1 0 ${cx} ${cy - innerRadius} Z" fill="${escapeXml(slice.color)}" fill-rule="evenodd"/>`;
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
svg += `<circle cx="${cx}" cy="${cy}" r="${outerR}" fill="${escapeXml(slice.color)}"/>`;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
const largeArc = sliceAngle > Math.PI ? 1 : 0;
|
|
295
|
+
const x1 = cx + outerR * Math.cos(startAngle);
|
|
296
|
+
const y1 = cy + outerR * Math.sin(startAngle);
|
|
297
|
+
const x2 = cx + outerR * Math.cos(endAngle);
|
|
298
|
+
const y2 = cy + outerR * Math.sin(endAngle);
|
|
299
|
+
let pathD;
|
|
300
|
+
if (innerRadius > 0) {
|
|
301
|
+
const ix1 = cx + innerRadius * Math.cos(startAngle);
|
|
302
|
+
const iy1 = cy + innerRadius * Math.sin(startAngle);
|
|
303
|
+
const ix2 = cx + innerRadius * Math.cos(endAngle);
|
|
304
|
+
const iy2 = cy + innerRadius * Math.sin(endAngle);
|
|
305
|
+
pathD = `M ${ix1} ${iy1} L ${x1} ${y1} A ${outerR} ${outerR} 0 ${largeArc} 1 ${x2} ${y2} L ${ix2} ${iy2} A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${ix1} ${iy1} Z`;
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
pathD = `M ${cx} ${cy} L ${x1} ${y1} A ${outerR} ${outerR} 0 ${largeArc} 1 ${x2} ${y2} Z`;
|
|
309
|
+
}
|
|
310
|
+
svg += `<path d="${pathD}" fill="${escapeXml(slice.color)}"/>`;
|
|
311
|
+
}
|
|
312
|
+
// Labels
|
|
313
|
+
if (showLabels) {
|
|
314
|
+
const midAngle = startAngle + sliceAngle / 2;
|
|
315
|
+
const labelR = outerR + 12;
|
|
316
|
+
const lx = cx + labelR * Math.cos(midAngle);
|
|
317
|
+
const ly = cy + labelR * Math.sin(midAngle);
|
|
318
|
+
const isRight = Math.cos(midAngle) >= 0;
|
|
319
|
+
labels.push(React.createElement(Text, {
|
|
320
|
+
key: `label-${i}`,
|
|
321
|
+
style: {
|
|
322
|
+
position: 'absolute',
|
|
323
|
+
top: ly - AXIS_LABEL_FONT / 2,
|
|
324
|
+
left: isRight ? lx : lx - 50,
|
|
325
|
+
width: 50,
|
|
326
|
+
fontSize: AXIS_LABEL_FONT,
|
|
327
|
+
textAlign: isRight ? 'left' : 'right',
|
|
328
|
+
color: '#2d3748',
|
|
329
|
+
},
|
|
330
|
+
}, slice.label));
|
|
331
|
+
}
|
|
332
|
+
startAngle = endAngle;
|
|
333
|
+
}
|
|
334
|
+
const viewBox = `0 0 ${width} ${height}`;
|
|
335
|
+
return React.createElement(View, {
|
|
336
|
+
style: { width, height, position: 'relative', ...props.style },
|
|
337
|
+
}, React.createElement(Svg, { width, height, viewBox, content: svg }), ...labels);
|
|
338
|
+
}
|
package/dist/components.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DocumentProps, PageProps, ViewProps, TextProps, ImageProps, TableProps, RowProps, CellProps, FixedProps, SvgProps } from './types.js';
|
|
1
|
+
import type { DocumentProps, PageProps, ViewProps, TextProps, ImageProps, TableProps, RowProps, CellProps, FixedProps, SvgProps, QrCodeProps, CanvasProps, WatermarkProps } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Root document container. Must be the top-level element in every Forme document.
|
|
4
4
|
*
|
|
@@ -187,6 +187,61 @@ export declare function Fixed(_props: FixedProps): null;
|
|
|
187
187
|
* ```
|
|
188
188
|
*/
|
|
189
189
|
export declare function Svg(_props: SvgProps): null;
|
|
190
|
+
/**
|
|
191
|
+
* A QR code rendered as crisp vector graphics in the PDF.
|
|
192
|
+
*
|
|
193
|
+
* @param props.data - The data to encode (URL, text, etc.)
|
|
194
|
+
* @param props.size - Display size in points. QR codes are square. Defaults to available width.
|
|
195
|
+
* @param props.color - QR code color. Default: black.
|
|
196
|
+
* @param props.style - Style properties for the QR code container.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```tsx
|
|
200
|
+
* <QrCode data="https://formepdf.com" size={100} />
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export declare function QrCode(_props: QrCodeProps): null;
|
|
204
|
+
/**
|
|
205
|
+
* A canvas drawing primitive for arbitrary vector graphics.
|
|
206
|
+
*
|
|
207
|
+
* The `draw` callback receives a `CanvasContext` that records drawing operations.
|
|
208
|
+
* These are serialized to JSON and rendered as native PDF vector commands.
|
|
209
|
+
*
|
|
210
|
+
* @param props.width - Canvas width in points
|
|
211
|
+
* @param props.height - Canvas height in points
|
|
212
|
+
* @param props.draw - Drawing callback that receives a `CanvasContext`
|
|
213
|
+
* @param props.style - Additional style properties
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```tsx
|
|
217
|
+
* <Canvas width={200} height={100} draw={(ctx) => {
|
|
218
|
+
* ctx.setFillColor(0, 0, 255);
|
|
219
|
+
* ctx.rect(10, 10, 180, 80);
|
|
220
|
+
* ctx.fill();
|
|
221
|
+
* }} />
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
export declare function Canvas(_props: CanvasProps): null;
|
|
225
|
+
/**
|
|
226
|
+
* A watermark rendered as rotated text behind all page content.
|
|
227
|
+
*
|
|
228
|
+
* Appears on every page. Use `rgba()` colors for translucent watermarks.
|
|
229
|
+
*
|
|
230
|
+
* @param props.text - Watermark text (e.g. "DRAFT", "CONFIDENTIAL")
|
|
231
|
+
* @param props.fontSize - Font size in points. Default: 60.
|
|
232
|
+
* @param props.color - Text color. Use `rgba(0,0,0,0.1)` for subtle watermarks. Default: "rgba(0,0,0,0.1)".
|
|
233
|
+
* @param props.angle - Rotation angle in degrees. Default: -45.
|
|
234
|
+
* @param props.style - Additional style properties (fontFamily, etc.)
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```tsx
|
|
238
|
+
* <Page size="A4" margin={40}>
|
|
239
|
+
* <Watermark text="DRAFT" fontSize={60} color="rgba(0,0,0,0.1)" angle={-45} />
|
|
240
|
+
* <Text>Document content here</Text>
|
|
241
|
+
* </Page>
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
export declare function Watermark(_props: WatermarkProps): null;
|
|
190
245
|
/**
|
|
191
246
|
* An explicit page break. Content after this element starts on a new page.
|
|
192
247
|
*
|
package/dist/components.js
CHANGED
|
@@ -206,6 +206,67 @@ export function Fixed(_props) {
|
|
|
206
206
|
export function Svg(_props) {
|
|
207
207
|
return null;
|
|
208
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* A QR code rendered as crisp vector graphics in the PDF.
|
|
211
|
+
*
|
|
212
|
+
* @param props.data - The data to encode (URL, text, etc.)
|
|
213
|
+
* @param props.size - Display size in points. QR codes are square. Defaults to available width.
|
|
214
|
+
* @param props.color - QR code color. Default: black.
|
|
215
|
+
* @param props.style - Style properties for the QR code container.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```tsx
|
|
219
|
+
* <QrCode data="https://formepdf.com" size={100} />
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
export function QrCode(_props) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* A canvas drawing primitive for arbitrary vector graphics.
|
|
227
|
+
*
|
|
228
|
+
* The `draw` callback receives a `CanvasContext` that records drawing operations.
|
|
229
|
+
* These are serialized to JSON and rendered as native PDF vector commands.
|
|
230
|
+
*
|
|
231
|
+
* @param props.width - Canvas width in points
|
|
232
|
+
* @param props.height - Canvas height in points
|
|
233
|
+
* @param props.draw - Drawing callback that receives a `CanvasContext`
|
|
234
|
+
* @param props.style - Additional style properties
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```tsx
|
|
238
|
+
* <Canvas width={200} height={100} draw={(ctx) => {
|
|
239
|
+
* ctx.setFillColor(0, 0, 255);
|
|
240
|
+
* ctx.rect(10, 10, 180, 80);
|
|
241
|
+
* ctx.fill();
|
|
242
|
+
* }} />
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
export function Canvas(_props) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* A watermark rendered as rotated text behind all page content.
|
|
250
|
+
*
|
|
251
|
+
* Appears on every page. Use `rgba()` colors for translucent watermarks.
|
|
252
|
+
*
|
|
253
|
+
* @param props.text - Watermark text (e.g. "DRAFT", "CONFIDENTIAL")
|
|
254
|
+
* @param props.fontSize - Font size in points. Default: 60.
|
|
255
|
+
* @param props.color - Text color. Use `rgba(0,0,0,0.1)` for subtle watermarks. Default: "rgba(0,0,0,0.1)".
|
|
256
|
+
* @param props.angle - Rotation angle in degrees. Default: -45.
|
|
257
|
+
* @param props.style - Additional style properties (fontFamily, etc.)
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```tsx
|
|
261
|
+
* <Page size="A4" margin={40}>
|
|
262
|
+
* <Watermark text="DRAFT" fontSize={60} color="rgba(0,0,0,0.1)" angle={-45} />
|
|
263
|
+
* <Text>Document content here</Text>
|
|
264
|
+
* </Page>
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export function Watermark(_props) {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
209
270
|
/**
|
|
210
271
|
* An explicit page break. Content after this element starts on a new page.
|
|
211
272
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { Document, Page, View, Text, Image, Table, Row, Cell, Fixed, Svg, PageBreak } from './components.js';
|
|
1
|
+
export { Document, Page, View, Text, Image, Table, Row, Cell, Fixed, Svg, QrCode, Canvas, Watermark, PageBreak } from './components.js';
|
|
2
|
+
export { BarChart, LineChart, PieChart } from './charts.js';
|
|
2
3
|
export { serialize, serializeTemplate, mapStyle, mapDimension, parseColor, expandEdges, expandCorners } from './serialize.js';
|
|
3
4
|
export { StyleSheet } from './stylesheet.js';
|
|
4
5
|
export { Font } from './font.js';
|
|
@@ -6,4 +7,4 @@ export type { FontRegistration } from './font.js';
|
|
|
6
7
|
export { createDataProxy, isRefMarker, isEachMarker, isExprMarker } from './template-proxy.js';
|
|
7
8
|
export { expr } from './expr.js';
|
|
8
9
|
export { render, renderToObject } from './render.js';
|
|
9
|
-
export type { Style, Edges, Corners, EdgeColors, DocumentProps, PageProps, ViewProps, TextProps, ImageProps, ColumnDef, TableProps, RowProps, CellProps, FixedProps, SvgProps, TextRun, FormeDocument, FormeFont, FormeNode, FormeNodeKind, FormeStyle, FormePageConfig, FormePageSize, FormeEdges, FormeMetadata, FormeColumnDef, FormeColumnWidth, FormeDimension, FormeColor, FormeEdgeValues, FormeCornerValues, } from './types.js';
|
|
10
|
+
export type { Style, GridTrackSize, Edges, Corners, EdgeColors, DocumentProps, PageProps, ViewProps, TextProps, ImageProps, ColumnDef, TableProps, RowProps, CellProps, FixedProps, SvgProps, QrCodeProps, CanvasProps, CanvasContext, CanvasOp, WatermarkProps, ChartDataPoint, PieDataPoint, BarChartProps, LineChartProps, PieChartProps, TextRun, FormeDocument, FormeFont, FormeNode, FormeNodeKind, FormeStyle, FormePageConfig, FormePageSize, FormeEdges, FormeMetadata, FormeColumnDef, FormeColumnWidth, FormeDimension, FormeColor, FormeEdgeValues, FormeCornerValues, FormeGridTrackSize, FormeGridPlacement, } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Components
|
|
2
|
-
export { Document, Page, View, Text, Image, Table, Row, Cell, Fixed, Svg, PageBreak } from './components.js';
|
|
2
|
+
export { Document, Page, View, Text, Image, Table, Row, Cell, Fixed, Svg, QrCode, Canvas, Watermark, PageBreak } from './components.js';
|
|
3
|
+
export { BarChart, LineChart, PieChart } from './charts.js';
|
|
3
4
|
// Serialization
|
|
4
5
|
export { serialize, serializeTemplate, mapStyle, mapDimension, parseColor, expandEdges, expandCorners } from './serialize.js';
|
|
5
6
|
// StyleSheet
|
package/dist/serialize.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isValidElement, Children, Fragment } from 'react';
|
|
2
|
-
import { Document, Page, View, Text, Image, Table, Row, Cell, Fixed, Svg, PageBreak } from './components.js';
|
|
2
|
+
import { Document, Page, View, Text, Image, Table, Row, Cell, Fixed, Svg, QrCode, Canvas, Watermark, PageBreak } from './components.js';
|
|
3
3
|
import { Font } from './font.js';
|
|
4
4
|
import { isRefMarker, getRefPath, isEachMarker, getEachPath, getEachTemplate, isExprMarker, getExpr, REF_SENTINEL, REF_SENTINEL_END, } from './template-proxy.js';
|
|
5
5
|
const VALID_PARENTS = {
|
|
@@ -102,6 +102,10 @@ export function serialize(element) {
|
|
|
102
102
|
wrap: true,
|
|
103
103
|
},
|
|
104
104
|
};
|
|
105
|
+
if (props.tagged !== undefined)
|
|
106
|
+
result.tagged = props.tagged;
|
|
107
|
+
if (props.pdfa !== undefined)
|
|
108
|
+
result.pdfa = props.pdfa;
|
|
105
109
|
if (mergedFonts.length > 0) {
|
|
106
110
|
result.fonts = mergedFonts;
|
|
107
111
|
}
|
|
@@ -196,6 +200,15 @@ function serializeChild(child, parent = null) {
|
|
|
196
200
|
if (element.type === Svg) {
|
|
197
201
|
return serializeSvg(element);
|
|
198
202
|
}
|
|
203
|
+
if (element.type === QrCode) {
|
|
204
|
+
return serializeQrCode(element);
|
|
205
|
+
}
|
|
206
|
+
if (element.type === Canvas) {
|
|
207
|
+
return serializeCanvas(element);
|
|
208
|
+
}
|
|
209
|
+
if (element.type === Watermark) {
|
|
210
|
+
return serializeWatermark(element);
|
|
211
|
+
}
|
|
199
212
|
if (element.type === PageBreak) {
|
|
200
213
|
return {
|
|
201
214
|
kind: { type: 'PageBreak' },
|
|
@@ -383,6 +396,82 @@ function serializeSvg(element) {
|
|
|
383
396
|
node.alt = props.alt;
|
|
384
397
|
return node;
|
|
385
398
|
}
|
|
399
|
+
function serializeQrCode(element) {
|
|
400
|
+
const props = element.props;
|
|
401
|
+
const kind = { type: 'QrCode', data: props.data };
|
|
402
|
+
if (props.size !== undefined)
|
|
403
|
+
kind.size = props.size;
|
|
404
|
+
const style = mapStyle(props.style);
|
|
405
|
+
if (props.color)
|
|
406
|
+
style.color = parseColor(props.color);
|
|
407
|
+
return {
|
|
408
|
+
kind,
|
|
409
|
+
style,
|
|
410
|
+
children: [],
|
|
411
|
+
sourceLocation: extractSourceLocation(element),
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
function serializeCanvas(element) {
|
|
415
|
+
const props = element.props;
|
|
416
|
+
const operations = [];
|
|
417
|
+
// Create a recording context that captures draw calls as CanvasOp[]
|
|
418
|
+
const ctx = {
|
|
419
|
+
moveTo(x, y) { operations.push({ op: 'MoveTo', x, y }); },
|
|
420
|
+
lineTo(x, y) { operations.push({ op: 'LineTo', x, y }); },
|
|
421
|
+
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
422
|
+
operations.push({ op: 'BezierCurveTo', cp1x, cp1y, cp2x, cp2y, x, y });
|
|
423
|
+
},
|
|
424
|
+
quadraticCurveTo(cpx, cpy, x, y) {
|
|
425
|
+
operations.push({ op: 'QuadraticCurveTo', cpx, cpy, x, y });
|
|
426
|
+
},
|
|
427
|
+
closePath() { operations.push({ op: 'ClosePath' }); },
|
|
428
|
+
rect(x, y, w, h) { operations.push({ op: 'Rect', x, y, width: w, height: h }); },
|
|
429
|
+
circle(cx, cy, r) { operations.push({ op: 'Circle', cx, cy, r }); },
|
|
430
|
+
ellipse(cx, cy, rx, ry) { operations.push({ op: 'Ellipse', cx, cy, rx, ry }); },
|
|
431
|
+
arc(cx, cy, r, startAngle, endAngle, counterclockwise = false) {
|
|
432
|
+
operations.push({ op: 'Arc', cx, cy, r, start_angle: startAngle, end_angle: endAngle, counterclockwise });
|
|
433
|
+
},
|
|
434
|
+
stroke() { operations.push({ op: 'Stroke' }); },
|
|
435
|
+
fill() { operations.push({ op: 'Fill' }); },
|
|
436
|
+
fillAndStroke() { operations.push({ op: 'FillAndStroke' }); },
|
|
437
|
+
setFillColor(r, g, b) { operations.push({ op: 'SetFillColor', r, g, b }); },
|
|
438
|
+
setStrokeColor(r, g, b) { operations.push({ op: 'SetStrokeColor', r, g, b }); },
|
|
439
|
+
setLineWidth(w) { operations.push({ op: 'SetLineWidth', width: w }); },
|
|
440
|
+
setLineCap(cap) { operations.push({ op: 'SetLineCap', cap }); },
|
|
441
|
+
setLineJoin(join) { operations.push({ op: 'SetLineJoin', join }); },
|
|
442
|
+
save() { operations.push({ op: 'Save' }); },
|
|
443
|
+
restore() { operations.push({ op: 'Restore' }); },
|
|
444
|
+
};
|
|
445
|
+
// Execute the draw callback to record operations
|
|
446
|
+
props.draw(ctx);
|
|
447
|
+
return {
|
|
448
|
+
kind: { type: 'Canvas', width: props.width, height: props.height, operations },
|
|
449
|
+
style: mapStyle(props.style),
|
|
450
|
+
children: [],
|
|
451
|
+
sourceLocation: extractSourceLocation(element),
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function serializeWatermark(element) {
|
|
455
|
+
const props = element.props;
|
|
456
|
+
const fontSize = props.fontSize ?? 60;
|
|
457
|
+
const angle = props.angle ?? -45;
|
|
458
|
+
const colorStr = props.color ?? 'rgba(0,0,0,0.1)';
|
|
459
|
+
// Parse color — extract alpha for opacity
|
|
460
|
+
const parsedColor = parseColor(colorStr);
|
|
461
|
+
const style = mapStyle(props.style);
|
|
462
|
+
style.color = { r: parsedColor.r, g: parsedColor.g, b: parsedColor.b, a: 1 };
|
|
463
|
+
// Multiply color alpha with any existing opacity
|
|
464
|
+
const colorOpacity = parsedColor.a;
|
|
465
|
+
const styleOpacity = (style.opacity !== undefined) ? style.opacity : 1;
|
|
466
|
+
style.opacity = colorOpacity * styleOpacity;
|
|
467
|
+
style.fontSize = fontSize;
|
|
468
|
+
return {
|
|
469
|
+
kind: { type: 'Watermark', text: props.text, font_size: fontSize, angle },
|
|
470
|
+
style,
|
|
471
|
+
children: [],
|
|
472
|
+
sourceLocation: extractSourceLocation(element),
|
|
473
|
+
};
|
|
474
|
+
}
|
|
386
475
|
// ─── Children helpers ────────────────────────────────────────────────
|
|
387
476
|
function flattenChildren(children) {
|
|
388
477
|
const result = [];
|
|
@@ -501,6 +590,20 @@ const TEXT_TRANSFORM_MAP = {
|
|
|
501
590
|
'lowercase': 'Lowercase',
|
|
502
591
|
'capitalize': 'Capitalize',
|
|
503
592
|
};
|
|
593
|
+
const HYPHENS_MAP = {
|
|
594
|
+
'none': 'none',
|
|
595
|
+
'manual': 'manual',
|
|
596
|
+
'auto': 'auto',
|
|
597
|
+
};
|
|
598
|
+
const TEXT_OVERFLOW_MAP = {
|
|
599
|
+
'wrap': 'Wrap',
|
|
600
|
+
'ellipsis': 'Ellipsis',
|
|
601
|
+
'clip': 'Clip',
|
|
602
|
+
};
|
|
603
|
+
const OVERFLOW_MAP = {
|
|
604
|
+
'visible': 'Visible',
|
|
605
|
+
'hidden': 'Hidden',
|
|
606
|
+
};
|
|
504
607
|
export function mapStyle(style) {
|
|
505
608
|
if (!style)
|
|
506
609
|
return {};
|
|
@@ -579,6 +682,42 @@ export function mapStyle(style) {
|
|
|
579
682
|
result.rowGap = style.rowGap;
|
|
580
683
|
if (style.columnGap !== undefined)
|
|
581
684
|
result.columnGap = style.columnGap;
|
|
685
|
+
// Display mode
|
|
686
|
+
if (style.display !== undefined) {
|
|
687
|
+
result.display = style.display === 'grid' ? 'Grid' : 'Flex';
|
|
688
|
+
}
|
|
689
|
+
// CSS Grid
|
|
690
|
+
if (style.gridTemplateColumns !== undefined) {
|
|
691
|
+
result.gridTemplateColumns = parseGridTemplate(style.gridTemplateColumns);
|
|
692
|
+
}
|
|
693
|
+
if (style.gridTemplateRows !== undefined) {
|
|
694
|
+
result.gridTemplateRows = parseGridTemplate(style.gridTemplateRows);
|
|
695
|
+
}
|
|
696
|
+
if (style.gridAutoRows !== undefined) {
|
|
697
|
+
result.gridAutoRows = mapGridTrack(style.gridAutoRows);
|
|
698
|
+
}
|
|
699
|
+
if (style.gridAutoColumns !== undefined) {
|
|
700
|
+
result.gridAutoColumns = mapGridTrack(style.gridAutoColumns);
|
|
701
|
+
}
|
|
702
|
+
// Grid placement (individual props → single gridPlacement object)
|
|
703
|
+
if (style.gridColumnStart !== undefined || style.gridColumnEnd !== undefined ||
|
|
704
|
+
style.gridRowStart !== undefined || style.gridRowEnd !== undefined ||
|
|
705
|
+
style.gridColumnSpan !== undefined || style.gridRowSpan !== undefined) {
|
|
706
|
+
const placement = {};
|
|
707
|
+
if (style.gridColumnStart !== undefined)
|
|
708
|
+
placement.columnStart = style.gridColumnStart;
|
|
709
|
+
if (style.gridColumnEnd !== undefined)
|
|
710
|
+
placement.columnEnd = style.gridColumnEnd;
|
|
711
|
+
if (style.gridRowStart !== undefined)
|
|
712
|
+
placement.rowStart = style.gridRowStart;
|
|
713
|
+
if (style.gridRowEnd !== undefined)
|
|
714
|
+
placement.rowEnd = style.gridRowEnd;
|
|
715
|
+
if (style.gridColumnSpan !== undefined)
|
|
716
|
+
placement.columnSpan = style.gridColumnSpan;
|
|
717
|
+
if (style.gridRowSpan !== undefined)
|
|
718
|
+
placement.rowSpan = style.gridRowSpan;
|
|
719
|
+
result.gridPlacement = placement;
|
|
720
|
+
}
|
|
582
721
|
// Typography
|
|
583
722
|
if (style.fontFamily !== undefined)
|
|
584
723
|
result.fontFamily = style.fontFamily;
|
|
@@ -599,6 +738,16 @@ export function mapStyle(style) {
|
|
|
599
738
|
result.textDecoration = TEXT_DECORATION_MAP[style.textDecoration];
|
|
600
739
|
if (style.textTransform !== undefined)
|
|
601
740
|
result.textTransform = TEXT_TRANSFORM_MAP[style.textTransform];
|
|
741
|
+
if (style.hyphens !== undefined)
|
|
742
|
+
result.hyphens = HYPHENS_MAP[style.hyphens];
|
|
743
|
+
if (style.lang !== undefined)
|
|
744
|
+
result.lang = style.lang;
|
|
745
|
+
if (style.direction !== undefined)
|
|
746
|
+
result.direction = style.direction;
|
|
747
|
+
if (style.textOverflow !== undefined)
|
|
748
|
+
result.textOverflow = TEXT_OVERFLOW_MAP[style.textOverflow];
|
|
749
|
+
if (style.overflow !== undefined)
|
|
750
|
+
result.overflow = OVERFLOW_MAP[style.overflow];
|
|
602
751
|
// Color
|
|
603
752
|
if (style.color !== undefined)
|
|
604
753
|
result.color = parseColor(style.color);
|
|
@@ -709,6 +858,60 @@ export function mapStyle(style) {
|
|
|
709
858
|
result.minOrphanLines = style.minOrphanLines;
|
|
710
859
|
return result;
|
|
711
860
|
}
|
|
861
|
+
// ─── Grid helpers ───────────────────────────────────────────────────
|
|
862
|
+
/** Convert a single GridTrackSize to the Forme JSON format. */
|
|
863
|
+
function mapGridTrack(track) {
|
|
864
|
+
if (typeof track === 'number')
|
|
865
|
+
return { Pt: track };
|
|
866
|
+
if (track === 'auto')
|
|
867
|
+
return 'Auto';
|
|
868
|
+
if (typeof track === 'string') {
|
|
869
|
+
const frMatch = track.match(/^([0-9.]+)fr$/);
|
|
870
|
+
if (frMatch)
|
|
871
|
+
return { Fr: parseFloat(frMatch[1]) };
|
|
872
|
+
// Try numeric string
|
|
873
|
+
const num = parseFloat(track);
|
|
874
|
+
if (!isNaN(num))
|
|
875
|
+
return { Pt: num };
|
|
876
|
+
return 'Auto';
|
|
877
|
+
}
|
|
878
|
+
if (typeof track === 'object' && 'min' in track && 'max' in track) {
|
|
879
|
+
return { MinMax: [mapGridTrack(track.min), mapGridTrack(track.max)] };
|
|
880
|
+
}
|
|
881
|
+
return 'Auto';
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Expand `repeat(N, tracks)` in a grid template string.
|
|
885
|
+
* E.g. `"repeat(3, 1fr)"` → `"1fr 1fr 1fr"`
|
|
886
|
+
* `"200 repeat(2, 1fr) 200"` → `"200 1fr 1fr 200"`
|
|
887
|
+
*/
|
|
888
|
+
function expandRepeat(input) {
|
|
889
|
+
return input.replace(/repeat\(\s*(\d+)\s*,\s*([^)]+)\)/g, (_match, count, tracks) => {
|
|
890
|
+
return (tracks.trim() + ' ').repeat(parseInt(count, 10)).trim();
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Parse a grid template string shorthand into an array of FormeGridTrackSize.
|
|
895
|
+
* E.g. `"1fr 2fr 200"` → `[{Fr:1}, {Fr:2}, {Pt:200}]`
|
|
896
|
+
* Supports `repeat(N, tracks)` syntax.
|
|
897
|
+
*/
|
|
898
|
+
function parseGridTemplate(value) {
|
|
899
|
+
if (Array.isArray(value)) {
|
|
900
|
+
return value.map(mapGridTrack);
|
|
901
|
+
}
|
|
902
|
+
const expanded = expandRepeat(value);
|
|
903
|
+
return expanded.split(/\s+/).filter(Boolean).map((token) => {
|
|
904
|
+
if (token === 'auto')
|
|
905
|
+
return 'Auto';
|
|
906
|
+
const frMatch = token.match(/^([0-9.]+)fr$/);
|
|
907
|
+
if (frMatch)
|
|
908
|
+
return { Fr: parseFloat(frMatch[1]) };
|
|
909
|
+
const num = parseFloat(token);
|
|
910
|
+
if (!isNaN(num))
|
|
911
|
+
return { Pt: num };
|
|
912
|
+
return 'Auto';
|
|
913
|
+
});
|
|
914
|
+
}
|
|
712
915
|
export function mapDimension(val) {
|
|
713
916
|
if (typeof val === 'number') {
|
|
714
917
|
return { Pt: val };
|
|
@@ -727,7 +930,28 @@ export function mapDimension(val) {
|
|
|
727
930
|
return 'Auto';
|
|
728
931
|
}
|
|
729
932
|
export function parseColor(hex) {
|
|
730
|
-
const
|
|
933
|
+
const s = hex.trim();
|
|
934
|
+
// rgba(r, g, b, a)
|
|
935
|
+
const rgbaMatch = s.match(/^rgba\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*\)$/);
|
|
936
|
+
if (rgbaMatch) {
|
|
937
|
+
return {
|
|
938
|
+
r: parseFloat(rgbaMatch[1]) / 255,
|
|
939
|
+
g: parseFloat(rgbaMatch[2]) / 255,
|
|
940
|
+
b: parseFloat(rgbaMatch[3]) / 255,
|
|
941
|
+
a: parseFloat(rgbaMatch[4]),
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
// rgb(r, g, b)
|
|
945
|
+
const rgbMatch = s.match(/^rgb\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*\)$/);
|
|
946
|
+
if (rgbMatch) {
|
|
947
|
+
return {
|
|
948
|
+
r: parseFloat(rgbMatch[1]) / 255,
|
|
949
|
+
g: parseFloat(rgbMatch[2]) / 255,
|
|
950
|
+
b: parseFloat(rgbMatch[3]) / 255,
|
|
951
|
+
a: 1,
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
const h = s.replace(/^#/, '');
|
|
731
955
|
if (h.length === 3) {
|
|
732
956
|
const r = parseInt(h[0] + h[0], 16) / 255;
|
|
733
957
|
const g = parseInt(h[1] + h[1], 16) / 255;
|
|
@@ -916,6 +1140,10 @@ export function serializeTemplate(element) {
|
|
|
916
1140
|
wrap: true,
|
|
917
1141
|
},
|
|
918
1142
|
};
|
|
1143
|
+
if (props.tagged !== undefined)
|
|
1144
|
+
result.tagged = props.tagged;
|
|
1145
|
+
if (props.pdfa !== undefined)
|
|
1146
|
+
result.pdfa = props.pdfa;
|
|
919
1147
|
if (mergedFonts.length > 0) {
|
|
920
1148
|
result.fonts = mergedFonts;
|
|
921
1149
|
}
|
|
@@ -1008,6 +1236,12 @@ function serializeTemplateChild(child, parent = null) {
|
|
|
1008
1236
|
return serializeTemplateFixed(element);
|
|
1009
1237
|
if (element.type === Svg)
|
|
1010
1238
|
return serializeSvg(element);
|
|
1239
|
+
if (element.type === QrCode)
|
|
1240
|
+
return serializeQrCode(element);
|
|
1241
|
+
if (element.type === Canvas)
|
|
1242
|
+
return serializeCanvas(element);
|
|
1243
|
+
if (element.type === Watermark)
|
|
1244
|
+
return serializeWatermark(element);
|
|
1011
1245
|
if (element.type === PageBreak) {
|
|
1012
1246
|
return { kind: { type: 'PageBreak' }, style: {}, children: [] };
|
|
1013
1247
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -14,6 +14,11 @@ export interface Corners {
|
|
|
14
14
|
bottomRight: number;
|
|
15
15
|
bottomLeft: number;
|
|
16
16
|
}
|
|
17
|
+
/** A single CSS Grid track size */
|
|
18
|
+
export type GridTrackSize = number | `${number}fr` | 'auto' | {
|
|
19
|
+
min: GridTrackSize;
|
|
20
|
+
max: GridTrackSize;
|
|
21
|
+
};
|
|
17
22
|
/** Per-edge colors for borderColor */
|
|
18
23
|
export interface EdgeColors {
|
|
19
24
|
top: string;
|
|
@@ -23,6 +28,7 @@ export interface EdgeColors {
|
|
|
23
28
|
}
|
|
24
29
|
/** CSS-like style properties for Forme components */
|
|
25
30
|
export interface Style {
|
|
31
|
+
display?: 'flex' | 'grid';
|
|
26
32
|
width?: number | string;
|
|
27
33
|
height?: number | string;
|
|
28
34
|
minWidth?: number | string;
|
|
@@ -42,6 +48,26 @@ export interface Style {
|
|
|
42
48
|
gap?: number;
|
|
43
49
|
rowGap?: number;
|
|
44
50
|
columnGap?: number;
|
|
51
|
+
/** Column track definitions. String shorthand: `"1fr 2fr 200"` or array of track sizes. */
|
|
52
|
+
gridTemplateColumns?: string | GridTrackSize[];
|
|
53
|
+
/** Row track definitions. String shorthand: `"auto 1fr"` or array of track sizes. */
|
|
54
|
+
gridTemplateRows?: string | GridTrackSize[];
|
|
55
|
+
/** Default size for auto-generated rows. */
|
|
56
|
+
gridAutoRows?: GridTrackSize;
|
|
57
|
+
/** Default size for auto-generated columns. */
|
|
58
|
+
gridAutoColumns?: GridTrackSize;
|
|
59
|
+
/** Grid column start line (1-based). */
|
|
60
|
+
gridColumnStart?: number;
|
|
61
|
+
/** Grid column end line (1-based). */
|
|
62
|
+
gridColumnEnd?: number;
|
|
63
|
+
/** Grid row start line (1-based). */
|
|
64
|
+
gridRowStart?: number;
|
|
65
|
+
/** Grid row end line (1-based). */
|
|
66
|
+
gridRowEnd?: number;
|
|
67
|
+
/** Number of columns to span. */
|
|
68
|
+
gridColumnSpan?: number;
|
|
69
|
+
/** Number of rows to span. */
|
|
70
|
+
gridRowSpan?: number;
|
|
45
71
|
padding?: number | string | number[] | Edges;
|
|
46
72
|
paddingTop?: number;
|
|
47
73
|
paddingRight?: number;
|
|
@@ -65,6 +91,15 @@ export interface Style {
|
|
|
65
91
|
letterSpacing?: number;
|
|
66
92
|
textDecoration?: 'none' | 'underline' | 'line-through';
|
|
67
93
|
textTransform?: 'none' | 'uppercase' | 'lowercase' | 'capitalize';
|
|
94
|
+
hyphens?: 'none' | 'manual' | 'auto';
|
|
95
|
+
/** Language tag (BCP 47, e.g. "en-US", "de"). Controls hyphenation dictionary. */
|
|
96
|
+
lang?: string;
|
|
97
|
+
/** Text direction for BiDi support (Arabic, Hebrew). */
|
|
98
|
+
direction?: 'ltr' | 'rtl' | 'auto';
|
|
99
|
+
/** Text overflow behavior: 'wrap' (default), 'ellipsis' (truncate with ...), 'clip' (truncate). */
|
|
100
|
+
textOverflow?: 'wrap' | 'ellipsis' | 'clip';
|
|
101
|
+
/** Overflow behavior: 'visible' (default) or 'hidden' (clips children to bounds). */
|
|
102
|
+
overflow?: 'visible' | 'hidden';
|
|
68
103
|
color?: string;
|
|
69
104
|
backgroundColor?: string;
|
|
70
105
|
opacity?: number;
|
|
@@ -110,6 +145,10 @@ export interface DocumentProps {
|
|
|
110
145
|
creator?: string;
|
|
111
146
|
/** Document language (BCP 47 tag, e.g. "en-US"). Emitted as /Lang in the PDF Catalog. */
|
|
112
147
|
lang?: string;
|
|
148
|
+
/** Whether to produce a tagged (accessible) PDF with structure tree. */
|
|
149
|
+
tagged?: boolean;
|
|
150
|
+
/** PDF/A conformance level. "2a" requires tagging, "2b" is visual-only compliance. */
|
|
151
|
+
pdfa?: '2a' | '2b';
|
|
113
152
|
fonts?: FontRegistration[];
|
|
114
153
|
children?: ReactNode;
|
|
115
154
|
}
|
|
@@ -184,6 +223,187 @@ export interface SvgProps {
|
|
|
184
223
|
/** Alt text for accessibility. */
|
|
185
224
|
alt?: string;
|
|
186
225
|
}
|
|
226
|
+
export interface QrCodeProps {
|
|
227
|
+
/** Data to encode (URL, text, etc.) */
|
|
228
|
+
data: string;
|
|
229
|
+
/** Display size in points (QR codes are square). Defaults to available width. */
|
|
230
|
+
size?: number;
|
|
231
|
+
/** QR code color. Default: black. */
|
|
232
|
+
color?: string;
|
|
233
|
+
style?: Style;
|
|
234
|
+
}
|
|
235
|
+
/** Data point for bar and line charts. */
|
|
236
|
+
export interface ChartDataPoint {
|
|
237
|
+
label: string;
|
|
238
|
+
value: number;
|
|
239
|
+
}
|
|
240
|
+
/** Data point for pie charts with per-slice color. */
|
|
241
|
+
export interface PieDataPoint {
|
|
242
|
+
label: string;
|
|
243
|
+
value: number;
|
|
244
|
+
color: string;
|
|
245
|
+
}
|
|
246
|
+
export interface BarChartProps {
|
|
247
|
+
width: number;
|
|
248
|
+
height: number;
|
|
249
|
+
data: ChartDataPoint[];
|
|
250
|
+
/** Bar color. Default: "#1a365d". */
|
|
251
|
+
color?: string;
|
|
252
|
+
/** Gap between bars in points. Default: 4. */
|
|
253
|
+
barGap?: number;
|
|
254
|
+
/** Show horizontal grid lines. Default: false. */
|
|
255
|
+
showGrid?: boolean;
|
|
256
|
+
/** Show value labels above bars. Default: false. */
|
|
257
|
+
showValues?: boolean;
|
|
258
|
+
/** Number of Y-axis ticks. Default: 5. */
|
|
259
|
+
yAxisTicks?: number;
|
|
260
|
+
style?: Style;
|
|
261
|
+
}
|
|
262
|
+
export interface LineChartProps {
|
|
263
|
+
width: number;
|
|
264
|
+
height: number;
|
|
265
|
+
data: ChartDataPoint[];
|
|
266
|
+
/** Line color. Default: "#2b6cb0". */
|
|
267
|
+
color?: string;
|
|
268
|
+
/** Line stroke width. Default: 2. */
|
|
269
|
+
strokeWidth?: number;
|
|
270
|
+
/** Show dots at data points. Default: false. */
|
|
271
|
+
showDots?: boolean;
|
|
272
|
+
/** Show horizontal grid lines. Default: false. */
|
|
273
|
+
showGrid?: boolean;
|
|
274
|
+
/** Show filled area under the line. Default: false. */
|
|
275
|
+
showArea?: boolean;
|
|
276
|
+
style?: Style;
|
|
277
|
+
}
|
|
278
|
+
export interface PieChartProps {
|
|
279
|
+
width: number;
|
|
280
|
+
height: number;
|
|
281
|
+
data: PieDataPoint[];
|
|
282
|
+
/** Show labels outside slices. Default: false. */
|
|
283
|
+
showLabels?: boolean;
|
|
284
|
+
/** Inner radius for donut charts. Default: 0 (full pie). */
|
|
285
|
+
innerRadius?: number;
|
|
286
|
+
style?: Style;
|
|
287
|
+
}
|
|
288
|
+
export interface WatermarkProps {
|
|
289
|
+
/** The watermark text (e.g. "DRAFT", "CONFIDENTIAL"). */
|
|
290
|
+
text: string;
|
|
291
|
+
/** Font size in points. Default: 60. */
|
|
292
|
+
fontSize?: number;
|
|
293
|
+
/** Text color with alpha. Use `rgba(r,g,b,a)` for opacity. Default: "rgba(0,0,0,0.1)". */
|
|
294
|
+
color?: string;
|
|
295
|
+
/** Rotation angle in degrees (negative = counterclockwise). Default: -45. */
|
|
296
|
+
angle?: number;
|
|
297
|
+
style?: Style;
|
|
298
|
+
}
|
|
299
|
+
/** Canvas drawing context for the draw callback. */
|
|
300
|
+
export interface CanvasContext {
|
|
301
|
+
moveTo(x: number, y: number): void;
|
|
302
|
+
lineTo(x: number, y: number): void;
|
|
303
|
+
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
|
|
304
|
+
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
|
305
|
+
closePath(): void;
|
|
306
|
+
rect(x: number, y: number, w: number, h: number): void;
|
|
307
|
+
circle(cx: number, cy: number, r: number): void;
|
|
308
|
+
ellipse(cx: number, cy: number, rx: number, ry: number): void;
|
|
309
|
+
arc(cx: number, cy: number, r: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
|
|
310
|
+
stroke(): void;
|
|
311
|
+
fill(): void;
|
|
312
|
+
fillAndStroke(): void;
|
|
313
|
+
setFillColor(r: number, g: number, b: number): void;
|
|
314
|
+
setStrokeColor(r: number, g: number, b: number): void;
|
|
315
|
+
setLineWidth(w: number): void;
|
|
316
|
+
setLineCap(cap: number): void;
|
|
317
|
+
setLineJoin(join: number): void;
|
|
318
|
+
save(): void;
|
|
319
|
+
restore(): void;
|
|
320
|
+
}
|
|
321
|
+
/** A single canvas drawing operation (serialized to JSON). */
|
|
322
|
+
export type CanvasOp = {
|
|
323
|
+
op: 'MoveTo';
|
|
324
|
+
x: number;
|
|
325
|
+
y: number;
|
|
326
|
+
} | {
|
|
327
|
+
op: 'LineTo';
|
|
328
|
+
x: number;
|
|
329
|
+
y: number;
|
|
330
|
+
} | {
|
|
331
|
+
op: 'BezierCurveTo';
|
|
332
|
+
cp1x: number;
|
|
333
|
+
cp1y: number;
|
|
334
|
+
cp2x: number;
|
|
335
|
+
cp2y: number;
|
|
336
|
+
x: number;
|
|
337
|
+
y: number;
|
|
338
|
+
} | {
|
|
339
|
+
op: 'QuadraticCurveTo';
|
|
340
|
+
cpx: number;
|
|
341
|
+
cpy: number;
|
|
342
|
+
x: number;
|
|
343
|
+
y: number;
|
|
344
|
+
} | {
|
|
345
|
+
op: 'ClosePath';
|
|
346
|
+
} | {
|
|
347
|
+
op: 'Rect';
|
|
348
|
+
x: number;
|
|
349
|
+
y: number;
|
|
350
|
+
width: number;
|
|
351
|
+
height: number;
|
|
352
|
+
} | {
|
|
353
|
+
op: 'Circle';
|
|
354
|
+
cx: number;
|
|
355
|
+
cy: number;
|
|
356
|
+
r: number;
|
|
357
|
+
} | {
|
|
358
|
+
op: 'Ellipse';
|
|
359
|
+
cx: number;
|
|
360
|
+
cy: number;
|
|
361
|
+
rx: number;
|
|
362
|
+
ry: number;
|
|
363
|
+
} | {
|
|
364
|
+
op: 'Arc';
|
|
365
|
+
cx: number;
|
|
366
|
+
cy: number;
|
|
367
|
+
r: number;
|
|
368
|
+
start_angle: number;
|
|
369
|
+
end_angle: number;
|
|
370
|
+
counterclockwise: boolean;
|
|
371
|
+
} | {
|
|
372
|
+
op: 'Stroke';
|
|
373
|
+
} | {
|
|
374
|
+
op: 'Fill';
|
|
375
|
+
} | {
|
|
376
|
+
op: 'FillAndStroke';
|
|
377
|
+
} | {
|
|
378
|
+
op: 'SetFillColor';
|
|
379
|
+
r: number;
|
|
380
|
+
g: number;
|
|
381
|
+
b: number;
|
|
382
|
+
} | {
|
|
383
|
+
op: 'SetStrokeColor';
|
|
384
|
+
r: number;
|
|
385
|
+
g: number;
|
|
386
|
+
b: number;
|
|
387
|
+
} | {
|
|
388
|
+
op: 'SetLineWidth';
|
|
389
|
+
width: number;
|
|
390
|
+
} | {
|
|
391
|
+
op: 'SetLineCap';
|
|
392
|
+
cap: number;
|
|
393
|
+
} | {
|
|
394
|
+
op: 'SetLineJoin';
|
|
395
|
+
join: number;
|
|
396
|
+
} | {
|
|
397
|
+
op: 'Save';
|
|
398
|
+
} | {
|
|
399
|
+
op: 'Restore';
|
|
400
|
+
};
|
|
401
|
+
export interface CanvasProps {
|
|
402
|
+
width: number;
|
|
403
|
+
height: number;
|
|
404
|
+
draw: (ctx: CanvasContext) => void;
|
|
405
|
+
style?: Style;
|
|
406
|
+
}
|
|
187
407
|
/** A styled text segment within a <Text> element */
|
|
188
408
|
export interface TextRun {
|
|
189
409
|
content: string;
|
|
@@ -201,6 +421,8 @@ export interface FormeDocument {
|
|
|
201
421
|
metadata: FormeMetadata;
|
|
202
422
|
defaultPage: FormePageConfig;
|
|
203
423
|
fonts?: FormeFont[];
|
|
424
|
+
tagged?: boolean;
|
|
425
|
+
pdfa?: '2a' | '2b';
|
|
204
426
|
}
|
|
205
427
|
export interface FormeMetadata {
|
|
206
428
|
title?: string;
|
|
@@ -273,6 +495,20 @@ export type FormeNodeKind = {
|
|
|
273
495
|
height: number;
|
|
274
496
|
view_box?: string;
|
|
275
497
|
content: string;
|
|
498
|
+
} | {
|
|
499
|
+
type: 'QrCode';
|
|
500
|
+
data: string;
|
|
501
|
+
size?: number;
|
|
502
|
+
} | {
|
|
503
|
+
type: 'Canvas';
|
|
504
|
+
width: number;
|
|
505
|
+
height: number;
|
|
506
|
+
operations: CanvasOp[];
|
|
507
|
+
} | {
|
|
508
|
+
type: 'Watermark';
|
|
509
|
+
text: string;
|
|
510
|
+
font_size: number;
|
|
511
|
+
angle: number;
|
|
276
512
|
} | {
|
|
277
513
|
type: 'PageBreak';
|
|
278
514
|
};
|
|
@@ -307,8 +543,26 @@ export interface FormeCornerValues {
|
|
|
307
543
|
bottom_right: number;
|
|
308
544
|
bottom_left: number;
|
|
309
545
|
}
|
|
546
|
+
/** Grid track size in Forme JSON format (matches Rust GridTrackSize enum) */
|
|
547
|
+
export type FormeGridTrackSize = {
|
|
548
|
+
Pt: number;
|
|
549
|
+
} | {
|
|
550
|
+
Fr: number;
|
|
551
|
+
} | 'Auto' | {
|
|
552
|
+
MinMax: [FormeGridTrackSize, FormeGridTrackSize];
|
|
553
|
+
};
|
|
554
|
+
/** Grid placement in Forme JSON format */
|
|
555
|
+
export interface FormeGridPlacement {
|
|
556
|
+
columnStart?: number;
|
|
557
|
+
columnEnd?: number;
|
|
558
|
+
rowStart?: number;
|
|
559
|
+
rowEnd?: number;
|
|
560
|
+
columnSpan?: number;
|
|
561
|
+
rowSpan?: number;
|
|
562
|
+
}
|
|
310
563
|
/** Style in the Forme JSON format (camelCase field names, PascalCase enum values) */
|
|
311
564
|
export interface FormeStyle {
|
|
565
|
+
display?: string;
|
|
312
566
|
width?: FormeDimension;
|
|
313
567
|
height?: FormeDimension;
|
|
314
568
|
minWidth?: FormeDimension;
|
|
@@ -329,6 +583,11 @@ export interface FormeStyle {
|
|
|
329
583
|
gap?: number;
|
|
330
584
|
rowGap?: number;
|
|
331
585
|
columnGap?: number;
|
|
586
|
+
gridTemplateColumns?: FormeGridTrackSize[];
|
|
587
|
+
gridTemplateRows?: FormeGridTrackSize[];
|
|
588
|
+
gridAutoRows?: FormeGridTrackSize;
|
|
589
|
+
gridAutoColumns?: FormeGridTrackSize;
|
|
590
|
+
gridPlacement?: FormeGridPlacement;
|
|
332
591
|
fontFamily?: string;
|
|
333
592
|
fontSize?: number;
|
|
334
593
|
fontWeight?: number;
|
|
@@ -338,6 +597,11 @@ export interface FormeStyle {
|
|
|
338
597
|
letterSpacing?: number;
|
|
339
598
|
textDecoration?: string;
|
|
340
599
|
textTransform?: string;
|
|
600
|
+
hyphens?: string;
|
|
601
|
+
lang?: string;
|
|
602
|
+
direction?: string;
|
|
603
|
+
textOverflow?: string;
|
|
604
|
+
overflow?: string;
|
|
341
605
|
color?: FormeColor;
|
|
342
606
|
backgroundColor?: FormeColor;
|
|
343
607
|
opacity?: number;
|