index-legacy.7929dd9f.js 13 KB

1
  1. !function(){function e(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,a,o=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(u){l=!0,a=u}finally{try{i||null==n.return||n.return()}finally{if(l)throw a}}return o}(e,t)||n(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}System.register(["./index-legacy.c1f63540.js","./index-legacy.aa9b4ef8.js","./utils-legacy.270b3ede.js"],(function(n){"use strict";var r,a,o,i,l,u,c,f,s,d,v,m,p,h,y,g,b,w,D,S,k,x,T,A,O,M,B,C,I,R;return{setters:[function(e){r=e.t,a=e.d,o=e.aB,i=e.aC,l=e.y,u=e.c,c=e.aD,f=e.R,s=e.aE,d=e.U,v=e.W,m=e.z,p=e.an,h=e.aF,y=e.am,g=e.u,b=e.v,w=e.w,D=e.aG,S=e.Z,k=e.aH,x=e.P,T=e.aI,A=e.ar,O=e.E,M=e.o,B=e.B,C=e.D},function(e){I=e.u},function(e){R=e.g}],execute:function(){var H=t(r("calendar"),3),P=H[0],W=H[1],j=H[2];function F(e,t){var n=e.getFullYear(),r=t.getFullYear();if(n===r){var a=e.getMonth(),o=t.getMonth();return a===o?0:a>o?1:-1}return n>r?1:-1}function Y(e,t){var n=F(e,t);if(0===n){var r=e.getDate(),a=t.getDate();return r===a?0:r>a?1:-1}return n}var z=function(e){return new Date(e)},E=function(e){return Array.isArray(e)?e.map(z):z(e)};function N(e,t){var n=z(e);return n.setDate(n.getDate()+t),n}var U=function(e){return N(e,-1)},V=function(e){return N(e,1)},G=function(){var e=new Date;return e.setHours(0,0,0,0),e};var L=t(r("calendar-day"),1)[0],Z=a({name:L,props:{item:o(Object),color:String,index:Number,offset:i(0),rowHeight:String},emits:["click"],setup:function(e,t){var n=t.emit,r=t.slots,a=l((function(){var t,n=e.item,r=e.index,a=e.color,o=e.offset,i={height:e.rowHeight};if("placeholder"===n.type)return i.width="100%",i;if(0===r&&(i.marginLeft="".concat(100*o/7,"%")),a)switch(n.type){case"end":case"start":case"start-end":case"multiple-middle":case"multiple-selected":i.background=a;break;case"middle":i.color=a}return o+((null==(t=n.date)?void 0:t.getDate())||1)>28&&(i.marginBottom=0),i})),o=function(){"disabled"!==e.item.type&&n("click",e.item)},i=function(){var t=e.item.topInfo;if(t||r["top-info"])return u("div",{class:W("top-info")},[r["top-info"]?r["top-info"](e.item):t])},c=function(){var t=e.item.bottomInfo;if(t||r["bottom-info"])return u("div",{class:W("bottom-info")},[r["bottom-info"]?r["bottom-info"](e.item):t])},f=function(){var t=e.item,n=e.color,r=e.rowHeight,a=t.type,o=t.text,l=[i(),o,c()];return"selected"===a?u("div",{class:W("selected-day"),style:{width:r,height:r,background:n}},[l]):l};return function(){var t=e.item,n=t.type,r=t.className;return"placeholder"===n?u("div",{class:W("day"),style:a.value},null):u("div",{role:"gridcell",style:a.value,class:[W("day",n),r],tabindex:"disabled"===n?void 0:-1,onClick:o},[f()])}}}),$=t(r("calendar-month"),1)[0],q={date:o(Date),type:String,color:String,minDate:o(Date),maxDate:o(Date),showMark:Boolean,rowHeight:m,formatter:Function,lazyRender:Boolean,currentDate:[Date,Array],allowSameDay:Boolean,showSubtitle:Boolean,showMonthTitle:Boolean,firstDayOfWeek:Number},J=a({name:$,props:q,emits:["click"],setup:function(e,n){var r=n.emit,a=n.slots,o=t(c(),2),i=o[0],m=o[1],g=f(),b=f(),w=s(b),D=l((function(){return t=e.date,j("monthTitle",t.getFullYear(),t.getMonth()+1);var t})),S=l((function(){return d(e.rowHeight)})),k=l((function(){var t=e.date.getDay();return e.firstDayOfWeek?(t+7-e.firstDayOfWeek)%7:t})),x=l((function(){return R(e.date.getFullYear(),e.date.getMonth()+1)})),T=l((function(){return i.value||!e.lazyRender})),A=function(n){var r=e.type,a=e.minDate,o=e.maxDate,i=e.currentDate;if(Y(n,a)<0||Y(n,o)>0)return"disabled";if(null===i)return"";if(Array.isArray(i)){if("multiple"===r)return function(t){var n=function(t){return e.currentDate.some((function(e){return 0===Y(e,t)}))};if(n(t)){var r=U(t),a=V(t),o=n(r),i=n(a);return o&&i?"multiple-middle":o?"end":i?"start":"multiple-selected"}return""}(n);if("range"===r)return function(n){var r=t(e.currentDate,2),a=r[0],o=r[1];if(!a)return"";var i=Y(n,a);if(!o)return 0===i?"start":"";var l=Y(n,o);return e.allowSameDay&&0===i&&0===l?"start-end":0===i?"start":0===l?"end":i>0&&l<0?"middle":""}(n)}else if("single"===r)return 0===Y(n,i)?"selected":"";return""},O=function(t){if("range"===e.type){if("start"===t||"end"===t)return j(t);if("start-end"===t)return"".concat(j("start"),"/").concat(j("end"))}},M=function(){if(e.showMonthTitle)return u("div",{class:W("month-title")},[D.value])},B=function(){if(e.showMark&&T.value)return u("div",{class:W("month-mark")},[e.date.getMonth()+1])},C=l((function(){var e=Math.ceil((x.value+k.value)/7);return Array(e).fill({type:"placeholder"})})),I=l((function(){for(var t=[],n=e.date.getFullYear(),r=e.date.getMonth(),a=1;a<=x.value;a++){var o=new Date(n,r,a),i=A(o),l={date:o,type:i,text:a,bottomInfo:O(i)};e.formatter&&(l=e.formatter(l)),t.push(l)}return t})),H=l((function(){return I.value.filter((function(e){return"disabled"===e.type}))})),P=function(t,n){return u(Z,{item:t,index:n,color:e.color,offset:k.value,rowHeight:S.value,onClick:function(e){return r("click",e)}},y(a,["top-info","bottom-info"]))};return v({getTitle:function(){return D.value},getHeight:function(){return w.value},setVisible:m,scrollToDate:function(e,t){if(g.value){var n=p(g.value),r=C.value.length,a=(Math.ceil((t.getDate()+k.value)/7)-1)*n.height/r;h(e,n.top+a+e.scrollTop-p(e).top)}},disabledDays:H}),function(){return u("div",{class:W("month"),ref:b},[M(),u("div",{ref:g,role:"grid",class:W("days")},[B(),(T.value?I:C).value.map(P)])])}}}),K=t(r("calendar-header"),1)[0],Q=a({name:K,props:{date:Date,title:String,subtitle:String,showTitle:Boolean,showSubtitle:Boolean,firstDayOfWeek:Number},emits:["clickSubtitle"],setup:function(t,n){var r=n.slots,a=n.emit,o=function(){if(t.showTitle){var e=t.title||j("title"),n=r.title?r.title():e;return u("div",{class:W("header-title")},[n])}},i=function(e){return a("clickSubtitle",e)},l=function(){if(t.showSubtitle){var e=r.subtitle?r.subtitle({date:t.date,text:t.subtitle}):t.subtitle;return u("div",{class:W("header-subtitle"),onClick:i},[e])}};return function(){return u("div",{class:W("header")},[o(),l(),(n=t.firstDayOfWeek,r=j("weekdays"),a=[].concat(e(r.slice(n,7)),e(r.slice(0,n))),u("div",{class:W("weekdays")},[a.map((function(e){return u("span",{class:W("weekday")},[e])}))]))]);var n,r,a}}}),X={show:Boolean,type:g("single"),title:String,color:String,round:b,readonly:Boolean,poppable:b,maxRange:w(null),position:g("bottom"),teleport:[String,Object],showMark:b,showTitle:b,formatter:Function,rowHeight:m,confirmText:String,rangePrompt:String,lazyRender:b,showConfirm:b,defaultDate:[Date,Array],allowSameDay:Boolean,showSubtitle:b,closeOnPopstate:b,showRangePrompt:b,confirmDisabledText:String,closeOnClickOverlay:b,safeAreaInsetTop:Boolean,safeAreaInsetBottom:b,minDate:{type:Date,validator:D,default:G},maxDate:{type:Date,validator:D,default:function(){var e=G();return new Date(e.getFullYear(),e.getMonth()+6,e.getDate())}},firstDayOfWeek:{type:m,default:0,validator:function(e){return e>=0&&e<=6}}},_=a({name:P,props:X,emits:["select","confirm","unselect","monthShow","overRange","update:show","clickSubtitle"],setup:function(n,r){var a,o=r.emit,i=r.slots,c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.minDate,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.maxDate;return-1===Y(e,t)?t:1===Y(e,r)?r:e},s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n.defaultDate,t=n.type,r=n.minDate,a=n.maxDate,o=n.allowSameDay;if(null===e)return e;var i=G();if("range"===t){Array.isArray(e)||(e=[]);var l=c(e[0]||i,r,o?a:U(a)),u=c(e[1]||i,o?r:V(r));return[l,u]}return"multiple"===t?Array.isArray(e)?e.map((function(e){return c(e)})):[c(i)]:(e&&!Array.isArray(e)||(e=i),c(e))},d=f(),m=f({text:"",date:void 0}),h=f(s()),g=t(I(),2),b=g[0],w=g[1],C=l((function(){return n.firstDayOfWeek?+n.firstDayOfWeek%7:0})),R=l((function(){var e=[],t=new Date(n.minDate);t.setDate(1);do{e.push(new Date(t)),t.setMonth(t.getMonth()+1)}while(1!==F(t,n.maxDate));return e})),H=l((function(){if(h.value){if("range"===n.type)return!h.value[0]||!h.value[1];if("multiple"===n.type)return!h.value.length}return!h.value})),P=function(){var e=A(d.value),t=e+a,n=R.value.map((function(e,t){return b.value[t].getHeight()}));if(!(t>n.reduce((function(e,t){return e+t}),0)&&e>0)){for(var r,i=0,l=[-1,-1],u=0;u<R.value.length;u++){var c=b.value[u];i<=t&&i+n[u]>=e&&(l[1]=u,r||(r=c,l[0]=u),b.value[u].showed||(b.value[u].showed=!0,o("monthShow",{date:c.date,title:c.getTitle()}))),i+=n[u]}R.value.forEach((function(e,t){var n=t>=l[0]-1&&t<=l[1]+1;b.value[t].setVisible(n)})),r&&(m.value={text:r.getTitle(),date:r.date})}},L=function(e){T((function(){R.value.some((function(t,n){return 0===F(t,e)&&(d.value&&b.value[n].scrollToDate(d.value,e),!0)})),P()}))},Z=function(){if(!n.poppable||n.show)if(h.value){var e="single"===n.type?h.value:h.value[0];D(e)&&L(e)}else T(P)},$=function(){n.poppable&&!n.show||(T((function(){a=Math.floor(p(d).height)})),Z())},q=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s();h.value=e,Z()},K=function(){var e;return o("confirm",null!=(e=h.value)?e:E(h.value))},X=function(e,t){var r=function(e){h.value=e,o("select",E(e))};if(t&&"range"===n.type){var a=function(e){var t=n.maxRange,r=n.rangePrompt,a=n.showRangePrompt;return!(t&&function(e){var t=e[0].getTime();return(e[1].getTime()-t)/864e5+1}(e)>t&&(a&&M(r||j("rangePrompt",t)),o("overRange"),1))}(e);if(!a)return void r([e[0],N(e[0],+n.maxRange-1)])}r(e),t&&!n.showConfirm&&K()},_=l((function(){return b.value.reduce((function(t,n){var r,a;return t.push.apply(t,e(null!=(a=null==(r=n.disabledDays)?void 0:r.value)?a:[])),t}),[])})),ee=function(r){if(!n.readonly&&r.date){var a=r.date,i=n.type;if("range"===i){if(!h.value)return void X([a]);var l=t(h.value,2),u=l[0],c=l[1];if(u&&!c){var f=Y(a,u);if(1===f){var s=function(e,t,n){var r;return null==(r=e.find((function(e){return-1===Y(t,e.date)&&-1===Y(e.date,n)})))?void 0:r.date}(_.value,u,a);if(s){var d=U(s);-1===Y(u,d)?X([u,d]):X([a])}else X([u,a],!0)}else-1===f?X([a]):n.allowSameDay&&X([a,a],!0)}else X([a])}else if("multiple"===i){if(!h.value)return void X([a]);var v=h.value,m=v.findIndex((function(e){return 0===Y(e,a)}));if(-1!==m){var p=t(v.splice(m,1),1)[0];o("unselect",z(p))}else n.maxRange&&v.length>=n.maxRange?M(n.rangePrompt||j("rangePrompt",n.maxRange)):X([].concat(e(v),[a]))}else X(a,!0)}},te=function(e){return o("update:show",e)},ne=function(e,t){var r=0!==t||!n.showSubtitle;return u(J,O({ref:w(t),date:e,currentDate:h.value,showMonthTitle:r,firstDayOfWeek:C.value},y(n,["type","color","minDate","maxDate","showMark","formatter","rowHeight","lazyRender","showSubtitle","allowSameDay"]),{onClick:ee}),y(i,["top-info","bottom-info"]))},re=function(){if(i.footer)return i.footer();if(n.showConfirm){var e=i["confirm-text"],t=H.value,r=t?n.confirmDisabledText:n.confirmText;return u(B,{round:!0,block:!0,type:"primary",color:n.color,class:W("confirm"),disabled:t,nativeType:"button",onClick:K},{default:function(){return[e?e({disabled:t}):r||j("confirm")]}})}},ae=function(){return u("div",{class:W()},[u(Q,{date:m.value.date,title:n.title,subtitle:m.value.text,showTitle:n.showTitle,showSubtitle:n.showSubtitle,firstDayOfWeek:C.value,onClickSubtitle:function(e){return o("clickSubtitle",e)}},y(i,["title","subtitle"])),u("div",{ref:d,class:W("body"),onScroll:P},[R.value.map(ne)]),u("div",{class:[W("footer"),{"van-safe-area-bottom":n.safeAreaInsetBottom}]},[re()])])};return S((function(){return n.show}),$),S((function(){return[n.type,n.minDate,n.maxDate]}),(function(){return q(s(h.value))})),S((function(){return n.defaultDate}),(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;h.value=e,Z()})),v({reset:q,scrollToDate:L,getSelectedDate:function(){return h.value}}),k($),function(){return n.poppable?u(x,{show:n.show,class:W("popup"),round:n.round,position:n.position,closeable:n.showTitle||n.showSubtitle,teleport:n.teleport,closeOnPopstate:n.closeOnPopstate,safeAreaInsetTop:n.safeAreaInsetTop,closeOnClickOverlay:n.closeOnClickOverlay,"onUpdate:show":te},{default:ae}):ae()}}});n("C",C(_))}}}))}();