flatpickr-ce 4.11.0 → 4.12.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.
- package/README.md +31 -0
- package/dist/esm/index.js +111 -55
- package/dist/esm/plugins/rangePlugin.js +13 -4
- package/dist/esm/plugins/scrollPlugin.js +3 -3
- package/dist/esm/utils/dates.js +36 -18
- package/dist/flatpickr.css +13 -0
- package/dist/flatpickr.js +207 -81
- package/dist/flatpickr.min.css +1 -1
- package/dist/flatpickr.min.js +2 -2
- package/dist/plugins/rangePlugin.js +17 -5
- package/dist/plugins/scrollPlugin.js +3 -3
- package/dist/themes/airbnb.css +13 -0
- package/dist/themes/confetti.css +13 -0
- package/dist/themes/dark.css +13 -0
- package/dist/themes/light.css +13 -0
- package/dist/themes/material_blue.css +13 -0
- package/dist/themes/material_green.css +13 -0
- package/dist/themes/material_orange.css +13 -0
- package/dist/themes/material_red.css +13 -0
- package/package.json +1 -1
- package/src/style/flatpickr.styl +16 -0
package/dist/flatpickr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* flatpickr v4.
|
|
1
|
+
/* flatpickr v4.12.0, @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) :
|
|
@@ -585,7 +585,10 @@
|
|
|
585
585
|
/**
|
|
586
586
|
* The default time for a date on the given day. minDate and maxDate hold it
|
|
587
587
|
* only on their own day, and only when set with a time: a date-only limit
|
|
588
|
-
* leaves its whole day open, as for the time inputs (setHoursFromInputs)
|
|
588
|
+
* leaves its whole day open, as for the time inputs (setHoursFromInputs).
|
|
589
|
+
* minTime and maxTime hold it on every day, as they do the time inputs: an
|
|
590
|
+
* overnight window, minTime after maxTime, moves it to minTime only from the
|
|
591
|
+
* hours between the two
|
|
589
592
|
*/
|
|
590
593
|
function getDefaultHours(config, date) {
|
|
591
594
|
var hours = config.defaultHour;
|
|
@@ -596,27 +599,45 @@
|
|
|
596
599
|
compareDates(date, limit) === 0 &&
|
|
597
600
|
(limit.getHours() > 0 || limit.getMinutes() > 0 || limit.getSeconds() > 0);
|
|
598
601
|
};
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
if (hours ===
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
602
|
+
var holdAbove = function (limit) {
|
|
603
|
+
hours = Math.max(hours, limit.getHours());
|
|
604
|
+
if (hours === limit.getHours()) {
|
|
605
|
+
minutes = Math.max(minutes, limit.getMinutes());
|
|
606
|
+
if (minutes === limit.getMinutes())
|
|
607
|
+
seconds = Math.max(seconds, limit.getSeconds());
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
var holdBelow = function (limit) {
|
|
611
|
+
hours = Math.min(hours, limit.getHours());
|
|
612
|
+
if (hours === limit.getHours()) {
|
|
613
|
+
minutes = Math.min(minutes, limit.getMinutes());
|
|
614
|
+
if (minutes === limit.getMinutes())
|
|
615
|
+
seconds = Math.min(seconds, limit.getSeconds());
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
var secondsOf = function (time) {
|
|
619
|
+
return calculateSecondsSinceMidnight(time.getHours(), time.getMinutes(), time.getSeconds());
|
|
620
|
+
};
|
|
621
|
+
if (holdsTime(config.minDate))
|
|
622
|
+
holdAbove(config.minDate);
|
|
623
|
+
if (holdsTime(config.maxDate))
|
|
624
|
+
holdBelow(config.maxDate);
|
|
625
|
+
var minTime = config.minTime, maxTime = config.maxTime;
|
|
626
|
+
if (minTime !== undefined &&
|
|
627
|
+
maxTime !== undefined &&
|
|
628
|
+
secondsOf(minTime) > secondsOf(maxTime)) {
|
|
629
|
+
var time = calculateSecondsSinceMidnight(hours, minutes, seconds);
|
|
630
|
+
if (time > secondsOf(maxTime) && time < secondsOf(minTime)) {
|
|
631
|
+
hours = minTime.getHours();
|
|
632
|
+
minutes = minTime.getMinutes();
|
|
633
|
+
seconds = minTime.getSeconds();
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
if (maxTime !== undefined)
|
|
638
|
+
holdBelow(maxTime);
|
|
639
|
+
if (minTime !== undefined)
|
|
640
|
+
holdAbove(minTime);
|
|
620
641
|
}
|
|
621
642
|
return { hours: hours, minutes: minutes, seconds: seconds };
|
|
622
643
|
}
|
|
@@ -671,6 +692,10 @@
|
|
|
671
692
|
// Listeners on the document and the window, bound only while the calendar
|
|
672
693
|
// is open; kept apart from _handlers, which last until destroy()
|
|
673
694
|
var openHandlers = [];
|
|
695
|
+
// Watches the calendar until it is laid out, while an element around it is
|
|
696
|
+
// hidden and its day grid has no width to measure (#2579). ResizeObserver
|
|
697
|
+
// is missing from TypeScript 4.1's DOM types
|
|
698
|
+
var layoutObserver;
|
|
674
699
|
self._handlers = [];
|
|
675
700
|
self.pluginElements = [];
|
|
676
701
|
self.loadedPlugins = [];
|
|
@@ -752,30 +777,65 @@
|
|
|
752
777
|
}
|
|
753
778
|
function setCalendarWidth() {
|
|
754
779
|
var config = self.config;
|
|
755
|
-
|
|
780
|
+
// the stylesheet's width fits one month without a week column; drop the
|
|
781
|
+
// widths written below, which set("showMonths", 1) would otherwise keep
|
|
782
|
+
// from more months (#2392). The week column is built once, and
|
|
783
|
+
// set("weekNumbers", false) doesn't remove it, so look at the DOM
|
|
784
|
+
if (self.weekWrapper === undefined && config.showMonths === 1) {
|
|
785
|
+
if (self.daysContainer !== undefined) {
|
|
786
|
+
self.daysContainer.style.removeProperty("width");
|
|
787
|
+
self.calendarContainer.style.removeProperty("width");
|
|
788
|
+
}
|
|
789
|
+
// nor measure it once it is laid out (#2579)
|
|
790
|
+
unobserveLayout();
|
|
756
791
|
return;
|
|
757
792
|
}
|
|
758
793
|
else if (config.noCalendar !== true) {
|
|
759
|
-
win.requestAnimationFrame(
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
794
|
+
win.requestAnimationFrame(measureCalendarWidth);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
function measureCalendarWidth() {
|
|
798
|
+
if (self.calendarContainer !== undefined) {
|
|
799
|
+
self.calendarContainer.style.visibility = "hidden";
|
|
800
|
+
self.calendarContainer.style.display = "block";
|
|
801
|
+
}
|
|
802
|
+
if (self.daysContainer !== undefined) {
|
|
803
|
+
var gridWidth = self.days.offsetWidth;
|
|
804
|
+
// displaying the calendar doesn't lay it out while an element around
|
|
805
|
+
// it is hidden, e.g. a modal not shown yet: wait until it is
|
|
806
|
+
if (gridWidth === 0) {
|
|
807
|
+
observeLayout();
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
var daysWidth = (gridWidth + 1) * self.config.showMonths;
|
|
811
|
+
self.daysContainer.style.width = daysWidth + "px";
|
|
812
|
+
self.calendarContainer.style.width =
|
|
813
|
+
daysWidth +
|
|
814
|
+
(self.weekWrapper !== undefined ? self.weekWrapper.offsetWidth : 0) +
|
|
815
|
+
"px";
|
|
816
|
+
unobserveLayout();
|
|
817
|
+
}
|
|
818
|
+
self.calendarContainer.style.removeProperty("visibility");
|
|
819
|
+
self.calendarContainer.style.removeProperty("display");
|
|
777
820
|
}
|
|
778
821
|
}
|
|
822
|
+
// The page lays an inline calendar out when it shows it, which only an
|
|
823
|
+
// observer tells of, called back after layout and before paint. open()
|
|
824
|
+
// measures a popup as it opens; the observer is left for one opened while
|
|
825
|
+
// an element around it is still hidden
|
|
826
|
+
function observeLayout() {
|
|
827
|
+
var Observer = win.ResizeObserver;
|
|
828
|
+
if (layoutObserver !== undefined || Observer === undefined)
|
|
829
|
+
return;
|
|
830
|
+
layoutObserver = new Observer(measureCalendarWidth);
|
|
831
|
+
layoutObserver.observe(self.calendarContainer);
|
|
832
|
+
}
|
|
833
|
+
function unobserveLayout() {
|
|
834
|
+
if (layoutObserver === undefined)
|
|
835
|
+
return;
|
|
836
|
+
layoutObserver.disconnect();
|
|
837
|
+
layoutObserver = undefined;
|
|
838
|
+
}
|
|
779
839
|
/**
|
|
780
840
|
* The day the time inputs' time goes on while no date is selected: today,
|
|
781
841
|
* or the minDate or maxDate it falls outside of, as the calendar opens on.
|
|
@@ -817,14 +877,27 @@
|
|
|
817
877
|
return hour % 12;
|
|
818
878
|
}
|
|
819
879
|
}
|
|
880
|
+
/**
|
|
881
|
+
* The number in a time input, or `shown`, the selected time's, instead of
|
|
882
|
+
* 0 when it holds none (#2498): emptied, or holding text the browser can't
|
|
883
|
+
* read as a number, such as "7:13" in Firefox or "7e" in any, which leaves
|
|
884
|
+
* an empty value. updateTime() selects the default time before reading,
|
|
885
|
+
* when nothing is selected
|
|
886
|
+
*/
|
|
887
|
+
function readTimeInput(value, shown) {
|
|
888
|
+
var number = parseInt(value, 10);
|
|
889
|
+
return isNaN(number) && shown !== undefined ? shown : number || 0;
|
|
890
|
+
}
|
|
820
891
|
/**
|
|
821
892
|
* Syncs the selected date object time with user's time input
|
|
822
893
|
*/
|
|
823
894
|
function setHoursFromInputs() {
|
|
824
895
|
if (self.hourElement === undefined || self.minuteElement === undefined)
|
|
825
896
|
return;
|
|
826
|
-
var
|
|
827
|
-
|
|
897
|
+
var shown = self.latestSelectedDateObj;
|
|
898
|
+
var hours = readTimeInput(self.hourElement.value.slice(-2), shown && shown.getHours()) % 24, minutes = readTimeInput(self.minuteElement.value, shown && shown.getMinutes()) %
|
|
899
|
+
60, seconds = self.secondElement !== undefined
|
|
900
|
+
? readTimeInput(self.secondElement.value, shown && shown.getSeconds()) % 60
|
|
828
901
|
: 0;
|
|
829
902
|
if (self.amPM !== undefined) {
|
|
830
903
|
hours = ampm2military(hours, self.amPM.textContent);
|
|
@@ -1407,7 +1480,6 @@
|
|
|
1407
1480
|
var month = createElement("option", "flatpickr-monthDropdown-month");
|
|
1408
1481
|
month.value = new Date(self.currentYear, i).getMonth().toString();
|
|
1409
1482
|
month.textContent = monthToStr(i, self.config.shorthandCurrentMonth, self.l10n);
|
|
1410
|
-
month.tabIndex = -1;
|
|
1411
1483
|
if (self.currentMonth === i) {
|
|
1412
1484
|
month.selected = true;
|
|
1413
1485
|
}
|
|
@@ -1430,7 +1502,6 @@
|
|
|
1430
1502
|
var target = getEventTarget(e);
|
|
1431
1503
|
var selectedMonth = parseInt(target.value, 10);
|
|
1432
1504
|
self.changeMonth(selectedMonth - self.currentMonth);
|
|
1433
|
-
triggerEvent("onMonthChange");
|
|
1434
1505
|
});
|
|
1435
1506
|
buildMonthSwitch();
|
|
1436
1507
|
monthElement = self.monthsDropdownContainer;
|
|
@@ -1536,10 +1607,8 @@
|
|
|
1536
1607
|
: defaults.minutes);
|
|
1537
1608
|
self.hourElement.setAttribute("min", self.config.time_24hr ? "0" : "1");
|
|
1538
1609
|
self.hourElement.setAttribute("max", self.config.time_24hr ? "23" : "12");
|
|
1539
|
-
self.hourElement.setAttribute("maxlength", "2");
|
|
1540
1610
|
self.minuteElement.setAttribute("min", "0");
|
|
1541
1611
|
self.minuteElement.setAttribute("max", "59");
|
|
1542
|
-
self.minuteElement.setAttribute("maxlength", "2");
|
|
1543
1612
|
self.timeContainer.appendChild(hourInput);
|
|
1544
1613
|
self.timeContainer.appendChild(separator);
|
|
1545
1614
|
self.timeContainer.appendChild(minuteInput);
|
|
@@ -1557,7 +1626,6 @@
|
|
|
1557
1626
|
: defaults.seconds);
|
|
1558
1627
|
self.secondElement.setAttribute("min", "0");
|
|
1559
1628
|
self.secondElement.setAttribute("max", "59");
|
|
1560
|
-
self.secondElement.setAttribute("maxlength", "2");
|
|
1561
1629
|
self.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
|
|
1562
1630
|
self.timeContainer.appendChild(secondInput);
|
|
1563
1631
|
}
|
|
@@ -1565,7 +1633,7 @@
|
|
|
1565
1633
|
// add self.amPM if appropriate
|
|
1566
1634
|
self.amPM = createElement("span", "flatpickr-am-pm", self.l10n.amPM[int((self.latestSelectedDateObj
|
|
1567
1635
|
? self.hourElement.value
|
|
1568
|
-
:
|
|
1636
|
+
: defaults.hours) > 11)]);
|
|
1569
1637
|
self.amPM.title = self.l10n.toggleTitle;
|
|
1570
1638
|
self.amPM.tabIndex = -1;
|
|
1571
1639
|
self.timeContainer.appendChild(self.amPM);
|
|
@@ -1709,6 +1777,7 @@
|
|
|
1709
1777
|
}
|
|
1710
1778
|
self._handlers = [];
|
|
1711
1779
|
unbindOpenEvents();
|
|
1780
|
+
unobserveLayout();
|
|
1712
1781
|
if (self.mobileInput) {
|
|
1713
1782
|
if (self.mobileInput.parentNode)
|
|
1714
1783
|
self.mobileInput.parentNode.removeChild(self.mobileInput);
|
|
@@ -1838,12 +1907,15 @@
|
|
|
1838
1907
|
var _a;
|
|
1839
1908
|
if (timeless === void 0) { timeless = true; }
|
|
1840
1909
|
var dateToCheck = self.parseDate(date, undefined, timeless); // timeless
|
|
1910
|
+
// a time is compared only with a minDate or maxDate that has one: a
|
|
1911
|
+
// date-only limit leaves its whole day open, as the calendar and the time
|
|
1912
|
+
// inputs do (#2460)
|
|
1841
1913
|
if ((self.config.minDate &&
|
|
1842
1914
|
dateToCheck &&
|
|
1843
|
-
compareDates(dateToCheck, self.config.minDate, timeless
|
|
1915
|
+
compareDates(dateToCheck, self.config.minDate, timeless || !self.minDateHasTime) < 0) ||
|
|
1844
1916
|
(self.config.maxDate &&
|
|
1845
1917
|
dateToCheck &&
|
|
1846
|
-
compareDates(dateToCheck, self.config.maxDate, timeless
|
|
1918
|
+
compareDates(dateToCheck, self.config.maxDate, timeless || !self.maxDateHasTime) > 0))
|
|
1847
1919
|
return false;
|
|
1848
1920
|
if (!self.config.enable && self.config.disable.length === 0)
|
|
1849
1921
|
return true;
|
|
@@ -2189,6 +2261,10 @@
|
|
|
2189
2261
|
bindOpenEvents();
|
|
2190
2262
|
self.calendarContainer.classList.add("open");
|
|
2191
2263
|
self._input.classList.add("active");
|
|
2264
|
+
// a popup created where it couldn't be laid out can be now: measure it
|
|
2265
|
+
// before it is placed by its width (#2579)
|
|
2266
|
+
if (layoutObserver !== undefined)
|
|
2267
|
+
measureCalendarWidth();
|
|
2192
2268
|
triggerEvent("onOpen");
|
|
2193
2269
|
positionCalendar(positionElement);
|
|
2194
2270
|
}
|
|
@@ -2285,6 +2361,10 @@
|
|
|
2285
2361
|
});
|
|
2286
2362
|
var minMaxTimeSetter = function (type) { return function (val) {
|
|
2287
2363
|
self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i:S");
|
|
2364
|
+
// with none selected, the time inputs show the default time, which the
|
|
2365
|
+
// new limit may hold, as for minDate and maxDate (#2547)
|
|
2366
|
+
if (self.selectedDates && !self.selectedDates.length)
|
|
2367
|
+
setDefaultHours();
|
|
2288
2368
|
}; };
|
|
2289
2369
|
Object.defineProperty(self.config, "minTime", {
|
|
2290
2370
|
get: function () { return self.config._minTime; },
|
|
@@ -2377,9 +2457,14 @@
|
|
|
2377
2457
|
self.config.altFormat = formats.altFormat;
|
|
2378
2458
|
}
|
|
2379
2459
|
function getInputElem() {
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2460
|
+
if (!self.config.wrap)
|
|
2461
|
+
return element;
|
|
2462
|
+
// parseConfig() reads the input before setupInputs() does: without one,
|
|
2463
|
+
// init can't go on, and flatpickr() logs this rather than a TypeError
|
|
2464
|
+
var input = element.querySelector("[data-input]");
|
|
2465
|
+
if (!input)
|
|
2466
|
+
throw new Error('flatpickr: "wrap" needs an input with the data-input attribute inside the element');
|
|
2467
|
+
return input;
|
|
2383
2468
|
}
|
|
2384
2469
|
function setupLocale() {
|
|
2385
2470
|
if (typeof self.config.locale !== "object" &&
|
|
@@ -2419,7 +2504,12 @@
|
|
|
2419
2504
|
if (self.calendarContainer === undefined)
|
|
2420
2505
|
return;
|
|
2421
2506
|
triggerEvent("onPreCalendarPosition");
|
|
2422
|
-
|
|
2507
|
+
// a static calendar goes next to its wrapper, whichever element a popup
|
|
2508
|
+
// would be placed by; the page lays it out when it is also inline
|
|
2509
|
+
var wrapper = self.config.static && !self.config.inline
|
|
2510
|
+
? self.calendarContainer.parentNode
|
|
2511
|
+
: undefined;
|
|
2512
|
+
var positionElement = wrapper || customPositionElement || self._positionElement;
|
|
2423
2513
|
var calendarHeight = self.calendarContainer.offsetHeight, calendarWidth = self.calendarContainer.offsetWidth, configPos = self.config.position.split(" "), configPosVertical = configPos[0], configPosHorizontal = configPos.length > 1 ? configPos[1] : null, inputBounds = positionElement.getBoundingClientRect(), distanceFromBottom = win.innerHeight - inputBounds.bottom, isAutoVertical = configPosVertical !== "above" && configPosVertical !== "below", fitsBelow = distanceFromBottom >= calendarHeight, fitsAbove = inputBounds.top > calendarHeight,
|
|
2424
2514
|
// the page can't always be scrolled to what sticks out of the viewport
|
|
2425
2515
|
// (scroll-locked modals, touch screens), so a calendar that fits
|
|
@@ -2431,7 +2521,14 @@
|
|
|
2431
2521
|
!self.config.inline, showOnTop = keepInViewport
|
|
2432
2522
|
? inputBounds.top > distanceFromBottom
|
|
2433
2523
|
: configPosVertical === "above" ||
|
|
2434
|
-
(isAutoVertical &&
|
|
2524
|
+
(isAutoVertical &&
|
|
2525
|
+
!fitsBelow &&
|
|
2526
|
+
fitsAbove &&
|
|
2527
|
+
// a scroll container can't be scrolled to what it cuts off above
|
|
2528
|
+
// a static calendar, unlike what sticks out below, which it grows
|
|
2529
|
+
// to hold
|
|
2530
|
+
(wrapper === undefined ||
|
|
2531
|
+
inputBounds.top - getClipTop(wrapper) > calendarHeight));
|
|
2435
2532
|
var anchoredTop = win.pageYOffset +
|
|
2436
2533
|
inputBounds.top +
|
|
2437
2534
|
(!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
|
|
@@ -2463,6 +2560,8 @@
|
|
|
2463
2560
|
var rightMost = left + calendarWidth > bodyWidth;
|
|
2464
2561
|
var centerMost = rightMost && inputRight < calendarWidth;
|
|
2465
2562
|
toggleClass(self.calendarContainer, "rightMost", rightMost);
|
|
2563
|
+
// the stylesheet places a static calendar against its wrapper, by the
|
|
2564
|
+
// arrow classes set above
|
|
2466
2565
|
if (self.config.static)
|
|
2467
2566
|
return;
|
|
2468
2567
|
toggleClass(self.calendarContainer, "centerMost", centerMost);
|
|
@@ -2481,6 +2580,23 @@
|
|
|
2481
2580
|
self.calendarContainer.style.left = left - origin.left + "px";
|
|
2482
2581
|
self.calendarContainer.style.right = "auto";
|
|
2483
2582
|
}
|
|
2583
|
+
// The top of what can be seen of a static calendar: the viewport's, or the
|
|
2584
|
+
// lowest inner top edge of the elements around it that clip their overflow
|
|
2585
|
+
function getClipTop(wrapper) {
|
|
2586
|
+
var _a;
|
|
2587
|
+
var clipTop = 0;
|
|
2588
|
+
for (var ancestor = wrapper; ancestor !== null;
|
|
2589
|
+
// shadow DOM lays an element out in the slot it is assigned to, and a
|
|
2590
|
+
// shadow root's children in its host
|
|
2591
|
+
ancestor =
|
|
2592
|
+
ancestor.assignedSlot ||
|
|
2593
|
+
ancestor.parentElement || ((_a = ancestor.parentNode) === null || _a === void 0 ? void 0 : _a.host) ||
|
|
2594
|
+
null) {
|
|
2595
|
+
if (win.getComputedStyle(ancestor).overflowY !== "visible")
|
|
2596
|
+
clipTop = Math.max(clipTop, ancestor.getBoundingClientRect().top + ancestor.clientTop);
|
|
2597
|
+
}
|
|
2598
|
+
return clipTop;
|
|
2599
|
+
}
|
|
2484
2600
|
function getContainingBlockOrigin() {
|
|
2485
2601
|
var containingBlock = self.calendarContainer.offsetParent;
|
|
2486
2602
|
// offsetParent is null while the calendar is hidden, and stops at <body>
|
|
@@ -2531,7 +2647,7 @@
|
|
|
2531
2647
|
* Makes way for a day picked on a range that has both ends: a new range,
|
|
2532
2648
|
* from no dates and at the default time, which the day takes from the time
|
|
2533
2649
|
* inputs. rangePlugin makes the pick an edit of one end, which keeps the
|
|
2534
|
-
* time the time inputs show for it
|
|
2650
|
+
* time the time inputs show for it, unless the calendar is inline
|
|
2535
2651
|
*/
|
|
2536
2652
|
function startNewRange() {
|
|
2537
2653
|
self.clear(false, false);
|
|
@@ -2633,22 +2749,27 @@
|
|
|
2633
2749
|
],
|
|
2634
2750
|
};
|
|
2635
2751
|
function set(option, value) {
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2752
|
+
var _a;
|
|
2753
|
+
var options = option !== null && typeof option === "object"
|
|
2754
|
+
? option
|
|
2755
|
+
: (_a = {}, _a[option] = value, _a);
|
|
2756
|
+
// own keys only, as Object.assign took them
|
|
2757
|
+
var keys = Object.keys(options);
|
|
2758
|
+
keys.forEach(function (key) {
|
|
2759
|
+
userConfig[key] = options[key];
|
|
2760
|
+
// triggerEvent() runs a hook from a list, whichever form it's given in
|
|
2761
|
+
// (#2578)
|
|
2762
|
+
self.config[key] =
|
|
2763
|
+
HOOKS.indexOf(key) > -1
|
|
2764
|
+
? arrayify(options[key])
|
|
2765
|
+
: options[key];
|
|
2766
|
+
});
|
|
2767
|
+
// once every option is in: a callback may read another one given with it
|
|
2768
|
+
keys.forEach(function (key) {
|
|
2769
|
+
var callbacks = CALLBACKS[key];
|
|
2770
|
+
if (callbacks !== undefined)
|
|
2771
|
+
callbacks.forEach(function (x) { return x(); });
|
|
2772
|
+
});
|
|
2652
2773
|
self.redraw();
|
|
2653
2774
|
updateValue(true);
|
|
2654
2775
|
}
|
|
@@ -2784,11 +2905,6 @@
|
|
|
2784
2905
|
}
|
|
2785
2906
|
function setupInputs() {
|
|
2786
2907
|
self.input = getInputElem();
|
|
2787
|
-
/* istanbul ignore next */
|
|
2788
|
-
if (!self.input) {
|
|
2789
|
-
self.config.errorHandler(new Error("Invalid input element specified"));
|
|
2790
|
-
return;
|
|
2791
|
-
}
|
|
2792
2908
|
// hack: store previous type to restore it after destroy()
|
|
2793
2909
|
self.input._type = self.input.type;
|
|
2794
2910
|
self.input.type = "text";
|
|
@@ -2802,6 +2918,12 @@
|
|
|
2802
2918
|
self.altInput.disabled = self.input.disabled;
|
|
2803
2919
|
self.altInput.required = self.input.required;
|
|
2804
2920
|
self.altInput.tabIndex = self.input.tabIndex;
|
|
2921
|
+
// The attribute as written: the autocomplete property reads "" for a
|
|
2922
|
+
// value browsers don't know, such as the "nope" pages write where
|
|
2923
|
+
// Chrome ignores "off" (#2577)
|
|
2924
|
+
var autocomplete = self.input.getAttribute("autocomplete");
|
|
2925
|
+
if (autocomplete !== null)
|
|
2926
|
+
self.altInput.setAttribute("autocomplete", autocomplete);
|
|
2805
2927
|
self.altInput.type = "text";
|
|
2806
2928
|
self.input.setAttribute("type", "hidden");
|
|
2807
2929
|
if (!self.config.static && self.input.parentNode)
|
|
@@ -2843,14 +2965,18 @@
|
|
|
2843
2965
|
// picker offers only the times on the input's step: min is raised to the
|
|
2844
2966
|
// next one, as flatpickr drops a value before minDate, and max is cut to the
|
|
2845
2967
|
// one before. A date input holds no time, and raising min there could move
|
|
2846
|
-
// it a day on
|
|
2968
|
+
// it a day on. A maxDate without a time leaves its whole day open, as
|
|
2969
|
+
// flatpickr does (#2460): max is cut from the day's last moment
|
|
2847
2970
|
function setMobileLimit(type) {
|
|
2848
2971
|
var mobileInput = self.mobileInput;
|
|
2849
2972
|
var limit = self.config[type + "Date"];
|
|
2850
2973
|
if (limit === undefined)
|
|
2851
2974
|
return mobileInput.removeAttribute(type);
|
|
2852
2975
|
var round = type === "min" && mobileInput.type !== "date" ? Math.ceil : Math.floor;
|
|
2853
|
-
|
|
2976
|
+
var date = new Date(limit.getTime());
|
|
2977
|
+
if (type === "max" && !self.maxDateHasTime)
|
|
2978
|
+
date.setHours(23, 59, 59, 999);
|
|
2979
|
+
mobileInput[type] = formatMobileDate(date, round);
|
|
2854
2980
|
}
|
|
2855
2981
|
// A date in the native input's format, put on its step: on a whole minute
|
|
2856
2982
|
// with a step of whole minutes, 60 s by default, and on a whole second with
|
package/dist/flatpickr.min.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:#fff;-webkit-box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08);box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08)}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible}.flatpickr-calendar.open{display:inline-block;z-index:99999}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1);animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1)}.flatpickr-calendar.inline{display:block;position:relative;top:2px}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px)}.flatpickr-calendar.static.open{z-index:999;display:block}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none !important;box-shadow:none !important}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid #e6e6e6}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.arrowRight:after{left:auto;right:22px}.flatpickr-calendar.arrowCenter:before,.flatpickr-calendar.arrowCenter:after{left:50%;right:50%}.flatpickr-calendar.centerMost:before,.flatpickr-calendar.centerMost:after{left:var(--fp-arrow-left,22px);right:auto}.flatpickr-calendar:before{border-width:5px;margin:0 -5px}.flatpickr-calendar:after{border-width:4px;margin:0 -4px}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%}.flatpickr-calendar.arrowTop:before{border-bottom-color:#e6e6e6}.flatpickr-calendar.arrowTop:after{border-bottom-color:#fff}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%}.flatpickr-calendar.arrowBottom:before{border-top-color:#e6e6e6}.flatpickr-calendar.arrowBottom:after{border-top-color:#fff}.flatpickr-calendar:focus{outline:0}.flatpickr-wrapper{position:relative;display:inline-block}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-months .flatpickr-month{background:transparent;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9)}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{/*
|
|
1
|
+
.flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:#fff;-webkit-box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08);box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08)}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible}.flatpickr-calendar.open{display:inline-block;z-index:99999}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1);animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1)}.flatpickr-calendar.inline{display:block;position:relative;top:2px}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px)}.flatpickr-calendar.static.arrowBottom{top:auto;bottom:calc(100% + 2px)}.flatpickr-calendar.static.arrowRight{right:0}@supports (translate:0){.flatpickr-calendar.static.arrowCenter{left:50%;translate:-50%}}.flatpickr-calendar.static.open{z-index:999;display:block}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none !important;box-shadow:none !important}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid #e6e6e6}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.arrowRight:after{left:auto;right:22px}.flatpickr-calendar.arrowCenter:before,.flatpickr-calendar.arrowCenter:after{left:50%;right:50%}.flatpickr-calendar.centerMost:before,.flatpickr-calendar.centerMost:after{left:var(--fp-arrow-left,22px);right:auto}.flatpickr-calendar:before{border-width:5px;margin:0 -5px}.flatpickr-calendar:after{border-width:4px;margin:0 -4px}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%}.flatpickr-calendar.arrowTop:before{border-bottom-color:#e6e6e6}.flatpickr-calendar.arrowTop:after{border-bottom-color:#fff}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%}.flatpickr-calendar.arrowBottom:before{border-top-color:#e6e6e6}.flatpickr-calendar.arrowBottom:after{border-top-color:#fff}.flatpickr-calendar:focus{outline:0}.flatpickr-wrapper{position:relative;display:inline-block}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-months .flatpickr-month{background:transparent;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9)}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{/*
|
|
2
2
|
/*rtl:begin:ignore*/left:0/*
|
|
3
3
|
/*rtl:end:ignore*/}/*
|
|
4
4
|
/*rtl:begin:ignore*/
|