mirror of
https://github.com/ZeroCatDev/Classworks.git
synced 2025-12-08 13:49:37 +00:00
2 lines
5.2 KiB
JavaScript
2 lines
5.2 KiB
JavaScript
import{g as re,p as se,b2 as W,$ as ce,a1 as C,W as g,X as de,aq as fe,b1 as ve,ah as me,a2 as f,aO as xe,c as he,ay as ge,d as A,i as r,F as M,E as z,I as O,aR as we,e as ye,aH as B,ab as Ve,a3 as P,aW as Fe,az as be}from"./index-Cn8n78WY.js";import{a as Ce,h as Pe,b as p,c as $,d as ke,k as Ie,e as Re,f as He,l as Ne}from"./VTextField-DKNOTL7-.js";const Se=se({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))},maxHeight:{type:[Number,String],validator:e=>!isNaN(parseFloat(e))},maxRows:{type:[Number,String],validator:e=>!isNaN(parseFloat(e))},suffix:String,modelModifiers:Object,...Ne(),...He(),...Re()},"VTextarea"),ze=re()({name:"VTextarea",directives:{vIntersect:W},inheritAttrs:!1,props:Se(),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:k,emit:I,slots:o}=j;const l=ce(e,"modelValue"),{isFocused:w,focus:q,blur:X}=Ce(e),{onIntersect:J}=Ie(e),K=C(()=>typeof e.counterValue=="function"?e.counterValue(l.value):(l.value||"").toString().length),L=C(()=>{if(k.maxlength)return k.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),T=g(),V=g(),_=de(""),v=g(),R=g(0),{platform:Q}=fe(),F=Pe(e),Y=C(()=>e.persistentPlaceholder||w.value||e.active);function H(){var t;F.isSuppressing.value&&F.update(),v.value!==document.activeElement&&((t=v.value)==null||t.focus()),w.value||q()}function Z(t){H(),I("click:control",t)}function ee(t){I("mousedown:control",t)}function te(t){t.stopPropagation(),H(),P(()=>{l.value="",be(e["onClick:clear"],t)})}function ae(t){var h;const a=t.target;if(!((h=e.modelModifiers)!=null&&h.trim)){l.value=a.value;return}const n=a.value,x=a.selectionStart,c=a.selectionEnd;l.value=n,P(()=>{let d=0;n.trimStart().length===a.value.length&&(d=n.length-a.value.length),x!=null&&(a.selectionStart=x-d),c!=null&&(a.selectionEnd=c-d)})}const m=g(),y=g(Number(e.rows)),N=C(()=>["plain","underlined"].includes(e.variant));ve(()=>{e.autoGrow||(y.value=Number(e.rows))});function s(){P(()=>{if(!v.value)return;if(Q.value.firefox){R.value=12;return}const{offsetWidth:t,clientWidth:a}=v.value;R.value=Math.max(0,t-a)}),e.autoGrow&&P(()=>{if(!m.value||!V.value)return;const t=getComputedStyle(m.value),a=getComputedStyle(V.value.$el),n=parseFloat(t.getPropertyValue("--v-field-padding-top"))+parseFloat(t.getPropertyValue("--v-input-padding-top"))+parseFloat(t.getPropertyValue("--v-field-padding-bottom")),x=m.value.scrollHeight,c=parseFloat(t.lineHeight),h=Math.max(parseFloat(e.rows)*c+n,parseFloat(a.getPropertyValue("--v-input-control-height"))),d=e.maxHeight?parseFloat(e.maxHeight):parseFloat(e.maxRows)*c+n||1/0,i=Fe(x??0,h,d);y.value=Math.floor((i-n)/c),_.value=B(i)})}me(s),f(l,s),f(()=>e.rows,s),f(()=>e.maxHeight,s),f(()=>e.maxRows,s),f(()=>e.density,s),f(y,t=>{I("update:rows",t)});let u;return f(m,t=>{t?(u=new ResizeObserver(s),u.observe(m.value)):u==null||u.disconnect()}),xe(()=>{u==null||u.disconnect()}),he(()=>{const t=!!(o.counter||e.counter||e.counterValue),a=!!(t||o.details),[n,x]=ge(k),{modelValue:c,...h}=p.filterProps(e),d={...$.filterProps(e),"onClick:clear":te};return A(p,z({ref:T,modelValue:l.value,"onUpdate:modelValue":i=>l.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":N.value},e.class],style:[{"--v-textarea-max-height":e.maxHeight?B(e.maxHeight):void 0,"--v-textarea-scroll-bar-width":B(R.value)},e.style]},n,h,{centerAffix:y.value===1&&!N.value,focused:w.value}),{...o,default:i=>{let{id:b,isDisabled:D,isDirty:E,isReadonly:le,isValid:ne,hasDetails:oe}=i;return A($,z({ref:V,style:{"--v-textarea-control-height":_.value},onClick:Z,onMousedown:ee,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},d,{id:b.value,active:Y.value||E.value,centerAffix:y.value===1&&!N.value,dirty:E.value||e.dirty,disabled:D.value,focused:w.value,details:oe.value,error:ne.value===!1}),{...o,default:ue=>{let{props:{class:G,...U},controlRef:ie}=ue;return r(M,null,[e.prefix&&r("span",{class:"v-text-field__prefix"},[e.prefix]),O(r("textarea",z({ref:S=>v.value=ie.value=S,class:G,value:l.value,onInput:ae,autofocus:e.autofocus,readonly:le.value,disabled:D.value,placeholder:e.placeholder,rows:e.rows,name:F.fieldName.value,autocomplete:F.fieldAutocomplete.value,onFocus:H,onBlur:X},U,x),null),[[W,{handler:J},null,{once:!0}]]),e.autoGrow&&O(r("textarea",{class:ye([G,"v-textarea__sizer"]),id:`${U.id}-sizer`,"onUpdate:modelValue":S=>l.value=S,ref:m,readonly:!0,"aria-hidden":"true"},null),[[we,l.value]]),e.suffix&&r("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:a?i=>{var b;return r(M,null,[(b=o.details)==null?void 0:b.call(o,i),t&&r(M,null,[r("span",null,null),A(ke,{active:e.persistentCounter||w.value,value:K.value,max:L.value,disabled:e.disabled},o.counter)])])}:void 0})}),Ve({},T,V,v)}});export{ze as V};
|