index-2a51a0f7.js 4.5 KB

1
  1. import{f as A,F as z}from"./index-6c6fed8e.js";import{j as D,A as g,n as h,v as L,d as b,aJ as V,i as F,g as l,p as f,m as Q,an as Z,aj as O,D as M,O as W,w as J,I as j,B as U,h as N}from"./index-e362c2e8.js";const[G,o,P]=D("search"),K=g({},A,{label:String,shape:h("square"),leftIcon:h("search"),clearable:L,actionText:String,background:String,showAction:Boolean});var _=b({name:G,props:K,emits:["blur","focus","clear","search","cancel","clickInput","clickLeftIcon","clickRightIcon","update:modelValue"],setup(a,{emit:n,slots:c,attrs:t}){const r=V(),u=F(),I=()=>{c.action||(n("update:modelValue",""),n("cancel"))},B=e=>{e.keyCode===13&&(O(e),n("search",a.modelValue))},d=()=>a.id||`${r}-input`,C=()=>{if(c.label||a.label)return l("label",{class:o("label"),for:d()},[c.label?c.label():a.label])},k=()=>{if(a.showAction){const e=a.actionText||P("cancel");return l("div",{class:o("action"),role:"button",tabindex:0,onClick:I},[c.action?c.action():e])}},p=()=>{var e;return(e=u.value)==null?void 0:e.blur()},S=()=>{var e;return(e=u.value)==null?void 0:e.focus()},E=e=>n("blur",e),m=e=>n("focus",e),w=e=>n("clear",e),q=e=>n("clickInput",e),x=e=>n("clickLeftIcon",e),y=e=>n("clickRightIcon",e),R=Object.keys(A),T=()=>{const e=g({},t,f(a,R),{id:d()}),i=v=>n("update:modelValue",v);return l(z,Q({ref:u,type:"search",class:o("field"),border:!1,onBlur:E,onFocus:m,onClear:w,onKeypress:B,onClickInput:q,onClickLeftIcon:x,onClickRightIcon:y,"onUpdate:modelValue":i},e),f(c,["left-icon","right-icon"]))};return Z({focus:S,blur:p}),()=>{var e;return l("div",{class:o({"show-action":a.showAction}),style:{background:a.background}},[(e=c.left)==null?void 0:e.call(c),l("div",{class:o("content",a.shape)},[C(),T()]),k()])}}});const X=M(_),H="_white_q4sn4_25",Y="_transparent_q4sn4_28",$="_searchBtn_q4sn4_40",s={"m-search":"_m-search_q4sn4_1",default:"_default_q4sn4_22",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9CUnnqxJAWAnTfrugB6Ms3S3buWfCAAL/EUpRO+ZxJZ1r47YLzSjj3cAsjoQs+Wpl2IDFzqFxQxzyL+GAjhWHFZEbymeDwW5oBd5OCWsipz9r8qQFuOX2f84bQiK7O8OWXEhq8idNqZuH+vqzQyNQiMIcZnEUwLRIIdDAf3dhyaqTY4aQwgr7Oo2KFS/EWQHb2Vtu69yJqMdvZU4fA0hEgj/IwnI0uz+OGiIM+xnsGDx5QfEL2c6CSh126EwY+I8S2gLl8yFcAyTeMImaV9HY0jssSCo1GYn+dZSerTCghj2g3djOQ+UQlafiwFtJYQeAqTGH2fCiBO2HxROQ1QtpOqhZFBoBtpSN7+EMGSZ2fezJDYEY/n9B2rueQPh88m10TCtMOGAjmlv3WYG/XcDa4SCq/zPKdLnM5sIGFc7+VeR5XMRWTKl7azDbJY4EUR2giJ7x5sDwNstovsjZMKqFhdME/zDA9xDS8Qp3TsRGgBg9wJjuoIJwBQiBay4cQMhUBnHhASIIBJ335WNkt+76Hw4CxdKCzADsAAAAAElFTkSuQmCC",ce=b({name:"m-search",props:{modelValue:{type:String,default:""},shape:{type:String,default:"round"},disabled:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1},placeholder:{type:String,default:"请输入搜索关键词"},background:{type:String,default:"#fff"},inputBackground:{type:String,default:"default"}},emits:["search"],setup(a,{slots:n,emit:c}){const t=W({search:a.modelValue||""});return J(()=>a.modelValue,()=>{t.search=a.modelValue}),()=>l(X,{class:[s["m-search"],s[a.inputBackground]],shape:a.shape,background:a.background,placeholder:a.placeholder,disabled:a.disabled,autofocus:a.autofocus,autocomplete:"off",modelValue:t.search,"onUpdate:modelValue":r=>t.search=r,clearTrigger:"always",onClear:()=>{console.log("clear"),t.search="",c("search",t.search)},onSearch:()=>c("search",t.search)},{left:()=>n.left&&n.left(),"left-icon":()=>l(j,{name:ee,class:s.leftIcon},null),"right-icon":()=>l(U,{disabled:a.disabled,class:s.searchBtn,round:!0,type:"primary",size:"mini",onClick:()=>c("search",t.search)},{default:()=>[N("搜索")]})})}});export{ce as M};