svelte-multistyle-ui 0.0.1-alpha
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/LICENSE +201 -0
- package/README.md +183 -0
- package/dist/actions/portal.d.ts +20 -0
- package/dist/actions/portal.js +32 -0
- package/dist/components/Accordion.svelte +64 -0
- package/dist/components/Accordion.svelte.d.ts +19 -0
- package/dist/components/Alert.svelte +61 -0
- package/dist/components/Alert.svelte.d.ts +23 -0
- package/dist/components/Avatar.svelte +31 -0
- package/dist/components/Avatar.svelte.d.ts +21 -0
- package/dist/components/Breadcrumb.svelte +35 -0
- package/dist/components/Breadcrumb.svelte.d.ts +15 -0
- package/dist/components/Button.svelte +34 -0
- package/dist/components/Button.svelte.d.ts +25 -0
- package/dist/components/ButtonGroup.svelte +45 -0
- package/dist/components/ButtonGroup.svelte.d.ts +23 -0
- package/dist/components/Card.svelte +29 -0
- package/dist/components/Card.svelte.d.ts +21 -0
- package/dist/components/Carousel.svelte +111 -0
- package/dist/components/Carousel.svelte.d.ts +23 -0
- package/dist/components/Checkbox.svelte +64 -0
- package/dist/components/Checkbox.svelte.d.ts +21 -0
- package/dist/components/Chip.svelte +43 -0
- package/dist/components/Chip.svelte.d.ts +27 -0
- package/dist/components/Column.svelte +38 -0
- package/dist/components/Column.svelte.d.ts +21 -0
- package/dist/components/CommandPalette.svelte +207 -0
- package/dist/components/CommandPalette.svelte.d.ts +19 -0
- package/dist/components/DatePicker.svelte +365 -0
- package/dist/components/DatePicker.svelte.d.ts +31 -0
- package/dist/components/Divider.svelte +32 -0
- package/dist/components/Divider.svelte.d.ts +17 -0
- package/dist/components/Drawer.svelte +69 -0
- package/dist/components/Drawer.svelte.d.ts +21 -0
- package/dist/components/DropdownMenu.svelte +113 -0
- package/dist/components/DropdownMenu.svelte.d.ts +25 -0
- package/dist/components/FAB.svelte +27 -0
- package/dist/components/FAB.svelte.d.ts +19 -0
- package/dist/components/FileUpload.svelte +76 -0
- package/dist/components/FileUpload.svelte.d.ts +21 -0
- package/dist/components/Grid.svelte +51 -0
- package/dist/components/Grid.svelte.d.ts +27 -0
- package/dist/components/IconButton.svelte +39 -0
- package/dist/components/IconButton.svelte.d.ts +27 -0
- package/dist/components/Input.svelte +121 -0
- package/dist/components/Input.svelte.d.ts +69 -0
- package/dist/components/Modal.svelte +57 -0
- package/dist/components/Modal.svelte.d.ts +23 -0
- package/dist/components/MultiSelect.svelte +125 -0
- package/dist/components/MultiSelect.svelte.d.ts +23 -0
- package/dist/components/Pagination.svelte +52 -0
- package/dist/components/Pagination.svelte.d.ts +19 -0
- package/dist/components/Popover.svelte +114 -0
- package/dist/components/Popover.svelte.d.ts +23 -0
- package/dist/components/ProgressBar.svelte +72 -0
- package/dist/components/ProgressBar.svelte.d.ts +21 -0
- package/dist/components/Radio.svelte +39 -0
- package/dist/components/Radio.svelte.d.ts +21 -0
- package/dist/components/Rating.svelte +102 -0
- package/dist/components/Rating.svelte.d.ts +25 -0
- package/dist/components/Row.svelte +39 -0
- package/dist/components/Row.svelte.d.ts +23 -0
- package/dist/components/Select.svelte +80 -0
- package/dist/components/Select.svelte.d.ts +23 -0
- package/dist/components/Skeleton.svelte +26 -0
- package/dist/components/Skeleton.svelte.d.ts +19 -0
- package/dist/components/Slider.svelte +46 -0
- package/dist/components/Slider.svelte.d.ts +25 -0
- package/dist/components/Spinner.svelte +27 -0
- package/dist/components/Spinner.svelte.d.ts +15 -0
- package/dist/components/Stepper.svelte +34 -0
- package/dist/components/Stepper.svelte.d.ts +17 -0
- package/dist/components/Table.svelte +59 -0
- package/dist/components/Table.svelte.d.ts +19 -0
- package/dist/components/Tabs.svelte +32 -0
- package/dist/components/Tabs.svelte.d.ts +17 -0
- package/dist/components/Textarea.svelte +86 -0
- package/dist/components/Textarea.svelte.d.ts +31 -0
- package/dist/components/Toast.svelte +90 -0
- package/dist/components/Toast.svelte.d.ts +19 -0
- package/dist/components/Toggle.svelte +46 -0
- package/dist/components/Toggle.svelte.d.ts +21 -0
- package/dist/components/Tooltip.svelte +35 -0
- package/dist/components/Tooltip.svelte.d.ts +19 -0
- package/dist/components/accordion-styles.css +89 -0
- package/dist/components/alert-styles.css +66 -0
- package/dist/components/avatar-styles.css +50 -0
- package/dist/components/breadcrumb-styles.css +73 -0
- package/dist/components/button-styles.css +272 -0
- package/dist/components/buttongroup-styles.css +118 -0
- package/dist/components/card-styles.css +101 -0
- package/dist/components/carousel-styles.css +145 -0
- package/dist/components/charts/BarChart.svelte +5 -0
- package/dist/components/charts/BarChart.svelte.d.ts +29 -0
- package/dist/components/charts/BubbleChart.svelte +5 -0
- package/dist/components/charts/BubbleChart.svelte.d.ts +29 -0
- package/dist/components/charts/Chart.svelte +186 -0
- package/dist/components/charts/Chart.svelte.d.ts +37 -0
- package/dist/components/charts/ComboChart.svelte +5 -0
- package/dist/components/charts/ComboChart.svelte.d.ts +29 -0
- package/dist/components/charts/DoughnutChart.svelte +5 -0
- package/dist/components/charts/DoughnutChart.svelte.d.ts +29 -0
- package/dist/components/charts/LineChart.svelte +5 -0
- package/dist/components/charts/LineChart.svelte.d.ts +29 -0
- package/dist/components/charts/PieChart.svelte +5 -0
- package/dist/components/charts/PieChart.svelte.d.ts +29 -0
- package/dist/components/charts/PolarAreaChart.svelte +5 -0
- package/dist/components/charts/PolarAreaChart.svelte.d.ts +29 -0
- package/dist/components/charts/RadarChart.svelte +5 -0
- package/dist/components/charts/RadarChart.svelte.d.ts +29 -0
- package/dist/components/charts/ScatterChart.svelte +5 -0
- package/dist/components/charts/ScatterChart.svelte.d.ts +29 -0
- package/dist/components/charts/StackedBarChart.svelte +18 -0
- package/dist/components/charts/StackedBarChart.svelte.d.ts +29 -0
- package/dist/components/charts/StackedLineChart.svelte +21 -0
- package/dist/components/charts/StackedLineChart.svelte.d.ts +29 -0
- package/dist/components/charts/chart-config.d.ts +102 -0
- package/dist/components/charts/chart-config.js +616 -0
- package/dist/components/charts/chart-styles.css +159 -0
- package/dist/components/checkbox-styles.css +125 -0
- package/dist/components/chip-styles.css +107 -0
- package/dist/components/column-styles.css +6 -0
- package/dist/components/commandpalette-styles.css +162 -0
- package/dist/components/datepicker-styles.css +1011 -0
- package/dist/components/divider-styles.css +56 -0
- package/dist/components/drawer-styles.css +83 -0
- package/dist/components/dropdown-styles.css +128 -0
- package/dist/components/fab-styles.css +61 -0
- package/dist/components/fileupload-styles.css +125 -0
- package/dist/components/grid-styles.css +6 -0
- package/dist/components/iconbutton-styles.css +146 -0
- package/dist/components/input-styles.css +436 -0
- package/dist/components/modal-styles.css +103 -0
- package/dist/components/multiselect-styles.css +202 -0
- package/dist/components/pagination-styles.css +63 -0
- package/dist/components/popover-styles.css +122 -0
- package/dist/components/progressbar-styles.css +106 -0
- package/dist/components/radio-styles.css +120 -0
- package/dist/components/rating-styles.css +68 -0
- package/dist/components/row-styles.css +6 -0
- package/dist/components/select-styles.css +218 -0
- package/dist/components/skeleton-styles.css +48 -0
- package/dist/components/slider-styles.css +85 -0
- package/dist/components/spinner-styles.css +52 -0
- package/dist/components/stepper-styles.css +93 -0
- package/dist/components/table-styles.css +114 -0
- package/dist/components/tabs-styles.css +74 -0
- package/dist/components/textarea-styles.css +224 -0
- package/dist/components/theme-base.css +64 -0
- package/dist/components/theme.css +440 -0
- package/dist/components/toast-styles.css +106 -0
- package/dist/components/toggle-styles.css +131 -0
- package/dist/components/tooltip-styles.css +56 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +9 -0
- package/dist/config.svelte.d.ts +25 -0
- package/dist/config.svelte.js +41 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +69 -0
- package/package.json +65 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onDestroy } from "svelte";
|
|
3
|
+
import { Chart as ChartJS } from "chart.js";
|
|
4
|
+
import "./chart-styles.css";
|
|
5
|
+
import { defaults } from "../../config.js";
|
|
6
|
+
import { buildData, buildOptions, readTokens } from "./chart-config.js";
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
type,
|
|
10
|
+
data = null,
|
|
11
|
+
series = null,
|
|
12
|
+
labels = null,
|
|
13
|
+
options = {},
|
|
14
|
+
title = "",
|
|
15
|
+
height = 320,
|
|
16
|
+
legend = "auto",
|
|
17
|
+
animated = true,
|
|
18
|
+
downloadable = false,
|
|
19
|
+
xAxisLabel = "",
|
|
20
|
+
yAxisLabel = "",
|
|
21
|
+
style: styleProp,
|
|
22
|
+
theme: themeProp,
|
|
23
|
+
...rest
|
|
24
|
+
} = $props();
|
|
25
|
+
|
|
26
|
+
const style = $derived(styleProp ?? defaults.style);
|
|
27
|
+
const theme = $derived(themeProp ?? defaults.theme);
|
|
28
|
+
const styleClass = $derived(`s-chart-${style}`);
|
|
29
|
+
const themeClass = $derived(`theme-${theme}`);
|
|
30
|
+
const typeClass = $derived(`s-chart-${type}`);
|
|
31
|
+
const heightStyle = $derived(typeof height === "number" ? `${height}px` : height);
|
|
32
|
+
|
|
33
|
+
// Normalize data formats:
|
|
34
|
+
// [{label:"q1", value:5}, ...] → single-series (labels + data array)
|
|
35
|
+
// [{label:"jan", revenue:10, Cost:5}, ...] → multi-series (labels + series)
|
|
36
|
+
const normalized = $derived.by(() => {
|
|
37
|
+
let d = data;
|
|
38
|
+
let s = series;
|
|
39
|
+
let l = labels;
|
|
40
|
+
|
|
41
|
+
// Combo chart: row-oriented data + optional series for chartType
|
|
42
|
+
if (type === "combo" && Array.isArray(d) && d.length > 0 && d[0] &&
|
|
43
|
+
typeof d[0] === "object" && !Array.isArray(d[0]) && "label" in d[0]) {
|
|
44
|
+
const keys = Object.keys(d[0]).filter(k => k !== "label");
|
|
45
|
+
l = d.map(item => item.label);
|
|
46
|
+
const chartTypeMap = {};
|
|
47
|
+
if (s) { s.forEach(sv => { chartTypeMap[sv.name] = sv.chartType; }); }
|
|
48
|
+
s = keys.map(key => ({
|
|
49
|
+
name: key,
|
|
50
|
+
values: d.map(item => item[key]),
|
|
51
|
+
chartType: chartTypeMap[key] || "bar",
|
|
52
|
+
}));
|
|
53
|
+
d = null;
|
|
54
|
+
} else if (Array.isArray(d) && d.length > 0 && d[0] &&
|
|
55
|
+
typeof d[0] === "object" && !Array.isArray(d[0]) &&
|
|
56
|
+
"label" in d[0] && "value" in d[0] && !s) {
|
|
57
|
+
// Single-series {label, value} format
|
|
58
|
+
l = d.map(item => item.label);
|
|
59
|
+
d = d.map(item => item.value);
|
|
60
|
+
} else if (Array.isArray(d) && d.length > 0 && d[0] &&
|
|
61
|
+
typeof d[0] === "object" && !Array.isArray(d[0]) &&
|
|
62
|
+
"label" in d[0] && !s) {
|
|
63
|
+
// Multi-series row-oriented format
|
|
64
|
+
const keys = Object.keys(d[0]).filter(k => k !== "label");
|
|
65
|
+
l = d.map(item => item.label);
|
|
66
|
+
s = keys.map(key => ({ name: key, values: d.map(item => item[key]) }));
|
|
67
|
+
d = null;
|
|
68
|
+
}
|
|
69
|
+
// Bubble chart: row-oriented {label, x, y, r} format
|
|
70
|
+
if (type === "bubble" && Array.isArray(s) && s.length > 0 && s[0] &&
|
|
71
|
+
typeof s[0] === "object" && !Array.isArray(s[0]) &&
|
|
72
|
+
"x" in s[0] && "y" in s[0]) {
|
|
73
|
+
const points = s.map(item => ({
|
|
74
|
+
x: item.x,
|
|
75
|
+
y: item.y,
|
|
76
|
+
r: item.r ?? 10,
|
|
77
|
+
}));
|
|
78
|
+
const datasetLabel = s[0].label || "Data";
|
|
79
|
+
s = [{ name: datasetLabel, points }];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Normalize row-oriented format passed via series prop
|
|
83
|
+
else if (!d && Array.isArray(s) && s.length > 0 && s[0] &&
|
|
84
|
+
typeof s[0] === "object" && !Array.isArray(s[0]) &&
|
|
85
|
+
"label" in s[0]) {
|
|
86
|
+
if ("value" in s[0]) {
|
|
87
|
+
// Single-series {label, value}
|
|
88
|
+
l = s.map(item => item.label);
|
|
89
|
+
d = s.map(item => item.value);
|
|
90
|
+
s = null;
|
|
91
|
+
} else {
|
|
92
|
+
// Multi-series row-oriented
|
|
93
|
+
const keys = Object.keys(s[0]).filter(k => k !== "label");
|
|
94
|
+
l = s.map(item => item.label);
|
|
95
|
+
s = keys.map(key => ({ name: key, values: s.map(item => item[key]) }));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return { data: d, series: s, labels: l };
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const seriesCount = $derived(normalized.series ? normalized.series.length : (normalized.data ? 1 : 0));
|
|
103
|
+
|
|
104
|
+
// Shape version — changes only when chart structure changes
|
|
105
|
+
const shapeKey = $derived(`${type}-${style}-${theme}`);
|
|
106
|
+
|
|
107
|
+
let canvasEl = $state();
|
|
108
|
+
let chartInstance = null;
|
|
109
|
+
|
|
110
|
+
// Clean up chart when component unmounts
|
|
111
|
+
onDestroy(() => {
|
|
112
|
+
chartInstance?.destroy();
|
|
113
|
+
chartInstance = null;
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Single effect: recreate on shape change, update in-place otherwise
|
|
117
|
+
$effect(() => {
|
|
118
|
+
if (!canvasEl) return;
|
|
119
|
+
|
|
120
|
+
// Track all deps
|
|
121
|
+
shapeKey; normalized; options; title; legend; animated; xAxisLabel; yAxisLabel;
|
|
122
|
+
|
|
123
|
+
const canvas = canvasEl;
|
|
124
|
+
const tokens = readTokens(canvas);
|
|
125
|
+
|
|
126
|
+
// Check if a chart already exists on this canvas
|
|
127
|
+
const existing = ChartJS.getChart(canvas);
|
|
128
|
+
|
|
129
|
+
if (existing && existing.config.type === type) {
|
|
130
|
+
// Shape unchanged — update data and options in place
|
|
131
|
+
existing.data = buildData(type, { data: normalized.data, series: normalized.series, labels: normalized.labels }, tokens);
|
|
132
|
+
existing.options = buildOptions(type, style, tokens, { title, legend, animated, userOptions: options, seriesCount, xAxisLabel, yAxisLabel });
|
|
133
|
+
existing.update();
|
|
134
|
+
chartInstance = existing;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Shape changed (or first mount) — destroy old if any, then create new
|
|
139
|
+
if (existing) existing.destroy();
|
|
140
|
+
|
|
141
|
+
const ctx = canvas.getContext("2d");
|
|
142
|
+
const cfg = {
|
|
143
|
+
type,
|
|
144
|
+
data: buildData(type, { data: normalized.data, series: normalized.series, labels: normalized.labels }, tokens),
|
|
145
|
+
options: buildOptions(type, style, tokens, { title, legend, animated, userOptions: options, seriesCount, xAxisLabel, yAxisLabel }),
|
|
146
|
+
};
|
|
147
|
+
chartInstance = new ChartJS(ctx, cfg);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
function downloadChart() {
|
|
151
|
+
if (!canvasEl) return;
|
|
152
|
+
const link = document.createElement("a");
|
|
153
|
+
link.download = `${title || type}-chart.png`;
|
|
154
|
+
link.href = canvasEl.toDataURL("image/png");
|
|
155
|
+
document.body.appendChild(link);
|
|
156
|
+
link.click();
|
|
157
|
+
document.body.removeChild(link);
|
|
158
|
+
}
|
|
159
|
+
</script>
|
|
160
|
+
|
|
161
|
+
<div
|
|
162
|
+
class="s-chart {styleClass} {themeClass} {typeClass} {downloadable ? 's-chart-downloadable' : ''}"
|
|
163
|
+
style="height:{heightStyle}"
|
|
164
|
+
{...rest}
|
|
165
|
+
>
|
|
166
|
+
<canvas
|
|
167
|
+
bind:this={canvasEl}
|
|
168
|
+
role="img"
|
|
169
|
+
aria-label={title || `${type} chart`}
|
|
170
|
+
></canvas>
|
|
171
|
+
{#if downloadable}
|
|
172
|
+
<button
|
|
173
|
+
type="button"
|
|
174
|
+
class="s-chart-download-btn"
|
|
175
|
+
onclick={downloadChart}
|
|
176
|
+
aria-label="Download chart as PNG"
|
|
177
|
+
title="Download as PNG"
|
|
178
|
+
>
|
|
179
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
180
|
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
|
|
181
|
+
<polyline points="7 10 12 15 17 10"/>
|
|
182
|
+
<line x1="12" y1="15" x2="12" y2="3"/>
|
|
183
|
+
</svg>
|
|
184
|
+
</button>
|
|
185
|
+
{/if}
|
|
186
|
+
</div>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default Chart;
|
|
2
|
+
type Chart = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Chart: import("svelte").Component<{
|
|
7
|
+
type: any;
|
|
8
|
+
data?: any;
|
|
9
|
+
series?: any;
|
|
10
|
+
labels?: any;
|
|
11
|
+
options?: Record<string, any>;
|
|
12
|
+
title?: string;
|
|
13
|
+
height?: number;
|
|
14
|
+
legend?: string;
|
|
15
|
+
animated?: boolean;
|
|
16
|
+
downloadable?: boolean;
|
|
17
|
+
xAxisLabel?: string;
|
|
18
|
+
yAxisLabel?: string;
|
|
19
|
+
style: any;
|
|
20
|
+
theme: any;
|
|
21
|
+
} & Record<string, any>, {}, "">;
|
|
22
|
+
type $$ComponentProps = {
|
|
23
|
+
type: any;
|
|
24
|
+
data?: any;
|
|
25
|
+
series?: any;
|
|
26
|
+
labels?: any;
|
|
27
|
+
options?: Record<string, any>;
|
|
28
|
+
title?: string;
|
|
29
|
+
height?: number;
|
|
30
|
+
legend?: string;
|
|
31
|
+
animated?: boolean;
|
|
32
|
+
downloadable?: boolean;
|
|
33
|
+
xAxisLabel?: string;
|
|
34
|
+
yAxisLabel?: string;
|
|
35
|
+
style: any;
|
|
36
|
+
theme: any;
|
|
37
|
+
} & Record<string, any>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Chart from "./Chart.svelte";
|
|
3
|
+
let { data, series, labels, title, height, legend, animated, options, style, theme, ...rest } = $props();
|
|
4
|
+
</script>
|
|
5
|
+
<Chart type="combo" {data} {series} {labels} {title} {height} {legend} {animated} {options} {style} {theme} {...rest} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default ComboChart;
|
|
2
|
+
type ComboChart = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ComboChart: import("svelte").Component<{
|
|
7
|
+
data: any;
|
|
8
|
+
series: any;
|
|
9
|
+
labels: any;
|
|
10
|
+
title: any;
|
|
11
|
+
height: any;
|
|
12
|
+
legend: any;
|
|
13
|
+
animated: any;
|
|
14
|
+
options: any;
|
|
15
|
+
style: any;
|
|
16
|
+
theme: any;
|
|
17
|
+
} & Record<string, any>, {}, "">;
|
|
18
|
+
type $$ComponentProps = {
|
|
19
|
+
data: any;
|
|
20
|
+
series: any;
|
|
21
|
+
labels: any;
|
|
22
|
+
title: any;
|
|
23
|
+
height: any;
|
|
24
|
+
legend: any;
|
|
25
|
+
animated: any;
|
|
26
|
+
options: any;
|
|
27
|
+
style: any;
|
|
28
|
+
theme: any;
|
|
29
|
+
} & Record<string, any>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Chart from "./Chart.svelte";
|
|
3
|
+
let { data, series, labels, title, height, legend, animated, options, style, theme, ...rest } = $props();
|
|
4
|
+
</script>
|
|
5
|
+
<Chart type="doughnut" {data} {series} {labels} {title} {height} {legend} {animated} {options} {style} {theme} {...rest} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default DoughnutChart;
|
|
2
|
+
type DoughnutChart = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const DoughnutChart: import("svelte").Component<{
|
|
7
|
+
data: any;
|
|
8
|
+
series: any;
|
|
9
|
+
labels: any;
|
|
10
|
+
title: any;
|
|
11
|
+
height: any;
|
|
12
|
+
legend: any;
|
|
13
|
+
animated: any;
|
|
14
|
+
options: any;
|
|
15
|
+
style: any;
|
|
16
|
+
theme: any;
|
|
17
|
+
} & Record<string, any>, {}, "">;
|
|
18
|
+
type $$ComponentProps = {
|
|
19
|
+
data: any;
|
|
20
|
+
series: any;
|
|
21
|
+
labels: any;
|
|
22
|
+
title: any;
|
|
23
|
+
height: any;
|
|
24
|
+
legend: any;
|
|
25
|
+
animated: any;
|
|
26
|
+
options: any;
|
|
27
|
+
style: any;
|
|
28
|
+
theme: any;
|
|
29
|
+
} & Record<string, any>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Chart from "./Chart.svelte";
|
|
3
|
+
let { data, series, labels, title, height, legend, animated, options, style, theme, ...rest } = $props();
|
|
4
|
+
</script>
|
|
5
|
+
<Chart type="line" {data} {series} {labels} {title} {height} {legend} {animated} {options} {style} {theme} {...rest} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default LineChart;
|
|
2
|
+
type LineChart = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const LineChart: import("svelte").Component<{
|
|
7
|
+
data: any;
|
|
8
|
+
series: any;
|
|
9
|
+
labels: any;
|
|
10
|
+
title: any;
|
|
11
|
+
height: any;
|
|
12
|
+
legend: any;
|
|
13
|
+
animated: any;
|
|
14
|
+
options: any;
|
|
15
|
+
style: any;
|
|
16
|
+
theme: any;
|
|
17
|
+
} & Record<string, any>, {}, "">;
|
|
18
|
+
type $$ComponentProps = {
|
|
19
|
+
data: any;
|
|
20
|
+
series: any;
|
|
21
|
+
labels: any;
|
|
22
|
+
title: any;
|
|
23
|
+
height: any;
|
|
24
|
+
legend: any;
|
|
25
|
+
animated: any;
|
|
26
|
+
options: any;
|
|
27
|
+
style: any;
|
|
28
|
+
theme: any;
|
|
29
|
+
} & Record<string, any>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Chart from "./Chart.svelte";
|
|
3
|
+
let { data, series, labels, title, height, legend, animated, options, style, theme, ...rest } = $props();
|
|
4
|
+
</script>
|
|
5
|
+
<Chart type="pie" {data} {series} {labels} {title} {height} {legend} {animated} {options} {style} {theme} {...rest} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default PieChart;
|
|
2
|
+
type PieChart = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const PieChart: import("svelte").Component<{
|
|
7
|
+
data: any;
|
|
8
|
+
series: any;
|
|
9
|
+
labels: any;
|
|
10
|
+
title: any;
|
|
11
|
+
height: any;
|
|
12
|
+
legend: any;
|
|
13
|
+
animated: any;
|
|
14
|
+
options: any;
|
|
15
|
+
style: any;
|
|
16
|
+
theme: any;
|
|
17
|
+
} & Record<string, any>, {}, "">;
|
|
18
|
+
type $$ComponentProps = {
|
|
19
|
+
data: any;
|
|
20
|
+
series: any;
|
|
21
|
+
labels: any;
|
|
22
|
+
title: any;
|
|
23
|
+
height: any;
|
|
24
|
+
legend: any;
|
|
25
|
+
animated: any;
|
|
26
|
+
options: any;
|
|
27
|
+
style: any;
|
|
28
|
+
theme: any;
|
|
29
|
+
} & Record<string, any>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Chart from "./Chart.svelte";
|
|
3
|
+
let { data, series, labels, title, height, legend, animated, options, style, theme, ...rest } = $props();
|
|
4
|
+
</script>
|
|
5
|
+
<Chart type="polarArea" {data} {series} {labels} {title} {height} {legend} {animated} {options} {style} {theme} {...rest} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default PolarAreaChart;
|
|
2
|
+
type PolarAreaChart = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const PolarAreaChart: import("svelte").Component<{
|
|
7
|
+
data: any;
|
|
8
|
+
series: any;
|
|
9
|
+
labels: any;
|
|
10
|
+
title: any;
|
|
11
|
+
height: any;
|
|
12
|
+
legend: any;
|
|
13
|
+
animated: any;
|
|
14
|
+
options: any;
|
|
15
|
+
style: any;
|
|
16
|
+
theme: any;
|
|
17
|
+
} & Record<string, any>, {}, "">;
|
|
18
|
+
type $$ComponentProps = {
|
|
19
|
+
data: any;
|
|
20
|
+
series: any;
|
|
21
|
+
labels: any;
|
|
22
|
+
title: any;
|
|
23
|
+
height: any;
|
|
24
|
+
legend: any;
|
|
25
|
+
animated: any;
|
|
26
|
+
options: any;
|
|
27
|
+
style: any;
|
|
28
|
+
theme: any;
|
|
29
|
+
} & Record<string, any>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Chart from "./Chart.svelte";
|
|
3
|
+
let { data, series, labels, title, height, legend, animated, options, style, theme, ...rest } = $props();
|
|
4
|
+
</script>
|
|
5
|
+
<Chart type="radar" {data} {series} {labels} {title} {height} {legend} {animated} {options} {style} {theme} {...rest} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default RadarChart;
|
|
2
|
+
type RadarChart = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const RadarChart: import("svelte").Component<{
|
|
7
|
+
data: any;
|
|
8
|
+
series: any;
|
|
9
|
+
labels: any;
|
|
10
|
+
title: any;
|
|
11
|
+
height: any;
|
|
12
|
+
legend: any;
|
|
13
|
+
animated: any;
|
|
14
|
+
options: any;
|
|
15
|
+
style: any;
|
|
16
|
+
theme: any;
|
|
17
|
+
} & Record<string, any>, {}, "">;
|
|
18
|
+
type $$ComponentProps = {
|
|
19
|
+
data: any;
|
|
20
|
+
series: any;
|
|
21
|
+
labels: any;
|
|
22
|
+
title: any;
|
|
23
|
+
height: any;
|
|
24
|
+
legend: any;
|
|
25
|
+
animated: any;
|
|
26
|
+
options: any;
|
|
27
|
+
style: any;
|
|
28
|
+
theme: any;
|
|
29
|
+
} & Record<string, any>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Chart from "./Chart.svelte";
|
|
3
|
+
let { data, series, labels, title, height, legend, animated, options, style, theme, ...rest } = $props();
|
|
4
|
+
</script>
|
|
5
|
+
<Chart type="scatter" {data} {series} {labels} {title} {height} {legend} {animated} {options} {style} {theme} {...rest} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default ScatterChart;
|
|
2
|
+
type ScatterChart = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ScatterChart: import("svelte").Component<{
|
|
7
|
+
data: any;
|
|
8
|
+
series: any;
|
|
9
|
+
labels: any;
|
|
10
|
+
title: any;
|
|
11
|
+
height: any;
|
|
12
|
+
legend: any;
|
|
13
|
+
animated: any;
|
|
14
|
+
options: any;
|
|
15
|
+
style: any;
|
|
16
|
+
theme: any;
|
|
17
|
+
} & Record<string, any>, {}, "">;
|
|
18
|
+
type $$ComponentProps = {
|
|
19
|
+
data: any;
|
|
20
|
+
series: any;
|
|
21
|
+
labels: any;
|
|
22
|
+
title: any;
|
|
23
|
+
height: any;
|
|
24
|
+
legend: any;
|
|
25
|
+
animated: any;
|
|
26
|
+
options: any;
|
|
27
|
+
style: any;
|
|
28
|
+
theme: any;
|
|
29
|
+
} & Record<string, any>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Chart from "./Chart.svelte";
|
|
3
|
+
let { data, series, labels, title, height, legend, animated, options: userOpts = {}, style, theme, ...rest } = $props();
|
|
4
|
+
// Merge user options over the stacked defaults so users can override
|
|
5
|
+
let mergedOptions = $derived.by(() => {
|
|
6
|
+
const base = {
|
|
7
|
+
scales: {
|
|
8
|
+
x: { stacked: true },
|
|
9
|
+
y: { stacked: true },
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
if (userOpts && typeof userOpts === "object" && Object.keys(userOpts).length > 0) {
|
|
13
|
+
return { ...base, ...userOpts, scales: { ...base.scales, ...(userOpts.scales || {}) } };
|
|
14
|
+
}
|
|
15
|
+
return base;
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
<Chart type="bar" {data} {series} {labels} {title} {height} {legend} {animated} options={mergedOptions} {style} {theme} {...rest} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default StackedBarChart;
|
|
2
|
+
type StackedBarChart = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const StackedBarChart: import("svelte").Component<{
|
|
7
|
+
data: any;
|
|
8
|
+
series: any;
|
|
9
|
+
labels: any;
|
|
10
|
+
title: any;
|
|
11
|
+
height: any;
|
|
12
|
+
legend: any;
|
|
13
|
+
animated: any;
|
|
14
|
+
options?: Record<string, any>;
|
|
15
|
+
style: any;
|
|
16
|
+
theme: any;
|
|
17
|
+
} & Record<string, any>, {}, "">;
|
|
18
|
+
type $$ComponentProps = {
|
|
19
|
+
data: any;
|
|
20
|
+
series: any;
|
|
21
|
+
labels: any;
|
|
22
|
+
title: any;
|
|
23
|
+
height: any;
|
|
24
|
+
legend: any;
|
|
25
|
+
animated: any;
|
|
26
|
+
options?: Record<string, any>;
|
|
27
|
+
style: any;
|
|
28
|
+
theme: any;
|
|
29
|
+
} & Record<string, any>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Chart from "./Chart.svelte";
|
|
3
|
+
let { data, series, labels, title, height, legend, animated, options: userOpts = {}, style, theme, ...rest } = $props();
|
|
4
|
+
// Merge user options over the stacked defaults so users can override
|
|
5
|
+
let mergedOptions = $derived.by(() => {
|
|
6
|
+
const base = {
|
|
7
|
+
scales: {
|
|
8
|
+
x: { stacked: true },
|
|
9
|
+
y: { stacked: true },
|
|
10
|
+
},
|
|
11
|
+
elements: {
|
|
12
|
+
line: { fill: true },
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
if (userOpts && typeof userOpts === "object" && Object.keys(userOpts).length > 0) {
|
|
16
|
+
return { ...base, ...userOpts, scales: { ...base.scales, ...(userOpts.scales || {}) }, elements: { ...base.elements, ...(userOpts.elements || {}), line: { ...base.elements.line, ...((userOpts.elements || {}).line || {}) } } };
|
|
17
|
+
}
|
|
18
|
+
return base;
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
<Chart type="line" {data} {series} {labels} {title} {height} {legend} {animated} options={mergedOptions} {style} {theme} {...rest} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default StackedLineChart;
|
|
2
|
+
type StackedLineChart = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const StackedLineChart: import("svelte").Component<{
|
|
7
|
+
data: any;
|
|
8
|
+
series: any;
|
|
9
|
+
labels: any;
|
|
10
|
+
title: any;
|
|
11
|
+
height: any;
|
|
12
|
+
legend: any;
|
|
13
|
+
animated: any;
|
|
14
|
+
options?: Record<string, any>;
|
|
15
|
+
style: any;
|
|
16
|
+
theme: any;
|
|
17
|
+
} & Record<string, any>, {}, "">;
|
|
18
|
+
type $$ComponentProps = {
|
|
19
|
+
data: any;
|
|
20
|
+
series: any;
|
|
21
|
+
labels: any;
|
|
22
|
+
title: any;
|
|
23
|
+
height: any;
|
|
24
|
+
legend: any;
|
|
25
|
+
animated: any;
|
|
26
|
+
options?: Record<string, any>;
|
|
27
|
+
style: any;
|
|
28
|
+
theme: any;
|
|
29
|
+
} & Record<string, any>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read theme tokens from a DOM element's computed style.
|
|
3
|
+
* Every returned value is a resolved CSS color string.
|
|
4
|
+
*/
|
|
5
|
+
export function readTokens(el: any): {
|
|
6
|
+
primary: string;
|
|
7
|
+
secondary: string;
|
|
8
|
+
surface: string;
|
|
9
|
+
text: string;
|
|
10
|
+
textHint: string;
|
|
11
|
+
textSecondary: string;
|
|
12
|
+
cardBg: string;
|
|
13
|
+
border: string;
|
|
14
|
+
info: string;
|
|
15
|
+
success: string;
|
|
16
|
+
warning: string;
|
|
17
|
+
error: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Generate a palette of n colors cycling through the theme's status colors.
|
|
21
|
+
* For n > 6, alpha-reduced repeats are used (no external color deps).
|
|
22
|
+
*/
|
|
23
|
+
export function palette(n: any, tokens: any): any[];
|
|
24
|
+
/**
|
|
25
|
+
* Build a Chart.js data object from the canonical user-facing API.
|
|
26
|
+
*/
|
|
27
|
+
export function buildData(type: any, { data, series, labels }: {
|
|
28
|
+
data: any;
|
|
29
|
+
series: any;
|
|
30
|
+
labels: any;
|
|
31
|
+
}, tokens: any): {
|
|
32
|
+
datasets: {
|
|
33
|
+
label: any;
|
|
34
|
+
data: any;
|
|
35
|
+
backgroundColor: any;
|
|
36
|
+
}[];
|
|
37
|
+
labels?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
labels: any;
|
|
40
|
+
datasets: any;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Build a full Chart.js options object inferred from type, style, and tokens.
|
|
44
|
+
* @param {string} type - chart type
|
|
45
|
+
* @param {string} style - visual design language
|
|
46
|
+
* @param {object} tokens - resolved CSS theme tokens
|
|
47
|
+
* @param {{ title, legend, animated, userOptions, seriesCount, xAxisLabel, yAxisLabel }} params
|
|
48
|
+
*/
|
|
49
|
+
export function buildOptions(type: string, style: string, tokens: object, { title, legend, animated, userOptions, seriesCount, xAxisLabel, yAxisLabel }: {
|
|
50
|
+
title: any;
|
|
51
|
+
legend: any;
|
|
52
|
+
animated: any;
|
|
53
|
+
userOptions: any;
|
|
54
|
+
seriesCount: any;
|
|
55
|
+
xAxisLabel: any;
|
|
56
|
+
yAxisLabel: any;
|
|
57
|
+
}): {
|
|
58
|
+
responsive: boolean;
|
|
59
|
+
maintainAspectRatio: boolean;
|
|
60
|
+
animation: boolean;
|
|
61
|
+
color: any;
|
|
62
|
+
font: {
|
|
63
|
+
family: string;
|
|
64
|
+
};
|
|
65
|
+
plugins: {
|
|
66
|
+
legend: {
|
|
67
|
+
display: boolean;
|
|
68
|
+
position: string;
|
|
69
|
+
labels: {
|
|
70
|
+
color: any;
|
|
71
|
+
usePointStyle: boolean;
|
|
72
|
+
padding: number;
|
|
73
|
+
font: {
|
|
74
|
+
size: number;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
tooltip: {
|
|
79
|
+
enabled: boolean;
|
|
80
|
+
backgroundColor: any;
|
|
81
|
+
titleColor: any;
|
|
82
|
+
bodyColor: any;
|
|
83
|
+
borderColor: any;
|
|
84
|
+
borderWidth: number;
|
|
85
|
+
padding: number;
|
|
86
|
+
cornerRadius: number;
|
|
87
|
+
boxPadding: number;
|
|
88
|
+
};
|
|
89
|
+
title: {
|
|
90
|
+
display: boolean;
|
|
91
|
+
text: any;
|
|
92
|
+
color: any;
|
|
93
|
+
font: {
|
|
94
|
+
size: number;
|
|
95
|
+
weight: string;
|
|
96
|
+
};
|
|
97
|
+
padding: {
|
|
98
|
+
bottom: number;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|