zwave-js-ui
Version:
Z-Wave Control Panel and MQTT Gateway
2 lines (1 loc) • 5 kB
JavaScript
import{a3 as se,a4 as ie,aK as G,a5 as ce,dk as de,bl as b,bF as m,bI as fe,cM as ve,dl as me,bM as xe,dm as ge,d5 as x,dn as he,a6 as we,dp as Ve,dq as U,dr as E,b as N,T as A,cU as O,df as ye,ds as be,dt as Ce,du as Fe,a9 as C,d7 as Pe,H as u,P as p,dv as Ie,q as W,dw as ke,dx as Re,n as Se,cI as Me}from"./index-DwzE-W2i.js";const Ne=ie({autoGrow:Boolean,autofocus:Boolean,counter:[Boolean,Number,String],counterValue:Function,prefix:String,placeholder:String,persistentPlaceholder:Boolean,persistentCounter:Boolean,noResize:Boolean,rows:{type:[Number,String],default:5,validator:e=>!isNaN(parseFloat(e))},maxRows:{type:[Number,String],validator:e=>!isNaN(parseFloat(e))},suffix:String,modelModifiers:Object,...Fe(),...Ce(),...be()},"VTextarea"),pe=se()({name:"VTextarea",directives:{vIntersect:G},inheritAttrs:!1,props:Ne(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0,"update:rows":e=>!0},setup(e,q){let{attrs:F,emit:P,slots:i}=q;const l=ce(e,"modelValue"),{isFocused:g,focus:$,blur:j}=de(e),{onIntersect:K}=ke(e),J=b(()=>typeof e.counterValue=="function"?e.counterValue(l.value):(l.value||"").toString().length),L=b(()=>{if(F.maxlength)return F.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),B=m(),w=m(),H=fe(""),c=m(),I=m(0),{platform:Q}=ve(),V=me(e),X=b(()=>e.persistentPlaceholder||g.value||e.active);function k(){V.isSuppressing.value&&V.update(),c.value!==document.activeElement&&c.value?.focus(),g.value||$()}function Y(t){k(),P("click:control",t)}function Z(t){P("mousedown:control",t)}function ee(t){t.stopPropagation(),k(),C(()=>{l.value="",Me(e["onClick:clear"],t)})}function te(t){const a=t.target;if(!e.modelModifiers?.trim){l.value=a.value;return}const n=a.value,v=a.selectionStart,r=a.selectionEnd;l.value=n,C(()=>{let s=0;n.trimStart().length===a.value.length&&(s=n.length-a.value.length),v!=null&&(a.selectionStart=v-s),r!=null&&(a.selectionEnd=r-s)})}const d=m(),h=m(Number(e.rows)),R=b(()=>["plain","underlined"].includes(e.variant));xe(()=>{e.autoGrow||(h.value=Number(e.rows))});function f(){C(()=>{if(!c.value)return;if(Q.value.firefox){I.value=12;return}const{offsetWidth:t,clientWidth:a}=c.value;I.value=Math.max(0,t-a)}),e.autoGrow&&C(()=>{if(!d.value||!w.value)return;const t=getComputedStyle(d.value),a=getComputedStyle(w.value.$el),n=parseFloat(t.getPropertyValue("--v-field-padding-top"))+parseFloat(t.getPropertyValue("--v-input-padding-top"))+parseFloat(t.getPropertyValue("--v-field-padding-bottom")),v=d.value.scrollHeight,r=parseFloat(t.lineHeight),s=Math.max(parseFloat(e.rows)*r+n,parseFloat(a.getPropertyValue("--v-input-control-height"))),S=parseFloat(e.maxRows)*r+n||1/0,o=Pe(v??0,s,S);h.value=Math.floor((o-n)/r),H.value=O(o)})}ge(f),x(l,f),x(()=>e.rows,f),x(()=>e.maxRows,f),x(()=>e.density,f),x(h,t=>{P("update:rows",t)});let y;return x(d,t=>{t?(y=new ResizeObserver(f),y.observe(d.value)):y?.disconnect()}),he(()=>{y?.disconnect()}),we(()=>{const t=!!(i.counter||e.counter||e.counterValue),a=!!(t||i.details),[n,v]=Ve(F),{modelValue:r,...s}=U.filterProps(e),S={...E.filterProps(e),"onClick:clear":ee};return N(U,A({ref:B,modelValue:l.value,"onUpdate:modelValue":o=>l.value=o,class:["v-textarea v-text-field",{"v-textarea--prefixed":e.prefix,"v-textarea--suffixed":e.suffix,"v-text-field--prefixed":e.prefix,"v-text-field--suffixed":e.suffix,"v-textarea--auto-grow":e.autoGrow,"v-textarea--no-resize":e.noResize||e.autoGrow,"v-input--plain-underlined":R.value},e.class],style:[{"--v-textarea-scroll-bar-width":O(I.value)},e.style]},n,s,{centerAffix:h.value===1&&!R.value,focused:g.value}),{...i,default:o=>{let{id:ae,isDisabled:z,isDirty:T,isReadonly:le,isValid:ne,hasDetails:oe}=o;return N(E,A({ref:w,style:{"--v-textarea-control-height":H.value},onClick:Y,onMousedown:Z,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},S,{id:ae.value,active:X.value||T.value,centerAffix:h.value===1&&!R.value,dirty:T.value||e.dirty,disabled:z.value,focused:g.value,details:oe.value,error:ne.value===!1}),{...i,default:ue=>{let{props:{class:_,...D},controlRef:re}=ue;return u(p,null,[e.prefix&&u("span",{class:"v-text-field__prefix"},[e.prefix]),W(u("textarea",A({ref:M=>c.value=re.value=M,class:_,value:l.value,onInput:te,autofocus:e.autofocus,readonly:le.value,disabled:z.value,placeholder:e.placeholder,rows:e.rows,name:V.fieldName.value,autocomplete:V.fieldAutocomplete.value,onFocus:k,onBlur:j},D,v),null),[[G,{handler:K},null,{once:!0}]]),e.autoGrow&&W(u("textarea",{class:Se([_,"v-textarea__sizer"]),id:`${D.id}-sizer`,"onUpdate:modelValue":M=>l.value=M,ref:d,readonly:!0,"aria-hidden":"true"},null),[[Re,l.value]]),e.suffix&&u("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:a?o=>u(p,null,[i.details?.(o),t&&u(p,null,[u("span",null,null),N(Ie,{active:e.persistentCounter||g.value,value:J.value,max:L.value,disabled:e.disabled},i.counter)])]):void 0})}),ye({},B,w,c)}});export{pe as V};