2 lines
6.1 KiB
JavaScript
2 lines
6.1 KiB
JavaScript
import{a7 as B,a8 as $,dU as le,eh as ne,ab as w,f as s,af as L,x as a,G as U,H as N,dT as te,c$ as F,dr as P,dm as ie,aA as oe,aa as se,ac as re,dn as de,aF as ue,ae as ce,d0 as ve,r as S,aC as fe,an as ye,d6 as me,w as ge,ei as be,at as Ce,d8 as ke,d9 as he,dp as Ve,ej as _e,aK as Ie,S as xe,z as Fe,de as Pe,ek as Se}from"./index-bf26ab50.js";import{a as Be,c as $e,u as we,d as Le}from"./VInput-39e2e84d.js";const Re=B({active:Boolean,disabled:Boolean,max:[Number,String],value:{type:[Number,String],default:0},...$(),...le({transition:{component:ne}})},"VCounter"),Oe=w()({name:"VCounter",functional:!0,props:Re(),setup(e,r){let{slots:i}=r;const I=s(()=>e.max?`${e.value} / ${e.max}`:String(e.value));return L(()=>a(te,{transition:e.transition},{default:()=>[U(a("div",{class:["v-counter",{"text-error":e.max&&!e.disabled&&parseFloat(e.value)>parseFloat(e.max)},e.class],style:e.style},[i.default?i.default({counter:I.value,max:e.max,value:e.value}):I.value]),[[N,e.active]])]})),{}}});const Te=B({floating:Boolean,...$()},"VFieldLabel"),_=w()({name:"VFieldLabel",props:Te(),setup(e,r){let{slots:i}=r;return L(()=>a(Be,{class:["v-field-label",{"v-field-label--floating":e.floating},e.class],style:e.style,"aria-hidden":e.floating||void 0},i)),{}}}),Ae=["underlined","outlined","filled","solo","solo-inverted","solo-filled","plain"],Ee=B({appendInnerIcon:F,bgColor:String,clearable:Boolean,clearIcon:{type:F,default:"$clear"},active:Boolean,centerAffix:{type:Boolean,default:void 0},color:String,baseColor:String,dirty:Boolean,disabled:{type:Boolean,default:null},error:Boolean,flat:Boolean,label:String,persistentClear:Boolean,prependInnerIcon:F,reverse:Boolean,singleLine:Boolean,variant:{type:String,default:"filled",validator:e=>Ae.includes(e)},"onClick:clear":P(),"onClick:appendInner":P(),"onClick:prependInner":P(),...$(),...ie(),...oe(),...se()},"VField"),De=w()({name:"VField",inheritAttrs:!1,props:{id:String,...$e(),...Ee()},emits:{"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,r){let{attrs:i,emit:I,slots:l}=r;const{themeClasses:j}=re(e),{loaderClasses:W}=de(e),{focusClasses:q,isFocused:R,focus:y,blur:m}=we(e),{InputIcon:x}=Le(e),{roundedClasses:z}=ue(e),{rtlClasses:G}=ce(),g=s(()=>e.dirty||e.active),b=s(()=>!e.singleLine&&!!(e.label||l.label)),H=ve(),d=s(()=>e.id||`input-${H}`),X=s(()=>`${d.value}-messages`),T=S(),C=S(),A=S(),E=s(()=>["plain","underlined"].includes(e.variant)),{backgroundColorClasses:Y,backgroundColorStyles:J}=fe(ye(e,"bgColor")),{textColorClasses:D,textColorStyles:K}=me(s(()=>e.error||e.disabled?void 0:g.value&&R.value?e.color:e.baseColor));ge(g,n=>{if(b.value){const t=T.value.$el,u=C.value.$el;requestAnimationFrame(()=>{const c=be(t),o=u.getBoundingClientRect(),k=o.x-c.x,h=o.y-c.y-(c.height/2-o.height/2),f=o.width/.75,V=Math.abs(f-c.width)>1?{maxWidth:Ce(f)}:void 0,Z=getComputedStyle(t),O=getComputedStyle(u),p=parseFloat(Z.transitionDuration)*1e3||150,ee=parseFloat(O.getPropertyValue("--v-field-label-scale")),ae=O.getPropertyValue("color");t.style.visibility="visible",u.style.visibility="hidden",ke(t,{transform:`translate(${k}px, ${h}px) scale(${ee})`,color:ae,...V},{duration:p,easing:he,direction:n?"normal":"reverse"}).finished.then(()=>{t.style.removeProperty("visibility"),u.style.removeProperty("visibility")})})}},{flush:"post"});const v=s(()=>({isActive:g,isFocused:R,controlRef:A,blur:m,focus:y}));function Q(n){n.target!==document.activeElement&&n.preventDefault()}function M(n){var t;n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),n.stopPropagation(),(t=e["onClick:clear"])==null||t.call(e,new MouseEvent("click")))}return L(()=>{var k,h,f;const n=e.variant==="outlined",t=!!(l["prepend-inner"]||e.prependInnerIcon),u=!!(e.clearable||l.clear),c=!!(l["append-inner"]||e.appendInnerIcon||u),o=()=>l.label?l.label({...v.value,label:e.label,props:{for:d.value}}):e.label;return a("div",Fe({class:["v-field",{"v-field--active":g.value,"v-field--appended":c,"v-field--center-affix":e.centerAffix??!E.value,"v-field--disabled":e.disabled,"v-field--dirty":e.dirty,"v-field--error":e.error,"v-field--flat":e.flat,"v-field--has-background":!!e.bgColor,"v-field--persistent-clear":e.persistentClear,"v-field--prepended":t,"v-field--reverse":e.reverse,"v-field--single-line":e.singleLine,"v-field--no-label":!o(),[`v-field--variant-${e.variant}`]:!0},j.value,Y.value,q.value,W.value,z.value,G.value,e.class],style:[J.value,e.style],onClick:Q},i),[a("div",{class:"v-field__overlay"},null),a(Ve,{name:"v-field",active:!!e.loading,color:e.error?"error":typeof e.loading=="string"?e.loading:e.color},{default:l.loader}),t&&a("div",{key:"prepend",class:"v-field__prepend-inner"},[e.prependInnerIcon&&a(x,{key:"prepend-icon",name:"prependInner"},null),(k=l["prepend-inner"])==null?void 0:k.call(l,v.value)]),a("div",{class:"v-field__field","data-no-activator":""},[["filled","solo","solo-inverted","solo-filled"].includes(e.variant)&&b.value&&a(_,{key:"floating-label",ref:C,class:[D.value],floating:!0,for:d.value,style:K.value},{default:()=>[o()]}),a(_,{ref:T,for:d.value},{default:()=>[o()]}),(h=l.default)==null?void 0:h.call(l,{...v.value,props:{id:d.value,class:"v-field__input","aria-describedby":X.value},focus:y,blur:m})]),u&&a(_e,{key:"clear"},{default:()=>[U(a("div",{class:"v-field__clearable",onMousedown:V=>{V.preventDefault(),V.stopPropagation()}},[a(Ie,{defaults:{VIcon:{icon:e.clearIcon}}},{default:()=>[l.clear?l.clear({...v.value,props:{onKeydown:M,onFocus:y,onBlur:m,onClick:e["onClick:clear"]}}):a(x,{name:"clear",onKeydown:M,onFocus:y,onBlur:m},null)]})]),[[N,e.dirty]])]}),c&&a("div",{key:"append",class:"v-field__append-inner"},[(f=l["append-inner"])==null?void 0:f.call(l,v.value),e.appendInnerIcon&&a(x,{key:"append-icon",name:"appendInner"},null)]),a("div",{class:["v-field__outline",D.value],style:K.value},[n&&a(xe,null,[a("div",{class:"v-field__outline__start"},null),b.value&&a("div",{class:"v-field__outline__notch"},[a(_,{ref:C,floating:!0,for:d.value},{default:()=>[o()]})]),a("div",{class:"v-field__outline__end"},null)]),E.value&&b.value&&a(_,{ref:C,floating:!0,for:d.value},{default:()=>[o()]})])])}),{controlRef:A}}});function Ue(e){const r=Object.keys(De.props).filter(i=>!Pe(i)&&i!=="class"&&i!=="style");return Se(e,r)}export{De as V,Oe as a,Ue as f,Ee as m};
|