@classic-homes/charts-svelte 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/components/base/ChartContainer.svelte +63 -0
- package/dist/lib/components/base/ChartContainer.svelte.d.ts +17 -0
- package/dist/lib/components/base/ChartEmpty.svelte +39 -0
- package/dist/lib/components/base/ChartEmpty.svelte.d.ts +8 -0
- package/dist/lib/components/base/ChartError.svelte +49 -0
- package/dist/lib/components/base/ChartError.svelte.d.ts +9 -0
- package/dist/lib/components/base/ChartSkeleton.svelte +37 -0
- package/dist/lib/components/base/ChartSkeleton.svelte.d.ts +7 -0
- package/dist/lib/components/base/index.d.ts +4 -0
- package/dist/lib/components/base/index.js +4 -0
- package/dist/lib/components/core/AreaChart.svelte +198 -0
- package/dist/lib/components/core/AreaChart.svelte.d.ts +7 -0
- package/dist/lib/components/core/BarChart.svelte +186 -0
- package/dist/lib/components/core/BarChart.svelte.d.ts +7 -0
- package/dist/lib/components/core/DonutChart.svelte +207 -0
- package/dist/lib/components/core/DonutChart.svelte.d.ts +7 -0
- package/dist/lib/components/core/LineChart.svelte +203 -0
- package/dist/lib/components/core/LineChart.svelte.d.ts +7 -0
- package/dist/lib/components/core/PieChart.svelte +156 -0
- package/dist/lib/components/core/PieChart.svelte.d.ts +7 -0
- package/dist/lib/components/core/ScatterChart.svelte +224 -0
- package/dist/lib/components/core/ScatterChart.svelte.d.ts +7 -0
- package/dist/lib/components/core/index.d.ts +6 -0
- package/dist/lib/components/core/index.js +6 -0
- package/dist/lib/components/extended/CandlestickChart.svelte +200 -0
- package/dist/lib/components/extended/CandlestickChart.svelte.d.ts +7 -0
- package/dist/lib/components/extended/FunnelChart.svelte +142 -0
- package/dist/lib/components/extended/FunnelChart.svelte.d.ts +7 -0
- package/dist/lib/components/extended/GaugeChart.svelte +113 -0
- package/dist/lib/components/extended/GaugeChart.svelte.d.ts +7 -0
- package/dist/lib/components/extended/HeatmapChart.svelte +159 -0
- package/dist/lib/components/extended/HeatmapChart.svelte.d.ts +7 -0
- package/dist/lib/components/extended/RadarChart.svelte +131 -0
- package/dist/lib/components/extended/RadarChart.svelte.d.ts +7 -0
- package/dist/lib/components/extended/SankeyChart.svelte +129 -0
- package/dist/lib/components/extended/SankeyChart.svelte.d.ts +7 -0
- package/dist/lib/components/extended/TreemapChart.svelte +133 -0
- package/dist/lib/components/extended/TreemapChart.svelte.d.ts +7 -0
- package/dist/lib/components/extended/index.d.ts +7 -0
- package/dist/lib/components/extended/index.js +7 -0
- package/dist/lib/components/index.d.ts +3 -0
- package/dist/lib/components/index.js +6 -0
- package/dist/lib/composables/index.d.ts +2 -0
- package/dist/lib/composables/index.js +2 -0
- package/dist/lib/composables/useChartTheme.svelte.d.ts +11 -0
- package/dist/lib/composables/useChartTheme.svelte.js +66 -0
- package/dist/lib/composables/useReducedMotion.svelte.d.ts +6 -0
- package/dist/lib/composables/useReducedMotion.svelte.js +26 -0
- package/dist/lib/index.d.ts +9 -0
- package/dist/lib/index.js +17 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/package.json +45 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TreemapChartProps } from '@classic-homes/charts-core';
|
|
2
|
+
interface Props extends Omit<TreemapChartProps, 'class'> {
|
|
3
|
+
class?: string;
|
|
4
|
+
}
|
|
5
|
+
declare const TreemapChart: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type TreemapChart = ReturnType<typeof TreemapChart>;
|
|
7
|
+
export default TreemapChart;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as RadarChart } from './RadarChart.svelte';
|
|
2
|
+
export { default as FunnelChart } from './FunnelChart.svelte';
|
|
3
|
+
export { default as GaugeChart } from './GaugeChart.svelte';
|
|
4
|
+
export { default as HeatmapChart } from './HeatmapChart.svelte';
|
|
5
|
+
export { default as TreemapChart } from './TreemapChart.svelte';
|
|
6
|
+
export { default as CandlestickChart } from './CandlestickChart.svelte';
|
|
7
|
+
export { default as SankeyChart } from './SankeyChart.svelte';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as RadarChart } from './RadarChart.svelte';
|
|
2
|
+
export { default as FunnelChart } from './FunnelChart.svelte';
|
|
3
|
+
export { default as GaugeChart } from './GaugeChart.svelte';
|
|
4
|
+
export { default as HeatmapChart } from './HeatmapChart.svelte';
|
|
5
|
+
export { default as TreemapChart } from './TreemapChart.svelte';
|
|
6
|
+
export { default as CandlestickChart } from './CandlestickChart.svelte';
|
|
7
|
+
export { default as SankeyChart } from './SankeyChart.svelte';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ChartContainer, ChartSkeleton, ChartError, ChartEmpty } from './base/index.js';
|
|
2
|
+
export { LineChart, BarChart, PieChart, AreaChart, ScatterChart, DonutChart, } from './core/index.js';
|
|
3
|
+
export { RadarChart, FunnelChart, GaugeChart, HeatmapChart, TreemapChart, CandlestickChart, SankeyChart, } from './extended/index.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Base components
|
|
2
|
+
export { ChartContainer, ChartSkeleton, ChartError, ChartEmpty } from './base/index.js';
|
|
3
|
+
// Core charts
|
|
4
|
+
export { LineChart, BarChart, PieChart, AreaChart, ScatterChart, DonutChart, } from './core/index.js';
|
|
5
|
+
// Extended charts
|
|
6
|
+
export { RadarChart, FunnelChart, GaugeChart, HeatmapChart, TreemapChart, CandlestickChart, SankeyChart, } from './extended/index.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register Classic Theme ECharts themes
|
|
3
|
+
*/
|
|
4
|
+
export declare function registerClassicThemes(): void;
|
|
5
|
+
/**
|
|
6
|
+
* Create a reactive chart theme based on system/document dark mode
|
|
7
|
+
* @param getPreference - A getter function that returns the current theme preference
|
|
8
|
+
*/
|
|
9
|
+
export declare function useChartTheme(getPreference: () => 'light' | 'dark' | 'auto'): {
|
|
10
|
+
readonly theme: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as echarts from 'echarts/core';
|
|
2
|
+
import { lightTheme, darkTheme, THEME_LIGHT, THEME_DARK } from '@classic-homes/charts-core';
|
|
3
|
+
let themesRegistered = false;
|
|
4
|
+
/**
|
|
5
|
+
* Register Classic Theme ECharts themes
|
|
6
|
+
*/
|
|
7
|
+
export function registerClassicThemes() {
|
|
8
|
+
if (themesRegistered)
|
|
9
|
+
return;
|
|
10
|
+
echarts.registerTheme(THEME_LIGHT, lightTheme);
|
|
11
|
+
echarts.registerTheme(THEME_DARK, darkTheme);
|
|
12
|
+
themesRegistered = true;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create a reactive chart theme based on system/document dark mode
|
|
16
|
+
* @param getPreference - A getter function that returns the current theme preference
|
|
17
|
+
*/
|
|
18
|
+
export function useChartTheme(getPreference) {
|
|
19
|
+
let currentTheme = $state(THEME_LIGHT);
|
|
20
|
+
function updateTheme() {
|
|
21
|
+
const preference = getPreference();
|
|
22
|
+
if (preference !== 'auto') {
|
|
23
|
+
currentTheme = preference === 'dark' ? THEME_DARK : THEME_LIGHT;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// Check for dark class on html element
|
|
27
|
+
if (typeof document !== 'undefined') {
|
|
28
|
+
const isDark = document.documentElement.classList.contains('dark');
|
|
29
|
+
currentTheme = isDark ? THEME_DARK : THEME_LIGHT;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
$effect(() => {
|
|
33
|
+
// Register themes on first use
|
|
34
|
+
registerClassicThemes();
|
|
35
|
+
// Initial theme check
|
|
36
|
+
updateTheme();
|
|
37
|
+
const preference = getPreference();
|
|
38
|
+
if (preference !== 'auto' || typeof document === 'undefined')
|
|
39
|
+
return;
|
|
40
|
+
// Watch for dark mode class changes
|
|
41
|
+
const observer = new MutationObserver((mutations) => {
|
|
42
|
+
mutations.forEach((mutation) => {
|
|
43
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
|
44
|
+
updateTheme();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
observer.observe(document.documentElement, {
|
|
49
|
+
attributes: true,
|
|
50
|
+
attributeFilter: ['class'],
|
|
51
|
+
});
|
|
52
|
+
// Also listen for media query changes
|
|
53
|
+
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
54
|
+
const handleMediaChange = () => updateTheme();
|
|
55
|
+
mediaQuery.addEventListener('change', handleMediaChange);
|
|
56
|
+
return () => {
|
|
57
|
+
observer.disconnect();
|
|
58
|
+
mediaQuery.removeEventListener('change', handleMediaChange);
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
get theme() {
|
|
63
|
+
return currentTheme;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composable to detect user's reduced motion preference
|
|
3
|
+
*/
|
|
4
|
+
export function useReducedMotion() {
|
|
5
|
+
let reducedMotion = $state(false);
|
|
6
|
+
$effect(() => {
|
|
7
|
+
if (typeof window === 'undefined')
|
|
8
|
+
return;
|
|
9
|
+
const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
10
|
+
// Set initial value
|
|
11
|
+
reducedMotion = mediaQuery.matches;
|
|
12
|
+
// Listen for changes
|
|
13
|
+
const handleChange = (event) => {
|
|
14
|
+
reducedMotion = event.matches;
|
|
15
|
+
};
|
|
16
|
+
mediaQuery.addEventListener('change', handleChange);
|
|
17
|
+
return () => {
|
|
18
|
+
mediaQuery.removeEventListener('change', handleChange);
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
get value() {
|
|
23
|
+
return reducedMotion;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classic-homes/charts-svelte
|
|
3
|
+
*
|
|
4
|
+
* Svelte ECharts components for the Classic Theme design system
|
|
5
|
+
*/
|
|
6
|
+
export { ChartContainer, ChartSkeleton, ChartError, ChartEmpty, LineChart, BarChart, PieChart, AreaChart, ScatterChart, DonutChart, RadarChart, FunnelChart, GaugeChart, HeatmapChart, TreemapChart, CandlestickChart, SankeyChart, } from './components/index.js';
|
|
7
|
+
export { useChartTheme, registerClassicThemes, useReducedMotion } from './composables/index.js';
|
|
8
|
+
export { cn } from './utils.js';
|
|
9
|
+
export type { BaseChartProps, LineChartProps, BarChartProps, PieChartProps, DonutChartProps, AreaChartProps, ScatterChartProps, RadarChartProps, FunnelChartProps, GaugeChartProps, HeatmapChartProps, TreemapChartProps, CandlestickChartProps, SankeyChartProps, LineChartData, LineSeriesData, BarChartData, BarSeriesData, PieSliceData, AreaChartData, AreaSeriesData, ScatterChartData, ScatterSeriesData, RadarChartData, RadarSeriesData, RadarIndicator, FunnelSliceData, HeatmapData, TreemapNode, TreemapLevel, CandlestickData, CandlestickItem, SankeyData, SankeyNode, SankeyLink, DataPointEventParams, SliceEventParams, HeatmapEventParams, TreemapEventParams, CandlestickEventParams, SankeyEventParams, } from '@classic-homes/charts-core';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classic-homes/charts-svelte
|
|
3
|
+
*
|
|
4
|
+
* Svelte ECharts components for the Classic Theme design system
|
|
5
|
+
*/
|
|
6
|
+
// Components
|
|
7
|
+
export {
|
|
8
|
+
// Base
|
|
9
|
+
ChartContainer, ChartSkeleton, ChartError, ChartEmpty,
|
|
10
|
+
// Core charts
|
|
11
|
+
LineChart, BarChart, PieChart, AreaChart, ScatterChart, DonutChart,
|
|
12
|
+
// Extended charts
|
|
13
|
+
RadarChart, FunnelChart, GaugeChart, HeatmapChart, TreemapChart, CandlestickChart, SankeyChart, } from './components/index.js';
|
|
14
|
+
// Composables
|
|
15
|
+
export { useChartTheme, registerClassicThemes, useReducedMotion } from './composables/index.js';
|
|
16
|
+
// Utils
|
|
17
|
+
export { cn } from './utils.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@classic-homes/charts-svelte",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Svelte ECharts components for Classic Theme",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"svelte": "./dist/lib/index.js",
|
|
7
|
+
"types": "./dist/lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/lib/index.d.ts",
|
|
11
|
+
"svelte": "./dist/lib/index.js",
|
|
12
|
+
"default": "./dist/lib/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "svelte-package -i src",
|
|
20
|
+
"dev": "svelte-package -i src --watch",
|
|
21
|
+
"clean": "rm -rf dist",
|
|
22
|
+
"typecheck": "svelte-check --tsconfig ./tsconfig.json"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@classic-homes/charts-core": "*",
|
|
26
|
+
"@classic-homes/theme-tokens": "*",
|
|
27
|
+
"clsx": "^2.1.0",
|
|
28
|
+
"tailwind-merge": "^2.2.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"echarts": "^5.5.0",
|
|
32
|
+
"svelte": "^5.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@sveltejs/package": "^2.3.0",
|
|
36
|
+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
|
37
|
+
"echarts": "^5.5.0",
|
|
38
|
+
"svelte": "^5.0.0",
|
|
39
|
+
"svelte-check": "^4.0.0",
|
|
40
|
+
"typescript": "^5.3.0"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
}
|
|
45
|
+
}
|