1 |
- System.register(["./index-legacy-e1ea41b7.js","./index-legacy-2c98c5e9.js"],(function(e,t){"use strict";var a,n,r,l,u,o,c,m,s,i,d,D,f,y,g,p,h;return{setters:[e=>{a=e.ac,n=e.ab,r=e.b5,l=e.$,u=e.c,o=e.bH,c=e.d,m=e.r,s=e.e,i=e.w,d=e.aS,D=e.a,f=e.h,y=e.ae,g=e.k},e=>{p=e.p,h=e.P}],execute:function(){const t=a({},p,{modelValue:n(),filter:Function,formatter:{type:Function,default:(e,t)=>t}}),v=Object.keys(p),x=(e,t,a,n,l,u)=>{const o=function(e,t){if(e<0)return[];const a=Array(e);let n=-1;for(;++n<e;)a[n]=t(n);return a}(t-e+1,(t=>{const l=r(e+t);return n(a,{text:l,value:l})}));return l?l(a,o,u):o},V=(new Date).getFullYear(),[w]=u("date-picker"),F=a({},t,{columnsType:{type:Array,default:()=>["year","month","day"]},minDate:{type:Date,default:()=>new Date(V-10,0,1),validator:o},maxDate:{type:Date,default:()=>new Date(V+10,11,31),validator:o}});var Y=c({name:w,props:F,emits:["confirm","cancel","change","update:modelValue"],setup(e,{emit:t,slots:a}){const n=m(e.modelValue),u=m(!1),o=t=>t===e.minDate.getFullYear(),c=t=>t===e.maxDate.getFullYear(),g=t=>{const{minDate:a,columnsType:r}=e,l=r.indexOf(t),o=u.value?e.modelValue[l]:n.value[l];if(o)return+o;switch(t){case"year":return a.getFullYear();case"month":return a.getMonth()+1;case"day":return a.getDate()}},p=()=>{const t=g("year"),a=g("month"),n=o(t)&&(t=>t===e.minDate.getMonth()+1)(a)?e.minDate.getDate():1,r=c(t)&&(t=>t===e.maxDate.getMonth()+1)(a)?e.maxDate.getDate():((e,t)=>32-new Date(e,t-1,32).getDate())(t,a);return x(n,r,"day",e.formatter,e.filter)},V=s((()=>e.columnsType.map((t=>{switch(t){case"year":return(()=>{const t=e.minDate.getFullYear(),a=e.maxDate.getFullYear();return x(t,a,"year",e.formatter,e.filter)})();case"month":return(()=>{const t=g("year"),a=o(t)?e.minDate.getMonth()+1:1,n=c(t)?e.maxDate.getMonth()+1:12;return x(a,n,"month",e.formatter,e.filter)})();case"day":return p();default:throw new Error(`[Vant] DatePicker: unsupported columns type: ${t}`)}}))));i(n,(a=>{d(a,e.modelValue)||t("update:modelValue",a)})),i((()=>e.modelValue),((e,t)=>{u.value=d(t,n.value),e=((e,t)=>e.map(((e,a)=>{const n=t[a];if(n.length){const t=+n[0].value,a=+n[n.length-1].value;return r(l(+e,t,a))}return e})))(e,V.value),d(e,n.value)||(n.value=e),u.value=!1}),{immediate:!0});const w=(...e)=>t("change",...e),F=(...e)=>t("cancel",...e),Y=(...e)=>t("confirm",...e);return()=>D(h,f({modelValue:n.value,"onUpdate:modelValue":e=>n.value=e,columns:V.value,onChange:w,onCancel:F,onConfirm:Y},y(e,v)),a)}});e("D",g(Y))}}}));
|