@vtj/ui 0.0.5
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 +4 -0
- package/lib/cdn/index.cjs.js +1 -0
- package/lib/cdn/index.es.js +242 -0
- package/lib/cdn/index.umd.js +1 -0
- package/lib/cdn/style.css +1 -0
- package/lib/index.cjs.js +1 -0
- package/lib/index.es.js +246 -0
- package/lib/index.umd.js +1 -0
- package/lib/style.css +1 -0
- package/package.json +55 -0
- package/src/components/XChart/Chart.vue +42 -0
- package/src/components/XChart/index.ts +8 -0
- package/src/components/XChart/style.scss +0 -0
- package/src/components/XChartBar/Bar.vue +27 -0
- package/src/components/XChartBar/index.ts +8 -0
- package/src/components/XChartLine/Line.vue +27 -0
- package/src/components/XChartLine/index.ts +8 -0
- package/src/components/XChartPie/Pie.vue +54 -0
- package/src/components/XChartPie/index.ts +8 -0
- package/src/components/XTestSuit/TestSuit.vue +47 -0
- package/src/components/XTestSuit/index.ts +8 -0
- package/src/components/XTestSuit/style.scss +14 -0
- package/src/hooks/useECharts.ts +55 -0
- package/src/hooks/useRectChart.ts +46 -0
- package/src/index.ts +23 -0
- package/src/theme/_vars.scss +8 -0
- package/src/theme/base.scss +0 -0
- package/src/theme/index.scss +4 -0
- package/types/dev/vite-env.d.ts +7 -0
- package/types/index.d.ts +4 -0
- package/types/src/components/XChart/Chart.vue.d.ts +69 -0
- package/types/src/components/XChart/index.d.ts +2 -0
- package/types/src/components/XChartBar/Bar.vue.d.ts +124 -0
- package/types/src/components/XChartBar/index.d.ts +2 -0
- package/types/src/components/XChartLine/Line.vue.d.ts +124 -0
- package/types/src/components/XChartLine/index.d.ts +2 -0
- package/types/src/components/XChartPie/Pie.vue.d.ts +111 -0
- package/types/src/components/XChartPie/index.d.ts +2 -0
- package/types/src/components/XTestSuit/TestSuit.vue.d.ts +59 -0
- package/types/src/components/XTestSuit/index.d.ts +2 -0
- package/types/src/hooks/useECharts.d.ts +15 -0
- package/types/src/hooks/useRectChart.d.ts +4 -0
- package/types/src/index.d.ts +6 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var F=Object.defineProperty,g=Object.defineProperties;var x=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var k=(e,t,o)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,d=(e,t)=>{for(var o in t||(t={}))C.call(t,o)&&k(e,o,t[o]);if(h)for(var o of h(t))B.call(t,o)&&k(e,o,t[o]);return e},y=(e,t)=>g(e,x(t));var p=(e,t,o)=>new Promise((n,u)=>{var s=i=>{try{c(o.next(i))}catch(l){u(l)}},r=i=>{try{c(o.throw(i))}catch(l){u(l)}},c=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,r);c((o=o.apply(e,t)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S={class:"x-test-suit"},E=Vue.createElementVNode("div",{class:"x-test-suit__header"},"XTestSuit",-1),w={class:"x-test-suit__body"},b={class:"x-test-suit_props"},X={class:"x-test-suit_slots"},A=Vue.createTextVNode(" Default Slot"),N={key:0},V=Vue.defineComponent({__name:"TestSuit",props:{p1:null,p2:null,p3:{type:Boolean},p4:null},emits:["click"],setup(e,{emit:t}){const o=e,n=Vue.computed(()=>[{name:"p1",value:o.p1},{name:"p2",value:o.p2},{name:"p3",value:o.p3},{name:"p4",value:o.p4}]),u=()=>{t("click")};return(s,r)=>(Vue.openBlock(),Vue.createElementBlock("div",S,[E,Vue.createElementVNode("div",w,[Vue.createElementVNode("div",b,[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(Vue.unref(n),c=>(Vue.openBlock(),Vue.createElementBlock("div",null,Vue.toDisplayString(c.name)+": "+Vue.toDisplayString(JSON.stringify(c.value)),1))),256))]),Vue.createElementVNode("div",{class:"x-test-suit_events"},[Vue.createElementVNode("button",{onClick:u},"Tigger Click Event")]),Vue.createElementVNode("div",X,[Vue.createElementVNode("div",null,[Vue.renderSlot(s.$slots,"default",{},()=>[A])]),s.$slots.footer?(Vue.openBlock(),Vue.createElementBlock("div",N,[Vue.renderSlot(s.$slots,"footer")])):Vue.createCommentVNode("",!0)])])]))}});V.install=function(e){e.component("XTestSuit",V)};function T(e,t={}){const o=Vue.ref(!1);let n=null;const u=c=>p(this,null,function*(){n=echarts.init(e.value);const i=c||VtjUtils.merge({},t.option,t.optionFactory?yield t.optionFactory(t.option):{});n.setOption(i)}),s=()=>{n==null||n.dispose(),u()},r=VtjUtils.debounce(()=>{if(!o.value){o.value=!0;return}n==null||n.resize()},100);return Vue.onMounted(u),Vue.watch(()=>[t.option,t.optionFactory],s),VueUse.useResizeObserver(e,r),{getChart:()=>n,echarts,reset:s,resize:r}}const a=Vue.defineComponent({__name:"Chart",props:{width:{default:"100%"},height:{default:"400px"},option:{default:()=>({})},optionFactory:null},setup(e,{expose:t}){const o=e,n=Vue.ref(),u=Vue.computed(()=>({width:o.width,height:o.height})),{getChart:s,reset:r,resize:c,echarts:i}=T(n,o);return t({getChart:s,echarts:i,reset:r,resize:c}),(l,$)=>(Vue.openBlock(),Vue.createElementBlock("div",{ref_key:"container",ref:n,style:Vue.normalizeStyle(Vue.unref(u))},"Chart",4))}});a.install=function(e){e.component("XChart",a)};function v(e,t){const o=u=>p(this,null,function*(){const s=y(d({},u),{title:{},xAxis:{},yAxis:{}});e.category==="x"?(s.xAxis={type:"category"},s.yAxis={}):(s.xAxis={},s.yAxis={type:"category"}),s.dataset={dimensions:e.dimensions,source:typeof e.source=="function"?yield e.source():e.source};const r=(e.dimensions||[]).length;if(r>1){const c=new Array(r-1);c.fill({type:t}),s.series=c}return VtjUtils.merge(s,e.optionFactory?yield e.optionFactory(s):{})}),n=Vue.ref(Symbol("key"));return Vue.watch(()=>[e.category,e.dimensions,e.source,e.optionFactory],()=>{n.value=Symbol("key")}),{optionFactory:o,key:n}}const m=Vue.defineComponent({__name:"Bar",props:{category:{default:"x"},dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(e){const t=e,{optionFactory:o,key:n}=v(t,"bar");return(u,s)=>(Vue.openBlock(),Vue.createBlock(Vue.unref(a),{key:Vue.unref(n),optionFactory:Vue.unref(o)},null,8,["optionFactory"]))}});m.install=function(e){e.component("XChartBar",m)};const f=Vue.defineComponent({__name:"Line",props:{category:{default:"x"},dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(e){const t=e,{optionFactory:o,key:n}=v(t,"line");return(u,s)=>(Vue.openBlock(),Vue.createBlock(Vue.unref(a),{key:Vue.unref(n),optionFactory:Vue.unref(o)},null,8,["optionFactory"]))}});f.install=function(e){e.component("XChartLine",f)};const _=Vue.defineComponent({__name:"Pie",props:{dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(e){const t=e,o=Vue.ref(Symbol("key")),n=u=>p(this,null,function*(){const s=y(d({},u),{dataset:{dimensions:t.dimensions,source:typeof t.source=="function"?yield t.source():t.source},series:[{type:"pie"}]});return VtjUtils.merge(s,t.optionFactory?yield t.optionFactory(s):{})});return Vue.watch(()=>[t.dimensions,t.source,t.optionFactory],()=>{o.value=Symbol("key")}),(u,s)=>(Vue.openBlock(),Vue.createBlock(Vue.unref(a),{key:o.value,optionFactory:n}))}});_.install=function(e){e.component("XChartPie",_)};exports.XChart=a;exports.XChartBar=m;exports.XChartLine=f;exports.XChartPie=_;exports.XTestSuit=V;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
var v = Object.defineProperty, x = Object.defineProperties;
|
|
2
|
+
var g = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var V = Object.getOwnPropertySymbols;
|
|
4
|
+
var C = Object.prototype.hasOwnProperty, B = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var m = (e, t, n) => t in e ? v(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, y = (e, t) => {
|
|
6
|
+
for (var n in t || (t = {}))
|
|
7
|
+
C.call(t, n) && m(e, n, t[n]);
|
|
8
|
+
if (V)
|
|
9
|
+
for (var n of V(t))
|
|
10
|
+
B.call(t, n) && m(e, n, t[n]);
|
|
11
|
+
return e;
|
|
12
|
+
}, d = (e, t) => x(e, g(t));
|
|
13
|
+
var p = (e, t, n) => new Promise((o, u) => {
|
|
14
|
+
var s = (i) => {
|
|
15
|
+
try {
|
|
16
|
+
c(n.next(i));
|
|
17
|
+
} catch (l) {
|
|
18
|
+
u(l);
|
|
19
|
+
}
|
|
20
|
+
}, r = (i) => {
|
|
21
|
+
try {
|
|
22
|
+
c(n.throw(i));
|
|
23
|
+
} catch (l) {
|
|
24
|
+
u(l);
|
|
25
|
+
}
|
|
26
|
+
}, c = (i) => i.done ? o(i.value) : Promise.resolve(i.value).then(s, r);
|
|
27
|
+
c((n = n.apply(e, t)).next());
|
|
28
|
+
});
|
|
29
|
+
const S = { class: "x-test-suit" }, E = /* @__PURE__ */ Vue.createElementVNode("div", { class: "x-test-suit__header" }, "XTestSuit", -1), w = { class: "x-test-suit__body" }, X = { class: "x-test-suit_props" }, A = { class: "x-test-suit_slots" }, N = /* @__PURE__ */ Vue.createTextVNode(" Default Slot"), b = { key: 0 }, f = /* @__PURE__ */ Vue.defineComponent({
|
|
30
|
+
__name: "TestSuit",
|
|
31
|
+
props: {
|
|
32
|
+
p1: null,
|
|
33
|
+
p2: null,
|
|
34
|
+
p3: { type: Boolean },
|
|
35
|
+
p4: null
|
|
36
|
+
},
|
|
37
|
+
emits: ["click"],
|
|
38
|
+
setup(e, { emit: t }) {
|
|
39
|
+
const n = e, o = Vue.computed(() => [
|
|
40
|
+
{ name: "p1", value: n.p1 },
|
|
41
|
+
{ name: "p2", value: n.p2 },
|
|
42
|
+
{ name: "p3", value: n.p3 },
|
|
43
|
+
{ name: "p4", value: n.p4 }
|
|
44
|
+
]), u = () => {
|
|
45
|
+
t("click");
|
|
46
|
+
};
|
|
47
|
+
return (s, r) => (Vue.openBlock(), Vue.createElementBlock("div", S, [
|
|
48
|
+
E,
|
|
49
|
+
Vue.createElementVNode("div", w, [
|
|
50
|
+
Vue.createElementVNode("div", X, [
|
|
51
|
+
(Vue.openBlock(!0), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(o), (c) => (Vue.openBlock(), Vue.createElementBlock("div", null, Vue.toDisplayString(c.name) + ": " + Vue.toDisplayString(JSON.stringify(c.value)), 1))), 256))
|
|
52
|
+
]),
|
|
53
|
+
Vue.createElementVNode("div", { class: "x-test-suit_events" }, [
|
|
54
|
+
Vue.createElementVNode("button", { onClick: u }, "Tigger Click Event")
|
|
55
|
+
]),
|
|
56
|
+
Vue.createElementVNode("div", A, [
|
|
57
|
+
Vue.createElementVNode("div", null, [
|
|
58
|
+
Vue.renderSlot(s.$slots, "default", {}, () => [
|
|
59
|
+
N
|
|
60
|
+
])
|
|
61
|
+
]),
|
|
62
|
+
s.$slots.footer ? (Vue.openBlock(), Vue.createElementBlock("div", b, [
|
|
63
|
+
Vue.renderSlot(s.$slots, "footer")
|
|
64
|
+
])) : Vue.createCommentVNode("", !0)
|
|
65
|
+
])
|
|
66
|
+
])
|
|
67
|
+
]));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
f.install = function(e) {
|
|
71
|
+
e.component("XTestSuit", f);
|
|
72
|
+
};
|
|
73
|
+
function $(e, t = {}) {
|
|
74
|
+
const n = Vue.ref(!1);
|
|
75
|
+
let o = null;
|
|
76
|
+
const u = (c) => p(this, null, function* () {
|
|
77
|
+
o = echarts.init(e.value);
|
|
78
|
+
const i = c || VtjUtils.merge(
|
|
79
|
+
{},
|
|
80
|
+
t.option,
|
|
81
|
+
t.optionFactory ? yield t.optionFactory(t.option) : {}
|
|
82
|
+
);
|
|
83
|
+
o.setOption(i);
|
|
84
|
+
}), s = () => {
|
|
85
|
+
o == null || o.dispose(), u();
|
|
86
|
+
}, r = VtjUtils.debounce(() => {
|
|
87
|
+
if (!n.value) {
|
|
88
|
+
n.value = !0;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
o == null || o.resize();
|
|
92
|
+
}, 100);
|
|
93
|
+
return Vue.onMounted(u), Vue.watch(() => [t.option, t.optionFactory], s), VueUse.useResizeObserver(e, r), {
|
|
94
|
+
getChart: () => o,
|
|
95
|
+
echarts,
|
|
96
|
+
reset: s,
|
|
97
|
+
resize: r
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const a = /* @__PURE__ */ Vue.defineComponent({
|
|
101
|
+
__name: "Chart",
|
|
102
|
+
props: {
|
|
103
|
+
width: { default: "100%" },
|
|
104
|
+
height: { default: "400px" },
|
|
105
|
+
option: { default: () => ({}) },
|
|
106
|
+
optionFactory: null
|
|
107
|
+
},
|
|
108
|
+
setup(e, { expose: t }) {
|
|
109
|
+
const n = e, o = Vue.ref(), u = Vue.computed(() => ({
|
|
110
|
+
width: n.width,
|
|
111
|
+
height: n.height
|
|
112
|
+
})), { getChart: s, reset: r, resize: c, echarts: i } = $(o, n);
|
|
113
|
+
return t({
|
|
114
|
+
getChart: s,
|
|
115
|
+
echarts: i,
|
|
116
|
+
reset: r,
|
|
117
|
+
resize: c
|
|
118
|
+
}), (l, T) => (Vue.openBlock(), Vue.createElementBlock("div", {
|
|
119
|
+
ref_key: "container",
|
|
120
|
+
ref: o,
|
|
121
|
+
style: Vue.normalizeStyle(Vue.unref(u))
|
|
122
|
+
}, "Chart", 4));
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
a.install = function(e) {
|
|
126
|
+
e.component("XChart", a);
|
|
127
|
+
};
|
|
128
|
+
function F(e, t) {
|
|
129
|
+
const n = (u) => p(this, null, function* () {
|
|
130
|
+
const s = d(y({}, u), {
|
|
131
|
+
title: {},
|
|
132
|
+
xAxis: {},
|
|
133
|
+
yAxis: {}
|
|
134
|
+
});
|
|
135
|
+
e.category === "x" ? (s.xAxis = { type: "category" }, s.yAxis = {}) : (s.xAxis = {}, s.yAxis = { type: "category" }), s.dataset = {
|
|
136
|
+
dimensions: e.dimensions,
|
|
137
|
+
source: typeof e.source == "function" ? yield e.source() : e.source
|
|
138
|
+
};
|
|
139
|
+
const r = (e.dimensions || []).length;
|
|
140
|
+
if (r > 1) {
|
|
141
|
+
const c = new Array(r - 1);
|
|
142
|
+
c.fill({ type: t }), s.series = c;
|
|
143
|
+
}
|
|
144
|
+
return VtjUtils.merge(
|
|
145
|
+
s,
|
|
146
|
+
e.optionFactory ? yield e.optionFactory(s) : {}
|
|
147
|
+
);
|
|
148
|
+
}), o = Vue.ref(Symbol("key"));
|
|
149
|
+
return Vue.watch(
|
|
150
|
+
() => [e.category, e.dimensions, e.source, e.optionFactory],
|
|
151
|
+
() => {
|
|
152
|
+
o.value = Symbol("key");
|
|
153
|
+
}
|
|
154
|
+
), {
|
|
155
|
+
optionFactory: n,
|
|
156
|
+
key: o
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const _ = /* @__PURE__ */ Vue.defineComponent({
|
|
160
|
+
__name: "Bar",
|
|
161
|
+
props: {
|
|
162
|
+
category: { default: "x" },
|
|
163
|
+
dimensions: { default: () => [] },
|
|
164
|
+
source: { type: [Array, Function], default: () => [] },
|
|
165
|
+
optionFactory: null
|
|
166
|
+
},
|
|
167
|
+
setup(e) {
|
|
168
|
+
const t = e, { optionFactory: n, key: o } = F(t, "bar");
|
|
169
|
+
return (u, s) => (Vue.openBlock(), Vue.createBlock(Vue.unref(a), {
|
|
170
|
+
key: Vue.unref(o),
|
|
171
|
+
optionFactory: Vue.unref(n)
|
|
172
|
+
}, null, 8, ["optionFactory"]));
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
_.install = function(e) {
|
|
176
|
+
e.component("XChartBar", _);
|
|
177
|
+
};
|
|
178
|
+
const h = /* @__PURE__ */ Vue.defineComponent({
|
|
179
|
+
__name: "Line",
|
|
180
|
+
props: {
|
|
181
|
+
category: { default: "x" },
|
|
182
|
+
dimensions: { default: () => [] },
|
|
183
|
+
source: { type: [Array, Function], default: () => [] },
|
|
184
|
+
optionFactory: null
|
|
185
|
+
},
|
|
186
|
+
setup(e) {
|
|
187
|
+
const t = e, { optionFactory: n, key: o } = F(t, "line");
|
|
188
|
+
return (u, s) => (Vue.openBlock(), Vue.createBlock(Vue.unref(a), {
|
|
189
|
+
key: Vue.unref(o),
|
|
190
|
+
optionFactory: Vue.unref(n)
|
|
191
|
+
}, null, 8, ["optionFactory"]));
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
h.install = function(e) {
|
|
195
|
+
e.component("XChartLine", h);
|
|
196
|
+
};
|
|
197
|
+
const k = /* @__PURE__ */ Vue.defineComponent({
|
|
198
|
+
__name: "Pie",
|
|
199
|
+
props: {
|
|
200
|
+
dimensions: { default: () => [] },
|
|
201
|
+
source: { type: [Array, Function], default: () => [] },
|
|
202
|
+
optionFactory: null
|
|
203
|
+
},
|
|
204
|
+
setup(e) {
|
|
205
|
+
const t = e, n = Vue.ref(Symbol("key")), o = (u) => p(this, null, function* () {
|
|
206
|
+
const s = d(y({}, u), {
|
|
207
|
+
dataset: {
|
|
208
|
+
dimensions: t.dimensions,
|
|
209
|
+
source: typeof t.source == "function" ? yield t.source() : t.source
|
|
210
|
+
},
|
|
211
|
+
series: [
|
|
212
|
+
{
|
|
213
|
+
type: "pie"
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
});
|
|
217
|
+
return VtjUtils.merge(
|
|
218
|
+
s,
|
|
219
|
+
t.optionFactory ? yield t.optionFactory(s) : {}
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
return Vue.watch(
|
|
223
|
+
() => [t.dimensions, t.source, t.optionFactory],
|
|
224
|
+
() => {
|
|
225
|
+
n.value = Symbol("key");
|
|
226
|
+
}
|
|
227
|
+
), (u, s) => (Vue.openBlock(), Vue.createBlock(Vue.unref(a), {
|
|
228
|
+
key: n.value,
|
|
229
|
+
optionFactory: o
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
k.install = function(e) {
|
|
234
|
+
e.component("XChartPie", k);
|
|
235
|
+
};
|
|
236
|
+
export {
|
|
237
|
+
a as XChart,
|
|
238
|
+
_ as XChartBar,
|
|
239
|
+
h as XChartLine,
|
|
240
|
+
k as XChartPie,
|
|
241
|
+
f as XTestSuit
|
|
242
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(u,s){typeof exports=="object"&&typeof module!="undefined"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(u=typeof globalThis!="undefined"?globalThis:u||self,s(u.VtjUI={}))})(this,function(u){"use strict";var X=Object.defineProperty,A=Object.defineProperties;var N=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var b=(u,s,c)=>s in u?X(u,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):u[s]=c,x=(u,s)=>{for(var c in s||(s={}))T.call(s,c)&&b(u,c,s[c]);if(E)for(var c of E(s))j.call(s,c)&&b(u,c,s[c]);return u},B=(u,s)=>A(u,N(s));var m=(u,s,c)=>new Promise((_,f)=>{var h=a=>{try{V(c.next(a))}catch(p){f(p)}},k=a=>{try{V(c.throw(a))}catch(p){f(p)}},V=a=>a.done?_(a.value):Promise.resolve(a.value).then(h,k);V((c=c.apply(u,s)).next())});const s="",c={class:"x-test-suit"},_=Vue.createElementVNode("div",{class:"x-test-suit__header"},"XTestSuit",-1),f={class:"x-test-suit__body"},h={class:"x-test-suit_props"},k={class:"x-test-suit_slots"},V=Vue.createTextVNode(" Default Slot"),a={key:0},p=Vue.defineComponent({__name:"TestSuit",props:{p1:null,p2:null,p3:{type:Boolean},p4:null},emits:["click"],setup(e,{emit:t}){const i=e,n=Vue.computed(()=>[{name:"p1",value:i.p1},{name:"p2",value:i.p2},{name:"p3",value:i.p3},{name:"p4",value:i.p4}]),r=()=>{t("click")};return(o,d)=>(Vue.openBlock(),Vue.createElementBlock("div",c,[_,Vue.createElementVNode("div",f,[Vue.createElementVNode("div",h,[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(Vue.unref(n),l=>(Vue.openBlock(),Vue.createElementBlock("div",null,Vue.toDisplayString(l.name)+": "+Vue.toDisplayString(JSON.stringify(l.value)),1))),256))]),Vue.createElementVNode("div",{class:"x-test-suit_events"},[Vue.createElementVNode("button",{onClick:r},"Tigger Click Event")]),Vue.createElementVNode("div",k,[Vue.createElementVNode("div",null,[Vue.renderSlot(o.$slots,"default",{},()=>[V])]),o.$slots.footer?(Vue.openBlock(),Vue.createElementBlock("div",a,[Vue.renderSlot(o.$slots,"footer")])):Vue.createCommentVNode("",!0)])])]))}});p.install=function(e){e.component("XTestSuit",p)};function w(e,t={}){const i=Vue.ref(!1);let n=null;const r=l=>m(this,null,function*(){n=echarts.init(e.value);const C=l||VtjUtils.merge({},t.option,t.optionFactory?yield t.optionFactory(t.option):{});n.setOption(C)}),o=()=>{n==null||n.dispose(),r()},d=VtjUtils.debounce(()=>{if(!i.value){i.value=!0;return}n==null||n.resize()},100);return Vue.onMounted(r),Vue.watch(()=>[t.option,t.optionFactory],o),VueUse.useResizeObserver(e,d),{getChart:()=>n,echarts,reset:o,resize:d}}const y=Vue.defineComponent({__name:"Chart",props:{width:{default:"100%"},height:{default:"400px"},option:{default:()=>({})},optionFactory:null},setup(e,{expose:t}){const i=e,n=Vue.ref(),r=Vue.computed(()=>({width:i.width,height:i.height})),{getChart:o,reset:d,resize:l,echarts:C}=w(n,i);return t({getChart:o,echarts:C,reset:d,resize:l}),($,U)=>(Vue.openBlock(),Vue.createElementBlock("div",{ref_key:"container",ref:n,style:Vue.normalizeStyle(Vue.unref(r))},"Chart",4))}});y.install=function(e){e.component("XChart",y)};function S(e,t){const i=r=>m(this,null,function*(){const o=B(x({},r),{title:{},xAxis:{},yAxis:{}});e.category==="x"?(o.xAxis={type:"category"},o.yAxis={}):(o.xAxis={},o.yAxis={type:"category"}),o.dataset={dimensions:e.dimensions,source:typeof e.source=="function"?yield e.source():e.source};const d=(e.dimensions||[]).length;if(d>1){const l=new Array(d-1);l.fill({type:t}),o.series=l}return VtjUtils.merge(o,e.optionFactory?yield e.optionFactory(o):{})}),n=Vue.ref(Symbol("key"));return Vue.watch(()=>[e.category,e.dimensions,e.source,e.optionFactory],()=>{n.value=Symbol("key")}),{optionFactory:i,key:n}}const v=Vue.defineComponent({__name:"Bar",props:{category:{default:"x"},dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(e){const t=e,{optionFactory:i,key:n}=S(t,"bar");return(r,o)=>(Vue.openBlock(),Vue.createBlock(Vue.unref(y),{key:Vue.unref(n),optionFactory:Vue.unref(i)},null,8,["optionFactory"]))}});v.install=function(e){e.component("XChartBar",v)};const F=Vue.defineComponent({__name:"Line",props:{category:{default:"x"},dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(e){const t=e,{optionFactory:i,key:n}=S(t,"line");return(r,o)=>(Vue.openBlock(),Vue.createBlock(Vue.unref(y),{key:Vue.unref(n),optionFactory:Vue.unref(i)},null,8,["optionFactory"]))}});F.install=function(e){e.component("XChartLine",F)};const g=Vue.defineComponent({__name:"Pie",props:{dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(e){const t=e,i=Vue.ref(Symbol("key")),n=r=>m(this,null,function*(){const o=B(x({},r),{dataset:{dimensions:t.dimensions,source:typeof t.source=="function"?yield t.source():t.source},series:[{type:"pie"}]});return VtjUtils.merge(o,t.optionFactory?yield t.optionFactory(o):{})});return Vue.watch(()=>[t.dimensions,t.source,t.optionFactory],()=>{i.value=Symbol("key")}),(r,o)=>(Vue.openBlock(),Vue.createBlock(Vue.unref(y),{key:i.value,optionFactory:n}))}});g.install=function(e){e.component("XChartPie",g)},u.XChart=y,u.XChartBar=v,u.XChartLine=F,u.XChartPie=g,u.XTestSuit=p,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.x-test-suit{width:100%;height:100%;border:1px solid #ccc}.x-test-suit__header{padding:5px 10px;background-color:#efefef}.x-test-suit__body{padding:10px}
|
package/lib/index.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var B=Object.defineProperty,S=Object.defineProperties;var b=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var F=(e,n,o)=>n in e?B(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,f=(e,n)=>{for(var o in n||(n={}))E.call(n,o)&&F(e,o,n[o]);if(g)for(var o of g(n))w.call(n,o)&&F(e,o,n[o]);return e},m=(e,n)=>S(e,b(n));var d=(e,n,o)=>new Promise((r,s)=>{var c=a=>{try{i(o.next(a))}catch(p){s(p)}},u=a=>{try{i(o.throw(a))}catch(p){s(p)}},i=a=>a.done?r(a.value):Promise.resolve(a.value).then(c,u);i((o=o.apply(e,n)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),N=require("echarts"),X=require("@vueuse/core"),y=require("@vtj/utils");function A(e){if(e&&e.__esModule)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return n.default=e,Object.freeze(n)}const x=A(N);const O={class:"x-test-suit"},V=t.createElementVNode("div",{class:"x-test-suit__header"},"XTestSuit",-1),T={class:"x-test-suit__body"},$={class:"x-test-suit_props"},j={class:"x-test-suit_slots"},z=t.createTextVNode(" Default Slot"),P={key:0},_=t.defineComponent({__name:"TestSuit",props:{p1:null,p2:null,p3:{type:Boolean},p4:null},emits:["click"],setup(e,{emit:n}){const o=e,r=t.computed(()=>[{name:"p1",value:o.p1},{name:"p2",value:o.p2},{name:"p3",value:o.p3},{name:"p4",value:o.p4}]),s=()=>{n("click")};return(c,u)=>(t.openBlock(),t.createElementBlock("div",O,[V,t.createElementVNode("div",T,[t.createElementVNode("div",$,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(r),i=>(t.openBlock(),t.createElementBlock("div",null,t.toDisplayString(i.name)+": "+t.toDisplayString(JSON.stringify(i.value)),1))),256))]),t.createElementVNode("div",{class:"x-test-suit_events"},[t.createElementVNode("button",{onClick:s},"Tigger Click Event")]),t.createElementVNode("div",j,[t.createElementVNode("div",null,[t.renderSlot(c.$slots,"default",{},()=>[z])]),c.$slots.footer?(t.openBlock(),t.createElementBlock("div",P,[t.renderSlot(c.$slots,"footer")])):t.createCommentVNode("",!0)])])]))}});_.install=function(e){e.component("XTestSuit",_)};function L(e,n={}){const o=t.ref(!1);let r=null;const s=i=>d(this,null,function*(){r=x.init(e.value);const a=i||y.merge({},n.option,n.optionFactory?yield n.optionFactory(n.option):{});r.setOption(a)}),c=()=>{r==null||r.dispose(),s()},u=y.debounce(()=>{if(!o.value){o.value=!0;return}r==null||r.resize()},100);return t.onMounted(s),t.watch(()=>[n.option,n.optionFactory],c),X.useResizeObserver(e,u),{getChart:()=>r,echarts:x,reset:c,resize:u}}const l=t.defineComponent({__name:"Chart",props:{width:{default:"100%"},height:{default:"400px"},option:{default:()=>({})},optionFactory:null},setup(e,{expose:n}){const o=e,r=t.ref(),s=t.computed(()=>({width:o.width,height:o.height})),{getChart:c,reset:u,resize:i,echarts:a}=L(r,o);return n({getChart:c,echarts:a,reset:u,resize:i}),(p,M)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:r,style:t.normalizeStyle(t.unref(s))},"Chart",4))}});l.install=function(e){e.component("XChart",l)};function C(e,n){const o=s=>d(this,null,function*(){const c=m(f({},s),{title:{},xAxis:{},yAxis:{}});e.category==="x"?(c.xAxis={type:"category"},c.yAxis={}):(c.xAxis={},c.yAxis={type:"category"}),c.dataset={dimensions:e.dimensions,source:typeof e.source=="function"?yield e.source():e.source};const u=(e.dimensions||[]).length;if(u>1){const i=new Array(u-1);i.fill({type:n}),c.series=i}return y.merge(c,e.optionFactory?yield e.optionFactory(c):{})}),r=t.ref(Symbol("key"));return t.watch(()=>[e.category,e.dimensions,e.source,e.optionFactory],()=>{r.value=Symbol("key")}),{optionFactory:o,key:r}}const h=t.defineComponent({__name:"Bar",props:{category:{default:"x"},dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(e){const n=e,{optionFactory:o,key:r}=C(n,"bar");return(s,c)=>(t.openBlock(),t.createBlock(t.unref(l),{key:t.unref(r),optionFactory:t.unref(o)},null,8,["optionFactory"]))}});h.install=function(e){e.component("XChartBar",h)};const k=t.defineComponent({__name:"Line",props:{category:{default:"x"},dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(e){const n=e,{optionFactory:o,key:r}=C(n,"line");return(s,c)=>(t.openBlock(),t.createBlock(t.unref(l),{key:t.unref(r),optionFactory:t.unref(o)},null,8,["optionFactory"]))}});k.install=function(e){e.component("XChartLine",k)};const v=t.defineComponent({__name:"Pie",props:{dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(e){const n=e,o=t.ref(Symbol("key")),r=s=>d(this,null,function*(){const c=m(f({},s),{dataset:{dimensions:n.dimensions,source:typeof n.source=="function"?yield n.source():n.source},series:[{type:"pie"}]});return y.merge(c,n.optionFactory?yield n.optionFactory(c):{})});return t.watch(()=>[n.dimensions,n.source,n.optionFactory],()=>{o.value=Symbol("key")}),(s,c)=>(t.openBlock(),t.createBlock(t.unref(l),{key:o.value,optionFactory:r}))}});v.install=function(e){e.component("XChartPie",v)};exports.XChart=l;exports.XChartBar=h;exports.XChartLine=k;exports.XChartPie=v;exports.XTestSuit=_;
|
package/lib/index.es.js
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
var E = Object.defineProperty, N = Object.defineProperties;
|
|
2
|
+
var O = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var C = Object.getOwnPropertySymbols;
|
|
4
|
+
var P = Object.prototype.hasOwnProperty, V = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var S = (t, e, o) => e in t ? E(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, F = (t, e) => {
|
|
6
|
+
for (var o in e || (e = {}))
|
|
7
|
+
P.call(e, o) && S(t, o, e[o]);
|
|
8
|
+
if (C)
|
|
9
|
+
for (var o of C(e))
|
|
10
|
+
V.call(e, o) && S(t, o, e[o]);
|
|
11
|
+
return t;
|
|
12
|
+
}, v = (t, e) => N(t, O(e));
|
|
13
|
+
var f = (t, e, o) => new Promise((n, i) => {
|
|
14
|
+
var s = (a) => {
|
|
15
|
+
try {
|
|
16
|
+
r(o.next(a));
|
|
17
|
+
} catch (_) {
|
|
18
|
+
i(_);
|
|
19
|
+
}
|
|
20
|
+
}, c = (a) => {
|
|
21
|
+
try {
|
|
22
|
+
r(o.throw(a));
|
|
23
|
+
} catch (_) {
|
|
24
|
+
i(_);
|
|
25
|
+
}
|
|
26
|
+
}, r = (a) => a.done ? n(a.value) : Promise.resolve(a.value).then(s, c);
|
|
27
|
+
r((o = o.apply(t, e)).next());
|
|
28
|
+
});
|
|
29
|
+
import { defineComponent as m, computed as z, openBlock as l, createElementBlock as p, createElementVNode as y, Fragment as D, renderList as R, unref as u, toDisplayString as X, renderSlot as w, createCommentVNode as J, createTextVNode as M, ref as h, onMounted as j, watch as x, normalizeStyle as q, createBlock as k } from "vue";
|
|
30
|
+
import * as A from "echarts";
|
|
31
|
+
import { useResizeObserver as G } from "@vueuse/core";
|
|
32
|
+
import { debounce as H, merge as g } from "@vtj/utils";
|
|
33
|
+
const I = { class: "x-test-suit" }, K = /* @__PURE__ */ y("div", { class: "x-test-suit__header" }, "XTestSuit", -1), Q = { class: "x-test-suit__body" }, U = { class: "x-test-suit_props" }, W = { class: "x-test-suit_slots" }, Y = /* @__PURE__ */ M(" Default Slot"), Z = { key: 0 }, b = /* @__PURE__ */ m({
|
|
34
|
+
__name: "TestSuit",
|
|
35
|
+
props: {
|
|
36
|
+
p1: null,
|
|
37
|
+
p2: null,
|
|
38
|
+
p3: { type: Boolean },
|
|
39
|
+
p4: null
|
|
40
|
+
},
|
|
41
|
+
emits: ["click"],
|
|
42
|
+
setup(t, { emit: e }) {
|
|
43
|
+
const o = t, n = z(() => [
|
|
44
|
+
{ name: "p1", value: o.p1 },
|
|
45
|
+
{ name: "p2", value: o.p2 },
|
|
46
|
+
{ name: "p3", value: o.p3 },
|
|
47
|
+
{ name: "p4", value: o.p4 }
|
|
48
|
+
]), i = () => {
|
|
49
|
+
e("click");
|
|
50
|
+
};
|
|
51
|
+
return (s, c) => (l(), p("div", I, [
|
|
52
|
+
K,
|
|
53
|
+
y("div", Q, [
|
|
54
|
+
y("div", U, [
|
|
55
|
+
(l(!0), p(D, null, R(u(n), (r) => (l(), p("div", null, X(r.name) + ": " + X(JSON.stringify(r.value)), 1))), 256))
|
|
56
|
+
]),
|
|
57
|
+
y("div", { class: "x-test-suit_events" }, [
|
|
58
|
+
y("button", { onClick: i }, "Tigger Click Event")
|
|
59
|
+
]),
|
|
60
|
+
y("div", W, [
|
|
61
|
+
y("div", null, [
|
|
62
|
+
w(s.$slots, "default", {}, () => [
|
|
63
|
+
Y
|
|
64
|
+
])
|
|
65
|
+
]),
|
|
66
|
+
s.$slots.footer ? (l(), p("div", Z, [
|
|
67
|
+
w(s.$slots, "footer")
|
|
68
|
+
])) : J("", !0)
|
|
69
|
+
])
|
|
70
|
+
])
|
|
71
|
+
]));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
b.install = function(t) {
|
|
75
|
+
t.component("XTestSuit", b);
|
|
76
|
+
};
|
|
77
|
+
function tt(t, e = {}) {
|
|
78
|
+
const o = h(!1);
|
|
79
|
+
let n = null;
|
|
80
|
+
const i = (r) => f(this, null, function* () {
|
|
81
|
+
n = A.init(t.value);
|
|
82
|
+
const a = r || g(
|
|
83
|
+
{},
|
|
84
|
+
e.option,
|
|
85
|
+
e.optionFactory ? yield e.optionFactory(e.option) : {}
|
|
86
|
+
);
|
|
87
|
+
n.setOption(a);
|
|
88
|
+
}), s = () => {
|
|
89
|
+
n == null || n.dispose(), i();
|
|
90
|
+
}, c = H(() => {
|
|
91
|
+
if (!o.value) {
|
|
92
|
+
o.value = !0;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
n == null || n.resize();
|
|
96
|
+
}, 100);
|
|
97
|
+
return j(i), x(() => [e.option, e.optionFactory], s), G(t, c), {
|
|
98
|
+
getChart: () => n,
|
|
99
|
+
echarts: A,
|
|
100
|
+
reset: s,
|
|
101
|
+
resize: c
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const d = /* @__PURE__ */ m({
|
|
105
|
+
__name: "Chart",
|
|
106
|
+
props: {
|
|
107
|
+
width: { default: "100%" },
|
|
108
|
+
height: { default: "400px" },
|
|
109
|
+
option: { default: () => ({}) },
|
|
110
|
+
optionFactory: null
|
|
111
|
+
},
|
|
112
|
+
setup(t, { expose: e }) {
|
|
113
|
+
const o = t, n = h(), i = z(() => ({
|
|
114
|
+
width: o.width,
|
|
115
|
+
height: o.height
|
|
116
|
+
})), { getChart: s, reset: c, resize: r, echarts: a } = tt(n, o);
|
|
117
|
+
return e({
|
|
118
|
+
getChart: s,
|
|
119
|
+
echarts: a,
|
|
120
|
+
reset: c,
|
|
121
|
+
resize: r
|
|
122
|
+
}), (_, et) => (l(), p("div", {
|
|
123
|
+
ref_key: "container",
|
|
124
|
+
ref: n,
|
|
125
|
+
style: q(u(i))
|
|
126
|
+
}, "Chart", 4));
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
d.install = function(t) {
|
|
130
|
+
t.component("XChart", d);
|
|
131
|
+
};
|
|
132
|
+
function L(t, e) {
|
|
133
|
+
const o = (i) => f(this, null, function* () {
|
|
134
|
+
const s = v(F({}, i), {
|
|
135
|
+
title: {},
|
|
136
|
+
xAxis: {},
|
|
137
|
+
yAxis: {}
|
|
138
|
+
});
|
|
139
|
+
t.category === "x" ? (s.xAxis = { type: "category" }, s.yAxis = {}) : (s.xAxis = {}, s.yAxis = { type: "category" }), s.dataset = {
|
|
140
|
+
dimensions: t.dimensions,
|
|
141
|
+
source: typeof t.source == "function" ? yield t.source() : t.source
|
|
142
|
+
};
|
|
143
|
+
const c = (t.dimensions || []).length;
|
|
144
|
+
if (c > 1) {
|
|
145
|
+
const r = new Array(c - 1);
|
|
146
|
+
r.fill({ type: e }), s.series = r;
|
|
147
|
+
}
|
|
148
|
+
return g(
|
|
149
|
+
s,
|
|
150
|
+
t.optionFactory ? yield t.optionFactory(s) : {}
|
|
151
|
+
);
|
|
152
|
+
}), n = h(Symbol("key"));
|
|
153
|
+
return x(
|
|
154
|
+
() => [t.category, t.dimensions, t.source, t.optionFactory],
|
|
155
|
+
() => {
|
|
156
|
+
n.value = Symbol("key");
|
|
157
|
+
}
|
|
158
|
+
), {
|
|
159
|
+
optionFactory: o,
|
|
160
|
+
key: n
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const B = /* @__PURE__ */ m({
|
|
164
|
+
__name: "Bar",
|
|
165
|
+
props: {
|
|
166
|
+
category: { default: "x" },
|
|
167
|
+
dimensions: { default: () => [] },
|
|
168
|
+
source: { type: [Array, Function], default: () => [] },
|
|
169
|
+
optionFactory: null
|
|
170
|
+
},
|
|
171
|
+
setup(t) {
|
|
172
|
+
const e = t, { optionFactory: o, key: n } = L(e, "bar");
|
|
173
|
+
return (i, s) => (l(), k(u(d), {
|
|
174
|
+
key: u(n),
|
|
175
|
+
optionFactory: u(o)
|
|
176
|
+
}, null, 8, ["optionFactory"]));
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
B.install = function(t) {
|
|
180
|
+
t.component("XChartBar", B);
|
|
181
|
+
};
|
|
182
|
+
const $ = /* @__PURE__ */ m({
|
|
183
|
+
__name: "Line",
|
|
184
|
+
props: {
|
|
185
|
+
category: { default: "x" },
|
|
186
|
+
dimensions: { default: () => [] },
|
|
187
|
+
source: { type: [Array, Function], default: () => [] },
|
|
188
|
+
optionFactory: null
|
|
189
|
+
},
|
|
190
|
+
setup(t) {
|
|
191
|
+
const e = t, { optionFactory: o, key: n } = L(e, "line");
|
|
192
|
+
return (i, s) => (l(), k(u(d), {
|
|
193
|
+
key: u(n),
|
|
194
|
+
optionFactory: u(o)
|
|
195
|
+
}, null, 8, ["optionFactory"]));
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
$.install = function(t) {
|
|
199
|
+
t.component("XChartLine", $);
|
|
200
|
+
};
|
|
201
|
+
const T = /* @__PURE__ */ m({
|
|
202
|
+
__name: "Pie",
|
|
203
|
+
props: {
|
|
204
|
+
dimensions: { default: () => [] },
|
|
205
|
+
source: { type: [Array, Function], default: () => [] },
|
|
206
|
+
optionFactory: null
|
|
207
|
+
},
|
|
208
|
+
setup(t) {
|
|
209
|
+
const e = t, o = h(Symbol("key")), n = (i) => f(this, null, function* () {
|
|
210
|
+
const s = v(F({}, i), {
|
|
211
|
+
dataset: {
|
|
212
|
+
dimensions: e.dimensions,
|
|
213
|
+
source: typeof e.source == "function" ? yield e.source() : e.source
|
|
214
|
+
},
|
|
215
|
+
series: [
|
|
216
|
+
{
|
|
217
|
+
type: "pie"
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
});
|
|
221
|
+
return g(
|
|
222
|
+
s,
|
|
223
|
+
e.optionFactory ? yield e.optionFactory(s) : {}
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
return x(
|
|
227
|
+
() => [e.dimensions, e.source, e.optionFactory],
|
|
228
|
+
() => {
|
|
229
|
+
o.value = Symbol("key");
|
|
230
|
+
}
|
|
231
|
+
), (i, s) => (l(), k(u(d), {
|
|
232
|
+
key: o.value,
|
|
233
|
+
optionFactory: n
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
T.install = function(t) {
|
|
238
|
+
t.component("XChartPie", T);
|
|
239
|
+
};
|
|
240
|
+
export {
|
|
241
|
+
d as XChart,
|
|
242
|
+
B as XChartBar,
|
|
243
|
+
$ as XChartLine,
|
|
244
|
+
T as XChartPie,
|
|
245
|
+
b as XTestSuit
|
|
246
|
+
};
|
package/lib/index.umd.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue"),require("echarts"),require("@vueuse/core"),require("@vtj/utils")):typeof define=="function"&&define.amd?define(["exports","vue","echarts","@vueuse/core","@vtj/utils"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o.VtjUI={},o.vue,o.echarts,o.core,o.utils))})(this,function(o,e,s,k,p){"use strict";var z=Object.defineProperty,P=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var X=(o,e,s)=>e in o?z(o,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[e]=s,b=(o,e)=>{for(var s in e||(e={}))M.call(e,s)&&X(o,s,e[s]);if(N)for(var s of N(e))q.call(e,s)&&X(o,s,e[s]);return o},E=(o,e)=>P(o,L(e));var h=(o,e,s)=>new Promise((k,p)=>{var g=l=>{try{_(s.next(l))}catch(y){p(y)}},m=l=>{try{_(s.throw(l))}catch(y){p(y)}},_=l=>l.done?k(l.value):Promise.resolve(l.value).then(g,m);_((s=s.apply(o,e)).next())});function g(t){if(t&&t.__esModule)return t;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const c in t)if(c!=="default"){const r=Object.getOwnPropertyDescriptor(t,c);Object.defineProperty(n,c,r.get?r:{enumerable:!0,get:()=>t[c]})}}return n.default=t,Object.freeze(n)}const m=g(s),_="",l={class:"x-test-suit"},y=e.createElementVNode("div",{class:"x-test-suit__header"},"XTestSuit",-1),A={class:"x-test-suit__body"},T={class:"x-test-suit_props"},V={class:"x-test-suit_slots"},j=e.createTextVNode(" Default Slot"),O={key:0},F=e.defineComponent({__name:"TestSuit",props:{p1:null,p2:null,p3:{type:Boolean},p4:null},emits:["click"],setup(t,{emit:n}){const c=t,r=e.computed(()=>[{name:"p1",value:c.p1},{name:"p2",value:c.p2},{name:"p3",value:c.p3},{name:"p4",value:c.p4}]),a=()=>{n("click")};return(i,d)=>(e.openBlock(),e.createElementBlock("div",l,[y,e.createElementVNode("div",A,[e.createElementVNode("div",T,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),u=>(e.openBlock(),e.createElementBlock("div",null,e.toDisplayString(u.name)+": "+e.toDisplayString(JSON.stringify(u.value)),1))),256))]),e.createElementVNode("div",{class:"x-test-suit_events"},[e.createElementVNode("button",{onClick:a},"Tigger Click Event")]),e.createElementVNode("div",V,[e.createElementVNode("div",null,[e.renderSlot(i.$slots,"default",{},()=>[j])]),i.$slots.footer?(e.openBlock(),e.createElementBlock("div",O,[e.renderSlot(i.$slots,"footer")])):e.createCommentVNode("",!0)])])]))}});F.install=function(t){t.component("XTestSuit",F)};function $(t,n={}){const c=e.ref(!1);let r=null;const a=u=>h(this,null,function*(){r=m.init(t.value);const S=u||p.merge({},n.option,n.optionFactory?yield n.optionFactory(n.option):{});r.setOption(S)}),i=()=>{r==null||r.dispose(),a()},d=p.debounce(()=>{if(!c.value){c.value=!0;return}r==null||r.resize()},100);return e.onMounted(a),e.watch(()=>[n.option,n.optionFactory],i),k.useResizeObserver(t,d),{getChart:()=>r,echarts:m,reset:i,resize:d}}const f=e.defineComponent({__name:"Chart",props:{width:{default:"100%"},height:{default:"400px"},option:{default:()=>({})},optionFactory:null},setup(t,{expose:n}){const c=t,r=e.ref(),a=e.computed(()=>({width:c.width,height:c.height})),{getChart:i,reset:d,resize:u,echarts:S}=$(r,c);return n({getChart:i,echarts:S,reset:d,resize:u}),(D,R)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"container",ref:r,style:e.normalizeStyle(e.unref(a))},"Chart",4))}});f.install=function(t){t.component("XChart",f)};function w(t,n){const c=a=>h(this,null,function*(){const i=E(b({},a),{title:{},xAxis:{},yAxis:{}});t.category==="x"?(i.xAxis={type:"category"},i.yAxis={}):(i.xAxis={},i.yAxis={type:"category"}),i.dataset={dimensions:t.dimensions,source:typeof t.source=="function"?yield t.source():t.source};const d=(t.dimensions||[]).length;if(d>1){const u=new Array(d-1);u.fill({type:n}),i.series=u}return p.merge(i,t.optionFactory?yield t.optionFactory(i):{})}),r=e.ref(Symbol("key"));return e.watch(()=>[t.category,t.dimensions,t.source,t.optionFactory],()=>{r.value=Symbol("key")}),{optionFactory:c,key:r}}const C=e.defineComponent({__name:"Bar",props:{category:{default:"x"},dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(t){const n=t,{optionFactory:c,key:r}=w(n,"bar");return(a,i)=>(e.openBlock(),e.createBlock(e.unref(f),{key:e.unref(r),optionFactory:e.unref(c)},null,8,["optionFactory"]))}});C.install=function(t){t.component("XChartBar",C)};const x=e.defineComponent({__name:"Line",props:{category:{default:"x"},dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(t){const n=t,{optionFactory:c,key:r}=w(n,"line");return(a,i)=>(e.openBlock(),e.createBlock(e.unref(f),{key:e.unref(r),optionFactory:e.unref(c)},null,8,["optionFactory"]))}});x.install=function(t){t.component("XChartLine",x)};const B=e.defineComponent({__name:"Pie",props:{dimensions:{default:()=>[]},source:{type:[Array,Function],default:()=>[]},optionFactory:null},setup(t){const n=t,c=e.ref(Symbol("key")),r=a=>h(this,null,function*(){const i=E(b({},a),{dataset:{dimensions:n.dimensions,source:typeof n.source=="function"?yield n.source():n.source},series:[{type:"pie"}]});return p.merge(i,n.optionFactory?yield n.optionFactory(i):{})});return e.watch(()=>[n.dimensions,n.source,n.optionFactory],()=>{c.value=Symbol("key")}),(a,i)=>(e.openBlock(),e.createBlock(e.unref(f),{key:c.value,optionFactory:r}))}});B.install=function(t){t.component("XChartPie",B)},o.XChart=f,o.XChartBar=C,o.XChartLine=x,o.XChartPie=B,o.XTestSuit=F,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/lib/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.x-test-suit{width:100%;height:100%;border:1px solid #ccc}.x-test-suit__header{padding:5px 10px;background-color:#efefef}.x-test-suit__body{padding:10px}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vtj/ui",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.0.5",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "cross-env ENV_TYPE=dev vite",
|
|
8
|
+
"build": "vue-tsc --noEmit && cross-env ENV_TYPE=prod vite build && npm run build:cdn",
|
|
9
|
+
"build:cdn": "vue-tsc --noEmit && cross-env ENV_TYPE=prod CDN=true vite build",
|
|
10
|
+
"preview": "vite preview",
|
|
11
|
+
"deploy:major": "npm run build && npm version major && npm publish --access public",
|
|
12
|
+
"deploy:minor": "npm run build && npm version minor && npm publish --access public",
|
|
13
|
+
"deploy:patch": "npm run build && npm version patch && npm publish --access public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@vtj/utils": "^0.0.6",
|
|
17
|
+
"echarts": "^5.3.3",
|
|
18
|
+
"element-plus": "^2.2.14"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@babel/types": "^7.18.10",
|
|
22
|
+
"@types/lodash-es": "^4.17.6",
|
|
23
|
+
"@types/node": "^18.7.8",
|
|
24
|
+
"@vitejs/plugin-legacy": "^2.0.1",
|
|
25
|
+
"@vitejs/plugin-vue": "^3.0.3",
|
|
26
|
+
"@vitejs/plugin-vue-jsx": "^2.0.0",
|
|
27
|
+
"cross-env": "^7.0.3",
|
|
28
|
+
"rollup-plugin-external-globals": "^0.6.1",
|
|
29
|
+
"sass": "^1.54.5",
|
|
30
|
+
"typescript": "^4.7.4",
|
|
31
|
+
"unplugin-element-plus": "^0.4.1",
|
|
32
|
+
"vite": "^3.0.7",
|
|
33
|
+
"vite-plugin-dts": "^1.4.1",
|
|
34
|
+
"vue": "^3.2.37",
|
|
35
|
+
"vue-router": "^4.1.3",
|
|
36
|
+
"vue-tsc": "^0.39.5",
|
|
37
|
+
"@vueuse/core": "^9.1.0"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"lib",
|
|
41
|
+
"types",
|
|
42
|
+
"src"
|
|
43
|
+
],
|
|
44
|
+
"main": "lib/index.umd.js",
|
|
45
|
+
"module": "lib/index.es.js",
|
|
46
|
+
"types": "types/index.d.ts",
|
|
47
|
+
"exports": {
|
|
48
|
+
"./lib/style.css": "./lib/style.css",
|
|
49
|
+
".": {
|
|
50
|
+
"types": "./types/index.d.ts",
|
|
51
|
+
"import": "./lib/index.es.js",
|
|
52
|
+
"require": "./lib/index.cjs.js"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="container" :style="style">Chart</div>
|
|
3
|
+
</template>
|
|
4
|
+
<script lang="ts" setup>
|
|
5
|
+
import { ref, computed } from 'vue';
|
|
6
|
+
import useECharts from '../../hooks/useECharts';
|
|
7
|
+
|
|
8
|
+
export type IOptionFactory = (
|
|
9
|
+
opt?: Record<string, any>
|
|
10
|
+
) => Promise<Record<string, any>>;
|
|
11
|
+
|
|
12
|
+
export interface Props {
|
|
13
|
+
width?: string;
|
|
14
|
+
height?: string;
|
|
15
|
+
option?: Record<string, any>;
|
|
16
|
+
optionFactory?: IOptionFactory;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
20
|
+
width: '100%',
|
|
21
|
+
height: '400px',
|
|
22
|
+
option: () => ({})
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const container = ref<HTMLElement>();
|
|
26
|
+
|
|
27
|
+
const style = computed(() => {
|
|
28
|
+
return {
|
|
29
|
+
width: props.width,
|
|
30
|
+
height: props.height
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const { getChart, reset, resize, echarts } = useECharts(container, props);
|
|
35
|
+
|
|
36
|
+
defineExpose({
|
|
37
|
+
getChart,
|
|
38
|
+
echarts,
|
|
39
|
+
reset,
|
|
40
|
+
resize
|
|
41
|
+
});
|
|
42
|
+
</script>
|
|
File without changes
|