1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2026-03-21 17:33:10 +00:00
Classworks/assets/VTextarea-CCCqy4pz.js

2 lines
5.3 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,ah as de,n as fe,I as F,e as P,s as ve}from"./vendor-vue-H0jQBZ7T.js";import{u as me,h as xe,V as $,a as j,b as he,m as ge,c as we,i as Ve,j as ye}from"./autofocus-BrMOVHY_.js";import{aC as O,C as be}from"./index-_6IQhlPZ.js";import{f as Ce,n as Fe,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-ChAgIwn2.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,...Ve(),...He(we(),["direction"]),...ge()},"VTextarea"),Te=Ce()({name:"VTextarea",directives:{vIntersect:O},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,W){let{attrs:I,emit:k,slots:o}=W;const l=Fe(e,"modelValue"),{isFocused:V,focus:q,blur:J}=me(e),{onIntersect:K}=ye(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(),T=ve(""),v=w(),R=w(0),{platform:X}=Pe(),C=xe(e),Y=P(()=>e.persistentPlaceholder||V.value||e.active);function N(){var t;C.isSuppressing.value&&C.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(),F(()=>{l.value="",Ne(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,F(()=>{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(){F(()=>{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&&F(()=>{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),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=Re(x??0,h,d);y.value=Math.floor((i-n)/c),T.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,...h}=$.filterProps(e),d={...j.filterProps(e),"onClick:clear":te};return A($,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,h,{centerAffix:y.value===1&&!S.value,focused:V.value}),{...o,default:i=>{let{id:g,isDisabled:_,isDirty:p,isReadonly:le,isValid:ne,hasDetails:oe}=i;return A(j,z({ref:b,style:{"--v-textarea-control-height":T.value},onClick:Z,onMousedown:ee,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},d,{id:g.value,active:Y.value||p.value,labelId:`${g.value}-label`,centerAffix:y.value===1&&!S.value,dirty:p.value||e.dirty,disabled:_.value,focused:V.value,details:oe.value,error:ne.value===!1}),{...o,default:ue=>{let{props:{class:G,...E},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:G,value:l.value,onInput:ae,autofocus:e.autofocus,readonly:le.value,disabled:_.value,placeholder:e.placeholder,rows:e.rows,name:C.fieldName.value,autocomplete:C.fieldAutocomplete.value,onFocus:N,onBlur:J,"aria-labelledby":`${g.value}-label`},E,x),null),[[O,{handler:K},null,{once:!0}]]),e.autoGrow&&U(r("textarea",{class:fe([G,"v-textarea__sizer"]),id:`${E.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 g;return r(M,null,[(g=o.details)==null?void 0:g.call(o,i),t&&r(M,null,[r("span",null,null),A(he,{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};