flatpickr 4.5.2.0 → 4.6.6.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/LICENSE.txt +1 -1
- data/README.md +12 -14
- data/Rakefile +14 -15
- data/flatpickr.gemspec +3 -3
- data/lib/flatpickr/version.rb +1 -1
- data/vendor/assets/javascripts/flatpickr.js +1193 -750
- data/vendor/assets/javascripts/flatpickr/l10n/ar.js +45 -45
- data/vendor/assets/javascripts/flatpickr/l10n/at.js +62 -63
- data/vendor/assets/javascripts/flatpickr/l10n/az.js +74 -0
- data/vendor/assets/javascripts/flatpickr/l10n/be.js +68 -68
- data/vendor/assets/javascripts/flatpickr/l10n/bg.js +59 -58
- data/vendor/assets/javascripts/flatpickr/l10n/bn.js +57 -58
- data/vendor/assets/javascripts/flatpickr/l10n/bs.js +66 -0
- data/vendor/assets/javascripts/flatpickr/l10n/cat.js +76 -76
- data/vendor/assets/javascripts/flatpickr/l10n/cs.js +68 -68
- data/vendor/assets/javascripts/flatpickr/l10n/cy.js +86 -85
- data/vendor/assets/javascripts/flatpickr/l10n/da.js +64 -64
- data/vendor/assets/javascripts/flatpickr/l10n/de.js +63 -63
- data/vendor/assets/javascripts/flatpickr/l10n/default.js +77 -74
- data/vendor/assets/javascripts/flatpickr/l10n/eo.js +66 -66
- data/vendor/assets/javascripts/flatpickr/l10n/es.js +63 -63
- data/vendor/assets/javascripts/flatpickr/l10n/et.js +66 -66
- data/vendor/assets/javascripts/flatpickr/l10n/fa.js +61 -62
- data/vendor/assets/javascripts/flatpickr/l10n/fi.js +62 -62
- data/vendor/assets/javascripts/flatpickr/l10n/fo.js +74 -0
- data/vendor/assets/javascripts/flatpickr/l10n/fr.js +68 -68
- data/vendor/assets/javascripts/flatpickr/l10n/ga.js +66 -0
- data/vendor/assets/javascripts/flatpickr/l10n/gr.js +66 -67
- data/vendor/assets/javascripts/flatpickr/l10n/he.js +51 -50
- data/vendor/assets/javascripts/flatpickr/l10n/hi.js +57 -58
- data/vendor/assets/javascripts/flatpickr/l10n/hr.js +59 -59
- data/vendor/assets/javascripts/flatpickr/l10n/hu.js +66 -65
- data/vendor/assets/javascripts/flatpickr/l10n/id.js +55 -54
- data/vendor/assets/javascripts/flatpickr/l10n/index.js +807 -235
- data/vendor/assets/javascripts/flatpickr/l10n/is.js +72 -0
- data/vendor/assets/javascripts/flatpickr/l10n/it.js +64 -64
- data/vendor/assets/javascripts/flatpickr/l10n/ja.js +60 -58
- data/vendor/assets/javascripts/flatpickr/l10n/ka.js +75 -0
- data/vendor/assets/javascripts/flatpickr/l10n/km.js +67 -67
- data/vendor/assets/javascripts/flatpickr/l10n/ko.js +61 -61
- data/vendor/assets/javascripts/flatpickr/l10n/kz.js +67 -68
- data/vendor/assets/javascripts/flatpickr/l10n/lt.js +66 -65
- data/vendor/assets/javascripts/flatpickr/l10n/lv.js +60 -60
- data/vendor/assets/javascripts/flatpickr/l10n/mk.js +61 -61
- data/vendor/assets/javascripts/flatpickr/l10n/mn.js +52 -52
- data/vendor/assets/javascripts/flatpickr/l10n/ms.js +60 -61
- data/vendor/assets/javascripts/flatpickr/l10n/my.js +62 -62
- data/vendor/assets/javascripts/flatpickr/l10n/nl.js +68 -68
- data/vendor/assets/javascripts/flatpickr/l10n/no.js +66 -66
- data/vendor/assets/javascripts/flatpickr/l10n/pa.js +58 -58
- data/vendor/assets/javascripts/flatpickr/l10n/pl.js +66 -66
- data/vendor/assets/javascripts/flatpickr/l10n/pt.js +59 -59
- data/vendor/assets/javascripts/flatpickr/l10n/ro.js +62 -62
- data/vendor/assets/javascripts/flatpickr/l10n/ru.js +68 -68
- data/vendor/assets/javascripts/flatpickr/l10n/si.js +58 -58
- data/vendor/assets/javascripts/flatpickr/l10n/sk.js +63 -63
- data/vendor/assets/javascripts/flatpickr/l10n/sl.js +63 -63
- data/vendor/assets/javascripts/flatpickr/l10n/sq.js +58 -58
- data/vendor/assets/javascripts/flatpickr/l10n/sr-cyr.js +67 -0
- data/vendor/assets/javascripts/flatpickr/l10n/sr.js +61 -61
- data/vendor/assets/javascripts/flatpickr/l10n/sv.js +63 -63
- data/vendor/assets/javascripts/flatpickr/l10n/th.js +65 -65
- data/vendor/assets/javascripts/flatpickr/l10n/tr.js +67 -67
- data/vendor/assets/javascripts/flatpickr/l10n/uk.js +59 -59
- data/vendor/assets/javascripts/flatpickr/l10n/uz.js +75 -0
- data/vendor/assets/javascripts/flatpickr/l10n/uz_latn.js +75 -0
- data/vendor/assets/javascripts/flatpickr/l10n/vn.js +59 -59
- data/vendor/assets/javascripts/flatpickr/l10n/zh-tw.js +68 -0
- data/vendor/assets/javascripts/flatpickr/l10n/zh.js +61 -62
- data/vendor/assets/javascripts/flatpickr/plugins/confirmDate/confirmDate.js +65 -14
- data/vendor/assets/javascripts/flatpickr/plugins/labelPlugin/labelPlugin.js +25 -25
- data/vendor/assets/javascripts/flatpickr/plugins/minMaxTimePlugin.js +321 -270
- data/vendor/assets/javascripts/flatpickr/plugins/momentPlugin.js +69 -0
- data/vendor/assets/javascripts/flatpickr/plugins/monthSelect/index.js +233 -0
- data/vendor/assets/javascripts/flatpickr/plugins/rangePlugin.js +61 -30
- data/vendor/assets/javascripts/flatpickr/plugins/scrollPlugin.js +79 -44
- data/vendor/assets/javascripts/flatpickr/plugins/weekSelect/weekSelect.js +93 -74
- data/vendor/assets/stylesheets/flatpickr.css +67 -17
- data/vendor/assets/stylesheets/flatpickr/plugins/monthSelect/style.css +79 -0
- data/vendor/assets/stylesheets/flatpickr/themes/airbnb.css +77 -17
- data/vendor/assets/stylesheets/flatpickr/themes/confetti.css +69 -19
- data/vendor/assets/stylesheets/flatpickr/themes/dark.css +69 -19
- data/vendor/assets/stylesheets/flatpickr/themes/light.css +69 -19
- data/vendor/assets/stylesheets/flatpickr/themes/material_blue.css +69 -19
- data/vendor/assets/stylesheets/flatpickr/themes/material_green.css +69 -19
- data/vendor/assets/stylesheets/flatpickr/themes/material_orange.css +69 -19
- data/vendor/assets/stylesheets/flatpickr/themes/material_red.css +69 -19
- metadata +21 -11
- data/vendor/assets/javascripts/flatpickr/plugins/monthSelect/monthSelect.js +0 -77
- data/vendor/assets/stylesheets/flatpickr/plugins/monthSelect/monthSelect.css +0 -10
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = global || self, global.momentPlugin = factory());
|
|
5
|
+
}(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
function getEventTarget(event) {
|
|
8
|
+
try {
|
|
9
|
+
if (typeof event.composedPath === "function") {
|
|
10
|
+
var path = event.composedPath();
|
|
11
|
+
return path[0];
|
|
12
|
+
}
|
|
13
|
+
return event.target;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
return event.target;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function momentPlugin(config) {
|
|
21
|
+
var moment = config.moment;
|
|
22
|
+
return function (fp) {
|
|
23
|
+
function captureIncrement(e) {
|
|
24
|
+
var event = e;
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
var date = moment(fp.selectedDates[0]);
|
|
27
|
+
var input = getEventTarget(event);
|
|
28
|
+
var unit = Array.from(input.classList)
|
|
29
|
+
.filter(function (name) { return name.startsWith("flatpickr-"); })
|
|
30
|
+
.map(function (name) { return name.substring(10); })[0];
|
|
31
|
+
var step = parseFloat(input.getAttribute("step"));
|
|
32
|
+
date.add(step * event.delta, unit);
|
|
33
|
+
fp.setDate(date.toDate());
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
parseDate: function (datestr, format) {
|
|
37
|
+
return moment(datestr, format, true).toDate();
|
|
38
|
+
},
|
|
39
|
+
formatDate: function (date, format) {
|
|
40
|
+
// locale can also be used
|
|
41
|
+
var momentDate = moment(date);
|
|
42
|
+
if (typeof fp.config.locale === "string") {
|
|
43
|
+
momentDate.locale(fp.config.locale);
|
|
44
|
+
}
|
|
45
|
+
return momentDate.format(format);
|
|
46
|
+
},
|
|
47
|
+
onReady: function () {
|
|
48
|
+
[fp.hourElement, fp.minuteElement, fp.secondElement].forEach(function (element) {
|
|
49
|
+
return element &&
|
|
50
|
+
element.addEventListener("increment", captureIncrement, {
|
|
51
|
+
capture: true,
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
onDestroy: function () {
|
|
56
|
+
[fp.hourElement, fp.minuteElement, fp.secondElement].forEach(function (element) {
|
|
57
|
+
return element &&
|
|
58
|
+
element.removeEventListener("increment", captureIncrement, {
|
|
59
|
+
capture: true,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return momentPlugin;
|
|
68
|
+
|
|
69
|
+
})));
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = global || self, global.monthSelectPlugin = factory());
|
|
5
|
+
}(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
/*! *****************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
|
|
22
|
+
var __assign = function() {
|
|
23
|
+
__assign = Object.assign || function __assign(t) {
|
|
24
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25
|
+
s = arguments[i];
|
|
26
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
27
|
+
}
|
|
28
|
+
return t;
|
|
29
|
+
};
|
|
30
|
+
return __assign.apply(this, arguments);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
|
|
34
|
+
|
|
35
|
+
function getEventTarget(event) {
|
|
36
|
+
try {
|
|
37
|
+
if (typeof event.composedPath === "function") {
|
|
38
|
+
var path = event.composedPath();
|
|
39
|
+
return path[0];
|
|
40
|
+
}
|
|
41
|
+
return event.target;
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return event.target;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var defaultConfig = {
|
|
49
|
+
shorthand: false,
|
|
50
|
+
dateFormat: "F Y",
|
|
51
|
+
altFormat: "F Y",
|
|
52
|
+
theme: "light",
|
|
53
|
+
};
|
|
54
|
+
function monthSelectPlugin(pluginConfig) {
|
|
55
|
+
var config = __assign(__assign({}, defaultConfig), pluginConfig);
|
|
56
|
+
return function (fp) {
|
|
57
|
+
fp.config.dateFormat = config.dateFormat;
|
|
58
|
+
fp.config.altFormat = config.altFormat;
|
|
59
|
+
var self = { monthsContainer: null };
|
|
60
|
+
function clearUnnecessaryDOMElements() {
|
|
61
|
+
if (!fp.rContainer || !fp.daysContainer || !fp.weekdayContainer)
|
|
62
|
+
return;
|
|
63
|
+
fp.rContainer.removeChild(fp.daysContainer);
|
|
64
|
+
fp.rContainer.removeChild(fp.weekdayContainer);
|
|
65
|
+
for (var index = 0; index < fp.monthElements.length; index++) {
|
|
66
|
+
var element = fp.monthElements[index];
|
|
67
|
+
if (!element.parentNode)
|
|
68
|
+
continue;
|
|
69
|
+
element.parentNode.removeChild(element);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function addListeners() {
|
|
73
|
+
fp._bind(fp.prevMonthNav, "click", function (e) {
|
|
74
|
+
var _a;
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
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
|
+
}
|
|
81
|
+
selectYear();
|
|
82
|
+
});
|
|
83
|
+
fp._bind(fp.nextMonthNav, "click", function (e) {
|
|
84
|
+
var _a;
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
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
|
+
}
|
|
91
|
+
selectYear();
|
|
92
|
+
});
|
|
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
|
+
}
|
|
115
|
+
function setCurrentlySelected() {
|
|
116
|
+
if (!fp.rContainer)
|
|
117
|
+
return;
|
|
118
|
+
var currentlySelected = fp.rContainer.querySelectorAll(".flatpickr-monthSelect-month.selected");
|
|
119
|
+
for (var index = 0; index < currentlySelected.length; index++) {
|
|
120
|
+
currentlySelected[index].classList.remove("selected");
|
|
121
|
+
}
|
|
122
|
+
var month = fp.rContainer.querySelector(".flatpickr-monthSelect-month:nth-child(" + (fp.currentMonth + 1) + ")");
|
|
123
|
+
if (month) {
|
|
124
|
+
month.classList.add("selected");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function selectYear() {
|
|
128
|
+
var selectedDate = fp.selectedDates[0];
|
|
129
|
+
if (selectedDate) {
|
|
130
|
+
selectedDate = new Date(selectedDate);
|
|
131
|
+
selectedDate.setFullYear(fp.currentYear);
|
|
132
|
+
if (fp.config.minDate && selectedDate < fp.config.minDate) {
|
|
133
|
+
selectedDate = fp.config.minDate;
|
|
134
|
+
}
|
|
135
|
+
if (fp.config.maxDate && selectedDate > fp.config.maxDate) {
|
|
136
|
+
selectedDate = fp.config.maxDate;
|
|
137
|
+
}
|
|
138
|
+
fp.currentYear = selectedDate.getFullYear();
|
|
139
|
+
fp.currentYearElement.value = String(fp.currentYear);
|
|
140
|
+
fp.currentMonth = selectedDate.getMonth();
|
|
141
|
+
}
|
|
142
|
+
if (fp.rContainer) {
|
|
143
|
+
var months = fp.rContainer.querySelectorAll(".flatpickr-monthSelect-month");
|
|
144
|
+
months.forEach(function (month) {
|
|
145
|
+
month.dateObj.setFullYear(fp.currentYear);
|
|
146
|
+
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
|
147
|
+
(fp.config.maxDate && month.dateObj > fp.config.maxDate)) {
|
|
148
|
+
month.classList.add("disabled");
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
month.classList.remove("disabled");
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
setCurrentlySelected();
|
|
156
|
+
}
|
|
157
|
+
function selectMonth(e) {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
e.stopPropagation();
|
|
160
|
+
var eventTarget = getEventTarget(e);
|
|
161
|
+
if (eventTarget instanceof Element &&
|
|
162
|
+
!eventTarget.classList.contains("disabled")) {
|
|
163
|
+
setMonth(eventTarget.dateObj);
|
|
164
|
+
fp.close();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function setMonth(date) {
|
|
168
|
+
var selectedDate = new Date(date);
|
|
169
|
+
selectedDate.setFullYear(fp.currentYear);
|
|
170
|
+
fp.currentMonth = selectedDate.getMonth();
|
|
171
|
+
fp.setDate(selectedDate, true);
|
|
172
|
+
setCurrentlySelected();
|
|
173
|
+
}
|
|
174
|
+
var shifts = {
|
|
175
|
+
37: -1,
|
|
176
|
+
39: 1,
|
|
177
|
+
40: 3,
|
|
178
|
+
38: -3,
|
|
179
|
+
};
|
|
180
|
+
function onKeyDown(_, __, ___, e) {
|
|
181
|
+
var shouldMove = shifts[e.keyCode] !== undefined;
|
|
182
|
+
if (!shouldMove && e.keyCode !== 13) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (!fp.rContainer || !self.monthsContainer)
|
|
186
|
+
return;
|
|
187
|
+
var currentlySelected = fp.rContainer.querySelector(".flatpickr-monthSelect-month.selected");
|
|
188
|
+
var index = Array.prototype.indexOf.call(self.monthsContainer.children, document.activeElement);
|
|
189
|
+
if (index === -1) {
|
|
190
|
+
var target = currentlySelected || self.monthsContainer.firstElementChild;
|
|
191
|
+
target.focus();
|
|
192
|
+
index = target.$i;
|
|
193
|
+
}
|
|
194
|
+
if (shouldMove) {
|
|
195
|
+
self.monthsContainer.children[(12 + index + shifts[e.keyCode]) % 12].focus();
|
|
196
|
+
}
|
|
197
|
+
else if (e.keyCode === 13 &&
|
|
198
|
+
self.monthsContainer.contains(document.activeElement)) {
|
|
199
|
+
setMonth(document.activeElement.dateObj);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function destroyPluginInstance() {
|
|
203
|
+
if (self.monthsContainer !== null) {
|
|
204
|
+
var months = self.monthsContainer.querySelectorAll(".flatpickr-monthSelect-month");
|
|
205
|
+
for (var index = 0; index < months.length; index++) {
|
|
206
|
+
months[index].removeEventListener("click", selectMonth);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
onParseConfig: function () {
|
|
212
|
+
fp.config.mode = "single";
|
|
213
|
+
fp.config.enableTime = false;
|
|
214
|
+
},
|
|
215
|
+
onValueUpdate: setCurrentlySelected,
|
|
216
|
+
onKeyDown: onKeyDown,
|
|
217
|
+
onReady: [
|
|
218
|
+
clearUnnecessaryDOMElements,
|
|
219
|
+
addListeners,
|
|
220
|
+
addMonths,
|
|
221
|
+
setCurrentlySelected,
|
|
222
|
+
function () {
|
|
223
|
+
fp.loadedPlugins.push("monthSelect");
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
onDestroy: destroyPluginInstance,
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return monthSelectPlugin;
|
|
232
|
+
|
|
233
|
+
})));
|
|
@@ -1,19 +1,49 @@
|
|
|
1
|
-
/* flatpickr v4.5.2, @license MIT */
|
|
2
1
|
(function (global, factory) {
|
|
3
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
3
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
5
|
-
(global.rangePlugin = factory());
|
|
4
|
+
(global = global || self, global.rangePlugin = factory());
|
|
6
5
|
}(this, (function () { 'use strict';
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
/*! *****************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
|
|
22
|
+
function __spreadArrays() {
|
|
23
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
24
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
25
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
26
|
+
r[k] = a[j];
|
|
27
|
+
return r;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function rangePlugin(config) {
|
|
31
|
+
if (config === void 0) { config = {}; }
|
|
9
32
|
return function (fp) {
|
|
10
|
-
|
|
11
|
-
|
|
33
|
+
var dateFormat = "", secondInput, _secondInputFocused, _prevDates;
|
|
34
|
+
var createSecondInput = function () {
|
|
12
35
|
if (config.input) {
|
|
13
36
|
secondInput =
|
|
14
37
|
config.input instanceof Element
|
|
15
38
|
? config.input
|
|
16
39
|
: window.document.querySelector(config.input);
|
|
40
|
+
if (!secondInput) {
|
|
41
|
+
fp.config.errorHandler(new Error("Invalid input element specified"));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (fp.config.wrap) {
|
|
45
|
+
secondInput = secondInput.querySelector("[data-input]");
|
|
46
|
+
}
|
|
17
47
|
}
|
|
18
48
|
else {
|
|
19
49
|
secondInput = fp._input.cloneNode();
|
|
@@ -21,28 +51,28 @@
|
|
|
21
51
|
secondInput._flatpickr = undefined;
|
|
22
52
|
}
|
|
23
53
|
if (secondInput.value) {
|
|
24
|
-
|
|
54
|
+
var parsedDate = fp.parseDate(secondInput.value);
|
|
25
55
|
if (parsedDate)
|
|
26
56
|
fp.selectedDates.push(parsedDate);
|
|
27
57
|
}
|
|
28
58
|
secondInput.setAttribute("data-fp-omit", "");
|
|
29
|
-
fp._bind(secondInput, ["focus", "click"], ()
|
|
59
|
+
fp._bind(secondInput, ["focus", "click"], function () {
|
|
30
60
|
if (fp.selectedDates[1]) {
|
|
31
61
|
fp.latestSelectedDateObj = fp.selectedDates[1];
|
|
32
62
|
fp._setHoursFromDate(fp.selectedDates[1]);
|
|
33
63
|
fp.jumpToDate(fp.selectedDates[1]);
|
|
34
64
|
}
|
|
35
|
-
|
|
65
|
+
_secondInputFocused = true;
|
|
36
66
|
fp.isOpen = false;
|
|
37
|
-
fp.open(undefined, secondInput);
|
|
67
|
+
fp.open(undefined, config.position === "left" ? fp._input : secondInput);
|
|
38
68
|
});
|
|
39
|
-
fp._bind(fp._input, ["focus", "click"], (e)
|
|
69
|
+
fp._bind(fp._input, ["focus", "click"], function (e) {
|
|
40
70
|
e.preventDefault();
|
|
41
71
|
fp.isOpen = false;
|
|
42
72
|
fp.open();
|
|
43
73
|
});
|
|
44
74
|
if (fp.config.allowInput)
|
|
45
|
-
fp._bind(secondInput, "keydown", (e)
|
|
75
|
+
fp._bind(secondInput, "keydown", function (e) {
|
|
46
76
|
if (e.key === "Enter") {
|
|
47
77
|
fp.setDate([fp.selectedDates[0], secondInput.value], true, dateFormat);
|
|
48
78
|
secondInput.click();
|
|
@@ -52,14 +82,14 @@
|
|
|
52
82
|
fp._input.parentNode &&
|
|
53
83
|
fp._input.parentNode.insertBefore(secondInput, fp._input.nextSibling);
|
|
54
84
|
};
|
|
55
|
-
|
|
56
|
-
onParseConfig() {
|
|
85
|
+
var plugin = {
|
|
86
|
+
onParseConfig: function () {
|
|
57
87
|
fp.config.mode = "range";
|
|
58
88
|
dateFormat = fp.config.altInput
|
|
59
89
|
? fp.config.altFormat
|
|
60
90
|
: fp.config.dateFormat;
|
|
61
91
|
},
|
|
62
|
-
onReady() {
|
|
92
|
+
onReady: function () {
|
|
63
93
|
createSecondInput();
|
|
64
94
|
fp.config.ignoredFocusElements.push(secondInput);
|
|
65
95
|
if (fp.config.allowInput) {
|
|
@@ -69,31 +99,32 @@
|
|
|
69
99
|
else {
|
|
70
100
|
secondInput.setAttribute("readonly", "readonly");
|
|
71
101
|
}
|
|
72
|
-
fp._bind(fp._input, "focus", ()
|
|
102
|
+
fp._bind(fp._input, "focus", function () {
|
|
73
103
|
fp.latestSelectedDateObj = fp.selectedDates[0];
|
|
74
104
|
fp._setHoursFromDate(fp.selectedDates[0]);
|
|
75
|
-
|
|
105
|
+
_secondInputFocused = false;
|
|
76
106
|
fp.jumpToDate(fp.selectedDates[0]);
|
|
77
107
|
});
|
|
78
108
|
if (fp.config.allowInput)
|
|
79
|
-
fp._bind(fp._input, "keydown", (e)
|
|
109
|
+
fp._bind(fp._input, "keydown", function (e) {
|
|
80
110
|
if (e.key === "Enter")
|
|
81
111
|
fp.setDate([fp._input.value, fp.selectedDates[1]], true, dateFormat);
|
|
82
112
|
});
|
|
83
113
|
fp.setDate(fp.selectedDates, false);
|
|
84
114
|
plugin.onValueUpdate(fp.selectedDates);
|
|
115
|
+
fp.loadedPlugins.push("range");
|
|
85
116
|
},
|
|
86
|
-
onPreCalendarPosition() {
|
|
117
|
+
onPreCalendarPosition: function () {
|
|
87
118
|
if (_secondInputFocused) {
|
|
88
119
|
fp._positionElement = secondInput;
|
|
89
|
-
setTimeout(()
|
|
120
|
+
setTimeout(function () {
|
|
90
121
|
fp._positionElement = fp._input;
|
|
91
122
|
}, 0);
|
|
92
123
|
}
|
|
93
124
|
},
|
|
94
|
-
onChange() {
|
|
125
|
+
onChange: function () {
|
|
95
126
|
if (!fp.selectedDates.length) {
|
|
96
|
-
setTimeout(()
|
|
127
|
+
setTimeout(function () {
|
|
97
128
|
if (fp.selectedDates.length)
|
|
98
129
|
return;
|
|
99
130
|
secondInput.value = "";
|
|
@@ -101,32 +132,32 @@
|
|
|
101
132
|
}, 10);
|
|
102
133
|
}
|
|
103
134
|
if (_secondInputFocused) {
|
|
104
|
-
setTimeout(()
|
|
135
|
+
setTimeout(function () {
|
|
105
136
|
secondInput.focus();
|
|
106
137
|
}, 0);
|
|
107
138
|
}
|
|
108
139
|
},
|
|
109
|
-
onDestroy() {
|
|
140
|
+
onDestroy: function () {
|
|
110
141
|
if (!config.input)
|
|
111
142
|
secondInput.parentNode &&
|
|
112
143
|
secondInput.parentNode.removeChild(secondInput);
|
|
113
144
|
},
|
|
114
|
-
onValueUpdate(selDates) {
|
|
145
|
+
onValueUpdate: function (selDates) {
|
|
146
|
+
var _a, _b, _c;
|
|
115
147
|
if (!secondInput)
|
|
116
148
|
return;
|
|
117
149
|
_prevDates =
|
|
118
150
|
!_prevDates || selDates.length >= _prevDates.length
|
|
119
|
-
?
|
|
120
|
-
: _prevDates;
|
|
151
|
+
? __spreadArrays(selDates) : _prevDates;
|
|
121
152
|
if (_prevDates.length > selDates.length) {
|
|
122
|
-
|
|
123
|
-
|
|
153
|
+
var newSelectedDate = selDates[0];
|
|
154
|
+
var newDates = _secondInputFocused
|
|
124
155
|
? [_prevDates[0], newSelectedDate]
|
|
125
156
|
: [newSelectedDate, _prevDates[1]];
|
|
126
157
|
fp.setDate(newDates, false);
|
|
127
|
-
_prevDates =
|
|
158
|
+
_prevDates = __spreadArrays(newDates);
|
|
128
159
|
}
|
|
129
|
-
[fp._input.value = "", secondInput.value =
|
|
160
|
+
_a = fp.selectedDates.map(function (d) { return fp.formatDate(d, dateFormat); }), _b = _a[0], fp._input.value = _b === void 0 ? "" : _b, _c = _a[1], secondInput.value = _c === void 0 ? "" : _c;
|
|
130
161
|
},
|
|
131
162
|
};
|
|
132
163
|
return plugin;
|