1 |
- var Ae=Object.defineProperty,Ie=Object.defineProperties;var Pe=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var De=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable;var ee=(e,i,a)=>i in e?Ae(e,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[i]=a,x=(e,i)=>{for(var a in i||(i={}))De.call(i,a)&&ee(e,a,i[a]);if(Q)for(var a of Q(i))Re.call(i,a)&&ee(e,a,i[a]);return e},le=(e,i)=>Ie(e,Pe(i));import{q as _e,bR as Te,bS as Me,b0 as Le,bT as Be,bU as Ee,x as Ne,bd as Oe,r as T,ar as A,y as z,C as V,bV as Ue,bp as Ke,bW as $e,bX as qe,bY as ze,A as M,B as ae,I as He,E as We,F as je,j as te,b as c,a0 as L,bZ as Je,D as F,b_ as Xe,b$ as ue,c0 as Ye,c1 as Ze,c2 as Ge,S as ne,c3 as Qe,c4 as el,J as ll,n as al,c5 as tl,c6 as ul,c7 as oe}from"./index.6c36cb53.js";function nl(e,i,a){if(i==null)return e;if(Array.isArray(i))throw new Error("Multiple matches is not implemented");return typeof i=="number"&&~i?c(L,null,[c("span",{class:"v-autocomplete__unmask"},[e.substr(0,i)]),c("span",{class:"v-autocomplete__mask"},[e.substr(i,a)]),c("span",{class:"v-autocomplete__unmask"},[e.substr(i+a)])]):e}const ol=_e(x(x(x(x({autoSelectFirst:{type:[Boolean,String]},clearOnSelect:Boolean,search:String},Te({filterKeys:["title"]})),Me()),Le(Be({modelValue:null,role:"combobox"}),["validationValue","dirty","appendInnerIcon"])),Ee({transition:!1})),"VAutocomplete"),cl=Ne()({name:"VAutocomplete",props:ol(),emits:{"update:focused":e=>!0,"update:search":e=>!0,"update:modelValue":e=>!0,"update:menu":e=>!0},setup(e,i){let{slots:a}=i;const{t:B}=Oe(),h=T(),y=A(!1),S=A(!0),I=A(!1),H=T(),W=T(),E=z(e,"menu"),v=V({get:()=>E.value,set:l=>{var t;E.value&&!l&&((t=H.value)==null?void 0:t.\u03A8openChildren)||(E.value=l)}}),r=A(-1),se=V(()=>{var l;return(l=h.value)==null?void 0:l.color}),j=V(()=>v.value?e.closeText:e.openText),{items:J,transformIn:ie,transformOut:ce}=Ue(e),{textColorClasses:re,textColorStyles:ve}=Ke(se),m=z(e,"search",""),n=z(e,"modelValue",[],l=>ie(l===null?[null]:ul(l)),l=>{var o;const t=ce(l);return e.multiple?t:(o=t[0])!=null?o:null}),de=V(()=>typeof e.counterValue=="function"?e.counterValue(n.value):typeof e.counterValue=="number"?e.counterValue:n.value.length),C=$e(),{filteredItems:N,getMatches:fe}=qe(e,J,()=>S.value?"":m.value),g=V(()=>e.hideSelected?N.value.filter(l=>!n.value.some(t=>t.value===l.value)):N.value),P=V(()=>!!(e.chips||a.chip)),O=V(()=>P.value||!!a.selection),me=V(()=>n.value.map(l=>l.props.value)),D=V(()=>{var t;return(e.autoSelectFirst===!0||e.autoSelectFirst==="exact"&&m.value===((t=g.value[0])==null?void 0:t.title))&&g.value.length>0&&!S.value&&!I.value}),U=V(()=>e.hideNoData&&!g.value.length||e.readonly||(C==null?void 0:C.isReadonly.value)),K=T(),{onListScroll:pe,onListKeydown:he}=ze(K,h);function ge(l){e.openOnClear&&(v.value=!0),m.value=""}function Ve(){U.value||(v.value=!0)}function ye(l){U.value||(y.value&&(l.preventDefault(),l.stopPropagation()),v.value=!v.value)}function be(l){var u,s,p;if(e.readonly||(C==null?void 0:C.isReadonly.value))return;const t=h.value.selectionStart,o=n.value.length;if((r.value>-1||["Enter","ArrowDown","ArrowUp"].includes(l.key))&&l.preventDefault(),["Enter","ArrowDown"].includes(l.key)&&(v.value=!0),["Escape"].includes(l.key)&&(v.value=!1),D.value&&["Enter","Tab"].includes(l.key)&&k(g.value[0]),l.key==="ArrowDown"&&D.value&&((u=K.value)==null||u.focus("next")),!!e.multiple){if(["Backspace","Delete"].includes(l.key)){if(r.value<0){l.key==="Backspace"&&!m.value&&(r.value=o-1);return}const d=r.value,b=n.value[r.value];b&&!b.props.disabled&&k(b,!1),r.value=d>=o-1?o-2:d}if(l.key==="ArrowLeft"){if(r.value<0&&t>0)return;const d=r.value>-1?r.value-1:o-1;n.value[d]?r.value=d:(r.value=-1,h.value.setSelectionRange((s=m.value)==null?void 0:s.length,(p=m.value)==null?void 0:p.length))}if(l.key==="ArrowRight"){if(r.value<0)return;const d=r.value+1;n.value[d]?r.value=d:(r.value=-1,h.value.setSelectionRange(0,0))}}}function Se(l){if(oe(h.value,":autofill")||oe(h.value,":-webkit-autofill")){const t=J.value.find(o=>o.title===l.target.value);t&&k(t)}}function ke(){var l;y.value&&(S.value=!0,(l=h.value)==null||l.focus())}function we(l){y.value=!0,setTimeout(()=>{I.value=!0})}function Ce(l){I.value=!1}function xe(l){(l==null||l===""&&!e.multiple)&&(n.value=[])}const $=A(!1);function k(l){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(!l.props.disabled)if(e.multiple){const o=n.value.findIndex(s=>e.valueComparator(s.value,l.value)),u=t==null?!~o:t;if(~o){const s=u?[...n.value,l]:[...n.value];s.splice(o,1),n.value=s}else u&&(n.value=[...n.value,l]);e.clearOnSelect&&(m.value="")}else{const o=t!==!1;n.value=o?[l]:[],m.value=o&&!O.value?l.title:"",ae(()=>{v.value=!1,S.value=!0})}}return M(y,(l,t)=>{var o,u;l!==t&&(l?($.value=!0,m.value=e.multiple||O.value?"":String((u=(o=n.value.at(-1))==null?void 0:o.props.title)!=null?u:""),S.value=!0,ae(()=>$.value=!1)):(!e.multiple&&m.value==null?n.value=[]:D.value&&!I.value&&!n.value.some(s=>{let{value:p}=s;return p===g.value[0].value})&&k(g.value[0]),v.value=!1,m.value="",r.value=-1))}),M(m,l=>{!y.value||$.value||(l&&(v.value=!0),S.value=!l)}),M(v,()=>{if(!e.hideSelected&&v.value&&n.value.length){const l=g.value.findIndex(t=>n.value.some(o=>t.value===o.value));He&&window.requestAnimationFrame(()=>{var t;l>=0&&((t=W.value)==null||t.scrollToIndex(l))})}}),M(()=>e.items,l=>{!y.value||!l.length||v.value||(v.value=!0)}),We(()=>{const l=!!(!e.hideNoData||g.value.length||a["prepend-item"]||a["append-item"]||a["no-data"]),t=n.value.length>0,o=te.filterProps(e);return c(te,F({ref:h},o,{modelValue:m.value,"onUpdate:modelValue":[u=>m.value=u,xe],focused:y.value,"onUpdate:focused":u=>y.value=u,validationValue:n.externalValue,counterValue:de.value,dirty:t,onChange:Se,class:["v-autocomplete",`v-autocomplete--${e.multiple?"multiple":"single"}`,{"v-autocomplete--active-menu":v.value,"v-autocomplete--chips":!!e.chips,"v-autocomplete--selection-slot":!!O.value,"v-autocomplete--selecting-index":r.value>-1},e.class],style:e.style,readonly:e.readonly,placeholder:t?void 0:e.placeholder,"onClick:clear":ge,"onMousedown:control":Ve,onKeydown:be}),le(x({},a),{default:()=>c(L,null,[c(Je,F({ref:H,modelValue:v.value,"onUpdate:modelValue":u=>v.value=u,activator:"parent",contentClass:"v-autocomplete__content",disabled:U.value,eager:e.eager,maxHeight:310,openOnClick:!1,closeOnContentClick:!1,transition:e.transition,onAfterLeave:ke},e.menuProps),{default:()=>{var u;return[l&&c(Xe,F({ref:K,selected:me.value,selectStrategy:e.multiple?"independent":"single-independent",onMousedown:s=>s.preventDefault(),onKeydown:he,onFocusin:we,onFocusout:Ce,onScrollPassive:pe,tabindex:"-1","aria-live":"polite",color:(u=e.itemColor)!=null?u:e.color},e.listProps),{default:()=>{var s,p,d,b;return[(s=a["prepend-item"])==null?void 0:s.call(a),!g.value.length&&!e.hideNoData&&((d=(p=a["no-data"])==null?void 0:p.call(a))!=null?d:c(ue,{title:B(e.noDataText)},null)),c(Ye,{ref:W,renderless:!0,items:g.value},{default:w=>{var Y,Z;let{item:f,index:q,itemRef:Fe}=w;const X=F(f.props,{ref:Fe,key:q,active:D.value&&q===0?!0:void 0,onClick:()=>k(f,null)});return(Z=(Y=a.item)==null?void 0:Y.call(a,{item:f,index:q,props:X}))!=null?Z:c(ue,F(X,{role:"option"}),{prepend:R=>{let{isSelected:_}=R;return c(L,null,[e.multiple&&!e.hideSelected?c(Ze,{key:f.value,modelValue:_,ripple:!1,tabindex:"-1"},null):void 0,f.props.prependAvatar&&c(Ge,{image:f.props.prependAvatar},null),f.props.prependIcon&&c(ne,{icon:f.props.prependIcon},null)])},title:()=>{var R,_,G;return S.value?f.title:nl(f.title,(R=fe(f))==null?void 0:R.title,(G=(_=m.value)==null?void 0:_.length)!=null?G:0)}})}}),(b=a["append-item"])==null?void 0:b.call(a)]}})]}}),n.value.map((u,s)=>{function p(f){f.stopPropagation(),f.preventDefault(),k(u,!1)}const d={"onClick:close":p,onMousedown(f){f.preventDefault(),f.stopPropagation()},modelValue:!0,"onUpdate:modelValue":void 0},b=P.value?!!a.chip:!!a.selection,w=b?Qe(P.value?a.chip({item:u,index:s,props:d}):a.selection({item:u,index:s})):void 0;if(!(b&&!w))return c("div",{key:u.value,class:["v-autocomplete__selection",s===r.value&&["v-autocomplete__selection--selected",re.value]],style:s===r.value?ve.value:{}},[P.value?a.chip?c(ll,{key:"chip-defaults",defaults:{VChip:{closable:e.closableChips,size:"small",text:u.title}}},{default:()=>[w]}):c(el,F({key:"chip",closable:e.closableChips,size:"small",text:u.title,disabled:u.props.disabled},d),null):w!=null?w:c("span",{class:"v-autocomplete__selection-text"},[u.title,e.multiple&&s<n.value.length-1&&c("span",{class:"v-autocomplete__selection-comma"},[al(",")])])])})]),"append-inner":function(){var d;for(var u=arguments.length,s=new Array(u),p=0;p<u;p++)s[p]=arguments[p];return c(L,null,[(d=a["append-inner"])==null?void 0:d.call(a,...s),e.menuIcon?c(ne,{class:"v-autocomplete__menu-icon",icon:e.menuIcon,onMousedown:ye,onClick:tl,"aria-label":B(j.value),title:B(j.value)},null):void 0])}}))}),je({isFocused:y,isPristine:S,menu:v,search:m,filteredItems:N,select:k},h)}});export{cl as V};
|