1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2025-09-05 01:19:23 +00:00
Classworks/assets/VTextField-CVE6iehY.js

2 lines
18 KiB
JavaScript

import{g as H,p as T,t as $,j as q,k as b,aJ as oe,aK as ye,G as r,n as W,l as U,a4 as be,aL as he,z as Q,ck as Ce,o as re,a6 as j,am as Ee,a0 as ee,V as Te,aQ as Ve,cl as xe,a8 as se,a as ke,bY as Ne,d as ze,an as Ie,aM as de,f as g,r as z,u as Oe,aG as Se,aa as Y,cm as Ue,aS as Ke,aT as je,m as We,bZ as He,a5 as qe,ci as Ge,H as te,v as Je,b_ as Xe,a3 as ae,a9 as ie,s as ue,bw as Ye,bq as _e,cn as Qe,bJ as Ze,b$ as pe,co as ea,bg as aa,af as na,h as ve,ag as p,aU as la,K as ta,by as ia,aX as sa,N as ua,cd as fe,aN as oa,cp as ra,aP as da}from"./index-B1_BiCfs.js";const ca=T({active:Boolean,disabled:Boolean,max:[Number,String],value:{type:[Number,String],default:0},...Q(),...he({transition:{component:Ce}})},"VCounter"),va=H()({name:"VCounter",functional:!0,props:ca(),setup(e,t){let{slots:u}=t;const l=$(()=>e.max?`${e.value} / ${e.max}`:String(e.value));return q(()=>b(be,{transition:e.transition},{default:()=>[oe(r("div",{class:U(["v-counter",{"text-error":e.max&&!e.disabled&&parseFloat(e.value)>parseFloat(e.max)},e.class]),style:W(e.style)},[u.default?u.default({counter:l.value,max:e.max,value:e.value}):l.value]),[[ye,e.active]])]})),{}}}),fa=T({text:String,onClick:j(),...Q(),...re()},"VLabel"),ga=H()({name:"VLabel",props:fa(),setup(e,t){let{slots:u}=t;return q(()=>{var l;return r("label",{class:U(["v-label",{"v-label--clickable":!!e.onClick},e.class]),style:W(e.style),onClick:e.onClick},[e.text,(l=u.default)==null?void 0:l.call(u)])}),{}}}),ma=T({floating:Boolean,...Q()},"VFieldLabel"),le=H()({name:"VFieldLabel",props:ma(),setup(e,t){let{slots:u}=t;return q(()=>b(ga,{class:U(["v-field-label",{"v-field-label--floating":e.floating},e.class]),style:W(e.style),"aria-hidden":e.floating||void 0},u)),{}}});function Pe(e){const{t}=Ee();function u(l){let{name:a,color:n,...m}=l;const y={prepend:"prependAction",prependInner:"prependAction",append:"appendAction",appendInner:"appendAction",clear:"clear"}[a],h=e[`onClick:${a}`];function x(s){s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),s.stopPropagation(),Ve(h,new PointerEvent("click",s)))}const o=h&&y?t(`$vuetify.input.${y}`,e.label??""):void 0;return b(Te,ee({icon:e[`${a}Icon`],"aria-label":o,onClick:h,onKeydown:x,color:n},m),null)}return{InputIcon:u}}const Be=T({focused:Boolean,"onUpdate:focused":j()},"focus");function we(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:xe();const u=se(e,"focused"),l=$(()=>({[`${t}--focused`]:u.value}));function a(){u.value=!0}function n(){u.value=!1}return{focusClasses:l,isFocused:u,focus:a,blur:n}}const ya=["underlined","outlined","filled","solo","solo-inverted","solo-filled","plain"],Fe=T({appendInnerIcon:ae,bgColor:String,clearable:Boolean,clearIcon:{type:ae,default:"$clear"},active:Boolean,centerAffix:{type:Boolean,default:void 0},color:String,baseColor:String,dirty:Boolean,disabled:{type:Boolean,default:null},glow:Boolean,error:Boolean,flat:Boolean,iconColor:[Boolean,String],label:String,persistentClear:Boolean,prependInnerIcon:ae,reverse:Boolean,singleLine:Boolean,variant:{type:String,default:"filled",validator:e=>ya.includes(e)},"onClick:clear":j(),"onClick:appendInner":j(),"onClick:prependInner":j(),...Q(),...Xe(),...Je(),...re()},"VField"),ge=H()({name:"VField",inheritAttrs:!1,props:{id:String,...Be(),...Fe()},emits:{"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,t){let{attrs:u,emit:l,slots:a}=t;const{themeClasses:n}=ke(e),{loaderClasses:m}=Ne(e),{focusClasses:y,isFocused:h,focus:x,blur:o}=we(e),{InputIcon:s}=Pe(e),{roundedClasses:v}=ze(e),{rtlClasses:c}=Ie(),k=$(()=>e.dirty||e.active),_=$(()=>!!(e.label||a.label)),I=$(()=>!e.singleLine&&_.value),A=de(),V=g(()=>e.id||`input-${A}`),P=$(()=>`${V.value}-messages`),i=z(),f=z(),d=z(),S=g(()=>["plain","underlined"].includes(e.variant)),C=g(()=>e.error||e.disabled?void 0:k.value&&h.value?e.color:e.baseColor),L=g(()=>{if(!(!e.iconColor||e.glow&&!h.value))return e.iconColor===!0?C.value:e.iconColor}),{backgroundColorClasses:Z,backgroundColorStyles:G}=Oe(()=>e.bgColor),{textColorClasses:N,textColorStyles:E}=Se(C);Y(k,M=>{if(I.value){const F=i.value.$el,R=f.value.$el;requestAnimationFrame(()=>{const D=Ue(F),B=R.getBoundingClientRect(),K=B.x-D.x,X=B.y-D.y-(D.height/2-B.height/2),O=B.width/.75,ne=Math.abs(O-D.width)>1?{maxWidth:We(O)}:void 0,De=getComputedStyle(F),ce=getComputedStyle(R),$e=parseFloat(De.transitionDuration)*1e3||150,Ae=parseFloat(ce.getPropertyValue("--v-field-label-scale")),Le=ce.getPropertyValue("color");F.style.visibility="visible",R.style.visibility="hidden",Ke(F,{transform:`translate(${K}px, ${X}px) scale(${Ae})`,color:Le,...ne},{duration:$e,easing:je,direction:M?"normal":"reverse"}).finished.then(()=>{F.style.removeProperty("visibility"),R.style.removeProperty("visibility")})})}},{flush:"post"});const w=g(()=>({isActive:k,isFocused:h,controlRef:d,blur:o,focus:x}));function J(M){M.target!==document.activeElement&&M.preventDefault()}return q(()=>{var K,X,O;const M=e.variant==="outlined",F=!!(a["prepend-inner"]||e.prependInnerIcon),R=!!(e.clearable||a.clear)&&!e.disabled,D=!!(a["append-inner"]||e.appendInnerIcon||R),B=()=>a.label?a.label({...w.value,label:e.label,props:{for:V.value}}):e.label;return r("div",ee({class:["v-field",{"v-field--active":k.value,"v-field--appended":D,"v-field--center-affix":e.centerAffix??!S.value,"v-field--disabled":e.disabled,"v-field--dirty":e.dirty,"v-field--error":e.error,"v-field--glow":e.glow,"v-field--flat":e.flat,"v-field--has-background":!!e.bgColor,"v-field--persistent-clear":e.persistentClear,"v-field--prepended":F,"v-field--reverse":e.reverse,"v-field--single-line":e.singleLine,"v-field--no-label":!B(),[`v-field--variant-${e.variant}`]:!0},n.value,Z.value,y.value,m.value,v.value,c.value,e.class],style:[G.value,e.style],onClick:J},u),[r("div",{class:"v-field__overlay"},null),b(He,{name:"v-field",active:!!e.loading,color:e.error?"error":typeof e.loading=="string"?e.loading:e.color},{default:a.loader}),F&&r("div",{key:"prepend",class:"v-field__prepend-inner"},[e.prependInnerIcon&&b(s,{key:"prepend-icon",name:"prependInner",color:L.value},null),(K=a["prepend-inner"])==null?void 0:K.call(a,w.value)]),r("div",{class:"v-field__field","data-no-activator":""},[["filled","solo","solo-inverted","solo-filled"].includes(e.variant)&&I.value&&b(le,{key:"floating-label",ref:f,class:U([N.value]),floating:!0,for:V.value,style:W(E.value)},{default:()=>[B()]}),_.value&&b(le,{key:"label",ref:i,for:V.value},{default:()=>[B()]}),((X=a.default)==null?void 0:X.call(a,{...w.value,props:{id:V.value,class:"v-field__input","aria-describedby":P.value},focus:x,blur:o}))??r("div",{id:V.value,class:"v-field__input","aria-describedby":P.value},null)]),R&&b(Ge,{key:"clear"},{default:()=>[oe(r("div",{class:"v-field__clearable",onMousedown:ne=>{ne.preventDefault(),ne.stopPropagation()}},[b(qe,{defaults:{VIcon:{icon:e.clearIcon}}},{default:()=>[a.clear?a.clear({...w.value,props:{onFocus:x,onBlur:o,onClick:e["onClick:clear"],tabindex:-1}}):b(s,{name:"clear",onFocus:x,onBlur:o,tabindex:-1},null)]})]),[[ye,e.dirty]])]}),D&&r("div",{key:"append",class:"v-field__append-inner"},[(O=a["append-inner"])==null?void 0:O.call(a,w.value),e.appendInnerIcon&&b(s,{key:"append-icon",name:"appendInner",color:L.value},null)]),r("div",{class:U(["v-field__outline",N.value]),style:W(E.value)},[M&&r(te,null,[r("div",{class:"v-field__outline__start"},null),I.value&&r("div",{class:"v-field__outline__notch"},[b(le,{ref:f,floating:!0,for:V.value},{default:()=>[B()]})]),r("div",{class:"v-field__outline__end"},null)]),S.value&&I.value&&b(le,{ref:f,floating:!0,for:V.value},{default:()=>[B()]})])])}),{controlRef:d,fieldIconColor:L}}}),ba=T({active:Boolean,color:String,messages:{type:[Array,String],default:()=>[]},...Q(),...he({transition:{component:Ce,leaveAbsolute:!0,group:!0}})},"VMessages"),ha=H()({name:"VMessages",props:ba(),setup(e,t){let{slots:u}=t;const l=g(()=>ie(e.messages)),{textColorClasses:a,textColorStyles:n}=Se(()=>e.color);return q(()=>b(be,{transition:e.transition,tag:"div",class:U(["v-messages",a.value,e.class]),style:W([n.value,e.style])},{default:()=>[e.active&&l.value.map((m,y)=>r("div",{class:"v-messages__message",key:`${y}-${l.value}`},[u.message?u.message({message:m}):m]))]})),{}}}),Me=Symbol.for("vuetify:form"),wa=T({disabled:Boolean,fastFail:Boolean,readonly:Boolean,modelValue:{type:Boolean,default:null},validateOn:{type:String,default:"input"}},"form");function Fa(e){const t=se(e,"modelValue"),u=$(()=>e.disabled),l=$(()=>e.readonly),a=ue(!1),n=z([]),m=z([]);async function y(){const o=[];let s=!0;m.value=[],a.value=!0;for(const v of n.value){const c=await v.validate();if(c.length>0&&(s=!1,o.push({id:v.id,errorMessages:c})),!s&&e.fastFail)break}return m.value=o,a.value=!1,{valid:s,errors:m.value}}function h(){n.value.forEach(o=>o.reset())}function x(){n.value.forEach(o=>o.resetValidation())}return Y(n,()=>{let o=0,s=0;const v=[];for(const c of n.value)c.isValid===!1?(s++,v.push({id:c.id,errorMessages:c.errorMessages})):c.isValid===!0&&o++;m.value=v,t.value=s>0?!1:o===n.value.length?!0:null},{deep:!0,flush:"post"}),Ye(Me,{register:o=>{let{id:s,vm:v,validate:c,reset:k,resetValidation:_}=o;n.value.some(I=>I.id===s),n.value.push({id:s,validate:c,reset:k,resetValidation:_,vm:Qe(v),isValid:null,errorMessages:[]})},unregister:o=>{n.value=n.value.filter(s=>s.id!==o)},update:(o,s,v)=>{const c=n.value.find(k=>k.id===o);c&&(c.isValid=s,c.errorMessages=v)},isDisabled:u,isReadonly:l,isValidating:a,isValid:t,items:n,validateOn:$(()=>e.validateOn)}),{errors:m,isDisabled:u,isReadonly:l,isValidating:a,isValid:t,items:n,validate:y,reset:h,resetValidation:x}}function Ca(e){const t=_e(Me,null);return{...t,isReadonly:g(()=>!!((e==null?void 0:e.readonly)??(t==null?void 0:t.isReadonly.value))),isDisabled:g(()=>!!((e==null?void 0:e.disabled)??(t==null?void 0:t.isDisabled.value)))}}const Va=Symbol.for("vuetify:rules");function xa(e){const t=_e(Va,null);return t?t(e):$(e)}const ka=T({disabled:{type:Boolean,default:null},error:Boolean,errorMessages:{type:[Array,String],default:()=>[]},maxErrors:{type:[Number,String],default:1},name:String,label:String,readonly:{type:Boolean,default:null},rules:{type:Array,default:()=>[]},modelValue:null,validateOn:String,validationValue:null,...Be()},"validation");function Ia(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:xe(),u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:de();const l=se(e,"modelValue"),a=g(()=>e.validationValue===void 0?l.value:e.validationValue),n=Ca(e),m=xa(()=>e.rules),y=z([]),h=ue(!0),x=g(()=>!!(ie(l.value===""?null:l.value).length||ie(a.value===""?null:a.value).length)),o=g(()=>{var i;return(i=e.errorMessages)!=null&&i.length?ie(e.errorMessages).concat(y.value).slice(0,Math.max(0,Number(e.maxErrors))):y.value}),s=g(()=>{var d;let i=(e.validateOn??((d=n.validateOn)==null?void 0:d.value))||"input";i==="lazy"&&(i="input lazy"),i==="eager"&&(i="input eager");const f=new Set((i==null?void 0:i.split(" "))??[]);return{input:f.has("input"),blur:f.has("blur")||f.has("input")||f.has("invalid-input"),invalidInput:f.has("invalid-input"),lazy:f.has("lazy"),eager:f.has("eager")}}),v=g(()=>{var i;return e.error||(i=e.errorMessages)!=null&&i.length?!1:e.rules.length?h.value?y.value.length||s.value.lazy?null:!0:!y.value.length:!0}),c=ue(!1),k=g(()=>({[`${t}--error`]:v.value===!1,[`${t}--dirty`]:x.value,[`${t}--disabled`]:n.isDisabled.value,[`${t}--readonly`]:n.isReadonly.value})),_=Ze("validation"),I=g(()=>e.name??pe(u));ea(()=>{var i;(i=n.register)==null||i.call(n,{id:I.value,vm:_,validate:P,reset:A,resetValidation:V})}),aa(()=>{var i;(i=n.unregister)==null||i.call(n,I.value)}),na(async()=>{var i;s.value.lazy||await P(!s.value.eager),(i=n.update)==null||i.call(n,I.value,v.value,o.value)}),ve(()=>s.value.input||s.value.invalidInput&&v.value===!1,()=>{Y(a,()=>{if(a.value!=null)P();else if(e.focused){const i=Y(()=>e.focused,f=>{f||P(),i()})}})}),ve(()=>s.value.blur,()=>{Y(()=>e.focused,i=>{i||P()})}),Y([v,o],()=>{var i;(i=n.update)==null||i.call(n,I.value,v.value,o.value)});async function A(){l.value=null,await p(),await V()}async function V(){h.value=!0,s.value.lazy?y.value=[]:await P(!s.value.eager)}async function P(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;const f=[];c.value=!0;for(const d of m.value){if(f.length>=Number(e.maxErrors??1))break;const C=await(typeof d=="function"?d:()=>d)(a.value);if(C!==!0){if(C!==!1&&typeof C!="string"){console.warn(`${C} is not a valid value. Rule functions must return boolean true or a string.`);continue}f.push(C||"")}}return y.value=f,c.value=!1,h.value=i,y.value}return{errorMessages:o,isDirty:x,isDisabled:n.isDisabled,isReadonly:n.isReadonly,isPristine:h,isValid:v,isValidating:c,reset:A,resetValidation:V,validate:P,validationClasses:k}}const Re=T({id:String,appendIcon:ae,baseColor:String,centerAffix:{type:Boolean,default:!0},color:String,glow:Boolean,iconColor:[Boolean,String],prependIcon:ae,hideDetails:[Boolean,String],hideSpinButtons:Boolean,hint:String,persistentHint:Boolean,messages:{type:[Array,String],default:()=>[]},direction:{type:String,default:"horizontal",validator:e=>["horizontal","vertical"].includes(e)},"onClick:prepend":j(),"onClick:append":j(),...Q(),...sa(),...ia(ua(),["maxWidth","minWidth","width"]),...re(),...ka()},"VInput"),me=H()({name:"VInput",props:{...Re()},emits:{"update:modelValue":e=>!0},setup(e,t){let{attrs:u,slots:l,emit:a}=t;const{densityClasses:n}=la(e),{dimensionStyles:m}=ta(e),{themeClasses:y}=ke(e),{rtlClasses:h}=Ie(),{InputIcon:x}=Pe(e),o=de(),s=g(()=>e.id||`input-${o}`),v=g(()=>`${s.value}-messages`),{errorMessages:c,isDirty:k,isDisabled:_,isReadonly:I,isPristine:A,isValid:V,isValidating:P,reset:i,resetValidation:f,validate:d,validationClasses:S}=Ia(e,"v-input",s),C=g(()=>({id:s,messagesId:v,isDirty:k,isDisabled:_,isReadonly:I,isPristine:A,isValid:V,isValidating:P,reset:i,resetValidation:f,validate:d})),L=$(()=>e.error||e.disabled?void 0:e.focused?e.color:e.baseColor),Z=$(()=>{if(e.iconColor)return e.iconColor===!0?L.value:e.iconColor}),G=g(()=>{var N;return(N=e.errorMessages)!=null&&N.length||!A.value&&c.value.length?c.value:e.hint&&(e.persistentHint||e.focused)?e.hint:e.messages});return q(()=>{var M,F,R,D;const N=!!(l.prepend||e.prependIcon),E=!!(l.append||e.appendIcon),w=G.value.length>0,J=!e.hideDetails||e.hideDetails==="auto"&&(w||!!l.details);return r("div",{class:U(["v-input",`v-input--${e.direction}`,{"v-input--center-affix":e.centerAffix,"v-input--focused":e.focused,"v-input--glow":e.glow,"v-input--hide-spin-buttons":e.hideSpinButtons},n.value,y.value,h.value,S.value,e.class]),style:W([m.value,e.style])},[N&&r("div",{key:"prepend",class:"v-input__prepend"},[(M=l.prepend)==null?void 0:M.call(l,C.value),e.prependIcon&&b(x,{key:"prepend-icon",name:"prepend",color:Z.value},null)]),l.default&&r("div",{class:"v-input__control"},[(F=l.default)==null?void 0:F.call(l,C.value)]),E&&r("div",{key:"append",class:"v-input__append"},[e.appendIcon&&b(x,{key:"append-icon",name:"append",color:Z.value},null),(R=l.append)==null?void 0:R.call(l,C.value)]),J&&r("div",{id:v.value,class:"v-input__details",role:"alert","aria-live":"polite"},[b(ha,{active:w,messages:G.value},{message:l.message}),(D=l.details)==null?void 0:D.call(l,C.value)])])}),{reset:i,resetValidation:f,validate:d,isValid:V,errorMessages:c}}});function Sa(e){function t(u,l){var a,n;!e.autofocus||!u||(n=(a=l[0].target)==null?void 0:a.focus)==null||n.call(a)}return{onIntersect:t}}const _a=["color","file","time","date","datetime-local","week","month"],Pa=T({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,...Re(),...Fe()},"VTextField"),Ma=H()({name:"VTextField",directives:{vIntersect:fe},inheritAttrs:!1,props:Pa(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,t){let{attrs:u,emit:l,slots:a}=t;const n=se(e,"modelValue"),{isFocused:m,focus:y,blur:h}=we(e),{onIntersect:x}=Sa(e),o=g(()=>typeof e.counterValue=="function"?e.counterValue(n.value):typeof e.counterValue=="number"?e.counterValue:(n.value??"").toString().length),s=g(()=>{if(u.maxlength)return u.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),v=g(()=>["plain","underlined"].includes(e.variant)),c=z(),k=z(),_=z(),I=g(()=>_a.includes(e.type)||e.persistentPlaceholder||m.value||e.active);function A(){m.value||y(),p(()=>{_.value!==document.activeElement&&p(()=>{var d;return(d=_.value)==null?void 0:d.focus()})})}function V(d){l("mousedown:control",d),d.target!==_.value&&(A(),d.preventDefault())}function P(d){l("click:control",d)}function i(d,S){d.stopPropagation(),A(),p(()=>{n.value=null,S(),Ve(e["onClick:clear"],d)})}function f(d){var C;const S=d.target;if(n.value=S.value,(C=e.modelModifiers)!=null&&C.trim&&["text","search","password","tel","url"].includes(e.type)){const L=[S.selectionStart,S.selectionEnd];p(()=>{S.selectionStart=L[0],S.selectionEnd=L[1]})}}return q(()=>{const d=!!(a.counter||e.counter!==!1&&e.counter!=null),S=!!(d||a.details),[C,L]=oa(u),{modelValue:Z,...G}=me.filterProps(e),N=ge.filterProps(e);return b(me,ee({ref:c,modelValue:n.value,"onUpdate:modelValue":E=>n.value=E,class:["v-text-field",{"v-text-field--prefixed":e.prefix,"v-text-field--suffixed":e.suffix,"v-input--plain-underlined":v.value},e.class],style:e.style},C,G,{centerAffix:!v.value,focused:m.value}),{...a,default:E=>{let{id:w,isDisabled:J,isDirty:M,isReadonly:F,isValid:R,reset:D}=E;return b(ge,ee({ref:k,onMousedown:V,onClick:P,"onClick:clear":B=>i(B,D),"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"],role:e.role},N,{id:w.value,active:I.value||M.value,dirty:M.value||e.dirty,disabled:J.value,focused:m.value,error:R.value===!1}),{...a,default:B=>{let{props:{class:K,...X}}=B;const O=oe(r("input",ee({ref:_,value:n.value,onInput:f,autofocus:e.autofocus,readonly:F.value,disabled:J.value,name:e.name,placeholder:e.placeholder,size:1,type:e.type,onFocus:A,onBlur:h},X,L),null),[[fe,{handler:x},null,{once:!0}]]);return r(te,null,[e.prefix&&r("span",{class:"v-text-field__prefix"},[r("span",{class:"v-text-field__prefix__text"},[e.prefix])]),a.default?r("div",{class:U(K),"data-no-activator":""},[a.default(),O]):ra(O,{class:K}),e.suffix&&r("span",{class:"v-text-field__suffix"},[r("span",{class:"v-text-field__suffix__text"},[e.suffix])])])}})},details:S?E=>{var w;return r(te,null,[(w=a.details)==null?void 0:w.call(a,E),d&&r(te,null,[r("span",null,null),b(va,{active:e.persistentCounter||m.value,value:o.value,max:s.value,disabled:e.disabled},a.counter)])])}:void 0})}),da({},c,k,_)}});export{Ma as V,me as a,ge as b,va as c,Fe as d,ga as e,Fa as f,wa as g,Ca as h,Pa as i,Sa as j,Re as m,we as u};