flatpickr 4.6.6.0 → 4.6.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/lib/flatpickr/version.rb +1 -1
  3. data/package.json +5 -0
  4. data/vendor/assets/javascripts/flatpickr/l10n/ar-dz.js +61 -0
  5. data/vendor/assets/javascripts/flatpickr/l10n/ar.js +12 -2
  6. data/vendor/assets/javascripts/flatpickr/l10n/at.js +2 -1
  7. data/vendor/assets/javascripts/flatpickr/l10n/az.js +1 -1
  8. data/vendor/assets/javascripts/flatpickr/l10n/be.js +1 -1
  9. data/vendor/assets/javascripts/flatpickr/l10n/bg.js +1 -1
  10. data/vendor/assets/javascripts/flatpickr/l10n/bn.js +1 -1
  11. data/vendor/assets/javascripts/flatpickr/l10n/bs.js +1 -1
  12. data/vendor/assets/javascripts/flatpickr/l10n/cat.js +2 -1
  13. data/vendor/assets/javascripts/flatpickr/l10n/ckb.js +68 -0
  14. data/vendor/assets/javascripts/flatpickr/l10n/cs.js +1 -1
  15. data/vendor/assets/javascripts/flatpickr/l10n/cy.js +1 -1
  16. data/vendor/assets/javascripts/flatpickr/l10n/da.js +1 -1
  17. data/vendor/assets/javascripts/flatpickr/l10n/de.js +1 -1
  18. data/vendor/assets/javascripts/flatpickr/l10n/default.js +1 -1
  19. data/vendor/assets/javascripts/flatpickr/l10n/eo.js +1 -1
  20. data/vendor/assets/javascripts/flatpickr/l10n/es.js +1 -1
  21. data/vendor/assets/javascripts/flatpickr/l10n/et.js +1 -1
  22. data/vendor/assets/javascripts/flatpickr/l10n/fa.js +1 -1
  23. data/vendor/assets/javascripts/flatpickr/l10n/fi.js +33 -33
  24. data/vendor/assets/javascripts/flatpickr/l10n/fo.js +1 -1
  25. data/vendor/assets/javascripts/flatpickr/l10n/fr.js +1 -1
  26. data/vendor/assets/javascripts/flatpickr/l10n/ga.js +1 -1
  27. data/vendor/assets/javascripts/flatpickr/l10n/gr.js +7 -3
  28. data/vendor/assets/javascripts/flatpickr/l10n/he.js +1 -1
  29. data/vendor/assets/javascripts/flatpickr/l10n/hi.js +1 -1
  30. data/vendor/assets/javascripts/flatpickr/l10n/hr.js +1 -1
  31. data/vendor/assets/javascripts/flatpickr/l10n/hu.js +1 -1
  32. data/vendor/assets/javascripts/flatpickr/l10n/hy.js +86 -0
  33. data/vendor/assets/javascripts/flatpickr/l10n/id.js +1 -1
  34. data/vendor/assets/javascripts/flatpickr/l10n/index.js +442 -226
  35. data/vendor/assets/javascripts/flatpickr/l10n/is.js +1 -1
  36. data/vendor/assets/javascripts/flatpickr/l10n/it.js +1 -1
  37. data/vendor/assets/javascripts/flatpickr/l10n/ja.js +6 -2
  38. data/vendor/assets/javascripts/flatpickr/l10n/ka.js +1 -1
  39. data/vendor/assets/javascripts/flatpickr/l10n/km.js +1 -1
  40. data/vendor/assets/javascripts/flatpickr/l10n/ko.js +2 -1
  41. data/vendor/assets/javascripts/flatpickr/l10n/kz.js +1 -1
  42. data/vendor/assets/javascripts/flatpickr/l10n/lt.js +1 -1
  43. data/vendor/assets/javascripts/flatpickr/l10n/lv.js +1 -1
  44. data/vendor/assets/javascripts/flatpickr/l10n/mk.js +1 -1
  45. data/vendor/assets/javascripts/flatpickr/l10n/mn.js +1 -1
  46. data/vendor/assets/javascripts/flatpickr/l10n/ms.js +3 -3
  47. data/vendor/assets/javascripts/flatpickr/l10n/my.js +1 -1
  48. data/vendor/assets/javascripts/flatpickr/l10n/nl.js +1 -1
  49. data/vendor/assets/javascripts/flatpickr/l10n/nn.js +73 -0
  50. data/vendor/assets/javascripts/flatpickr/l10n/no.js +1 -1
  51. data/vendor/assets/javascripts/flatpickr/l10n/pa.js +1 -1
  52. data/vendor/assets/javascripts/flatpickr/l10n/pl.js +1 -1
  53. data/vendor/assets/javascripts/flatpickr/l10n/pt.js +1 -1
  54. data/vendor/assets/javascripts/flatpickr/l10n/ro.js +1 -1
  55. data/vendor/assets/javascripts/flatpickr/l10n/ru.js +1 -1
  56. data/vendor/assets/javascripts/flatpickr/l10n/si.js +1 -1
  57. data/vendor/assets/javascripts/flatpickr/l10n/sk.js +1 -1
  58. data/vendor/assets/javascripts/flatpickr/l10n/sl.js +1 -1
  59. data/vendor/assets/javascripts/flatpickr/l10n/sq.js +1 -1
  60. data/vendor/assets/javascripts/flatpickr/l10n/sr-cyr.js +1 -1
  61. data/vendor/assets/javascripts/flatpickr/l10n/sr.js +1 -1
  62. data/vendor/assets/javascripts/flatpickr/l10n/sv.js +34 -33
  63. data/vendor/assets/javascripts/flatpickr/l10n/th.js +1 -1
  64. data/vendor/assets/javascripts/flatpickr/l10n/tr.js +1 -1
  65. data/vendor/assets/javascripts/flatpickr/l10n/uk.js +1 -1
  66. data/vendor/assets/javascripts/flatpickr/l10n/uz.js +1 -1
  67. data/vendor/assets/javascripts/flatpickr/l10n/uz_latn.js +1 -1
  68. data/vendor/assets/javascripts/flatpickr/l10n/vn.js +3 -3
  69. data/vendor/assets/javascripts/flatpickr/l10n/zh-tw.js +1 -1
  70. data/vendor/assets/javascripts/flatpickr/l10n/zh.js +1 -1
  71. data/vendor/assets/javascripts/flatpickr/plugins/confirmDate/confirmDate.js +6 -2
  72. data/vendor/assets/javascripts/flatpickr/plugins/labelPlugin/labelPlugin.js +1 -1
  73. data/vendor/assets/javascripts/flatpickr/plugins/minMaxTimePlugin.js +24 -7
  74. data/vendor/assets/javascripts/flatpickr/plugins/momentPlugin.js +1 -1
  75. data/vendor/assets/javascripts/flatpickr/plugins/monthSelect/index.js +108 -53
  76. data/vendor/assets/javascripts/flatpickr/plugins/rangePlugin.js +26 -16
  77. data/vendor/assets/javascripts/flatpickr/plugins/scrollPlugin.js +23 -15
  78. data/vendor/assets/javascripts/flatpickr/plugins/weekSelect/weekSelect.js +1 -1
  79. data/vendor/assets/javascripts/flatpickr.js +220 -164
  80. data/vendor/assets/stylesheets/flatpickr/plugins/monthSelect/style.css +45 -7
  81. data/vendor/assets/stylesheets/flatpickr/themes/airbnb.css +4 -0
  82. data/vendor/assets/stylesheets/flatpickr/themes/confetti.css +4 -0
  83. data/vendor/assets/stylesheets/flatpickr/themes/dark.css +4 -0
  84. data/vendor/assets/stylesheets/flatpickr/themes/light.css +4 -0
  85. data/vendor/assets/stylesheets/flatpickr/themes/material_blue.css +4 -0
  86. data/vendor/assets/stylesheets/flatpickr/themes/material_green.css +4 -0
  87. data/vendor/assets/stylesheets/flatpickr/themes/material_orange.css +4 -0
  88. data/vendor/assets/stylesheets/flatpickr/themes/material_red.css +4 -0
  89. data/vendor/assets/stylesheets/flatpickr.css +4 -0
  90. metadata +12 -7
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
- (global = global || self, global.minMaxTimePlugin = factory());
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.minMaxTimePlugin = factory());
5
5
  }(this, (function () { 'use strict';
6
6
 
7
7
  var pad = function (number, length) {
@@ -77,7 +77,6 @@
77
77
 
78
78
  var defaults = {
79
79
  _disable: [],
80
- _enable: [],
81
80
  allowInput: false,
82
81
  allowInvalidPreload: false,
83
82
  altFormat: "F j, Y",
@@ -96,7 +95,6 @@
96
95
  defaultSeconds: 0,
97
96
  disable: [],
98
97
  disableMobile: false,
99
- enable: [],
100
98
  enableSeconds: false,
101
99
  enableTime: false,
102
100
  errorHandler: function (err) {
@@ -261,6 +259,13 @@
261
259
  date1.getSeconds() -
262
260
  date2.getSeconds());
263
261
  }
262
+ var calculateSecondsSinceMidnight = function (hours, minutes, seconds) {
263
+ return hours * 3600 + minutes * 60 + seconds;
264
+ };
265
+ var parseSeconds = function (secondsSinceMidnight) {
266
+ var hours = Math.floor(secondsSinceMidnight / 3600), minutes = (secondsSinceMidnight - hours * 3600) / 60;
267
+ return [hours, minutes, secondsSinceMidnight - hours * 3600 - minutes * 60];
268
+ };
264
269
 
265
270
  function minMaxTimePlugin(config) {
266
271
  if (config === void 0) { config = {}; }
@@ -299,11 +304,23 @@
299
304
  fp.config.maxTime.setMonth(latest.getMonth());
300
305
  fp.config.minTime.setDate(latest.getDate());
301
306
  fp.config.maxTime.setDate(latest.getDate());
302
- if (compareDates(latest, fp.config.maxTime, false) > 0) {
303
- fp.setDate(new Date(latest.getTime()).setHours(fp.config.maxTime.getHours(), fp.config.maxTime.getMinutes(), fp.config.maxTime.getSeconds(), fp.config.maxTime.getMilliseconds()), false);
307
+ if (fp.config.minTime > fp.config.maxTime) {
308
+ var minBound = calculateSecondsSinceMidnight(fp.config.minTime.getHours(), fp.config.minTime.getMinutes(), fp.config.minTime.getSeconds());
309
+ var maxBound = calculateSecondsSinceMidnight(fp.config.maxTime.getHours(), fp.config.maxTime.getMinutes(), fp.config.maxTime.getSeconds());
310
+ var currentTime = calculateSecondsSinceMidnight(latest.getHours(), latest.getMinutes(), latest.getSeconds());
311
+ if (currentTime > maxBound && currentTime < minBound) {
312
+ var result = parseSeconds(minBound);
313
+ fp.setDate(new Date(latest.getTime()).setHours(result[0], result[1], result[2]), false);
314
+ }
315
+ }
316
+ else {
317
+ if (compareDates(latest, fp.config.maxTime, false) > 0) {
318
+ fp.setDate(new Date(latest.getTime()).setHours(fp.config.maxTime.getHours(), fp.config.maxTime.getMinutes(), fp.config.maxTime.getSeconds(), fp.config.maxTime.getMilliseconds()), false);
319
+ }
320
+ else if (compareDates(latest, fp.config.minTime, false) < 0) {
321
+ fp.setDate(new Date(latest.getTime()).setHours(fp.config.minTime.getHours(), fp.config.minTime.getMinutes(), fp.config.minTime.getSeconds(), fp.config.minTime.getMilliseconds()), false);
322
+ }
304
323
  }
305
- else if (compareDates(latest, fp.config.minTime, false) < 0)
306
- fp.setDate(new Date(latest.getTime()).setHours(fp.config.minTime.getHours(), fp.config.minTime.getMinutes(), fp.config.minTime.getSeconds(), fp.config.minTime.getMilliseconds()), false);
307
324
  }
308
325
  else {
309
326
  var newMinMax = state.defaults || {
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
- (global = global || self, global.momentPlugin = factory());
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.momentPlugin = factory());
5
5
  }(this, (function () { 'use strict';
6
6
 
7
7
  function getEventTarget(event) {
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
- (global = global || self, global.monthSelectPlugin = factory());
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.monthSelectPlugin = factory());
5
5
  }(this, (function () { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
@@ -32,6 +32,10 @@
32
32
 
33
33
  var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
34
34
 
35
+ function clearNode(node) {
36
+ while (node.firstChild)
37
+ node.removeChild(node.firstChild);
38
+ }
35
39
  function getEventTarget(event) {
36
40
  try {
37
41
  if (typeof event.composedPath === "function") {
@@ -58,10 +62,9 @@
58
62
  fp.config.altFormat = config.altFormat;
59
63
  var self = { monthsContainer: null };
60
64
  function clearUnnecessaryDOMElements() {
61
- if (!fp.rContainer || !fp.daysContainer || !fp.weekdayContainer)
65
+ if (!fp.rContainer)
62
66
  return;
63
- fp.rContainer.removeChild(fp.daysContainer);
64
- fp.rContainer.removeChild(fp.weekdayContainer);
67
+ clearNode(fp.rContainer);
65
68
  for (var index = 0; index < fp.monthElements.length; index++) {
66
69
  var element = fp.monthElements[index];
67
70
  if (!element.parentNode)
@@ -69,57 +72,62 @@
69
72
  element.parentNode.removeChild(element);
70
73
  }
71
74
  }
72
- function addListeners() {
75
+ function build() {
76
+ if (!fp.rContainer)
77
+ return;
78
+ self.monthsContainer = fp._createElement("div", "flatpickr-monthSelect-months");
79
+ self.monthsContainer.tabIndex = -1;
80
+ buildMonths();
81
+ fp.rContainer.appendChild(self.monthsContainer);
82
+ fp.calendarContainer.classList.add("flatpickr-monthSelect-theme-" + config.theme);
83
+ }
84
+ function buildMonths() {
85
+ if (!self.monthsContainer)
86
+ return;
87
+ clearNode(self.monthsContainer);
88
+ var frag = document.createDocumentFragment();
89
+ for (var i = 0; i < 12; i++) {
90
+ var month = fp.createDay("flatpickr-monthSelect-month", new Date(fp.currentYear, i), 0, i);
91
+ if (month.dateObj.getMonth() === new Date().getMonth() &&
92
+ month.dateObj.getFullYear() === new Date().getFullYear())
93
+ month.classList.add("today");
94
+ month.textContent = monthToStr(i, config.shorthand, fp.l10n);
95
+ month.addEventListener("click", selectMonth);
96
+ frag.appendChild(month);
97
+ }
98
+ self.monthsContainer.appendChild(frag);
99
+ }
100
+ function bindEvents() {
73
101
  fp._bind(fp.prevMonthNav, "click", function (e) {
74
- var _a;
75
102
  e.preventDefault();
76
103
  e.stopPropagation();
77
- var selectedMonth = (_a = fp.rContainer) === null || _a === void 0 ? void 0 : _a.querySelector(".flatpickr-monthSelect-month.selected").dateObj.getMonth();
78
- if (selectedMonth === 0) {
79
- fp.currentYear--;
80
- }
104
+ fp.changeYear(fp.currentYear - 1);
81
105
  selectYear();
106
+ buildMonths();
82
107
  });
83
108
  fp._bind(fp.nextMonthNav, "click", function (e) {
84
- var _a;
85
109
  e.preventDefault();
86
110
  e.stopPropagation();
87
- var selectedMonth = (_a = fp.rContainer) === null || _a === void 0 ? void 0 : _a.querySelector(".flatpickr-monthSelect-month.selected").dateObj.getMonth();
88
- if (selectedMonth === 11) {
89
- fp.currentYear++;
90
- }
111
+ fp.changeYear(fp.currentYear + 1);
91
112
  selectYear();
113
+ buildMonths();
114
+ });
115
+ fp._bind(self.monthsContainer, "mouseover", function (e) {
116
+ if (fp.config.mode === "range")
117
+ fp.onMouseOver(getEventTarget(e), "flatpickr-monthSelect-month");
92
118
  });
93
- }
94
- function addMonths() {
95
- if (!fp.rContainer)
96
- return;
97
- self.monthsContainer = fp._createElement("div", "flatpickr-monthSelect-months");
98
- self.monthsContainer.tabIndex = -1;
99
- fp.calendarContainer.classList.add("flatpickr-monthSelect-theme-" + config.theme);
100
- for (var i = 0; i < 12; i++) {
101
- var month = fp._createElement("span", "flatpickr-monthSelect-month");
102
- month.dateObj = new Date(fp.currentYear, i);
103
- month.$i = i;
104
- month.textContent = monthToStr(i, config.shorthand, fp.l10n);
105
- month.tabIndex = -1;
106
- month.addEventListener("click", selectMonth);
107
- self.monthsContainer.appendChild(month);
108
- if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
109
- (fp.config.maxDate && month.dateObj > fp.config.maxDate)) {
110
- month.classList.add("disabled");
111
- }
112
- }
113
- fp.rContainer.appendChild(self.monthsContainer);
114
119
  }
115
120
  function setCurrentlySelected() {
116
121
  if (!fp.rContainer)
117
122
  return;
123
+ if (!fp.selectedDates.length)
124
+ return;
118
125
  var currentlySelected = fp.rContainer.querySelectorAll(".flatpickr-monthSelect-month.selected");
119
126
  for (var index = 0; index < currentlySelected.length; index++) {
120
127
  currentlySelected[index].classList.remove("selected");
121
128
  }
122
- var month = fp.rContainer.querySelector(".flatpickr-monthSelect-month:nth-child(" + (fp.currentMonth + 1) + ")");
129
+ var targetMonth = fp.selectedDates[0].getMonth();
130
+ var month = fp.rContainer.querySelector(".flatpickr-monthSelect-month:nth-child(" + (targetMonth + 1) + ")");
123
131
  if (month) {
124
132
  month.classList.add("selected");
125
133
  }
@@ -136,19 +144,18 @@
136
144
  selectedDate = fp.config.maxDate;
137
145
  }
138
146
  fp.currentYear = selectedDate.getFullYear();
139
- fp.currentYearElement.value = String(fp.currentYear);
140
- fp.currentMonth = selectedDate.getMonth();
141
147
  }
148
+ fp.currentYearElement.value = String(fp.currentYear);
142
149
  if (fp.rContainer) {
143
150
  var months = fp.rContainer.querySelectorAll(".flatpickr-monthSelect-month");
144
151
  months.forEach(function (month) {
145
152
  month.dateObj.setFullYear(fp.currentYear);
146
153
  if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
147
154
  (fp.config.maxDate && month.dateObj > fp.config.maxDate)) {
148
- month.classList.add("disabled");
155
+ month.classList.add("flatpickr-disabled");
149
156
  }
150
157
  else {
151
- month.classList.remove("disabled");
158
+ month.classList.remove("flatpickr-disabled");
152
159
  }
153
160
  });
154
161
  }
@@ -158,17 +165,37 @@
158
165
  e.preventDefault();
159
166
  e.stopPropagation();
160
167
  var eventTarget = getEventTarget(e);
161
- if (eventTarget instanceof Element &&
162
- !eventTarget.classList.contains("disabled")) {
163
- setMonth(eventTarget.dateObj);
164
- fp.close();
168
+ if (!(eventTarget instanceof Element))
169
+ return;
170
+ if (eventTarget.classList.contains("flatpickr-disabled"))
171
+ return;
172
+ if (eventTarget.classList.contains("notAllowed"))
173
+ return; // necessary??
174
+ setMonth(eventTarget.dateObj);
175
+ if (fp.config.closeOnSelect) {
176
+ var single = fp.config.mode === "single";
177
+ var range = fp.config.mode === "range" && fp.selectedDates.length === 2;
178
+ if (single || range)
179
+ fp.close();
165
180
  }
166
181
  }
167
182
  function setMonth(date) {
168
- var selectedDate = new Date(date);
169
- selectedDate.setFullYear(fp.currentYear);
170
- fp.currentMonth = selectedDate.getMonth();
171
- fp.setDate(selectedDate, true);
183
+ var selectedDate = new Date(fp.currentYear, date.getMonth(), date.getDate());
184
+ switch (fp.config.mode) {
185
+ case "single":
186
+ fp.selectedDates = [selectedDate];
187
+ break;
188
+ case "range":
189
+ if (fp.selectedDates.length === 2) {
190
+ fp.clear(false, false);
191
+ buildMonths();
192
+ }
193
+ fp.selectedDates.push(selectedDate);
194
+ fp.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
195
+ break;
196
+ }
197
+ fp.latestSelectedDateObj = selectedDate;
198
+ fp.updateValue();
172
199
  setCurrentlySelected();
173
200
  }
174
201
  var shifts = {
@@ -199,6 +226,27 @@
199
226
  setMonth(document.activeElement.dateObj);
200
227
  }
201
228
  }
229
+ function closeHook() {
230
+ var _a;
231
+ if (((_a = fp.config) === null || _a === void 0 ? void 0 : _a.mode) === "range" &&
232
+ fp.selectedDates.length === 1)
233
+ fp.clear(false);
234
+ if (!fp.selectedDates.length)
235
+ buildMonths();
236
+ }
237
+ // Help the prev/next year nav honor config.minDate (see 3fa5a69)
238
+ function stubCurrentMonth() {
239
+ config._stubbedCurrentMonth = fp._initialDate.getMonth();
240
+ fp._initialDate.setMonth(0);
241
+ fp.currentMonth = 0;
242
+ }
243
+ function unstubCurrentMonth() {
244
+ if (!config._stubbedCurrentMonth)
245
+ return;
246
+ fp._initialDate.setMonth(config._stubbedCurrentMonth);
247
+ fp.currentMonth = config._stubbedCurrentMonth;
248
+ delete config._stubbedCurrentMonth;
249
+ }
202
250
  function destroyPluginInstance() {
203
251
  if (self.monthsContainer !== null) {
204
252
  var months = self.monthsContainer.querySelectorAll(".flatpickr-monthSelect-month");
@@ -209,21 +257,28 @@
209
257
  }
210
258
  return {
211
259
  onParseConfig: function () {
212
- fp.config.mode = "single";
213
260
  fp.config.enableTime = false;
214
261
  },
215
262
  onValueUpdate: setCurrentlySelected,
216
263
  onKeyDown: onKeyDown,
217
264
  onReady: [
265
+ stubCurrentMonth,
218
266
  clearUnnecessaryDOMElements,
219
- addListeners,
220
- addMonths,
267
+ build,
268
+ bindEvents,
221
269
  setCurrentlySelected,
222
270
  function () {
271
+ fp.config.onClose.push(closeHook);
223
272
  fp.loadedPlugins.push("monthSelect");
224
273
  },
225
274
  ],
226
- onDestroy: destroyPluginInstance,
275
+ onDestroy: [
276
+ unstubCurrentMonth,
277
+ destroyPluginInstance,
278
+ function () {
279
+ fp.config.onClose = fp.config.onClose.filter(function (hook) { return hook !== closeHook; });
280
+ },
281
+ ],
227
282
  };
228
283
  };
229
284
  }
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
- (global = global || self, global.rangePlugin = factory());
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.rangePlugin = factory());
5
5
  }(this, (function () { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
@@ -56,21 +56,23 @@
56
56
  fp.selectedDates.push(parsedDate);
57
57
  }
58
58
  secondInput.setAttribute("data-fp-omit", "");
59
- fp._bind(secondInput, ["focus", "click"], function () {
60
- if (fp.selectedDates[1]) {
61
- fp.latestSelectedDateObj = fp.selectedDates[1];
62
- fp._setHoursFromDate(fp.selectedDates[1]);
63
- fp.jumpToDate(fp.selectedDates[1]);
64
- }
65
- _secondInputFocused = true;
66
- fp.isOpen = false;
67
- fp.open(undefined, config.position === "left" ? fp._input : secondInput);
68
- });
69
- fp._bind(fp._input, ["focus", "click"], function (e) {
70
- e.preventDefault();
71
- fp.isOpen = false;
72
- fp.open();
73
- });
59
+ if (fp.config.clickOpens) {
60
+ fp._bind(secondInput, ["focus", "click"], function () {
61
+ if (fp.selectedDates[1]) {
62
+ fp.latestSelectedDateObj = fp.selectedDates[1];
63
+ fp._setHoursFromDate(fp.selectedDates[1]);
64
+ fp.jumpToDate(fp.selectedDates[1]);
65
+ }
66
+ _secondInputFocused = true;
67
+ fp.isOpen = false;
68
+ fp.open(undefined, config.position === "left" ? fp._input : secondInput);
69
+ });
70
+ fp._bind(fp._input, ["focus", "click"], function (e) {
71
+ e.preventDefault();
72
+ fp.isOpen = false;
73
+ fp.open();
74
+ });
75
+ }
74
76
  if (fp.config.allowInput)
75
77
  fp._bind(secondInput, "keydown", function (e) {
76
78
  if (e.key === "Enter") {
@@ -154,6 +156,14 @@
154
156
  var newDates = _secondInputFocused
155
157
  ? [_prevDates[0], newSelectedDate]
156
158
  : [newSelectedDate, _prevDates[1]];
159
+ if (newDates[0].getTime() > newDates[1].getTime()) {
160
+ if (_secondInputFocused) {
161
+ newDates[0] = newDates[1];
162
+ }
163
+ else {
164
+ newDates[1] = newDates[0];
165
+ }
166
+ }
157
167
  fp.setDate(newDates, false);
158
168
  _prevDates = __spreadArrays(newDates);
159
169
  }
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
- (global = global || self, global.scrollPlugin = factory());
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.scrollPlugin = factory());
5
5
  }(this, (function () { 'use strict';
6
6
 
7
7
  function getEventTarget(event) {
@@ -18,7 +18,7 @@
18
18
  }
19
19
 
20
20
  if (typeof window.CustomEvent !== "function") {
21
- function CustomEvent(typeArg, eventInitDict) {
21
+ var CustomEvent = function (typeArg, eventInitDict) {
22
22
  eventInitDict = eventInitDict || {
23
23
  bubbles: false,
24
24
  cancelable: false,
@@ -27,7 +27,7 @@
27
27
  var evt = document.createEvent("CustomEvent");
28
28
  evt.initCustomEvent(typeArg, eventInitDict.bubbles, eventInitDict.cancelable, eventInitDict.detail);
29
29
  return evt;
30
- }
30
+ };
31
31
  CustomEvent.prototype = window.Event.prototype;
32
32
  window.CustomEvent = CustomEvent;
33
33
  }
@@ -57,24 +57,32 @@
57
57
  if (fp.timeContainer) {
58
58
  fp.timeContainer.addEventListener("wheel", scroll);
59
59
  }
60
- fp.yearElements.forEach(function (yearElem) {
61
- return yearElem.addEventListener("wheel", scroll);
62
- });
63
- fp.monthElements.forEach(function (monthElem) {
64
- return monthElem.addEventListener("wheel", monthScroller);
65
- });
60
+ if (fp.yearElements) {
61
+ fp.yearElements.forEach(function (yearElem) {
62
+ return yearElem.addEventListener("wheel", scroll);
63
+ });
64
+ }
65
+ if (fp.monthElements) {
66
+ fp.monthElements.forEach(function (monthElem) {
67
+ return monthElem.addEventListener("wheel", monthScroller);
68
+ });
69
+ }
66
70
  fp.loadedPlugins.push("scroll");
67
71
  },
68
72
  onDestroy: function () {
69
73
  if (fp.timeContainer) {
70
74
  fp.timeContainer.removeEventListener("wheel", scroll);
71
75
  }
72
- fp.yearElements.forEach(function (yearElem) {
73
- return yearElem.removeEventListener("wheel", scroll);
74
- });
75
- fp.monthElements.forEach(function (monthElem) {
76
- return monthElem.removeEventListener("wheel", monthScroller);
77
- });
76
+ if (fp.yearElements) {
77
+ fp.yearElements.forEach(function (yearElem) {
78
+ return yearElem.removeEventListener("wheel", scroll);
79
+ });
80
+ }
81
+ if (fp.monthElements) {
82
+ fp.monthElements.forEach(function (monthElem) {
83
+ return monthElem.removeEventListener("wheel", monthScroller);
84
+ });
85
+ }
78
86
  },
79
87
  };
80
88
  };
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
- (global = global || self, global.weekSelect = factory());
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.weekSelect = factory());
5
5
  }(this, (function () { 'use strict';
6
6
 
7
7
  function getEventTarget(event) {