12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933 |
- // modules are defined as an array
- // [ module function, map of requires ]
- //
- // map of requires is short require name -> numeric require
- //
- // anything defined in a previous bundle is accessed via the
- // orig method which is the require for previous bundles
- parcelRequire = (function (modules, cache, entry, globalName) {
- // Save the require from previous bundle to this closure if any
- var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
- var nodeRequire = typeof require === 'function' && require;
- function newRequire(name, jumped) {
- if (!cache[name]) {
- if (!modules[name]) {
- // if we cannot find the module within our internal map or
- // cache jump to the current global require ie. the last bundle
- // that was added to the page.
- var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
- if (!jumped && currentRequire) {
- return currentRequire(name, true);
- }
- // If there are other bundles on this page the require from the
- // previous one is saved to 'previousRequire'. Repeat this as
- // many times as there are bundles until the module is found or
- // we exhaust the require chain.
- if (previousRequire) {
- return previousRequire(name, true);
- }
- // Try the node require function if it exists.
- if (nodeRequire && typeof name === 'string') {
- return nodeRequire(name);
- }
- var err = new Error('Cannot find module \'' + name + '\'');
- err.code = 'MODULE_NOT_FOUND';
- throw err;
- }
- localRequire.resolve = resolve;
- localRequire.cache = {};
- var module = cache[name] = new newRequire.Module(name);
- modules[name][0].call(module.exports, localRequire, module, module.exports, this);
- }
- return cache[name].exports;
- function localRequire(x){
- return newRequire(localRequire.resolve(x));
- }
- function resolve(x){
- return modules[name][1][x] || x;
- }
- }
- function Module(moduleName) {
- this.id = moduleName;
- this.bundle = newRequire;
- this.exports = {};
- }
- newRequire.isParcelRequire = true;
- newRequire.Module = Module;
- newRequire.modules = modules;
- newRequire.cache = cache;
- newRequire.parent = previousRequire;
- newRequire.register = function (id, exports) {
- modules[id] = [function (require, module) {
- module.exports = exports;
- }, {}];
- };
- var error;
- for (var i = 0; i < entry.length; i++) {
- try {
- newRequire(entry[i]);
- } catch (e) {
- // Save first error but execute all entries
- if (!error) {
- error = e;
- }
- }
- }
- if (entry.length) {
- // Expose entry point to Node, AMD or browser globals
- // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
- var mainExports = newRequire(entry[entry.length - 1]);
- // CommonJS
- if (typeof exports === "object" && typeof module !== "undefined") {
- module.exports = mainExports;
- // RequireJS
- } else if (typeof define === "function" && define.amd) {
- define(function () {
- return mainExports;
- });
- // <script>
- } else if (globalName) {
- this[globalName] = mainExports;
- }
- }
- // Override the current require with this new one
- parcelRequire = newRequire;
- if (error) {
- // throw error from earlier, _after updating parcelRequire_
- throw error;
- }
- return newRequire;
- })({"node_modules/flatpickr/dist/flatpickr.js":[function(require,module,exports) {
- var define;
- var global = arguments[3];
- /* flatpickr v4.6.3, @license MIT */
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = global || self, global.flatpickr = factory());
- })(this, function () {
- 'use strict';
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation. All rights reserved.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of the
- License at http://www.apache.org/licenses/LICENSE-2.0
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
- MERCHANTABLITY OR NON-INFRINGEMENT.
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
- ***************************************************************************** */
- var __assign = function () {
- __assign = Object.assign || function __assign(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- var HOOKS = ["onChange", "onClose", "onDayCreate", "onDestroy", "onKeyDown", "onMonthChange", "onOpen", "onParseConfig", "onReady", "onValueUpdate", "onYearChange", "onPreCalendarPosition"];
- var defaults = {
- _disable: [],
- _enable: [],
- allowInput: false,
- altFormat: "F j, Y",
- altInput: false,
- altInputClass: "form-control input",
- animate: typeof window === "object" && window.navigator.userAgent.indexOf("MSIE") === -1,
- ariaDateFormat: "F j, Y",
- clickOpens: true,
- closeOnSelect: true,
- conjunction: ", ",
- dateFormat: "Y-m-d",
- defaultHour: 12,
- defaultMinute: 0,
- defaultSeconds: 0,
- disable: [],
- disableMobile: false,
- enable: [],
- enableSeconds: false,
- enableTime: false,
- errorHandler: function (err) {
- return typeof console !== "undefined" && console.warn(err);
- },
- getWeek: function (givenDate) {
- var date = new Date(givenDate.getTime());
- date.setHours(0, 0, 0, 0); // Thursday in current week decides the year.
- date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7); // January 4 is always in week 1.
- var week1 = new Date(date.getFullYear(), 0, 4); // Adjust to Thursday in week 1 and count number of weeks from date to week1.
- return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
- },
- hourIncrement: 1,
- ignoredFocusElements: [],
- inline: false,
- locale: "default",
- minuteIncrement: 5,
- mode: "single",
- monthSelectorType: "dropdown",
- nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",
- noCalendar: false,
- now: new Date(),
- onChange: [],
- onClose: [],
- onDayCreate: [],
- onDestroy: [],
- onKeyDown: [],
- onMonthChange: [],
- onOpen: [],
- onParseConfig: [],
- onReady: [],
- onValueUpdate: [],
- onYearChange: [],
- onPreCalendarPosition: [],
- plugins: [],
- position: "auto",
- positionElement: undefined,
- prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",
- shorthandCurrentMonth: false,
- showMonths: 1,
- static: false,
- time_24hr: false,
- weekNumbers: false,
- wrap: false
- };
- var english = {
- weekdays: {
- shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
- longhand: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
- },
- months: {
- shorthand: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
- longhand: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
- },
- daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
- firstDayOfWeek: 0,
- ordinal: function (nth) {
- var s = nth % 100;
- if (s > 3 && s < 21) return "th";
- switch (s % 10) {
- case 1:
- return "st";
- case 2:
- return "nd";
- case 3:
- return "rd";
- default:
- return "th";
- }
- },
- rangeSeparator: " to ",
- weekAbbreviation: "Wk",
- scrollTitle: "Scroll to increment",
- toggleTitle: "Click to toggle",
- amPM: ["AM", "PM"],
- yearAriaLabel: "Year",
- hourAriaLabel: "Hour",
- minuteAriaLabel: "Minute",
- time_24hr: false
- };
- var pad = function (number) {
- return ("0" + number).slice(-2);
- };
- var int = function (bool) {
- return bool === true ? 1 : 0;
- };
- /* istanbul ignore next */
- function debounce(func, wait, immediate) {
- if (immediate === void 0) {
- immediate = false;
- }
- var timeout;
- return function () {
- var context = this,
- args = arguments;
- timeout !== null && clearTimeout(timeout);
- timeout = window.setTimeout(function () {
- timeout = null;
- if (!immediate) func.apply(context, args);
- }, wait);
- if (immediate && !timeout) func.apply(context, args);
- };
- }
- var arrayify = function (obj) {
- return obj instanceof Array ? obj : [obj];
- };
- function toggleClass(elem, className, bool) {
- if (bool === true) return elem.classList.add(className);
- elem.classList.remove(className);
- }
- function createElement(tag, className, content) {
- var e = window.document.createElement(tag);
- className = className || "";
- content = content || "";
- e.className = className;
- if (content !== undefined) e.textContent = content;
- return e;
- }
- function clearNode(node) {
- while (node.firstChild) node.removeChild(node.firstChild);
- }
- function findParent(node, condition) {
- if (condition(node)) return node;else if (node.parentNode) return findParent(node.parentNode, condition);
- return undefined; // nothing found
- }
- function createNumberInput(inputClassName, opts) {
- var wrapper = createElement("div", "numInputWrapper"),
- numInput = createElement("input", "numInput " + inputClassName),
- arrowUp = createElement("span", "arrowUp"),
- arrowDown = createElement("span", "arrowDown");
- if (navigator.userAgent.indexOf("MSIE 9.0") === -1) {
- numInput.type = "number";
- } else {
- numInput.type = "text";
- numInput.pattern = "\\d*";
- }
- if (opts !== undefined) for (var key in opts) numInput.setAttribute(key, opts[key]);
- wrapper.appendChild(numInput);
- wrapper.appendChild(arrowUp);
- wrapper.appendChild(arrowDown);
- return wrapper;
- }
- function getEventTarget(event) {
- if (typeof event.composedPath === "function") {
- var path = event.composedPath();
- return path[0];
- }
- return event.target;
- }
- var doNothing = function () {
- return undefined;
- };
- var monthToStr = function (monthNumber, shorthand, locale) {
- return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber];
- };
- var revFormat = {
- D: doNothing,
- F: function (dateObj, monthName, locale) {
- dateObj.setMonth(locale.months.longhand.indexOf(monthName));
- },
- G: function (dateObj, hour) {
- dateObj.setHours(parseFloat(hour));
- },
- H: function (dateObj, hour) {
- dateObj.setHours(parseFloat(hour));
- },
- J: function (dateObj, day) {
- dateObj.setDate(parseFloat(day));
- },
- K: function (dateObj, amPM, locale) {
- dateObj.setHours(dateObj.getHours() % 12 + 12 * int(new RegExp(locale.amPM[1], "i").test(amPM)));
- },
- M: function (dateObj, shortMonth, locale) {
- dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth));
- },
- S: function (dateObj, seconds) {
- dateObj.setSeconds(parseFloat(seconds));
- },
- U: function (_, unixSeconds) {
- return new Date(parseFloat(unixSeconds) * 1000);
- },
- W: function (dateObj, weekNum, locale) {
- var weekNumber = parseInt(weekNum);
- var date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
- date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek);
- return date;
- },
- Y: function (dateObj, year) {
- dateObj.setFullYear(parseFloat(year));
- },
- Z: function (_, ISODate) {
- return new Date(ISODate);
- },
- d: function (dateObj, day) {
- dateObj.setDate(parseFloat(day));
- },
- h: function (dateObj, hour) {
- dateObj.setHours(parseFloat(hour));
- },
- i: function (dateObj, minutes) {
- dateObj.setMinutes(parseFloat(minutes));
- },
- j: function (dateObj, day) {
- dateObj.setDate(parseFloat(day));
- },
- l: doNothing,
- m: function (dateObj, month) {
- dateObj.setMonth(parseFloat(month) - 1);
- },
- n: function (dateObj, month) {
- dateObj.setMonth(parseFloat(month) - 1);
- },
- s: function (dateObj, seconds) {
- dateObj.setSeconds(parseFloat(seconds));
- },
- u: function (_, unixMillSeconds) {
- return new Date(parseFloat(unixMillSeconds));
- },
- w: doNothing,
- y: function (dateObj, year) {
- dateObj.setFullYear(2000 + parseFloat(year));
- }
- };
- var tokenRegex = {
- D: "(\\w+)",
- F: "(\\w+)",
- G: "(\\d\\d|\\d)",
- H: "(\\d\\d|\\d)",
- J: "(\\d\\d|\\d)\\w+",
- K: "",
- M: "(\\w+)",
- S: "(\\d\\d|\\d)",
- U: "(.+)",
- W: "(\\d\\d|\\d)",
- Y: "(\\d{4})",
- Z: "(.+)",
- d: "(\\d\\d|\\d)",
- h: "(\\d\\d|\\d)",
- i: "(\\d\\d|\\d)",
- j: "(\\d\\d|\\d)",
- l: "(\\w+)",
- m: "(\\d\\d|\\d)",
- n: "(\\d\\d|\\d)",
- s: "(\\d\\d|\\d)",
- u: "(.+)",
- w: "(\\d\\d|\\d)",
- y: "(\\d{2})"
- };
- var formats = {
- // get the date in UTC
- Z: function (date) {
- return date.toISOString();
- },
- // weekday name, short, e.g. Thu
- D: function (date, locale, options) {
- return locale.weekdays.shorthand[formats.w(date, locale, options)];
- },
- // full month name e.g. January
- F: function (date, locale, options) {
- return monthToStr(formats.n(date, locale, options) - 1, false, locale);
- },
- // padded hour 1-12
- G: function (date, locale, options) {
- return pad(formats.h(date, locale, options));
- },
- // hours with leading zero e.g. 03
- H: function (date) {
- return pad(date.getHours());
- },
- // day (1-30) with ordinal suffix e.g. 1st, 2nd
- J: function (date, locale) {
- return locale.ordinal !== undefined ? date.getDate() + locale.ordinal(date.getDate()) : date.getDate();
- },
- // AM/PM
- K: function (date, locale) {
- return locale.amPM[int(date.getHours() > 11)];
- },
- // shorthand month e.g. Jan, Sep, Oct, etc
- M: function (date, locale) {
- return monthToStr(date.getMonth(), true, locale);
- },
- // seconds 00-59
- S: function (date) {
- return pad(date.getSeconds());
- },
- // unix timestamp
- U: function (date) {
- return date.getTime() / 1000;
- },
- W: function (date, _, options) {
- return options.getWeek(date);
- },
- // full year e.g. 2016
- Y: function (date) {
- return date.getFullYear();
- },
- // day in month, padded (01-30)
- d: function (date) {
- return pad(date.getDate());
- },
- // hour from 1-12 (am/pm)
- h: function (date) {
- return date.getHours() % 12 ? date.getHours() % 12 : 12;
- },
- // minutes, padded with leading zero e.g. 09
- i: function (date) {
- return pad(date.getMinutes());
- },
- // day in month (1-30)
- j: function (date) {
- return date.getDate();
- },
- // weekday name, full, e.g. Thursday
- l: function (date, locale) {
- return locale.weekdays.longhand[date.getDay()];
- },
- // padded month number (01-12)
- m: function (date) {
- return pad(date.getMonth() + 1);
- },
- // the month number (1-12)
- n: function (date) {
- return date.getMonth() + 1;
- },
- // seconds 0-59
- s: function (date) {
- return date.getSeconds();
- },
- // Unix Milliseconds
- u: function (date) {
- return date.getTime();
- },
- // number of the day of the week
- w: function (date) {
- return date.getDay();
- },
- // last two digits of year e.g. 16 for 2016
- y: function (date) {
- return String(date.getFullYear()).substring(2);
- }
- };
- var createDateFormatter = function (_a) {
- var _b = _a.config,
- config = _b === void 0 ? defaults : _b,
- _c = _a.l10n,
- l10n = _c === void 0 ? english : _c;
- return function (dateObj, frmt, overrideLocale) {
- var locale = overrideLocale || l10n;
- if (config.formatDate !== undefined) {
- return config.formatDate(dateObj, frmt, locale);
- }
- return frmt.split("").map(function (c, i, arr) {
- return formats[c] && arr[i - 1] !== "\\" ? formats[c](dateObj, locale, config) : c !== "\\" ? c : "";
- }).join("");
- };
- };
- var createDateParser = function (_a) {
- var _b = _a.config,
- config = _b === void 0 ? defaults : _b,
- _c = _a.l10n,
- l10n = _c === void 0 ? english : _c;
- return function (date, givenFormat, timeless, customLocale) {
- if (date !== 0 && !date) return undefined;
- var locale = customLocale || l10n;
- var parsedDate;
- var dateOrig = date;
- if (date instanceof Date) parsedDate = new Date(date.getTime());else if (typeof date !== "string" && date.toFixed !== undefined // timestamp
- ) // create a copy
- parsedDate = new Date(date);else if (typeof date === "string") {
- // date string
- var format = givenFormat || (config || defaults).dateFormat;
- var datestr = String(date).trim();
- if (datestr === "today") {
- parsedDate = new Date();
- timeless = true;
- } else if (/Z$/.test(datestr) || /GMT$/.test(datestr) // datestrings w/ timezone
- ) parsedDate = new Date(date);else if (config && config.parseDate) parsedDate = config.parseDate(date, format);else {
- parsedDate = !config || !config.noCalendar ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0) : new Date(new Date().setHours(0, 0, 0, 0));
- var matched = void 0,
- ops = [];
- for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
- var token_1 = format[i];
- var isBackSlash = token_1 === "\\";
- var escaped = format[i - 1] === "\\" || isBackSlash;
- if (tokenRegex[token_1] && !escaped) {
- regexStr += tokenRegex[token_1];
- var match = new RegExp(regexStr).exec(date);
- if (match && (matched = true)) {
- ops[token_1 !== "Y" ? "push" : "unshift"]({
- fn: revFormat[token_1],
- val: match[++matchIndex]
- });
- }
- } else if (!isBackSlash) regexStr += "."; // don't really care
- ops.forEach(function (_a) {
- var fn = _a.fn,
- val = _a.val;
- return parsedDate = fn(parsedDate, val, locale) || parsedDate;
- });
- }
- parsedDate = matched ? parsedDate : undefined;
- }
- }
- /* istanbul ignore next */
- if (!(parsedDate instanceof Date && !isNaN(parsedDate.getTime()))) {
- config.errorHandler(new Error("Invalid date provided: " + dateOrig));
- return undefined;
- }
- if (timeless === true) parsedDate.setHours(0, 0, 0, 0);
- return parsedDate;
- };
- };
- /**
- * Compute the difference in dates, measured in ms
- */
- function compareDates(date1, date2, timeless) {
- if (timeless === void 0) {
- timeless = true;
- }
- if (timeless !== false) {
- return new Date(date1.getTime()).setHours(0, 0, 0, 0) - new Date(date2.getTime()).setHours(0, 0, 0, 0);
- }
- return date1.getTime() - date2.getTime();
- }
- var isBetween = function (ts, ts1, ts2) {
- return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2);
- };
- var duration = {
- DAY: 86400000
- };
- if (typeof Object.assign !== "function") {
- Object.assign = function (target) {
- var args = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- args[_i - 1] = arguments[_i];
- }
- if (!target) {
- throw TypeError("Cannot convert undefined or null to object");
- }
- var _loop_1 = function (source) {
- if (source) {
- Object.keys(source).forEach(function (key) {
- return target[key] = source[key];
- });
- }
- };
- for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
- var source = args_1[_a];
- _loop_1(source);
- }
- return target;
- };
- }
- var DEBOUNCED_CHANGE_MS = 300;
- function FlatpickrInstance(element, instanceConfig) {
- var self = {
- config: __assign({}, defaults, flatpickr.defaultConfig),
- l10n: english
- };
- self.parseDate = createDateParser({
- config: self.config,
- l10n: self.l10n
- });
- self._handlers = [];
- self.pluginElements = [];
- self.loadedPlugins = [];
- self._bind = bind;
- self._setHoursFromDate = setHoursFromDate;
- self._positionCalendar = positionCalendar;
- self.changeMonth = changeMonth;
- self.changeYear = changeYear;
- self.clear = clear;
- self.close = close;
- self._createElement = createElement;
- self.destroy = destroy;
- self.isEnabled = isEnabled;
- self.jumpToDate = jumpToDate;
- self.open = open;
- self.redraw = redraw;
- self.set = set;
- self.setDate = setDate;
- self.toggle = toggle;
- function setupHelperFunctions() {
- self.utils = {
- getDaysInMonth: function (month, yr) {
- if (month === void 0) {
- month = self.currentMonth;
- }
- if (yr === void 0) {
- yr = self.currentYear;
- }
- if (month === 1 && (yr % 4 === 0 && yr % 100 !== 0 || yr % 400 === 0)) return 29;
- return self.l10n.daysInMonth[month];
- }
- };
- }
- function init() {
- self.element = self.input = element;
- self.isOpen = false;
- parseConfig();
- setupLocale();
- setupInputs();
- setupDates();
- setupHelperFunctions();
- if (!self.isMobile) build();
- bindEvents();
- if (self.selectedDates.length || self.config.noCalendar) {
- if (self.config.enableTime) {
- setHoursFromDate(self.config.noCalendar ? self.latestSelectedDateObj || self.config.minDate : undefined);
- }
- updateValue(false);
- }
- setCalendarWidth();
- self.showTimeInput = self.selectedDates.length > 0 || self.config.noCalendar;
- var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
- /* TODO: investigate this further
- Currently, there is weird positioning behavior in safari causing pages
- to scroll up. https://github.com/chmln/flatpickr/issues/563
- However, most browsers are not Safari and positioning is expensive when used
- in scale. https://github.com/chmln/flatpickr/issues/1096
- */
- if (!self.isMobile && isSafari) {
- positionCalendar();
- }
- triggerEvent("onReady");
- }
- function bindToInstance(fn) {
- return fn.bind(self);
- }
- function setCalendarWidth() {
- var config = self.config;
- if (config.weekNumbers === false && config.showMonths === 1) return;else if (config.noCalendar !== true) {
- window.requestAnimationFrame(function () {
- if (self.calendarContainer !== undefined) {
- self.calendarContainer.style.visibility = "hidden";
- self.calendarContainer.style.display = "block";
- }
- if (self.daysContainer !== undefined) {
- var daysWidth = (self.days.offsetWidth + 1) * config.showMonths;
- self.daysContainer.style.width = daysWidth + "px";
- self.calendarContainer.style.width = daysWidth + (self.weekWrapper !== undefined ? self.weekWrapper.offsetWidth : 0) + "px";
- self.calendarContainer.style.removeProperty("visibility");
- self.calendarContainer.style.removeProperty("display");
- }
- });
- }
- }
- /**
- * The handler for all events targeting the time inputs
- */
- function updateTime(e) {
- if (self.selectedDates.length === 0) {
- setDefaultTime();
- }
- if (e !== undefined && e.type !== "blur") {
- timeWrapper(e);
- }
- var prevValue = self._input.value;
- setHoursFromInputs();
- updateValue();
- if (self._input.value !== prevValue) {
- self._debouncedChange();
- }
- }
- function ampm2military(hour, amPM) {
- return hour % 12 + 12 * int(amPM === self.l10n.amPM[1]);
- }
- function military2ampm(hour) {
- switch (hour % 24) {
- case 0:
- case 12:
- return 12;
- default:
- return hour % 12;
- }
- }
- /**
- * Syncs the selected date object time with user's time input
- */
- function setHoursFromInputs() {
- if (self.hourElement === undefined || self.minuteElement === undefined) return;
- var hours = (parseInt(self.hourElement.value.slice(-2), 10) || 0) % 24,
- minutes = (parseInt(self.minuteElement.value, 10) || 0) % 60,
- seconds = self.secondElement !== undefined ? (parseInt(self.secondElement.value, 10) || 0) % 60 : 0;
- if (self.amPM !== undefined) {
- hours = ampm2military(hours, self.amPM.textContent);
- }
- var limitMinHours = self.config.minTime !== undefined || self.config.minDate && self.minDateHasTime && self.latestSelectedDateObj && compareDates(self.latestSelectedDateObj, self.config.minDate, true) === 0;
- var limitMaxHours = self.config.maxTime !== undefined || self.config.maxDate && self.maxDateHasTime && self.latestSelectedDateObj && compareDates(self.latestSelectedDateObj, self.config.maxDate, true) === 0;
- if (limitMaxHours) {
- var maxTime = self.config.maxTime !== undefined ? self.config.maxTime : self.config.maxDate;
- hours = Math.min(hours, maxTime.getHours());
- if (hours === maxTime.getHours()) minutes = Math.min(minutes, maxTime.getMinutes());
- if (minutes === maxTime.getMinutes()) seconds = Math.min(seconds, maxTime.getSeconds());
- }
- if (limitMinHours) {
- var minTime = self.config.minTime !== undefined ? self.config.minTime : self.config.minDate;
- hours = Math.max(hours, minTime.getHours());
- if (hours === minTime.getHours()) minutes = Math.max(minutes, minTime.getMinutes());
- if (minutes === minTime.getMinutes()) seconds = Math.max(seconds, minTime.getSeconds());
- }
- setHours(hours, minutes, seconds);
- }
- /**
- * Syncs time input values with a date
- */
- function setHoursFromDate(dateObj) {
- var date = dateObj || self.latestSelectedDateObj;
- if (date) setHours(date.getHours(), date.getMinutes(), date.getSeconds());
- }
- function setDefaultHours() {
- var hours = self.config.defaultHour;
- var minutes = self.config.defaultMinute;
- var seconds = self.config.defaultSeconds;
- if (self.config.minDate !== undefined) {
- var minHr = self.config.minDate.getHours();
- var minMinutes = self.config.minDate.getMinutes();
- hours = Math.max(hours, minHr);
- if (hours === minHr) minutes = Math.max(minMinutes, minutes);
- if (hours === minHr && minutes === minMinutes) seconds = self.config.minDate.getSeconds();
- }
- if (self.config.maxDate !== undefined) {
- var maxHr = self.config.maxDate.getHours();
- var maxMinutes = self.config.maxDate.getMinutes();
- hours = Math.min(hours, maxHr);
- if (hours === maxHr) minutes = Math.min(maxMinutes, minutes);
- if (hours === maxHr && minutes === maxMinutes) seconds = self.config.maxDate.getSeconds();
- }
- setHours(hours, minutes, seconds);
- }
- /**
- * Sets the hours, minutes, and optionally seconds
- * of the latest selected date object and the
- * corresponding time inputs
- * @param {Number} hours the hour. whether its military
- * or am-pm gets inferred from config
- * @param {Number} minutes the minutes
- * @param {Number} seconds the seconds (optional)
- */
- function setHours(hours, minutes, seconds) {
- if (self.latestSelectedDateObj !== undefined) {
- self.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0);
- }
- if (!self.hourElement || !self.minuteElement || self.isMobile) return;
- self.hourElement.value = pad(!self.config.time_24hr ? (12 + hours) % 12 + 12 * int(hours % 12 === 0) : hours);
- self.minuteElement.value = pad(minutes);
- if (self.amPM !== undefined) self.amPM.textContent = self.l10n.amPM[int(hours >= 12)];
- if (self.secondElement !== undefined) self.secondElement.value = pad(seconds);
- }
- /**
- * Handles the year input and incrementing events
- * @param {Event} event the keyup or increment event
- */
- function onYearInput(event) {
- var year = parseInt(event.target.value) + (event.delta || 0);
- if (year / 1000 > 1 || event.key === "Enter" && !/[^\d]/.test(year.toString())) {
- changeYear(year);
- }
- }
- /**
- * Essentially addEventListener + tracking
- * @param {Element} element the element to addEventListener to
- * @param {String} event the event name
- * @param {Function} handler the event handler
- */
- function bind(element, event, handler, options) {
- if (event instanceof Array) return event.forEach(function (ev) {
- return bind(element, ev, handler, options);
- });
- if (element instanceof Array) return element.forEach(function (el) {
- return bind(el, event, handler, options);
- });
- element.addEventListener(event, handler, options);
- self._handlers.push({
- element: element,
- event: event,
- handler: handler,
- options: options
- });
- }
- /**
- * A mousedown handler which mimics click.
- * Minimizes latency, since we don't need to wait for mouseup in most cases.
- * Also, avoids handling right clicks.
- *
- * @param {Function} handler the event handler
- */
- function onClick(handler) {
- return function (evt) {
- evt.which === 1 && handler(evt);
- };
- }
- function triggerChange() {
- triggerEvent("onChange");
- }
- /**
- * Adds all the necessary event listeners
- */
- function bindEvents() {
- if (self.config.wrap) {
- ["open", "close", "toggle", "clear"].forEach(function (evt) {
- Array.prototype.forEach.call(self.element.querySelectorAll("[data-" + evt + "]"), function (el) {
- return bind(el, "click", self[evt]);
- });
- });
- }
- if (self.isMobile) {
- setupMobile();
- return;
- }
- var debouncedResize = debounce(onResize, 50);
- self._debouncedChange = debounce(triggerChange, DEBOUNCED_CHANGE_MS);
- if (self.daysContainer && !/iPhone|iPad|iPod/i.test(navigator.userAgent)) bind(self.daysContainer, "mouseover", function (e) {
- if (self.config.mode === "range") onMouseOver(e.target);
- });
- bind(window.document.body, "keydown", onKeyDown);
- if (!self.config.inline && !self.config.static) bind(window, "resize", debouncedResize);
- if (window.ontouchstart !== undefined) bind(window.document, "touchstart", documentClick);else bind(window.document, "mousedown", onClick(documentClick));
- bind(window.document, "focus", documentClick, {
- capture: true
- });
- if (self.config.clickOpens === true) {
- bind(self._input, "focus", self.open);
- bind(self._input, "mousedown", onClick(self.open));
- }
- if (self.daysContainer !== undefined) {
- bind(self.monthNav, "mousedown", onClick(onMonthNavClick));
- bind(self.monthNav, ["keyup", "increment"], onYearInput);
- bind(self.daysContainer, "mousedown", onClick(selectDate));
- }
- if (self.timeContainer !== undefined && self.minuteElement !== undefined && self.hourElement !== undefined) {
- var selText = function (e) {
- return e.target.select();
- };
- bind(self.timeContainer, ["increment"], updateTime);
- bind(self.timeContainer, "blur", updateTime, {
- capture: true
- });
- bind(self.timeContainer, "mousedown", onClick(timeIncrement));
- bind([self.hourElement, self.minuteElement], ["focus", "click"], selText);
- if (self.secondElement !== undefined) bind(self.secondElement, "focus", function () {
- return self.secondElement && self.secondElement.select();
- });
- if (self.amPM !== undefined) {
- bind(self.amPM, "mousedown", onClick(function (e) {
- updateTime(e);
- triggerChange();
- }));
- }
- }
- }
- /**
- * Set the calendar view to a particular date.
- * @param {Date} jumpDate the date to set the view to
- * @param {boolean} triggerChange if change events should be triggered
- */
- function jumpToDate(jumpDate, triggerChange) {
- var jumpTo = jumpDate !== undefined ? self.parseDate(jumpDate) : self.latestSelectedDateObj || (self.config.minDate && self.config.minDate > self.now ? self.config.minDate : self.config.maxDate && self.config.maxDate < self.now ? self.config.maxDate : self.now);
- var oldYear = self.currentYear;
- var oldMonth = self.currentMonth;
- try {
- if (jumpTo !== undefined) {
- self.currentYear = jumpTo.getFullYear();
- self.currentMonth = jumpTo.getMonth();
- }
- } catch (e) {
- /* istanbul ignore next */
- e.message = "Invalid date supplied: " + jumpTo;
- self.config.errorHandler(e);
- }
- if (triggerChange && self.currentYear !== oldYear) {
- triggerEvent("onYearChange");
- buildMonthSwitch();
- }
- if (triggerChange && (self.currentYear !== oldYear || self.currentMonth !== oldMonth)) {
- triggerEvent("onMonthChange");
- }
- self.redraw();
- }
- /**
- * The up/down arrow handler for time inputs
- * @param {Event} e the click event
- */
- function timeIncrement(e) {
- if (~e.target.className.indexOf("arrow")) incrementNumInput(e, e.target.classList.contains("arrowUp") ? 1 : -1);
- }
- /**
- * Increments/decrements the value of input associ-
- * ated with the up/down arrow by dispatching an
- * "increment" event on the input.
- *
- * @param {Event} e the click event
- * @param {Number} delta the diff (usually 1 or -1)
- * @param {Element} inputElem the input element
- */
- function incrementNumInput(e, delta, inputElem) {
- var target = e && e.target;
- var input = inputElem || target && target.parentNode && target.parentNode.firstChild;
- var event = createEvent("increment");
- event.delta = delta;
- input && input.dispatchEvent(event);
- }
- function build() {
- var fragment = window.document.createDocumentFragment();
- self.calendarContainer = createElement("div", "flatpickr-calendar");
- self.calendarContainer.tabIndex = -1;
- if (!self.config.noCalendar) {
- fragment.appendChild(buildMonthNav());
- self.innerContainer = createElement("div", "flatpickr-innerContainer");
- if (self.config.weekNumbers) {
- var _a = buildWeeks(),
- weekWrapper = _a.weekWrapper,
- weekNumbers = _a.weekNumbers;
- self.innerContainer.appendChild(weekWrapper);
- self.weekNumbers = weekNumbers;
- self.weekWrapper = weekWrapper;
- }
- self.rContainer = createElement("div", "flatpickr-rContainer");
- self.rContainer.appendChild(buildWeekdays());
- if (!self.daysContainer) {
- self.daysContainer = createElement("div", "flatpickr-days");
- self.daysContainer.tabIndex = -1;
- }
- buildDays();
- self.rContainer.appendChild(self.daysContainer);
- self.innerContainer.appendChild(self.rContainer);
- fragment.appendChild(self.innerContainer);
- }
- if (self.config.enableTime) {
- fragment.appendChild(buildTime());
- }
- toggleClass(self.calendarContainer, "rangeMode", self.config.mode === "range");
- toggleClass(self.calendarContainer, "animate", self.config.animate === true);
- toggleClass(self.calendarContainer, "multiMonth", self.config.showMonths > 1);
- self.calendarContainer.appendChild(fragment);
- var customAppend = self.config.appendTo !== undefined && self.config.appendTo.nodeType !== undefined;
- if (self.config.inline || self.config.static) {
- self.calendarContainer.classList.add(self.config.inline ? "inline" : "static");
- if (self.config.inline) {
- if (!customAppend && self.element.parentNode) self.element.parentNode.insertBefore(self.calendarContainer, self._input.nextSibling);else if (self.config.appendTo !== undefined) self.config.appendTo.appendChild(self.calendarContainer);
- }
- if (self.config.static) {
- var wrapper = createElement("div", "flatpickr-wrapper");
- if (self.element.parentNode) self.element.parentNode.insertBefore(wrapper, self.element);
- wrapper.appendChild(self.element);
- if (self.altInput) wrapper.appendChild(self.altInput);
- wrapper.appendChild(self.calendarContainer);
- }
- }
- if (!self.config.static && !self.config.inline) (self.config.appendTo !== undefined ? self.config.appendTo : window.document.body).appendChild(self.calendarContainer);
- }
- function createDay(className, date, dayNumber, i) {
- var dateIsEnabled = isEnabled(date, true),
- dayElement = createElement("span", "flatpickr-day " + className, date.getDate().toString());
- dayElement.dateObj = date;
- dayElement.$i = i;
- dayElement.setAttribute("aria-label", self.formatDate(date, self.config.ariaDateFormat));
- if (className.indexOf("hidden") === -1 && compareDates(date, self.now) === 0) {
- self.todayDateElem = dayElement;
- dayElement.classList.add("today");
- dayElement.setAttribute("aria-current", "date");
- }
- if (dateIsEnabled) {
- dayElement.tabIndex = -1;
- if (isDateSelected(date)) {
- dayElement.classList.add("selected");
- self.selectedDateElem = dayElement;
- if (self.config.mode === "range") {
- toggleClass(dayElement, "startRange", self.selectedDates[0] && compareDates(date, self.selectedDates[0], true) === 0);
- toggleClass(dayElement, "endRange", self.selectedDates[1] && compareDates(date, self.selectedDates[1], true) === 0);
- if (className === "nextMonthDay") dayElement.classList.add("inRange");
- }
- }
- } else {
- dayElement.classList.add("flatpickr-disabled");
- }
- if (self.config.mode === "range") {
- if (isDateInRange(date) && !isDateSelected(date)) dayElement.classList.add("inRange");
- }
- if (self.weekNumbers && self.config.showMonths === 1 && className !== "prevMonthDay" && dayNumber % 7 === 1) {
- self.weekNumbers.insertAdjacentHTML("beforeend", "<span class='flatpickr-day'>" + self.config.getWeek(date) + "</span>");
- }
- triggerEvent("onDayCreate", dayElement);
- return dayElement;
- }
- function focusOnDayElem(targetNode) {
- targetNode.focus();
- if (self.config.mode === "range") onMouseOver(targetNode);
- }
- function getFirstAvailableDay(delta) {
- var startMonth = delta > 0 ? 0 : self.config.showMonths - 1;
- var endMonth = delta > 0 ? self.config.showMonths : -1;
- for (var m = startMonth; m != endMonth; m += delta) {
- var month = self.daysContainer.children[m];
- var startIndex = delta > 0 ? 0 : month.children.length - 1;
- var endIndex = delta > 0 ? month.children.length : -1;
- for (var i = startIndex; i != endIndex; i += delta) {
- var c = month.children[i];
- if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj)) return c;
- }
- }
- return undefined;
- }
- function getNextAvailableDay(current, delta) {
- var givenMonth = current.className.indexOf("Month") === -1 ? current.dateObj.getMonth() : self.currentMonth;
- var endMonth = delta > 0 ? self.config.showMonths : -1;
- var loopDelta = delta > 0 ? 1 : -1;
- for (var m = givenMonth - self.currentMonth; m != endMonth; m += loopDelta) {
- var month = self.daysContainer.children[m];
- var startIndex = givenMonth - self.currentMonth === m ? current.$i + delta : delta < 0 ? month.children.length - 1 : 0;
- var numMonthDays = month.children.length;
- for (var i = startIndex; i >= 0 && i < numMonthDays && i != (delta > 0 ? numMonthDays : -1); i += loopDelta) {
- var c = month.children[i];
- if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj) && Math.abs(current.$i - i) >= Math.abs(delta)) return focusOnDayElem(c);
- }
- }
- self.changeMonth(loopDelta);
- focusOnDay(getFirstAvailableDay(loopDelta), 0);
- return undefined;
- }
- function focusOnDay(current, offset) {
- var dayFocused = isInView(document.activeElement || document.body);
- var startElem = current !== undefined ? current : dayFocused ? document.activeElement : self.selectedDateElem !== undefined && isInView(self.selectedDateElem) ? self.selectedDateElem : self.todayDateElem !== undefined && isInView(self.todayDateElem) ? self.todayDateElem : getFirstAvailableDay(offset > 0 ? 1 : -1);
- if (startElem === undefined) return self._input.focus();
- if (!dayFocused) return focusOnDayElem(startElem);
- getNextAvailableDay(startElem, offset);
- }
- function buildMonthDays(year, month) {
- var firstOfMonth = (new Date(year, month, 1).getDay() - self.l10n.firstDayOfWeek + 7) % 7;
- var prevMonthDays = self.utils.getDaysInMonth((month - 1 + 12) % 12);
- var daysInMonth = self.utils.getDaysInMonth(month),
- days = window.document.createDocumentFragment(),
- isMultiMonth = self.config.showMonths > 1,
- prevMonthDayClass = isMultiMonth ? "prevMonthDay hidden" : "prevMonthDay",
- nextMonthDayClass = isMultiMonth ? "nextMonthDay hidden" : "nextMonthDay";
- var dayNumber = prevMonthDays + 1 - firstOfMonth,
- dayIndex = 0; // prepend days from the ending of previous month
- for (; dayNumber <= prevMonthDays; dayNumber++, dayIndex++) {
- days.appendChild(createDay(prevMonthDayClass, new Date(year, month - 1, dayNumber), dayNumber, dayIndex));
- } // Start at 1 since there is no 0th day
- for (dayNumber = 1; dayNumber <= daysInMonth; dayNumber++, dayIndex++) {
- days.appendChild(createDay("", new Date(year, month, dayNumber), dayNumber, dayIndex));
- } // append days from the next month
- for (var dayNum = daysInMonth + 1; dayNum <= 42 - firstOfMonth && (self.config.showMonths === 1 || dayIndex % 7 !== 0); dayNum++, dayIndex++) {
- days.appendChild(createDay(nextMonthDayClass, new Date(year, month + 1, dayNum % daysInMonth), dayNum, dayIndex));
- } //updateNavigationCurrentMonth();
- var dayContainer = createElement("div", "dayContainer");
- dayContainer.appendChild(days);
- return dayContainer;
- }
- function buildDays() {
- if (self.daysContainer === undefined) {
- return;
- }
- clearNode(self.daysContainer); // TODO: week numbers for each month
- if (self.weekNumbers) clearNode(self.weekNumbers);
- var frag = document.createDocumentFragment();
- for (var i = 0; i < self.config.showMonths; i++) {
- var d = new Date(self.currentYear, self.currentMonth, 1);
- d.setMonth(self.currentMonth + i);
- frag.appendChild(buildMonthDays(d.getFullYear(), d.getMonth()));
- }
- self.daysContainer.appendChild(frag);
- self.days = self.daysContainer.firstChild;
- if (self.config.mode === "range" && self.selectedDates.length === 1) {
- onMouseOver();
- }
- }
- function buildMonthSwitch() {
- if (self.config.showMonths > 1 || self.config.monthSelectorType !== "dropdown") return;
- var shouldBuildMonth = function (month) {
- if (self.config.minDate !== undefined && self.currentYear === self.config.minDate.getFullYear() && month < self.config.minDate.getMonth()) {
- return false;
- }
- return !(self.config.maxDate !== undefined && self.currentYear === self.config.maxDate.getFullYear() && month > self.config.maxDate.getMonth());
- };
- self.monthsDropdownContainer.tabIndex = -1;
- self.monthsDropdownContainer.innerHTML = "";
- for (var i = 0; i < 12; i++) {
- if (!shouldBuildMonth(i)) continue;
- var month = createElement("option", "flatpickr-monthDropdown-month");
- month.value = new Date(self.currentYear, i).getMonth().toString();
- month.textContent = monthToStr(i, self.config.shorthandCurrentMonth, self.l10n);
- month.tabIndex = -1;
- if (self.currentMonth === i) {
- month.selected = true;
- }
- self.monthsDropdownContainer.appendChild(month);
- }
- }
- function buildMonth() {
- var container = createElement("div", "flatpickr-month");
- var monthNavFragment = window.document.createDocumentFragment();
- var monthElement;
- if (self.config.showMonths > 1 || self.config.monthSelectorType === "static") {
- monthElement = createElement("span", "cur-month");
- } else {
- self.monthsDropdownContainer = createElement("select", "flatpickr-monthDropdown-months");
- bind(self.monthsDropdownContainer, "change", function (e) {
- var target = e.target;
- var selectedMonth = parseInt(target.value, 10);
- self.changeMonth(selectedMonth - self.currentMonth);
- triggerEvent("onMonthChange");
- });
- buildMonthSwitch();
- monthElement = self.monthsDropdownContainer;
- }
- var yearInput = createNumberInput("cur-year", {
- tabindex: "-1"
- });
- var yearElement = yearInput.getElementsByTagName("input")[0];
- yearElement.setAttribute("aria-label", self.l10n.yearAriaLabel);
- if (self.config.minDate) {
- yearElement.setAttribute("min", self.config.minDate.getFullYear().toString());
- }
- if (self.config.maxDate) {
- yearElement.setAttribute("max", self.config.maxDate.getFullYear().toString());
- yearElement.disabled = !!self.config.minDate && self.config.minDate.getFullYear() === self.config.maxDate.getFullYear();
- }
- var currentMonth = createElement("div", "flatpickr-current-month");
- currentMonth.appendChild(monthElement);
- currentMonth.appendChild(yearInput);
- monthNavFragment.appendChild(currentMonth);
- container.appendChild(monthNavFragment);
- return {
- container: container,
- yearElement: yearElement,
- monthElement: monthElement
- };
- }
- function buildMonths() {
- clearNode(self.monthNav);
- self.monthNav.appendChild(self.prevMonthNav);
- if (self.config.showMonths) {
- self.yearElements = [];
- self.monthElements = [];
- }
- for (var m = self.config.showMonths; m--;) {
- var month = buildMonth();
- self.yearElements.push(month.yearElement);
- self.monthElements.push(month.monthElement);
- self.monthNav.appendChild(month.container);
- }
- self.monthNav.appendChild(self.nextMonthNav);
- }
- function buildMonthNav() {
- self.monthNav = createElement("div", "flatpickr-months");
- self.yearElements = [];
- self.monthElements = [];
- self.prevMonthNav = createElement("span", "flatpickr-prev-month");
- self.prevMonthNav.innerHTML = self.config.prevArrow;
- self.nextMonthNav = createElement("span", "flatpickr-next-month");
- self.nextMonthNav.innerHTML = self.config.nextArrow;
- buildMonths();
- Object.defineProperty(self, "_hidePrevMonthArrow", {
- get: function () {
- return self.__hidePrevMonthArrow;
- },
- set: function (bool) {
- if (self.__hidePrevMonthArrow !== bool) {
- toggleClass(self.prevMonthNav, "flatpickr-disabled", bool);
- self.__hidePrevMonthArrow = bool;
- }
- }
- });
- Object.defineProperty(self, "_hideNextMonthArrow", {
- get: function () {
- return self.__hideNextMonthArrow;
- },
- set: function (bool) {
- if (self.__hideNextMonthArrow !== bool) {
- toggleClass(self.nextMonthNav, "flatpickr-disabled", bool);
- self.__hideNextMonthArrow = bool;
- }
- }
- });
- self.currentYearElement = self.yearElements[0];
- updateNavigationCurrentMonth();
- return self.monthNav;
- }
- function buildTime() {
- self.calendarContainer.classList.add("hasTime");
- if (self.config.noCalendar) self.calendarContainer.classList.add("noCalendar");
- self.timeContainer = createElement("div", "flatpickr-time");
- self.timeContainer.tabIndex = -1;
- var separator = createElement("span", "flatpickr-time-separator", ":");
- var hourInput = createNumberInput("flatpickr-hour", {
- "aria-label": self.l10n.hourAriaLabel
- });
- self.hourElement = hourInput.getElementsByTagName("input")[0];
- var minuteInput = createNumberInput("flatpickr-minute", {
- "aria-label": self.l10n.minuteAriaLabel
- });
- self.minuteElement = minuteInput.getElementsByTagName("input")[0];
- self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
- self.hourElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getHours() : self.config.time_24hr ? self.config.defaultHour : military2ampm(self.config.defaultHour));
- self.minuteElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getMinutes() : self.config.defaultMinute);
- self.hourElement.setAttribute("step", self.config.hourIncrement.toString());
- self.minuteElement.setAttribute("step", self.config.minuteIncrement.toString());
- self.hourElement.setAttribute("min", self.config.time_24hr ? "0" : "1");
- self.hourElement.setAttribute("max", self.config.time_24hr ? "23" : "12");
- self.minuteElement.setAttribute("min", "0");
- self.minuteElement.setAttribute("max", "59");
- self.timeContainer.appendChild(hourInput);
- self.timeContainer.appendChild(separator);
- self.timeContainer.appendChild(minuteInput);
- if (self.config.time_24hr) self.timeContainer.classList.add("time24hr");
- if (self.config.enableSeconds) {
- self.timeContainer.classList.add("hasSeconds");
- var secondInput = createNumberInput("flatpickr-second");
- self.secondElement = secondInput.getElementsByTagName("input")[0];
- self.secondElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getSeconds() : self.config.defaultSeconds);
- self.secondElement.setAttribute("step", self.minuteElement.getAttribute("step"));
- self.secondElement.setAttribute("min", "0");
- self.secondElement.setAttribute("max", "59");
- self.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
- self.timeContainer.appendChild(secondInput);
- }
- if (!self.config.time_24hr) {
- // add self.amPM if appropriate
- self.amPM = createElement("span", "flatpickr-am-pm", self.l10n.amPM[int((self.latestSelectedDateObj ? self.hourElement.value : self.config.defaultHour) > 11)]);
- self.amPM.title = self.l10n.toggleTitle;
- self.amPM.tabIndex = -1;
- self.timeContainer.appendChild(self.amPM);
- }
- return self.timeContainer;
- }
- function buildWeekdays() {
- if (!self.weekdayContainer) self.weekdayContainer = createElement("div", "flatpickr-weekdays");else clearNode(self.weekdayContainer);
- for (var i = self.config.showMonths; i--;) {
- var container = createElement("div", "flatpickr-weekdaycontainer");
- self.weekdayContainer.appendChild(container);
- }
- updateWeekdays();
- return self.weekdayContainer;
- }
- function updateWeekdays() {
- if (!self.weekdayContainer) {
- return;
- }
- var firstDayOfWeek = self.l10n.firstDayOfWeek;
- var weekdays = self.l10n.weekdays.shorthand.slice();
- if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
- weekdays = weekdays.splice(firstDayOfWeek, weekdays.length).concat(weekdays.splice(0, firstDayOfWeek));
- }
- for (var i = self.config.showMonths; i--;) {
- self.weekdayContainer.children[i].innerHTML = "\n <span class='flatpickr-weekday'>\n " + weekdays.join("</span><span class='flatpickr-weekday'>") + "\n </span>\n ";
- }
- }
- /* istanbul ignore next */
- function buildWeeks() {
- self.calendarContainer.classList.add("hasWeeks");
- var weekWrapper = createElement("div", "flatpickr-weekwrapper");
- weekWrapper.appendChild(createElement("span", "flatpickr-weekday", self.l10n.weekAbbreviation));
- var weekNumbers = createElement("div", "flatpickr-weeks");
- weekWrapper.appendChild(weekNumbers);
- return {
- weekWrapper: weekWrapper,
- weekNumbers: weekNumbers
- };
- }
- function changeMonth(value, isOffset) {
- if (isOffset === void 0) {
- isOffset = true;
- }
- var delta = isOffset ? value : value - self.currentMonth;
- if (delta < 0 && self._hidePrevMonthArrow === true || delta > 0 && self._hideNextMonthArrow === true) return;
- self.currentMonth += delta;
- if (self.currentMonth < 0 || self.currentMonth > 11) {
- self.currentYear += self.currentMonth > 11 ? 1 : -1;
- self.currentMonth = (self.currentMonth + 12) % 12;
- triggerEvent("onYearChange");
- buildMonthSwitch();
- }
- buildDays();
- triggerEvent("onMonthChange");
- updateNavigationCurrentMonth();
- }
- function clear(triggerChangeEvent, toInitial) {
- if (triggerChangeEvent === void 0) {
- triggerChangeEvent = true;
- }
- if (toInitial === void 0) {
- toInitial = true;
- }
- self.input.value = "";
- if (self.altInput !== undefined) self.altInput.value = "";
- if (self.mobileInput !== undefined) self.mobileInput.value = "";
- self.selectedDates = [];
- self.latestSelectedDateObj = undefined;
- if (toInitial === true) {
- self.currentYear = self._initialDate.getFullYear();
- self.currentMonth = self._initialDate.getMonth();
- }
- self.showTimeInput = false;
- if (self.config.enableTime === true) {
- setDefaultHours();
- }
- self.redraw();
- if (triggerChangeEvent) // triggerChangeEvent is true (default) or an Event
- triggerEvent("onChange");
- }
- function close() {
- self.isOpen = false;
- if (!self.isMobile) {
- if (self.calendarContainer !== undefined) {
- self.calendarContainer.classList.remove("open");
- }
- if (self._input !== undefined) {
- self._input.classList.remove("active");
- }
- }
- triggerEvent("onClose");
- }
- function destroy() {
- if (self.config !== undefined) triggerEvent("onDestroy");
- for (var i = self._handlers.length; i--;) {
- var h = self._handlers[i];
- h.element.removeEventListener(h.event, h.handler, h.options);
- }
- self._handlers = [];
- if (self.mobileInput) {
- if (self.mobileInput.parentNode) self.mobileInput.parentNode.removeChild(self.mobileInput);
- self.mobileInput = undefined;
- } else if (self.calendarContainer && self.calendarContainer.parentNode) {
- if (self.config.static && self.calendarContainer.parentNode) {
- var wrapper = self.calendarContainer.parentNode;
- wrapper.lastChild && wrapper.removeChild(wrapper.lastChild);
- if (wrapper.parentNode) {
- while (wrapper.firstChild) wrapper.parentNode.insertBefore(wrapper.firstChild, wrapper);
- wrapper.parentNode.removeChild(wrapper);
- }
- } else self.calendarContainer.parentNode.removeChild(self.calendarContainer);
- }
- if (self.altInput) {
- self.input.type = "text";
- if (self.altInput.parentNode) self.altInput.parentNode.removeChild(self.altInput);
- delete self.altInput;
- }
- if (self.input) {
- self.input.type = self.input._type;
- self.input.classList.remove("flatpickr-input");
- self.input.removeAttribute("readonly");
- self.input.value = "";
- }
- ["_showTimeInput", "latestSelectedDateObj", "_hideNextMonthArrow", "_hidePrevMonthArrow", "__hideNextMonthArrow", "__hidePrevMonthArrow", "isMobile", "isOpen", "selectedDateElem", "minDateHasTime", "maxDateHasTime", "days", "daysContainer", "_input", "_positionElement", "innerContainer", "rContainer", "monthNav", "todayDateElem", "calendarContainer", "weekdayContainer", "prevMonthNav", "nextMonthNav", "monthsDropdownContainer", "currentMonthElement", "currentYearElement", "navigationCurrentMonth", "selectedDateElem", "config"].forEach(function (k) {
- try {
- delete self[k];
- } catch (_) {}
- });
- }
- function isCalendarElem(elem) {
- if (self.config.appendTo && self.config.appendTo.contains(elem)) return true;
- return self.calendarContainer.contains(elem);
- }
- function documentClick(e) {
- if (self.isOpen && !self.config.inline) {
- var eventTarget_1 = getEventTarget(e);
- var isCalendarElement = isCalendarElem(eventTarget_1);
- var isInput = eventTarget_1 === self.input || eventTarget_1 === self.altInput || self.element.contains(eventTarget_1) || // web components
- // e.path is not present in all browsers. circumventing typechecks
- e.path && e.path.indexOf && (~e.path.indexOf(self.input) || ~e.path.indexOf(self.altInput));
- var lostFocus = e.type === "blur" ? isInput && e.relatedTarget && !isCalendarElem(e.relatedTarget) : !isInput && !isCalendarElement && !isCalendarElem(e.relatedTarget);
- var isIgnored = !self.config.ignoredFocusElements.some(function (elem) {
- return elem.contains(eventTarget_1);
- });
- if (lostFocus && isIgnored) {
- if (self.timeContainer !== undefined && self.minuteElement !== undefined && self.hourElement !== undefined) {
- updateTime();
- }
- self.close();
- if (self.config.mode === "range" && self.selectedDates.length === 1) {
- self.clear(false);
- self.redraw();
- }
- }
- }
- }
- function changeYear(newYear) {
- if (!newYear || self.config.minDate && newYear < self.config.minDate.getFullYear() || self.config.maxDate && newYear > self.config.maxDate.getFullYear()) return;
- var newYearNum = newYear,
- isNewYear = self.currentYear !== newYearNum;
- self.currentYear = newYearNum || self.currentYear;
- if (self.config.maxDate && self.currentYear === self.config.maxDate.getFullYear()) {
- self.currentMonth = Math.min(self.config.maxDate.getMonth(), self.currentMonth);
- } else if (self.config.minDate && self.currentYear === self.config.minDate.getFullYear()) {
- self.currentMonth = Math.max(self.config.minDate.getMonth(), self.currentMonth);
- }
- if (isNewYear) {
- self.redraw();
- triggerEvent("onYearChange");
- buildMonthSwitch();
- }
- }
- function isEnabled(date, timeless) {
- if (timeless === void 0) {
- timeless = true;
- }
- var dateToCheck = self.parseDate(date, undefined, timeless); // timeless
- if (self.config.minDate && dateToCheck && compareDates(dateToCheck, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0 || self.config.maxDate && dateToCheck && compareDates(dateToCheck, self.config.maxDate, timeless !== undefined ? timeless : !self.maxDateHasTime) > 0) return false;
- if (self.config.enable.length === 0 && self.config.disable.length === 0) return true;
- if (dateToCheck === undefined) return false;
- var bool = self.config.enable.length > 0,
- array = bool ? self.config.enable : self.config.disable;
- for (var i = 0, d = void 0; i < array.length; i++) {
- d = array[i];
- if (typeof d === "function" && d(dateToCheck) // disabled by function
- ) return bool;else if (d instanceof Date && dateToCheck !== undefined && d.getTime() === dateToCheck.getTime()) // disabled by date
- return bool;else if (typeof d === "string" && dateToCheck !== undefined) {
- // disabled by date string
- var parsed = self.parseDate(d, undefined, true);
- return parsed && parsed.getTime() === dateToCheck.getTime() ? bool : !bool;
- } else if ( // disabled by range
- typeof d === "object" && dateToCheck !== undefined && d.from && d.to && dateToCheck.getTime() >= d.from.getTime() && dateToCheck.getTime() <= d.to.getTime()) return bool;
- }
- return !bool;
- }
- function isInView(elem) {
- if (self.daysContainer !== undefined) return elem.className.indexOf("hidden") === -1 && self.daysContainer.contains(elem);
- return false;
- }
- function onKeyDown(e) {
- // e.key e.keyCode
- // "Backspace" 8
- // "Tab" 9
- // "Enter" 13
- // "Escape" (IE "Esc") 27
- // "ArrowLeft" (IE "Left") 37
- // "ArrowUp" (IE "Up") 38
- // "ArrowRight" (IE "Right") 39
- // "ArrowDown" (IE "Down") 40
- // "Delete" (IE "Del") 46
- var isInput = e.target === self._input;
- var allowInput = self.config.allowInput;
- var allowKeydown = self.isOpen && (!allowInput || !isInput);
- var allowInlineKeydown = self.config.inline && isInput && !allowInput;
- if (e.keyCode === 13 && isInput) {
- if (allowInput) {
- self.setDate(self._input.value, true, e.target === self.altInput ? self.config.altFormat : self.config.dateFormat);
- return e.target.blur();
- } else {
- self.open();
- }
- } else if (isCalendarElem(e.target) || allowKeydown || allowInlineKeydown) {
- var isTimeObj = !!self.timeContainer && self.timeContainer.contains(e.target);
- switch (e.keyCode) {
- case 13:
- if (isTimeObj) {
- e.preventDefault();
- updateTime();
- focusAndClose();
- } else selectDate(e);
- break;
- case 27:
- // escape
- e.preventDefault();
- focusAndClose();
- break;
- case 8:
- case 46:
- if (isInput && !self.config.allowInput) {
- e.preventDefault();
- self.clear();
- }
- break;
- case 37:
- case 39:
- if (!isTimeObj && !isInput) {
- e.preventDefault();
- if (self.daysContainer !== undefined && (allowInput === false || document.activeElement && isInView(document.activeElement))) {
- var delta_1 = e.keyCode === 39 ? 1 : -1;
- if (!e.ctrlKey) focusOnDay(undefined, delta_1);else {
- e.stopPropagation();
- changeMonth(delta_1);
- focusOnDay(getFirstAvailableDay(1), 0);
- }
- }
- } else if (self.hourElement) self.hourElement.focus();
- break;
- case 38:
- case 40:
- e.preventDefault();
- var delta = e.keyCode === 40 ? 1 : -1;
- if (self.daysContainer && e.target.$i !== undefined || e.target === self.input || e.target === self.altInput) {
- if (e.ctrlKey) {
- e.stopPropagation();
- changeYear(self.currentYear - delta);
- focusOnDay(getFirstAvailableDay(1), 0);
- } else if (!isTimeObj) focusOnDay(undefined, delta * 7);
- } else if (e.target === self.currentYearElement) {
- changeYear(self.currentYear - delta);
- } else if (self.config.enableTime) {
- if (!isTimeObj && self.hourElement) self.hourElement.focus();
- updateTime(e);
- self._debouncedChange();
- }
- break;
- case 9:
- if (isTimeObj) {
- var elems = [self.hourElement, self.minuteElement, self.secondElement, self.amPM].concat(self.pluginElements).filter(function (x) {
- return x;
- });
- var i = elems.indexOf(e.target);
- if (i !== -1) {
- var target = elems[i + (e.shiftKey ? -1 : 1)];
- e.preventDefault();
- (target || self._input).focus();
- }
- } else if (!self.config.noCalendar && self.daysContainer && self.daysContainer.contains(e.target) && e.shiftKey) {
- e.preventDefault();
- self._input.focus();
- }
- break;
- default:
- break;
- }
- }
- if (self.amPM !== undefined && e.target === self.amPM) {
- switch (e.key) {
- case self.l10n.amPM[0].charAt(0):
- case self.l10n.amPM[0].charAt(0).toLowerCase():
- self.amPM.textContent = self.l10n.amPM[0];
- setHoursFromInputs();
- updateValue();
- break;
- case self.l10n.amPM[1].charAt(0):
- case self.l10n.amPM[1].charAt(0).toLowerCase():
- self.amPM.textContent = self.l10n.amPM[1];
- setHoursFromInputs();
- updateValue();
- break;
- }
- }
- if (isInput || isCalendarElem(e.target)) {
- triggerEvent("onKeyDown", e);
- }
- }
- function onMouseOver(elem) {
- if (self.selectedDates.length !== 1 || elem && (!elem.classList.contains("flatpickr-day") || elem.classList.contains("flatpickr-disabled"))) return;
- var hoverDate = elem ? elem.dateObj.getTime() : self.days.firstElementChild.dateObj.getTime(),
- initialDate = self.parseDate(self.selectedDates[0], undefined, true).getTime(),
- rangeStartDate = Math.min(hoverDate, self.selectedDates[0].getTime()),
- rangeEndDate = Math.max(hoverDate, self.selectedDates[0].getTime());
- var containsDisabled = false;
- var minRange = 0,
- maxRange = 0;
- for (var t = rangeStartDate; t < rangeEndDate; t += duration.DAY) {
- if (!isEnabled(new Date(t), true)) {
- containsDisabled = containsDisabled || t > rangeStartDate && t < rangeEndDate;
- if (t < initialDate && (!minRange || t > minRange)) minRange = t;else if (t > initialDate && (!maxRange || t < maxRange)) maxRange = t;
- }
- }
- for (var m = 0; m < self.config.showMonths; m++) {
- var month = self.daysContainer.children[m];
- var _loop_1 = function (i, l) {
- var dayElem = month.children[i],
- date = dayElem.dateObj;
- var timestamp = date.getTime();
- var outOfRange = minRange > 0 && timestamp < minRange || maxRange > 0 && timestamp > maxRange;
- if (outOfRange) {
- dayElem.classList.add("notAllowed");
- ["inRange", "startRange", "endRange"].forEach(function (c) {
- dayElem.classList.remove(c);
- });
- return "continue";
- } else if (containsDisabled && !outOfRange) return "continue";
- ["startRange", "inRange", "endRange", "notAllowed"].forEach(function (c) {
- dayElem.classList.remove(c);
- });
- if (elem !== undefined) {
- elem.classList.add(hoverDate <= self.selectedDates[0].getTime() ? "startRange" : "endRange");
- if (initialDate < hoverDate && timestamp === initialDate) dayElem.classList.add("startRange");else if (initialDate > hoverDate && timestamp === initialDate) dayElem.classList.add("endRange");
- if (timestamp >= minRange && (maxRange === 0 || timestamp <= maxRange) && isBetween(timestamp, initialDate, hoverDate)) dayElem.classList.add("inRange");
- }
- };
- for (var i = 0, l = month.children.length; i < l; i++) {
- _loop_1(i, l);
- }
- }
- }
- function onResize() {
- if (self.isOpen && !self.config.static && !self.config.inline) positionCalendar();
- }
- function setDefaultTime() {
- self.setDate(self.config.minDate !== undefined ? new Date(self.config.minDate.getTime()) : new Date(), true);
- setDefaultHours();
- updateValue();
- }
- function open(e, positionElement) {
- if (positionElement === void 0) {
- positionElement = self._positionElement;
- }
- if (self.isMobile === true) {
- if (e) {
- e.preventDefault();
- e.target && e.target.blur();
- }
- if (self.mobileInput !== undefined) {
- self.mobileInput.focus();
- self.mobileInput.click();
- }
- triggerEvent("onOpen");
- return;
- }
- if (self._input.disabled || self.config.inline) return;
- var wasOpen = self.isOpen;
- self.isOpen = true;
- if (!wasOpen) {
- self.calendarContainer.classList.add("open");
- self._input.classList.add("active");
- triggerEvent("onOpen");
- positionCalendar(positionElement);
- }
- if (self.config.enableTime === true && self.config.noCalendar === true) {
- if (self.selectedDates.length === 0) {
- setDefaultTime();
- }
- if (self.config.allowInput === false && (e === undefined || !self.timeContainer.contains(e.relatedTarget))) {
- setTimeout(function () {
- return self.hourElement.select();
- }, 50);
- }
- }
- }
- function minMaxDateSetter(type) {
- return function (date) {
- var dateObj = self.config["_" + type + "Date"] = self.parseDate(date, self.config.dateFormat);
- var inverseDateObj = self.config["_" + (type === "min" ? "max" : "min") + "Date"];
- if (dateObj !== undefined) {
- self[type === "min" ? "minDateHasTime" : "maxDateHasTime"] = dateObj.getHours() > 0 || dateObj.getMinutes() > 0 || dateObj.getSeconds() > 0;
- }
- if (self.selectedDates) {
- self.selectedDates = self.selectedDates.filter(function (d) {
- return isEnabled(d);
- });
- if (!self.selectedDates.length && type === "min") setHoursFromDate(dateObj);
- updateValue();
- }
- if (self.daysContainer) {
- redraw();
- if (dateObj !== undefined) self.currentYearElement[type] = dateObj.getFullYear().toString();else self.currentYearElement.removeAttribute(type);
- self.currentYearElement.disabled = !!inverseDateObj && dateObj !== undefined && inverseDateObj.getFullYear() === dateObj.getFullYear();
- }
- };
- }
- function parseConfig() {
- var boolOpts = ["wrap", "weekNumbers", "allowInput", "clickOpens", "time_24hr", "enableTime", "noCalendar", "altInput", "shorthandCurrentMonth", "inline", "static", "enableSeconds", "disableMobile"];
- var userConfig = __assign({}, instanceConfig, JSON.parse(JSON.stringify(element.dataset || {})));
- var formats = {};
- self.config.parseDate = userConfig.parseDate;
- self.config.formatDate = userConfig.formatDate;
- Object.defineProperty(self.config, "enable", {
- get: function () {
- return self.config._enable;
- },
- set: function (dates) {
- self.config._enable = parseDateRules(dates);
- }
- });
- Object.defineProperty(self.config, "disable", {
- get: function () {
- return self.config._disable;
- },
- set: function (dates) {
- self.config._disable = parseDateRules(dates);
- }
- });
- var timeMode = userConfig.mode === "time";
- if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
- var defaultDateFormat = flatpickr.defaultConfig.dateFormat || defaults.dateFormat;
- formats.dateFormat = userConfig.noCalendar || timeMode ? "H:i" + (userConfig.enableSeconds ? ":S" : "") : defaultDateFormat + " H:i" + (userConfig.enableSeconds ? ":S" : "");
- }
- if (userConfig.altInput && (userConfig.enableTime || timeMode) && !userConfig.altFormat) {
- var defaultAltFormat = flatpickr.defaultConfig.altFormat || defaults.altFormat;
- formats.altFormat = userConfig.noCalendar || timeMode ? "h:i" + (userConfig.enableSeconds ? ":S K" : " K") : defaultAltFormat + (" h:i" + (userConfig.enableSeconds ? ":S" : "") + " K");
- }
- if (!userConfig.altInputClass) {
- self.config.altInputClass = self.input.className + " " + self.config.altInputClass;
- }
- Object.defineProperty(self.config, "minDate", {
- get: function () {
- return self.config._minDate;
- },
- set: minMaxDateSetter("min")
- });
- Object.defineProperty(self.config, "maxDate", {
- get: function () {
- return self.config._maxDate;
- },
- set: minMaxDateSetter("max")
- });
- var minMaxTimeSetter = function (type) {
- return function (val) {
- self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i:S");
- };
- };
- Object.defineProperty(self.config, "minTime", {
- get: function () {
- return self.config._minTime;
- },
- set: minMaxTimeSetter("min")
- });
- Object.defineProperty(self.config, "maxTime", {
- get: function () {
- return self.config._maxTime;
- },
- set: minMaxTimeSetter("max")
- });
- if (userConfig.mode === "time") {
- self.config.noCalendar = true;
- self.config.enableTime = true;
- }
- Object.assign(self.config, formats, userConfig);
- for (var i = 0; i < boolOpts.length; i++) self.config[boolOpts[i]] = self.config[boolOpts[i]] === true || self.config[boolOpts[i]] === "true";
- HOOKS.filter(function (hook) {
- return self.config[hook] !== undefined;
- }).forEach(function (hook) {
- self.config[hook] = arrayify(self.config[hook] || []).map(bindToInstance);
- });
- self.isMobile = !self.config.disableMobile && !self.config.inline && self.config.mode === "single" && !self.config.disable.length && !self.config.enable.length && !self.config.weekNumbers && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
- for (var i = 0; i < self.config.plugins.length; i++) {
- var pluginConf = self.config.plugins[i](self) || {};
- for (var key in pluginConf) {
- if (HOOKS.indexOf(key) > -1) {
- self.config[key] = arrayify(pluginConf[key]).map(bindToInstance).concat(self.config[key]);
- } else if (typeof userConfig[key] === "undefined") self.config[key] = pluginConf[key];
- }
- }
- triggerEvent("onParseConfig");
- }
- function setupLocale() {
- if (typeof self.config.locale !== "object" && typeof flatpickr.l10ns[self.config.locale] === "undefined") self.config.errorHandler(new Error("flatpickr: invalid locale " + self.config.locale));
- self.l10n = __assign({}, flatpickr.l10ns["default"], typeof self.config.locale === "object" ? self.config.locale : self.config.locale !== "default" ? flatpickr.l10ns[self.config.locale] : undefined);
- tokenRegex.K = "(" + self.l10n.amPM[0] + "|" + self.l10n.amPM[1] + "|" + self.l10n.amPM[0].toLowerCase() + "|" + self.l10n.amPM[1].toLowerCase() + ")";
- var userConfig = __assign({}, instanceConfig, JSON.parse(JSON.stringify(element.dataset || {})));
- if (userConfig.time_24hr === undefined && flatpickr.defaultConfig.time_24hr === undefined) {
- self.config.time_24hr = self.l10n.time_24hr;
- }
- self.formatDate = createDateFormatter(self);
- self.parseDate = createDateParser({
- config: self.config,
- l10n: self.l10n
- });
- }
- function positionCalendar(customPositionElement) {
- if (self.calendarContainer === undefined) return;
- triggerEvent("onPreCalendarPosition");
- var positionElement = customPositionElement || self._positionElement;
- var calendarHeight = Array.prototype.reduce.call(self.calendarContainer.children, function (acc, child) {
- return acc + child.offsetHeight;
- }, 0),
- calendarWidth = self.calendarContainer.offsetWidth,
- configPos = self.config.position.split(" "),
- configPosVertical = configPos[0],
- configPosHorizontal = configPos.length > 1 ? configPos[1] : null,
- inputBounds = positionElement.getBoundingClientRect(),
- distanceFromBottom = window.innerHeight - inputBounds.bottom,
- showOnTop = configPosVertical === "above" || configPosVertical !== "below" && distanceFromBottom < calendarHeight && inputBounds.top > calendarHeight;
- var top = window.pageYOffset + inputBounds.top + (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
- toggleClass(self.calendarContainer, "arrowTop", !showOnTop);
- toggleClass(self.calendarContainer, "arrowBottom", showOnTop);
- if (self.config.inline) return;
- var left = window.pageXOffset + inputBounds.left - (configPosHorizontal != null && configPosHorizontal === "center" ? (calendarWidth - inputBounds.width) / 2 : 0);
- var right = window.document.body.offsetWidth - (window.pageXOffset + inputBounds.right);
- var rightMost = left + calendarWidth > window.document.body.offsetWidth;
- var centerMost = right + calendarWidth > window.document.body.offsetWidth;
- toggleClass(self.calendarContainer, "rightMost", rightMost);
- if (self.config.static) return;
- self.calendarContainer.style.top = top + "px";
- if (!rightMost) {
- self.calendarContainer.style.left = left + "px";
- self.calendarContainer.style.right = "auto";
- } else if (!centerMost) {
- self.calendarContainer.style.left = "auto";
- self.calendarContainer.style.right = right + "px";
- } else {
- var doc = document.styleSheets[0]; // some testing environments don't have css support
- if (doc === undefined) return;
- var bodyWidth = window.document.body.offsetWidth;
- var centerLeft = Math.max(0, bodyWidth / 2 - calendarWidth / 2);
- var centerBefore = ".flatpickr-calendar.centerMost:before";
- var centerAfter = ".flatpickr-calendar.centerMost:after";
- var centerIndex = doc.cssRules.length;
- var centerStyle = "{left:" + inputBounds.left + "px;right:auto;}";
- toggleClass(self.calendarContainer, "rightMost", false);
- toggleClass(self.calendarContainer, "centerMost", true);
- doc.insertRule(centerBefore + "," + centerAfter + centerStyle, centerIndex);
- self.calendarContainer.style.left = centerLeft + "px";
- self.calendarContainer.style.right = "auto";
- }
- }
- function redraw() {
- if (self.config.noCalendar || self.isMobile) return;
- updateNavigationCurrentMonth();
- buildDays();
- }
- function focusAndClose() {
- self._input.focus();
- if (window.navigator.userAgent.indexOf("MSIE") !== -1 || navigator.msMaxTouchPoints !== undefined) {
- // hack - bugs in the way IE handles focus keeps the calendar open
- setTimeout(self.close, 0);
- } else {
- self.close();
- }
- }
- function selectDate(e) {
- e.preventDefault();
- e.stopPropagation();
- var isSelectable = function (day) {
- return day.classList && day.classList.contains("flatpickr-day") && !day.classList.contains("flatpickr-disabled") && !day.classList.contains("notAllowed");
- };
- var t = findParent(e.target, isSelectable);
- if (t === undefined) return;
- var target = t;
- var selectedDate = self.latestSelectedDateObj = new Date(target.dateObj.getTime());
- var shouldChangeMonth = (selectedDate.getMonth() < self.currentMonth || selectedDate.getMonth() > self.currentMonth + self.config.showMonths - 1) && self.config.mode !== "range";
- self.selectedDateElem = target;
- if (self.config.mode === "single") self.selectedDates = [selectedDate];else if (self.config.mode === "multiple") {
- var selectedIndex = isDateSelected(selectedDate);
- if (selectedIndex) self.selectedDates.splice(parseInt(selectedIndex), 1);else self.selectedDates.push(selectedDate);
- } else if (self.config.mode === "range") {
- if (self.selectedDates.length === 2) {
- self.clear(false, false);
- }
- self.latestSelectedDateObj = selectedDate;
- self.selectedDates.push(selectedDate); // unless selecting same date twice, sort ascendingly
- if (compareDates(selectedDate, self.selectedDates[0], true) !== 0) self.selectedDates.sort(function (a, b) {
- return a.getTime() - b.getTime();
- });
- }
- setHoursFromInputs();
- if (shouldChangeMonth) {
- var isNewYear = self.currentYear !== selectedDate.getFullYear();
- self.currentYear = selectedDate.getFullYear();
- self.currentMonth = selectedDate.getMonth();
- if (isNewYear) {
- triggerEvent("onYearChange");
- buildMonthSwitch();
- }
- triggerEvent("onMonthChange");
- }
- updateNavigationCurrentMonth();
- buildDays();
- updateValue();
- if (self.config.enableTime) setTimeout(function () {
- return self.showTimeInput = true;
- }, 50); // maintain focus
- if (!shouldChangeMonth && self.config.mode !== "range" && self.config.showMonths === 1) focusOnDayElem(target);else if (self.selectedDateElem !== undefined && self.hourElement === undefined) {
- self.selectedDateElem && self.selectedDateElem.focus();
- }
- if (self.hourElement !== undefined) self.hourElement !== undefined && self.hourElement.focus();
- if (self.config.closeOnSelect) {
- var single = self.config.mode === "single" && !self.config.enableTime;
- var range = self.config.mode === "range" && self.selectedDates.length === 2 && !self.config.enableTime;
- if (single || range) {
- focusAndClose();
- }
- }
- triggerChange();
- }
- var CALLBACKS = {
- locale: [setupLocale, updateWeekdays],
- showMonths: [buildMonths, setCalendarWidth, buildWeekdays],
- minDate: [jumpToDate],
- maxDate: [jumpToDate]
- };
- function set(option, value) {
- if (option !== null && typeof option === "object") {
- Object.assign(self.config, option);
- for (var key in option) {
- if (CALLBACKS[key] !== undefined) CALLBACKS[key].forEach(function (x) {
- return x();
- });
- }
- } else {
- self.config[option] = value;
- if (CALLBACKS[option] !== undefined) CALLBACKS[option].forEach(function (x) {
- return x();
- });else if (HOOKS.indexOf(option) > -1) self.config[option] = arrayify(value);
- }
- self.redraw();
- updateValue(false);
- }
- function setSelectedDate(inputDate, format) {
- var dates = [];
- if (inputDate instanceof Array) dates = inputDate.map(function (d) {
- return self.parseDate(d, format);
- });else if (inputDate instanceof Date || typeof inputDate === "number") dates = [self.parseDate(inputDate, format)];else if (typeof inputDate === "string") {
- switch (self.config.mode) {
- case "single":
- case "time":
- dates = [self.parseDate(inputDate, format)];
- break;
- case "multiple":
- dates = inputDate.split(self.config.conjunction).map(function (date) {
- return self.parseDate(date, format);
- });
- break;
- case "range":
- dates = inputDate.split(self.l10n.rangeSeparator).map(function (date) {
- return self.parseDate(date, format);
- });
- break;
- default:
- break;
- }
- } else self.config.errorHandler(new Error("Invalid date supplied: " + JSON.stringify(inputDate)));
- self.selectedDates = dates.filter(function (d) {
- return d instanceof Date && isEnabled(d, false);
- });
- if (self.config.mode === "range") self.selectedDates.sort(function (a, b) {
- return a.getTime() - b.getTime();
- });
- }
- function setDate(date, triggerChange, format) {
- if (triggerChange === void 0) {
- triggerChange = false;
- }
- if (format === void 0) {
- format = self.config.dateFormat;
- }
- if (date !== 0 && !date || date instanceof Array && date.length === 0) return self.clear(triggerChange);
- setSelectedDate(date, format);
- self.showTimeInput = self.selectedDates.length > 0;
- self.latestSelectedDateObj = self.selectedDates[self.selectedDates.length - 1];
- self.redraw();
- jumpToDate();
- setHoursFromDate();
- if (self.selectedDates.length === 0) {
- self.clear(false);
- }
- updateValue(triggerChange);
- if (triggerChange) triggerEvent("onChange");
- }
- function parseDateRules(arr) {
- return arr.slice().map(function (rule) {
- if (typeof rule === "string" || typeof rule === "number" || rule instanceof Date) {
- return self.parseDate(rule, undefined, true);
- } else if (rule && typeof rule === "object" && rule.from && rule.to) return {
- from: self.parseDate(rule.from, undefined),
- to: self.parseDate(rule.to, undefined)
- };
- return rule;
- }).filter(function (x) {
- return x;
- }); // remove falsy values
- }
- function setupDates() {
- self.selectedDates = [];
- self.now = self.parseDate(self.config.now) || new Date(); // Workaround IE11 setting placeholder as the input's value
- var preloadedDate = self.config.defaultDate || ((self.input.nodeName === "INPUT" || self.input.nodeName === "TEXTAREA") && self.input.placeholder && self.input.value === self.input.placeholder ? null : self.input.value);
- if (preloadedDate) setSelectedDate(preloadedDate, self.config.dateFormat);
- self._initialDate = self.selectedDates.length > 0 ? self.selectedDates[0] : self.config.minDate && self.config.minDate.getTime() > self.now.getTime() ? self.config.minDate : self.config.maxDate && self.config.maxDate.getTime() < self.now.getTime() ? self.config.maxDate : self.now;
- self.currentYear = self._initialDate.getFullYear();
- self.currentMonth = self._initialDate.getMonth();
- if (self.selectedDates.length > 0) self.latestSelectedDateObj = self.selectedDates[0];
- if (self.config.minTime !== undefined) self.config.minTime = self.parseDate(self.config.minTime, "H:i");
- if (self.config.maxTime !== undefined) self.config.maxTime = self.parseDate(self.config.maxTime, "H:i");
- self.minDateHasTime = !!self.config.minDate && (self.config.minDate.getHours() > 0 || self.config.minDate.getMinutes() > 0 || self.config.minDate.getSeconds() > 0);
- self.maxDateHasTime = !!self.config.maxDate && (self.config.maxDate.getHours() > 0 || self.config.maxDate.getMinutes() > 0 || self.config.maxDate.getSeconds() > 0);
- Object.defineProperty(self, "showTimeInput", {
- get: function () {
- return self._showTimeInput;
- },
- set: function (bool) {
- self._showTimeInput = bool;
- if (self.calendarContainer) toggleClass(self.calendarContainer, "showTimeInput", bool);
- self.isOpen && positionCalendar();
- }
- });
- }
- function setupInputs() {
- self.input = self.config.wrap ? element.querySelector("[data-input]") : element;
- /* istanbul ignore next */
- if (!self.input) {
- self.config.errorHandler(new Error("Invalid input element specified"));
- return;
- } // hack: store previous type to restore it after destroy()
- self.input._type = self.input.type;
- self.input.type = "text";
- self.input.classList.add("flatpickr-input");
- self._input = self.input;
- if (self.config.altInput) {
- // replicate self.element
- self.altInput = createElement(self.input.nodeName, self.config.altInputClass);
- self._input = self.altInput;
- self.altInput.placeholder = self.input.placeholder;
- self.altInput.disabled = self.input.disabled;
- self.altInput.required = self.input.required;
- self.altInput.tabIndex = self.input.tabIndex;
- self.altInput.type = "text";
- self.input.setAttribute("type", "hidden");
- if (!self.config.static && self.input.parentNode) self.input.parentNode.insertBefore(self.altInput, self.input.nextSibling);
- }
- if (!self.config.allowInput) self._input.setAttribute("readonly", "readonly");
- self._positionElement = self.config.positionElement || self._input;
- }
- function setupMobile() {
- var inputType = self.config.enableTime ? self.config.noCalendar ? "time" : "datetime-local" : "date";
- self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
- self.mobileInput.step = self.input.getAttribute("step") || "any";
- self.mobileInput.tabIndex = 1;
- self.mobileInput.type = inputType;
- self.mobileInput.disabled = self.input.disabled;
- self.mobileInput.required = self.input.required;
- self.mobileInput.placeholder = self.input.placeholder;
- self.mobileFormatStr = inputType === "datetime-local" ? "Y-m-d\\TH:i:S" : inputType === "date" ? "Y-m-d" : "H:i:S";
- if (self.selectedDates.length > 0) {
- self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(self.selectedDates[0], self.mobileFormatStr);
- }
- if (self.config.minDate) self.mobileInput.min = self.formatDate(self.config.minDate, "Y-m-d");
- if (self.config.maxDate) self.mobileInput.max = self.formatDate(self.config.maxDate, "Y-m-d");
- self.input.type = "hidden";
- if (self.altInput !== undefined) self.altInput.type = "hidden";
- try {
- if (self.input.parentNode) self.input.parentNode.insertBefore(self.mobileInput, self.input.nextSibling);
- } catch (_a) {}
- bind(self.mobileInput, "change", function (e) {
- self.setDate(e.target.value, false, self.mobileFormatStr);
- triggerEvent("onChange");
- triggerEvent("onClose");
- });
- }
- function toggle(e) {
- if (self.isOpen === true) return self.close();
- self.open(e);
- }
- function triggerEvent(event, data) {
- // If the instance has been destroyed already, all hooks have been removed
- if (self.config === undefined) return;
- var hooks = self.config[event];
- if (hooks !== undefined && hooks.length > 0) {
- for (var i = 0; hooks[i] && i < hooks.length; i++) hooks[i](self.selectedDates, self.input.value, self, data);
- }
- if (event === "onChange") {
- self.input.dispatchEvent(createEvent("change")); // many front-end frameworks bind to the input event
- self.input.dispatchEvent(createEvent("input"));
- }
- }
- function createEvent(name) {
- var e = document.createEvent("Event");
- e.initEvent(name, true, true);
- return e;
- }
- function isDateSelected(date) {
- for (var i = 0; i < self.selectedDates.length; i++) {
- if (compareDates(self.selectedDates[i], date) === 0) return "" + i;
- }
- return false;
- }
- function isDateInRange(date) {
- if (self.config.mode !== "range" || self.selectedDates.length < 2) return false;
- return compareDates(date, self.selectedDates[0]) >= 0 && compareDates(date, self.selectedDates[1]) <= 0;
- }
- function updateNavigationCurrentMonth() {
- if (self.config.noCalendar || self.isMobile || !self.monthNav) return;
- self.yearElements.forEach(function (yearElement, i) {
- var d = new Date(self.currentYear, self.currentMonth, 1);
- d.setMonth(self.currentMonth + i);
- if (self.config.showMonths > 1 || self.config.monthSelectorType === "static") {
- self.monthElements[i].textContent = monthToStr(d.getMonth(), self.config.shorthandCurrentMonth, self.l10n) + " ";
- } else {
- self.monthsDropdownContainer.value = d.getMonth().toString();
- }
- yearElement.value = d.getFullYear().toString();
- });
- self._hidePrevMonthArrow = self.config.minDate !== undefined && (self.currentYear === self.config.minDate.getFullYear() ? self.currentMonth <= self.config.minDate.getMonth() : self.currentYear < self.config.minDate.getFullYear());
- self._hideNextMonthArrow = self.config.maxDate !== undefined && (self.currentYear === self.config.maxDate.getFullYear() ? self.currentMonth + 1 > self.config.maxDate.getMonth() : self.currentYear > self.config.maxDate.getFullYear());
- }
- function getDateStr(format) {
- return self.selectedDates.map(function (dObj) {
- return self.formatDate(dObj, format);
- }).filter(function (d, i, arr) {
- return self.config.mode !== "range" || self.config.enableTime || arr.indexOf(d) === i;
- }).join(self.config.mode !== "range" ? self.config.conjunction : self.l10n.rangeSeparator);
- }
- /**
- * Updates the values of inputs associated with the calendar
- */
- function updateValue(triggerChange) {
- if (triggerChange === void 0) {
- triggerChange = true;
- }
- if (self.mobileInput !== undefined && self.mobileFormatStr) {
- self.mobileInput.value = self.latestSelectedDateObj !== undefined ? self.formatDate(self.latestSelectedDateObj, self.mobileFormatStr) : "";
- }
- self.input.value = getDateStr(self.config.dateFormat);
- if (self.altInput !== undefined) {
- self.altInput.value = getDateStr(self.config.altFormat);
- }
- if (triggerChange !== false) triggerEvent("onValueUpdate");
- }
- function onMonthNavClick(e) {
- var isPrevMonth = self.prevMonthNav.contains(e.target);
- var isNextMonth = self.nextMonthNav.contains(e.target);
- if (isPrevMonth || isNextMonth) {
- changeMonth(isPrevMonth ? -1 : 1);
- } else if (self.yearElements.indexOf(e.target) >= 0) {
- e.target.select();
- } else if (e.target.classList.contains("arrowUp")) {
- self.changeYear(self.currentYear + 1);
- } else if (e.target.classList.contains("arrowDown")) {
- self.changeYear(self.currentYear - 1);
- }
- }
- function timeWrapper(e) {
- e.preventDefault();
- var isKeyDown = e.type === "keydown",
- input = e.target;
- if (self.amPM !== undefined && e.target === self.amPM) {
- self.amPM.textContent = self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
- }
- var min = parseFloat(input.getAttribute("min")),
- max = parseFloat(input.getAttribute("max")),
- step = parseFloat(input.getAttribute("step")),
- curValue = parseInt(input.value, 10),
- delta = e.delta || (isKeyDown ? e.which === 38 ? 1 : -1 : 0);
- var newValue = curValue + step * delta;
- if (typeof input.value !== "undefined" && input.value.length === 2) {
- var isHourElem = input === self.hourElement,
- isMinuteElem = input === self.minuteElement;
- if (newValue < min) {
- newValue = max + newValue + int(!isHourElem) + (int(isHourElem) && int(!self.amPM));
- if (isMinuteElem) incrementNumInput(undefined, -1, self.hourElement);
- } else if (newValue > max) {
- newValue = input === self.hourElement ? newValue - max - int(!self.amPM) : min;
- if (isMinuteElem) incrementNumInput(undefined, 1, self.hourElement);
- }
- if (self.amPM && isHourElem && (step === 1 ? newValue + curValue === 23 : Math.abs(newValue - curValue) > step)) {
- self.amPM.textContent = self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
- }
- input.value = pad(newValue);
- }
- }
- init();
- return self;
- }
- /* istanbul ignore next */
- function _flatpickr(nodeList, config) {
- // static list
- var nodes = Array.prototype.slice.call(nodeList).filter(function (x) {
- return x instanceof HTMLElement;
- });
- var instances = [];
- for (var i = 0; i < nodes.length; i++) {
- var node = nodes[i];
- try {
- if (node.getAttribute("data-fp-omit") !== null) continue;
- if (node._flatpickr !== undefined) {
- node._flatpickr.destroy();
- node._flatpickr = undefined;
- }
- node._flatpickr = FlatpickrInstance(node, config || {});
- instances.push(node._flatpickr);
- } catch (e) {
- console.error(e);
- }
- }
- return instances.length === 1 ? instances[0] : instances;
- }
- /* istanbul ignore next */
- if (typeof HTMLElement !== "undefined" && typeof HTMLCollection !== "undefined" && typeof NodeList !== "undefined") {
- // browser env
- HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function (config) {
- return _flatpickr(this, config);
- };
- HTMLElement.prototype.flatpickr = function (config) {
- return _flatpickr([this], config);
- };
- }
- /* istanbul ignore next */
- var flatpickr = function (selector, config) {
- if (typeof selector === "string") {
- return _flatpickr(window.document.querySelectorAll(selector), config);
- } else if (selector instanceof Node) {
- return _flatpickr([selector], config);
- } else {
- return _flatpickr(selector, config);
- }
- };
- /* istanbul ignore next */
- flatpickr.defaultConfig = {};
- flatpickr.l10ns = {
- en: __assign({}, english),
- "default": __assign({}, english)
- };
- flatpickr.localize = function (l10n) {
- flatpickr.l10ns["default"] = __assign({}, flatpickr.l10ns["default"], l10n);
- };
- flatpickr.setDefaults = function (config) {
- flatpickr.defaultConfig = __assign({}, flatpickr.defaultConfig, config);
- };
- flatpickr.parseDate = createDateParser({});
- flatpickr.formatDate = createDateFormatter({});
- flatpickr.compareDates = compareDates;
- /* istanbul ignore next */
- if (typeof jQuery !== "undefined" && typeof jQuery.fn !== "undefined") {
- jQuery.fn.flatpickr = function (config) {
- return _flatpickr(this, config);
- };
- } // eslint-disable-next-line @typescript-eslint/camelcase
- Date.prototype.fp_incr = function (days) {
- return new Date(this.getFullYear(), this.getMonth(), this.getDate() + (typeof days === "string" ? parseInt(days, 10) : days));
- };
- if (typeof window !== "undefined") {
- window.flatpickr = flatpickr;
- }
- return flatpickr;
- });
- },{}],"scripts/main.js":[function(require,module,exports) {
- "use strict";
- var _flatpickr = _interopRequireDefault(require("flatpickr"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- var initSwitcher = function initSwitcher(gridMode, listMode, content) {
- var activeClass = 'active';
- var displayList = 'display_list';
- var displayGrid = 'display_grid';
- var toggleSwitch = function toggleSwitch(btn, className) {
- btn.classList.toggle(activeClass);
- content.classList.toggle(className);
- };
- var active = listMode;
- var eventListener = function eventListener(oldBtn, oldClass, newBtn, newClass) {
- return function () {
- if (active !== newBtn) {
- active = newBtn; // remove old state
- toggleSwitch(oldBtn, oldClass); // add new state
- toggleSwitch(newBtn, newClass);
- }
- };
- };
- gridMode.addEventListener('click', eventListener(listMode, displayList, gridMode, displayGrid));
- listMode.addEventListener('click', eventListener(gridMode, displayGrid, listMode, displayList));
- };
- initSwitcher(document.getElementById('mode-switcher-grid'), document.getElementById('mode-switcher-list'), document.getElementById('content'));
- var initDatepicker = function initDatepicker(id) {
- (0, _flatpickr.default)(id, {
- dateFormat: "Y-m-d",
- wrap: true,
- weekNumbers: true
- });
- };
- initDatepicker('#from-date');
- initDatepicker('#to-date');
- },{"flatpickr":"node_modules/flatpickr/dist/flatpickr.js"}],"node_modules/parcel/src/builtins/hmr-runtime.js":[function(require,module,exports) {
- var global = arguments[3];
- var OVERLAY_ID = '__parcel__error__overlay__';
- var OldModule = module.bundle.Module;
- function Module(moduleName) {
- OldModule.call(this, moduleName);
- this.hot = {
- data: module.bundle.hotData,
- _acceptCallbacks: [],
- _disposeCallbacks: [],
- accept: function (fn) {
- this._acceptCallbacks.push(fn || function () {});
- },
- dispose: function (fn) {
- this._disposeCallbacks.push(fn);
- }
- };
- module.bundle.hotData = null;
- }
- module.bundle.Module = Module;
- var checkedAssets, assetsToAccept;
- var parent = module.bundle.parent;
- if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
- var hostname = "" || location.hostname;
- var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
- var ws = new WebSocket(protocol + '://' + hostname + ':' + "53056" + '/');
- ws.onmessage = function (event) {
- checkedAssets = {};
- assetsToAccept = [];
- var data = JSON.parse(event.data);
- if (data.type === 'update') {
- var handled = false;
- data.assets.forEach(function (asset) {
- if (!asset.isNew) {
- var didAccept = hmrAcceptCheck(global.parcelRequire, asset.id);
- if (didAccept) {
- handled = true;
- }
- }
- }); // Enable HMR for CSS by default.
- handled = handled || data.assets.every(function (asset) {
- return asset.type === 'css' && asset.generated.js;
- });
- if (handled) {
- console.clear();
- data.assets.forEach(function (asset) {
- hmrApply(global.parcelRequire, asset);
- });
- assetsToAccept.forEach(function (v) {
- hmrAcceptRun(v[0], v[1]);
- });
- } else if (location.reload) {
- // `location` global exists in a web worker context but lacks `.reload()` function.
- location.reload();
- }
- }
- if (data.type === 'reload') {
- ws.close();
- ws.onclose = function () {
- location.reload();
- };
- }
- if (data.type === 'error-resolved') {
- console.log('[parcel] ✨ Error resolved');
- removeErrorOverlay();
- }
- if (data.type === 'error') {
- console.error('[parcel] 🚨 ' + data.error.message + '\n' + data.error.stack);
- removeErrorOverlay();
- var overlay = createErrorOverlay(data);
- document.body.appendChild(overlay);
- }
- };
- }
- function removeErrorOverlay() {
- var overlay = document.getElementById(OVERLAY_ID);
- if (overlay) {
- overlay.remove();
- }
- }
- function createErrorOverlay(data) {
- var overlay = document.createElement('div');
- overlay.id = OVERLAY_ID; // html encode message and stack trace
- var message = document.createElement('div');
- var stackTrace = document.createElement('pre');
- message.innerText = data.error.message;
- stackTrace.innerText = data.error.stack;
- overlay.innerHTML = '<div style="background: black; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; opacity: 0.85; font-family: Menlo, Consolas, monospace; z-index: 9999;">' + '<span style="background: red; padding: 2px 4px; border-radius: 2px;">ERROR</span>' + '<span style="top: 2px; margin-left: 5px; position: relative;">🚨</span>' + '<div style="font-size: 18px; font-weight: bold; margin-top: 20px;">' + message.innerHTML + '</div>' + '<pre>' + stackTrace.innerHTML + '</pre>' + '</div>';
- return overlay;
- }
- function getParents(bundle, id) {
- var modules = bundle.modules;
- if (!modules) {
- return [];
- }
- var parents = [];
- var k, d, dep;
- for (k in modules) {
- for (d in modules[k][1]) {
- dep = modules[k][1][d];
- if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) {
- parents.push(k);
- }
- }
- }
- if (bundle.parent) {
- parents = parents.concat(getParents(bundle.parent, id));
- }
- return parents;
- }
- function hmrApply(bundle, asset) {
- var modules = bundle.modules;
- if (!modules) {
- return;
- }
- if (modules[asset.id] || !bundle.parent) {
- var fn = new Function('require', 'module', 'exports', asset.generated.js);
- asset.isNew = !modules[asset.id];
- modules[asset.id] = [fn, asset.deps];
- } else if (bundle.parent) {
- hmrApply(bundle.parent, asset);
- }
- }
- function hmrAcceptCheck(bundle, id) {
- var modules = bundle.modules;
- if (!modules) {
- return;
- }
- if (!modules[id] && bundle.parent) {
- return hmrAcceptCheck(bundle.parent, id);
- }
- if (checkedAssets[id]) {
- return;
- }
- checkedAssets[id] = true;
- var cached = bundle.cache[id];
- assetsToAccept.push([bundle, id]);
- if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
- return true;
- }
- return getParents(global.parcelRequire, id).some(function (id) {
- return hmrAcceptCheck(global.parcelRequire, id);
- });
- }
- function hmrAcceptRun(bundle, id) {
- var cached = bundle.cache[id];
- bundle.hotData = {};
- if (cached) {
- cached.hot.data = bundle.hotData;
- }
- if (cached && cached.hot && cached.hot._disposeCallbacks.length) {
- cached.hot._disposeCallbacks.forEach(function (cb) {
- cb(bundle.hotData);
- });
- }
- delete bundle.cache[id];
- bundle(id);
- cached = bundle.cache[id];
- if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
- cached.hot._acceptCallbacks.forEach(function (cb) {
- cb();
- });
- return true;
- }
- }
- },{}]},{},["node_modules/parcel/src/builtins/hmr-runtime.js","scripts/main.js"], null)
- //# sourceMappingURL=/main.d8ebb8d6.js.map
|