vuux
Version:
Vue3 Nuxt3 Nuxt4 组件库
2 lines (1 loc) • 2.78 kB
JavaScript
;const e=require("vue"),w=require("../../ScrollBar/index.cjs"),C=require("./hook/useAutoComplete.cjs"),N=require("@vuux/icons"),_={class:"input-data"},g=["value"],x={key:0,class:"is-loading"},y={key:1,class:"no-data"},I=["onClick","innerHTML"],M=e.defineComponent({name:"AutoComplete",__name:"index",props:{modelValue:{},label:{default:"name"},value:{default:"id"},options:{},fetchOptions:{},maxVisible:{default:10},debounceTime:{default:300},shadow:{type:Boolean},clear:{type:Boolean}},emits:["update:modelValue","select"],setup(c,{emit:i}){const o=c,u=i,l=e.useTemplateRef("wrapperEl"),{inputValue:r,loading:d,showDropdown:p,filteredOptions:m,highlightIndex:k,startIndex:f,visibleOptions:h,clearInput:B,selectItem:E,onInputBox:a,onInputClick:s,highlightMatch:V}=C.useAutoComplete(o,l,u);return(T,n)=>(e.openBlock(),e.createElementBlock("div",{class:"app-auto-complete",ref_key:"wrapperEl",ref:l},[e.createElementVNode("div",_,[e.createElementVNode("input",{value:e.unref(r),onInput:n[0]||(n[0]=(...t)=>e.unref(a)&&e.unref(a)(...t)),onClick:n[1]||(n[1]=(...t)=>e.unref(s)&&e.unref(s)(...t)),placeholder:"请输入内容"},null,40,g),e.unref(r)&&o.clear?(e.openBlock(),e.createBlock(e.unref(N.Icon),{key:0,name:"Icon9176904",size:13,onClick:e.withModifiers(e.unref(B),["stop"])},null,8,["onClick"])):e.createCommentVNode("",!0)]),e.createVNode(e.Transition,{name:"ease-drop"},{default:e.withCtx(()=>[e.unref(p)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["result-lists",{"is-shadow":o.shadow}])},[e.unref(d)?(e.openBlock(),e.createElementBlock("div",x,[...n[2]||(n[2]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"M12 2v4"}),e.createElementVNode("path",{d:"m16.2 7.8 2.9-2.9"}),e.createElementVNode("path",{d:"M18 12h4"}),e.createElementVNode("path",{d:"m16.2 16.2 2.9 2.9"}),e.createElementVNode("path",{d:"M12 18v4"}),e.createElementVNode("path",{d:"m4.9 19.1 2.9-2.9"}),e.createElementVNode("path",{d:"M2 12h4"}),e.createElementVNode("path",{d:"m4.9 4.9 2.9 2.9"})],-1)])])):e.unref(m).length===0?(e.openBlock(),e.createElementBlock("div",y,"暂无数据")):(e.openBlock(),e.createBlock(e.unref(w.ScrollBar),{key:2},{default:e.withCtx(()=>[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(h),(t,v)=>(e.openBlock(),e.createElementBlock("li",{key:t[o.value??"id"],class:e.normalizeClass({active:v+e.unref(f)===e.unref(k)}),onClick:b=>e.unref(E)(t),innerHTML:e.unref(V)(t)},null,10,I))),128))])]),_:1}))],2)):e.createCommentVNode("",!0)]),_:1})],512))}});module.exports=M;