zwave-js-ui
Version:
Z-Wave Control Panel and MQTT Gateway
2 lines (1 loc) • 1.49 kB
JavaScript
import{_ as m,a8 as d,o,l as u,w as n,b as h,e as f,U as V,t as c,c as _,n as w,q as p}from"./index-B9yS4Bcc.js";import{V as y}from"./VTreeview-gSGU9saB.js";const g={name:"CCTreeView",props:{modelValue:{type:[Object,Array],default:()=>({})},level:{type:Number,default:0}},data:()=>({items:[]}),watch:{modelValue:{immediate:!0,deep:!0,handler(){Array.isArray(this.modelValue)?this.items=this.modelValue:(this.items=[],d(()=>{this.items=this.parseEntry(this.modelValue)}))}}},methods:{parseEntry(s,t="root"){const l=[],r=[];this.openIds=[];for(const i in s)if(i==="tags")l.push({id:t,name:s.tags.join(" - "),children:r});else if(i==="message")for(const a in s.message){const e=s.message[a];r.push({id:`${t}.${a}`,name:`${a}`,value:typeof e=="string"?e.trimStart():e})}else if(i==="encapsulated")for(let a=0;a<s.encapsulated.length;a++){const e=s.encapsulated[a];r.push(...this.parseEntry(e,`${t}.encapsulated[${a}]`))}return l}}},v={class:"tree-item-name",style:{"white-space":"pre-wrap"}};function $(s,t,l,r,i,a){return s.items.length>0?(o(),u(y,{key:0,ref:"treeview","open-all":"",density:"compact",items:s.items},{title:n(({item:e})=>[h(f,{class:"ma-0 pa-0",dense:""},{default:n(()=>[V("strong",v,c(e.name),1),e.value!==void 0?(o(),_("div",{key:0,class:w(["tree-item-value",e.name==="payload"?"mono":""]),style:{"white-space":"pre-wrap"}},c(e.value),3)):p("",!0)]),_:2},1024)]),_:1},8,["items"])):p("",!0)}const b=m(g,[["render",$],["__scopeId","data-v-01be5cfb"]]);export{b as default};