flatpickr 4.6.3.0 → 4.6.9.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/Rakefile +14 -15
- data/flatpickr.gemspec +1 -1
- data/lib/flatpickr/version.rb +1 -1
- data/package.json +5 -0
- data/vendor/assets/javascripts/flatpickr/l10n/ar.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/at.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/az.js +8 -8
- data/vendor/assets/javascripts/flatpickr/l10n/be.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/bg.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/bn.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/bs.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/cat.js +8 -8
- data/vendor/assets/javascripts/flatpickr/l10n/cs.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/cy.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/da.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/de.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/default.js +7 -6
- data/vendor/assets/javascripts/flatpickr/l10n/eo.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/es.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/et.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/fa.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/fi.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/fo.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/fr.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/ga.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/gr.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/he.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/hi.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/hr.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/hu.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/id.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/index.js +394 -259
- data/vendor/assets/javascripts/flatpickr/l10n/is.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/it.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/ja.js +11 -7
- data/vendor/assets/javascripts/flatpickr/l10n/ka.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/km.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/ko.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/kz.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/lt.js +8 -7
- data/vendor/assets/javascripts/flatpickr/l10n/lv.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/mk.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/mn.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/ms.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/my.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/nl.js +8 -8
- data/vendor/assets/javascripts/flatpickr/l10n/no.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/pa.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/pl.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/pt.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/ro.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/ru.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/si.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/sk.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/sl.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/sq.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/sr-cyr.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/sr.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/sv.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/th.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/tr.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/uk.js +7 -7
- 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 +9 -9
- data/vendor/assets/javascripts/flatpickr/l10n/zh-tw.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/zh.js +7 -7
- data/vendor/assets/javascripts/flatpickr/plugins/confirmDate/confirmDate.js +34 -18
- data/vendor/assets/javascripts/flatpickr/plugins/labelPlugin/labelPlugin.js +4 -4
- data/vendor/assets/javascripts/flatpickr/plugins/minMaxTimePlugin.js +24 -20
- data/vendor/assets/javascripts/flatpickr/plugins/momentPlugin.js +69 -0
- data/vendor/assets/javascripts/flatpickr/plugins/monthSelect/index.js +53 -29
- data/vendor/assets/javascripts/flatpickr/plugins/rangePlugin.js +167 -142
- data/vendor/assets/javascripts/flatpickr/plugins/scrollPlugin.js +33 -6
- data/vendor/assets/javascripts/flatpickr/plugins/weekSelect/weekSelect.js +18 -5
- data/vendor/assets/javascripts/flatpickr.js +295 -227
- 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
- data/vendor/assets/stylesheets/flatpickr.css +9 -2
- metadata +12 -8
@@ -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 = typeof globalThis !== 'undefined' ? globalThis : 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
|
+
})));
|
@@ -1,22 +1,22 @@
|
|
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());
|
5
|
-
}(this, function () { 'use strict';
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.monthSelectPlugin = factory());
|
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,16 @@
|
|
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
|
+
e.preventDefault();
|
75
|
+
e.stopPropagation();
|
76
|
+
fp.changeYear(fp.currentYear - 1);
|
62
77
|
selectYear();
|
63
78
|
});
|
64
|
-
fp._bind(fp.nextMonthNav, "
|
65
|
-
|
79
|
+
fp._bind(fp.nextMonthNav, "click", function (e) {
|
80
|
+
e.preventDefault();
|
81
|
+
e.stopPropagation();
|
82
|
+
fp.changeYear(fp.currentYear + 1);
|
66
83
|
selectYear();
|
67
84
|
});
|
68
85
|
}
|
@@ -80,7 +97,8 @@
|
|
80
97
|
month.tabIndex = -1;
|
81
98
|
month.addEventListener("click", selectMonth);
|
82
99
|
self.monthsContainer.appendChild(month);
|
83
|
-
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
100
|
+
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
101
|
+
(fp.config.maxDate && month.dateObj > fp.config.maxDate)) {
|
84
102
|
month.classList.add("disabled");
|
85
103
|
}
|
86
104
|
}
|
@@ -93,7 +111,8 @@
|
|
93
111
|
for (var index = 0; index < currentlySelected.length; index++) {
|
94
112
|
currentlySelected[index].classList.remove("selected");
|
95
113
|
}
|
96
|
-
var
|
114
|
+
var targetMonth = (fp.selectedDates[0] || new Date()).getMonth();
|
115
|
+
var month = fp.rContainer.querySelector(".flatpickr-monthSelect-month:nth-child(" + (targetMonth + 1) + ")");
|
97
116
|
if (month) {
|
98
117
|
month.classList.add("selected");
|
99
118
|
}
|
@@ -110,14 +129,14 @@
|
|
110
129
|
selectedDate = fp.config.maxDate;
|
111
130
|
}
|
112
131
|
fp.currentYear = selectedDate.getFullYear();
|
113
|
-
fp.currentYearElement.value = String(fp.currentYear);
|
114
|
-
setCurrentlySelected();
|
115
132
|
}
|
133
|
+
fp.currentYearElement.value = String(fp.currentYear);
|
116
134
|
if (fp.rContainer) {
|
117
135
|
var months = fp.rContainer.querySelectorAll(".flatpickr-monthSelect-month");
|
118
136
|
months.forEach(function (month) {
|
119
137
|
month.dateObj.setFullYear(fp.currentYear);
|
120
|
-
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
138
|
+
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
139
|
+
(fp.config.maxDate && month.dateObj > fp.config.maxDate)) {
|
121
140
|
month.classList.add("disabled");
|
122
141
|
}
|
123
142
|
else {
|
@@ -125,19 +144,21 @@
|
|
125
144
|
}
|
126
145
|
});
|
127
146
|
}
|
147
|
+
setCurrentlySelected();
|
128
148
|
}
|
129
149
|
function selectMonth(e) {
|
130
150
|
e.preventDefault();
|
131
151
|
e.stopPropagation();
|
132
|
-
|
133
|
-
|
152
|
+
var eventTarget = getEventTarget(e);
|
153
|
+
if (eventTarget instanceof Element &&
|
154
|
+
!eventTarget.classList.contains("disabled")) {
|
155
|
+
setMonth(eventTarget.dateObj);
|
134
156
|
fp.close();
|
135
157
|
}
|
136
158
|
}
|
137
159
|
function setMonth(date) {
|
138
160
|
var selectedDate = new Date(date);
|
139
161
|
selectedDate.setFullYear(fp.currentYear);
|
140
|
-
fp.currentMonth = selectedDate.getMonth();
|
141
162
|
fp.setDate(selectedDate, true);
|
142
163
|
setCurrentlySelected();
|
143
164
|
}
|
@@ -145,7 +166,7 @@
|
|
145
166
|
37: -1,
|
146
167
|
39: 1,
|
147
168
|
40: 3,
|
148
|
-
38: -3
|
169
|
+
38: -3,
|
149
170
|
};
|
150
171
|
function onKeyDown(_, __, ___, e) {
|
151
172
|
var shouldMove = shifts[e.keyCode] !== undefined;
|
@@ -185,6 +206,9 @@
|
|
185
206
|
onValueUpdate: setCurrentlySelected,
|
186
207
|
onKeyDown: onKeyDown,
|
187
208
|
onReady: [
|
209
|
+
function () {
|
210
|
+
fp.currentMonth = 0;
|
211
|
+
},
|
188
212
|
clearUnnecessaryDOMElements,
|
189
213
|
addListeners,
|
190
214
|
addMonths,
|
@@ -193,11 +217,11 @@
|
|
193
217
|
fp.loadedPlugins.push("monthSelect");
|
194
218
|
},
|
195
219
|
],
|
196
|
-
onDestroy: destroyPluginInstance
|
220
|
+
onDestroy: destroyPluginInstance,
|
197
221
|
};
|
198
222
|
};
|
199
223
|
}
|
200
224
|
|
201
225
|
return monthSelectPlugin;
|
202
226
|
|
203
|
-
}));
|
227
|
+
})));
|
@@ -1,146 +1,171 @@
|
|
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 = typeof globalThis !== 'undefined' ? globalThis : 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
|
+
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
|
+
}
|
76
|
+
if (fp.config.allowInput)
|
77
|
+
fp._bind(secondInput, "keydown", function (e) {
|
78
|
+
if (e.key === "Enter") {
|
79
|
+
fp.setDate([fp.selectedDates[0], secondInput.value], true, dateFormat);
|
80
|
+
secondInput.click();
|
81
|
+
}
|
82
|
+
});
|
83
|
+
if (!config.input)
|
84
|
+
fp._input.parentNode &&
|
85
|
+
fp._input.parentNode.insertBefore(secondInput, fp._input.nextSibling);
|
86
|
+
};
|
87
|
+
var plugin = {
|
88
|
+
onParseConfig: function () {
|
89
|
+
fp.config.mode = "range";
|
90
|
+
dateFormat = fp.config.altInput
|
91
|
+
? fp.config.altFormat
|
92
|
+
: fp.config.dateFormat;
|
93
|
+
},
|
94
|
+
onReady: function () {
|
95
|
+
createSecondInput();
|
96
|
+
fp.config.ignoredFocusElements.push(secondInput);
|
97
|
+
if (fp.config.allowInput) {
|
98
|
+
fp._input.removeAttribute("readonly");
|
99
|
+
secondInput.removeAttribute("readonly");
|
100
|
+
}
|
101
|
+
else {
|
102
|
+
secondInput.setAttribute("readonly", "readonly");
|
103
|
+
}
|
104
|
+
fp._bind(fp._input, "focus", function () {
|
105
|
+
fp.latestSelectedDateObj = fp.selectedDates[0];
|
106
|
+
fp._setHoursFromDate(fp.selectedDates[0]);
|
107
|
+
_secondInputFocused = false;
|
108
|
+
fp.jumpToDate(fp.selectedDates[0]);
|
109
|
+
});
|
110
|
+
if (fp.config.allowInput)
|
111
|
+
fp._bind(fp._input, "keydown", function (e) {
|
112
|
+
if (e.key === "Enter")
|
113
|
+
fp.setDate([fp._input.value, fp.selectedDates[1]], true, dateFormat);
|
114
|
+
});
|
115
|
+
fp.setDate(fp.selectedDates, false);
|
116
|
+
plugin.onValueUpdate(fp.selectedDates);
|
117
|
+
fp.loadedPlugins.push("range");
|
118
|
+
},
|
119
|
+
onPreCalendarPosition: function () {
|
120
|
+
if (_secondInputFocused) {
|
121
|
+
fp._positionElement = secondInput;
|
122
|
+
setTimeout(function () {
|
123
|
+
fp._positionElement = fp._input;
|
124
|
+
}, 0);
|
125
|
+
}
|
126
|
+
},
|
127
|
+
onChange: function () {
|
128
|
+
if (!fp.selectedDates.length) {
|
129
|
+
setTimeout(function () {
|
130
|
+
if (fp.selectedDates.length)
|
131
|
+
return;
|
132
|
+
secondInput.value = "";
|
133
|
+
_prevDates = [];
|
134
|
+
}, 10);
|
135
|
+
}
|
136
|
+
if (_secondInputFocused) {
|
137
|
+
setTimeout(function () {
|
138
|
+
secondInput.focus();
|
139
|
+
}, 0);
|
140
|
+
}
|
141
|
+
},
|
142
|
+
onDestroy: function () {
|
143
|
+
if (!config.input)
|
144
|
+
secondInput.parentNode &&
|
145
|
+
secondInput.parentNode.removeChild(secondInput);
|
146
|
+
},
|
147
|
+
onValueUpdate: function (selDates) {
|
148
|
+
var _a, _b, _c;
|
149
|
+
if (!secondInput)
|
150
|
+
return;
|
151
|
+
_prevDates =
|
152
|
+
!_prevDates || selDates.length >= _prevDates.length
|
153
|
+
? __spreadArrays(selDates) : _prevDates;
|
154
|
+
if (_prevDates.length > selDates.length) {
|
155
|
+
var newSelectedDate = selDates[0];
|
156
|
+
var newDates = _secondInputFocused
|
157
|
+
? [_prevDates[0], newSelectedDate]
|
158
|
+
: [newSelectedDate, _prevDates[1]];
|
159
|
+
fp.setDate(newDates, false);
|
160
|
+
_prevDates = __spreadArrays(newDates);
|
161
|
+
}
|
162
|
+
_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;
|
163
|
+
},
|
164
|
+
};
|
165
|
+
return plugin;
|
166
|
+
};
|
167
|
+
}
|
145
168
|
|
146
|
-
|
169
|
+
return rangePlugin;
|
170
|
+
|
171
|
+
})));
|
@@ -1,19 +1,46 @@
|
|
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());
|
5
|
-
}(this, function () { 'use strict';
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.scrollPlugin = factory());
|
5
|
+
}(this, (function () { 'use strict';
|
6
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
|
+
if (typeof window.CustomEvent !== "function") {
|
21
|
+
function CustomEvent(typeArg, eventInitDict) {
|
22
|
+
eventInitDict = eventInitDict || {
|
23
|
+
bubbles: false,
|
24
|
+
cancelable: false,
|
25
|
+
detail: undefined,
|
26
|
+
};
|
27
|
+
var evt = document.createEvent("CustomEvent");
|
28
|
+
evt.initCustomEvent(typeArg, eventInitDict.bubbles, eventInitDict.cancelable, eventInitDict.detail);
|
29
|
+
return evt;
|
30
|
+
}
|
31
|
+
CustomEvent.prototype = window.Event.prototype;
|
32
|
+
window.CustomEvent = CustomEvent;
|
33
|
+
}
|
7
34
|
function delta(e) {
|
8
35
|
return Math.max(-1, Math.min(1, e.wheelDelta || -e.deltaY));
|
9
36
|
}
|
10
37
|
var scroll = function (e) {
|
11
38
|
e.preventDefault();
|
12
39
|
var ev = new CustomEvent("increment", {
|
13
|
-
bubbles: true
|
40
|
+
bubbles: true,
|
14
41
|
});
|
15
42
|
ev.delta = delta(e);
|
16
|
-
e.
|
43
|
+
getEventTarget(e).dispatchEvent(ev);
|
17
44
|
};
|
18
45
|
function scrollMonth(fp) {
|
19
46
|
return function (e) {
|
@@ -48,11 +75,11 @@
|
|
48
75
|
fp.monthElements.forEach(function (monthElem) {
|
49
76
|
return monthElem.removeEventListener("wheel", monthScroller);
|
50
77
|
});
|
51
|
-
}
|
78
|
+
},
|
52
79
|
};
|
53
80
|
};
|
54
81
|
}
|
55
82
|
|
56
83
|
return scrollPlugin;
|
57
84
|
|
58
|
-
}));
|
85
|
+
})));
|
@@ -1,13 +1,26 @@
|
|
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());
|
5
|
-
}(this, function () { 'use strict';
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.weekSelect = 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
|
+
}
|
6
19
|
|
7
20
|
function weekSelectPlugin() {
|
8
21
|
return function (fp) {
|
9
22
|
function onDayHover(event) {
|
10
|
-
var day = event
|
23
|
+
var day = getEventTarget(event);
|
11
24
|
if (!day.classList.contains("flatpickr-day"))
|
12
25
|
return;
|
13
26
|
var days = fp.days.childNodes;
|
@@ -76,11 +89,11 @@
|
|
76
89
|
fp.loadedPlugins.push("weekSelect");
|
77
90
|
},
|
78
91
|
],
|
79
|
-
onDestroy: onDestroy
|
92
|
+
onDestroy: onDestroy,
|
80
93
|
};
|
81
94
|
};
|
82
95
|
}
|
83
96
|
|
84
97
|
return weekSelectPlugin;
|
85
98
|
|
86
|
-
}));
|
99
|
+
})));
|