index-15874193.js 1.7 KB

1
  1. import{f as a,F as e}from"./index-7c808196.js";import{x as l,a6 as c,C as o,E as n,d as s,ae as t,H as r,ad as i,a as u,az as d,G as b,aF as f,w as p}from"./index-d31722d5.js";const[h,k,m]=l("search"),g=p(s({name:h,props:c({},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(l,{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",l.modelValue))},I=()=>l.id||"".concat(p,"-input"),x=()=>{if(n.label||l.label)return u("label",{"class":k("label"),"for":I()},[n.label?n.label():l.label])},C=()=>{if(l.showAction){const a=l.actionText||m("cancel");return u("div",{"class":k("action"),role:"button",tabindex:0,onClick:g},[n.action?n.action():a])}},w=a=>o("blur",a),y=a=>o("focus",a),V=a=>o("clear",a),S=a=>o("clickInput",a),j=a=>o("clickLeftIcon",a),A=a=>o("clickRightIcon",a),F=Object.keys(a),L=()=>{const a=c({},s,d(l,F),{id:I()});return u(e,b({ref:h,type:"search","class":k("field",{"with-message":a.errorMessage}),border:!1,onBlur:w,onFocus:y,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":l.showAction}),style:{background:l.background}},[null==(a=n.left)?void 0:a.call(n),u("div",{"class":k("content",l.shape)},[x(),L()]),C()])}}}));export{g as S};