1 |
- import{c as A,a9 as b,m as f,t as L,d as g,b5 as N,r as P,X as T,a as o,ae as h,h as F,p as D,k as O,x as U,w as K,I as M,C as j,A as z}from"./index-fac4d009.js";import{f as k,F as X}from"./index-ff3fe408.js";const[$,l,G]=A("search"),H=b({},k,{label:String,shape:f("square"),leftIcon:f("search"),clearable:L,actionText:String,background:String,showAction:Boolean});var J=g({name:$,props:H,emits:["blur","focus","clear","search","cancel","clickInput","clickLeftIcon","clickRightIcon","update:modelValue"],setup(a,{emit:c,slots:n,attrs:t}){const s=N(),u=P(),m=()=>{n.action||(c("update:modelValue",""),c("cancel"))},p=e=>{e.keyCode===13&&(D(e),c("search",a.modelValue))},d=()=>a.id||`${s}-input`,I=()=>{if(n.label||a.label)return o("label",{class:l("label"),for:d()},[n.label?n.label():a.label])},_=()=>{if(a.showAction){const e=a.actionText||G("cancel");return o("div",{class:l("action"),role:"button",tabindex:0,onClick:m},[n.action?n.action():e])}},y=()=>{var e;return(e=u.value)==null?void 0:e.blur()},C=()=>{var e;return(e=u.value)==null?void 0:e.focus()},S=e=>c("blur",e),v=e=>c("focus",e),V=e=>c("clear",e),w=e=>c("clickInput",e),B=e=>c("clickLeftIcon",e),x=e=>c("clickRightIcon",e),R=Object.keys(k),E=()=>{const e=b({},t,h(a,R),{id:d()}),i=q=>c("update:modelValue",q);return o(X,F({ref:u,type:"search",class:l("field"),border:!1,onBlur:S,onFocus:v,onClear:V,onKeypress:p,onClickInput:w,onClickLeftIcon:B,onClickRightIcon:x,"onUpdate:modelValue":i},e),h(n,["left-icon","right-icon"]))};return T({focus:C,blur:y}),()=>{var e;return o("div",{class:l({"show-action":a.showAction}),style:{background:a.background}},[(e=n.left)==null?void 0:e.call(n),o("div",{class:l("content",a.shape)},[I(),E()]),_()])}}});const Q=O(J),W="_white_1oqt0_25",Y="_transparent_1oqt0_28",Z="_searchBtn_1oqt0_40",r={"m-search":"_m-search_1oqt0_1",default:"_default_1oqt0_22",white:W,transparent:Y,searchBtn:Z},ee=""+new URL("icon-search-d43eb2c3.svg",import.meta.url).href,ne=g({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"},searchIcon:{type:String,default:ee},inputBackground:{type:String,default:"default"}},emits:["search"],setup(a,{slots:c,emit:n}){const t=U({search:a.modelValue||""});return K(()=>a.modelValue,()=>{t.search=a.modelValue}),()=>o(Q,{class:[r["m-search"],r[a.inputBackground]],shape:a.shape,background:a.background,placeholder:a.placeholder,disabled:a.disabled,autofocus:a.autofocus,autocomplete:"off",modelValue:t.search,"onUpdate:modelValue":s=>t.search=s,clearTrigger:"always",onClear:()=>{console.log("clear"),t.search="",n("search",t.search)},onSearch:()=>n("search",t.search)},{left:()=>c.left&&c.left(),"left-icon":()=>o(M,{name:a.searchIcon,class:r.leftIcon},null),"right-icon":()=>o(j,{disabled:a.disabled,class:r.searchBtn,round:!0,type:"primary",size:"mini",onClick:()=>n("search",t.search)},{default:()=>[z("搜索")]})})}});export{ne as M};
|