flatpickr-ce 4.9.0 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +31 -0
  2. package/dist/esm/index.js +67 -36
  3. package/dist/esm/l10n/ckb.js +1 -9
  4. package/dist/esm/l10n/fi.js +1 -0
  5. package/dist/esm/l10n/ga.js +1 -1
  6. package/dist/esm/l10n/id.js +1 -1
  7. package/dist/esm/l10n/index.js +4 -0
  8. package/dist/esm/l10n/no.js +1 -1
  9. package/dist/esm/l10n/vn.js +1 -1
  10. package/dist/esm/plugins/momentPlugin.js +1 -1
  11. package/dist/esm/plugins/monthSelect/index.js +13 -9
  12. package/dist/esm/utils/dates.js +8 -3
  13. package/dist/flatpickr.js +113 -40
  14. package/dist/flatpickr.min.js +2 -2
  15. package/dist/l10n/ar-dz.d.ts +3 -0
  16. package/dist/l10n/ar.d.ts +3 -0
  17. package/dist/l10n/at.d.ts +3 -0
  18. package/dist/l10n/az.d.ts +3 -0
  19. package/dist/l10n/be.d.ts +3 -0
  20. package/dist/l10n/bg.d.ts +3 -0
  21. package/dist/l10n/bn.d.ts +3 -0
  22. package/dist/l10n/br.d.ts +3 -0
  23. package/dist/l10n/bs.d.ts +3 -0
  24. package/dist/l10n/cat.d.ts +3 -0
  25. package/dist/l10n/ckb.d.ts +3 -0
  26. package/dist/l10n/ckb.js +1 -9
  27. package/dist/l10n/cs.d.ts +3 -0
  28. package/dist/l10n/cy.d.ts +3 -0
  29. package/dist/l10n/da.d.ts +3 -0
  30. package/dist/l10n/de.d.ts +3 -0
  31. package/dist/l10n/eo.d.ts +3 -0
  32. package/dist/l10n/es.d.ts +3 -0
  33. package/dist/l10n/et.d.ts +3 -0
  34. package/dist/l10n/fa.d.ts +3 -0
  35. package/dist/l10n/fi.d.ts +3 -0
  36. package/dist/l10n/fi.js +1 -0
  37. package/dist/l10n/fo.d.ts +3 -0
  38. package/dist/l10n/fr.d.ts +3 -0
  39. package/dist/l10n/ga.d.ts +3 -0
  40. package/dist/l10n/ga.js +1 -1
  41. package/dist/l10n/gl.d.ts +3 -0
  42. package/dist/l10n/gr.d.ts +3 -0
  43. package/dist/l10n/he.d.ts +3 -0
  44. package/dist/l10n/hi.d.ts +3 -0
  45. package/dist/l10n/hr.d.ts +3 -0
  46. package/dist/l10n/hu.d.ts +3 -0
  47. package/dist/l10n/hy.d.ts +3 -0
  48. package/dist/l10n/id.d.ts +3 -0
  49. package/dist/l10n/id.js +1 -1
  50. package/dist/l10n/index.js +191 -141
  51. package/dist/l10n/is.d.ts +3 -0
  52. package/dist/l10n/it.d.ts +3 -0
  53. package/dist/l10n/ja.d.ts +3 -0
  54. package/dist/l10n/ka.d.ts +3 -0
  55. package/dist/l10n/km.d.ts +3 -0
  56. package/dist/l10n/ko.d.ts +3 -0
  57. package/dist/l10n/kz.d.ts +3 -0
  58. package/dist/l10n/lt.d.ts +3 -0
  59. package/dist/l10n/lv.d.ts +3 -0
  60. package/dist/l10n/mk.d.ts +3 -0
  61. package/dist/l10n/mn.d.ts +3 -0
  62. package/dist/l10n/ms.d.ts +3 -0
  63. package/dist/l10n/my.d.ts +3 -0
  64. package/dist/l10n/nl.d.ts +3 -0
  65. package/dist/l10n/nn.d.ts +3 -0
  66. package/dist/l10n/no.d.ts +3 -0
  67. package/dist/l10n/no.js +1 -1
  68. package/dist/l10n/pa.d.ts +3 -0
  69. package/dist/l10n/pl.d.ts +3 -0
  70. package/dist/l10n/pt.d.ts +3 -0
  71. package/dist/l10n/ro.d.ts +3 -0
  72. package/dist/l10n/ru.d.ts +3 -0
  73. package/dist/l10n/si.d.ts +3 -0
  74. package/dist/l10n/sk.d.ts +3 -0
  75. package/dist/l10n/sl.d.ts +3 -0
  76. package/dist/l10n/sq.d.ts +3 -0
  77. package/dist/l10n/sr-cyr.d.ts +3 -0
  78. package/dist/l10n/sr.d.ts +3 -0
  79. package/dist/l10n/sv.d.ts +3 -0
  80. package/dist/l10n/tg.d.ts +3 -0
  81. package/dist/l10n/th.d.ts +3 -0
  82. package/dist/l10n/tr.d.ts +3 -0
  83. package/dist/l10n/uk.d.ts +3 -0
  84. package/dist/l10n/uz.d.ts +3 -0
  85. package/dist/l10n/uz_latn.d.ts +3 -0
  86. package/dist/l10n/vn.d.ts +3 -0
  87. package/dist/l10n/vn.js +1 -1
  88. package/dist/l10n/zh.d.ts +3 -0
  89. package/dist/l10n/zh_tw.d.ts +3 -0
  90. package/dist/plugins/momentPlugin.js +1 -1
  91. package/dist/plugins/monthSelect/index.js +17 -10
  92. package/dist/themes/airbnb.css +9 -10
  93. package/dist/types/instance.d.ts +1 -0
  94. package/dist/types/locale.d.ts +1 -1
  95. package/dist/types/options.d.ts +2 -0
  96. package/dist/typings.d.ts +1 -1
  97. package/dist/utils/dates.d.ts +1 -1
  98. package/package.json +1 -1
  99. package/src/style/themes/airbnb.styl +4 -8
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.10.0
46
+
47
+ - The native mobile input follows `set("minDate")` and `set("maxDate")`, and its `min` and `max` are a date and time with `enableTime` and a time with `noCalendar`, on a time its picker can offer ([#2860](https://github.com/flatpickr/flatpickr/issues/2860))
48
+ - With `enableSeconds`, the native mobile input shows and picks seconds ([#2908](https://github.com/flatpickr/flatpickr/issues/2908))
49
+ - New `secondIncrement` option for the seconds input; without it the seconds step by `minuteIncrement` as before ([#2912](https://github.com/flatpickr/flatpickr/pull/2912))
50
+ - A time off its increment, as `minDate` can give, no longer keeps a form with the calendar inside it from submitting, and `set("hourIncrement")` and `set("minuteIncrement")` apply at once ([#2923](https://github.com/flatpickr/flatpickr/issues/2923))
51
+ - `enable` and `disable` are checked by day for a value with a time, as for a click ([#2855](https://github.com/flatpickr/flatpickr/issues/2855))
52
+ - The default time is held to `minDate` and `maxDate` only on their own day, so a date-only `maxDate` no longer turns it into 00:00 ([#2894](https://github.com/flatpickr/flatpickr/issues/2894))
53
+ - In multiple mode, dates typed without the space after the conjunction, such as `01/08/2023,02/08/2023`, are read as separate dates ([#2922](https://github.com/flatpickr/flatpickr/issues/2922))
54
+ - monthSelect's multiple mode adds and removes months on click ([#2849](https://github.com/flatpickr/flatpickr/issues/2849), [#2858](https://github.com/flatpickr/flatpickr/issues/2858))
55
+ - In range mode, a tapped end can no longer cross a disabled day ([#2974](https://github.com/flatpickr/flatpickr/pull/2974))
56
+ - With `allowInput`, Escape in the input closes the calendar ([#2915](https://github.com/flatpickr/flatpickr/pull/2915))
57
+ - `set("locale")` switches the time inputs to the locale's 12- or 24-hour form and AM/PM ([#2954](https://github.com/flatpickr/flatpickr/issues/2954))
58
+ - A year past what a Date can hold leaves the calendar as it was instead of breaking it ([#2906](https://github.com/flatpickr/flatpickr/issues/2906))
59
+ - `element._flatpickr` is the instance in the hooks `init` fires and in plugins ([#2977](https://github.com/flatpickr/flatpickr/issues/2977))
60
+ - The airbnb theme's IE rule is a media query that CSS parsers such as lightningcss accept ([#2976](https://github.com/flatpickr/flatpickr/issues/2976))
61
+ - The main entry is typed as `export =`, so the default import works under `moduleResolution` `node16` and `nodenext` ([#2857](https://github.com/flatpickr/flatpickr/pull/2857))
62
+ - Locales: Finnish ranges are separated with an en dash and Indonesian ones with "sampai"; Irish is registered as `ga`, Vietnamese also as `vi` and Norwegian also as `nb`; the Kurdish (Sorani) weekday shorthand is abbreviated ([#2842](https://github.com/flatpickr/flatpickr/pull/2842), [#2966](https://github.com/flatpickr/flatpickr/pull/2966), [#2848](https://github.com/flatpickr/flatpickr/pull/2848), [#2867](https://github.com/flatpickr/flatpickr/pull/2867), [#2904](https://github.com/flatpickr/flatpickr/pull/2904), [#2895](https://github.com/flatpickr/flatpickr/pull/2895))
63
+
64
+ Behavior changes to check when upgrading:
65
+
66
+ - Finnish ranges saved with " to " and Indonesian ones saved with " - " read as a same-day range of their first date. Replace the separator in stored values, or keep it with `locale: { ...Finnish, rangeSeparator: " to " }`.
67
+ - `locale: "hr"` no longer gives Irish; use `"ga"`.
68
+ - TypeScript: under `moduleResolution` `node` with neither `esModuleInterop` nor `allowSyntheticDefaultImports`, the default import is an error (TS1259); turn on `allowSyntheticDefaultImports`. `import * as flatpickr` is typed as the function itself, so `flatpickr.default(...)` no longer compiles.
69
+ - A value with a time (`defaultDate`, `setDate`, typed text) on a day `disable` lists is dropped, and one on a day `enable` lists is kept; an `enable` or `disable` function is called with midnight of its day, as for a click.
70
+ - In multiple mode, a conjunction without leading whitespace whose trimmed part appears in `dateFormat`, such as the default ", " with `"j,M,Y"`, now splits a date apart. A custom `parseDate` gets each date with the whitespace around it trimmed.
71
+ - With the native mobile input and `enableTime` or `noCalendar`, the native picker keeps to `minDate` and `maxDate`, which it ignored. A value kept outside them, as `allowInvalidPreload` keeps one, leaves the input invalid, so its form doesn't submit until it's changed.
72
+ - The calendar's hour, minute and second inputs have no `step` attribute.
73
+ - With `enableTime`, `set("locale")` rebuilds the time inputs, so listeners attached directly to them are lost, as on `set("time_24hr")`.
74
+ - In monthSelect, the view stays on the year of the month picked.
75
+
45
76
  ### 4.9.0
46
77
 
47
78
  - New yearSelect plugin: a year-only picker modeled on monthSelect, for single, multiple and range mode ([#5](https://github.com/colinli007/flatpickr-ce/issues/5), [#6](https://github.com/colinli007/flatpickr-ce/pull/6))
package/dist/esm/index.js CHANGED
@@ -44,6 +44,7 @@ function FlatpickrInstance(element, instanceConfig) {
44
44
  self._positionCalendar = positionCalendar;
45
45
  self._showValue = showValue;
46
46
  self._typedValue = typedValue;
47
+ self._getIncrement = getIncrement;
47
48
  self.changeMonth = changeMonth;
48
49
  self.changeYear = changeYear;
49
50
  self.clear = clear;
@@ -129,13 +130,13 @@ function FlatpickrInstance(element, instanceConfig) {
129
130
  });
130
131
  }
131
132
  }
133
+ function defaultTimeDate() {
134
+ return new Date(withinLimits(new Date()).getTime());
135
+ }
132
136
  function updateTime(e) {
133
137
  if (self.selectedDates.length === 0) {
134
- var defaultDate = self.config.minDate === undefined ||
135
- compareDates(new Date(), self.config.minDate) >= 0
136
- ? new Date()
137
- : new Date(self.config.minDate.getTime());
138
- var defaults = getDefaultHours(self.config);
138
+ var defaultDate = defaultTimeDate();
139
+ var defaults = getDefaultHours(self.config, defaultDate);
139
140
  defaultDate.setHours(defaults.hours, defaults.minutes, defaults.seconds, defaultDate.getMilliseconds());
140
141
  self.selectedDates = [defaultDate];
141
142
  self.latestSelectedDateObj = defaultDate;
@@ -387,6 +388,14 @@ function FlatpickrInstance(element, instanceConfig) {
387
388
  event.delta = delta;
388
389
  input && input.dispatchEvent(event);
389
390
  }
391
+ function getIncrement(input) {
392
+ var _a;
393
+ return Number(input === self.hourElement
394
+ ? self.config.hourIncrement
395
+ : input === self.minuteElement
396
+ ? self.config.minuteIncrement
397
+ : (_a = self.config.secondIncrement) !== null && _a !== void 0 ? _a : self.config.minuteIncrement);
398
+ }
390
399
  function build() {
391
400
  var fragment = doc.createDocumentFragment();
392
401
  self.calendarContainer = createElement("div", "flatpickr-calendar");
@@ -740,7 +749,7 @@ function FlatpickrInstance(element, instanceConfig) {
740
749
  self.calendarContainer.classList.add("hasTime");
741
750
  if (self.config.noCalendar)
742
751
  self.calendarContainer.classList.add("noCalendar");
743
- var defaults = getDefaultHours(self.config);
752
+ var defaults = getDefaultHours(self.config, defaultTimeDate());
744
753
  self.timeContainer = createElement("div", "flatpickr-time");
745
754
  self.timeContainer.tabIndex = -1;
746
755
  var separator = createElement("span", "flatpickr-time-separator", ":");
@@ -763,8 +772,6 @@ function FlatpickrInstance(element, instanceConfig) {
763
772
  self.minuteElement.value = pad(self.latestSelectedDateObj
764
773
  ? self.latestSelectedDateObj.getMinutes()
765
774
  : defaults.minutes);
766
- self.hourElement.setAttribute("step", self.config.hourIncrement.toString());
767
- self.minuteElement.setAttribute("step", self.config.minuteIncrement.toString());
768
775
  self.hourElement.setAttribute("min", self.config.time_24hr ? "0" : "1");
769
776
  self.hourElement.setAttribute("max", self.config.time_24hr ? "23" : "12");
770
777
  self.hourElement.setAttribute("maxlength", "2");
@@ -785,7 +792,6 @@ function FlatpickrInstance(element, instanceConfig) {
785
792
  self.secondElement.value = pad(self.latestSelectedDateObj
786
793
  ? self.latestSelectedDateObj.getSeconds()
787
794
  : defaults.seconds);
788
- self.secondElement.setAttribute("step", self.minuteElement.getAttribute("step"));
789
795
  self.secondElement.setAttribute("min", "0");
790
796
  self.secondElement.setAttribute("max", "59");
791
797
  self.secondElement.setAttribute("maxlength", "2");
@@ -888,7 +894,7 @@ function FlatpickrInstance(element, instanceConfig) {
888
894
  self.currentMonth = initialDate.getMonth();
889
895
  }
890
896
  if (self.config.enableTime === true) {
891
- var _a = getDefaultHours(self.config), hours = _a.hours, minutes = _a.minutes, seconds = _a.seconds;
897
+ var _a = getDefaultHours(self.config, defaultTimeDate()), hours = _a.hours, minutes = _a.minutes, seconds = _a.seconds;
892
898
  setHours(hours, minutes, seconds);
893
899
  }
894
900
  self.redraw();
@@ -1017,6 +1023,7 @@ function FlatpickrInstance(element, instanceConfig) {
1017
1023
  }
1018
1024
  function changeYear(newYear) {
1019
1025
  if (!newYear ||
1026
+ isNaN(new Date(newYear, self.currentMonth, 1).getTime()) ||
1020
1027
  (self.config.minDate && newYear < self.config.minDate.getFullYear()) ||
1021
1028
  (self.config.maxDate && newYear > self.config.maxDate.getFullYear()))
1022
1029
  return;
@@ -1050,28 +1057,25 @@ function FlatpickrInstance(element, instanceConfig) {
1050
1057
  return true;
1051
1058
  if (dateToCheck === undefined)
1052
1059
  return false;
1060
+ var day = new Date(dateToCheck.getTime());
1061
+ day.setHours(0, 0, 0, 0);
1053
1062
  var bool = !!self.config.enable, array = (_a = self.config.enable) !== null && _a !== void 0 ? _a : self.config.disable;
1054
1063
  for (var i = 0, d = void 0; i < array.length; i++) {
1055
1064
  d = array[i];
1056
1065
  if (typeof d === "function" &&
1057
- d(dateToCheck))
1066
+ d(day))
1058
1067
  return bool;
1059
- else if (d instanceof Date &&
1060
- dateToCheck !== undefined &&
1061
- d.getTime() === dateToCheck.getTime())
1068
+ else if (d instanceof Date && d.getTime() === day.getTime())
1062
1069
  return bool;
1063
1070
  else if (typeof d === "string") {
1064
1071
  var parsed = self.parseDate(d, undefined, true);
1065
- return parsed && parsed.getTime() === dateToCheck.getTime()
1066
- ? bool
1067
- : !bool;
1072
+ return parsed && parsed.getTime() === day.getTime() ? bool : !bool;
1068
1073
  }
1069
1074
  else if (typeof d === "object" &&
1070
- dateToCheck !== undefined &&
1071
1075
  d.from &&
1072
1076
  d.to &&
1073
- dateToCheck.getTime() >= d.from.getTime() &&
1074
- dateToCheck.getTime() <= d.to.getTime())
1077
+ day.getTime() >= d.from.getTime() &&
1078
+ day.getTime() <= d.to.getTime())
1075
1079
  return bool;
1076
1080
  }
1077
1081
  return !bool;
@@ -1128,7 +1132,8 @@ function FlatpickrInstance(element, instanceConfig) {
1128
1132
  ? element.contains(eventTarget)
1129
1133
  : eventTarget === self._input;
1130
1134
  var allowInput = self.config.allowInput;
1131
- var allowKeydown = self.isOpen && (!allowInput || !isInput);
1135
+ var isTypingKey = allowInput && isInput && e.keyCode !== 27;
1136
+ var allowKeydown = self.isOpen && !isTypingKey;
1132
1137
  var allowInlineKeydown = self.config.inline && isInput && !allowInput;
1133
1138
  var isMonthDropdownArrowKey = eventTarget === self.monthsDropdownContainer &&
1134
1139
  e.keyCode >= 37 &&
@@ -1395,6 +1400,8 @@ function FlatpickrInstance(element, instanceConfig) {
1395
1400
  dateObj !== undefined &&
1396
1401
  inverseDateObj.getFullYear() === dateObj.getFullYear();
1397
1402
  }
1403
+ if (self.mobileInput !== undefined)
1404
+ setMobileLimit(type);
1398
1405
  };
1399
1406
  }
1400
1407
  function parseConfig() {
@@ -1649,6 +1656,8 @@ function FlatpickrInstance(element, instanceConfig) {
1649
1656
  function selectDate(e) {
1650
1657
  e.preventDefault();
1651
1658
  e.stopPropagation();
1659
+ if (self.config.mode === "range")
1660
+ onMouseOver(getEventTarget(e));
1652
1661
  var isSelectable = function (day) {
1653
1662
  return day.classList &&
1654
1663
  day.classList.contains("flatpickr-day") &&
@@ -1720,7 +1729,7 @@ function FlatpickrInstance(element, instanceConfig) {
1720
1729
  triggerChange();
1721
1730
  }
1722
1731
  var CALLBACKS = {
1723
- locale: [setupLocale, updateWeekdays],
1732
+ locale: [setupLocale, updateWeekdays, rebuildTime],
1724
1733
  showMonths: [buildMonths, setCalendarWidth, buildWeekdays],
1725
1734
  minDate: [jumpToDate],
1726
1735
  maxDate: [jumpToDate],
@@ -1779,11 +1788,13 @@ function FlatpickrInstance(element, instanceConfig) {
1779
1788
  case "time":
1780
1789
  dates = [self.parseDate(inputDate, format)];
1781
1790
  break;
1782
- case "multiple":
1791
+ case "multiple": {
1792
+ var conjunction = self.config.conjunction;
1783
1793
  dates = inputDate
1784
- .split(self.config.conjunction)
1785
- .map(function (date) { return self.parseDate(date, format); });
1794
+ .split(conjunction.replace(/\s+$/, "") || conjunction)
1795
+ .map(function (date) { return self.parseDate(date.trim(), format); });
1786
1796
  break;
1797
+ }
1787
1798
  case "range":
1788
1799
  dates = inputDate
1789
1800
  .split(self.l10n.rangeSeparator)
@@ -1908,18 +1919,38 @@ function FlatpickrInstance(element, instanceConfig) {
1908
1919
  self._positionElement = self.config.positionElement || self._input;
1909
1920
  }
1910
1921
  function setMobileInputType() {
1922
+ var mobileInput = self.mobileInput;
1911
1923
  var inputType = self.config.enableTime
1912
1924
  ? self.config.noCalendar
1913
1925
  ? "time"
1914
1926
  : "datetime-local"
1915
1927
  : "date";
1916
- self.mobileInput.type = inputType;
1928
+ mobileInput.type = inputType;
1917
1929
  self.mobileFormatStr =
1918
1930
  inputType === "datetime-local"
1919
1931
  ? "Y-m-d\\TH:i:S"
1920
1932
  : inputType === "date"
1921
1933
  ? "Y-m-d"
1922
1934
  : "H:i:S";
1935
+ var step = self.input.getAttribute("step") || (self.config.enableSeconds ? "1" : "");
1936
+ if (step)
1937
+ mobileInput.step = step;
1938
+ else
1939
+ mobileInput.removeAttribute("step");
1940
+ setMobileLimit("min");
1941
+ setMobileLimit("max");
1942
+ }
1943
+ function setMobileLimit(type) {
1944
+ var mobileInput = self.mobileInput;
1945
+ var limit = self.config[type + "Date"];
1946
+ if (limit === undefined)
1947
+ return mobileInput.removeAttribute(type);
1948
+ var date = new Date(limit.getTime());
1949
+ var unit = Number(mobileInput.step || 60) % 60 === 0 ? 60 : 1;
1950
+ var round = type === "min" && mobileInput.type !== "date" ? Math.ceil : Math.floor;
1951
+ var seconds = date.getSeconds() + date.getMilliseconds() / 1000;
1952
+ date.setSeconds(round(seconds / unit) * unit, 0);
1953
+ mobileInput[type] = self.formatDate(date, self.mobileFormatStr);
1923
1954
  }
1924
1955
  function setupMobile() {
1925
1956
  self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
@@ -1931,12 +1962,6 @@ function FlatpickrInstance(element, instanceConfig) {
1931
1962
  if (self.selectedDates.length > 0) {
1932
1963
  self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(self.selectedDates[0], self.mobileFormatStr);
1933
1964
  }
1934
- if (self.config.minDate)
1935
- self.mobileInput.min = self.formatDate(self.config.minDate, "Y-m-d");
1936
- if (self.config.maxDate)
1937
- self.mobileInput.max = self.formatDate(self.config.maxDate, "Y-m-d");
1938
- if (self.input.getAttribute("step"))
1939
- self.mobileInput.step = String(self.input.getAttribute("step"));
1940
1965
  self.input.type = "hidden";
1941
1966
  if (self.altInput !== undefined)
1942
1967
  self.altInput.type = "hidden";
@@ -2073,7 +2098,7 @@ function FlatpickrInstance(element, instanceConfig) {
2073
2098
  self.amPM.textContent =
2074
2099
  self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
2075
2100
  }
2076
- var min = parseFloat(input.getAttribute("min")), max = parseFloat(input.getAttribute("max")), step = parseFloat(input.getAttribute("step")), curValue = parseInt(input.value, 10), delta = e.delta ||
2101
+ var min = parseFloat(input.getAttribute("min")), max = parseFloat(input.getAttribute("max")), step = getIncrement(input), curValue = parseInt(input.value, 10), delta = e.delta ||
2077
2102
  (isKeyDown ? (e.which === 38 ? 1 : -1) : 0);
2078
2103
  var newValue = curValue + step * delta;
2079
2104
  if (typeof input.value !== "undefined" && input.value.length === 2) {
@@ -2104,7 +2129,14 @@ function FlatpickrInstance(element, instanceConfig) {
2104
2129
  input.value = pad(newValue);
2105
2130
  }
2106
2131
  }
2107
- init();
2132
+ element._flatpickr = self;
2133
+ try {
2134
+ init();
2135
+ }
2136
+ catch (e) {
2137
+ element._flatpickr = undefined;
2138
+ throw e;
2139
+ }
2108
2140
  return self;
2109
2141
  }
2110
2142
  function _flatpickr(nodeList, config) {
@@ -2121,8 +2153,7 @@ function _flatpickr(nodeList, config) {
2121
2153
  node._flatpickr.destroy();
2122
2154
  node._flatpickr = undefined;
2123
2155
  }
2124
- node._flatpickr = FlatpickrInstance(node, config || {});
2125
- instances.push(node._flatpickr);
2156
+ instances.push(FlatpickrInstance(node, config || {}));
2126
2157
  }
2127
2158
  catch (e) {
2128
2159
  console.error(e);
@@ -5,15 +5,7 @@ var fp = typeof window !== "undefined" && window.flatpickr !== undefined
5
5
  };
6
6
  export var Kurdish = {
7
7
  weekdays: {
8
- shorthand: [
9
- "یەکشەممە",
10
- "دووشەممە",
11
- "سێشەممە",
12
- "چوارشەممە",
13
- "پێنجشەممە",
14
- "هەینی",
15
- "شەممە",
16
- ],
8
+ shorthand: ["یەک", "دوو", "سێ", "چوار", "پێنج", "هەینی", "شەممە"],
17
9
  longhand: [
18
10
  "یەکشەممە",
19
11
  "دووشەممە",
@@ -51,6 +51,7 @@ export var Finnish = {
51
51
  return ".";
52
52
  },
53
53
  time_24hr: true,
54
+ rangeSeparator: "–",
54
55
  yearAriaLabel: "vuosi",
55
56
  monthAriaLabel: "kuukausi",
56
57
  hourAriaLabel: "tunti",
@@ -49,5 +49,5 @@ export var Irish = {
49
49
  },
50
50
  time_24hr: true,
51
51
  };
52
- fp.l10ns.hr = Irish;
52
+ fp.l10ns.ga = Irish;
53
53
  export default fp.l10ns;
@@ -43,7 +43,7 @@ export var Indonesian = {
43
43
  return "";
44
44
  },
45
45
  time_24hr: true,
46
- rangeSeparator: " - ",
46
+ rangeSeparator: " sampai ",
47
47
  };
48
48
  fp.l10ns.id = Indonesian;
49
49
  export default fp.l10ns;
@@ -31,6 +31,7 @@ import { Persian as fa } from "./fa";
31
31
  import { Finnish as fi } from "./fi";
32
32
  import { Faroese as fo } from "./fo";
33
33
  import { French as fr } from "./fr";
34
+ import { Irish as ga } from "./ga";
34
35
  import { Galician as gl } from "./gl";
35
36
  import { Greek as gr } from "./gr";
36
37
  import { Hebrew as he } from "./he";
@@ -100,6 +101,7 @@ var l10n = {
100
101
  fi: fi,
101
102
  fo: fo,
102
103
  fr: fr,
104
+ ga: ga,
103
105
  gl: gl,
104
106
  gr: gr,
105
107
  he: he,
@@ -122,6 +124,7 @@ var l10n = {
122
124
  ms: ms,
123
125
  my: my,
124
126
  nl: nl,
127
+ nb: no,
125
128
  nn: nn,
126
129
  no: no,
127
130
  pa: pa,
@@ -139,6 +142,7 @@ var l10n = {
139
142
  th: th,
140
143
  tr: tr,
141
144
  uk: uk,
145
+ vi: vn,
142
146
  vn: vn,
143
147
  zh: zh,
144
148
  zh_tw: zhTw,
@@ -56,5 +56,5 @@ export var Norwegian = {
56
56
  return ".";
57
57
  },
58
58
  };
59
- fp.l10ns.no = Norwegian;
59
+ fp.l10ns.no = fp.l10ns.nb = Norwegian;
60
60
  export default fp.l10ns;
@@ -49,5 +49,5 @@ export var Vietnamese = {
49
49
  firstDayOfWeek: 1,
50
50
  rangeSeparator: " đến ",
51
51
  };
52
- fp.l10ns.vn = Vietnamese;
52
+ fp.l10ns.vn = fp.l10ns.vi = Vietnamese;
53
53
  export default fp.l10ns;
@@ -10,7 +10,7 @@ function momentPlugin(config) {
10
10
  var unit = Array.from(input.classList)
11
11
  .filter(function (name) { return name.startsWith("flatpickr-"); })
12
12
  .map(function (name) { return name.substring(10); })[0];
13
- var step = parseFloat(input.getAttribute("step"));
13
+ var step = fp._getIncrement(input);
14
14
  date.add(step * event.delta, unit);
15
15
  fp.setDate(date.toDate());
16
16
  }
@@ -88,13 +88,10 @@ function monthSelectPlugin(pluginConfig) {
88
88
  if (!self.monthsContainer)
89
89
  return;
90
90
  buildMonths();
91
- var selected = self.monthsContainer.querySelectorAll(".selected");
92
- for (var index = 0; index < selected.length; index++) {
93
- selected[index].classList.remove("selected");
94
- }
95
- var selectedDate = fp.selectedDates[0];
96
- if (selectedDate && selectedDate.getFullYear() === fp.currentYear) {
97
- self.monthsContainer.children[selectedDate.getMonth()].classList.add("selected");
91
+ for (var _i = 0, _a = fp.selectedDates; _i < _a.length; _i++) {
92
+ var date = _a[_i];
93
+ if (date.getFullYear() === fp.currentYear)
94
+ self.monthsContainer.children[date.getMonth()].classList.add("selected");
98
95
  }
99
96
  }
100
97
  function selectMonth(e) {
@@ -119,14 +116,20 @@ function monthSelectPlugin(pluginConfig) {
119
116
  if (!self.monthsContainer)
120
117
  return;
121
118
  var focusedIndex = Array.prototype.indexOf.call(self.monthsContainer.children, document.activeElement);
122
- var selectedDate = new Date(fp.currentYear, date.getMonth(), date.getDate());
119
+ var month = date.getMonth();
120
+ var selectedDate = new Date(fp.currentYear, month, date.getDate());
121
+ var isInMonth = function (d) {
122
+ return d.getFullYear() === fp.currentYear && d.getMonth() === month;
123
+ };
123
124
  var selectedDates = [];
124
125
  switch (fp.config.mode) {
125
126
  case "single":
126
127
  selectedDates = [selectedDate];
127
128
  break;
128
129
  case "multiple":
129
- selectedDates.push(selectedDate);
130
+ selectedDates = fp.selectedDates.filter(function (d) { return !isInMonth(d); });
131
+ if (selectedDates.length === fp.selectedDates.length)
132
+ selectedDates.push(selectedDate);
130
133
  break;
131
134
  case "range":
132
135
  if (fp.selectedDates.length === 2) {
@@ -139,6 +142,7 @@ function monthSelectPlugin(pluginConfig) {
139
142
  break;
140
143
  }
141
144
  fp.setDate(selectedDates, true);
145
+ fp.jumpToDate(selectedDate, true);
142
146
  if (focusedIndex !== -1)
143
147
  self.monthsContainer.children[focusedIndex].focus();
144
148
  }
@@ -124,11 +124,16 @@ export var parseSeconds = function (secondsSinceMidnight) {
124
124
  export var duration = {
125
125
  DAY: 86400000,
126
126
  };
127
- export function getDefaultHours(config) {
127
+ export function getDefaultHours(config, date) {
128
128
  var hours = config.defaultHour;
129
129
  var minutes = config.defaultMinute;
130
130
  var seconds = config.defaultSeconds;
131
- if (config.minDate !== undefined) {
131
+ var holdsTime = function (limit) {
132
+ return limit !== undefined &&
133
+ compareDates(date, limit) === 0 &&
134
+ (limit.getHours() > 0 || limit.getMinutes() > 0 || limit.getSeconds() > 0);
135
+ };
136
+ if (holdsTime(config.minDate)) {
132
137
  var minHour = config.minDate.getHours();
133
138
  var minMinutes = config.minDate.getMinutes();
134
139
  var minSeconds = config.minDate.getSeconds();
@@ -141,7 +146,7 @@ export function getDefaultHours(config) {
141
146
  if (hours === minHour && minutes === minMinutes && seconds < minSeconds)
142
147
  seconds = config.minDate.getSeconds();
143
148
  }
144
- if (config.maxDate !== undefined) {
149
+ if (holdsTime(config.maxDate)) {
145
150
  var maxHr = config.maxDate.getHours();
146
151
  var maxMinutes = config.maxDate.getMinutes();
147
152
  hours = Math.min(hours, maxHr);