-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfdatepicker.min.js
More file actions
12 lines (12 loc) · 45 KB
/
fdatepicker.min.js
File metadata and controls
12 lines (12 loc) · 45 KB
1
2
3
4
5
6
7
8
9
10
11
12
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.FDatepicker=factory())})(this,function(){const FDATEPICKER_DEFAULT_MESSAGES={days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today",clear:"Clear",close:"Close",format:"m/d/Y h:i a",firstDayOfWeek:1,noDatesSelected:"No dates selected",singleDateSelected:"1 date selected",multipleDatesSelected:"{count} dates selected",datesSelected:"Selected dates ({0}):"};class FDatepicker{static _documentListenersAdded=false;static _openInstances=new Set;static setMessages(customMessages){Object.assign(FDATEPICKER_DEFAULT_MESSAGES,customMessages)}static _handleGlobalClick(e){const target=e.target;for(const instance of FDatepicker._openInstances){if(instance.isOpen&&target!==instance.input&&!instance.popup.contains(target)){instance.close()}}}static _handleGlobalKeydown(e){const key=e.key;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(key)){return}for(const instance of FDatepicker._openInstances){if(instance.isOpen&&(instance.grid===e.target||instance.popup.contains(e.target))){e.preventDefault();e.stopPropagation();break}}}static _addGlobalListeners(){if(!FDatepicker._documentListenersAdded){document.addEventListener("click",FDatepicker._handleGlobalClick);document.addEventListener("keydown",FDatepicker._handleGlobalKeydown);FDatepicker._documentListenersAdded=true}}static _removeGlobalListeners(){if(FDatepicker._documentListenersAdded){document.removeEventListener("click",FDatepicker._handleGlobalClick);document.removeEventListener("keydown",FDatepicker._handleGlobalKeydown);FDatepicker._documentListenersAdded=false}}static _cleanupOpenInstances(){const validInstances=new Set;for(const instance of FDatepicker._openInstances){if(instance.input&&instance.input._fdatepicker===instance){validInstances.add(instance)}}FDatepicker._openInstances=validInstances;if(FDatepicker._openInstances.size===0){FDatepicker._removeGlobalListeners()}}constructor(input,options={}){this.input=typeof input==="string"?document.querySelector(input):input;if(!this.input){return}if(this.input._fdatepicker){return this.input._fdatepicker}this.input._fdatepicker=this;this.container=this.getOrCreateGlobalContainer();this.focusedDate=new Date;this.selectedDate=null;this.selectedEndDate=null;this.selectedDates=[];this.isOpen=false;this.currentYear=(new Date).getFullYear();this.focusedElement=null;this.locale=FDATEPICKER_DEFAULT_MESSAGES;this.options={format:this.input.dataset.format||"",view:this.input.dataset.view||"days",minDate:this.input.dataset.minDate?new Date(this.input.dataset.minDate):null,maxDate:this.input.dataset.maxDate?new Date(this.input.dataset.maxDate):null,disabledDates:this.input.dataset.disabledDates?this.input.dataset.disabledDates.split(",").map(d=>d.trim()):[],disabledDays:this.input.dataset.disabledDays?this.input.dataset.disabledDays.split(",").map(d=>d.trim()):[],weekendDays:this.input.dataset.weekendDays?this.input.dataset.weekendDays.split(",").map(d=>d.trim()):[0,6],altField:this.input.dataset.altField||null,altFormat:this.input.dataset.altFormat||"Y-m-d",range:this.input.dataset.range==="true",multiple:this.input.dataset.multiple==="true",multipleSeparator:this.input.dataset.multipleSeparator||",",altFieldMultipleSeparator:this.input.dataset.altFieldMultipleSeparator||",",multipleDisplaySelector:this.input.dataset.multipleDisplaySelector||"",autoClose:this.input.dataset.autoClose!=="false",firstDayOfWeek:this.input.dataset.firstDayOfWeek!==undefined?parseInt(this.input.dataset.firstDayOfWeek):null,todayButton:this.input.dataset.todayButton!=="false",clearButton:this.input.dataset.clearButton!=="false",closeButton:this.input.dataset.closeButton!=="false",timepicker:this.input.dataset.timepicker==="true",timeOnly:this.input.dataset.timeOnly==="true",timepickerDefaultNow:this.input.dataset.timepickerDefaultNow!=="false",ampm:this.input.dataset.ampm==="true",hoursStep:parseInt(this.input.dataset.hoursStep)||1,minutesStep:parseInt(this.input.dataset.minutesStep)||1,minHours:this.input.dataset.minHours!==undefined?parseInt(this.input.dataset.minHours):null,maxHours:this.input.dataset.maxHours!==undefined?parseInt(this.input.dataset.maxHours):null,minMinutes:this.input.dataset.minMinutes!==undefined?parseInt(this.input.dataset.minMinutes):0,maxMinutes:this.input.dataset.maxMinutes!==undefined?parseInt(this.input.dataset.maxMinutes):59,...options};if(isNaN(this.options.minutesStep))this.options.minutesStep=1;if(isNaN(this.options.hoursStep))this.options.hoursStep=1;if(isNaN(this.options.minMinutes))this.options.minMinutes=0;if(isNaN(this.options.maxMinutes))this.options.maxMinutes=59;if(isNaN(this.options.minHours))this.options.minHours=null;if(isNaN(this.options.maxHours))this.options.maxHours=null;if(this.options.firstDayOfWeek===null||this.options.firstDayOfWeek===undefined||isNaN(this.options.firstDayOfWeek)){this.options.firstDayOfWeek=this.locale.firstDayOfWeek;if(this.options.firstDayOfWeek==null||isNaN(this.options.firstDayOfWeek)){this.options.firstDayOfWeek=1}}if(!Array.isArray(this.options.weekendDays)){this.options.weekendDays=[0,6]}if(this.input.value||this.input.dataset.date){this.options.view="days"}this.view=this.options.view==="years"?"years":this.options.view==="months"?"months":"days";if(this.options.timeOnly){this.options.autoClose=false;this.options.todayButton=false;this.options.clearButton=false}if(!this.input.dataset.format&&!this.options.format){this.options.format=this.locale.format||"m/d/Y"}this.options.ampmuppercase=false;if(this.options.format.includes("a")||this.options.format.includes("A")){this.options.ampm=true;if(this.options.format.includes("A")){this.options.ampmuppercase=true}}this.boundHandlers={paste:e=>e.preventDefault(),drop:e=>e.preventDefault(),click:()=>this.toggle(),input:e=>{if(this.input.value&&!this.selectedDate){this.updateInput()}e.preventDefault();e.stopPropagation()},keydown:e=>{this._keyboardActive=true;if(!this.isOpen){if(["ArrowDown"," ","Enter"].includes(e.key)){e.preventDefault();e.stopPropagation();this.open()}else if(!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key!="Tab"){e.preventDefault();e.stopPropagation()}return}switch(e.key){case"Escape":e.preventDefault();e.stopPropagation();this.close();break;case"ArrowLeft":this.keyboardNavigate(-1,"horizontal");break;case"ArrowRight":this.keyboardNavigate(1,"horizontal");break;case"ArrowUp":this.keyboardNavigate(-1,"vertical");break;case"ArrowDown":this.keyboardNavigate(1,"vertical");break;case"PageUp":if(this.view==="days"){if(e.shiftKey){this.focusedDate.setFullYear(this.focusedDate.getFullYear()-1)}else{this.focusedDate.setMonth(this.focusedDate.getMonth()-1)}this.render();this.setInitialFocus()}break;case"PageDown":if(this.view==="days"){if(e.shiftKey){this.focusedDate.setFullYear(this.focusedDate.getFullYear()+1)}else{this.focusedDate.setMonth(this.focusedDate.getMonth()+1)}this.render();this.setInitialFocus()}break;case"Home":if(this.view==="days"){this.focusedDate.setDate(1);this.render();this.setDayFocus()}break;case"End":if(this.view==="days"){const lastDay=new Date(this.focusedDate.getFullYear(),this.focusedDate.getMonth()+1,0).getDate();this.focusedDate.setDate(lastDay);this.render();this.setDayFocus()}break;case"Enter":case" ":this.keyboardHandleSelection();break;default:e.preventDefault();break}}};this.init()}isDateDisabled(date){if(!date||isNaN(date.getTime())){return true}const dateString=this.formatDate(date,"Y-m-d");const dayOfWeek=date.getDay();const normalizedDate=new Date(date.getFullYear(),date.getMonth(),date.getDate());const normalizedTime=normalizedDate.getTime();if(this.options.minDate){const minDateCopy=new Date(this.options.minDate);const minTime=new Date(minDateCopy.getFullYear(),minDateCopy.getMonth(),minDateCopy.getDate()).getTime();if(normalizedTime<minTime)return true}if(this.options.maxDate){const maxDateCopy=new Date(this.options.maxDate);const maxTime=new Date(maxDateCopy.getFullYear(),maxDateCopy.getMonth(),maxDateCopy.getDate()).getTime();if(normalizedTime>maxTime)return true}if(this.options.disabledDates&&this.options.disabledDates.includes(dateString)){return true}if(this.options.disabledDays&&this.options.disabledDays.includes(dayOfWeek)){return true}return false}getOrCreateGlobalContainer(){let container=document.getElementById("fdatepicker-global-container");if(!container){container=document.createElement("div");container.id="fdatepicker-global-container";container.className="fdatepicker-global-container";document.body.appendChild(container)}return container}wrapInput(){const wrapper=document.createElement("div");wrapper.style.position="relative";wrapper.style.display="inline-block";wrapper.style.width="100%";this.input.parentNode.insertBefore(wrapper,this.input);wrapper.appendChild(this.input);return wrapper}init(){this.input.removeAttribute("readonly");this.input.setAttribute("aria-haspopup","dialog");this.input.setAttribute("aria-expanded","false");if(this.options.altFormat&&!this.options.altField){const hiddenId=this.input.id?this.input.id+"-fdp-alt":"fdp-alt-"+Math.random().toString(36).slice(2);const hiddenInput=document.createElement("input");hiddenInput.type="hidden";hiddenInput.id=hiddenId;if(this.input.name){hiddenInput.name=this.input.name;this.input.removeAttribute("name")}this.input.insertAdjacentElement("afterend",hiddenInput);this.options.altField=hiddenId;this._autoCreatedAltField=hiddenInput}this.initializePrefilledDates();this.bindInputEvents();this.updateInput();this._reposition=()=>this.setPosition();this._scrollHandler=e=>{if(!this.popup?.contains(e.target))this._reposition()};this._resizeObserver=new ResizeObserver(this._reposition);this._keyboardActive=false}initializePrefilledDates(){if(this.options.multiple&&this.input.dataset.date){const dates=this.input.dataset.date.split(",");this.selectedDates=dates.map(dateStr=>new Date(dateStr.trim())).filter(date=>!isNaN(date));if(this.selectedDates.length>0){this.focusedDate=new Date(this.selectedDates[0])}}else if(this.input.dataset.date){const date=new Date(this.input.dataset.date);if(!isNaN(date)){this.selectedDate=date;this.focusedDate=new Date(date)}}}getInitialTimeValues(){let hours=12;let minutes=0;let isAM=true;if(this.selectedDate){hours=this.selectedDate.getHours();minutes=this.selectedDate.getMinutes();isAM=hours<12}else if(this.options.timepickerDefaultNow){const now=new Date;hours=now.getHours();minutes=now.getMinutes();isAM=hours<12}let displayHours=hours;if(this.options.ampm){displayHours=hours===0?12:hours>12?hours-12:hours}return{hours:displayHours,minutes:minutes,isAM:isAM}}createPopup(){const popup=document.createElement("div");popup.className="fdatepicker-popup";popup.setAttribute("role","dialog");popup.setAttribute("aria-modal","true");popup.setAttribute("aria-label","Date picker");if(!this.options.timeOnly){popup.innerHTML=`
<div class="fdatepicker-header">
<button class="fdatepicker-nav" data-action="prev" aria-label="Previous" tabindex="0">‹</button>
<div class="fdatepicker-title" tabindex="0" aria-live="polite" aria-atomic="true"></div>
<button class="fdatepicker-nav" data-action="next" aria-label="Next" tabindex="0">›</button>
</div>
<div class="fdatepicker-content">
<div class="fdatepicker-grid">
<!-- Days headers will be added dynamically -->
</div>
</div>
`}if(this.options.timepicker){const initialTime=this.getInitialTimeValues();const is24Hour=!this.options.ampm;let minHours,maxHours;if(this.options.minHours!==null&&this.options.maxHours!==null){minHours=this.options.minHours;maxHours=this.options.maxHours}else if(is24Hour){minHours=this.options.minHours!==null?this.options.minHours:0;maxHours=this.options.maxHours!==null?this.options.maxHours:23}else{minHours=this.options.minHours!==null?this.options.minHours:1;maxHours=this.options.maxHours!==null?this.options.maxHours:12}const timeInputs=document.createElement("div");timeInputs.className="fdatepicker-time-inputs";const hoursInput=document.createElement("input");hoursInput.type="number";hoursInput.className="fdatepicker-time-input";hoursInput.dataset.time="hours";hoursInput.min=minHours;hoursInput.max=maxHours;hoursInput.step=this.options.hoursStep;hoursInput.value=String(initialTime.hours).padStart(2,"0");hoursInput.tabIndex=0;hoursInput.setAttribute("aria-label","Hours");timeInputs.appendChild(hoursInput);const separator=document.createElement("span");separator.className="fdatepicker-time-separator";separator.textContent=":";timeInputs.appendChild(separator);const minutesInput=document.createElement("input");minutesInput.type="number";minutesInput.className="fdatepicker-time-input";minutesInput.dataset.time="minutes";minutesInput.min=this.options.minMinutes;minutesInput.max=this.options.maxMinutes;minutesInput.step=this.options.minutesStep;minutesInput.value=String(initialTime.minutes).padStart(2,"0");minutesInput.tabIndex=0;minutesInput.setAttribute("aria-label","Minutes");timeInputs.appendChild(minutesInput);if(this.options.ampm){const amButton=document.createElement("div");amButton.className=`fdatepicker-time-ampm ${initialTime.isAM?"active":""}`;amButton.dataset.ampm="AM";if(this.options.ampmuppercase)amButton.textContent="AM";else amButton.textContent="am";amButton.tabIndex=0;amButton.setAttribute("role","button");amButton.setAttribute("aria-label","AM");amButton.setAttribute("aria-pressed",initialTime.isAM?"true":"false");amButton.addEventListener("click",()=>{amButton.classList.add("active");amButton.setAttribute("aria-pressed","true");pmButton.classList.remove("active");pmButton.setAttribute("aria-pressed","false");this.updateSelectedTime()});amButton.addEventListener("keydown",e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();amButton.click()}});timeInputs.appendChild(amButton);const pmButton=document.createElement("div");pmButton.className=`fdatepicker-time-ampm ${!initialTime.isAM?"active":""}`;pmButton.dataset.ampm="PM";if(this.options.ampmuppercase)pmButton.textContent="PM";else pmButton.textContent="pm";pmButton.tabIndex=0;pmButton.setAttribute("role","button");pmButton.setAttribute("aria-label","PM");pmButton.setAttribute("aria-pressed",!initialTime.isAM?"true":"false");pmButton.addEventListener("click",()=>{pmButton.classList.add("active");pmButton.setAttribute("aria-pressed","true");amButton.classList.remove("active");amButton.setAttribute("aria-pressed","false");this.updateSelectedTime()});pmButton.addEventListener("keydown",e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();pmButton.click()}});timeInputs.appendChild(pmButton)}const timepicker=document.createElement("div");timepicker.className="fdatepicker-timepicker";timepicker.appendChild(timeInputs);popup.appendChild(timepicker)}if(this.options.todayButton||this.options.clearButton||this.options.closeButton){const buttonRow=document.createElement("div");buttonRow.className="fdatepicker-buttons";if(this.options.todayButton){const todayBtn=document.createElement("button");todayBtn.type="button";todayBtn.className="fdatepicker-button-text";todayBtn.textContent=this.locale.today||"Today";todayBtn.addEventListener("click",e=>{e.stopPropagation();const today=new Date;this.focusedDate=new Date(today);this.selectDate(today.getDate());this.render()});buttonRow.appendChild(todayBtn)}if(this.options.clearButton){const clearBtn=document.createElement("button");clearBtn.type="button";clearBtn.className="fdatepicker-button-text";clearBtn.textContent=this.locale.clear||"Clear";clearBtn.addEventListener("click",e=>{e.stopPropagation();this.selectedDate=null;this.selectedEndDate=null;this.selectedDates=[];this.updateInput();this.render()});buttonRow.appendChild(clearBtn)}if(this.options.closeButton){const closeBtn=document.createElement("button");closeBtn.type="button";closeBtn.className="fdatepicker-button-text";closeBtn.textContent=this.locale.close||"Close";closeBtn.addEventListener("click",e=>{e.stopPropagation();this.close()});buttonRow.appendChild(closeBtn)}popup.appendChild(buttonRow)}this.container.appendChild(popup);return popup}bindInputEvents(){this.input.addEventListener("input",this.boundHandlers.input);this.input.addEventListener("click",this.boundHandlers.click);this.input.addEventListener("paste",this.boundHandlers.paste);this.input.addEventListener("drop",this.boundHandlers.drop);this.input.addEventListener("keydown",this.boundHandlers.keydown)}bindGridAndPopupEvents(){this.grid?.addEventListener("mouseover",e=>{if(this._keyboardActive)return;if(e.target.classList.contains("fdatepicker-day")&&!e.target.classList.contains("other-month")){this.focusedDate.setDate(parseInt(e.target.textContent));this.setFocus(e.target)}else if(e.target.classList.contains("fdatepicker-month")){this.focusedDate.setMonth(parseInt(e.target.dataset.month));this.setFocus(e.target)}else if(e.target.classList.contains("fdatepicker-year")){this.focusedDate.setFullYear(parseInt(e.target.dataset.year));this.setFocus(e.target)}});this.grid?.addEventListener("mouseleave",()=>{this.clearFocus()});this.grid?.addEventListener("mousemove",()=>{this._keyboardActive=false});this.grid?.addEventListener("keydown",e=>{const keys=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," ","Enter","Escape"];if(keys.includes(e.key)){e.preventDefault();e.stopPropagation();const syntheticEvent=new KeyboardEvent("keydown",{key:e.key,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,bubbles:false,cancelable:true});this.input.dispatchEvent(syntheticEvent)}});this.popup.addEventListener("keydown",e=>{if(e.key==="Tab"){const focusableElements=this.popup.querySelectorAll('button:not([disabled]), [tabindex="0"], input:not([disabled])');const focusableArray=Array.from(focusableElements);const currentIndex=focusableArray.indexOf(e.target);if(currentIndex===-1)return;if(e.shiftKey){if(currentIndex===0){e.preventDefault();focusableArray[focusableArray.length-1].focus()}}else{let nextIndex=currentIndex+1;if(nextIndex>=focusableArray.length)nextIndex=0;if(focusableArray[currentIndex].parentElement.classList.contains("fdatepicker-header")&&focusableArray[nextIndex].parentElement.classList.contains("fdatepicker-buttons")){e.preventDefault();if(this.view==="days"){this.setDayFocus()}else if(this.view==="months"){this.setMonthFocus()}else if(this.view==="years"){this.setYearFocus()}}if(currentIndex===focusableArray.length-1){e.preventDefault();focusableArray[0].focus()}}}});this.popup.addEventListener("click",e=>{e.stopPropagation();const action=e.target.dataset.action;if(action==="prev"){this.navigateView(-1);this.setInitialFocus()}if(action==="next"){this.navigateView(1);this.setInitialFocus()}if(e.target===this.title){if(this.view==="days")this.view="months";else if(this.view==="months")this.view="years";this.render();this.setInitialFocus()}if(e.target.classList.contains("fdatepicker-day")&&!e.target.classList.contains("other-month")){this.selectDate(parseInt(e.target.textContent))}if(e.target.classList.contains("fdatepicker-month")){this.selectMonth(parseInt(e.target.dataset.month))}if(e.target.classList.contains("fdatepicker-year")&&!e.target.classList.contains("other-decade")){this.selectYear(parseInt(e.target.dataset.year))}});if(this.options.timepicker){[this.hoursInput,this.minutesInput].forEach(input=>{if(input){input.addEventListener("keydown",e=>{if(["Enter","Escape"].includes(e.key)){e.preventDefault();e.stopPropagation();this.close();return}if(["ArrowUp","ArrowDown"].includes(e.key)){e.stopPropagation()}});input.addEventListener("change",()=>this.updateSelectedTime());input.addEventListener("blur",()=>this.updateSelectedTime())}})}}keyboardNavigate(direction,orientation){if(this.view==="days"){if(orientation==="horizontal"){this.focusedDate.setDate(this.focusedDate.getDate()+direction)}else{this.focusedDate.setDate(this.focusedDate.getDate()+direction*7)}this.render();this.setDayFocus()}else if(this.view==="months"){const currentMonth=this.focusedDate.getMonth();let newMonth;if(orientation==="horizontal"){newMonth=currentMonth+direction}else{newMonth=currentMonth+direction*3}if(newMonth<0){this.focusedDate.setFullYear(this.focusedDate.getFullYear()-1);this.focusedDate.setMonth(11+newMonth+1)}else if(newMonth>11){this.focusedDate.setFullYear(this.focusedDate.getFullYear()+1);this.focusedDate.setMonth(newMonth-12)}else{this.focusedDate.setMonth(newMonth)}this.render();this.setMonthFocus()}else if(this.view==="years"){if(orientation==="horizontal"){this.currentYear+=direction}else{this.currentYear+=direction*3}this.focusedDate.setFullYear(this.currentYear);this.render();this.setYearFocus()}}keyboardHandleSelection(){if(this.view==="days"){const focusedDay=this.popup.querySelector(".fdatepicker-day:focus, .fdatepicker-day.focus");if(focusedDay&&!focusedDay.classList.contains("other-month")&&!focusedDay.classList.contains("disabled")){this.selectDate(parseInt(focusedDay.textContent))}}else if(this.view==="months"){const focusedMonth=this.popup.querySelector(".fdatepicker-month:focus, .fdatepicker-month.focus");if(focusedMonth){this.selectMonth(parseInt(focusedMonth.dataset.month))}}else if(this.view==="years"){const focusedYear=this.popup.querySelector(".fdatepicker-year:focus, .fdatepicker-year.focus");if(focusedYear&&!focusedYear.classList.contains("other-decade")&&!focusedYear.classList.contains("disabled")){this.selectYear(parseInt(focusedYear.dataset.year))}}}setInitialFocus(){setTimeout(()=>{if(this.options.timeOnly){if(this.hoursInput){this.hoursInput.focus()}else if(this.minutesInput){this.minutesInput.focus()}return}if(this.view==="days")this.setDayFocus();else if(this.view==="months")this.setMonthFocus();else if(this.view==="years")this.setYearFocus()},0)}setDayFocus(){if(this.view!=="days")return;this.clearFocus();if(this.popup){const day=this.focusedDate.getDate();const dayElements=Array.from(this.popup.querySelectorAll(".fdatepicker-day:not(.other-month)"));const targetDay=dayElements.find(el=>parseInt(el.textContent)===day);if(targetDay){this.setFocus(targetDay)}}}setMonthFocus(){if(this.view!=="months")return;this.clearFocus();if(this.popup){const month=this.focusedDate.getMonth();const monthElement=this.popup.querySelector(`[data-month="${month}"]`);if(monthElement){this.setFocus(monthElement)}}}setYearFocus(){if(this.view!=="years")return;this.clearFocus();if(this.popup){const year=this.focusedDate.getFullYear();const startDecade=Math.floor(this.currentYear/10)*10;const minYear=startDecade;const maxYear=startDecade+9;if(year>=minYear&&year<=maxYear){const yearElement=this.popup.querySelector(`[data-year="${year}"]`);if(yearElement){this.setFocus(yearElement)}}else{const firstValidYear=this.popup.querySelector(`.fdatepicker-year:not(.disabled):not(.other-decade)`);if(firstValidYear){this.setFocus(firstValidYear)}}}}setFocus(element){if(this.focusedElement){this.focusedElement.setAttribute("tabindex","-1");this.focusedElement.classList.remove("focus")}this.focusedElement=element;element.setAttribute("tabindex","0");element.classList.add("focus");element.focus();if(this.options.range&&this.selectedDate&&!this.selectedEndDate){if(this.popup){this.popup.querySelectorAll(".fdatepicker-day.in-range").forEach(day=>{day.classList.remove("in-range")})}const day=parseInt(element.textContent);const month=this.focusedDate.getMonth();const year=this.focusedDate.getFullYear();const focusedDate=new Date(year,month,day);if(isNaN(focusedDate.getTime())||element.classList.contains("other-month")||element.classList.contains("disabled")){return}const startDate=this.selectedDate;const endDate=focusedDate;const start=startDate<endDate?startDate:endDate;const end=startDate<endDate?endDate:startDate;if(this.popup){const dayElements=Array.from(this.popup.querySelectorAll(".fdatepicker-day:not(.other-month)"));dayElements.forEach(dayEl=>{const dayNum=parseInt(dayEl.textContent);const dayDate=new Date(year,month,dayNum);if(dayDate>start&&dayDate<end){dayEl.classList.add("in-range")}})}}}clearFocus(){if(this.popup){this.popup.querySelectorAll(".fdatepicker-day, .fdatepicker-month, .fdatepicker-year").forEach(el=>{el.classList.remove("focus");el.classList.remove("hover");el.setAttribute("tabindex","-1")})}this.focusedElement=null}getDaysInMonth(year,monthIndex){return new Date(year,monthIndex+1,0).getDate()}navigateView(direction){if(this.view==="days"){const targetMonth=this.focusedDate.getMonth()+direction;const targetYear=this.focusedDate.getFullYear();const maxDay=this.getDaysInMonth(targetYear,targetMonth);this.focusedDate.setMonth(targetMonth,Math.min(this.focusedDate.getDate(),maxDay))}else if(this.view==="months"){this.focusedDate.setFullYear(this.focusedDate.getFullYear()+direction)}else if(this.view==="years"){this.currentYear+=direction*10;this.focusedDate.setFullYear(this.currentYear)}this.render()}toggle(){this.isOpen?this.close():this.open()}open(){if(this.isOpen)return;if(this.selectedDate){this.focusedDate=new Date(this.selectedDate);if(this.view==="years"){this.currentYear=this.selectedDate.getFullYear()}}else{this.focusedDate=new Date;if(this.view==="years"){this.currentYear=this.focusedDate.getFullYear()}}if(this.options.multiple&&this.selectedDates.length>0){this.focusedDate=new Date(this.selectedDates[0]);if(this.view==="years"){this.currentYear=this.focusedDate.getFullYear()}}this.popup=this.createPopup();this.title=this.popup.querySelector(".fdatepicker-title");this.content=this.popup.querySelector(".fdatepicker-content");this.grid=this.popup.querySelector(".fdatepicker-grid");this.hoursInput=this.popup.querySelector('[data-time="hours"]');this.minutesInput=this.popup.querySelector('[data-time="minutes"]');this.bindGridAndPopupEvents();FDatepicker._openInstances.add(this);FDatepicker._addGlobalListeners();this.isOpen=true;this.input.setAttribute("aria-expanded","true");this.render();this.popup.classList.add("active");this.setInitialFocus();this.setPosition();window.addEventListener("scroll",this._scrollHandler,true);window.addEventListener("resize",this._reposition);this._resizeObserver.observe(this.input);if(this.options.onOpen&&typeof this.options.onOpen==="function")this.options.onOpen.call(this.input,this)}setPosition(){if(!this.isOpen)return;const inputRect=this.input.getBoundingClientRect();const inputBounds=this.input.getBoundingClientRect();const offset=4;const inputTop=inputRect.top+window.scrollY;const inputLeft=inputRect.left+window.scrollX;const spaceBelow=window.innerHeight-inputBounds.bottom;const spaceAbove=inputBounds.top;let top,left;this.popup.classList.remove("fdatepicker-popup-top","fdatepicker-popup-bottom","fdatepicker-popup-middle");if(spaceAbove>spaceBelow&&spaceAbove>300){this.popup.classList.add("fdatepicker-popup-top");top=inputTop-offset}else if(spaceAbove>spaceBelow&&spaceAbove>150||spaceBelow<150){this.popup.classList.add("fdatepicker-popup-middle");top=inputTop-offset}else{this.popup.classList.add("fdatepicker-popup-bottom");top=inputTop+inputBounds.height+offset}left=inputLeft;const popupWidth=320;if(left<10)left=10;if(left>window.innerWidth-popupWidth)left=window.innerWidth-popupWidth;if(top<10)top=10;this.popup.style.top=`${top}px`;this.popup.style.left=`${left}px`}close(){if(!this.isOpen)return;this.isOpen=false;this.input.setAttribute("aria-expanded","false");this.popup.classList.remove("active");this.clearFocus();if(this.popup&&this.popup.parentNode){this.popup.parentNode.removeChild(this.popup)}window.removeEventListener("scroll",this._scrollHandler,true);window.removeEventListener("resize",this._reposition);this._resizeObserver.unobserve(this.input);this.popup=null;FDatepicker._openInstances.delete(this);setTimeout(()=>{FDatepicker._cleanupOpenInstances()},0);if(this.options.onClose&&typeof this.options.onClose==="function")this.options.onClose.call(this.input,this);this.input.focus()}destroy(){if(this.isOpen){this.close()}if(this.input&&this.input._fdatepicker===this){delete this.input._fdatepicker}this.input.removeEventListener("input",this.boundHandlers.input);this.input.removeEventListener("click",this.boundHandlers.click);this.input.removeEventListener("paste",this.boundHandlers.paste);this.input.removeEventListener("drop",this.boundHandlers.drop);this.input.removeEventListener("keydown",this.boundHandlers.keydown);if(this._autoCreatedAltField){if(this._autoCreatedAltField.name&&this.input){this.input.setAttribute("name",this._autoCreatedAltField.name)}this._autoCreatedAltField.parentNode?.removeChild(this._autoCreatedAltField);this._autoCreatedAltField=null}this.input=null;this.popup=null;this.container=null;this.title=null;this.content=null;this.grid=null;this.hoursInput=null;this.minutesInput=null;this.focusedElement=null;this.selectedDate=null;this.selectedEndDate=null;this.selectedDates=[];this.options=null;this.locale=null;this._reposition=null;this._scrollHandler=null;this._resizeObserver?.disconnect();this._resizeObserver=null;FDatepicker._openInstances.delete(this);this.cleanupGlobalContainer();setTimeout(()=>{FDatepicker._cleanupOpenInstances()},0)}static destroyAll(){const instancesToDestroy=Array.from(FDatepicker._openInstances);const inputs=document.querySelectorAll("input[data-fdatepicker]");inputs.forEach(input=>{if(input._fdatepicker){instancesToDestroy.push(input._fdatepicker)}});instancesToDestroy.forEach(instance=>{if(instance&&typeof instance.destroy==="function"){instance.destroy()}});FDatepicker._openInstances.clear();FDatepicker._removeGlobalListeners()}static cleanup(){FDatepicker._cleanupOpenInstances()}cleanupGlobalContainer(){const container=document.getElementById("fdatepicker-global-container");if(container&&container.children.length===0){container.parentNode.removeChild(container)}}triggerOnSelect(){if(typeof this.options.onSelect!=="function")return;let date=null;let formattedDate="";if(this.options.multiple){date=this.selectedDates;formattedDate=this.selectedDates.map(d=>this.formatDate(d)).join(this.options.multipleSeparator)}else if(this.options.range){date=[this.selectedDate,this.selectedEndDate].filter(Boolean);formattedDate=date.map(d=>this.formatDate(d)).join(" - ")}else{date=this.selectedDate;formattedDate=this.selectedDate?this.formatDate(this.selectedDate):""}this.options.onSelect.call(this.input,formattedDate,date,this)}setDate(date,doTriggerOnSelect=true){const safeDate=d=>{const dateObj=new Date(d);return isNaN(dateObj.getTime())?null:dateObj};if(!date){this.selectedDate=null;this.selectedEndDate=null;this.selectedDates=[]}else if(this.options.multiple){if(Array.isArray(date)){this.selectedDates=date.map(safeDate).filter(d=>d!==null)}else{this.selectedDates=[safeDate(date)].filter(d=>d!==null)}this.selectedDate=null;this.selectedEndDate=null}else if(this.options.range){if(Array.isArray(date)&&date.length>=2){this.selectedDate=safeDate(date[0]);this.selectedEndDate=safeDate(date[1])}else{this.selectedDate=safeDate(date);this.selectedEndDate=null}}else{this.selectedDate=safeDate(date);this.selectedEndDate=null;this.selectedDates=[]}this.focusedDate=this.selectedDate?new Date(this.selectedDate):new Date;this.updateInput();if(this.isOpen){this.render();this.setDayFocus()}if(this.options.autoClose&&!this.options.timepicker){this.close()}if(doTriggerOnSelect){this.triggerOnSelect()}}selectDate(day){if(this.options.timeOnly){this.updateSelectedTime();return}const year=this.focusedDate.getFullYear();const month=this.focusedDate.getMonth();let hours=0,minutes=0;if(this.selectedDate){hours=this.selectedDate.getHours();minutes=this.selectedDate.getMinutes()}else if(this.options.timepicker){hours=parseInt(this.hoursInput?.value)||0;minutes=parseInt(this.minutesInput?.value)||0;if(this.options.ampm){const isAM=this.popup.querySelector("[data-ampm].active")?.dataset.ampm==="AM";if(!isAM&&hours<12){hours+=12}else if(isAM&&hours===12){hours=0}}}const selectedDate=new Date(year,month,day,hours,minutes);if(this.isDateDisabled(selectedDate)){return}if(this.options.multiple){const existingIndex=this.selectedDates.findIndex(date=>date.toDateString()===selectedDate.toDateString());if(existingIndex>=0){this.selectedDates.splice(existingIndex,1)}else{this.selectedDates.push(selectedDate);this.selectedDates.sort((a,b)=>a-b)}this.updateInput();this.render();this.updateMultipleDisplay();this.setDayFocus()}else if(this.options.range){if(!this.selectedDate||this.selectedEndDate){this.selectedDate=selectedDate;this.selectedEndDate=null;this.render();this.setDayFocus()}else{if(selectedDate<this.selectedDate){this.selectedEndDate=this.selectedDate;this.selectedDate=selectedDate}else{this.selectedEndDate=selectedDate}this.updateInput();if(!this.options.timepicker){if(this.options.autoClose){this.close()}}else{this.render();this.setDayFocus()}}}else{if(this.selectedDate&&this.selectedDate.toDateString()===selectedDate.toDateString()){this.selectedDate=null}else{this.selectedDate=selectedDate}this.updateInput();if(!this.options.timepicker){if(this.options.autoClose){this.close()}}else{this.render();this.setDayFocus()}}this.triggerOnSelect()}selectMonth(month){this.focusedDate.setMonth(month);this.view="days";this.render();this.setInitialFocus()}selectYear(year){this.focusedDate.setFullYear(year);this.currentYear=year;this.view="months";this.render();this.setInitialFocus()}validateTimeInput(type,value){if(type==="hours"){const is24Hour=!this.options.ampm;let min=is24Hour?0:1;let max=is24Hour?23:12;if(this.options.minHours!==null)min=this.options.minHours;if(this.options.maxHours!==null)max=this.options.maxHours;if(value<min)return min;if(value>max)return max;const remainder=(value-min)%this.options.hoursStep;if(remainder!==0){return value-remainder}}else if(type==="minutes"){if(value<this.options.minMinutes)return this.options.minMinutes;if(value>this.options.maxMinutes)return this.options.maxMinutes;const remainder=(value-this.options.minMinutes)%this.options.minutesStep;if(remainder!==0){return value-remainder}}return value}updateSelectedTime(){let target;if(this.options.timeOnly){if(!this.selectedDate){this.selectedDate=new Date}target=this.selectedDate}else{target=this.options.multiple?this.selectedDates[this.selectedDates.length-1]:this.selectedEndDate?this.selectedEndDate:this.selectedDate?this.selectedDate:null}if(!target)return;let hours=parseInt(this.hoursInput?.value)||0;let minutes=parseInt(this.minutesInput?.value)||0;hours=this.validateTimeInput("hours",hours);minutes=this.validateTimeInput("minutes",minutes);if(this.hoursInput){this.hoursInput.value=String(hours).padStart(2,"0")}if(this.minutesInput){this.minutesInput.value=String(minutes).padStart(2,"0")}if(this.options.ampm){const isAM=this.popup.querySelector("[data-ampm].active")?.dataset.ampm==="AM";if(isAM&&hours===12)hours=0;else if(!isAM&&hours!==12)hours+=12}target.setHours(hours,minutes);this.updateInput()}updateMultipleDisplay(){if(!this.options.multiple){return}if(!this.options.multipleDisplaySelector){return}const display=document.querySelector(this.options.multipleDisplaySelector);if(display&&this.options.multiple){if(this.selectedDates.length===0){display.textContent=this.locale.noDatesSelected}else{const dateStrings=this.selectedDates.map(date=>this.formatDate(date));const selectedString=this.locale.datesSelected;display.innerHTML="<strong>"+selectedString.replace(/\{0\}/g,this.selectedDates.length)+`</strong><br>${dateStrings.join(", ")}`}}}formatDate(date,format=null){if(!date)return"";format=format||this.options.format;return FDatepicker.formatDate(date,format,this.locale)}static formatDate(date,format="m/d/Y",locale=null){if(!date)return"";const loc=locale||FDATEPICKER_DEFAULT_MESSAGES;const hours=date.getHours();const minutes=date.getMinutes();const seconds=date.getSeconds();const isPM=hours>=12;const hour12=hours%12===0?12:hours%12;const formatMap={d:String(date.getDate()).padStart(2,"0"),j:date.getDate(),l:loc.days[date.getDay()],D:loc.daysShort[date.getDay()],S:FDatepicker.getOrdinalSuffix(date.getDate()),m:String(date.getMonth()+1).padStart(2,"0"),n:date.getMonth()+1,F:loc.months[date.getMonth()],M:loc.monthsShort[date.getMonth()],Y:date.getFullYear(),y:String(date.getFullYear()).slice(-2),H:String(hours).padStart(2,"0"),G:hours,h:String(hour12).padStart(2,"0"),g:hour12,i:String(minutes).padStart(2,"0"),s:String(seconds).padStart(2,"0"),A:isPM?"PM":"AM",a:isPM?"pm":"am"};const escapedChars={};let placeholderIndex=0;let processedFormat=format.replace(/\\(.)/g,(match,char)=>{const placeholder=`___${placeholderIndex}___`;escapedChars[placeholder]=char;placeholderIndex++;return placeholder});processedFormat=processedFormat.replace(/d|j|l|D|S|m|n|F|M|Y|y|H|G|h|g|i|s|A|a/g,match=>formatMap[match]||"");Object.keys(escapedChars).forEach(placeholder=>{processedFormat=processedFormat.replace(placeholder,escapedChars[placeholder])});return processedFormat}static getOrdinalSuffix(day){if(day>3&&day<21)return"th";switch(day%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}updateInput(){let value="";if(this.options.multiple){const count=this.selectedDates.length;if(count>0){if(this.options.altField&&this.options.multipleDisplaySelector){if(count===1){value=this.locale.singleDateSelected||"1 date selected"}else{value=this.locale.multipleDatesSelected||"{count} dates selected";value=value.replace("{count}",count)}}else{value=this.selectedDates.map(date=>this.formatDate(date)).join(this.options.multipleSeparator)}}}else if(this.options.range&&this.selectedDate&&this.selectedEndDate){if(this.options.altField){value=`${this.formatDate(this.selectedDate)} - ${this.formatDate(this.selectedEndDate)}`}else{value=this.formatDate(this.selectedDate)+this.options.multipleSeparator+this.formatDate(this.selectedEndDate)}}else if(this.selectedDate){value=this.formatDate(this.selectedDate)}this.input.value=value;if(this.options.altField){const altField=document.getElementById(this.options.altField);if(altField){let altValue="";if(this.options.multiple){altValue=this.selectedDates.map(date=>this.formatDate(date,this.options.altFormat)).join(this.options.altFieldMultipleSeparator)}else if(this.options.range&&this.selectedDate&&this.selectedEndDate){altValue=this.formatDate(this.selectedDate,this.options.altFormat)+this.options.altFieldMultipleSeparator+this.formatDate(this.selectedEndDate,this.options.altFormat)}else if(this.selectedDate){altValue=this.formatDate(this.selectedDate,this.options.altFormat)}altField.value=altValue;altField.dispatchEvent(new Event("change",{bubbles:true}));altField.dispatchEvent(new Event("input",{bubbles:true}))}}this.updateMultipleDisplay();if(!this.options.altField){this.input.dispatchEvent(new Event("change",{bubbles:true}));this.input.dispatchEvent(new Event("input",{bubbles:true}))}}render(){if(!this.popup||this.options.timeOnly)return;this.renderTitle();if(this.view==="days"){this.renderDays()}else if(this.view==="months"){this.renderMonths()}else if(this.view==="years"){this.renderYears()}}renderTitle(){let title="";let ariaLabel="";if(this.view==="days"){title=`${this.locale.months[this.focusedDate.getMonth()]} ${this.focusedDate.getFullYear()}`;ariaLabel=`${title}, click to select month`}else if(this.view==="months"){title=this.focusedDate.getFullYear();ariaLabel=`${title}, click to select year`}else if(this.view==="years"){const startDecade=Math.floor(this.currentYear/10)*10;const endDecade=startDecade+9;title=`${startDecade} - ${endDecade}`;ariaLabel=title}this.title.textContent=title;this.title.setAttribute("aria-label",ariaLabel)}renderDays(){this.grid.className="fdatepicker-grid";this.grid.setAttribute("role","grid");this.grid.setAttribute("aria-label",`${this.locale.months[this.focusedDate.getMonth()]} ${this.focusedDate.getFullYear()}`);this.grid.innerHTML="";for(let i=0;i<7;i++){const dayIndex=(this.options.firstDayOfWeek+i)%7;const header=document.createElement("div");header.className="fdatepicker-day-header";header.setAttribute("role","columnheader");header.setAttribute("aria-label",this.locale.days[dayIndex]);header.textContent=this.locale.daysMin[dayIndex];this.grid.appendChild(header)}const firstDayOfWeek=new Date(this.focusedDate.getFullYear(),this.focusedDate.getMonth(),1);const lastDay=new Date(this.focusedDate.getFullYear(),this.focusedDate.getMonth()+1,0);const today=new Date;let prevMonthDays=(firstDayOfWeek.getDay()-this.options.firstDayOfWeek+7)%7;const prevMonth=new Date(this.focusedDate.getFullYear(),this.focusedDate.getMonth()-1,0);for(let i=prevMonthDays-1;i>=0;i--){const day=document.createElement("div");day.className="fdatepicker-day other-month";day.textContent=prevMonth.getDate()-i;day.setAttribute("tabindex","-1");day.setAttribute("role","gridcell");day.setAttribute("aria-disabled","true");this.grid.appendChild(day)}for(let day=1;day<=lastDay.getDate();day++){const dayEl=document.createElement("div");dayEl.className="fdatepicker-day";dayEl.textContent=day;dayEl.setAttribute("tabindex","-1");dayEl.setAttribute("role","gridcell");const dayDate=new Date(this.focusedDate.getFullYear(),this.focusedDate.getMonth(),day);dayEl.setAttribute("aria-label",this.formatDate(dayDate,"l, F j, Y"));const dayOfWeek=dayDate.getDay();if(this.options.weekendDays.includes(dayOfWeek)){dayEl.classList.add("weekend")}if(dayDate.toDateString()===today.toDateString()){dayEl.classList.add("today")}if(this.isDateDisabled(dayDate)){dayEl.classList.add("disabled");dayEl.setAttribute("aria-disabled","true")}if(this.options.multiple){const isSelected=this.selectedDates.some(date=>date.toDateString()===dayDate.toDateString());if(isSelected){dayEl.classList.add("multi-selected");dayEl.setAttribute("aria-selected","true")}else{dayEl.setAttribute("aria-selected","false")}}else{dayEl.setAttribute("aria-selected","false");if(this.selectedDate&&dayDate.toDateString()===this.selectedDate.toDateString()){dayEl.classList.add(this.options.range?"range-start":"selected");dayEl.setAttribute("aria-selected","true")}if(this.options.range&&this.selectedEndDate&&dayDate.toDateString()===this.selectedEndDate.toDateString()){dayEl.classList.add("range-end");dayEl.setAttribute("aria-selected","true")}if(this.options.range&&this.selectedDate&&this.selectedEndDate&&dayDate>this.selectedDate&&dayDate<this.selectedEndDate){dayEl.classList.add("in-range");dayEl.setAttribute("aria-selected","true")}}this.grid.appendChild(dayEl)}const cellsWithoutHeaders=this.grid.children.length-7;const hasSixRows=cellsWithoutHeaders>35;const totalCellsNeeded=hasSixRows?42:35;const remainingCells=totalCellsNeeded-cellsWithoutHeaders;for(let day=1;day<=remainingCells;day++){const dayEl=document.createElement("div");dayEl.className="fdatepicker-day other-month";dayEl.textContent=day;dayEl.setAttribute("tabindex","-1");dayEl.setAttribute("role","gridcell");dayEl.setAttribute("aria-disabled","true");this.grid.appendChild(dayEl)}}renderMonths(){this.grid.className="fdatepicker-grid months";this.grid.setAttribute("role","grid");this.grid.setAttribute("aria-label",String(this.focusedDate.getFullYear()));this.grid.innerHTML="";for(let month=0;month<12;month++){const monthEl=document.createElement("div");monthEl.className="fdatepicker-month";monthEl.textContent=this.locale.monthsShort[month];monthEl.dataset.month=month;monthEl.setAttribute("tabindex","-1");monthEl.setAttribute("role","gridcell");monthEl.setAttribute("aria-label",this.locale.months[month]);monthEl.setAttribute("aria-selected","false");if(month===(new Date).getMonth()&&this.focusedDate.getFullYear()===(new Date).getFullYear()){monthEl.classList.add("current")}if(this.selectedDate&&month===this.selectedDate.getMonth()&&this.focusedDate.getFullYear()===this.selectedDate.getFullYear()){monthEl.classList.add("selected");monthEl.setAttribute("aria-selected","true")}this.grid.appendChild(monthEl)}}renderYears(){this.grid.className="fdatepicker-grid years";const startDecade=Math.floor(this.currentYear/10)*10;this.grid.setAttribute("role","grid");this.grid.setAttribute("aria-label",`${startDecade} – ${startDecade+9}`);this.grid.innerHTML="";const years=[startDecade-1,...Array.from({length:10},(_,i)=>startDecade+i),startDecade+10];years.forEach(year=>{const yearEl=document.createElement("div");yearEl.className="fdatepicker-year";yearEl.textContent=year;yearEl.dataset.year=year;yearEl.setAttribute("tabindex","-1");yearEl.setAttribute("role","gridcell");yearEl.setAttribute("aria-label",String(year));yearEl.setAttribute("aria-selected","false");if(year===(new Date).getFullYear()){yearEl.classList.add("current")}if(this.selectedDate&&year===this.selectedDate.getFullYear()){yearEl.classList.add("selected");yearEl.setAttribute("aria-selected","true")}if(year===startDecade-1||year===startDecade+10){yearEl.classList.add("disabled","other-decade");yearEl.setAttribute("aria-disabled","true")}this.grid.appendChild(yearEl)})}update(options,value){if(typeof options==="string"){this.setOption(options,value)}else{Object.entries(options).forEach(([key,val])=>{this.setOption(key,val)})}}setOption(option,value){const prevValue=this.options[option];if(prevValue===value)return;this.options[option]=value;switch(option){case"multiple":if(value){this.selectedDates=this.selectedDate?[this.selectedDate]:[];this.selectedDate=null;this.selectedEndDate=null}else{this.selectedDate=this.selectedDates.length>0?this.selectedDates[0]:null;this.selectedDates=[]}break;case"range":if(value){if(this.options.multiple){this.options.multiple=false;this.selectedDates=[]}}break;case"format":case"altFormat":case"todayButton":case"clearButton":case"closeButton":case"firstDay":case"timepickerDefaultNow":break}this.updateInput();this.render();this.updateMultipleDisplay()}}return FDatepicker});