| 1 |
- import{c as E,A as ke,e as R,F as ee,n as I,G as X,J as K,b as ue,K as q,D as de,H as G,m as H,t as Y,l as Oe,u as Ce,M as Fe,N as L,p as ie,O as ze,w as z,g as fe,f as he,I as me,v as Ue,P as Le,Q as Pe,R as Se,S as ge,T as $e,U as Ke,V as We,W as je,k as be,X as Ge}from"./index-c1f44820.js";import{d as _,r as S,a as p,D as qe,c as m,y as F,z as te,m as ne,o as Xe,E as Ze,G as Je,T as pe,n as Me,w as Qe,v as et}from"./index-ebd06049.js";import{u as ae}from"./use-expose-cd5a8a20.js";import{L as Ie}from"./index-8c362873.js";import{u as Ee}from"./index-1f15f5f3.js";import{C as tt}from"./index-b8adef18.js";import{P as nt}from"./index-e6307542.js";import{u as at}from"./index-edccefc2.js";import{u as ot}from"./use-placeholder-efd5789a.js";const[lt,V,xe]=E("picker"),Be=e=>e.find(n=>!n.disabled)||e[0];function st(e,n){const t=e[0];if(t){if(Array.isArray(t))return"multiple";if(n.children in t)return"cascade"}return"default"}function Q(e,n){n=ee(n,0,e.length);for(let t=n;t<e.length;t++)if(!e[t].disabled)return t;for(let t=n-1;t>=0;t--)if(!e[t].disabled)return t;return 0}const ye=(e,n,t)=>n!==void 0&&!!e.find(s=>s[t.value]===n);function re(e,n,t){const s=e.findIndex(r=>r[t.value]===n),a=Q(e,s);return e[a]}function ct(e,n,t){const s=[];let a={[n.children]:e},r=0;for(;a&&a[n.children];){const d=a[n.children],c=t.value[r];if(a=ke(c)?re(d,c,n):void 0,!a&&d.length){const v=Be(d)[n.value];a=re(d,v,n)}r++,s.push(d)}return s}function it(e){const{transform:n}=window.getComputedStyle(e),t=n.slice(7,n.length-1).split(", ")[5];return Number(t)}function rt(e){return R({text:"text",value:"value",children:"children"},e)}const Te=200,De=300,ut=15,[Ve,le]=E("picker-column"),He=Symbol(Ve);var dt=_({name:Ve,props:{value:I,fields:X(Object),options:K(),readonly:Boolean,allowHtml:Boolean,optionHeight:X(Number),swipeDuration:X(I),visibleOptionNum:X(I)},emits:["change","clickOption","scrollInto"],setup(e,{emit:n,slots:t}){let s,a,r,d,c;const v=S(),k=S(),h=S(0),T=S(0),w=Ee(),x=()=>e.options.length,O=()=>e.optionHeight*(+e.visibleOptionNum-1)/2,P=D=>{let l=Q(e.options,D);const f=-l*e.optionHeight,b=()=>{l>x()-1&&(l=Q(e.options,D));const A=e.options[l][e.fields.value];A!==e.value&&n("change",A)};s&&f!==h.value?c=b:b(),h.value=f},C=()=>e.readonly||!e.options.length,o=D=>{s||C()||(c=null,T.value=Te,P(D),n("clickOption",e.options[D]))},u=D=>ee(Math.round(-D/e.optionHeight),0,x()-1),y=p(()=>u(h.value)),i=(D,l)=>{const f=Math.abs(D/l);D=h.value+f/.003*(D<0?-1:1);const b=u(D);T.value=+e.swipeDuration,P(b)},g=()=>{s=!1,T.value=0,c&&(c(),c=null)},$=D=>{if(!C()){if(w.start(D),s){const l=it(k.value);h.value=Math.min(0,l-O())}T.value=0,a=h.value,r=Date.now(),d=a,c=null}},N=D=>{if(C())return;w.move(D),w.isVertical()&&(s=!0,de(D,!0));const l=ee(a+w.deltaY.value,-(x()*e.optionHeight),e.optionHeight),f=u(l);f!==y.value&&n("scrollInto",e.options[f]),h.value=l;const b=Date.now();b-r>De&&(r=b,d=l)},M=()=>{if(C())return;const D=h.value-d,l=Date.now()-r;if(l<De&&Math.abs(D)>ut){i(D,l);return}const b=u(h.value);T.value=Te,P(b),setTimeout(()=>{s=!1},0)},U=()=>{const D={height:`${e.optionHeight}px`};return e.options.map((l,f)=>{const b=l[e.fields.text],{disabled:A}=l,W=l[e.fields.value],Ne={role:"button",style:D,tabindex:A?-1:0,class:[le("item",{disabled:A,selected:W===e.value}),l.className],onClick:()=>o(f)},Ye={class:"van-ellipsis",[e.allowHtml?"innerHTML":"textContent"]:b};return m("li",Ne,[t.option?t.option(l,f):m("div",Ye,null)])})};return ue(He),ae({stopMomentum:g}),qe(()=>{const D=s?Math.floor(-h.value/e.optionHeight):e.options.findIndex(b=>b[e.fields.value]===e.value),l=Q(e.options,D),f=-l*e.optionHeight;s&&l<D&&g(),h.value=f}),q("touchmove",N,{target:v}),()=>m("div",{ref:v,class:le(),onTouchstartPassive:$,onTouchend:M,onTouchcancel:M},[m("ul",{ref:k,style:{transform:`translate3d(0, ${h.value+O()}px, 0)`,transitionDuration:`${T.value}ms`,transitionProperty:T.value?"all":"none"},class:le("wrapper"),onTransitionend:g},[U()])])}});const[ft]=E("picker-toolbar"),oe={title:String,cancelButtonText:String,confirmButtonText:String},mt=["cancel","confirm","title","toolbar"],vt=Object.keys(oe);var ht=_({name:ft,props:oe,emits:["confirm","cancel"],setup(e,{emit:n,slots:t}){const s=()=>{if(t.title)return t.title();if(e.title)return m("div",{class:[V("title"),"van-ellipsis"]},[e.title])},a=()=>n("cancel"),r=()=>n("confirm"),d=()=>{const v=e.cancelButtonText||xe("cancel");return m("button",{type:"button",class:[V("cancel"),G],onClick:a},[t.cancel?t.cancel():v])},c=()=>{const v=e.confirmButtonText||xe("confirm");return m("button",{type:"button",class:[V("confirm"),G],onClick:r},[t.confirm?t.confirm():v])};return()=>m("div",{class:V("toolbar")},[t.toolbar?t.toolbar():[d(),s(),c()]])}});const[gt,tn]=E("picker-group"),bt=Symbol(gt);R({tabs:K(),activeTab:H(0),nextStepText:String},oe);const ve=R({loading:Boolean,readonly:Boolean,allowHtml:Boolean,optionHeight:H(44),showToolbar:Y,swipeDuration:H(1e3),visibleOptionNum:H(6)},oe),xt=R({},ve,{columns:K(),modelValue:K(),toolbarPosition:Oe("top"),columnsFieldNames:Object});var yt=_({name:lt,props:xt,emits:["confirm","cancel","change","scrollInto","clickOption","update:modelValue"],setup(e,{emit:n,slots:t}){const s=S(),a=S(e.modelValue.slice(0)),{parent:r}=ue(bt),{children:d,linkChildren:c}=Ce(He);c();const v=p(()=>rt(e.columnsFieldNames)),k=p(()=>Fe(e.optionHeight)),h=p(()=>st(e.columns,v.value)),T=p(()=>{const{columns:l}=e;switch(h.value){case"multiple":return l;case"cascade":return ct(l,v.value,a);default:return[l]}}),w=p(()=>T.value.some(l=>l.length)),x=p(()=>T.value.map((l,f)=>re(l,a.value[f],v.value))),O=p(()=>T.value.map((l,f)=>l.findIndex(b=>b[v.value.value]===a.value[f]))),P=(l,f)=>{if(a.value[l]!==f){const b=a.value.slice(0);b[l]=f,a.value=b}},C=()=>({selectedValues:a.value.slice(0),selectedOptions:x.value,selectedIndexes:O.value}),o=(l,f)=>{P(f,l),h.value==="cascade"&&a.value.forEach((b,A)=>{const W=T.value[A];ye(W,b,v.value)||P(A,W.length?W[0][v.value.value]:void 0)}),te(()=>{n("change",R({columnIndex:f},C()))})},u=(l,f)=>{const b={columnIndex:f,currentOption:l};n("clickOption",R(C(),b)),n("scrollInto",b)},y=()=>{d.forEach(f=>f.stopMomentum());const l=C();return te(()=>{n("confirm",l)}),l},i=()=>n("cancel",C()),g=()=>T.value.map((l,f)=>m(dt,{value:a.value[f],fields:v.value,options:l,readonly:e.readonly,allowHtml:e.allowHtml,optionHeight:k.value,swipeDuration:e.swipeDuration,visibleOptionNum:e.visibleOptionNum,onChange:b=>o(b,f),onClickOption:b=>u(b,f),onScrollInto:b=>{n("scrollInto",{currentOption:b,columnIndex:f})}},{option:t.option})),$=l=>{if(w.value){const f={height:`${k.value}px`},b={backgroundSize:`100% ${(l-k.value)/2}px`};return[m("div",{class:V("mask"),style:b},null),m("div",{class:[ze,V("frame")],style:f},null)]}},N=()=>{const l=k.value*+e.visibleOptionNum,f={height:`${l}px`};return m("div",{ref:s,class:V("columns"),style:f},[g(),$(l)])},M=()=>{if(e.showToolbar&&!r)return m(ht,ne(ie(e,vt),{onConfirm:y,onCancel:i}),ie(t,mt))};F(T,l=>{l.forEach((f,b)=>{f.length&&!ye(f,a.value[b],v.value)&&P(b,Be(f)[v.value.value])})},{immediate:!0});let U;return F(()=>e.modelValue,l=>{!L(l,a.value)&&!L(l,U)&&(a.value=l.slice(0),U=l.slice(0))},{deep:!0}),F(a,l=>{L(l,e.modelValue)||(U=l.slice(0),n("update:modelValue",U))},{immediate:!0}),q("touchmove",de,{target:s}),ae({confirm:y,getSelectedOptions:()=>x.value}),()=>{var l,f;return m("div",{class:V()},[e.toolbarPosition==="top"?M():null,e.loading?m(Ie,{class:V("loading")},null):null,(l=t["columns-top"])==null?void 0:l.call(t),N(),(f=t["columns-bottom"])==null?void 0:f.call(t),e.toolbarPosition==="bottom"?M():null])}}});const Tt=z(yt);function Dt(e,n){let t=null,s=0;return function(...a){if(t)return;const r=Date.now()-s,d=()=>{s=Date.now(),t=!1,e.apply(this,a)};r>=n?d():t=setTimeout(d,n)}}const[wt,se]=E("back-top"),kt={right:I,bottom:I,zIndex:I,target:[String,Object],offset:H(200),immediate:Boolean,teleport:{type:[String,Object],default:"body"}};var Ot=_({name:wt,inheritAttrs:!1,props:kt,emits:["click"],setup(e,{emit:n,slots:t,attrs:s}){let a=!1;const r=S(!1),d=S(),c=S(),v=p(()=>R(fe(e.zIndex),{right:he(e.right),bottom:he(e.bottom)})),k=x=>{var O;n("click",x),(O=c.value)==null||O.scrollTo({top:0,behavior:e.immediate?"auto":"smooth"})},h=()=>{r.value=c.value?Pe(c.value)>=+e.offset:!1},T=()=>{const{target:x}=e;if(typeof x=="string"){const O=document.querySelector(x);if(O)return O}else return x},w=()=>{Ue&&te(()=>{c.value=e.target?T():Le(d.value),h()})};return q("scroll",Dt(h,100),{target:c}),Xe(w),Ze(()=>{a&&(r.value=!0,a=!1)}),Je(()=>{r.value&&e.teleport&&(r.value=!1,a=!0)}),F(()=>e.target,w),()=>{const x=m("div",ne({ref:e.teleport?void 0:d,class:se({active:r.value}),style:v.value,onClick:k},s),[t.default?t.default():m(me,{name:"back-top",class:se("icon")},null)]);return e.teleport?[m("div",{ref:d,class:se("placeholder")},null),m(pe,{to:e.teleport},{default:()=>[x]})]:x}}});const nn=z(Ot),Ct=R({},ve,{modelValue:K(),filter:Function,formatter:{type:Function,default:(e,n)=>n}}),Pt=Object.keys(ve);function St(e,n){if(e<0)return[];const t=Array(e);let s=-1;for(;++s<e;)t[s]=n(s);return t}const $t=(e,n)=>32-new Date(e,n-1,32).getDate(),ce=(e,n,t,s,a,r)=>{const d=St(n-e+1,c=>{const v=Se(e+c);return s(t,{text:v,value:v})});return a?a(t,d,r):d},pt=(e,n)=>e.map((t,s)=>{const a=n[s];if(a.length){const r=+a[0].value,d=+a[a.length-1].value;return Se(ee(+t,r,d))}return t}),we=new Date().getFullYear(),[Mt]=E("date-picker"),It=R({},Ct,{columnsType:{type:Array,default:()=>["year","month","day"]},minDate:{type:Date,default:()=>new Date(we-10,0,1),validator:ge},maxDate:{type:Date,default:()=>new Date(we+10,11,31),validator:ge}});var Et=_({name:Mt,props:It,emits:["confirm","cancel","change","update:modelValue"],setup(e,{emit:n,slots:t}){const s=S(e.modelValue),a=S(!1),r=()=>{const o=e.minDate.getFullYear(),u=e.maxDate.getFullYear();return ce(o,u,"year",e.formatter,e.filter)},d=o=>o===e.minDate.getFullYear(),c=o=>o===e.maxDate.getFullYear(),v=o=>o===e.minDate.getMonth()+1,k=o=>o===e.maxDate.getMonth()+1,h=o=>{const{minDate:u,columnsType:y}=e,i=y.indexOf(o),g=a.value?e.modelValue[i]:s.value[i];if(g)return+g;switch(o){case"year":return u.getFullYear();case"month":return u.getMonth()+1;case"day":return u.getDate()}},T=()=>{const o=h("year"),u=d(o)?e.minDate.getMonth()+1:1,y=c(o)?e.maxDate.getMonth()+1:12;return ce(u,y,"month",e.formatter,e.filter)},w=()=>{const o=h("year"),u=h("month"),y=d(o)&&v(u)?e.minDate.getDate():1,i=c(o)&&k(u)?e.maxDate.getDate():$t(o,u);return ce(y,i,"day",e.formatter,e.filter)},x=p(()=>e.columnsType.map(o=>{switch(o){case"year":return r();case"month":return T();case"day":return w();default:return[]}}));F(s,o=>{L(o,e.modelValue)||n("update:modelValue",o)}),F(()=>e.modelValue,(o,u)=>{a.value=L(u,s.value),o=pt(o,x.value),L(o,s.value)||(s.value=o),a.value=!1},{immediate:!0});const O=(...o)=>n("change",...o),P=(...o)=>n("cancel",...o),C=(...o)=>n("confirm",...o);return()=>m(Tt,ne({modelValue:s.value,"onUpdate:modelValue":o=>s.value=o,columns:x.value,onChange:O,onCancel:P,onConfirm:C},ie(e,Pt)),t)}});const an=z(Et),[Re,Z]=E("dropdown-menu"),Bt={overlay:Y,zIndex:I,duration:H(.2),direction:Oe("down"),activeColor:String,closeOnClickOutside:Y,closeOnClickOverlay:Y,swipeThreshold:I},_e=Symbol(Re);var Vt=_({name:Re,props:Bt,setup(e,{slots:n}){const t=at(),s=S(),a=S(),r=S(0),{children:d,linkChildren:c}=Ce(_e),v=$e(s),k=p(()=>d.some(u=>u.state.showWrapper)),h=p(()=>e.swipeThreshold&&d.length>+e.swipeThreshold),T=p(()=>{if(k.value&&ke(e.zIndex))return{zIndex:+e.zIndex+1}}),w=()=>{d.forEach(u=>{u.toggle(!1)})},x=()=>{e.closeOnClickOutside&&w()},O=()=>{if(a.value){const u=We(a);e.direction==="down"?r.value=u.bottom:r.value=je.value-u.top}},P=()=>{k.value&&O()},C=u=>{d.forEach((y,i)=>{i===u?y.toggle():y.state.showPopup&&y.toggle(!1,{immediate:!0})})},o=(u,y)=>{const{showPopup:i}=u.state,{disabled:g,titleClass:$}=u;return m("div",{id:`${t}-${y}`,role:"button",tabindex:g?void 0:0,class:[Z("item",{disabled:g,grow:h.value}),{[G]:!g}],onClick:()=>{g||C(y)}},[m("span",{class:[Z("title",{down:i===(e.direction==="down"),active:i}),$],style:{color:i?e.activeColor:""}},[m("div",{class:"van-ellipsis"},[u.renderTitle()])])])};return ae({close:w}),c({id:t,props:e,offset:r,updateOffset:O}),Ke(s,x),q("scroll",P,{target:v,passive:!0}),()=>{var u;return m("div",{ref:s,class:Z()},[m("div",{ref:a,style:T.value,class:Z("bar",{opened:k.value,scrollable:h.value})},[d.map(o)]),(u=n.default)==null?void 0:u.call(n)])}}});const[Ht,J]=E("dropdown-item"),Rt={title:String,options:K(),disabled:Boolean,teleport:[String,Object],lazyRender:Y,modelValue:be,titleClass:be};var _t=_({name:Ht,inheritAttrs:!1,props:Rt,emits:["open","opened","close","closed","change","update:modelValue"],setup(e,{emit:n,slots:t,attrs:s}){const a=Me({showPopup:!1,transition:!0,showWrapper:!1}),{parent:r,index:d}=ue(_e);if(!r)return;const c=o=>()=>n(o),v=c("open"),k=c("close"),h=c("opened"),T=()=>{a.showWrapper=!1,n("closed")},w=o=>{e.teleport&&o.stopPropagation()},x=(o=!a.showPopup,u={})=>{o!==a.showPopup&&(a.showPopup=o,a.transition=!u.immediate,o&&(r.updateOffset(),a.showWrapper=!0))},O=()=>{if(t.title)return t.title();if(e.title)return e.title;const o=e.options.find(u=>u.value===e.modelValue);return o?o.text:""},P=o=>{const{activeColor:u}=r.props,y=o.value===e.modelValue,i=()=>{a.showPopup=!1,o.value!==e.modelValue&&(n("update:modelValue",o.value),n("change",o.value))},g=()=>{if(y)return m(me,{class:J("icon"),color:u,name:"success"},null)};return m(tt,{role:"menuitem",key:String(o.value),icon:o.icon,title:o.text,class:J("option",{active:y}),style:{color:y?u:""},tabindex:y?0:-1,clickable:!0,onClick:i},{value:g})},C=()=>{const{offset:o}=r,{zIndex:u,overlay:y,duration:i,direction:g,closeOnClickOverlay:$}=r.props,N=fe(u);return g==="down"?N.top=`${o.value}px`:N.bottom=`${o.value}px`,Qe(m("div",ne({style:N,class:J([g]),onClick:w},s),[m(nt,{show:a.showPopup,"onUpdate:show":M=>a.showPopup=M,role:"menu",class:J("content"),overlay:y,position:g==="down"?"top":"bottom",duration:a.transition?i:0,lazyRender:e.lazyRender,overlayStyle:{position:"absolute"},"aria-labelledby":`${r.id}-${d.value}`,closeOnClickOverlay:$,onOpen:v,onClose:k,onOpened:h,onClosed:T},{default:()=>{var M;return[e.options.map(P),(M=t.default)==null?void 0:M.call(t)]}})]),[[et,a.showWrapper]])};return ae({state:a,toggle:x,renderTitle:O}),()=>e.teleport?m(pe,{to:e.teleport},{default:()=>[C()]}):C()}});const on=z(_t),ln=z(Vt),[At,B]=E("nav-bar"),Nt={title:String,fixed:Boolean,zIndex:I,border:Y,leftText:String,rightText:String,leftDisabled:Boolean,rightDisabled:Boolean,leftArrow:Boolean,placeholder:Boolean,safeAreaInsetTop:Boolean,clickable:Y};var Yt=_({name:At,props:Nt,emits:["clickLeft","clickRight"],setup(e,{emit:n,slots:t}){const s=S(),a=ot(s,B),r=h=>{e.leftDisabled||n("clickLeft",h)},d=h=>{e.rightDisabled||n("clickRight",h)},c=()=>t.left?t.left():[e.leftArrow&&m(me,{class:B("arrow"),name:"arrow-left"},null),e.leftText&&m("span",{class:B("text")},[e.leftText])],v=()=>t.right?t.right():m("span",{class:B("text")},[e.rightText]),k=()=>{const{title:h,fixed:T,border:w,zIndex:x}=e,O=fe(x),P=e.leftArrow||e.leftText||t.left,C=e.rightText||t.right;return m("div",{ref:s,style:O,class:[B({fixed:T}),{[Ge]:w,"van-safe-area-top":e.safeAreaInsetTop}]},[m("div",{class:B("content")},[P&&m("div",{class:[B("left",{disabled:e.leftDisabled}),e.clickable&&!e.leftDisabled?G:""],onClick:r},[c()]),m("div",{class:[B("title"),"van-ellipsis"]},[t.title?t.title():h]),C&&m("div",{class:[B("right",{disabled:e.rightDisabled}),e.clickable&&!e.rightDisabled?G:""],onClick:d},[v()])])])};return()=>e.fixed&&e.placeholder?a(k):k()}});const sn=z(Yt),[Ft,j,zt]=E("pull-refresh"),Ae=50,Ut=["pulling","loosing","success"],Lt={disabled:Boolean,modelValue:Boolean,headHeight:H(Ae),successText:String,pullingText:String,loosingText:String,loadingText:String,pullDistance:I,successDuration:H(500),animationDuration:H(300)};var Kt=_({name:Ft,props:Lt,emits:["change","refresh","update:modelValue"],setup(e,{emit:n,slots:t}){let s;const a=S(),r=S(),d=$e(a),c=Me({status:"normal",distance:0,duration:0}),v=Ee(),k=()=>{if(e.headHeight!==Ae)return{height:`${e.headHeight}px`}},h=()=>c.status!=="loading"&&c.status!=="success"&&!e.disabled,T=i=>{const g=+(e.pullDistance||e.headHeight);return i>g&&(i<g*2?i=g+(i-g)/2:i=g*1.5+(i-g*2)/4),Math.round(i)},w=(i,g)=>{const $=+(e.pullDistance||e.headHeight);c.distance=i,g?c.status="loading":i===0?c.status="normal":i<$?c.status="pulling":c.status="loosing",n("change",{status:c.status,distance:i})},x=()=>{const{status:i}=c;return i==="normal"?"":e[`${i}Text`]||zt(i)},O=()=>{const{status:i,distance:g}=c;if(t[i])return t[i]({distance:g});const $=[];return Ut.includes(i)&&$.push(m("div",{class:j("text")},[x()])),i==="loading"&&$.push(m(Ie,{class:j("loading")},{default:x})),$},P=()=>{c.status="success",setTimeout(()=>{w(0)},+e.successDuration)},C=i=>{s=Pe(d.value)===0,s&&(c.duration=0,v.start(i))},o=i=>{h()&&C(i)},u=i=>{if(h()){s||C(i);const{deltaY:g}=v;v.move(i),s&&g.value>=0&&v.isVertical()&&(de(i),w(T(g.value)))}},y=()=>{s&&v.deltaY.value&&h()&&(c.duration=+e.animationDuration,c.status==="loosing"?(w(+e.headHeight,!0),n("update:modelValue",!0),te(()=>n("refresh"))):w(0))};return F(()=>e.modelValue,i=>{c.duration=+e.animationDuration,i?w(+e.headHeight,!0):t.success||e.successText?P():w(0,!1)}),q("touchmove",u,{target:r}),()=>{var i;const g={transitionDuration:`${c.duration}ms`,transform:c.distance?`translate3d(0,${c.distance}px, 0)`:""};return m("div",{ref:a,class:j()},[m("div",{ref:r,class:j("track"),style:g,onTouchstartPassive:o,onTouchend:y,onTouchcancel:y},[m("div",{class:j("head"),style:k()},[O()]),(i=t.default)==null?void 0:i.call(t)])])}}});const cn=z(Kt);const rn=function(e){const n=new Date;let t=n.getFullYear(),s=n.getMonth(),a=n.getDate(),r=0,d=0,c=Math.trunc(e/12),v=e%12;return v<s?(r=t-c,d=s-v):(r=t-c-1,d=s+12-v),new Date(r,d,a)};export{nn as B,an as D,sn as N,cn as P,ln as a,on as b,rn as g};
|