import{bd as e,q as t,o,c as l,w as a,t as s,R as r,A as i,G as c,a0 as n,v as u,x as d,i as h,b4 as p}from"./index-DL8B2Mxu.js";import{_ as m}from"./u-icon.CLOPtL2B.js";import{r as y}from"./uni-app.es.BSVEa1f2.js";import{_ as f}from"./_plugin-vue_export-helper.BCo6x5W8.js";const g=f({name:"u-search",emits:["update:modelValue","input","change","search","custom","clear","focus","blur"],props:{value:{type:String,default:""},modelValue:{type:String,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"},disabled:{type:Boolean,default:!1},animation:{type:Boolean,default:!1},borderColor:{type:String,default:"none"},height:{type:[Number,String],default:64},inputStyle:{type:Object,default:()=>({})},maxlength:{type:[Number,String],default:"-1"},searchIconColor:{type:String,default:""},color:{type:String,default:"#606266"},placeholderColor:{type:String,default:"#909399"},margin:{type:String,default:"0"},searchIcon:{type:String,default:"search"}},data(){return{keyword:"",showClear:!1,show:!1,focused:this.focus}},watch:{keyword(e){this.$emit("input",e),this.$emit("update:modelValue",e),this.$emit("change",e)},valueCom:{immediate:!0,handler(e){this.keyword=e}}},computed:{valueCom(){return this.modelValue},showActionBtn(){return!(this.animation||!this.showAction)},borderStyle(){return this.borderColor?`1px solid ${this.borderColor}`:"none"}},methods:{inputChange(e){this.keyword=e.detail.value},clear(){this.keyword="",this.$nextTick((()=>{this.$emit("clear")}))},search(t){this.$emit("search",t.detail.value);try{e()}catch(o){}},custom(){this.$emit("custom",this.keyword);try{e()}catch(t){}},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")}}},[["render",function(e,f,g,b,C,w){const k=y(t("u-icon"),m),S=h,x=p;return o(),l(S,{class:"u-search",onClick:w.clickHandler,style:r({margin:g.margin})},{default:a((()=>[s(S,{class:"u-content",style:r({backgroundColor:g.bgColor,borderRadius:"round"==g.shape?"100rpx":"10rpx",border:w.borderStyle,height:g.height+"rpx"})},{default:a((()=>[s(S,{class:"u-icon-wrap"},{default:a((()=>[s(k,{class:"u-clear-icon",size:30,name:g.searchIcon,color:g.searchIconColor?g.searchIconColor:g.color},null,8,["name","color"])])),_:1}),s(x,{"confirm-type":"search",onBlur:w.blur,value:w.valueCom,onConfirm:w.search,onInput:w.inputChange,disabled:g.disabled,onFocus:w.getFocus,focus:g.focus,maxlength:g.maxlength,"placeholder-class":"u-placeholder-class",placeholder:g.placeholder,"placeholder-style":`color: ${g.placeholderColor}`,class:"u-input",type:"text",style:r([{textAlign:g.inputAlign,color:g.color,backgroundColor:g.bgColor},g.inputStyle])},null,8,["onBlur","value","onConfirm","onInput","disabled","onFocus","focus","maxlength","placeholder","placeholder-style","style"]),C.keyword&&g.clearabled&&C.focused?(o(),l(S,{key:0,class:"u-close-wrap",onClick:w.clear},{default:a((()=>[s(k,{class:"u-clear-icon",name:"close-circle-fill",size:"34",color:"#c0c4cc"})])),_:1},8,["onClick"])):i("",!0)])),_:1},8,["style"]),s(S,{style:r([g.actionStyle]),class:c(["u-action",[w.showActionBtn||C.show?"u-action-active":""]]),onClick:n(w.custom,["stop","prevent"])},{default:a((()=>[u(d(g.actionText),1)])),_:1},8,["style","class","onClick"])])),_:1},8,["onClick","style"])}],["__scopeId","data-v-209d41ca"]]);export{g as _};
