var e,t;import{x as o,y as l,T as a,g as s,o as r,c,w as i,a as n,A as u,j as d,m as h,n as p,p as y,h as f,t as m,d as g,I as _,B as k}from"./index-3714412c.js";import{_ as b}from"./uv-icon.c593f91d.js";import{r as v}from"./useRouter.f44141c1.js";import{_ as S}from"./_plugin-vue_export-helper.1b428a4d.js";const w=S({name:"uv-search",emits:["click","input","change","clear","search","custom","focus","blur","clickIcon","update:modelValue"],mixins:[o,l,{props:{value:{type:[String,Number],default:""},modelValue:{type:[String,Number],default:""},shape:{type:String,default:"round"},bgColor:{type:String,default:"#f2f2f2"},placeholder:{type:String,default:"请输入关键字"},clearabled:{type:Boolean,default:!0},focus:{type:Boolean,default:!1},showAction:{type:Boolean,default:!0},actionStyle:{type:Object,default:()=>({})},actionText:{type:String,default:"搜索"},inputAlign:{type:String,default:"left"},inputStyle:{type:Object,default:()=>({})},disabled:{type:Boolean,default:!1},borderColor:{type:String,default:"transparent"},searchIconColor:{type:String,default:"#909399"},color:{type:String,default:"#606266"},placeholderColor:{type:String,default:"#909399"},searchIcon:{type:String,default:"search"},searchIconSize:{type:[Number,String],default:22},margin:{type:String,default:"0"},animation:{type:Boolean,default:!1},maxlength:{type:[String,Number],default:-1},height:{type:[String,Number],default:32},label:{type:[String,Number,null],default:null},boxStyle:{type:[String,Object],default:()=>({})},...null==(t=null==(e=uni.$uv)?void 0:e.props)?void 0:t.search}}],data(){return{keyword:"",showClear:!1,show:!1,focused:this.focus}},created(){this.keyword=this.modelValue},watch:{value(e){this.keyword=e},modelValue(e){this.keyword=e}},computed:{showActionBtn(){return!this.animation&&this.showAction}},methods:{keywordChange(){this.$emit("input",this.keyword),this.$emit("update:modelValue",this.keyword),this.$emit("change",this.keyword)},inputChange(e){this.keyword=e.detail.value,this.keywordChange()},clear(){this.keyword="",this.$nextTick((()=>{this.$emit("clear")})),this.keywordChange()},search(e){this.$emit("search",e.detail.value);try{a()}catch(t){}},custom(){this.$emit("custom",this.keyword);try{a()}catch(e){}},getFocus(){this.focused=!0,this.animation&&this.showAction&&(this.show=!0),this.$emit("focus",this.keyword)},blur(){setTimeout((()=>{this.focused=!1}),100),this.show=!1,this.$emit("blur",this.keyword)},clickHandler(){this.disabled&&this.$emit("click")},clickIcon(){this.$emit("clickIcon")}}},[["render",function(e,t,o,l,a,S){const w=v(s("uv-icon"),b),C=g,x=_,$=k;return r(),c(C,{class:"uv-search",onClick:S.clickHandler,style:u([{margin:e.margin},e.$uv.addStyle(e.customStyle)])},{default:i((()=>[n(C,{class:"uv-search__content",style:u([{backgroundColor:e.bgColor,borderRadius:"round"==e.shape?"100px":"4px",borderColor:e.borderColor},e.$uv.addStyle(e.boxStyle)])},{default:i((()=>[d(e.$slots,"prefix",{},(()=>[n(C,{class:"uv-search__content__icon"},{default:i((()=>[n(w,{onClick:S.clickIcon,size:e.searchIconSize,name:e.searchIcon,color:e.searchIconColor?e.searchIconColor:e.color},null,8,["onClick","size","name","color"])])),_:1})]),!0),n(x,{"confirm-type":"search",onBlur:S.blur,value:a.keyword,onConfirm:S.search,onInput:S.inputChange,disabled:e.disabled,onFocus:S.getFocus,focus:e.focus,maxlength:e.maxlength,"placeholder-class":"uv-search__content__input--placeholder",placeholder:e.placeholder,"placeholder-style":`color: ${e.placeholderColor}`,class:"uv-search__content__input",type:"text",style:u([{textAlign:e.inputAlign,color:e.color,backgroundColor:e.bgColor,height:e.$uv.addUnit(e.height)},e.inputStyle])},null,8,["onBlur","value","onConfirm","onInput","disabled","onFocus","focus","maxlength","placeholder","placeholder-style","style"]),a.keyword&&e.clearabled&&a.focused?(r(),c(C,{key:0,class:"uv-search__content__icon uv-search__content__close",onClick:S.clear},{default:i((()=>[n(w,{name:"close",size:"11",color:"#ffffff",customStyle:"line-height: 12px"})])),_:1},8,["onClick"])):h("",!0),d(e.$slots,"suffix",{},void 0,!0)])),_:3},8,["style"]),n($,{style:u([e.actionStyle]),class:p(["uv-search__action",[(S.showActionBtn||a.show)&&"uv-search__action--active"]]),onClick:y(S.custom,["stop","prevent"])},{default:i((()=>[f(m(e.actionText),1)])),_:1},8,["style","class","onClick"])])),_:3},8,["onClick","style"])}],["__scopeId","data-v-12c4e7c5"]]);export{w as _};
