UNPKG

zwave-js-ui

Version:

Z-Wave Control Panel and MQTT Gateway

2 lines (1 loc) 9.36 kB
import{a2 as j,bl as ae,bn as ie,a4 as R,a6 as z,b as f,n as X,a1 as le,c$ as M,d0 as se,bE as G,bj as y,d1 as K,U as P,bF as re,an as N,$ as A,ce as $,d2 as ce,cc as de,d3 as E,Z as H,h as oe,af as ue,d4 as ve,cr as fe,cz as he,d5 as me,cQ as Ie,d6 as U,M as ge,T as be,bm as Le,d7 as we,d8 as Ve,bq as k,a5 as Q,br as ke,cp as ye,cv as Ce,ae as W}from"./index-B9yS4Bcc.js";function Ae(e){let{depth:u,isLast:t,isLastGroup:L,leafLinks:g,separateRoots:s,parentIndentLines:a,variant:w}=e;if(!a||!u)return{leaf:void 0,node:void 0,children:a};if(w==="simple")return{leaf:[...a,"line"],node:[...a,"line"],children:[...a,"line"]};const i=t&&(!L||s||u>1);return{leaf:[...a,i?"last-leaf":"leaf",...g?["leaf-link"]:[]],node:[...a,i?"last-leaf":"leaf"],children:[...a,i?"none":"line"]}}const Pe=j({start:Boolean,end:Boolean,...ae(),...ie()},"VListItemAction"),Te=R()({name:"VListItemAction",props:Pe(),setup(e,u){let{slots:t}=u;return z(()=>f(e.tag,{class:X(["v-list-item-action",{"v-list-item-action--start":e.start,"v-list-item-action--end":e.end},e.class]),style:le(e.style)},t)),{}}}),Se=j({...M(se({collapseIcon:"$treeviewCollapse",expandIcon:"$treeviewExpand"}),["subgroup"])},"VTreeviewGroup"),Z=R()({name:"VTreeviewGroup",props:Se(),setup(e,u){let{slots:t}=u;const L=G(),g=y(()=>{var a;return(a=L.value)!=null&&a.isOpen?e.collapseIcon:e.expandIcon}),s=y(()=>({VTreeviewItem:{prependIcon:void 0,appendIcon:void 0,toggleIcon:g.value}}));return z(()=>{const a=K.filterProps(e);return f(K,A(a,{ref:L,class:["v-treeview-group",e.class],subgroup:!0}),{...t,activator:t.activator?w=>P(N,null,[f(re,{defaults:s.value},{default:()=>{var i;return[(i=t.activator)==null?void 0:i.call(t,w)]}})]):void 0})}),{}}}),Y=Symbol.for("vuetify:v-treeview"),ee=j({loading:Boolean,hideActions:Boolean,indentLines:Array,toggleIcon:$,...ce({slim:!0})},"VTreeviewItem"),J=R()({name:"VTreeviewItem",props:ee(),emits:{toggleExpand:e=>!0},setup(e,u){let{slots:t,emit:L}=u;const g=de(Y,{visibleIds:G()}).visibleIds,s=G(),a=y(()=>{var l,c;return((l=s.value)==null?void 0:l.root.activatable.value)&&((c=s.value)==null?void 0:c.isGroupActivator)}),w=y(()=>{var l,c;return((l=s.value)==null?void 0:l.link.isClickable.value)||e.value!=null&&!!((c=s.value)!=null&&c.list)}),i=y(()=>!e.disabled&&e.link!==!1&&(e.link||w.value||a.value)),V=y(()=>{var l;return g.value&&!g.value.has(E((l=s.value)==null?void 0:l.id))});function n(l){var c,r;i.value&&a.value&&((r=s.value)==null||r.activate(!((c=s.value)!=null&&c.isActivated),l))}function h(l){l.preventDefault(),l.stopPropagation(),L("toggleExpand",l)}return z(()=>{var r;const l=H.filterProps(e),c=t.prepend||e.toggleIcon||e.indentLines;return f(H,A({ref:s},l,{active:((r=s.value)==null?void 0:r.isActivated)||void 0,class:["v-treeview-item",{"v-treeview-item--activatable-group-activator":a.value,"v-treeview-item--filtered":V.value},e.class],ripple:!1,onClick:n}),{...t,prepend:c?T=>{var S;return P(N,null,[e.indentLines&&e.indentLines.length>0?P("div",{key:"indent-lines",class:"v-treeview-indent-lines",style:{"--v-indent-parts":e.indentLines.length}},[e.indentLines.map(p=>P("div",{class:X(`v-treeview-indent-line v-treeview-indent-line--${p}`)},null))]):"",!e.hideActions&&f(Te,{start:!0},{default:()=>[e.toggleIcon?f(oe,{density:"compact",icon:e.toggleIcon,loading:e.loading,variant:"text",onClick:h},{loader:()=>f(ue,{indeterminate:"disable-shrink",size:"20",width:"2"},null)}):P("div",{class:"v-treeview-item__level"},null)]}),(S=t.prepend)==null?void 0:S.call(t,T)])}:void 0})}),ve({},s)}}),te=j({disabled:Boolean,loadChildren:Function,loadingIcon:{type:String,default:"$loading"},items:Array,openOnClick:{type:Boolean,default:void 0},indeterminateIcon:{type:$,default:"$checkboxIndeterminate"},falseIcon:$,trueIcon:$,returnObject:Boolean,activatable:Boolean,selectable:Boolean,selectedColor:String,selectStrategy:[String,Function,Object],index:Number,isLastGroup:Boolean,separateRoots:Boolean,parentIndentLines:Array,indentLinesVariant:String,path:{type:Array,default:()=>[]},...fe(ee(),["hideActions"]),...he()},"VTreeviewChildren"),D=R()({name:"VTreeviewChildren",props:te(),setup(e,u){let{slots:t}=u;const L=me(new Set),g=G([]),s=y(()=>!e.disabled&&(e.openOnClick!=null?e.openOnClick:e.selectable&&!e.activatable));async function a(i){var V,n;try{if(!((V=e.items)!=null&&V.length)||!e.loadChildren)return;((n=i==null?void 0:i.children)==null?void 0:n.length)===0&&(L.add(i.value),await e.loadChildren(i.raw))}finally{L.delete(i.value)}}function w(i,V){e.selectable&&i(V)}return()=>{var i,V;return((i=t.default)==null?void 0:i.call(t))??((V=e.items)==null?void 0:V.map((n,h,l)=>{var B,_;const{children:c,props:r}=n,T=L.has(n.value),S=!!((B=l.at(h+1))!=null&&B.children),p=((_=e.path)==null?void 0:_.length)??0,O=l.length-1===h,m={index:h,depth:p,isFirst:h===0,isLast:O,path:[...e.path,h],hideAction:e.hideActions},v=Ae({depth:p,isLast:O,isLastGroup:e.isLastGroup,leafLinks:!e.hideActions,separateRoots:e.separateRoots,parentIndentLines:e.parentIndentLines,variant:e.indentLinesVariant}),d={prepend:b=>{var I;return P(N,null,[e.selectable&&(!c||c&&!["leaf","single-leaf"].includes(e.selectStrategy))&&P("div",null,[f(Ie,{key:n.value,modelValue:b.isSelected,disabled:e.disabled,loading:T,color:e.selectedColor,density:e.density,indeterminate:b.isIndeterminate,indeterminateIcon:e.indeterminateIcon,falseIcon:e.falseIcon,trueIcon:e.trueIcon,"onUpdate:modelValue":C=>w(b.select,C),onClick:C=>C.stopPropagation(),onKeydown:C=>{["Enter","Space"].includes(C.key)&&(C.stopPropagation(),w(b.select,b.isSelected))}},null)]),(I=t.prepend)==null?void 0:I.call(t,{...b,...m,item:n.raw,internalItem:n})])},append:t.append?b=>{var I;return(I=t.append)==null?void 0:I.call(t,{...b,...m,item:n.raw,internalItem:n})}:void 0,title:t.title?b=>{var I;return(I=t.title)==null?void 0:I.call(t,{...b,item:n.raw,internalItem:n})}:void 0,subtitle:t.subtitle?b=>{var I;return(I=t.subtitle)==null?void 0:I.call(t,{...b,item:n.raw,internalItem:n})}:void 0},o=Z.filterProps(r),x=D.filterProps({...e,...m});return c?f(Z,A(o,{value:e.returnObject?n.raw:o==null?void 0:o.value,rawId:o==null?void 0:o.value}),{activator:b=>{let{props:I}=b;const C={...r,...I,value:r==null?void 0:r.value,onToggleExpand:[()=>a(n),I.onClick],onClick:s.value?[()=>a(n),I.onClick]:()=>{var F,q;return w((F=g.value[h])==null?void 0:F.select,!((q=g.value[h])!=null&&q.isSelected))}};return f(J,A({ref:F=>g.value[h]=F},C,{hideActions:e.hideActions,indentLines:v.node,value:e.returnObject?n.raw:r.value,loading:T}),d)},default:()=>f(D,A(x,{items:c,indentLinesVariant:e.indentLinesVariant,parentIndentLines:v.children,isLastGroup:S,returnObject:e.returnObject}),t)}):U(t.item,{props:r,item:n.raw,internalItem:n},()=>n.type==="divider"?U(t.divider,{props:n.raw},()=>f(ge,n.props,null)):n.type==="subheader"?U(t.subheader,{props:n.raw},()=>f(be,n.props,null)):f(J,A(r,{hideActions:e.hideActions,indentLines:v.leaf,value:e.returnObject?E(n.raw):r.value}),d))}))}}});function ne(e){let u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];for(const t of e)u.push(t),t.children&&ne(t.children,u);return u}const pe=j({fluid:Boolean,openAll:Boolean,indentLines:[Boolean,String],search:String,...Le({filterKeys:["title"]}),...M(te(),["index","path","indentLinesVariant","parentIndentLines","isLastGroup"]),...M(we({collapseIcon:"$treeviewCollapse",expandIcon:"$treeviewExpand",slim:!0}),["nav","openStrategy"]),modelValue:Array},"VTreeview"),Oe=R()({name:"VTreeview",props:pe(),emits:{"update:opened":e=>!0,"update:activated":e=>!0,"update:selected":e=>!0,"update:modelValue":e=>!0,"click:open":e=>!0,"click:select":e=>!0},setup(e,u){let{slots:t,emit:L}=u;const{items:g}=Ve(e),s=k(()=>e.activeColor),a=k(()=>e.baseColor),w=k(()=>e.color),i=Q(e,"activated"),V=Q(e,"selected"),n=y({get:()=>e.modelValue??V.value,set(m){V.value=m,L("update:modelValue",m)}}),h=G(),l=y(()=>e.openAll?O(g.value):e.opened),c=y(()=>ne(g.value)),r=k(()=>e.search),{filteredItems:T}=ke(e,c,r),S=y(()=>{var v;if(!r.value)return null;const m=(v=h.value)==null?void 0:v.getPath;return m?new Set(T.value.flatMap(d=>{const o=e.returnObject?d.raw:d.props.value;return[...m(o),...p(o)].map(E)})):null});function p(m){var o,x;const v=[],d=(((o=h.value)==null?void 0:o.children.get(m))??[]).slice();for(;d.length;){const B=d.shift();B&&(v.push(B),d.push(...(((x=h.value)==null?void 0:x.children.get(B))??[]).slice()))}return v}function O(m){let v=[];for(const d of m)d.children&&(v.push(e.returnObject?E(d.raw):d.value),d.children&&(v=v.concat(O(d.children))));return v}return ye(Y,{visibleIds:S}),Ce({VTreeviewGroup:{activeColor:s,baseColor:a,color:w,collapseIcon:k(()=>e.collapseIcon),expandIcon:k(()=>e.expandIcon)},VTreeviewItem:{activeClass:k(()=>e.activeClass),activeColor:s,baseColor:a,color:w,density:k(()=>e.density),disabled:k(()=>e.disabled),lines:k(()=>e.lines),variant:k(()=>e.variant)}}),z(()=>{const m=W.filterProps(e),v=D.filterProps(e),d=typeof e.indentLines=="boolean"?"default":e.indentLines;return f(W,A({ref:h},m,{class:["v-treeview",{"v-treeview--fluid":e.fluid},e.class],openStrategy:"multiple",style:e.style,opened:l.value,activated:i.value,"onUpdate:activated":o=>i.value=o,selected:n.value,"onUpdate:selected":o=>n.value=o}),{default:()=>[f(D,A(v,{density:e.density,returnObject:e.returnObject,items:g.value,parentIndentLines:e.indentLines?[]:void 0,indentLinesVariant:d}),t)]})}),{}}});export{Oe as V};