1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2025-10-23 02:43:10 +00:00
Classworks/assets/VTextarea-CqMEgm5W.js

2 lines
4.6 KiB
JavaScript

import{g as le,p as oe,aW as E,ak as ue,aj as C,an as x,ap as ie,aV as se,aM as re,aq as f,bj as ce,c as de,ar as fe,d as S,i as s,F as N,E as A,K as G,cj as ve,e as me,as as xe,at as M,aC as ge,bn as he,au as we}from"./index-BrYd6ITk.js";import{u as Ve,j as ye,a as j,b as D,c as Ce,k as Fe,m as Pe,d as ke,l as be}from"./VTextField-pk7N4pT7.js";const Ie=oe({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,...be(),...ke(),...Pe()},"VTextarea"),Ne=le()({name:"VTextarea",directives:{vIntersect:E},inheritAttrs:!1,props:Ie(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0,"update:rows":e=>!0},setup(e,U){let{attrs:F,emit:P,slots:l}=U;const a=ue(e,"modelValue"),{isFocused:v,focus:O,blur:$}=Ve(e),{onIntersect:q}=Fe(e),K=C(()=>typeof e.counterValue=="function"?e.counterValue(a.value):(a.value||"").toString().length),W=C(()=>{if(F.maxlength)return F.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),p=x(),g=x(),B=ie(""),h=x(),w=ye(e),J=C(()=>e.persistentPlaceholder||v.value||e.active);function k(){var t;w.isSuppressing.value&&w.update(),h.value!==document.activeElement&&((t=h.value)==null||t.focus()),v.value||O()}function L(t){k(),P("click:control",t)}function Q(t){P("mousedown:control",t)}function X(t){t.stopPropagation(),k(),M(()=>{a.value="",we(e["onClick:clear"],t)})}function Y(t){var u;const n=t.target;if(a.value=n.value,(u=e.modelModifiers)!=null&&u.trim){const d=[n.selectionStart,n.selectionEnd];M(()=>{n.selectionStart=d[0],n.selectionEnd=d[1]})}}const r=x(),m=x(Number(e.rows)),b=C(()=>["plain","underlined"].includes(e.variant));se(()=>{e.autoGrow||(m.value=Number(e.rows))});function c(){e.autoGrow&&M(()=>{if(!r.value||!g.value)return;const t=getComputedStyle(r.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=r.value.scrollHeight,V=parseFloat(t.lineHeight),I=Math.max(parseFloat(e.rows)*V+u,parseFloat(n.getPropertyValue("--v-input-control-height"))),R=parseFloat(e.maxRows)*V+u||1/0,i=he(d??0,I,R);m.value=Math.floor((i-u)/V),B.value=ge(i)})}re(c),f(a,c),f(()=>e.rows,c),f(()=>e.maxRows,c),f(()=>e.density,c),f(m,t=>{P("update:rows",t)});let o;return f(r,t=>{t?(o=new ResizeObserver(c),o.observe(r.value)):o==null||o.disconnect()}),ce(()=>{o==null||o.disconnect()}),de(()=>{const t=!!(l.counter||e.counter||e.counterValue),n=!!(t||l.details),[u,d]=fe(F),{modelValue:V,...I}=j.filterProps(e),R={...D.filterProps(e),"onClick:clear":X};return S(j,A({ref:p,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,I,{centerAffix:m.value===1&&!b.value,focused:v.value}),{...l,default:i=>{let{id:y,isDisabled:z,isDirty:H,isReadonly:Z,isValid:ee,hasDetails:te}=i;return S(D,A({ref:g,style:{"--v-textarea-control-height":B.value},onClick:L,onMousedown:Q,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},R,{id:y.value,active:J.value||H.value,centerAffix:m.value===1&&!b.value,dirty:H.value||e.dirty,disabled:z.value,focused:v.value,details:te.value,error:ee.value===!1}),{...l,default:ae=>{let{props:{class:T,..._}}=ae;return s(N,null,[e.prefix&&s("span",{class:"v-text-field__prefix"},[e.prefix]),G(s("textarea",A({ref:h,class:T,value:a.value,onInput:Y,autofocus:e.autofocus,readonly:Z.value,disabled:z.value,placeholder:e.placeholder,rows:e.rows,name:w.fieldName.value,autocomplete:w.fieldAutocomplete.value,onFocus:k,onBlur:$},_,d),null),[[E,{handler:q},null,{once:!0}]]),e.autoGrow&&G(s("textarea",{class:me([T,"v-textarea__sizer"]),id:`${_.id}-sizer`,"onUpdate:modelValue":ne=>a.value=ne,ref:r,readonly:!0,"aria-hidden":"true"},null),[[ve,a.value]]),e.suffix&&s("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:n?i=>{var y;return s(N,null,[(y=l.details)==null?void 0:y.call(l,i),t&&s(N,null,[s("span",null,null),S(Ce,{active:e.persistentCounter||v.value,value:K.value,max:W.value,disabled:e.disabled},l.counter)])])}:void 0})}),xe({},p,g,h)}});export{Ne as V};