1 |
- import{t as F,N as w,aG as D,d as O,R as N,D as T,Z as h,a_ as g,c as E,v as I,am as R,x as _}from"./index.f2940478.js";import{s as A,f as G,p as K,a as m,g as S}from"./utils.b9ed2192.js";import{P as U}from"./index.26b6b013.js";const f=new Date().getFullYear(),[Z]=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:Z,props:$,emits:["confirm","cancel","change","update:modelValue"],setup(t,{emit:r,slots:y}){const n=N(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,v=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()}},Y=()=>{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)&&v(a)?t.maxDate.getDate():S(e,a);return m(o,s,"day",t.formatter,t.filter)},u=T(()=>t.columnsType.map(e=>{switch(e){case"year":return x();case"month":return Y();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=G(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()=>E(U,I({modelValue:n.value,"onUpdate:modelValue":e=>n.value=e,columns:u.value,onChange:P,onCancel:k,onConfirm:C},R(t,K)),y)}});const B=_(b);export{B as D};
|