flatpickr-ce 4.10.0 → 4.11.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 (152) hide show
  1. package/README.md +41 -1
  2. package/dist/esm/index.js +110 -59
  3. package/dist/esm/l10n/af.js +68 -0
  4. package/dist/esm/l10n/ar-dz.js +2 -1
  5. package/dist/esm/l10n/ar-sy.js +50 -0
  6. package/dist/esm/l10n/ar.js +1 -0
  7. package/dist/esm/l10n/az.js +1 -0
  8. package/dist/esm/l10n/br.js +1 -0
  9. package/dist/esm/l10n/da.js +1 -0
  10. package/dist/esm/l10n/de.js +1 -0
  11. package/dist/esm/l10n/default.js +1 -0
  12. package/dist/esm/l10n/es.js +1 -0
  13. package/dist/esm/l10n/eu.js +65 -0
  14. package/dist/esm/l10n/fi.js +1 -0
  15. package/dist/esm/l10n/fr.js +1 -0
  16. package/dist/esm/l10n/gl.js +1 -0
  17. package/dist/esm/l10n/gr.js +2 -1
  18. package/dist/esm/l10n/hy.js +1 -0
  19. package/dist/esm/l10n/index.js +11 -0
  20. package/dist/esm/l10n/ja.js +1 -0
  21. package/dist/esm/l10n/ko.js +1 -0
  22. package/dist/esm/l10n/pl.js +1 -0
  23. package/dist/esm/l10n/pt.js +1 -0
  24. package/dist/esm/l10n/sq.js +1 -0
  25. package/dist/esm/l10n/sv.js +1 -0
  26. package/dist/esm/l10n/tk.js +80 -0
  27. package/dist/esm/l10n/uk.js +1 -0
  28. package/dist/esm/l10n/zh.js +2 -0
  29. package/dist/esm/l10n/zh_tw.js +1 -0
  30. package/dist/esm/plugins/momentPlugin.js +2 -2
  31. package/dist/esm/plugins/rangePlugin.js +6 -0
  32. package/dist/esm/plugins/weekSelect/weekSelect.js +1 -0
  33. package/dist/esm/utils/dates.js +1 -1
  34. package/dist/flatpickr.css +2 -1
  35. package/dist/flatpickr.js +174 -69
  36. package/dist/flatpickr.min.css +1 -1
  37. package/dist/flatpickr.min.js +2 -2
  38. package/dist/l10n/af.d.ts +84 -0
  39. package/dist/l10n/af.js +81 -0
  40. package/dist/l10n/ar-dz.d.ts +6 -0
  41. package/dist/l10n/ar-dz.js +2 -1
  42. package/dist/l10n/ar-sy.d.ts +84 -0
  43. package/dist/l10n/ar-sy.js +63 -0
  44. package/dist/l10n/ar.d.ts +6 -0
  45. package/dist/l10n/ar.js +1 -0
  46. package/dist/l10n/at.d.ts +6 -0
  47. package/dist/l10n/az.d.ts +6 -0
  48. package/dist/l10n/az.js +1 -0
  49. package/dist/l10n/be.d.ts +6 -0
  50. package/dist/l10n/bg.d.ts +6 -0
  51. package/dist/l10n/bn.d.ts +6 -0
  52. package/dist/l10n/br.d.ts +6 -0
  53. package/dist/l10n/br.js +1 -0
  54. package/dist/l10n/bs.d.ts +6 -0
  55. package/dist/l10n/cat.d.ts +6 -0
  56. package/dist/l10n/ckb.d.ts +6 -0
  57. package/dist/l10n/cs.d.ts +6 -0
  58. package/dist/l10n/cy.d.ts +6 -0
  59. package/dist/l10n/da.d.ts +6 -0
  60. package/dist/l10n/da.js +1 -0
  61. package/dist/l10n/de.d.ts +6 -0
  62. package/dist/l10n/de.js +1 -0
  63. package/dist/l10n/default.js +1 -0
  64. package/dist/l10n/eo.d.ts +6 -0
  65. package/dist/l10n/es.d.ts +6 -0
  66. package/dist/l10n/es.js +1 -0
  67. package/dist/l10n/et.d.ts +6 -0
  68. package/dist/l10n/eu.d.ts +84 -0
  69. package/dist/l10n/eu.js +78 -0
  70. package/dist/l10n/fa.d.ts +6 -0
  71. package/dist/l10n/fi.d.ts +6 -0
  72. package/dist/l10n/fi.js +1 -0
  73. package/dist/l10n/fo.d.ts +6 -0
  74. package/dist/l10n/fr.d.ts +6 -0
  75. package/dist/l10n/fr.js +1 -0
  76. package/dist/l10n/ga.d.ts +6 -0
  77. package/dist/l10n/gl.d.ts +6 -0
  78. package/dist/l10n/gl.js +1 -0
  79. package/dist/l10n/gr.d.ts +6 -0
  80. package/dist/l10n/gr.js +2 -1
  81. package/dist/l10n/he.d.ts +6 -0
  82. package/dist/l10n/hi.d.ts +6 -0
  83. package/dist/l10n/hr.d.ts +6 -0
  84. package/dist/l10n/hu.d.ts +6 -0
  85. package/dist/l10n/hy.d.ts +6 -0
  86. package/dist/l10n/hy.js +1 -0
  87. package/dist/l10n/id.d.ts +6 -0
  88. package/dist/l10n/index.js +542 -197
  89. package/dist/l10n/is.d.ts +6 -0
  90. package/dist/l10n/it.d.ts +6 -0
  91. package/dist/l10n/ja.d.ts +6 -0
  92. package/dist/l10n/ja.js +1 -0
  93. package/dist/l10n/ka.d.ts +6 -0
  94. package/dist/l10n/km.d.ts +6 -0
  95. package/dist/l10n/ko.d.ts +6 -0
  96. package/dist/l10n/ko.js +1 -0
  97. package/dist/l10n/kz.d.ts +6 -0
  98. package/dist/l10n/lt.d.ts +6 -0
  99. package/dist/l10n/lv.d.ts +6 -0
  100. package/dist/l10n/mk.d.ts +6 -0
  101. package/dist/l10n/mn.d.ts +6 -0
  102. package/dist/l10n/ms.d.ts +6 -0
  103. package/dist/l10n/my.d.ts +6 -0
  104. package/dist/l10n/nl.d.ts +6 -0
  105. package/dist/l10n/nn.d.ts +6 -0
  106. package/dist/l10n/no.d.ts +6 -0
  107. package/dist/l10n/pa.d.ts +6 -0
  108. package/dist/l10n/pl.d.ts +6 -0
  109. package/dist/l10n/pl.js +1 -0
  110. package/dist/l10n/pt.d.ts +6 -0
  111. package/dist/l10n/pt.js +1 -0
  112. package/dist/l10n/ro.d.ts +6 -0
  113. package/dist/l10n/ru.d.ts +6 -0
  114. package/dist/l10n/si.d.ts +6 -0
  115. package/dist/l10n/sk.d.ts +6 -0
  116. package/dist/l10n/sl.d.ts +6 -0
  117. package/dist/l10n/sq.d.ts +6 -0
  118. package/dist/l10n/sq.js +1 -0
  119. package/dist/l10n/sr-cyr.d.ts +6 -0
  120. package/dist/l10n/sr.d.ts +6 -0
  121. package/dist/l10n/sv.d.ts +6 -0
  122. package/dist/l10n/sv.js +1 -0
  123. package/dist/l10n/tg.d.ts +6 -0
  124. package/dist/l10n/th.d.ts +6 -0
  125. package/dist/l10n/tk.d.ts +84 -0
  126. package/dist/l10n/tk.js +93 -0
  127. package/dist/l10n/tr.d.ts +6 -0
  128. package/dist/l10n/uk.d.ts +6 -0
  129. package/dist/l10n/uk.js +1 -0
  130. package/dist/l10n/uz.d.ts +6 -0
  131. package/dist/l10n/uz_latn.d.ts +6 -0
  132. package/dist/l10n/vn.d.ts +6 -0
  133. package/dist/l10n/zh.d.ts +6 -0
  134. package/dist/l10n/zh.js +2 -0
  135. package/dist/l10n/zh_tw.d.ts +6 -0
  136. package/dist/l10n/zh_tw.js +1 -0
  137. package/dist/plugins/minMaxTimePlugin.js +3 -1
  138. package/dist/plugins/momentPlugin.js +2 -2
  139. package/dist/plugins/rangePlugin.js +12 -0
  140. package/dist/plugins/weekSelect/weekSelect.js +2 -0
  141. package/dist/themes/airbnb.css +2 -1
  142. package/dist/themes/confetti.css +1 -0
  143. package/dist/themes/dark.css +1 -0
  144. package/dist/themes/light.css +1 -0
  145. package/dist/themes/material_blue.css +1 -0
  146. package/dist/themes/material_green.css +1 -0
  147. package/dist/themes/material_orange.css +1 -0
  148. package/dist/themes/material_red.css +1 -0
  149. package/dist/types/instance.d.ts +1 -0
  150. package/dist/types/locale.d.ts +3 -1
  151. package/package.json +6 -1
  152. package/src/style/flatpickr.styl +8 -1
package/README.md CHANGED
@@ -42,6 +42,44 @@ npm install flatpickr@npm:flatpickr-ce
42
42
 
43
43
  ## What's changed since flatpickr 4.6.13
44
44
 
45
+ ### 4.11.0
46
+
47
+ - 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))
48
+ - The focus stays on the day just picked, so keyboard users keep their place in multiple mode, with `closeOnSelect: false` and with several months shown ([#2791](https://github.com/flatpickr/flatpickr/issues/2791))
49
+ - Picking a day that leaves the selection as it was no longer fires `onChange`, nor change and input on the input ([#2700](https://github.com/flatpickr/flatpickr/issues/2700))
50
+ - On touch screens, scrolling or zooming the page no longer closes the calendar; a tap outside closes it when the finger lifts ([#2680](https://github.com/flatpickr/flatpickr/issues/2680))
51
+ - `minDate`, `maxDate`, `enable` and `disable` strings with month or weekday names or AM/PM are read in the instance's locale ([#2721](https://github.com/flatpickr/flatpickr/issues/2721))
52
+ - A custom locale whose `weekdays` or `months` gives only `shorthand` or only `longhand` no longer throws; the other list is the default locale's ([#2654](https://github.com/flatpickr/flatpickr/issues/2654), [#2693](https://github.com/flatpickr/flatpickr/issues/2693))
53
+ - With rangePlugin and `enableTime`, a day picked anew for an end keeps that end's time, and the time inputs stay on it ([#2712](https://github.com/flatpickr/flatpickr/issues/2712))
54
+ - With `enableTime` and no date selected, `set("minDate")` and `set("maxDate")` put the default time on the time inputs ([#1869](https://github.com/flatpickr/flatpickr/issues/1869))
55
+ - `null` for `appendTo`, `formatDate` and `conjunction`, and `null` or `undefined` for `enable`, are taken as unset, as the docs list them ([#2725](https://github.com/flatpickr/flatpickr/issues/2725))
56
+ - The calendar is positioned by its full height, padding and border included ([#2628](https://github.com/flatpickr/flatpickr/issues/2628))
57
+ - With `showMonths` above 1, the days stay under their weekdays on a page whose `.hidden` rule sets `display: none`, as Tailwind's does ([#2822](https://github.com/flatpickr/flatpickr/issues/2822))
58
+ - In the default styles and the airbnb theme, the month dropdown's options are drawn on the calendar's background, so they stay readable when the browser's popup is dark ([#2629](https://github.com/flatpickr/flatpickr/issues/2629))
59
+ - The weekday labels carry no surrounding whitespace, so a page that preserves white-space shows the header aligned ([#2749](https://github.com/flatpickr/flatpickr/issues/2749))
60
+ - In Safari, an inline calendar no longer gets an arrow or a popup's positioning at init ([#2787](https://github.com/flatpickr/flatpickr/issues/2787), [#1377](https://github.com/flatpickr/flatpickr/issues/1377))
61
+ - weekSelect shows its calendar on mobile devices instead of failing to initialize ([#2824](https://github.com/flatpickr/flatpickr/issues/2824))
62
+ - The native mobile input's value is put on its step, so a date with seconds no longer keeps its form from submitting ([#2393](https://github.com/flatpickr/flatpickr/issues/2393)); it takes the original input's tabindex instead of 1 ([#2672](https://github.com/flatpickr/flatpickr/issues/2672)); `open()` opens its picker with `showPicker()` where the browser has it, as Firefox for Android needs ([#2726](https://github.com/flatpickr/flatpickr/issues/2726))
63
+ - With `enableSeconds`, the seconds input has an aria-label, the locale's new `secondAriaLabel` ([#2821](https://github.com/flatpickr/flatpickr/pull/2821))
64
+ - In IE, committing typed input, hovering a range and stepping a time input with momentPlugin no longer throw ([#2709](https://github.com/flatpickr/flatpickr/issues/2709))
65
+ - Locales: new Turkmen (`tk`), Basque (`eu`), Afrikaans (`af`) and Levantine Arabic (`ar_sy`); Greek is also registered as `el`, and Algerian Arabic as `ar_dz` instead of over `ar`; Mandarin writes AM and PM as 上午 and 下午, and Ukrainian ranges are separated with an em dash ([#2664](https://github.com/flatpickr/flatpickr/pull/2664), [#2706](https://github.com/flatpickr/flatpickr/pull/2706), [#2765](https://github.com/flatpickr/flatpickr/pull/2765), [#2774](https://github.com/flatpickr/flatpickr/pull/2774), [#2796](https://github.com/flatpickr/flatpickr/issues/2796), [#2830](https://github.com/flatpickr/flatpickr/pull/2830), [#2771](https://github.com/flatpickr/flatpickr/pull/2771), [#2826](https://github.com/flatpickr/flatpickr/pull/2826))
66
+ - The bug report template and the Contributing section link a JSFiddle that runs flatpickr-ce ([#2759](https://github.com/flatpickr/flatpickr/issues/2759))
67
+
68
+ Behavior changes to check when upgrading:
69
+
70
+ - Mandarin's AM/PM is 上午/下午, and in a value saved with AM or PM under a format with `K`, the AM or PM is skipped and the hour read as `h` gives it. Replace them in stored values, or keep them with `locale: { ...Mandarin, amPM: ["AM", "PM"] }`.
71
+ - Ukrainian ranges saved with " to " read as a same-day range of their first date, or a start alone with `enableTime`. Replace the separator in stored values, or keep it with `locale: { ...Ukrainian, rangeSeparator: " to " }`.
72
+ - With ar-dz.js loaded, `locale: "ar"` no longer gives Algerian Arabic; use `"ar_dz"`.
73
+ - Picking a day that leaves the selected dates and times as they were fires no `onChange`, change or input event, so plugins and handlers that act in `onChange` don't run for it; `onValueUpdate` still fires.
74
+ - On windows with touch and pointer events, a tap outside closes the calendar on `pointerup`, and a mouse there closes it on `pointerdown`. A page that keeps the calendar open by stopping `touchstart` or `mousedown` has to stop `pointerup` or `pointerdown` instead, or list the element in `ignoredFocusElements`.
75
+ - Closing after browsing away, with no selected date in view, moves the view back: the days are rebuilt, then `onYearChange` (when the year changes) and `onMonthChange` fire, before `onClose`.
76
+ - Without time inputs, the day picked takes the focus; in single mode with `closeOnSelect`, it holds it for a moment before the input does.
77
+ - With `enableTime` and no date selected, `set("minDate")` puts the default time on the time inputs instead of minDate's own time, so a picker whose `minDate` follows another picker's date no longer copies its time.
78
+ - With the native mobile input and `enableTime` but not `enableSeconds`, its value has no seconds. It gets `tabindex="0"` instead of `"1"`. Where `showPicker()` exists, `open()` no longer dispatches a click on it, and uses up the page's user activation.
79
+ - Weekday names in a custom locale are written as text, no longer parsed as HTML.
80
+ - An explicit `conjunction: undefined` joins dates with ", " instead of ",".
81
+ - TypeScript: the `Locale` type has a required `secondAriaLabel`; `CustomLocale` takes it as optional.
82
+
45
83
  ### 4.10.0
46
84
 
47
85
  - 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))
@@ -170,13 +208,15 @@ Framework addons (they depend on the `flatpickr` package, so use the alias above
170
208
 
171
209
  ### Options are trusted
172
210
 
173
- A few options are inserted into the calendar as HTML, not text: `prevArrow`, `nextArrow`, what `getWeek` returns, the locale's short weekday names, and confirmDate's `confirmIcon`. Like the rest of the config, they are meant to come from your code: don't build them from user input or other untrusted data without escaping it.
211
+ A few options are inserted into the calendar as HTML, not text: `prevArrow`, `nextArrow`, what `getWeek` returns and confirmDate's `confirmIcon`. Like the rest of the config, they are meant to come from your code: don't build them from user input or other untrusted data without escaping it.
174
212
 
175
213
 
176
214
  ## Contributing
177
215
 
178
216
  Bug reports, triage and pull requests are all welcome. Fixes that are still open upstream can be reopened here.
179
217
 
218
+ To report a bug, start from [this fiddle](https://jsfiddle.net/gh/get/library/pure/colinli007/flatpickr-ce/tree/main/.github/repro), which loads the latest flatpickr-ce from jsDelivr: reproduce the bug there, save it and link it in the issue.
219
+
180
220
  ```sh
181
221
  npm install
182
222
  npm test # typecheck + unit tests
package/dist/esm/index.js CHANGED
@@ -25,17 +25,18 @@ import { tokenRegex, monthToStr } from "./utils/formatting";
25
25
  import "./utils/polyfills";
26
26
  var DEBOUNCED_CHANGE_MS = 300;
27
27
  var instanceCount = 0;
28
+ function mergeLocale(base, custom) {
29
+ return __assign(__assign(__assign({}, base), custom), { weekdays: __assign(__assign({}, base.weekdays), custom === null || custom === void 0 ? void 0 : custom.weekdays), months: __assign(__assign({}, base.months), custom === null || custom === void 0 ? void 0 : custom.months) });
30
+ }
28
31
  function FlatpickrInstance(element, instanceConfig) {
29
32
  var self = {
30
33
  config: __assign(__assign({}, defaultOptions), flatpickr.defaultConfig),
31
- l10n: English,
32
34
  };
33
35
  var userConfig = {};
34
36
  var idPrefix = "flatpickr-" + ++instanceCount;
35
37
  var win = element.ownerDocument.defaultView || window;
36
38
  var doc = win.document;
37
39
  var openHandlers = [];
38
- self.parseDate = createDateParser({ config: self.config, l10n: self.l10n });
39
40
  self._handlers = [];
40
41
  self.pluginElements = [];
41
42
  self.loadedPlugins = [];
@@ -44,6 +45,7 @@ function FlatpickrInstance(element, instanceConfig) {
44
45
  self._positionCalendar = positionCalendar;
45
46
  self._showValue = showValue;
46
47
  self._typedValue = typedValue;
48
+ self._startNewRange = startNewRange;
47
49
  self._getIncrement = getIncrement;
48
50
  self.changeMonth = changeMonth;
49
51
  self.changeYear = changeYear;
@@ -91,7 +93,7 @@ function FlatpickrInstance(element, instanceConfig) {
91
93
  }
92
94
  setCalendarWidth();
93
95
  var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
94
- if (!self.isMobile && isSafari) {
96
+ if (!self.isMobile && !self.config.inline && isSafari) {
95
97
  positionCalendar();
96
98
  }
97
99
  triggerEvent("onReady");
@@ -229,6 +231,10 @@ function FlatpickrInstance(element, instanceConfig) {
229
231
  setHours(date.getHours(), date.getMinutes(), date.getSeconds());
230
232
  }
231
233
  }
234
+ function setDefaultHours() {
235
+ var _a = getDefaultHours(self.config, defaultTimeDate()), hours = _a.hours, minutes = _a.minutes, seconds = _a.seconds;
236
+ setHours(hours, minutes, seconds);
237
+ }
232
238
  function setHours(hours, minutes, seconds) {
233
239
  if (self.latestSelectedDateObj !== undefined) {
234
240
  self.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0);
@@ -276,7 +282,20 @@ function FlatpickrInstance(element, instanceConfig) {
276
282
  };
277
283
  if (!self.config.static)
278
284
  listen(win, "resize", debounce(onResize, 50));
279
- listen(doc, win.ontouchstart !== undefined ? "touchstart" : "mousedown", documentClick);
285
+ if (win.ontouchstart === undefined)
286
+ listen(doc, "mousedown", documentClick);
287
+ else if (win.PointerEvent === undefined)
288
+ listen(doc, "touchstart", documentClick);
289
+ else {
290
+ listen(doc, "pointerdown", function (e) {
291
+ if (e.pointerType === "mouse")
292
+ documentClick(e);
293
+ });
294
+ listen(doc, "pointerup", function (e) {
295
+ if (e.pointerType !== "mouse")
296
+ documentClick(e);
297
+ });
298
+ }
280
299
  listen(doc, "focus", documentClick, { capture: true });
281
300
  }
282
301
  function unbindOpenEvents() {
@@ -347,6 +366,11 @@ function FlatpickrInstance(element, instanceConfig) {
347
366
  return maxDate;
348
367
  return date;
349
368
  }
369
+ function isMonthShown(date) {
370
+ var firstMonth = self.currentYear * 12 + self.currentMonth;
371
+ var month = date.getFullYear() * 12 + date.getMonth();
372
+ return month >= firstMonth && month < firstMonth + self.config.showMonths;
373
+ }
350
374
  function jumpToDate(jumpDate, triggerChange) {
351
375
  var jumpTo = jumpDate !== undefined
352
376
  ? self.parseDate(jumpDate)
@@ -427,14 +451,13 @@ function FlatpickrInstance(element, instanceConfig) {
427
451
  toggleClass(self.calendarContainer, "animate", self.config.animate === true);
428
452
  toggleClass(self.calendarContainer, "multiMonth", self.config.showMonths > 1);
429
453
  self.calendarContainer.appendChild(fragment);
430
- var customAppend = self.config.appendTo !== undefined &&
431
- self.config.appendTo.nodeType !== undefined;
454
+ var customAppend = !!self.config.appendTo && self.config.appendTo.nodeType !== undefined;
432
455
  if (self.config.inline || self.config.static) {
433
456
  self.calendarContainer.classList.add(self.config.inline ? "inline" : "static");
434
457
  if (self.config.inline) {
435
458
  if (!customAppend && self.element.parentNode)
436
459
  self.element.parentNode.insertBefore(self.calendarContainer, self._input.nextSibling);
437
- else if (self.config.appendTo !== undefined)
460
+ else if (self.config.appendTo)
438
461
  self.config.appendTo.appendChild(self.calendarContainer);
439
462
  }
440
463
  if (self.config.static) {
@@ -448,9 +471,7 @@ function FlatpickrInstance(element, instanceConfig) {
448
471
  }
449
472
  }
450
473
  if (!self.config.static && !self.config.inline)
451
- (self.config.appendTo !== undefined
452
- ? self.config.appendTo
453
- : doc.body).appendChild(self.calendarContainer);
474
+ (self.config.appendTo || doc.body).appendChild(self.calendarContainer);
454
475
  }
455
476
  function createDay(className, date, _dayNumber, i) {
456
477
  var dateIsEnabled = isEnabled(date, true), dayElement = createElement("span", className, date.getDate().toString());
@@ -787,6 +808,7 @@ function FlatpickrInstance(element, instanceConfig) {
787
808
  self.timeContainer.classList.add("hasSeconds");
788
809
  var secondInput = createNumberInput("flatpickr-second", {
789
810
  id: idPrefix + "-second",
811
+ "aria-label": self.l10n.secondAriaLabel,
790
812
  });
791
813
  self.secondElement = secondInput.getElementsByTagName("input")[0];
792
814
  self.secondElement.value = pad(self.latestSelectedDateObj
@@ -848,8 +870,15 @@ function FlatpickrInstance(element, instanceConfig) {
848
870
  if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
849
871
  weekdays = __spreadArrays(weekdays.splice(firstDayOfWeek, weekdays.length), weekdays.splice(0, firstDayOfWeek));
850
872
  }
873
+ var _loop_1 = function (i) {
874
+ var container = self.weekdayContainer.children[i];
875
+ clearNode(container);
876
+ weekdays.forEach(function (weekday) {
877
+ return container.appendChild(createElement("span", "flatpickr-weekday", weekday));
878
+ });
879
+ };
851
880
  for (var i = self.config.showMonths; i--;) {
852
- self.weekdayContainer.children[i].innerHTML = "\n <span class='flatpickr-weekday'>\n " + weekdays.join("</span><span class='flatpickr-weekday'>") + "\n </span>\n ";
881
+ _loop_1(i);
853
882
  }
854
883
  }
855
884
  function buildWeeks() {
@@ -893,15 +922,20 @@ function FlatpickrInstance(element, instanceConfig) {
893
922
  self.currentYear = initialDate.getFullYear();
894
923
  self.currentMonth = initialDate.getMonth();
895
924
  }
896
- if (self.config.enableTime === true) {
897
- var _a = getDefaultHours(self.config, defaultTimeDate()), hours = _a.hours, minutes = _a.minutes, seconds = _a.seconds;
898
- setHours(hours, minutes, seconds);
899
- }
925
+ if (self.config.enableTime === true)
926
+ setDefaultHours();
900
927
  self.redraw();
901
928
  if (triggerChangeEvent)
902
929
  triggerEvent("onChange");
903
930
  }
904
931
  function close() {
932
+ if (self.isOpen &&
933
+ self.selectedDates.length > 0 &&
934
+ !self.selectedDates.some(isMonthShown)) {
935
+ var currentYear = self.currentYear, currentMonth = self.currentMonth;
936
+ jumpToDate();
937
+ triggerViewChange(currentYear, currentMonth);
938
+ }
905
939
  self.isOpen = false;
906
940
  unbindOpenEvents();
907
941
  if (!self.isMobile) {
@@ -1093,7 +1127,7 @@ function FlatpickrInstance(element, instanceConfig) {
1093
1127
  announceCommit(commitTypedValue());
1094
1128
  }
1095
1129
  function typedValue() {
1096
- return self._input.value.trimEnd() === getDateStr()
1130
+ return self._input.value.replace(/\s+$/, "") === getDateStr()
1097
1131
  ? undefined
1098
1132
  : self._input.value;
1099
1133
  }
@@ -1294,7 +1328,7 @@ function FlatpickrInstance(element, instanceConfig) {
1294
1328
  maxRange = t;
1295
1329
  }
1296
1330
  }
1297
- var hoverableCells = Array.from(self.rContainer.querySelectorAll("*:nth-child(-n+" + self.config.showMonths + ") > ." + cellClass));
1331
+ var hoverableCells = Array.prototype.slice.call(self.rContainer.querySelectorAll("*:nth-child(-n+" + self.config.showMonths + ") > ." + cellClass));
1298
1332
  hoverableCells.forEach(function (dayElem) {
1299
1333
  var date = dayElem.dateObj;
1300
1334
  var timestamp = date.getTime();
@@ -1343,7 +1377,12 @@ function FlatpickrInstance(element, instanceConfig) {
1343
1377
  }
1344
1378
  if (self.mobileInput !== undefined) {
1345
1379
  self.mobileInput.focus();
1346
- self.mobileInput.click();
1380
+ try {
1381
+ self.mobileInput.showPicker();
1382
+ }
1383
+ catch (_a) {
1384
+ self.mobileInput.click();
1385
+ }
1347
1386
  }
1348
1387
  triggerEvent("onOpen");
1349
1388
  return;
@@ -1385,8 +1424,8 @@ function FlatpickrInstance(element, instanceConfig) {
1385
1424
  self.selectedDates.indexOf(self.latestSelectedDateObj) === -1)
1386
1425
  self.latestSelectedDateObj =
1387
1426
  self.selectedDates[self.selectedDates.length - 1];
1388
- if (!self.selectedDates.length && type === "min")
1389
- setHoursFromDate(dateObj);
1427
+ if (!self.selectedDates.length)
1428
+ setDefaultHours();
1390
1429
  updateValue();
1391
1430
  }
1392
1431
  if (self.daysContainer) {
@@ -1405,6 +1444,7 @@ function FlatpickrInstance(element, instanceConfig) {
1405
1444
  };
1406
1445
  }
1407
1446
  function parseConfig() {
1447
+ var _a;
1408
1448
  var boolOpts = [
1409
1449
  "wrap",
1410
1450
  "weekNumbers",
@@ -1427,7 +1467,7 @@ function FlatpickrInstance(element, instanceConfig) {
1427
1467
  Object.defineProperty(self.config, "enable", {
1428
1468
  get: function () { return self.config._enable; },
1429
1469
  set: function (dates) {
1430
- self.config._enable = parseDateRules(dates);
1470
+ self.config._enable = dates ? parseDateRules(dates) : undefined;
1431
1471
  },
1432
1472
  });
1433
1473
  Object.defineProperty(self.config, "disable", {
@@ -1455,10 +1495,19 @@ function FlatpickrInstance(element, instanceConfig) {
1455
1495
  get: function () { return self.config._maxTime; },
1456
1496
  set: minMaxTimeSetter("max"),
1457
1497
  });
1498
+ var conjunction = self.config.conjunction;
1499
+ Object.defineProperty(self.config, "conjunction", {
1500
+ get: function () { return conjunction; },
1501
+ set: function (value) {
1502
+ conjunction = value !== null && value !== void 0 ? value : defaultOptions.conjunction;
1503
+ },
1504
+ });
1505
+ self.config.conjunction = conjunction;
1458
1506
  if (userConfig.mode === "time") {
1459
1507
  self.config.noCalendar = true;
1460
1508
  self.config.enableTime = true;
1461
1509
  }
1510
+ setupL10n((_a = userConfig.locale) !== null && _a !== void 0 ? _a : self.config.locale);
1462
1511
  Object.assign(self.config, defaultFormats(), userConfig);
1463
1512
  for (var i = 0; i < boolOpts.length; i++)
1464
1513
  self.config[boolOpts[i]] =
@@ -1528,11 +1577,19 @@ function FlatpickrInstance(element, instanceConfig) {
1528
1577
  if (typeof self.config.locale !== "object" &&
1529
1578
  typeof flatpickr.l10ns[self.config.locale] === "undefined")
1530
1579
  self.config.errorHandler(new Error("flatpickr: invalid locale " + self.config.locale));
1531
- self.l10n = __assign(__assign({}, flatpickr.l10ns.default), (typeof self.config.locale === "object"
1532
- ? self.config.locale
1533
- : self.config.locale !== "default"
1534
- ? flatpickr.l10ns[self.config.locale]
1535
- : undefined));
1580
+ setupL10n(self.config.locale);
1581
+ if (userConfig.time_24hr === undefined &&
1582
+ flatpickr.defaultConfig.time_24hr === undefined) {
1583
+ self.config.time_24hr = self.l10n.time_24hr;
1584
+ }
1585
+ self.formatDate = createDateFormatter(self);
1586
+ }
1587
+ function setupL10n(locale) {
1588
+ self.l10n = mergeLocale(flatpickr.l10ns.default, typeof locale === "object"
1589
+ ? locale
1590
+ : locale !== "default"
1591
+ ? flatpickr.l10ns[locale]
1592
+ : undefined);
1536
1593
  tokenRegex.D = "(" + self.l10n.weekdays.shorthand.join("|") + ")";
1537
1594
  tokenRegex.l = "(" + self.l10n.weekdays.longhand.join("|") + ")";
1538
1595
  tokenRegex.M = "(" + self.l10n.months.shorthand
@@ -1544,11 +1601,6 @@ function FlatpickrInstance(element, instanceConfig) {
1544
1601
  .sort(function (a, b) { return b.length - a.length; })
1545
1602
  .join("|") + ")";
1546
1603
  tokenRegex.K = "(" + self.l10n.amPM[0] + "|" + self.l10n.amPM[1] + ")";
1547
- if (userConfig.time_24hr === undefined &&
1548
- flatpickr.defaultConfig.time_24hr === undefined) {
1549
- self.config.time_24hr = self.l10n.time_24hr;
1550
- }
1551
- self.formatDate = createDateFormatter(self);
1552
1604
  self.parseDate = createDateParser({ config: self.config, l10n: self.l10n });
1553
1605
  }
1554
1606
  function positionCalendar(customPositionElement) {
@@ -1559,7 +1611,7 @@ function FlatpickrInstance(element, instanceConfig) {
1559
1611
  return;
1560
1612
  triggerEvent("onPreCalendarPosition");
1561
1613
  var positionElement = customPositionElement || self._positionElement;
1562
- var calendarHeight = Array.prototype.reduce.call(self.calendarContainer.children, (function (acc, child) { return acc + child.offsetHeight; }), 0), 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 &&
1614
+ 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 &&
1563
1615
  !fitsBelow &&
1564
1616
  !fitsAbove &&
1565
1617
  !self.config.static &&
@@ -1653,6 +1705,9 @@ function FlatpickrInstance(element, instanceConfig) {
1653
1705
  self.close();
1654
1706
  }
1655
1707
  }
1708
+ function startNewRange() {
1709
+ self.clear(false, false);
1710
+ }
1656
1711
  function selectDate(e) {
1657
1712
  e.preventDefault();
1658
1713
  e.stopPropagation();
@@ -1668,12 +1723,9 @@ function FlatpickrInstance(element, instanceConfig) {
1668
1723
  if (t === undefined)
1669
1724
  return;
1670
1725
  var target = t;
1726
+ var prevTimes = getSelectedTimes();
1671
1727
  var selectedDate = (self.latestSelectedDateObj = new Date(target.dateObj.getTime()));
1672
- var firstMonth = self.currentYear * 12 + self.currentMonth;
1673
- var selectedMonth = selectedDate.getFullYear() * 12 + selectedDate.getMonth();
1674
- var shouldChangeMonth = (selectedMonth < firstMonth ||
1675
- selectedMonth > firstMonth + self.config.showMonths - 1) &&
1676
- self.config.mode !== "range";
1728
+ var shouldChangeMonth = !isMonthShown(selectedDate) && self.config.mode !== "range";
1677
1729
  self.selectedDateElem = target;
1678
1730
  if (self.config.mode === "single")
1679
1731
  self.selectedDates = [selectedDate];
@@ -1685,9 +1737,8 @@ function FlatpickrInstance(element, instanceConfig) {
1685
1737
  self.selectedDates.push(selectedDate);
1686
1738
  }
1687
1739
  else if (self.config.mode === "range") {
1688
- if (self.selectedDates.length === 2) {
1689
- self.clear(false, false);
1690
- }
1740
+ if (self.selectedDates.length === 2)
1741
+ self._startNewRange();
1691
1742
  self.latestSelectedDateObj = selectedDate;
1692
1743
  self.selectedDates.push(selectedDate);
1693
1744
  if (compareDates(selectedDate, self.selectedDates[0], true) !== 0)
@@ -1707,16 +1758,10 @@ function FlatpickrInstance(element, instanceConfig) {
1707
1758
  updateNavigationCurrentMonth();
1708
1759
  buildDays();
1709
1760
  updateValue();
1710
- if (!shouldChangeMonth &&
1711
- self.config.mode !== "range" &&
1712
- self.config.showMonths === 1)
1713
- focusOnDayElem(target);
1714
- else if (self.selectedDateElem !== undefined &&
1715
- self.hourElement === undefined) {
1716
- self.selectedDateElem && self.selectedDateElem.focus();
1717
- }
1718
1761
  if (self.hourElement !== undefined)
1719
- self.hourElement !== undefined && self.hourElement.focus();
1762
+ self.hourElement.focus();
1763
+ else
1764
+ focusOnDay(getVisibleDay(selectedDate), 0);
1720
1765
  if (self.config.closeOnSelect) {
1721
1766
  var single = self.config.mode === "single" && !self.config.enableTime;
1722
1767
  var range = self.config.mode === "range" &&
@@ -1726,7 +1771,8 @@ function FlatpickrInstance(element, instanceConfig) {
1726
1771
  focusAndClose();
1727
1772
  }
1728
1773
  }
1729
- triggerChange();
1774
+ if (getSelectedTimes() !== prevTimes)
1775
+ triggerChange();
1730
1776
  }
1731
1777
  var CALLBACKS = {
1732
1778
  locale: [setupLocale, updateWeekdays, rebuildTime],
@@ -1945,22 +1991,27 @@ function FlatpickrInstance(element, instanceConfig) {
1945
1991
  var limit = self.config[type + "Date"];
1946
1992
  if (limit === undefined)
1947
1993
  return mobileInput.removeAttribute(type);
1948
- var date = new Date(limit.getTime());
1949
- var unit = Number(mobileInput.step || 60) % 60 === 0 ? 60 : 1;
1950
1994
  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);
1995
+ mobileInput[type] = formatMobileDate(limit, round);
1996
+ }
1997
+ function formatMobileDate(date, round) {
1998
+ if (round === void 0) { round = Math.floor; }
1999
+ var step = self.mobileInput.step;
2000
+ var unit = Number(step || 60) % 60 === 0 ? 60 : 1;
2001
+ var onStep = new Date(date.getTime());
2002
+ var seconds = onStep.getSeconds() + onStep.getMilliseconds() / 1000;
2003
+ onStep.setSeconds(round(seconds / unit) * unit, 0);
2004
+ return self.formatDate(onStep, self.mobileFormatStr);
1954
2005
  }
1955
2006
  function setupMobile() {
1956
2007
  self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
1957
- self.mobileInput.tabIndex = 1;
2008
+ self.mobileInput.tabIndex = self.input.tabIndex;
1958
2009
  setMobileInputType();
1959
2010
  self.mobileInput.disabled = self.input.disabled;
1960
2011
  self.mobileInput.required = self.input.required;
1961
2012
  self.mobileInput.placeholder = self.input.placeholder;
1962
2013
  if (self.selectedDates.length > 0) {
1963
- self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(self.selectedDates[0], self.mobileFormatStr);
2014
+ self.mobileInput.defaultValue = self.mobileInput.value = formatMobileDate(self.selectedDates[0]);
1964
2015
  }
1965
2016
  self.input.type = "hidden";
1966
2017
  if (self.altInput !== undefined)
@@ -2057,7 +2108,7 @@ function FlatpickrInstance(element, instanceConfig) {
2057
2108
  if (triggerChange === void 0) { triggerChange = true; }
2058
2109
  if (self.mobileInput !== undefined && self.mobileFormatStr) {
2059
2110
  var mobileValue = self.latestSelectedDateObj !== undefined
2060
- ? self.formatDate(self.latestSelectedDateObj, self.mobileFormatStr)
2111
+ ? formatMobileDate(self.latestSelectedDateObj)
2061
2112
  : "";
2062
2113
  var currentDate = self.parseDate(self.mobileInput.value, self.mobileFormatStr);
2063
2114
  if (currentDate === undefined ||
@@ -2188,7 +2239,7 @@ flatpickr.l10ns = {
2188
2239
  default: __assign({}, English),
2189
2240
  };
2190
2241
  flatpickr.localize = function (l10n) {
2191
- flatpickr.l10ns.default = __assign(__assign({}, flatpickr.l10ns.default), l10n);
2242
+ flatpickr.l10ns.default = mergeLocale(flatpickr.l10ns.default, l10n);
2192
2243
  };
2193
2244
  flatpickr.setDefaults = function (config) {
2194
2245
  flatpickr.defaultConfig = __assign(__assign({}, flatpickr.defaultConfig), config);
@@ -0,0 +1,68 @@
1
+ var fp = typeof window !== "undefined" && window.flatpickr !== undefined
2
+ ? window.flatpickr
3
+ : {
4
+ l10ns: {},
5
+ };
6
+ export var Afrikaans = {
7
+ weekdays: {
8
+ shorthand: ["So.", "Ma.", "Di.", "Wo.", "Do.", "Vr.", "Sa."],
9
+ longhand: [
10
+ "Sondag",
11
+ "Maandag",
12
+ "Dinsdag",
13
+ "Woensdag",
14
+ "Donderdag",
15
+ "Vrydag",
16
+ "Saterdag",
17
+ ],
18
+ },
19
+ months: {
20
+ shorthand: [
21
+ "Jan",
22
+ "Feb",
23
+ "Mrt",
24
+ "Apr",
25
+ "Mei",
26
+ "Jun",
27
+ "Jul",
28
+ "Aug",
29
+ "Sep",
30
+ "Okt",
31
+ "Nov",
32
+ "Des",
33
+ ],
34
+ longhand: [
35
+ "Januarie",
36
+ "Februarie",
37
+ "Maart",
38
+ "April",
39
+ "Mei",
40
+ "Junie",
41
+ "Julie",
42
+ "Augustus",
43
+ "September",
44
+ "Oktober",
45
+ "November",
46
+ "Desember",
47
+ ],
48
+ },
49
+ ordinal: function (nth) {
50
+ var s = nth % 100;
51
+ if (s == 1 || s == 8 || s > 19)
52
+ return "ste";
53
+ return "de";
54
+ },
55
+ weekAbbreviation: "Wk",
56
+ rangeSeparator: " tot ",
57
+ scrollTitle: "Rol om te verander",
58
+ toggleTitle: "Kliek om te wissel",
59
+ yearAriaLabel: "Jaar",
60
+ monthAriaLabel: "Maand",
61
+ hourAriaLabel: "Uur",
62
+ minuteAriaLabel: "Minuut",
63
+ secondAriaLabel: "Sekonde",
64
+ time_24hr: true,
65
+ firstDayOfWeek: 0,
66
+ };
67
+ fp.l10ns.af = Afrikaans;
68
+ export default fp.l10ns;
@@ -42,7 +42,8 @@ export var AlgerianArabic = {
42
42
  monthAriaLabel: "شهر",
43
43
  hourAriaLabel: "ساعة",
44
44
  minuteAriaLabel: "دقيقة",
45
+ secondAriaLabel: "ثانية",
45
46
  time_24hr: true,
46
47
  };
47
- fp.l10ns.ar = AlgerianArabic;
48
+ fp.l10ns.ar_dz = AlgerianArabic;
48
49
  export default fp.l10ns;
@@ -0,0 +1,50 @@
1
+ var fp = typeof window !== "undefined" && window.flatpickr !== undefined
2
+ ? window.flatpickr
3
+ : {
4
+ l10ns: {},
5
+ };
6
+ export var SyrianArabic = {
7
+ weekdays: {
8
+ shorthand: ["أحد", "اثنين", "ثلاثاء", "أربعاء", "خميس", "جمعة", "سبت"],
9
+ longhand: [
10
+ "الأحد",
11
+ "الاثنين",
12
+ "الثلاثاء",
13
+ "الأربعاء",
14
+ "الخميس",
15
+ "الجمعة",
16
+ "السبت",
17
+ ],
18
+ },
19
+ months: {
20
+ shorthand: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
21
+ longhand: [
22
+ "كانون الثاني",
23
+ "شباط",
24
+ "آذار",
25
+ "نيسان",
26
+ "أيار",
27
+ "حزيران",
28
+ "تموز",
29
+ "آب",
30
+ "أيلول",
31
+ "تشرين الأول",
32
+ "تشرين الثاني",
33
+ "كانون الأول",
34
+ ],
35
+ },
36
+ firstDayOfWeek: 6,
37
+ rangeSeparator: " إلى ",
38
+ weekAbbreviation: "Wk",
39
+ scrollTitle: "قم بالتمرير للزيادة",
40
+ toggleTitle: "اضغط للتبديل",
41
+ amPM: ["ص", "م"],
42
+ yearAriaLabel: "سنة",
43
+ monthAriaLabel: "شهر",
44
+ hourAriaLabel: "ساعة",
45
+ minuteAriaLabel: "دقيقة",
46
+ secondAriaLabel: "ثانية",
47
+ time_24hr: false,
48
+ };
49
+ fp.l10ns.ar_sy = SyrianArabic;
50
+ export default fp.l10ns;
@@ -43,6 +43,7 @@ export var Arabic = {
43
43
  monthAriaLabel: "شهر",
44
44
  hourAriaLabel: "ساعة",
45
45
  minuteAriaLabel: "دقيقة",
46
+ secondAriaLabel: "ثانية",
46
47
  time_24hr: false,
47
48
  };
48
49
  fp.l10ns.ar = Arabic;
@@ -59,6 +59,7 @@ export var Azerbaijan = {
59
59
  monthAriaLabel: "Ay",
60
60
  hourAriaLabel: "Saat",
61
61
  minuteAriaLabel: "Dəqiqə",
62
+ secondAriaLabel: "Saniyə",
62
63
  time_24hr: true,
63
64
  };
64
65
  fp.l10ns.az = Azerbaijan;
@@ -61,6 +61,7 @@ export var Breton = {
61
61
  monthAriaLabel: "Miz",
62
62
  hourAriaLabel: "Eur",
63
63
  minuteAriaLabel: "Munud",
64
+ secondAriaLabel: "Eilenn",
64
65
  time_24hr: false,
65
66
  };
66
67
  fp.l10ns.br = Breton;
@@ -57,6 +57,7 @@ export var Danish = {
57
57
  monthAriaLabel: "måned",
58
58
  hourAriaLabel: "time",
59
59
  minuteAriaLabel: "minut",
60
+ secondAriaLabel: "sekund",
60
61
  };
61
62
  fp.l10ns.da = Danish;
62
63
  export default fp.l10ns;
@@ -56,6 +56,7 @@ export var German = {
56
56
  monthAriaLabel: "Monat",
57
57
  hourAriaLabel: "Stunde",
58
58
  minuteAriaLabel: "Minute",
59
+ secondAriaLabel: "Sekunde",
59
60
  };
60
61
  fp.l10ns.de = German;
61
62
  export default fp.l10ns;
@@ -67,6 +67,7 @@ export var english = {
67
67
  monthAriaLabel: "Month",
68
68
  hourAriaLabel: "Hour",
69
69
  minuteAriaLabel: "Minute",
70
+ secondAriaLabel: "Second",
70
71
  time_24hr: false,
71
72
  };
72
73
  export default english;
@@ -56,6 +56,7 @@ export var Spanish = {
56
56
  monthAriaLabel: "mes",
57
57
  hourAriaLabel: "hora",
58
58
  minuteAriaLabel: "minuto",
59
+ secondAriaLabel: "segundo",
59
60
  };
60
61
  fp.l10ns.es = Spanish;
61
62
  export default fp.l10ns;