@stacksjs/components 0.2.990 → 0.2.997

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 (95) hide show
  1. package/dist/ApiOperation-369y1zgt.stx +114 -0
  2. package/dist/ApiReference-ww45jj32.stx +92 -0
  3. package/dist/ApiSchema-dsx4tsv4.stx +47 -0
  4. package/dist/AreaChart-8fy34adp.stx +77 -0
  5. package/dist/BarChart-4xdrjhhn.stx +77 -0
  6. package/dist/{Combobox-9n04ec5w.stx → Combobox-fgbpxbty.stx} +174 -5
  7. package/dist/ComboboxOptions-sfkc98a9.stx +36 -0
  8. package/dist/{CommandPalette-cj6pe5ph.stx → CommandPalette-sf03s7b2.stx} +3 -1
  9. package/dist/LineChart-ctebkkm8.stx +77 -0
  10. package/dist/{List-5ey6k813.stx → List-mjkged1z.stx} +1 -1
  11. package/dist/{Notification-b3cz24f0.stx → Notification-1pvt347q.stx} +16 -4
  12. package/dist/{Popover-jjt7p7sn.stx → Popover-gntg33xd.stx} +1 -1
  13. package/dist/PricingPlan-h7jt2696.stx +67 -0
  14. package/dist/PricingTable-v3vdn6av.stx +149 -0
  15. package/dist/SecretField-q2xgth94.stx +219 -0
  16. package/dist/{Select-36s22z6d.stx → Select-yhmtvqcx.stx} +7 -4
  17. package/dist/Sparkline-gp859n4h.stx +29 -0
  18. package/dist/StatCard-gff0yx6b.stx +93 -0
  19. package/dist/StatGroup-e0d5dmt7.stx +17 -0
  20. package/dist/components/CodeBlock.d.ts +4 -1
  21. package/dist/components/CodeGroup.d.ts +34 -0
  22. package/dist/components/code-group.d.ts +19 -0
  23. package/dist/components/index.d.ts +2 -0
  24. package/dist/index.d.ts +13 -0
  25. package/dist/index.js +25 -22
  26. package/dist/ui/api-reference/ApiOperation.d.ts +17 -0
  27. package/dist/ui/api-reference/ApiReference.d.ts +28 -0
  28. package/dist/ui/api-reference/ApiSchema.d.ts +17 -0
  29. package/dist/ui/api-reference/index.d.ts +30 -0
  30. package/dist/ui/api-reference/openapi.d.ts +137 -0
  31. package/dist/ui/chart/AreaChart.d.ts +33 -0
  32. package/dist/ui/chart/BarChart.d.ts +33 -0
  33. package/dist/ui/chart/LineChart.d.ts +33 -0
  34. package/dist/ui/chart/Sparkline.d.ts +19 -0
  35. package/dist/ui/chart/core.d.ts +111 -0
  36. package/dist/ui/chart/index.d.ts +51 -0
  37. package/dist/ui/chart/interaction.d.ts +11 -0
  38. package/dist/ui/combobox/Combobox.d.ts +10 -1
  39. package/dist/ui/combobox/ComboboxOptions.d.ts +6 -0
  40. package/dist/ui/combobox/index.d.ts +7 -0
  41. package/dist/ui/command-palette/CommandPalette.d.ts +2 -0
  42. package/dist/ui/input/SecretField.d.ts +56 -0
  43. package/dist/ui/input/index.d.ts +21 -0
  44. package/dist/ui/notification/Notification.d.ts +2 -0
  45. package/dist/ui/pricing/PricingPlan.d.ts +21 -0
  46. package/dist/ui/pricing/PricingTable.d.ts +50 -0
  47. package/dist/ui/pricing/index.d.ts +38 -0
  48. package/dist/ui/pricing/pricing.d.ts +64 -0
  49. package/dist/ui/select/Select.d.ts +2 -0
  50. package/dist/ui/stat/StatCard.d.ts +42 -0
  51. package/dist/ui/stat/StatGroup.d.ts +12 -0
  52. package/dist/ui/stat/format.d.ts +37 -0
  53. package/dist/ui/stat/index.d.ts +23 -0
  54. package/package.json +3 -3
  55. package/src/components/CodeBlock.stx +4 -1
  56. package/src/components/CodeGroup.stx +217 -0
  57. package/src/components/code-group.ts +57 -0
  58. package/src/components/index.ts +2 -0
  59. package/src/index.ts +18 -0
  60. package/src/ui/api-reference/ApiOperation.stx +114 -0
  61. package/src/ui/api-reference/ApiReference.stx +92 -0
  62. package/src/ui/api-reference/ApiSchema.stx +47 -0
  63. package/src/ui/api-reference/README.md +44 -0
  64. package/src/ui/api-reference/index.ts +35 -0
  65. package/src/ui/api-reference/openapi.ts +825 -0
  66. package/src/ui/chart/AreaChart.stx +77 -0
  67. package/src/ui/chart/BarChart.stx +77 -0
  68. package/src/ui/chart/LineChart.stx +77 -0
  69. package/src/ui/chart/README.md +97 -0
  70. package/src/ui/chart/Sparkline.stx +29 -0
  71. package/src/ui/chart/core.ts +730 -0
  72. package/src/ui/chart/index.ts +71 -0
  73. package/src/ui/chart/interaction.ts +175 -0
  74. package/src/ui/combobox/Combobox.stx +174 -5
  75. package/src/ui/combobox/ComboboxOptions.stx +20 -0
  76. package/src/ui/combobox/README.md +41 -0
  77. package/src/ui/combobox/index.ts +13 -0
  78. package/src/ui/command-palette/CommandPalette.stx +3 -1
  79. package/src/ui/input/SecretField.stx +219 -0
  80. package/src/ui/input/index.ts +32 -0
  81. package/src/ui/list/List.stx +1 -1
  82. package/src/ui/notification/Notification.stx +16 -4
  83. package/src/ui/popover/Popover.stx +1 -1
  84. package/src/ui/pricing/PricingPlan.stx +67 -0
  85. package/src/ui/pricing/PricingTable.stx +149 -0
  86. package/src/ui/pricing/README.md +74 -0
  87. package/src/ui/pricing/index.ts +49 -0
  88. package/src/ui/pricing/pricing.ts +177 -0
  89. package/src/ui/select/Select.stx +7 -4
  90. package/src/ui/stat/README.md +60 -0
  91. package/src/ui/stat/StatCard.stx +93 -0
  92. package/src/ui/stat/StatGroup.stx +17 -0
  93. package/src/ui/stat/format.ts +147 -0
  94. package/src/ui/stat/index.ts +38 -0
  95. package/dist/ComboboxOptions-zhr9b6rx.stx +0 -16
@@ -0,0 +1,77 @@
1
+ <script server>
2
+ import { prepareChart } from './core'
3
+
4
+ /*
5
+ * <AreaChart> (stacksjs/stx#2318). The SVG is drawn here, on the server, so
6
+ * the chart shows before any script runs; the client script only lays it out
7
+ * again at its real width and adds the crosshair, tooltip and keyboard.
8
+ *
9
+ * The data and the accessors stay on the server (`serverOnlyProps`): the
10
+ * client gets the prepared model, every label already formatted, so a
11
+ * `formatY` function works and the records are not shipped twice.
12
+ */
13
+ export const serverOnlyProps = ['data', 'x', 'y', 'series', 'formatX', 'formatY', 'colors', 'yDomain']
14
+ const chart = prepareChart('area', $props)
15
+ export const label = $props.label || 'Chart'
16
+ export const loading = $bool($props.loading)
17
+ export const emptyText = $props.emptyText || 'No data to show yet'
18
+ export const empty = chart.empty
19
+ export const svg = chart.svg
20
+ export const modelJson = chart.modelJson
21
+ export const summary = chart.summary
22
+ export const tableHead = chart.tableHead
23
+ export const tableRows = chart.tableRows
24
+ export const legend = chart.legend
25
+ export const height = chart.model.height
26
+ export const chartId = $props.id || `chart-${$uid}`
27
+ export const summaryId = `${chartId}-summary`
28
+ export const className = $props.className || ''
29
+ export const figureClasses = `relative ${className}`.trim()
30
+ export const surfaceClasses = 'relative rounded-control outline-none focus-visible:ring-2 focus-visible:ring-accent'
31
+ export const tooltipClasses = 'pointer-events-none absolute top-2 z-10 min-w-32 rounded-panel bg-inverse px-3 py-2 text-xs text-inverse-ink shadow-lg'
32
+ </script>
33
+
34
+ <script client>
35
+ import { mountChart } from './interaction'
36
+
37
+ const emit = defineEmits(['hover'])
38
+ const chartId = {{ chartId }}
39
+ const model = {!! modelJson !!}
40
+ let dispose = null
41
+
42
+ onMount(() => {
43
+ const root = document.getElementById(chartId)
44
+ if (root) dispose = mountChart(root, model, { onHover: detail => emit('hover', detail) })
45
+ })
46
+
47
+ onDestroy(() => { if (dispose) dispose() })
48
+ </script>
49
+
50
+ <figure id="{{ chartId }}" class="{{ figureClasses }}" data-stx-chart="area" @if(!empty && !loading)tabindex="0" role="group" aria-label="{{ label }}" aria-describedby="{{ summaryId }}"@endif>
51
+ @if(loading)
52
+ <div aria-busy="true"><span class="sr-only">Loading {{ label }}</span><Skeleton variant="rect" :height="height" width="100%" /></div>
53
+ @elseif(empty)
54
+ <EmptyState variant="bare" :title="emptyText" />
55
+ @else
56
+ @if(legend.length)
57
+ <ul class="mb-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-fg-soft" aria-hidden="true" data-stx-chart-legend>
58
+ @foreach(legend as item)
59
+ <li class="inline-flex items-center gap-1.5"><span class="inline-block h-2 w-2 rounded-full" style="background: {{ item.color }}"></span>{{ item.label }}</li>
60
+ @endforeach
61
+ </ul>
62
+ @endif
63
+ <div class="{{ surfaceClasses }}" data-stx-chart-surface>{!! svg !!}</div>
64
+ <div class="{{ tooltipClasses }}" data-stx-chart-tooltip hidden aria-hidden="true"></div>
65
+ <p id="{{ summaryId }}" class="sr-only">{{ summary }}. Use the arrow keys to step through the points.</p>
66
+ <table class="sr-only" data-stx-chart-table>
67
+ <caption>{{ label }}</caption>
68
+ <thead><tr>@foreach(tableHead as heading)<th scope="col">{{ heading }}</th>@endforeach</tr></thead>
69
+ <tbody>
70
+ @foreach(tableRows as row)
71
+ <tr>@foreach(row as cell)<td>{{ cell }}</td>@endforeach</tr>
72
+ @endforeach
73
+ </tbody>
74
+ </table>
75
+ <span class="sr-only" role="status" aria-live="polite" data-stx-chart-live></span>
76
+ @endif
77
+ </figure>
@@ -0,0 +1,77 @@
1
+ <script server>
2
+ import { prepareChart } from './core'
3
+
4
+ /*
5
+ * <BarChart> (stacksjs/stx#2318). The SVG is drawn here, on the server, so
6
+ * the chart shows before any script runs; the client script only lays it out
7
+ * again at its real width and adds the crosshair, tooltip and keyboard.
8
+ *
9
+ * The data and the accessors stay on the server (`serverOnlyProps`): the
10
+ * client gets the prepared model, every label already formatted, so a
11
+ * `formatY` function works and the records are not shipped twice.
12
+ */
13
+ export const serverOnlyProps = ['data', 'x', 'y', 'series', 'formatX', 'formatY', 'colors', 'yDomain']
14
+ const chart = prepareChart('bar', $props)
15
+ export const label = $props.label || 'Chart'
16
+ export const loading = $bool($props.loading)
17
+ export const emptyText = $props.emptyText || 'No data to show yet'
18
+ export const empty = chart.empty
19
+ export const svg = chart.svg
20
+ export const modelJson = chart.modelJson
21
+ export const summary = chart.summary
22
+ export const tableHead = chart.tableHead
23
+ export const tableRows = chart.tableRows
24
+ export const legend = chart.legend
25
+ export const height = chart.model.height
26
+ export const chartId = $props.id || `chart-${$uid}`
27
+ export const summaryId = `${chartId}-summary`
28
+ export const className = $props.className || ''
29
+ export const figureClasses = `relative ${className}`.trim()
30
+ export const surfaceClasses = 'relative rounded-control outline-none focus-visible:ring-2 focus-visible:ring-accent'
31
+ export const tooltipClasses = 'pointer-events-none absolute top-2 z-10 min-w-32 rounded-panel bg-inverse px-3 py-2 text-xs text-inverse-ink shadow-lg'
32
+ </script>
33
+
34
+ <script client>
35
+ import { mountChart } from './interaction'
36
+
37
+ const emit = defineEmits(['hover'])
38
+ const chartId = {{ chartId }}
39
+ const model = {!! modelJson !!}
40
+ let dispose = null
41
+
42
+ onMount(() => {
43
+ const root = document.getElementById(chartId)
44
+ if (root) dispose = mountChart(root, model, { onHover: detail => emit('hover', detail) })
45
+ })
46
+
47
+ onDestroy(() => { if (dispose) dispose() })
48
+ </script>
49
+
50
+ <figure id="{{ chartId }}" class="{{ figureClasses }}" data-stx-chart="bar" @if(!empty && !loading)tabindex="0" role="group" aria-label="{{ label }}" aria-describedby="{{ summaryId }}"@endif>
51
+ @if(loading)
52
+ <div aria-busy="true"><span class="sr-only">Loading {{ label }}</span><Skeleton variant="rect" :height="height" width="100%" /></div>
53
+ @elseif(empty)
54
+ <EmptyState variant="bare" :title="emptyText" />
55
+ @else
56
+ @if(legend.length)
57
+ <ul class="mb-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-fg-soft" aria-hidden="true" data-stx-chart-legend>
58
+ @foreach(legend as item)
59
+ <li class="inline-flex items-center gap-1.5"><span class="inline-block h-2 w-2 rounded-full" style="background: {{ item.color }}"></span>{{ item.label }}</li>
60
+ @endforeach
61
+ </ul>
62
+ @endif
63
+ <div class="{{ surfaceClasses }}" data-stx-chart-surface>{!! svg !!}</div>
64
+ <div class="{{ tooltipClasses }}" data-stx-chart-tooltip hidden aria-hidden="true"></div>
65
+ <p id="{{ summaryId }}" class="sr-only">{{ summary }}. Use the arrow keys to step through the points.</p>
66
+ <table class="sr-only" data-stx-chart-table>
67
+ <caption>{{ label }}</caption>
68
+ <thead><tr>@foreach(tableHead as heading)<th scope="col">{{ heading }}</th>@endforeach</tr></thead>
69
+ <tbody>
70
+ @foreach(tableRows as row)
71
+ <tr>@foreach(row as cell)<td>{{ cell }}</td>@endforeach</tr>
72
+ @endforeach
73
+ </tbody>
74
+ </table>
75
+ <span class="sr-only" role="status" aria-live="polite" data-stx-chart-live></span>
76
+ @endif
77
+ </figure>
@@ -0,0 +1,77 @@
1
+ <script server>
2
+ import { prepareChart } from './core'
3
+
4
+ /*
5
+ * <LineChart> (stacksjs/stx#2318). The SVG is drawn here, on the server, so
6
+ * the chart shows before any script runs; the client script only lays it out
7
+ * again at its real width and adds the crosshair, tooltip and keyboard.
8
+ *
9
+ * The data and the accessors stay on the server (`serverOnlyProps`): the
10
+ * client gets the prepared model, every label already formatted, so a
11
+ * `formatY` function works and the records are not shipped twice.
12
+ */
13
+ export const serverOnlyProps = ['data', 'x', 'y', 'series', 'formatX', 'formatY', 'colors', 'yDomain']
14
+ const chart = prepareChart('line', $props)
15
+ export const label = $props.label || 'Chart'
16
+ export const loading = $bool($props.loading)
17
+ export const emptyText = $props.emptyText || 'No data to show yet'
18
+ export const empty = chart.empty
19
+ export const svg = chart.svg
20
+ export const modelJson = chart.modelJson
21
+ export const summary = chart.summary
22
+ export const tableHead = chart.tableHead
23
+ export const tableRows = chart.tableRows
24
+ export const legend = chart.legend
25
+ export const height = chart.model.height
26
+ export const chartId = $props.id || `chart-${$uid}`
27
+ export const summaryId = `${chartId}-summary`
28
+ export const className = $props.className || ''
29
+ export const figureClasses = `relative ${className}`.trim()
30
+ export const surfaceClasses = 'relative rounded-control outline-none focus-visible:ring-2 focus-visible:ring-accent'
31
+ export const tooltipClasses = 'pointer-events-none absolute top-2 z-10 min-w-32 rounded-panel bg-inverse px-3 py-2 text-xs text-inverse-ink shadow-lg'
32
+ </script>
33
+
34
+ <script client>
35
+ import { mountChart } from './interaction'
36
+
37
+ const emit = defineEmits(['hover'])
38
+ const chartId = {{ chartId }}
39
+ const model = {!! modelJson !!}
40
+ let dispose = null
41
+
42
+ onMount(() => {
43
+ const root = document.getElementById(chartId)
44
+ if (root) dispose = mountChart(root, model, { onHover: detail => emit('hover', detail) })
45
+ })
46
+
47
+ onDestroy(() => { if (dispose) dispose() })
48
+ </script>
49
+
50
+ <figure id="{{ chartId }}" class="{{ figureClasses }}" data-stx-chart="line" @if(!empty && !loading)tabindex="0" role="group" aria-label="{{ label }}" aria-describedby="{{ summaryId }}"@endif>
51
+ @if(loading)
52
+ <div aria-busy="true"><span class="sr-only">Loading {{ label }}</span><Skeleton variant="rect" :height="height" width="100%" /></div>
53
+ @elseif(empty)
54
+ <EmptyState variant="bare" :title="emptyText" />
55
+ @else
56
+ @if(legend.length)
57
+ <ul class="mb-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-fg-soft" aria-hidden="true" data-stx-chart-legend>
58
+ @foreach(legend as item)
59
+ <li class="inline-flex items-center gap-1.5"><span class="inline-block h-2 w-2 rounded-full" style="background: {{ item.color }}"></span>{{ item.label }}</li>
60
+ @endforeach
61
+ </ul>
62
+ @endif
63
+ <div class="{{ surfaceClasses }}" data-stx-chart-surface>{!! svg !!}</div>
64
+ <div class="{{ tooltipClasses }}" data-stx-chart-tooltip hidden aria-hidden="true"></div>
65
+ <p id="{{ summaryId }}" class="sr-only">{{ summary }}. Use the arrow keys to step through the points.</p>
66
+ <table class="sr-only" data-stx-chart-table>
67
+ <caption>{{ label }}</caption>
68
+ <thead><tr>@foreach(tableHead as heading)<th scope="col">{{ heading }}</th>@endforeach</tr></thead>
69
+ <tbody>
70
+ @foreach(tableRows as row)
71
+ <tr>@foreach(row as cell)<td>{{ cell }}</td>@endforeach</tr>
72
+ @endforeach
73
+ </tbody>
74
+ </table>
75
+ <span class="sr-only" role="status" aria-live="polite" data-stx-chart-live></span>
76
+ @endif
77
+ </figure>
@@ -0,0 +1,97 @@
1
+ # Chart
2
+
3
+ Declarative charts drawn as SVG: `<LineChart>`, `<AreaChart>`, `<BarChart>` and `<Sparkline>`. No dependency, no canvas.
4
+
5
+ - **Server-rendered first.** The SVG is drawn on the server, so a chart is visible before any script runs. The client script only lays it out again at the container's real width (a `ResizeObserver`) and adds the crosshair, tooltip and keyboard.
6
+ - **Themed by role tokens.** Series default to the accent, info, success, warning, danger and secondary roles; grid and labels use `line` and `fg-soft`. Dark mode and an app's palette follow without configuration.
7
+ - **Accessible.** Each chart has a name (`label`), a one-sentence summary, a visually hidden data table, and keyboard stepping that announces each point.
8
+
9
+ ## Usage
10
+
11
+ ```stx
12
+ <script server>
13
+ const latency = await Monitor.latency(monitor.id) // [{ checked_at, ms }, ...]
14
+ </script>
15
+
16
+ <AreaChart :data="latency" x="checked_at" y="ms" formatY="duration" label="Response time" :height="200" />
17
+ ```
18
+
19
+ That is the StatusHQ monitor latency chart: one tag instead of a page of scale and path math.
20
+
21
+ ### Several series
22
+
23
+ ```stx
24
+ <LineChart
25
+ :data="usage"
26
+ x="day"
27
+ :series="[{ key: 'requests', label: 'Requests' }, { key: 'errors', label: 'Errors', color: 'var(--stx-danger)' }]"
28
+ label="Requests and errors per day"
29
+ @hover="showDetail"
30
+ />
31
+ ```
32
+
33
+ ### Bars
34
+
35
+ ```stx
36
+ <BarChart :data="spendByMonth" x="month" y="total" formatY="currency" label="Spend per month" />
37
+ ```
38
+
39
+ `x` values that are strings make a band axis; ISO dates are labelled as days.
40
+
41
+ ### Sparkline
42
+
43
+ ```stx
44
+ <Sparkline :data="[120, 180, 150, 210, 96, 240]" label="Requests this week" area />
45
+ ```
46
+
47
+ A plain array of numbers is plotted against its index. `<StatCard :series="...">` draws one beside its value.
48
+
49
+ ## Props
50
+
51
+ Shared by `LineChart`, `AreaChart` and `BarChart`:
52
+
53
+ | Prop | Type | Default | Description |
54
+ |------|------|---------|-------------|
55
+ | `data` | `object[] \| number[]` | - | The records, or numbers plotted by index |
56
+ | `x` | `string \| (d, i) => any` | `'x'` | Key or accessor for x |
57
+ | `y` | `string \| function \| string[]` | `'y'` | Key or accessor for y; an array of keys draws one series per key |
58
+ | `series` | `Array<string \| { key, label, color }>` | - | Series with labels and colours; overrides `y` |
59
+ | `height` | `number` | `240` | Pixel height |
60
+ | `xType` | `'time' \| 'linear' \| 'band'` | inferred | `band` for bars and string x, `time` for dates, else `linear` |
61
+ | `yDomain` | `[min, max]` | from data | A `null` end is taken from the data; bars and areas include zero |
62
+ | `curve` | `'monotone' \| 'linear' \| 'step'` | `'monotone'` | Line interpolation (`monotone` never overshoots a point) |
63
+ | `colors` | `string[]` | role tokens | Series colours |
64
+ | `formatX` | `(value, index) => string` | dates by span, numbers by locale | Tick and tooltip labels for x |
65
+ | `formatY` | `function \| 'number' \| 'percent' \| 'duration' \| 'bytes' \| 'currency'` | locale number | Tick and tooltip labels for y; a string uses the StatCard formats |
66
+ | `label` | `string` | `'Chart'` | Accessible name, and the caption of the data table |
67
+ | `xLabel` | `string` | `'Time'` / `'X'` | Header of the x column in the data table |
68
+ | `locale` | `string` | `'en-US'` | Number and date locale |
69
+ | `timeZone` | `string` | `'UTC'` | Zone for time labels, so the server and browser agree |
70
+ | `ticks` | `number` | `5` | Approximate ticks per axis |
71
+ | `loading` | `boolean` | `false` | Show a skeleton at the chart's height |
72
+ | `emptyText` | `string` | `'No data to show yet'` | Shown through `EmptyState` for an empty array |
73
+ | `id`, `className` | `string` | - | |
74
+
75
+ `Sparkline` takes `data`, `x`, `y`, `label`, `height` (32), `area`, `curve`, `colors`, `formatY` and `className`.
76
+
77
+ Formatter and accessor functions run on the server, so pass them as bound props (`:formatX="d => ..."`). The records and accessors are listed in `serverOnlyProps`: the client receives only the prepared model, with every label already formatted.
78
+
79
+ ## Events
80
+
81
+ | Event | Payload |
82
+ |------|---------|
83
+ | `hover` | `{ index, datum, x, values: [{ series, value, label }] }` for the point under the pointer or keyboard focus, `null` when it leaves |
84
+
85
+ ## Keyboard
86
+
87
+ The chart is a single tab stop. Arrow keys step point to point, Home and End jump to the ends, Escape clears. Each step is announced through a polite live region ("Nov 3, 2026: Requests 150, Errors 8").
88
+
89
+ ## States
90
+
91
+ - **Empty**: an empty array renders `EmptyState` with `emptyText`.
92
+ - **Loading**: `loading` renders a `Skeleton` at the chart's height.
93
+ - **Gaps**: a `null` or missing y breaks the line; a point with no neighbour is drawn as a dot, so a single datum still shows.
94
+
95
+ ## Out of scope
96
+
97
+ Pie, donut, scatter, candlestick and map charts; canvas or WebGL rendering; native-screen rendering.
@@ -0,0 +1,29 @@
1
+ <script server cache>
2
+ import { prepareChart } from './core'
3
+
4
+ /*
5
+ * <Sparkline> (stacksjs/stx#2318): a word-sized trend line with no axes and
6
+ * no script. `data` is an array of numbers, or records with `x` and `y`
7
+ * accessors like the other charts. It is an image to assistive technology,
8
+ * named by `label` and a sentence: "from 120 to 180, low 96, high 210".
9
+ */
10
+ const chart = prepareChart('sparkline', {
11
+ ...$props,
12
+ height: $num($props.height, 32),
13
+ area: $bool($props.area),
14
+ }, $num($props.width, 120))
15
+ export const label = $props.label || 'Trend'
16
+ export const empty = chart.empty
17
+ export const description = `${label}: ${chart.summary.replace(/^[^:]*:\s*/, '')}`
18
+ export const height = chart.model.height
19
+ export const className = $props.className || ''
20
+ export const svg = chart.empty ? '' : chart.svg
21
+ export const color = chart.model.series[0] ? chart.model.series[0].color : ''
22
+ export const sparkClasses = `block ${className}`.trim()
23
+ </script>
24
+
25
+ @if(empty)
26
+ <span class="{{ sparkClasses }}" style="height: {{ height }}px" role="img" aria-label="{{ label }}: no data" data-stx-sparkline data-empty="true"></span>
27
+ @else
28
+ <span class="{{ sparkClasses }}" role="img" aria-label="{{ description }}" data-stx-sparkline>{!! svg !!}</span>
29
+ @endif