index-575d1b2d.js 4.5 KB

1
  1. import{f as A,F as z}from"./index-dbc03ded.js";import{j as D,A as g,n as h,v as L,d as b,aG as V,i as F,g as l,p as f,m as Q,ap as Z,al as O,D as M,O as W,w as J,I as U,B as j,h as N}from"./index-1d4a9afa.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:c,slots:n,attrs:t}){const r=V(),u=F(),I=()=>{n.action||(c("update:modelValue",""),c("cancel"))},B=e=>{e.keyCode===13&&(O(e),c("search",a.modelValue))},d=()=>a.id||`${r}-input`,C=()=>{if(n.label||a.label)return l("label",{class:o("label"),for:d()},[n.label?n.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},[n.action?n.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=>c("blur",e),m=e=>c("focus",e),w=e=>c("clear",e),q=e=>c("clickInput",e),x=e=>c("clickLeftIcon",e),y=e=>c("clickRightIcon",e),R=Object.keys(A),T=()=>{const e=g({},t,f(a,R),{id:d()}),i=v=>c("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(n,["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=n.left)==null?void 0:e.call(n),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",white: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UnnqxJAWAnTfrugB6Ms3S3buWfCAAL/EUpRO+ZxJZ1r47YLzSjj3cAsjoQs+Wpl2IDFzqFxQxzyL+GAjhWHFZEbymeDwW5oBd5OCWsipz9r8qQFuOX2f84bQiK7O8OWXEhq8idNqZuH+vqzQyNQiMIcZnEUwLRIIdDAf3dhyaqTY4aQwgr7Oo2KFS/EWQHb2Vtu69yJqMdvZU4fA0hEgj/IwnI0uz+OGiIM+xnsGDx5QfEL2c6CSh126EwY+I8S2gLl8yFcAyTeMImaV9HY0jssSCo1GYn+dZSerTCghj2g3djOQ+UQlafiwFtJYQeAqTGH2fCiBO2HxROQ1QtpOqhZFBoBtpSN7+EMGSZ2fezJDYEY/n9B2rueQPh88m10TCtMOGAjmlv3WYG/XcDa4SCq/zPKdLnM5sIGFc7+VeR5XMRWTKl7azDbJY4EUR2giJ7x5sDwNstovsjZMKqFhdME/zDA9xDS8Qp3TsRGgBg9wJjuoIJwBQiBay4cQMhUBnHhASIIBJ335WNkt+76Hw4CxdKCzADsAAAAAElFTkSuQmCC",ne=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:c,emit:n}){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="",n("search",t.search)},onSearch:()=>n("search",t.search)},{left:()=>c.left&&c.left(),"left-icon":()=>l(U,{name:ee,class:s.leftIcon},null),"right-icon":()=>l(j,{disabled:a.disabled,class:s.searchBtn,round:!0,type:"primary",size:"mini",onClick:()=>n("search",t.search)},{default:()=>[N("搜索")]})})}});export{ne as M};