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 CHANGED
@@ -42,6 +42,37 @@ npm install flatpickr@npm:flatpickr-ce
42
42
 
43
43
  ## What's changed since flatpickr 4.6.13
44
44
 
45
+ ### 4.12.0
46
+
47
+ - With a `maxDate` given without a time, such as `"today"`, a `defaultDate`, a `setDate()` or a typed value at any time on that day is kept instead of dropped, and the native mobile input's `max` is that day's last minute ([#2460](https://github.com/flatpickr/flatpickr/issues/2460))
48
+ - With `static: true`, the calendar opens above the input for `position: "above"`, and with the automatic position when it doesn't fit below; `"right"` and `"center"` align it with the input's wrapper ([#2497](https://github.com/flatpickr/flatpickr/issues/2497), [#1847](https://github.com/flatpickr/flatpickr/issues/1847))
49
+ - With `enableTime`, `minTime` or `maxTime` and nothing selected, the time inputs show the default time held within them, the time a picked day gets, and AM/PM follows the hour shown ([#2547](https://github.com/flatpickr/flatpickr/issues/2547))
50
+ - A time input left holding no number, such as "7:13" typed in Firefox or one emptied with Delete, keeps the selected time instead of turning it to 12 AM or 00 ([#2498](https://github.com/flatpickr/flatpickr/issues/2498))
51
+ - A calendar with more than one month or with week numbers, created inside a hidden modal, tab or panel, is sized once it is shown instead of being squeezed to a few pixels ([#2579](https://github.com/flatpickr/flatpickr/issues/2579)); `set("showMonths", 1)` shrinks a calendar back to one month ([#2392](https://github.com/flatpickr/flatpickr/issues/2392))
52
+ - A hook given to `set()` in an object, such as `set({ onChange: fn })`, is called ([#2578](https://github.com/flatpickr/flatpickr/issues/2578))
53
+ - Picking a month in the month dropdown fires `onMonthChange` once instead of twice ([#2398](https://github.com/flatpickr/flatpickr/issues/2398)), and its options no longer carry a tabindex, which kept the dropdown from changing the month in Firefox 51 ([#2438](https://github.com/flatpickr/flatpickr/issues/2438))
54
+ - With rangePlugin and `inline: true`, a day picked on a range that has both ends starts a new range ([#2572](https://github.com/flatpickr/flatpickr/issues/2572)); with nothing selected, focusing the first input keeps the month the calendar shows instead of going to today's ([#2573](https://github.com/flatpickr/flatpickr/issues/2573))
55
+ - With `altInput`, the input shown takes the original input's `autocomplete` attribute, so `autocomplete="off"` works ([#2577](https://github.com/flatpickr/flatpickr/issues/2577))
56
+ - The wheel over a time input or the year no longer throws "CustomEvent is not a constructor" with `dist/plugins/scrollPlugin.js` ([#2510](https://github.com/flatpickr/flatpickr/pull/2510))
57
+ - With `wrap` and no `data-input` element inside, the error says so instead of being a TypeError ([#2404](https://github.com/flatpickr/flatpickr/pull/2404))
58
+ - The time inputs no longer carry `maxlength`, which number inputs don't allow, so pages with them pass HTML validation ([#2372](https://github.com/flatpickr/flatpickr/issues/2372))
59
+
60
+ Behavior changes to check when upgrading:
61
+
62
+ - A `maxDate` without a time, or with a midnight time such as `"2025-03-10 00:00"`, leaves its whole day open: `setDate()`, `defaultDate`, typed and preloaded values at any time that day are kept, `isEnabled(date, false)` returns true for them, and the native mobile input's `max` is `"2025-03-10T23:59:00"` (`23:59:59` with `enableSeconds`) instead of `"2025-03-10T00:00:00"`.
63
+ - A static calendar can open above the input. Pages that moved it there themselves, with rules on `.arrowBottom` such as a transform or a negative `margin-top`, should drop them; a page rule setting `top` on `.flatpickr-calendar.static` no longer applies while it is above. `positionElement` and the element passed to `open()` no longer affect a static calendar. flatpickr.css and the themes have the new `.static` rules; a stylesheet of your own built from an older one doesn't.
64
+ - With `enableTime` and nothing selected, the time inputs show the default time held within `minTime` and `maxTime`, also after `set("minTime")` or `set("maxTime")`. With a 12-hour clock, AM/PM follows the hour shown, so with a `maxDate` whose time is in the morning, a day other than `maxDate`'s gets that morning time instead of the same hour in the afternoon.
65
+ - A time input emptied and left keeps the selected time instead of setting it to 0; type 0 for 0. Left that way, it fires no `onChange`.
66
+ - With rangePlugin and `inline: true`, a day picked on a range that has both ends empties the second input until the next day completes the range, `onClose` fires only then, and with `enableTime` the new range starts at the default time. Calendars that aren't inline are unchanged.
67
+ - With rangePlugin and nothing selected, focusing the first input no longer moves the view, so `changeMonth()` and `jumpToDate()` called before opening hold, and a `minDate` or `maxDate` assigned to `fp.config` without `set()` no longer brings the view within it.
68
+ - `set({ onChange: fn })` replaces the hooks given before, including one a plugin added, as `set("onChange", fn)` does; a `null` hook in an object is kept as `[null]`.
69
+ - A month picked in the dropdown that `changeMonth()` refuses fires no `onMonthChange`.
70
+ - A calendar with more than one month or with week numbers that can't be measured has no inline width until it is laid out. An inline one gets its width in a ResizeObserver callback; a ResizeObserver of the page's own on an element whose size follows the calendar may then report "ResizeObserver loop completed with undelivered notifications" as an error event, which error trackers and Cypress see. Browsers without ResizeObserver (IE, Safari before 13.1) keep such a calendar at one month's width until `set("showMonths", ...)` is called once it is shown.
71
+ - `set("showMonths", 1)` removes the inline width of `.flatpickr-calendar` and `.flatpickr-days`, one the page wrote included.
72
+ - With `altInput`, an `autocomplete` that asks for autofill, such as `"bday"`, is on the input shown too.
73
+ - With `wrap` and no `data-input` element, `errorHandler` no longer gets "Invalid input element specified"; the error is logged with `console.error`.
74
+ - In IE9, typing in the time inputs is no longer cut at two digits; the value is still folded into two when the input is left.
75
+
45
76
  ### 4.11.0
46
77
 
47
78
  - Closing the calendar after browsing to other months without picking a day no longer leaves it there: it reopens on the selected date ([#2835](https://github.com/flatpickr/flatpickr/issues/2835))
package/dist/esm/index.js CHANGED
@@ -37,6 +37,7 @@ function FlatpickrInstance(element, instanceConfig) {
37
37
  var win = element.ownerDocument.defaultView || window;
38
38
  var doc = win.document;
39
39
  var openHandlers = [];
40
+ var layoutObserver;
40
41
  self._handlers = [];
41
42
  self.pluginElements = [];
42
43
  self.loadedPlugins = [];
@@ -108,30 +109,54 @@ function FlatpickrInstance(element, instanceConfig) {
108
109
  }
109
110
  function setCalendarWidth() {
110
111
  var config = self.config;
111
- if (config.weekNumbers === false && config.showMonths === 1) {
112
+ if (self.weekWrapper === undefined && config.showMonths === 1) {
113
+ if (self.daysContainer !== undefined) {
114
+ self.daysContainer.style.removeProperty("width");
115
+ self.calendarContainer.style.removeProperty("width");
116
+ }
117
+ unobserveLayout();
112
118
  return;
113
119
  }
114
120
  else if (config.noCalendar !== true) {
115
- win.requestAnimationFrame(function () {
116
- if (self.calendarContainer !== undefined) {
117
- self.calendarContainer.style.visibility = "hidden";
118
- self.calendarContainer.style.display = "block";
119
- }
120
- if (self.daysContainer !== undefined) {
121
- var daysWidth = (self.days.offsetWidth + 1) * config.showMonths;
122
- self.daysContainer.style.width = daysWidth + "px";
123
- self.calendarContainer.style.width =
124
- daysWidth +
125
- (self.weekWrapper !== undefined
126
- ? self.weekWrapper.offsetWidth
127
- : 0) +
128
- "px";
129
- self.calendarContainer.style.removeProperty("visibility");
130
- self.calendarContainer.style.removeProperty("display");
131
- }
132
- });
121
+ win.requestAnimationFrame(measureCalendarWidth);
133
122
  }
134
123
  }
124
+ function measureCalendarWidth() {
125
+ if (self.calendarContainer !== undefined) {
126
+ self.calendarContainer.style.visibility = "hidden";
127
+ self.calendarContainer.style.display = "block";
128
+ }
129
+ if (self.daysContainer !== undefined) {
130
+ var gridWidth = self.days.offsetWidth;
131
+ if (gridWidth === 0) {
132
+ observeLayout();
133
+ }
134
+ else {
135
+ var daysWidth = (gridWidth + 1) * self.config.showMonths;
136
+ self.daysContainer.style.width = daysWidth + "px";
137
+ self.calendarContainer.style.width =
138
+ daysWidth +
139
+ (self.weekWrapper !== undefined ? self.weekWrapper.offsetWidth : 0) +
140
+ "px";
141
+ unobserveLayout();
142
+ }
143
+ self.calendarContainer.style.removeProperty("visibility");
144
+ self.calendarContainer.style.removeProperty("display");
145
+ }
146
+ }
147
+ function observeLayout() {
148
+ var Observer = win.ResizeObserver;
149
+ if (layoutObserver !== undefined || Observer === undefined)
150
+ return;
151
+ layoutObserver = new Observer(measureCalendarWidth);
152
+ layoutObserver.observe(self.calendarContainer);
153
+ }
154
+ function unobserveLayout() {
155
+ if (layoutObserver === undefined)
156
+ return;
157
+ layoutObserver.disconnect();
158
+ layoutObserver = undefined;
159
+ }
135
160
  function defaultTimeDate() {
136
161
  return new Date(withinLimits(new Date()).getTime());
137
162
  }
@@ -165,11 +190,17 @@ function FlatpickrInstance(element, instanceConfig) {
165
190
  return hour % 12;
166
191
  }
167
192
  }
193
+ function readTimeInput(value, shown) {
194
+ var number = parseInt(value, 10);
195
+ return isNaN(number) && shown !== undefined ? shown : number || 0;
196
+ }
168
197
  function setHoursFromInputs() {
169
198
  if (self.hourElement === undefined || self.minuteElement === undefined)
170
199
  return;
171
- var hours = (parseInt(self.hourElement.value.slice(-2), 10) || 0) % 24, minutes = (parseInt(self.minuteElement.value, 10) || 0) % 60, seconds = self.secondElement !== undefined
172
- ? (parseInt(self.secondElement.value, 10) || 0) % 60
200
+ var shown = self.latestSelectedDateObj;
201
+ var hours = readTimeInput(self.hourElement.value.slice(-2), shown && shown.getHours()) % 24, minutes = readTimeInput(self.minuteElement.value, shown && shown.getMinutes()) %
202
+ 60, seconds = self.secondElement !== undefined
203
+ ? readTimeInput(self.secondElement.value, shown && shown.getSeconds()) % 60
173
204
  : 0;
174
205
  if (self.amPM !== undefined) {
175
206
  hours = ampm2military(hours, self.amPM.textContent);
@@ -666,7 +697,6 @@ function FlatpickrInstance(element, instanceConfig) {
666
697
  var month = createElement("option", "flatpickr-monthDropdown-month");
667
698
  month.value = new Date(self.currentYear, i).getMonth().toString();
668
699
  month.textContent = monthToStr(i, self.config.shorthandCurrentMonth, self.l10n);
669
- month.tabIndex = -1;
670
700
  if (self.currentMonth === i) {
671
701
  month.selected = true;
672
702
  }
@@ -689,7 +719,6 @@ function FlatpickrInstance(element, instanceConfig) {
689
719
  var target = getEventTarget(e);
690
720
  var selectedMonth = parseInt(target.value, 10);
691
721
  self.changeMonth(selectedMonth - self.currentMonth);
692
- triggerEvent("onMonthChange");
693
722
  });
694
723
  buildMonthSwitch();
695
724
  monthElement = self.monthsDropdownContainer;
@@ -795,10 +824,8 @@ function FlatpickrInstance(element, instanceConfig) {
795
824
  : defaults.minutes);
796
825
  self.hourElement.setAttribute("min", self.config.time_24hr ? "0" : "1");
797
826
  self.hourElement.setAttribute("max", self.config.time_24hr ? "23" : "12");
798
- self.hourElement.setAttribute("maxlength", "2");
799
827
  self.minuteElement.setAttribute("min", "0");
800
828
  self.minuteElement.setAttribute("max", "59");
801
- self.minuteElement.setAttribute("maxlength", "2");
802
829
  self.timeContainer.appendChild(hourInput);
803
830
  self.timeContainer.appendChild(separator);
804
831
  self.timeContainer.appendChild(minuteInput);
@@ -816,14 +843,13 @@ function FlatpickrInstance(element, instanceConfig) {
816
843
  : defaults.seconds);
817
844
  self.secondElement.setAttribute("min", "0");
818
845
  self.secondElement.setAttribute("max", "59");
819
- self.secondElement.setAttribute("maxlength", "2");
820
846
  self.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
821
847
  self.timeContainer.appendChild(secondInput);
822
848
  }
823
849
  if (!self.config.time_24hr) {
824
850
  self.amPM = createElement("span", "flatpickr-am-pm", self.l10n.amPM[int((self.latestSelectedDateObj
825
851
  ? self.hourElement.value
826
- : self.config.defaultHour) > 11)]);
852
+ : defaults.hours) > 11)]);
827
853
  self.amPM.title = self.l10n.toggleTitle;
828
854
  self.amPM.tabIndex = -1;
829
855
  self.timeContainer.appendChild(self.amPM);
@@ -956,6 +982,7 @@ function FlatpickrInstance(element, instanceConfig) {
956
982
  }
957
983
  self._handlers = [];
958
984
  unbindOpenEvents();
985
+ unobserveLayout();
959
986
  if (self.mobileInput) {
960
987
  if (self.mobileInput.parentNode)
961
988
  self.mobileInput.parentNode.removeChild(self.mobileInput);
@@ -1082,10 +1109,10 @@ function FlatpickrInstance(element, instanceConfig) {
1082
1109
  var dateToCheck = self.parseDate(date, undefined, timeless);
1083
1110
  if ((self.config.minDate &&
1084
1111
  dateToCheck &&
1085
- compareDates(dateToCheck, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0) ||
1112
+ compareDates(dateToCheck, self.config.minDate, timeless || !self.minDateHasTime) < 0) ||
1086
1113
  (self.config.maxDate &&
1087
1114
  dateToCheck &&
1088
- compareDates(dateToCheck, self.config.maxDate, timeless !== undefined ? timeless : !self.maxDateHasTime) > 0))
1115
+ compareDates(dateToCheck, self.config.maxDate, timeless || !self.maxDateHasTime) > 0))
1089
1116
  return false;
1090
1117
  if (!self.config.enable && self.config.disable.length === 0)
1091
1118
  return true;
@@ -1396,6 +1423,8 @@ function FlatpickrInstance(element, instanceConfig) {
1396
1423
  bindOpenEvents();
1397
1424
  self.calendarContainer.classList.add("open");
1398
1425
  self._input.classList.add("active");
1426
+ if (layoutObserver !== undefined)
1427
+ measureCalendarWidth();
1399
1428
  triggerEvent("onOpen");
1400
1429
  positionCalendar(positionElement);
1401
1430
  }
@@ -1486,6 +1515,8 @@ function FlatpickrInstance(element, instanceConfig) {
1486
1515
  });
1487
1516
  var minMaxTimeSetter = function (type) { return function (val) {
1488
1517
  self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i:S");
1518
+ if (self.selectedDates && !self.selectedDates.length)
1519
+ setDefaultHours();
1489
1520
  }; };
1490
1521
  Object.defineProperty(self.config, "minTime", {
1491
1522
  get: function () { return self.config._minTime; },
@@ -1569,9 +1600,12 @@ function FlatpickrInstance(element, instanceConfig) {
1569
1600
  self.config.altFormat = formats.altFormat;
1570
1601
  }
1571
1602
  function getInputElem() {
1572
- return self.config.wrap
1573
- ? element.querySelector("[data-input]")
1574
- : element;
1603
+ if (!self.config.wrap)
1604
+ return element;
1605
+ var input = element.querySelector("[data-input]");
1606
+ if (!input)
1607
+ throw new Error('flatpickr: "wrap" needs an input with the data-input attribute inside the element');
1608
+ return input;
1575
1609
  }
1576
1610
  function setupLocale() {
1577
1611
  if (typeof self.config.locale !== "object" &&
@@ -1610,7 +1644,10 @@ function FlatpickrInstance(element, instanceConfig) {
1610
1644
  if (self.calendarContainer === undefined)
1611
1645
  return;
1612
1646
  triggerEvent("onPreCalendarPosition");
1613
- var positionElement = customPositionElement || self._positionElement;
1647
+ var wrapper = self.config.static && !self.config.inline
1648
+ ? self.calendarContainer.parentNode
1649
+ : undefined;
1650
+ var positionElement = wrapper || customPositionElement || self._positionElement;
1614
1651
  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, keepInViewport = isAutoVertical &&
1615
1652
  !fitsBelow &&
1616
1653
  !fitsAbove &&
@@ -1618,7 +1655,11 @@ function FlatpickrInstance(element, instanceConfig) {
1618
1655
  !self.config.inline, showOnTop = keepInViewport
1619
1656
  ? inputBounds.top > distanceFromBottom
1620
1657
  : configPosVertical === "above" ||
1621
- (isAutoVertical && !fitsBelow && fitsAbove);
1658
+ (isAutoVertical &&
1659
+ !fitsBelow &&
1660
+ fitsAbove &&
1661
+ (wrapper === undefined ||
1662
+ inputBounds.top - getClipTop(wrapper) > calendarHeight));
1622
1663
  var anchoredTop = win.pageYOffset +
1623
1664
  inputBounds.top +
1624
1665
  (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
@@ -1664,6 +1705,18 @@ function FlatpickrInstance(element, instanceConfig) {
1664
1705
  self.calendarContainer.style.left = left - origin.left + "px";
1665
1706
  self.calendarContainer.style.right = "auto";
1666
1707
  }
1708
+ function getClipTop(wrapper) {
1709
+ var _a;
1710
+ var clipTop = 0;
1711
+ for (var ancestor = wrapper; ancestor !== null; ancestor =
1712
+ ancestor.assignedSlot ||
1713
+ ancestor.parentElement || ((_a = ancestor.parentNode) === null || _a === void 0 ? void 0 : _a.host) ||
1714
+ null) {
1715
+ if (win.getComputedStyle(ancestor).overflowY !== "visible")
1716
+ clipTop = Math.max(clipTop, ancestor.getBoundingClientRect().top + ancestor.clientTop);
1717
+ }
1718
+ return clipTop;
1719
+ }
1667
1720
  function getContainingBlockOrigin() {
1668
1721
  var containingBlock = self.calendarContainer.offsetParent;
1669
1722
  if (containingBlock === doc.body && isStatic(doc.body))
@@ -1797,22 +1850,23 @@ function FlatpickrInstance(element, instanceConfig) {
1797
1850
  ],
1798
1851
  };
1799
1852
  function set(option, value) {
1800
- if (option !== null && typeof option === "object") {
1801
- Object.assign(self.config, option);
1802
- Object.assign(userConfig, option);
1803
- for (var key in option) {
1804
- if (CALLBACKS[key] !== undefined)
1805
- CALLBACKS[key].forEach(function (x) { return x(); });
1806
- }
1807
- }
1808
- else {
1809
- self.config[option] = value;
1810
- userConfig[option] = value;
1811
- if (CALLBACKS[option] !== undefined)
1812
- CALLBACKS[option].forEach(function (x) { return x(); });
1813
- else if (HOOKS.indexOf(option) > -1)
1814
- self.config[option] = arrayify(value);
1815
- }
1853
+ var _a;
1854
+ var options = option !== null && typeof option === "object"
1855
+ ? option
1856
+ : (_a = {}, _a[option] = value, _a);
1857
+ var keys = Object.keys(options);
1858
+ keys.forEach(function (key) {
1859
+ userConfig[key] = options[key];
1860
+ self.config[key] =
1861
+ HOOKS.indexOf(key) > -1
1862
+ ? arrayify(options[key])
1863
+ : options[key];
1864
+ });
1865
+ keys.forEach(function (key) {
1866
+ var callbacks = CALLBACKS[key];
1867
+ if (callbacks !== undefined)
1868
+ callbacks.forEach(function (x) { return x(); });
1869
+ });
1816
1870
  self.redraw();
1817
1871
  updateValue(true);
1818
1872
  }
@@ -1937,10 +1991,6 @@ function FlatpickrInstance(element, instanceConfig) {
1937
1991
  }
1938
1992
  function setupInputs() {
1939
1993
  self.input = getInputElem();
1940
- if (!self.input) {
1941
- self.config.errorHandler(new Error("Invalid input element specified"));
1942
- return;
1943
- }
1944
1994
  self.input._type = self.input.type;
1945
1995
  self.input.type = "text";
1946
1996
  self.input.classList.add("flatpickr-input");
@@ -1952,6 +2002,9 @@ function FlatpickrInstance(element, instanceConfig) {
1952
2002
  self.altInput.disabled = self.input.disabled;
1953
2003
  self.altInput.required = self.input.required;
1954
2004
  self.altInput.tabIndex = self.input.tabIndex;
2005
+ var autocomplete = self.input.getAttribute("autocomplete");
2006
+ if (autocomplete !== null)
2007
+ self.altInput.setAttribute("autocomplete", autocomplete);
1955
2008
  self.altInput.type = "text";
1956
2009
  self.input.setAttribute("type", "hidden");
1957
2010
  if (!self.config.static && self.input.parentNode)
@@ -1992,7 +2045,10 @@ function FlatpickrInstance(element, instanceConfig) {
1992
2045
  if (limit === undefined)
1993
2046
  return mobileInput.removeAttribute(type);
1994
2047
  var round = type === "min" && mobileInput.type !== "date" ? Math.ceil : Math.floor;
1995
- mobileInput[type] = formatMobileDate(limit, round);
2048
+ var date = new Date(limit.getTime());
2049
+ if (type === "max" && !self.maxDateHasTime)
2050
+ date.setHours(23, 59, 59, 999);
2051
+ mobileInput[type] = formatMobileDate(date, round);
1996
2052
  }
1997
2053
  function formatMobileDate(date, round) {
1998
2054
  if (round === void 0) { round = Math.floor; }
@@ -110,18 +110,27 @@ function rangePlugin(config) {
110
110
  secondInput.value = second;
111
111
  };
112
112
  fp._typedValue = typedValue;
113
+ var startNewRange = fp._startNewRange;
113
114
  fp._startNewRange = function () {
114
- fp.selectedDates = [];
115
+ if (fp.config.inline) {
116
+ _prevDates = [];
117
+ startNewRange();
118
+ }
119
+ else {
120
+ fp.selectedDates = [];
121
+ }
115
122
  };
116
123
  fp._bind(fp._input, "focus", function () {
117
124
  var anchor = firstInputAnchor();
118
125
  if (fp.isOpen && fp._positionElement !== anchor)
119
126
  fp._positionCalendar(anchor);
120
127
  fp._positionElement = anchor;
121
- fp.latestSelectedDateObj = fp.selectedDates[0];
122
- fp._setHoursFromDate(fp.selectedDates[0]);
128
+ if (fp.selectedDates[0]) {
129
+ fp.latestSelectedDateObj = fp.selectedDates[0];
130
+ fp._setHoursFromDate(fp.selectedDates[0]);
131
+ fp.jumpToDate(fp.selectedDates[0]);
132
+ }
123
133
  _secondInputFocused = false;
124
- fp.jumpToDate(fp.selectedDates[0]);
125
134
  });
126
135
  fp.setDate(fp.selectedDates, false);
127
136
  plugin.onValueUpdate(fp.selectedDates);
@@ -1,6 +1,6 @@
1
1
  import { getEventTarget } from "../utils/dom";
2
2
  if (typeof window.CustomEvent !== "function") {
3
- var CustomEvent_1 = function (typeArg, eventInitDict) {
3
+ var CustomEventPolyfill = function (typeArg, eventInitDict) {
4
4
  eventInitDict = eventInitDict || {
5
5
  bubbles: false,
6
6
  cancelable: false,
@@ -10,8 +10,8 @@ if (typeof window.CustomEvent !== "function") {
10
10
  evt.initCustomEvent(typeArg, eventInitDict.bubbles, eventInitDict.cancelable, eventInitDict.detail);
11
11
  return evt;
12
12
  };
13
- CustomEvent_1.prototype = window.Event.prototype;
14
- window.CustomEvent = CustomEvent_1;
13
+ CustomEventPolyfill.prototype = window.Event.prototype;
14
+ window.CustomEvent = CustomEventPolyfill;
15
15
  }
16
16
  function delta(e) {
17
17
  return Math.max(-1, Math.min(1, e.wheelDelta || -e.deltaY));
@@ -133,27 +133,45 @@ export function getDefaultHours(config, date) {
133
133
  compareDates(date, limit) === 0 &&
134
134
  (limit.getHours() > 0 || limit.getMinutes() > 0 || limit.getSeconds() > 0);
135
135
  };
136
- if (holdsTime(config.minDate)) {
137
- var minHour = config.minDate.getHours();
138
- var minMinutes = config.minDate.getMinutes();
139
- var minSeconds = config.minDate.getSeconds();
140
- if (hours < minHour) {
141
- hours = minHour;
136
+ var holdAbove = function (limit) {
137
+ hours = Math.max(hours, limit.getHours());
138
+ if (hours === limit.getHours()) {
139
+ minutes = Math.max(minutes, limit.getMinutes());
140
+ if (minutes === limit.getMinutes())
141
+ seconds = Math.max(seconds, limit.getSeconds());
142
142
  }
143
- if (hours === minHour && minutes < minMinutes) {
144
- minutes = minMinutes;
143
+ };
144
+ var holdBelow = function (limit) {
145
+ hours = Math.min(hours, limit.getHours());
146
+ if (hours === limit.getHours()) {
147
+ minutes = Math.min(minutes, limit.getMinutes());
148
+ if (minutes === limit.getMinutes())
149
+ seconds = Math.min(seconds, limit.getSeconds());
150
+ }
151
+ };
152
+ var secondsOf = function (time) {
153
+ return calculateSecondsSinceMidnight(time.getHours(), time.getMinutes(), time.getSeconds());
154
+ };
155
+ if (holdsTime(config.minDate))
156
+ holdAbove(config.minDate);
157
+ if (holdsTime(config.maxDate))
158
+ holdBelow(config.maxDate);
159
+ var minTime = config.minTime, maxTime = config.maxTime;
160
+ if (minTime !== undefined &&
161
+ maxTime !== undefined &&
162
+ secondsOf(minTime) > secondsOf(maxTime)) {
163
+ var time = calculateSecondsSinceMidnight(hours, minutes, seconds);
164
+ if (time > secondsOf(maxTime) && time < secondsOf(minTime)) {
165
+ hours = minTime.getHours();
166
+ minutes = minTime.getMinutes();
167
+ seconds = minTime.getSeconds();
145
168
  }
146
- if (hours === minHour && minutes === minMinutes && seconds < minSeconds)
147
- seconds = config.minDate.getSeconds();
148
169
  }
149
- if (holdsTime(config.maxDate)) {
150
- var maxHr = config.maxDate.getHours();
151
- var maxMinutes = config.maxDate.getMinutes();
152
- hours = Math.min(hours, maxHr);
153
- if (hours === maxHr)
154
- minutes = Math.min(maxMinutes, minutes);
155
- if (hours === maxHr && minutes === maxMinutes)
156
- seconds = Math.min(seconds, config.maxDate.getSeconds());
170
+ else {
171
+ if (maxTime !== undefined)
172
+ holdBelow(maxTime);
173
+ if (minTime !== undefined)
174
+ holdAbove(minTime);
157
175
  }
158
176
  return { hours: hours, minutes: minutes, seconds: seconds };
159
177
  }
@@ -45,6 +45,19 @@
45
45
  position: absolute;
46
46
  top: calc(100% + 2px);
47
47
  }
48
+ .flatpickr-calendar.static.arrowBottom {
49
+ top: auto;
50
+ bottom: calc(100% + 2px);
51
+ }
52
+ .flatpickr-calendar.static.arrowRight {
53
+ right: 0;
54
+ }
55
+ @supports (translate: 0) {
56
+ .flatpickr-calendar.static.arrowCenter {
57
+ left: 50%;
58
+ translate: -50%;
59
+ }
60
+ }
48
61
  .flatpickr-calendar.static.open {
49
62
  z-index: 999;
50
63
  display: block;