UNPKG

zwave-js-ui

Version:

Z-Wave Control Panel and MQTT Gateway

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