flatpickr 2.3.7.0 → 2.4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flatpickr/version.rb +1 -1
- data/vendor/assets/javascripts/flatpickr.js +121 -61
- data/vendor/assets/javascripts/flatpickr/l10n/et.js +1 -0
- data/vendor/assets/javascripts/flatpickr/l10n/uk.js +2 -0
- data/vendor/assets/stylesheets/flatpickr.css +15 -1
- data/vendor/assets/stylesheets/flatpickr/rtl/flatpickr.min.css +13 -1
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/airbnb.rtl.css +657 -1
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/base16_flat.rtl.css +608 -1
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/confetti.rtl.css +621 -1
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/dark.rtl.css +608 -1
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/material_blue.rtl.css +621 -1
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/material_green.rtl.css +621 -1
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/material_orange.rtl.css +621 -1
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/material_red.rtl.css +621 -1
- data/vendor/assets/stylesheets/flatpickr/themes/airbnb.css +659 -1
- data/vendor/assets/stylesheets/flatpickr/themes/base16_flat.css +610 -1
- data/vendor/assets/stylesheets/flatpickr/themes/confetti.css +623 -1
- data/vendor/assets/stylesheets/flatpickr/themes/dark.css +610 -1
- data/vendor/assets/stylesheets/flatpickr/themes/material_blue.css +623 -1
- data/vendor/assets/stylesheets/flatpickr/themes/material_green.css +623 -1
- data/vendor/assets/stylesheets/flatpickr/themes/material_orange.css +623 -1
- data/vendor/assets/stylesheets/flatpickr/themes/material_red.css +623 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47f1e976b5bdeb448137f8946b7a24bd291ddbf0
|
4
|
+
data.tar.gz: bd9635b2fe87f7a35f1d832af6a5accbdd98c631
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f32e3597a1baac34db9b686b02ad1d803094fbcce1bdd21ad70674d62b5a00242fa729a8d1142047d80e11c4d1e7f9d9a3dcd3b8514dacf2553df0ecf7d615a
|
7
|
+
data.tar.gz: 7cdc2e9afb2f5a6337ce621c6b730abf3332f06bf44ed80b46cd481859663b297fc6f2a1c31d05487fada8fe098bb3841ce999e218d21d5a23b763e9f6be6b10
|
data/lib/flatpickr/version.rb
CHANGED
@@ -2,7 +2,7 @@ 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.
|
5
|
+
/*! flatpickr v2.4, @license MIT */
|
6
6
|
function Flatpickr(element, config) {
|
7
7
|
var self = this;
|
8
8
|
|
@@ -13,6 +13,7 @@ function Flatpickr(element, config) {
|
|
13
13
|
self._createElement = createElement;
|
14
14
|
self.destroy = destroy;
|
15
15
|
self.formatDate = formatDate;
|
16
|
+
self.isEnabled = isEnabled;
|
16
17
|
self.jumpToDate = jumpToDate;
|
17
18
|
self.open = open;
|
18
19
|
self.redraw = redraw;
|
@@ -27,6 +28,7 @@ function Flatpickr(element, config) {
|
|
27
28
|
|
28
29
|
self.element = element;
|
29
30
|
self.instanceConfig = config || {};
|
31
|
+
self.parseDate = Flatpickr.prototype.parseDate.bind(self);
|
30
32
|
|
31
33
|
setupFormats();
|
32
34
|
|
@@ -99,7 +101,9 @@ function Flatpickr(element, config) {
|
|
99
101
|
|
100
102
|
hours = Math.max(hours, self.config.minDate.getHours());
|
101
103
|
if (hours === self.config.minDate.getHours()) minutes = Math.max(minutes, self.config.minDate.getMinutes());
|
102
|
-
}
|
104
|
+
}
|
105
|
+
|
106
|
+
if (self.maxDateHasTime && compareDates(self.latestSelectedDateObj, self.config.maxDate) === 0) {
|
103
107
|
hours = Math.min(hours, self.config.maxDate.getHours());
|
104
108
|
if (hours === self.config.maxDate.getHours()) minutes = Math.min(minutes, self.config.maxDate.getMinutes());
|
105
109
|
}
|
@@ -130,27 +134,24 @@ function Flatpickr(element, config) {
|
|
130
134
|
}
|
131
135
|
|
132
136
|
function onYearInput(event) {
|
133
|
-
|
137
|
+
var year = event.target.value;
|
138
|
+
if (year.length === 4) {
|
134
139
|
self.currentYearElement.blur();
|
135
|
-
changeYear(
|
136
|
-
event.target.value = self.currentYear;
|
140
|
+
if (!/[^\d]/.test(year)) changeYear(year);
|
137
141
|
}
|
138
142
|
}
|
139
143
|
|
140
144
|
function onMonthScroll(e) {
|
141
145
|
e.preventDefault();
|
142
|
-
|
143
|
-
|
144
|
-
if (delta < 0 && !self._hidePrevMonthArrow || delta > 0 && !self._hideNextMonthArrow) self.changeMonth(delta);
|
146
|
+
self.changeMonth(Math.max(-1, Math.min(1, e.wheelDelta || -e.deltaY)));
|
145
147
|
}
|
146
148
|
|
147
149
|
function bind() {
|
148
150
|
if (self.config.wrap) {
|
149
151
|
["open", "close", "toggle", "clear"].forEach(function (el) {
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
//
|
152
|
+
var toggles = self.element.querySelectorAll("[data-" + el + "]");
|
153
|
+
for (var i = 0; i < toggles.length; i++) {
|
154
|
+
toggles[i].addEventListener("click", self[el]);
|
154
155
|
}
|
155
156
|
});
|
156
157
|
}
|
@@ -275,6 +276,7 @@ function Flatpickr(element, config) {
|
|
275
276
|
arrowDown = createElement("span", "arrowDown");
|
276
277
|
|
277
278
|
numInput.type = "text";
|
279
|
+
numInput.pattern = "\\d*";
|
278
280
|
wrapper.appendChild(numInput);
|
279
281
|
wrapper.appendChild(arrowUp);
|
280
282
|
wrapper.appendChild(arrowDown);
|
@@ -348,17 +350,19 @@ function Flatpickr(element, config) {
|
|
348
350
|
|
349
351
|
dayElement.dateObj = date;
|
350
352
|
|
351
|
-
|
353
|
+
toggleClass(dayElement, "today", compareDates(date, self.now) === 0);
|
352
354
|
|
353
355
|
if (dateIsEnabled) {
|
354
356
|
dayElement.tabIndex = 0;
|
355
357
|
|
356
358
|
if (isDateSelected(date)) {
|
357
359
|
dayElement.classList.add("selected");
|
358
|
-
|
360
|
+
self.selectedDateElem = dayElement;
|
359
361
|
if (self.config.mode === "range") {
|
360
|
-
dayElement
|
361
|
-
|
362
|
+
toggleClass(dayElement, "startRange", compareDates(date, self.selectedDates[0]) === 0);
|
363
|
+
|
364
|
+
toggleClass(dayElement, "endRange", compareDates(date, self.selectedDates[1]) === 0);
|
365
|
+
}
|
362
366
|
}
|
363
367
|
} else {
|
364
368
|
dayElement.classList.add("disabled");
|
@@ -381,7 +385,8 @@ function Flatpickr(element, config) {
|
|
381
385
|
}
|
382
386
|
|
383
387
|
function buildDays(year, month) {
|
384
|
-
var firstOfMonth = (new Date(self.currentYear, self.currentMonth, 1).getDay() - self.l10n.firstDayOfWeek + 7) % 7
|
388
|
+
var firstOfMonth = (new Date(self.currentYear, self.currentMonth, 1).getDay() - self.l10n.firstDayOfWeek + 7) % 7,
|
389
|
+
isRangeMode = self.config.mode === "range";
|
385
390
|
|
386
391
|
self.prevMonthDays = self.utils.getDaysinMonth((self.currentMonth - 1 + 12) % 12);
|
387
392
|
|
@@ -392,7 +397,7 @@ function Flatpickr(element, config) {
|
|
392
397
|
|
393
398
|
if (self.config.weekNumbers && self.weekNumbers.firstChild) self.weekNumbers.textContent = "";
|
394
399
|
|
395
|
-
if (
|
400
|
+
if (isRangeMode) {
|
396
401
|
// const dateLimits = self.config.enable.length || self.config.disable.length || self.config.mixDate || self.config.maxDate;
|
397
402
|
self.minRangeDate = new Date(self.currentYear, self.currentMonth - 1, dayNumber);
|
398
403
|
self.maxRangeDate = new Date(self.currentYear, self.currentMonth + 1, (42 - firstOfMonth) % daysInMonth);
|
@@ -415,6 +420,12 @@ function Flatpickr(element, config) {
|
|
415
420
|
days.appendChild(createDay("nextMonthDay", new Date(self.currentYear, self.currentMonth + 1, dayNum % daysInMonth), dayNum));
|
416
421
|
}
|
417
422
|
|
423
|
+
if (isRangeMode && self.selectedDates.length === 1 && days.childNodes[0]) {
|
424
|
+
self._hidePrevMonthArrow = self._hidePrevMonthArrow || self.minRangeDate > days.childNodes[0].dateObj;
|
425
|
+
|
426
|
+
self._hideNextMonthArrow = self._hideNextMonthArrow || self.maxRangeDate < days.childNodes[41].dateObj;
|
427
|
+
} else updateNavigationCurrentMonth();
|
428
|
+
|
418
429
|
self.days.appendChild(days);
|
419
430
|
return self.days;
|
420
431
|
}
|
@@ -492,7 +503,6 @@ function Flatpickr(element, config) {
|
|
492
503
|
self.minuteElement = minuteInput.childNodes[0];
|
493
504
|
|
494
505
|
self.hourElement.tabIndex = self.minuteElement.tabIndex = 0;
|
495
|
-
self.hourElement.pattern = self.minuteElement.pattern = "\\d*";
|
496
506
|
|
497
507
|
self.hourElement.value = self.pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getHours() : self.config.defaultHour);
|
498
508
|
|
@@ -521,7 +531,6 @@ function Flatpickr(element, config) {
|
|
521
531
|
var secondInput = createNumberInput("flatpickr-second");
|
522
532
|
self.secondElement = secondInput.childNodes[0];
|
523
533
|
|
524
|
-
self.secondElement.pattern = self.hourElement.pattern;
|
525
534
|
self.secondElement.value = self.latestSelectedDateObj ? self.pad(self.latestSelectedDateObj.getSeconds()) : "00";
|
526
535
|
|
527
536
|
self.secondElement.step = self.minuteElement.step;
|
@@ -570,7 +579,12 @@ function Flatpickr(element, config) {
|
|
570
579
|
}
|
571
580
|
|
572
581
|
function changeMonth(value, is_offset) {
|
573
|
-
|
582
|
+
is_offset = typeof is_offset === "undefined" || is_offset;
|
583
|
+
var delta = is_offset ? value : value - self.currentMonth;
|
584
|
+
|
585
|
+
if (delta < 0 && self._hidePrevMonthArrow || delta > 0 && self._hideNextMonthArrow) return;
|
586
|
+
|
587
|
+
self.currentMonth += delta;
|
574
588
|
|
575
589
|
if (self.currentMonth < 0 || self.currentMonth > 11) {
|
576
590
|
self.currentYear += self.currentMonth > 11 ? 1 : -1;
|
@@ -629,11 +643,15 @@ function Flatpickr(element, config) {
|
|
629
643
|
|
630
644
|
if (instance.timeContainer) instance.timeContainer.removeEventListener("transitionend", positionCalendar);
|
631
645
|
|
632
|
-
if (instance.mobileInput
|
646
|
+
if (instance.mobileInput) {
|
647
|
+
if (instance.mobileInput.parentNode) instance.mobileInput.parentNode.removeChild(instance.mobileInput);
|
648
|
+
delete instance.mobileInput;
|
649
|
+
} else if (instance.calendarContainer && instance.calendarContainer.parentNode) instance.calendarContainer.parentNode.removeChild(instance.calendarContainer);
|
633
650
|
|
634
651
|
if (instance.altInput) {
|
635
652
|
instance.input.type = "text";
|
636
653
|
if (instance.altInput.parentNode) instance.altInput.parentNode.removeChild(instance.altInput);
|
654
|
+
delete instance.altInput;
|
637
655
|
}
|
638
656
|
|
639
657
|
instance.input.type = instance.input._type;
|
@@ -645,13 +663,9 @@ function Flatpickr(element, config) {
|
|
645
663
|
}
|
646
664
|
|
647
665
|
function isCalendarElem(elem) {
|
648
|
-
|
649
|
-
while (e) {
|
650
|
-
if (/flatpickr-day|flatpickr-calendar/.test(e.className)) return true;
|
651
|
-
e = e.parentNode;
|
652
|
-
}
|
666
|
+
if (self.config.appendTo && self.config.appendTo.contains(elem)) return true;
|
653
667
|
|
654
|
-
return
|
668
|
+
return self.calendarContainer.contains(elem);
|
655
669
|
}
|
656
670
|
|
657
671
|
function documentClick(e) {
|
@@ -682,7 +696,10 @@ function Flatpickr(element, config) {
|
|
682
696
|
function changeYear(newYear) {
|
683
697
|
if (!newYear || self.currentYearElement.min && newYear < self.currentYearElement.min || self.currentYearElement.max && newYear > self.currentYearElement.max) return;
|
684
698
|
|
685
|
-
|
699
|
+
var newYearNum = parseInt(newYear, 10),
|
700
|
+
isNewYear = self.currentYear !== newYearNum;
|
701
|
+
|
702
|
+
self.currentYear = newYearNum || self.currentYear;
|
686
703
|
|
687
704
|
if (self.config.maxDate && self.currentYear === self.config.maxDate.getFullYear()) {
|
688
705
|
self.currentMonth = Math.min(self.config.maxDate.getMonth(), self.currentMonth);
|
@@ -690,8 +707,10 @@ function Flatpickr(element, config) {
|
|
690
707
|
self.currentMonth = Math.max(self.config.minDate.getMonth(), self.currentMonth);
|
691
708
|
}
|
692
709
|
|
693
|
-
|
694
|
-
|
710
|
+
if (isNewYear) {
|
711
|
+
self.redraw();
|
712
|
+
triggerEvent("YearChange");
|
713
|
+
}
|
695
714
|
}
|
696
715
|
|
697
716
|
function isEnabled(date, timeless) {
|
@@ -723,7 +742,7 @@ function Flatpickr(element, config) {
|
|
723
742
|
}
|
724
743
|
|
725
744
|
function onKeyDown(e) {
|
726
|
-
if (self.isOpen) {
|
745
|
+
if (e.target === (self.altInput || self.input) && e.which === 13) selectDate(e);else if (self.isOpen && isCalendarElem(e.target)) {
|
727
746
|
switch (e.which) {
|
728
747
|
case 13:
|
729
748
|
if (self.timeContainer && self.timeContainer.contains(e.target)) updateValue();else selectDate(e);
|
@@ -736,29 +755,40 @@ function Flatpickr(element, config) {
|
|
736
755
|
break;
|
737
756
|
|
738
757
|
case 37:
|
739
|
-
if (e.target !== self.input & e.target !== self.altInput)
|
758
|
+
if (e.target !== self.input & e.target !== self.altInput) {
|
759
|
+
changeMonth(-1);
|
760
|
+
self.currentMonthElement.focus();
|
761
|
+
}
|
740
762
|
break;
|
741
763
|
|
742
764
|
case 38:
|
743
|
-
e.
|
744
|
-
|
745
|
-
|
765
|
+
if (!self.timeContainer || !self.timeContainer.contains(e.target)) {
|
766
|
+
e.preventDefault();
|
767
|
+
self.currentYear++;
|
768
|
+
self.redraw();
|
769
|
+
} else updateTime(e);
|
746
770
|
|
747
771
|
break;
|
748
772
|
|
749
773
|
case 39:
|
750
|
-
if (e.target !== self.input & e.target !== self.altInput)
|
774
|
+
if (e.target !== self.input & e.target !== self.altInput) {
|
775
|
+
changeMonth(1);
|
776
|
+
self.currentMonthElement.focus();
|
777
|
+
}
|
751
778
|
break;
|
752
779
|
|
753
780
|
case 40:
|
754
|
-
e.
|
755
|
-
|
756
|
-
|
781
|
+
if (!self.timeContainer || !self.timeContainer.contains(e.target)) {
|
782
|
+
e.preventDefault();
|
783
|
+
self.currentYear--;
|
784
|
+
self.redraw();
|
785
|
+
} else updateTime(e);
|
757
786
|
|
758
787
|
break;
|
759
788
|
|
760
789
|
default:
|
761
790
|
break;
|
791
|
+
|
762
792
|
}
|
763
793
|
}
|
764
794
|
}
|
@@ -871,7 +901,7 @@ function Flatpickr(element, config) {
|
|
871
901
|
function parseConfig() {
|
872
902
|
var boolOpts = ["utc", "wrap", "weekNumbers", "allowInput", "clickOpens", "time_24hr", "enableTime", "noCalendar", "altInput", "shorthandCurrentMonth", "inline", "static", "enableSeconds", "disableMobile"];
|
873
903
|
|
874
|
-
var hooks = ["onChange", "onClose", "onDayCreate", "onOpen", "onReady", "onValueUpdate"];
|
904
|
+
var hooks = ["onChange", "onClose", "onDayCreate", "onMonthChange", "onOpen", "onReady", "onValueUpdate", "onYearChange"];
|
875
905
|
|
876
906
|
self.config = Object.create(Flatpickr.defaultConfig);
|
877
907
|
|
@@ -891,6 +921,9 @@ function Flatpickr(element, config) {
|
|
891
921
|
|
892
922
|
var userConfig = _extends({}, self.instanceConfig, JSON.parse(JSON.stringify(self.element.dataset || {})));
|
893
923
|
|
924
|
+
self.config.parseDate = userConfig.parseDate;
|
925
|
+
self.config.formatDate = userConfig.formatDate;
|
926
|
+
|
894
927
|
_extends(self.config, userConfig);
|
895
928
|
|
896
929
|
for (var i = 0; i < boolOpts.length; i++) {
|
@@ -965,6 +998,8 @@ function Flatpickr(element, config) {
|
|
965
998
|
|
966
999
|
function selectDate(e) {
|
967
1000
|
e.preventDefault();
|
1001
|
+
e.stopPropagation();
|
1002
|
+
|
968
1003
|
if (self.config.allowInput && e.which === 13 && e.target === (self.altInput || self.input)) return self.setDate((self.altInput || self.input).value), e.target.blur();
|
969
1004
|
|
970
1005
|
if (!e.target.classList.contains("flatpickr-day") || e.target.classList.contains("disabled") || e.target.classList.contains("notAllowed")) return;
|
@@ -980,7 +1015,9 @@ function Flatpickr(element, config) {
|
|
980
1015
|
if (self.selectedDates.length === 2) self.clear();
|
981
1016
|
|
982
1017
|
self.selectedDates.push(selectedDate);
|
983
|
-
|
1018
|
+
|
1019
|
+
// unless selecting same date twice, sort ascendingly
|
1020
|
+
if (compareDates(selectedDate, self.selectedDates[0], true) !== 0) self.selectedDates.sort(function (a, b) {
|
984
1021
|
return a.getTime() - b.getTime();
|
985
1022
|
});
|
986
1023
|
}
|
@@ -988,9 +1025,13 @@ function Flatpickr(element, config) {
|
|
988
1025
|
setHoursFromInputs();
|
989
1026
|
|
990
1027
|
if (selectedDate.getMonth() !== self.currentMonth && self.config.mode !== "range") {
|
1028
|
+
var isNewYear = self.currentYear !== selectedDate.getFullYear();
|
991
1029
|
self.currentYear = selectedDate.getFullYear();
|
992
1030
|
self.currentMonth = selectedDate.getMonth();
|
993
|
-
|
1031
|
+
|
1032
|
+
if (isNewYear) triggerEvent("YearChange");
|
1033
|
+
|
1034
|
+
triggerEvent("MonthChange");
|
994
1035
|
}
|
995
1036
|
|
996
1037
|
buildDays();
|
@@ -1013,6 +1054,10 @@ function Flatpickr(element, config) {
|
|
1013
1054
|
} else updateNavigationCurrentMonth();
|
1014
1055
|
}
|
1015
1056
|
|
1057
|
+
if (e.which === 13 && self.config.enableTime) setTimeout(function () {
|
1058
|
+
return self.hourElement.focus();
|
1059
|
+
}, 451);
|
1060
|
+
|
1016
1061
|
if (self.config.mode === "single" && !self.config.enableTime) self.close();
|
1017
1062
|
|
1018
1063
|
triggerEvent("Change");
|
@@ -1070,7 +1115,7 @@ function Flatpickr(element, config) {
|
|
1070
1115
|
setHoursFromDate();
|
1071
1116
|
updateValue();
|
1072
1117
|
|
1073
|
-
if (triggerChange
|
1118
|
+
if (triggerChange !== false) triggerEvent("Change");
|
1074
1119
|
}
|
1075
1120
|
|
1076
1121
|
function setupDates() {
|
@@ -1090,12 +1135,12 @@ function Flatpickr(element, config) {
|
|
1090
1135
|
self.selectedDates = [];
|
1091
1136
|
self.now = new Date();
|
1092
1137
|
|
1093
|
-
setSelectedDate(self.config.defaultDate || self.input.value);
|
1094
|
-
|
1095
1138
|
if (self.config.disable.length) self.config.disable = parseDateRules(self.config.disable);
|
1096
1139
|
|
1097
1140
|
if (self.config.enable.length) self.config.enable = parseDateRules(self.config.enable);
|
1098
1141
|
|
1142
|
+
setSelectedDate(self.config.defaultDate || self.input.value);
|
1143
|
+
|
1099
1144
|
var initialDate = self.selectedDates.length ? self.selectedDates[0] : self.config.minDate && self.config.minDate.getTime() > self.now ? self.config.minDate : self.config.maxDate && self.config.maxDate.getTime() < self.now ? self.config.maxDate : self.now;
|
1100
1145
|
|
1101
1146
|
self.currentYear = initialDate.getFullYear();
|
@@ -1142,6 +1187,11 @@ function Flatpickr(element, config) {
|
|
1142
1187
|
/* istanbul ignore next */
|
1143
1188
|
function setupFormats() {
|
1144
1189
|
self.formats = {
|
1190
|
+
// get the date in UTC
|
1191
|
+
Z: function Z(date) {
|
1192
|
+
return date.toISOString();
|
1193
|
+
},
|
1194
|
+
|
1145
1195
|
// weekday name, short, e.g. Thu
|
1146
1196
|
D: function D(date) {
|
1147
1197
|
return self.l10n.weekdays.shorthand[self.formats.w(date)];
|
@@ -1438,9 +1488,15 @@ function Flatpickr(element, config) {
|
|
1438
1488
|
|
1439
1489
|
function timeWrapper(e) {
|
1440
1490
|
e.preventDefault();
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1491
|
+
|
1492
|
+
var isKeyDown = e.type === "keydown",
|
1493
|
+
isWheel = e.type === "wheel";
|
1494
|
+
|
1495
|
+
if (e.type !== "input" && !isKeyDown && (e.target.value || e.target.textContent).length >= 2 // typed two digits
|
1496
|
+
) {
|
1497
|
+
e.target.focus();
|
1498
|
+
e.target.blur();
|
1499
|
+
}
|
1444
1500
|
|
1445
1501
|
if (self.amPM && e.target === self.amPM) return e.target.textContent = ["AM", "PM"][e.target.textContent === "AM" | 0];
|
1446
1502
|
|
@@ -1448,23 +1504,23 @@ function Flatpickr(element, config) {
|
|
1448
1504
|
max = Number(e.target.max),
|
1449
1505
|
step = Number(e.target.step),
|
1450
1506
|
curValue = parseInt(e.target.value, 10),
|
1451
|
-
delta = Math.max(-1, Math.min(1, e.wheelDelta || -e.deltaY));
|
1507
|
+
delta = !isKeyDown ? Math.max(-1, Math.min(1, e.wheelDelta || -e.deltaY)) || 0 : e.which === 38 ? 1 : -1;
|
1452
1508
|
|
1453
|
-
var newValue =
|
1509
|
+
var newValue = curValue + (isWheel || isKeyDown) * step * delta;
|
1454
1510
|
|
1455
|
-
if (e.
|
1511
|
+
if (e.target.value.length === 2) {
|
1512
|
+
var isHourElem = e.target === self.hourElement;
|
1456
1513
|
|
1457
|
-
if (e.type !== "input" || e.target.value.length === 2) {
|
1458
1514
|
if (newValue < min) {
|
1459
|
-
newValue = max + newValue +
|
1515
|
+
newValue = max + newValue + !isHourElem + (isHourElem && !self.amPM);
|
1460
1516
|
} else if (newValue > max) {
|
1461
1517
|
newValue = e.target === self.hourElement ? newValue - max - !self.amPM : min;
|
1462
1518
|
}
|
1463
1519
|
|
1464
|
-
if (self.amPM &&
|
1520
|
+
if (self.amPM && isHourElem && (step === 1 ? newValue + curValue === 23 : Math.abs(newValue - curValue) > step)) self.amPM.textContent = self.amPM.textContent === "PM" ? "AM" : "PM";
|
1465
1521
|
|
1466
1522
|
e.target.value = self.pad(newValue);
|
1467
|
-
}
|
1523
|
+
}
|
1468
1524
|
}
|
1469
1525
|
|
1470
1526
|
init();
|
@@ -1603,7 +1659,11 @@ Flatpickr.defaultConfig = {
|
|
1603
1659
|
|
1604
1660
|
onValueUpdate: [],
|
1605
1661
|
|
1606
|
-
onDayCreate: []
|
1662
|
+
onDayCreate: [],
|
1663
|
+
|
1664
|
+
onMonthChange: [],
|
1665
|
+
|
1666
|
+
onYearChange: []
|
1607
1667
|
};
|
1608
1668
|
|
1609
1669
|
/* istanbul ignore next */
|
@@ -1656,13 +1716,13 @@ Flatpickr.prototype = {
|
|
1656
1716
|
if (!date) return null;
|
1657
1717
|
|
1658
1718
|
var dateTimeRegex = /(\d+)/g,
|
1659
|
-
timeRegex = /^(\d{1,2})[:\s](\d\d)?[:\s]?(\d\d)?\s?(a|p)?/i,
|
1719
|
+
timeRegex = /^(\d{1,2})[:\s](\d\d)?[:\s]?(\d\d)?\s?(a|p|A|P)?/i,
|
1660
1720
|
timestamp = /^(\d+)$/g,
|
1661
1721
|
date_orig = date;
|
1662
1722
|
|
1663
1723
|
if (date.toFixed || timestamp.test(date)) // timestamp
|
1664
1724
|
date = new Date(date);else if (typeof date === "string") {
|
1665
|
-
date = date.trim()
|
1725
|
+
date = date.trim();
|
1666
1726
|
|
1667
1727
|
if (date === "today") {
|
1668
1728
|
date = new Date();
|
@@ -1678,8 +1738,8 @@ Flatpickr.prototype = {
|
|
1678
1738
|
} else if (/Z$/.test(date) || /GMT$/.test(date)) // datestrings w/ timezone
|
1679
1739
|
date = new Date(date);else if (dateTimeRegex.test(date) && /^[0-9]/.test(date)) {
|
1680
1740
|
var d = date.match(dateTimeRegex),
|
1681
|
-
isAM = /(am)$/.test(date),
|
1682
|
-
isPM = /(pm)$/.test(date);
|
1741
|
+
isAM = /(am|AM)$/.test(date),
|
1742
|
+
isPM = /(pm|PM)$/.test(date);
|
1683
1743
|
|
1684
1744
|
date = new Date(d[0] + "/" + (d[1] || 1) + "/" + (d[2] || 1) + " " + (d[3] || 0) + ":" + (d[4] || 0) + ":" + (d[5] || 0));
|
1685
1745
|
|