@lostgradient/cinder 0.22.0 → 0.23.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/CHANGELOG.md +31 -0
- package/components.json +1 -1
- package/dist/_internal/chart/chart-bar-model.d.ts +24 -0
- package/dist/_internal/chart/chart-cartesian-model.d.ts +16 -0
- package/dist/_internal/chart/chart-layout.d.ts +23 -0
- package/dist/_internal/chart/chart-model-utilities.d.ts +157 -0
- package/dist/_internal/chart/chart-scale.d.ts +37 -0
- package/dist/_internal/chart/chart-utilities.d.ts +7 -164
- package/dist/_internal/chart/heatmap-utilities.d.ts +5 -4
- package/dist/components/_internal/chart-tooltip.css +21 -0
- package/dist/components/_internal/chart-tooltip.svelte.d.ts +11 -0
- package/dist/components/approval-card/index.js +5 -5
- package/dist/components/area-chart/area-chart.css +27 -23
- package/dist/components/area-chart/area-chart.schema.js +38 -1
- package/dist/components/area-chart/area-chart.types.d.ts +6 -2
- package/dist/components/area-chart/index.js +1589 -768
- package/dist/components/badge/badge.css +2 -2
- package/dist/components/badge/badge.schema.js +2 -2
- package/dist/components/badge/badge.types.d.ts +3 -3
- package/dist/components/badge/index.js +4 -4
- package/dist/components/bar-chart/bar-chart.css +27 -21
- package/dist/components/bar-chart/bar-chart.schema.js +38 -1
- package/dist/components/bar-chart/bar-chart.types.d.ts +7 -3
- package/dist/components/bar-chart/index.js +1544 -740
- package/dist/components/chart.types.d.ts +98 -2
- package/dist/components/json-schema-editor/index.js +4 -4
- package/dist/components/line-chart/index.js +1587 -785
- package/dist/components/line-chart/line-chart.css +25 -24
- package/dist/components/line-chart/line-chart.schema.js +38 -1
- package/dist/components/line-chart/line-chart.types.d.ts +6 -2
- package/dist/components/matrix-chart/index.js +1038 -429
- package/dist/components/matrix-chart/matrix-chart.css +12 -6
- package/dist/components/matrix-chart/matrix-chart.schema.js +26 -1
- package/dist/components/matrix-chart/matrix-chart.types.d.ts +5 -1
- package/dist/components/payload-inspector/index.js +4 -4
- package/dist/components/run-step-timeline/index.js +6 -6
- package/dist/components/sparkbar/index.js +1291 -4
- package/dist/components/sparkbar/sparkbar.css +5 -4
- package/dist/components/sparkbar/sparkbar.schema.js +26 -1
- package/dist/components/sparkbar/sparkbar.types.d.ts +5 -0
- package/dist/components/spectrogram/index.js +1076 -437
- package/dist/components/spectrogram/spectrogram.css +7 -6
- package/dist/components/spectrogram/spectrogram.schema.js +26 -1
- package/dist/components/spectrogram/spectrogram.types.d.ts +5 -1
- package/dist/components/spectrum-chart/index.js +1037 -423
- package/dist/components/spectrum-chart/spectrum-chart.css +8 -7
- package/dist/components/spectrum-chart/spectrum-chart.schema.js +26 -1
- package/dist/components/spectrum-chart/spectrum-chart.types.d.ts +5 -1
- package/dist/components/statistic/index.js +1284 -2
- package/dist/components/statistic/statistic.css +6 -5
- package/dist/components/statistic/statistic.schema.js +26 -1
- package/dist/components/statistic/statistic.types.d.ts +5 -0
- package/dist/components/statistic-group/index.js +1284 -2
- package/dist/components/waveform/index.js +1004 -404
- package/dist/components/waveform/waveform.css +8 -7
- package/dist/components/waveform/waveform.schema.js +26 -1
- package/dist/components/waveform/waveform.types.d.ts +5 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17730 -16540
- package/dist/server/components/approval-card/index.js +3 -3
- package/dist/server/components/area-chart/index.js +3 -3
- package/dist/server/components/badge/index.js +2 -2
- package/dist/server/components/bar-chart/index.js +3 -3
- package/dist/server/components/json-schema-editor/index.js +2 -2
- package/dist/server/components/line-chart/index.js +3 -3
- package/dist/server/components/matrix-chart/index.js +3 -3
- package/dist/server/components/payload-inspector/index.js +3 -3
- package/dist/server/components/run-step-timeline/index.js +2 -2
- package/dist/server/components/sparkbar/index.js +3 -2
- package/dist/server/components/spectrogram/index.js +3 -3
- package/dist/server/components/spectrum-chart/index.js +2 -2
- package/dist/server/components/statistic/index.js +4 -3
- package/dist/server/components/statistic-group/index.js +4 -3
- package/dist/server/components/waveform/index.js +2 -2
- package/dist/server/index.js +21 -21
- package/dist/server/{index.server-3dkwzkd3.js → index.server-10r7yf13.js} +110 -27
- package/dist/server/{index.server-93943z3e.js → index.server-151dt1tx.js} +1 -1
- package/dist/server/{index.server-pp2n6def.js → index.server-2y0xz53g.js} +37 -14
- package/dist/server/{index.server-bd8rcgf0.js → index.server-4hvjet4z.js} +1 -1
- package/dist/server/{index.server-bsm39gpy.js → index.server-5d83fkyg.js} +75 -21
- package/dist/server/{index.server-4wweyb2e.js → index.server-8dh2rtnc.js} +1 -1
- package/dist/server/{index.server-abqbstkt.js → index.server-9gj583qs.js} +41 -14
- package/dist/server/{index.server-2nmwsacy.js → index.server-9scm7zf9.js} +4 -4
- package/dist/server/{index.server-5j6jv7rm.js → index.server-9vwxyy06.js} +108 -29
- package/dist/server/{index.server-abjsjsw8.js → index.server-afpjvfz1.js} +111 -35
- package/dist/server/{index.server-86sw5ea6.js → index.server-dw9bz17h.js} +4 -4
- package/dist/server/{index.server-d26jzn2m.js → index.server-en31rprd.js} +3 -3
- package/dist/server/{index.server-dx58qant.js → index.server-f3a0ecqg.js} +72 -9
- package/dist/server/{index.server-d63pwytk.js → index.server-kz8aeeq5.js} +18 -10
- package/dist/server/index.server-mmmrgvyd.js +1274 -0
- package/dist/server/{index.server-1221p7e4.js → index.server-scahngwv.js} +13 -1
- package/dist/server/{index.server-nj8kk5bv.js → index.server-t73q59c1.js} +1 -1
- package/dist/server/{index.server-5schb2vt.js → index.server-tdrncj5e.js} +16 -6
- package/dist/server/{index.server-wm8957be.js → index.server-veqke4sq.js} +10 -1
- package/dist/server/{index.server-fphvzcfb.js → index.server-wqajghn9.js} +1 -1
- package/dist/server/{index.server-yd9shwqq.js → index.server-zjcjzcv6.js} +1 -1
- package/package.json +1 -1
- package/src/_internal/chart/chart-bar-model.ts +330 -0
- package/src/_internal/chart/chart-cartesian-model.ts +450 -0
- package/src/_internal/chart/chart-interaction.svelte.ts +25 -6
- package/src/_internal/chart/chart-layout.ts +348 -0
- package/src/_internal/chart/chart-model-utilities.ts +357 -0
- package/src/_internal/chart/chart-scale.ts +487 -0
- package/src/_internal/chart/chart-utilities.ts +22 -1078
- package/src/_internal/chart/heatmap-utilities.ts +21 -17
- package/src/components/_internal/chart-tooltip.css +21 -0
- package/src/components/_internal/chart-tooltip.svelte +44 -0
- package/src/components/approval-card/approval-card.svelte +1 -1
- package/src/components/area-chart/area-chart.css +27 -23
- package/src/components/area-chart/area-chart.examples.json +1 -1
- package/src/components/area-chart/area-chart.schema.json +37 -0
- package/src/components/area-chart/area-chart.schema.ts +40 -0
- package/src/components/area-chart/area-chart.svelte +103 -35
- package/src/components/area-chart/area-chart.types.ts +7 -1
- package/src/components/badge/badge.css +2 -2
- package/src/components/badge/badge.schema.json +1 -1
- package/src/components/badge/badge.schema.ts +1 -1
- package/src/components/badge/badge.svelte +2 -2
- package/src/components/badge/badge.types.ts +3 -3
- package/src/components/bar-chart/bar-chart.css +27 -21
- package/src/components/bar-chart/bar-chart.schema.json +37 -0
- package/src/components/bar-chart/bar-chart.schema.ts +40 -0
- package/src/components/bar-chart/bar-chart.svelte +94 -33
- package/src/components/bar-chart/bar-chart.types.ts +9 -2
- package/src/components/chart.types.ts +112 -2
- package/src/components/line-chart/line-chart.css +25 -24
- package/src/components/line-chart/line-chart.examples.json +1 -1
- package/src/components/line-chart/line-chart.schema.json +37 -0
- package/src/components/line-chart/line-chart.schema.ts +40 -0
- package/src/components/line-chart/line-chart.svelte +95 -40
- package/src/components/line-chart/line-chart.types.ts +7 -1
- package/src/components/matrix-chart/matrix-chart.css +12 -6
- package/src/components/matrix-chart/matrix-chart.schema.json +25 -0
- package/src/components/matrix-chart/matrix-chart.schema.ts +25 -0
- package/src/components/matrix-chart/matrix-chart.svelte +30 -12
- package/src/components/matrix-chart/matrix-chart.types.ts +5 -1
- package/src/components/run-step-timeline/run-step-timeline.svelte +2 -2
- package/src/components/sparkbar/sparkbar.css +5 -4
- package/src/components/sparkbar/sparkbar.schema.json +25 -0
- package/src/components/sparkbar/sparkbar.schema.ts +26 -0
- package/src/components/sparkbar/sparkbar.svelte +8 -1
- package/src/components/sparkbar/sparkbar.types.ts +5 -0
- package/src/components/spectrogram/spectrogram.css +7 -6
- package/src/components/spectrogram/spectrogram.schema.json +25 -0
- package/src/components/spectrogram/spectrogram.schema.ts +25 -0
- package/src/components/spectrogram/spectrogram.svelte +73 -28
- package/src/components/spectrogram/spectrogram.types.ts +5 -1
- package/src/components/spectrum-chart/spectrum-chart.css +8 -7
- package/src/components/spectrum-chart/spectrum-chart.schema.json +25 -0
- package/src/components/spectrum-chart/spectrum-chart.schema.ts +26 -0
- package/src/components/spectrum-chart/spectrum-chart.svelte +38 -12
- package/src/components/spectrum-chart/spectrum-chart.types.ts +5 -1
- package/src/components/statistic/statistic.css +6 -5
- package/src/components/statistic/statistic.schema.json +25 -0
- package/src/components/statistic/statistic.schema.ts +26 -0
- package/src/components/statistic/statistic.svelte +6 -1
- package/src/components/statistic/statistic.types.ts +5 -0
- package/src/components/waveform/waveform.css +8 -7
- package/src/components/waveform/waveform.schema.json +25 -0
- package/src/components/waveform/waveform.schema.ts +26 -0
- package/src/components/waveform/waveform.svelte +16 -3
- package/src/components/waveform/waveform.types.ts +5 -1
- package/src/index.ts +8 -0
- package/dist/server/index.server-6vbpz6dd.js +0 -690
|
@@ -45,6 +45,31 @@
|
|
|
45
45
|
"type": "string",
|
|
46
46
|
"description": "Custom data table caption; falls back to `label`."
|
|
47
47
|
},
|
|
48
|
+
"theme": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"properties": {
|
|
51
|
+
"foreground": {
|
|
52
|
+
"type": "string"
|
|
53
|
+
},
|
|
54
|
+
"muted": {
|
|
55
|
+
"type": "string"
|
|
56
|
+
},
|
|
57
|
+
"grid": {
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"background": {
|
|
61
|
+
"type": "string"
|
|
62
|
+
},
|
|
63
|
+
"palette": {
|
|
64
|
+
"type": "array",
|
|
65
|
+
"items": {
|
|
66
|
+
"type": "string"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"additionalProperties": false,
|
|
71
|
+
"description": "Partial visual theme override. Omitted fields inherit the surrounding application."
|
|
72
|
+
},
|
|
48
73
|
"class": {
|
|
49
74
|
"type": "string",
|
|
50
75
|
"description": "Custom class applied to the root element."
|
|
@@ -47,6 +47,32 @@ const schema = {
|
|
|
47
47
|
type: 'string',
|
|
48
48
|
description: 'Custom data table caption; falls back to `label`.',
|
|
49
49
|
},
|
|
50
|
+
theme: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {
|
|
53
|
+
foreground: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
},
|
|
56
|
+
muted: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
},
|
|
59
|
+
grid: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
},
|
|
62
|
+
background: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
},
|
|
65
|
+
palette: {
|
|
66
|
+
type: 'array',
|
|
67
|
+
items: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
additionalProperties: false,
|
|
73
|
+
description:
|
|
74
|
+
'Partial visual theme override. Omitted fields inherit the surrounding application.',
|
|
75
|
+
},
|
|
50
76
|
class: {
|
|
51
77
|
type: 'string',
|
|
52
78
|
description: 'Custom class applied to the root element.',
|
|
@@ -3,17 +3,14 @@ export {};
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
-
import {
|
|
6
|
+
import { onMount } from 'svelte';
|
|
7
|
+
import { chartPaletteColor, createChartGeometry, dataTableClass, formatNumericValue, observeChartFontLoading, resolveChartTheme, } from '../../_internal/chart/chart-utilities.ts';
|
|
7
8
|
import { classNames } from '../../utilities/class-names.ts';
|
|
8
9
|
import { useResizeObserver } from '../../utilities/use-resize-observer.svelte.ts';
|
|
9
|
-
let { label, description, bins, height = 160, loading = false, dataTableVisibility = 'screen-reader-only', dataTableCaption, class: customClassName, empty, loadingContent, id, ...rest } = $props();
|
|
10
|
+
let { label, description, bins, height = 160, loading = false, dataTableVisibility = 'screen-reader-only', dataTableCaption, theme, class: customClassName, empty, loadingContent, id, ...rest } = $props();
|
|
10
11
|
const generatedId = $props.id();
|
|
11
12
|
const rootId = $derived(id ?? generatedId);
|
|
12
13
|
const descriptionId = $derived(description ? `${rootId}-description` : undefined);
|
|
13
|
-
const marginTop = 8;
|
|
14
|
-
const marginRight = 8;
|
|
15
|
-
const marginBottom = 32;
|
|
16
|
-
const marginLeft = 40;
|
|
17
14
|
let measuredWidth = $state(400);
|
|
18
15
|
const observeResize = useResizeObserver((entries) => {
|
|
19
16
|
const entry = entries[0];
|
|
@@ -22,9 +19,17 @@ const observeResize = useResizeObserver((entries) => {
|
|
|
22
19
|
if (entry && entry.contentRect.width > 0)
|
|
23
20
|
measuredWidth = entry.contentRect.width;
|
|
24
21
|
});
|
|
25
|
-
const plotWidth = $derived(Math.max(1, measuredWidth - marginLeft - marginRight));
|
|
26
|
-
const plotHeight = $derived(Math.max(1, height - marginTop - marginBottom));
|
|
27
22
|
const isEmpty = $derived(bins.length === 0);
|
|
23
|
+
const resolvedTheme = $derived(resolveChartTheme(theme));
|
|
24
|
+
let rootElement = $state();
|
|
25
|
+
let measureText = $state(false);
|
|
26
|
+
let measurementVersion = $state(0);
|
|
27
|
+
onMount(() => {
|
|
28
|
+
measureText = true;
|
|
29
|
+
return observeChartFontLoading(() => {
|
|
30
|
+
measurementVersion += 1;
|
|
31
|
+
});
|
|
32
|
+
});
|
|
28
33
|
// Spectrum magnitudes are linear non-negative. Coerce each bin's value to a
|
|
29
34
|
// finite, non-negative number so a stray NaN/Infinity/negative can't break the
|
|
30
35
|
// axis domain or invert bar geometry.
|
|
@@ -49,6 +54,21 @@ const yTicks = $derived.by(() => {
|
|
|
49
54
|
return [0];
|
|
50
55
|
return Array.from({ length: tickCount }, (_, index) => (maxValue * index) / (tickCount - 1));
|
|
51
56
|
});
|
|
57
|
+
// Feed the actual guide labels into the shared geometry calculator so long
|
|
58
|
+
// numeric/frequency labels receive enough room without fixed margins.
|
|
59
|
+
const maxXLabels = 8;
|
|
60
|
+
const xLabelStep = $derived(Math.max(1, Math.ceil(bins.length / maxXLabels)));
|
|
61
|
+
const xTickLabels = $derived(bins.filter((_, index) => index % xLabelStep === 0).map((bin) => bin.label));
|
|
62
|
+
const yTickLabels = $derived(yTicks.map((tick, index) => formatNumericValue(tick, undefined, undefined, { index })));
|
|
63
|
+
const geometry = $derived(createChartGeometry(measuredWidth, height, {
|
|
64
|
+
xTickLabels,
|
|
65
|
+
yTickLabels,
|
|
66
|
+
measureText,
|
|
67
|
+
measurementElement: rootElement,
|
|
68
|
+
measurementVersion,
|
|
69
|
+
}));
|
|
70
|
+
const plotWidth = $derived(geometry.plotWidth);
|
|
71
|
+
const plotHeight = $derived(geometry.plotHeight);
|
|
52
72
|
function scaleY(value) {
|
|
53
73
|
if (maxValue <= 0)
|
|
54
74
|
return plotHeight;
|
|
@@ -71,19 +91,22 @@ const spectrumBars = $derived.by(() => {
|
|
|
71
91
|
};
|
|
72
92
|
});
|
|
73
93
|
});
|
|
74
|
-
// Show only a subset of x-axis labels to avoid clutter
|
|
75
|
-
const maxXLabels = 8;
|
|
76
|
-
const xLabelStep = $derived(Math.max(1, Math.ceil(bins.length / maxXLabels)));
|
|
77
94
|
const hasDataTable = $derived(dataTableVisibility !== 'hidden');
|
|
78
95
|
</script>
|
|
79
96
|
|
|
80
97
|
<figure
|
|
81
98
|
{...rest}
|
|
82
99
|
{@attach observeResize}
|
|
100
|
+
bind:this={rootElement}
|
|
83
101
|
id={rootId}
|
|
84
102
|
class={classNames('cinder-spectrum-chart', customClassName)}
|
|
85
103
|
aria-label={label}
|
|
86
104
|
aria-describedby={descriptionId}
|
|
105
|
+
style:--_cinder-chart-foreground={resolvedTheme.foreground}
|
|
106
|
+
style:--_cinder-chart-muted={resolvedTheme.muted}
|
|
107
|
+
style:--_cinder-chart-grid={resolvedTheme.grid}
|
|
108
|
+
style:--_cinder-chart-background={resolvedTheme.background}
|
|
109
|
+
style:--_cinder-chart-series-color={chartPaletteColor(0, resolvedTheme.palette)}
|
|
87
110
|
>
|
|
88
111
|
{#if description}
|
|
89
112
|
<p id={descriptionId} class="cinder-spectrum-chart__description">{description}</p>
|
|
@@ -115,7 +138,7 @@ const hasDataTable = $derived(dataTableVisibility !== 'hidden');
|
|
|
115
138
|
overlay would have a stray baseline grid line and ticks drawn under it
|
|
116
139
|
(yTicks falls back to [0] when there is no data). -->
|
|
117
140
|
{#if !loading && !isEmpty}
|
|
118
|
-
<g transform={`translate(${marginLeft}, ${marginTop})`}>
|
|
141
|
+
<g transform={`translate(${geometry.marginLeft}, ${geometry.marginTop})`}>
|
|
119
142
|
<!-- Y-axis ticks -->
|
|
120
143
|
{#each yTicks as tick, index (index)}
|
|
121
144
|
<text
|
|
@@ -124,6 +147,7 @@ const hasDataTable = $derived(dataTableVisibility !== 'hidden');
|
|
|
124
147
|
y={scaleY(tick)}
|
|
125
148
|
text-anchor="end"
|
|
126
149
|
dominant-baseline="middle"
|
|
150
|
+
fill={resolvedTheme.muted}
|
|
127
151
|
>{formatNumericValue(tick, undefined, undefined, { index })}</text
|
|
128
152
|
>
|
|
129
153
|
<line
|
|
@@ -133,6 +157,7 @@ const hasDataTable = $derived(dataTableVisibility !== 'hidden');
|
|
|
133
157
|
y1={scaleY(tick)}
|
|
134
158
|
y2={scaleY(tick)}
|
|
135
159
|
aria-hidden="true"
|
|
160
|
+
stroke={resolvedTheme.grid}
|
|
136
161
|
/>
|
|
137
162
|
{/each}
|
|
138
163
|
<!-- Frequency bars -->
|
|
@@ -145,6 +170,7 @@ const hasDataTable = $derived(dataTableVisibility !== 'hidden');
|
|
|
145
170
|
height={bar.barHeight}
|
|
146
171
|
aria-hidden="true"
|
|
147
172
|
data-cinder-bin={bar.label}
|
|
173
|
+
fill={chartPaletteColor(0, resolvedTheme.palette)}
|
|
148
174
|
/>
|
|
149
175
|
{/each}
|
|
150
176
|
<!-- X-axis frequency labels (sampled to avoid overlap) -->
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import type { ChartDataTableVisibility } from '../chart.types.ts';
|
|
3
|
+
import type { ChartDataTableVisibility, ChartTheme, ChartThemeSchema } from '../chart.types.ts';
|
|
4
4
|
|
|
5
5
|
/** @schemaObject */
|
|
6
6
|
export type SpectrumBin = {
|
|
@@ -25,6 +25,8 @@ export type SpectrumChartProps = Omit<HTMLAttributes<HTMLElement>, 'class'> & {
|
|
|
25
25
|
dataTableVisibility?: ChartDataTableVisibility;
|
|
26
26
|
/** Custom data table caption; falls back to `label`. */
|
|
27
27
|
dataTableCaption?: string;
|
|
28
|
+
/** Partial visual theme override. Omitted fields inherit the surrounding application. */
|
|
29
|
+
theme?: ChartTheme;
|
|
28
30
|
/** Custom class applied to the root element. */
|
|
29
31
|
class?: string;
|
|
30
32
|
/** Snippet rendered when there are no bins. */
|
|
@@ -48,6 +50,8 @@ export type SpectrumChartSchemaProps = {
|
|
|
48
50
|
dataTableVisibility?: ChartDataTableVisibility;
|
|
49
51
|
/** Custom data table caption; falls back to `label`. */
|
|
50
52
|
dataTableCaption?: string;
|
|
53
|
+
/** Partial visual theme override. Omitted fields inherit the surrounding application. */
|
|
54
|
+
theme?: ChartThemeSchema;
|
|
51
55
|
/** Custom class applied to the root element. */
|
|
52
56
|
class?: string;
|
|
53
57
|
};
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
grid-template-rows: auto auto auto;
|
|
15
15
|
row-gap: var(--cinder-statistic-row-gap, var(--cinder-space-1, 0.25rem));
|
|
16
16
|
align-items: start;
|
|
17
|
-
color: var(--
|
|
17
|
+
color: var(--_cinder-chart-foreground, currentColor);
|
|
18
|
+
background: var(--_cinder-chart-background, transparent);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
.cinder-statistic[data-cinder-has-icon] {
|
|
@@ -29,12 +30,12 @@
|
|
|
29
30
|
display: inline-flex;
|
|
30
31
|
align-items: center;
|
|
31
32
|
justify-content: center;
|
|
32
|
-
color: var(--
|
|
33
|
+
color: var(--_cinder-chart-muted, currentColor);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
.cinder-statistic__label {
|
|
36
37
|
font-size: var(--cinder-statistic-label-font-size, var(--cinder-text-sm));
|
|
37
|
-
color: var(--
|
|
38
|
+
color: var(--_cinder-chart-muted, currentColor);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
.cinder-statistic[data-cinder-has-icon] .cinder-statistic__label {
|
|
@@ -72,10 +73,10 @@
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
.cinder-statistic__change[data-cinder-direction='neutral'] {
|
|
75
|
-
color: var(--
|
|
76
|
+
color: var(--_cinder-chart-muted, currentColor);
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
.cinder-statistic__change-description {
|
|
79
|
-
color: var(--
|
|
80
|
+
color: var(--_cinder-chart-muted, currentColor);
|
|
80
81
|
}
|
|
81
82
|
}
|
|
@@ -17,6 +17,31 @@
|
|
|
17
17
|
],
|
|
18
18
|
"description": "The statistic. Strings rendered verbatim; numbers formatted via formatNumber."
|
|
19
19
|
},
|
|
20
|
+
"theme": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"properties": {
|
|
23
|
+
"foreground": {
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"muted": {
|
|
27
|
+
"type": "string"
|
|
28
|
+
},
|
|
29
|
+
"grid": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
},
|
|
32
|
+
"background": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
},
|
|
35
|
+
"palette": {
|
|
36
|
+
"type": "array",
|
|
37
|
+
"items": {
|
|
38
|
+
"type": "string"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"additionalProperties": false,
|
|
43
|
+
"description": "Partial visual theme override. Omitted fields inherit the surrounding application."
|
|
44
|
+
},
|
|
20
45
|
"valueLocale": {
|
|
21
46
|
"type": "string",
|
|
22
47
|
"description": "Locale forwarded to formatNumber. Defaults to the nearest LocaleProvider locale, then en-US."
|
|
@@ -19,6 +19,32 @@ const schema = {
|
|
|
19
19
|
],
|
|
20
20
|
description: 'The statistic. Strings rendered verbatim; numbers formatted via formatNumber.',
|
|
21
21
|
},
|
|
22
|
+
theme: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
foreground: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
},
|
|
28
|
+
muted: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
},
|
|
31
|
+
grid: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
},
|
|
34
|
+
background: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
},
|
|
37
|
+
palette: {
|
|
38
|
+
type: 'array',
|
|
39
|
+
items: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
additionalProperties: false,
|
|
45
|
+
description:
|
|
46
|
+
'Partial visual theme override. Omitted fields inherit the surrounding application.',
|
|
47
|
+
},
|
|
22
48
|
valueLocale: {
|
|
23
49
|
type: 'string',
|
|
24
50
|
description:
|
|
@@ -3,6 +3,7 @@ export {};
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
+
import { resolveChartTheme } from '../../_internal/chart/chart-utilities.ts';
|
|
6
7
|
import { getLocaleContext } from '../../_internal/locale-context.ts';
|
|
7
8
|
import { classNames } from '../../utilities/class-names.ts';
|
|
8
9
|
import { formatNumber } from '../../utilities/format-number.ts';
|
|
@@ -10,7 +11,7 @@ import { formatNumber } from '../../utilities/format-number.ts';
|
|
|
10
11
|
// instance. Pass an explicit `id` prop to control the base when a specific value
|
|
11
12
|
// is required (e.g. for testing or when a stable server-rendered id is needed).
|
|
12
13
|
const generatedId = $props.id();
|
|
13
|
-
let { label, value, change, icon, valueFormatOptions, valueLocale, class: customClassName, id, ...rest } = $props();
|
|
14
|
+
let { label, value, change, icon, theme, valueFormatOptions, valueLocale, class: customClassName, id, ...rest } = $props();
|
|
14
15
|
const localeContext = getLocaleContext();
|
|
15
16
|
const stableId = $derived(id ?? generatedId);
|
|
16
17
|
const labelId = $derived(`${stableId}-label`);
|
|
@@ -31,6 +32,7 @@ const changeAccessibleText = $derived.by(() => {
|
|
|
31
32
|
return `decreased by ${change.value}${suffix}`;
|
|
32
33
|
return `no change, ${change.value}${suffix}`;
|
|
33
34
|
});
|
|
35
|
+
const resolvedTheme = $derived(resolveChartTheme(theme));
|
|
34
36
|
</script>
|
|
35
37
|
|
|
36
38
|
<div
|
|
@@ -40,6 +42,9 @@ const changeAccessibleText = $derived.by(() => {
|
|
|
40
42
|
role="group"
|
|
41
43
|
aria-labelledby={`${labelId} ${valueId}`}
|
|
42
44
|
data-cinder-has-icon={icon ? '' : undefined}
|
|
45
|
+
style:--_cinder-chart-foreground={resolvedTheme.foreground}
|
|
46
|
+
style:--_cinder-chart-muted={resolvedTheme.muted}
|
|
47
|
+
style:--_cinder-chart-background={resolvedTheme.background}
|
|
43
48
|
>
|
|
44
49
|
{#if icon}
|
|
45
50
|
<span class="cinder-statistic__icon" aria-hidden="true">{@render icon()}</span>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ChartTheme, ChartThemeSchema } from '../chart.types.ts';
|
|
3
4
|
/** Direction of a stat change indicator. */
|
|
4
5
|
export type StatisticChangeDirection = 'up' | 'down' | 'neutral';
|
|
5
6
|
/** Data for the optional change indicator rendered below the stat value. */
|
|
@@ -24,6 +25,8 @@ export type StatisticProps = Omit<HTMLAttributes<HTMLDivElement>, 'class'> & {
|
|
|
24
25
|
value: string | number;
|
|
25
26
|
/** Optional change indicator with direction and accessible wording. */
|
|
26
27
|
change?: StatisticChange;
|
|
28
|
+
/** Partial visual theme override. Omitted fields inherit the surrounding application. */
|
|
29
|
+
theme?: ChartTheme;
|
|
27
30
|
/** Optional leading icon snippet (decorative — wrapper is aria-hidden). */
|
|
28
31
|
icon?: Snippet;
|
|
29
32
|
/** Intl.NumberFormat options applied only when `value` is a number. */
|
|
@@ -42,6 +45,8 @@ export interface StatisticSchemaProps {
|
|
|
42
45
|
value: string | number;
|
|
43
46
|
/** Optional change indicator with direction and accessible wording. */
|
|
44
47
|
change?: StatisticChange;
|
|
48
|
+
/** Partial visual theme override. Omitted fields inherit the surrounding application. */
|
|
49
|
+
theme?: ChartThemeSchema;
|
|
45
50
|
/** Optional leading icon snippet (decorative — wrapper is aria-hidden). */
|
|
46
51
|
icon?: Snippet;
|
|
47
52
|
/** Intl.NumberFormat options applied only when `value` is a number. */
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
.cinder-waveform {
|
|
4
4
|
display: grid;
|
|
5
5
|
gap: var(--cinder-space-2);
|
|
6
|
-
color: var(--
|
|
6
|
+
color: var(--_cinder-chart-foreground, currentColor);
|
|
7
|
+
background: var(--_cinder-chart-background, transparent);
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
.cinder-waveform__description {
|
|
10
11
|
margin: 0;
|
|
11
|
-
color: var(--
|
|
12
|
+
color: var(--_cinder-chart-muted, currentColor);
|
|
12
13
|
font-size: var(--cinder-text-sm);
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -23,13 +24,13 @@
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
.cinder-waveform__baseline {
|
|
26
|
-
stroke: var(--
|
|
27
|
+
stroke: var(--_cinder-chart-grid, currentColor);
|
|
27
28
|
stroke-width: 1;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
.cinder-waveform__path {
|
|
31
32
|
fill: none;
|
|
32
|
-
stroke: var(--
|
|
33
|
+
stroke: var(--_cinder-chart-series-color, currentColor);
|
|
33
34
|
stroke-width: 1.5;
|
|
34
35
|
stroke-linecap: round;
|
|
35
36
|
stroke-linejoin: round;
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
.cinder-waveform__bar {
|
|
40
|
-
fill: var(--
|
|
41
|
+
fill: var(--_cinder-chart-series-color, currentColor);
|
|
41
42
|
rx: 1;
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -46,8 +47,8 @@
|
|
|
46
47
|
inset: 0;
|
|
47
48
|
display: grid;
|
|
48
49
|
place-items: center;
|
|
49
|
-
color: var(--
|
|
50
|
-
background:
|
|
50
|
+
color: var(--_cinder-chart-muted, currentColor);
|
|
51
|
+
background: var(--_cinder-chart-background, transparent);
|
|
51
52
|
z-index: 1;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -37,6 +37,31 @@
|
|
|
37
37
|
"type": "string",
|
|
38
38
|
"description": "Custom data table caption; falls back to `label`."
|
|
39
39
|
},
|
|
40
|
+
"theme": {
|
|
41
|
+
"type": "object",
|
|
42
|
+
"properties": {
|
|
43
|
+
"foreground": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
},
|
|
46
|
+
"muted": {
|
|
47
|
+
"type": "string"
|
|
48
|
+
},
|
|
49
|
+
"grid": {
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"background": {
|
|
53
|
+
"type": "string"
|
|
54
|
+
},
|
|
55
|
+
"palette": {
|
|
56
|
+
"type": "array",
|
|
57
|
+
"items": {
|
|
58
|
+
"type": "string"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"additionalProperties": false,
|
|
63
|
+
"description": "Partial visual theme override. Omitted fields inherit the surrounding application."
|
|
64
|
+
},
|
|
40
65
|
"class": {
|
|
41
66
|
"type": "string",
|
|
42
67
|
"description": "Custom class applied to the root element."
|
|
@@ -41,6 +41,32 @@ const schema = {
|
|
|
41
41
|
type: 'string',
|
|
42
42
|
description: 'Custom data table caption; falls back to `label`.',
|
|
43
43
|
},
|
|
44
|
+
theme: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {
|
|
47
|
+
foreground: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
},
|
|
50
|
+
muted: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
},
|
|
53
|
+
grid: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
},
|
|
56
|
+
background: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
},
|
|
59
|
+
palette: {
|
|
60
|
+
type: 'array',
|
|
61
|
+
items: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
additionalProperties: false,
|
|
67
|
+
description:
|
|
68
|
+
'Partial visual theme override. Omitted fields inherit the surrounding application.',
|
|
69
|
+
},
|
|
44
70
|
class: {
|
|
45
71
|
type: 'string',
|
|
46
72
|
description: 'Custom class applied to the root element.',
|
|
@@ -3,13 +3,14 @@ export {};
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
-
import { dataTableClass } from '../../_internal/chart/chart-utilities.ts';
|
|
6
|
+
import { chartPaletteColor, dataTableClass, resolveChartTheme, } from '../../_internal/chart/chart-utilities.ts';
|
|
7
7
|
import { classNames } from '../../utilities/class-names.ts';
|
|
8
8
|
import { useResizeObserver } from '../../utilities/use-resize-observer.svelte.ts';
|
|
9
|
-
let { label, description, data, renderMode = 'path', height = 80, loading = false, dataTableVisibility = 'screen-reader-only', dataTableCaption, class: customClassName, empty, loadingContent, id, ...rest } = $props();
|
|
9
|
+
let { label, description, data, renderMode = 'path', height = 80, loading = false, dataTableVisibility = 'screen-reader-only', dataTableCaption, theme, class: customClassName, empty, loadingContent, id, ...rest } = $props();
|
|
10
10
|
const generatedId = $props.id();
|
|
11
11
|
const rootId = $derived(id ?? generatedId);
|
|
12
12
|
const descriptionId = $derived(description ? `${rootId}-description` : undefined);
|
|
13
|
+
const resolvedTheme = $derived(resolveChartTheme(theme));
|
|
13
14
|
let measuredWidth = $state(400);
|
|
14
15
|
const observeResize = useResizeObserver((entries) => {
|
|
15
16
|
const entry = entries[0];
|
|
@@ -159,6 +160,11 @@ const tableCaption = $derived.by(() => {
|
|
|
159
160
|
aria-label={label}
|
|
160
161
|
aria-describedby={descriptionId}
|
|
161
162
|
data-cinder-render-mode={renderMode}
|
|
163
|
+
style:--_cinder-chart-foreground={resolvedTheme.foreground}
|
|
164
|
+
style:--_cinder-chart-muted={resolvedTheme.muted}
|
|
165
|
+
style:--_cinder-chart-grid={resolvedTheme.grid}
|
|
166
|
+
style:--_cinder-chart-background={resolvedTheme.background}
|
|
167
|
+
style:--_cinder-chart-series-color={chartPaletteColor(0, resolvedTheme.palette)}
|
|
162
168
|
>
|
|
163
169
|
{#if description}
|
|
164
170
|
<p id={descriptionId} class="cinder-waveform__description">{description}</p>
|
|
@@ -194,6 +200,7 @@ const tableCaption = $derived.by(() => {
|
|
|
194
200
|
x2={measuredWidth}
|
|
195
201
|
y1={midY}
|
|
196
202
|
y2={midY}
|
|
203
|
+
stroke={resolvedTheme.grid}
|
|
197
204
|
aria-hidden="true"
|
|
198
205
|
/>
|
|
199
206
|
{#if renderMode === 'bars'}
|
|
@@ -204,11 +211,17 @@ const tableCaption = $derived.by(() => {
|
|
|
204
211
|
y={bar.y}
|
|
205
212
|
width={bar.width}
|
|
206
213
|
height={bar.height}
|
|
214
|
+
fill={chartPaletteColor(0, resolvedTheme.palette)}
|
|
207
215
|
aria-hidden="true"
|
|
208
216
|
/>
|
|
209
217
|
{/each}
|
|
210
218
|
{:else}
|
|
211
|
-
<path
|
|
219
|
+
<path
|
|
220
|
+
class="cinder-waveform__path"
|
|
221
|
+
d={waveformPath}
|
|
222
|
+
stroke={chartPaletteColor(0, resolvedTheme.palette)}
|
|
223
|
+
aria-hidden="true"
|
|
224
|
+
/>
|
|
212
225
|
{/if}
|
|
213
226
|
{/if}
|
|
214
227
|
</svg>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import type { ChartDataTableVisibility } from '../chart.types.ts';
|
|
3
|
+
import type { ChartDataTableVisibility, ChartTheme, ChartThemeSchema } from '../chart.types.ts';
|
|
4
4
|
|
|
5
5
|
export type WaveformRenderMode = 'path' | 'bars';
|
|
6
6
|
|
|
@@ -24,6 +24,8 @@ export type WaveformProps = Omit<HTMLAttributes<HTMLElement>, 'class'> & {
|
|
|
24
24
|
dataTableVisibility?: ChartDataTableVisibility;
|
|
25
25
|
/** Custom data table caption; falls back to `label`. */
|
|
26
26
|
dataTableCaption?: string;
|
|
27
|
+
/** Partial visual theme override. Omitted fields inherit the surrounding application. */
|
|
28
|
+
theme?: ChartTheme;
|
|
27
29
|
/** Custom class applied to the root element. */
|
|
28
30
|
class?: string;
|
|
29
31
|
/** Snippet rendered when the chart has no data. */
|
|
@@ -49,6 +51,8 @@ export type WaveformSchemaProps = {
|
|
|
49
51
|
dataTableVisibility?: ChartDataTableVisibility;
|
|
50
52
|
/** Custom data table caption; falls back to `label`. */
|
|
51
53
|
dataTableCaption?: string;
|
|
54
|
+
/** Partial visual theme override. Omitted fields inherit the surrounding application. */
|
|
55
|
+
theme?: ChartThemeSchema;
|
|
52
56
|
/** Custom class applied to the root element. */
|
|
53
57
|
class?: string;
|
|
54
58
|
};
|
package/src/index.ts
CHANGED
|
@@ -95,6 +95,7 @@ export type {
|
|
|
95
95
|
BarChartDatum,
|
|
96
96
|
BarChartMode,
|
|
97
97
|
BarChartOrientation,
|
|
98
|
+
BarChartPlacedBar,
|
|
98
99
|
BarChartSchemaDatum,
|
|
99
100
|
BarChartSchemaSeries,
|
|
100
101
|
BarChartSeries,
|
|
@@ -104,16 +105,23 @@ export type {
|
|
|
104
105
|
ChartCartesianSeries,
|
|
105
106
|
ChartDataTableVisibility,
|
|
106
107
|
ChartFormatterContext,
|
|
108
|
+
ChartGeometry,
|
|
107
109
|
ChartJsonValue,
|
|
108
110
|
ChartJsonXValue,
|
|
109
111
|
ChartLegendPosition,
|
|
112
|
+
ChartMarkContext,
|
|
110
113
|
ChartNumericValue,
|
|
111
114
|
ChartPoint,
|
|
112
115
|
ChartSchemaPoint,
|
|
113
116
|
ChartSharedProps,
|
|
117
|
+
ChartTarget,
|
|
118
|
+
ChartTheme,
|
|
114
119
|
ChartTickFormatter,
|
|
115
120
|
ChartValueFormatter,
|
|
121
|
+
ChartXAxisConfiguration,
|
|
116
122
|
ChartXValue,
|
|
123
|
+
NormalizedXValue,
|
|
124
|
+
PlacedPoint,
|
|
117
125
|
} from './components/chart.types.ts';
|
|
118
126
|
|
|
119
127
|
export { default as BentoCell } from './components/bento-cell/index.ts';
|