flatpickr 2.6.3.0 → 3.0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/flatpickr/version.rb +1 -1
  3. data/vendor/assets/javascripts/flatpickr.js +316 -292
  4. data/vendor/assets/javascripts/flatpickr/l10n/ar.js +5 -5
  5. data/vendor/assets/javascripts/flatpickr/l10n/bg.js +5 -5
  6. data/vendor/assets/javascripts/flatpickr/l10n/bn.js +5 -5
  7. data/vendor/assets/javascripts/flatpickr/l10n/cat.js +7 -7
  8. data/vendor/assets/javascripts/flatpickr/l10n/cs.js +7 -7
  9. data/vendor/assets/javascripts/flatpickr/l10n/cy.js +7 -7
  10. data/vendor/assets/javascripts/flatpickr/l10n/da.js +6 -6
  11. data/vendor/assets/javascripts/flatpickr/l10n/de.js +10 -10
  12. data/vendor/assets/javascripts/flatpickr/l10n/eo.js +11 -11
  13. data/vendor/assets/javascripts/flatpickr/l10n/es.js +7 -7
  14. data/vendor/assets/javascripts/flatpickr/l10n/et.js +11 -11
  15. data/vendor/assets/javascripts/flatpickr/l10n/fa.js +6 -6
  16. data/vendor/assets/javascripts/flatpickr/l10n/fi.js +7 -7
  17. data/vendor/assets/javascripts/flatpickr/l10n/fr.js +11 -11
  18. data/vendor/assets/javascripts/flatpickr/l10n/gr.js +13 -13
  19. data/vendor/assets/javascripts/flatpickr/l10n/he.js +5 -5
  20. data/vendor/assets/javascripts/flatpickr/l10n/hi.js +5 -5
  21. data/vendor/assets/javascripts/flatpickr/l10n/hr.js +6 -6
  22. data/vendor/assets/javascripts/flatpickr/l10n/hu.js +10 -10
  23. data/vendor/assets/javascripts/flatpickr/l10n/id.js +7 -7
  24. data/vendor/assets/javascripts/flatpickr/l10n/index.js +99 -0
  25. data/vendor/assets/javascripts/flatpickr/l10n/it.js +10 -10
  26. data/vendor/assets/javascripts/flatpickr/l10n/ja.js +5 -5
  27. data/vendor/assets/javascripts/flatpickr/l10n/ko.js +6 -6
  28. data/vendor/assets/javascripts/flatpickr/l10n/lt.js +10 -10
  29. data/vendor/assets/javascripts/flatpickr/l10n/lv.js +6 -6
  30. data/vendor/assets/javascripts/flatpickr/l10n/mk.js +8 -8
  31. data/vendor/assets/javascripts/flatpickr/l10n/ms.js +7 -7
  32. data/vendor/assets/javascripts/flatpickr/l10n/my.js +7 -7
  33. data/vendor/assets/javascripts/flatpickr/l10n/nl.js +11 -11
  34. data/vendor/assets/javascripts/flatpickr/l10n/no.js +11 -11
  35. data/vendor/assets/javascripts/flatpickr/l10n/pa.js +5 -5
  36. data/vendor/assets/javascripts/flatpickr/l10n/pl.js +6 -6
  37. data/vendor/assets/javascripts/flatpickr/l10n/pt.js +6 -8
  38. data/vendor/assets/javascripts/flatpickr/l10n/ro.js +7 -9
  39. data/vendor/assets/javascripts/flatpickr/l10n/ru.js +6 -8
  40. data/vendor/assets/javascripts/flatpickr/l10n/si.js +5 -7
  41. data/vendor/assets/javascripts/flatpickr/l10n/sk.js +8 -8
  42. data/vendor/assets/javascripts/flatpickr/l10n/sl.js +8 -10
  43. data/vendor/assets/javascripts/flatpickr/l10n/sq.js +5 -7
  44. data/vendor/assets/javascripts/flatpickr/l10n/sr.js +9 -10
  45. data/vendor/assets/javascripts/flatpickr/l10n/sv.js +8 -10
  46. data/vendor/assets/javascripts/flatpickr/l10n/th.js +10 -11
  47. data/vendor/assets/javascripts/flatpickr/l10n/tr.js +6 -8
  48. data/vendor/assets/javascripts/flatpickr/l10n/uk.js +6 -7
  49. data/vendor/assets/javascripts/flatpickr/l10n/vn.js +6 -8
  50. data/vendor/assets/javascripts/flatpickr/l10n/zh.js +9 -11
  51. data/vendor/assets/stylesheets/flatpickr.css +2 -2
  52. data/vendor/assets/stylesheets/flatpickr/themes/airbnb.css +54 -28
  53. data/vendor/assets/stylesheets/flatpickr/themes/confetti.css +49 -25
  54. data/vendor/assets/stylesheets/flatpickr/themes/dark.css +51 -26
  55. data/vendor/assets/stylesheets/flatpickr/themes/light.css +49 -25
  56. data/vendor/assets/stylesheets/flatpickr/themes/material_blue.css +49 -25
  57. data/vendor/assets/stylesheets/flatpickr/themes/material_green.css +49 -25
  58. data/vendor/assets/stylesheets/flatpickr/themes/material_orange.css +49 -25
  59. data/vendor/assets/stylesheets/flatpickr/themes/material_red.css +49 -25
  60. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2941560968ee8c67b075ffce9bd7243c05bbfbe
4
- data.tar.gz: b9525cb5b677f9e276e1c63aeedb0ddd0824da06
3
+ metadata.gz: 2bec38961ec6a9561c326df64699acea948b1a90
4
+ data.tar.gz: e21341f12ff8ebfe7936f1b2023c16eb206393d9
5
5
  SHA512:
6
- metadata.gz: 3ee4fb839a5979beccd7ff41f11cac31179393902df384fbb7076dc635401ca55a29edfa4bca28e7044977ab95243a2faab068de5dfcbfb1768d518389e78881
7
- data.tar.gz: fe3ecad9f05c32e8a1d6a235d6023d40ec5587f5126a99d3b5b800f2c1b04496d8e0698ea5dddb55f059b1a877d5dd22d72c33e4a575aea9b0b4db980ffa0e8f
6
+ metadata.gz: 533712a46a842dc051752790439b0b3d96afad034f5206efe4e61ea63478f6170566001b1c12e170bf818d0b8b0ad178828fec8ceeb9231f75e638a27f04d254
7
+ data.tar.gz: ee47a2dab0a23aa0bb88d8bed1ce8c67ad4156eb5dadfb47139cfedec27596cc89d0da26deb684b15acd137cd45aadab6264b30a3bd9246540cbf7097f8096fa
@@ -1,3 +1,3 @@
1
1
  module Flatpickr
2
- VERSION = '2.6.3.0'
2
+ VERSION = '3.0.0.0'
3
3
  end
@@ -2,12 +2,15 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
2
2
 
3
3
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4
4
 
5
- /*! flatpickr v2.6.3, @license MIT */
6
- function Flatpickr(element, config) {
5
+ /*! flatpickr v3.0.5-1, @license MIT */
6
+ function FlatpickrInstance(element, config) {
7
7
  var self = this;
8
8
 
9
9
  self._ = {};
10
10
  self._.afterDayAnim = afterDayAnim;
11
+ self._bind = bind;
12
+ self._compareDates = compareDates;
13
+ self._setHoursFromDate = setHoursFromDate;
11
14
  self.changeMonth = changeMonth;
12
15
  self.changeYear = changeYear;
13
16
  self.clear = clear;
@@ -25,8 +28,8 @@ function Flatpickr(element, config) {
25
28
  function init() {
26
29
  self.element = self.input = element;
27
30
  self.instanceConfig = config || {};
28
- self.parseDate = Flatpickr.prototype.parseDate.bind(self);
29
- self.formatDate = Flatpickr.prototype.formatDate.bind(self);
31
+ self.parseDate = FlatpickrInstance.prototype.parseDate.bind(self);
32
+ self.formatDate = FlatpickrInstance.prototype.formatDate.bind(self);
30
33
 
31
34
  setupFormats();
32
35
  parseConfig();
@@ -50,12 +53,12 @@ function Flatpickr(element, config) {
50
53
  updateValue();
51
54
  }
52
55
 
56
+ self.showTimeInput = self.selectedDates.length > 0 || self.config.noCalendar;
57
+
53
58
  if (self.config.weekNumbers) {
54
59
  self.calendarContainer.style.width = self.daysContainer.offsetWidth + self.weekWrapper.offsetWidth + "px";
55
60
  }
56
61
 
57
- self.showTimeInput = self.selectedDates.length > 0 || self.config.noCalendar;
58
-
59
62
  if (!self.isMobile) positionCalendar();
60
63
 
61
64
  triggerEvent("Ready");
@@ -238,7 +241,10 @@ function Flatpickr(element, config) {
238
241
  bind(window.document, "mousedown", onClick(documentClick));
239
242
  bind(self._input, "blur", documentClick);
240
243
 
241
- if (self.config.clickOpens === true) bind(self._input, "focus", self.open);
244
+ if (self.config.clickOpens === true) {
245
+ bind(self._input, "focus", self.open);
246
+ bind(self._input, "mousedown", onClick(self.open));
247
+ }
242
248
 
243
249
  if (!self.config.noCalendar) {
244
250
  self.monthNav.addEventListener("wheel", function (e) {
@@ -840,6 +846,8 @@ function Flatpickr(element, config) {
840
846
  }
841
847
 
842
848
  function destroy() {
849
+ if (self.config !== undefined) triggerEvent("Destroy");
850
+
843
851
  for (var i = self._handlers.length; i--;) {
844
852
  var h = self._handlers[i];
845
853
  h.element.removeEventListener(h.event, h.handler);
@@ -885,8 +893,7 @@ function Flatpickr(element, config) {
885
893
 
886
894
  var lostFocus = e.type === "blur" ? isInput && e.relatedTarget && !isCalendarElem(e.relatedTarget) : !isInput && !isCalendarElement;
887
895
 
888
- if (lostFocus) {
889
- e.preventDefault();
896
+ if (lostFocus && self.config.ignoredFocusElements.indexOf(e.target) === -1) {
890
897
  self.close();
891
898
 
892
899
  if (self.config.mode === "range" && self.selectedDates.length === 1) {
@@ -1089,7 +1096,7 @@ function Flatpickr(element, config) {
1089
1096
  if (self.isOpen && !self.config.static && !self.config.inline) positionCalendar();
1090
1097
  }
1091
1098
 
1092
- function open(e) {
1099
+ function open(e, positionElement) {
1093
1100
  if (self.isMobile) {
1094
1101
  if (e) {
1095
1102
  e.preventDefault();
@@ -1108,7 +1115,7 @@ function Flatpickr(element, config) {
1108
1115
 
1109
1116
  self.isOpen = true;
1110
1117
  self.calendarContainer.classList.add("open");
1111
- positionCalendar();
1118
+ positionCalendar(positionElement);
1112
1119
  self._input.classList.add("active");
1113
1120
 
1114
1121
  triggerEvent("Open");
@@ -1144,25 +1151,43 @@ function Flatpickr(element, config) {
1144
1151
  }
1145
1152
 
1146
1153
  function parseConfig() {
1147
- var boolOpts = ["utc", "wrap", "weekNumbers", "allowInput", "clickOpens", "time_24hr", "enableTime", "noCalendar", "altInput", "shorthandCurrentMonth", "inline", "static", "enableSeconds", "disableMobile"];
1154
+ var boolOpts = ["wrap", "weekNumbers", "allowInput", "clickOpens", "time_24hr", "enableTime", "noCalendar", "altInput", "shorthandCurrentMonth", "inline", "static", "enableSeconds", "disableMobile"];
1148
1155
 
1149
- var hooks = ["onChange", "onClose", "onDayCreate", "onKeyDown", "onMonthChange", "onOpen", "onParseConfig", "onReady", "onValueUpdate", "onYearChange"];
1156
+ var hooks = ["onChange", "onClose", "onDayCreate", "onDestroy", "onKeyDown", "onMonthChange", "onOpen", "onParseConfig", "onReady", "onValueUpdate", "onYearChange"];
1150
1157
 
1151
- self.config = Object.create(Flatpickr.defaultConfig);
1158
+ self.config = Object.create(flatpickr.defaultConfig);
1152
1159
 
1153
1160
  var userConfig = _extends({}, self.instanceConfig, JSON.parse(JSON.stringify(self.element.dataset || {})));
1154
1161
 
1155
1162
  self.config.parseDate = userConfig.parseDate;
1156
1163
  self.config.formatDate = userConfig.formatDate;
1157
1164
 
1165
+ Object.defineProperty(self.config, "enable", {
1166
+ get: function get() {
1167
+ return self.config._enable || [];
1168
+ },
1169
+ set: function set(dates) {
1170
+ return self.config._enable = parseDateRules(dates);
1171
+ }
1172
+ });
1173
+
1174
+ Object.defineProperty(self.config, "disable", {
1175
+ get: function get() {
1176
+ return self.config._disable || [];
1177
+ },
1178
+ set: function set(dates) {
1179
+ return self.config._disable = parseDateRules(dates);
1180
+ }
1181
+ });
1182
+
1158
1183
  _extends(self.config, userConfig);
1159
1184
 
1160
1185
  if (!userConfig.dateFormat && userConfig.enableTime) {
1161
- self.config.dateFormat = self.config.noCalendar ? "H:i" + (self.config.enableSeconds ? ":S" : "") : Flatpickr.defaultConfig.dateFormat + " H:i" + (self.config.enableSeconds ? ":S" : "");
1186
+ self.config.dateFormat = self.config.noCalendar ? "H:i" + (self.config.enableSeconds ? ":S" : "") : flatpickr.defaultConfig.dateFormat + " H:i" + (self.config.enableSeconds ? ":S" : "");
1162
1187
  }
1163
1188
 
1164
1189
  if (userConfig.altInput && userConfig.enableTime && !userConfig.altFormat) {
1165
- self.config.altFormat = self.config.noCalendar ? "h:i" + (self.config.enableSeconds ? ":S K" : " K") : Flatpickr.defaultConfig.altFormat + (" h:i" + (self.config.enableSeconds ? ":S" : "") + " K");
1190
+ self.config.altFormat = self.config.noCalendar ? "h:i" + (self.config.enableSeconds ? ":S K" : " K") : flatpickr.defaultConfig.altFormat + (" h:i" + (self.config.enableSeconds ? ":S" : "") + " K");
1166
1191
  }
1167
1192
 
1168
1193
  Object.defineProperty(self.config, "minDate", {
@@ -1204,22 +1229,24 @@ function Flatpickr(element, config) {
1204
1229
  }
1205
1230
 
1206
1231
  function setupLocale() {
1207
- if (_typeof(self.config.locale) !== "object" && typeof Flatpickr.l10ns[self.config.locale] === "undefined") console.warn("flatpickr: invalid locale " + self.config.locale);
1232
+ if (_typeof(self.config.locale) !== "object" && typeof flatpickr.l10ns[self.config.locale] === "undefined") console.warn("flatpickr: invalid locale " + self.config.locale);
1208
1233
 
1209
- self.l10n = _extends(Object.create(Flatpickr.l10ns.default), _typeof(self.config.locale) === "object" ? self.config.locale : self.config.locale !== "default" ? Flatpickr.l10ns[self.config.locale] || {} : {});
1234
+ self.l10n = _extends(Object.create(flatpickr.l10ns.default), _typeof(self.config.locale) === "object" ? self.config.locale : self.config.locale !== "default" ? flatpickr.l10ns[self.config.locale] || {} : {});
1210
1235
  }
1211
1236
 
1212
1237
  function positionCalendar() {
1238
+ var positionElement = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : self._positionElement;
1239
+
1213
1240
  if (self.calendarContainer === undefined) return;
1214
1241
 
1215
1242
  var calendarHeight = self.calendarContainer.offsetHeight,
1216
1243
  calendarWidth = self.calendarContainer.offsetWidth,
1217
1244
  configPos = self.config.position,
1218
- inputBounds = self._positionElement.getBoundingClientRect(),
1245
+ inputBounds = positionElement.getBoundingClientRect(),
1219
1246
  distanceFromBottom = window.innerHeight - inputBounds.bottom,
1220
1247
  showOnTop = configPos === "above" || configPos !== "below" && distanceFromBottom < calendarHeight && inputBounds.top > calendarHeight;
1221
1248
 
1222
- var top = window.pageYOffset + inputBounds.top + (!showOnTop ? self._positionElement.offsetHeight + 2 : -calendarHeight - 2);
1249
+ var top = window.pageYOffset + inputBounds.top + (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
1223
1250
 
1224
1251
  toggleClass(self.calendarContainer, "arrowTop", !showOnTop);
1225
1252
  toggleClass(self.calendarContainer, "arrowBottom", showOnTop);
@@ -1373,7 +1400,7 @@ function Flatpickr(element, config) {
1373
1400
  }
1374
1401
 
1375
1402
  function setDate(date, triggerChange, format) {
1376
- if (!date) return self.clear(triggerChange);
1403
+ if (date !== 0 && !date) return self.clear(triggerChange);
1377
1404
 
1378
1405
  setSelectedDate(date, format);
1379
1406
 
@@ -1389,27 +1416,23 @@ function Flatpickr(element, config) {
1389
1416
  if (triggerChange) triggerEvent("Change");
1390
1417
  }
1391
1418
 
1392
- function setupDates() {
1393
- function parseDateRules(arr) {
1394
- for (var i = arr.length; i--;) {
1395
- if (typeof arr[i] === "string" || +arr[i]) arr[i] = self.parseDate(arr[i], null, true);else if (arr[i] && arr[i].from && arr[i].to) {
1396
- arr[i].from = self.parseDate(arr[i].from);
1397
- arr[i].to = self.parseDate(arr[i].to);
1398
- }
1419
+ function parseDateRules(arr) {
1420
+ for (var i = arr.length; i--;) {
1421
+ if (typeof arr[i] === "string" || +arr[i]) arr[i] = self.parseDate(arr[i], null, true);else if (arr[i] && arr[i].from && arr[i].to) {
1422
+ arr[i].from = self.parseDate(arr[i].from);
1423
+ arr[i].to = self.parseDate(arr[i].to);
1399
1424
  }
1400
-
1401
- return arr.filter(function (x) {
1402
- return x;
1403
- }); // remove falsy values
1404
1425
  }
1405
1426
 
1427
+ return arr.filter(function (x) {
1428
+ return x;
1429
+ }); // remove falsy values
1430
+ }
1431
+
1432
+ function setupDates() {
1406
1433
  self.selectedDates = [];
1407
1434
  self.now = new Date();
1408
1435
 
1409
- if (self.config.disable.length) self.config.disable = parseDateRules(self.config.disable);
1410
-
1411
- if (self.config.enable.length) self.config.enable = parseDateRules(self.config.enable);
1412
-
1413
1436
  var preloadedDate = self.config.defaultDate || self.input.value;
1414
1437
  if (preloadedDate) setSelectedDate(preloadedDate, self.config.dateFormat);
1415
1438
 
@@ -1471,12 +1494,13 @@ function Flatpickr(element, config) {
1471
1494
 
1472
1495
  /* istanbul ignore next */
1473
1496
  function setupFormats() {
1497
+ self.formats = Object.create(FlatpickrInstance.prototype.formats);
1474
1498
  ["D", "F", "J", "M", "W", "l"].forEach(function (f) {
1475
- self.formats[f] = Flatpickr.prototype.formats[f].bind(self);
1499
+ self.formats[f] = FlatpickrInstance.prototype.formats[f].bind(self);
1476
1500
  });
1477
1501
 
1478
- self.revFormat.F = Flatpickr.prototype.revFormat.F.bind(self);
1479
- self.revFormat.M = Flatpickr.prototype.revFormat.M.bind(self);
1502
+ self.revFormat.F = FlatpickrInstance.prototype.revFormat.F.bind(self);
1503
+ self.revFormat.M = FlatpickrInstance.prototype.revFormat.M.bind(self);
1480
1504
  }
1481
1505
 
1482
1506
  function setupInputs() {
@@ -1497,6 +1521,7 @@ function Flatpickr(element, config) {
1497
1521
  self._input = self.altInput;
1498
1522
  self.altInput.placeholder = self.input.placeholder;
1499
1523
  self.altInput.disabled = self.input.disabled;
1524
+ self.altInput.required = self.input.required;
1500
1525
  self.altInput.type = "text";
1501
1526
  self.input.type = "hidden";
1502
1527
 
@@ -1625,7 +1650,8 @@ function Flatpickr(element, config) {
1625
1650
  return self.formatDate(dObj, self.config.altFormat);
1626
1651
  }).join(joinChar);
1627
1652
  }
1628
- triggerEvent("ValueUpdate");
1653
+
1654
+ if (triggerChange !== false) triggerEvent("ValueUpdate");
1629
1655
  }
1630
1656
 
1631
1657
  function mouseDelta(e) {
@@ -1760,204 +1786,7 @@ function Flatpickr(element, config) {
1760
1786
  return self;
1761
1787
  }
1762
1788
 
1763
- /* istanbul ignore next */
1764
- Flatpickr.defaultConfig = {
1765
- mode: "single",
1766
-
1767
- position: "auto",
1768
-
1769
- animate: window.navigator.userAgent.indexOf("MSIE") === -1,
1770
-
1771
- /* if true, dates will be parsed, formatted, and displayed in UTC.
1772
- preloading date strings w/ timezones is recommended but not necessary */
1773
- utc: false,
1774
-
1775
- // wrap: see https://chmln.github.io/flatpickr/examples/#flatpickr-external-elements
1776
- wrap: false,
1777
-
1778
- // enables week numbers
1779
- weekNumbers: false,
1780
-
1781
- // allow manual datetime input
1782
- allowInput: false,
1783
-
1784
- /*
1785
- clicking on input opens the date(time)picker.
1786
- disable if you wish to open the calendar manually with .open()
1787
- */
1788
- clickOpens: true,
1789
-
1790
- /*
1791
- closes calendar after date selection,
1792
- unless 'mode' is 'multiple' or enableTime is true
1793
- */
1794
- closeOnSelect: true,
1795
-
1796
- // display time picker in 24 hour mode
1797
- time_24hr: false,
1798
-
1799
- // enables the time picker functionality
1800
- enableTime: false,
1801
-
1802
- // noCalendar: true will hide the calendar. use for a time picker along w/ enableTime
1803
- noCalendar: false,
1804
-
1805
- // more date format chars at https://chmln.github.io/flatpickr/#dateformat
1806
- dateFormat: "Y-m-d",
1807
-
1808
- // date format used in aria-label for days
1809
- ariaDateFormat: "F j, Y",
1810
-
1811
- // altInput - see https://chmln.github.io/flatpickr/#altinput
1812
- altInput: false,
1813
-
1814
- // the created altInput element will have this class.
1815
- altInputClass: "form-control input",
1816
-
1817
- // same as dateFormat, but for altInput
1818
- altFormat: "F j, Y", // defaults to e.g. June 10, 2016
1819
-
1820
- // defaultDate - either a datestring or a date object. used for datetimepicker"s initial value
1821
- defaultDate: null,
1822
-
1823
- // the minimum date that user can pick (inclusive)
1824
- minDate: null,
1825
-
1826
- // the maximum date that user can pick (inclusive)
1827
- maxDate: null,
1828
-
1829
- // dateparser that transforms a given string to a date object
1830
- parseDate: null,
1831
-
1832
- // dateformatter that transforms a given date object to a string, according to passed format
1833
- formatDate: null,
1834
-
1835
- getWeek: function getWeek(givenDate) {
1836
- var date = new Date(givenDate.getTime());
1837
- var onejan = new Date(date.getFullYear(), 0, 1);
1838
- return Math.ceil(((date - onejan) / 86400000 + onejan.getDay() + 1) / 7);
1839
- },
1840
-
1841
-
1842
- // see https://chmln.github.io/flatpickr/#disable
1843
- enable: [],
1844
-
1845
- // see https://chmln.github.io/flatpickr/#disable
1846
- disable: [],
1847
-
1848
- // display the short version of month names - e.g. Sep instead of September
1849
- shorthandCurrentMonth: false,
1850
-
1851
- // displays calendar inline. see https://chmln.github.io/flatpickr/#inline-calendar
1852
- inline: false,
1853
-
1854
- // position calendar inside wrapper and next to the input element
1855
- // leave at false unless you know what you"re doing
1856
- "static": false,
1857
-
1858
- // DOM node to append the calendar to in *static* mode
1859
- appendTo: null,
1860
-
1861
- // code for previous/next icons. this is where you put your custom icon code e.g. fontawesome
1862
- 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>",
1863
- 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>",
1864
-
1865
- // enables seconds in the time picker
1866
- enableSeconds: false,
1867
-
1868
- // step size used when scrolling/incrementing the hour element
1869
- hourIncrement: 1,
1870
-
1871
- // step size used when scrolling/incrementing the minute element
1872
- minuteIncrement: 5,
1873
-
1874
- // initial value in the hour element
1875
- defaultHour: 12,
1876
-
1877
- // initial value in the minute element
1878
- defaultMinute: 0,
1879
-
1880
- // disable native mobile datetime input support
1881
- disableMobile: false,
1882
-
1883
- // default locale
1884
- locale: "default",
1885
-
1886
- plugins: [],
1887
-
1888
- // called every time calendar is closed
1889
- onClose: undefined, // function (dateObj, dateStr) {}
1890
-
1891
- // onChange callback when user selects a date or time
1892
- onChange: undefined, // function (dateObj, dateStr) {}
1893
-
1894
- // called for every day element
1895
- onDayCreate: undefined,
1896
-
1897
- // called every time the month is changed
1898
- onMonthChange: undefined,
1899
-
1900
- // called every time calendar is opened
1901
- onOpen: undefined, // function (dateObj, dateStr) {}
1902
-
1903
- // called after the configuration has been parsed
1904
- onParseConfig: undefined,
1905
-
1906
- // called after calendar is ready
1907
- onReady: undefined, // function (dateObj, dateStr) {}
1908
-
1909
- // called after input value updated
1910
- onValueUpdate: undefined,
1911
-
1912
- // called every time the year is changed
1913
- onYearChange: undefined,
1914
-
1915
- onKeyDown: undefined
1916
- };
1917
-
1918
- /* istanbul ignore next */
1919
- Flatpickr.l10ns = {
1920
- en: {
1921
- weekdays: {
1922
- shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
1923
- longhand: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
1924
- },
1925
- months: {
1926
- shorthand: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
1927
- longhand: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
1928
- },
1929
- daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
1930
- firstDayOfWeek: 0,
1931
- ordinal: function ordinal(nth) {
1932
- var s = nth % 100;
1933
- if (s > 3 && s < 21) return "th";
1934
- switch (s % 10) {
1935
- case 1:
1936
- return "st";
1937
- case 2:
1938
- return "nd";
1939
- case 3:
1940
- return "rd";
1941
- default:
1942
- return "th";
1943
- }
1944
- },
1945
- rangeSeparator: " to ",
1946
- weekAbbreviation: "Wk",
1947
- scrollTitle: "Scroll to increment",
1948
- toggleTitle: "Click to toggle"
1949
- }
1950
- };
1951
-
1952
- Flatpickr.l10ns.default = Object.create(Flatpickr.l10ns.en);
1953
- Flatpickr.localize = function (l10n) {
1954
- return _extends(Flatpickr.l10ns.default, l10n || {});
1955
- };
1956
- Flatpickr.setDefaults = function (config) {
1957
- return _extends(Flatpickr.defaultConfig, config || {});
1958
- };
1959
-
1960
- Flatpickr.prototype = {
1789
+ FlatpickrInstance.prototype = {
1961
1790
  formats: {
1962
1791
  // get the date in UTC
1963
1792
  Z: function Z(date) {
@@ -1976,12 +1805,12 @@ Flatpickr.prototype = {
1976
1805
 
1977
1806
  // padded hour 1-12
1978
1807
  G: function G(date) {
1979
- return Flatpickr.prototype.pad(Flatpickr.prototype.formats.h(date));
1808
+ return FlatpickrInstance.prototype.pad(FlatpickrInstance.prototype.formats.h(date));
1980
1809
  },
1981
1810
 
1982
1811
  // hours with leading zero e.g. 03
1983
1812
  H: function H(date) {
1984
- return Flatpickr.prototype.pad(date.getHours());
1813
+ return FlatpickrInstance.prototype.pad(date.getHours());
1985
1814
  },
1986
1815
 
1987
1816
  // day (1-30) with ordinal suffix e.g. 1st, 2nd
@@ -2001,7 +1830,7 @@ Flatpickr.prototype = {
2001
1830
 
2002
1831
  // seconds 00-59
2003
1832
  S: function S(date) {
2004
- return Flatpickr.prototype.pad(date.getSeconds());
1833
+ return FlatpickrInstance.prototype.pad(date.getSeconds());
2005
1834
  },
2006
1835
 
2007
1836
  // unix timestamp
@@ -2020,7 +1849,7 @@ Flatpickr.prototype = {
2020
1849
 
2021
1850
  // day in month, padded (01-30)
2022
1851
  d: function d(date) {
2023
- return Flatpickr.prototype.pad(date.getDate());
1852
+ return FlatpickrInstance.prototype.pad(date.getDate());
2024
1853
  },
2025
1854
 
2026
1855
  // hour from 1-12 (am/pm)
@@ -2030,7 +1859,7 @@ Flatpickr.prototype = {
2030
1859
 
2031
1860
  // minutes, padded with leading zero e.g. 09
2032
1861
  i: function i(date) {
2033
- return Flatpickr.prototype.pad(date.getMinutes());
1862
+ return FlatpickrInstance.prototype.pad(date.getMinutes());
2034
1863
  },
2035
1864
 
2036
1865
  // day in month (1-30)
@@ -2045,7 +1874,7 @@ Flatpickr.prototype = {
2045
1874
 
2046
1875
  // padded month number (01-12)
2047
1876
  m: function m(date) {
2048
- return Flatpickr.prototype.pad(date.getMonth() + 1);
1877
+ return FlatpickrInstance.prototype.pad(date.getMonth() + 1);
2049
1878
  },
2050
1879
 
2051
1880
  // the month number (1-12)
@@ -2160,7 +1989,7 @@ Flatpickr.prototype = {
2160
1989
  G: "(\\d\\d|\\d)",
2161
1990
  H: "(\\d\\d|\\d)",
2162
1991
  J: "(\\d\\d|\\d)\\w+",
2163
- K: "(\\w+)",
1992
+ K: "(am|AM|Am|aM|pm|PM|Pm|pM)",
2164
1993
  M: "(\\w+)",
2165
1994
  S: "(\\d\\d|\\d)",
2166
1995
  U: "(.+)",
@@ -2191,45 +2020,44 @@ Flatpickr.prototype = {
2191
2020
  * @return {Date} the parsed Date object
2192
2021
  */
2193
2022
  parseDate: function parseDate(date, givenFormat, timeless) {
2194
- if (!date) return null;
2023
+ if (date !== 0 && !date) return null;
2195
2024
 
2196
2025
  var date_orig = date;
2197
2026
 
2198
- if (date instanceof Date) {
2199
- date = new Date(date.getTime()); // create a copy
2200
- date.fp_isUTC = date_orig.fp_isUTC;
2201
- } else if (date.toFixed !== undefined) // timestamp
2202
- date = new Date(date);else {
2203
- // date string
2204
- var format = givenFormat || (this.config || Flatpickr.defaultConfig).dateFormat;
2205
- date = String(date).trim();
2206
-
2207
- if (date === "today") {
2208
- date = new Date();
2209
- timeless = true;
2210
- } else if (/Z$/.test(date) || /GMT$/.test(date)) // datestrings w/ timezone
2211
- date = new Date(date);else if (this.config && this.config.parseDate) date = this.config.parseDate(date, format);else {
2212
- var parsedDate = !this.config || !this.config.noCalendar ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0) : new Date(new Date().setHours(0, 0, 0, 0));
2213
-
2214
- var matched = void 0;
2215
-
2216
- for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
2217
- var token = format[i];
2218
- var isBackSlash = token === "\\";
2219
- var escaped = format[i - 1] === "\\" || isBackSlash;
2220
-
2221
- if (this.tokenRegex[token] && !escaped) {
2222
- regexStr += this.tokenRegex[token];
2223
- var match = new RegExp(regexStr).exec(date);
2224
- if (match && (matched = true)) {
2225
- parsedDate = this.revFormat[token](parsedDate, match[++matchIndex]) || parsedDate;
2226
- }
2227
- } else if (!isBackSlash) regexStr += "."; // don't really care
2228
- }
2027
+ if (date instanceof Date) date = new Date(date.getTime()); // create a copy
2028
+
2029
+ else if (date.toFixed !== undefined) // timestamp
2030
+ date = new Date(date);else {
2031
+ // date string
2032
+ var format = givenFormat || (this.config || flatpickr.defaultConfig).dateFormat;
2033
+ date = String(date).trim();
2034
+
2035
+ if (date === "today") {
2036
+ date = new Date();
2037
+ timeless = true;
2038
+ } else if (/Z$/.test(date) || /GMT$/.test(date)) // datestrings w/ timezone
2039
+ date = new Date(date);else if (this.config && this.config.parseDate) date = this.config.parseDate(date, format);else {
2040
+ var parsedDate = !this.config || !this.config.noCalendar ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0) : new Date(new Date().setHours(0, 0, 0, 0));
2041
+
2042
+ var matched = void 0;
2043
+
2044
+ for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
2045
+ var token = format[i];
2046
+ var isBackSlash = token === "\\";
2047
+ var escaped = format[i - 1] === "\\" || isBackSlash;
2048
+
2049
+ if (this.tokenRegex[token] && !escaped) {
2050
+ regexStr += this.tokenRegex[token];
2051
+ var match = new RegExp(regexStr).exec(date);
2052
+ if (match && (matched = true)) {
2053
+ parsedDate = this.revFormat[token](parsedDate, match[++matchIndex]) || parsedDate;
2054
+ }
2055
+ } else if (!isBackSlash) regexStr += "."; // don't really care
2056
+ }
2229
2057
 
2230
- date = matched ? parsedDate : null;
2058
+ date = matched ? parsedDate : null;
2059
+ }
2231
2060
  }
2232
- }
2233
2061
 
2234
2062
  /* istanbul ignore next */
2235
2063
  if (!(date instanceof Date)) {
@@ -2238,8 +2066,6 @@ Flatpickr.prototype = {
2238
2066
  return null;
2239
2067
  }
2240
2068
 
2241
- if (this.config && this.config.utc && !date.fp_isUTC) date = date.fp_toUTC();
2242
-
2243
2069
  if (timeless === true) date.setHours(0, 0, 0, 0);
2244
2070
 
2245
2071
  return date;
@@ -2252,7 +2078,14 @@ function _flatpickr(nodeList, config) {
2252
2078
  var instances = [];
2253
2079
  for (var i = 0; i < nodes.length; i++) {
2254
2080
  try {
2255
- nodes[i]._flatpickr = new Flatpickr(nodes[i], config || {});
2081
+ if (nodes[i].getAttribute("data-fp-omit") !== null) continue;
2082
+
2083
+ if (nodes[i]._flatpickr) {
2084
+ nodes[i]._flatpickr.destroy();
2085
+ nodes[i]._flatpickr = null;
2086
+ }
2087
+
2088
+ nodes[i]._flatpickr = new FlatpickrInstance(nodes[i], config || {});
2256
2089
  instances.push(nodes[i]._flatpickr);
2257
2090
  } catch (e) {
2258
2091
  console.warn(e, e.stack);
@@ -2276,9 +2109,208 @@ if (typeof HTMLElement !== "undefined") {
2276
2109
 
2277
2110
  /* istanbul ignore next */
2278
2111
  function flatpickr(selector, config) {
2279
- return _flatpickr(window.document.querySelectorAll(selector), config);
2112
+ if (selector instanceof NodeList) return _flatpickr(selector, config);else if (!(selector instanceof HTMLElement)) return _flatpickr(window.document.querySelectorAll(selector), config);
2113
+
2114
+ return _flatpickr([selector], config);
2280
2115
  }
2281
2116
 
2117
+ /* istanbul ignore next */
2118
+ flatpickr.defaultConfig = FlatpickrInstance.defaultConfig = {
2119
+ mode: "single",
2120
+
2121
+ position: "auto",
2122
+
2123
+ animate: window.navigator.userAgent.indexOf("MSIE") === -1,
2124
+
2125
+ // wrap: see https://chmln.github.io/flatpickr/examples/#flatpickr-external-elements
2126
+ wrap: false,
2127
+
2128
+ // enables week numbers
2129
+ weekNumbers: false,
2130
+
2131
+ // allow manual datetime input
2132
+ allowInput: false,
2133
+
2134
+ /*
2135
+ clicking on input opens the date(time)picker.
2136
+ disable if you wish to open the calendar manually with .open()
2137
+ */
2138
+ clickOpens: true,
2139
+
2140
+ /*
2141
+ closes calendar after date selection,
2142
+ unless 'mode' is 'multiple' or enableTime is true
2143
+ */
2144
+ closeOnSelect: true,
2145
+
2146
+ // display time picker in 24 hour mode
2147
+ time_24hr: false,
2148
+
2149
+ // enables the time picker functionality
2150
+ enableTime: false,
2151
+
2152
+ // noCalendar: true will hide the calendar. use for a time picker along w/ enableTime
2153
+ noCalendar: false,
2154
+
2155
+ // more date format chars at https://chmln.github.io/flatpickr/#dateformat
2156
+ dateFormat: "Y-m-d",
2157
+
2158
+ // date format used in aria-label for days
2159
+ ariaDateFormat: "F j, Y",
2160
+
2161
+ // altInput - see https://chmln.github.io/flatpickr/#altinput
2162
+ altInput: false,
2163
+
2164
+ // the created altInput element will have this class.
2165
+ altInputClass: "form-control input",
2166
+
2167
+ // same as dateFormat, but for altInput
2168
+ altFormat: "F j, Y", // defaults to e.g. June 10, 2016
2169
+
2170
+ // defaultDate - either a datestring or a date object. used for datetimepicker"s initial value
2171
+ defaultDate: null,
2172
+
2173
+ // the minimum date that user can pick (inclusive)
2174
+ minDate: null,
2175
+
2176
+ // the maximum date that user can pick (inclusive)
2177
+ maxDate: null,
2178
+
2179
+ // dateparser that transforms a given string to a date object
2180
+ parseDate: null,
2181
+
2182
+ // dateformatter that transforms a given date object to a string, according to passed format
2183
+ formatDate: null,
2184
+
2185
+ getWeek: function getWeek(givenDate) {
2186
+ var date = new Date(givenDate.getTime());
2187
+ var onejan = new Date(date.getFullYear(), 0, 1);
2188
+ return Math.ceil(((date - onejan) / 86400000 + onejan.getDay() + 1) / 7);
2189
+ },
2190
+
2191
+
2192
+ // see https://chmln.github.io/flatpickr/#disable
2193
+ enable: [],
2194
+
2195
+ // see https://chmln.github.io/flatpickr/#disable
2196
+ disable: [],
2197
+
2198
+ // display the short version of month names - e.g. Sep instead of September
2199
+ shorthandCurrentMonth: false,
2200
+
2201
+ // displays calendar inline. see https://chmln.github.io/flatpickr/#inline-calendar
2202
+ inline: false,
2203
+
2204
+ // position calendar inside wrapper and next to the input element
2205
+ // leave at false unless you know what you"re doing
2206
+ "static": false,
2207
+
2208
+ // DOM node to append the calendar to in *static* mode
2209
+ appendTo: null,
2210
+
2211
+ // code for previous/next icons. this is where you put your custom icon code e.g. fontawesome
2212
+ 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>",
2213
+ 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>",
2214
+
2215
+ // enables seconds in the time picker
2216
+ enableSeconds: false,
2217
+
2218
+ // step size used when scrolling/incrementing the hour element
2219
+ hourIncrement: 1,
2220
+
2221
+ // step size used when scrolling/incrementing the minute element
2222
+ minuteIncrement: 5,
2223
+
2224
+ // initial value in the hour element
2225
+ defaultHour: 12,
2226
+
2227
+ // initial value in the minute element
2228
+ defaultMinute: 0,
2229
+
2230
+ // disable native mobile datetime input support
2231
+ disableMobile: false,
2232
+
2233
+ // default locale
2234
+ locale: "default",
2235
+
2236
+ plugins: [],
2237
+
2238
+ ignoredFocusElements: [],
2239
+
2240
+ // called every time calendar is closed
2241
+ onClose: undefined, // function (dateObj, dateStr) {}
2242
+
2243
+ // onChange callback when user selects a date or time
2244
+ onChange: undefined, // function (dateObj, dateStr) {}
2245
+
2246
+ // called for every day element
2247
+ onDayCreate: undefined,
2248
+
2249
+ // called every time the month is changed
2250
+ onMonthChange: undefined,
2251
+
2252
+ // called every time calendar is opened
2253
+ onOpen: undefined, // function (dateObj, dateStr) {}
2254
+
2255
+ // called after the configuration has been parsed
2256
+ onParseConfig: undefined,
2257
+
2258
+ // called after calendar is ready
2259
+ onReady: undefined, // function (dateObj, dateStr) {}
2260
+
2261
+ // called after input value updated
2262
+ onValueUpdate: undefined,
2263
+
2264
+ // called every time the year is changed
2265
+ onYearChange: undefined,
2266
+
2267
+ onKeyDown: undefined,
2268
+
2269
+ onDestroy: undefined
2270
+ };
2271
+
2272
+ /* istanbul ignore next */
2273
+ flatpickr.l10ns = {
2274
+ en: {
2275
+ weekdays: {
2276
+ shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
2277
+ longhand: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
2278
+ },
2279
+ months: {
2280
+ shorthand: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
2281
+ longhand: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
2282
+ },
2283
+ daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
2284
+ firstDayOfWeek: 0,
2285
+ ordinal: function ordinal(nth) {
2286
+ var s = nth % 100;
2287
+ if (s > 3 && s < 21) return "th";
2288
+ switch (s % 10) {
2289
+ case 1:
2290
+ return "st";
2291
+ case 2:
2292
+ return "nd";
2293
+ case 3:
2294
+ return "rd";
2295
+ default:
2296
+ return "th";
2297
+ }
2298
+ },
2299
+ rangeSeparator: " to ",
2300
+ weekAbbreviation: "Wk",
2301
+ scrollTitle: "Scroll to increment",
2302
+ toggleTitle: "Click to toggle"
2303
+ }
2304
+ };
2305
+
2306
+ flatpickr.l10ns.default = Object.create(flatpickr.l10ns.en);
2307
+ flatpickr.localize = function (l10n) {
2308
+ return _extends(flatpickr.l10ns.default, l10n || {});
2309
+ };
2310
+ flatpickr.setDefaults = function (config) {
2311
+ return _extends(flatpickr.defaultConfig, config || {});
2312
+ };
2313
+
2282
2314
  /* istanbul ignore next */
2283
2315
  if (typeof jQuery !== "undefined") {
2284
2316
  jQuery.fn.flatpickr = function (config) {
@@ -2290,12 +2322,4 @@ Date.prototype.fp_incr = function (days) {
2290
2322
  return new Date(this.getFullYear(), this.getMonth(), this.getDate() + parseInt(days, 10));
2291
2323
  };
2292
2324
 
2293
- Date.prototype.fp_isUTC = false;
2294
- Date.prototype.fp_toUTC = function () {
2295
- var newDate = new Date(this.getUTCFullYear(), this.getUTCMonth(), this.getUTCDate(), this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds());
2296
-
2297
- newDate.fp_isUTC = true;
2298
- return newDate;
2299
- };
2300
-
2301
- if (typeof module !== "undefined") module.exports = Flatpickr;
2325
+ if (typeof module !== "undefined") module.exports = flatpickr;