@open-document/core 0.12.0 → 0.13.1

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 (48) hide show
  1. package/dist/{build-DfUfpeTR.js → build-CvsOak5B.js} +1 -1
  2. package/dist/{check-CHxiOkQG.js → check-CbUBwYmf.js} +3 -3
  3. package/dist/cli/bin.js +47 -10
  4. package/dist/config-BWtOZ1jc.d.ts +45 -0
  5. package/dist/{config-9IdbhVuT.js → config-CltJJVsw.js} +398 -493
  6. package/dist/{context-BLI1-64_.js → context-CWgfsHoE.js} +2 -1
  7. package/dist/deploy-gcp-BUiSuqz7.js +758 -0
  8. package/dist/{dev-yNYKv5mm.js → dev-B8H2qT6G.js} +1 -1
  9. package/dist/{diagram-BK4jTZr4.js → diagram-CKf3ptOE.js} +293 -13
  10. package/dist/{diff-Bs205mOx.js → diff-BvIjjgnc.js} +2 -2
  11. package/dist/{export-tkquS5O5.js → export-DX30_s2q.js} +3 -3
  12. package/dist/{sdk-CHEGeINh.d.ts → flow-CS5apebG.d.ts} +72 -3
  13. package/dist/{import-D1hIKIr3.js → import-DgsdJT5e.js} +2 -2
  14. package/dist/index.d.ts +155 -59
  15. package/dist/index.js +896 -90
  16. package/dist/open-doc-plugin-DnX5usgI.js +320 -0
  17. package/dist/ops/index.d.ts +98 -13
  18. package/dist/ops/index.js +3 -3
  19. package/dist/{ops-Dgqujq5a.js → ops-CSR5RlrE.js} +2 -1
  20. package/dist/{preview-BImdTH6K.js → preview-DYMUNjXL.js} +1 -1
  21. package/dist/{templates-DT5zzqHq.js → templates-B5Tz0AKb.js} +3 -3
  22. package/dist/vite/index.d.ts +1 -1
  23. package/dist/vite/index.js +2 -1
  24. package/package.json +1 -1
  25. package/skills/doc-authoring/SKILL.md +15 -16
  26. package/skills/doc-authoring/references/long-form.md +43 -2
  27. package/skills/doc-authoring/references/pagination.md +14 -2
  28. package/skills/doc-authoring/references/tables-and-charts.md +21 -17
  29. package/src/app/components/callout.tsx +101 -0
  30. package/src/app/components/chart.tsx +191 -33
  31. package/src/app/components/code-block.tsx +249 -0
  32. package/src/app/components/data-table.tsx +146 -18
  33. package/src/app/components/flow-page.tsx +57 -8
  34. package/src/app/components/numbering.tsx +226 -12
  35. package/src/app/components/page-frame.tsx +42 -0
  36. package/src/app/lib/chart.test.ts +15 -0
  37. package/src/app/lib/chart.ts +134 -9
  38. package/src/app/lib/diagnostics.ts +45 -1
  39. package/src/app/lib/export-dom.ts +15 -2
  40. package/src/app/lib/export-pdf.ts +9 -1
  41. package/src/app/lib/flow-measure.ts +33 -4
  42. package/src/app/lib/flow.test.ts +20 -1
  43. package/src/app/lib/flow.ts +120 -20
  44. package/src/app/lib/labels.ts +29 -10
  45. package/src/app/lib/sdk.ts +6 -0
  46. package/src/app/lib/use-doc-pages.ts +23 -8
  47. package/src/app/routes/doc.tsx +1 -0
  48. package/dist/config-P61niZMf.d.ts +0 -24
@@ -120,8 +120,10 @@ import services from './data/services.csv';
120
120
  arrives after the layout is decided.
121
121
  - Columns default to the keys of the first row. A column whose values are all
122
122
  numbers aligns right and gets `tabular-nums` without being told.
123
- - `format`: `'integer'`, `'number'`, `'percent'`, `'text'`, or your own
124
- `(value, row) => ReactNode`.
123
+ - `format`: `'integer'`, `'number'`, `'percent'`, `'currency'` (uses `column.currency ?? 'USD'`), `'delta'` (`+` prefix for positives, `−` for negatives), `'text'`, or your own `(value, row) => ReactNode`.
124
+ - `dataBar`: `true` or `{ color?: string; max?: number }` on a numeric column draws an inline proportional bar behind the cell's number.
125
+ - `summaryRow`: `'sum' | 'avg'` (aggregates all numeric columns automatically) or a custom record `{ service: 'Total', requests: 'sum', error_rate: 'avg' }` rendered in `<tfoot>`.
126
+ - `splittable`: when `true` inside a `flow()` section, automatically splits long tables across pages, repeating `<thead>` and appending `meta.labels?.continued ?? ' (continued)'` to the caption on continuation sheets.
125
127
  - `caption` numbers the table and prints the caption above it; without one you
126
128
  get a plain table.
127
129
  - `limit` prints the first N rows and says how many were left out — never
@@ -129,3 +131,42 @@ import services from './data/services.csv';
129
131
 
130
132
  **Retyping numbers into JSX is the thing this replaces.** If the user has the
131
133
  data in a file, import the file.
134
+
135
+ ## Citations and bibliography (`<Cite>` & `<Bibliography>`)
136
+
137
+ ```tsx
138
+ import { Bibliography, Cite } from '@open-document/core';
139
+
140
+ <p style={p}>
141
+ Tail latency dominates fan-out services <Cite id="dean2013" label="p. 75" source="J. Dean and L. A. Barroso, 'The Tail at Scale,' Communications of the ACM, vol. 56, no. 2, pp. 74–80, 2013." />.
142
+ </p>
143
+
144
+ <Bibliography title="References" />
145
+ ```
146
+
147
+ - `<Cite id="…" />` numbers citations `[1]`, `[2]` in order of first appearance across the entire document. Citing the same `id` again reuses the same number; pass `source` on at least the first occurrence, and optional `label` (e.g. `"p. 42"`) to render `[1, p. 42]`.
148
+ - `<Bibliography />` prints the numbered reference list in order of appearance. An entry cited without any `source` renders `[?id]` so missing bibliography text is immediately visible.
149
+
150
+ ## Syntax-highlighted code (`<CodeBlock>`)
151
+
152
+ ```tsx
153
+ import { CodeBlock } from '@open-document/core';
154
+
155
+ <CodeBlock
156
+ id="retry-policy"
157
+ caption="Exponential backoff retry policy"
158
+ lang="ts"
159
+ lineNumbers
160
+ highlightLines={[3, 4]}
161
+ code={`export async function withRetry<T>(fn: () => Promise<T>, retries = 3): Promise<T> {
162
+ for (let i = 0; i < retries; i++) {
163
+ try { return await fn(); }
164
+ catch (err) { if (i === retries - 1) throw err; }
165
+ }
166
+ throw new Error('Unreachable');
167
+ }`}
168
+ />
169
+ ```
170
+
171
+ - Highlights keywords, strings, comments, numbers, and types at render time with zero external dependencies using `--od-*` variables.
172
+ - Passing `caption` numbers the code block as a figure (retrievable via `<Ref to="retry-policy" />`).
@@ -41,13 +41,25 @@ export default [Cover, Contents, Body] satisfies DocEntry[];
41
41
  | Heading never last on a page | `data-od-keep-with-next` | **on** for `h1`–`h4` |
42
42
  | Caption stays with its figure | `data-od-keep-with-previous` on the caption | off |
43
43
  | Force a new page here | `data-od-break-before` | off |
44
+ | Span all columns in multi-column flow | `data-od-column-span="all"` | **on** for `h1` |
44
45
 
45
46
  Set `data-od-keep-with-next="false"` on a heading if you deliberately want it to end a page.
46
47
 
48
+ ### Multi-column flow (`columns` & `columnGap`)
49
+
50
+ Pass `columns: 2` (or `3`) and optional `columnGap` (default `24`) to `flow(children, { columns: 2, columnGap: 24, footer: Footer })` to pack blocks into balanced newspaper/academic columns on each page:
51
+
52
+ - Blocks flow down column 1 first, then column 2, then open a new page.
53
+ - `<h1>` elements (and any block carrying `data-od-column-span="all"`) span the full text-block width across all columns and flush the columns above them.
54
+ - Footnotes lifted from any column on a page share the single page-wide footnote area at the bottom of the sheet.
55
+
56
+ ### Splittable tables (`<DataTable splittable />`)
57
+
58
+ By default, blocks in `flow()` are atomic. However, `<DataTable splittable rows={…} />` is measured row-by-row and automatically sliced across as many flow pages as needed, repeating `<thead>` on every continuation page and appending the continuation suffix (`meta.labels?.continued ?? ' (continued)'`) to the caption.
59
+
47
60
  ### What flow does not do
48
61
 
49
- - **It never splits a block.** A 40-row table taller than one page stays whole and overflows — split it yourself into two tables with a repeated header.
50
- - **It does not balance pages.** Content fills top-down; the last page can be short.
62
+ - **It never splits an arbitrary block** unless it is a `<DataTable splittable />` (or bears `data-od-splittable="table"`).
51
63
  - **It does not reorder anything.** Blocks keep the order you wrote them in.
52
64
 
53
65
  ## Fixed pages and the vertical budget
@@ -67,7 +67,7 @@ Rules:
67
67
 
68
68
  ### Long tables
69
69
 
70
- Split by row groups across pages. Repeat the full header row and mark the continuation in the caption ("Table 3 (continued)"). Never let a header land on one page and its rows on the next.
70
+ Inside a `flow()` section, pass `splittable` to `<DataTable rows={…} splittable />` so the framework automatically slices rows across pages, repeats the `<thead>` header row, and marks the continuation in the caption ("Table 3 (continued)"). For hand-written `<table>` elements on fixed pages, split by row groups across pages and repeat the header row yourself. Never let a header land on one page and its rows on the next.
71
71
 
72
72
  ## Stat rows
73
73
 
@@ -106,13 +106,24 @@ import costs from './data/costs.csv';
106
106
  <Chart type="pie" data={services} x="service" y="cost" values caption="費用占比" />
107
107
  ```
108
108
 
109
- - `type`: `bar` (default), `line`, `pie`. `y` takes one key or several (one series each); a pie reads the first.
110
- - `stacked` stacks bar series instead of grouping them; `values` prints each value on its bar, point or slice.
111
- - `format`: `number`, `integer`, `percent`, or a function — the same vocabulary as `<DataTable>`.
109
+ - `type`: `'bar'` (default), `'horizontal-bar'`, `'line'`, `'area'`, `'pie'`. `y` takes one key or several (one series each); a pie reads the first.
110
+ - `stacked` stacks `bar`, `horizontal-bar`, or `area` series instead of grouping/overlapping them; `values` prints each value on its bar, point or slice.
111
+ - `format`: `'number'`, `'integer'`, `'percent'`, `'currency'`, `'delta'`, or a function — the same vocabulary as `<DataTable>`.
112
112
  - `width` / `height` are the drawn size in px (default 560 × 260); it scales down to the column.
113
113
  - It lays out synchronously into a fixed box, so it paginates like any block. In Word it arrives as a picture.
114
114
 
115
- Anything `<Chart>` doesn't draw — a sparkline in a stat row, an annotated timeline — write as **inline SVG** sized in absolute px:
115
+ ### Inline sparklines (`<Sparkline>`)
116
+
117
+ For compact trend lines or mini bar strips inside a `<DataTable>` cell, stat card, or prose paragraph, use **`<Sparkline>`**:
118
+
119
+ ```tsx
120
+ import { Sparkline } from '@open-document/core';
121
+
122
+ <Sparkline data={[38, 42, 40, 49, 55, 61]} type="area" width={88} height={22} showEndDot />
123
+ <Sparkline data={[12, 18, 15, 24, 29]} type="bar" width={72} height={20} />
124
+ ```
125
+
126
+ Anything `<Chart>` or `<Sparkline>` doesn't draw — an annotated timeline or bespoke diagram — write as **inline SVG** sized in absolute px:
116
127
 
117
128
  ```tsx
118
129
  const Bars = () => {
@@ -158,21 +169,14 @@ Rules:
158
169
 
159
170
  ## Callouts
160
171
 
161
- One box style, used sparingly (at most one or two per page):
172
+ Use the built-in **`<Callout>`** primitive (`type`: `'note' | 'tip' | 'warning' | 'danger'`, default `'note'`) sparingly — at most one or two per page:
162
173
 
163
174
  ```tsx
164
- <div
165
- style={{
166
- borderLeft: '3px solid var(--od-accent)',
167
- background: '#f8fafc',
168
- padding: '12px 14px',
169
- borderRadius: 'var(--od-radius)',
170
- fontSize: 12,
171
- }}
172
- >
173
- <strong style={{ display: 'block', marginBottom: 4 }}>Recommendation</strong>
175
+ import { Callout } from '@open-document/core';
176
+
177
+ <Callout type="warning" title="Recommendation">
174
178
  Move the checkout queue to its own cluster before the November peak.
175
- </div>
179
+ </Callout>
176
180
  ```
177
181
 
178
182
  Reserve callouts for recommendations, risks, and definitions. A page where everything is boxed emphasizes nothing.
@@ -0,0 +1,101 @@
1
+ import type { CSSProperties, ReactNode } from 'react';
2
+ import { LOC_PROP, sourceAttrs } from '../lib/source-loc';
3
+
4
+ export type CalloutVariant = 'info' | 'tip' | 'warning' | 'danger' | 'neutral';
5
+
6
+ export type CalloutProps = {
7
+ variant?: CalloutVariant;
8
+ title?: ReactNode;
9
+ children?: ReactNode;
10
+ style?: CSSProperties;
11
+ className?: string;
12
+ [LOC_PROP]?: string;
13
+ };
14
+
15
+ const PALETTES: Record<
16
+ CalloutVariant,
17
+ { border: string; bg: string; badge: string; label: string }
18
+ > = {
19
+ info: {
20
+ border: 'var(--od-accent, #2563eb)',
21
+ bg: 'color-mix(in srgb, var(--od-accent, #2563eb) 7%, var(--od-bg, #ffffff))',
22
+ badge: 'var(--od-accent, #2563eb)',
23
+ label: 'NOTE',
24
+ },
25
+ tip: {
26
+ border: '#15803d',
27
+ bg: 'color-mix(in srgb, #15803d 7%, var(--od-bg, #ffffff))',
28
+ badge: '#15803d',
29
+ label: 'TIP',
30
+ },
31
+ warning: {
32
+ border: '#b45309',
33
+ bg: 'color-mix(in srgb, #d97706 8%, var(--od-bg, #ffffff))',
34
+ badge: '#b45309',
35
+ label: 'WARNING',
36
+ },
37
+ danger: {
38
+ border: '#b91c1c',
39
+ bg: 'color-mix(in srgb, #dc2626 7%, var(--od-bg, #ffffff))',
40
+ badge: '#b91c1c',
41
+ label: 'CRITICAL',
42
+ },
43
+ neutral: {
44
+ border: 'var(--od-muted, #6b7280)',
45
+ bg: 'color-mix(in srgb, var(--od-text, #16181d) 4%, var(--od-bg, #ffffff))',
46
+ badge: 'var(--od-muted, #6b7280)',
47
+ label: 'SUMMARY',
48
+ },
49
+ };
50
+
51
+ /**
52
+ * A structured admonition box (`info`, `tip`, `warning`, `danger`, `neutral`)
53
+ * rendered as a `<blockquote data-od-callout>` so Word and PDF exporters keep
54
+ * its panel border and shading intact.
55
+ */
56
+ export function Callout({
57
+ variant = 'info',
58
+ title,
59
+ children,
60
+ style,
61
+ className,
62
+ [LOC_PROP]: loc,
63
+ }: CalloutProps) {
64
+ const palette = PALETTES[variant] ?? PALETTES.info;
65
+
66
+ return (
67
+ <blockquote
68
+ {...sourceAttrs(loc)}
69
+ data-od-callout={variant}
70
+ className={className}
71
+ style={{
72
+ margin: '4px 0 12px',
73
+ padding: '10px 14px',
74
+ borderLeft: `3px solid ${palette.border}`,
75
+ background: palette.bg,
76
+ borderRadius: '0 var(--od-radius, 4px) var(--od-radius, 4px) 0',
77
+ color: 'var(--od-text, #16181d)',
78
+ fontStyle: 'normal',
79
+ fontSize: '0.95em',
80
+ lineHeight: 1.55,
81
+ ...style,
82
+ }}
83
+ >
84
+ {title !== undefined && (
85
+ <div
86
+ style={{
87
+ fontFamily: 'var(--od-font-heading, sans-serif)',
88
+ fontWeight: 650,
89
+ fontSize: '0.92em',
90
+ color: palette.badge,
91
+ marginBottom: 4,
92
+ letterSpacing: '0.01em',
93
+ }}
94
+ >
95
+ {typeof title === 'string' ? <span {...sourceAttrs(loc, 'title')}>{title}</span> : title}
96
+ </div>
97
+ )}
98
+ <div>{children}</div>
99
+ </blockquote>
100
+ );
101
+ }
@@ -114,26 +114,47 @@ export function Chart({
114
114
  }}
115
115
  className={caption ? undefined : className}
116
116
  >
117
- {chart.ticks.map((tick) => (
118
- <g key={tick.value}>
119
- <line
120
- x1={chart.plot.x}
121
- x2={chart.plot.x + chart.plot.width}
122
- y1={tick.at}
123
- y2={tick.at}
124
- style={{ stroke: RULE }}
125
- strokeWidth={1}
126
- />
127
- <text
128
- x={chart.plot.x - 6}
129
- y={tick.at + CHART_FONT_SIZE * 0.35}
130
- textAnchor="end"
131
- style={{ ...text, fill: MUTED }}
132
- >
133
- {tick.label}
134
- </text>
135
- </g>
136
- ))}
117
+ {chart.ticks.map((tick) =>
118
+ chart.horizontal ? (
119
+ <g key={tick.value}>
120
+ <line
121
+ x1={tick.at}
122
+ x2={tick.at}
123
+ y1={chart.plot.y}
124
+ y2={chart.plot.y + chart.plot.height}
125
+ style={{ stroke: RULE }}
126
+ strokeWidth={1}
127
+ />
128
+ <text
129
+ x={tick.at}
130
+ y={chart.plot.y + chart.plot.height + CHART_FONT_SIZE * 1.4}
131
+ textAnchor="middle"
132
+ style={{ ...text, fill: MUTED }}
133
+ >
134
+ {tick.label}
135
+ </text>
136
+ </g>
137
+ ) : (
138
+ <g key={tick.value}>
139
+ <line
140
+ x1={chart.plot.x}
141
+ x2={chart.plot.x + chart.plot.width}
142
+ y1={tick.at}
143
+ y2={tick.at}
144
+ style={{ stroke: RULE }}
145
+ strokeWidth={1}
146
+ />
147
+ <text
148
+ x={chart.plot.x - 6}
149
+ y={tick.at + CHART_FONT_SIZE * 0.35}
150
+ textAnchor="end"
151
+ style={{ ...text, fill: MUTED }}
152
+ >
153
+ {tick.label}
154
+ </text>
155
+ </g>
156
+ ),
157
+ )}
137
158
  {chart.bars.map((bar) => (
138
159
  <rect
139
160
  key={`${bar.series}-${bar.x}-${bar.y}`}
@@ -144,18 +165,38 @@ export function Chart({
144
165
  style={{ fill: colorOf(bar.series, colors) }}
145
166
  />
146
167
  ))}
147
- {chart.baseline !== null && chart.bars.length > 0 && (
148
- <line
149
- x1={chart.plot.x}
150
- x2={chart.plot.x + chart.plot.width}
151
- y1={chart.baseline}
152
- y2={chart.baseline}
153
- style={{ stroke: MUTED }}
154
- strokeWidth={1}
155
- />
156
- )}
168
+ {chart.baseline !== null &&
169
+ chart.bars.length > 0 &&
170
+ (chart.horizontal ? (
171
+ <line
172
+ x1={chart.baseline}
173
+ x2={chart.baseline}
174
+ y1={chart.plot.y}
175
+ y2={chart.plot.y + chart.plot.height}
176
+ style={{ stroke: MUTED }}
177
+ strokeWidth={1}
178
+ />
179
+ ) : (
180
+ <line
181
+ x1={chart.plot.x}
182
+ x2={chart.plot.x + chart.plot.width}
183
+ y1={chart.baseline}
184
+ y2={chart.baseline}
185
+ style={{ stroke: MUTED }}
186
+ strokeWidth={1}
187
+ />
188
+ ))}
157
189
  {chart.lines.map((line) => (
158
190
  <g key={line.series} style={{ stroke: colorOf(line.series, colors) }}>
191
+ {line.areaPath && (
192
+ <path
193
+ d={line.areaPath}
194
+ stroke="none"
195
+ style={{
196
+ fill: `color-mix(in srgb, ${colorOf(line.series, colors)} 20%, transparent)`,
197
+ }}
198
+ />
199
+ )}
159
200
  <polyline
160
201
  points={line.points.map((point) => `${point.x},${point.y}`).join(' ')}
161
202
  fill="none"
@@ -184,10 +225,10 @@ export function Chart({
184
225
  ))}
185
226
  {chart.categories.map((category) => (
186
227
  <text
187
- key={category.x}
228
+ key={`${category.x}-${category.y ?? 0}-${category.text}`}
188
229
  x={category.x}
189
- y={chart.plot.y + chart.plot.height + CHART_FONT_SIZE * 1.5}
190
- textAnchor="middle"
230
+ y={category.y ?? chart.plot.y + chart.plot.height + CHART_FONT_SIZE * 1.5}
231
+ textAnchor={chart.horizontal ? 'end' : 'middle'}
191
232
  style={{ ...text, fill: MUTED }}
192
233
  >
193
234
  {category.text}
@@ -237,3 +278,120 @@ export function Chart({
237
278
  </Figure>
238
279
  );
239
280
  }
281
+
282
+ export type SparklineProps = {
283
+ /** Numeric values to plot in order. */
284
+ data: number[];
285
+ /** Line with subtle fill, or compact inline bars. Defaults to 'line'. */
286
+ type?: 'line' | 'bar';
287
+ width?: number;
288
+ height?: number;
289
+ color?: string;
290
+ /** Highlight the final data point with a dot on line sparklines. Defaults to true. */
291
+ showEndDot?: boolean;
292
+ style?: CSSProperties;
293
+ className?: string;
294
+ };
295
+
296
+ /**
297
+ * A compact word-sized chart that sits inline inside a paragraph or table cell.
298
+ */
299
+ export function Sparkline({
300
+ data,
301
+ type = 'line',
302
+ width = 76,
303
+ height = 20,
304
+ color = ACCENT,
305
+ showEndDot = true,
306
+ style,
307
+ className,
308
+ }: SparklineProps) {
309
+ const nums = data.filter((v) => typeof v === 'number' && Number.isFinite(v));
310
+ if (nums.length === 0) return null;
311
+
312
+ const min = Math.min(...nums);
313
+ const max = Math.max(...nums);
314
+ const span = max - min || 1;
315
+ const pad = 2.5;
316
+ const w = Math.max(4, width - pad * 2);
317
+ const h = Math.max(4, height - pad * 2);
318
+
319
+ if (type === 'bar') {
320
+ const baseMin = Math.min(0, min);
321
+ const baseMax = Math.max(0, max) || 1;
322
+ const baseSpan = baseMax - baseMin || 1;
323
+ const step = w / nums.length;
324
+ const barW = Math.max(1.5, step * 0.72);
325
+ return (
326
+ <svg
327
+ viewBox={`0 0 ${width} ${height}`}
328
+ width={width}
329
+ height={height}
330
+ aria-hidden="true"
331
+ className={className}
332
+ style={{
333
+ display: 'inline-block',
334
+ verticalAlign: 'middle',
335
+ overflow: 'visible',
336
+ ...style,
337
+ }}
338
+ >
339
+ {nums.map((val, idx) => {
340
+ const bh = Math.max(1.5, (Math.abs(val) / baseSpan) * h);
341
+ const x = pad + idx * step + (step - barW) / 2;
342
+ const y = pad + h - bh;
343
+ return (
344
+ // biome-ignore lint/suspicious/noArrayIndexKey: index is data order
345
+ <rect key={idx} x={x} y={y} width={barW} height={bh} rx={1} style={{ fill: color }} />
346
+ );
347
+ })}
348
+ </svg>
349
+ );
350
+ }
351
+
352
+ const pts = nums.map((val, idx) => {
353
+ const x = pad + (nums.length === 1 ? w / 2 : (idx / (nums.length - 1)) * w);
354
+ const y = pad + h - ((val - min) / span) * h;
355
+ return { x: Math.round(x * 10) / 10, y: Math.round(y * 10) / 10 };
356
+ });
357
+ const poly = pts.map((p) => `${p.x},${p.y}`).join(' ');
358
+ const first = pts[0];
359
+ const last = pts[pts.length - 1];
360
+ const area =
361
+ pts.length >= 2 && first && last
362
+ ? `M${pts.map((p) => `${p.x},${p.y}`).join(' L')} L${last.x},${pad + h} L${first.x},${pad + h} Z`
363
+ : null;
364
+
365
+ return (
366
+ <svg
367
+ viewBox={`0 0 ${width} ${height}`}
368
+ width={width}
369
+ height={height}
370
+ aria-hidden="true"
371
+ className={className}
372
+ style={{
373
+ display: 'inline-block',
374
+ verticalAlign: 'middle',
375
+ overflow: 'visible',
376
+ ...style,
377
+ }}
378
+ >
379
+ {area && (
380
+ <path
381
+ d={area}
382
+ stroke="none"
383
+ style={{ fill: `color-mix(in srgb, ${color} 18%, transparent)` }}
384
+ />
385
+ )}
386
+ <polyline
387
+ points={poly}
388
+ fill="none"
389
+ strokeWidth={1.6}
390
+ strokeLinecap="round"
391
+ strokeLinejoin="round"
392
+ style={{ stroke: color }}
393
+ />
394
+ {showEndDot && last && <circle cx={last.x} cy={last.y} r={2.2} style={{ fill: color }} />}
395
+ </svg>
396
+ );
397
+ }