mirror of
https://github.com/ZeroCatDev/Classworks.git
synced 2026-08-12 17:40:32 +00:00
2 lines
5.4 KiB
JavaScript
2 lines
5.4 KiB
JavaScript
import{b as y,w as re,D as se,o as f,A as ce,j as A,k as r,F as B,m as M,R as j,aj as de,n as fe,I as C,e as P,s as ve}from"./vendor-vue-Hxtt57UU.js";import{u as me,l as xe,b as $,c as O,d as he,n as ge,e as we,m as ye,o as Ve}from"./VTextField-jDykTfh9.js";import{ax as W,I as be}from"./index-BvGH7GyK.js";import{j as Fe,q as Ce,a0 as Pe,u as Ie,aB as ke,a as z,z as Re,aE as Ne,p as Se,a5 as He}from"./vendor-vuetify-KiFW-YAv.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(ye(),["direction"]),...we()},"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,q){let{attrs:I,emit:k,slots:o}=q;const l=Ce(e,"modelValue"),{isFocused:v,focus:p,blur:J}=me(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=y(),b=y(),T=ve(""),m=y(),R=y(0),{platform:X}=Pe(),F=xe(e),Y=P(()=>e.persistentPlaceholder||v.value||e.active);function N(){var t;F.isSuppressing.value&&F.update(),m.value!==document.activeElement&&((t=m.value)==null||t.focus()),v.value||p()}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,h=a.selectionStart,c=a.selectionEnd;l.value=n,C(()=>{let d=0;n.trimStart().length===a.value.length&&(d=n.length-a.value.length),h!=null&&(a.selectionStart=h-d),c!=null&&(a.selectionEnd=c-d)})}const x=y(),V=y(Number(e.rows)),S=P(()=>["plain","underlined"].includes(e.variant));re(()=>{e.autoGrow||(V.value=Number(e.rows))});function s(){C(()=>{if(!m.value)return;if(X.value.firefox){R.value=12;return}const{offsetWidth:t,clientWidth:a}=m.value;R.value=Math.max(0,t-a)}),e.autoGrow&&C(()=>{if(!x.value||!b.value)return;const t=getComputedStyle(x.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")),h=x.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(h??0,g,d);V.value=Math.floor((i-n)/c),T.value=z(i)})}se(s),f(l,s),f(()=>e.rows,s),f(()=>e.maxHeight,s),f(()=>e.maxRows,s),f(()=>e.density,s),f(V,t=>{k("update:rows",t)});let u;return f(x,t=>{t?(u=new ResizeObserver(s),u.observe(x.value)):u==null||u.disconnect()}),ce(()=>{u==null||u.disconnect()}),Ie(()=>{const t=!!(o.counter||e.counter||e.counterValue),a=e.hideDetails!==!0&&!!(o.details||t&&(e.persistentCounter||e.hideDetails===!1||v.value)),[n,h]=ke(I),{modelValue:c,...g}=$.filterProps(e),d={...O.filterProps(e),"onClick:clear":te};return A($,M({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?z(e.maxHeight):void 0,"--v-textarea-scroll-bar-width":z(R.value)},e.style]},n,g,{centerAffix:V.value===1&&!S.value,focused:v.value}),{...o,default:i=>{let{id:w,isDisabled:_,isDirty:E,isReadonly:le,isValid:ne,hasDetails:oe}=i;return A(O,M({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:w.value,active:Y.value||E.value,labelId:`${w.value}-label`,centerAffix:V.value===1&&!S.value,dirty:E.value||e.dirty,disabled:_.value,focused:v.value,details:oe.value,error:ne.value===!1}),{...o,default:ue=>{let{props:{class:G,...U},controlRef:ie}=ue;return r(B,null,[e.prefix&&r("span",{class:"v-text-field__prefix"},[e.prefix]),j(r("textarea",M({ref:H=>m.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:F.fieldName.value,autocomplete:F.fieldAutocomplete.value,onFocus:N,onBlur:J,"aria-labelledby":`${w.value}-label`},U,h),null),[[W,{handler:K},null,{once:!0}]]),e.autoGrow&&j(r("textarea",{class:fe([G,"v-textarea__sizer"]),id:`${U.id}-sizer`,"onUpdate:modelValue":H=>l.value=H,ref:x,readonly:!0,"aria-hidden":"true"},null),[[de,l.value]]),e.suffix&&r("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:a?i=>{var w;return r(B,null,[(w=o.details)==null?void 0:w.call(o,i),t&&r(B,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,m)}});export{Te as V};
|