flatpickr 4.5.2.0 → 4.5.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -14
  3. data/lib/flatpickr/version.rb +1 -1
  4. data/vendor/assets/javascripts/flatpickr.js +2065 -2106
  5. data/vendor/assets/javascripts/flatpickr/l10n/ar.js +12 -35
  6. data/vendor/assets/javascripts/flatpickr/l10n/at.js +17 -53
  7. data/vendor/assets/javascripts/flatpickr/l10n/be.js +22 -58
  8. data/vendor/assets/javascripts/flatpickr/l10n/bg.js +12 -48
  9. data/vendor/assets/javascripts/flatpickr/l10n/bn.js +12 -48
  10. data/vendor/assets/javascripts/flatpickr/l10n/cat.js +34 -66
  11. data/vendor/assets/javascripts/flatpickr/l10n/cs.js +22 -58
  12. data/vendor/assets/javascripts/flatpickr/l10n/cy.js +23 -75
  13. data/vendor/assets/javascripts/flatpickr/l10n/da.js +18 -54
  14. data/vendor/assets/javascripts/flatpickr/l10n/de.js +17 -53
  15. data/vendor/assets/javascripts/flatpickr/l10n/default.js +35 -66
  16. data/vendor/assets/javascripts/flatpickr/l10n/eo.js +20 -56
  17. data/vendor/assets/javascripts/flatpickr/l10n/es.js +17 -53
  18. data/vendor/assets/javascripts/flatpickr/l10n/et.js +20 -56
  19. data/vendor/assets/javascripts/flatpickr/l10n/fa.js +16 -52
  20. data/vendor/assets/javascripts/flatpickr/l10n/fi.js +16 -52
  21. data/vendor/assets/javascripts/flatpickr/l10n/fr.js +21 -58
  22. data/vendor/assets/javascripts/flatpickr/l10n/gr.js +21 -57
  23. data/vendor/assets/javascripts/flatpickr/l10n/he.js +12 -40
  24. data/vendor/assets/javascripts/flatpickr/l10n/hi.js +12 -48
  25. data/vendor/assets/javascripts/flatpickr/l10n/hr.js +13 -49
  26. data/vendor/assets/javascripts/flatpickr/l10n/hu.js +19 -55
  27. data/vendor/assets/javascripts/flatpickr/l10n/id.js +16 -44
  28. data/vendor/assets/javascripts/flatpickr/l10n/index.js +963 -2805
  29. data/vendor/assets/javascripts/flatpickr/l10n/it.js +20 -54
  30. data/vendor/assets/javascripts/flatpickr/l10n/ja.js +12 -48
  31. data/vendor/assets/javascripts/flatpickr/l10n/km.js +21 -57
  32. data/vendor/assets/javascripts/flatpickr/l10n/ko.js +15 -51
  33. data/vendor/assets/javascripts/flatpickr/l10n/kz.js +22 -58
  34. data/vendor/assets/javascripts/flatpickr/l10n/lt.js +19 -55
  35. data/vendor/assets/javascripts/flatpickr/l10n/lv.js +14 -50
  36. data/vendor/assets/javascripts/flatpickr/l10n/mk.js +15 -51
  37. data/vendor/assets/javascripts/flatpickr/l10n/mn.js +14 -42
  38. data/vendor/assets/javascripts/flatpickr/l10n/ms.js +16 -52
  39. data/vendor/assets/javascripts/flatpickr/l10n/my.js +16 -52
  40. data/vendor/assets/javascripts/flatpickr/l10n/nl.js +21 -58
  41. data/vendor/assets/javascripts/flatpickr/l10n/no.js +20 -56
  42. data/vendor/assets/javascripts/flatpickr/l10n/pa.js +12 -48
  43. data/vendor/assets/javascripts/flatpickr/l10n/pl.js +20 -56
  44. data/vendor/assets/javascripts/flatpickr/l10n/pt.js +13 -49
  45. data/vendor/assets/javascripts/flatpickr/l10n/ro.js +16 -52
  46. data/vendor/assets/javascripts/flatpickr/l10n/ru.js +22 -58
  47. data/vendor/assets/javascripts/flatpickr/l10n/si.js +12 -48
  48. data/vendor/assets/javascripts/flatpickr/l10n/sk.js +17 -53
  49. data/vendor/assets/javascripts/flatpickr/l10n/sl.js +17 -53
  50. data/vendor/assets/javascripts/flatpickr/l10n/sq.js +12 -48
  51. data/vendor/assets/javascripts/flatpickr/l10n/sr.js +15 -51
  52. data/vendor/assets/javascripts/flatpickr/l10n/sv.js +17 -53
  53. data/vendor/assets/javascripts/flatpickr/l10n/th.js +19 -55
  54. data/vendor/assets/javascripts/flatpickr/l10n/tr.js +21 -57
  55. data/vendor/assets/javascripts/flatpickr/l10n/uk.js +13 -49
  56. data/vendor/assets/javascripts/flatpickr/l10n/vn.js +13 -49
  57. data/vendor/assets/javascripts/flatpickr/l10n/zh.js +16 -52
  58. data/vendor/assets/javascripts/flatpickr/plugins/confirmDate/confirmDate.js +32 -35
  59. data/vendor/assets/javascripts/flatpickr/plugins/labelPlugin/labelPlugin.js +18 -17
  60. data/vendor/assets/javascripts/flatpickr/plugins/minMaxTimePlugin.js +262 -251
  61. data/vendor/assets/javascripts/flatpickr/plugins/monthSelect/monthSelect.js +46 -63
  62. data/vendor/assets/javascripts/flatpickr/plugins/rangePlugin.js +134 -125
  63. data/vendor/assets/javascripts/flatpickr/plugins/scrollPlugin.js +44 -31
  64. data/vendor/assets/javascripts/flatpickr/plugins/weekSelect/weekSelect.js +63 -66
  65. metadata +3 -4
@@ -6,70 +6,53 @@
6
6
  }(this, (function () { 'use strict';
7
7
 
8
8
  function monthSelectPlugin() {
9
- return function (fp) {
10
- var days;
11
- function onDayHover(event) {
12
- if (!event.target ||
13
- !event.target.classList.contains("flatpickr-day"))
14
- return;
15
- const dayIndex = Array.prototype.indexOf.call(days, event.target);
16
- fp.monthStartDay = new Date(days[dayIndex].dateObj.getFullYear(), days[dayIndex].dateObj.getMonth(), 1, 0, 0, 0, 0).getTime();
17
- fp.monthEndDay = new Date(days[dayIndex].dateObj.getFullYear(), days[dayIndex].dateObj.getMonth() + 1, 0, 0, 0, 0, 0).getTime();
18
- for (var i = days.length; i--;) {
19
- var date = days[i].dateObj.getTime();
20
- if (date > fp.monthEndDay || date < fp.monthStartDay)
21
- days[i].classList.remove("inRange");
22
- else
23
- days[i].classList.add("inRange");
24
- if (date != fp.monthEndDay)
25
- days[i].classList.remove("endRange");
26
- else
27
- days[i].classList.add("endRange");
28
- if (date != fp.monthStartDay)
29
- days[i].classList.remove("startRange");
30
- else
31
- days[i].classList.add("startRange");
32
- }
33
- }
34
- function highlightMonth() {
35
- for (var i = days.length; i--;) {
36
- var date = days[i].dateObj.getTime();
37
- if (date >= fp.monthStartDay && date <= fp.monthEndDay)
38
- days[i].classList.add("month", "selected");
39
- if (date != fp.monthEndDay)
40
- days[i].classList.remove("endRange");
41
- else
42
- days[i].classList.add("endRange");
43
- if (date != fp.monthStartDay)
44
- days[i].classList.remove("startRange");
45
- else
46
- days[i].classList.add("startRange");
47
- }
48
- }
49
- function clearHover() {
50
- for (var i = days.length; i--;) {
51
- days[i].classList.remove("inRange");
52
- }
53
- }
54
- return {
55
- onChange: highlightMonth,
56
- onMonthChange: highlightMonth,
57
- onClose: clearHover,
58
- onParseConfig: function onParseConfig() {
59
- fp.config.mode = "single";
60
- fp.config.enableTime = false;
61
- },
62
- onReady: [
63
- function () {
64
- days = fp.days.childNodes;
65
- },
66
- function () {
67
- return fp.days.addEventListener("mouseover", onDayHover);
68
- },
69
- highlightMonth,
70
- ],
71
- };
9
+ return function (fp) {
10
+ var days;
11
+
12
+ function onDayHover(event) {
13
+ if (!event.target || !event.target.classList.contains("flatpickr-day")) return;
14
+ var dayIndex = Array.prototype.indexOf.call(days, event.target);
15
+ fp.monthStartDay = new Date(days[dayIndex].dateObj.getFullYear(), days[dayIndex].dateObj.getMonth(), 1, 0, 0, 0, 0).getTime();
16
+ fp.monthEndDay = new Date(days[dayIndex].dateObj.getFullYear(), days[dayIndex].dateObj.getMonth() + 1, 0, 0, 0, 0, 0).getTime();
17
+
18
+ for (var i = days.length; i--;) {
19
+ var date = days[i].dateObj.getTime();
20
+ if (date > fp.monthEndDay || date < fp.monthStartDay) days[i].classList.remove("inRange");else days[i].classList.add("inRange");
21
+ if (date != fp.monthEndDay) days[i].classList.remove("endRange");else days[i].classList.add("endRange");
22
+ if (date != fp.monthStartDay) days[i].classList.remove("startRange");else days[i].classList.add("startRange");
23
+ }
24
+ }
25
+
26
+ function highlightMonth() {
27
+ for (var i = days.length; i--;) {
28
+ var date = days[i].dateObj.getTime();
29
+ if (date >= fp.monthStartDay && date <= fp.monthEndDay) days[i].classList.add("month", "selected");
30
+ if (date != fp.monthEndDay) days[i].classList.remove("endRange");else days[i].classList.add("endRange");
31
+ if (date != fp.monthStartDay) days[i].classList.remove("startRange");else days[i].classList.add("startRange");
32
+ }
33
+ }
34
+
35
+ function clearHover() {
36
+ for (var i = days.length; i--;) {
37
+ days[i].classList.remove("inRange");
38
+ }
39
+ }
40
+
41
+ return {
42
+ onChange: highlightMonth,
43
+ onMonthChange: highlightMonth,
44
+ onClose: clearHover,
45
+ onParseConfig: function onParseConfig() {
46
+ fp.config.mode = "single";
47
+ fp.config.enableTime = false;
48
+ },
49
+ onReady: [function () {
50
+ days = fp.days.childNodes;
51
+ }, function () {
52
+ return fp.days.addEventListener("mouseover", onDayHover);
53
+ }, highlightMonth]
72
54
  };
55
+ };
73
56
  }
74
57
 
75
58
  return monthSelectPlugin;
@@ -5,132 +5,141 @@
5
5
  (global.rangePlugin = factory());
6
6
  }(this, (function () { 'use strict';
7
7
 
8
- function rangePlugin(config = {}) {
9
- return function (fp) {
10
- let dateFormat = "", secondInput, _firstInputFocused, _secondInputFocused, _prevDates;
11
- const createSecondInput = () => {
12
- if (config.input) {
13
- secondInput =
14
- config.input instanceof Element
15
- ? config.input
16
- : window.document.querySelector(config.input);
17
- }
18
- else {
19
- secondInput = fp._input.cloneNode();
20
- secondInput.removeAttribute("id");
21
- secondInput._flatpickr = undefined;
22
- }
23
- if (secondInput.value) {
24
- const parsedDate = fp.parseDate(secondInput.value);
25
- if (parsedDate)
26
- fp.selectedDates.push(parsedDate);
27
- }
28
- secondInput.setAttribute("data-fp-omit", "");
29
- fp._bind(secondInput, ["focus", "click"], () => {
30
- if (fp.selectedDates[1]) {
31
- fp.latestSelectedDateObj = fp.selectedDates[1];
32
- fp._setHoursFromDate(fp.selectedDates[1]);
33
- fp.jumpToDate(fp.selectedDates[1]);
34
- }
35
- [_firstInputFocused, _secondInputFocused] = [false, true];
36
- fp.isOpen = false;
37
- fp.open(undefined, secondInput);
38
- });
39
- fp._bind(fp._input, ["focus", "click"], (e) => {
40
- e.preventDefault();
41
- fp.isOpen = false;
42
- fp.open();
43
- });
44
- if (fp.config.allowInput)
45
- fp._bind(secondInput, "keydown", (e) => {
46
- if (e.key === "Enter") {
47
- fp.setDate([fp.selectedDates[0], secondInput.value], true, dateFormat);
48
- secondInput.click();
49
- }
50
- });
51
- if (!config.input)
52
- fp._input.parentNode &&
53
- fp._input.parentNode.insertBefore(secondInput, fp._input.nextSibling);
54
- };
55
- const plugin = {
56
- onParseConfig() {
57
- fp.config.mode = "range";
58
- dateFormat = fp.config.altInput
59
- ? fp.config.altFormat
60
- : fp.config.dateFormat;
61
- },
62
- onReady() {
63
- createSecondInput();
64
- fp.config.ignoredFocusElements.push(secondInput);
65
- if (fp.config.allowInput) {
66
- fp._input.removeAttribute("readonly");
67
- secondInput.removeAttribute("readonly");
68
- }
69
- else {
70
- secondInput.setAttribute("readonly", "readonly");
71
- }
72
- fp._bind(fp._input, "focus", () => {
73
- fp.latestSelectedDateObj = fp.selectedDates[0];
74
- fp._setHoursFromDate(fp.selectedDates[0]);
75
- [_firstInputFocused, _secondInputFocused] = [true, false];
76
- fp.jumpToDate(fp.selectedDates[0]);
77
- });
78
- if (fp.config.allowInput)
79
- fp._bind(fp._input, "keydown", (e) => {
80
- if (e.key === "Enter")
81
- fp.setDate([fp._input.value, fp.selectedDates[1]], true, dateFormat);
82
- });
83
- fp.setDate(fp.selectedDates, false);
84
- plugin.onValueUpdate(fp.selectedDates);
85
- },
86
- onPreCalendarPosition() {
87
- if (_secondInputFocused) {
88
- fp._positionElement = secondInput;
89
- setTimeout(() => {
90
- fp._positionElement = fp._input;
91
- }, 0);
92
- }
93
- },
94
- onChange() {
95
- if (!fp.selectedDates.length) {
96
- setTimeout(() => {
97
- if (fp.selectedDates.length)
98
- return;
99
- secondInput.value = "";
100
- _prevDates = [];
101
- }, 10);
102
- }
103
- if (_secondInputFocused) {
104
- setTimeout(() => {
105
- secondInput.focus();
106
- }, 0);
107
- }
108
- },
109
- onDestroy() {
110
- if (!config.input)
111
- secondInput.parentNode &&
112
- secondInput.parentNode.removeChild(secondInput);
113
- },
114
- onValueUpdate(selDates) {
115
- if (!secondInput)
116
- return;
117
- _prevDates =
118
- !_prevDates || selDates.length >= _prevDates.length
119
- ? [...selDates]
120
- : _prevDates;
121
- if (_prevDates.length > selDates.length) {
122
- const newSelectedDate = selDates[0];
123
- const newDates = _secondInputFocused
124
- ? [_prevDates[0], newSelectedDate]
125
- : [newSelectedDate, _prevDates[1]];
126
- fp.setDate(newDates, false);
127
- _prevDates = [...newDates];
128
- }
129
- [fp._input.value = "", secondInput.value = ""] = fp.selectedDates.map(d => fp.formatDate(d, dateFormat));
130
- },
131
- };
132
- return plugin;
8
+ function rangePlugin(config) {
9
+ if (config === void 0) {
10
+ config = {};
11
+ }
12
+
13
+ return function (fp) {
14
+ var dateFormat = "",
15
+ secondInput,
16
+ _secondInputFocused,
17
+ _prevDates;
18
+
19
+ var createSecondInput = function createSecondInput() {
20
+ if (config.input) {
21
+ secondInput = config.input instanceof Element ? config.input : window.document.querySelector(config.input);
22
+ } else {
23
+ secondInput = fp._input.cloneNode();
24
+ secondInput.removeAttribute("id");
25
+ secondInput._flatpickr = undefined;
26
+ }
27
+
28
+ if (secondInput.value) {
29
+ var parsedDate = fp.parseDate(secondInput.value);
30
+ if (parsedDate) fp.selectedDates.push(parsedDate);
31
+ }
32
+
33
+ secondInput.setAttribute("data-fp-omit", "");
34
+
35
+ fp._bind(secondInput, ["focus", "click"], function () {
36
+ if (fp.selectedDates[1]) {
37
+ fp.latestSelectedDateObj = fp.selectedDates[1];
38
+
39
+ fp._setHoursFromDate(fp.selectedDates[1]);
40
+
41
+ fp.jumpToDate(fp.selectedDates[1]);
42
+ }
43
+ _secondInputFocused = true;
44
+ fp.isOpen = false;
45
+ fp.open(undefined, secondInput);
46
+ });
47
+
48
+ fp._bind(fp._input, ["focus", "click"], function (e) {
49
+ e.preventDefault();
50
+ fp.isOpen = false;
51
+ fp.open();
52
+ });
53
+
54
+ if (fp.config.allowInput) fp._bind(secondInput, "keydown", function (e) {
55
+ if (e.key === "Enter") {
56
+ fp.setDate([fp.selectedDates[0], secondInput.value], true, dateFormat);
57
+ secondInput.click();
58
+ }
59
+ });
60
+ if (!config.input) fp._input.parentNode && fp._input.parentNode.insertBefore(secondInput, fp._input.nextSibling);
61
+ };
62
+
63
+ var plugin = {
64
+ onParseConfig: function onParseConfig() {
65
+ fp.config.mode = "range";
66
+ dateFormat = fp.config.altInput ? fp.config.altFormat : fp.config.dateFormat;
67
+ },
68
+ onReady: function onReady() {
69
+ createSecondInput();
70
+ fp.config.ignoredFocusElements.push(secondInput);
71
+
72
+ if (fp.config.allowInput) {
73
+ fp._input.removeAttribute("readonly");
74
+
75
+ secondInput.removeAttribute("readonly");
76
+ } else {
77
+ secondInput.setAttribute("readonly", "readonly");
78
+ }
79
+
80
+ fp._bind(fp._input, "focus", function () {
81
+ fp.latestSelectedDateObj = fp.selectedDates[0];
82
+
83
+ fp._setHoursFromDate(fp.selectedDates[0]);
84
+ _secondInputFocused = false;
85
+ fp.jumpToDate(fp.selectedDates[0]);
86
+ });
87
+
88
+ if (fp.config.allowInput) fp._bind(fp._input, "keydown", function (e) {
89
+ if (e.key === "Enter") fp.setDate([fp._input.value, fp.selectedDates[1]], true, dateFormat);
90
+ });
91
+ fp.setDate(fp.selectedDates, false);
92
+ plugin.onValueUpdate(fp.selectedDates);
93
+ },
94
+ onPreCalendarPosition: function onPreCalendarPosition() {
95
+ if (_secondInputFocused) {
96
+ fp._positionElement = secondInput;
97
+ setTimeout(function () {
98
+ fp._positionElement = fp._input;
99
+ }, 0);
100
+ }
101
+ },
102
+ onChange: function onChange() {
103
+ if (!fp.selectedDates.length) {
104
+ setTimeout(function () {
105
+ if (fp.selectedDates.length) return;
106
+ secondInput.value = "";
107
+ _prevDates = [];
108
+ }, 10);
109
+ }
110
+
111
+ if (_secondInputFocused) {
112
+ setTimeout(function () {
113
+ secondInput.focus();
114
+ }, 0);
115
+ }
116
+ },
117
+ onDestroy: function onDestroy() {
118
+ if (!config.input) secondInput.parentNode && secondInput.parentNode.removeChild(secondInput);
119
+ },
120
+ onValueUpdate: function onValueUpdate(selDates) {
121
+ if (!secondInput) return;
122
+ _prevDates = !_prevDates || selDates.length >= _prevDates.length ? selDates.concat() : _prevDates;
123
+
124
+ if (_prevDates.length > selDates.length) {
125
+ var newSelectedDate = selDates[0];
126
+ var newDates = _secondInputFocused ? [_prevDates[0], newSelectedDate] : [newSelectedDate, _prevDates[1]];
127
+ fp.setDate(newDates, false);
128
+ _prevDates = newDates.concat();
129
+ }
130
+
131
+ var _fp$selectedDates$map = fp.selectedDates.map(function (d) {
132
+ return fp.formatDate(d, dateFormat);
133
+ });
134
+
135
+ var _fp$selectedDates$map2 = _fp$selectedDates$map[0];
136
+ fp._input.value = _fp$selectedDates$map2 === void 0 ? "" : _fp$selectedDates$map2;
137
+ var _fp$selectedDates$map3 = _fp$selectedDates$map[1];
138
+ secondInput.value = _fp$selectedDates$map3 === void 0 ? "" : _fp$selectedDates$map3;
139
+ }
133
140
  };
141
+ return plugin;
142
+ };
134
143
  }
135
144
 
136
145
  return rangePlugin;
@@ -6,43 +6,56 @@
6
6
  }(this, (function () { 'use strict';
7
7
 
8
8
  function delta(e) {
9
- return Math.max(-1, Math.min(1, e.wheelDelta || -e.deltaY));
9
+ return Math.max(-1, Math.min(1, e.wheelDelta || -e.deltaY));
10
10
  }
11
- const scroll = (e) => {
12
- e.preventDefault();
13
- const ev = new CustomEvent("increment", {
14
- bubbles: true,
15
- });
16
- ev.delta = delta(e);
17
- e.target.dispatchEvent(ev);
11
+
12
+ var scroll = function scroll(e) {
13
+ e.preventDefault();
14
+ var ev = new CustomEvent("increment", {
15
+ bubbles: true
16
+ });
17
+ ev.delta = delta(e);
18
+ e.target.dispatchEvent(ev);
18
19
  };
20
+
19
21
  function scrollMonth(fp) {
20
- return (e) => {
21
- e.preventDefault();
22
- const mDelta = delta(e);
23
- fp.changeMonth(mDelta);
24
- };
22
+ return function (e) {
23
+ e.preventDefault();
24
+ var mDelta = delta(e);
25
+ fp.changeMonth(mDelta);
26
+ };
25
27
  }
28
+
26
29
  function scrollPlugin() {
27
- return function (fp) {
28
- const monthScroller = scrollMonth(fp);
29
- return {
30
- onReady() {
31
- if (fp.timeContainer) {
32
- fp.timeContainer.addEventListener("wheel", scroll);
33
- }
34
- fp.yearElements.forEach(yearElem => yearElem.addEventListener("wheel", scroll));
35
- fp.monthElements.forEach(monthElem => monthElem.addEventListener("wheel", monthScroller));
36
- },
37
- onDestroy() {
38
- if (fp.timeContainer) {
39
- fp.timeContainer.removeEventListener("wheel", scroll);
40
- }
41
- fp.yearElements.forEach(yearElem => yearElem.removeEventListener("wheel", scroll));
42
- fp.monthElements.forEach(monthElem => monthElem.removeEventListener("wheel", monthScroller));
43
- },
44
- };
30
+ return function (fp) {
31
+ var monthScroller = scrollMonth(fp);
32
+ return {
33
+ onReady: function onReady() {
34
+ if (fp.timeContainer) {
35
+ fp.timeContainer.addEventListener("wheel", scroll);
36
+ }
37
+
38
+ fp.yearElements.forEach(function (yearElem) {
39
+ return yearElem.addEventListener("wheel", scroll);
40
+ });
41
+ fp.monthElements.forEach(function (monthElem) {
42
+ return monthElem.addEventListener("wheel", monthScroller);
43
+ });
44
+ },
45
+ onDestroy: function onDestroy() {
46
+ if (fp.timeContainer) {
47
+ fp.timeContainer.removeEventListener("wheel", scroll);
48
+ }
49
+
50
+ fp.yearElements.forEach(function (yearElem) {
51
+ return yearElem.removeEventListener("wheel", scroll);
52
+ });
53
+ fp.monthElements.forEach(function (monthElem) {
54
+ return monthElem.removeEventListener("wheel", monthScroller);
55
+ });
56
+ }
45
57
  };
58
+ };
46
59
  }
47
60
 
48
61
  return scrollPlugin;