import{_ as e,b as t,h as l,d as a,o,p as s,w as i,B as n,f as d,k as u,t as c,v as r,e as p,F as m,y as h,a4 as _,C as f,i as b,Y as y,S as x}from"./index-2PZN6pGH.js";import{_ as S}from"./uni-card.CpdfOoXJ.js";import{_ as V}from"./uni-section.BISPxi99.js";const C=e({name:"uniCombox",emits:["input","update:modelValue"],props:{border:{type:Boolean,default:!0},label:{type:String,default:""},labelWidth:{type:String,default:"auto"},placeholder:{type:String,default:""},candidates:{type:Array,default:()=>[]},emptyTips:{type:String,default:"无匹配项"},modelValue:{type:[String,Number],default:""}},data:()=>({showSelector:!1,inputVal:""}),computed:{labelStyle(){return"auto"===this.labelWidth?"":`width: ${this.labelWidth}`},filterCandidates(){return this.candidates.filter((e=>e.toString().indexOf(this.inputVal)>-1))},filterCandidatesLength(){return this.filterCandidates.length}},watch:{modelValue:{handler(e){this.inputVal=e},immediate:!0}},methods:{toggleSelector(){this.showSelector=!this.showSelector},onFocus(){this.showSelector=!0},onBlur(){setTimeout((()=>{this.showSelector=!1}),153)},onSelectorClick(e){this.inputVal=this.filterCandidates[e],this.showSelector=!1,this.$emit("input",this.inputVal),this.$emit("update:modelValue",this.inputVal)},onInput(){setTimeout((()=>{this.$emit("input",this.inputVal),this.$emit("update:modelValue",this.inputVal)}))}}},[["render",function(e,S,V,C,g,w){const k=f,T=b,B=y,I=t(a("uni-icons"),l),F=x;return o(),s(T,{class:_(["uni-combox",V.border?"":"uni-combox__no-border"])},{default:i((()=>[V.label?(o(),s(T,{key:0,class:"uni-combox__label",style:n(w.labelStyle)},{default:i((()=>[d(k,null,{default:i((()=>[u(c(V.label),1)])),_:1})])),_:1},8,["style"])):r("",!0),d(T,{class:"uni-combox__input-box"},{default:i((()=>[d(B,{class:"uni-combox__input",type:"text",placeholder:V.placeholder,"placeholder-class":"uni-combox__input-plac",modelValue:g.inputVal,"onUpdate:modelValue":S[0]||(S[0]=e=>g.inputVal=e),onInput:w.onInput,onFocus:w.onFocus,onBlur:w.onBlur},null,8,["placeholder","modelValue","onInput","onFocus","onBlur"]),d(I,{type:g.showSelector?"top":"bottom",size:"14",color:"#999",onClick:w.toggleSelector},null,8,["type","onClick"])])),_:1}),g.showSelector?(o(),s(T,{key:1,class:"uni-combox__selector"},{default:i((()=>[d(T,{class:"uni-popper__arrow"}),d(F,{"scroll-y":"true",class:"uni-combox__selector-scroll"},{default:i((()=>[0===w.filterCandidatesLength?(o(),s(T,{key:0,class:"uni-combox__selector-empty"},{default:i((()=>[d(k,null,{default:i((()=>[u(c(V.emptyTips),1)])),_:1})])),_:1})):r("",!0),(o(!0),p(m,null,h(w.filterCandidates,((e,t)=>(o(),s(T,{class:"uni-combox__selector-item",key:t,onClick:e=>w.onSelectorClick(t)},{default:i((()=>[d(k,null,{default:i((()=>[u(c(e),1)])),_:2},1024)])),_:2},1032,["onClick"])))),128))])),_:1})])),_:1})):r("",!0)])),_:1},8,["class"])}],["__scopeId","data-v-b4a266aa"]]);const g=e({components:{},data:()=>({candidates:["北京","南京","东京","武汉","天津","上海","海口"],city:""}),methods:{}},[["render",function(e,l,n,r,p,m){const h=f,_=t(a("uni-card"),S),y=t(a("uni-combox"),C),x=b,g=t(a("uni-section"),V);return o(),s(x,{class:"container"},{default:i((()=>[d(_,{"is-shadow":!1,"is-full":""},{default:i((()=>[d(h,{class:"uni-h6"},{default:i((()=>[u("组合框一般用于可以选择也可以输入的表单项。")])),_:1})])),_:1}),d(g,{title:"基本用法",type:"line"},{default:i((()=>[d(x,{class:"example-body"},{default:i((()=>[d(y,{candidates:p.candidates,placeholder:"请选择所在城市",modelValue:p.city,"onUpdate:modelValue":l[0]||(l[0]=e=>p.city=e)},null,8,["candidates","modelValue"]),d(x,{class:"result-box"},{default:i((()=>[d(h,null,{default:i((()=>[u("所选城市为："+c(p.city),1)])),_:1})])),_:1})])),_:1})])),_:1}),d(g,{title:"无边框",subTitle:"使用 border = false 取消边框",type:"line"},{default:i((()=>[d(x,{class:"example-body"},{default:i((()=>[d(y,{border:!1,candidates:p.candidates,placeholder:"请选择所在城市"},null,8,["candidates"])])),_:1})])),_:1}),d(g,{title:"设置无匹配项时的提示语",subTitle:"使用 emptyTips 属性设置无匹配项时的提示语",type:"line"},{default:i((()=>[d(x,{class:"example-body"},{default:i((()=>[d(y,{emptyTips:"这里啥都没有",placeholder:"请选择所在城市"})])),_:1})])),_:1})])),_:1})}],["__scopeId","data-v-d1b68d2d"]]);export{g as default};
