flatpickr 4.6.3.0 → 4.6.13.1
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/LICENSE.txt +1 -1
- data/lib/flatpickr/version.rb +1 -1
- data/vendor/assets/javascripts/flatpickr/l10n/ar-dz.js +61 -0
- data/vendor/assets/javascripts/flatpickr/l10n/ar.js +17 -7
- data/vendor/assets/javascripts/flatpickr/l10n/at.js +8 -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 +9 -8
- data/vendor/assets/javascripts/flatpickr/l10n/ckb.js +76 -0
- 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 +39 -39
- 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 +13 -9
- 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/hy.js +78 -0
- data/vendor/assets/javascripts/flatpickr/l10n/id.js +7 -7
- data/vendor/assets/javascripts/flatpickr/l10n/index.js +820 -474
- 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 +8 -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 +8 -16
- 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/nn.js +73 -0
- 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 +14 -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 +40 -39
- 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 +38 -18
- data/vendor/assets/javascripts/flatpickr/plugins/labelPlugin/labelPlugin.js +4 -4
- data/vendor/assets/javascripts/flatpickr/plugins/minMaxTimePlugin.js +47 -24
- data/vendor/assets/javascripts/flatpickr/plugins/momentPlugin.js +69 -0
- data/vendor/assets/javascripts/flatpickr/plugins/monthSelect/index.js +154 -56
- data/vendor/assets/javascripts/flatpickr/plugins/rangePlugin.js +175 -142
- data/vendor/assets/javascripts/flatpickr/plugins/scrollPlugin.js +53 -18
- data/vendor/assets/javascripts/flatpickr/plugins/weekSelect/weekSelect.js +18 -5
- data/vendor/assets/javascripts/flatpickr.js +435 -321
- data/vendor/assets/stylesheets/flatpickr/plugins/monthSelect/style.css +45 -7
- data/vendor/assets/stylesheets/flatpickr/themes/airbnb.css +13 -2
- data/vendor/assets/stylesheets/flatpickr/themes/confetti.css +15 -4
- data/vendor/assets/stylesheets/flatpickr/themes/dark.css +13 -2
- data/vendor/assets/stylesheets/flatpickr/themes/light.css +15 -4
- data/vendor/assets/stylesheets/flatpickr/themes/material_blue.css +15 -4
- data/vendor/assets/stylesheets/flatpickr/themes/material_green.css +15 -4
- data/vendor/assets/stylesheets/flatpickr/themes/material_orange.css +15 -4
- data/vendor/assets/stylesheets/flatpickr/themes/material_red.css +15 -4
- data/vendor/assets/stylesheets/flatpickr.css +13 -2
- metadata +15 -17
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/Gemfile +0 -3
- data/Rakefile +0 -44
- data/bin/console +0 -7
- data/bin/setup +0 -6
- data/flatpickr.gemspec +0 -26
@@ -1,10 +1,13 @@
|
|
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());
|
5
|
-
}(this, function () { 'use strict';
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.minMaxTimePlugin = factory());
|
5
|
+
}(this, (function () { 'use strict';
|
6
6
|
|
7
|
-
var pad = function (number) {
|
7
|
+
var pad = function (number, length) {
|
8
|
+
if (length === void 0) { length = 2; }
|
9
|
+
return ("000" + number).slice(length * -1);
|
10
|
+
};
|
8
11
|
var int = function (bool) { return (bool === true ? 1 : 0); };
|
9
12
|
|
10
13
|
var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
|
@@ -44,8 +47,8 @@
|
|
44
47
|
W: function (date, _, options) {
|
45
48
|
return options.getWeek(date);
|
46
49
|
},
|
47
|
-
// full year e.g. 2016
|
48
|
-
Y: function (date) { return date.getFullYear(); },
|
50
|
+
// full year e.g. 2016, padded (0001-9999)
|
51
|
+
Y: function (date) { return pad(date.getFullYear(), 4); },
|
49
52
|
// day in month, padded (01-30)
|
50
53
|
d: function (date) { return pad(date.getDate()); },
|
51
54
|
// hour from 1-12 (am/pm)
|
@@ -69,19 +72,20 @@
|
|
69
72
|
// number of the day of the week
|
70
73
|
w: function (date) { return date.getDay(); },
|
71
74
|
// last two digits of year e.g. 16 for 2016
|
72
|
-
y: function (date) { return String(date.getFullYear()).substring(2); }
|
75
|
+
y: function (date) { return String(date.getFullYear()).substring(2); },
|
73
76
|
};
|
74
77
|
|
75
78
|
var defaults = {
|
76
79
|
_disable: [],
|
77
|
-
_enable: [],
|
78
80
|
allowInput: false,
|
81
|
+
allowInvalidPreload: false,
|
79
82
|
altFormat: "F j, Y",
|
80
83
|
altInput: false,
|
81
84
|
altInputClass: "form-control input",
|
82
85
|
animate: typeof window === "object" &&
|
83
86
|
window.navigator.userAgent.indexOf("MSIE") === -1,
|
84
87
|
ariaDateFormat: "F j, Y",
|
88
|
+
autoFillDefaultTime: true,
|
85
89
|
clickOpens: true,
|
86
90
|
closeOnSelect: true,
|
87
91
|
conjunction: ", ",
|
@@ -91,7 +95,6 @@
|
|
91
95
|
defaultSeconds: 0,
|
92
96
|
disable: [],
|
93
97
|
disableMobile: false,
|
94
|
-
enable: [],
|
95
98
|
enableSeconds: false,
|
96
99
|
enableTime: false,
|
97
100
|
errorHandler: function (err) {
|
@@ -142,7 +145,7 @@
|
|
142
145
|
static: false,
|
143
146
|
time_24hr: false,
|
144
147
|
weekNumbers: false,
|
145
|
-
wrap: false
|
148
|
+
wrap: false,
|
146
149
|
};
|
147
150
|
|
148
151
|
var english = {
|
@@ -156,7 +159,7 @@
|
|
156
159
|
"Thursday",
|
157
160
|
"Friday",
|
158
161
|
"Saturday",
|
159
|
-
]
|
162
|
+
],
|
160
163
|
},
|
161
164
|
months: {
|
162
165
|
shorthand: [
|
@@ -186,7 +189,7 @@
|
|
186
189
|
"October",
|
187
190
|
"November",
|
188
191
|
"December",
|
189
|
-
]
|
192
|
+
],
|
190
193
|
},
|
191
194
|
daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
|
192
195
|
firstDayOfWeek: 0,
|
@@ -211,16 +214,17 @@
|
|
211
214
|
toggleTitle: "Click to toggle",
|
212
215
|
amPM: ["AM", "PM"],
|
213
216
|
yearAriaLabel: "Year",
|
217
|
+
monthAriaLabel: "Month",
|
214
218
|
hourAriaLabel: "Hour",
|
215
219
|
minuteAriaLabel: "Minute",
|
216
|
-
time_24hr: false
|
220
|
+
time_24hr: false,
|
217
221
|
};
|
218
222
|
|
219
223
|
var createDateFormatter = function (_a) {
|
220
|
-
var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
|
224
|
+
var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c, _d = _a.isMobile, isMobile = _d === void 0 ? false : _d;
|
221
225
|
return function (dateObj, frmt, overrideLocale) {
|
222
226
|
var locale = overrideLocale || l10n;
|
223
|
-
if (config.formatDate !== undefined) {
|
227
|
+
if (config.formatDate !== undefined && !isMobile) {
|
224
228
|
return config.formatDate(dateObj, frmt, locale);
|
225
229
|
}
|
226
230
|
return frmt
|
@@ -255,6 +259,13 @@
|
|
255
259
|
date1.getSeconds() -
|
256
260
|
date2.getSeconds());
|
257
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
|
+
};
|
258
269
|
|
259
270
|
function minMaxTimePlugin(config) {
|
260
271
|
if (config === void 0) { config = {}; }
|
@@ -263,8 +274,8 @@
|
|
263
274
|
tableDateFormat: config.tableDateFormat || "Y-m-d",
|
264
275
|
defaults: {
|
265
276
|
minTime: undefined,
|
266
|
-
maxTime: undefined
|
267
|
-
}
|
277
|
+
maxTime: undefined,
|
278
|
+
},
|
268
279
|
};
|
269
280
|
function findDateTimeLimit(date) {
|
270
281
|
if (config.table !== undefined) {
|
@@ -278,7 +289,7 @@
|
|
278
289
|
state.formatDate = this.formatDate;
|
279
290
|
state.defaults = {
|
280
291
|
minTime: this.config.minTime && state.formatDate(this.config.minTime, "H:i"),
|
281
|
-
maxTime: this.config.maxTime && state.formatDate(this.config.maxTime, "H:i")
|
292
|
+
maxTime: this.config.maxTime && state.formatDate(this.config.maxTime, "H:i"),
|
282
293
|
};
|
283
294
|
fp.loadedPlugins.push("minMaxTime");
|
284
295
|
},
|
@@ -293,16 +304,28 @@
|
|
293
304
|
fp.config.maxTime.setMonth(latest.getMonth());
|
294
305
|
fp.config.minTime.setDate(latest.getDate());
|
295
306
|
fp.config.maxTime.setDate(latest.getDate());
|
296
|
-
if (
|
297
|
-
|
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
|
+
}
|
298
323
|
}
|
299
|
-
else if (compareDates(latest, fp.config.minTime, false) < 0)
|
300
|
-
fp.setDate(new Date(latest.getTime()).setHours(fp.config.minTime.getHours(), fp.config.minTime.getMinutes(), fp.config.minTime.getSeconds(), fp.config.minTime.getMilliseconds()), false);
|
301
324
|
}
|
302
325
|
else {
|
303
326
|
var newMinMax = state.defaults || {
|
304
327
|
minTime: undefined,
|
305
|
-
maxTime: undefined
|
328
|
+
maxTime: undefined,
|
306
329
|
};
|
307
330
|
this.set(newMinMax);
|
308
331
|
if (!latest)
|
@@ -316,11 +339,11 @@
|
|
316
339
|
}
|
317
340
|
//
|
318
341
|
}
|
319
|
-
}
|
342
|
+
},
|
320
343
|
};
|
321
344
|
};
|
322
345
|
}
|
323
346
|
|
324
347
|
return minMaxTimePlugin;
|
325
348
|
|
326
|
-
}));
|
349
|
+
})));
|
@@ -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,23 +32,39 @@
|
|
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
|
+
}
|
39
|
+
function getEventTarget(event) {
|
40
|
+
try {
|
41
|
+
if (typeof event.composedPath === "function") {
|
42
|
+
var path = event.composedPath();
|
43
|
+
return path[0];
|
44
|
+
}
|
45
|
+
return event.target;
|
46
|
+
}
|
47
|
+
catch (error) {
|
48
|
+
return event.target;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
35
52
|
var defaultConfig = {
|
36
53
|
shorthand: false,
|
37
54
|
dateFormat: "F Y",
|
38
55
|
altFormat: "F Y",
|
39
|
-
theme: "light"
|
56
|
+
theme: "light",
|
40
57
|
};
|
41
58
|
function monthSelectPlugin(pluginConfig) {
|
42
|
-
var config = __assign({}, defaultConfig, pluginConfig);
|
59
|
+
var config = __assign(__assign({}, defaultConfig), pluginConfig);
|
43
60
|
return function (fp) {
|
44
61
|
fp.config.dateFormat = config.dateFormat;
|
45
62
|
fp.config.altFormat = config.altFormat;
|
46
63
|
var self = { monthsContainer: null };
|
47
64
|
function clearUnnecessaryDOMElements() {
|
48
|
-
if (!fp.rContainer
|
65
|
+
if (!fp.rContainer)
|
49
66
|
return;
|
50
|
-
fp.rContainer
|
51
|
-
fp.rContainer.removeChild(fp.weekdayContainer);
|
67
|
+
clearNode(fp.rContainer);
|
52
68
|
for (var index = 0; index < fp.monthElements.length; index++) {
|
53
69
|
var element = fp.monthElements[index];
|
54
70
|
if (!element.parentNode)
|
@@ -56,44 +72,72 @@
|
|
56
72
|
element.parentNode.removeChild(element);
|
57
73
|
}
|
58
74
|
}
|
59
|
-
function
|
60
|
-
fp._bind(fp.prevMonthNav, "click", function () {
|
61
|
-
fp.currentYear -= 1;
|
62
|
-
selectYear();
|
63
|
-
});
|
64
|
-
fp._bind(fp.nextMonthNav, "mousedown", function () {
|
65
|
-
fp.currentYear += 1;
|
66
|
-
selectYear();
|
67
|
-
});
|
68
|
-
}
|
69
|
-
function addMonths() {
|
75
|
+
function build() {
|
70
76
|
if (!fp.rContainer)
|
71
77
|
return;
|
72
78
|
self.monthsContainer = fp._createElement("div", "flatpickr-monthSelect-months");
|
73
79
|
self.monthsContainer.tabIndex = -1;
|
80
|
+
buildMonths();
|
81
|
+
fp.rContainer.appendChild(self.monthsContainer);
|
74
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();
|
75
89
|
for (var i = 0; i < 12; i++) {
|
76
|
-
var month = fp.
|
77
|
-
month.dateObj
|
78
|
-
|
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");
|
79
94
|
month.textContent = monthToStr(i, config.shorthand, fp.l10n);
|
80
|
-
month.tabIndex = -1;
|
81
95
|
month.addEventListener("click", selectMonth);
|
82
|
-
|
83
|
-
if ((fp.config.minDate && month.dateObj < fp.config.minDate) || (fp.config.maxDate && month.dateObj > fp.config.maxDate)) {
|
84
|
-
month.classList.add("disabled");
|
85
|
-
}
|
96
|
+
frag.appendChild(month);
|
86
97
|
}
|
87
|
-
|
98
|
+
self.monthsContainer.appendChild(frag);
|
99
|
+
if (fp.config.minDate &&
|
100
|
+
fp.currentYear === fp.config.minDate.getFullYear())
|
101
|
+
fp.prevMonthNav.classList.add("flatpickr-disabled");
|
102
|
+
else
|
103
|
+
fp.prevMonthNav.classList.remove("flatpickr-disabled");
|
104
|
+
if (fp.config.maxDate &&
|
105
|
+
fp.currentYear === fp.config.maxDate.getFullYear())
|
106
|
+
fp.nextMonthNav.classList.add("flatpickr-disabled");
|
107
|
+
else
|
108
|
+
fp.nextMonthNav.classList.remove("flatpickr-disabled");
|
109
|
+
}
|
110
|
+
function bindEvents() {
|
111
|
+
fp._bind(fp.prevMonthNav, "click", function (e) {
|
112
|
+
e.preventDefault();
|
113
|
+
e.stopPropagation();
|
114
|
+
fp.changeYear(fp.currentYear - 1);
|
115
|
+
selectYear();
|
116
|
+
buildMonths();
|
117
|
+
});
|
118
|
+
fp._bind(fp.nextMonthNav, "click", function (e) {
|
119
|
+
e.preventDefault();
|
120
|
+
e.stopPropagation();
|
121
|
+
fp.changeYear(fp.currentYear + 1);
|
122
|
+
selectYear();
|
123
|
+
buildMonths();
|
124
|
+
});
|
125
|
+
fp._bind(self.monthsContainer, "mouseover", function (e) {
|
126
|
+
if (fp.config.mode === "range")
|
127
|
+
fp.onMouseOver(getEventTarget(e), "flatpickr-monthSelect-month");
|
128
|
+
});
|
88
129
|
}
|
89
130
|
function setCurrentlySelected() {
|
90
131
|
if (!fp.rContainer)
|
91
132
|
return;
|
133
|
+
if (!fp.selectedDates.length)
|
134
|
+
return;
|
92
135
|
var currentlySelected = fp.rContainer.querySelectorAll(".flatpickr-monthSelect-month.selected");
|
93
136
|
for (var index = 0; index < currentlySelected.length; index++) {
|
94
137
|
currentlySelected[index].classList.remove("selected");
|
95
138
|
}
|
96
|
-
var
|
139
|
+
var targetMonth = fp.selectedDates[0].getMonth();
|
140
|
+
var month = fp.rContainer.querySelector(".flatpickr-monthSelect-month:nth-child(" + (targetMonth + 1) + ")");
|
97
141
|
if (month) {
|
98
142
|
month.classList.add("selected");
|
99
143
|
}
|
@@ -110,42 +154,69 @@
|
|
110
154
|
selectedDate = fp.config.maxDate;
|
111
155
|
}
|
112
156
|
fp.currentYear = selectedDate.getFullYear();
|
113
|
-
fp.currentYearElement.value = String(fp.currentYear);
|
114
|
-
setCurrentlySelected();
|
115
157
|
}
|
158
|
+
fp.currentYearElement.value = String(fp.currentYear);
|
116
159
|
if (fp.rContainer) {
|
117
160
|
var months = fp.rContainer.querySelectorAll(".flatpickr-monthSelect-month");
|
118
161
|
months.forEach(function (month) {
|
119
162
|
month.dateObj.setFullYear(fp.currentYear);
|
120
|
-
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
121
|
-
month.
|
163
|
+
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
164
|
+
(fp.config.maxDate && month.dateObj > fp.config.maxDate)) {
|
165
|
+
month.classList.add("flatpickr-disabled");
|
122
166
|
}
|
123
167
|
else {
|
124
|
-
month.classList.remove("disabled");
|
168
|
+
month.classList.remove("flatpickr-disabled");
|
125
169
|
}
|
126
170
|
});
|
127
171
|
}
|
172
|
+
setCurrentlySelected();
|
128
173
|
}
|
129
174
|
function selectMonth(e) {
|
130
175
|
e.preventDefault();
|
131
176
|
e.stopPropagation();
|
132
|
-
|
133
|
-
|
134
|
-
|
177
|
+
var eventTarget = getEventTarget(e);
|
178
|
+
if (!(eventTarget instanceof Element))
|
179
|
+
return;
|
180
|
+
if (eventTarget.classList.contains("flatpickr-disabled"))
|
181
|
+
return;
|
182
|
+
if (eventTarget.classList.contains("notAllowed"))
|
183
|
+
return; // necessary??
|
184
|
+
setMonth(eventTarget.dateObj);
|
185
|
+
if (fp.config.closeOnSelect) {
|
186
|
+
var single = fp.config.mode === "single";
|
187
|
+
var range = fp.config.mode === "range" && fp.selectedDates.length === 2;
|
188
|
+
if (single || range)
|
189
|
+
fp.close();
|
135
190
|
}
|
136
191
|
}
|
137
192
|
function setMonth(date) {
|
138
|
-
var selectedDate = new Date(date);
|
139
|
-
|
140
|
-
fp.
|
141
|
-
|
193
|
+
var selectedDate = new Date(fp.currentYear, date.getMonth(), date.getDate());
|
194
|
+
var selectedDates = [];
|
195
|
+
switch (fp.config.mode) {
|
196
|
+
case "single":
|
197
|
+
selectedDates = [selectedDate];
|
198
|
+
break;
|
199
|
+
case "multiple":
|
200
|
+
selectedDates.push(selectedDate);
|
201
|
+
break;
|
202
|
+
case "range":
|
203
|
+
if (fp.selectedDates.length === 2) {
|
204
|
+
selectedDates = [selectedDate];
|
205
|
+
}
|
206
|
+
else {
|
207
|
+
selectedDates = fp.selectedDates.concat([selectedDate]);
|
208
|
+
selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
|
209
|
+
}
|
210
|
+
break;
|
211
|
+
}
|
212
|
+
fp.setDate(selectedDates, true);
|
142
213
|
setCurrentlySelected();
|
143
214
|
}
|
144
215
|
var shifts = {
|
145
216
|
37: -1,
|
146
217
|
39: 1,
|
147
218
|
40: 3,
|
148
|
-
38: -3
|
219
|
+
38: -3,
|
149
220
|
};
|
150
221
|
function onKeyDown(_, __, ___, e) {
|
151
222
|
var shouldMove = shifts[e.keyCode] !== undefined;
|
@@ -169,6 +240,26 @@
|
|
169
240
|
setMonth(document.activeElement.dateObj);
|
170
241
|
}
|
171
242
|
}
|
243
|
+
function closeHook() {
|
244
|
+
var _a;
|
245
|
+
if (((_a = fp.config) === null || _a === void 0 ? void 0 : _a.mode) === "range" && fp.selectedDates.length === 1)
|
246
|
+
fp.clear(false);
|
247
|
+
if (!fp.selectedDates.length)
|
248
|
+
buildMonths();
|
249
|
+
}
|
250
|
+
// Help the prev/next year nav honor config.minDate (see 3fa5a69)
|
251
|
+
function stubCurrentMonth() {
|
252
|
+
config._stubbedCurrentMonth = fp._initialDate.getMonth();
|
253
|
+
fp._initialDate.setMonth(config._stubbedCurrentMonth);
|
254
|
+
fp.currentMonth = config._stubbedCurrentMonth;
|
255
|
+
}
|
256
|
+
function unstubCurrentMonth() {
|
257
|
+
if (!config._stubbedCurrentMonth)
|
258
|
+
return;
|
259
|
+
fp._initialDate.setMonth(config._stubbedCurrentMonth);
|
260
|
+
fp.currentMonth = config._stubbedCurrentMonth;
|
261
|
+
delete config._stubbedCurrentMonth;
|
262
|
+
}
|
172
263
|
function destroyPluginInstance() {
|
173
264
|
if (self.monthsContainer !== null) {
|
174
265
|
var months = self.monthsContainer.querySelectorAll(".flatpickr-monthSelect-month");
|
@@ -179,25 +270,32 @@
|
|
179
270
|
}
|
180
271
|
return {
|
181
272
|
onParseConfig: function () {
|
182
|
-
fp.config.mode = "single";
|
183
273
|
fp.config.enableTime = false;
|
184
274
|
},
|
185
275
|
onValueUpdate: setCurrentlySelected,
|
186
276
|
onKeyDown: onKeyDown,
|
187
277
|
onReady: [
|
278
|
+
stubCurrentMonth,
|
188
279
|
clearUnnecessaryDOMElements,
|
189
|
-
|
190
|
-
|
280
|
+
build,
|
281
|
+
bindEvents,
|
191
282
|
setCurrentlySelected,
|
192
283
|
function () {
|
284
|
+
fp.config.onClose.push(closeHook);
|
193
285
|
fp.loadedPlugins.push("monthSelect");
|
194
286
|
},
|
195
287
|
],
|
196
|
-
onDestroy:
|
288
|
+
onDestroy: [
|
289
|
+
unstubCurrentMonth,
|
290
|
+
destroyPluginInstance,
|
291
|
+
function () {
|
292
|
+
fp.config.onClose = fp.config.onClose.filter(function (hook) { return hook !== closeHook; });
|
293
|
+
},
|
294
|
+
],
|
197
295
|
};
|
198
296
|
};
|
199
297
|
}
|
200
298
|
|
201
299
|
return monthSelectPlugin;
|
202
300
|
|
203
|
-
}));
|
301
|
+
})));
|