mirror of
https://github.com/ZeroCatDev/Classworks.git
synced 2026-02-04 07:53:11 +00:00
2 lines
5.2 KiB
JavaScript
2 lines
5.2 KiB
JavaScript
import{g as re,p as se,b7 as $,am as ce,a5 as C,a4 as w,aq as de,X as fe,b6 as ve,a7 as me,a6 as f,aM as xe,c as ge,ar as he,d as A,i as r,F as M,E as B,I as p,aP as we,e as ye,aE as z,as as Ve,at as P,be,au as Fe}from"./index-D15NmdZo.js";import{u as Ce,j as Pe,a as O,b as W,c as Ie,l as ke,m as Ne,d as Re,n as Se}from"./VTextField-GDBuOmnU.js";const He=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,...Se(),...Re(),...Ne()},"VTextarea"),Be=re()({name:"VTextarea",directives:{vIntersect:$},inheritAttrs:!1,props:He(),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:y,focus:q,blur:X}=Ce(e),{onIntersect:J}=ke(e),K=C(()=>typeof e.counterValue=="function"?e.counterValue(l.value):(l.value||"").toString().length),L=C(()=>{if(I.maxlength)return I.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),E=w(),b=w(),T=de(""),v=w(),N=w(0),{platform:Q}=fe(),F=Pe(e),Y=C(()=>e.persistentPlaceholder||y.value||e.active);function R(){var t;F.isSuppressing.value&&F.update(),v.value!==document.activeElement&&((t=v.value)==null||t.focus()),y.value||q()}function Z(t){R(),k("click:control",t)}function ee(t){k("mousedown:control",t)}function te(t){t.stopPropagation(),R(),P(()=>{l.value="",Fe(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,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=w(),V=w(Number(e.rows)),S=C(()=>["plain","underlined"].includes(e.variant));ve(()=>{e.autoGrow||(V.value=Number(e.rows))});function s(){P(()=>{if(!v.value)return;if(Q.value.firefox){N.value=12;return}const{offsetWidth:t,clientWidth:a}=v.value;N.value=Math.max(0,t-a)}),e.autoGrow&&P(()=>{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=be(x??0,g,d);V.value=Math.floor((i-n)/c),T.value=z(i)})}me(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(m,t=>{t?(u=new ResizeObserver(s),u.observe(m.value)):u==null||u.disconnect()}),xe(()=>{u==null||u.disconnect()}),ge(()=>{const t=!!(o.counter||e.counter||e.counterValue),a=!!(t||o.details),[n,x]=he(I),{modelValue:c,...g}=O.filterProps(e),d={...W.filterProps(e),"onClick:clear":te};return A(O,B({ref:E,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(N.value)},e.style]},n,g,{centerAffix:V.value===1&&!S.value,focused:y.value}),{...o,default:i=>{let{id:h,isDisabled:_,isDirty:D,isReadonly:le,isValid:ne,hasDetails:oe}=i;return A(W,B({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:h.value,active:Y.value||D.value,labelId:`${h.value}-label`,centerAffix:V.value===1&&!S.value,dirty:D.value||e.dirty,disabled:_.value,focused:y.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]),p(r("textarea",B({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:F.fieldName.value,autocomplete:F.fieldAutocomplete.value,onFocus:R,onBlur:X,"aria-labelledby":`${h.value}-label`},U,x),null),[[$,{handler:J},null,{once:!0}]]),e.autoGrow&&p(r("textarea",{class:ye([G,"v-textarea__sizer"]),id:`${U.id}-sizer`,"onUpdate:modelValue":H=>l.value=H,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 h;return r(M,null,[(h=o.details)==null?void 0:h.call(o,i),t&&r(M,null,[r("span",null,null),A(Ie,{active:e.persistentCounter||y.value,value:K.value,max:L.value,disabled:e.disabled},o.counter)])])}:void 0})}),Ve({},E,b,v)}});export{Be as V};
|