import{aC as e,_ as a,aF as c,d as l,e as s,o as t,f as r,w as n,h as o,n as i,v as h,j as u,t as d,k as m,i as p,aD as f,l as y}from"./index--EfctvOJ.js";import{_ as b}from"./uni-icons.5vxwhpmM.js";const _={en:{"uni-search-bar.cancel":"cancel","uni-search-bar.placeholder":"Search enter content"},"zh-Hans":{"uni-search-bar.cancel":"取消","uni-search-bar.placeholder":"请输入搜索内容"},"zh-Hant":{"uni-search-bar.cancel":"取消","uni-search-bar.placeholder":"請輸入搜索內容"}},{t:x}=e(_);const V=a({name:"UniSearchBar",emits:["input","update:modelValue","clear","cancel","confirm","blur","focus"],props:{placeholder:{type:String,default:""},radius:{type:[Number,String],default:5},clearButton:{type:String,default:"auto"},cancelButton:{type:String,default:"auto"},cancelText:{type:String,default:""},bgColor:{type:String,default:"#F8F8F8"},maxlength:{type:[Number,String],default:100},value:{type:[Number,String],default:""},modelValue:{type:[Number,String],default:""},focus:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},data:()=>({show:!1,showSync:!1,searchVal:""}),computed:{cancelTextI18n(){return this.cancelText||x("uni-search-bar.cancel")},placeholderText(){return this.placeholder||x("uni-search-bar.placeholder")}},watch:{modelValue:{immediate:!0,handler(e){this.searchVal=e,e&&(this.show=!0)}},focus:{immediate:!0,handler(e){if(e){if(this.readonly)return;this.show=!0,this.$nextTick((()=>{this.showSync=!0}))}}},searchVal(e,a){this.$emit("input",e),this.$emit("update:modelValue",e)}},methods:{searchClick(){this.readonly||this.show||(this.show=!0,this.$nextTick((()=>{this.showSync=!0})))},clear(){this.$emit("clear",{value:this.searchVal}),this.searchVal=""},cancel(){this.readonly||(this.$emit("cancel",{value:this.searchVal}),this.searchVal="",this.show=!1,this.showSync=!1,c())},confirm(){c(),this.$emit("confirm",{value:this.searchVal})},blur(){c(),this.$emit("blur",{value:this.searchVal})},emitFocus(e){this.$emit("focus",e.detail)}}},[["render",function(e,a,c,_,x,V){const w=l(s("uni-icons"),b),g=p,k=f,S=y;return t(),r(g,{class:"uni-searchbar"},{default:n((()=>[o(g,{style:i({borderRadius:c.radius+"px",backgroundColor:c.bgColor}),class:"uni-searchbar__box",onClick:V.searchClick},{default:n((()=>[o(g,{class:"uni-searchbar__box-icon-search"},{default:n((()=>[h(e.$slots,"searchIcon",{},(()=>[o(w,{color:"#c0c4cc",size:"18",type:"search"})]),!0)])),_:3}),x.show||x.searchVal?(t(),r(k,{key:0,focus:x.showSync,disabled:c.readonly,placeholder:V.placeholderText,maxlength:c.maxlength,class:"uni-searchbar__box-search-input","confirm-type":"search",type:"text",modelValue:x.searchVal,"onUpdate:modelValue":a[0]||(a[0]=e=>x.searchVal=e),onConfirm:V.confirm,onBlur:V.blur,onFocus:V.emitFocus},null,8,["focus","disabled","placeholder","maxlength","modelValue","onConfirm","onBlur","onFocus"])):(t(),r(S,{key:1,class:"uni-searchbar__text-placeholder"},{default:n((()=>[u(d(c.placeholder),1)])),_:1})),x.show&&("always"===c.clearButton||"auto"===c.clearButton&&""!==x.searchVal)&&!c.readonly?(t(),r(g,{key:2,class:"uni-searchbar__box-icon-clear",onClick:V.clear},{default:n((()=>[h(e.$slots,"clearIcon",{},(()=>[o(w,{color:"#c0c4cc",size:"20",type:"clear"})]),!0)])),_:3},8,["onClick"])):m("",!0)])),_:3},8,["style","onClick"]),"always"===c.cancelButton||x.show&&"auto"===c.cancelButton?(t(),r(S,{key:0,onClick:V.cancel,class:"uni-searchbar__cancel"},{default:n((()=>[u(d(V.cancelTextI18n),1)])),_:1},8,["onClick"])):m("",!0)])),_:3})}],["__scopeId","data-v-d101640d"]]);export{V as _};
