1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2025-07-02 00:59:23 +00:00
Classworks/assets/VTextarea-SupiQVXT.js

2 lines
4.5 KiB
JavaScript

import{g as ee,p as te,cc as ae,a7 as ne,f as y,r as v,s as le,w as oe,ad as ue,a9 as m,bf as ie,j as re,aM as se,k as l,F as I,Z as R,aI as T,bs as ce,cd as de,aO as fe,ae as S,l as ve,bG as me,aP as xe}from"./index-ByVcHmHP.js";import{u as ge,a as _,b as D,c as he,d as we,m as Ve}from"./VTextField-xmohowzo.js";const ye=te({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))},maxRows:{type:[Number,String],validator:e=>!isNaN(parseFloat(e))},suffix:String,modelModifiers:Object,...Ve(),...we()},"VTextarea"),Ce=ee()({name:"VTextarea",directives:{Intersect:ae},inheritAttrs:!1,props:ye(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,E){let{attrs:F,emit:M,slots:i}=E;const o=ne(e,"modelValue"),{isFocused:f,focus:U,blur:O}=ge(e),j=y(()=>typeof e.counterValue=="function"?e.counterValue(o.value):(o.value||"").toString().length),$=y(()=>{if(F.maxlength)return F.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter});function Z(t,n){var a,u;!e.autofocus||!t||(u=(a=n[0].target)==null?void 0:a.focus)==null||u.call(a)}const N=v(),x=v(),B=le(""),g=v(),q=y(()=>e.persistentPlaceholder||f.value||e.active);function P(){var t;g.value!==document.activeElement&&((t=g.value)==null||t.focus()),f.value||U()}function J(t){P(),M("click:control",t)}function K(t){M("mousedown:control",t)}function L(t){t.stopPropagation(),P(),S(()=>{o.value="",xe(e["onClick:clear"],t)})}function Q(t){var a;const n=t.target;if(o.value=n.value,(a=e.modelModifiers)!=null&&a.trim){const u=[n.selectionStart,n.selectionEnd];S(()=>{n.selectionStart=u[0],n.selectionEnd=u[1]})}}const c=v(),h=v(Number(e.rows)),C=y(()=>["plain","underlined"].includes(e.variant));oe(()=>{e.autoGrow||(h.value=Number(e.rows))});function d(){e.autoGrow&&S(()=>{if(!c.value||!x.value)return;const t=getComputedStyle(c.value),n=getComputedStyle(x.value.$el),a=parseFloat(t.getPropertyValue("--v-field-padding-top"))+parseFloat(t.getPropertyValue("--v-input-padding-top"))+parseFloat(t.getPropertyValue("--v-field-padding-bottom")),u=c.value.scrollHeight,w=parseFloat(t.lineHeight),b=Math.max(parseFloat(e.rows)*w+a,parseFloat(n.getPropertyValue("--v-input-control-height"))),k=parseFloat(e.maxRows)*w+a||1/0,s=me(u??0,b,k);h.value=Math.floor((s-a)/w),B.value=ve(s)})}ue(d),m(o,d),m(()=>e.rows,d),m(()=>e.maxRows,d),m(()=>e.density,d);let r;return m(c,t=>{t?(r=new ResizeObserver(d),r.observe(c.value)):r==null||r.disconnect()}),ie(()=>{r==null||r.disconnect()}),re(()=>{const t=!!(i.counter||e.counter||e.counterValue),n=!!(t||i.details),[a,u]=se(F),{modelValue:w,...b}=_.filterProps(e),k=D.filterProps(e);return l(_,R({ref:N,modelValue:o.value,"onUpdate:modelValue":s=>o.value=s,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":C.value},e.class],style:e.style},a,b,{centerAffix:h.value===1&&!C.value,focused:f.value}),{...i,default:s=>{let{id:V,isDisabled:H,isDirty:z,isReadonly:W,isValid:X}=s;return l(D,R({ref:x,style:{"--v-textarea-control-height":B.value},onClick:J,onMousedown:K,"onClick:clear":L,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},k,{id:V.value,active:q.value||z.value,centerAffix:h.value===1&&!C.value,dirty:z.value||e.dirty,disabled:H.value,focused:f.value,error:X.value===!1}),{...i,default:Y=>{let{props:{class:A,...G}}=Y;return l(I,null,[e.prefix&&l("span",{class:"v-text-field__prefix"},[e.prefix]),T(l("textarea",R({ref:g,class:A,value:o.value,onInput:Q,autofocus:e.autofocus,readonly:W.value,disabled:H.value,placeholder:e.placeholder,rows:e.rows,name:e.name,onFocus:P,onBlur:O},G,u),null),[[ce("intersect"),{handler:Z},null,{once:!0}]]),e.autoGrow&&T(l("textarea",{class:[A,"v-textarea__sizer"],id:`${G.id}-sizer`,"onUpdate:modelValue":p=>o.value=p,ref:c,readonly:!0,"aria-hidden":"true"},null),[[de,o.value]]),e.suffix&&l("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:n?s=>{var V;return l(I,null,[(V=i.details)==null?void 0:V.call(i,s),t&&l(I,null,[l("span",null,null),l(he,{active:e.persistentCounter||f.value,value:j.value,max:$.value,disabled:e.disabled},i.counter)])])}:void 0})}),fe({},N,x,g)}});export{Ce as V};