zwave-js-ui
Version:
Z-Wave Control Panel and MQTT Gateway
2 lines (1 loc) • 4.6 kB
JavaScript
import{a2 as ne,de as le,df as oe,a4 as ue,aR as E,a5 as ie,dg as re,bj as y,bE as x,cF as se,cL as ce,dh as de,cW as f,di as fe,a6 as ve,dj as me,dk as G,dl as U,b as R,$ as S,U as r,v as D,dm as xe,n as ge,an as N,dn as he,d4 as we,dp as Ve,a8 as B,dq as ye,cK as Ce,cY as Fe}from"./index-B9yS4Bcc.js";const Pe=ne({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,...le(),...oe()},"VTextarea"),ke=ue()({name:"VTextarea",directives:{vIntersect:E},inheritAttrs:!1,props:Pe(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0,"update:rows":e=>!0},setup(e,j){let{attrs:C,emit:F,slots:l}=j;const a=ie(e,"modelValue"),{isFocused:v,focus:O,blur:$}=re(e),{onIntersect:q}=Ve(e),K=y(()=>typeof e.counterValue=="function"?e.counterValue(a.value):(a.value||"").toString().length),L=y(()=>{if(C.maxlength)return C.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),M=x(),g=x(),z=se(""),h=x(),W=y(()=>e.persistentPlaceholder||v.value||e.active);function P(){var t;h.value!==document.activeElement&&((t=h.value)==null||t.focus()),v.value||O()}function Y(t){P(),F("click:control",t)}function J(t){F("mousedown:control",t)}function Q(t){t.stopPropagation(),P(),B(()=>{a.value="",ye(e["onClick:clear"],t)})}function X(t){var u;const n=t.target;if(a.value=n.value,(u=e.modelModifiers)!=null&&u.trim){const d=[n.selectionStart,n.selectionEnd];B(()=>{n.selectionStart=d[0],n.selectionEnd=d[1]})}}const s=x(),m=x(Number(e.rows)),b=y(()=>["plain","underlined"].includes(e.variant));ce(()=>{e.autoGrow||(m.value=Number(e.rows))});function c(){e.autoGrow&&B(()=>{if(!s.value||!g.value)return;const t=getComputedStyle(s.value),n=getComputedStyle(g.value.$el),u=parseFloat(t.getPropertyValue("--v-field-padding-top"))+parseFloat(t.getPropertyValue("--v-input-padding-top"))+parseFloat(t.getPropertyValue("--v-field-padding-bottom")),d=s.value.scrollHeight,w=parseFloat(t.lineHeight),k=Math.max(parseFloat(e.rows)*w+u,parseFloat(n.getPropertyValue("--v-input-control-height"))),I=parseFloat(e.maxRows)*w+u||1/0,i=Fe(d??0,k,I);m.value=Math.floor((i-u)/w),z.value=Ce(i)})}de(c),f(a,c),f(()=>e.rows,c),f(()=>e.maxRows,c),f(()=>e.density,c),f(m,t=>{F("update:rows",t)});let o;return f(s,t=>{t?(o=new ResizeObserver(c),o.observe(s.value)):o==null||o.disconnect()}),fe(()=>{o==null||o.disconnect()}),ve(()=>{const t=!!(l.counter||e.counter||e.counterValue),n=!!(t||l.details),[u,d]=me(C),{modelValue:w,...k}=G.filterProps(e),I=U.filterProps(e);return R(G,S({ref:M,modelValue:a.value,"onUpdate:modelValue":i=>a.value=i,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":b.value},e.class],style:e.style},u,k,{centerAffix:m.value===1&&!b.value,focused:v.value}),{...l,default:i=>{let{id:V,isDisabled:A,isDirty:H,isReadonly:Z,isValid:p,hasDetails:ee}=i;return R(U,S({ref:g,style:{"--v-textarea-control-height":z.value},onClick:Y,onMousedown:J,"onClick:clear":Q,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},I,{id:V.value,active:W.value||H.value,centerAffix:m.value===1&&!b.value,dirty:H.value||e.dirty,disabled:A.value,focused:v.value,details:ee.value,error:p.value===!1}),{...l,default:te=>{let{props:{class:T,..._}}=te;return r(N,null,[e.prefix&&r("span",{class:"v-text-field__prefix"},[e.prefix]),D(r("textarea",S({ref:h,class:T,value:a.value,onInput:X,autofocus:e.autofocus,readonly:Z.value,disabled:A.value,placeholder:e.placeholder,rows:e.rows,name:e.name,onFocus:P,onBlur:$},_,d),null),[[E,{handler:q},null,{once:!0}]]),e.autoGrow&&D(r("textarea",{class:ge([T,"v-textarea__sizer"]),id:`${_.id}-sizer`,"onUpdate:modelValue":ae=>a.value=ae,ref:s,readonly:!0,"aria-hidden":"true"},null),[[xe,a.value]]),e.suffix&&r("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:n?i=>{var V;return r(N,null,[(V=l.details)==null?void 0:V.call(l,i),t&&r(N,null,[r("span",null,null),R(he,{active:e.persistentCounter||v.value,value:K.value,max:L.value,disabled:e.disabled},l.counter)])])}:void 0})}),we({},M,g,h)}});export{ke as V};