2 lines
4.6 KiB
JavaScript
2 lines
4.6 KiB
JavaScript
import{s as G,o as D,c as g,bP as ee,p as te,a6 as ae,by as ne,a9 as le,r as x,at as oe,w as m,l as ue,ac as ie,aW as re,F as l,H as k,Z as I,N as z,bw as se,bQ as ce,be as de,z as R,bh as fe,b as ve,aa as xe}from"./index-0a3df21c.js";import{m as me,a as ge,u as he,V as _,f as we,b as Ve,c as ye}from"./VInput-72dd485d.js";function be(){const e=G(!1);return D(()=>{window.requestAnimationFrame(()=>{e.value=!0})}),{ssrBootStyles:g(()=>e.value?void 0:{transition:"none !important"}),isBooted:ee(e)}}const Fe=te({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,...me(),...ge()},"VTextarea"),Se=ae()({name:"VTextarea",directives:{Intersect:ne},inheritAttrs:!1,props:Fe(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,B){let{attrs:F,emit:H,slots:i}=B;const o=le(e,"modelValue"),{isFocused:f,focus:E,blur:U}=he(e),O=g(()=>typeof e.counterValue=="function"?e.counterValue(o.value):(o.value||"").toString().length),$=g(()=>{if(F.maxlength)return F.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter});function j(t,n){var a,u;!e.autofocus||!t||(u=(a=n[0].target)==null?void 0:a.focus)==null||u.call(a)}const M=x(),h=x(),N=G(""),w=x(),q=g(()=>e.persistentPlaceholder||f.value||e.active);function P(){var t;w.value!==document.activeElement&&((t=w.value)==null||t.focus()),f.value||E()}function Q(t){P(),H("click:control",t)}function W(t){H("mousedown:control",t)}function Z(t){t.stopPropagation(),P(),R(()=>{o.value="",fe(e["onClick:clear"],t)})}function J(t){var a;const n=t.target;if(o.value=n.value,(a=e.modelModifiers)!=null&&a.trim){const u=[n.selectionStart,n.selectionEnd];R(()=>{n.selectionStart=u[0],n.selectionEnd=u[1]})}}const c=x(),V=x(+e.rows),C=g(()=>["plain","underlined"].includes(e.variant));oe(()=>{e.autoGrow||(V.value=+e.rows)});function d(){e.autoGrow&&R(()=>{if(!c.value||!h.value)return;const t=getComputedStyle(c.value),n=getComputedStyle(h.value.$el),a=parseFloat(t.getPropertyValue("--v-field-padding-top"))+parseFloat(t.getPropertyValue("--v-input-padding-top"))+parseFloat(t.getPropertyValue("--v-field-padding-bottom")),u=c.value.scrollHeight,y=parseFloat(t.lineHeight),b=Math.max(parseFloat(e.rows)*y+a,parseFloat(n.getPropertyValue("--v-input-control-height"))),S=parseFloat(e.maxRows)*y+a||1/0,s=xe(u??0,b,S);V.value=Math.floor((s-a)/y),N.value=ve(s)})}D(d),m(o,d),m(()=>e.rows,d),m(()=>e.maxRows,d),m(()=>e.density,d);let r;return m(c,t=>{t?(r=new ResizeObserver(d),r.observe(c.value)):r==null||r.disconnect()}),ue(()=>{r==null||r.disconnect()}),ie(()=>{const t=!!(i.counter||e.counter||e.counterValue),n=!!(t||i.details),[a,u]=re(F),[{modelValue:y,...b}]=_.filterProps(e),[S]=we(e);return l(_,k({ref:M,modelValue:o.value,"onUpdate:modelValue":s=>o.value=s,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-text-field--plain-underlined":C.value},e.class],style:e.style},a,b,{centerAffix:V.value===1&&!C.value,focused:f.value}),{...i,default:s=>{let{isDisabled:v,isDirty:T,isReadonly:K,isValid:L}=s;return l(Ve,k({ref:h,style:{"--v-textarea-control-height":N.value},onClick:Q,onMousedown:W,"onClick:clear":Z,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"],role:"textbox"},S,{active:q.value||T.value,centerAffix:V.value===1&&!C.value,dirty:T.value||e.dirty,disabled:v.value,focused:f.value,error:L.value===!1}),{...i,default:X=>{let{props:{class:A,...Y}}=X;return l(I,null,[e.prefix&&l("span",{class:"v-text-field__prefix"},[e.prefix]),z(l("textarea",k({ref:w,class:A,value:o.value,onInput:J,autofocus:e.autofocus,readonly:K.value,disabled:v.value,placeholder:e.placeholder,rows:e.rows,name:e.name,onFocus:P,onBlur:U},Y,u),null),[[se("intersect"),{handler:j},null,{once:!0}]]),e.autoGrow&&z(l("textarea",{class:[A,"v-textarea__sizer"],"onUpdate:modelValue":p=>o.value=p,ref:c,readonly:!0,"aria-hidden":"true"},null),[[ce,o.value]]),e.suffix&&l("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:n?s=>{var v;return l(I,null,[(v=i.details)==null?void 0:v.call(i,s),t&&l(I,null,[l("span",null,null),l(ye,{active:e.persistentCounter||f.value,value:O.value,max:$.value},i.counter)])])}:void 0})}),de({},M,h,w)}});export{Se as V,be as u};
|