@sentropic/design-system-svelte 0.7.0 → 0.9.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/Accordion.svelte +11 -3
- package/dist/Accordion.svelte.d.ts.map +1 -1
- package/dist/Alert.svelte +1 -1
- package/dist/AreaChart.svelte +414 -0
- package/dist/AreaChart.svelte.d.ts +18 -0
- package/dist/AreaChart.svelte.d.ts.map +1 -0
- package/dist/BarChart.svelte +383 -0
- package/dist/BarChart.svelte.d.ts +18 -0
- package/dist/BarChart.svelte.d.ts.map +1 -0
- package/dist/ChatComposer.svelte +238 -0
- package/dist/ChatComposer.svelte.d.ts +57 -0
- package/dist/ChatComposer.svelte.d.ts.map +1 -0
- package/dist/ChatMessage.svelte +271 -0
- package/dist/ChatMessage.svelte.d.ts +19 -0
- package/dist/ChatMessage.svelte.d.ts.map +1 -0
- package/dist/ChatThread.svelte +120 -0
- package/dist/ChatThread.svelte.d.ts +13 -0
- package/dist/ChatThread.svelte.d.ts.map +1 -0
- package/dist/Combobox.svelte +16 -2
- package/dist/Combobox.svelte.d.ts.map +1 -1
- package/dist/CopyButton.svelte +3 -7
- package/dist/CopyButton.svelte.d.ts.map +1 -1
- package/dist/Drawer.svelte +23 -3
- package/dist/Drawer.svelte.d.ts +1 -1
- package/dist/Drawer.svelte.d.ts.map +1 -1
- package/dist/Dropdown.svelte +38 -2
- package/dist/Dropdown.svelte.d.ts.map +1 -1
- package/dist/FileUploader.svelte +119 -4
- package/dist/FileUploader.svelte.d.ts +1 -0
- package/dist/FileUploader.svelte.d.ts.map +1 -1
- package/dist/IconButton.svelte +103 -0
- package/dist/IconButton.svelte.d.ts +15 -0
- package/dist/IconButton.svelte.d.ts.map +1 -0
- package/dist/InlineLoading.svelte +22 -14
- package/dist/InlineLoading.svelte.d.ts.map +1 -1
- package/dist/LineChart.svelte +397 -0
- package/dist/LineChart.svelte.d.ts +19 -0
- package/dist/LineChart.svelte.d.ts.map +1 -0
- package/dist/Menu.svelte +164 -24
- package/dist/Menu.svelte.d.ts +26 -4
- package/dist/Menu.svelte.d.ts.map +1 -1
- package/dist/MenuPopover.svelte +180 -0
- package/dist/MenuPopover.svelte.d.ts +17 -0
- package/dist/MenuPopover.svelte.d.ts.map +1 -0
- package/dist/MenuTriggerButton.svelte +50 -0
- package/dist/MenuTriggerButton.svelte.d.ts +16 -0
- package/dist/MenuTriggerButton.svelte.d.ts.map +1 -0
- package/dist/MessageActions.svelte +89 -0
- package/dist/MessageActions.svelte.d.ts +22 -0
- package/dist/MessageActions.svelte.d.ts.map +1 -0
- package/dist/MessageStatusBadge.svelte +52 -0
- package/dist/MessageStatusBadge.svelte.d.ts +12 -0
- package/dist/MessageStatusBadge.svelte.d.ts.map +1 -0
- package/dist/Modal.svelte +83 -3
- package/dist/Modal.svelte.d.ts.map +1 -1
- package/dist/MultiSelect.svelte +17 -3
- package/dist/MultiSelect.svelte.d.ts.map +1 -1
- package/dist/OverflowMenu.svelte +111 -24
- package/dist/OverflowMenu.svelte.d.ts +21 -2
- package/dist/OverflowMenu.svelte.d.ts.map +1 -1
- package/dist/PaginationNav.svelte +6 -21
- package/dist/PaginationNav.svelte.d.ts.map +1 -1
- package/dist/PasswordInput.svelte +3 -9
- package/dist/PasswordInput.svelte.d.ts.map +1 -1
- package/dist/ProgressIndicator.svelte +3 -19
- package/dist/ProgressIndicator.svelte.d.ts.map +1 -1
- package/dist/Search.svelte +3 -6
- package/dist/Search.svelte.d.ts.map +1 -1
- package/dist/Sparkline.svelte +123 -0
- package/dist/Sparkline.svelte.d.ts +15 -0
- package/dist/Sparkline.svelte.d.ts.map +1 -0
- package/dist/StreamingMessage.svelte +292 -0
- package/dist/StreamingMessage.svelte.d.ts +51 -0
- package/dist/StreamingMessage.svelte.d.ts.map +1 -0
- package/dist/Tag.svelte +2 -1
- package/dist/Tag.svelte.d.ts.map +1 -1
- package/dist/Toast.svelte +2 -2
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/package.json +3 -2
package/dist/Accordion.svelte
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
10
|
<script lang="ts">
|
|
11
|
+
import { ChevronDown } from "@lucide/svelte";
|
|
11
12
|
import type { HTMLAttributes } from "svelte/elements";
|
|
12
13
|
|
|
13
14
|
type AccordionProps = Omit<HTMLAttributes<HTMLDivElement>, "class" | "onchange"> & {
|
|
@@ -68,11 +69,15 @@
|
|
|
68
69
|
onclick={() => toggle(item.id, item.disabled)}
|
|
69
70
|
>
|
|
70
71
|
{#if align === "start"}
|
|
71
|
-
<span class="st-accordion__icon" aria-hidden="true"
|
|
72
|
+
<span class="st-accordion__icon" aria-hidden="true">
|
|
73
|
+
<ChevronDown size={18} strokeWidth={2.25} />
|
|
74
|
+
</span>
|
|
72
75
|
<span class="st-accordion__title">{item.title}</span>
|
|
73
76
|
{:else}
|
|
74
77
|
<span class="st-accordion__title">{item.title}</span>
|
|
75
|
-
<span class="st-accordion__icon" aria-hidden="true"
|
|
78
|
+
<span class="st-accordion__icon" aria-hidden="true">
|
|
79
|
+
<ChevronDown size={18} strokeWidth={2.25} />
|
|
80
|
+
</span>
|
|
76
81
|
{/if}
|
|
77
82
|
</button>
|
|
78
83
|
</h3>
|
|
@@ -160,11 +165,14 @@
|
|
|
160
165
|
}
|
|
161
166
|
|
|
162
167
|
.st-accordion__icon {
|
|
168
|
+
align-items: center;
|
|
163
169
|
color: var(--st-semantic-text-secondary);
|
|
164
170
|
display: inline-flex;
|
|
165
171
|
flex: 0 0 auto;
|
|
166
|
-
|
|
172
|
+
height: 1.25rem;
|
|
173
|
+
justify-content: center;
|
|
167
174
|
transition: transform var(--st-motion-fast, 120ms) var(--st-motion-easing, ease);
|
|
175
|
+
width: 1.25rem;
|
|
168
176
|
}
|
|
169
177
|
|
|
170
178
|
.st-accordion__item--open .st-accordion__icon {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Accordion.svelte.ts"],"names":[],"mappings":"AAGE,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"Accordion.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Accordion.svelte.ts"],"names":[],"mappings":"AAGE,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,GAAG;IACjF,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACrC,CAAC;AAyEJ,QAAA,MAAM,SAAS,wDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
|
package/dist/Alert.svelte
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
background: var(--st-component-alert-background, var(--st-semantic-surface-raised));
|
|
44
44
|
border: 1px solid var(--st-component-alert-border, var(--st-semantic-border-subtle));
|
|
45
45
|
border-left-width: 0.25rem;
|
|
46
|
-
border-radius:
|
|
46
|
+
border-radius: 0;
|
|
47
47
|
color: var(--st-component-alert-text, var(--st-semantic-text-primary));
|
|
48
48
|
display: flex;
|
|
49
49
|
gap: var(--st-spacing-4, 1rem);
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type AreaChartTone =
|
|
3
|
+
| "category1"
|
|
4
|
+
| "category2"
|
|
5
|
+
| "category3"
|
|
6
|
+
| "category4"
|
|
7
|
+
| "category5"
|
|
8
|
+
| "category6"
|
|
9
|
+
| "category7"
|
|
10
|
+
| "category8";
|
|
11
|
+
|
|
12
|
+
export type AreaChartDatum = {
|
|
13
|
+
x: number | string;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script lang="ts">
|
|
19
|
+
type AreaChartProps = {
|
|
20
|
+
data: (number | AreaChartDatum)[];
|
|
21
|
+
width?: number;
|
|
22
|
+
height?: number;
|
|
23
|
+
tone?: AreaChartTone;
|
|
24
|
+
smooth?: boolean;
|
|
25
|
+
label: string;
|
|
26
|
+
class?: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
data = [],
|
|
31
|
+
width = 480,
|
|
32
|
+
height = 240,
|
|
33
|
+
tone = "category1",
|
|
34
|
+
smooth = false,
|
|
35
|
+
label,
|
|
36
|
+
class: className
|
|
37
|
+
}: AreaChartProps = $props();
|
|
38
|
+
|
|
39
|
+
const MARGIN = { top: 12, right: 16, bottom: 32, left: 44 };
|
|
40
|
+
|
|
41
|
+
function niceTicks(min: number, max: number, target = 5): number[] {
|
|
42
|
+
if (!Number.isFinite(min) || !Number.isFinite(max) || min === max) {
|
|
43
|
+
const base = Number.isFinite(max) ? max : 0;
|
|
44
|
+
return [base];
|
|
45
|
+
}
|
|
46
|
+
const range = max - min;
|
|
47
|
+
const rough = range / Math.max(target - 1, 1);
|
|
48
|
+
const pow = Math.pow(10, Math.floor(Math.log10(rough)));
|
|
49
|
+
const norm = rough / pow;
|
|
50
|
+
let step: number;
|
|
51
|
+
if (norm < 1.5) step = 1 * pow;
|
|
52
|
+
else if (norm < 3) step = 2 * pow;
|
|
53
|
+
else if (norm < 7) step = 5 * pow;
|
|
54
|
+
else step = 10 * pow;
|
|
55
|
+
const start = Math.floor(min / step) * step;
|
|
56
|
+
const end = Math.ceil(max / step) * step;
|
|
57
|
+
const ticks: number[] = [];
|
|
58
|
+
for (let v = start; v <= end + step / 2; v += step) {
|
|
59
|
+
ticks.push(Number(v.toFixed(10)));
|
|
60
|
+
}
|
|
61
|
+
return ticks;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function scaleLinear(v: number, d0: number, d1: number, r0: number, r1: number) {
|
|
65
|
+
if (d1 === d0) return r0;
|
|
66
|
+
return r0 + ((v - d0) * (r1 - r0)) / (d1 - d0);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function formatTick(v: number): string {
|
|
70
|
+
if (Math.abs(v) >= 1000) return `${(v / 1000).toFixed(v % 1000 === 0 ? 0 : 1)}k`;
|
|
71
|
+
if (Number.isInteger(v)) return String(v);
|
|
72
|
+
return v.toFixed(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function isNumeric(x: number | string): x is number {
|
|
76
|
+
return typeof x === "number" && Number.isFinite(x);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const normalizedData = $derived.by(() => {
|
|
80
|
+
return data.map((d, i) => {
|
|
81
|
+
if (typeof d === "number") {
|
|
82
|
+
return { x: i, y: d } as AreaChartDatum;
|
|
83
|
+
}
|
|
84
|
+
return d;
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
let hoveredIndex: number | null = $state(null);
|
|
89
|
+
|
|
90
|
+
const plotWidth = $derived(Math.max(width - MARGIN.left - MARGIN.right, 1));
|
|
91
|
+
const plotHeight = $derived(Math.max(height - MARGIN.top - MARGIN.bottom, 1));
|
|
92
|
+
|
|
93
|
+
const xDomain = $derived.by(() => {
|
|
94
|
+
if (normalizedData.length === 0) return { kind: "ordinal" as const, values: [] as (number | string)[] };
|
|
95
|
+
const allNumeric = normalizedData.every((d) => isNumeric(d.x));
|
|
96
|
+
if (allNumeric) {
|
|
97
|
+
const xs = normalizedData.map((d) => d.x as number);
|
|
98
|
+
return { kind: "numeric" as const, min: Math.min(...xs), max: Math.max(...xs) };
|
|
99
|
+
}
|
|
100
|
+
return { kind: "ordinal" as const, values: normalizedData.map((d) => d.x) };
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const yTicks = $derived.by(() => {
|
|
104
|
+
const ys = normalizedData.map((d) => d.y);
|
|
105
|
+
if (ys.length === 0) return [0];
|
|
106
|
+
const minRaw = Math.min(...ys);
|
|
107
|
+
const maxRaw = Math.max(...ys);
|
|
108
|
+
const padded = (maxRaw - minRaw) * 0.08 || Math.max(Math.abs(maxRaw), 1) * 0.1;
|
|
109
|
+
const minTickVal = Math.min(0, minRaw - padded);
|
|
110
|
+
return niceTicks(minTickVal, maxRaw + padded, 5);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const yDomain = $derived.by(() => {
|
|
114
|
+
if (yTicks.length === 0) return { min: 0, max: 1 };
|
|
115
|
+
return { min: yTicks[0], max: yTicks[yTicks.length - 1] };
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const points = $derived.by(() => {
|
|
119
|
+
if (normalizedData.length === 0) return [];
|
|
120
|
+
return normalizedData.map((d, i) => {
|
|
121
|
+
let x: number;
|
|
122
|
+
if (xDomain.kind === "numeric") {
|
|
123
|
+
x = scaleLinear(d.x as number, xDomain.min, xDomain.max, 0, plotWidth);
|
|
124
|
+
} else {
|
|
125
|
+
const denom = Math.max(normalizedData.length - 1, 1);
|
|
126
|
+
x = normalizedData.length === 1 ? plotWidth / 2 : (i / denom) * plotWidth;
|
|
127
|
+
}
|
|
128
|
+
const y = scaleLinear(d.y, yDomain.min, yDomain.max, plotHeight, 0);
|
|
129
|
+
return {
|
|
130
|
+
x: MARGIN.left + x,
|
|
131
|
+
y: MARGIN.top + y,
|
|
132
|
+
datum: d,
|
|
133
|
+
index: i
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
function buildLinearPath(pts: { x: number; y: number }[]): string {
|
|
139
|
+
return pts.map((p, i) => `${i === 0 ? "M" : "L"}${p.x.toFixed(2)},${p.y.toFixed(2)}`).join(" ");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function buildSmoothPath(pts: { x: number; y: number }[]): string {
|
|
143
|
+
if (pts.length < 2) return buildLinearPath(pts);
|
|
144
|
+
const t = 0.18;
|
|
145
|
+
let d = `M${pts[0].x.toFixed(2)},${pts[0].y.toFixed(2)}`;
|
|
146
|
+
for (let i = 0; i < pts.length - 1; i++) {
|
|
147
|
+
const p0 = pts[i - 1] ?? pts[i];
|
|
148
|
+
const p1 = pts[i];
|
|
149
|
+
const p2 = pts[i + 1];
|
|
150
|
+
const p3 = pts[i + 2] ?? p2;
|
|
151
|
+
const c1x = p1.x + (p2.x - p0.x) * t;
|
|
152
|
+
const c1y = p1.y + (p2.y - p0.y) * t;
|
|
153
|
+
const c2x = p2.x - (p3.x - p1.x) * t;
|
|
154
|
+
const c2y = p2.y - (p3.y - p1.y) * t;
|
|
155
|
+
d += ` C${c1x.toFixed(2)},${c1y.toFixed(2)} ${c2x.toFixed(2)},${c2y.toFixed(2)} ${p2.x.toFixed(2)},${p2.y.toFixed(2)}`;
|
|
156
|
+
}
|
|
157
|
+
return d;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const linePath = $derived(
|
|
161
|
+
points.length === 0 ? "" : smooth ? buildSmoothPath(points) : buildLinearPath(points)
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const areaPath = $derived.by(() => {
|
|
165
|
+
if (points.length === 0) return "";
|
|
166
|
+
const base = MARGIN.top + scaleLinear(Math.max(0, yDomain.min), yDomain.min, yDomain.max, plotHeight, 0);
|
|
167
|
+
const first = points[0];
|
|
168
|
+
const last = points[points.length - 1];
|
|
169
|
+
return `${linePath} L${last.x.toFixed(2)},${base.toFixed(2)} L${first.x.toFixed(2)},${base.toFixed(2)} Z`;
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const gridLines = $derived(
|
|
173
|
+
yTicks.map((tick) => ({
|
|
174
|
+
value: tick,
|
|
175
|
+
y: MARGIN.top + scaleLinear(tick, yDomain.min, yDomain.max, plotHeight, 0)
|
|
176
|
+
}))
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
const xTickEntries = $derived.by(() => {
|
|
180
|
+
if (normalizedData.length === 0) return [];
|
|
181
|
+
if (xDomain.kind === "ordinal") {
|
|
182
|
+
return points.map((p, i) => ({
|
|
183
|
+
x: p.x,
|
|
184
|
+
label: String(normalizedData[i].x)
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
const target = Math.min(5, normalizedData.length);
|
|
188
|
+
const stride = Math.max(1, Math.round((normalizedData.length - 1) / (target - 1 || 1)));
|
|
189
|
+
const entries: { x: number; label: string }[] = [];
|
|
190
|
+
for (let i = 0; i < normalizedData.length; i += stride) {
|
|
191
|
+
entries.push({ x: points[i].x, label: String(normalizedData[i].x) });
|
|
192
|
+
}
|
|
193
|
+
const lastIdx = normalizedData.length - 1;
|
|
194
|
+
if (entries[entries.length - 1]?.label !== String(normalizedData[lastIdx].x)) {
|
|
195
|
+
entries.push({ x: points[lastIdx].x, label: String(normalizedData[lastIdx].x) });
|
|
196
|
+
}
|
|
197
|
+
return entries;
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
function handleEnter(i: number) {
|
|
201
|
+
hoveredIndex = i;
|
|
202
|
+
}
|
|
203
|
+
function handleLeave() {
|
|
204
|
+
hoveredIndex = null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Generates a unique gradient id to avoid conflicts when rendering multiple charts on the same page
|
|
208
|
+
const gradientId = $derived.by(() => {
|
|
209
|
+
return `st-areachart-gradient-${Math.random().toString(36).substring(2, 9)}`;
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
const classes = () =>
|
|
213
|
+
["st-areaChart", `st-areaChart--${tone}`, className].filter(Boolean).join(" ");
|
|
214
|
+
</script>
|
|
215
|
+
|
|
216
|
+
<div class={classes()} role="img" aria-label={label}>
|
|
217
|
+
<svg
|
|
218
|
+
viewBox="0 0 {width} {height}"
|
|
219
|
+
preserveAspectRatio="xMidYMid meet"
|
|
220
|
+
width="100%"
|
|
221
|
+
height="100%"
|
|
222
|
+
focusable="false"
|
|
223
|
+
aria-hidden="true"
|
|
224
|
+
>
|
|
225
|
+
<defs>
|
|
226
|
+
<linearGradient id={gradientId} x1="0" y1="0" x2="0" y2="1">
|
|
227
|
+
<stop offset="0%" stop-color="currentColor" stop-opacity="0.3" />
|
|
228
|
+
<stop offset="100%" stop-color="currentColor" stop-opacity="0.0" />
|
|
229
|
+
</linearGradient>
|
|
230
|
+
</defs>
|
|
231
|
+
|
|
232
|
+
<!-- gridlines + Y axis ticks -->
|
|
233
|
+
{#each gridLines as g (g.value)}
|
|
234
|
+
<line
|
|
235
|
+
class="st-areaChart__grid"
|
|
236
|
+
x1={MARGIN.left}
|
|
237
|
+
x2={width - MARGIN.right}
|
|
238
|
+
y1={g.y}
|
|
239
|
+
y2={g.y}
|
|
240
|
+
/>
|
|
241
|
+
<text
|
|
242
|
+
class="st-areaChart__tickLabel"
|
|
243
|
+
x={MARGIN.left - 6}
|
|
244
|
+
y={g.y}
|
|
245
|
+
text-anchor="end"
|
|
246
|
+
dominant-baseline="middle"
|
|
247
|
+
>
|
|
248
|
+
{formatTick(g.value)}
|
|
249
|
+
</text>
|
|
250
|
+
{/each}
|
|
251
|
+
|
|
252
|
+
<!-- axes -->
|
|
253
|
+
<line
|
|
254
|
+
class="st-areaChart__axis"
|
|
255
|
+
x1={MARGIN.left}
|
|
256
|
+
x2={MARGIN.left}
|
|
257
|
+
y1={MARGIN.top}
|
|
258
|
+
y2={height - MARGIN.bottom}
|
|
259
|
+
/>
|
|
260
|
+
<line
|
|
261
|
+
class="st-areaChart__axis"
|
|
262
|
+
x1={MARGIN.left}
|
|
263
|
+
x2={width - MARGIN.right}
|
|
264
|
+
y1={height - MARGIN.bottom}
|
|
265
|
+
y2={height - MARGIN.bottom}
|
|
266
|
+
/>
|
|
267
|
+
|
|
268
|
+
<!-- X tick labels -->
|
|
269
|
+
{#each xTickEntries as tick, i (i)}
|
|
270
|
+
<text
|
|
271
|
+
class="st-areaChart__tickLabel"
|
|
272
|
+
x={tick.x}
|
|
273
|
+
y={height - MARGIN.bottom + 16}
|
|
274
|
+
text-anchor="middle"
|
|
275
|
+
>
|
|
276
|
+
{tick.label}
|
|
277
|
+
</text>
|
|
278
|
+
{/each}
|
|
279
|
+
|
|
280
|
+
{#if areaPath}
|
|
281
|
+
<path class="st-areaChart__area" d={areaPath} fill="url(#{gradientId})" />
|
|
282
|
+
{/if}
|
|
283
|
+
{#if linePath}
|
|
284
|
+
<path
|
|
285
|
+
class="st-areaChart__line"
|
|
286
|
+
d={linePath}
|
|
287
|
+
fill="none"
|
|
288
|
+
stroke-width="2"
|
|
289
|
+
stroke-linecap="round"
|
|
290
|
+
stroke-linejoin="round"
|
|
291
|
+
/>
|
|
292
|
+
{/if}
|
|
293
|
+
|
|
294
|
+
{#each points as p (p.index)}
|
|
295
|
+
<circle
|
|
296
|
+
class="st-areaChart__dot"
|
|
297
|
+
cx={p.x}
|
|
298
|
+
cy={p.y}
|
|
299
|
+
r="4"
|
|
300
|
+
tabindex="0"
|
|
301
|
+
role="img"
|
|
302
|
+
aria-label="{p.datum.x}: {p.datum.y}"
|
|
303
|
+
onmouseenter={() => handleEnter(p.index)}
|
|
304
|
+
onmouseleave={handleLeave}
|
|
305
|
+
onfocus={() => handleEnter(p.index)}
|
|
306
|
+
onblur={handleLeave}
|
|
307
|
+
/>
|
|
308
|
+
{/each}
|
|
309
|
+
</svg>
|
|
310
|
+
|
|
311
|
+
{#if hoveredIndex !== null && points[hoveredIndex]}
|
|
312
|
+
{@const p = points[hoveredIndex]}
|
|
313
|
+
<div
|
|
314
|
+
class="st-areaChart__tooltip"
|
|
315
|
+
role="presentation"
|
|
316
|
+
style="left: {(p.x / width) * 100}%; top: {(p.y / height) * 100}%"
|
|
317
|
+
>
|
|
318
|
+
<span class="st-areaChart__tooltipLabel">{p.datum.x}</span>
|
|
319
|
+
<span class="st-areaChart__tooltipValue">{p.datum.y}</span>
|
|
320
|
+
</div>
|
|
321
|
+
{/if}
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
<style>
|
|
325
|
+
.st-areaChart {
|
|
326
|
+
color: var(--st-semantic-data-category1);
|
|
327
|
+
display: block;
|
|
328
|
+
font-family: inherit;
|
|
329
|
+
position: relative;
|
|
330
|
+
width: 100%;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.st-areaChart--category1 { color: var(--st-semantic-data-category1); }
|
|
334
|
+
.st-areaChart--category2 { color: var(--st-semantic-data-category2); }
|
|
335
|
+
.st-areaChart--category3 { color: var(--st-semantic-data-category3); }
|
|
336
|
+
.st-areaChart--category4 { color: var(--st-semantic-data-category4); }
|
|
337
|
+
.st-areaChart--category5 { color: var(--st-semantic-data-category5); }
|
|
338
|
+
.st-areaChart--category6 { color: var(--st-semantic-data-category6); }
|
|
339
|
+
.st-areaChart--category7 { color: var(--st-semantic-data-category7); }
|
|
340
|
+
.st-areaChart--category8 { color: var(--st-semantic-data-category8); }
|
|
341
|
+
|
|
342
|
+
.st-areaChart svg {
|
|
343
|
+
display: block;
|
|
344
|
+
overflow: visible;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.st-areaChart__grid {
|
|
348
|
+
stroke: var(--st-component-areaChart-gridStroke, var(--st-semantic-border-subtle));
|
|
349
|
+
stroke-dasharray: 2 3;
|
|
350
|
+
stroke-width: 1;
|
|
351
|
+
opacity: 0.7;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.st-areaChart__axis {
|
|
355
|
+
stroke: var(--st-component-areaChart-axisStroke, var(--st-semantic-border-subtle));
|
|
356
|
+
stroke-width: 1;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.st-areaChart__tickLabel {
|
|
360
|
+
fill: var(--st-component-areaChart-labelColor, var(--st-semantic-text-secondary));
|
|
361
|
+
font-size: 0.6875rem;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.st-areaChart__line {
|
|
365
|
+
stroke: currentColor;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.st-areaChart__area {
|
|
369
|
+
stroke: none;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.st-areaChart__dot {
|
|
373
|
+
fill: currentColor;
|
|
374
|
+
stroke: var(--st-semantic-surface-default);
|
|
375
|
+
stroke-width: 1.5;
|
|
376
|
+
cursor: pointer;
|
|
377
|
+
transition: r 120ms ease;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.st-areaChart__dot:hover,
|
|
381
|
+
.st-areaChart__dot:focus-visible {
|
|
382
|
+
r: 5.5;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.st-areaChart__dot:focus-visible {
|
|
386
|
+
outline: 2px solid var(--st-semantic-border-interactive);
|
|
387
|
+
outline-offset: 1px;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.st-areaChart__tooltip {
|
|
391
|
+
background: var(--st-component-areaChart-tooltipBackground, var(--st-semantic-surface-inverse));
|
|
392
|
+
border-radius: var(--st-radius-sm, 0.25rem);
|
|
393
|
+
color: var(--st-component-areaChart-tooltipText, var(--st-semantic-text-inverse));
|
|
394
|
+
display: inline-flex;
|
|
395
|
+
flex-direction: column;
|
|
396
|
+
font-size: 0.75rem;
|
|
397
|
+
gap: 0.125rem;
|
|
398
|
+
line-height: 1.2;
|
|
399
|
+
padding: 0.375rem 0.5rem;
|
|
400
|
+
pointer-events: none;
|
|
401
|
+
position: absolute;
|
|
402
|
+
transform: translate(-50%, calc(-100% - 8px));
|
|
403
|
+
white-space: nowrap;
|
|
404
|
+
z-index: 1;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.st-areaChart__tooltipLabel {
|
|
408
|
+
font-weight: 600;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.st-areaChart__tooltipValue {
|
|
412
|
+
opacity: 0.85;
|
|
413
|
+
}
|
|
414
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type AreaChartTone = "category1" | "category2" | "category3" | "category4" | "category5" | "category6" | "category7" | "category8";
|
|
2
|
+
export type AreaChartDatum = {
|
|
3
|
+
x: number | string;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
type AreaChartProps = {
|
|
7
|
+
data: (number | AreaChartDatum)[];
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
tone?: AreaChartTone;
|
|
11
|
+
smooth?: boolean;
|
|
12
|
+
label: string;
|
|
13
|
+
class?: string;
|
|
14
|
+
};
|
|
15
|
+
declare const AreaChart: import("svelte").Component<AreaChartProps, {}, "">;
|
|
16
|
+
type AreaChart = ReturnType<typeof AreaChart>;
|
|
17
|
+
export default AreaChart;
|
|
18
|
+
//# sourceMappingURL=AreaChart.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AreaChart.svelte.d.ts","sourceRoot":"","sources":["../src/lib/AreaChart.svelte.ts"],"names":[],"mappings":"AAGE,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,CAAC;AAEhB,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAsPJ,QAAA,MAAM,SAAS,oDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
|