1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2026-03-21 09:13:10 +00:00
Classworks/assets/VTextField-CuXGbmmC.js

2 lines
3.9 KiB
JavaScript

import{u as te,h as le,V as D,a as T,b as ae,m as ne,c as ue,i as oe,j as ie}from"./autofocus-BrMOVHY_.js";import{aC as M,C as se}from"./index-_6IQhlPZ.js";import{f as re,n as ce,u as de,ao as fe,a5 as j,ap as ve,p as me}from"./vendor-vuetify-ChAgIwn2.js";import{j as y,k as n,F as b,m as C,R as xe,n as Ve,ai as ge,e as x,b as F,I as P}from"./vendor-vue-H0jQBZ7T.js";const he=["color","file","time","date","datetime-local","week","month"],ye=me({autofocus:Boolean,counter:[Boolean,Number,String],counterValue:[Number,Function],prefix:String,placeholder:String,persistentPlaceholder:Boolean,persistentCounter:Boolean,suffix:String,role:String,type:{type:String,default:"text"},modelModifiers:Object,...oe(),...j(ue(),["direction"]),...ne()},"VTextField"),ke=re()({name:"VTextField",directives:{vIntersect:M},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:V,emit:k,slots:a}=E;const u=ce(e,"modelValue",void 0,t=>Object.is(t,-0)?"-0":t),{isFocused:i,focus:_,blur:O}=te(e),{onIntersect:z}=ie(e),U=x(()=>typeof e.counterValue=="function"?e.counterValue(u.value):typeof e.counterValue=="number"?e.counterValue:(u.value??"").toString().length),$=x(()=>{if(V.maxlength)return V.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),I=x(()=>["plain","underlined"].includes(e.variant)),S=F(),A=F(),s=F(),f=le(e),q=x(()=>he.includes(e.type)||e.persistentPlaceholder||i.value||e.active);function p(){f.isSuppressing.value&&f.update(),i.value||_(),P(()=>{var t;s.value!==document.activeElement&&((t=s.value)==null||t.focus())})}function G(t){k("mousedown:control",t),t.target!==s.value&&(p(),t.preventDefault())}function H(t){k("click:control",t)}function J(t,l){t.stopPropagation(),p(),P(()=>{l(),ve(e["onClick:clear"],t)})}function K(t){var m;const l=t.target;if(!((m=e.modelModifiers)!=null&&m.trim&&["text","search","password","tel","url"].includes(e.type))){u.value=l.value;return}const r=l.value,v=l.selectionStart,g=l.selectionEnd;u.value=r,P(()=>{let c=0;r.trimStart().length===l.value.length&&(c=r.length-l.value.length),v!=null&&(l.selectionStart=v-c),g!=null&&(l.selectionEnd=g-c)})}return de(()=>{const t=!!(a.counter||e.counter!==!1&&e.counter!=null),l=!!(t||a.details),[r,v]=fe(V),{modelValue:g,...m}=D.filterProps(e),c=T.filterProps(e);return y(D,C({ref:S,modelValue:u.value,"onUpdate:modelValue":d=>u.value=d,class:["v-text-field",{"v-text-field--prefixed":e.prefix,"v-text-field--suffixed":e.suffix,"v-input--plain-underlined":I.value},e.class],style:e.style},r,m,{centerAffix:!I.value,focused:i.value}),{...a,default:d=>{let{id:o,isDisabled:w,isDirty:R,isReadonly:L,isValid:Q,hasDetails:W,reset:X}=d;return y(T,C({ref:A,onMousedown:G,onClick:H,"onClick:clear":h=>J(h,X),role:e.role},j(c,["onClick:clear"]),{id:o.value,labelId:`${o.value}-label`,active:q.value||R.value,dirty:R.value||e.dirty,disabled:w.value,focused:i.value,details:W.value,error:Q.value===!1}),{...a,default:h=>{let{props:{class:N,...Y},controlRef:Z}=h;const B=n("input",C({ref:ee=>s.value=Z.value=ee,value:u.value,onInput:K,autofocus:e.autofocus,readonly:L.value,disabled:w.value,name:f.fieldName.value,autocomplete:f.fieldAutocomplete.value,placeholder:e.placeholder,size:1,role:e.role,type:e.type,onFocus:_,onBlur:O,"aria-labelledby":`${o.value}-label`},Y,v),null);return n(b,null,[e.prefix&&n("span",{class:"v-text-field__prefix"},[n("span",{class:"v-text-field__prefix__text"},[e.prefix])]),xe(a.default?n("div",{class:Ve(N),"data-no-activator":""},[a.default({id:o}),B]):ge(B,{class:N}),[[M,z,null,{once:!0}]]),e.suffix&&n("span",{class:"v-text-field__suffix"},[n("span",{class:"v-text-field__suffix__text"},[e.suffix])])])}})},details:l?d=>{var o;return n(b,null,[(o=a.details)==null?void 0:o.call(a,d),t&&n(b,null,[n("span",null,null),y(ae,{active:e.persistentCounter||i.value,value:U.value,max:$.value,disabled:e.disabled},a.counter)])])}:void 0})}),se({},S,A,s)}});export{ke as V,ye as m};