Socket
Socket
Sign inDemoInstall

hotel-datepicker

Package Overview
Dependencies
1
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.4.1 to 4.5.0

.babelrc

4

dist/js/hotel-datepicker.min.js

@@ -1,2 +0,2 @@

/*! hotel-datepicker 4.4.1 - Copyright 2022 Benito Lopez (http://lopezb.com) - https://github.com/benitolopez/hotel-datepicker - MIT */
var HotelDatepicker=function(){"use strict";function s(e,t){this._boundedEventHandlers={},this.id=s.getNewId(),t=t||{},this.format=t.format||"YYYY-MM-DD",this.infoFormat=t.infoFormat||this.format,this.separator=t.separator||" - ",this.startOfWeek=t.startOfWeek||"sunday",this.startDate=t.startDate||new Date,this.endDate=t.endDate||!1,this.minNights=t.minNights||1,this.maxNights=t.maxNights||0,this.selectForward=t.selectForward||!1,this.disabledDates=t.disabledDates||[],this.noCheckInDates=t.noCheckInDates||[],this.noCheckOutDates=t.noCheckOutDates||[],this.disabledDaysOfWeek=t.disabledDaysOfWeek||[],this.noCheckInDaysOfWeek=t.noCheckInDaysOfWeek||[],this.noCheckOutDaysOfWeek=t.noCheckOutDaysOfWeek||[],this.enableCheckout=t.enableCheckout||!1,this.preventContainerClose=t.preventContainerClose||!1,this.container=t.container||"",this.animationSpeed=t.animationSpeed||".5s",this.hoveringTooltip=t.hoveringTooltip||!0,this.autoClose=void 0===t.autoClose||t.autoClose,this.showTopbar=void 0===t.showTopbar||t.showTopbar,this.topbarPosition="bottom"===t.topbarPosition?"bottom":"top",this.moveBothMonths=t.moveBothMonths||!1,this.inline=t.inline||!1,this.clearButton=Boolean(this.inline&&t.clearButton),this.submitButton=Boolean(this.inline&&t.submitButton),this.submitButtonName=this.submitButton&&t.submitButtonName?t.submitButtonName:"",this.i18n=t.i18n||{selected:"Your stay:",night:"Night",nights:"Nights",button:"Close",clearButton:"Clear",submitButton:"Submit","checkin-disabled":"Check-in disabled","checkout-disabled":"Check-out disabled","day-names-short":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"day-names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"month-names-short":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"month-names":["January","February","March","April","May","June","July","August","September","October","November","December"],"error-more":"Date range should not be more than 1 night","error-more-plural":"Date range should not be more than %d nights","error-less":"Date range should not be less than 1 night","error-less-plural":"Date range should not be less than %d nights","info-more":"Please select a date range of at least 1 night","info-more-plural":"Please select a date range of at least %d nights","info-range":"Please select a date range between %d and %d nights","info-range-equal":"Please select a date range of %d nights","info-default":"Please select a date range"},this.getValue=t.getValue||function(){return e.value},this.setValue=t.setValue||function(t){e.value=t},this.onDayClick=void 0!==t.onDayClick&&t.onDayClick,this.onOpenDatepicker=void 0!==t.onOpenDatepicker&&t.onOpenDatepicker,this.onSelectRange=void 0!==t.onSelectRange&&t.onSelectRange,this.input=e,this.init()}var t=0;return s.prototype.addBoundedListener=function(t,e,s,i){t in this._boundedEventHandlers||(this._boundedEventHandlers[t]={}),e in this._boundedEventHandlers[t]||(this._boundedEventHandlers[t][e]=[]);s=s.bind(this);this._boundedEventHandlers[t][e].push([s,i]),t.addEventListener(e,s,i)},s.prototype.removeAllBoundedListeners=function(t,e){if(t in this._boundedEventHandlers){var s=this._boundedEventHandlers[t];if(e in s)for(var i=s[e],a=i.length;a--;){var n=i[a];t.removeEventListener(e,n[0],n[1])}}},s.getNewId=function(){return++t},s.prototype.setFechaI18n=function(){fecha.setGlobalDateI18n({dayNamesShort:this.i18n["day-names-short"],dayNames:this.i18n["day-names"],monthNamesShort:this.i18n["month-names-short"],monthNames:this.i18n["month-names"]})},s.prototype.getWeekDayNames=function(){var t="";if("monday"===this.startOfWeek)for(var e=0;e<7;e++)t+='<th class="datepicker__week-name">'+this.lang("day-names-short")[(1+e)%7]+"</th>";else for(var s=0;s<7;s++)t+='<th class="datepicker__week-name">'+this.lang("day-names-short")[s]+"</th>";return t},s.prototype.getMonthDom=function(t){return document.getElementById(this.getMonthTableId(t))},s.prototype.getMonthName=function(t){return this.lang("month-names")[t]},s.prototype.getDatepickerId=function(){return"datepicker-"+this.generateId()},s.prototype.getMonthTableId=function(t){return"month-"+t+"-"+this.generateId()},s.prototype.getCloseButtonId=function(){return"close-"+this.generateId()},s.prototype.getClearButtonId=function(){return"clear-"+this.generateId()},s.prototype.getSubmitButtonId=function(){return"submit-"+this.generateId()},s.prototype.getTooltipId=function(){return"tooltip-"+this.generateId()},s.prototype.getNextMonth=function(t){t=new Date(t.valueOf());return new Date(t.setMonth(t.getMonth()+1,1))},s.prototype.getPrevMonth=function(t){t=new Date(t.valueOf());return new Date(t.setMonth(t.getMonth()-1,1))},s.prototype.getDateString=function(t,e){return void 0===e&&(e=this.format),this.setFechaI18n(),fecha.format(t,e)},s.prototype.parseDate=function(t,e){return void 0===e&&(e=this.format),this.setFechaI18n(),fecha.parse(t,e)},s.prototype.init=function(){this.parent=this.container||this.input.parentElement,this.start=!1,this.end=!1,this.minDays=1<this.minNights?this.minNights+1:2,this.maxDays=0<this.maxNights?this.maxNights+1:0,this.startDate&&"string"==typeof this.startDate&&(this.startDate=this.parseDate(this.startDate)),this.endDate&&"string"==typeof this.endDate&&(this.endDate=this.parseDate(this.endDate)),this.isTouchDevice()&&(this.hoveringTooltip=!1),this.isOpen=!1,this.changed=!1,this.createDom();var t=new Date;this.startDate&&this.compareMonth(t,this.startDate)<0&&(t=new Date(this.startDate.getTime())),this.endDate&&0<this.compareMonth(this.getNextMonth(t),this.endDate)&&(t=new Date(this.getPrevMonth(this.endDate.getTime()))),0<this.disabledDates.length&&this.parseDisabledDates(),0<this.disabledDaysOfWeek.length&&this.getDisabledDays(),this.showMonth(t,1),this.showMonth(this.getNextMonth(t),2),this.topBarDefaultText(),this.inline&&(this.openDatepicker(),this.clearButton&&(document.getElementById(this.getClearButtonId()).disabled=!0),this.submitButton&&(document.getElementById(this.getSubmitButtonId()).disabled=!0)),this.addListeners(),this.isFirstDisabledDate=0,this.lastDisabledDate=!1},s.prototype.addListeners=function(){for(var e=this,t=this.datepicker.getElementsByClassName("datepicker__month-button--next"),s=0;s<t.length;s++)t[s].addEventListener("click",function(t){return e.goToNextMonth(t)});for(var i=this.datepicker.getElementsByClassName("datepicker__month-button--prev"),a=0;a<i.length;a++)i[a].addEventListener("click",function(t){return e.goToPreviousMonth(t)});this.addBoundedListener(this.input,"click",function(t){return e.openDatepicker(t)}),this.showTopbar&&!this.inline&&document.getElementById(this.getCloseButtonId()).addEventListener("click",function(t){return e.closeDatepicker(t)}),this.showTopbar&&this.clearButton&&document.getElementById(this.getClearButtonId()).addEventListener("click",function(t){return e.clearDatepicker(t)}),window.addEventListener("resize",function(t){return e.onResizeDatepicker(t)}),this.datepicker.addEventListener("mouseover",function(t){return e.datepickerHover(t)}),this.datepicker.addEventListener("mouseout",function(t){return e.datepickerMouseOut(t)}),this.addBoundedListener(this.input,"change",function(){return e.checkAndSetDefaultValue()})},s.prototype.generateId=function(){return this.input.id||this.id},s.prototype.createDom=function(){var t=this.createDatepickerDomString();this.parent.insertAdjacentHTML("beforeend",t),this.datepicker=document.getElementById(this.getDatepickerId())},s.prototype.createDatepickerDomString=function(){var t=this.inline?" datepicker--inline":"",e=(this.showTopbar&&"bottom"===this.topbarPosition&&(t+=" datepicker--topbar-bottom"),this.inline||(t+=" datepicker--topbar-has-close-button"),this.clearButton&&(t+=" datepicker--topbar-has-clear-button"),this.submitButton&&(t+=" datepicker--topbar-has-submit-button"),this.inline?"":' style="display:none"'),s='<div id="'+this.getDatepickerId()+'"'+e+' class="datepicker datepicker--closed'+t+'">',e=(s+='<div class="datepicker__inner">',"");this.showTopbar&&(e+='<div class="datepicker__topbar"><div class="datepicker__info datepicker__info--selected"><span class="datepicker__info datepicker__info--selected-label">'+this.lang("selected")+' </span> <strong class="datepicker__info-text datepicker__info-text--start-day">...</strong> <span class="datepicker__info-text datepicker__info--separator">'+this.separator+'</span> <strong class="datepicker__info-text datepicker__info-text--end-day">...</strong> <em class="datepicker__info-text datepicker__info-text--selected-days">(<span></span>)</em></div><div class="datepicker__info datepicker__info--feedback"></div>',this.inline||(e+='<button type="button" id="'+this.getCloseButtonId()+'" class="datepicker__close-button">'+this.lang("button")+"</button>"),(this.clearButton||this.submitButton)&&(e+='<div class="datepicker__buttons">'),this.clearButton&&(e+='<button type="button" id="'+this.getClearButtonId()+'" class="datepicker__clear-button">'+this.lang("clearButton")+"</button>"),this.submitButton&&(e+='<input type="submit" id="'+this.getSubmitButtonId()+'" class="datepicker__submit-button" value="'+this.lang("submitButton")+'" name="'+this.submitButtonName+'">'),(this.clearButton||this.submitButton)&&(e+="</div>"),e+="</div>"),this.showTopbar&&"top"===this.topbarPosition&&(s+=e),s+='<div class="datepicker__months">';for(var i=1;i<=2;i++)s+='<table id="'+this.getMonthTableId(i)+'" class="datepicker__month datepicker__month--month'+i+'"><thead><tr class="datepicker__month-caption"><th><span class="datepicker__month-button datepicker__month-button--prev" month="'+i+'">&lt;</span></th><th colspan="5" class="datepicker__month-name"></th><th><span class="datepicker__month-button datepicker__month-button--next" month="'+i+'">&gt;</span></th></tr><tr class="datepicker__week-days">'+this.getWeekDayNames(i)+"</tr></thead><tbody></tbody></table>";return s+="</div>",this.showTopbar&&"bottom"===this.topbarPosition&&(s+=e),s=(s+='<div style="display:none" id="'+this.getTooltipId()+'" class="datepicker__tooltip"></div>')+"</div>"+"</div>"},s.prototype.showMonth=function(t,e){t.setHours(0,0,0,0);var s=this.getMonthName(t.getMonth()),i=this.getMonthDom(e),a=i.getElementsByClassName("datepicker__month-name")[0],i=i.getElementsByTagName("tbody")[0];a.textContent=s+" "+t.getFullYear(),this.emptyElement(i),i.insertAdjacentHTML("beforeend",this.createMonthDomString(t)),this.updateSelectableRange(),this["month"+e]=t},s.prototype.createMonthDomString=function(t){var e=this,s=[],i="",a=(t.setDate(1),t.getDay()),n=t.getMonth();if(0<(a=0===a&&"monday"===this.startOfWeek?7:a))for(var o=a;0<o;o--){var h=new Date(t.getTime()-864e5*o),r=e.isValidDate(h.getTime());(e.startDate&&e.compareDay(h,e.startDate)<0||e.endDate&&0<e.compareDay(h,e.endDate))&&(r=!1),s.push({date:h,type:"lastMonth",day:h.getDate(),time:h.getTime(),valid:r})}for(var d=0;d<40;d++){var l=e.addDays(t,d);r=e.isValidDate(l.getTime()),(e.startDate&&e.compareDay(l,e.startDate)<0||e.endDate&&0<e.compareDay(l,e.endDate))&&(r=!1),s.push({date:l,type:l.getMonth()===n?"visibleMonth":"nextMonth",day:l.getDate(),time:l.getTime(),valid:r})}for(var c=0;c<6&&"nextMonth"!==s[7*c].type;c++){i+='<tr class="datepicker__week-row">';for(var p=0;p<7;p++){var m=s[7*c+("monday"===e.startOfWeek?p+1:p)],u=e.getDayClasses(m),y="",u=(e.hasClass(m,"datepicker__month-day--no-checkin")&&(y=e.i18n["checkin-disabled"]),e.hasClass(m,"datepicker__month-day--no-checkout")&&(y&&(y+=". "),y+=e.i18n["checkout-disabled"]),{daytype:m.type,time:m.time,class:u.join(" ")});y&&(u.title=y),i+='<td class="'+u.class+'" '+e.printAttributes(u)+">"+m.day+"</td>"}i+="</tr>"}return i},s.prototype.openDatepicker=function(){var e=this;this.isOpen||(this.removeClass(this.datepicker,"datepicker--closed"),this.addClass(this.datepicker,"datepicker--open"),this.checkAndSetDefaultValue(),this.inline||this.slideDown(this.datepicker,this.animationSpeed),this.isOpen=!0,this.showSelectedDays(),this.disableNextPrevButtons(),this.addBoundedListener(document,"click",function(t){return e.documentClick(t)}),this.onOpenDatepicker&&this.onOpenDatepicker())},s.prototype.closeDatepicker=function(){var t;this.isOpen&&!this.inline&&(this.removeClass(this.datepicker,"datepicker--open"),this.addClass(this.datepicker,"datepicker--closed"),this.slideUp(this.datepicker,this.animationSpeed),this.isOpen=!1,(t=document.createEvent("Event")).initEvent("afterClose",!0,!0),this.input.dispatchEvent(t),this.removeAllBoundedListeners(document,"click"))},s.prototype.autoclose=function(){this.autoClose&&this.changed&&this.isOpen&&this.start&&this.end&&!this.inline&&this.closeDatepicker()},s.prototype.documentClick=function(t){this.parent.contains(t.target)||t.target===this.input?"td"===t.target.tagName.toLowerCase()&&this.dayClicked(t.target):this.preventContainerClose||this.closeDatepicker()},s.prototype.datepickerHover=function(t){t.target.tagName&&"td"===t.target.tagName.toLowerCase()&&this.dayHovering(t.target)},s.prototype.datepickerMouseOut=function(t){t.target.tagName&&"td"===t.target.tagName.toLowerCase()&&(document.getElementById(this.getTooltipId()).style.display="none")},s.prototype.onResizeDatepicker=function(){this.checkAndSetDefaultValue(!0)},s.prototype.getDayClasses=function(t){var e,s,i,a=this.getDateString(t.time)===this.getDateString(new Date),n=this.getDateString(t.time)===this.getDateString(this.startDate),o=!1,h=!1,r=!1,d=!1,l=!1,c=!1;return!t.valid&&"visibleMonth"!==t.type||(e=this.getDateString(t.time,"YYYY-MM-DD"),0<this.disabledDates.length&&((i=this.getClosestDisabledDates(t.date))[0]&&i[1]&&this.compareDay(t.date,i[0])&&0<this.countDays(i[0],i[1])-2&&(s=this.countDays(i[1],t.date)-1,i=this.countDays(t.date,i[0])-1,(this.selectForward&&s<this.minDays||!this.selectForward&&s<this.minDays&&i<this.minDays)&&(t.valid=!1),!t.valid&&this.enableCheckout&&2==s&&(c=!0)),-1<this.disabledDates.indexOf(e)?(o=!(t.valid=!1),this.isFirstDisabledDate++,this.lastDisabledDate=t.date):this.isFirstDisabledDate=0,t.valid&&this.lastDisabledDate&&0<this.compareDay(t.date,this.lastDisabledDate)&&2===this.countDays(t.date,this.lastDisabledDate)&&(l=!0)),0<this.disabledDaysOfWeek.length&&-1<this.disabledDaysOfWeek.indexOf(fecha.format(t.time,"dddd"))&&(d=!(t.valid=!1)),0<this.noCheckInDates.length&&-1<this.noCheckInDates.indexOf(e)&&(l=!(h=!0)),0<this.noCheckOutDates.length&&-1<this.noCheckOutDates.indexOf(e)&&(r=!0),0<this.noCheckInDaysOfWeek.length&&-1<this.noCheckInDaysOfWeek.indexOf(fecha.format(t.time,"dddd"))&&(l=!(h=!0)),0<this.noCheckOutDaysOfWeek.length&&-1<this.noCheckOutDaysOfWeek.indexOf(fecha.format(t.time,"dddd"))&&(r=!0)),["datepicker__month-day","datepicker__month-day--"+t.type,"datepicker__month-day--"+(t.valid?"valid":"invalid"),a?"datepicker__month-day--today":"",o?"datepicker__month-day--disabled":"",o&&this.enableCheckout&&1===this.isFirstDisabledDate?"datepicker__month-day--checkout-enabled":"",c?"datepicker__month-day--before-disabled-date":"",n||l?"datepicker__month-day--checkin-only":"",h?"datepicker__month-day--no-checkin":"",r?"datepicker__month-day--no-checkout":"",d?"datepicker__month-day--day-of-week-disabled":""]},s.prototype.checkAndSetDayClasses=function(){for(var t=this,e=this.datepicker.getElementsByTagName("td"),s=0;s<e.length;s++){var i=parseInt(e[s].getAttribute("time"),10),a=new Date(i),n=e[s].getAttribute("daytype"),o=void 0,o=t.isValidDate(a.getTime()),n=((t.startDate&&t.compareDay(a,t.startDate)<0||t.endDate&&0<t.compareDay(a,t.endDate))&&(o=!1),{date:a,type:n,day:a.getDate(),time:i,valid:o}),a=t.getDayClasses(n);e[s].className=a.join(" ")}},s.prototype.checkAndSetDefaultValue=function(t){void 0===t&&(t=!1);var e,s=this.getValue(),s=s?s.split(this.separator):"";s&&2<=s.length?(e=this.format,this.changed=!1,this.setDateRange(this.parseDate(s[0],e),this.parseDate(s[1],e),t),this.changed=!0):this.showTopbar&&(this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none",t&&(s=new Date,this.startDate&&this.compareMonth(s,this.startDate)<0&&(s=new Date(this.startDate.getTime())),this.endDate&&0<this.compareMonth(this.getNextMonth(s),this.endDate)&&(s=new Date(this.getPrevMonth(this.endDate.getTime()))),this.start&&!this.end&&this.clearSelection(),this.showMonth(s,1),this.showMonth(this.getNextMonth(s),2)))},s.prototype.setDateRange=function(t,e,s){void 0===s&&(s=!1),t.getTime()>e.getTime()&&(i=e,e=t,t=i,i=null);var i=!0;if(!(i=this.startDate&&this.compareDay(t,this.startDate)<0||this.endDate&&0<this.compareDay(e,this.endDate)?!1:i))return this.showMonth(this.startDate,1),this.showMonth(this.getNextMonth(this.startDate),2),this.showSelectedDays(),void this.disableNextPrevButtons();t.setTime(t.getTime()+432e5),e.setTime(e.getTime()+432e5),this.start=t.getTime(),this.end=e.getTime(),0<this.compareDay(t,e)&&0===this.compareMonth(t,e)&&(e=this.getNextMonth(t)),0===this.compareMonth(t,e)&&(e=this.getNextMonth(t)),this.showMonth(t,1),this.showMonth(e,2),this.showSelectedDays(),this.disableNextPrevButtons(),this.checkSelection(),this.showSelectedInfo(),s||this.autoclose()},s.prototype.showSelectedDays=function(){var t=this;if(this.start||this.end)for(var e=this.datepicker.getElementsByTagName("td"),s=0;s<e.length;s++){var i=parseInt(e[s].getAttribute("time"),10);t.start&&t.end&&t.end>=i&&t.start<=i||t.start&&!t.end&&t.getDateString(t.start,"YYYY-MM-DD")===t.getDateString(i,"YYYY-MM-DD")?t.addClass(e[s],"datepicker__month-day--selected"):t.removeClass(e[s],"datepicker__month-day--selected"),t.start&&t.getDateString(t.start,"YYYY-MM-DD")===t.getDateString(i,"YYYY-MM-DD")?t.addClass(e[s],"datepicker__month-day--first-day-selected"):t.removeClass(e[s],"datepicker__month-day--first-day-selected"),t.end&&t.getDateString(t.end,"YYYY-MM-DD")===t.getDateString(i,"YYYY-MM-DD")?t.addClass(e[s],"datepicker__month-day--last-day-selected"):t.removeClass(e[s],"datepicker__month-day--last-day-selected")}},s.prototype.showSelectedInfo=function(){var t,e,s,i,a,n,o;this.showTopbar?(n=(a=this.datepicker.getElementsByClassName("datepicker__info--selected")[0]).getElementsByClassName("datepicker__info-text--start-day")[0],o=a.getElementsByClassName("datepicker__info-text--end-day")[0],t=a.getElementsByClassName("datepicker__info-text--selected-days")[0],e=document.getElementById(this.getCloseButtonId()),s=document.getElementById(this.getClearButtonId()),i=document.getElementById(this.getSubmitButtonId()),n.textContent="...",o.textContent="...",t.style.display="none",this.start&&(a.style.display="",n.textContent=this.getDateString(new Date(parseInt(this.start,10)),this.infoFormat),this.inline&&this.clearButton&&(s.disabled=!1)),this.end&&(o.textContent=this.getDateString(new Date(parseInt(this.end,10)),this.infoFormat)),this.start&&this.end?(n=1==(a=this.countDays(this.end,this.start)-1)?a+" "+this.lang("night"):a+" "+this.lang("nights"),o=this.getDateString(new Date(this.start))+this.separator+this.getDateString(new Date(this.end)),t.style.display="",t.firstElementChild.textContent=n,this.inline?this.submitButton&&(i.disabled=!1):e.disabled=!1,this.setValue(o,this.getDateString(new Date(this.start)),this.getDateString(new Date(this.end))),this.changed=!0):this.inline?(!this.clearButton||this.start||this.end||(s.disabled=!0),this.submitButton&&(i.disabled=!0)):e.disabled=!0):this.start&&this.end&&(a=this.getDateString(new Date(this.start))+this.separator+this.getDateString(new Date(this.end)),this.setValue(a,this.getDateString(new Date(this.start)),this.getDateString(new Date(this.end))),this.changed=!0)},s.prototype.dayClicked=function(t){if(!this.hasClass(t,"datepicker__month-day--invalid")){var e=this.start&&this.end||!this.start&&!this.end,s=parseInt(t.getAttribute("time"),10);if(e){if(this.hasClass(t,"datepicker__month-day--no-checkin"))return}else if(this.start){if(this.start>s&&this.hasClass(t,"datepicker__month-day--no-checkin"))return;var i=this.datepicker.querySelectorAll('td[time="'+this.start+'"]')[0];if(i&&this.hasClass(i,"datepicker__month-day--no-checkout")&&this.start>s)return;if(this.hasClass(t,"datepicker__month-day--no-checkout")&&s>this.start)return}this.addClass(t,"datepicker__month-day--selected"),e?(this.start=s,this.end=!1):this.start&&(this.end=s),this.start&&this.end&&this.start>this.end&&(i=this.end,this.end=this.start,this.start=i),this.start=parseInt(this.start,10),this.end=parseInt(this.end,10),this.clearHovering(),this.start&&!this.end&&this.dayHovering(t),this.updateSelectableRange(),this.checkSelection(),this.showSelectedInfo(),this.start&&this.end&&this.checkAndSetDayClasses(),this.showSelectedDays(),this.autoclose(),this.onDayClick&&this.onDayClick(),this.end&&this.onSelectRange&&this.onSelectRange()}},s.prototype.isValidDate=function(t){if(t=parseInt(t,10),this.startDate&&this.compareDay(t,this.startDate)<0||this.endDate&&0<this.compareDay(t,this.endDate))return!1;if(this.start&&!this.end){if(0<this.maxDays&&this.countDays(t,this.start)>this.maxDays||0<this.minDays&&1<this.countDays(t,this.start)&&this.countDays(t,this.start)<this.minDays)return!1;if(this.selectForward&&t<this.start)return!1;if(0<this.disabledDates.length){var e=this.getClosestDisabledDates(new Date(parseInt(this.start,10)));if(e[0]&&this.compareDay(t,e[0])<=0)return!1;if(e[1]&&0<=this.compareDay(t,e[1]))return!1}if(0<this.disabledDaysOfWeek.length){e=this.getClosestDisabledDays(new Date(parseInt(this.start,10)));if(e[0]&&this.compareDay(t,e[0])<=0)return!1;if(e[1]&&0<=this.compareDay(t,e[1]))return!1}}return!0},s.prototype.checkSelection=function(){var t=this,e=this.countDays(this.end,this.start),s=!!this.showTopbar&&this.datepicker.getElementsByClassName("datepicker__info--feedback")[0];if(this.maxDays&&e>this.maxDays){this.start=!1,this.end=!1;for(var i=this.datepicker.getElementsByTagName("td"),a=0;a<i.length;a++)t.removeClass(i[a],"datepicker__month-day--selected"),t.removeClass(i[a],"datepicker__month-day--first-day-selected"),t.removeClass(i[a],"datepicker__month-day--last-day-selected");this.showTopbar&&(n=this.maxDays-1,this.topBarErrorText(s,"error-more",n))}else if(this.minDays&&e<this.minDays){this.start=!1,this.end=!1;for(var n,o=this.datepicker.getElementsByTagName("td"),h=0;h<o.length;h++)t.removeClass(o[h],"datepicker__month-day--selected"),t.removeClass(o[h],"datepicker__month-day--first-day-selected"),t.removeClass(o[h],"datepicker__month-day--last-day-selected");this.showTopbar&&(n=this.minDays-1,this.topBarErrorText(s,"error-less",n))}else this.start||this.end?this.showTopbar&&(this.removeClass(s,"datepicker__info--error"),this.removeClass(s,"datepicker__info--help")):this.showTopbar&&(this.removeClass(s,"datepicker__info--error"),this.addClass(s,"datepicker__info--help"))},s.prototype.addDays=function(t,e){t=new Date(t);return t.setDate(t.getDate()+e),t},s.prototype.substractDays=function(t,e){t=new Date(t);return t.setDate(t.getDate()-e),t},s.prototype.countDays=function(t,e){return Math.abs(this.daysFrom1970(t)-this.daysFrom1970(e))+1},s.prototype.compareDay=function(t,e){t=parseInt(this.getDateString(t,"YYYYMMDD"),10)-parseInt(this.getDateString(e,"YYYYMMDD"),10);return 0<t?1:0==t?0:-1},s.prototype.compareMonth=function(t,e){t=parseInt(this.getDateString(t,"YYYYMM"),10)-parseInt(this.getDateString(e,"YYYYMM"),10);return 0<t?1:0==t?0:-1},s.prototype.daysFrom1970=function(t){return Math.round(this.toLocalTimestamp(t)/864e5)},s.prototype.toLocalTimestamp=function(t){return"string"!=typeof(t="object"==typeof t&&t.getTime?t.getTime():t)||t.match(/\d{13}/)||(t=this.parseDate(t).getTime()),t=parseInt(t,10)-60*(new Date).getTimezoneOffset()*1e3},s.prototype.printAttributes=function(t){var e,s=t,i="";for(e in t)Object.prototype.hasOwnProperty.call(s,e)&&(i+=e+'="'+s[e]+'" ');return i},s.prototype.goToNextMonth=function(t){var t=t.target.getAttribute("month"),e=1<t,s=e?this.month2:this.month1,s=this.getNextMonth(s);!this.isSingleMonth()&&!e&&0<=this.compareMonth(s,this.month2)||this.isMonthOutOfRange(s)||(this.moveBothMonths&&e&&this.showMonth(this.month2,1),this.showMonth(s,t),this.showSelectedDays(),this.disableNextPrevButtons())},s.prototype.goToPreviousMonth=function(t){var t=t.target.getAttribute("month"),e=1<t,s=e?this.month2:this.month1,s=this.getPrevMonth(s);e&&this.compareMonth(s,this.month1)<=0||this.isMonthOutOfRange(s)||(this.moveBothMonths&&!e&&this.showMonth(this.month1,2),this.showMonth(s,t),this.showSelectedDays(),this.disableNextPrevButtons())},s.prototype.isSingleMonth=function(){return!this.isVisible(this.getMonthDom(2))},s.prototype.isMonthOutOfRange=function(t){t=new Date(t.valueOf());return!!(this.startDate&&new Date(t.getFullYear(),t.getMonth()+1,0,23,59,59)<this.startDate||this.endDate&&new Date(t.getFullYear(),t.getMonth(),1)>this.endDate)},s.prototype.disableNextPrevButtons=function(){var t,e,s;this.isSingleMonth()||(t=parseInt(this.getDateString(this.month1,"YYYYMM"),10),e=parseInt(this.getDateString(this.month2,"YYYYMM"),10),t=Math.abs(t-e),e=this.datepicker.getElementsByClassName("datepicker__month-button--next"),s=this.datepicker.getElementsByClassName("datepicker__month-button--prev"),1<t&&89!==t?(this.removeClass(e[0],"datepicker__month-button--disabled"),this.removeClass(s[1],"datepicker__month-button--disabled")):(this.addClass(e[0],"datepicker__month-button--disabled"),this.addClass(s[1],"datepicker__month-button--disabled")),this.isMonthOutOfRange(this.getPrevMonth(this.month1))?this.addClass(s[0],"datepicker__month-button--disabled"):this.removeClass(s[0],"datepicker__month-button--disabled"),this.isMonthOutOfRange(this.getNextMonth(this.month2))?this.addClass(e[1],"datepicker__month-button--disabled"):this.removeClass(e[1],"datepicker__month-button--disabled"))},s.prototype.topBarDefaultText=function(){var t,e;this.showTopbar&&(t="",t=this.minDays&&this.maxDays?this.minDays===this.maxDays?this.lang("info-range-equal"):this.lang("info-range"):this.minDays&&2<this.minDays?this.lang("info-more-plural"):this.minDays?this.lang("info-more"):this.lang("info-default"),e=this.datepicker.getElementsByClassName("datepicker__info--feedback")[0],t=t.replace(/%d/,this.minDays-1).replace(/%d/,this.maxDays-1),this.addClass(e,"datepicker__info--help"),this.removeClass(e,"datepicker__info--error"),e.textContent=t)},s.prototype.topBarErrorText=function(t,e,s){this.showTopbar&&(this.addClass(t,"datepicker__info--error"),this.removeClass(t,"datepicker__info--help"),1<s?(e=(e=this.lang(e+"-plural")).replace("%d",s),t.textContent=e):e=this.lang(e),this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none")},s.prototype.updateSelectableRange=function(){for(var t,e=this,s=this.datepicker.getElementsByTagName("td"),i=this.start&&!this.end,a=0;a<s.length;a++)e.hasClass(s[a],"datepicker__month-day--invalid")&&e.hasClass(s[a],"datepicker__month-day--tmp")&&(e.removeClass(s[a],"datepicker__month-day--tmp"),e.hasClass(s[a],"datepicker__month-day--tmpinvalid")?e.removeClass(s[a],"datepicker__month-day--tmpinvalid"):(e.removeClass(s[a],"datepicker__month-day--invalid"),e.addClass(s[a],"datepicker__month-day--valid"))),i?e.hasClass(s[a],"datepicker__month-day--visibleMonth")&&(e.hasClass(s[a],"datepicker__month-day--valid")||e.hasClass(s[a],"datepicker__month-day--disabled")||e.hasClass(s[a],"datepicker__month-day--before-disabled-date"))&&(t=parseInt(s[a].getAttribute("time"),10),e.isValidDate(t)?(e.addClass(s[a],"datepicker__month-day--valid"),e.addClass(s[a],"datepicker__month-day--tmp"),e.removeClass(s[a],"datepicker__month-day--invalid"),e.removeClass(s[a],"datepicker__month-day--disabled")):(e.hasClass(s[a],"datepicker__month-day--invalid")&&e.addClass(s[a],"datepicker__month-day--tmpinvalid"),e.addClass(s[a],"datepicker__month-day--invalid"),e.addClass(s[a],"datepicker__month-day--tmp"),e.removeClass(s[a],"datepicker__month-day--valid"))):(e.hasClass(s[a],"datepicker__month-day--checkout-enabled")||e.hasClass(s[a],"datepicker__month-day--before-disabled-date"))&&(e.addClass(s[a],"datepicker__month-day--invalid"),e.removeClass(s[a],"datepicker__month-day--valid"),e.hasClass(s[a],"datepicker__month-day--before-disabled-date")||e.addClass(s[a],"datepicker__month-day--disabled"));return!0},s.prototype.dayHovering=function(t){var e,s,i,a=this,n=parseInt(t.getAttribute("time"),10),o="";if(!this.hasClass(t,"datepicker__month-day--invalid")){for(var h,r=this.datepicker.getElementsByTagName("td"),d=0;d<r.length;d++){var l=parseInt(r[d].getAttribute("time"),10);l===n?a.addClass(r[d],"datepicker__month-day--hovering"):a.removeClass(r[d],"datepicker__month-day--hovering"),a.start&&!a.end&&(a.start<l&&l<=n||a.start>l&&n<=l)?a.addClass(r[d],"datepicker__month-day--hovering"):a.removeClass(r[d],"datepicker__month-day--hovering")}this.start&&!this.end&&(h=this.countDays(n,this.start)-1,this.hoveringTooltip&&("function"==typeof this.hoveringTooltip?o=this.hoveringTooltip(h,this.start,n):!0===this.hoveringTooltip&&0<h&&(o=h+" "+(1==h?this.lang("night"):this.lang("nights")))))}o?(h=t.getBoundingClientRect(),t=this.datepicker.getBoundingClientRect(),e=h.left-t.left,s=h.top-t.top,e+=h.width/2,(i=document.getElementById(this.getTooltipId())).style.display="",i.textContent=o,t=i.getBoundingClientRect().width,h=i.getBoundingClientRect().height,e-=t/2,s-=h,setTimeout(function(){i.style.left=e+"px",i.style.top=s+"px"},10)):document.getElementById(this.getTooltipId()).style.display="none"},s.prototype.clearHovering=function(){for(var t=this.datepicker.getElementsByTagName("td"),e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--hovering");document.getElementById(this.getTooltipId()).style.display="none"},s.prototype.clearSelection=function(){this.start=!1,this.end=!1;for(var t=this.datepicker.getElementsByTagName("td"),e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--selected"),this.removeClass(t[e],"datepicker__month-day--first-day-selected"),this.removeClass(t[e],"datepicker__month-day--last-day-selected"),this.removeClass(t[e],"datepicker__month-day--hovering");this.setValue(""),this.checkSelection(),this.showSelectedInfo(),this.showSelectedDays()},s.prototype.clearDatepicker=function(){this.start=!1,this.end=!1;for(var t=this.datepicker.getElementsByTagName("td"),e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--selected"),this.removeClass(t[e],"datepicker__month-day--first-day-selected"),this.removeClass(t[e],"datepicker__month-day--last-day-selected"),this.removeClass(t[e],"datepicker__month-day--hovering");this.setValue(""),this.checkSelection(),this.showSelectedInfo(),this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none",this.showSelectedDays(),this.updateSelectableRange()},s.prototype.parseDisabledDates=function(){var t=[];this.setFechaI18n();for(var e=0;e<this.disabledDates.length;e++)t[e]=fecha.parse(this.disabledDates[e],"YYYY-MM-DD");t.sort(function(t,e){return t-e}),this.disabledDatesTime=t},s.prototype.getClosestDisabledDates=function(t){var e=[!1,!1];if(t<this.disabledDatesTime[0])e=this.enableCheckout?[!1,this.addDays(this.disabledDatesTime[0],1)]:[!1,this.disabledDatesTime[0]];else if(t>this.disabledDatesTime[this.disabledDatesTime.length-1])e=[this.disabledDatesTime[this.disabledDatesTime.length-1],!1];else{for(var s,i=this.disabledDatesTime.length,a=this.disabledDatesTime.length,n=Math.abs(new Date(0,0,0).valueOf()),o=n,h=-n,r=0;r<this.disabledDatesTime.length;++r)(s=t-this.disabledDatesTime[r])<0&&h<s&&(a=r,h=s),0<s&&s<o&&(i=r,o=s);this.disabledDatesTime[i]&&(e[0]=this.disabledDatesTime[i]),void 0===this.disabledDatesTime[i]?e[1]=!1:this.enableCheckout?e[1]=this.addDays(this.disabledDatesTime[a],1):e[1]=this.disabledDatesTime[a]}return e},s.prototype.getDisabledDays=function(){for(var t=[],e=[],s=new Date,i=0;i<7;i++){var a=this.addDays(s,i);t[fecha.format(a,"d")]=fecha.format(a,"dddd")}for(var n=0;n<this.disabledDaysOfWeek.length;n++)e.push(t.indexOf(this.disabledDaysOfWeek[n]));e.sort(),this.disabledDaysIndexes=e},s.prototype.getClosestDisabledDays=function(t){for(var e=[!1,!1],s=0;s<7;s++){var i=this.substractDays(t,s);if(-1<this.disabledDaysIndexes.indexOf(parseInt(fecha.format(i,"d"),10))){e[0]=i;break}}for(var a=0;a<7;a++){var n=this.addDays(t,a);if(-1<this.disabledDaysIndexes.indexOf(parseInt(fecha.format(n,"d"),10))){e[1]=n;break}}return e},s.prototype.lang=function(t){return t in this.i18n?this.i18n[t]:""},s.prototype.emptyElement=function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},s.prototype.classRegex=function(t){return new RegExp("(^|\\s+)"+t+"(\\s+|$)")},s.prototype.hasClass=function(t,e){return this.classRegex(e).test(t.className)},s.prototype.addClass=function(t,e){this.hasClass(t,e)||(t.className=t.className+" "+e)},s.prototype.removeClass=function(t,e){t.className=t.className.replace(this.classRegex(e)," ")},s.prototype.isVisible=function(t){return t.offsetWidth||t.offsetHeight||t.getClientRects().length},s.prototype.slideDown=function(t,e){t.style.display="";var s=t.getBoundingClientRect().height;t.style.height=0,this.recalc(t.offsetHeight),t.style.transition="height "+e,t.style.height=s+"px",t.addEventListener("transitionend",function(){t.style.height=t.style.transition=t.style.display=""})},s.prototype.slideUp=function(t,e){var s=t.getBoundingClientRect().height;t.style.height=s+"px",this.recalc(t.offsetHeight),t.style.transition="height "+e,t.style.height=0,t.addEventListener("transitionend",function(){t.style.display="none"})},s.prototype.recalc=function(t){return t.offsetHeight},s.prototype.isTouchDevice=function(){return"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch},s.prototype.open=function(){this.openDatepicker()},s.prototype.close=function(){this.closeDatepicker()},s.prototype.getDatePicker=function(){return this.datepicker},s.prototype.setRange=function(t,e){"string"==typeof t&&"string"==typeof e&&(t=this.parseDate(t),e=this.parseDate(e)),this.setDateRange(t,e)},s.prototype.clear=function(){this.clearSelection()},s.prototype.getNights=function(){var t,e,s=0;return this.start&&this.end?s=this.countDays(this.end,this.start)-1:(t=(t=this.getValue())?t.split(this.separator):"")&&2<=t.length&&(e=this.format,s=this.countDays(this.parseDate(t[0],e),this.parseDate(t[1],e))-1),s},s.prototype.destroy=function(){document.getElementById(this.getDatepickerId())&&(this.removeAllBoundedListeners(this.input,"click"),this.removeAllBoundedListeners(document,"click"),this.removeAllBoundedListeners(this.input,"change"),this.datepicker.parentNode.removeChild(this.datepicker))},s}();
/*! hotel-datepicker 4.5.0 - Copyright 2022 Benito Lopez (http://lopezb.com) - https://github.com/benitolopez/hotel-datepicker - MIT */
var HotelDatepicker=function(t){"use strict";function e(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:function(){return t[s]}})}})),e.default=t,Object.freeze(e)}var s=e(t);let i=0;class a{constructor(t,e){this._boundedEventHandlers={},this.id=a.getNewId();const s=e||{};this.format=s.format||"YYYY-MM-DD",this.infoFormat=s.infoFormat||this.format,this.ariaDayFormat=s.ariaDayFormat||"dddd, MMMM DD, YYYY",this.separator=s.separator||" - ",this.startOfWeek=s.startOfWeek||"sunday",this.startDate=s.startDate||new Date,this.endDate=s.endDate||!1,this.minNights=s.minNights||1,this.maxNights=s.maxNights||0,this.selectForward=s.selectForward||!1,this.disabledDates=s.disabledDates||[],this.noCheckInDates=s.noCheckInDates||[],this.noCheckOutDates=s.noCheckOutDates||[],this.disabledDaysOfWeek=s.disabledDaysOfWeek||[],this.noCheckInDaysOfWeek=s.noCheckInDaysOfWeek||[],this.noCheckOutDaysOfWeek=s.noCheckOutDaysOfWeek||[],this.enableCheckout=s.enableCheckout||!1,this.preventContainerClose=s.preventContainerClose||!1,this.container=s.container||"",this.animationSpeed=s.animationSpeed||".5s",this.hoveringTooltip=s.hoveringTooltip||!0,this.autoClose=void 0===s.autoClose||s.autoClose,this.showTopbar=void 0===s.showTopbar||s.showTopbar,this.topbarPosition="bottom"===s.topbarPosition?"bottom":"top",this.moveBothMonths=s.moveBothMonths||!1,this.inline=s.inline||!1,this.clearButton=s.clearButton||!1,this.submitButton=Boolean(this.inline&&s.submitButton),this.submitButtonName=this.submitButton&&s.submitButtonName?s.submitButtonName:"",this.i18n=s.i18n||{selected:"Your stay:",night:"Night",nights:"Nights",button:"Close",clearButton:"Clear",submitButton:"Submit","checkin-disabled":"Check-in disabled","checkout-disabled":"Check-out disabled","day-names-short":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"day-names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"month-names-short":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"month-names":["January","February","March","April","May","June","July","August","September","October","November","December"],"error-more":"Date range should not be more than 1 night","error-more-plural":"Date range should not be more than %d nights","error-less":"Date range should not be less than 1 night","error-less-plural":"Date range should not be less than %d nights","info-more":"Please select a date range of at least 1 night","info-more-plural":"Please select a date range of at least %d nights","info-range":"Please select a date range between %d and %d nights","info-range-equal":"Please select a date range of %d nights","info-default":"Please select a date range","aria-application":"Calendar","aria-selected-checkin":"Selected as check-in date, %s","aria-selected-checkout":"Selected as check-out date, %s","aria-selected":"Selected, %s","aria-disabled":"Not available, %s","aria-choose-checkin":"Choose %s as your check-in date","aria-choose-checkout":"Choose %s as your check-out date","aria-prev-month":"Move backward to switch to the previous month","aria-next-month":"Move forward to switch to the next month","aria-close-button":"Close the datepicker","aria-clear-button":"Clear the selected dates","aria-submit-button":"Submit the form"},this.getValue=s.getValue||function(){return t.value},this.setValue=s.setValue||function(e){t.value=e},this.onDayClick=void 0!==s.onDayClick&&s.onDayClick,this.onOpenDatepicker=void 0!==s.onOpenDatepicker&&s.onOpenDatepicker,this.onSelectRange=void 0!==s.onSelectRange&&s.onSelectRange,this.input=t,this.init()}addBoundedListener(t,e,s,i){t in this._boundedEventHandlers||(this._boundedEventHandlers[t]={}),e in this._boundedEventHandlers[t]||(this._boundedEventHandlers[t][e]=[]);const a=s.bind(this);this._boundedEventHandlers[t][e].push([a,i]),t.addEventListener(e,a,i)}removeAllBoundedListeners(t,e){if(t in this._boundedEventHandlers){const s=this._boundedEventHandlers[t];if(e in s){const i=s[e];for(let s=i.length;s--;){const a=i[s];t.removeEventListener(e,a[0],a[1])}}}}static getNewId(){return++i}setFechaI18n(){s.setGlobalDateI18n({dayNamesShort:this.i18n["day-names-short"],dayNames:this.i18n["day-names"],monthNamesShort:this.i18n["month-names-short"],monthNames:this.i18n["month-names"]})}getWeekDayNames(){let t="";if("monday"===this.startOfWeek){for(let e=0;e<7;e++)t+='<th class="datepicker__week-name">'+this.lang("day-names-short")[(1+e)%7]+"</th>";return t}for(let e=0;e<7;e++)t+='<th class="datepicker__week-name">'+this.lang("day-names-short")[e]+"</th>";return t}getMonthDom(t){return document.getElementById(this.getMonthTableId(t))}getMonthName(t){return this.lang("month-names")[t]}getDatepickerId(){return"datepicker-"+this.generateId()}getMonthTableId(t){return"month-"+t+"-"+this.generateId()}getCloseButtonId(){return"close-"+this.generateId()}getClearButtonId(){return"clear-"+this.generateId()}getSubmitButtonId(){return"submit-"+this.generateId()}getTooltipId(){return"tooltip-"+this.generateId()}getNextMonth(t){const e=new Date(t.valueOf());return new Date(e.setMonth(e.getMonth()+1,1))}getPrevMonth(t){const e=new Date(t.valueOf());return new Date(e.setMonth(e.getMonth()-1,1))}getDateString(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.format;return this.setFechaI18n(),s.format(t,e)}parseDate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.format;return this.setFechaI18n(),s.parse(t,e)}init(){this.parent=this.container?this.container:this.input.parentElement,this.start=!1,this.end=!1,this.minDays=this.minNights>1?this.minNights+1:2,this.maxDays=this.maxNights>0?this.maxNights+1:0,this.startDate&&"string"==typeof this.startDate&&(this.startDate=this.parseDate(this.startDate)),this.endDate&&"string"==typeof this.endDate&&(this.endDate=this.parseDate(this.endDate)),this.isTouchDevice()&&(this.hoveringTooltip=!1),this.isOpen=!1,this.changed=!1,this.justEsc=!1,this.isOnFocus=!1,this.createDom();let t=new Date;if(this.startDate&&this.compareMonth(t,this.startDate)<0&&(t=new Date(this.startDate.getTime())),this.endDate&&this.compareMonth(this.getNextMonth(t),this.endDate)>0&&(t=new Date(this.getPrevMonth(this.endDate.getTime()))),this.disabledDates.length>0&&this.parseDisabledDates(),this.disabledDaysOfWeek.length>0&&this.getDisabledDays(),this.showMonth(t,1),this.showMonth(this.getNextMonth(t),2),this.setDayIndexes(),this.topBarDefaultText(),this.inline&&(this.openDatepicker(),this.submitButton)){const t=document.getElementById(this.getSubmitButtonId());t.disabled=!0,t.setAttribute("aria-disabled","true")}if(this.clearButton&&(this.inline||!this.start&&!this.end)){const t=document.getElementById(this.getClearButtonId());t.disabled=!0,t.setAttribute("aria-disabled","true")}this.addListeners(),this.isFirstDisabledDate=0,this.lastDisabledDate=!1,this.setDayAriaAttributes()}addListeners(){const t=this.datepicker.getElementsByClassName("datepicker__month-button--next");for(let e=0;e<t.length;e++)t[e].addEventListener("click",(t=>this.goToNextMonth(t)));const e=this.datepicker.getElementsByClassName("datepicker__month-button--prev");for(let t=0;t<e.length;t++)e[t].addEventListener("click",(t=>this.goToPreviousMonth(t)));this.addBoundedListener(this.input,"click",(t=>this.openDatepicker(t))),this.showTopbar&&!this.inline&&document.getElementById(this.getCloseButtonId()).addEventListener("click",(t=>this.closeDatepicker(t))),this.showTopbar&&this.clearButton&&document.getElementById(this.getClearButtonId()).addEventListener("click",(t=>this.clearDatepicker(t))),window.addEventListener("resize",(t=>this.onResizeDatepicker(t))),this.datepicker.addEventListener("mouseover",(t=>this.datepickerHover(t))),this.datepicker.addEventListener("mouseout",(t=>this.datepickerMouseOut(t))),this.addBoundedListener(this.input,"change",(()=>this.checkAndSetDefaultValue())),this.inline||(this.justEsc||this.addBoundedListener(this.input,"focus",(t=>this.openDatepicker(t))),this.justEsc=!1),window.addEventListener("keydown",(t=>this.doKeyDown(t))),document.addEventListener("focus",(t=>this.checkOnFocus(t)),!0)}generateId(){return this.input.id?this.input.id:this.id}createDom(){const t=this.createDatepickerDomString();this.parent.insertAdjacentHTML("beforeend",t),this.datepicker=document.getElementById(this.getDatepickerId())}createDatepickerDomString(){let t=this.inline?" datepicker--inline":"";this.showTopbar&&("bottom"===this.topbarPosition?t+=" datepicker--topbar-bottom":t+=" datepicker--topbar-top"),this.inline||(t+=" datepicker--topbar-has-close-button"),this.clearButton&&(t+=" datepicker--topbar-has-clear-button"),this.submitButton&&(t+=" datepicker--topbar-has-submit-button");const e=this.inline?"":' style="display:none"';let s='<div id="'+this.getDatepickerId()+'"'+e+' class="datepicker datepicker--closed'+t+'">';s+='<div class="datepicker__inner">';let i="";if(this.showTopbar){i+='<div class="datepicker__topbar"><div class="datepicker__info datepicker__info--selected"><span class="datepicker__info datepicker__info--selected-label">'+this.lang("selected")+' </span> <strong class="datepicker__info-text datepicker__info-text--start-day">...</strong> <span class="datepicker__info-text datepicker__info--separator">'+this.separator+'</span> <strong class="datepicker__info-text datepicker__info-text--end-day">...</strong> <em class="datepicker__info-text datepicker__info-text--selected-days">(<span></span>)</em></div><div class="datepicker__info datepicker__info--feedback"></div>';let t="";this.clearButton&&(t+='<button type="button" id="'+this.getClearButtonId()+'" class="datepicker__clear-button" aria-label="'+this.i18n["aria-clear-button"]+'">'+this.lang("clearButton")+"</button>"),this.inline||(t+='<button type="button" id="'+this.getCloseButtonId()+'" class="datepicker__close-button" aria-label="'+this.i18n["aria-close-button"]+'">'+this.lang("button")+"</button>"),this.submitButton&&(t+='<input type="submit" id="'+this.getSubmitButtonId()+'" class="datepicker__submit-button" value="'+this.lang("submitButton")+'" name="'+this.submitButtonName+'" aria-label="'+this.i18n["aria-submit-button"]+'">'),t&&(i+='<div class="datepicker__buttons">'+t+"</div>"),i+="</div>"}this.showTopbar&&"top"===this.topbarPosition&&(s+=i),s+='<div class="datepicker__months" role="application" aria-roledescription="datepicker" aria-label="'+this.i18n["aria-application"]+'">';for(let t=1;t<=2;t++)s+='<table role="presentation" id="'+this.getMonthTableId(t)+'" class="datepicker__month datepicker__month--month'+t+'"><thead><tr class="datepicker__month-caption"><th><span role="button" tabindex="0" aria-label="'+this.i18n["aria-prev-month"]+'" class="datepicker__month-button datepicker__month-button--prev" month="'+t+'">&lt;</span></th><th colspan="5" class="datepicker__month-name"></th><th><span role="button" tabindex="0" aria-label="'+this.i18n["aria-next-month"]+'" class="datepicker__month-button datepicker__month-button--next" month="'+t+'">&gt;</span></th></tr><tr class="datepicker__week-days" aria-hidden="true" role="presentation">'+this.getWeekDayNames(t)+"</tr></thead><tbody></tbody></table>";return s+="</div>",this.showTopbar&&"bottom"===this.topbarPosition&&(s+=i),s+='<div style="display:none" id="'+this.getTooltipId()+'" class="datepicker__tooltip"></div>',s+="</div>",s+="</div>",s}showMonth(t,e){t.setHours(0,0,0,0);const s=this.getMonthName(t.getMonth()),i=this.getMonthDom(e),a=i.getElementsByClassName("datepicker__month-name")[0],n=i.getElementsByTagName("tbody")[0];a.textContent=s+" "+t.getFullYear(),this.emptyElement(n),n.insertAdjacentHTML("beforeend",this.createMonthDomString(t)),this.updateSelectableRange(),this["month"+e]=t}createMonthDomString(t){const e=[];let s,i="";t.setDate(1);let a=t.getDay();const n=t.getMonth();if(0===a&&"monday"===this.startOfWeek&&(a=7),a>0)for(let i=a;i>0;i--){const a=new Date(t.getTime()-864e5*i);s=this.isValidDate(a.getTime()),(this.startDate&&this.compareDay(a,this.startDate)<0||this.endDate&&this.compareDay(a,this.endDate)>0)&&(s=!1),e.push({date:a,type:"lastMonth",day:a.getDate(),time:a.getTime(),valid:s})}for(let i=0;i<40;i++){const a=this.addDays(t,i);s=this.isValidDate(a.getTime()),(this.startDate&&this.compareDay(a,this.startDate)<0||this.endDate&&this.compareDay(a,this.endDate)>0)&&(s=!1),e.push({date:a,type:a.getMonth()===n?"visibleMonth":"nextMonth",day:a.getDate(),time:a.getTime(),valid:s})}for(let t=0;t<6&&"nextMonth"!==e[7*t].type;t++){i+='<tr class="datepicker__week-row">';for(let s=0;s<7;s++){let a="monday"===this.startOfWeek?s+1:s;a=e[7*t+a];const n=this.getDayClasses(a);let h="";this.hasClass(a,"datepicker__month-day--no-checkin")&&(h=this.i18n["checkin-disabled"]),this.hasClass(a,"datepicker__month-day--no-checkout")&&(h&&(h+=". "),h+=this.i18n["checkout-disabled"]);const r={daytype:a.type,time:a.time,class:n.join(" "),d:s+1};h&&(r.title=h),r.role="button",this.getDateString(a.time)===this.getDateString(new Date)&&(r.tabindex="0"),i+='<td class="'+r.class+'" '+this.printAttributes(r)+">"+a.day+"</td>"}i+="</tr>"}return i}openDatepicker(){this.isOpen||(this.removeClass(this.datepicker,"datepicker--closed"),this.addClass(this.datepicker,"datepicker--open"),this.checkAndSetDefaultValue(),this.inline||this.slideDown(this.datepicker,this.animationSpeed),this.isOpen=!0,this.showSelectedDays(),this.disableNextPrevButtons(),this.addBoundedListener(document,"click",(t=>this.documentClick(t))),this.onOpenDatepicker&&this.onOpenDatepicker())}closeDatepicker(){if(!this.isOpen||this.inline)return;this.removeClass(this.datepicker,"datepicker--open"),this.addClass(this.datepicker,"datepicker--closed"),this.slideUp(this.datepicker,this.animationSpeed),this.isOpen=!1;const t=document.createEvent("Event");t.initEvent("afterClose",!0,!0),this.input.dispatchEvent(t),this.removeAllBoundedListeners(document,"click")}autoclose(){this.autoClose&&this.changed&&this.isOpen&&this.start&&this.end&&!this.inline&&this.closeDatepicker()}documentClick(t){this.parent.contains(t.target)||t.target===this.input?"td"===t.target.tagName.toLowerCase()&&this.dayClicked(t.target):this.preventContainerClose||this.closeDatepicker()}datepickerHover(t){t.target.tagName&&"td"===t.target.tagName.toLowerCase()&&this.dayHovering(t.target)}datepickerMouseOut(t){if(t.target.tagName&&"td"===t.target.tagName.toLowerCase()){document.getElementById(this.getTooltipId()).style.display="none"}}onResizeDatepicker(){this.checkAndSetDefaultValue(!0)}getDayClasses(t){const e=this.getDateString(t.time)===this.getDateString(new Date),i=this.getDateString(t.time)===this.getDateString(this.startDate);let a=!1,n=!1,h=!1,r=!1,o=!1,d=!1;if(t.valid||"visibleMonth"===t.type){const e=this.getDateString(t.time,"YYYY-MM-DD");if(this.disabledDates.length>0){const s=this.getClosestDisabledDates(t.date);if(s[0]&&s[1]&&this.compareDay(t.date,s[0])&&this.countDays(s[0],s[1])-2>0){const e=this.countDays(s[1],t.date)-1,i=this.countDays(t.date,s[0])-1;(this.selectForward&&e<this.minDays||!this.selectForward&&e<this.minDays&&i<this.minDays)&&(t.valid=!1),!t.valid&&this.enableCheckout&&2===e&&(d=!0)}this.disabledDates.indexOf(e)>-1?(t.valid=!1,a=!0,this.isFirstDisabledDate++,this.lastDisabledDate=t.date):this.isFirstDisabledDate=0,t.valid&&this.lastDisabledDate&&this.compareDay(t.date,this.lastDisabledDate)>0&&2===this.countDays(t.date,this.lastDisabledDate)&&(o=!0)}this.disabledDaysOfWeek.length>0&&this.disabledDaysOfWeek.indexOf(s.format(t.time,"dddd"))>-1&&(t.valid=!1,r=!0),this.noCheckInDates.length>0&&this.noCheckInDates.indexOf(e)>-1&&(n=!0,o=!1),this.noCheckOutDates.length>0&&this.noCheckOutDates.indexOf(e)>-1&&(h=!0),this.noCheckInDaysOfWeek.length>0&&this.noCheckInDaysOfWeek.indexOf(s.format(t.time,"dddd"))>-1&&(n=!0,o=!1),this.noCheckOutDaysOfWeek.length>0&&this.noCheckOutDaysOfWeek.indexOf(s.format(t.time,"dddd"))>-1&&(h=!0)}return["datepicker__month-day","datepicker__month-day--"+t.type,"datepicker__month-day--"+(t.valid?"valid":"invalid"),e?"datepicker__month-day--today":"",a?"datepicker__month-day--disabled":"",a&&this.enableCheckout&&1===this.isFirstDisabledDate?"datepicker__month-day--checkout-enabled":"",d?"datepicker__month-day--before-disabled-date":"",i||o?"datepicker__month-day--checkin-only":"",n?"datepicker__month-day--no-checkin":"",h?"datepicker__month-day--no-checkout":"",r?"datepicker__month-day--day-of-week-disabled":""]}checkAndSetDayClasses(){const t=this.datepicker.getElementsByTagName("td");for(let e=0;e<t.length;e++){const s=parseInt(t[e].getAttribute("time"),10),i=new Date(s),a=t[e].getAttribute("daytype");let n;n=this.isValidDate(i.getTime()),(this.startDate&&this.compareDay(i,this.startDate)<0||this.endDate&&this.compareDay(i,this.endDate)>0)&&(n=!1);const h={date:i,type:a,day:i.getDate(),time:s,valid:n},r=this.getDayClasses(h);t[e].className=r.join(" ")}}checkAndSetDefaultValue(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this.getValue(),s=e?e.split(this.separator):"";if(s&&s.length>=2){const e=this.format;this.changed=!1,this.setDateRange(this.parseDate(s[0],e),this.parseDate(s[1],e),t),this.changed=!0}else if(this.showTopbar){if(this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none",t){let t=new Date;this.startDate&&this.compareMonth(t,this.startDate)<0&&(t=new Date(this.startDate.getTime())),this.endDate&&this.compareMonth(this.getNextMonth(t),this.endDate)>0&&(t=new Date(this.getPrevMonth(this.endDate.getTime()))),this.start&&!this.end&&this.clearSelection(),this.showMonth(t,1),this.showMonth(this.getNextMonth(t),2),this.setDayIndexes()}}}setDateRange(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t.getTime()>e.getTime()){let s=e;e=t,t=s,s=null}let i=!0;if((this.startDate&&this.compareDay(t,this.startDate)<0||this.endDate&&this.compareDay(e,this.endDate)>0)&&(i=!1),!i)return this.showMonth(this.startDate,1),this.showMonth(this.getNextMonth(this.startDate),2),this.setDayIndexes(),this.showSelectedDays(),void this.disableNextPrevButtons();t.setTime(t.getTime()+432e5),e.setTime(e.getTime()+432e5),this.start=t.getTime(),this.end=e.getTime(),this.compareDay(t,e)>0&&0===this.compareMonth(t,e)&&(e=this.getNextMonth(t)),0===this.compareMonth(t,e)&&(e=this.getNextMonth(t)),this.showMonth(t,1),this.showMonth(e,2),this.setDayIndexes(),this.showSelectedDays(),this.disableNextPrevButtons(),this.checkSelection(),this.showSelectedInfo(),s||this.autoclose(),this.setDayAriaAttributes()}showSelectedDays(){if(!this.start&&!this.end)return;const t=this.datepicker.getElementsByTagName("td");for(let e=0;e<t.length;e++){const s=parseInt(t[e].getAttribute("time"),10);this.start&&this.end&&this.end>=s&&this.start<=s||this.start&&!this.end&&this.getDateString(this.start,"YYYY-MM-DD")===this.getDateString(s,"YYYY-MM-DD")?this.addClass(t[e],"datepicker__month-day--selected"):this.removeClass(t[e],"datepicker__month-day--selected"),this.start&&this.getDateString(this.start,"YYYY-MM-DD")===this.getDateString(s,"YYYY-MM-DD")?this.addClass(t[e],"datepicker__month-day--first-day-selected"):this.removeClass(t[e],"datepicker__month-day--first-day-selected"),this.end&&this.getDateString(this.end,"YYYY-MM-DD")===this.getDateString(s,"YYYY-MM-DD")?this.addClass(t[e],"datepicker__month-day--last-day-selected"):this.removeClass(t[e],"datepicker__month-day--last-day-selected")}}showSelectedInfo(){if(!this.showTopbar){if(this.start&&this.end){const t=this.getDateString(new Date(this.start))+this.separator+this.getDateString(new Date(this.end));this.setValue(t,this.getDateString(new Date(this.start)),this.getDateString(new Date(this.end))),this.changed=!0}return}const t=this.datepicker.getElementsByClassName("datepicker__info--selected")[0],e=t.getElementsByClassName("datepicker__info-text--start-day")[0],s=t.getElementsByClassName("datepicker__info-text--end-day")[0],i=t.getElementsByClassName("datepicker__info-text--selected-days")[0],a=document.getElementById(this.getCloseButtonId()),n=document.getElementById(this.getClearButtonId()),h=document.getElementById(this.getSubmitButtonId());if(e.textContent="...",s.textContent="...",i.style.display="none",this.start&&(t.style.display="",e.textContent=this.getDateString(new Date(parseInt(this.start,10)),this.infoFormat),this.clearButton&&(n.disabled=!1,n.setAttribute("aria-disabled","false"))),this.end&&(s.textContent=this.getDateString(new Date(parseInt(this.end,10)),this.infoFormat)),this.start&&this.end){const t=this.countDays(this.end,this.start)-1,e=1===t?t+" "+this.lang("night"):t+" "+this.lang("nights"),s=this.getDateString(new Date(this.start))+this.separator+this.getDateString(new Date(this.end));i.style.display="",i.firstElementChild.textContent=e,this.inline?this.submitButton&&(h.disabled=!1,h.setAttribute("aria-disabled","false")):(a.disabled=!1,a.setAttribute("aria-disabled","false")),this.setValue(s,this.getDateString(new Date(this.start)),this.getDateString(new Date(this.end))),this.changed=!0}else this.inline?this.submitButton&&(h.disabled=!0,h.setAttribute("aria-disabled","true")):(a.disabled=!0,a.setAttribute("aria-disabled","true"));!this.clearButton||this.start||this.end||(n.disabled=!0,n.setAttribute("aria-disabled","true"))}dayClicked(t){if(this.hasClass(t,"datepicker__month-day--invalid"))return;const e=this.start&&this.end||!this.start&&!this.end,s=parseInt(t.getAttribute("time"),10);if(e){if(this.hasClass(t,"datepicker__month-day--no-checkin"))return}else if(this.start){if(this.start>s&&this.hasClass(t,"datepicker__month-day--no-checkin"))return;const e=this.datepicker.querySelectorAll('td[time="'+this.start+'"]')[0];if(e&&this.hasClass(e,"datepicker__month-day--no-checkout")&&this.start>s)return;if(this.hasClass(t,"datepicker__month-day--no-checkout")&&s>this.start)return}if(this.addClass(t,"datepicker__month-day--selected"),e?(this.start=s,this.end=!1):this.start&&(this.end=s),this.start&&this.end&&this.start>this.end){const t=this.end;this.end=this.start,this.start=t}this.start=parseInt(this.start,10),this.end=parseInt(this.end,10),this.clearHovering(),this.start&&!this.end&&this.dayHovering(t),this.updateSelectableRange(),this.checkSelection(),this.showSelectedInfo(),this.start&&this.end&&this.checkAndSetDayClasses(),this.showSelectedDays(),this.autoclose(),this.onDayClick&&this.onDayClick(),this.end&&this.onSelectRange&&this.onSelectRange(),this.setDayAriaAttributes()}isValidDate(t){if(t=parseInt(t,10),this.startDate&&this.compareDay(t,this.startDate)<0||this.endDate&&this.compareDay(t,this.endDate)>0)return!1;if(this.start&&!this.end){if(this.maxDays>0&&this.countDays(t,this.start)>this.maxDays||this.minDays>0&&this.countDays(t,this.start)>1&&this.countDays(t,this.start)<this.minDays)return!1;if(this.selectForward&&t<this.start)return!1;if(this.disabledDates.length>0){const e=this.getClosestDisabledDates(new Date(parseInt(this.start,10)));if(e[0]&&this.compareDay(t,e[0])<=0)return!1;if(e[1]&&this.compareDay(t,e[1])>=0)return!1}if(this.disabledDaysOfWeek.length>0){const e=this.getClosestDisabledDays(new Date(parseInt(this.start,10)));if(e[0]&&this.compareDay(t,e[0])<=0)return!1;if(e[1]&&this.compareDay(t,e[1])>=0)return!1}}return!0}checkSelection(){const t=this.countDays(this.end,this.start),e=!!this.showTopbar&&this.datepicker.getElementsByClassName("datepicker__info--feedback")[0];if(this.maxDays&&t>this.maxDays){this.start=!1,this.end=!1;const t=this.datepicker.getElementsByTagName("td");for(let e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--selected"),this.removeClass(t[e],"datepicker__month-day--first-day-selected"),this.removeClass(t[e],"datepicker__month-day--last-day-selected");if(this.showTopbar){const t=this.maxDays-1;this.topBarErrorText(e,"error-more",t)}}else if(this.minDays&&t<this.minDays){this.start=!1,this.end=!1;const t=this.datepicker.getElementsByTagName("td");for(let e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--selected"),this.removeClass(t[e],"datepicker__month-day--first-day-selected"),this.removeClass(t[e],"datepicker__month-day--last-day-selected");if(this.showTopbar){const t=this.minDays-1;this.topBarErrorText(e,"error-less",t)}}else this.start||this.end?this.showTopbar&&(this.removeClass(e,"datepicker__info--error"),this.removeClass(e,"datepicker__info--help")):this.showTopbar&&(this.removeClass(e,"datepicker__info--error"),this.addClass(e,"datepicker__info--help"))}addDays(t,e){const s=new Date(t);return s.setDate(s.getDate()+e),s}substractDays(t,e){const s=new Date(t);return s.setDate(s.getDate()-e),s}countDays(t,e){return Math.abs(this.daysFrom1970(t)-this.daysFrom1970(e))+1}compareDay(t,e){const s=parseInt(this.getDateString(t,"YYYYMMDD"),10)-parseInt(this.getDateString(e,"YYYYMMDD"),10);return s>0?1:0===s?0:-1}compareMonth(t,e){const s=parseInt(this.getDateString(t,"YYYYMM"),10)-parseInt(this.getDateString(e,"YYYYMM"),10);return s>0?1:0===s?0:-1}daysFrom1970(t){return Math.round(this.toLocalTimestamp(t)/864e5)}toLocalTimestamp(t){return"object"==typeof t&&t.getTime&&(t=t.getTime()),"string"!=typeof t||t.match(/\d{13}/)||(t=this.parseDate(t).getTime()),t=parseInt(t,10)-60*(new Date).getTimezoneOffset()*1e3}printAttributes(t){const e=t;let s="";for(const i in t)Object.prototype.hasOwnProperty.call(e,i)&&(s+=i+'="'+e[i]+'" ');return s}goToNextMonth(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const s=Number.isInteger(t)?t:t.target.getAttribute("month"),i=s>1;let a=i?this.month2:this.month1;return a=this.getNextMonth(a),!(!this.isSingleMonth()&&!i&&this.compareMonth(a,this.month2)>=0||this.isMonthOutOfRange(a))&&((this.moveBothMonths||e)&&i&&this.showMonth(this.month2,1),this.showMonth(a,s),this.setDayIndexes(),this.showSelectedDays(),this.disableNextPrevButtons(),!0)}goToPreviousMonth(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const s=Number.isInteger(t)?t:t.target.getAttribute("month"),i=s>1;let a=i?this.month2:this.month1;return a=this.getPrevMonth(a),!(i&&this.compareMonth(a,this.month1)<=0||this.isMonthOutOfRange(a))&&(!this.moveBothMonths&&!e||i||this.showMonth(this.month1,2),this.showMonth(a,s),this.setDayIndexes(),this.showSelectedDays(),this.disableNextPrevButtons(),!0)}isSingleMonth(){return!this.isVisible(this.getMonthDom(2))}isMonthOutOfRange(t){const e=new Date(t.valueOf());return!!(this.startDate&&new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59)<this.startDate||this.endDate&&new Date(e.getFullYear(),e.getMonth(),1)>this.endDate)}disableNextPrevButtons(){if(this.isSingleMonth())return;const t=parseInt(this.getDateString(this.month1,"YYYYMM"),10),e=parseInt(this.getDateString(this.month2,"YYYYMM"),10),s=Math.abs(t-e),i=this.datepicker.getElementsByClassName("datepicker__month-button--next"),a=this.datepicker.getElementsByClassName("datepicker__month-button--prev");s>1&&89!==s?(this.removeClass(i[0],"datepicker__month-button--disabled"),i[0].setAttribute("aria-disabled","false"),this.removeClass(a[1],"datepicker__month-button--disabled"),a[1].setAttribute("aria-disabled","false")):(this.addClass(i[0],"datepicker__month-button--disabled"),i[0].setAttribute("aria-disabled","true"),this.addClass(a[1],"datepicker__month-button--disabled"),a[1].setAttribute("aria-disabled","true")),this.isMonthOutOfRange(this.getPrevMonth(this.month1))?(this.addClass(a[0],"datepicker__month-button--disabled"),a[0].setAttribute("aria-disabled","true")):(this.removeClass(a[0],"datepicker__month-button--disabled"),a[0].setAttribute("aria-disabled","false")),this.isMonthOutOfRange(this.getNextMonth(this.month2))?(this.addClass(i[1],"datepicker__month-button--disabled"),i[1].setAttribute("aria-disabled","true")):(this.removeClass(i[1],"datepicker__month-button--disabled"),i[1].setAttribute("aria-disabled","false"))}topBarDefaultText(){if(!this.showTopbar)return;let t="";t=this.minDays&&this.maxDays?this.minDays===this.maxDays?this.lang("info-range-equal"):this.lang("info-range"):this.minDays&&this.minDays>2?this.lang("info-more-plural"):this.minDays?this.lang("info-more"):this.lang("info-default");const e=this.datepicker.getElementsByClassName("datepicker__info--feedback")[0];t=t.replace(/%d/,this.minDays-1).replace(/%d/,this.maxDays-1),this.addClass(e,"datepicker__info--help"),this.removeClass(e,"datepicker__info--error"),e.textContent=t}topBarErrorText(t,e,s){if(!this.showTopbar)return;this.addClass(t,"datepicker__info--error"),this.removeClass(t,"datepicker__info--help"),s>1?(e=(e=this.lang(e+"-plural")).replace("%d",s),t.textContent=e):e=this.lang(e);this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none"}updateSelectableRange(){const t=this.datepicker.getElementsByTagName("td"),e=this.start&&!this.end;for(let s=0;s<t.length;s++)if(this.hasClass(t[s],"datepicker__month-day--invalid")&&this.hasClass(t[s],"datepicker__month-day--tmp")&&(this.removeClass(t[s],"datepicker__month-day--tmp"),this.hasClass(t[s],"datepicker__month-day--tmpinvalid")?this.removeClass(t[s],"datepicker__month-day--tmpinvalid"):(this.removeClass(t[s],"datepicker__month-day--invalid"),this.addClass(t[s],"datepicker__month-day--valid"))),e){if(this.hasClass(t[s],"datepicker__month-day--visibleMonth")&&(this.hasClass(t[s],"datepicker__month-day--valid")||this.hasClass(t[s],"datepicker__month-day--disabled")||this.hasClass(t[s],"datepicker__month-day--before-disabled-date"))){const e=parseInt(t[s].getAttribute("time"),10);this.isValidDate(e)?(this.addClass(t[s],"datepicker__month-day--valid"),this.addClass(t[s],"datepicker__month-day--tmp"),this.removeClass(t[s],"datepicker__month-day--invalid"),this.removeClass(t[s],"datepicker__month-day--disabled")):(this.hasClass(t[s],"datepicker__month-day--invalid")&&this.addClass(t[s],"datepicker__month-day--tmpinvalid"),this.addClass(t[s],"datepicker__month-day--invalid"),this.addClass(t[s],"datepicker__month-day--tmp"),this.removeClass(t[s],"datepicker__month-day--valid"))}this.setDayAriaAttributes()}else(this.hasClass(t[s],"datepicker__month-day--checkout-enabled")||this.hasClass(t[s],"datepicker__month-day--before-disabled-date"))&&(this.addClass(t[s],"datepicker__month-day--invalid"),this.removeClass(t[s],"datepicker__month-day--valid"),this.hasClass(t[s],"datepicker__month-day--before-disabled-date")||this.addClass(t[s],"datepicker__month-day--disabled"));return!0}dayHovering(t){const e=parseInt(t.getAttribute("time"),10);let s="";if(!this.hasClass(t,"datepicker__month-day--invalid")){const t=this.datepicker.getElementsByTagName("td");for(let s=0;s<t.length;s++){const i=parseInt(t[s].getAttribute("time"),10);i===e?this.addClass(t[s],"datepicker__month-day--hovering"):this.removeClass(t[s],"datepicker__month-day--hovering"),this.start&&!this.end&&(this.start<i&&e>=i||this.start>i&&e<=i)?this.addClass(t[s],"datepicker__month-day--hovering"):this.removeClass(t[s],"datepicker__month-day--hovering")}if(this.start&&!this.end){const t=this.countDays(e,this.start)-1;if(this.hoveringTooltip)if("function"==typeof this.hoveringTooltip)s=this.hoveringTooltip(t,this.start,e);else if(!0===this.hoveringTooltip&&t>0){s=t+" "+(1===t?this.lang("night"):this.lang("nights"))}}}if(s){const e=t.getBoundingClientRect(),i=this.datepicker.getBoundingClientRect();let a=e.left-i.left,n=e.top-i.top;a+=e.width/2;const h=document.getElementById(this.getTooltipId());h.style.display="",h.textContent=s;const r=h.getBoundingClientRect().width,o=h.getBoundingClientRect().height;a-=r/2,n-=o,setTimeout((()=>{h.style.left=a+"px",h.style.top=n+"px"}),10)}else{document.getElementById(this.getTooltipId()).style.display="none"}}clearHovering(){const t=this.datepicker.getElementsByTagName("td");for(let e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--hovering");document.getElementById(this.getTooltipId()).style.display="none"}clearSelection(){this.start=!1,this.end=!1;const t=this.datepicker.getElementsByTagName("td");for(let e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--selected"),this.removeClass(t[e],"datepicker__month-day--first-day-selected"),this.removeClass(t[e],"datepicker__month-day--last-day-selected"),this.removeClass(t[e],"datepicker__month-day--hovering");this.setValue(""),this.checkSelection(),this.showSelectedInfo(),this.showSelectedDays()}clearDatepicker(){this.start=!1,this.end=!1;const t=this.datepicker.getElementsByTagName("td");for(let e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--selected"),this.removeClass(t[e],"datepicker__month-day--first-day-selected"),this.removeClass(t[e],"datepicker__month-day--last-day-selected"),this.removeClass(t[e],"datepicker__month-day--hovering");this.setValue(""),this.checkSelection(),this.showSelectedInfo();this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none",this.showSelectedDays(),this.updateSelectableRange()}parseDisabledDates(){const t=[];this.setFechaI18n();for(let e=0;e<this.disabledDates.length;e++)t[e]=s.parse(this.disabledDates[e],"YYYY-MM-DD");t.sort(((t,e)=>t-e)),this.disabledDatesTime=t}getClosestDisabledDates(t){let e=[!1,!1];if(t<this.disabledDatesTime[0])e=this.enableCheckout?[!1,this.addDays(this.disabledDatesTime[0],1)]:[!1,this.disabledDatesTime[0]];else if(t>this.disabledDatesTime[this.disabledDatesTime.length-1])e=[this.disabledDatesTime[this.disabledDatesTime.length-1],!1];else{let s=this.disabledDatesTime.length,i=this.disabledDatesTime.length;const a=Math.abs(new Date(0,0,0).valueOf());let n,h=a,r=-a,o=0;for(n=0;n<this.disabledDatesTime.length;++n)o=t-this.disabledDatesTime[n],o<0&&o>r&&(i=n,r=o),o>0&&o<h&&(s=n,h=o);this.disabledDatesTime[s]&&(e[0]=this.disabledDatesTime[s]),void 0===this.disabledDatesTime[s]?e[1]=!1:this.enableCheckout?e[1]=this.addDays(this.disabledDatesTime[i],1):e[1]=this.disabledDatesTime[i]}return e}getDisabledDays(){const t=[],e=[],i=new Date;for(let e=0;e<7;e++){const a=this.addDays(i,e);t[s.format(a,"d")]=s.format(a,"dddd")}for(let s=0;s<this.disabledDaysOfWeek.length;s++)e.push(t.indexOf(this.disabledDaysOfWeek[s]));e.sort(),this.disabledDaysIndexes=e}getClosestDisabledDays(t){const e=[!1,!1];for(let i=0;i<7;i++){const a=this.substractDays(t,i);if(this.disabledDaysIndexes.indexOf(parseInt(s.format(a,"d"),10))>-1){e[0]=a;break}}for(let i=0;i<7;i++){const a=this.addDays(t,i);if(this.disabledDaysIndexes.indexOf(parseInt(s.format(a,"d"),10))>-1){e[1]=a;break}}return e}lang(t){return t in this.i18n?this.i18n[t]:""}emptyElement(t){for(;t.firstChild;)t.removeChild(t.firstChild)}classRegex(t){return new RegExp("(^|\\s+)"+t+"(\\s+|$)")}hasClass(t,e){return this.classRegex(e).test(t.className)}addClass(t,e){this.hasClass(t,e)||(t.className=t.className+" "+e)}removeClass(t,e){t.className=t.className.replace(this.classRegex(e)," ")}isVisible(t){return t.offsetWidth||t.offsetHeight||t.getClientRects().length}slideDown(t,e){t.style.display="";const s=t.getBoundingClientRect().height;t.style.height=0,this.recalc(t.offsetHeight),t.style.transition="height "+e,t.style.height=s+"px",t.addEventListener("transitionend",(()=>{t.style.height=t.style.transition=t.style.display=""}))}slideUp(t,e){const s=t.getBoundingClientRect().height;t.style.height=s+"px",this.recalc(t.offsetHeight),t.style.transition="height "+e,t.style.height=0,t.addEventListener("transitionend",(()=>{t.style.display="none"}))}recalc(t){return t.offsetHeight}isTouchDevice(){return"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch}setDayAriaAttributes(){const t=this.datepicker.getElementsByTagName("td");for(let e=0;e<t.length;e++){const i=t[e].className,a=parseInt(t[e].getAttribute("time"),10);let n="false",h="";i.includes("datepicker__month-day--invalid")?(h=this.replacei18n(this.i18n["aria-disabled"],s.format(a,this.ariaDayFormat)),n="true"):h=i.includes("datepicker__month-day--first-day-selected")?this.replacei18n(this.i18n["aria-selected-checkin"],s.format(a,this.ariaDayFormat)):i.includes("datepicker__month-day--last-day-selected")?this.replacei18n(this.i18n["aria-selected-checkout"],s.format(a,this.ariaDayFormat)):i.includes("datepicker__month-day--selected")?this.replacei18n(this.i18n["aria-selected"],s.format(a,this.ariaDayFormat)):this.start&&!this.end?this.replacei18n(this.i18n["aria-choose-checkout"],s.format(a,this.ariaDayFormat)):this.replacei18n(this.i18n["aria-choose-checkin"],s.format(a,this.ariaDayFormat)),h&&t[e].setAttribute("aria-label",h),t[e].setAttribute("aria-disabled",n)}}replacei18n(t,e){return t.replace("%s",e)}checkOnFocus(t){t.target&&this.input===t.target||this.datepicker.contains(t.target)?this.isOnFocus=!0:(this.isOnFocus=!1,this.isOpen&&this.closeDatepicker())}doKeyDown(t){switch(t.keyCode){case 39:this.isOnFocus&&(t.preventDefault(),this.setActiveDay("next"));break;case 37:this.isOnFocus&&(t.preventDefault(),this.setActiveDay("prev"));break;case 40:this.isOnFocus&&(t.preventDefault(),this.setActiveDay("down"));break;case 38:this.isOnFocus&&(t.preventDefault(),this.setActiveDay("up"));break;case 36:this.isOnFocus&&(t.preventDefault(),this.setActiveDay("first"));break;case 35:this.isOnFocus&&(t.preventDefault(),this.setActiveDay("last"));break;case 27:this.isOnFocus&&null!==this.input.offsetParent&&this.setFocusToInput();break;case 34:this.isOnFocus&&(t.preventDefault(),this.moveMonthFromKeyboard("next"));break;case 33:this.isOnFocus&&(t.preventDefault(),this.moveMonthFromKeyboard("prev"));break;case 13:this.isOnFocus&&(t.preventDefault(),this.handleReturn())}}setActiveDay(t){const e=document.activeElement;if(e&&this.hasClass(e,"datepicker__month-day--visibleMonth")&&this.datepicker.contains(e)){const s=parseInt(e.getAttribute("index"),10),i=parseInt(e.getAttribute("d"),10);let a=-1;switch(t){case"next":a=s+1;break;case"prev":a=s-1;break;case"up":a=s-7;break;case"down":a=s+7;break;case"first":if(1===i)return!1;a=s-(i-1);break;case"last":if(7===i)return!1;a=s+(7-i)}const n=this.datepicker.querySelectorAll('[index="'+a+'"]');if(n.length>0&&a>0)this.setDayFocus(n[0]);else if(a>0){let e="";if(this.goToNextMonth(2,!0)){const s=this.datepicker.getElementsByClassName("datepicker__month--month2");if(s.length>0){if("down"===t)e=s[0].querySelectorAll('.datepicker__month-day--visibleMonth[d="'+i+'"]');else if("last"===t){const t=i+(7-i);e=s[0].querySelectorAll('.datepicker__month-day--visibleMonth[d="'+t+'"]')}else e=s[0].querySelectorAll(".datepicker__month-day--visibleMonth");e.length>0&&this.setDayFocus(e[0])}}}else if(a<=0){let e="";if(this.goToPreviousMonth(1,!0)){const s=this.datepicker.getElementsByClassName("datepicker__month--month1");if(s.length>0){if("up"===t)e=s[0].querySelectorAll('.datepicker__month-day--visibleMonth[d="'+i+'"]');else if("first"===t){const t=i-(i-1);e=s[0].querySelectorAll('.datepicker__month-day--visibleMonth[d="'+t+'"]')}else e=s[0].querySelectorAll(".datepicker__month-day--visibleMonth");e.length>0&&this.setDayFocus(e[e.length-1])}}}}else this.setInitialActiveDay()}setInitialActiveDay(){const t=this.datepicker.getElementsByClassName("datepicker__month-day--today");if(t.length>0)return this.setDayFocus(t[0]),t[0];const e=this.datepicker.getElementsByClassName("datepicker__month-day--first-day-selected");if(e.length>0)return this.setDayFocus(e[0]),e[0];const s=this.datepicker.getElementsByClassName("datepicker__month-day--visibleMonth");return s.length>0?(this.setDayFocus(s[0]),s[0]):void 0}setDayFocus(t){const e=this.datepicker.getElementsByTagName("td");this.removeDaysTabIndex(e),t.setAttribute("tabindex","0"),t.focus(),this.start&&!this.end&&this.dayHovering(t)}removeDaysTabIndex(t){for(let e=0;e<t.length;e++)t[e].removeAttribute("tabindex")}setDayIndexes(){const t=this.datepicker.getElementsByTagName("td");this.dayIndex=1;for(let e=0;e<t.length;e++)this.hasClass(t[e],"datepicker__month-day--visibleMonth")?(t[e].setAttribute("index",this.dayIndex),this.dayIndex++):t[e].setAttribute("index",0)}setFocusToInput(){this.input.focus(),this.closeDatepicker(),this.clearHovering(),this.justEsc=!0,this.isOnFocus=!1}moveMonthFromKeyboard(t){"prev"===t?this.goToPreviousMonth(1,!0):this.goToNextMonth(2,!0)}handleReturn(){const t=document.activeElement;t&&this.datepicker.contains(t)&&(this.hasClass(t,"datepicker__month-day--visibleMonth")||this.hasClass(t,"datepicker__month-button")||this.hasClass(t,"datepicker__close-button")||this.hasClass(t,"datepicker__clear-button")||this.hasClass(t,"datepicker__submit-button"))&&t.click()}open(){this.openDatepicker()}close(){this.closeDatepicker()}getDatePicker(){return this.datepicker}setRange(t,e){"string"==typeof t&&"string"==typeof e&&(t=this.parseDate(t),e=this.parseDate(e)),this.setDateRange(t,e)}clear(){this.clearSelection()}getNights(){let t=0;if(this.start&&this.end)t=this.countDays(this.end,this.start)-1;else{const e=this.getValue(),s=e?e.split(this.separator):"";if(s&&s.length>=2){const e=this.format;t=this.countDays(this.parseDate(s[0],e),this.parseDate(s[1],e))-1}}return t}destroy(){document.getElementById(this.getDatepickerId())&&(this.removeAllBoundedListeners(this.input,"click"),this.removeAllBoundedListeners(document,"click"),this.removeAllBoundedListeners(this.input,"change"),this.datepicker.parentNode.removeChild(this.datepicker))}}return a}(fecha);
{
"name": "hotel-datepicker",
"version": "4.4.1",
"version": "4.5.0",
"author": "Benito Lopez (http://lopezb.com)",
"license": "MIT",
"description": "Date range picker for hotels",
"type": "module",
"repository": {

@@ -20,42 +21,40 @@ "type": "git",

],
"main": "src/js/hotel-datepicker.js",
"main": "dist/js/hotel-datepicker.esm.js",
"style": "dist/css/hotel-datepicker.css",
"scripts": {
"test": "xo",
"run:sass": "node-sass -o .sass-cache src/sass --output-style expanded",
"build:scss": "npm run run:sass && npm run run:sass -- -w",
"build:css": "postcss --no-map -w .sass-cache/hotel-datepicker.css -d dist/css",
"build:xo": "xo --fix || true",
"build:js": "node build.js",
"build:img": "cp -R src/icons dist",
"build:rollup": "rollup --config -w",
"lint": "eslint src/js/**",
"watch:server": "browser-sync start --startPath demo --reload-delay 300 --server --files 'dist/**,demo/**'",
"watch:build": "onchange 'src/js/*.js' -i -- npm-run-all --parallel --silent build:*",
"watch": "mkdir -p dist dist/css .sass-cache; touch .sass-cache/hotel-datepicker.css; npm-run-all --parallel --silent watch:*",
"build": "mkdir -p dist dist/css .sass-cache; touch .sass-cache/hotel-datepicker.css; npm-run-all --parallel --silent build:*"
"watch": "mkdir -p dist dist/css dist/icons .sass-cache; touch .sass-cache/hotel-datepicker.css; npm-run-all --parallel --silent watch:*",
"build": "mkdir -p dist dist/css dist/icons .sass-cache; touch .sass-cache/hotel-datepicker.css; npm-run-all --parallel --silent build:*"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"browser-sync": "^2.18.6",
"css-mqpacker": "^6.0.1",
"node-sass": "^7.0.1",
"npm-run-all": "^4.0.0",
"onchange": "^3.2.1",
"postcss-cli": "^4.0.0",
"rollup": "^0.45.2",
"rollup-plugin-buble": "^0.15.0",
"rollup-plugin-filesize": "^1.0.1",
"rollup-plugin-uglify": "^2.0.1",
"rollup-watch": "^4.3.1",
"xo": "^0.18.2"
"@babel/core": "^7.19.6",
"@babel/preset-env": "^7.19.4",
"@rollup/plugin-babel": "^6.0.2",
"@rollup/plugin-node-resolve": "^15.0.1",
"autoprefixer": "^10.4.12",
"browser-sync": "^2.27.10",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"node-sass": "^7.0.3",
"npm-run-all": "^4.1.5",
"onchange": "^7.1.0",
"postcss-cli": "^10.0.0",
"postcss-sort-media-queries": "^4.3.0",
"rollup": "^3.2.3",
"rollup-plugin-minification": "^0.2.0"
},
"xo": {
"esnext": true,
"ignores": [
"demo/**"
],
"env": [
"browser"
]
"dependencies": {
"fecha": "^4.2.3"
},
"dependencies": {
"fecha": "^4.2.0"
}
"browserslist": [
"defaults and supports es6-module",
"maintained node versions"
]
}
# Hotel Datepicker
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
A pure Javascript date range picker for hotels. Requires [Fecha](https://github.com/taylorhakes/fecha) **4.0.0** or above and supports all modern browsers. Check the [demo here](http://lopezb.com/hoteldatepicker).
![Hotel Datepicker Thumbnail](http://static.lopezb.com/hoteldatepicker/datepicker_card.png "Hotel Thumbnail")
![Hotel Datepicker Thumbnail](http://static.lopezb.com/hoteldatepicker/datepicker_card_2022.jpg "Hotel Datepicker Thumbnail")
## Installation
Download [Fecha](https://github.com/taylorhakes/fecha/releases).
### As a module:
Install with:
```
npm i hotel-datepicker
```
Then import the modules with:
```
import * as fecha from "fecha";
import HotelDatepicker from "hotel-datepicker";
import "hotel-datepicker/dist/css/hotel-datepicker.css";
```
### As a script:
Download [Fecha](https://github.com/taylorhakes/fecha/releases).
**[BREAK CHANGE]** Use Fecha 4.0.0 or above.

@@ -18,6 +34,5 @@

```html
<link href="/path/to/hotel-datepicker.css" rel="stylesheet"><!-- Optional -->
<link href="/path/to/hotel-datepicker.css" rel="stylesheet" /><!-- Optional -->
<script src="/path/to/fecha.js"></script>
<script src="/path/to/hotel-datepicker.min.js"></script>
```

@@ -30,8 +45,7 @@

```html
<input id="input-id" type="text">
<input id="input-id" type="text" />
```
```js
var hdpkr = new HotelDatepicker(document.getElementById('input-id'), options);
var hdpkr = new HotelDatepicker(document.getElementById("input-id"), options);
```

@@ -43,4 +57,4 @@

- Type: `String`
- Default: `YYYY-MM-DD`
- Type: `String`
- Default: `YYYY-MM-DD`

@@ -51,11 +65,18 @@ The date format string.

- Type: `String`
- Default: `YYYY-MM-DD`
- Type: `String`
- Default: `YYYY-MM-DD`
The date format string in the info box. If not set, it uses the `format` option.
### ariaDayFormat
- Type: `String`
- Default: `dddd, MMMM DD, YYYY`
The date format string in the aria label strings.
### separator
- Type: `String`
- Default: ` - `
- Type: `String`
- Default: `-`

@@ -66,4 +87,4 @@ The separator string used between date strings.

- Type: `String`
- Default: `sunday`
- Type: `String`
- Default: `sunday`

@@ -74,4 +95,4 @@ Default start week: `sunday` or `monday`.

- Type: `Date` or `String`
- Default: `new Date()`
- Type: `Date` or `String`
- Default: `new Date()`

@@ -82,4 +103,4 @@ The start view date. All the dates before this date will be disabled.

- Type: `Date` or `String` or `Boolean`
- Default: `false`
- Type: `Date` or `String` or `Boolean`
- Default: `false`

@@ -90,4 +111,4 @@ The end view date. All the dates after this date will be disabled.

- Type: `Number`
- Default: `1`
- Type: `Number`
- Default: `1`

@@ -98,4 +119,4 @@ Minimum nights required to select a range of dates.

- Type: `Number`
- Default: `0`
- Type: `Number`
- Default: `0`

@@ -106,4 +127,4 @@ Maximum nights required to select a range of dates.

- Type: `Boolean`
- Default: `false`
- Type: `Boolean`
- Default: `false`

@@ -114,4 +135,4 @@ If `true`, the selection of the second date must be after the first date. If `false`, you can select a range of dates in both directions.

- Type: `Array`
- Default: `[]`
- Type: `Array`
- Default: `[]`

@@ -122,4 +143,4 @@ An array of **strings** in this format: `'YYYY-MM-DD'` (note the `''`). All the dates passed to the list will be disabled.

- Type: `Boolean`
- Default: `false`
- Type: `Boolean`
- Default: `false`

@@ -130,4 +151,4 @@ If `true`, allows the checkout on a **disabled** date. But with a criteria. Let's say we have these disabled dates: `03 April 2020` and `04 April 2020`. With this option enabled, an user can still select the first date (`03 April 2020`) for the checkout. But not `04 April 2020`.

- Type: `Array`
- Default: `[]`
- Type: `Array`
- Default: `[]`

@@ -138,4 +159,4 @@ An array of **strings** in this format: `'YYYY-MM-DD'` (note the `''`). All the dates passed to the list will not allow a check-in on that day.

- Type: `Array`
- Default: `[]`
- Type: `Array`
- Default: `[]`

@@ -146,4 +167,4 @@ An array of **strings** in this format: `'YYYY-MM-DD'` (note the `''`). All the dates passed to the list will not allow a check-out on that day.

- Type: `Array`
- Default: `[]`
- Type: `Array`
- Default: `[]`

@@ -154,4 +175,4 @@ An array of **strings** of day names in your language (same names used in `i18n['day-names']`): `'Monday'` (note the `''` and the uppercase).

- Type: `Array`
- Default: `[]`
- Type: `Array`
- Default: `[]`

@@ -162,4 +183,4 @@ An array of **strings** of day names in your language (same names used in `i18n['day-names']`): `'Monday'` (note the `''` and the uppercase).

- Type: `Array`
- Default: `[]`
- Type: `Array`
- Default: `[]`

@@ -169,3 +190,3 @@ An array of **strings** of day names in your language (same names used in `i18n['day-names']`): `'Monday'` (note the `''` and the uppercase).

```js
['Monday', 'Tuesday', 'Wednesday']
["Monday", "Tuesday", "Wednesday"];
```

@@ -175,4 +196,4 @@

- Type: `Element`
- Default: `''`
- Type: `Element`
- Default: `''`

@@ -183,4 +204,4 @@ An element for putting the datepicker. If not set, the datepicker will be appended to the parent of the input.

- Type: `Boolean`
- Default: `false`
- Type: `Boolean`
- Default: `false`

@@ -191,11 +212,11 @@ Render the datepicker inline.

- Type: `Boolean`
- Default: `false`
- Type: `Boolean`
- Default: `false`
If `true`, a button to clear the selected dates is shown. Works only when `inline` and `showTopbar` are true.
If `true`, a button to clear the selected dates is shown. Works only when `showTopbar` is true.
### submitButton
- Type: `Boolean`
- Default: `false`
- Type: `Boolean`
- Default: `false`

@@ -206,4 +227,4 @@ If `true`, a submit button is shown. Works only when `inline` and `showTopbar` are true.

- Type: `String`
- Default: ``
- Type: `String`
- Default: ``

@@ -214,4 +235,4 @@ The name of the button to reference the form-data. Works only when `submitButton` is true.

- Type: `String`
- Default: `.5s`
- Type: `String`
- Default: `.5s`

@@ -222,4 +243,4 @@ The duration (in seconds) of the animation (open/close datepicker).

- Type: `Boolean` or `Function`
- Default: `true`
- Type: `Boolean` or `Function`
- Default: `true`

@@ -236,4 +257,4 @@ Shows a tooltip when hovering a date. It can be a custom function:

- Type: `Boolean`
- Default: `true`
- Type: `Boolean`
- Default: `true`

@@ -244,4 +265,4 @@ Show/hide the toolbar.

- Type: `String`
- Default: `top`
- Type: `String`
- Default: `top`

@@ -252,4 +273,4 @@ Set the position of the toolbar.

- Type: `Boolean`
- Default: `true`
- Type: `Boolean`
- Default: `true`

@@ -260,4 +281,4 @@ Close the datepicker after the selection of the second date.

- Type: `Boolean`
- Default: `false`
- Type: `Boolean`
- Default: `false`

@@ -268,4 +289,4 @@ When a click is done outside the datepicker container, the datepicker closes. Use this option to disable this behavior.

- Type: `Boolean`
- Default: `false`
- Type: `Boolean`
- Default: `false`

@@ -276,4 +297,4 @@ Move both months when clicking on the next/prev month button.

- Type: `Function`
- Default: `false`
- Type: `Function`
- Default: `false`

@@ -290,4 +311,4 @@ Run a custom function every time a day is clicked:

- Type: `Function`
- Default: `false`
- Type: `Function`
- Default: `false`

@@ -304,4 +325,4 @@ Run a custom function when the datepicker is opened:

- Type: `Function`
- Default: `false`
- Type: `Function`
- Default: `false`

@@ -318,5 +339,5 @@ Run a custom function when a range is selected:

**[BREAK CHANGE]** Two new options has been introduced in the v.3: `month-names-short` and `day-names-short`. Previously, the *short* day name version ('Sun', 'Mon', 'Tue', etc) was used in the `day-names` option. Now, the `day-names` option uses the *long* version.
**[BREAK CHANGE]** Two new options has been introduced in the v.3: `month-names-short` and `day-names-short`. Previously, the _short_ day name version ('Sun', 'Mon', 'Tue', etc) was used in the `day-names` option. Now, the `day-names` option uses the _long_ version.
- Type: `Object`
- Type: `Object`

@@ -347,3 +368,15 @@ Default:

'info-range-equal': 'Please select a date range of %d nights',
'info-default': 'Please select a date range'
'info-default': 'Please select a date range',
'aria-application': 'Calendar',
'aria-selected-checkin': 'Selected as check-in date, %s',
'aria-selected-checkout': 'Selected as check-out date, %s',
'aria-selected': 'Selected, %s',
'aria-disabled': 'Not available, %s',
'aria-choose-checkin': 'Choose %s as your check-in date',
'aria-choose-checkout': 'Choose %s as your check-out date',
'aria-prev-month': 'Move backward to switch to the previous month',
'aria-next-month': 'Move forward to switch to the next month',
'aria-close-button': 'Close the datepicker',
'aria-clear-button': 'Clear the selected dates',
'aria-submit-button': 'Submit the form'
}

@@ -399,9 +432,22 @@ ```

```js
var input = document.getElementById('input-id');
var input = document.getElementById("input-id");
input.addEventListener('afterClose', function () {
console.log('Closed!');
}, false);
input.addEventListener(
"afterClose",
function () {
console.log("Closed!");
},
false
);
```
## Keyboard Shortcuts
- `←/→`: Move backward (left) and forward (right) by one day.
- `↑/↓`: Move backward (up) and forward (down) by one week.
- `PGUP/PGDN`: Switch months.
- `HOME/END`: Go to the first or last day of a week.
- `↵`: Select the date in focus or trigger click on button in focus.
- `ESC`: Return to the date input field.
## Versioning

@@ -408,0 +454,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc