UNPKG

zwave-js-ui

Version:

Z-Wave Control Panel and MQTT Gateway

2 lines (1 loc) 9.56 kB
import{a2 as S,a3 as B,a5 as F,b as i,U as ee,n as Q,br as te,bt as ne,bG as G,bm as b,dc as N,H as y,bI as $,am as T,R as k,bQ as D,dd as ae,de as ie,cu as j,cn as le,d3 as x,Q as U,i as se,ae as re,df as de,l as oe,dg as ce,dh as ue,di as R,cR as ve,cG as fe,E as me,N as ge,c_ as Ie,dj as he,bo as h,a4 as _,bp as be,cE as we,ab as H,bs as Ve,dk as Le,cB as ye}from"./index-B8xHYEBg.js";function ke(e){let{depth:d,isLast:n,isLastGroup:m,leafLinks:v,separateRoots:s,parentIndentLines:l,variant:g}=e;if(!l||!d)return{leaf:void 0,node:void 0,children:l};if(g==="simple")return{leaf:[...l,"line"],node:[...l,"line"],children:[...l,"line"]};const t=n&&(!m||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=B({start:Boolean,end:Boolean,...ne(),...te()},"VListItemAction"),q=S()({name:"VListItemAction",props:Ce(),setup(e,d){let{slots:n}=d;return F(()=>i(e.tag,{class:Q(["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)),{}}}),Ae=B({...D(ae({collapseIcon:"$treeviewCollapse",expandIcon:"$treeviewExpand"}),["subgroup"])},"VTreeviewGroup"),K=S()({name:"VTreeviewGroup",props:Ae(),setup(e,d){let{slots:n}=d;const m=G(),v=b(()=>m.value?.isOpen?e.collapseIcon:e.expandIcon),s=b(()=>({VTreeviewItem:{prependIcon:void 0,appendIcon:void 0,toggleIcon:v.value}}));return F(()=>{const l=N.filterProps(e);return i(N,k(l,{ref:m,class:["v-treeview-group",e.class],subgroup:!0}),{...n,activator:n.activator?g=>y(T,null,[i($,{defaults:s.value},{default:()=>[n.activator?.(g)]})]):void 0})}),{}}}),W=Symbol.for("vuetify:v-treeview"),J=B({loading:Boolean,hideActions:Boolean,hasCustomPrepend:Boolean,indentLines:Array,toggleIcon:j,...ie({slim:!0})},"VTreeviewItem"),M=S()({name:"VTreeviewItem",props:J(),emits:{toggleExpand:e=>!0},setup(e,d){let{slots:n,emit:m}=d;const v=le(W,{visibleIds:G()}).visibleIds,s=G(),l=b(()=>s.value?.root.activatable.value&&s.value?.isGroupActivator),g=b(()=>s.value?.link.isClickable.value||e.value!=null&&!!s.value?.list),t=b(()=>!e.disabled&&e.link!==!1&&(e.link||g.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(),m("toggleExpand",r)}return F(()=>{const r=U.filterProps(e),V=n.prepend||e.toggleIcon||e.indentLines||e.prependIcon||e.prependAvatar;return i(U,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(A=>y("div",{class:Q(`v-treeview-indent-line v-treeview-indent-line--${A}`)},null))]):"",!e.hideActions&&i(q,{start:!0},{default:()=>[e.toggleIcon?y(T,null,[n.toggle?i($,{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($,{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)}}),X=B({fluid:Boolean,disabled:Boolean,loadChildren:Function,loadingIcon:{type:String,default:"$loading"},items:Array,openOnClick:{type:Boolean,default:void 0},indeterminateIcon:{type:j,default:"$checkboxIndeterminate"},falseIcon:j,trueIcon:j,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(J(),["hideActions"]),...ve()},"VTreeviewChildren"),E=S()({name:"VTreeviewChildren",props:X(),setup(e,d){let{slots:n}=d;const m=ue(new Set),v=G([]),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&&(m.add(t.value),await e.loadChildren(t.raw))}finally{m.delete(t.value)}}function g(t,u){e.selectable&&t(u)}return()=>n.default?.()??e.items?.map((t,u,C)=>{const{children:I,props:r}=t,V=m.has(t.value),L=!!C.at(u+1)?.children,A=e.path?.length??0,O=C.length-1===u,P={index:u,depth:A,isFirst:u===0,isLast:O,path:[...e.path,u],hideAction:e.hideActions},p=ke({depth:A,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,...P,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(q,{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=>g(a.select,w),onClick:w=>w.stopPropagation(),onKeydown:w=>{["Enter","Space"].includes(w.key)&&(w.stopPropagation(),g(a.select,a.isSelected))}},null)]}),n.prepend?.({...a,...P,item:t.raw,internalItem:t})]),append:n.append?a=>n.append?.({...a,...P,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=K.filterProps(r),c=E.filterProps({...e,...P});return I?i(K,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]:()=>g(v.value[u]?.select,!v.value[u]?.isSelected)};return R(n.header,{props:z,item:t.raw,internalItem:t,loading:V},()=>i(M,k({ref:Z=>v.value[u]=Z},z,{hasCustomPrepend:!!n.prepend,hideActions:e.hideActions,value:e.returnObject?t.raw:r.value,loading:V}),f))},default:()=>i(E,k(c,{items:I,indentLinesVariant:e.indentLinesVariant,parentIndentLines:p.children,isLastGroup:L,returnObject:e.returnObject}),n)}):R(n.item,{props:r,item:t.raw,internalItem:t},()=>t.type==="divider"?R(n.divider,{props:t.raw},()=>i(me,t.props,null)):t.type==="subheader"?R(n.subheader,{props:t.raw},()=>i(ge,t.props,null)):i(M,k(r,{hasCustomPrepend:!!n.prepend,hideActions:e.hideActions,indentLines:p.leaf,value:e.returnObject?x(t.raw):r.value}),f))})}});function Y(e){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];for(const n of e)d.push(n),n.children&&Y(n.children,d);return d}const Pe=B({openAll:Boolean,indentLines:[Boolean,String],search:String,...Ve({filterKeys:["title"]}),...D(X(),["index","path","indentLinesVariant","parentIndentLines","isLastGroup"]),...D(Le({collapseIcon:"$treeviewCollapse",expandIcon:"$treeviewExpand",slim:!0}),["nav","openStrategy"]),modelValue:Array},"VTreeview"),Te=S()({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,d){let{slots:n,emit:m}=d;const{items:v}=he(e),s=h(()=>e.activeColor),l=h(()=>e.baseColor),g=h(()=>e.color),t=_(e,"activated"),u=_(e,"selected"),C=b({get:()=>e.modelValue??u.value,set(f){u.value=f,m("update:modelValue",f)}}),I=G(),r=b(()=>e.openAll?p(v.value):e.opened),V=b(()=>Y(v.value)),L=h(()=>e.search),{filteredItems:A}=be(e,V,L),O=b(()=>{if(!L.value)return null;const f=I.value?.getPath;return f?new Set(A.value.flatMap(o=>{const c=e.returnObject?o.raw:o.props.value;return[...f(c),...P(c)].map(x)})):null});function P(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(W,{visibleIds:O}),we({VTreeviewGroup:{activeColor:s,baseColor:l,color:g,collapseIcon:h(()=>e.collapseIcon),expandIcon:h(()=>e.expandIcon)},VTreeviewItem:{activeClass:h(()=>e.activeClass),activeColor:s,baseColor:l,color:g,density:h(()=>e.density),disabled:h(()=>e.disabled),lines:h(()=>e.lines),variant:h(()=>e.variant)}}),F(()=>{const f=H.filterProps(e),o=E.filterProps(e),c=typeof e.indentLines=="boolean"?"default":e.indentLines;return i(H,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(E,k(o,{density:e.density,returnObject:e.returnObject,items:v.value,parentIndentLines:e.indentLines?[]:void 0,indentLinesVariant:c}),n)]})}),{}}});export{Te as V};