lcny-vue3-antd-admin/dist/assets/index.a5169cd8.js

2 lines
2.7 KiB
JavaScript

var m=(t,e,n)=>new Promise((s,u)=>{var l=a=>{try{r(n.next(a))}catch(c){u(c)}},o=a=>{try{r(n.throw(a))}catch(c){u(c)}},r=a=>a.done?s(a.value):Promise.resolve(a.value).then(l,o);r((n=n.apply(t,e)).next())});import{v as I,ay as z,ae as C,f as S,aq as h,al as F,k as d,az as A,s as f,aA as k,a as g,B as N,c as T,q as y,aB as D,aC as p,o as w,j as _,y as v,z as j,t as q,aD as $,b as E,aE as O,aF as P,aG as R,aH as L,aI as V,p as G,L as B}from"./index.96e740c6.js";function H(t,e="value",n="change",s){const u=A(),l=u==null?void 0:u.emit,o=I({value:t[e]}),r=z(o),a=i=>{o.value=i};return C(()=>{o.value=t[e]}),[S({get(){return o.value},set(i){h(i,r.value)||(o.value=i,l==null||l(n,i,...F(d(s))||[]))}}),a,r]}function U(t){const e=f(t),n=f(!1);let s;function u(){s&&window.clearInterval(s)}function l(){n.value=!1,u(),s=null}function o(){d(n)||!!s||(n.value=!0,s=setInterval(()=>{d(e)===1?(l(),e.value=t):e.value-=1},1e3))}function r(){e.value=t,l()}function a(){r(),o()}return k(()=>{r()}),{start:o,reset:r,restart:a,clear:u,stop:l,currentCount:e,isStart:n}}const J={value:{type:[Object,Number,String,Array]},count:{type:Number,default:60},beforeStartFunc:{type:Function,default:null}},K=g({name:"CountButton",components:{Button:N},props:J,setup(t){const e=f(!1),{currentCount:n,isStart:s,start:u,reset:l}=U(t.count),{t:o}=T(),r=S(()=>d(s)?o("component.countdown.sendText",[d(n)]):o("component.countdown.normalText"));C(()=>{t.value===void 0&&l()});function a(){return m(this,null,function*(){const{beforeStartFunc:c}=t;if(c&&D(c)){e.value=!0;try{(yield c())&&u()}finally{e.value=!1}}else u()})}return{handleStart:a,currentCount:n,loading:e,getButtonText:r,isStart:s}}});function M(t,e,n,s,u,l){const o=p("Button");return w(),_(o,$(t.$attrs,{disabled:t.isStart,onClick:t.handleStart,loading:t.loading}),{default:v(()=>[j(q(t.getButtonText),1)]),_:1},16,["disabled","onClick","loading"])}var b=y(K,[["render",M]]);const Q={value:{type:String},size:{type:String,validator:t=>["default","large","small"].includes(t)},count:{type:Number,default:60},sendCodeApi:{type:Function,default:null}},W=g({name:"CountDownInput",components:{CountButton:b},inheritAttrs:!1,props:Q,setup(t){const{prefixCls:e}=E("countdown-input"),[n]=H(t);return{prefixCls:e,state:n}}});function X(t,e,n,s,u,l){const o=p("CountButton"),r=p("a-input");return w(),_(r,$(t.$attrs,{class:t.prefixCls,size:t.size,value:t.state}),O({addonAfter:v(()=>[G(o,{size:t.size,count:t.count,value:t.state,beforeStartFunc:t.sendCodeApi},null,8,["size","count","value","beforeStartFunc"])]),_:2},[P(Object.keys(t.$slots).filter(a=>a!=="addonAfter"),a=>({name:a,fn:v(c=>[R(t.$slots,a,L(V(c||{})))])}))]),1040,["class","size","value"])}var Y=y(W,[["render",X]]);const tt=B(Y);B(b);export{tt as C,H as u};