@kunukn/vue-2-datepicker
Version:
A simple Vue 2 date picker component. Supports disabling of dates, inline mode, translations and custom formatters.
2 lines (1 loc) • 33.9 kB
JavaScript
(function(h,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(h=typeof globalThis<"u"?globalThis:h||self,d(h.DatePicker={}))})(this,function(h){"use strict";class d{constructor(t,s,i,a){i||(i=(s||[]).map(r=>(r||"").slice(0,3))),this.language=t,this.months=s,this.monthsAbbr=i,this.days=a,this.rtl=!1,this.ymd=!1,this.yearSuffix=""}get language(){return this._language}set language(t){if(typeof t!="string")throw new TypeError("Language must be a string");this._language=t}get months(){return this._months}set months(t){if(t.length!==12)throw new RangeError(`There must be 12 months for ${this.language} language`);this._months=t}get monthsAbbr(){return this._monthsAbbr}set monthsAbbr(t){if(t.length!==12)throw new RangeError(`There must be 12 abbreviated months for ${this.language} language`);this._monthsAbbr=t}get days(){return this._days}set days(t){if(t.length!==7)throw new RangeError(`There must be 7 days for ${this.language} language`);this._days=t}}const D=new d("English",["January","February","March","April","May","June","July","August","September","October","November","December"],["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),f={useUtc:!1,getFullYear(e){return this.useUtc?e.getUTCFullYear():e.getFullYear()},getMonth(e){return this.useUtc?e.getUTCMonth():e.getMonth()},getDate(e){return this.useUtc?e.getUTCDate():e.getDate()},getDay(e){return this.useUtc?e.getUTCDay():e.getDay()},getHours(e){return this.useUtc?e.getUTCHours():e.getHours()},getMinutes(e){return this.useUtc?e.getUTCMinutes():e.getMinutes()},setFullYear(e,t){return this.useUtc?e.setUTCFullYear(t):e.setFullYear(t)},setMonth(e,t){return this.useUtc?e.setUTCMonth(t):e.setMonth(t)},setDate(e,t){return this.useUtc?e.setUTCDate(t):e.setDate(t)},compareDates(e,t){const s=new Date(e.getTime()),i=new Date(t.getTime());return this.useUtc?(s.setUTCHours(0,0,0,0),i.setUTCHours(0,0,0,0)):(s.setHours(0,0,0,0),i.setHours(0,0,0,0)),s.getTime()===i.getTime()},isValidDate(e){return Object.prototype.toString.call(e)!=="[object Date]"?!1:!isNaN(e.getTime())},getDayNameAbbr(e,t){if(typeof e!="object")throw TypeError("Invalid Type");return t[this.getDay(e)]},getMonthName(e,t){if(!t)throw Error("missing 2nd parameter Months array");if(typeof e=="object")return t[this.getMonth(e)];if(typeof e=="number")return t[e];throw TypeError("Invalid type")},getMonthNameAbbr(e,t){if(!t)throw Error("missing 2nd paramter Months array");if(typeof e=="object")return t[this.getMonth(e)];if(typeof e=="number")return t[e];throw TypeError("Invalid type")},daysInMonth(e,t){return/8|3|5|10/.test(t)?30:t===1?!(e%4)&&e%100||!(e%400)?29:28:31},getNthSuffix(e){switch(e){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},formatDate(e,t,s){s=s||D;let i=this.getFullYear(e),a=this.getMonth(e)+1,r=this.getDate(e);return t.replace(/dd/,("0"+r).slice(-2)).replace(/d/,r).replace(/yyyy/,i).replace(/yy/,String(i).slice(2)).replace(/MMMM/,this.getMonthName(this.getMonth(e),s.months)).replace(/MMM/,this.getMonthNameAbbr(this.getMonth(e),s.monthsAbbr)).replace(/MM/,("0"+a).slice(-2)).replace(/M(?!a|ä|e)/,a).replace(/su/,this.getNthSuffix(this.getDate(e))).replace(/D(?!e|é|i)/,this.getDayNameAbbr(e,s.days))},createDateArray(e,t){let s=[];for(;e<=t;)s.push(new Date(e)),e=this.setDate(new Date(e),this.getDate(new Date(e))+1);return s},validateDateInput(e){return e===null||e instanceof Date||typeof e=="string"||typeof e=="number"}},c=e=>({...f,useUtc:e}),g={...f};var Y=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"vdp-datepicker__date-input",class:{"input-group":e.bootstrapStyling}},[s("input",{ref:e.refName,class:e.computedInputClass,attrs:{id:e.id,type:e.inline?"hidden":"text",name:e.name,"open-date":e.openDate,placeholder:e.placeholder,disabled:e.disabled,required:e.required,readonly:!e.typeable,autocomplete:"off"},domProps:{value:e.formattedValue},on:{click:e.showCalendar,keyup:e.parseTypedDate,keydown:e.onKeyDown,blur:e.inputBlurred}}),e._t("afterDateInput")],2)},T=[];function u(e,t,s,i,a,r,p,pe){var n=typeof e=="function"?e.options:e;t&&(n.render=t,n.staticRenderFns=s,n._compiled=!0),i&&(n.functional=!0),r&&(n._scopeId="data-v-"+r);var o;if(p?(o=function(l){l=l||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!l&&typeof __VUE_SSR_CONTEXT__<"u"&&(l=__VUE_SSR_CONTEXT__),a&&a.call(this,l),l&&l._registeredComponents&&l._registeredComponents.add(p)},n._ssrRegister=o):a&&(o=pe?function(){a.call(this,(n.functional?this.parent:this).$root.$options.shadowRoot)}:a),o)if(n.functional){n._injectStyles=o;var fe=n.render;n.render=function(ge,F){return o.call(F),fe(ge,F)}}else{var C=n.beforeCreate;n.beforeCreate=C?[].concat(C,o):[o]}return{exports:e,options:n}}const S={props:{selectedDate:Date,resetTypedDate:[Date],format:[String,Function],translation:Object,inline:Boolean,id:String,name:String,refName:String,openDate:Date,placeholder:String,inputClass:[String,Object,Array],disabled:Boolean,required:Boolean,typeable:Boolean,bootstrapStyling:Boolean,useUtc:Boolean,isOpen:Boolean},data(){return{input:null,typedDate:!1,utils:c(this.useUtc),keypressWasTab:!1}},computed:{formattedValue(){return this.selectedDate?this.typedDate?this.typedDate:typeof this.format=="function"?this.format(this.selectedDate):this.utils.formatDate(new Date(this.selectedDate),this.format+"",this.translation):null},computedInputClass(){return this.bootstrapStyling?typeof this.inputClass=="string"?[this.inputClass,"form-control"].join(" "):{"form-control":!0,...this.inputClass}:this.inputClass}},watch:{resetTypedDate(){this.typedDate=!1},isOpen(){this.keypressWasTab=!1}},mounted(){this.input=this.$el.querySelector("input")},methods:{showCalendar(){this.$emit("showCalendar")},onKeyDown(e){this.keypressWasTab=e.keyCode===9},parseTypedDate(e){if([27,13].includes(e.keyCode)&&this.input.blur(),this.typeable){const t=Date.parse(this.input.value);isNaN(t)||(this.typedDate=this.input.value,this.$emit("typedDate",new Date(this.typedDate)))}},inputBlurred(){this.typeable&&isNaN(Date.parse(this.input.value))&&(this.clearDate(),this.input.value=null,this.typedDate=null),this.keypressWasTab||this.$emit("closeCalendar")},clearDate(){this.$emit("clearDate")}}},m={};var $=u(S,Y,T,!1,x,null,null,null);function x(e){for(let t in m)this[t]=m[t]}const k=function(){return $.exports}();var N=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{directives:[{name:"show",rawName:"v-show",value:e.showDayView,expression:"showDayView"}],staticClass:"vdp-datepicker__calendar vdp-datepicker__calendar--day",class:[e.calendarClass],on:{mousedown:function(i){i.preventDefault()}}},[e._t("beforeCalendarHeader"),s("header",{staticClass:"vdp-datepicker__header"},[s("button",{staticClass:"prev",class:{disabled:e.isLeftNavDisabled},attrs:{type:"button","aria-label":e.isRtl?"<":">"},on:{click:function(i){e.isRtl?e.nextMonth():e.previousMonth()}}},[e._t(e.isRtl?"nextButton":"prevButton")],2),e.allowedToShowView("month")?s("button",{staticClass:"day__month_btn",class:e.allowedToShowView("month")?"up":"",attrs:{type:"button"},on:{click:e.showMonthCalendar}},[e.headlineDayFormatter?[s("span",{staticClass:"custom-formatted"},[e._v(e._s(e.headlineDayFormatter({pageDate:e.pageDate,selectedDate:e.selectedDate})))])]:[s("span",[e._v(e._s(e.isYmd?e.currYearName:e.currMonthName))]),s("span",[e._v(e._s(e.isYmd?e.currMonthName:e.currYearName))])]],2):s("span",{staticClass:"day__month_text"},[e.headlineDayFormatter?[s("span",{staticClass:"custom-formatted"},[e._v(e._s(e.headlineDayFormatter({pageDate:e.pageDate,selectedDate:e.selectedDate})))])]:[s("span",[e._v(e._s(e.isYmd?e.currYearName:e.currMonthName))]),s("span",[e._v(e._s(e.isYmd?e.currMonthName:e.currYearName))])]],2),s("button",{staticClass:"next",class:{disabled:e.isRightNavDisabled},attrs:{type:"button","aria-label":e.isRtl?">":"<"},on:{click:function(i){e.isRtl?e.previousMonth():e.nextMonth()}}},[e._t(e.isRtl?"prevButton":"nextButton")],2)]),s("div",{staticClass:"vdp-datepicker__pick-buttons vdp-datepicker__pick-buttons--day",class:e.isRtl?"flex-rtl":""},[s("div",{staticClass:"vdp-datepicker__day-header-background"}),e._l(e.daysOfWeekDataSource,function(i,a){return s("span",{key:i.timestamp,staticClass:"cell day-header"},[s("span",[e._v(e._s(e.formatDayHeader(i,a)))])])}),e.blankDays>0?e._l(e.blankDays,function(i){return s("span",{key:i.timestamp,staticClass:"cell day blank"},[s("span")])}):e._e(),e._l(e.days,function(i){return s("button",{key:i.timestamp,staticClass:"cell day",class:e.dayClasses(i),attrs:{type:"button"},on:{click:function(a){return e.selectDate(i)}}},[s("span",{domProps:{innerHTML:e._s(e.dayCellContent(i))}})])})],2)],2)},V=[];const U={components:{},props:{dayFormatter:Function,headlineDayFormatter:Function,nextDisabled:Function,prevDisabled:Function,showDayView:Boolean,selectedDate:Date,pageDate:Date,pageTimestamp:Number,fullMonthName:Boolean,allowedToShowView:Function,dayCellContent:{type:Function,default:e=>e.date},disabledDates:Object,highlighted:Object,calendarClass:[String,Object,Array],translation:Object,isRtl:Boolean,mondayFirst:Boolean,useUtc:Boolean,daysCustomDisplay:Array},data(){return{utils:c(this.useUtc)}},computed:{headlineFormatted(){return""},daysOfWeek(){if(this.mondayFirst){const e=this.translation.days.slice();return e.push(e.shift()),e}return this.translation.days},daysOfWeekDataSource(){var e;return((e=this.daysCustomDisplay)==null?void 0:e.length)===7?this.daysCustomDisplay:this.daysOfWeek},blankDays(){const e=this.pageDate;let t=this.useUtc?new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)):new Date(e.getFullYear(),e.getMonth(),1,e.getHours(),e.getMinutes());return this.mondayFirst?this.utils.getDay(t)>0?this.utils.getDay(t)-1:6:this.utils.getDay(t)},days(){const e=this.pageDate;let t=[],s=this.useUtc?new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)):new Date(e.getFullYear(),e.getMonth(),1,e.getHours(),e.getMinutes()),i=this.utils.daysInMonth(this.utils.getFullYear(s),this.utils.getMonth(s));for(let a=0;a<i;a++)t.push({date:this.utils.getDate(s),timestamp:s.getTime(),isSelected:this.isSelectedDate(s),isDisabled:this.isDisabledDate(s),isHighlighted:this.isHighlightedDate(s),isHighlightStart:this.isHighlightStart(s),isHighlightEnd:this.isHighlightEnd(s),isToday:this.utils.compareDates(s,new Date),isWeekend:this.utils.getDay(s)===0||this.utils.getDay(s)===6,isSaturday:this.utils.getDay(s)===6,isSunday:this.utils.getDay(s)===0}),this.utils.setDate(s,this.utils.getDate(s)+1);return t},currMonthName(){const e=this.fullMonthName?this.translation.months:this.translation.monthsAbbr;return this.utils.getMonthNameAbbr(this.utils.getMonth(this.pageDate),e)},currYearName(){const e=this.translation.yearSuffix;return`${this.utils.getFullYear(this.pageDate)}${e}`},isYmd(){return this.translation.ymd&&this.translation.ymd===!0},isLeftNavDisabled(){return this.isRtl?this.isNextMonthDisabled(this.pageTimestamp):this.isPreviousMonthDisabled(this.pageTimestamp)},isRightNavDisabled(){return this.isRtl?this.isPreviousMonthDisabled(this.pageTimestamp):this.isNextMonthDisabled(this.pageTimestamp)}},methods:{formatDayHeader(e,t){return this.dayFormatter?this.dayFormatter(e,t):e},selectDate(e){if(e.isDisabled)return this.$emit("selectedDisabled",e),!1;this.$emit("selectDate",e)},getPageMonth(){return this.utils.getMonth(this.pageDate)},showMonthCalendar(){this.$emit("showMonthCalendar")},changeMonth(e){let t=this.pageDate;this.utils.setMonth(t,this.utils.getMonth(t)+e),this.$emit("changedMonth",t)},previousMonth(){this.isPreviousMonthDisabled()||this.changeMonth(-1)},isPreviousMonthDisabled(){if(this.prevDisabled){let t=this.prevDisabled({view:"day"});if(t!=null)return t}if(!this.disabledDates||!this.disabledDates.to)return!1;let e=this.pageDate;return this.utils.getMonth(this.disabledDates.to)>=this.utils.getMonth(e)&&this.utils.getFullYear(this.disabledDates.to)>=this.utils.getFullYear(e)},nextMonth(){this.isNextMonthDisabled()||this.changeMonth(1)},isNextMonthDisabled(){if(this.nextDisabled){let t=this.nextDisabled({view:"day"});if(t!=null)return t}if(!this.disabledDates||!this.disabledDates.from)return!1;let e=this.pageDate;return this.utils.getMonth(this.disabledDates.from)<=this.utils.getMonth(e)&&this.utils.getFullYear(this.disabledDates.from)<=this.utils.getFullYear(e)},isSelectedDate(e){return this.selectedDate&&this.utils.compareDates(this.selectedDate,e)},isDisabledDate(e){let t=!1;return typeof this.disabledDates>"u"?!1:(typeof this.disabledDates.dates<"u"&&this.disabledDates.dates.forEach(s=>{if(this.utils.compareDates(e,s))return t=!0,!0}),typeof this.disabledDates.to<"u"&&this.disabledDates.to&&e<this.disabledDates.to&&(t=!0),typeof this.disabledDates.from<"u"&&this.disabledDates.from&&e>this.disabledDates.from&&(t=!0),typeof this.disabledDates.ranges<"u"&&this.disabledDates.ranges.forEach(s=>{if(typeof s.from<"u"&&s.from&&typeof s.to<"u"&&s.to&&e<s.to&&e>s.from)return t=!0,!0}),typeof this.disabledDates.days<"u"&&this.disabledDates.days.indexOf(this.utils.getDay(e))!==-1&&(t=!0),typeof this.disabledDates.daysOfMonth<"u"&&this.disabledDates.daysOfMonth.indexOf(this.utils.getDate(e))!==-1&&(t=!0),typeof this.disabledDates.customPredictor=="function"&&this.disabledDates.customPredictor(e)&&(t=!0),t)},isHighlightedDate(e){if(!(this.highlighted&&this.highlighted.includeDisabled)&&this.isDisabledDate(e))return!1;let t=!1;return typeof this.highlighted>"u"?!1:(typeof this.highlighted.dates<"u"&&this.highlighted.dates.forEach(s=>{if(this.utils.compareDates(e,s))return t=!0,!0}),this.isDefined(this.highlighted.from)&&this.isDefined(this.highlighted.to)&&(t=e>=this.highlighted.from&&e<=this.highlighted.to),typeof this.highlighted.days<"u"&&this.highlighted.days.indexOf(this.utils.getDay(e))!==-1&&(t=!0),typeof this.highlighted.daysOfMonth<"u"&&this.highlighted.daysOfMonth.indexOf(this.utils.getDate(e))!==-1&&(t=!0),typeof this.highlighted.customPredictor=="function"&&this.highlighted.customPredictor(e)&&(t=!0),t)},dayClasses(e){return{selected:e.isSelected,disabled:e.isDisabled,highlighted:e.isHighlighted,today:e.isToday,weekend:e.isWeekend,sat:e.isSaturday,sun:e.isSunday,"highlight-start":e.isHighlightStart,"highlight-end":e.isHighlightEnd}},isHighlightStart(e){return this.isHighlightedDate(e)&&this.highlighted.from instanceof Date&&this.utils.getFullYear(this.highlighted.from)===this.utils.getFullYear(e)&&this.utils.getMonth(this.highlighted.from)===this.utils.getMonth(e)&&this.utils.getDate(this.highlighted.from)===this.utils.getDate(e)},isHighlightEnd(e){return this.isHighlightedDate(e)&&this.highlighted.to instanceof Date&&this.utils.getFullYear(this.highlighted.to)===this.utils.getFullYear(e)&&this.utils.getMonth(this.highlighted.to)===this.utils.getMonth(e)&&this.utils.getDate(this.highlighted.to)===this.utils.getDate(e)},isDefined(e){return typeof e<"u"&&e}}},b={};var R=u(U,N,V,!1,P,null,null,null);function P(e){for(let t in b)this[t]=b[t]}const B=function(){return R.exports}();var O=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{directives:[{name:"show",rawName:"v-show",value:e.showMonthView,expression:"showMonthView"}],staticClass:"vdp-datepicker__calendar vdp-datepicker__calendar--month",class:[e.calendarClass],on:{mousedown:function(i){i.preventDefault()}}},[e._t("beforeCalendarHeader"),s("header",{staticClass:"vdp-datepicker__header"},[s("button",{staticClass:"prev",class:{disabled:e.isLeftNavDisabled},attrs:{type:"button","aria-label":e.isRtl?"<":">"},on:{click:function(i){e.isRtl?e.nextYear():e.previousYear()}}},[e._t(e.isRtl?"nextButton":"prevButton")],2),e.allowedToShowView("year")?s("button",{staticClass:"month__year_btn",class:e.allowedToShowView("year")?"up":"",attrs:{type:"button"},on:{click:e.showYearCalendar}},[e.headlineMonthFormatter?s("p",{staticClass:"custom-formatted"},[e._v(" "+e._s(e.headlineMonthFormatter({pageDate:e.pageDate,selectedDate:e.selectedDate,pageYearName:e.pageYearName}))+" ")]):s("p",[e._v(e._s(e.pageYearName))])]):s("span",{staticClass:"month__year_text"},[e.headlineMonthFormatter?s("p",{staticClass:"custom-formatted"},[e._v(" "+e._s(e.headlineMonthFormatter({pageDate:e.pageDate,selectedDate:e.selectedDate,pageYearName:e.pageYearName}))+" ")]):s("p",[e._v(e._s(e.pageYearName))])]),s("button",{staticClass:"next",class:{disabled:e.isRightNavDisabled},attrs:{type:"button","aria-label":e.isRtl?">":"<"},on:{click:function(i){e.isRtl?e.previousYear():e.nextYear()}}},[e._t(e.isRtl?"prevButton":"nextButton")],2)]),s("div",{staticClass:"vdp-datepicker__pick-buttons vdp-datepicker__pick-buttons--month"},e._l(e.months,function(i,a){return s("button",{key:i.timestamp,staticClass:"cell month",class:{selected:i.isSelected,disabled:i.isDisabled},attrs:{type:"button"},on:{click:function(r){return r.stopPropagation(),e.selectMonth(i)}}},[e._v(" "+e._s(e.format(i.month,a))+" ")])}),0)],2)},I=[];const H={props:{monthFormatter:Function,headlineMonthFormatter:Function,nextDisabled:Function,prevDisabled:Function,showMonthView:Boolean,selectedDate:Date,pageDate:Date,pageTimestamp:Number,disabledDates:Object,calendarClass:[String,Object,Array],translation:Object,isRtl:Boolean,allowedToShowView:Function,useUtc:Boolean,monthsCustomDisplay:Array},data(){return{utils:c(this.useUtc)}},computed:{months(){var a;const e=this.pageDate;let t=[],s=this.useUtc?new Date(Date.UTC(e.getUTCFullYear(),0,e.getUTCDate())):new Date(e.getFullYear(),0,e.getDate(),e.getHours(),e.getMinutes()),i=((a=this.monthsCustomDisplay)==null?void 0:a.length)===12?this.monthsCustomDisplay:this.translation.months;for(let r=0;r<=11;r++)t.push({month:this.utils.getMonthName(r,i),timestamp:s.getTime(),isSelected:this.isSelectedMonth(s),isDisabled:this.isDisabledMonth(s)}),this.utils.setMonth(s,this.utils.getMonth(s)+1);return t},pageYearName(){const e=this.translation.yearSuffix;return`${this.utils.getFullYear(this.pageDate)}${e}`},isLeftNavDisabled(){return this.isRtl?this.isNextYearDisabled(this.pageTimestamp):this.isPreviousYearDisabled(this.pageTimestamp)},isRightNavDisabled(){return this.isRtl?this.isPreviousYearDisabled(this.pageTimestamp):this.isNextYearDisabled(this.pageTimestamp)}},methods:{format(e,t){return this.monthFormatter?this.monthFormatter(e,t):e},selectMonth(e){if(e.isDisabled)return!1;this.$emit("selectMonth",e)},changeYear(e){let t=this.pageDate;this.utils.setFullYear(t,this.utils.getFullYear(t)+e),this.$emit("changedYear",t)},previousYear(){this.isPreviousYearDisabled()||this.changeYear(-1)},isPreviousYearDisabled(){if(this.prevDisabled){let e=this.prevDisabled({view:"month"});if(e!=null)return e}return!this.disabledDates||!this.disabledDates.to?!1:this.utils.getFullYear(this.disabledDates.to)>=this.utils.getFullYear(this.pageDate)},nextYear(){this.isNextYearDisabled()||this.changeYear(1)},isNextYearDisabled(){if(this.nextDisabled){let e=this.nextDisabled({view:"month"});if(e!=null)return e}return!this.disabledDates||!this.disabledDates.from?!1:this.utils.getFullYear(this.disabledDates.from)<=this.utils.getFullYear(this.pageDate)},showYearCalendar(){this.$emit("showYearCalendar")},isSelectedMonth(e){return this.selectedDate&&this.utils.getFullYear(this.selectedDate)===this.utils.getFullYear(e)&&this.utils.getMonth(this.selectedDate)===this.utils.getMonth(e)},isDisabledMonth(e){let t=!1;return typeof this.disabledDates>"u"?!1:(typeof this.disabledDates.to<"u"&&this.disabledDates.to&&(this.utils.getMonth(e)<this.utils.getMonth(this.disabledDates.to)&&this.utils.getFullYear(e)<=this.utils.getFullYear(this.disabledDates.to)||this.utils.getFullYear(e)<this.utils.getFullYear(this.disabledDates.to))&&(t=!0),typeof this.disabledDates.from<"u"&&this.disabledDates.from&&(this.utils.getMonth(e)>this.utils.getMonth(this.disabledDates.from)&&this.utils.getFullYear(e)>=this.utils.getFullYear(this.disabledDates.from)||this.utils.getFullYear(e)>this.utils.getFullYear(this.disabledDates.from))&&(t=!0),typeof this.disabledDates.customPredictor=="function"&&this.disabledDates.customPredictor(e)&&(t=!0),t)}}},y={};var j=u(H,O,I,!1,E,null,null,null);function E(e){for(let t in y)this[t]=y[t]}const L=function(){return j.exports}();var A=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{directives:[{name:"show",rawName:"v-show",value:e.showYearView,expression:"showYearView"}],staticClass:"vdp-datepicker__calendar vdp-datepicker__calendar--year",class:[e.calendarClass],on:{mousedown:function(i){i.preventDefault()}}},[e._t("beforeCalendarHeader"),s("header",{staticClass:"vdp-datepicker__header"},[s("button",{staticClass:"prev",class:{disabled:e.isLeftNavDisabled},attrs:{type:"button","aria-label":"<"},on:{click:function(i){e.isRtl?e.nextDecade():e.previousDecade()}}},[e._t("prevButton")],2),e.headlineYearFormatter?s("p",{staticClass:"custom-formatted page-decade"},[e._v(" "+e._s(e.headlineYearFormatter({pageDate:e.pageDate,selectedDate:e.selectedDate,getPageDecade:e.getPageDecade}))+" ")]):s("p",{staticClass:"page-decade"},[e._v(e._s(e.getPageDecade))]),s("button",{staticClass:"next",class:{disabled:e.isRightNavDisabled},attrs:{type:"button","aria-label":">"},on:{click:function(i){e.isRtl?e.previousDecade():e.nextDecade()}}},[e._t("nextButton")],2)]),s("div",{staticClass:"vdp-datepicker__pick-buttons vdp-datepicker__pick-buttons--year"},e._l(e.years,function(i){return s("button",{key:i.timestamp,staticClass:"cell year",class:{selected:i.isSelected,disabled:i.isDisabled},attrs:{type:"button"},on:{click:function(a){return a.stopPropagation(),e.selectYear(i)}}},[s("span",[e._v(e._s(e.format(i.year)))])])}),0)],2)},W=[];const q={props:{yearFormatter:Function,headlineYearFormatter:Function,nextDisabled:Function,prevDisabled:Function,showYearView:Boolean,selectedDate:Date,pageDate:Date,pageTimestamp:Number,disabledDates:Object,highlighted:Object,calendarClass:[String,Object,Array],translation:Object,isRtl:Boolean,allowedToShowView:Function,useUtc:Boolean},data(){return{utils:c(this.useUtc)}},computed:{years(){const e=this.pageDate;let t=[],s=this.useUtc?new Date(Date.UTC(Math.floor(e.getUTCFullYear()/10)*10,e.getUTCMonth(),e.getUTCDate())):new Date(Math.floor(e.getFullYear()/10)*10,e.getMonth(),e.getDate(),e.getHours(),e.getMinutes());for(let i=0;i<10;i++)t.push({year:this.utils.getFullYear(s),timestamp:s.getTime(),isSelected:this.isSelectedYear(s),isDisabled:this.isDisabledYear(s)}),this.utils.setFullYear(s,this.utils.getFullYear(s)+1);return t},getPageDecade(){const e=Math.floor(this.utils.getFullYear(this.pageDate)/10)*10,t=e+9,s=this.translation.yearSuffix;return`${e} - ${t}${s}`},isLeftNavDisabled(){return this.isRtl?this.isNextDecadeDisabled(this.pageTimestamp):this.isPreviousDecadeDisabled(this.pageTimestamp)},isRightNavDisabled(){return this.isRtl?this.isPreviousDecadeDisabled(this.pageTimestamp):this.isNextDecadeDisabled(this.pageTimestamp)}},methods:{format(e){return this.yearFormatter?this.yearFormatter(e):e},selectYear(e){if(e.isDisabled)return!1;this.$emit("selectYear",e)},changeYear(e){let t=this.pageDate;this.utils.setFullYear(t,this.utils.getFullYear(t)+e),this.$emit("changedDecade",t)},previousDecade(){if(this.isPreviousDecadeDisabled())return!1;this.changeYear(-10)},isPreviousDecadeDisabled(){if(this.prevDisabled){let s=this.prevDisabled({view:"year"});if(s!=null)return s}if(!this.disabledDates||!this.disabledDates.to)return!1;const e=this.utils.getFullYear(this.disabledDates.to),t=Math.floor(this.utils.getFullYear(this.pageDate)/10)*10-1;return e>t},nextDecade(){if(this.isNextDecadeDisabled())return!1;this.changeYear(10)},isNextDecadeDisabled(){if(this.nextDisabled){let s=this.nextDisabled({view:"year"});if(s!=null)return s}if(!this.disabledDates||!this.disabledDates.from)return!1;const e=this.utils.getFullYear(this.disabledDates.from),t=Math.ceil(this.utils.getFullYear(this.pageDate)/10)*10;return e<t},isSelectedYear(e){return this.selectedDate&&this.utils.getFullYear(this.selectedDate)===this.utils.getFullYear(e)},isDisabledYear(e){let t=!1;return typeof this.disabledDates>"u"||!this.disabledDates?!1:(typeof this.disabledDates.to<"u"&&this.disabledDates.to&&this.utils.getFullYear(e)<this.utils.getFullYear(this.disabledDates.to)&&(t=!0),typeof this.disabledDates.from<"u"&&this.disabledDates.from&&this.utils.getFullYear(e)>this.utils.getFullYear(this.disabledDates.from)&&(t=!0),typeof this.disabledDates.customPredictor=="function"&&this.disabledDates.customPredictor(e)&&(t=!0),t)}}},_={};var J=u(q,A,W,!1,K,null,null,null);function K(e){for(let t in _)this[t]=_[t]}const X=function(){return J.exports}();var Z=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("svg",{attrs:{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"}},[s("path",{attrs:{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9.0016 0.71811C9.37534 0.32692 10 0.32692 10.3737 0.71811C10.7241 1.08485 10.7241 1.6623 10.3737 2.02904L5.62456 7L10.3737 11.971C10.7241 12.3377 10.7241 12.9152 10.3737 13.2819C10 13.6731 9.37534 13.6731 9.0016 13.2819L2.99997 7L9.0016 0.71811Z",fill:"currentColor"}})])},z=[];const G={},w={};var Q=u(G,Z,z,!1,ee,null,null,null);function ee(e){for(let t in w)this[t]=w[t]}const te=function(){return Q.exports}();var se=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("svg",{attrs:{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"}},[s("path",{attrs:{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M4.9984 0.71811C4.62466 0.32692 3.99999 0.32692 3.62625 0.71811C3.27587 1.08485 3.27587 1.6623 3.62625 2.02904L8.37544 7L3.62625 11.971C3.27587 12.3377 3.27587 12.9152 3.62625 13.2819C3.99999 13.6731 4.62466 13.6731 4.9984 13.2819L11 7L4.9984 0.71811Z",fill:"currentColor"}})])},ie=[];const ae={},v={};var ne=u(ae,se,ie,!1,re,null,null,null);function re(e){for(let t in v)this[t]=v[t]}const le=function(){return ne.exports}();var oe=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"vdp-datepicker",class:[e.wrapperClass],attrs:{"data-rtl":!!e.isRtl+"","data-inline":!!e.isInline+"","data-min-height":!!e.ensureMinHeight+"","data-is-open":!!e.isOpen+""}},[s("DateInput",{attrs:{id:e.id,selectedDate:e.selectedDate,resetTypedDate:e.resetTypedDate,format:e.format,translation:e.translation,inline:e.inline,name:e.name,refName:e.refName,openDate:e.openDate,placeholder:e.placeholder,inputClass:e.inputClass,typeable:e.typeable,disabled:e.disabled,required:e.required,bootstrapStyling:e.bootstrapStyling,useUtc:e.useUtc,isOpen:e.isOpen},on:{showCalendar:e.showCalendar,closeCalendar:e.close,typedDate:e.setTypedDate,clearDate:e.clearDate}},[e._t("afterDateInput",null,{slot:"afterDateInput"})],2),s("div",{staticClass:"vdp-datepicker__container"},[s("div",{staticClass:"vdp-datepicker__picker"},[e.allowedToShowView("day")?s("PickerDay",{attrs:{value:e.value,dayFormatter:e.dayFormatter,headlineDayFormatter:e.headlineDayFormatter,prevDisabled:e.prevDisabled,nextDisabled:e.nextDisabled,pageDate:e.pageDate,selectedDate:e.selectedDate,showDayView:e.showDayView,fullMonthName:e.fullMonthName,allowedToShowView:e.allowedToShowView,disabledDates:e.disabledDates,highlighted:e.highlighted,calendarClass:e.calendarClass,translation:e.translation,pageTimestamp:e.pageTimestamp,isRtl:e.isRtl,mondayFirst:e.mondayFirst,dayCellContent:e.dayCellContent,useUtc:e.useUtc,daysCustomDisplay:e.daysCustomDisplay},on:{changedMonth:e.handleChangedMonthFromDayPicker,selectDate:e.selectDate,showMonthCalendar:e.showMonthCalendar,selectedDisabled:e.selectDisabledDate}},[e._t("beforeCalendarHeader",null,{slot:"beforeCalendarHeader"}),e._t("prevButton",function(){return[s("IconLeft")]},{slot:"prevButton"}),e._t("nextButton",function(){return[s("IconRight")]},{slot:"nextButton"})],2):e._e(),e.allowedToShowView("month")?s("PickerMonth",{attrs:{value:e.value,monthFormatter:e.monthFormatter,headlineMonthFormatter:e.headlineMonthFormatter,prevDisabled:e.prevDisabled,nextDisabled:e.nextDisabled,pageDate:e.pageDate,selectedDate:e.selectedDate,showMonthView:e.showMonthView,allowedToShowView:e.allowedToShowView,disabledDates:e.disabledDates,calendarClass:e.calendarClass,translation:e.translation,isRtl:e.isRtl,useUtc:e.useUtc,monthsCustomDisplay:e.monthsCustomDisplay},on:{selectMonth:e.selectMonth,showYearCalendar:e.showYearCalendar,changedYear:e.setPageDate}},[e._t("beforeCalendarHeader",null,{slot:"beforeCalendarHeader"}),e._t("prevButton",function(){return[s("IconLeft")]},{slot:"prevButton"}),e._t("nextButton",function(){return[s("IconRight")]},{slot:"nextButton"})],2):e._e(),e.allowedToShowView("year")?s("PickerYear",{attrs:{value:e.value,yearFormatter:e.yearFormatter,headlineYearFormatter:e.headlineYearFormatter,prevDisabled:e.prevDisabled,nextDisabled:e.nextDisabled,pageDate:e.pageDate,selectedDate:e.selectedDate,showYearView:e.showYearView,allowedToShowView:e.allowedToShowView,disabledDates:e.disabledDates,calendarClass:e.calendarClass,translation:e.translation,isRtl:e.isRtl,useUtc:e.useUtc},on:{selectYear:e.selectYear,changedDecade:e.setPageDate}},[e._t("beforeCalendarHeader",null,{slot:"beforeCalendarHeader"}),e._t("prevButton",function(){return[s("IconLeft")]},{slot:"prevButton"}),e._t("nextButton",function(){return[s("IconRight")]},{slot:"nextButton"})],2):e._e()],1)])],1)},he=[];const me="",ue={components:{DateInput:k,PickerDay:B,PickerMonth:L,PickerYear:X,IconLeft:te,IconRight:le},props:{value:{validator:e=>g.validateDateInput(e)},name:String,refName:String,id:String,format:{type:[String,Function],default:"dd MMM yyyy"},language:{type:Object,default:()=>D},openDate:{validator:e=>g.validateDateInput(e)},dayCellContent:Function,dayFormatter:Function,monthFormatter:Function,yearFormatter:Function,headlineDayFormatter:Function,headlineMonthFormatter:Function,headlineYearFormatter:Function,nextDisabled:Function,prevDisabled:Function,fullMonthName:Boolean,disabledDates:Object,highlighted:Object,placeholder:String,inline:Boolean,calendarClass:[String,Object,Array],inputClass:[String,Object,Array],wrapperClass:[String,Object,Array],mondayFirst:Boolean,ensureMinHeight:Boolean,bootstrapStyling:Boolean,initialView:String,disabled:Boolean,required:Boolean,typeable:Boolean,useUtc:Boolean,useRtl:{type:Boolean,default:null},minimumView:{type:String,default:"day"},maximumView:{type:String,default:"year"},daysCustomDisplay:Array,monthsCustomDisplay:Array},data(){const e=this.openDate?new Date(this.openDate):new Date,t=c(this.useUtc);return{pageTimestamp:t.setDate(e,1),selectedDate:null,showDayView:!1,showMonthView:!1,showYearView:!1,calendarHeight:0,resetTypedDate:new Date,utils:t}},computed:{computedInitialView(){return this.initialView?this.initialView:this.minimumView},pageDate(){return new Date(this.pageTimestamp)},translation(){return this.language||D},isOpen(){return this.showDayView||this.showMonthView||this.showYearView},isInline(){return!!this.inline},isRtl(){return this.useRtl!=null?this.useRtl:this.translation.rtl===!0}},watch:{value(e){this.setValue(e)},openDate(){this.setPageDate()},initialView(){this.setInitialView()}},mounted(){this.init()},methods:{resetDefaultPageDate(){if(this.selectedDate===null){this.setPageDate();return}this.setPageDate(this.selectedDate)},showCalendar(){if(this.disabled||this.isInline)return!1;if(this.isOpen)return this.close(!0);this.setInitialView()},setInitialView(){const e=this.computedInitialView;if(!this.allowedToShowView(e))throw new Error(`initialView '${this.initialView}' cannot be rendered based on minimum '${this.minimumView}' and maximum '${this.maximumView}'`);switch(e){case"year":this.showYearCalendar();break;case"month":this.showMonthCalendar();break;default:this.showDayCalendar();break}},allowedToShowView(e){const t=["day","month","year"],s=t.indexOf(this.minimumView),i=t.indexOf(this.maximumView),a=t.indexOf(e);return a>=s&&a<=i},showDayCalendar(){return this.allowedToShowView("day")?(this.close(),this.showDayView=!0,!0):!1},showMonthCalendar(){return this.allowedToShowView("month")?(this.close(),this.showMonthView=!0,!0):!1},showYearCalendar(){return this.allowedToShowView("year")?(this.close(),this.showYearView=!0,!0):!1},setDate(e){const t=new Date(e);this.selectedDate=t,this.setPageDate(t),this.$emit("selected",t),this.$emit("input",t)},clearDate(){this.selectedDate=null,this.setPageDate(),this.$emit("selected",null),this.$emit("input",null),this.$emit("cleared")},selectDate(e){this.setDate(e.timestamp),this.isInline||this.close(!0),this.resetTypedDate=new Date},selectDisabledDate(e){this.$emit("selectedDisabled",e)},selectMonth(e){const t=new Date(e.timestamp);this.allowedToShowView("day")?(this.setPageDate(t),this.$emit("changedMonth",e),this.showDayCalendar()):this.selectDate(e)},selectYear(e){const t=new Date(e.timestamp);this.allowedToShowView("month")?(this.setPageDate(t),this.$emit("changedYear",e),this.showMonthCalendar()):this.selectDate(e)},setValue(e){if(typeof e=="string"||typeof e=="number"){let t=new Date(e);e=isNaN(t.valueOf())?null:t}if(!e){this.setPageDate(),this.selectedDate=null;return}this.selectedDate=e,this.setPageDate(e)},setPageDate(e){e||(this.openDate?e=new Date(this.openDate):e=new Date),this.pageTimestamp=this.utils.setDate(new Date(e),1)},handleChangedMonthFromDayPicker(e){this.setPageDate(e),this.$emit("changedMonth",e)},setTypedDate(e){this.setDate(e.getTime())},close(e){this.showDayView=this.showMonthView=this.showYearView=!1,this.isInline||(e&&this.$emit("closed"),document.removeEventListener("click",this.clickOutside,!1))},init(){this.value&&this.setValue(this.value),this.isInline&&this.setInitialView()}}},M={};var de=u(ue,oe,he,!1,ce,null,null,null);function ce(e){for(let t in M)this[t]=M[t]}const De=function(){return de.exports}();h.DatePicker=De,h.Language=d,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});