2 lines
3.6 KiB
JavaScript
2 lines
3.6 KiB
JavaScript
import{m as e,b as l,u as t,V as a,f as n,d as o,e as u}from"./VInput-Ba6RirnE.js";import{p as s,s as r,af as i,C as c,t as d,H as f,aC as p,d as v,m,ab as x,ao as y,F as V,bq as b,ai as g,ar as h,aJ as _}from"./index-y1hS5lj0.js";import{I as C}from"./loader-C-60Rb6M.js";const k=["color","file","time","date","datetime-local","week","month"],I=s({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,...e(),...l()},"VTextField"),S=r()({name:"VTextField",directives:{Intersect:C},inheritAttrs:!1,props:I(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,l){function s(l,t){var a,n;e.autofocus&&l&&(null==(n=null==(a=t[0].target)?void 0:a.focus)||n.call(a))}function r(){var e;H.value!==document.activeElement&&(null==(e=H.value)||e.focus()),D.value||E()}function C(e){B("mousedown:control",e),e.target!==H.value&&(r(),e.preventDefault())}function I(e){r(),B("click:control",e)}function S(l){l.stopPropagation(),r(),h((()=>{P.value=null,_(e["onClick:clear"],l)}))}function F(l){var t;const a=l.target;if(P.value=a.value,(null==(t=e.modelModifiers)?void 0:t.trim)&&["text","search","password","tel","url"].includes(e.type)){const e=[a.selectionStart,a.selectionEnd];h((()=>{a.selectionStart=e[0],a.selectionEnd=e[1]}))}}let{attrs:w,emit:B,slots:j}=l;const P=i(e,"modelValue"),{isFocused:D,focus:E,blur:M}=t(e),z=c((()=>"function"==typeof e.counterValue?e.counterValue(P.value):"number"==typeof e.counterValue?e.counterValue:(""+(P.value??"")).length)),A=c((()=>w.maxlength?w.maxlength:!e.counter||"number"!=typeof e.counter&&"string"!=typeof e.counter?void 0:e.counter)),N=c((()=>["plain","underlined"].includes(e.variant))),T=d(),q=d(),H=d(),J=c((()=>k.includes(e.type)||e.persistentPlaceholder||D.value||e.active));return f((()=>{const l=!!(j.counter||!1!==e.counter&&null!=e.counter),t=!(!l&&!j.details),[i,c]=p(w),{modelValue:d,...f}=a.filterProps(e),g=n(e);return v(a,m({ref:T,modelValue:P.value,"onUpdate:modelValue":e=>P.value=e,class:["v-text-field",{"v-text-field--prefixed":e.prefix,"v-text-field--suffixed":e.suffix,"v-input--plain-underlined":N.value},e.class],style:e.style},i,f,{centerAffix:!N.value,focused:D.value}),{...j,default:l=>{let{id:t,isDisabled:a,isDirty:n,isReadonly:u,isValid:i}=l;return v(o,m({ref:q,onMousedown:C,onClick:I,"onClick:clear":S,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"],role:e.role},g,{id:t.value,active:J.value||n.value,dirty:n.value||e.dirty,disabled:a.value,focused:D.value,error:!1===i.value}),{...j,default:l=>{let{props:{class:t,...n}}=l;const o=x(v("input",m({ref:H,value:P.value,onInput:F,autofocus:e.autofocus,readonly:u.value,disabled:a.value,name:e.name,placeholder:e.placeholder,size:1,type:e.type,onFocus:r,onBlur:M},n,c),null),[[y("intersect"),{handler:s},null,{once:!0}]]);return v(V,null,[e.prefix&&v("span",{class:"v-text-field__prefix"},[v("span",{class:"v-text-field__prefix__text"},[e.prefix])]),j.default?v("div",{class:t,"data-no-activator":""},[j.default(),o]):b(o,{class:t}),e.suffix&&v("span",{class:"v-text-field__suffix"},[v("span",{class:"v-text-field__suffix__text"},[e.suffix])])])}})},details:t?t=>{var a;return v(V,null,[null==(a=j.details)?void 0:a.call(j,t),l&&v(V,null,[v("span",null,null),v(u,{active:e.persistentCounter||D.value,value:z.value,max:A.value,disabled:e.disabled},j.counter)])])}:void 0})})),g({},T,q,H)}});export{S as V,I as m};
|