flatpickr 4.5.7.0 → 4.6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/flatpickr.gemspec +2 -2
- data/lib/flatpickr/version.rb +1 -1
- data/vendor/assets/javascripts/flatpickr.js +201 -95
- data/vendor/assets/javascripts/flatpickr/l10n/ar.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/az.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/be.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/bg.js +3 -1
- data/vendor/assets/javascripts/flatpickr/l10n/bs.js +66 -0
- data/vendor/assets/javascripts/flatpickr/l10n/cat.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/cs.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/cy.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/da.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/de.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/default.js +5 -2
- data/vendor/assets/javascripts/flatpickr/l10n/eo.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/es.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/et.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/fi.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/fo.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/fr.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/ga.js +66 -0
- data/vendor/assets/javascripts/flatpickr/l10n/he.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/hr.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/hu.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/id.js +3 -1
- data/vendor/assets/javascripts/flatpickr/l10n/index.js +365 -193
- data/vendor/assets/javascripts/flatpickr/l10n/is.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/it.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/ja.js +4 -1
- data/vendor/assets/javascripts/flatpickr/l10n/ka.js +75 -0
- data/vendor/assets/javascripts/flatpickr/l10n/km.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/ko.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/lt.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/lv.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/mk.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/mn.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/my.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/nl.js +1 -0
- data/vendor/assets/javascripts/flatpickr/l10n/no.js +1 -0
- data/vendor/assets/javascripts/flatpickr/l10n/pa.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/pl.js +3 -2
- data/vendor/assets/javascripts/flatpickr/l10n/pt.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/ro.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/ru.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/si.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/sk.js +1 -0
- data/vendor/assets/javascripts/flatpickr/l10n/sl.js +1 -0
- data/vendor/assets/javascripts/flatpickr/l10n/sq.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/sr.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/sv.js +1 -0
- data/vendor/assets/javascripts/flatpickr/l10n/th.js +1 -0
- data/vendor/assets/javascripts/flatpickr/l10n/tr.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/uk.js +2 -1
- data/vendor/assets/javascripts/flatpickr/l10n/vn.js +2 -1
- data/vendor/assets/javascripts/flatpickr/plugins/confirmDate/confirmDate.js +15 -5
- data/vendor/assets/javascripts/flatpickr/plugins/labelPlugin/labelPlugin.js +1 -0
- data/vendor/assets/javascripts/flatpickr/plugins/minMaxTimePlugin.js +6 -1
- data/vendor/assets/javascripts/flatpickr/plugins/monthSelect/index.js +203 -0
- data/vendor/assets/javascripts/flatpickr/plugins/rangePlugin.js +11 -7
- data/vendor/assets/javascripts/flatpickr/plugins/scrollPlugin.js +1 -0
- data/vendor/assets/javascripts/flatpickr/plugins/weekSelect/weekSelect.js +9 -3
- data/vendor/assets/stylesheets/flatpickr.css +46 -14
- data/vendor/assets/stylesheets/flatpickr/plugins/monthSelect/style.css +79 -0
- data/vendor/assets/stylesheets/flatpickr/themes/airbnb.css +56 -14
- data/vendor/assets/stylesheets/flatpickr/themes/confetti.css +46 -14
- data/vendor/assets/stylesheets/flatpickr/themes/dark.css +48 -16
- data/vendor/assets/stylesheets/flatpickr/themes/light.css +46 -14
- data/vendor/assets/stylesheets/flatpickr/themes/material_blue.css +46 -14
- data/vendor/assets/stylesheets/flatpickr/themes/material_green.css +46 -14
- data/vendor/assets/stylesheets/flatpickr/themes/material_orange.css +46 -14
- data/vendor/assets/stylesheets/flatpickr/themes/material_red.css +46 -14
- metadata +12 -9
- data/vendor/assets/javascripts/flatpickr/plugins/monthSelect/monthSelect.js +0 -77
- data/vendor/assets/stylesheets/flatpickr/plugins/monthSelect/monthSelect.css +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54db0dff44f0812d623806c212203dab01c33e084f4c6d25b2389ad30569dc28
|
4
|
+
data.tar.gz: 21d6b70c91d7f9a791072c79642872a290b7e58e8c8fd6bed7acacf62495b53f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a810c005069dd25bd33d5a914e18f6a43e4e9ff4dbd51cf3b23f848b780065aee4b7347ae6762e9bcbcafb6c5ef1e74edc277702d449c591e9a4c19283affd4a
|
7
|
+
data.tar.gz: 9c984be6739a8058aaf3883f98b49531ae5339903d52dba74cb91569c758ee662f0d6e3cbd84e93d4ac2bececd2399c2cab3fe7e9d28d208312a319f57ac64fe
|
data/flatpickr.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.add_development_dependency 'bundler', '~>
|
24
|
-
spec.add_development_dependency 'rake', '~>
|
23
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
24
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
25
25
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
26
|
end
|
data/lib/flatpickr/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* flatpickr v4.
|
1
|
+
/* flatpickr v4.6.2, @license MIT */
|
2
2
|
(function (global, factory) {
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
@@ -90,6 +90,7 @@
|
|
90
90
|
locale: "default",
|
91
91
|
minuteIncrement: 5,
|
92
92
|
mode: "single",
|
93
|
+
monthSelectorType: "dropdown",
|
93
94
|
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>",
|
94
95
|
noCalendar: false,
|
95
96
|
now: new Date(),
|
@@ -182,7 +183,10 @@
|
|
182
183
|
scrollTitle: "Scroll to increment",
|
183
184
|
toggleTitle: "Click to toggle",
|
184
185
|
amPM: ["AM", "PM"],
|
185
|
-
yearAriaLabel: "Year"
|
186
|
+
yearAriaLabel: "Year",
|
187
|
+
hourAriaLabel: "Hour",
|
188
|
+
minuteAriaLabel: "Minute",
|
189
|
+
time_24hr: false
|
186
190
|
};
|
187
191
|
|
188
192
|
var pad = function (number) { return ("0" + number).slice(-2); };
|
@@ -257,10 +261,10 @@
|
|
257
261
|
return event.target;
|
258
262
|
}
|
259
263
|
|
260
|
-
var
|
264
|
+
var doNothing = function () { return undefined; };
|
261
265
|
var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
|
262
266
|
var revFormat = {
|
263
|
-
D:
|
267
|
+
D: doNothing,
|
264
268
|
F: function (dateObj, monthName, locale) {
|
265
269
|
dateObj.setMonth(locale.months.longhand.indexOf(monthName));
|
266
270
|
},
|
@@ -284,9 +288,11 @@
|
|
284
288
|
dateObj.setSeconds(parseFloat(seconds));
|
285
289
|
},
|
286
290
|
U: function (_, unixSeconds) { return new Date(parseFloat(unixSeconds) * 1000); },
|
287
|
-
W: function (dateObj, weekNum) {
|
291
|
+
W: function (dateObj, weekNum, locale) {
|
288
292
|
var weekNumber = parseInt(weekNum);
|
289
|
-
|
293
|
+
var date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
|
294
|
+
date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek);
|
295
|
+
return date;
|
290
296
|
},
|
291
297
|
Y: function (dateObj, year) {
|
292
298
|
dateObj.setFullYear(parseFloat(year));
|
@@ -304,7 +310,7 @@
|
|
304
310
|
j: function (dateObj, day) {
|
305
311
|
dateObj.setDate(parseFloat(day));
|
306
312
|
},
|
307
|
-
l:
|
313
|
+
l: doNothing,
|
308
314
|
m: function (dateObj, month) {
|
309
315
|
dateObj.setMonth(parseFloat(month) - 1);
|
310
316
|
},
|
@@ -317,7 +323,7 @@
|
|
317
323
|
u: function (_, unixMillSeconds) {
|
318
324
|
return new Date(parseFloat(unixMillSeconds));
|
319
325
|
},
|
320
|
-
w:
|
326
|
+
w: doNothing,
|
321
327
|
y: function (dateObj, year) {
|
322
328
|
dateObj.setFullYear(2000 + parseFloat(year));
|
323
329
|
}
|
@@ -437,7 +443,7 @@
|
|
437
443
|
return undefined;
|
438
444
|
var locale = customLocale || l10n;
|
439
445
|
var parsedDate;
|
440
|
-
var
|
446
|
+
var dateOrig = date;
|
441
447
|
if (date instanceof Date)
|
442
448
|
parsedDate = new Date(date.getTime());
|
443
449
|
else if (typeof date !== "string" &&
|
@@ -491,7 +497,7 @@
|
|
491
497
|
}
|
492
498
|
/* istanbul ignore next */
|
493
499
|
if (!(parsedDate instanceof Date && !isNaN(parsedDate.getTime()))) {
|
494
|
-
config.errorHandler(new Error("Invalid date provided: " +
|
500
|
+
config.errorHandler(new Error("Invalid date provided: " + dateOrig));
|
495
501
|
return undefined;
|
496
502
|
}
|
497
503
|
if (timeless === true)
|
@@ -542,11 +548,13 @@
|
|
542
548
|
var DEBOUNCED_CHANGE_MS = 300;
|
543
549
|
function FlatpickrInstance(element, instanceConfig) {
|
544
550
|
var self = {
|
545
|
-
config: __assign({}, flatpickr.defaultConfig),
|
551
|
+
config: __assign({}, defaults, flatpickr.defaultConfig),
|
546
552
|
l10n: english
|
547
553
|
};
|
548
554
|
self.parseDate = createDateParser({ config: self.config, l10n: self.l10n });
|
549
555
|
self._handlers = [];
|
556
|
+
self.pluginElements = [];
|
557
|
+
self.loadedPlugins = [];
|
550
558
|
self._bind = bind;
|
551
559
|
self._setHoursFromDate = setHoursFromDate;
|
552
560
|
self._positionCalendar = positionCalendar;
|
@@ -726,21 +734,21 @@
|
|
726
734
|
var minutes = self.config.defaultMinute;
|
727
735
|
var seconds = self.config.defaultSeconds;
|
728
736
|
if (self.config.minDate !== undefined) {
|
729
|
-
var
|
730
|
-
var
|
731
|
-
hours = Math.max(hours,
|
732
|
-
if (hours ===
|
733
|
-
minutes = Math.max(
|
734
|
-
if (hours ===
|
737
|
+
var minHr = self.config.minDate.getHours();
|
738
|
+
var minMinutes = self.config.minDate.getMinutes();
|
739
|
+
hours = Math.max(hours, minHr);
|
740
|
+
if (hours === minHr)
|
741
|
+
minutes = Math.max(minMinutes, minutes);
|
742
|
+
if (hours === minHr && minutes === minMinutes)
|
735
743
|
seconds = self.config.minDate.getSeconds();
|
736
744
|
}
|
737
745
|
if (self.config.maxDate !== undefined) {
|
738
|
-
var
|
739
|
-
var
|
740
|
-
hours = Math.min(hours,
|
741
|
-
if (hours ===
|
742
|
-
minutes = Math.min(
|
743
|
-
if (hours ===
|
746
|
+
var maxHr = self.config.maxDate.getHours();
|
747
|
+
var maxMinutes = self.config.maxDate.getMinutes();
|
748
|
+
hours = Math.min(hours, maxHr);
|
749
|
+
if (hours === maxHr)
|
750
|
+
minutes = Math.min(maxMinutes, minutes);
|
751
|
+
if (hours === maxHr && minutes === maxMinutes)
|
744
752
|
seconds = self.config.maxDate.getSeconds();
|
745
753
|
}
|
746
754
|
setHours(hours, minutes, seconds);
|
@@ -837,12 +845,10 @@
|
|
837
845
|
onMouseOver(e.target);
|
838
846
|
});
|
839
847
|
bind(window.document.body, "keydown", onKeyDown);
|
840
|
-
if (!self.config.static)
|
841
|
-
bind(self._input, "keydown", onKeyDown);
|
842
848
|
if (!self.config.inline && !self.config.static)
|
843
849
|
bind(window, "resize", debouncedResize);
|
844
850
|
if (window.ontouchstart !== undefined)
|
845
|
-
bind(window.document, "
|
851
|
+
bind(window.document, "touchstart", documentClick);
|
846
852
|
else
|
847
853
|
bind(window.document, "mousedown", onClick(documentClick));
|
848
854
|
bind(window.document, "focus", documentClick, { capture: true });
|
@@ -878,8 +884,9 @@
|
|
878
884
|
/**
|
879
885
|
* Set the calendar view to a particular date.
|
880
886
|
* @param {Date} jumpDate the date to set the view to
|
887
|
+
* @param {boolean} triggerChange if change events should be triggered
|
881
888
|
*/
|
882
|
-
function jumpToDate(jumpDate) {
|
889
|
+
function jumpToDate(jumpDate, triggerChange) {
|
883
890
|
var jumpTo = jumpDate !== undefined
|
884
891
|
? self.parseDate(jumpDate)
|
885
892
|
: self.latestSelectedDateObj ||
|
@@ -888,6 +895,8 @@
|
|
888
895
|
: self.config.maxDate && self.config.maxDate < self.now
|
889
896
|
? self.config.maxDate
|
890
897
|
: self.now);
|
898
|
+
var oldYear = self.currentYear;
|
899
|
+
var oldMonth = self.currentMonth;
|
891
900
|
try {
|
892
901
|
if (jumpTo !== undefined) {
|
893
902
|
self.currentYear = jumpTo.getFullYear();
|
@@ -899,6 +908,14 @@
|
|
899
908
|
e.message = "Invalid date supplied: " + jumpTo;
|
900
909
|
self.config.errorHandler(e);
|
901
910
|
}
|
911
|
+
if (triggerChange && self.currentYear !== oldYear) {
|
912
|
+
triggerEvent("onYearChange");
|
913
|
+
buildMonthSwitch();
|
914
|
+
}
|
915
|
+
if (triggerChange &&
|
916
|
+
(self.currentYear !== oldYear || self.currentMonth !== oldMonth)) {
|
917
|
+
triggerEvent("onMonthChange");
|
918
|
+
}
|
902
919
|
self.redraw();
|
903
920
|
}
|
904
921
|
/**
|
@@ -1009,7 +1026,7 @@
|
|
1009
1026
|
}
|
1010
1027
|
}
|
1011
1028
|
else {
|
1012
|
-
dayElement.classList.add("disabled");
|
1029
|
+
dayElement.classList.add("flatpickr-disabled");
|
1013
1030
|
}
|
1014
1031
|
if (self.config.mode === "range") {
|
1015
1032
|
if (isDateInRange(date) && !isDateSelected(date))
|
@@ -1130,10 +1147,54 @@
|
|
1130
1147
|
onMouseOver();
|
1131
1148
|
}
|
1132
1149
|
}
|
1150
|
+
function buildMonthSwitch() {
|
1151
|
+
if (self.config.showMonths > 1 ||
|
1152
|
+
self.config.monthSelectorType !== "dropdown")
|
1153
|
+
return;
|
1154
|
+
var shouldBuildMonth = function (month) {
|
1155
|
+
if (self.config.minDate !== undefined &&
|
1156
|
+
self.currentYear === self.config.minDate.getFullYear() &&
|
1157
|
+
month < self.config.minDate.getMonth()) {
|
1158
|
+
return false;
|
1159
|
+
}
|
1160
|
+
return !(self.config.maxDate !== undefined &&
|
1161
|
+
self.currentYear === self.config.maxDate.getFullYear() &&
|
1162
|
+
month > self.config.maxDate.getMonth());
|
1163
|
+
};
|
1164
|
+
self.monthsDropdownContainer.tabIndex = -1;
|
1165
|
+
self.monthsDropdownContainer.innerHTML = "";
|
1166
|
+
for (var i = 0; i < 12; i++) {
|
1167
|
+
if (!shouldBuildMonth(i))
|
1168
|
+
continue;
|
1169
|
+
var month = createElement("option", "flatpickr-monthDropdown-month");
|
1170
|
+
month.value = new Date(self.currentYear, i).getMonth().toString();
|
1171
|
+
month.textContent = monthToStr(i, self.config.shorthandCurrentMonth, self.l10n);
|
1172
|
+
month.tabIndex = -1;
|
1173
|
+
if (self.currentMonth === i) {
|
1174
|
+
month.selected = true;
|
1175
|
+
}
|
1176
|
+
self.monthsDropdownContainer.appendChild(month);
|
1177
|
+
}
|
1178
|
+
}
|
1133
1179
|
function buildMonth() {
|
1134
1180
|
var container = createElement("div", "flatpickr-month");
|
1135
1181
|
var monthNavFragment = window.document.createDocumentFragment();
|
1136
|
-
var monthElement
|
1182
|
+
var monthElement;
|
1183
|
+
if (self.config.showMonths > 1 ||
|
1184
|
+
self.config.monthSelectorType === "static") {
|
1185
|
+
monthElement = createElement("span", "cur-month");
|
1186
|
+
}
|
1187
|
+
else {
|
1188
|
+
self.monthsDropdownContainer = createElement("select", "flatpickr-monthDropdown-months");
|
1189
|
+
bind(self.monthsDropdownContainer, "change", function (e) {
|
1190
|
+
var target = e.target;
|
1191
|
+
var selectedMonth = parseInt(target.value, 10);
|
1192
|
+
self.changeMonth(selectedMonth - self.currentMonth);
|
1193
|
+
triggerEvent("onMonthChange");
|
1194
|
+
});
|
1195
|
+
buildMonthSwitch();
|
1196
|
+
monthElement = self.monthsDropdownContainer;
|
1197
|
+
}
|
1137
1198
|
var yearInput = createNumberInput("cur-year", { tabindex: "-1" });
|
1138
1199
|
var yearElement = yearInput.getElementsByTagName("input")[0];
|
1139
1200
|
yearElement.setAttribute("aria-label", self.l10n.yearAriaLabel);
|
@@ -1185,7 +1246,7 @@
|
|
1185
1246
|
get: function () { return self.__hidePrevMonthArrow; },
|
1186
1247
|
set: function (bool) {
|
1187
1248
|
if (self.__hidePrevMonthArrow !== bool) {
|
1188
|
-
toggleClass(self.prevMonthNav, "disabled", bool);
|
1249
|
+
toggleClass(self.prevMonthNav, "flatpickr-disabled", bool);
|
1189
1250
|
self.__hidePrevMonthArrow = bool;
|
1190
1251
|
}
|
1191
1252
|
}
|
@@ -1194,7 +1255,7 @@
|
|
1194
1255
|
get: function () { return self.__hideNextMonthArrow; },
|
1195
1256
|
set: function (bool) {
|
1196
1257
|
if (self.__hideNextMonthArrow !== bool) {
|
1197
|
-
toggleClass(self.nextMonthNav, "disabled", bool);
|
1258
|
+
toggleClass(self.nextMonthNav, "flatpickr-disabled", bool);
|
1198
1259
|
self.__hideNextMonthArrow = bool;
|
1199
1260
|
}
|
1200
1261
|
}
|
@@ -1210,9 +1271,13 @@
|
|
1210
1271
|
self.timeContainer = createElement("div", "flatpickr-time");
|
1211
1272
|
self.timeContainer.tabIndex = -1;
|
1212
1273
|
var separator = createElement("span", "flatpickr-time-separator", ":");
|
1213
|
-
var hourInput = createNumberInput("flatpickr-hour"
|
1274
|
+
var hourInput = createNumberInput("flatpickr-hour", {
|
1275
|
+
"aria-label": self.l10n.hourAriaLabel
|
1276
|
+
});
|
1214
1277
|
self.hourElement = hourInput.getElementsByTagName("input")[0];
|
1215
|
-
var minuteInput = createNumberInput("flatpickr-minute"
|
1278
|
+
var minuteInput = createNumberInput("flatpickr-minute", {
|
1279
|
+
"aria-label": self.l10n.minuteAriaLabel
|
1280
|
+
});
|
1216
1281
|
self.minuteElement = minuteInput.getElementsByTagName("input")[0];
|
1217
1282
|
self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
|
1218
1283
|
self.hourElement.value = pad(self.latestSelectedDateObj
|
@@ -1271,6 +1336,9 @@
|
|
1271
1336
|
return self.weekdayContainer;
|
1272
1337
|
}
|
1273
1338
|
function updateWeekdays() {
|
1339
|
+
if (!self.weekdayContainer) {
|
1340
|
+
return;
|
1341
|
+
}
|
1274
1342
|
var firstDayOfWeek = self.l10n.firstDayOfWeek;
|
1275
1343
|
var weekdays = self.l10n.weekdays.shorthand.slice();
|
1276
1344
|
if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
|
@@ -1292,9 +1360,9 @@
|
|
1292
1360
|
weekNumbers: weekNumbers
|
1293
1361
|
};
|
1294
1362
|
}
|
1295
|
-
function changeMonth(value,
|
1296
|
-
if (
|
1297
|
-
var delta =
|
1363
|
+
function changeMonth(value, isOffset) {
|
1364
|
+
if (isOffset === void 0) { isOffset = true; }
|
1365
|
+
var delta = isOffset ? value : value - self.currentMonth;
|
1298
1366
|
if ((delta < 0 && self._hidePrevMonthArrow === true) ||
|
1299
1367
|
(delta > 0 && self._hideNextMonthArrow === true))
|
1300
1368
|
return;
|
@@ -1303,6 +1371,7 @@
|
|
1303
1371
|
self.currentYear += self.currentMonth > 11 ? 1 : -1;
|
1304
1372
|
self.currentMonth = (self.currentMonth + 12) % 12;
|
1305
1373
|
triggerEvent("onYearChange");
|
1374
|
+
buildMonthSwitch();
|
1306
1375
|
}
|
1307
1376
|
buildDays();
|
1308
1377
|
triggerEvent("onMonthChange");
|
@@ -1405,6 +1474,7 @@
|
|
1405
1474
|
"weekdayContainer",
|
1406
1475
|
"prevMonthNav",
|
1407
1476
|
"nextMonthNav",
|
1477
|
+
"monthsDropdownContainer",
|
1408
1478
|
"currentMonthElement",
|
1409
1479
|
"currentYearElement",
|
1410
1480
|
"navigationCurrentMonth",
|
@@ -1446,6 +1516,11 @@
|
|
1446
1516
|
return elem.contains(eventTarget_1);
|
1447
1517
|
});
|
1448
1518
|
if (lostFocus && isIgnored) {
|
1519
|
+
if (self.timeContainer !== undefined &&
|
1520
|
+
self.minuteElement !== undefined &&
|
1521
|
+
self.hourElement !== undefined) {
|
1522
|
+
updateTime();
|
1523
|
+
}
|
1449
1524
|
self.close();
|
1450
1525
|
if (self.config.mode === "range" && self.selectedDates.length === 1) {
|
1451
1526
|
self.clear(false);
|
@@ -1472,6 +1547,7 @@
|
|
1472
1547
|
if (isNewYear) {
|
1473
1548
|
self.redraw();
|
1474
1549
|
triggerEvent("onYearChange");
|
1550
|
+
buildMonthSwitch();
|
1475
1551
|
}
|
1476
1552
|
}
|
1477
1553
|
function isEnabled(date, timeless) {
|
@@ -1547,8 +1623,9 @@
|
|
1547
1623
|
: self.config.dateFormat);
|
1548
1624
|
return e.target.blur();
|
1549
1625
|
}
|
1550
|
-
else
|
1626
|
+
else {
|
1551
1627
|
self.open();
|
1628
|
+
}
|
1552
1629
|
}
|
1553
1630
|
else if (isCalendarElem(e.target) ||
|
1554
1631
|
allowKeydown ||
|
@@ -1558,6 +1635,7 @@
|
|
1558
1635
|
switch (e.keyCode) {
|
1559
1636
|
case 13:
|
1560
1637
|
if (isTimeObj) {
|
1638
|
+
e.preventDefault();
|
1561
1639
|
updateTime();
|
1562
1640
|
focusAndClose();
|
1563
1641
|
}
|
@@ -1577,7 +1655,7 @@
|
|
1577
1655
|
break;
|
1578
1656
|
case 37:
|
1579
1657
|
case 39:
|
1580
|
-
if (!isTimeObj) {
|
1658
|
+
if (!isTimeObj && !isInput) {
|
1581
1659
|
e.preventDefault();
|
1582
1660
|
if (self.daysContainer !== undefined &&
|
1583
1661
|
(allowInput === false ||
|
@@ -1600,7 +1678,8 @@
|
|
1600
1678
|
e.preventDefault();
|
1601
1679
|
var delta = e.keyCode === 40 ? 1 : -1;
|
1602
1680
|
if ((self.daysContainer && e.target.$i !== undefined) ||
|
1603
|
-
e.target === self.input
|
1681
|
+
e.target === self.input ||
|
1682
|
+
e.target === self.altInput) {
|
1604
1683
|
if (e.ctrlKey) {
|
1605
1684
|
e.stopPropagation();
|
1606
1685
|
changeYear(self.currentYear - delta);
|
@@ -1609,6 +1688,9 @@
|
|
1609
1688
|
else if (!isTimeObj)
|
1610
1689
|
focusOnDay(undefined, delta * 7);
|
1611
1690
|
}
|
1691
|
+
else if (e.target === self.currentYearElement) {
|
1692
|
+
changeYear(self.currentYear - delta);
|
1693
|
+
}
|
1612
1694
|
else if (self.config.enableTime) {
|
1613
1695
|
if (!isTimeObj && self.hourElement)
|
1614
1696
|
self.hourElement.focus();
|
@@ -1623,20 +1705,23 @@
|
|
1623
1705
|
self.minuteElement,
|
1624
1706
|
self.secondElement,
|
1625
1707
|
self.amPM,
|
1626
|
-
]
|
1708
|
+
]
|
1709
|
+
.concat(self.pluginElements)
|
1710
|
+
.filter(function (x) { return x; });
|
1627
1711
|
var i = elems.indexOf(e.target);
|
1628
1712
|
if (i !== -1) {
|
1629
1713
|
var target = elems[i + (e.shiftKey ? -1 : 1)];
|
1630
|
-
|
1631
|
-
|
1632
|
-
target.focus();
|
1633
|
-
}
|
1634
|
-
else if (e.shiftKey) {
|
1635
|
-
e.preventDefault();
|
1636
|
-
self._input.focus();
|
1637
|
-
}
|
1714
|
+
e.preventDefault();
|
1715
|
+
(target || self._input).focus();
|
1638
1716
|
}
|
1639
1717
|
}
|
1718
|
+
else if (!self.config.noCalendar &&
|
1719
|
+
self.daysContainer &&
|
1720
|
+
self.daysContainer.contains(e.target) &&
|
1721
|
+
e.shiftKey) {
|
1722
|
+
e.preventDefault();
|
1723
|
+
self._input.focus();
|
1724
|
+
}
|
1640
1725
|
break;
|
1641
1726
|
default:
|
1642
1727
|
break;
|
@@ -1658,21 +1743,22 @@
|
|
1658
1743
|
break;
|
1659
1744
|
}
|
1660
1745
|
}
|
1661
|
-
|
1746
|
+
if (isInput || isCalendarElem(e.target)) {
|
1747
|
+
triggerEvent("onKeyDown", e);
|
1748
|
+
}
|
1662
1749
|
}
|
1663
1750
|
function onMouseOver(elem) {
|
1664
1751
|
if (self.selectedDates.length !== 1 ||
|
1665
1752
|
(elem &&
|
1666
1753
|
(!elem.classList.contains("flatpickr-day") ||
|
1667
|
-
elem.classList.contains("disabled"))))
|
1754
|
+
elem.classList.contains("flatpickr-disabled"))))
|
1668
1755
|
return;
|
1669
1756
|
var hoverDate = elem
|
1670
1757
|
? elem.dateObj.getTime()
|
1671
|
-
: 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())
|
1672
|
-
.lastChild.dateObj.getTime();
|
1758
|
+
: 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());
|
1673
1759
|
var containsDisabled = false;
|
1674
1760
|
var minRange = 0, maxRange = 0;
|
1675
|
-
for (var t = rangeStartDate; t <
|
1761
|
+
for (var t = rangeStartDate; t < rangeEndDate; t += duration.DAY) {
|
1676
1762
|
if (!isEnabled(new Date(t), true)) {
|
1677
1763
|
containsDisabled =
|
1678
1764
|
containsDisabled || (t > rangeStartDate && t < rangeEndDate);
|
@@ -1684,7 +1770,6 @@
|
|
1684
1770
|
}
|
1685
1771
|
for (var m = 0; m < self.config.showMonths; m++) {
|
1686
1772
|
var month = self.daysContainer.children[m];
|
1687
|
-
var prevMonth = self.daysContainer.children[m - 1];
|
1688
1773
|
var _loop_1 = function (i, l) {
|
1689
1774
|
var dayElem = month.children[i], date = dayElem.dateObj;
|
1690
1775
|
var timestamp = date.getTime();
|
@@ -1703,22 +1788,17 @@
|
|
1703
1788
|
dayElem.classList.remove(c);
|
1704
1789
|
});
|
1705
1790
|
if (elem !== undefined) {
|
1706
|
-
elem.classList.add(hoverDate
|
1791
|
+
elem.classList.add(hoverDate <= self.selectedDates[0].getTime()
|
1707
1792
|
? "startRange"
|
1708
1793
|
: "endRange");
|
1709
|
-
if (
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
if (timestamp >= minRange &&
|
1718
|
-
(maxRange === 0 || timestamp <= maxRange) &&
|
1719
|
-
isBetween(timestamp, initialDate, hoverDate))
|
1720
|
-
dayElem.classList.add("inRange");
|
1721
|
-
}
|
1794
|
+
if (initialDate < hoverDate && timestamp === initialDate)
|
1795
|
+
dayElem.classList.add("startRange");
|
1796
|
+
else if (initialDate > hoverDate && timestamp === initialDate)
|
1797
|
+
dayElem.classList.add("endRange");
|
1798
|
+
if (timestamp >= minRange &&
|
1799
|
+
(maxRange === 0 || timestamp <= maxRange) &&
|
1800
|
+
isBetween(timestamp, initialDate, hoverDate))
|
1801
|
+
dayElem.classList.add("inRange");
|
1722
1802
|
}
|
1723
1803
|
};
|
1724
1804
|
for (var i = 0, l = month.children.length; i < l; i++) {
|
@@ -1733,7 +1813,7 @@
|
|
1733
1813
|
function setDefaultTime() {
|
1734
1814
|
self.setDate(self.config.minDate !== undefined
|
1735
1815
|
? new Date(self.config.minDate.getTime())
|
1736
|
-
: new Date(),
|
1816
|
+
: new Date(), true);
|
1737
1817
|
setDefaultHours();
|
1738
1818
|
updateValue();
|
1739
1819
|
}
|
@@ -1818,7 +1898,7 @@
|
|
1818
1898
|
"disableMobile",
|
1819
1899
|
];
|
1820
1900
|
var userConfig = __assign({}, instanceConfig, JSON.parse(JSON.stringify(element.dataset || {})));
|
1821
|
-
var formats
|
1901
|
+
var formats = {};
|
1822
1902
|
self.config.parseDate = userConfig.parseDate;
|
1823
1903
|
self.config.formatDate = userConfig.formatDate;
|
1824
1904
|
Object.defineProperty(self.config, "enable", {
|
@@ -1835,21 +1915,24 @@
|
|
1835
1915
|
});
|
1836
1916
|
var timeMode = userConfig.mode === "time";
|
1837
1917
|
if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
|
1838
|
-
|
1918
|
+
var defaultDateFormat = flatpickr.defaultConfig.dateFormat || defaults.dateFormat;
|
1919
|
+
formats.dateFormat =
|
1839
1920
|
userConfig.noCalendar || timeMode
|
1840
1921
|
? "H:i" + (userConfig.enableSeconds ? ":S" : "")
|
1841
|
-
:
|
1842
|
-
" H:i" +
|
1843
|
-
(userConfig.enableSeconds ? ":S" : "");
|
1922
|
+
: defaultDateFormat + " H:i" + (userConfig.enableSeconds ? ":S" : "");
|
1844
1923
|
}
|
1845
1924
|
if (userConfig.altInput &&
|
1846
1925
|
(userConfig.enableTime || timeMode) &&
|
1847
1926
|
!userConfig.altFormat) {
|
1848
|
-
|
1927
|
+
var defaultAltFormat = flatpickr.defaultConfig.altFormat || defaults.altFormat;
|
1928
|
+
formats.altFormat =
|
1849
1929
|
userConfig.noCalendar || timeMode
|
1850
1930
|
? "h:i" + (userConfig.enableSeconds ? ":S K" : " K")
|
1851
|
-
:
|
1852
|
-
|
1931
|
+
: defaultAltFormat + (" h:i" + (userConfig.enableSeconds ? ":S" : "") + " K");
|
1932
|
+
}
|
1933
|
+
if (!userConfig.altInputClass) {
|
1934
|
+
self.config.altInputClass =
|
1935
|
+
self.input.className + " " + self.config.altInputClass;
|
1853
1936
|
}
|
1854
1937
|
Object.defineProperty(self.config, "minDate", {
|
1855
1938
|
get: function () { return self.config._minDate; },
|
@@ -1860,7 +1943,7 @@
|
|
1860
1943
|
set: minMaxDateSetter("max")
|
1861
1944
|
});
|
1862
1945
|
var minMaxTimeSetter = function (type) { return function (val) {
|
1863
|
-
self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i");
|
1946
|
+
self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i:S");
|
1864
1947
|
}; };
|
1865
1948
|
Object.defineProperty(self.config, "minTime", {
|
1866
1949
|
get: function () { return self.config._minTime; },
|
@@ -1874,7 +1957,7 @@
|
|
1874
1957
|
self.config.noCalendar = true;
|
1875
1958
|
self.config.enableTime = true;
|
1876
1959
|
}
|
1877
|
-
Object.assign(self.config, formats
|
1960
|
+
Object.assign(self.config, formats, userConfig);
|
1878
1961
|
for (var i = 0; i < boolOpts.length; i++)
|
1879
1962
|
self.config[boolOpts[i]] =
|
1880
1963
|
self.config[boolOpts[i]] === true ||
|
@@ -1914,6 +1997,11 @@
|
|
1914
1997
|
? flatpickr.l10ns[self.config.locale]
|
1915
1998
|
: undefined));
|
1916
1999
|
tokenRegex.K = "(" + self.l10n.amPM[0] + "|" + self.l10n.amPM[1] + "|" + self.l10n.amPM[0].toLowerCase() + "|" + self.l10n.amPM[1].toLowerCase() + ")";
|
2000
|
+
var userConfig = __assign({}, instanceConfig, JSON.parse(JSON.stringify(element.dataset || {})));
|
2001
|
+
if (userConfig.time_24hr === undefined &&
|
2002
|
+
flatpickr.defaultConfig.time_24hr === undefined) {
|
2003
|
+
self.config.time_24hr = self.l10n.time_24hr;
|
2004
|
+
}
|
1917
2005
|
self.formatDate = createDateFormatter(self);
|
1918
2006
|
self.parseDate = createDateParser({ config: self.config, l10n: self.l10n });
|
1919
2007
|
}
|
@@ -1938,7 +2026,7 @@
|
|
1938
2026
|
(configPosHorizontal != null && configPosHorizontal === "center"
|
1939
2027
|
? (calendarWidth - inputBounds.width) / 2
|
1940
2028
|
: 0);
|
1941
|
-
var right = window.document.body.offsetWidth - inputBounds.right;
|
2029
|
+
var right = window.document.body.offsetWidth - (window.pageXOffset + inputBounds.right);
|
1942
2030
|
var rightMost = left + calendarWidth > window.document.body.offsetWidth;
|
1943
2031
|
var centerMost = right + calendarWidth > window.document.body.offsetWidth;
|
1944
2032
|
toggleClass(self.calendarContainer, "rightMost", rightMost);
|
@@ -1994,7 +2082,7 @@
|
|
1994
2082
|
var isSelectable = function (day) {
|
1995
2083
|
return day.classList &&
|
1996
2084
|
day.classList.contains("flatpickr-day") &&
|
1997
|
-
!day.classList.contains("disabled") &&
|
2085
|
+
!day.classList.contains("flatpickr-disabled") &&
|
1998
2086
|
!day.classList.contains("notAllowed");
|
1999
2087
|
};
|
2000
2088
|
var t = findParent(e.target, isSelectable);
|
@@ -2031,8 +2119,10 @@
|
|
2031
2119
|
var isNewYear = self.currentYear !== selectedDate.getFullYear();
|
2032
2120
|
self.currentYear = selectedDate.getFullYear();
|
2033
2121
|
self.currentMonth = selectedDate.getMonth();
|
2034
|
-
if (isNewYear)
|
2122
|
+
if (isNewYear) {
|
2035
2123
|
triggerEvent("onYearChange");
|
2124
|
+
buildMonthSwitch();
|
2125
|
+
}
|
2036
2126
|
triggerEvent("onMonthChange");
|
2037
2127
|
}
|
2038
2128
|
updateNavigationCurrentMonth();
|
@@ -2064,11 +2154,18 @@
|
|
2064
2154
|
}
|
2065
2155
|
var CALLBACKS = {
|
2066
2156
|
locale: [setupLocale, updateWeekdays],
|
2067
|
-
showMonths: [buildMonths, setCalendarWidth, buildWeekdays]
|
2157
|
+
showMonths: [buildMonths, setCalendarWidth, buildWeekdays],
|
2158
|
+
minDate: [jumpToDate],
|
2159
|
+
maxDate: [jumpToDate]
|
2068
2160
|
};
|
2069
2161
|
function set(option, value) {
|
2070
|
-
if (option !== null && typeof option === "object")
|
2162
|
+
if (option !== null && typeof option === "object") {
|
2071
2163
|
Object.assign(self.config, option);
|
2164
|
+
for (var key in option) {
|
2165
|
+
if (CALLBACKS[key] !== undefined)
|
2166
|
+
CALLBACKS[key].forEach(function (x) { return x(); });
|
2167
|
+
}
|
2168
|
+
}
|
2072
2169
|
else {
|
2073
2170
|
self.config[option] = value;
|
2074
2171
|
if (CALLBACKS[option] !== undefined)
|
@@ -2118,10 +2215,14 @@
|
|
2118
2215
|
return self.clear(triggerChange);
|
2119
2216
|
setSelectedDate(date, format);
|
2120
2217
|
self.showTimeInput = self.selectedDates.length > 0;
|
2121
|
-
self.latestSelectedDateObj =
|
2218
|
+
self.latestSelectedDateObj =
|
2219
|
+
self.selectedDates[self.selectedDates.length - 1];
|
2122
2220
|
self.redraw();
|
2123
2221
|
jumpToDate();
|
2124
2222
|
setHoursFromDate();
|
2223
|
+
if (self.selectedDates.length === 0) {
|
2224
|
+
self.clear(false);
|
2225
|
+
}
|
2125
2226
|
updateValue(triggerChange);
|
2126
2227
|
if (triggerChange)
|
2127
2228
|
triggerEvent("onChange");
|
@@ -2214,7 +2315,7 @@
|
|
2214
2315
|
self._input = self.input;
|
2215
2316
|
if (self.config.altInput) {
|
2216
2317
|
// replicate self.element
|
2217
|
-
self.altInput = createElement(self.input.nodeName, self.
|
2318
|
+
self.altInput = createElement(self.input.nodeName, self.config.altInputClass);
|
2218
2319
|
self._input = self.altInput;
|
2219
2320
|
self.altInput.placeholder = self.input.placeholder;
|
2220
2321
|
self.altInput.disabled = self.input.disabled;
|
@@ -2313,9 +2414,14 @@
|
|
2313
2414
|
self.yearElements.forEach(function (yearElement, i) {
|
2314
2415
|
var d = new Date(self.currentYear, self.currentMonth, 1);
|
2315
2416
|
d.setMonth(self.currentMonth + i);
|
2316
|
-
self.
|
2317
|
-
|
2318
|
-
|
2417
|
+
if (self.config.showMonths > 1 ||
|
2418
|
+
self.config.monthSelectorType === "static") {
|
2419
|
+
self.monthElements[i].textContent =
|
2420
|
+
monthToStr(d.getMonth(), self.config.shorthandCurrentMonth, self.l10n) + " ";
|
2421
|
+
}
|
2422
|
+
else {
|
2423
|
+
self.monthsDropdownContainer.value = d.getMonth().toString();
|
2424
|
+
}
|
2319
2425
|
yearElement.value = d.getFullYear().toString();
|
2320
2426
|
});
|
2321
2427
|
self._hidePrevMonthArrow =
|
@@ -2346,8 +2452,6 @@
|
|
2346
2452
|
*/
|
2347
2453
|
function updateValue(triggerChange) {
|
2348
2454
|
if (triggerChange === void 0) { triggerChange = true; }
|
2349
|
-
if (self.selectedDates.length === 0)
|
2350
|
-
return self.clear(triggerChange);
|
2351
2455
|
if (self.mobileInput !== undefined && self.mobileFormatStr) {
|
2352
2456
|
self.mobileInput.value =
|
2353
2457
|
self.latestSelectedDateObj !== undefined
|
@@ -2362,7 +2466,6 @@
|
|
2362
2466
|
triggerEvent("onValueUpdate");
|
2363
2467
|
}
|
2364
2468
|
function onMonthNavClick(e) {
|
2365
|
-
e.preventDefault();
|
2366
2469
|
var isPrevMonth = self.prevMonthNav.contains(e.target);
|
2367
2470
|
var isNextMonth = self.nextMonthNav.contains(e.target);
|
2368
2471
|
if (isPrevMonth || isNextMonth) {
|
@@ -2445,7 +2548,9 @@
|
|
2445
2548
|
return instances.length === 1 ? instances[0] : instances;
|
2446
2549
|
}
|
2447
2550
|
/* istanbul ignore next */
|
2448
|
-
if (typeof HTMLElement !== "undefined"
|
2551
|
+
if (typeof HTMLElement !== "undefined" &&
|
2552
|
+
typeof HTMLCollection !== "undefined" &&
|
2553
|
+
typeof NodeList !== "undefined") {
|
2449
2554
|
// browser env
|
2450
2555
|
HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function (config) {
|
2451
2556
|
return _flatpickr(this, config);
|
@@ -2467,7 +2572,7 @@
|
|
2467
2572
|
}
|
2468
2573
|
};
|
2469
2574
|
/* istanbul ignore next */
|
2470
|
-
flatpickr.defaultConfig =
|
2575
|
+
flatpickr.defaultConfig = {};
|
2471
2576
|
flatpickr.l10ns = {
|
2472
2577
|
en: __assign({}, english),
|
2473
2578
|
"default": __assign({}, english)
|
@@ -2482,11 +2587,12 @@
|
|
2482
2587
|
flatpickr.formatDate = createDateFormatter({});
|
2483
2588
|
flatpickr.compareDates = compareDates;
|
2484
2589
|
/* istanbul ignore next */
|
2485
|
-
if (typeof jQuery !== "undefined") {
|
2590
|
+
if (typeof jQuery !== "undefined" && typeof jQuery.fn !== "undefined") {
|
2486
2591
|
jQuery.fn.flatpickr = function (config) {
|
2487
2592
|
return _flatpickr(this, config);
|
2488
2593
|
};
|
2489
2594
|
}
|
2595
|
+
// eslint-disable-next-line @typescript-eslint/camelcase
|
2490
2596
|
Date.prototype.fp_incr = function (days) {
|
2491
2597
|
return new Date(this.getFullYear(), this.getMonth(), this.getDate() + (typeof days === "string" ? parseInt(days, 10) : days));
|
2492
2598
|
};
|