UNPKG

zwave-js-ui

Version:

Z-Wave Control Panel and MQTT Gateway

2 lines (1 loc) 1.49 kB
import{_ as m,e as d,h as o,z as n,w as c,b as u,V as h,H as f,c as V,t as p,n as _,a9 as w}from"./index-DwzE-W2i.js";import{V as y}from"./VTreeview-BYmR7iQJ.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=[],w(()=>{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?(n(),d(y,{key:0,ref:"treeview","open-all":"",density:"compact",items:s.items},{title:c(({item:e})=>[u(h,{class:"ma-0 pa-0",dense:""},{default:c(()=>[f("strong",v,p(e.name),1),e.value!==void 0?(n(),V("div",{key:0,class:_(["tree-item-value",e.name==="payload"?"mono":""]),style:{"white-space":"pre-wrap"}},p(e.value),3)):o("",!0)]),_:2},1024)]),_:1},8,["items"])):o("",!0)}const b=m(g,[["render",$],["__scopeId","data-v-01be5cfb"]]);export{b as default};