import{f as a,F as e}from"./index-5d72a69d.js";import{y as c,a5 as l,D as o,G as n,d as s,ad as t,I as r,ac as i,a as u,ay as d,H as b,aE as f,w as p}from"./index-4bd11d60.js";const[h,k,m]=c("search"),g=p(s({name:h,props:l({},a,{label:String,shape:o("square"),leftIcon:o("search"),clearable:n,actionText:String,background:String,showAction:Boolean}),emits:["blur","focus","clear","search","cancel","clickInput","clickLeftIcon","clickRightIcon","update:modelValue"],setup(c,{emit:o,slots:n,attrs:s}){const p=t(),h=r(),g=()=>{n.action||(o("update:modelValue",""),o("cancel"))},v=a=>{13===a.keyCode&&(f(a),o("search",c.modelValue))},I=()=>c.id||"".concat(p,"-input"),y=()=>{if(n.label||c.label)return u("label",{"class":k("label"),"for":I()},[n.label?n.label():c.label])},w=()=>{if(c.showAction){const a=c.actionText||m("cancel");return u("div",{"class":k("action"),role:"button",tabindex:0,onClick:g},[n.action?n.action():a])}},x=a=>o("blur",a),C=a=>o("focus",a),V=a=>o("clear",a),S=a=>o("clickInput",a),j=a=>o("clickLeftIcon",a),A=a=>o("clickRightIcon",a),L=Object.keys(a),R=()=>{const a=l({},s,d(c,L),{id:I()});return u(e,b({ref:h,type:"search","class":k("field",{"with-message":a.errorMessage}),border:!1,onBlur:x,onFocus:C,onClear:V,onKeypress:v,onClickInput:S,onClickLeftIcon:j,onClickRightIcon:A,"onUpdate:modelValue":a=>o("update:modelValue",a)},a),d(n,["left-icon","right-icon"]))};return i({focus:()=>{var a;return null==(a=h.value)?void 0:a.focus()},blur:()=>{var a;return null==(a=h.value)?void 0:a.blur()}}),()=>{var a;return u("div",{"class":k({"show-action":c.showAction}),style:{background:c.background}},[null==(a=n.left)?void 0:a.call(n),u("div",{"class":k("content",c.shape)},[y(),R()]),w()])}}}));export{g as S};
