1 |
- import{t as F,N as w,aG as D,d as O,R as E,y as N,Z as h,aW as g,c as T,E as I,am as R,D as A}from"./index.332c7f08.js";import{s as G,f as K,p as S,a as m,g as U}from"./utils.4b86e8c9.js";import{P as W}from"./index.656e257f.js";const f=new Date().getFullYear(),[Z]=F("date-picker"),_=w({},G,{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 $=O({name:Z,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(W,I({modelValue:n.value,"onUpdate:modelValue":e=>n.value=e,columns:u.value,onChange:P,onCancel:k,onConfirm:C},R(t,S)),y)}});const z=A($);export{z as D};
|