flatpickr 4.6.3.1 → 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 +0 -1
- data/lib/flatpickr/version.rb +1 -1
- data/vendor/assets/javascripts/flatpickr.js +224 -171
- data/vendor/assets/javascripts/flatpickr/l10n/ar.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/at.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/az.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/be.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/bg.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/bn.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/bs.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/cat.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/cs.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/cy.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/da.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/de.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/default.js +6 -5
- data/vendor/assets/javascripts/flatpickr/l10n/eo.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/es.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/et.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/fa.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/fi.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/fo.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/fr.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/ga.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/gr.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/he.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/hi.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/hr.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/hu.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/id.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/index.js +387 -256
- data/vendor/assets/javascripts/flatpickr/l10n/is.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/it.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/ja.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/ka.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/km.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/ko.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/kz.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/lt.js +7 -6
- data/vendor/assets/javascripts/flatpickr/l10n/lv.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/mk.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/mn.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/ms.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/my.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/nl.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/no.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/pa.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/pl.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/pt.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/ro.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/ru.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/si.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/sk.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/sl.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/sq.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/sr-cyr.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/sr.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/sv.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/th.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/tr.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/uk.js +6 -6
- 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 +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/zh-tw.js +6 -6
- data/vendor/assets/javascripts/flatpickr/l10n/zh.js +6 -6
- data/vendor/assets/javascripts/flatpickr/plugins/confirmDate/confirmDate.js +33 -17
- data/vendor/assets/javascripts/flatpickr/plugins/labelPlugin/labelPlugin.js +3 -3
- data/vendor/assets/javascripts/flatpickr/plugins/minMaxTimePlugin.js +23 -17
- data/vendor/assets/javascripts/flatpickr/plugins/momentPlugin.js +69 -0
- data/vendor/assets/javascripts/flatpickr/plugins/monthSelect/index.js +55 -25
- data/vendor/assets/javascripts/flatpickr/plugins/rangePlugin.js +165 -142
- data/vendor/assets/javascripts/flatpickr/plugins/scrollPlugin.js +32 -5
- data/vendor/assets/javascripts/flatpickr/plugins/weekSelect/weekSelect.js +17 -4
- data/vendor/assets/stylesheets/flatpickr.css +9 -2
- data/vendor/assets/stylesheets/flatpickr/ie.css +0 -0
- data/vendor/assets/stylesheets/flatpickr/plugins/confirmDate/confirmDate.css +0 -0
- data/vendor/assets/stylesheets/flatpickr/plugins/monthSelect/style.css +0 -0
- data/vendor/assets/stylesheets/flatpickr/themes/airbnb.css +9 -2
- data/vendor/assets/stylesheets/flatpickr/themes/confetti.css +11 -4
- data/vendor/assets/stylesheets/flatpickr/themes/dark.css +9 -2
- data/vendor/assets/stylesheets/flatpickr/themes/light.css +11 -4
- data/vendor/assets/stylesheets/flatpickr/themes/material_blue.css +11 -4
- data/vendor/assets/stylesheets/flatpickr/themes/material_green.css +11 -4
- data/vendor/assets/stylesheets/flatpickr/themes/material_orange.css +11 -4
- data/vendor/assets/stylesheets/flatpickr/themes/material_red.css +11 -4
- metadata +5 -2
|
@@ -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
|
+
})));
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
4
|
(global = global || self, global.monthSelectPlugin = factory());
|
|
5
|
-
}(this, function () { 'use strict';
|
|
5
|
+
}(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*! *****************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
10
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
11
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
16
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
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
20
|
***************************************************************************** */
|
|
21
21
|
|
|
22
22
|
var __assign = function() {
|
|
@@ -32,14 +32,27 @@
|
|
|
32
32
|
|
|
33
33
|
var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
|
|
34
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
|
+
|
|
35
48
|
var defaultConfig = {
|
|
36
49
|
shorthand: false,
|
|
37
50
|
dateFormat: "F Y",
|
|
38
51
|
altFormat: "F Y",
|
|
39
|
-
theme: "light"
|
|
52
|
+
theme: "light",
|
|
40
53
|
};
|
|
41
54
|
function monthSelectPlugin(pluginConfig) {
|
|
42
|
-
var config = __assign({}, defaultConfig, pluginConfig);
|
|
55
|
+
var config = __assign(__assign({}, defaultConfig), pluginConfig);
|
|
43
56
|
return function (fp) {
|
|
44
57
|
fp.config.dateFormat = config.dateFormat;
|
|
45
58
|
fp.config.altFormat = config.altFormat;
|
|
@@ -57,12 +70,24 @@
|
|
|
57
70
|
}
|
|
58
71
|
}
|
|
59
72
|
function addListeners() {
|
|
60
|
-
fp._bind(fp.prevMonthNav, "click", function () {
|
|
61
|
-
|
|
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
|
+
}
|
|
62
81
|
selectYear();
|
|
63
82
|
});
|
|
64
|
-
fp._bind(fp.nextMonthNav, "
|
|
65
|
-
|
|
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
|
+
}
|
|
66
91
|
selectYear();
|
|
67
92
|
});
|
|
68
93
|
}
|
|
@@ -80,7 +105,8 @@
|
|
|
80
105
|
month.tabIndex = -1;
|
|
81
106
|
month.addEventListener("click", selectMonth);
|
|
82
107
|
self.monthsContainer.appendChild(month);
|
|
83
|
-
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
|
108
|
+
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
|
109
|
+
(fp.config.maxDate && month.dateObj > fp.config.maxDate)) {
|
|
84
110
|
month.classList.add("disabled");
|
|
85
111
|
}
|
|
86
112
|
}
|
|
@@ -111,13 +137,14 @@
|
|
|
111
137
|
}
|
|
112
138
|
fp.currentYear = selectedDate.getFullYear();
|
|
113
139
|
fp.currentYearElement.value = String(fp.currentYear);
|
|
114
|
-
|
|
140
|
+
fp.currentMonth = selectedDate.getMonth();
|
|
115
141
|
}
|
|
116
142
|
if (fp.rContainer) {
|
|
117
143
|
var months = fp.rContainer.querySelectorAll(".flatpickr-monthSelect-month");
|
|
118
144
|
months.forEach(function (month) {
|
|
119
145
|
month.dateObj.setFullYear(fp.currentYear);
|
|
120
|
-
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
|
146
|
+
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
|
147
|
+
(fp.config.maxDate && month.dateObj > fp.config.maxDate)) {
|
|
121
148
|
month.classList.add("disabled");
|
|
122
149
|
}
|
|
123
150
|
else {
|
|
@@ -125,12 +152,15 @@
|
|
|
125
152
|
}
|
|
126
153
|
});
|
|
127
154
|
}
|
|
155
|
+
setCurrentlySelected();
|
|
128
156
|
}
|
|
129
157
|
function selectMonth(e) {
|
|
130
158
|
e.preventDefault();
|
|
131
159
|
e.stopPropagation();
|
|
132
|
-
|
|
133
|
-
|
|
160
|
+
var eventTarget = getEventTarget(e);
|
|
161
|
+
if (eventTarget instanceof Element &&
|
|
162
|
+
!eventTarget.classList.contains("disabled")) {
|
|
163
|
+
setMonth(eventTarget.dateObj);
|
|
134
164
|
fp.close();
|
|
135
165
|
}
|
|
136
166
|
}
|
|
@@ -145,7 +175,7 @@
|
|
|
145
175
|
37: -1,
|
|
146
176
|
39: 1,
|
|
147
177
|
40: 3,
|
|
148
|
-
38: -3
|
|
178
|
+
38: -3,
|
|
149
179
|
};
|
|
150
180
|
function onKeyDown(_, __, ___, e) {
|
|
151
181
|
var shouldMove = shifts[e.keyCode] !== undefined;
|
|
@@ -193,11 +223,11 @@
|
|
|
193
223
|
fp.loadedPlugins.push("monthSelect");
|
|
194
224
|
},
|
|
195
225
|
],
|
|
196
|
-
onDestroy: destroyPluginInstance
|
|
226
|
+
onDestroy: destroyPluginInstance,
|
|
197
227
|
};
|
|
198
228
|
};
|
|
199
229
|
}
|
|
200
230
|
|
|
201
231
|
return monthSelectPlugin;
|
|
202
232
|
|
|
203
|
-
}));
|
|
233
|
+
})));
|
|
@@ -1,146 +1,169 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}(this, function () { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = global || self, global.rangePlugin = factory());
|
|
5
|
+
}(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
if (secondInput.value) {
|
|
31
|
-
var parsedDate = fp.parseDate(secondInput.value);
|
|
32
|
-
if (parsedDate)
|
|
33
|
-
fp.selectedDates.push(parsedDate);
|
|
34
|
-
}
|
|
35
|
-
secondInput.setAttribute("data-fp-omit", "");
|
|
36
|
-
fp._bind(secondInput, ["focus", "click"], function () {
|
|
37
|
-
if (fp.selectedDates[1]) {
|
|
38
|
-
fp.latestSelectedDateObj = fp.selectedDates[1];
|
|
39
|
-
fp._setHoursFromDate(fp.selectedDates[1]);
|
|
40
|
-
fp.jumpToDate(fp.selectedDates[1]);
|
|
41
|
-
}
|
|
42
|
-
_secondInputFocused = true;
|
|
43
|
-
fp.isOpen = false;
|
|
44
|
-
fp.open(undefined, config.position === "left" ? fp._input : secondInput);
|
|
45
|
-
});
|
|
46
|
-
fp._bind(fp._input, ["focus", "click"], function (e) {
|
|
47
|
-
e.preventDefault();
|
|
48
|
-
fp.isOpen = false;
|
|
49
|
-
fp.open();
|
|
50
|
-
});
|
|
51
|
-
if (fp.config.allowInput)
|
|
52
|
-
fp._bind(secondInput, "keydown", function (e) {
|
|
53
|
-
if (e.key === "Enter") {
|
|
54
|
-
fp.setDate([fp.selectedDates[0], secondInput.value], true, dateFormat);
|
|
55
|
-
secondInput.click();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
if (!config.input)
|
|
59
|
-
fp._input.parentNode &&
|
|
60
|
-
fp._input.parentNode.insertBefore(secondInput, fp._input.nextSibling);
|
|
61
|
-
};
|
|
62
|
-
var plugin = {
|
|
63
|
-
onParseConfig: function () {
|
|
64
|
-
fp.config.mode = "range";
|
|
65
|
-
dateFormat = fp.config.altInput
|
|
66
|
-
? fp.config.altFormat
|
|
67
|
-
: fp.config.dateFormat;
|
|
68
|
-
},
|
|
69
|
-
onReady: function () {
|
|
70
|
-
createSecondInput();
|
|
71
|
-
fp.config.ignoredFocusElements.push(secondInput);
|
|
72
|
-
if (fp.config.allowInput) {
|
|
73
|
-
fp._input.removeAttribute("readonly");
|
|
74
|
-
secondInput.removeAttribute("readonly");
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
secondInput.setAttribute("readonly", "readonly");
|
|
78
|
-
}
|
|
79
|
-
fp._bind(fp._input, "focus", function () {
|
|
80
|
-
fp.latestSelectedDateObj = fp.selectedDates[0];
|
|
81
|
-
fp._setHoursFromDate(fp.selectedDates[0]);
|
|
82
|
-
_secondInputFocused = false;
|
|
83
|
-
fp.jumpToDate(fp.selectedDates[0]);
|
|
84
|
-
});
|
|
85
|
-
if (fp.config.allowInput)
|
|
86
|
-
fp._bind(fp._input, "keydown", function (e) {
|
|
87
|
-
if (e.key === "Enter")
|
|
88
|
-
fp.setDate([fp._input.value, fp.selectedDates[1]], true, dateFormat);
|
|
89
|
-
});
|
|
90
|
-
fp.setDate(fp.selectedDates, false);
|
|
91
|
-
plugin.onValueUpdate(fp.selectedDates);
|
|
92
|
-
fp.loadedPlugins.push("range");
|
|
93
|
-
},
|
|
94
|
-
onPreCalendarPosition: function () {
|
|
95
|
-
if (_secondInputFocused) {
|
|
96
|
-
fp._positionElement = secondInput;
|
|
97
|
-
setTimeout(function () {
|
|
98
|
-
fp._positionElement = fp._input;
|
|
99
|
-
}, 0);
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
onChange: function () {
|
|
103
|
-
if (!fp.selectedDates.length) {
|
|
104
|
-
setTimeout(function () {
|
|
105
|
-
if (fp.selectedDates.length)
|
|
106
|
-
return;
|
|
107
|
-
secondInput.value = "";
|
|
108
|
-
_prevDates = [];
|
|
109
|
-
}, 10);
|
|
110
|
-
}
|
|
111
|
-
if (_secondInputFocused) {
|
|
112
|
-
setTimeout(function () {
|
|
113
|
-
secondInput.focus();
|
|
114
|
-
}, 0);
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
onDestroy: function () {
|
|
118
|
-
if (!config.input)
|
|
119
|
-
secondInput.parentNode &&
|
|
120
|
-
secondInput.parentNode.removeChild(secondInput);
|
|
121
|
-
},
|
|
122
|
-
onValueUpdate: function (selDates) {
|
|
123
|
-
var _a, _b, _c;
|
|
124
|
-
if (!secondInput)
|
|
125
|
-
return;
|
|
126
|
-
_prevDates =
|
|
127
|
-
!_prevDates || selDates.length >= _prevDates.length
|
|
128
|
-
? selDates.slice() : _prevDates;
|
|
129
|
-
if (_prevDates.length > selDates.length) {
|
|
130
|
-
var newSelectedDate = selDates[0];
|
|
131
|
-
var newDates = _secondInputFocused
|
|
132
|
-
? [_prevDates[0], newSelectedDate]
|
|
133
|
-
: [newSelectedDate, _prevDates[1]];
|
|
134
|
-
fp.setDate(newDates, false);
|
|
135
|
-
_prevDates = newDates.slice();
|
|
136
|
-
}
|
|
137
|
-
_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;
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
return plugin;
|
|
141
|
-
};
|
|
142
|
-
}
|
|
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
|
+
}
|
|
143
29
|
|
|
144
|
-
|
|
30
|
+
function rangePlugin(config) {
|
|
31
|
+
if (config === void 0) { config = {}; }
|
|
32
|
+
return function (fp) {
|
|
33
|
+
var dateFormat = "", secondInput, _secondInputFocused, _prevDates;
|
|
34
|
+
var createSecondInput = function () {
|
|
35
|
+
if (config.input) {
|
|
36
|
+
secondInput =
|
|
37
|
+
config.input instanceof Element
|
|
38
|
+
? config.input
|
|
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
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
secondInput = fp._input.cloneNode();
|
|
50
|
+
secondInput.removeAttribute("id");
|
|
51
|
+
secondInput._flatpickr = undefined;
|
|
52
|
+
}
|
|
53
|
+
if (secondInput.value) {
|
|
54
|
+
var parsedDate = fp.parseDate(secondInput.value);
|
|
55
|
+
if (parsedDate)
|
|
56
|
+
fp.selectedDates.push(parsedDate);
|
|
57
|
+
}
|
|
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
|
+
});
|
|
74
|
+
if (fp.config.allowInput)
|
|
75
|
+
fp._bind(secondInput, "keydown", function (e) {
|
|
76
|
+
if (e.key === "Enter") {
|
|
77
|
+
fp.setDate([fp.selectedDates[0], secondInput.value], true, dateFormat);
|
|
78
|
+
secondInput.click();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
if (!config.input)
|
|
82
|
+
fp._input.parentNode &&
|
|
83
|
+
fp._input.parentNode.insertBefore(secondInput, fp._input.nextSibling);
|
|
84
|
+
};
|
|
85
|
+
var plugin = {
|
|
86
|
+
onParseConfig: function () {
|
|
87
|
+
fp.config.mode = "range";
|
|
88
|
+
dateFormat = fp.config.altInput
|
|
89
|
+
? fp.config.altFormat
|
|
90
|
+
: fp.config.dateFormat;
|
|
91
|
+
},
|
|
92
|
+
onReady: function () {
|
|
93
|
+
createSecondInput();
|
|
94
|
+
fp.config.ignoredFocusElements.push(secondInput);
|
|
95
|
+
if (fp.config.allowInput) {
|
|
96
|
+
fp._input.removeAttribute("readonly");
|
|
97
|
+
secondInput.removeAttribute("readonly");
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
secondInput.setAttribute("readonly", "readonly");
|
|
101
|
+
}
|
|
102
|
+
fp._bind(fp._input, "focus", function () {
|
|
103
|
+
fp.latestSelectedDateObj = fp.selectedDates[0];
|
|
104
|
+
fp._setHoursFromDate(fp.selectedDates[0]);
|
|
105
|
+
_secondInputFocused = false;
|
|
106
|
+
fp.jumpToDate(fp.selectedDates[0]);
|
|
107
|
+
});
|
|
108
|
+
if (fp.config.allowInput)
|
|
109
|
+
fp._bind(fp._input, "keydown", function (e) {
|
|
110
|
+
if (e.key === "Enter")
|
|
111
|
+
fp.setDate([fp._input.value, fp.selectedDates[1]], true, dateFormat);
|
|
112
|
+
});
|
|
113
|
+
fp.setDate(fp.selectedDates, false);
|
|
114
|
+
plugin.onValueUpdate(fp.selectedDates);
|
|
115
|
+
fp.loadedPlugins.push("range");
|
|
116
|
+
},
|
|
117
|
+
onPreCalendarPosition: function () {
|
|
118
|
+
if (_secondInputFocused) {
|
|
119
|
+
fp._positionElement = secondInput;
|
|
120
|
+
setTimeout(function () {
|
|
121
|
+
fp._positionElement = fp._input;
|
|
122
|
+
}, 0);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
onChange: function () {
|
|
126
|
+
if (!fp.selectedDates.length) {
|
|
127
|
+
setTimeout(function () {
|
|
128
|
+
if (fp.selectedDates.length)
|
|
129
|
+
return;
|
|
130
|
+
secondInput.value = "";
|
|
131
|
+
_prevDates = [];
|
|
132
|
+
}, 10);
|
|
133
|
+
}
|
|
134
|
+
if (_secondInputFocused) {
|
|
135
|
+
setTimeout(function () {
|
|
136
|
+
secondInput.focus();
|
|
137
|
+
}, 0);
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
onDestroy: function () {
|
|
141
|
+
if (!config.input)
|
|
142
|
+
secondInput.parentNode &&
|
|
143
|
+
secondInput.parentNode.removeChild(secondInput);
|
|
144
|
+
},
|
|
145
|
+
onValueUpdate: function (selDates) {
|
|
146
|
+
var _a, _b, _c;
|
|
147
|
+
if (!secondInput)
|
|
148
|
+
return;
|
|
149
|
+
_prevDates =
|
|
150
|
+
!_prevDates || selDates.length >= _prevDates.length
|
|
151
|
+
? __spreadArrays(selDates) : _prevDates;
|
|
152
|
+
if (_prevDates.length > selDates.length) {
|
|
153
|
+
var newSelectedDate = selDates[0];
|
|
154
|
+
var newDates = _secondInputFocused
|
|
155
|
+
? [_prevDates[0], newSelectedDate]
|
|
156
|
+
: [newSelectedDate, _prevDates[1]];
|
|
157
|
+
fp.setDate(newDates, false);
|
|
158
|
+
_prevDates = __spreadArrays(newDates);
|
|
159
|
+
}
|
|
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;
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
return plugin;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
145
166
|
|
|
146
|
-
|
|
167
|
+
return rangePlugin;
|
|
168
|
+
|
|
169
|
+
})));
|