mirror of
https://github.com/ZeroCatDev/Classworks.git
synced 2025-10-22 02:03:10 +00:00
2 lines
4.6 KiB
JavaScript
2 lines
4.6 KiB
JavaScript
import{g as ne,p as oe,a$ as T,ap as ue,ao as C,a7 as x,at as ie,a_ as se,a8 as re,au as f,bm as ce,c as de,av as fe,d as S,i as s,F as N,E as A,K as E,co as ve,e as me,aw as xe,ax as p,aG as ge,bq as he,ay as we}from"./index-DFgkZgUi.js";import{u as Ve,j as ye,a as D,b as U,c as Ce,k as Fe,m as Pe,d as be,l as ke}from"./VTextField-DIOo4XZs.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,...ke(),...be(),...Pe()},"VTextarea"),Ne=ne()({name:"VTextarea",directives:{vIntersect:T},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,O){let{attrs:F,emit:P,slots:n}=O;const a=ue(e,"modelValue"),{isFocused:v,focus:$,blur:j}=Ve(e),{onIntersect:q}=Fe(e),K=C(()=>typeof e.counterValue=="function"?e.counterValue(a.value):(a.value||"").toString().length),J=C(()=>{if(F.maxlength)return F.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),B=x(),g=x(),M=ie(""),h=x(),w=ye(e),L=C(()=>e.persistentPlaceholder||v.value||e.active);function b(){var t;w.isSuppressing.value&&w.update(),h.value!==document.activeElement&&((t=h.value)==null||t.focus()),v.value||$()}function Q(t){b(),P("click:control",t)}function W(t){P("mousedown:control",t)}function X(t){t.stopPropagation(),b(),p(()=>{a.value="",we(e["onClick:clear"],t)})}function Y(t){var u;const l=t.target;if(a.value=l.value,(u=e.modelModifiers)!=null&&u.trim){const d=[l.selectionStart,l.selectionEnd];p(()=>{l.selectionStart=d[0],l.selectionEnd=d[1]})}}const r=x(),m=x(Number(e.rows)),k=C(()=>["plain","underlined"].includes(e.variant));se(()=>{e.autoGrow||(m.value=Number(e.rows))});function c(){e.autoGrow&&p(()=>{if(!r.value||!g.value)return;const t=getComputedStyle(r.value),l=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(l.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),M.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=!!(n.counter||e.counter||e.counterValue),l=!!(t||n.details),[u,d]=fe(F),{modelValue:V,...I}=D.filterProps(e),R={...U.filterProps(e),"onClick:clear":X};return S(D,A({ref:B,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":k.value},e.class],style:e.style},u,I,{centerAffix:m.value===1&&!k.value,focused:v.value}),{...n,default:i=>{let{id:y,isDisabled:z,isDirty:H,isReadonly:Z,isValid:ee,hasDetails:te}=i;return S(U,A({ref:g,style:{"--v-textarea-control-height":M.value},onClick:Q,onMousedown:W,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},R,{id:y.value,active:L.value||H.value,centerAffix:m.value===1&&!k.value,dirty:H.value||e.dirty,disabled:z.value,focused:v.value,details:te.value,error:ee.value===!1}),{...n,default:ae=>{let{props:{class:_,...G}}=ae;return s(N,null,[e.prefix&&s("span",{class:"v-text-field__prefix"},[e.prefix]),E(s("textarea",A({ref:h,class:_,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:b,onBlur:j},G,d),null),[[T,{handler:q},null,{once:!0}]]),e.autoGrow&&E(s("textarea",{class:me([_,"v-textarea__sizer"]),id:`${G.id}-sizer`,"onUpdate:modelValue":le=>a.value=le,ref:r,readonly:!0,"aria-hidden":"true"},null),[[ve,a.value]]),e.suffix&&s("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:l?i=>{var y;return s(N,null,[(y=n.details)==null?void 0:y.call(n,i),t&&s(N,null,[s("span",null,null),S(Ce,{active:e.persistentCounter||v.value,value:K.value,max:J.value,disabled:e.disabled},n.counter)])])}:void 0})}),xe({},B,g,h)}});export{Ne as V};
|