| 1 |
- import{p as U,P as ne}from"./index-d9fea0f3.js";import{e as Z,l as q,o as G,q as oe,c as R,s as W,v as z,x as le,w as $,t as M,n as _,m as re,y as se,u as ce,z as ie,j as ue,A as de,C as fe,D as J,E as me,a as he,F as j,g as Q,G as ve,I as X}from"./index-3075fd64.js";import{u as N}from"./use-scope-id-c38e64b2.js";import{d as A,r as k,a as B,w as H,c as u,m as ee,B as ge,T as ye,h as De,v as we}from"./index-16aedc47.js";import{C as xe}from"./index-188028a1.js";import{P as be}from"./index-0810be85.js";import{u as Ce}from"./index-a4e4d9e7.js";import{H as L,a as ke}from"./constant-7967f80c.js";import{u as pe}from"./use-placeholder-e354374c.js";const Pe=Z({},U,{modelValue:q(),filter:Function,formatter:{type:Function,default:(e,l)=>l}}),Oe=Object.keys(U);function Te(e,l){if(e<0)return[];const o=Array(e);let r=-1;for(;++r<e;)o[r]=l(r);return o}const Me=(e,l)=>32-new Date(e,l-1,32).getDate(),F=(e,l,o,r,n,i)=>{const s=Te(l-e+1,m=>{const d=G(e+m);return r(o,{text:d,value:d})});return n?n(o,s,i):s},Ie=(e,l)=>e.map((o,r)=>{const n=l[r];if(n.length){const i=+n[0].value,s=+n[n.length-1].value;return G(oe(+o,i,s))}return o}),K=new Date().getFullYear(),[Se]=R("date-picker"),Ve=Z({},Pe,{columnsType:{type:Array,default:()=>["year","month","day"]},minDate:{type:Date,default:()=>new Date(K-10,0,1),validator:W},maxDate:{type:Date,default:()=>new Date(K+10,11,31),validator:W}});var Be=A({name:Se,props:Ve,emits:["confirm","cancel","change","update:modelValue"],setup(e,{emit:l,slots:o}){const r=k(e.modelValue),n=k(!1),i=k(),s=()=>{const t=e.minDate.getFullYear(),c=e.maxDate.getFullYear();return F(t,c,"year",e.formatter,e.filter)},m=t=>t===e.minDate.getFullYear(),d=t=>t===e.maxDate.getFullYear(),g=t=>t===e.minDate.getMonth()+1,h=t=>t===e.maxDate.getMonth()+1,D=t=>{const{minDate:c,columnsType:v}=e,y=v.indexOf(t),I=n.value?e.modelValue[y]:r.value[y];if(I)return+I;switch(t){case"year":return c.getFullYear();case"month":return c.getMonth()+1;case"day":return c.getDate()}},x=()=>{const t=D("year"),c=m(t)?e.minDate.getMonth()+1:1,v=d(t)?e.maxDate.getMonth()+1:12;return F(c,v,"month",e.formatter,e.filter)},p=()=>{const t=D("year"),c=D("month"),v=m(t)&&g(c)?e.minDate.getDate():1,y=d(t)&&h(c)?e.maxDate.getDate():Me(t,c);return F(v,y,"day",e.formatter,e.filter)},b=()=>{var t;return(t=i.value)==null?void 0:t.confirm()},P=()=>r.value,C=B(()=>e.columnsType.map(t=>{switch(t){case"year":return s();case"month":return x();case"day":return p();default:return[]}}));H(r,t=>{z(t,e.modelValue)||l("update:modelValue",t)}),H(()=>e.modelValue,(t,c)=>{n.value=z(c,r.value),t=Ie(t,C.value),z(t,r.value)||(r.value=t),n.value=!1},{immediate:!0});const T=(...t)=>l("change",...t),a=(...t)=>l("cancel",...t),f=(...t)=>l("confirm",...t);return N({confirm:b,getSelectedDate:P}),()=>u(ne,ee({ref:i,modelValue:r.value,"onUpdate:modelValue":t=>r.value=t,columns:C.value,onChange:T,onCancel:a,onConfirm:f},le(e,Oe)),o)}});const Ge=$(Be),[te,S]=R("dropdown-menu"),Re={overlay:M,zIndex:_,duration:re(.2),direction:se("down"),activeColor:String,autoLocate:Boolean,closeOnClickOutside:M,closeOnClickOverlay:M,swipeThreshold:_},ae=Symbol(te);var $e=A({name:te,props:Re,setup(e,{slots:l}){const o=Ce(),r=k(),n=k(),i=k(0),{children:s,linkChildren:m}=ce(ae),d=ie(r),g=B(()=>s.some(a=>a.state.showWrapper)),h=B(()=>e.swipeThreshold&&s.length>+e.swipeThreshold),D=B(()=>{if(g.value&&ue(e.zIndex))return{zIndex:+e.zIndex+1}}),x=()=>{s.forEach(a=>{a.toggle(!1)})},p=()=>{e.closeOnClickOutside&&x()},b=()=>{if(n.value){const a=J(n);e.direction==="down"?i.value=a.bottom:i.value=me.value-a.top}},P=()=>{g.value&&b()},C=a=>{s.forEach((f,t)=>{t===a?f.toggle():f.state.showPopup&&f.toggle(!1,{immediate:!0})})},T=(a,f)=>{const{showPopup:t}=a.state,{disabled:c,titleClass:v}=a;return u("div",{id:`${o}-${f}`,role:"button",tabindex:c?void 0:0,class:[S("item",{disabled:c,grow:h.value}),{[L]:!c}],onClick:()=>{c||C(f)}},[u("span",{class:[S("title",{down:t===(e.direction==="down"),active:t}),v],style:{color:t?e.activeColor:""}},[u("div",{class:"van-ellipsis"},[a.renderTitle()])])])};return N({close:x}),m({id:o,props:e,offset:i,updateOffset:b}),de(r,p),fe("scroll",P,{target:d,passive:!0}),()=>{var a;return u("div",{ref:r,class:S()},[u("div",{ref:n,style:D.value,class:S("bar",{opened:g.value,scrollable:h.value})},[s.map(T)]),(a=l.default)==null?void 0:a.call(l)])}}});const[Ae,V]=R("dropdown-item"),Ye={title:String,options:q(),disabled:Boolean,teleport:[String,Object],lazyRender:M,modelValue:j,titleClass:j};var Ee=A({name:Ae,inheritAttrs:!1,props:Ye,emits:["open","opened","close","closed","change","update:modelValue"],setup(e,{emit:l,slots:o,attrs:r}){const n=ge({showPopup:!1,transition:!0,showWrapper:!1}),i=k(),{parent:s,index:m}=he(ae);if(!s)return;const d=a=>()=>l(a),g=d("open"),h=d("close"),D=d("opened"),x=()=>{n.showWrapper=!1,l("closed")},p=a=>{e.teleport&&a.stopPropagation()},b=(a=!n.showPopup,f={})=>{a!==n.showPopup&&(n.showPopup=a,n.transition=!f.immediate,a&&(s.updateOffset(),n.showWrapper=!0))},P=()=>{if(o.title)return o.title();if(e.title)return e.title;const a=e.options.find(f=>f.value===e.modelValue);return a?a.text:""},C=a=>{const{activeColor:f}=s.props,{disabled:t}=a,c=a.value===e.modelValue,v=()=>{t||(n.showPopup=!1,a.value!==e.modelValue&&(l("update:modelValue",a.value),l("change",a.value)))},y=()=>{if(c)return u(X,{class:V("icon"),color:t?void 0:f,name:"success"},null)};return u(xe,{role:"menuitem",key:String(a.value),icon:a.icon,title:a.text,class:V("option",{active:c,disabled:t}),style:{color:c?f:""},tabindex:c?0:-1,clickable:!t,onClick:v},{value:y})},T=()=>{const{offset:a}=s,{autoLocate:f,zIndex:t,overlay:c,duration:v,direction:y,closeOnClickOverlay:I}=s.props,Y=Q(t);let E=a.value;if(f&&i.value){const O=ve(i.value);O&&(E-=J(O).top)}return y==="down"?Y.top=`${E}px`:Y.bottom=`${E}px`,De(u("div",ee({ref:i,style:Y,class:V([y]),onClick:p},r),[u(be,{show:n.showPopup,"onUpdate:show":O=>n.showPopup=O,role:"menu",class:V("content"),overlay:c,position:y==="down"?"top":"bottom",duration:n.transition?v:0,lazyRender:e.lazyRender,overlayStyle:{position:"absolute"},"aria-labelledby":`${s.id}-${m.value}`,closeOnClickOverlay:I,onOpen:g,onClose:h,onOpened:D,onClosed:x},{default:()=>{var O;return[e.options.map(C),(O=o.default)==null?void 0:O.call(o)]}})]),[[we,n.showWrapper]])};return N({state:n,toggle:b,renderTitle:P}),()=>e.teleport?u(ye,{to:e.teleport},{default:()=>[T()]}):T()}});const Je=$(Ee),Qe=$($e),[ze,w]=R("nav-bar"),Fe={title:String,fixed:Boolean,zIndex:_,border:M,leftText:String,rightText:String,leftDisabled:Boolean,rightDisabled:Boolean,leftArrow:Boolean,placeholder:Boolean,safeAreaInsetTop:Boolean,clickable:M};var _e=A({name:ze,props:Fe,emits:["clickLeft","clickRight"],setup(e,{emit:l,slots:o}){const r=k(),n=pe(r,w),i=h=>{e.leftDisabled||l("clickLeft",h)},s=h=>{e.rightDisabled||l("clickRight",h)},m=()=>o.left?o.left():[e.leftArrow&&u(X,{class:w("arrow"),name:"arrow-left"},null),e.leftText&&u("span",{class:w("text")},[e.leftText])],d=()=>o.right?o.right():u("span",{class:w("text")},[e.rightText]),g=()=>{const{title:h,fixed:D,border:x,zIndex:p}=e,b=Q(p),P=e.leftArrow||e.leftText||o.left,C=e.rightText||o.right;return u("div",{ref:r,style:b,class:[w({fixed:D}),{[ke]:x,"van-safe-area-top":e.safeAreaInsetTop}]},[u("div",{class:w("content")},[P&&u("div",{class:[w("left",{disabled:e.leftDisabled}),e.clickable&&!e.leftDisabled?L:""],onClick:i},[m()]),u("div",{class:[w("title"),"van-ellipsis"]},[o.title?o.title():h]),C&&u("div",{class:[w("right",{disabled:e.rightDisabled}),e.clickable&&!e.rightDisabled?L:""],onClick:s},[d()])])])};return()=>e.fixed&&e.placeholder?n(g):g()}});const Xe=$(_e);const et=function(e){const l=new Date;let o=l.getFullYear(),r=l.getMonth(),n=l.getDate(),i=0,s=0,m=Math.trunc(e/12),d=e%12;return d<r?(i=o-m,s=r-d):(i=o-m-1,s=r+12-d),new Date(i,s,n)};export{Ge as D,Xe as N,Qe as a,Je as b,et as g};
|