mirror of
https://github.com/ZeroCatDev/Classworks.git
synced 2026-03-21 09:13:10 +00:00
2 lines
5.4 KiB
JavaScript
2 lines
5.4 KiB
JavaScript
import{b as w,w as re,D as se,o as f,A as ce,j as A,k as r,F as M,m as z,R as U,ai as de,n as fe,I as C,e as P,s as ve}from"./vendor-vue-B2vxubPy.js";import{u as me,V as $,a as xe,b as ge,m as he,c as we}from"./autofocus-BAgnxQiD.js";import{u as Ve,V as O,m as ye}from"./VLabel-CU-8PdVS.js";import{aE as W,D as be}from"./index-CFUCTEXJ.js";import{f as Fe,n as Ce,a0 as Pe,u as Ie,ao as ke,s as B,z as Re,ap as Ne,p as Se,a5 as He}from"./vendor-vuetify-s-yw_Hr8.js";const Ae=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,...we(),...He(ye(),["direction"]),...he()},"VTextarea"),Te=Fe()({name:"VTextarea",directives:{vIntersect:W},inheritAttrs:!1,props:Ae(),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:I,emit:k,slots:o}=j;const l=Ce(e,"modelValue"),{isFocused:V,focus:q,blur:J}=Ve(e),{onIntersect:K}=ge(e),L=P(()=>typeof e.counterValue=="function"?e.counterValue(l.value):(l.value||"").toString().length),Q=P(()=>{if(I.maxlength)return I.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),D=w(),b=w(),p=ve(""),v=w(),R=w(0),{platform:X}=Pe(),F=me(e),Y=P(()=>e.persistentPlaceholder||V.value||e.active);function N(){var t;F.isSuppressing.value&&F.update(),v.value!==document.activeElement&&((t=v.value)==null||t.focus()),V.value||q()}function Z(t){N(),k("click:control",t)}function ee(t){k("mousedown:control",t)}function te(t){t.stopPropagation(),N(),C(()=>{l.value="",Ne(e["onClick:clear"],t)})}function ae(t){var g;const a=t.target;if(!((g=e.modelModifiers)!=null&&g.trim)){l.value=a.value;return}const n=a.value,x=a.selectionStart,c=a.selectionEnd;l.value=n,C(()=>{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=w(),y=w(Number(e.rows)),S=P(()=>["plain","underlined"].includes(e.variant));re(()=>{e.autoGrow||(y.value=Number(e.rows))});function s(){C(()=>{if(!v.value)return;if(X.value.firefox){R.value=12;return}const{offsetWidth:t,clientWidth:a}=v.value;R.value=Math.max(0,t-a)}),e.autoGrow&&C(()=>{if(!m.value||!b.value)return;const t=getComputedStyle(m.value),a=getComputedStyle(b.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),g=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=Re(x??0,g,d);y.value=Math.floor((i-n)/c),p.value=B(i)})}se(s),f(l,s),f(()=>e.rows,s),f(()=>e.maxHeight,s),f(()=>e.maxRows,s),f(()=>e.density,s),f(y,t=>{k("update:rows",t)});let u;return f(m,t=>{t?(u=new ResizeObserver(s),u.observe(m.value)):u==null||u.disconnect()}),ce(()=>{u==null||u.disconnect()}),Ie(()=>{const t=!!(o.counter||e.counter||e.counterValue),a=!!(t||o.details),[n,x]=ke(I),{modelValue:c,...g}=O.filterProps(e),d={...$.filterProps(e),"onClick:clear":te};return A(O,z({ref:D,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":S.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,g,{centerAffix:y.value===1&&!S.value,focused:V.value}),{...o,default:i=>{let{id:h,isDisabled:T,isDirty:_,isReadonly:le,isValid:ne,hasDetails:oe}=i;return A($,z({ref:b,style:{"--v-textarea-control-height":p.value},onClick:Z,onMousedown:ee,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},d,{id:h.value,active:Y.value||_.value,labelId:`${h.value}-label`,centerAffix:y.value===1&&!S.value,dirty:_.value||e.dirty,disabled:T.value,focused:V.value,details:oe.value,error:ne.value===!1}),{...o,default:ue=>{let{props:{class:E,...G},controlRef:ie}=ue;return r(M,null,[e.prefix&&r("span",{class:"v-text-field__prefix"},[e.prefix]),U(r("textarea",z({ref:H=>v.value=ie.value=H,class:E,value:l.value,onInput:ae,autofocus:e.autofocus,readonly:le.value,disabled:T.value,placeholder:e.placeholder,rows:e.rows,name:F.fieldName.value,autocomplete:F.fieldAutocomplete.value,onFocus:N,onBlur:J,"aria-labelledby":`${h.value}-label`},G,x),null),[[W,{handler:K},null,{once:!0}]]),e.autoGrow&&U(r("textarea",{class:fe([E,"v-textarea__sizer"]),id:`${G.id}-sizer`,"onUpdate:modelValue":H=>l.value=H,ref:m,readonly:!0,"aria-hidden":"true"},null),[[de,l.value]]),e.suffix&&r("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:a?i=>{var h;return r(M,null,[(h=o.details)==null?void 0:h.call(o,i),t&&r(M,null,[r("span",null,null),A(xe,{active:e.persistentCounter||V.value,value:L.value,max:Q.value,disabled:e.disabled},o.counter)])])}:void 0})}),be({},D,b,v)}});export{Te as V};
|