1 |
- import{t as F,N as w,aq as D,d as O,R as E,y as N,Z as h,ar as g,c as T,E as I,al as R,D as q}from"./index.ffe80dbe.js";import{s as A,f as K,p as S,g as m,a as U}from"./utils.18cb7a73.js";import{P as Z}from"./index.777c6c1a.js";const f=new Date().getFullYear(),[_]=F("date-picker"),$=w({},A,{columnsType:{type:Array,default:()=>["year","month","day"]},minDate:{type:Date,default:()=>new Date(f-10,0,1),validator:D},maxDate:{type:Date,default:()=>new Date(f+10,11,31),validator:D}});var b=O({name:_,props:$,emits:["confirm","cancel","change","update:modelValue"],setup(t,{emit:r,slots:y}){const n=E(t.modelValue),x=()=>{const e=t.minDate.getFullYear(),a=t.maxDate.getFullYear();return m(e,a,"year",t.formatter,t.filter)},l=e=>e===t.minDate.getFullYear(),i=e=>e===t.maxDate.getFullYear(),M=e=>e===t.minDate.getMonth()+1,Y=e=>e===t.maxDate.getMonth()+1,c=e=>{const{minDate:a,columnsType:o}=t,s=o.indexOf(e),d=n.value[s];if(d)return+d;switch(e){case"year":return a.getFullYear();case"month":return a.getMonth()+1;case"day":return a.getDate()}},v=()=>{const e=c("year"),a=l(e)?t.minDate.getMonth()+1:1,o=i(e)?t.maxDate.getMonth()+1:12;return m(a,o,"month",t.formatter,t.filter)},V=()=>{const e=c("year"),a=c("month"),o=l(e)&&M(a)?t.minDate.getDate():1,s=i(e)&&Y(a)?t.maxDate.getDate():U(e,a);return m(o,s,"day",t.formatter,t.filter)},u=N(()=>t.columnsType.map(e=>{switch(e){case"year":return x();case"month":return v();case"day":return V();default:throw new Error(`[Vant] DatePicker: unsupported columns type: ${e}`)}}));h(n,e=>{g(e,t.modelValue)||r("update:modelValue",e)}),h(()=>t.modelValue,e=>{e=K(e,u.value),g(e,n.value)||(n.value=e)},{immediate:!0});const P=(...e)=>r("change",...e),k=(...e)=>r("cancel",...e),C=(...e)=>r("confirm",...e);return()=>T(Z,I({modelValue:n.value,"onUpdate:modelValue":e=>n.value=e,columns:u.value,onChange:P,onCancel:k,onConfirm:C},R(t,S)),y)}});const G=q(b);export{G as D};
|