@techui/scifi 0.0.5-alpha.1 → 0.0.7-alpha.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 +36 -0
- package/TECHUI.md +38 -40
- package/UPDATE.md +78 -6
- package/core/core.d.ts +6 -2
- package/core/core.js +61 -11
- package/core/core_bg.wasm +0 -0
- package/core/core_bg.wasm.d.ts +3 -1
- package/dist/index.css +1 -1
- package/dist/index.js +1 -1
- package/index.js +79 -13
- package/package.json +8 -8
- package/dist/modules/echartsTheme.js +0 -1
- package/dist/modules/tuiEcharts.js +0 -1
- package/dist/modules/tuiEchartsMap.js +0 -1
package/index.js
CHANGED
|
@@ -1,37 +1,103 @@
|
|
|
1
1
|
import "@techui/icons";
|
|
2
2
|
import "./dist/index.css";
|
|
3
|
-
import {
|
|
3
|
+
import { toComps, toDirective, toGlobal, toRoot } from "./dist/index.js";
|
|
4
|
+
|
|
5
|
+
const aliasName={
|
|
6
|
+
"ScifiButtonA1": "ScifiButtonHex",
|
|
7
|
+
"ScifiButtonA2": "ScifiButtonPod",
|
|
8
|
+
"ScifiButtonA3": "ScifiButtonDash",
|
|
9
|
+
"ScifiButtonA4": "ScifiButtonExo",
|
|
10
|
+
"ScifiButtonA5": "ScifiButtonFin",
|
|
11
|
+
|
|
12
|
+
"ScifiDecoA1": "ScifiDecoRune",
|
|
13
|
+
"ScifiDecoB1": "ScifiDecoOrb",
|
|
14
|
+
"ScifiDecoB2": "ScifiDecoHive",
|
|
15
|
+
"ScifiDecoB3": "ScifiDecoPrism",
|
|
16
|
+
"ScifiDecoC1": "ScifiDecoPair",
|
|
17
|
+
|
|
18
|
+
"ScifiHeaderA1": "ScifiHeaderSurge",
|
|
19
|
+
"ScifiHeaderA2": "ScifiHeaderRazor",
|
|
20
|
+
"ScifiHeaderA3": "ScifiHeaderEcho",
|
|
21
|
+
"ScifiHeaderA4": "ScifiHeaderPhantom",
|
|
22
|
+
|
|
23
|
+
"ScifiPanelA1": "ScifiPanelAlpha",
|
|
24
|
+
"ScifiPanelA2": "ScifiPanelVanguard",
|
|
25
|
+
"ScifiPanelA3": "ScifiPanelDelta",
|
|
26
|
+
"ScifiPanelB1": "ScifiPanelSentinel",
|
|
27
|
+
"ScifiPanelB2": "ScifiPanelDeck",
|
|
28
|
+
"ScifiPanelB3": "ScifiPanelPawn",
|
|
29
|
+
"ScifiPanelB4": "ScifiPanelInfinity",
|
|
30
|
+
"ScifiPanelDV1": "ScifiPanelProtocol",
|
|
31
|
+
"ScifiPanelDV2": "ScifiPanelReactor",
|
|
32
|
+
"ScifiPanelDV3": "ScifiPanelRanger",
|
|
33
|
+
"ScifiPanelDV4": "ScifiPanelQuad",
|
|
34
|
+
"ScifiPanelDV5": "ScifiPanelZone",
|
|
35
|
+
"ScifiPanelDV6": "ScifiPanelClip",
|
|
36
|
+
"ScifiPanelDV7": "ScifiPanelArc",
|
|
37
|
+
"ScifiPanelDV8": "ScifiPanelVeil",
|
|
38
|
+
"ScifiPanelDV9": "ScifiPanelFlow",
|
|
39
|
+
"TuiPanelA1": "TuiPanelZero",
|
|
40
|
+
|
|
41
|
+
"ScifiPanelTitleA1": "ScifiPanelTitleAlt",
|
|
42
|
+
"ScifiPanelTitleA2": "ScifiPanelTitleDuo",
|
|
43
|
+
"ScifiPanelTitleA3": "ScifiPanelTitlePipe",
|
|
44
|
+
"TuiPanelTitleA1": "TuiPanelTitleEave",
|
|
45
|
+
"TuiPanelTitleA2": "TuiPanelTitleRod"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const advanceComps=[
|
|
49
|
+
"Tui3DPanel",
|
|
50
|
+
"TuiBar3D",
|
|
51
|
+
"TuiBar3DGroup",
|
|
52
|
+
"TuiPie",
|
|
53
|
+
"TuiToggleT3DPanel",
|
|
54
|
+
"TuiPanicAlert",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
const echartsComps=[
|
|
58
|
+
"TuiEcharts",
|
|
59
|
+
"TuiEchartsMap",
|
|
60
|
+
]
|
|
4
61
|
|
|
5
62
|
const initComps=(app,license,features,debug=false)=>{
|
|
6
|
-
const {echarts=
|
|
63
|
+
const {echarts=null,advanced=false}=features
|
|
64
|
+
const isActEcharts = (
|
|
65
|
+
echarts !== null &&
|
|
66
|
+
typeof echarts === "object" &&
|
|
67
|
+
echarts.version?.startsWith('6.')
|
|
68
|
+
);
|
|
69
|
+
app.use(toGlobal.$gAttention)
|
|
7
70
|
app.use(toGlobal.$gMask)
|
|
8
71
|
app.use(toGlobal.$gLoading)
|
|
72
|
+
app.use(toGlobal.$gPopover)
|
|
73
|
+
app.use(toGlobal.$gPopoverDirectiveCloseAll)
|
|
74
|
+
app.directive('tuiMenu', toDirective.$dMenu)
|
|
9
75
|
app.directive('tuiResize', toDirective.$dResize)
|
|
10
76
|
app.directive('tuiDrag', toDirective.$dDrag)
|
|
77
|
+
app.directive('tuiPopover', toDirective.$dPopover)
|
|
78
|
+
app.directive('tuiCursorTip', toDirective.$dCursorTip)
|
|
11
79
|
app.directive('tuiVcid', toDirective.$dVcid)
|
|
12
80
|
const tService=toRoot.tuiService(advanced,debug)
|
|
13
81
|
app.config.globalProperties.$tBus = toRoot.tuiBus
|
|
14
82
|
app.config.globalProperties.$tService = tService
|
|
15
83
|
app.config.globalProperties.$tState = tService.state
|
|
16
|
-
app.config.globalProperties
|
|
17
|
-
app.config.globalProperties.isActEchartsFeatures =
|
|
84
|
+
app.config.globalProperties.$echarts = isActEcharts?echarts:null
|
|
85
|
+
app.config.globalProperties.isActEchartsFeatures = isActEcharts
|
|
18
86
|
app.config.globalProperties.isActAdminFeatures=false
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"TuiBar3D",
|
|
22
|
-
"TuiBar3DGroup",
|
|
23
|
-
"TuiPie",
|
|
24
|
-
]
|
|
25
|
-
dynamicEcharts(app,echarts);
|
|
87
|
+
app.config.globalProperties.isActAdvFeatures = advanced||license!=null
|
|
88
|
+
|
|
26
89
|
toComps.forEach((com) => {
|
|
27
90
|
if(com.name){
|
|
28
91
|
const isAdvanced = advanceComps.includes(com.name);
|
|
29
|
-
const isEcharts = com.name
|
|
92
|
+
const isEcharts = echartsComps.includes(com.name);
|
|
30
93
|
const skipAdvanced = isAdvanced && !advanced && !license;
|
|
31
|
-
const skipEcharts = isEcharts && !
|
|
94
|
+
const skipEcharts = isEcharts && !isActEcharts;
|
|
32
95
|
const shouldSkip = skipAdvanced || skipEcharts;
|
|
33
96
|
if (!shouldSkip) {
|
|
34
97
|
app.component(com.name, com);
|
|
98
|
+
//别名注册
|
|
99
|
+
const alName = aliasName[com.name];
|
|
100
|
+
if (alName) { app.component(alName, com); }
|
|
35
101
|
}
|
|
36
102
|
}else{
|
|
37
103
|
console.warn("TechUI Warning: Missing component name",com);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@techui/scifi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7-alpha.5",
|
|
4
4
|
"description": "TechUI Scifi is a sci-fi SVG component library developed based on Vue3. It uses dynamically calculated SVG elements to generate a variety of cool, futuristic, and technological components.",
|
|
5
5
|
"author": "aYin <ayin86cn@gmail.com> <wechat:jay1986cn>",
|
|
6
6
|
"homepage": "https://techui.net",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
],
|
|
42
42
|
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@techui/icons": "1.0.
|
|
45
|
-
"@techui/colors": "1.0.
|
|
46
|
-
"@techui/lessmixins": "0.0.
|
|
47
|
-
"@techui/libs": "0.0.
|
|
48
|
-
"@techui/locales": "0.0.
|
|
49
|
-
"@techui/themes": "0.0.
|
|
50
|
-
"@techui/utils": "0.0.
|
|
44
|
+
"@techui/icons": "1.0.3",
|
|
45
|
+
"@techui/colors": "1.0.2",
|
|
46
|
+
"@techui/lessmixins": "0.0.6",
|
|
47
|
+
"@techui/libs": "0.0.6",
|
|
48
|
+
"@techui/locales": "0.0.7",
|
|
49
|
+
"@techui/themes": "0.0.7",
|
|
50
|
+
"@techui/utils": "0.0.7",
|
|
51
51
|
"vue": "^3.4.27",
|
|
52
52
|
"vue-router": "^4.3.2"
|
|
53
53
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import*as N from"echarts";import{$c as y}from"@techui/colors";const O=o=>{const{chart:e,common:r,font:l,scifi:t}=o,{bg:i,bd:s}=r,{line:{weak:a,base:c,strong:h},bubble:{fc:d,bg:b,hlite:n},map:{fc:S,fc_hov:m,fc_act:w,bg:x,bd:p,bg_hov:C,bd_hov:g,bg_act:W,bd_act:f,glow:L,shadow:u},palette:k,visual:T}=e,{hlite:A,focus:B}=t,{weaker:v,weak:z,base:_,strong:N,stronger:O}=l;let J=y.scale(k,6,"lch"),E=y.scale(T,4,"lch");return JSON.stringify({color:J,textStyle:{},title:{textStyle:{color:_},subtextStyle:{color:z}},line:{label:{color:"inherit",textBorderColor:i,textBorderWidth:5},itemStyle:{borderWidth:"2"},lineStyle:{width:"3"},symbolSize:"7",symbol:"emptyCircle",smooth:!0},radar:{splitLine:{lineStyle:{show:!0,color:c,type:"dashed"}},axisLine:{show:!0,lineStyle:{color:c,type:"dashed"}},axisName:{show:!0,color:_},splitArea:{areaStyle:{color:[a,i]}},symbolSize:"7",symbol:"emptyCircle",markLine:{label:{color:"inherit",textBorderColor:i,textBorderWidth:5}},smooth:!0},bar:{itemStyle:{barBorderWidth:0,barBorderColor:a},markLine:{label:{color:"inherit",textBorderColor:i,textBorderWidth:5}}},pie:{itemStyle:{borderWidth:0,borderColor:i}},scatter:{label:{show:!0,color:d},emphasis:{labele:{fontWeight:"bold"}},itemStyle:{color:{type:"radial",x:.3,y:.3,r:.5,colorStops:[{offset:0,color:n},{offset:1,color:b}],global:!1},borderWidth:0,borderColor:a}},boxplot:{itemStyle:{borderWidth:0,borderColor:a}},parallel:{itemStyle:{borderWidth:0,borderColor:a}},sankey:{itemStyle:{borderWidth:0,borderColor:a}},funnel:{itemStyle:{borderWidth:0,borderColor:a}},gauge:{itemStyle:{borderWidth:0,borderColor:h},axisLine:{show:!0,lineStyle:{color:[[1,a]]}},axisTick:{show:!0,lineStyle:{color:h}},axisLabel:{show:!0,color:_},splitLine:{show:!0,lineStyle:{color:h}},detail:{color:"inherit"}},graph:{itemStyle:{borderWidth:0,borderColor:a},lineStyle:{width:1,color:c},symbolSize:"7",symbol:"circle",smooth:!0,color:J,label:{color:_}},map:{itemStyle:{areaColor:x,borderColor:p,borderWidth:.5},label:{color:_},emphasis:{itemStyle:{areaColor:C,borderColor:p,borderWidth:1},label:{color:_}}},geo:{scaleLimit:{min:.5,max:7},itemStyle:{areaColor:x,borderColor:p,shadowColor:u,shadowOffsetY:0,shadowBlur:5,borderWidth:.5},label:{show:!0,fontSize:12,color:S},emphasis:{itemStyle:{areaColor:C,borderColor:g,borderWidth:1},label:{fontSize:14,color:m}},select:{itemStyle:{areaColor:W,borderColor:f,borderWidth:1},label:{fontSize:14,color:w}}},categoryAxis:{axisLine:{show:!0,lineStyle:{color:c}},splitLine:{show:!1,lineStyle:{color:a}},axisTick:{show:!1,lineStyle:{color:a}},axisLabel:{show:!0,color:_},splitArea:{show:!1}},valueAxis:{axisLine:{show:!0,lineStyle:{color:c}},axisTick:{show:!1,lineStyle:{color:a}},axisLabel:{show:!0,color:_},splitLine:{show:!0,lineStyle:{color:a}},splitArea:{show:!1}},logAxis:{axisLine:{show:!0,lineStyle:{color:c}},axisTick:{show:!1,lineStyle:{color:a}},axisLabel:{show:!0,color:_},splitLine:{show:!1,lineStyle:{color:a}},splitArea:{show:!1}},timeAxis:{axisLine:{show:!0,lineStyle:{color:c}},axisTick:{show:!1,lineStyle:{color:a}},axisLabel:{show:!0,color:_},splitLine:{show:!1,lineStyle:{color:a}},splitArea:{show:!1}},toolbox:{iconStyle:{borderColor:_},emphasis:{iconStyle:{borderColor:N}}},legend:{y:"bottom",x:"center",textStyle:{color:_},itemStyle:{borderColor:"transparent",borderWidth:1,opacity:1}},tooltip:{backgroundColor:i,textStyle:{color:_},axisPointer:{lineStyle:{color:_,width:1},crossStyle:{color:_,width:1}}},timeline:{symbol:"circle",progress:{itemStyle:{color:A,borderColor:"white",borderWidth:0},lineStyle:{color:A,shadowColor:"rgba(0, 0, 0, 0)"}},lineStyle:{color:B,width:1,shadowColor:"rgba(0, 0, 0, 0)"},itemStyle:{color:B,borderColor:"white",borderWidth:0},controlStyle:{color:v,borderColor:"white",borderWidth:0},checkpointStyle:{symbol:"circle",color:A,borderColor:"white",borderWidth:0,shadowColor:"rgba(0, 0, 0, 0)"},label:{color:_},emphasis:{itemStyle:{color:B},controlStyle:{color:_,borderWidth:0},label:{color:N}}},visualMap:{color:E,textStyle:{color:_},zlevel:10}})};let J=null;function $(o){if(o)try{const e=JSON.parse(O(o));N.registerTheme("eTheme",e),J=o}catch(o){console.error("registerEchartsTheme: Failed to register theme",o)}else console.warn("registerEchartsTheme: themePalette is required!")}export{$ as registerEchartsTheme};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{inject as D,ref as U,shallowRef as q,reactive as L,computed as B,watch as v,nextTick as h,onMounted as W,onBeforeUnmount as F,resolveComponent as V,resolveDirective as H,createBlock as Q,openBlock as J,withCtx as K,withDirectives as X,renderSlot as Y,createElementVNode as Z,normalizeStyle as ee,normalizeClass as te,unref as P}from"vue";import{cidGen as ie,cssVarGen as ae}from"@techui/scifi";import{tQuery as z,tClass as R,tStr as re,tType as _}from"@techui/utils";import*as ne from"echarts";import{$c as oe}from"@techui/colors";const se=(e,t,a="358")=>{const i=z.get1stParent(e,".tui-3d-panel");if(!i)return;if(R.has(i,"is-3doff"))return;if(!(e&&e instanceof HTMLElement&&"string"==typeof t&&""!==t.trim()))return;const r=e.querySelector("svg");if(!r)return;const l="pathG"+t,n=r.querySelector(`g#${CSS.escape(l)}`);n&&r.removeChild(n);const s=r.querySelectorAll("path"),o=[];if(s.forEach((e=>{const t=e.getAttribute("stroke-width");null!=t&&""!==t.trim()&&String(t).includes(a)&&o.push(e)})),o.length>0){const e=document.createElementNS("http://www.w3.org/2000/svg","g");e.setAttribute("id",l),o.forEach((t=>{const a=t.getAttribute("fill"),i=t.getAttribute("stroke");t.setAttribute("class","ori-svg-item");const r=t.cloneNode(!0);r.setAttribute("class","t3d-shadow-item"),r.setAttribute("style",`--tui-t3d-thickcolor:${oe.darken("none"!=a?a:i,2.5)}`),e.appendChild(r)})),r.insertBefore(e,r.firstChild)}},le=e=>{const t="pathG"+e,a=z.el(`#${t}`);a&&a.remove()},E="TuiEcharts",fe=Object.assign({name:E},{__name:"tuiEcharts",props:{width:[Number,String],height:[Number,String],chartOption:{type:Object,required:!0},initOptions:{type:Object,default:()=>({})},loading:{type:Boolean,default:null},initT3DShadow:{type:Boolean,default:!1},t3DShadowUpdate:{type:String,default:"finished",validator:e=>["rendered","finished"].includes(e)},renderer:{type:String,default:"canvas",validator:e=>["svg","canvas"].includes(e)},ready:{type:Boolean,default:!1},dataOpacity:Number,dataBlur:Number,resizeObserver:{type:String,default:"global",validator:e=>["self","global","none"].includes(e)}},emits:["chartClick","chartDblClick","chartMouseDown","chartMouseUp","chartMouseOver","chartGlobalOut","chartInit","chartReady","chartRendered","chartFinished","update:loading"],setup(e,{expose:t,emit:a}){const{$gT3D:i,$gTheme:r,$optResizeCounter:l,initResizeBy:n}=D("$global",null),s=n(),o=ie(E),u="echart_"+re.rdm(),c=e,d=a,p=U(null),f=q(null),g=L({loading:!0,inited:!1,resizing:!0}),m=B({get:()=>c.loading??g.loading,set:e=>{null!==c.loading?d("update:loading",e):g.loading=e}}),b=async()=>{if(p.value)try{if(S(),f.value)return;await h(),f.value=ne.init(p.value,"eTheme",{...c.initOptions,renderer:c.initT3DShadow?"svg":c.renderer}),d("chartInit",f.value),f.value.setOption(c.chartOption),y(),await h(),f.value&&(d("chartReady",f.value),m.value=!1)}catch(e){console.error("ECharts initialization failed:",e)}},y=()=>{if(!f.value)return;const e=(e,t)=>{f.value&&f.value.on(e,t)};e("click",(e=>d("chartClick",e))),e("dblclick",(e=>d("chartDblClick",e))),e("mousedown",(e=>d("chartMouseDown",e))),e("mouseup",(e=>d("chartMouseUp",e))),e("mouseover",(e=>d("chartMouseOver",e))),e("globalout",(e=>d("chartGlobalOut",e))),e("rendered",(()=>{f.value&&"rendered"==c.t3DShadowUpdate&&w(),d("chartRendered")})),e("finished",(function(){f.value&&("finished"==c.t3DShadowUpdate&&w(),d("chartFinished"),m.value=!1,g.inited=!1)}))},w=()=>{if(!p.value)return;let e=!0;const t=z.get1stParent(p.value,".tui-3d-panel");(!t||t&&R.has(t,"is-3doff"))&&(e=!1),c.initT3DShadow&&e?se(p.value,u):le(u)},O=D("TuiT3DPanel",null);v((()=>[i.value,c.initT3DShadow,O?.view3d?.value]),(([e,t,a])=>{w()})),v((()=>r.value),(async e=>{f.value&&(await h(),f.value.setTheme("eTheme"))}));const S=()=>{f.value&&(f.value.dispose(),f.value=null)},T=()=>{f.value&&f.value.resize()};v((()=>c.ready),(e=>{e&&b()})),v((()=>c.chartOption),(()=>{f.value&&h((()=>{f.value&&(f.value.setOption(c.chartOption),m.value=!1)}))}),{deep:!0});const C=B((()=>ae("cpt-echart",{...c.width&&{width:_.join("number",c.width,"px")},...c.height&&{height:_.join("number",c.height,"px")},...c.dataOpacity&&{opa:c.dataOpacity},...c.dataBlur&&{blur:c.dataBlur+"px"}})));v((()=>l.value),((e,t)=>{"root"==s.value(c.resizeObserver)&&e>t&&k()}));const k=async()=>{g.resizing=!0,T(),await h(),setTimeout((()=>{g?.resizing&&(g.resizing=!1)}),500)};return W((()=>{c.ready&&h((()=>{b()}))})),F((()=>{S()})),t({resize:T,getChart:()=>f.value,setOption:(e,t)=>{f.value&&f.value.setOption(e,t)},clear:()=>{f.value&&f.value.clear()},initChart:b,dispose:S}),(t,a)=>{const i=V("TuiLoaderPanel"),r=H("tui-resize");return J(),Q(i,{loading:m.value,inited:g.inited},{default:K((()=>[X(Z("div",{ref_key:"chartRef",ref:p,class:te(["tui-echarts",{"is-resizing":g.resizing}]),style:ee(C.value)},null,6),[[r,{callback:k,uid:u,cid:P(o),disabled:"self"!=P(s)(e.resizeObserver)}]]),Y(t.$slots,"default")])),_:3},8,["loading","inited"])}}});export{fe as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{nextTick as m,markRaw as K,inject as Q,ref as W,shallowRef as Z,reactive as I,computed as C,watch as y,onMounted as ee,onBeforeUnmount as te,resolveComponent as ae,resolveDirective as re,createBlock as ie,openBlock as k,withCtx as oe,withDirectives as ne,createElementBlock as B,createCommentVNode as le,renderSlot as ce,createElementVNode as M,normalizeStyle as x,normalizeClass as ue,unref as N,Fragment as se,renderList as de,toDisplayString as pe}from"vue";import{cidGen as fe,cssVarGen as ve}from"@techui/scifi";import{tEvent as ge,tStr as me,tType as S}from"@techui/utils";import*as E from"echarts";const be=(e,a,t,i,r)=>{if(!e.value)return;const o=(a,t)=>{e.value&&e.value.on(a,t)};o("click",ge.debounce((t=>{let r,o=t;if(t.value&&!a.chartOption.geo3D)r=e.value.convertToPixel("geo",[t.value[0],t.value[1]]),o.domPosition=r;else if("geo"==t.componentType&&t.event?.offsetX){const{offsetX:a,offsetY:i}=t.event;r=e.value.convertFromPixel("geo",[a,i]),o.coordPosition=r}i("chartClick",o,t)}),500,!0)),o("dblclick",(e=>i("chartDblClick",e))),o("mousedown",(e=>i("chartMouseDown",e))),o("mouseup",(e=>i("chartMouseUp",e))),o("mouseover",(e=>i("chartMouseOver",e))),o("globalout",(e=>i("chartGlobalOut",e))),o("geoRoam",(e=>i("chartGeoRoam",e))),o("timelinechanged",(t=>{const{allAreaCodes:r,chartOption:{timeline:o}}=a;let l=t;if("geoTitle"==o.titleType){let a=o.data[t.currentIndex],i=r.find((e=>e.name.includes(a))),n=e.value.convertToPixel("geo",[i.lng,i.lat]);l.domPosition=n,l.current=i}i("chartTimelinechanged",l)})),o("rendered",(()=>{i("chartRendered")})),o("finished",(()=>{e.value&&(i("chartFinished"),t.inited=!0)}))},he=e=>{e.value&&e.value.resize()},ye=e=>e.value,Oe=(e,a,t)=>{e.value&&e.value.setOption(a,t)},Ce=e=>{e.value&&e.value.clear()},ke=e=>{if(e.value)try{const a=e.value.getOption();a.geo&&a.geo[0]&&(a.geo[0].roam=!0,a.geo[0].zoom=1,a.geo[0].center=null,e.value.setOption(a,!1))}catch(e){console.error("Failed to reset map view:",e)}},G=(e,a)=>{try{return a?(E.registerMap(e,a),!0):(console.warn("GeoJSON data is missing"),!1)}catch(e){return console.error("Failed to register map:",e),!1}},ze=async(e,a,t,i,r,o)=>{if(e.value)try{if(F(a),a.value)return;if(!G(t.mapName,t.geoJsonData))return void console.error("Map registration failed, aborting chart initialization");await m(),a.value=K(E.init(e.value,"eTheme",{...t.initOptions,notMerge:!1,renderer:t.renderer})),r("chartInit",a.value),a.value.setOption(t.chartOption),o(),await m(),a.value&&(r("chartReady",a.value),i.value=!1)}catch(e){console.error("ECharts Map initialization failed:",e)}},we=(e,a,t,i,r=!1)=>{e.value&&(e.value.setOption(a,r),t.value=!1,i("chartUpdate"))},F=e=>{e.value&&(e.value.dispose(),e.value=null)},Te=["onClick"],Be={class:"breadcrumb-text"},P="TuiEchartsMap",_e=Object.assign({name:P},{__name:"tuiEchartsMap",props:{width:[Number,String],height:[Number,String],chartOption:{type:Object,required:!0},geoJsonData:{type:Object,required:!0},allAreaCodes:Object,mapName:{type:String,required:!0},initOptions:{type:Object,default:()=>({})},loading:{type:Boolean,default:null},renderer:{type:String,default:"canvas",validator:e=>["svg","canvas"].includes(e)},ready:{type:Boolean,default:!1},dataOpacity:Number,dataBlur:Number,resizeObserver:{type:String,default:"global",validator:e=>["self","global","none"].includes(e)},updateReplace:{type:Boolean,default:!0},enableBreadcrumb:{type:Boolean,default:!1},breadcrumbConfig:{type:Object,default:()=>({data:[{code:1e5,name:"全国"}],position:{top:"5%",left:"5%"}})}},emits:["chartClick","chartDblClick","chartMouseDown","chartMouseUp","chartMouseOver","chartGlobalOut","chartInit","chartReady","chartRendered","chartFinished","chartGeoRoam","chartUpdate","chartTimelinechanged","breadcrumbClick","update:loading"],setup(e,{expose:a,emit:t}){const{$gT3D:i,$gTheme:r,$optResizeCounter:o,initResizeBy:l}=Q("$global",null),n=l(),s=fe(P),c="echart_map_"+me.rdm(),u=W(null),d=Z(null),p=e,v=t,h=I({loading:!0,inited:!1,resizing:!0}),g=C({get:()=>p.loading??h.loading,set:e=>{null!==p.loading?v("update:loading",e):h.loading=e}}),b=C((()=>p.breadcrumbConfig?.data||[])),f=C((()=>{let e=p.breadcrumbConfig?.position||{},a={};for(let t in e)"number"==typeof e[t]?a[t]=e[t]+"px":a[t]=e[t];return a})),O=async()=>{await ze(u,d,p,g,v,z,p.updateReplace)},w=()=>{we(d,p.chartOption,g,v,p.updateReplace)},z=()=>{be(d,p,h,v)},T=()=>{F(d)},R=()=>{he(d)},D=C((()=>ve("cpt-echart-map",{...p.width&&{width:S.join("number",p.width,"px")},...p.height&&{height:S.join("number",p.height,"px")},...p.dataOpacity&&{opa:p.dataOpacity},...p.dataBlur&&{blur:p.dataBlur+"px"}})));y((()=>p.geoJsonData),(()=>{d.value&&(G(p.mapName,p.geoJsonData),m((()=>{w()})))}),{deep:!0}),y((()=>p.ready),(e=>{e&&O()})),y((()=>p.chartOption),(()=>{d.value&&m((()=>{w()}))}),{deep:!0}),y((()=>r.value),(e=>{d.value&&m((()=>{d.value.setTheme("eTheme")}))})),y((()=>o.value),((e,a)=>{"root"==n.value(p.resizeObserver)&&e>a&&j()}));const j=async()=>{h.resizing=!0,R(),await m(),setTimeout((()=>{h?.resizing&&(h.resizing=!1)}),500)};return ee((()=>{p.ready&&m((()=>{O()}))})),te((()=>{T()})),a({resize:R,getChart:()=>ye(d),setOption:(e,a)=>{Oe(d,e,a)},initChart:O,clear:()=>{Ce(d)},resetMapView:()=>{ke(d)},dispose:T}),(a,t)=>{const i=ae("TuiLoaderPanel"),r=re("tui-resize");return k(),ie(i,{loading:g.value,inited:h.inited},{default:oe((()=>[ne(M("div",{ref_key:"mapRef",ref:u,class:ue(["tui-echarts-map",{"is-resizing":h.resizing}]),style:x(D.value)},null,6),[[r,{callback:j,uid:c,cid:N(s),disabled:"self"!=N(n)(e.resizeObserver)}]]),e.enableBreadcrumb&&b.value.length>0?(k(),B("div",{key:0,class:"tui-map-breadcrumb",style:x(f.value)},[(k(!0),B(se,null,de(b.value,((e,a)=>(k(),B("div",{key:`${e.code}-${a}`,class:"breadcrumb-item",onClick:t=>((e,a)=>{const t=b.value.slice(0,a+1);v("breadcrumbClick",{item:e,index:a,breadcrumb:t,chart:d.value})})(e,a)},[M("span",Be,pe(e.name),1)],8,Te)))),128)),t[0]||(t[0]=M("i",{class:"tui-icon ti-map breadcrumb-icon"},null,-1))],4)):le("",!0),ce(a.$slots,"default")])),_:3},8,["loading","inited"])}}});export{_e as default};
|