2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
import{d as $,t as X,g as S,i as g,ak as je,al as pe,b as d,Z as Oe,j as q,ap as Ne,ag as Me,q as c,m as O,b2 as se,aJ as Y,aI as Re,D as Fe,a4 as Te,am as Ae,b3 as We,a8 as De,aA as Ge,F as Ze,_ as N,c as ee,o as _,f as M,a as me,n as ne,k as he,e as E,h as j,T as qe,A as x,u as I,C as He,N as ue,l as Ke,y as Ue,z as Je}from"./index-C4UKuwCQ.js";import{u as Qe,p as Xe,F as Ye,E as en,I as ce}from"./index-BAOCFoRq.js";import{u as nn}from"./use-merge-state-BIwn2CEf.js";var tn=Object.defineProperty,de=Object.getOwnPropertySymbols,an=Object.prototype.hasOwnProperty,ln=Object.prototype.propertyIsEnumerable,ve=(e,a,n)=>a in e?tn(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,fe=(e,a)=>{for(var n in a||(a={}))an.call(a,n)&&ve(e,n,a[n]);if(de)for(var n of de(a))ln.call(a,n)&&ve(e,n,a[n]);return e},B=$({name:"Input",inheritAttrs:!1,props:{modelValue:String,defaultValue:{type:String,default:""},size:{type:String},allowClear:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},error:{type:Boolean,default:!1},placeholder:String,maxLength:{type:[Number,Object],default:0},showWordLimit:{type:Boolean,default:!1},wordLength:{type:Function},wordSlice:{type:Function},inputAttrs:{type:Object},type:{type:String,default:"text"}},emits:{"update:modelValue":e=>!0,input:(e,a)=>!0,change:(e,a)=>!0,pressEnter:e=>!0,clear:e=>!0,focus:e=>!0,blur:e=>!0},setup(e,{emit:a,slots:n,attrs:i}){const{size:v,disabled:f,error:o,modelValue:b}=X(e),r=S("input"),s=g(),{mergedSize:te,mergedDisabled:p,mergedError:k,feedback:L,eventHandlers:C}=je({size:v,disabled:f,error:o}),{mergedSize:ae}=pe(te),[ye,be]=Qe(s),R=g(e.defaultValue),h=d(()=>{var t;return(t=e.modelValue)!=null?t:R.value});Oe(b,t=>{(Ae(t)||We(t))&&(R.value="")});let F=h.value;const T=g(!1),ge=d(()=>e.allowClear&&!e.readonly&&!p.value&&!!h.value),z=g(!1),le=g(""),w=t=>{var l;return Me(e.wordLength)?e.wordLength(t):(l=t.length)!=null?l:0},P=d(()=>w(h.value)),oe=d(()=>k.value||!!(q(e.maxLength)&&e.maxLength.errorOnly&&P.value>m.value)),A=d(()=>q(e.maxLength)&&!!e.maxLength.errorOnly),m=d(()=>q(e.maxLength)?e.maxLength.length:e.maxLength),_e=d(()=>{const t=w("a");return Math.floor(m.value/t)}),W=t=>{var l,u;m.value&&!A.value&&w(t)>m.value&&(t=(u=(l=e.wordSlice)==null?void 0:l.call(e,t,m.value))!=null?u:t.slice(0,_e.value)),R.value=t,a("update:modelValue",t)},$e=t=>{s.value&&t.target!==s.value&&(t.preventDefault(),s.value.focus())},D=(t,l)=>{var u,y;t!==F&&(F=t,a("change",t,l),(y=(u=C.value)==null?void 0:u.onChange)==null||y.call(u,l))},ke=t=>{var l,u;T.value=!0,F=h.value,a("focus",t),(u=(l=C.value)==null?void 0:l.onFocus)==null||u.call(l,t)},Ce=t=>{var l,u;T.value=!1,D(h.value,t),a("blur",t),(u=(l=C.value)==null?void 0:l.onBlur)==null||u.call(l,t)},G=t=>{var l,u,y;const{value:Z,selectionStart:Ve,selectionEnd:Ee}=t.target;if(t.type==="compositionend"){if(z.value=!1,le.value="",m.value&&!A.value&&P.value>=m.value&&w(Z)>m.value&&Ve===Ee){V();return}W(Z),a("input",Z,t),(u=(l=C.value)==null?void 0:l.onInput)==null||u.call(l,t),V()}else z.value=!0,le.value=h.value+((y=t.data)!=null?y:"")},V=()=>{ye(),Te(()=>{s.value&&h.value!==s.value.value&&(s.value.value=h.value,be())})},we=t=>{var l,u;const{value:y}=t.target;if(!z.value){if(m.value&&!A.value&&P.value>=m.value&&w(y)>m.value&&t.inputType==="insertText"){V();return}W(y),a("input",y,t),(u=(l=C.value)==null?void 0:l.onInput)==null||u.call(l,t),V()}},xe=t=>{W(""),D("",t),a("clear",t)},Ie=t=>{const l=t.key||t.code;!z.value&&l===en.key&&(D(h.value,t),a("pressEnter",t))},Be=d(()=>[`${r}-outer`,`${r}-outer-size-${ae.value}`,{[`${r}-outer-has-suffix`]:!!n.suffix,[`${r}-outer-disabled`]:p.value}]),Se=d(()=>[`${r}-wrapper`,{[`${r}-error`]:oe.value,[`${r}-disabled`]:p.value,[`${r}-focus`]:T.value}]),Le=d(()=>[r,`${r}-size-${ae.value}`]),re=d(()=>Ne(i,se)),ze=d(()=>Xe(i,se)),Pe=d(()=>{const t=fe(fe({},ze.value),e.inputAttrs);return oe.value&&(t["aria-invalid"]=!0),t}),ie=t=>{var l;return c("span",O({class:Se.value,onMousedown:$e},t?void 0:re.value),[n.prefix&&c("span",{class:`${r}-prefix`},[n.prefix()]),c("input",O({ref:s,class:Le.value,value:h.value,type:e.type,placeholder:e.placeholder,readonly:e.readonly,disabled:p.value,onInput:we,onKeydown:Ie,onFocus:ke,onBlur:Ce,onCompositionstart:G,onCompositionupdate:G,onCompositionend:G},Pe.value),null),ge.value&&c(Y,{prefix:r,class:`${r}-clear-btn`,onClick:xe},{default:()=>[c(Re,null,null)]}),(n.suffix||!!e.maxLength&&e.showWordLimit||!!L.value)&&c("span",{class:[`${r}-suffix`,{[`${r}-suffix-has-feedback`]:L.value}]},[!!e.maxLength&&e.showWordLimit&&c("span",{class:`${r}-word-limit`},[P.value,Fe("/"),m.value]),(l=n.suffix)==null?void 0:l.call(n),!!L.value&&c(Ye,{type:L.value},null)])])};return{inputRef:s,render:()=>n.prepend||n.append?c("span",O({class:Be.value},re.value),[n.prepend&&c("span",{class:`${r}-prepend`},[n.prepend()]),ie(!0),n.append&&c("span",{class:`${r}-append`},[n.append()])]):ie()}},methods:{focus(){var e;(e=this.inputRef)==null||e.focus()},blur(){var e;(e=this.inputRef)==null||e.blur()}},render(){return this.render()}}),H=$({name:"InputSearch",props:{searchButton:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},size:{type:String},buttonText:{type:String},buttonProps:{type:Object}},emits:{search:(e,a)=>!0},setup(e,{emit:a,slots:n}){const{size:i}=X(e),v=S("input-search"),{mergedSize:f}=pe(i),o=g(),b=p=>{o.value.inputRef&&a("search",o.value.inputRef.value,p)},r=()=>{var p;return c(Ze,null,[e.loading?c(Ge,null,null):c(Y,{onClick:b},{default:()=>[c(ce,null,null)]}),(p=n.suffix)==null?void 0:p.call(n)])},s=()=>{var p;let k={};return e.buttonText||n["button-default"]||n["button-icon"]?k={default:(p=n["button-default"])!=null?p:e.buttonText?()=>e.buttonText:void 0,icon:n["button-icon"]}:k={icon:()=>c(ce,null,null)},c(De,O({type:"primary",class:`${v}-btn`,disabled:e.disabled,size:f.value,loading:e.loading},e.buttonProps,{onClick:b}),k)};return{inputRef:o,render:()=>c(B,{ref:o,class:v,size:f.value,disabled:e.disabled},{prepend:n.prepend,prefix:n.prefix,suffix:e.searchButton?n.suffix:r,append:e.searchButton?s:n.append})}},methods:{focus(){var e;(e=this.inputRef)==null||e.focus()},blur(){var e;(e=this.inputRef)==null||e.blur()}},render(){return this.render()}});const on=$({name:"IconEye",props:{size:{type:[Number,String]},strokeWidth:{type:Number,default:4},strokeLinecap:{type:String,default:"butt",validator:e=>["butt","round","square"].includes(e)},strokeLinejoin:{type:String,default:"miter",validator:e=>["arcs","bevel","miter","miter-clip","round"].includes(e)},rotate:Number,spin:Boolean},emits:{click:e=>!0},setup(e,{emit:a}){const n=S("icon"),i=d(()=>[n,`${n}-eye`,{[`${n}-spin`]:e.spin}]),v=d(()=>{const o={};return e.size&&(o.fontSize=he(e.size)?`${e.size}px`:e.size),e.rotate&&(o.transform=`rotate(${e.rotate}deg)`),o});return{cls:i,innerStyle:v,onClick:o=>{a("click",o)}}}}),rn=["stroke-width","stroke-linecap","stroke-linejoin"],sn=M("path",{"clip-rule":"evenodd",d:"M24 37c6.627 0 12.627-4.333 18-13-5.373-8.667-11.373-13-18-13-6.627 0-12.627 4.333-18 13 5.373 8.667 11.373 13 18 13Z"},null,-1),un=M("path",{d:"M29 24a5 5 0 1 1-10 0 5 5 0 0 1 10 0Z"},null,-1),cn=[sn,un];function dn(e,a,n,i,v,f){return _(),ee("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",class:ne(e.cls),style:me(e.innerStyle),"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin,onClick:a[0]||(a[0]=(...o)=>e.onClick&&e.onClick(...o))},cn,14,rn)}var K=N(on,[["render",dn]]);const vn=Object.assign(K,{install:(e,a)=>{var n;const i=(n=a==null?void 0:a.iconPrefix)!=null?n:"";e.component(i+K.name,K)}}),fn=$({name:"IconEyeInvisible",props:{size:{type:[Number,String]},strokeWidth:{type:Number,default:4},strokeLinecap:{type:String,default:"butt",validator:e=>["butt","round","square"].includes(e)},strokeLinejoin:{type:String,default:"miter",validator:e=>["arcs","bevel","miter","miter-clip","round"].includes(e)},rotate:Number,spin:Boolean},emits:{click:e=>!0},setup(e,{emit:a}){const n=S("icon"),i=d(()=>[n,`${n}-eye-invisible`,{[`${n}-spin`]:e.spin}]),v=d(()=>{const o={};return e.size&&(o.fontSize=he(e.size)?`${e.size}px`:e.size),e.rotate&&(o.transform=`rotate(${e.rotate}deg)`),o});return{cls:i,innerStyle:v,onClick:o=>{a("click",o)}}}}),pn=["stroke-width","stroke-linecap","stroke-linejoin"],mn=M("path",{d:"M14 14.5c-2.69 2-5.415 5.33-8 9.5 5.373 8.667 11.373 13 18 13 3.325 0 6.491-1.09 9.5-3.271M17.463 12.5C19 11 21.75 11 24 11c6.627 0 12.627 4.333 18 13-1.766 2.848-3.599 5.228-5.5 7.14"},null,-1),hn=M("path",{d:"M29 24a5 5 0 1 1-10 0 5 5 0 0 1 10 0ZM6.852 7.103l34.294 34.294"},null,-1),yn=[mn,hn];function bn(e,a,n,i,v,f){return _(),ee("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",class:ne(e.cls),style:me(e.innerStyle),"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin,onClick:a[0]||(a[0]=(...o)=>e.onClick&&e.onClick(...o))},yn,14,pn)}var U=N(fn,[["render",bn]]);const gn=Object.assign(U,{install:(e,a)=>{var n;const i=(n=a==null?void 0:a.iconPrefix)!=null?n:"";e.component(i+U.name,U)}}),_n=$({name:"InputPassword",components:{IconEye:vn,IconEyeInvisible:gn,AIconHover:Y,AInput:B},props:{visibility:{type:Boolean,default:void 0},defaultVisibility:{type:Boolean,default:!0},invisibleButton:{type:Boolean,default:!0}},emits:["visibility-change","update:visibility"],setup(e,{emit:a}){const{visibility:n,defaultVisibility:i}=X(e),v=g(),f=()=>{r(!o.value)},[o,b]=nn(i.value,Ke({value:n})),r=s=>{s!==o.value&&(a("visibility-change",s),a("update:visibility",s),b(s))};return{inputRef:v,mergedVisible:o,handleInvisible:f}},methods:{focus(){var e;(e=this.inputRef)==null||e.focus()},blur(){var e;(e=this.inputRef)==null||e.blur()}}});function $n(e,a,n,i,v,f){const o=E("icon-eye"),b=E("icon-eye-invisible"),r=E("a-icon-hover"),s=E("a-input");return _(),j(s,{ref:"inputRef",type:e.mergedVisible?"password":"text"},qe({_:2},[e.$slots.prepend?{name:"prepend",fn:x(()=>[I(e.$slots,"prepend")])}:void 0,e.$slots.prefix?{name:"prefix",fn:x(()=>[I(e.$slots,"prefix")])}:void 0,e.invisibleButton||e.$slots.suffix?{name:"suffix",fn:x(()=>[e.invisibleButton?(_(),j(r,{key:0,onClick:e.handleInvisible,onMousedown:a[0]||(a[0]=ue(()=>{},["prevent"])),onMouseup:a[1]||(a[1]=ue(()=>{},["prevent"]))},{default:x(()=>[e.mergedVisible?(_(),j(b,{key:1})):(_(),j(o,{key:0}))]),_:1},8,["onClick"])):He("v-if",!0),I(e.$slots,"suffix")])}:void 0,e.$slots.append?{name:"append",fn:x(()=>[I(e.$slots,"append")])}:void 0]),1032,["type"])}var J=N(_n,[["render",$n]]);const kn=$({name:"InputGroup",setup(){return{prefixCls:S("input-group")}}});function Cn(e,a,n,i,v,f){return _(),ee("div",{class:ne(e.prefixCls)},[I(e.$slots,"default")],2)}var Q=N(kn,[["render",Cn]]);const Sn=Object.assign(B,{Search:H,Password:J,Group:Q,install:(e,a)=>{Ue(e,a);const n=Je(a);e.component(n+B.name,B),e.component(n+Q.name,Q),e.component(n+H.name,H),e.component(n+J.name,J)}});export{Sn as I,J as a};
|