import{F as P,f as d}from"./index-W6Us0Nev.js";import{u as V}from"./use-id-AqrWcv5P.js";import{b7 as _,am as f,bk as F,bH as L,N as o,cI as i,cA as T,r as B,by as D,bm as u,bp as O,aq as q}from"./index-xnhGKCfe.js";const[K,t,j]=F("search"),H=f({},d,{label:String,shape:u("square"),leftIcon:u("search"),clearable:D,actionText:String,background:String,showAction:Boolean});var M=_({name:K,props:H,emits:["blur","focus","clear","search","cancel","clickInput","clickLeftIcon","clickRightIcon","update:modelValue"],setup(n,{emit:c,slots:a,attrs:b}){const h=V(),l=B(),k=()=>{a.action||(c("update:modelValue",""),c("cancel"))},I=e=>{e.keyCode===13&&(O(e),c("search",n.modelValue))},r=()=>n.id||`${h}-input`,p=()=>{if(a.label||n.label)return o("label",{class:t("label"),for:r(),"data-allow-mismatch":"attribute"},[a.label?a.label():n.label])},g=()=>{if(n.showAction){const e=n.actionText||j("cancel");return o("div",{class:t("action"),role:"button",tabindex:0,onClick:k},[a.action?a.action():e])}},m=()=>{var e;return(e=l.value)==null?void 0:e.blur()},C=()=>{var e;return(e=l.value)==null?void 0:e.focus()},v=e=>c("blur",e),w=e=>c("focus",e),x=e=>c("clear",e),y=e=>c("clickInput",e),E=e=>c("clickLeftIcon",e),R=e=>c("clickRightIcon",e),S=Object.keys(d),A=()=>{const e=f({},b,i(n,S),{id:r()}),s=N=>c("update:modelValue",N);return o(P,T({ref:l,type:"search",class:t("field",{"with-message":e.errorMessage}),border:!1,onBlur:v,onFocus:w,onClear:x,onKeypress:I,onClickInput:y,onClickLeftIcon:E,onClickRightIcon:R,"onUpdate:modelValue":s},e),i(a,["left-icon","right-icon"]))};return L({focus:C,blur:m}),()=>{var e;return o("div",{class:t({"show-action":n.showAction}),style:{background:n.background}},[(e=a.left)==null?void 0:e.call(a),o("div",{class:t("content",n.shape)},[p(),A()]),g()])}}});const G=q(M);export{G as S};
