import{f as d,F as _}from"./index-fc073ec7.js";import{u as A}from"./use-id-22cfdfcf.js";import{c as F,J as f,a2 as i,D as L,d as N,a8 as u,p as D,w as T}from"./index-ae60edf9.js";import{d as B,b as O,$ as o,am as K}from"./@vue-cb50a1c4.js";const[$,t,j]=F("search"),q=f({},d,{label:String,shape:i("square"),leftIcon:i("search"),clearable:L,actionText:String,background:String,showAction:Boolean});var J=B({name:$,props:q,emits:["blur","focus","clear","search","cancel","clickInput","clickLeftIcon","clickRightIcon","update:modelValue"],setup(n,{emit:c,slots:a,attrs:b}){const h=A(),l=O(),k=()=>{a.action||(c("update:modelValue",""),c("cancel"))},p=e=>{e.keyCode===13&&(D(e),c("search",n.modelValue))},r=()=>n.id||`${h}-input`,I=()=>{if(a.label||n.label)return o("label",{class:t("label"),for:r()},[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),x=e=>c("focus",e),w=e=>c("clear",e),E=e=>c("clickInput",e),R=e=>c("clickLeftIcon",e),S=e=>c("clickRightIcon",e),y=Object.keys(d),P=()=>{const e=f({},b,u(n,y),{id:r()}),s=V=>c("update:modelValue",V);return o(_,K({ref:l,type:"search",class:t("field",{"with-message":e.errorMessage}),border:!1,onBlur:v,onFocus:x,onClear:w,onKeypress:p,onClickInput:E,onClickLeftIcon:R,onClickRightIcon:S,"onUpdate:modelValue":s},e),u(a,["left-icon","right-icon"]))};return N({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)},[I(),P()]),g()])}}});const H=T(J);export{H as S};
