shadcn-vue-echarts 0.1.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/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # shadcn-vue-echarts
2
+
3
+ Vue 3 ECharts wrapper with shadcn theming support.
4
+
5
+ ## Features
6
+
7
+ - ๐ŸŽจ Shadcn-compatible theming via CSS variables
8
+ - ๐ŸŒ“ Automatic light/dark mode detection
9
+ - ๐Ÿ“ฑ Responsive resizing with ResizeObserver
10
+ - โšก SSR-safe (Nuxt 3 compatible)
11
+ - ๐Ÿ“ฆ Zero runtime dependencies (echarts is peer dep)
12
+ - ๐Ÿงช Full TypeScript support
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pnpm add shadcn-vue-echarts echarts
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```vue
23
+ <script setup lang="ts">
24
+ import { ref } from 'vue'
25
+ import { Chart } from 'shadcn-vue-echarts'
26
+ import type { EChartsOption } from 'shadcn-vue-echarts'
27
+
28
+ const option = ref<EChartsOption>({
29
+ xAxis: {
30
+ type: 'category',
31
+ data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
32
+ },
33
+ yAxis: {
34
+ type: 'value'
35
+ },
36
+ series: [
37
+ {
38
+ data: [120, 132, 101, 134, 90, 230, 210],
39
+ type: 'line'
40
+ }
41
+ ]
42
+ })
43
+ </script>
44
+
45
+ <template>
46
+ <Chart :option="option" />
47
+ </template>
48
+ ```
49
+
50
+ ## Documentation
51
+
52
+ See [docs](../../docs) for complete guides on theming, SSR, and recipes.
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var le=Object.create;var q=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ce=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ie(t))!se.call(e,a)&&a!==r&&q(e,a,{get:()=>t[a],enumerable:!(o=ne(t,a))||o.enumerable});return e};var ue=(e,t,r)=>(r=e!=null?le(ae(e)):{},ce(t||!e||!e.__esModule?q(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("vue");function R(e){return/^\d+\.?\d*\s+\d+\.?\d*%\s+\d+\.?\d*%$/.test(e.trim())}function n(e,t){if(!e)return;const r=String(e).trim();if(r.startsWith("#")){if(t!=null){const o=r.slice(1),a=parseInt(o.slice(0,2),16),u=parseInt(o.slice(2,4),16),s=parseInt(o.slice(4,6),16);return`rgba(${a}, ${u}, ${s}, ${t})`}return r}if(r.startsWith("rgb("))return t!=null&&!r.includes("rgba")?r.replace(/rgb\(/,"rgba(").replace(/\)$/,`, ${t})`):t!=null&&r.includes("rgba")?r.replace(/rgba\(([^,]+),\s*([^,]+),\s*([^,]+),\s*[^)]+\)/,`rgba($1, $2, $3, ${t})`):r;if(r.startsWith("hsl("))return t!=null?r.replace(/hsl\(/,"hsla(").replace(/\)$/,`, ${t})`):r;if(r.startsWith("hsla("))return t!=null?r.replace(/hsla\(([^,]+),\s*([^,]+),\s*([^,]+),\s*[^)]+\)/,`hsla($1, $2, $3, ${t})`):r;if(R(r)||/^\d+\.?\d*\s+\d+\.?\d*%\s+\d+\.?\d*%\s*\/\s*[\d.]+$/.test(r)){if(r.includes("/"))return t!=null&&t!==1?`hsl(${r.split("/")[0].trim()} / ${t})`:`hsl(${r})`;const o=r.split(/\s+/),a=o[0],u=o[1].replace("%",""),s=o[2].replace("%","");return t!=null&&t!==1?`hsla(${a}, ${u}%, ${s}%, ${t})`:`hsl(${a}, ${u}%, ${s}%)`}return r}function j(e,t){const r=JSON.parse(JSON.stringify(e));r.color||(r.color=t.chart.map(s=>n(s)||s)),r.textStyle||(r.textStyle={}),r.textStyle.color||(r.textStyle.color=n(t.foreground)),r.textStyle.fontFamily||(r.textStyle.fontFamily="inherit"),r.title||(r.title={}),Array.isArray(r.title)?r.title=r.title.map(s=>({...s,textStyle:{color:n(t.foreground),...s.textStyle}})):r.title.textStyle={color:n(t.foreground),...r.title.textStyle||{}},r.legend||(r.legend={}),Array.isArray(r.legend)?r.legend=r.legend.map(s=>({...s,textStyle:{color:n(t.mutedForeground),...s.textStyle}})):r.legend.textStyle={color:n(t.mutedForeground),...r.legend.textStyle||{}},r.xAxis||(r.xAxis={}),r.yAxis||(r.yAxis={});const o=n(t.border,.6)||t.border,a=n(t.border,.35)||t.border,u=n(t.mutedForeground)||t.mutedForeground;for(const s of[r.xAxis,r.yAxis])Array.isArray(s)?s.forEach(b=>G(b,o,a,u)):G(s,o,a,u);return r.tooltip||(r.tooltip={}),Array.isArray(r.tooltip)||(r.tooltip.backgroundColor=n(t.popover),r.tooltip.borderColor=n(t.border,.6),r.tooltip.textStyle={color:n(t.popoverForeground),...r.tooltip.textStyle}),r.grid||(r.grid={}),Array.isArray(r.grid)?r.grid.forEach(s=>{s.containLabel=!0}):r.grid.containLabel=!0,r}function G(e,t,r,o){e&&(e.axisLine||(e.axisLine={}),e.axisLine.lineStyle||(e.axisLine.lineStyle={}),e.axisLine.lineStyle.color||(e.axisLine.lineStyle.color=t),e.axisLabel||(e.axisLabel={}),e.axisLabel.color||(e.axisLabel.color=o),e.splitLine||(e.splitLine={}),e.splitLine.lineStyle||(e.splitLine.lineStyle={}),e.splitLine.lineStyle.color||(e.splitLine.lineStyle.color=r))}function K(e){const t=n(e.border,.6),r=n(e.border,.35),o=n(e.background);return{color:e.chart.map(u=>n(u)||u),backgroundColor:o,textStyle:{color:n(e.foreground),fontFamily:"inherit"},title:{textStyle:{color:n(e.foreground)}},grid:{borderColor:t},legend:{textStyle:{color:n(e.mutedForeground)}},tooltip:{borderColor:t,backgroundColor:o,textStyle:{color:n(e.foreground)},axisPointer:{lineStyle:{color:t,width:1},crossStyle:{color:t,width:1}}},line:{lineStyle:{width:2},symbol:"circle",symbolSize:4},bar:{borderRadius:0},pie:{itemStyle:{borderWidth:0,borderColor:t}},candlestick:{itemStyle:{color:e.chart[0],color0:e.chart[1],borderColor:e.chart[0],borderColor0:e.chart[1],borderWidth:1}},gauge:{axisTick:{distance:-30,length:8,lineStyle:{color:e.foreground,width:2}},axisLabel:{color:n(e.foreground)},splitLine:{distance:-30,length:30,lineStyle:{color:e.foreground,width:2}},detail:{valueAnimation:!0,formatter:"{value}",color:n(e.foreground)}},geo:{borderColor:t,itemStyle:{areaColor:n(e.muted),borderColor:t,borderWidth:.5},emphasis:{itemStyle:{areaColor:n(e.border,.5)}}},categoryAxis:{axisLine:{show:!0,lineStyle:{color:t}},axisLabel:{show:!0,color:n(e.mutedForeground)},splitLine:{show:!1,lineStyle:{color:r}}},valueAxis:{axisLine:{show:!1,lineStyle:{color:t}},axisLabel:{show:!0,color:n(e.mutedForeground)},splitLine:{show:!0,lineStyle:{color:r}}},logAxis:{axisLine:{show:!0,lineStyle:{color:t}},axisLabel:{show:!0,color:n(e.mutedForeground)},splitLine:{show:!0,lineStyle:{color:r}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:t}},axisLabel:{show:!0,color:n(e.mutedForeground)},splitLine:{show:!1,lineStyle:{color:r}}},angleAxis:{axisLine:{show:!0,lineStyle:{color:t}},axisLabel:{show:!0,color:n(e.mutedForeground)},splitLine:{show:!0,lineStyle:{color:r}}},radiusAxis:{axisLine:{show:!0,lineStyle:{color:t}},axisLabel:{show:!0,color:n(e.mutedForeground)},splitLine:{show:!0,lineStyle:{color:r}}},radar:{itemStyle:{borderWidth:1},lineStyle:{width:2},symbolSize:4},scatter:{itemStyle:{borderWidth:0,borderColor:t}},graph:{itemStyle:{borderWidth:0,borderColor:t},lineStyle:{width:1,color:t},symbolSize:4,smooth:!1},map:{itemStyle:{areaColor:n(e.muted),borderColor:t,borderWidth:.5},emphasis:{itemStyle:{areaColor:n(e.border,.5)}}},toolbox:{iconStyle:{borderColor:n(e.foreground)},emphasis:{iconStyle:{borderColor:n(e.foreground)}}},timeline:{lineStyle:{color:t,width:1},itemStyle:{color:e.chart[0],borderWidth:1},controlStyle:{color:n(e.foreground),borderColor:t,borderWidth:.5},checkpointStyle:{color:e.chart[0],borderColor:e.chart[0]},label:{color:n(e.foreground)},emphasis:{itemStyle:{color:e.chart[0]},controlStyle:{color:n(e.foreground),borderColor:t,borderWidth:.5},label:{color:n(e.foreground)}}},visualMap:{textStyle:{color:n(e.foreground)}},dataZoom:{backgroundColor:"rgba(0,0,0,0)",dataBackgroundColor:n(e.border,.1),fillerColor:n(e.border,.2),handleColor:n(e.foreground),handleSize:"100%",textStyle:{color:n(e.foreground)}},markPoint:{label:{color:n(e.popoverForeground)}},parallel:{itemStyle:{borderColor:t,borderWidth:1}}}}function V(){return typeof document<"u"&&typeof window<"u"}function de(e,t){if(e===t)return!0;if(e==null||t==null||typeof e!="object"||typeof t!="object")return!1;const r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(const a of r)if(!o.includes(a)||e[a]!==t[a])return!1;return!0}function m(e,t){if(!e)return null;try{return getComputedStyle(e).getPropertyValue(t).trim()||null}catch{return null}}function fe(e){return typeof document>"u"?null:m(document.documentElement,e)}const J=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899"];function X(e){var g,L,z,S,$,F,w,x,B,h;const t=e||(typeof document<"u"?document.documentElement:null);if(!t)return{background:"0 0% 100%",foreground:"0 0% 0%",muted:"210 40% 96%",mutedForeground:"215.4 16.3% 46.9%",card:"0 0% 100%",cardForeground:"0 0% 0%",popover:"0 0% 100%",popoverForeground:"0 0% 0%",border:"214.3 31.8% 91.4%",ring:"222.2 84% 4.9%",chart:J};const r=((g=m(t,"--background"))==null?void 0:g.trim())||"0 0% 100%",o=((L=m(t,"--foreground"))==null?void 0:L.trim())||"0 0% 0%",a=((z=m(t,"--muted"))==null?void 0:z.trim())||"210 40% 96%",u=((S=m(t,"--muted-foreground"))==null?void 0:S.trim())||"215.4 16.3% 46.9%",s=(($=m(t,"--card"))==null?void 0:$.trim())||"0 0% 100%",b=((F=m(t,"--card-foreground"))==null?void 0:F.trim())||"0 0% 0%",v=((w=m(t,"--popover"))==null?void 0:w.trim())||"0 0% 100%",y=((x=m(t,"--popover-foreground"))==null?void 0:x.trim())||"0 0% 0%",p=((B=m(t,"--border"))==null?void 0:B.trim())||"214.3 31.8% 91.4%",C=((h=m(t,"--ring"))==null?void 0:h.trim())||"222.2 84% 4.9%",_=Array.from({length:8},(I,O)=>{const W=`--chart-${O+1}`,A=m(t,W);return(A==null?void 0:A.trim())||J[O]});return{background:r,foreground:o,muted:a,mutedForeground:u,card:s,cardForeground:b,popover:v,popoverForeground:y,border:p,ring:C,chart:_}}function Y(e,t=l.ref("auto")){const r=l.shallowRef(null),o=l.ref(!1);let a=null,u=null;const s=()=>{if(!V()||!e.value)return;r.value=X(e.value);const p=document.documentElement.classList.contains("dark"),C=(u==null?void 0:u.matches)??!1;o.value=p||C},b=()=>{if(!V())return;const y=document.documentElement;a=new MutationObserver(()=>{s()}),a.observe(y,{attributes:!0,attributeFilter:["class"]}),u=matchMedia("(prefers-color-scheme: dark)");const p=()=>s();u.addEventListener("change",p)},v=()=>{a==null||a.disconnect(),a=null,u&&u.removeEventListener("change",()=>{})};return l.onMounted(()=>{s(),b()}),l.onUnmounted(()=>{v()}),l.watch(()=>t.value,()=>{s()}),{tokens:r,isDark:o,refresh:s}}function he(e){let t=null;return()=>{t===null&&(t=typeof requestAnimationFrame<"u"?requestAnimationFrame(()=>{e(),t=null}):setTimeout(()=>{e(),t=null},16))}}function me(e,t){const r=he(t);let o=null;return{start:()=>{!V()||!e.value||typeof ResizeObserver>"u"||(o=new ResizeObserver(()=>{r()}),o.observe(e.value))},stop:()=>{o&&(o.disconnect(),o=null)},isActive:()=>o!==null}}function Q(e,t,r={}){const o=l.shallowRef(null),{echarts:a,renderer:u="canvas",autoresize:s=!0,initOnNonZeroSize:b=!0,themeMode:v=l.ref("auto"),themeStrategy:y="option",themeName:p="shadcn",themeObject:C,updateMode:_="merge",notMerge:g=!1,lazyUpdate:L=!0,watch:z="shallow",loading:S,group:$,connectGroup:F=!1,events:w,debug:x=!1}=r,B=l.ref(v),{tokens:h,isDark:I}=Y(e,B),{start:O,stop:W}=me(e,()=>{var i;(i=o.value)==null||i.resize()});let A=null,M=null;const ee=async()=>{if(o.value)return;let i;if(a)i=a;else try{const c=await import("echarts");i=c.default||c}catch(c){throw console.error("[Chart] Failed to load echarts:",c),c}return i},N=async()=>{if(console.log("[Chart] init called, instance="+(o.value?"set":"null")),o.value)return;const i=V();if(!i||!e.value){console.error("[Chart] init skipped: domAvailable="+i+", elRef="+(e.value?"set":"null"));return}console.log("[Chart] init proceeding with ec.init");try{const c=await ee();console.log("[Chart] loaded echarts, ec.init="+(c.init?"exists":"missing"));let d;if(y==="echartsTheme"){if(C)c.registerTheme(p,C),d=p;else if(h.value){const E=K(h.value);c.registerTheme(p,E),d=p}}const f=c.init(e.value,d,{renderer:u});if(!f){console.error("[Chart] ec.init returned undefined");return}$&&(f.group=$,F&&c.connect($)),o.value=f,P(f,w),M=w?{...w}:null;const T=t.value,D=y==="option"&&h.value?j(T,h.value):T;if(f.setOption(D,{notMerge:_==="replace",lazyUpdate:L}),S===!0)f.showLoading();else if(typeof S=="object"&&S){const{text:E,color:H,maskColor:oe}=S;f.showLoading("default",{text:E,textColor:H,maskColor:oe})}x&&console.log("[Chart] Initialized")}catch(c){throw console.error("[Chart] Init failed:",c),c}},U=i=>{if(!o.value)return;const c=i||t.value,d=y==="option"&&h.value?j(c,h.value):c;o.value.setOption(d,{notMerge:_==="replace"||g,lazyUpdate:L}),A=d},te=i=>{var c;(c=o.value)==null||c.resize(i)},k=()=>{o.value&&(o.value.dispose(),o.value=null),W()},P=(i,c)=>{if(i){if(M)for(const[d,f]of Object.entries(M))i.off(d,f);if(c)for(const[d,f]of Object.entries(c))i.on(d,f)}},re=()=>{if(!o.value||y!=="option")return;if(!h.value){x&&console.log("[Chart] No tokens available for theme change");return}const i=t.value,c=j(i,h.value);o.value.setOption(c,{notMerge:!0}),x&&console.log("[Chart] Theme changed")};l.watch(()=>h.value,re,{deep:!1});const Z=()=>{if(!o.value)return;const i=t.value;z==="shallow"&&de(A,i)||(U(i),x&&console.log("[Chart] Option changed"))};return z==="shallow"?l.watch(()=>t.value,Z,{deep:!1}):l.watch(()=>t.value,Z,{deep:!0}),l.watch(()=>w,i=>{o.value&&(P(o.value,i),M=i?{...i}:null)},{deep:!0}),l.watch(()=>S,i=>{if(o.value){if(i===!1)o.value.hideLoading();else if(i===!0)o.value.showLoading();else if(typeof i=="object"&&i){const{text:c,color:d,maskColor:f}=i;o.value.showLoading("default",{text:c,textColor:d,maskColor:f})}}},{deep:!0}),l.onMounted(async()=>{try{if(b&&e.value){const{width:i,height:c}=e.value.getBoundingClientRect();if(i>0&&c>0){await N(),s&&O();return}let d=0;const f=10;for(;d<f&&e.value;){const T=e.value,{width:D,height:E}=T.getBoundingClientRect();if(D>0&&E>0)break;d++,await new Promise(H=>setTimeout(H,10))}e.value&&(await N(),s&&O())}else await N(),s&&O()}catch(i){throw console.error("[Chart] onMounted error:",i),i}}),l.onUnmounted(()=>{k()}),{instance:o,init:N,setOption:U,resize:te,dispose:k,tokens:h,isDark:I}}const pe=l.defineComponent({__name:"Chart",props:{echarts:{},renderer:{default:"canvas"},autoresize:{type:Boolean,default:!0},initOnNonZeroSize:{type:Boolean,default:!0},themeMode:{default:"auto"},themeStrategy:{default:"option"},themeName:{default:"shadcn"},themeObject:{},updateMode:{default:"merge"},notMerge:{type:Boolean},lazyUpdate:{type:Boolean,default:!0},watch:{default:"shallow"},loading:{type:[Boolean,Object]},group:{},connectGroup:{type:[Boolean,String],default:!1},events:{},minHeight:{default:240},debug:{type:Boolean,default:!1},option:{default:()=>({})}},emits:["ready","error","rendered"],setup(e,{expose:t,emit:r}){const o=e,a=r,u=l.ref(null),{instance:s,setOption:b,resize:v,dispose:y}=Q(u,l.computed(()=>o.option),{echarts:o.echarts,renderer:o.renderer,autoresize:o.autoresize,initOnNonZeroSize:o.initOnNonZeroSize,themeMode:o.themeMode,themeStrategy:o.themeStrategy,themeName:o.themeName,themeObject:o.themeObject,updateMode:o.updateMode,notMerge:o.notMerge,lazyUpdate:o.lazyUpdate,watch:o.watch,loading:o.loading,group:o.group,connectGroup:o.connectGroup,events:o.events,debug:o.debug}),p=l.computed(()=>({minHeight:typeof o.minHeight=="number"?`${o.minHeight}px`:o.minHeight}));return t({getInstance:()=>s.value,setOption:g=>{g&&b(g)},resize:v,dispose:y}),l.watch(s,g=>{g&&a("ready",g)}),(g,L)=>(l.openBlock(),l.createElementBlock("div",{ref_key:"el",ref:u,style:l.normalizeStyle(p.value),class:"w-full"},null,4))}});const ge=(e,t)=>{const r=e.__vccOpts||e;for(const[o,a]of t)r[o]=a;return r},ye=ge(pe,[["__scopeId","data-v-6e94ba6b"]]),be={class:"rounded-xl border bg-card text-card-foreground shadow-sm"},Se={key:0,class:"font-semibold"},ve={key:2,class:"text-sm text-muted-foreground"},Ce={key:1,class:"p-6 pt-0"},we=l.defineComponent({__name:"ChartCard",props:{title:{},description:{},contentClass:{},headerClass:{}},setup(e){return(t,r)=>(l.openBlock(),l.createElementBlock("div",be,[e.title||t.$slots.title||t.$slots.actions||e.description||t.$slots.description?(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(["flex items-start justify-between p-6 pb-2",e.headerClass])},[l.createElementVNode("div",null,[e.title?(l.openBlock(),l.createElementBlock("h3",Se,l.toDisplayString(e.title),1)):l.createCommentVNode("",!0),e.title?l.createCommentVNode("",!0):l.renderSlot(t.$slots,"title",{key:1}),e.description?(l.openBlock(),l.createElementBlock("p",ve,l.toDisplayString(e.description),1)):l.createCommentVNode("",!0),e.description?l.createCommentVNode("",!0):l.renderSlot(t.$slots,"description",{key:3})]),l.renderSlot(t.$slots,"actions")],2)):l.createCommentVNode("",!0),l.createElementVNode("div",{class:l.normalizeClass(["p-6 pt-4",e.contentClass])},[l.renderSlot(t.$slots,"default")],2),t.$slots.footer?(l.openBlock(),l.createElementBlock("div",Ce,[l.renderSlot(t.$slots,"footer")])):l.createCommentVNode("",!0)]))}}),xe={class:"flex flex-col items-center justify-center py-12 text-center"},Le={class:"mt-4 font-semibold"},$e={class:"text-sm text-muted-foreground"},Oe=l.defineComponent({__name:"ChartEmpty",props:{title:{default:"No data"},description:{default:"Try adjusting filters."}},setup(e){return(t,r)=>(l.openBlock(),l.createElementBlock("div",xe,[l.renderSlot(t.$slots,"default"),l.createElementVNode("h3",Le,l.toDisplayString(e.title),1),l.createElementVNode("p",$e,l.toDisplayString(e.description),1)]))}}),Ae={class:"h-[240px] w-full rounded-md bg-muted animate-pulse"},_e=l.defineComponent({__name:"ChartSkeleton",props:{height:{}},setup(e){return(t,r)=>(l.openBlock(),l.createElementBlock("div",Ae))}});exports.Chart=ye;exports.ChartCard=we;exports.ChartEmpty=Oe;exports.ChartSkeleton=_e;exports.createEChartsTheme=K;exports.isHslComponent=R;exports.readCssVar=m;exports.readRootCssVar=fe;exports.readShadcnTokens=X;exports.resolveColor=n;exports.useChartTheme=Y;exports.useECharts=Q;exports.withShadcnDefaults=j;
package/dist/index.mjs ADDED
@@ -0,0 +1,845 @@
1
+ import { shallowRef as le, ref as W, onMounted as ne, onUnmounted as ie, watch as $, defineComponent as G, computed as ee, openBlock as v, createElementBlock as S, normalizeStyle as ue, normalizeClass as te, createElementVNode as V, toDisplayString as U, createCommentVNode as F, renderSlot as M } from "vue";
2
+ function de(e) {
3
+ return /^\d+\.?\d*\s+\d+\.?\d*%\s+\d+\.?\d*%$/.test(e.trim());
4
+ }
5
+ function l(e, t) {
6
+ if (!e)
7
+ return;
8
+ const r = String(e).trim();
9
+ if (r.startsWith("#")) {
10
+ if (t != null) {
11
+ const o = r.slice(1), s = parseInt(o.slice(0, 2), 16), c = parseInt(o.slice(2, 4), 16), i = parseInt(o.slice(4, 6), 16);
12
+ return `rgba(${s}, ${c}, ${i}, ${t})`;
13
+ }
14
+ return r;
15
+ }
16
+ if (r.startsWith("rgb("))
17
+ return t != null && !r.includes("rgba") ? r.replace(/rgb\(/, "rgba(").replace(/\)$/, `, ${t})`) : t != null && r.includes("rgba") ? r.replace(/rgba\(([^,]+),\s*([^,]+),\s*([^,]+),\s*[^)]+\)/, `rgba($1, $2, $3, ${t})`) : r;
18
+ if (r.startsWith("hsl("))
19
+ return t != null ? r.replace(/hsl\(/, "hsla(").replace(/\)$/, `, ${t})`) : r;
20
+ if (r.startsWith("hsla("))
21
+ return t != null ? r.replace(/hsla\(([^,]+),\s*([^,]+),\s*([^,]+),\s*[^)]+\)/, `hsla($1, $2, $3, ${t})`) : r;
22
+ if (de(r) || /^\d+\.?\d*\s+\d+\.?\d*%\s+\d+\.?\d*%\s*\/\s*[\d.]+$/.test(r)) {
23
+ if (r.includes("/"))
24
+ return t != null && t !== 1 ? `hsl(${r.split("/")[0].trim()} / ${t})` : `hsl(${r})`;
25
+ const o = r.split(/\s+/), s = o[0], c = o[1].replace("%", ""), i = o[2].replace("%", "");
26
+ return t != null && t !== 1 ? `hsla(${s}, ${c}%, ${i}%, ${t})` : `hsl(${s}, ${c}%, ${i}%)`;
27
+ }
28
+ return r;
29
+ }
30
+ function K(e, t) {
31
+ const r = JSON.parse(JSON.stringify(e));
32
+ r.color || (r.color = t.chart.map((i) => l(i) || i)), r.textStyle || (r.textStyle = {}), r.textStyle.color || (r.textStyle.color = l(t.foreground)), r.textStyle.fontFamily || (r.textStyle.fontFamily = "inherit"), r.title || (r.title = {}), Array.isArray(r.title) ? r.title = r.title.map((i) => ({
33
+ ...i,
34
+ textStyle: {
35
+ color: l(t.foreground),
36
+ ...i.textStyle
37
+ }
38
+ })) : r.title.textStyle = {
39
+ color: l(t.foreground),
40
+ ...r.title.textStyle || {}
41
+ }, r.legend || (r.legend = {}), Array.isArray(r.legend) ? r.legend = r.legend.map((i) => ({
42
+ ...i,
43
+ textStyle: {
44
+ color: l(t.mutedForeground),
45
+ ...i.textStyle
46
+ }
47
+ })) : r.legend.textStyle = {
48
+ color: l(t.mutedForeground),
49
+ ...r.legend.textStyle || {}
50
+ }, r.xAxis || (r.xAxis = {}), r.yAxis || (r.yAxis = {});
51
+ const o = l(t.border, 0.6) || t.border, s = l(t.border, 0.35) || t.border, c = l(t.mutedForeground) || t.mutedForeground;
52
+ for (const i of [r.xAxis, r.yAxis])
53
+ Array.isArray(i) ? i.forEach((y) => re(y, o, s, c)) : re(i, o, s, c);
54
+ return r.tooltip || (r.tooltip = {}), Array.isArray(r.tooltip) || (r.tooltip.backgroundColor = l(t.popover), r.tooltip.borderColor = l(t.border, 0.6), r.tooltip.textStyle = {
55
+ color: l(t.popoverForeground),
56
+ ...r.tooltip.textStyle
57
+ }), r.grid || (r.grid = {}), Array.isArray(r.grid) ? r.grid.forEach((i) => {
58
+ i.containLabel = !0;
59
+ }) : r.grid.containLabel = !0, r;
60
+ }
61
+ function re(e, t, r, o) {
62
+ e && (e.axisLine || (e.axisLine = {}), e.axisLine.lineStyle || (e.axisLine.lineStyle = {}), e.axisLine.lineStyle.color || (e.axisLine.lineStyle.color = t), e.axisLabel || (e.axisLabel = {}), e.axisLabel.color || (e.axisLabel.color = o), e.splitLine || (e.splitLine = {}), e.splitLine.lineStyle || (e.splitLine.lineStyle = {}), e.splitLine.lineStyle.color || (e.splitLine.lineStyle.color = r));
63
+ }
64
+ function fe(e) {
65
+ const t = l(e.border, 0.6), r = l(e.border, 0.35), o = l(e.background);
66
+ return {
67
+ color: e.chart.map((c) => l(c) || c),
68
+ backgroundColor: o,
69
+ textStyle: {
70
+ color: l(e.foreground),
71
+ fontFamily: "inherit"
72
+ },
73
+ title: {
74
+ textStyle: {
75
+ color: l(e.foreground)
76
+ }
77
+ },
78
+ grid: {
79
+ borderColor: t
80
+ },
81
+ legend: {
82
+ textStyle: {
83
+ color: l(e.mutedForeground)
84
+ }
85
+ },
86
+ tooltip: {
87
+ borderColor: t,
88
+ backgroundColor: o,
89
+ textStyle: {
90
+ color: l(e.foreground)
91
+ },
92
+ axisPointer: {
93
+ lineStyle: {
94
+ color: t,
95
+ width: 1
96
+ },
97
+ crossStyle: {
98
+ color: t,
99
+ width: 1
100
+ }
101
+ }
102
+ },
103
+ line: {
104
+ lineStyle: {
105
+ width: 2
106
+ },
107
+ symbol: "circle",
108
+ symbolSize: 4
109
+ },
110
+ bar: {
111
+ borderRadius: 0
112
+ },
113
+ pie: {
114
+ itemStyle: {
115
+ borderWidth: 0,
116
+ borderColor: t
117
+ }
118
+ },
119
+ candlestick: {
120
+ itemStyle: {
121
+ color: e.chart[0],
122
+ color0: e.chart[1],
123
+ borderColor: e.chart[0],
124
+ borderColor0: e.chart[1],
125
+ borderWidth: 1
126
+ }
127
+ },
128
+ gauge: {
129
+ axisTick: {
130
+ distance: -30,
131
+ length: 8,
132
+ lineStyle: {
133
+ color: e.foreground,
134
+ width: 2
135
+ }
136
+ },
137
+ axisLabel: {
138
+ color: l(e.foreground)
139
+ },
140
+ splitLine: {
141
+ distance: -30,
142
+ length: 30,
143
+ lineStyle: {
144
+ color: e.foreground,
145
+ width: 2
146
+ }
147
+ },
148
+ detail: {
149
+ valueAnimation: !0,
150
+ formatter: "{value}",
151
+ color: l(e.foreground)
152
+ }
153
+ },
154
+ geo: {
155
+ borderColor: t,
156
+ itemStyle: {
157
+ areaColor: l(e.muted),
158
+ borderColor: t,
159
+ borderWidth: 0.5
160
+ },
161
+ emphasis: {
162
+ itemStyle: {
163
+ areaColor: l(e.border, 0.5)
164
+ }
165
+ }
166
+ },
167
+ categoryAxis: {
168
+ axisLine: {
169
+ show: !0,
170
+ lineStyle: {
171
+ color: t
172
+ }
173
+ },
174
+ axisLabel: {
175
+ show: !0,
176
+ color: l(e.mutedForeground)
177
+ },
178
+ splitLine: {
179
+ show: !1,
180
+ lineStyle: {
181
+ color: r
182
+ }
183
+ }
184
+ },
185
+ valueAxis: {
186
+ axisLine: {
187
+ show: !1,
188
+ lineStyle: {
189
+ color: t
190
+ }
191
+ },
192
+ axisLabel: {
193
+ show: !0,
194
+ color: l(e.mutedForeground)
195
+ },
196
+ splitLine: {
197
+ show: !0,
198
+ lineStyle: {
199
+ color: r
200
+ }
201
+ }
202
+ },
203
+ logAxis: {
204
+ axisLine: {
205
+ show: !0,
206
+ lineStyle: {
207
+ color: t
208
+ }
209
+ },
210
+ axisLabel: {
211
+ show: !0,
212
+ color: l(e.mutedForeground)
213
+ },
214
+ splitLine: {
215
+ show: !0,
216
+ lineStyle: {
217
+ color: r
218
+ }
219
+ }
220
+ },
221
+ timeAxis: {
222
+ axisLine: {
223
+ show: !0,
224
+ lineStyle: {
225
+ color: t
226
+ }
227
+ },
228
+ axisLabel: {
229
+ show: !0,
230
+ color: l(e.mutedForeground)
231
+ },
232
+ splitLine: {
233
+ show: !1,
234
+ lineStyle: {
235
+ color: r
236
+ }
237
+ }
238
+ },
239
+ angleAxis: {
240
+ axisLine: {
241
+ show: !0,
242
+ lineStyle: {
243
+ color: t
244
+ }
245
+ },
246
+ axisLabel: {
247
+ show: !0,
248
+ color: l(e.mutedForeground)
249
+ },
250
+ splitLine: {
251
+ show: !0,
252
+ lineStyle: {
253
+ color: r
254
+ }
255
+ }
256
+ },
257
+ radiusAxis: {
258
+ axisLine: {
259
+ show: !0,
260
+ lineStyle: {
261
+ color: t
262
+ }
263
+ },
264
+ axisLabel: {
265
+ show: !0,
266
+ color: l(e.mutedForeground)
267
+ },
268
+ splitLine: {
269
+ show: !0,
270
+ lineStyle: {
271
+ color: r
272
+ }
273
+ }
274
+ },
275
+ radar: {
276
+ itemStyle: {
277
+ borderWidth: 1
278
+ },
279
+ lineStyle: {
280
+ width: 2
281
+ },
282
+ symbolSize: 4
283
+ },
284
+ scatter: {
285
+ itemStyle: {
286
+ borderWidth: 0,
287
+ borderColor: t
288
+ }
289
+ },
290
+ graph: {
291
+ itemStyle: {
292
+ borderWidth: 0,
293
+ borderColor: t
294
+ },
295
+ lineStyle: {
296
+ width: 1,
297
+ color: t
298
+ },
299
+ symbolSize: 4,
300
+ smooth: !1
301
+ },
302
+ map: {
303
+ itemStyle: {
304
+ areaColor: l(e.muted),
305
+ borderColor: t,
306
+ borderWidth: 0.5
307
+ },
308
+ emphasis: {
309
+ itemStyle: {
310
+ areaColor: l(e.border, 0.5)
311
+ }
312
+ }
313
+ },
314
+ toolbox: {
315
+ iconStyle: {
316
+ borderColor: l(e.foreground)
317
+ },
318
+ emphasis: {
319
+ iconStyle: {
320
+ borderColor: l(e.foreground)
321
+ }
322
+ }
323
+ },
324
+ timeline: {
325
+ lineStyle: {
326
+ color: t,
327
+ width: 1
328
+ },
329
+ itemStyle: {
330
+ color: e.chart[0],
331
+ borderWidth: 1
332
+ },
333
+ controlStyle: {
334
+ color: l(e.foreground),
335
+ borderColor: t,
336
+ borderWidth: 0.5
337
+ },
338
+ checkpointStyle: {
339
+ color: e.chart[0],
340
+ borderColor: e.chart[0]
341
+ },
342
+ label: {
343
+ color: l(e.foreground)
344
+ },
345
+ emphasis: {
346
+ itemStyle: {
347
+ color: e.chart[0]
348
+ },
349
+ controlStyle: {
350
+ color: l(e.foreground),
351
+ borderColor: t,
352
+ borderWidth: 0.5
353
+ },
354
+ label: {
355
+ color: l(e.foreground)
356
+ }
357
+ }
358
+ },
359
+ visualMap: {
360
+ textStyle: {
361
+ color: l(e.foreground)
362
+ }
363
+ },
364
+ dataZoom: {
365
+ backgroundColor: "rgba(0,0,0,0)",
366
+ dataBackgroundColor: l(e.border, 0.1),
367
+ fillerColor: l(e.border, 0.2),
368
+ handleColor: l(e.foreground),
369
+ handleSize: "100%",
370
+ textStyle: {
371
+ color: l(e.foreground)
372
+ }
373
+ },
374
+ markPoint: {
375
+ label: {
376
+ color: l(e.popoverForeground)
377
+ }
378
+ },
379
+ parallel: {
380
+ itemStyle: {
381
+ borderColor: t,
382
+ borderWidth: 1
383
+ }
384
+ }
385
+ };
386
+ }
387
+ function Z() {
388
+ return typeof document < "u" && typeof window < "u";
389
+ }
390
+ function he(e, t) {
391
+ if (e === t)
392
+ return !0;
393
+ if (e == null || t == null || typeof e != "object" || typeof t != "object")
394
+ return !1;
395
+ const r = Object.keys(e), o = Object.keys(t);
396
+ if (r.length !== o.length)
397
+ return !1;
398
+ for (const s of r)
399
+ if (!o.includes(s) || e[s] !== t[s])
400
+ return !1;
401
+ return !0;
402
+ }
403
+ function g(e, t) {
404
+ if (!e)
405
+ return null;
406
+ try {
407
+ return getComputedStyle(e).getPropertyValue(t).trim() || null;
408
+ } catch {
409
+ return null;
410
+ }
411
+ }
412
+ function Me(e) {
413
+ return typeof document > "u" ? null : g(document.documentElement, e);
414
+ }
415
+ const oe = [
416
+ "#ef4444",
417
+ "#f97316",
418
+ "#eab308",
419
+ "#22c55e",
420
+ "#06b6d4",
421
+ "#3b82f6",
422
+ "#8b5cf6",
423
+ "#ec4899"
424
+ ];
425
+ function me(e) {
426
+ var m, O, j, b, A, N, w, L, B, f;
427
+ const t = e || (typeof document < "u" ? document.documentElement : null);
428
+ if (!t)
429
+ return {
430
+ background: "0 0% 100%",
431
+ foreground: "0 0% 0%",
432
+ muted: "210 40% 96%",
433
+ mutedForeground: "215.4 16.3% 46.9%",
434
+ card: "0 0% 100%",
435
+ cardForeground: "0 0% 0%",
436
+ popover: "0 0% 100%",
437
+ popoverForeground: "0 0% 0%",
438
+ border: "214.3 31.8% 91.4%",
439
+ ring: "222.2 84% 4.9%",
440
+ chart: oe
441
+ };
442
+ const r = ((m = g(t, "--background")) == null ? void 0 : m.trim()) || "0 0% 100%", o = ((O = g(t, "--foreground")) == null ? void 0 : O.trim()) || "0 0% 0%", s = ((j = g(t, "--muted")) == null ? void 0 : j.trim()) || "210 40% 96%", c = ((b = g(t, "--muted-foreground")) == null ? void 0 : b.trim()) || "215.4 16.3% 46.9%", i = ((A = g(t, "--card")) == null ? void 0 : A.trim()) || "0 0% 100%", y = ((N = g(t, "--card-foreground")) == null ? void 0 : N.trim()) || "0 0% 0%", C = ((w = g(t, "--popover")) == null ? void 0 : w.trim()) || "0 0% 100%", p = ((L = g(t, "--popover-foreground")) == null ? void 0 : L.trim()) || "0 0% 0%", h = ((B = g(t, "--border")) == null ? void 0 : B.trim()) || "214.3 31.8% 91.4%", x = ((f = g(t, "--ring")) == null ? void 0 : f.trim()) || "222.2 84% 4.9%", T = Array.from({ length: 8 }, (X, _) => {
443
+ const P = `--chart-${_ + 1}`, z = g(t, P);
444
+ return (z == null ? void 0 : z.trim()) || oe[_];
445
+ });
446
+ return {
447
+ background: r,
448
+ foreground: o,
449
+ muted: s,
450
+ mutedForeground: c,
451
+ card: i,
452
+ cardForeground: y,
453
+ popover: C,
454
+ popoverForeground: p,
455
+ border: h,
456
+ ring: x,
457
+ chart: T
458
+ };
459
+ }
460
+ function ge(e, t = W("auto")) {
461
+ const r = le(null), o = W(!1);
462
+ let s = null, c = null;
463
+ const i = () => {
464
+ if (!Z() || !e.value)
465
+ return;
466
+ r.value = me(e.value);
467
+ const h = document.documentElement.classList.contains("dark"), x = (c == null ? void 0 : c.matches) ?? !1;
468
+ o.value = h || x;
469
+ }, y = () => {
470
+ if (!Z())
471
+ return;
472
+ const p = document.documentElement;
473
+ s = new MutationObserver(() => {
474
+ i();
475
+ }), s.observe(p, { attributes: !0, attributeFilter: ["class"] }), c = matchMedia("(prefers-color-scheme: dark)");
476
+ const h = () => i();
477
+ c.addEventListener("change", h);
478
+ }, C = () => {
479
+ s == null || s.disconnect(), s = null, c && c.removeEventListener("change", () => {
480
+ });
481
+ };
482
+ return ne(() => {
483
+ i(), y();
484
+ }), ie(() => {
485
+ C();
486
+ }), $(() => t.value, () => {
487
+ i();
488
+ }), {
489
+ tokens: r,
490
+ isDark: o,
491
+ refresh: i
492
+ };
493
+ }
494
+ function pe(e) {
495
+ let t = null;
496
+ return () => {
497
+ t === null && (t = typeof requestAnimationFrame < "u" ? requestAnimationFrame(() => {
498
+ e(), t = null;
499
+ }) : setTimeout(() => {
500
+ e(), t = null;
501
+ }, 16));
502
+ };
503
+ }
504
+ function ye(e, t) {
505
+ const r = pe(t);
506
+ let o = null;
507
+ return {
508
+ start: () => {
509
+ !Z() || !e.value || typeof ResizeObserver > "u" || (o = new ResizeObserver(() => {
510
+ r();
511
+ }), o.observe(e.value));
512
+ },
513
+ stop: () => {
514
+ o && (o.disconnect(), o = null);
515
+ },
516
+ isActive: () => o !== null
517
+ };
518
+ }
519
+ function be(e, t, r = {}) {
520
+ const o = le(null), {
521
+ echarts: s,
522
+ renderer: c = "canvas",
523
+ autoresize: i = !0,
524
+ initOnNonZeroSize: y = !0,
525
+ themeMode: C = W("auto"),
526
+ themeStrategy: p = "option",
527
+ themeName: h = "shadcn",
528
+ themeObject: x,
529
+ updateMode: T = "merge",
530
+ notMerge: m = !1,
531
+ lazyUpdate: O = !0,
532
+ watch: j = "shallow",
533
+ loading: b,
534
+ group: A,
535
+ connectGroup: N = !1,
536
+ events: w,
537
+ debug: L = !1
538
+ } = r, B = W(C), { tokens: f, isDark: X } = ge(e, B), { start: _, stop: P } = ye(e, () => {
539
+ var n;
540
+ (n = o.value) == null || n.resize();
541
+ });
542
+ let z = null, D = null;
543
+ const se = async () => {
544
+ if (o.value)
545
+ return;
546
+ let n;
547
+ if (s)
548
+ n = s;
549
+ else
550
+ try {
551
+ const a = await import("echarts");
552
+ n = a.default || a;
553
+ } catch (a) {
554
+ throw console.error("[Chart] Failed to load echarts:", a), a;
555
+ }
556
+ return n;
557
+ }, H = async () => {
558
+ if (console.log("[Chart] init called, instance=" + (o.value ? "set" : "null")), o.value)
559
+ return;
560
+ const n = Z();
561
+ if (!n || !e.value) {
562
+ console.error("[Chart] init skipped: domAvailable=" + n + ", elRef=" + (e.value ? "set" : "null"));
563
+ return;
564
+ }
565
+ console.log("[Chart] init proceeding with ec.init");
566
+ try {
567
+ const a = await se();
568
+ console.log("[Chart] loaded echarts, ec.init=" + (a.init ? "exists" : "missing"));
569
+ let u;
570
+ if (p === "echartsTheme") {
571
+ if (x)
572
+ a.registerTheme(h, x), u = h;
573
+ else if (f.value) {
574
+ const E = fe(f.value);
575
+ a.registerTheme(h, E), u = h;
576
+ }
577
+ }
578
+ const d = a.init(e.value, u, { renderer: c });
579
+ if (!d) {
580
+ console.error("[Chart] ec.init returned undefined");
581
+ return;
582
+ }
583
+ A && (d.group = A, N && a.connect(A)), o.value = d, R(d, w), D = w ? { ...w } : null;
584
+ const I = t.value, q = p === "option" && f.value ? K(I, f.value) : I;
585
+ if (d.setOption(q, {
586
+ notMerge: T === "replace",
587
+ lazyUpdate: O
588
+ }), b === !0)
589
+ d.showLoading();
590
+ else if (typeof b == "object" && b) {
591
+ const { text: E, color: J, maskColor: ce } = b;
592
+ d.showLoading("default", { text: E, textColor: J, maskColor: ce });
593
+ }
594
+ L && console.log("[Chart] Initialized");
595
+ } catch (a) {
596
+ throw console.error("[Chart] Init failed:", a), a;
597
+ }
598
+ }, Y = (n) => {
599
+ if (!o.value)
600
+ return;
601
+ const a = n || t.value, u = p === "option" && f.value ? K(a, f.value) : a;
602
+ o.value.setOption(u, {
603
+ notMerge: T === "replace" || m,
604
+ lazyUpdate: O
605
+ }), z = u;
606
+ }, ae = (n) => {
607
+ var a;
608
+ (a = o.value) == null || a.resize(n);
609
+ }, Q = () => {
610
+ o.value && (o.value.dispose(), o.value = null), P();
611
+ }, R = (n, a) => {
612
+ if (n) {
613
+ if (D)
614
+ for (const [u, d] of Object.entries(D))
615
+ n.off(u, d);
616
+ if (a)
617
+ for (const [u, d] of Object.entries(a))
618
+ n.on(u, d);
619
+ }
620
+ };
621
+ $(() => f.value, () => {
622
+ if (!o.value || p !== "option")
623
+ return;
624
+ if (!f.value) {
625
+ L && console.log("[Chart] No tokens available for theme change");
626
+ return;
627
+ }
628
+ const n = t.value, a = K(n, f.value);
629
+ o.value.setOption(a, { notMerge: !0 }), L && console.log("[Chart] Theme changed");
630
+ }, { deep: !1 });
631
+ const k = () => {
632
+ if (!o.value)
633
+ return;
634
+ const n = t.value;
635
+ j === "shallow" && he(z, n) || (Y(n), L && console.log("[Chart] Option changed"));
636
+ };
637
+ return j === "shallow" ? $(() => t.value, k, { deep: !1 }) : $(() => t.value, k, { deep: !0 }), $(
638
+ () => w,
639
+ (n) => {
640
+ o.value && (R(o.value, n), D = n ? { ...n } : null);
641
+ },
642
+ { deep: !0 }
643
+ ), $(
644
+ () => b,
645
+ (n) => {
646
+ if (o.value) {
647
+ if (n === !1)
648
+ o.value.hideLoading();
649
+ else if (n === !0)
650
+ o.value.showLoading();
651
+ else if (typeof n == "object" && n) {
652
+ const { text: a, color: u, maskColor: d } = n;
653
+ o.value.showLoading("default", {
654
+ text: a,
655
+ textColor: u,
656
+ maskColor: d
657
+ });
658
+ }
659
+ }
660
+ },
661
+ { deep: !0 }
662
+ ), ne(async () => {
663
+ try {
664
+ if (y && e.value) {
665
+ const { width: n, height: a } = e.value.getBoundingClientRect();
666
+ if (n > 0 && a > 0) {
667
+ await H(), i && _();
668
+ return;
669
+ }
670
+ let u = 0;
671
+ const d = 10;
672
+ for (; u < d && e.value; ) {
673
+ const I = e.value, { width: q, height: E } = I.getBoundingClientRect();
674
+ if (q > 0 && E > 0)
675
+ break;
676
+ u++, await new Promise((J) => setTimeout(J, 10));
677
+ }
678
+ e.value && (await H(), i && _());
679
+ } else
680
+ await H(), i && _();
681
+ } catch (n) {
682
+ throw console.error("[Chart] onMounted error:", n), n;
683
+ }
684
+ }), ie(() => {
685
+ Q();
686
+ }), {
687
+ instance: o,
688
+ init: H,
689
+ setOption: Y,
690
+ resize: ae,
691
+ dispose: Q,
692
+ tokens: f,
693
+ isDark: X
694
+ };
695
+ }
696
+ const ve = /* @__PURE__ */ G({
697
+ __name: "Chart",
698
+ props: {
699
+ echarts: {},
700
+ renderer: { default: "canvas" },
701
+ autoresize: { type: Boolean, default: !0 },
702
+ initOnNonZeroSize: { type: Boolean, default: !0 },
703
+ themeMode: { default: "auto" },
704
+ themeStrategy: { default: "option" },
705
+ themeName: { default: "shadcn" },
706
+ themeObject: {},
707
+ updateMode: { default: "merge" },
708
+ notMerge: { type: Boolean },
709
+ lazyUpdate: { type: Boolean, default: !0 },
710
+ watch: { default: "shallow" },
711
+ loading: { type: [Boolean, Object] },
712
+ group: {},
713
+ connectGroup: { type: [Boolean, String], default: !1 },
714
+ events: {},
715
+ minHeight: { default: 240 },
716
+ debug: { type: Boolean, default: !1 },
717
+ option: { default: () => ({}) }
718
+ },
719
+ emits: ["ready", "error", "rendered"],
720
+ setup(e, { expose: t, emit: r }) {
721
+ const o = e, s = r, c = W(null), { instance: i, setOption: y, resize: C, dispose: p } = be(
722
+ c,
723
+ ee(() => o.option),
724
+ {
725
+ echarts: o.echarts,
726
+ renderer: o.renderer,
727
+ autoresize: o.autoresize,
728
+ initOnNonZeroSize: o.initOnNonZeroSize,
729
+ themeMode: o.themeMode,
730
+ themeStrategy: o.themeStrategy,
731
+ themeName: o.themeName,
732
+ themeObject: o.themeObject,
733
+ updateMode: o.updateMode,
734
+ notMerge: o.notMerge,
735
+ lazyUpdate: o.lazyUpdate,
736
+ watch: o.watch,
737
+ loading: o.loading,
738
+ group: o.group,
739
+ connectGroup: o.connectGroup,
740
+ events: o.events,
741
+ debug: o.debug
742
+ }
743
+ ), h = ee(() => ({
744
+ minHeight: typeof o.minHeight == "number" ? `${o.minHeight}px` : o.minHeight
745
+ }));
746
+ return t({
747
+ getInstance: () => i.value,
748
+ setOption: (m) => {
749
+ m && y(m);
750
+ },
751
+ resize: C,
752
+ dispose: p
753
+ }), $(i, (m) => {
754
+ m && s("ready", m);
755
+ }), (m, O) => (v(), S("div", {
756
+ ref_key: "el",
757
+ ref: c,
758
+ style: ue(h.value),
759
+ class: "w-full"
760
+ }, null, 4));
761
+ }
762
+ });
763
+ const Se = (e, t) => {
764
+ const r = e.__vccOpts || e;
765
+ for (const [o, s] of t)
766
+ r[o] = s;
767
+ return r;
768
+ }, Te = /* @__PURE__ */ Se(ve, [["__scopeId", "data-v-6e94ba6b"]]), Ce = { class: "rounded-xl border bg-card text-card-foreground shadow-sm" }, xe = {
769
+ key: 0,
770
+ class: "font-semibold"
771
+ }, we = {
772
+ key: 2,
773
+ class: "text-sm text-muted-foreground"
774
+ }, Le = {
775
+ key: 1,
776
+ class: "p-6 pt-0"
777
+ }, je = /* @__PURE__ */ G({
778
+ __name: "ChartCard",
779
+ props: {
780
+ title: {},
781
+ description: {},
782
+ contentClass: {},
783
+ headerClass: {}
784
+ },
785
+ setup(e) {
786
+ return (t, r) => (v(), S("div", Ce, [
787
+ e.title || t.$slots.title || t.$slots.actions || e.description || t.$slots.description ? (v(), S("div", {
788
+ key: 0,
789
+ class: te(["flex items-start justify-between p-6 pb-2", e.headerClass])
790
+ }, [
791
+ V("div", null, [
792
+ e.title ? (v(), S("h3", xe, U(e.title), 1)) : F("", !0),
793
+ e.title ? F("", !0) : M(t.$slots, "title", { key: 1 }),
794
+ e.description ? (v(), S("p", we, U(e.description), 1)) : F("", !0),
795
+ e.description ? F("", !0) : M(t.$slots, "description", { key: 3 })
796
+ ]),
797
+ M(t.$slots, "actions")
798
+ ], 2)) : F("", !0),
799
+ V("div", {
800
+ class: te(["p-6 pt-4", e.contentClass])
801
+ }, [
802
+ M(t.$slots, "default")
803
+ ], 2),
804
+ t.$slots.footer ? (v(), S("div", Le, [
805
+ M(t.$slots, "footer")
806
+ ])) : F("", !0)
807
+ ]));
808
+ }
809
+ }), $e = { class: "flex flex-col items-center justify-center py-12 text-center" }, Oe = { class: "mt-4 font-semibold" }, Ae = { class: "text-sm text-muted-foreground" }, Ee = /* @__PURE__ */ G({
810
+ __name: "ChartEmpty",
811
+ props: {
812
+ title: { default: "No data" },
813
+ description: { default: "Try adjusting filters." }
814
+ },
815
+ setup(e) {
816
+ return (t, r) => (v(), S("div", $e, [
817
+ M(t.$slots, "default"),
818
+ V("h3", Oe, U(e.title), 1),
819
+ V("p", Ae, U(e.description), 1)
820
+ ]));
821
+ }
822
+ }), _e = { class: "h-[240px] w-full rounded-md bg-muted animate-pulse" }, We = /* @__PURE__ */ G({
823
+ __name: "ChartSkeleton",
824
+ props: {
825
+ height: {}
826
+ },
827
+ setup(e) {
828
+ return (t, r) => (v(), S("div", _e));
829
+ }
830
+ });
831
+ export {
832
+ Te as Chart,
833
+ je as ChartCard,
834
+ Ee as ChartEmpty,
835
+ We as ChartSkeleton,
836
+ fe as createEChartsTheme,
837
+ de as isHslComponent,
838
+ g as readCssVar,
839
+ Me as readRootCssVar,
840
+ me as readShadcnTokens,
841
+ l as resolveColor,
842
+ ge as useChartTheme,
843
+ be as useECharts,
844
+ K as withShadcnDefaults
845
+ };
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ [data-v-6e94ba6b] canvas{display:block;width:100%!important;height:100%!important}
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "shadcn-vue-echarts",
3
+ "version": "0.1.0",
4
+ "description": "Vue 3 ECharts wrapper with shadcn theming",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "license": "MIT",
8
+ "author": "Jordan Thompson <jtthompson1887@gmail.com>",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/jtthompson1887/shadcn-vue-echarts.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/jtthompson1887/shadcn-vue-echarts/issues"
15
+ },
16
+ "keywords": [
17
+ "vue",
18
+ "echarts",
19
+ "shadcn",
20
+ "chart",
21
+ "theming",
22
+ "tailwind"
23
+ ],
24
+ "exports": {
25
+ ".": {
26
+ "import": "./dist/index.mjs",
27
+ "require": "./dist/index.cjs",
28
+ "types": "./dist/index.d.ts"
29
+ },
30
+ "./components": {
31
+ "import": "./dist/components/index.mjs",
32
+ "require": "./dist/components/index.cjs",
33
+ "types": "./dist/components/index.d.ts"
34
+ },
35
+ "./composables": {
36
+ "import": "./dist/composables/index.mjs",
37
+ "require": "./dist/composables/index.cjs",
38
+ "types": "./dist/composables/index.d.ts"
39
+ },
40
+ "./theme": {
41
+ "import": "./dist/theme/index.mjs",
42
+ "require": "./dist/theme/index.cjs",
43
+ "types": "./dist/theme/index.d.ts"
44
+ }
45
+ },
46
+ "main": "./dist/index.cjs",
47
+ "module": "./dist/index.mjs",
48
+ "types": "./dist/index.d.ts",
49
+ "files": [
50
+ "dist",
51
+ "README.md",
52
+ "LICENSE"
53
+ ],
54
+ "scripts": {
55
+ "build": "vite build",
56
+ "test": "vitest",
57
+ "test:ui": "vitest --ui",
58
+ "typecheck": "echo \"Type checking handled by ESLint and Vite\"",
59
+ "lint": "eslint src --ext .vue,.ts",
60
+ "lint:fix": "eslint src --ext .vue,.ts --fix"
61
+ },
62
+ "peerDependencies": {
63
+ "vue": "^3.3.0",
64
+ "echarts": "^5.4.0 || ^6.0.0"
65
+ },
66
+ "devDependencies": {
67
+ "@testing-library/vue": "^8.0.0",
68
+ "@types/node": "^20.0.0",
69
+ "@vitejs/plugin-vue": "^4.0.0",
70
+ "@vue/test-utils": "^2.4.0",
71
+ "happy-dom": "^12.0.0",
72
+ "typescript": "^5.0.0",
73
+ "vite": "^4.4.0",
74
+ "vitest": "^0.34.0",
75
+ "vue": "^3.3.0",
76
+ "vue-tsc": "^1.8.0"
77
+ }
78
+ }