UNPKG

zwave-js-ui

Version:

Z-Wave Control Panel and MQTT Gateway

2 lines (1 loc) 5 kB
import{a2 as se,a3 as ie,aL as D,a4 as ce,dl as de,bm as b,bG as m,bJ as fe,cN as ve,dm as me,bN as xe,dn as ge,d6 as x,dp as he,a5 as we,dq as Ve,dr as E,ds as U,b as A,R as M,cV as O,dg as ye,dt as be,du as Ce,dv as Fe,a8 as C,d8 as Pe,H as u,am as p,dw as Re,q as W,dx as ke,dy as Ie,n as Ne,cJ as Se}from"./index-B8xHYEBg.js";const Ae=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:D},inheritAttrs:!1,props:Ae(),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:J,blur:$}=de(e),{onIntersect:j}=ke(e),L=b(()=>typeof e.counterValue=="function"?e.counterValue(l.value):(l.value||"").toString().length),K=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(),R=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||J()}function Y(t){k(),P("click:control",t)}function Z(t){P("mousedown:control",t)}function ee(t){t.stopPropagation(),k(),C(()=>{l.value="",Se(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)),I=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){R.value=12;return}const{offsetWidth:t,clientWidth:a}=c.value;R.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"))),N=parseFloat(e.maxRows)*r+n||1/0,o=Pe(v??0,s,N);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}=E.filterProps(e),N={...U.filterProps(e),"onClick:clear":ee};return A(E,M({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":I.value},e.class],style:[{"--v-textarea-scroll-bar-width":O(R.value)},e.style]},n,s,{centerAffix:h.value===1&&!I.value,focused:g.value}),{...i,default:o=>{let{id:ae,isDisabled:z,isDirty:G,isReadonly:le,isValid:ne,hasDetails:oe}=o;return A(U,M({ref:w,style:{"--v-textarea-control-height":H.value},onClick:Y,onMousedown:Z,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},N,{id:ae.value,active:X.value||G.value,centerAffix:h.value===1&&!I.value,dirty:G.value||e.dirty,disabled:z.value,focused:g.value,details:oe.value,error:ne.value===!1}),{...i,default:ue=>{let{props:{class:T,..._},controlRef:re}=ue;return u(p,null,[e.prefix&&u("span",{class:"v-text-field__prefix"},[e.prefix]),W(u("textarea",M({ref:S=>c.value=re.value=S,class:T,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:$},_,v),null),[[D,{handler:j},null,{once:!0}]]),e.autoGrow&&W(u("textarea",{class:Ne([T,"v-textarea__sizer"]),id:`${_.id}-sizer`,"onUpdate:modelValue":S=>l.value=S,ref:d,readonly:!0,"aria-hidden":"true"},null),[[Ie,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),A(Re,{active:e.persistentCounter||g.value,value:L.value,max:K.value,disabled:e.disabled},i.counter)])]):void 0})}),ye({},B,w,c)}});export{pe as V};