@sunggang/ui-lib 0.4.2 → 0.4.4
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.
- package/BaseCkeditor.cjs.js +3 -0
- package/BaseCkeditor.esm.js +4 -1
- package/BigCalender.cjs.js +81 -28
- package/BigCalender.esm.js +82 -29
- package/CkEditor.cjs.js +3 -0
- package/CkEditor.esm.js +3 -0
- package/CustomSelect.cjs.js +124 -0
- package/CustomSelect.esm.js +122 -0
- package/Form.cjs.js +25 -138
- package/Form.esm.js +25 -138
- package/Modal.cjs.js +1 -2
- package/Modal.esm.js +1 -2
- package/_commonjsHelpers.esm.js +1 -1
- package/baseSwitch.cjs.js +40 -2407
- package/baseSwitch.esm.js +53 -2422
- package/index.cjs.css +0 -18
- package/index.cjs.js +92 -11
- package/index.cjs3.js +1039 -977
- package/index.esm.cjs.js +190 -132
- package/index.esm.css +0 -18
- package/index.esm.esm.js +190 -114
- package/index.esm.js +91 -12
- package/index.esm3.js +1039 -977
- package/package.json +2 -7
- package/src/index.d.ts +2 -0
- package/styled-components.esm.cjs.js +1 -1
- package/styled-components.esm.esm.js +1 -1
package/baseSwitch.cjs.js
CHANGED
|
@@ -17,6 +17,9 @@ var _commonjsHelpers = require('./_commonjsHelpers.cjs.js');
|
|
|
17
17
|
var Modal = require('./Modal.cjs.js');
|
|
18
18
|
var SelectPrimitive = require('@radix-ui/react-select');
|
|
19
19
|
var reactIcons = require('@radix-ui/react-icons');
|
|
20
|
+
var flatpickr = require('flatpickr');
|
|
21
|
+
var Mandarin = require('flatpickr/dist/l10n/zh-tw.js');
|
|
22
|
+
require('flatpickr/dist/flatpickr.min.css');
|
|
20
23
|
|
|
21
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
25
|
|
|
@@ -43,6 +46,8 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
43
46
|
var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
|
|
44
47
|
var dynamic__default = /*#__PURE__*/_interopDefaultLegacy(dynamic);
|
|
45
48
|
var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
|
|
49
|
+
var flatpickr__default = /*#__PURE__*/_interopDefaultLegacy(flatpickr);
|
|
50
|
+
var Mandarin__default = /*#__PURE__*/_interopDefaultLegacy(Mandarin);
|
|
46
51
|
|
|
47
52
|
var _excluded$6 = [
|
|
48
53
|
"defaultInputValue",
|
|
@@ -152,7 +157,7 @@ function rectToClientRect(rect) {
|
|
|
152
157
|
};
|
|
153
158
|
}
|
|
154
159
|
|
|
155
|
-
function _instanceof$
|
|
160
|
+
function _instanceof$2(left, right) {
|
|
156
161
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
157
162
|
return !!right[Symbol.hasInstance](left);
|
|
158
163
|
} else {
|
|
@@ -183,43 +188,45 @@ function isNode(value) {
|
|
|
183
188
|
if (!hasWindow()) {
|
|
184
189
|
return false;
|
|
185
190
|
}
|
|
186
|
-
return _instanceof$
|
|
191
|
+
return _instanceof$2(value, Node) || _instanceof$2(value, getWindow(value).Node);
|
|
187
192
|
}
|
|
188
193
|
function isElement(value) {
|
|
189
194
|
if (!hasWindow()) {
|
|
190
195
|
return false;
|
|
191
196
|
}
|
|
192
|
-
return _instanceof$
|
|
197
|
+
return _instanceof$2(value, Element) || _instanceof$2(value, getWindow(value).Element);
|
|
193
198
|
}
|
|
194
199
|
function isHTMLElement(value) {
|
|
195
200
|
if (!hasWindow()) {
|
|
196
201
|
return false;
|
|
197
202
|
}
|
|
198
|
-
return _instanceof$
|
|
203
|
+
return _instanceof$2(value, HTMLElement) || _instanceof$2(value, getWindow(value).HTMLElement);
|
|
199
204
|
}
|
|
200
205
|
function isShadowRoot(value) {
|
|
201
206
|
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
202
207
|
return false;
|
|
203
208
|
}
|
|
204
|
-
return _instanceof$
|
|
209
|
+
return _instanceof$2(value, ShadowRoot) || _instanceof$2(value, getWindow(value).ShadowRoot);
|
|
205
210
|
}
|
|
211
|
+
var invalidOverflowDisplayValues = /*#__PURE__*/ new Set([
|
|
212
|
+
"inline",
|
|
213
|
+
"contents"
|
|
214
|
+
]);
|
|
206
215
|
function isOverflowElement(element) {
|
|
207
216
|
var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY, display = _getComputedStyle.display;
|
|
208
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !
|
|
209
|
-
"inline",
|
|
210
|
-
"contents"
|
|
211
|
-
].includes(display);
|
|
217
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
212
218
|
}
|
|
213
219
|
function isWebKit() {
|
|
214
220
|
if (typeof CSS === "undefined" || !CSS.supports) return false;
|
|
215
221
|
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
216
222
|
}
|
|
223
|
+
var lastTraversableNodeNames = /*#__PURE__*/ new Set([
|
|
224
|
+
"html",
|
|
225
|
+
"body",
|
|
226
|
+
"#document"
|
|
227
|
+
]);
|
|
217
228
|
function isLastTraversableNode(node) {
|
|
218
|
-
return
|
|
219
|
-
"html",
|
|
220
|
-
"body",
|
|
221
|
-
"#document"
|
|
222
|
-
].includes(getNodeName(node));
|
|
229
|
+
return lastTraversableNodeNames.has(getNodeName(node));
|
|
223
230
|
}
|
|
224
231
|
function getComputedStyle$1(element) {
|
|
225
232
|
return getWindow(element).getComputedStyle(element);
|
|
@@ -1850,7 +1857,7 @@ var defaultComponents = function defaultComponents(props) {
|
|
|
1850
1857
|
return setPrototypeOf._objectSpread2(setPrototypeOf._objectSpread2({}, components), props.components);
|
|
1851
1858
|
};
|
|
1852
1859
|
|
|
1853
|
-
function _instanceof$
|
|
1860
|
+
function _instanceof$1(left, right) {
|
|
1854
1861
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1855
1862
|
return !!right[Symbol.hasInstance](left);
|
|
1856
1863
|
} else {
|
|
@@ -3083,7 +3090,8 @@ var Select$1 = /*#__PURE__*/ function(_Component) {
|
|
|
3083
3090
|
prevWasFocused: false,
|
|
3084
3091
|
inputIsHiddenAfterUpdate: undefined,
|
|
3085
3092
|
prevProps: undefined,
|
|
3086
|
-
instancePrefix: ""
|
|
3093
|
+
instancePrefix: "",
|
|
3094
|
+
isAppleDevice: false
|
|
3087
3095
|
};
|
|
3088
3096
|
_this.blockOptionHover = false;
|
|
3089
3097
|
_this.isComposing = false;
|
|
@@ -3093,7 +3101,6 @@ var Select$1 = /*#__PURE__*/ function(_Component) {
|
|
|
3093
3101
|
_this.openAfterFocus = false;
|
|
3094
3102
|
_this.scrollToFocusedOptionOnUpdate = false;
|
|
3095
3103
|
_this.userIsDragging = void 0;
|
|
3096
|
-
_this.isAppleDevice = isAppleDevice();
|
|
3097
3104
|
_this.controlRef = null;
|
|
3098
3105
|
_this.getControlRef = function(ref) {
|
|
3099
3106
|
_this.controlRef = ref;
|
|
@@ -3334,7 +3341,7 @@ var Select$1 = /*#__PURE__*/ function(_Component) {
|
|
|
3334
3341
|
};
|
|
3335
3342
|
_this.onScroll = function(event) {
|
|
3336
3343
|
if (typeof _this.props.closeMenuOnScroll === "boolean") {
|
|
3337
|
-
if (_instanceof$
|
|
3344
|
+
if (_instanceof$1(event.target, HTMLElement) && isDocumentElement(event.target)) {
|
|
3338
3345
|
_this.props.onMenuClose();
|
|
3339
3346
|
}
|
|
3340
3347
|
} else if (typeof _this.props.closeMenuOnScroll === "function") {
|
|
@@ -3605,6 +3612,12 @@ var Select$1 = /*#__PURE__*/ function(_Component) {
|
|
|
3605
3612
|
if (this.props.menuIsOpen && this.state.focusedOption && this.menuListRef && this.focusedOptionRef) {
|
|
3606
3613
|
scrollIntoView(this.menuListRef, this.focusedOptionRef);
|
|
3607
3614
|
}
|
|
3615
|
+
if (isAppleDevice()) {
|
|
3616
|
+
// eslint-disable-next-line react/no-did-mount-set-state
|
|
3617
|
+
this.setState({
|
|
3618
|
+
isAppleDevice: true
|
|
3619
|
+
});
|
|
3620
|
+
}
|
|
3608
3621
|
}
|
|
3609
3622
|
},
|
|
3610
3623
|
{
|
|
@@ -3953,7 +3966,7 @@ var Select$1 = /*#__PURE__*/ function(_Component) {
|
|
|
3953
3966
|
"aria-labelledby": this.props["aria-labelledby"],
|
|
3954
3967
|
"aria-required": required,
|
|
3955
3968
|
role: "combobox",
|
|
3956
|
-
"aria-activedescendant": this.isAppleDevice ? undefined : this.state.focusedOptionId || ""
|
|
3969
|
+
"aria-activedescendant": this.state.isAppleDevice ? undefined : this.state.focusedOptionId || ""
|
|
3957
3970
|
}, menuIsOpen && {
|
|
3958
3971
|
"aria-controls": this.getElementId("listbox")
|
|
3959
3972
|
}), !isSearchable && {
|
|
@@ -4155,7 +4168,7 @@ var Select$1 = /*#__PURE__*/ function(_Component) {
|
|
|
4155
4168
|
onMouseOver: onHover,
|
|
4156
4169
|
tabIndex: -1,
|
|
4157
4170
|
role: "option",
|
|
4158
|
-
"aria-selected": _this4.isAppleDevice ? undefined : isSelected // is not supported on Apple devices
|
|
4171
|
+
"aria-selected": _this4.state.isAppleDevice ? undefined : isSelected // is not supported on Apple devices
|
|
4159
4172
|
};
|
|
4160
4173
|
return /*#__PURE__*/ React__namespace.createElement(Option, setPrototypeOf._extends({}, commonProps, {
|
|
4161
4174
|
innerProps: innerProps,
|
|
@@ -4319,7 +4332,7 @@ var Select$1 = /*#__PURE__*/ function(_Component) {
|
|
|
4319
4332
|
isFocused: isFocused,
|
|
4320
4333
|
selectValue: selectValue,
|
|
4321
4334
|
focusableOptions: focusableOptions,
|
|
4322
|
-
isAppleDevice: this.isAppleDevice
|
|
4335
|
+
isAppleDevice: this.state.isAppleDevice
|
|
4323
4336
|
}));
|
|
4324
4337
|
}
|
|
4325
4338
|
},
|
|
@@ -21607,7 +21620,7 @@ function _array_like_to_array$2(arr, len) {
|
|
|
21607
21620
|
function _array_with_holes$2(arr) {
|
|
21608
21621
|
if (Array.isArray(arr)) return arr;
|
|
21609
21622
|
}
|
|
21610
|
-
function _instanceof
|
|
21623
|
+
function _instanceof(left, right) {
|
|
21611
21624
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
21612
21625
|
return !!right[Symbol.hasInstance](left);
|
|
21613
21626
|
} else {
|
|
@@ -21709,7 +21722,7 @@ var CustomUpload = function(param) {
|
|
|
21709
21722
|
}
|
|
21710
21723
|
field.onChange(currentFile);
|
|
21711
21724
|
};
|
|
21712
|
-
var previewUrl = _instanceof
|
|
21725
|
+
var previewUrl = _instanceof(field.value, File) ? URL.createObjectURL(field.value) : typeof field.value === "string" ? field.value : null;
|
|
21713
21726
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
21714
21727
|
children: [
|
|
21715
21728
|
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
@@ -21722,7 +21735,7 @@ var CustomUpload = function(param) {
|
|
|
21722
21735
|
onClick: handleImageClick,
|
|
21723
21736
|
children: [
|
|
21724
21737
|
/*#__PURE__*/ jsxRuntime.jsx(BaseTemplate, {
|
|
21725
|
-
file: _instanceof
|
|
21738
|
+
file: _instanceof(field.value, File) ? field.value : undefined,
|
|
21726
21739
|
imageUrl: previewUrl,
|
|
21727
21740
|
item: item,
|
|
21728
21741
|
field: field
|
|
@@ -22237,2387 +22250,6 @@ var DropdownList = function(param) {
|
|
|
22237
22250
|
}, item.name);
|
|
22238
22251
|
};
|
|
22239
22252
|
|
|
22240
|
-
var HOOKS = [
|
|
22241
|
-
"onChange",
|
|
22242
|
-
"onClose",
|
|
22243
|
-
"onDayCreate",
|
|
22244
|
-
"onDestroy",
|
|
22245
|
-
"onKeyDown",
|
|
22246
|
-
"onMonthChange",
|
|
22247
|
-
"onOpen",
|
|
22248
|
-
"onParseConfig",
|
|
22249
|
-
"onReady",
|
|
22250
|
-
"onValueUpdate",
|
|
22251
|
-
"onYearChange",
|
|
22252
|
-
"onPreCalendarPosition"
|
|
22253
|
-
];
|
|
22254
|
-
var defaults = {
|
|
22255
|
-
_disable: [],
|
|
22256
|
-
allowInput: false,
|
|
22257
|
-
allowInvalidPreload: false,
|
|
22258
|
-
altFormat: "F j, Y",
|
|
22259
|
-
altInput: false,
|
|
22260
|
-
altInputClass: "form-control input",
|
|
22261
|
-
animate: typeof window === "object" && window.navigator.userAgent.indexOf("MSIE") === -1,
|
|
22262
|
-
ariaDateFormat: "F j, Y",
|
|
22263
|
-
autoFillDefaultTime: true,
|
|
22264
|
-
clickOpens: true,
|
|
22265
|
-
closeOnSelect: true,
|
|
22266
|
-
conjunction: ", ",
|
|
22267
|
-
dateFormat: "Y-m-d",
|
|
22268
|
-
defaultHour: 12,
|
|
22269
|
-
defaultMinute: 0,
|
|
22270
|
-
defaultSeconds: 0,
|
|
22271
|
-
disable: [],
|
|
22272
|
-
disableMobile: false,
|
|
22273
|
-
enableSeconds: false,
|
|
22274
|
-
enableTime: false,
|
|
22275
|
-
errorHandler: function errorHandler(err) {
|
|
22276
|
-
return typeof console !== "undefined" && console.warn(err);
|
|
22277
|
-
},
|
|
22278
|
-
getWeek: function getWeek(givenDate) {
|
|
22279
|
-
var date = new Date(givenDate.getTime());
|
|
22280
|
-
date.setHours(0, 0, 0, 0);
|
|
22281
|
-
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
|
|
22282
|
-
var week1 = new Date(date.getFullYear(), 0, 4);
|
|
22283
|
-
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
|
|
22284
|
-
},
|
|
22285
|
-
hourIncrement: 1,
|
|
22286
|
-
ignoredFocusElements: [],
|
|
22287
|
-
inline: false,
|
|
22288
|
-
locale: "default",
|
|
22289
|
-
minuteIncrement: 5,
|
|
22290
|
-
mode: "single",
|
|
22291
|
-
monthSelectorType: "dropdown",
|
|
22292
|
-
nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",
|
|
22293
|
-
noCalendar: false,
|
|
22294
|
-
now: new Date(),
|
|
22295
|
-
onChange: [],
|
|
22296
|
-
onClose: [],
|
|
22297
|
-
onDayCreate: [],
|
|
22298
|
-
onDestroy: [],
|
|
22299
|
-
onKeyDown: [],
|
|
22300
|
-
onMonthChange: [],
|
|
22301
|
-
onOpen: [],
|
|
22302
|
-
onParseConfig: [],
|
|
22303
|
-
onReady: [],
|
|
22304
|
-
onValueUpdate: [],
|
|
22305
|
-
onYearChange: [],
|
|
22306
|
-
onPreCalendarPosition: [],
|
|
22307
|
-
plugins: [],
|
|
22308
|
-
position: "auto",
|
|
22309
|
-
positionElement: undefined,
|
|
22310
|
-
prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",
|
|
22311
|
-
shorthandCurrentMonth: false,
|
|
22312
|
-
showMonths: 1,
|
|
22313
|
-
static: false,
|
|
22314
|
-
time_24hr: false,
|
|
22315
|
-
weekNumbers: false,
|
|
22316
|
-
wrap: false
|
|
22317
|
-
};
|
|
22318
|
-
|
|
22319
|
-
var english = {
|
|
22320
|
-
weekdays: {
|
|
22321
|
-
shorthand: [
|
|
22322
|
-
"Sun",
|
|
22323
|
-
"Mon",
|
|
22324
|
-
"Tue",
|
|
22325
|
-
"Wed",
|
|
22326
|
-
"Thu",
|
|
22327
|
-
"Fri",
|
|
22328
|
-
"Sat"
|
|
22329
|
-
],
|
|
22330
|
-
longhand: [
|
|
22331
|
-
"Sunday",
|
|
22332
|
-
"Monday",
|
|
22333
|
-
"Tuesday",
|
|
22334
|
-
"Wednesday",
|
|
22335
|
-
"Thursday",
|
|
22336
|
-
"Friday",
|
|
22337
|
-
"Saturday"
|
|
22338
|
-
]
|
|
22339
|
-
},
|
|
22340
|
-
months: {
|
|
22341
|
-
shorthand: [
|
|
22342
|
-
"Jan",
|
|
22343
|
-
"Feb",
|
|
22344
|
-
"Mar",
|
|
22345
|
-
"Apr",
|
|
22346
|
-
"May",
|
|
22347
|
-
"Jun",
|
|
22348
|
-
"Jul",
|
|
22349
|
-
"Aug",
|
|
22350
|
-
"Sep",
|
|
22351
|
-
"Oct",
|
|
22352
|
-
"Nov",
|
|
22353
|
-
"Dec"
|
|
22354
|
-
],
|
|
22355
|
-
longhand: [
|
|
22356
|
-
"January",
|
|
22357
|
-
"February",
|
|
22358
|
-
"March",
|
|
22359
|
-
"April",
|
|
22360
|
-
"May",
|
|
22361
|
-
"June",
|
|
22362
|
-
"July",
|
|
22363
|
-
"August",
|
|
22364
|
-
"September",
|
|
22365
|
-
"October",
|
|
22366
|
-
"November",
|
|
22367
|
-
"December"
|
|
22368
|
-
]
|
|
22369
|
-
},
|
|
22370
|
-
daysInMonth: [
|
|
22371
|
-
31,
|
|
22372
|
-
28,
|
|
22373
|
-
31,
|
|
22374
|
-
30,
|
|
22375
|
-
31,
|
|
22376
|
-
30,
|
|
22377
|
-
31,
|
|
22378
|
-
31,
|
|
22379
|
-
30,
|
|
22380
|
-
31,
|
|
22381
|
-
30,
|
|
22382
|
-
31
|
|
22383
|
-
],
|
|
22384
|
-
firstDayOfWeek: 0,
|
|
22385
|
-
ordinal: function ordinal(nth) {
|
|
22386
|
-
var s = nth % 100;
|
|
22387
|
-
if (s > 3 && s < 21) return "th";
|
|
22388
|
-
switch(s % 10){
|
|
22389
|
-
case 1:
|
|
22390
|
-
return "st";
|
|
22391
|
-
case 2:
|
|
22392
|
-
return "nd";
|
|
22393
|
-
case 3:
|
|
22394
|
-
return "rd";
|
|
22395
|
-
default:
|
|
22396
|
-
return "th";
|
|
22397
|
-
}
|
|
22398
|
-
},
|
|
22399
|
-
rangeSeparator: " to ",
|
|
22400
|
-
weekAbbreviation: "Wk",
|
|
22401
|
-
scrollTitle: "Scroll to increment",
|
|
22402
|
-
toggleTitle: "Click to toggle",
|
|
22403
|
-
amPM: [
|
|
22404
|
-
"AM",
|
|
22405
|
-
"PM"
|
|
22406
|
-
],
|
|
22407
|
-
yearAriaLabel: "Year",
|
|
22408
|
-
monthAriaLabel: "Month",
|
|
22409
|
-
hourAriaLabel: "Hour",
|
|
22410
|
-
minuteAriaLabel: "Minute",
|
|
22411
|
-
time_24hr: false
|
|
22412
|
-
};
|
|
22413
|
-
|
|
22414
|
-
function _instanceof$2(left, right) {
|
|
22415
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
22416
|
-
return !!right[Symbol.hasInstance](left);
|
|
22417
|
-
} else {
|
|
22418
|
-
return left instanceof right;
|
|
22419
|
-
}
|
|
22420
|
-
}
|
|
22421
|
-
var pad = function pad(number, length) {
|
|
22422
|
-
if (length === void 0) {
|
|
22423
|
-
length = 2;
|
|
22424
|
-
}
|
|
22425
|
-
return ("000" + number).slice(length * -1);
|
|
22426
|
-
};
|
|
22427
|
-
var int = function int(bool) {
|
|
22428
|
-
return bool === true ? 1 : 0;
|
|
22429
|
-
};
|
|
22430
|
-
function debounce(fn, wait) {
|
|
22431
|
-
var t;
|
|
22432
|
-
return function() {
|
|
22433
|
-
var _this = this;
|
|
22434
|
-
var args = arguments;
|
|
22435
|
-
clearTimeout(t);
|
|
22436
|
-
t = setTimeout(function() {
|
|
22437
|
-
return fn.apply(_this, args);
|
|
22438
|
-
}, wait);
|
|
22439
|
-
};
|
|
22440
|
-
}
|
|
22441
|
-
var arrayify = function arrayify(obj) {
|
|
22442
|
-
return _instanceof$2(obj, Array) ? obj : [
|
|
22443
|
-
obj
|
|
22444
|
-
];
|
|
22445
|
-
};
|
|
22446
|
-
|
|
22447
|
-
function toggleClass(elem, className, bool) {
|
|
22448
|
-
if (bool === true) return elem.classList.add(className);
|
|
22449
|
-
elem.classList.remove(className);
|
|
22450
|
-
}
|
|
22451
|
-
function createElement(tag, className, content) {
|
|
22452
|
-
var e = window.document.createElement(tag);
|
|
22453
|
-
className = className || "";
|
|
22454
|
-
content = content || "";
|
|
22455
|
-
e.className = className;
|
|
22456
|
-
if (content !== undefined) e.textContent = content;
|
|
22457
|
-
return e;
|
|
22458
|
-
}
|
|
22459
|
-
function clearNode(node) {
|
|
22460
|
-
while(node.firstChild)node.removeChild(node.firstChild);
|
|
22461
|
-
}
|
|
22462
|
-
function findParent(node, condition) {
|
|
22463
|
-
if (condition(node)) return node;
|
|
22464
|
-
else if (node.parentNode) return findParent(node.parentNode, condition);
|
|
22465
|
-
return undefined;
|
|
22466
|
-
}
|
|
22467
|
-
function createNumberInput(inputClassName, opts) {
|
|
22468
|
-
var wrapper = createElement("div", "numInputWrapper"), numInput = createElement("input", "numInput " + inputClassName), arrowUp = createElement("span", "arrowUp"), arrowDown = createElement("span", "arrowDown");
|
|
22469
|
-
if (navigator.userAgent.indexOf("MSIE 9.0") === -1) {
|
|
22470
|
-
numInput.type = "number";
|
|
22471
|
-
} else {
|
|
22472
|
-
numInput.type = "text";
|
|
22473
|
-
numInput.pattern = "\\d*";
|
|
22474
|
-
}
|
|
22475
|
-
if (opts !== undefined) for(var key in opts)numInput.setAttribute(key, opts[key]);
|
|
22476
|
-
wrapper.appendChild(numInput);
|
|
22477
|
-
wrapper.appendChild(arrowUp);
|
|
22478
|
-
wrapper.appendChild(arrowDown);
|
|
22479
|
-
return wrapper;
|
|
22480
|
-
}
|
|
22481
|
-
function getEventTarget(event) {
|
|
22482
|
-
try {
|
|
22483
|
-
if (typeof event.composedPath === "function") {
|
|
22484
|
-
var path = event.composedPath();
|
|
22485
|
-
return path[0];
|
|
22486
|
-
}
|
|
22487
|
-
return event.target;
|
|
22488
|
-
} catch (error) {
|
|
22489
|
-
return event.target;
|
|
22490
|
-
}
|
|
22491
|
-
}
|
|
22492
|
-
|
|
22493
|
-
var doNothing = function doNothing() {
|
|
22494
|
-
return undefined;
|
|
22495
|
-
};
|
|
22496
|
-
var monthToStr = function monthToStr(monthNumber, shorthand, locale) {
|
|
22497
|
-
return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber];
|
|
22498
|
-
};
|
|
22499
|
-
var revFormat = {
|
|
22500
|
-
D: doNothing,
|
|
22501
|
-
F: function F(dateObj, monthName, locale) {
|
|
22502
|
-
dateObj.setMonth(locale.months.longhand.indexOf(monthName));
|
|
22503
|
-
},
|
|
22504
|
-
G: function G(dateObj, hour) {
|
|
22505
|
-
dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + parseFloat(hour));
|
|
22506
|
-
},
|
|
22507
|
-
H: function H(dateObj, hour) {
|
|
22508
|
-
dateObj.setHours(parseFloat(hour));
|
|
22509
|
-
},
|
|
22510
|
-
J: function J(dateObj, day) {
|
|
22511
|
-
dateObj.setDate(parseFloat(day));
|
|
22512
|
-
},
|
|
22513
|
-
K: function K(dateObj, amPM, locale) {
|
|
22514
|
-
dateObj.setHours(dateObj.getHours() % 12 + 12 * int(new RegExp(locale.amPM[1], "i").test(amPM)));
|
|
22515
|
-
},
|
|
22516
|
-
M: function M(dateObj, shortMonth, locale) {
|
|
22517
|
-
dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth));
|
|
22518
|
-
},
|
|
22519
|
-
S: function S(dateObj, seconds) {
|
|
22520
|
-
dateObj.setSeconds(parseFloat(seconds));
|
|
22521
|
-
},
|
|
22522
|
-
U: function U(_, unixSeconds) {
|
|
22523
|
-
return new Date(parseFloat(unixSeconds) * 1000);
|
|
22524
|
-
},
|
|
22525
|
-
W: function W(dateObj, weekNum, locale) {
|
|
22526
|
-
var weekNumber = parseInt(weekNum);
|
|
22527
|
-
var date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
|
|
22528
|
-
date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek);
|
|
22529
|
-
return date;
|
|
22530
|
-
},
|
|
22531
|
-
Y: function Y(dateObj, year) {
|
|
22532
|
-
dateObj.setFullYear(parseFloat(year));
|
|
22533
|
-
},
|
|
22534
|
-
Z: function Z(_, ISODate) {
|
|
22535
|
-
return new Date(ISODate);
|
|
22536
|
-
},
|
|
22537
|
-
d: function d(dateObj, day) {
|
|
22538
|
-
dateObj.setDate(parseFloat(day));
|
|
22539
|
-
},
|
|
22540
|
-
h: function h(dateObj, hour) {
|
|
22541
|
-
dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + parseFloat(hour));
|
|
22542
|
-
},
|
|
22543
|
-
i: function i(dateObj, minutes) {
|
|
22544
|
-
dateObj.setMinutes(parseFloat(minutes));
|
|
22545
|
-
},
|
|
22546
|
-
j: function j(dateObj, day) {
|
|
22547
|
-
dateObj.setDate(parseFloat(day));
|
|
22548
|
-
},
|
|
22549
|
-
l: doNothing,
|
|
22550
|
-
m: function m(dateObj, month) {
|
|
22551
|
-
dateObj.setMonth(parseFloat(month) - 1);
|
|
22552
|
-
},
|
|
22553
|
-
n: function n(dateObj, month) {
|
|
22554
|
-
dateObj.setMonth(parseFloat(month) - 1);
|
|
22555
|
-
},
|
|
22556
|
-
s: function s(dateObj, seconds) {
|
|
22557
|
-
dateObj.setSeconds(parseFloat(seconds));
|
|
22558
|
-
},
|
|
22559
|
-
u: function u(_, unixMillSeconds) {
|
|
22560
|
-
return new Date(parseFloat(unixMillSeconds));
|
|
22561
|
-
},
|
|
22562
|
-
w: doNothing,
|
|
22563
|
-
y: function y(dateObj, year) {
|
|
22564
|
-
dateObj.setFullYear(2000 + parseFloat(year));
|
|
22565
|
-
}
|
|
22566
|
-
};
|
|
22567
|
-
var tokenRegex = {
|
|
22568
|
-
D: "",
|
|
22569
|
-
F: "",
|
|
22570
|
-
G: "(\\d\\d|\\d)",
|
|
22571
|
-
H: "(\\d\\d|\\d)",
|
|
22572
|
-
J: "(\\d\\d|\\d)\\w+",
|
|
22573
|
-
K: "",
|
|
22574
|
-
M: "",
|
|
22575
|
-
S: "(\\d\\d|\\d)",
|
|
22576
|
-
U: "(.+)",
|
|
22577
|
-
W: "(\\d\\d|\\d)",
|
|
22578
|
-
Y: "(\\d{4})",
|
|
22579
|
-
Z: "(.+)",
|
|
22580
|
-
d: "(\\d\\d|\\d)",
|
|
22581
|
-
h: "(\\d\\d|\\d)",
|
|
22582
|
-
i: "(\\d\\d|\\d)",
|
|
22583
|
-
j: "(\\d\\d|\\d)",
|
|
22584
|
-
l: "",
|
|
22585
|
-
m: "(\\d\\d|\\d)",
|
|
22586
|
-
n: "(\\d\\d|\\d)",
|
|
22587
|
-
s: "(\\d\\d|\\d)",
|
|
22588
|
-
u: "(.+)",
|
|
22589
|
-
w: "(\\d\\d|\\d)",
|
|
22590
|
-
y: "(\\d{2})"
|
|
22591
|
-
};
|
|
22592
|
-
var formats = {
|
|
22593
|
-
Z: function Z(date) {
|
|
22594
|
-
return date.toISOString();
|
|
22595
|
-
},
|
|
22596
|
-
D: function D(date, locale, options) {
|
|
22597
|
-
return locale.weekdays.shorthand[formats.w(date, locale, options)];
|
|
22598
|
-
},
|
|
22599
|
-
F: function F(date, locale, options) {
|
|
22600
|
-
return monthToStr(formats.n(date, locale, options) - 1, false, locale);
|
|
22601
|
-
},
|
|
22602
|
-
G: function G(date, locale, options) {
|
|
22603
|
-
return pad(formats.h(date, locale, options));
|
|
22604
|
-
},
|
|
22605
|
-
H: function H(date) {
|
|
22606
|
-
return pad(date.getHours());
|
|
22607
|
-
},
|
|
22608
|
-
J: function J(date, locale) {
|
|
22609
|
-
return locale.ordinal !== undefined ? date.getDate() + locale.ordinal(date.getDate()) : date.getDate();
|
|
22610
|
-
},
|
|
22611
|
-
K: function K(date, locale) {
|
|
22612
|
-
return locale.amPM[int(date.getHours() > 11)];
|
|
22613
|
-
},
|
|
22614
|
-
M: function M(date, locale) {
|
|
22615
|
-
return monthToStr(date.getMonth(), true, locale);
|
|
22616
|
-
},
|
|
22617
|
-
S: function S(date) {
|
|
22618
|
-
return pad(date.getSeconds());
|
|
22619
|
-
},
|
|
22620
|
-
U: function U(date) {
|
|
22621
|
-
return date.getTime() / 1000;
|
|
22622
|
-
},
|
|
22623
|
-
W: function W(date, _, options) {
|
|
22624
|
-
return options.getWeek(date);
|
|
22625
|
-
},
|
|
22626
|
-
Y: function Y(date) {
|
|
22627
|
-
return pad(date.getFullYear(), 4);
|
|
22628
|
-
},
|
|
22629
|
-
d: function d(date) {
|
|
22630
|
-
return pad(date.getDate());
|
|
22631
|
-
},
|
|
22632
|
-
h: function h(date) {
|
|
22633
|
-
return date.getHours() % 12 ? date.getHours() % 12 : 12;
|
|
22634
|
-
},
|
|
22635
|
-
i: function i(date) {
|
|
22636
|
-
return pad(date.getMinutes());
|
|
22637
|
-
},
|
|
22638
|
-
j: function j(date) {
|
|
22639
|
-
return date.getDate();
|
|
22640
|
-
},
|
|
22641
|
-
l: function l(date, locale) {
|
|
22642
|
-
return locale.weekdays.longhand[date.getDay()];
|
|
22643
|
-
},
|
|
22644
|
-
m: function m(date) {
|
|
22645
|
-
return pad(date.getMonth() + 1);
|
|
22646
|
-
},
|
|
22647
|
-
n: function n(date) {
|
|
22648
|
-
return date.getMonth() + 1;
|
|
22649
|
-
},
|
|
22650
|
-
s: function s(date) {
|
|
22651
|
-
return date.getSeconds();
|
|
22652
|
-
},
|
|
22653
|
-
u: function u(date) {
|
|
22654
|
-
return date.getTime();
|
|
22655
|
-
},
|
|
22656
|
-
w: function w(date) {
|
|
22657
|
-
return date.getDay();
|
|
22658
|
-
},
|
|
22659
|
-
y: function y(date) {
|
|
22660
|
-
return String(date.getFullYear()).substring(2);
|
|
22661
|
-
}
|
|
22662
|
-
};
|
|
22663
|
-
|
|
22664
|
-
function _instanceof$1(left, right) {
|
|
22665
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
22666
|
-
return !!right[Symbol.hasInstance](left);
|
|
22667
|
-
} else {
|
|
22668
|
-
return left instanceof right;
|
|
22669
|
-
}
|
|
22670
|
-
}
|
|
22671
|
-
var createDateFormatter = function createDateFormatter(_a) {
|
|
22672
|
-
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;
|
|
22673
|
-
return function(dateObj, frmt, overrideLocale) {
|
|
22674
|
-
var locale = overrideLocale || l10n;
|
|
22675
|
-
if (config.formatDate !== undefined && !isMobile) {
|
|
22676
|
-
return config.formatDate(dateObj, frmt, locale);
|
|
22677
|
-
}
|
|
22678
|
-
return frmt.split("").map(function(c, i, arr) {
|
|
22679
|
-
return formats[c] && arr[i - 1] !== "\\" ? formats[c](dateObj, locale, config) : c !== "\\" ? c : "";
|
|
22680
|
-
}).join("");
|
|
22681
|
-
};
|
|
22682
|
-
};
|
|
22683
|
-
var createDateParser = function createDateParser(_a) {
|
|
22684
|
-
var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
|
|
22685
|
-
return function(date, givenFormat, timeless, customLocale) {
|
|
22686
|
-
if (date !== 0 && !date) return undefined;
|
|
22687
|
-
var locale = customLocale || l10n;
|
|
22688
|
-
var parsedDate;
|
|
22689
|
-
var dateOrig = date;
|
|
22690
|
-
if (_instanceof$1(date, Date)) parsedDate = new Date(date.getTime());
|
|
22691
|
-
else if (typeof date !== "string" && date.toFixed !== undefined) parsedDate = new Date(date);
|
|
22692
|
-
else if (typeof date === "string") {
|
|
22693
|
-
var format = givenFormat || (config || defaults).dateFormat;
|
|
22694
|
-
var datestr = String(date).trim();
|
|
22695
|
-
if (datestr === "today") {
|
|
22696
|
-
parsedDate = new Date();
|
|
22697
|
-
timeless = true;
|
|
22698
|
-
} else if (config && config.parseDate) {
|
|
22699
|
-
parsedDate = config.parseDate(date, format);
|
|
22700
|
-
} else if (/Z$/.test(datestr) || /GMT$/.test(datestr)) {
|
|
22701
|
-
parsedDate = new Date(date);
|
|
22702
|
-
} else {
|
|
22703
|
-
var matched = void 0, ops = [];
|
|
22704
|
-
for(var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++){
|
|
22705
|
-
var token = format[i];
|
|
22706
|
-
var isBackSlash = token === "\\";
|
|
22707
|
-
var escaped = format[i - 1] === "\\" || isBackSlash;
|
|
22708
|
-
if (tokenRegex[token] && !escaped) {
|
|
22709
|
-
regexStr += tokenRegex[token];
|
|
22710
|
-
var match = new RegExp(regexStr).exec(date);
|
|
22711
|
-
if (match && (matched = true)) {
|
|
22712
|
-
ops[token !== "Y" ? "push" : "unshift"]({
|
|
22713
|
-
fn: revFormat[token],
|
|
22714
|
-
val: match[++matchIndex]
|
|
22715
|
-
});
|
|
22716
|
-
}
|
|
22717
|
-
} else if (!isBackSlash) regexStr += ".";
|
|
22718
|
-
}
|
|
22719
|
-
parsedDate = !config || !config.noCalendar ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0) : new Date(new Date().setHours(0, 0, 0, 0));
|
|
22720
|
-
ops.forEach(function(_a) {
|
|
22721
|
-
var fn = _a.fn, val = _a.val;
|
|
22722
|
-
return parsedDate = fn(parsedDate, val, locale) || parsedDate;
|
|
22723
|
-
});
|
|
22724
|
-
parsedDate = matched ? parsedDate : undefined;
|
|
22725
|
-
}
|
|
22726
|
-
}
|
|
22727
|
-
if (!(_instanceof$1(parsedDate, Date) && !isNaN(parsedDate.getTime()))) {
|
|
22728
|
-
config.errorHandler(new Error("Invalid date provided: " + dateOrig));
|
|
22729
|
-
return undefined;
|
|
22730
|
-
}
|
|
22731
|
-
if (timeless === true) parsedDate.setHours(0, 0, 0, 0);
|
|
22732
|
-
return parsedDate;
|
|
22733
|
-
};
|
|
22734
|
-
};
|
|
22735
|
-
function compareDates(date1, date2, timeless) {
|
|
22736
|
-
if (timeless === void 0) {
|
|
22737
|
-
timeless = true;
|
|
22738
|
-
}
|
|
22739
|
-
if (timeless !== false) {
|
|
22740
|
-
return new Date(date1.getTime()).setHours(0, 0, 0, 0) - new Date(date2.getTime()).setHours(0, 0, 0, 0);
|
|
22741
|
-
}
|
|
22742
|
-
return date1.getTime() - date2.getTime();
|
|
22743
|
-
}
|
|
22744
|
-
var isBetween = function isBetween(ts, ts1, ts2) {
|
|
22745
|
-
return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2);
|
|
22746
|
-
};
|
|
22747
|
-
var calculateSecondsSinceMidnight = function calculateSecondsSinceMidnight(hours, minutes, seconds) {
|
|
22748
|
-
return hours * 3600 + minutes * 60 + seconds;
|
|
22749
|
-
};
|
|
22750
|
-
var parseSeconds = function parseSeconds(secondsSinceMidnight) {
|
|
22751
|
-
var hours = Math.floor(secondsSinceMidnight / 3600), minutes = (secondsSinceMidnight - hours * 3600) / 60;
|
|
22752
|
-
return [
|
|
22753
|
-
hours,
|
|
22754
|
-
minutes,
|
|
22755
|
-
secondsSinceMidnight - hours * 3600 - minutes * 60
|
|
22756
|
-
];
|
|
22757
|
-
};
|
|
22758
|
-
var duration = {
|
|
22759
|
-
DAY: 86400000
|
|
22760
|
-
};
|
|
22761
|
-
function getDefaultHours(config) {
|
|
22762
|
-
var hours = config.defaultHour;
|
|
22763
|
-
var minutes = config.defaultMinute;
|
|
22764
|
-
var seconds = config.defaultSeconds;
|
|
22765
|
-
if (config.minDate !== undefined) {
|
|
22766
|
-
var minHour = config.minDate.getHours();
|
|
22767
|
-
var minMinutes = config.minDate.getMinutes();
|
|
22768
|
-
var minSeconds = config.minDate.getSeconds();
|
|
22769
|
-
if (hours < minHour) {
|
|
22770
|
-
hours = minHour;
|
|
22771
|
-
}
|
|
22772
|
-
if (hours === minHour && minutes < minMinutes) {
|
|
22773
|
-
minutes = minMinutes;
|
|
22774
|
-
}
|
|
22775
|
-
if (hours === minHour && minutes === minMinutes && seconds < minSeconds) seconds = config.minDate.getSeconds();
|
|
22776
|
-
}
|
|
22777
|
-
if (config.maxDate !== undefined) {
|
|
22778
|
-
var maxHr = config.maxDate.getHours();
|
|
22779
|
-
var maxMinutes = config.maxDate.getMinutes();
|
|
22780
|
-
hours = Math.min(hours, maxHr);
|
|
22781
|
-
if (hours === maxHr) minutes = Math.min(maxMinutes, minutes);
|
|
22782
|
-
if (hours === maxHr && minutes === maxMinutes) seconds = config.maxDate.getSeconds();
|
|
22783
|
-
}
|
|
22784
|
-
return {
|
|
22785
|
-
hours: hours,
|
|
22786
|
-
minutes: minutes,
|
|
22787
|
-
seconds: seconds
|
|
22788
|
-
};
|
|
22789
|
-
}
|
|
22790
|
-
|
|
22791
|
-
if (typeof Object.assign !== "function") {
|
|
22792
|
-
Object.assign = function(target) {
|
|
22793
|
-
var args = [];
|
|
22794
|
-
for(var _i = 1; _i < arguments.length; _i++){
|
|
22795
|
-
args[_i - 1] = arguments[_i];
|
|
22796
|
-
}
|
|
22797
|
-
if (!target) {
|
|
22798
|
-
throw TypeError("Cannot convert undefined or null to object");
|
|
22799
|
-
}
|
|
22800
|
-
var _loop_1 = function _loop_1(source) {
|
|
22801
|
-
if (source) {
|
|
22802
|
-
Object.keys(source).forEach(function(key) {
|
|
22803
|
-
return target[key] = source[key];
|
|
22804
|
-
});
|
|
22805
|
-
}
|
|
22806
|
-
};
|
|
22807
|
-
for(var _a = 0, args_1 = args; _a < args_1.length; _a++){
|
|
22808
|
-
var source = args_1[_a];
|
|
22809
|
-
_loop_1(source);
|
|
22810
|
-
}
|
|
22811
|
-
return target;
|
|
22812
|
-
};
|
|
22813
|
-
}
|
|
22814
|
-
|
|
22815
|
-
function _instanceof(left, right) {
|
|
22816
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
22817
|
-
return !!right[Symbol.hasInstance](left);
|
|
22818
|
-
} else {
|
|
22819
|
-
return left instanceof right;
|
|
22820
|
-
}
|
|
22821
|
-
}
|
|
22822
|
-
var __assign = undefined && undefined.__assign || function() {
|
|
22823
|
-
__assign = Object.assign || function(t) {
|
|
22824
|
-
for(var s, i = 1, n = arguments.length; i < n; i++){
|
|
22825
|
-
s = arguments[i];
|
|
22826
|
-
for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
22827
|
-
}
|
|
22828
|
-
return t;
|
|
22829
|
-
};
|
|
22830
|
-
return __assign.apply(this, arguments);
|
|
22831
|
-
};
|
|
22832
|
-
var __spreadArrays = undefined && undefined.__spreadArrays || function() {
|
|
22833
|
-
for(var s = 0, i = 0, il = arguments.length; i < il; i++)s += arguments[i].length;
|
|
22834
|
-
for(var r = Array(s), k = 0, i = 0; i < il; i++)for(var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)r[k] = a[j];
|
|
22835
|
-
return r;
|
|
22836
|
-
};
|
|
22837
|
-
var DEBOUNCED_CHANGE_MS = 300;
|
|
22838
|
-
function FlatpickrInstance(element, instanceConfig) {
|
|
22839
|
-
var self = {
|
|
22840
|
-
config: __assign(__assign({}, defaults), flatpickr.defaultConfig),
|
|
22841
|
-
l10n: english
|
|
22842
|
-
};
|
|
22843
|
-
self.parseDate = createDateParser({
|
|
22844
|
-
config: self.config,
|
|
22845
|
-
l10n: self.l10n
|
|
22846
|
-
});
|
|
22847
|
-
self._handlers = [];
|
|
22848
|
-
self.pluginElements = [];
|
|
22849
|
-
self.loadedPlugins = [];
|
|
22850
|
-
self._bind = bind;
|
|
22851
|
-
self._setHoursFromDate = setHoursFromDate;
|
|
22852
|
-
self._positionCalendar = positionCalendar;
|
|
22853
|
-
self.changeMonth = changeMonth;
|
|
22854
|
-
self.changeYear = changeYear;
|
|
22855
|
-
self.clear = clear;
|
|
22856
|
-
self.close = close;
|
|
22857
|
-
self.onMouseOver = onMouseOver;
|
|
22858
|
-
self._createElement = createElement;
|
|
22859
|
-
self.createDay = createDay;
|
|
22860
|
-
self.destroy = destroy;
|
|
22861
|
-
self.isEnabled = isEnabled;
|
|
22862
|
-
self.jumpToDate = jumpToDate;
|
|
22863
|
-
self.updateValue = updateValue;
|
|
22864
|
-
self.open = open;
|
|
22865
|
-
self.redraw = redraw;
|
|
22866
|
-
self.set = set;
|
|
22867
|
-
self.setDate = setDate;
|
|
22868
|
-
self.toggle = toggle;
|
|
22869
|
-
function setupHelperFunctions() {
|
|
22870
|
-
self.utils = {
|
|
22871
|
-
getDaysInMonth: function getDaysInMonth(month, yr) {
|
|
22872
|
-
if (month === void 0) {
|
|
22873
|
-
month = self.currentMonth;
|
|
22874
|
-
}
|
|
22875
|
-
if (yr === void 0) {
|
|
22876
|
-
yr = self.currentYear;
|
|
22877
|
-
}
|
|
22878
|
-
if (month === 1 && (yr % 4 === 0 && yr % 100 !== 0 || yr % 400 === 0)) return 29;
|
|
22879
|
-
return self.l10n.daysInMonth[month];
|
|
22880
|
-
}
|
|
22881
|
-
};
|
|
22882
|
-
}
|
|
22883
|
-
function init() {
|
|
22884
|
-
self.element = self.input = element;
|
|
22885
|
-
self.isOpen = false;
|
|
22886
|
-
parseConfig();
|
|
22887
|
-
setupLocale();
|
|
22888
|
-
setupInputs();
|
|
22889
|
-
setupDates();
|
|
22890
|
-
setupHelperFunctions();
|
|
22891
|
-
if (!self.isMobile) build();
|
|
22892
|
-
bindEvents();
|
|
22893
|
-
if (self.selectedDates.length || self.config.noCalendar) {
|
|
22894
|
-
if (self.config.enableTime) {
|
|
22895
|
-
setHoursFromDate(self.config.noCalendar ? self.latestSelectedDateObj : undefined);
|
|
22896
|
-
}
|
|
22897
|
-
updateValue(false);
|
|
22898
|
-
}
|
|
22899
|
-
setCalendarWidth();
|
|
22900
|
-
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
22901
|
-
if (!self.isMobile && isSafari) {
|
|
22902
|
-
positionCalendar();
|
|
22903
|
-
}
|
|
22904
|
-
triggerEvent("onReady");
|
|
22905
|
-
}
|
|
22906
|
-
function getClosestActiveElement() {
|
|
22907
|
-
var _a;
|
|
22908
|
-
return ((_a = self.calendarContainer) === null || _a === void 0 ? void 0 : _a.getRootNode()).activeElement || document.activeElement;
|
|
22909
|
-
}
|
|
22910
|
-
function bindToInstance(fn) {
|
|
22911
|
-
return fn.bind(self);
|
|
22912
|
-
}
|
|
22913
|
-
function setCalendarWidth() {
|
|
22914
|
-
var config = self.config;
|
|
22915
|
-
if (config.weekNumbers === false && config.showMonths === 1) {
|
|
22916
|
-
return;
|
|
22917
|
-
} else if (config.noCalendar !== true) {
|
|
22918
|
-
window.requestAnimationFrame(function() {
|
|
22919
|
-
if (self.calendarContainer !== undefined) {
|
|
22920
|
-
self.calendarContainer.style.visibility = "hidden";
|
|
22921
|
-
self.calendarContainer.style.display = "block";
|
|
22922
|
-
}
|
|
22923
|
-
if (self.daysContainer !== undefined) {
|
|
22924
|
-
var daysWidth = (self.days.offsetWidth + 1) * config.showMonths;
|
|
22925
|
-
self.daysContainer.style.width = daysWidth + "px";
|
|
22926
|
-
self.calendarContainer.style.width = daysWidth + (self.weekWrapper !== undefined ? self.weekWrapper.offsetWidth : 0) + "px";
|
|
22927
|
-
self.calendarContainer.style.removeProperty("visibility");
|
|
22928
|
-
self.calendarContainer.style.removeProperty("display");
|
|
22929
|
-
}
|
|
22930
|
-
});
|
|
22931
|
-
}
|
|
22932
|
-
}
|
|
22933
|
-
function updateTime(e) {
|
|
22934
|
-
if (self.selectedDates.length === 0) {
|
|
22935
|
-
var defaultDate = self.config.minDate === undefined || compareDates(new Date(), self.config.minDate) >= 0 ? new Date() : new Date(self.config.minDate.getTime());
|
|
22936
|
-
var defaults = getDefaultHours(self.config);
|
|
22937
|
-
defaultDate.setHours(defaults.hours, defaults.minutes, defaults.seconds, defaultDate.getMilliseconds());
|
|
22938
|
-
self.selectedDates = [
|
|
22939
|
-
defaultDate
|
|
22940
|
-
];
|
|
22941
|
-
self.latestSelectedDateObj = defaultDate;
|
|
22942
|
-
}
|
|
22943
|
-
if (e !== undefined && e.type !== "blur") {
|
|
22944
|
-
timeWrapper(e);
|
|
22945
|
-
}
|
|
22946
|
-
var prevValue = self._input.value;
|
|
22947
|
-
setHoursFromInputs();
|
|
22948
|
-
updateValue();
|
|
22949
|
-
if (self._input.value !== prevValue) {
|
|
22950
|
-
self._debouncedChange();
|
|
22951
|
-
}
|
|
22952
|
-
}
|
|
22953
|
-
function ampm2military(hour, amPM) {
|
|
22954
|
-
return hour % 12 + 12 * int(amPM === self.l10n.amPM[1]);
|
|
22955
|
-
}
|
|
22956
|
-
function military2ampm(hour) {
|
|
22957
|
-
switch(hour % 24){
|
|
22958
|
-
case 0:
|
|
22959
|
-
case 12:
|
|
22960
|
-
return 12;
|
|
22961
|
-
default:
|
|
22962
|
-
return hour % 12;
|
|
22963
|
-
}
|
|
22964
|
-
}
|
|
22965
|
-
function setHoursFromInputs() {
|
|
22966
|
-
if (self.hourElement === undefined || self.minuteElement === undefined) return;
|
|
22967
|
-
var hours = (parseInt(self.hourElement.value.slice(-2), 10) || 0) % 24, minutes = (parseInt(self.minuteElement.value, 10) || 0) % 60, seconds = self.secondElement !== undefined ? (parseInt(self.secondElement.value, 10) || 0) % 60 : 0;
|
|
22968
|
-
if (self.amPM !== undefined) {
|
|
22969
|
-
hours = ampm2military(hours, self.amPM.textContent);
|
|
22970
|
-
}
|
|
22971
|
-
var limitMinHours = self.config.minTime !== undefined || self.config.minDate && self.minDateHasTime && self.latestSelectedDateObj && compareDates(self.latestSelectedDateObj, self.config.minDate, true) === 0;
|
|
22972
|
-
var limitMaxHours = self.config.maxTime !== undefined || self.config.maxDate && self.maxDateHasTime && self.latestSelectedDateObj && compareDates(self.latestSelectedDateObj, self.config.maxDate, true) === 0;
|
|
22973
|
-
if (self.config.maxTime !== undefined && self.config.minTime !== undefined && self.config.minTime > self.config.maxTime) {
|
|
22974
|
-
var minBound = calculateSecondsSinceMidnight(self.config.minTime.getHours(), self.config.minTime.getMinutes(), self.config.minTime.getSeconds());
|
|
22975
|
-
var maxBound = calculateSecondsSinceMidnight(self.config.maxTime.getHours(), self.config.maxTime.getMinutes(), self.config.maxTime.getSeconds());
|
|
22976
|
-
var currentTime = calculateSecondsSinceMidnight(hours, minutes, seconds);
|
|
22977
|
-
if (currentTime > maxBound && currentTime < minBound) {
|
|
22978
|
-
var result = parseSeconds(minBound);
|
|
22979
|
-
hours = result[0];
|
|
22980
|
-
minutes = result[1];
|
|
22981
|
-
seconds = result[2];
|
|
22982
|
-
}
|
|
22983
|
-
} else {
|
|
22984
|
-
if (limitMaxHours) {
|
|
22985
|
-
var maxTime = self.config.maxTime !== undefined ? self.config.maxTime : self.config.maxDate;
|
|
22986
|
-
hours = Math.min(hours, maxTime.getHours());
|
|
22987
|
-
if (hours === maxTime.getHours()) minutes = Math.min(minutes, maxTime.getMinutes());
|
|
22988
|
-
if (minutes === maxTime.getMinutes()) seconds = Math.min(seconds, maxTime.getSeconds());
|
|
22989
|
-
}
|
|
22990
|
-
if (limitMinHours) {
|
|
22991
|
-
var minTime = self.config.minTime !== undefined ? self.config.minTime : self.config.minDate;
|
|
22992
|
-
hours = Math.max(hours, minTime.getHours());
|
|
22993
|
-
if (hours === minTime.getHours() && minutes < minTime.getMinutes()) minutes = minTime.getMinutes();
|
|
22994
|
-
if (minutes === minTime.getMinutes()) seconds = Math.max(seconds, minTime.getSeconds());
|
|
22995
|
-
}
|
|
22996
|
-
}
|
|
22997
|
-
setHours(hours, minutes, seconds);
|
|
22998
|
-
}
|
|
22999
|
-
function setHoursFromDate(dateObj) {
|
|
23000
|
-
var date = dateObj || self.latestSelectedDateObj;
|
|
23001
|
-
if (date && _instanceof(date, Date)) {
|
|
23002
|
-
setHours(date.getHours(), date.getMinutes(), date.getSeconds());
|
|
23003
|
-
}
|
|
23004
|
-
}
|
|
23005
|
-
function setHours(hours, minutes, seconds) {
|
|
23006
|
-
if (self.latestSelectedDateObj !== undefined) {
|
|
23007
|
-
self.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0);
|
|
23008
|
-
}
|
|
23009
|
-
if (!self.hourElement || !self.minuteElement || self.isMobile) return;
|
|
23010
|
-
self.hourElement.value = pad(!self.config.time_24hr ? (12 + hours) % 12 + 12 * int(hours % 12 === 0) : hours);
|
|
23011
|
-
self.minuteElement.value = pad(minutes);
|
|
23012
|
-
if (self.amPM !== undefined) self.amPM.textContent = self.l10n.amPM[int(hours >= 12)];
|
|
23013
|
-
if (self.secondElement !== undefined) self.secondElement.value = pad(seconds);
|
|
23014
|
-
}
|
|
23015
|
-
function onYearInput(event) {
|
|
23016
|
-
var eventTarget = getEventTarget(event);
|
|
23017
|
-
var year = parseInt(eventTarget.value) + (event.delta || 0);
|
|
23018
|
-
if (year / 1000 > 1 || event.key === "Enter" && !/[^\d]/.test(year.toString())) {
|
|
23019
|
-
changeYear(year);
|
|
23020
|
-
}
|
|
23021
|
-
}
|
|
23022
|
-
function bind(element, event, handler, options) {
|
|
23023
|
-
if (_instanceof(event, Array)) return event.forEach(function(ev) {
|
|
23024
|
-
return bind(element, ev, handler, options);
|
|
23025
|
-
});
|
|
23026
|
-
if (_instanceof(element, Array)) return element.forEach(function(el) {
|
|
23027
|
-
return bind(el, event, handler, options);
|
|
23028
|
-
});
|
|
23029
|
-
element.addEventListener(event, handler, options);
|
|
23030
|
-
self._handlers.push({
|
|
23031
|
-
remove: function remove() {
|
|
23032
|
-
return element.removeEventListener(event, handler, options);
|
|
23033
|
-
}
|
|
23034
|
-
});
|
|
23035
|
-
}
|
|
23036
|
-
function triggerChange() {
|
|
23037
|
-
triggerEvent("onChange");
|
|
23038
|
-
}
|
|
23039
|
-
function bindEvents() {
|
|
23040
|
-
if (self.config.wrap) {
|
|
23041
|
-
[
|
|
23042
|
-
"open",
|
|
23043
|
-
"close",
|
|
23044
|
-
"toggle",
|
|
23045
|
-
"clear"
|
|
23046
|
-
].forEach(function(evt) {
|
|
23047
|
-
Array.prototype.forEach.call(self.element.querySelectorAll("[data-" + evt + "]"), function(el) {
|
|
23048
|
-
return bind(el, "click", self[evt]);
|
|
23049
|
-
});
|
|
23050
|
-
});
|
|
23051
|
-
}
|
|
23052
|
-
if (self.isMobile) {
|
|
23053
|
-
setupMobile();
|
|
23054
|
-
return;
|
|
23055
|
-
}
|
|
23056
|
-
var debouncedResize = debounce(onResize, 50);
|
|
23057
|
-
self._debouncedChange = debounce(triggerChange, DEBOUNCED_CHANGE_MS);
|
|
23058
|
-
if (self.daysContainer && !/iPhone|iPad|iPod/i.test(navigator.userAgent)) bind(self.daysContainer, "mouseover", function(e) {
|
|
23059
|
-
if (self.config.mode === "range") onMouseOver(getEventTarget(e));
|
|
23060
|
-
});
|
|
23061
|
-
bind(self._input, "keydown", onKeyDown);
|
|
23062
|
-
if (self.calendarContainer !== undefined) {
|
|
23063
|
-
bind(self.calendarContainer, "keydown", onKeyDown);
|
|
23064
|
-
}
|
|
23065
|
-
if (!self.config.inline && !self.config.static) bind(window, "resize", debouncedResize);
|
|
23066
|
-
if (window.ontouchstart !== undefined) bind(window.document, "touchstart", documentClick);
|
|
23067
|
-
else bind(window.document, "mousedown", documentClick);
|
|
23068
|
-
bind(window.document, "focus", documentClick, {
|
|
23069
|
-
capture: true
|
|
23070
|
-
});
|
|
23071
|
-
if (self.config.clickOpens === true) {
|
|
23072
|
-
bind(self._input, "focus", self.open);
|
|
23073
|
-
bind(self._input, "click", self.open);
|
|
23074
|
-
}
|
|
23075
|
-
if (self.daysContainer !== undefined) {
|
|
23076
|
-
bind(self.monthNav, "click", onMonthNavClick);
|
|
23077
|
-
bind(self.monthNav, [
|
|
23078
|
-
"keyup",
|
|
23079
|
-
"increment"
|
|
23080
|
-
], onYearInput);
|
|
23081
|
-
bind(self.daysContainer, "click", selectDate);
|
|
23082
|
-
}
|
|
23083
|
-
if (self.timeContainer !== undefined && self.minuteElement !== undefined && self.hourElement !== undefined) {
|
|
23084
|
-
var selText = function selText(e) {
|
|
23085
|
-
return getEventTarget(e).select();
|
|
23086
|
-
};
|
|
23087
|
-
bind(self.timeContainer, [
|
|
23088
|
-
"increment"
|
|
23089
|
-
], updateTime);
|
|
23090
|
-
bind(self.timeContainer, "blur", updateTime, {
|
|
23091
|
-
capture: true
|
|
23092
|
-
});
|
|
23093
|
-
bind(self.timeContainer, "click", timeIncrement);
|
|
23094
|
-
bind([
|
|
23095
|
-
self.hourElement,
|
|
23096
|
-
self.minuteElement
|
|
23097
|
-
], [
|
|
23098
|
-
"focus",
|
|
23099
|
-
"click"
|
|
23100
|
-
], selText);
|
|
23101
|
-
if (self.secondElement !== undefined) bind(self.secondElement, "focus", function() {
|
|
23102
|
-
return self.secondElement && self.secondElement.select();
|
|
23103
|
-
});
|
|
23104
|
-
if (self.amPM !== undefined) {
|
|
23105
|
-
bind(self.amPM, "click", function(e) {
|
|
23106
|
-
updateTime(e);
|
|
23107
|
-
});
|
|
23108
|
-
}
|
|
23109
|
-
}
|
|
23110
|
-
if (self.config.allowInput) {
|
|
23111
|
-
bind(self._input, "blur", onBlur);
|
|
23112
|
-
}
|
|
23113
|
-
}
|
|
23114
|
-
function jumpToDate(jumpDate, triggerChange) {
|
|
23115
|
-
var jumpTo = jumpDate !== undefined ? self.parseDate(jumpDate) : self.latestSelectedDateObj || (self.config.minDate && self.config.minDate > self.now ? self.config.minDate : self.config.maxDate && self.config.maxDate < self.now ? self.config.maxDate : self.now);
|
|
23116
|
-
var oldYear = self.currentYear;
|
|
23117
|
-
var oldMonth = self.currentMonth;
|
|
23118
|
-
try {
|
|
23119
|
-
if (jumpTo !== undefined) {
|
|
23120
|
-
self.currentYear = jumpTo.getFullYear();
|
|
23121
|
-
self.currentMonth = jumpTo.getMonth();
|
|
23122
|
-
}
|
|
23123
|
-
} catch (e) {
|
|
23124
|
-
e.message = "Invalid date supplied: " + jumpTo;
|
|
23125
|
-
self.config.errorHandler(e);
|
|
23126
|
-
}
|
|
23127
|
-
if (triggerChange && self.currentYear !== oldYear) {
|
|
23128
|
-
triggerEvent("onYearChange");
|
|
23129
|
-
buildMonthSwitch();
|
|
23130
|
-
}
|
|
23131
|
-
if (triggerChange && (self.currentYear !== oldYear || self.currentMonth !== oldMonth)) {
|
|
23132
|
-
triggerEvent("onMonthChange");
|
|
23133
|
-
}
|
|
23134
|
-
self.redraw();
|
|
23135
|
-
}
|
|
23136
|
-
function timeIncrement(e) {
|
|
23137
|
-
var eventTarget = getEventTarget(e);
|
|
23138
|
-
if (~eventTarget.className.indexOf("arrow")) incrementNumInput(e, eventTarget.classList.contains("arrowUp") ? 1 : -1);
|
|
23139
|
-
}
|
|
23140
|
-
function incrementNumInput(e, delta, inputElem) {
|
|
23141
|
-
var target = e && getEventTarget(e);
|
|
23142
|
-
var input = inputElem || target && target.parentNode && target.parentNode.firstChild;
|
|
23143
|
-
var event = createEvent("increment");
|
|
23144
|
-
event.delta = delta;
|
|
23145
|
-
input && input.dispatchEvent(event);
|
|
23146
|
-
}
|
|
23147
|
-
function build() {
|
|
23148
|
-
var fragment = window.document.createDocumentFragment();
|
|
23149
|
-
self.calendarContainer = createElement("div", "flatpickr-calendar");
|
|
23150
|
-
self.calendarContainer.tabIndex = -1;
|
|
23151
|
-
if (!self.config.noCalendar) {
|
|
23152
|
-
fragment.appendChild(buildMonthNav());
|
|
23153
|
-
self.innerContainer = createElement("div", "flatpickr-innerContainer");
|
|
23154
|
-
if (self.config.weekNumbers) {
|
|
23155
|
-
var _a = buildWeeks(), weekWrapper = _a.weekWrapper, weekNumbers = _a.weekNumbers;
|
|
23156
|
-
self.innerContainer.appendChild(weekWrapper);
|
|
23157
|
-
self.weekNumbers = weekNumbers;
|
|
23158
|
-
self.weekWrapper = weekWrapper;
|
|
23159
|
-
}
|
|
23160
|
-
self.rContainer = createElement("div", "flatpickr-rContainer");
|
|
23161
|
-
self.rContainer.appendChild(buildWeekdays());
|
|
23162
|
-
if (!self.daysContainer) {
|
|
23163
|
-
self.daysContainer = createElement("div", "flatpickr-days");
|
|
23164
|
-
self.daysContainer.tabIndex = -1;
|
|
23165
|
-
}
|
|
23166
|
-
buildDays();
|
|
23167
|
-
self.rContainer.appendChild(self.daysContainer);
|
|
23168
|
-
self.innerContainer.appendChild(self.rContainer);
|
|
23169
|
-
fragment.appendChild(self.innerContainer);
|
|
23170
|
-
}
|
|
23171
|
-
if (self.config.enableTime) {
|
|
23172
|
-
fragment.appendChild(buildTime());
|
|
23173
|
-
}
|
|
23174
|
-
toggleClass(self.calendarContainer, "rangeMode", self.config.mode === "range");
|
|
23175
|
-
toggleClass(self.calendarContainer, "animate", self.config.animate === true);
|
|
23176
|
-
toggleClass(self.calendarContainer, "multiMonth", self.config.showMonths > 1);
|
|
23177
|
-
self.calendarContainer.appendChild(fragment);
|
|
23178
|
-
var customAppend = self.config.appendTo !== undefined && self.config.appendTo.nodeType !== undefined;
|
|
23179
|
-
if (self.config.inline || self.config.static) {
|
|
23180
|
-
self.calendarContainer.classList.add(self.config.inline ? "inline" : "static");
|
|
23181
|
-
if (self.config.inline) {
|
|
23182
|
-
if (!customAppend && self.element.parentNode) self.element.parentNode.insertBefore(self.calendarContainer, self._input.nextSibling);
|
|
23183
|
-
else if (self.config.appendTo !== undefined) self.config.appendTo.appendChild(self.calendarContainer);
|
|
23184
|
-
}
|
|
23185
|
-
if (self.config.static) {
|
|
23186
|
-
var wrapper = createElement("div", "flatpickr-wrapper");
|
|
23187
|
-
if (self.element.parentNode) self.element.parentNode.insertBefore(wrapper, self.element);
|
|
23188
|
-
wrapper.appendChild(self.element);
|
|
23189
|
-
if (self.altInput) wrapper.appendChild(self.altInput);
|
|
23190
|
-
wrapper.appendChild(self.calendarContainer);
|
|
23191
|
-
}
|
|
23192
|
-
}
|
|
23193
|
-
if (!self.config.static && !self.config.inline) (self.config.appendTo !== undefined ? self.config.appendTo : window.document.body).appendChild(self.calendarContainer);
|
|
23194
|
-
}
|
|
23195
|
-
function createDay(className, date, _dayNumber, i) {
|
|
23196
|
-
var dateIsEnabled = isEnabled(date, true), dayElement = createElement("span", className, date.getDate().toString());
|
|
23197
|
-
dayElement.dateObj = date;
|
|
23198
|
-
dayElement.$i = i;
|
|
23199
|
-
dayElement.setAttribute("aria-label", self.formatDate(date, self.config.ariaDateFormat));
|
|
23200
|
-
if (className.indexOf("hidden") === -1 && compareDates(date, self.now) === 0) {
|
|
23201
|
-
self.todayDateElem = dayElement;
|
|
23202
|
-
dayElement.classList.add("today");
|
|
23203
|
-
dayElement.setAttribute("aria-current", "date");
|
|
23204
|
-
}
|
|
23205
|
-
if (dateIsEnabled) {
|
|
23206
|
-
dayElement.tabIndex = -1;
|
|
23207
|
-
if (isDateSelected(date)) {
|
|
23208
|
-
dayElement.classList.add("selected");
|
|
23209
|
-
self.selectedDateElem = dayElement;
|
|
23210
|
-
if (self.config.mode === "range") {
|
|
23211
|
-
toggleClass(dayElement, "startRange", self.selectedDates[0] && compareDates(date, self.selectedDates[0], true) === 0);
|
|
23212
|
-
toggleClass(dayElement, "endRange", self.selectedDates[1] && compareDates(date, self.selectedDates[1], true) === 0);
|
|
23213
|
-
if (className === "nextMonthDay") dayElement.classList.add("inRange");
|
|
23214
|
-
}
|
|
23215
|
-
}
|
|
23216
|
-
} else {
|
|
23217
|
-
dayElement.classList.add("flatpickr-disabled");
|
|
23218
|
-
}
|
|
23219
|
-
if (self.config.mode === "range") {
|
|
23220
|
-
if (isDateInRange(date) && !isDateSelected(date)) dayElement.classList.add("inRange");
|
|
23221
|
-
}
|
|
23222
|
-
if (self.weekNumbers && self.config.showMonths === 1 && className !== "prevMonthDay" && i % 7 === 6) {
|
|
23223
|
-
self.weekNumbers.insertAdjacentHTML("beforeend", "<span class='flatpickr-day'>" + self.config.getWeek(date) + "</span>");
|
|
23224
|
-
}
|
|
23225
|
-
triggerEvent("onDayCreate", dayElement);
|
|
23226
|
-
return dayElement;
|
|
23227
|
-
}
|
|
23228
|
-
function focusOnDayElem(targetNode) {
|
|
23229
|
-
targetNode.focus();
|
|
23230
|
-
if (self.config.mode === "range") onMouseOver(targetNode);
|
|
23231
|
-
}
|
|
23232
|
-
function getFirstAvailableDay(delta) {
|
|
23233
|
-
var startMonth = delta > 0 ? 0 : self.config.showMonths - 1;
|
|
23234
|
-
var endMonth = delta > 0 ? self.config.showMonths : -1;
|
|
23235
|
-
for(var m = startMonth; m != endMonth; m += delta){
|
|
23236
|
-
var month = self.daysContainer.children[m];
|
|
23237
|
-
var startIndex = delta > 0 ? 0 : month.children.length - 1;
|
|
23238
|
-
var endIndex = delta > 0 ? month.children.length : -1;
|
|
23239
|
-
for(var i = startIndex; i != endIndex; i += delta){
|
|
23240
|
-
var c = month.children[i];
|
|
23241
|
-
if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj)) return c;
|
|
23242
|
-
}
|
|
23243
|
-
}
|
|
23244
|
-
return undefined;
|
|
23245
|
-
}
|
|
23246
|
-
function getNextAvailableDay(current, delta) {
|
|
23247
|
-
var givenMonth = current.className.indexOf("Month") === -1 ? current.dateObj.getMonth() : self.currentMonth;
|
|
23248
|
-
var endMonth = delta > 0 ? self.config.showMonths : -1;
|
|
23249
|
-
var loopDelta = delta > 0 ? 1 : -1;
|
|
23250
|
-
for(var m = givenMonth - self.currentMonth; m != endMonth; m += loopDelta){
|
|
23251
|
-
var month = self.daysContainer.children[m];
|
|
23252
|
-
var startIndex = givenMonth - self.currentMonth === m ? current.$i + delta : delta < 0 ? month.children.length - 1 : 0;
|
|
23253
|
-
var numMonthDays = month.children.length;
|
|
23254
|
-
for(var i = startIndex; i >= 0 && i < numMonthDays && i != (delta > 0 ? numMonthDays : -1); i += loopDelta){
|
|
23255
|
-
var c = month.children[i];
|
|
23256
|
-
if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj) && Math.abs(current.$i - i) >= Math.abs(delta)) return focusOnDayElem(c);
|
|
23257
|
-
}
|
|
23258
|
-
}
|
|
23259
|
-
self.changeMonth(loopDelta);
|
|
23260
|
-
focusOnDay(getFirstAvailableDay(loopDelta), 0);
|
|
23261
|
-
return undefined;
|
|
23262
|
-
}
|
|
23263
|
-
function focusOnDay(current, offset) {
|
|
23264
|
-
var activeElement = getClosestActiveElement();
|
|
23265
|
-
var dayFocused = isInView(activeElement || document.body);
|
|
23266
|
-
var startElem = current !== undefined ? current : dayFocused ? activeElement : self.selectedDateElem !== undefined && isInView(self.selectedDateElem) ? self.selectedDateElem : self.todayDateElem !== undefined && isInView(self.todayDateElem) ? self.todayDateElem : getFirstAvailableDay(offset > 0 ? 1 : -1);
|
|
23267
|
-
if (startElem === undefined) {
|
|
23268
|
-
self._input.focus();
|
|
23269
|
-
} else if (!dayFocused) {
|
|
23270
|
-
focusOnDayElem(startElem);
|
|
23271
|
-
} else {
|
|
23272
|
-
getNextAvailableDay(startElem, offset);
|
|
23273
|
-
}
|
|
23274
|
-
}
|
|
23275
|
-
function buildMonthDays(year, month) {
|
|
23276
|
-
var firstOfMonth = (new Date(year, month, 1).getDay() - self.l10n.firstDayOfWeek + 7) % 7;
|
|
23277
|
-
var prevMonthDays = self.utils.getDaysInMonth((month - 1 + 12) % 12, year);
|
|
23278
|
-
var daysInMonth = self.utils.getDaysInMonth(month, year), days = window.document.createDocumentFragment(), isMultiMonth = self.config.showMonths > 1, prevMonthDayClass = isMultiMonth ? "prevMonthDay hidden" : "prevMonthDay", nextMonthDayClass = isMultiMonth ? "nextMonthDay hidden" : "nextMonthDay";
|
|
23279
|
-
var dayNumber = prevMonthDays + 1 - firstOfMonth, dayIndex = 0;
|
|
23280
|
-
for(; dayNumber <= prevMonthDays; dayNumber++, dayIndex++){
|
|
23281
|
-
days.appendChild(createDay("flatpickr-day " + prevMonthDayClass, new Date(year, month - 1, dayNumber), dayNumber, dayIndex));
|
|
23282
|
-
}
|
|
23283
|
-
for(dayNumber = 1; dayNumber <= daysInMonth; dayNumber++, dayIndex++){
|
|
23284
|
-
days.appendChild(createDay("flatpickr-day", new Date(year, month, dayNumber), dayNumber, dayIndex));
|
|
23285
|
-
}
|
|
23286
|
-
for(var dayNum = daysInMonth + 1; dayNum <= 42 - firstOfMonth && (self.config.showMonths === 1 || dayIndex % 7 !== 0); dayNum++, dayIndex++){
|
|
23287
|
-
days.appendChild(createDay("flatpickr-day " + nextMonthDayClass, new Date(year, month + 1, dayNum % daysInMonth), dayNum, dayIndex));
|
|
23288
|
-
}
|
|
23289
|
-
var dayContainer = createElement("div", "dayContainer");
|
|
23290
|
-
dayContainer.appendChild(days);
|
|
23291
|
-
return dayContainer;
|
|
23292
|
-
}
|
|
23293
|
-
function buildDays() {
|
|
23294
|
-
if (self.daysContainer === undefined) {
|
|
23295
|
-
return;
|
|
23296
|
-
}
|
|
23297
|
-
clearNode(self.daysContainer);
|
|
23298
|
-
if (self.weekNumbers) clearNode(self.weekNumbers);
|
|
23299
|
-
var frag = document.createDocumentFragment();
|
|
23300
|
-
for(var i = 0; i < self.config.showMonths; i++){
|
|
23301
|
-
var d = new Date(self.currentYear, self.currentMonth, 1);
|
|
23302
|
-
d.setMonth(self.currentMonth + i);
|
|
23303
|
-
frag.appendChild(buildMonthDays(d.getFullYear(), d.getMonth()));
|
|
23304
|
-
}
|
|
23305
|
-
self.daysContainer.appendChild(frag);
|
|
23306
|
-
self.days = self.daysContainer.firstChild;
|
|
23307
|
-
if (self.config.mode === "range" && self.selectedDates.length === 1) {
|
|
23308
|
-
onMouseOver();
|
|
23309
|
-
}
|
|
23310
|
-
}
|
|
23311
|
-
function buildMonthSwitch() {
|
|
23312
|
-
if (self.config.showMonths > 1 || self.config.monthSelectorType !== "dropdown") return;
|
|
23313
|
-
var shouldBuildMonth = function shouldBuildMonth(month) {
|
|
23314
|
-
if (self.config.minDate !== undefined && self.currentYear === self.config.minDate.getFullYear() && month < self.config.minDate.getMonth()) {
|
|
23315
|
-
return false;
|
|
23316
|
-
}
|
|
23317
|
-
return !(self.config.maxDate !== undefined && self.currentYear === self.config.maxDate.getFullYear() && month > self.config.maxDate.getMonth());
|
|
23318
|
-
};
|
|
23319
|
-
self.monthsDropdownContainer.tabIndex = -1;
|
|
23320
|
-
self.monthsDropdownContainer.innerHTML = "";
|
|
23321
|
-
for(var i = 0; i < 12; i++){
|
|
23322
|
-
if (!shouldBuildMonth(i)) continue;
|
|
23323
|
-
var month = createElement("option", "flatpickr-monthDropdown-month");
|
|
23324
|
-
month.value = new Date(self.currentYear, i).getMonth().toString();
|
|
23325
|
-
month.textContent = monthToStr(i, self.config.shorthandCurrentMonth, self.l10n);
|
|
23326
|
-
month.tabIndex = -1;
|
|
23327
|
-
if (self.currentMonth === i) {
|
|
23328
|
-
month.selected = true;
|
|
23329
|
-
}
|
|
23330
|
-
self.monthsDropdownContainer.appendChild(month);
|
|
23331
|
-
}
|
|
23332
|
-
}
|
|
23333
|
-
function buildMonth() {
|
|
23334
|
-
var container = createElement("div", "flatpickr-month");
|
|
23335
|
-
var monthNavFragment = window.document.createDocumentFragment();
|
|
23336
|
-
var monthElement;
|
|
23337
|
-
if (self.config.showMonths > 1 || self.config.monthSelectorType === "static") {
|
|
23338
|
-
monthElement = createElement("span", "cur-month");
|
|
23339
|
-
} else {
|
|
23340
|
-
self.monthsDropdownContainer = createElement("select", "flatpickr-monthDropdown-months");
|
|
23341
|
-
self.monthsDropdownContainer.setAttribute("aria-label", self.l10n.monthAriaLabel);
|
|
23342
|
-
bind(self.monthsDropdownContainer, "change", function(e) {
|
|
23343
|
-
var target = getEventTarget(e);
|
|
23344
|
-
var selectedMonth = parseInt(target.value, 10);
|
|
23345
|
-
self.changeMonth(selectedMonth - self.currentMonth);
|
|
23346
|
-
triggerEvent("onMonthChange");
|
|
23347
|
-
});
|
|
23348
|
-
buildMonthSwitch();
|
|
23349
|
-
monthElement = self.monthsDropdownContainer;
|
|
23350
|
-
}
|
|
23351
|
-
var yearInput = createNumberInput("cur-year", {
|
|
23352
|
-
tabindex: "-1"
|
|
23353
|
-
});
|
|
23354
|
-
var yearElement = yearInput.getElementsByTagName("input")[0];
|
|
23355
|
-
yearElement.setAttribute("aria-label", self.l10n.yearAriaLabel);
|
|
23356
|
-
if (self.config.minDate) {
|
|
23357
|
-
yearElement.setAttribute("min", self.config.minDate.getFullYear().toString());
|
|
23358
|
-
}
|
|
23359
|
-
if (self.config.maxDate) {
|
|
23360
|
-
yearElement.setAttribute("max", self.config.maxDate.getFullYear().toString());
|
|
23361
|
-
yearElement.disabled = !!self.config.minDate && self.config.minDate.getFullYear() === self.config.maxDate.getFullYear();
|
|
23362
|
-
}
|
|
23363
|
-
var currentMonth = createElement("div", "flatpickr-current-month");
|
|
23364
|
-
currentMonth.appendChild(monthElement);
|
|
23365
|
-
currentMonth.appendChild(yearInput);
|
|
23366
|
-
monthNavFragment.appendChild(currentMonth);
|
|
23367
|
-
container.appendChild(monthNavFragment);
|
|
23368
|
-
return {
|
|
23369
|
-
container: container,
|
|
23370
|
-
yearElement: yearElement,
|
|
23371
|
-
monthElement: monthElement
|
|
23372
|
-
};
|
|
23373
|
-
}
|
|
23374
|
-
function buildMonths() {
|
|
23375
|
-
clearNode(self.monthNav);
|
|
23376
|
-
self.monthNav.appendChild(self.prevMonthNav);
|
|
23377
|
-
if (self.config.showMonths) {
|
|
23378
|
-
self.yearElements = [];
|
|
23379
|
-
self.monthElements = [];
|
|
23380
|
-
}
|
|
23381
|
-
for(var m = self.config.showMonths; m--;){
|
|
23382
|
-
var month = buildMonth();
|
|
23383
|
-
self.yearElements.push(month.yearElement);
|
|
23384
|
-
self.monthElements.push(month.monthElement);
|
|
23385
|
-
self.monthNav.appendChild(month.container);
|
|
23386
|
-
}
|
|
23387
|
-
self.monthNav.appendChild(self.nextMonthNav);
|
|
23388
|
-
}
|
|
23389
|
-
function buildMonthNav() {
|
|
23390
|
-
self.monthNav = createElement("div", "flatpickr-months");
|
|
23391
|
-
self.yearElements = [];
|
|
23392
|
-
self.monthElements = [];
|
|
23393
|
-
self.prevMonthNav = createElement("span", "flatpickr-prev-month");
|
|
23394
|
-
self.prevMonthNav.innerHTML = self.config.prevArrow;
|
|
23395
|
-
self.nextMonthNav = createElement("span", "flatpickr-next-month");
|
|
23396
|
-
self.nextMonthNav.innerHTML = self.config.nextArrow;
|
|
23397
|
-
buildMonths();
|
|
23398
|
-
Object.defineProperty(self, "_hidePrevMonthArrow", {
|
|
23399
|
-
get: function get() {
|
|
23400
|
-
return self.__hidePrevMonthArrow;
|
|
23401
|
-
},
|
|
23402
|
-
set: function set(bool) {
|
|
23403
|
-
if (self.__hidePrevMonthArrow !== bool) {
|
|
23404
|
-
toggleClass(self.prevMonthNav, "flatpickr-disabled", bool);
|
|
23405
|
-
self.__hidePrevMonthArrow = bool;
|
|
23406
|
-
}
|
|
23407
|
-
}
|
|
23408
|
-
});
|
|
23409
|
-
Object.defineProperty(self, "_hideNextMonthArrow", {
|
|
23410
|
-
get: function get() {
|
|
23411
|
-
return self.__hideNextMonthArrow;
|
|
23412
|
-
},
|
|
23413
|
-
set: function set(bool) {
|
|
23414
|
-
if (self.__hideNextMonthArrow !== bool) {
|
|
23415
|
-
toggleClass(self.nextMonthNav, "flatpickr-disabled", bool);
|
|
23416
|
-
self.__hideNextMonthArrow = bool;
|
|
23417
|
-
}
|
|
23418
|
-
}
|
|
23419
|
-
});
|
|
23420
|
-
self.currentYearElement = self.yearElements[0];
|
|
23421
|
-
updateNavigationCurrentMonth();
|
|
23422
|
-
return self.monthNav;
|
|
23423
|
-
}
|
|
23424
|
-
function buildTime() {
|
|
23425
|
-
self.calendarContainer.classList.add("hasTime");
|
|
23426
|
-
if (self.config.noCalendar) self.calendarContainer.classList.add("noCalendar");
|
|
23427
|
-
var defaults = getDefaultHours(self.config);
|
|
23428
|
-
self.timeContainer = createElement("div", "flatpickr-time");
|
|
23429
|
-
self.timeContainer.tabIndex = -1;
|
|
23430
|
-
var separator = createElement("span", "flatpickr-time-separator", ":");
|
|
23431
|
-
var hourInput = createNumberInput("flatpickr-hour", {
|
|
23432
|
-
"aria-label": self.l10n.hourAriaLabel
|
|
23433
|
-
});
|
|
23434
|
-
self.hourElement = hourInput.getElementsByTagName("input")[0];
|
|
23435
|
-
var minuteInput = createNumberInput("flatpickr-minute", {
|
|
23436
|
-
"aria-label": self.l10n.minuteAriaLabel
|
|
23437
|
-
});
|
|
23438
|
-
self.minuteElement = minuteInput.getElementsByTagName("input")[0];
|
|
23439
|
-
self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
|
|
23440
|
-
self.hourElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getHours() : self.config.time_24hr ? defaults.hours : military2ampm(defaults.hours));
|
|
23441
|
-
self.minuteElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getMinutes() : defaults.minutes);
|
|
23442
|
-
self.hourElement.setAttribute("step", self.config.hourIncrement.toString());
|
|
23443
|
-
self.minuteElement.setAttribute("step", self.config.minuteIncrement.toString());
|
|
23444
|
-
self.hourElement.setAttribute("min", self.config.time_24hr ? "0" : "1");
|
|
23445
|
-
self.hourElement.setAttribute("max", self.config.time_24hr ? "23" : "12");
|
|
23446
|
-
self.hourElement.setAttribute("maxlength", "2");
|
|
23447
|
-
self.minuteElement.setAttribute("min", "0");
|
|
23448
|
-
self.minuteElement.setAttribute("max", "59");
|
|
23449
|
-
self.minuteElement.setAttribute("maxlength", "2");
|
|
23450
|
-
self.timeContainer.appendChild(hourInput);
|
|
23451
|
-
self.timeContainer.appendChild(separator);
|
|
23452
|
-
self.timeContainer.appendChild(minuteInput);
|
|
23453
|
-
if (self.config.time_24hr) self.timeContainer.classList.add("time24hr");
|
|
23454
|
-
if (self.config.enableSeconds) {
|
|
23455
|
-
self.timeContainer.classList.add("hasSeconds");
|
|
23456
|
-
var secondInput = createNumberInput("flatpickr-second");
|
|
23457
|
-
self.secondElement = secondInput.getElementsByTagName("input")[0];
|
|
23458
|
-
self.secondElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getSeconds() : defaults.seconds);
|
|
23459
|
-
self.secondElement.setAttribute("step", self.minuteElement.getAttribute("step"));
|
|
23460
|
-
self.secondElement.setAttribute("min", "0");
|
|
23461
|
-
self.secondElement.setAttribute("max", "59");
|
|
23462
|
-
self.secondElement.setAttribute("maxlength", "2");
|
|
23463
|
-
self.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
|
|
23464
|
-
self.timeContainer.appendChild(secondInput);
|
|
23465
|
-
}
|
|
23466
|
-
if (!self.config.time_24hr) {
|
|
23467
|
-
self.amPM = createElement("span", "flatpickr-am-pm", self.l10n.amPM[int((self.latestSelectedDateObj ? self.hourElement.value : self.config.defaultHour) > 11)]);
|
|
23468
|
-
self.amPM.title = self.l10n.toggleTitle;
|
|
23469
|
-
self.amPM.tabIndex = -1;
|
|
23470
|
-
self.timeContainer.appendChild(self.amPM);
|
|
23471
|
-
}
|
|
23472
|
-
return self.timeContainer;
|
|
23473
|
-
}
|
|
23474
|
-
function buildWeekdays() {
|
|
23475
|
-
if (!self.weekdayContainer) self.weekdayContainer = createElement("div", "flatpickr-weekdays");
|
|
23476
|
-
else clearNode(self.weekdayContainer);
|
|
23477
|
-
for(var i = self.config.showMonths; i--;){
|
|
23478
|
-
var container = createElement("div", "flatpickr-weekdaycontainer");
|
|
23479
|
-
self.weekdayContainer.appendChild(container);
|
|
23480
|
-
}
|
|
23481
|
-
updateWeekdays();
|
|
23482
|
-
return self.weekdayContainer;
|
|
23483
|
-
}
|
|
23484
|
-
function updateWeekdays() {
|
|
23485
|
-
if (!self.weekdayContainer) {
|
|
23486
|
-
return;
|
|
23487
|
-
}
|
|
23488
|
-
var firstDayOfWeek = self.l10n.firstDayOfWeek;
|
|
23489
|
-
var weekdays = __spreadArrays(self.l10n.weekdays.shorthand);
|
|
23490
|
-
if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
|
|
23491
|
-
weekdays = __spreadArrays(weekdays.splice(firstDayOfWeek, weekdays.length), weekdays.splice(0, firstDayOfWeek));
|
|
23492
|
-
}
|
|
23493
|
-
for(var i = self.config.showMonths; i--;){
|
|
23494
|
-
self.weekdayContainer.children[i].innerHTML = "\n <span class='flatpickr-weekday'>\n " + weekdays.join("</span><span class='flatpickr-weekday'>") + "\n </span>\n ";
|
|
23495
|
-
}
|
|
23496
|
-
}
|
|
23497
|
-
function buildWeeks() {
|
|
23498
|
-
self.calendarContainer.classList.add("hasWeeks");
|
|
23499
|
-
var weekWrapper = createElement("div", "flatpickr-weekwrapper");
|
|
23500
|
-
weekWrapper.appendChild(createElement("span", "flatpickr-weekday", self.l10n.weekAbbreviation));
|
|
23501
|
-
var weekNumbers = createElement("div", "flatpickr-weeks");
|
|
23502
|
-
weekWrapper.appendChild(weekNumbers);
|
|
23503
|
-
return {
|
|
23504
|
-
weekWrapper: weekWrapper,
|
|
23505
|
-
weekNumbers: weekNumbers
|
|
23506
|
-
};
|
|
23507
|
-
}
|
|
23508
|
-
function changeMonth(value, isOffset) {
|
|
23509
|
-
if (isOffset === void 0) {
|
|
23510
|
-
isOffset = true;
|
|
23511
|
-
}
|
|
23512
|
-
var delta = isOffset ? value : value - self.currentMonth;
|
|
23513
|
-
if (delta < 0 && self._hidePrevMonthArrow === true || delta > 0 && self._hideNextMonthArrow === true) return;
|
|
23514
|
-
self.currentMonth += delta;
|
|
23515
|
-
if (self.currentMonth < 0 || self.currentMonth > 11) {
|
|
23516
|
-
self.currentYear += self.currentMonth > 11 ? 1 : -1;
|
|
23517
|
-
self.currentMonth = (self.currentMonth + 12) % 12;
|
|
23518
|
-
triggerEvent("onYearChange");
|
|
23519
|
-
buildMonthSwitch();
|
|
23520
|
-
}
|
|
23521
|
-
buildDays();
|
|
23522
|
-
triggerEvent("onMonthChange");
|
|
23523
|
-
updateNavigationCurrentMonth();
|
|
23524
|
-
}
|
|
23525
|
-
function clear(triggerChangeEvent, toInitial) {
|
|
23526
|
-
if (triggerChangeEvent === void 0) {
|
|
23527
|
-
triggerChangeEvent = true;
|
|
23528
|
-
}
|
|
23529
|
-
if (toInitial === void 0) {
|
|
23530
|
-
toInitial = true;
|
|
23531
|
-
}
|
|
23532
|
-
self.input.value = "";
|
|
23533
|
-
if (self.altInput !== undefined) self.altInput.value = "";
|
|
23534
|
-
if (self.mobileInput !== undefined) self.mobileInput.value = "";
|
|
23535
|
-
self.selectedDates = [];
|
|
23536
|
-
self.latestSelectedDateObj = undefined;
|
|
23537
|
-
if (toInitial === true) {
|
|
23538
|
-
self.currentYear = self._initialDate.getFullYear();
|
|
23539
|
-
self.currentMonth = self._initialDate.getMonth();
|
|
23540
|
-
}
|
|
23541
|
-
if (self.config.enableTime === true) {
|
|
23542
|
-
var _a = getDefaultHours(self.config), hours = _a.hours, minutes = _a.minutes, seconds = _a.seconds;
|
|
23543
|
-
setHours(hours, minutes, seconds);
|
|
23544
|
-
}
|
|
23545
|
-
self.redraw();
|
|
23546
|
-
if (triggerChangeEvent) triggerEvent("onChange");
|
|
23547
|
-
}
|
|
23548
|
-
function close() {
|
|
23549
|
-
self.isOpen = false;
|
|
23550
|
-
if (!self.isMobile) {
|
|
23551
|
-
if (self.calendarContainer !== undefined) {
|
|
23552
|
-
self.calendarContainer.classList.remove("open");
|
|
23553
|
-
}
|
|
23554
|
-
if (self._input !== undefined) {
|
|
23555
|
-
self._input.classList.remove("active");
|
|
23556
|
-
}
|
|
23557
|
-
}
|
|
23558
|
-
triggerEvent("onClose");
|
|
23559
|
-
}
|
|
23560
|
-
function destroy() {
|
|
23561
|
-
if (self.config !== undefined) triggerEvent("onDestroy");
|
|
23562
|
-
for(var i = self._handlers.length; i--;){
|
|
23563
|
-
self._handlers[i].remove();
|
|
23564
|
-
}
|
|
23565
|
-
self._handlers = [];
|
|
23566
|
-
if (self.mobileInput) {
|
|
23567
|
-
if (self.mobileInput.parentNode) self.mobileInput.parentNode.removeChild(self.mobileInput);
|
|
23568
|
-
self.mobileInput = undefined;
|
|
23569
|
-
} else if (self.calendarContainer && self.calendarContainer.parentNode) {
|
|
23570
|
-
if (self.config.static && self.calendarContainer.parentNode) {
|
|
23571
|
-
var wrapper = self.calendarContainer.parentNode;
|
|
23572
|
-
wrapper.lastChild && wrapper.removeChild(wrapper.lastChild);
|
|
23573
|
-
if (wrapper.parentNode) {
|
|
23574
|
-
while(wrapper.firstChild)wrapper.parentNode.insertBefore(wrapper.firstChild, wrapper);
|
|
23575
|
-
wrapper.parentNode.removeChild(wrapper);
|
|
23576
|
-
}
|
|
23577
|
-
} else self.calendarContainer.parentNode.removeChild(self.calendarContainer);
|
|
23578
|
-
}
|
|
23579
|
-
if (self.altInput) {
|
|
23580
|
-
self.input.type = "text";
|
|
23581
|
-
if (self.altInput.parentNode) self.altInput.parentNode.removeChild(self.altInput);
|
|
23582
|
-
delete self.altInput;
|
|
23583
|
-
}
|
|
23584
|
-
if (self.input) {
|
|
23585
|
-
self.input.type = self.input._type;
|
|
23586
|
-
self.input.classList.remove("flatpickr-input");
|
|
23587
|
-
self.input.removeAttribute("readonly");
|
|
23588
|
-
}
|
|
23589
|
-
[
|
|
23590
|
-
"_showTimeInput",
|
|
23591
|
-
"latestSelectedDateObj",
|
|
23592
|
-
"_hideNextMonthArrow",
|
|
23593
|
-
"_hidePrevMonthArrow",
|
|
23594
|
-
"__hideNextMonthArrow",
|
|
23595
|
-
"__hidePrevMonthArrow",
|
|
23596
|
-
"isMobile",
|
|
23597
|
-
"isOpen",
|
|
23598
|
-
"selectedDateElem",
|
|
23599
|
-
"minDateHasTime",
|
|
23600
|
-
"maxDateHasTime",
|
|
23601
|
-
"days",
|
|
23602
|
-
"daysContainer",
|
|
23603
|
-
"_input",
|
|
23604
|
-
"_positionElement",
|
|
23605
|
-
"innerContainer",
|
|
23606
|
-
"rContainer",
|
|
23607
|
-
"monthNav",
|
|
23608
|
-
"todayDateElem",
|
|
23609
|
-
"calendarContainer",
|
|
23610
|
-
"weekdayContainer",
|
|
23611
|
-
"prevMonthNav",
|
|
23612
|
-
"nextMonthNav",
|
|
23613
|
-
"monthsDropdownContainer",
|
|
23614
|
-
"currentMonthElement",
|
|
23615
|
-
"currentYearElement",
|
|
23616
|
-
"navigationCurrentMonth",
|
|
23617
|
-
"selectedDateElem",
|
|
23618
|
-
"config"
|
|
23619
|
-
].forEach(function(k) {
|
|
23620
|
-
try {
|
|
23621
|
-
delete self[k];
|
|
23622
|
-
} catch (_) {}
|
|
23623
|
-
});
|
|
23624
|
-
}
|
|
23625
|
-
function isCalendarElem(elem) {
|
|
23626
|
-
return self.calendarContainer.contains(elem);
|
|
23627
|
-
}
|
|
23628
|
-
function documentClick(e) {
|
|
23629
|
-
if (self.isOpen && !self.config.inline) {
|
|
23630
|
-
var eventTarget_1 = getEventTarget(e);
|
|
23631
|
-
var isCalendarElement = isCalendarElem(eventTarget_1);
|
|
23632
|
-
var isInput = eventTarget_1 === self.input || eventTarget_1 === self.altInput || self.element.contains(eventTarget_1) || e.path && e.path.indexOf && (~e.path.indexOf(self.input) || ~e.path.indexOf(self.altInput));
|
|
23633
|
-
var lostFocus = !isInput && !isCalendarElement && !isCalendarElem(e.relatedTarget);
|
|
23634
|
-
var isIgnored = !self.config.ignoredFocusElements.some(function(elem) {
|
|
23635
|
-
return elem.contains(eventTarget_1);
|
|
23636
|
-
});
|
|
23637
|
-
if (lostFocus && isIgnored) {
|
|
23638
|
-
if (self.config.allowInput) {
|
|
23639
|
-
self.setDate(self._input.value, false, self.config.altInput ? self.config.altFormat : self.config.dateFormat);
|
|
23640
|
-
}
|
|
23641
|
-
if (self.timeContainer !== undefined && self.minuteElement !== undefined && self.hourElement !== undefined && self.input.value !== "" && self.input.value !== undefined) {
|
|
23642
|
-
updateTime();
|
|
23643
|
-
}
|
|
23644
|
-
self.close();
|
|
23645
|
-
if (self.config && self.config.mode === "range" && self.selectedDates.length === 1) self.clear(false);
|
|
23646
|
-
}
|
|
23647
|
-
}
|
|
23648
|
-
}
|
|
23649
|
-
function changeYear(newYear) {
|
|
23650
|
-
if (!newYear || self.config.minDate && newYear < self.config.minDate.getFullYear() || self.config.maxDate && newYear > self.config.maxDate.getFullYear()) return;
|
|
23651
|
-
var newYearNum = newYear, isNewYear = self.currentYear !== newYearNum;
|
|
23652
|
-
self.currentYear = newYearNum || self.currentYear;
|
|
23653
|
-
if (self.config.maxDate && self.currentYear === self.config.maxDate.getFullYear()) {
|
|
23654
|
-
self.currentMonth = Math.min(self.config.maxDate.getMonth(), self.currentMonth);
|
|
23655
|
-
} else if (self.config.minDate && self.currentYear === self.config.minDate.getFullYear()) {
|
|
23656
|
-
self.currentMonth = Math.max(self.config.minDate.getMonth(), self.currentMonth);
|
|
23657
|
-
}
|
|
23658
|
-
if (isNewYear) {
|
|
23659
|
-
self.redraw();
|
|
23660
|
-
triggerEvent("onYearChange");
|
|
23661
|
-
buildMonthSwitch();
|
|
23662
|
-
}
|
|
23663
|
-
}
|
|
23664
|
-
function isEnabled(date, timeless) {
|
|
23665
|
-
var _a;
|
|
23666
|
-
if (timeless === void 0) {
|
|
23667
|
-
timeless = true;
|
|
23668
|
-
}
|
|
23669
|
-
var dateToCheck = self.parseDate(date, undefined, timeless);
|
|
23670
|
-
if (self.config.minDate && dateToCheck && compareDates(dateToCheck, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0 || self.config.maxDate && dateToCheck && compareDates(dateToCheck, self.config.maxDate, timeless !== undefined ? timeless : !self.maxDateHasTime) > 0) return false;
|
|
23671
|
-
if (!self.config.enable && self.config.disable.length === 0) return true;
|
|
23672
|
-
if (dateToCheck === undefined) return false;
|
|
23673
|
-
var bool = !!self.config.enable, array = (_a = self.config.enable) !== null && _a !== void 0 ? _a : self.config.disable;
|
|
23674
|
-
for(var i = 0, d = void 0; i < array.length; i++){
|
|
23675
|
-
d = array[i];
|
|
23676
|
-
if (typeof d === "function" && d(dateToCheck)) return bool;
|
|
23677
|
-
else if (_instanceof(d, Date) && dateToCheck !== undefined && d.getTime() === dateToCheck.getTime()) return bool;
|
|
23678
|
-
else if (typeof d === "string") {
|
|
23679
|
-
var parsed = self.parseDate(d, undefined, true);
|
|
23680
|
-
return parsed && parsed.getTime() === dateToCheck.getTime() ? bool : !bool;
|
|
23681
|
-
} else if (typeof d === "object" && dateToCheck !== undefined && d.from && d.to && dateToCheck.getTime() >= d.from.getTime() && dateToCheck.getTime() <= d.to.getTime()) return bool;
|
|
23682
|
-
}
|
|
23683
|
-
return !bool;
|
|
23684
|
-
}
|
|
23685
|
-
function isInView(elem) {
|
|
23686
|
-
if (self.daysContainer !== undefined) return elem.className.indexOf("hidden") === -1 && elem.className.indexOf("flatpickr-disabled") === -1 && self.daysContainer.contains(elem);
|
|
23687
|
-
return false;
|
|
23688
|
-
}
|
|
23689
|
-
function onBlur(e) {
|
|
23690
|
-
var isInput = e.target === self._input;
|
|
23691
|
-
var valueChanged = self._input.value.trimEnd() !== getDateStr();
|
|
23692
|
-
if (isInput && valueChanged && !(e.relatedTarget && isCalendarElem(e.relatedTarget))) {
|
|
23693
|
-
self.setDate(self._input.value, true, e.target === self.altInput ? self.config.altFormat : self.config.dateFormat);
|
|
23694
|
-
}
|
|
23695
|
-
}
|
|
23696
|
-
function onKeyDown(e) {
|
|
23697
|
-
var eventTarget = getEventTarget(e);
|
|
23698
|
-
var isInput = self.config.wrap ? element.contains(eventTarget) : eventTarget === self._input;
|
|
23699
|
-
var allowInput = self.config.allowInput;
|
|
23700
|
-
var allowKeydown = self.isOpen && (!allowInput || !isInput);
|
|
23701
|
-
var allowInlineKeydown = self.config.inline && isInput && !allowInput;
|
|
23702
|
-
if (e.keyCode === 13 && isInput) {
|
|
23703
|
-
if (allowInput) {
|
|
23704
|
-
self.setDate(self._input.value, true, eventTarget === self.altInput ? self.config.altFormat : self.config.dateFormat);
|
|
23705
|
-
self.close();
|
|
23706
|
-
return eventTarget.blur();
|
|
23707
|
-
} else {
|
|
23708
|
-
self.open();
|
|
23709
|
-
}
|
|
23710
|
-
} else if (isCalendarElem(eventTarget) || allowKeydown || allowInlineKeydown) {
|
|
23711
|
-
var isTimeObj = !!self.timeContainer && self.timeContainer.contains(eventTarget);
|
|
23712
|
-
switch(e.keyCode){
|
|
23713
|
-
case 13:
|
|
23714
|
-
if (isTimeObj) {
|
|
23715
|
-
e.preventDefault();
|
|
23716
|
-
updateTime();
|
|
23717
|
-
focusAndClose();
|
|
23718
|
-
} else selectDate(e);
|
|
23719
|
-
break;
|
|
23720
|
-
case 27:
|
|
23721
|
-
e.preventDefault();
|
|
23722
|
-
focusAndClose();
|
|
23723
|
-
break;
|
|
23724
|
-
case 8:
|
|
23725
|
-
case 46:
|
|
23726
|
-
if (isInput && !self.config.allowInput) {
|
|
23727
|
-
e.preventDefault();
|
|
23728
|
-
self.clear();
|
|
23729
|
-
}
|
|
23730
|
-
break;
|
|
23731
|
-
case 37:
|
|
23732
|
-
case 39:
|
|
23733
|
-
if (!isTimeObj && !isInput) {
|
|
23734
|
-
e.preventDefault();
|
|
23735
|
-
var activeElement = getClosestActiveElement();
|
|
23736
|
-
if (self.daysContainer !== undefined && (allowInput === false || activeElement && isInView(activeElement))) {
|
|
23737
|
-
var delta_1 = e.keyCode === 39 ? 1 : -1;
|
|
23738
|
-
if (!e.ctrlKey) focusOnDay(undefined, delta_1);
|
|
23739
|
-
else {
|
|
23740
|
-
e.stopPropagation();
|
|
23741
|
-
changeMonth(delta_1);
|
|
23742
|
-
focusOnDay(getFirstAvailableDay(1), 0);
|
|
23743
|
-
}
|
|
23744
|
-
}
|
|
23745
|
-
} else if (self.hourElement) self.hourElement.focus();
|
|
23746
|
-
break;
|
|
23747
|
-
case 38:
|
|
23748
|
-
case 40:
|
|
23749
|
-
e.preventDefault();
|
|
23750
|
-
var delta = e.keyCode === 40 ? 1 : -1;
|
|
23751
|
-
if (self.daysContainer && eventTarget.$i !== undefined || eventTarget === self.input || eventTarget === self.altInput) {
|
|
23752
|
-
if (e.ctrlKey) {
|
|
23753
|
-
e.stopPropagation();
|
|
23754
|
-
changeYear(self.currentYear - delta);
|
|
23755
|
-
focusOnDay(getFirstAvailableDay(1), 0);
|
|
23756
|
-
} else if (!isTimeObj) focusOnDay(undefined, delta * 7);
|
|
23757
|
-
} else if (eventTarget === self.currentYearElement) {
|
|
23758
|
-
changeYear(self.currentYear - delta);
|
|
23759
|
-
} else if (self.config.enableTime) {
|
|
23760
|
-
if (!isTimeObj && self.hourElement) self.hourElement.focus();
|
|
23761
|
-
updateTime(e);
|
|
23762
|
-
self._debouncedChange();
|
|
23763
|
-
}
|
|
23764
|
-
break;
|
|
23765
|
-
case 9:
|
|
23766
|
-
if (isTimeObj) {
|
|
23767
|
-
var elems = [
|
|
23768
|
-
self.hourElement,
|
|
23769
|
-
self.minuteElement,
|
|
23770
|
-
self.secondElement,
|
|
23771
|
-
self.amPM
|
|
23772
|
-
].concat(self.pluginElements).filter(function(x) {
|
|
23773
|
-
return x;
|
|
23774
|
-
});
|
|
23775
|
-
var i = elems.indexOf(eventTarget);
|
|
23776
|
-
if (i !== -1) {
|
|
23777
|
-
var target = elems[i + (e.shiftKey ? -1 : 1)];
|
|
23778
|
-
e.preventDefault();
|
|
23779
|
-
(target || self._input).focus();
|
|
23780
|
-
}
|
|
23781
|
-
} else if (!self.config.noCalendar && self.daysContainer && self.daysContainer.contains(eventTarget) && e.shiftKey) {
|
|
23782
|
-
e.preventDefault();
|
|
23783
|
-
self._input.focus();
|
|
23784
|
-
}
|
|
23785
|
-
break;
|
|
23786
|
-
}
|
|
23787
|
-
}
|
|
23788
|
-
if (self.amPM !== undefined && eventTarget === self.amPM) {
|
|
23789
|
-
switch(e.key){
|
|
23790
|
-
case self.l10n.amPM[0].charAt(0):
|
|
23791
|
-
case self.l10n.amPM[0].charAt(0).toLowerCase():
|
|
23792
|
-
self.amPM.textContent = self.l10n.amPM[0];
|
|
23793
|
-
setHoursFromInputs();
|
|
23794
|
-
updateValue();
|
|
23795
|
-
break;
|
|
23796
|
-
case self.l10n.amPM[1].charAt(0):
|
|
23797
|
-
case self.l10n.amPM[1].charAt(0).toLowerCase():
|
|
23798
|
-
self.amPM.textContent = self.l10n.amPM[1];
|
|
23799
|
-
setHoursFromInputs();
|
|
23800
|
-
updateValue();
|
|
23801
|
-
break;
|
|
23802
|
-
}
|
|
23803
|
-
}
|
|
23804
|
-
if (isInput || isCalendarElem(eventTarget)) {
|
|
23805
|
-
triggerEvent("onKeyDown", e);
|
|
23806
|
-
}
|
|
23807
|
-
}
|
|
23808
|
-
function onMouseOver(elem, cellClass) {
|
|
23809
|
-
if (cellClass === void 0) {
|
|
23810
|
-
cellClass = "flatpickr-day";
|
|
23811
|
-
}
|
|
23812
|
-
if (self.selectedDates.length !== 1 || elem && (!elem.classList.contains(cellClass) || elem.classList.contains("flatpickr-disabled"))) return;
|
|
23813
|
-
var hoverDate = elem ? elem.dateObj.getTime() : self.days.firstElementChild.dateObj.getTime(), initialDate = self.parseDate(self.selectedDates[0], undefined, true).getTime(), rangeStartDate = Math.min(hoverDate, self.selectedDates[0].getTime()), rangeEndDate = Math.max(hoverDate, self.selectedDates[0].getTime());
|
|
23814
|
-
var containsDisabled = false;
|
|
23815
|
-
var minRange = 0, maxRange = 0;
|
|
23816
|
-
for(var t = rangeStartDate; t < rangeEndDate; t += duration.DAY){
|
|
23817
|
-
if (!isEnabled(new Date(t), true)) {
|
|
23818
|
-
containsDisabled = containsDisabled || t > rangeStartDate && t < rangeEndDate;
|
|
23819
|
-
if (t < initialDate && (!minRange || t > minRange)) minRange = t;
|
|
23820
|
-
else if (t > initialDate && (!maxRange || t < maxRange)) maxRange = t;
|
|
23821
|
-
}
|
|
23822
|
-
}
|
|
23823
|
-
var hoverableCells = Array.from(self.rContainer.querySelectorAll("*:nth-child(-n+" + self.config.showMonths + ") > ." + cellClass));
|
|
23824
|
-
hoverableCells.forEach(function(dayElem) {
|
|
23825
|
-
var date = dayElem.dateObj;
|
|
23826
|
-
var timestamp = date.getTime();
|
|
23827
|
-
var outOfRange = minRange > 0 && timestamp < minRange || maxRange > 0 && timestamp > maxRange;
|
|
23828
|
-
if (outOfRange) {
|
|
23829
|
-
dayElem.classList.add("notAllowed");
|
|
23830
|
-
[
|
|
23831
|
-
"inRange",
|
|
23832
|
-
"startRange",
|
|
23833
|
-
"endRange"
|
|
23834
|
-
].forEach(function(c) {
|
|
23835
|
-
dayElem.classList.remove(c);
|
|
23836
|
-
});
|
|
23837
|
-
return;
|
|
23838
|
-
} else if (containsDisabled && !outOfRange) return;
|
|
23839
|
-
[
|
|
23840
|
-
"startRange",
|
|
23841
|
-
"inRange",
|
|
23842
|
-
"endRange",
|
|
23843
|
-
"notAllowed"
|
|
23844
|
-
].forEach(function(c) {
|
|
23845
|
-
dayElem.classList.remove(c);
|
|
23846
|
-
});
|
|
23847
|
-
if (elem !== undefined) {
|
|
23848
|
-
elem.classList.add(hoverDate <= self.selectedDates[0].getTime() ? "startRange" : "endRange");
|
|
23849
|
-
if (initialDate < hoverDate && timestamp === initialDate) dayElem.classList.add("startRange");
|
|
23850
|
-
else if (initialDate > hoverDate && timestamp === initialDate) dayElem.classList.add("endRange");
|
|
23851
|
-
if (timestamp >= minRange && (maxRange === 0 || timestamp <= maxRange) && isBetween(timestamp, initialDate, hoverDate)) dayElem.classList.add("inRange");
|
|
23852
|
-
}
|
|
23853
|
-
});
|
|
23854
|
-
}
|
|
23855
|
-
function onResize() {
|
|
23856
|
-
if (self.isOpen && !self.config.static && !self.config.inline) positionCalendar();
|
|
23857
|
-
}
|
|
23858
|
-
function open(e, positionElement) {
|
|
23859
|
-
if (positionElement === void 0) {
|
|
23860
|
-
positionElement = self._positionElement;
|
|
23861
|
-
}
|
|
23862
|
-
if (self.isMobile === true) {
|
|
23863
|
-
if (e) {
|
|
23864
|
-
e.preventDefault();
|
|
23865
|
-
var eventTarget = getEventTarget(e);
|
|
23866
|
-
if (eventTarget) {
|
|
23867
|
-
eventTarget.blur();
|
|
23868
|
-
}
|
|
23869
|
-
}
|
|
23870
|
-
if (self.mobileInput !== undefined) {
|
|
23871
|
-
self.mobileInput.focus();
|
|
23872
|
-
self.mobileInput.click();
|
|
23873
|
-
}
|
|
23874
|
-
triggerEvent("onOpen");
|
|
23875
|
-
return;
|
|
23876
|
-
} else if (self._input.disabled || self.config.inline) {
|
|
23877
|
-
return;
|
|
23878
|
-
}
|
|
23879
|
-
var wasOpen = self.isOpen;
|
|
23880
|
-
self.isOpen = true;
|
|
23881
|
-
if (!wasOpen) {
|
|
23882
|
-
self.calendarContainer.classList.add("open");
|
|
23883
|
-
self._input.classList.add("active");
|
|
23884
|
-
triggerEvent("onOpen");
|
|
23885
|
-
positionCalendar(positionElement);
|
|
23886
|
-
}
|
|
23887
|
-
if (self.config.enableTime === true && self.config.noCalendar === true) {
|
|
23888
|
-
if (self.config.allowInput === false && (e === undefined || !self.timeContainer.contains(e.relatedTarget))) {
|
|
23889
|
-
setTimeout(function() {
|
|
23890
|
-
return self.hourElement.select();
|
|
23891
|
-
}, 50);
|
|
23892
|
-
}
|
|
23893
|
-
}
|
|
23894
|
-
}
|
|
23895
|
-
function minMaxDateSetter(type) {
|
|
23896
|
-
return function(date) {
|
|
23897
|
-
var dateObj = self.config["_" + type + "Date"] = self.parseDate(date, self.config.dateFormat);
|
|
23898
|
-
var inverseDateObj = self.config["_" + (type === "min" ? "max" : "min") + "Date"];
|
|
23899
|
-
if (dateObj !== undefined) {
|
|
23900
|
-
self[type === "min" ? "minDateHasTime" : "maxDateHasTime"] = dateObj.getHours() > 0 || dateObj.getMinutes() > 0 || dateObj.getSeconds() > 0;
|
|
23901
|
-
}
|
|
23902
|
-
if (self.selectedDates) {
|
|
23903
|
-
self.selectedDates = self.selectedDates.filter(function(d) {
|
|
23904
|
-
return isEnabled(d);
|
|
23905
|
-
});
|
|
23906
|
-
if (!self.selectedDates.length && type === "min") setHoursFromDate(dateObj);
|
|
23907
|
-
updateValue();
|
|
23908
|
-
}
|
|
23909
|
-
if (self.daysContainer) {
|
|
23910
|
-
redraw();
|
|
23911
|
-
if (dateObj !== undefined) self.currentYearElement[type] = dateObj.getFullYear().toString();
|
|
23912
|
-
else self.currentYearElement.removeAttribute(type);
|
|
23913
|
-
self.currentYearElement.disabled = !!inverseDateObj && dateObj !== undefined && inverseDateObj.getFullYear() === dateObj.getFullYear();
|
|
23914
|
-
}
|
|
23915
|
-
};
|
|
23916
|
-
}
|
|
23917
|
-
function parseConfig() {
|
|
23918
|
-
var boolOpts = [
|
|
23919
|
-
"wrap",
|
|
23920
|
-
"weekNumbers",
|
|
23921
|
-
"allowInput",
|
|
23922
|
-
"allowInvalidPreload",
|
|
23923
|
-
"clickOpens",
|
|
23924
|
-
"time_24hr",
|
|
23925
|
-
"enableTime",
|
|
23926
|
-
"noCalendar",
|
|
23927
|
-
"altInput",
|
|
23928
|
-
"shorthandCurrentMonth",
|
|
23929
|
-
"inline",
|
|
23930
|
-
"static",
|
|
23931
|
-
"enableSeconds",
|
|
23932
|
-
"disableMobile"
|
|
23933
|
-
];
|
|
23934
|
-
var userConfig = __assign(__assign({}, JSON.parse(JSON.stringify(element.dataset || {}))), instanceConfig);
|
|
23935
|
-
var formats = {};
|
|
23936
|
-
self.config.parseDate = userConfig.parseDate;
|
|
23937
|
-
self.config.formatDate = userConfig.formatDate;
|
|
23938
|
-
Object.defineProperty(self.config, "enable", {
|
|
23939
|
-
get: function get() {
|
|
23940
|
-
return self.config._enable;
|
|
23941
|
-
},
|
|
23942
|
-
set: function set(dates) {
|
|
23943
|
-
self.config._enable = parseDateRules(dates);
|
|
23944
|
-
}
|
|
23945
|
-
});
|
|
23946
|
-
Object.defineProperty(self.config, "disable", {
|
|
23947
|
-
get: function get() {
|
|
23948
|
-
return self.config._disable;
|
|
23949
|
-
},
|
|
23950
|
-
set: function set(dates) {
|
|
23951
|
-
self.config._disable = parseDateRules(dates);
|
|
23952
|
-
}
|
|
23953
|
-
});
|
|
23954
|
-
var timeMode = userConfig.mode === "time";
|
|
23955
|
-
if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
|
|
23956
|
-
var defaultDateFormat = flatpickr.defaultConfig.dateFormat || defaults.dateFormat;
|
|
23957
|
-
formats.dateFormat = userConfig.noCalendar || timeMode ? "H:i" + (userConfig.enableSeconds ? ":S" : "") : defaultDateFormat + " H:i" + (userConfig.enableSeconds ? ":S" : "");
|
|
23958
|
-
}
|
|
23959
|
-
if (userConfig.altInput && (userConfig.enableTime || timeMode) && !userConfig.altFormat) {
|
|
23960
|
-
var defaultAltFormat = flatpickr.defaultConfig.altFormat || defaults.altFormat;
|
|
23961
|
-
formats.altFormat = userConfig.noCalendar || timeMode ? "h:i" + (userConfig.enableSeconds ? ":S K" : " K") : defaultAltFormat + (" h:i" + (userConfig.enableSeconds ? ":S" : "") + " K");
|
|
23962
|
-
}
|
|
23963
|
-
Object.defineProperty(self.config, "minDate", {
|
|
23964
|
-
get: function get() {
|
|
23965
|
-
return self.config._minDate;
|
|
23966
|
-
},
|
|
23967
|
-
set: minMaxDateSetter("min")
|
|
23968
|
-
});
|
|
23969
|
-
Object.defineProperty(self.config, "maxDate", {
|
|
23970
|
-
get: function get() {
|
|
23971
|
-
return self.config._maxDate;
|
|
23972
|
-
},
|
|
23973
|
-
set: minMaxDateSetter("max")
|
|
23974
|
-
});
|
|
23975
|
-
var minMaxTimeSetter = function minMaxTimeSetter(type) {
|
|
23976
|
-
return function(val) {
|
|
23977
|
-
self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i:S");
|
|
23978
|
-
};
|
|
23979
|
-
};
|
|
23980
|
-
Object.defineProperty(self.config, "minTime", {
|
|
23981
|
-
get: function get() {
|
|
23982
|
-
return self.config._minTime;
|
|
23983
|
-
},
|
|
23984
|
-
set: minMaxTimeSetter("min")
|
|
23985
|
-
});
|
|
23986
|
-
Object.defineProperty(self.config, "maxTime", {
|
|
23987
|
-
get: function get() {
|
|
23988
|
-
return self.config._maxTime;
|
|
23989
|
-
},
|
|
23990
|
-
set: minMaxTimeSetter("max")
|
|
23991
|
-
});
|
|
23992
|
-
if (userConfig.mode === "time") {
|
|
23993
|
-
self.config.noCalendar = true;
|
|
23994
|
-
self.config.enableTime = true;
|
|
23995
|
-
}
|
|
23996
|
-
Object.assign(self.config, formats, userConfig);
|
|
23997
|
-
for(var i = 0; i < boolOpts.length; i++)self.config[boolOpts[i]] = self.config[boolOpts[i]] === true || self.config[boolOpts[i]] === "true";
|
|
23998
|
-
HOOKS.filter(function(hook) {
|
|
23999
|
-
return self.config[hook] !== undefined;
|
|
24000
|
-
}).forEach(function(hook) {
|
|
24001
|
-
self.config[hook] = arrayify(self.config[hook] || []).map(bindToInstance);
|
|
24002
|
-
});
|
|
24003
|
-
self.isMobile = !self.config.disableMobile && !self.config.inline && self.config.mode === "single" && !self.config.disable.length && !self.config.enable && !self.config.weekNumbers && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
24004
|
-
for(var i = 0; i < self.config.plugins.length; i++){
|
|
24005
|
-
var pluginConf = self.config.plugins[i](self) || {};
|
|
24006
|
-
for(var key in pluginConf){
|
|
24007
|
-
if (HOOKS.indexOf(key) > -1) {
|
|
24008
|
-
self.config[key] = arrayify(pluginConf[key]).map(bindToInstance).concat(self.config[key]);
|
|
24009
|
-
} else if (typeof userConfig[key] === "undefined") self.config[key] = pluginConf[key];
|
|
24010
|
-
}
|
|
24011
|
-
}
|
|
24012
|
-
if (!userConfig.altInputClass) {
|
|
24013
|
-
self.config.altInputClass = getInputElem().className + " " + self.config.altInputClass;
|
|
24014
|
-
}
|
|
24015
|
-
triggerEvent("onParseConfig");
|
|
24016
|
-
}
|
|
24017
|
-
function getInputElem() {
|
|
24018
|
-
return self.config.wrap ? element.querySelector("[data-input]") : element;
|
|
24019
|
-
}
|
|
24020
|
-
function setupLocale() {
|
|
24021
|
-
if (typeof self.config.locale !== "object" && typeof flatpickr.l10ns[self.config.locale] === "undefined") self.config.errorHandler(new Error("flatpickr: invalid locale " + self.config.locale));
|
|
24022
|
-
self.l10n = __assign(__assign({}, flatpickr.l10ns.default), typeof self.config.locale === "object" ? self.config.locale : self.config.locale !== "default" ? flatpickr.l10ns[self.config.locale] : undefined);
|
|
24023
|
-
tokenRegex.D = "(" + self.l10n.weekdays.shorthand.join("|") + ")";
|
|
24024
|
-
tokenRegex.l = "(" + self.l10n.weekdays.longhand.join("|") + ")";
|
|
24025
|
-
tokenRegex.M = "(" + self.l10n.months.shorthand.join("|") + ")";
|
|
24026
|
-
tokenRegex.F = "(" + self.l10n.months.longhand.join("|") + ")";
|
|
24027
|
-
tokenRegex.K = "(" + self.l10n.amPM[0] + "|" + self.l10n.amPM[1] + "|" + self.l10n.amPM[0].toLowerCase() + "|" + self.l10n.amPM[1].toLowerCase() + ")";
|
|
24028
|
-
var userConfig = __assign(__assign({}, instanceConfig), JSON.parse(JSON.stringify(element.dataset || {})));
|
|
24029
|
-
if (userConfig.time_24hr === undefined && flatpickr.defaultConfig.time_24hr === undefined) {
|
|
24030
|
-
self.config.time_24hr = self.l10n.time_24hr;
|
|
24031
|
-
}
|
|
24032
|
-
self.formatDate = createDateFormatter(self);
|
|
24033
|
-
self.parseDate = createDateParser({
|
|
24034
|
-
config: self.config,
|
|
24035
|
-
l10n: self.l10n
|
|
24036
|
-
});
|
|
24037
|
-
}
|
|
24038
|
-
function positionCalendar(customPositionElement) {
|
|
24039
|
-
if (typeof self.config.position === "function") {
|
|
24040
|
-
return void self.config.position(self, customPositionElement);
|
|
24041
|
-
}
|
|
24042
|
-
if (self.calendarContainer === undefined) return;
|
|
24043
|
-
triggerEvent("onPreCalendarPosition");
|
|
24044
|
-
var positionElement = customPositionElement || self._positionElement;
|
|
24045
|
-
var calendarHeight = Array.prototype.reduce.call(self.calendarContainer.children, function(acc, child) {
|
|
24046
|
-
return acc + child.offsetHeight;
|
|
24047
|
-
}, 0), calendarWidth = self.calendarContainer.offsetWidth, configPos = self.config.position.split(" "), configPosVertical = configPos[0], configPosHorizontal = configPos.length > 1 ? configPos[1] : null, inputBounds = positionElement.getBoundingClientRect(), distanceFromBottom = window.innerHeight - inputBounds.bottom, showOnTop = configPosVertical === "above" || configPosVertical !== "below" && distanceFromBottom < calendarHeight && inputBounds.top > calendarHeight;
|
|
24048
|
-
var top = window.pageYOffset + inputBounds.top + (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
|
|
24049
|
-
toggleClass(self.calendarContainer, "arrowTop", !showOnTop);
|
|
24050
|
-
toggleClass(self.calendarContainer, "arrowBottom", showOnTop);
|
|
24051
|
-
if (self.config.inline) return;
|
|
24052
|
-
var left = window.pageXOffset + inputBounds.left;
|
|
24053
|
-
var isCenter = false;
|
|
24054
|
-
var isRight = false;
|
|
24055
|
-
if (configPosHorizontal === "center") {
|
|
24056
|
-
left -= (calendarWidth - inputBounds.width) / 2;
|
|
24057
|
-
isCenter = true;
|
|
24058
|
-
} else if (configPosHorizontal === "right") {
|
|
24059
|
-
left -= calendarWidth - inputBounds.width;
|
|
24060
|
-
isRight = true;
|
|
24061
|
-
}
|
|
24062
|
-
toggleClass(self.calendarContainer, "arrowLeft", !isCenter && !isRight);
|
|
24063
|
-
toggleClass(self.calendarContainer, "arrowCenter", isCenter);
|
|
24064
|
-
toggleClass(self.calendarContainer, "arrowRight", isRight);
|
|
24065
|
-
var right = window.document.body.offsetWidth - (window.pageXOffset + inputBounds.right);
|
|
24066
|
-
var rightMost = left + calendarWidth > window.document.body.offsetWidth;
|
|
24067
|
-
var centerMost = right + calendarWidth > window.document.body.offsetWidth;
|
|
24068
|
-
toggleClass(self.calendarContainer, "rightMost", rightMost);
|
|
24069
|
-
if (self.config.static) return;
|
|
24070
|
-
self.calendarContainer.style.top = top + "px";
|
|
24071
|
-
if (!rightMost) {
|
|
24072
|
-
self.calendarContainer.style.left = left + "px";
|
|
24073
|
-
self.calendarContainer.style.right = "auto";
|
|
24074
|
-
} else if (!centerMost) {
|
|
24075
|
-
self.calendarContainer.style.left = "auto";
|
|
24076
|
-
self.calendarContainer.style.right = right + "px";
|
|
24077
|
-
} else {
|
|
24078
|
-
var doc = getDocumentStyleSheet();
|
|
24079
|
-
if (doc === undefined) return;
|
|
24080
|
-
var bodyWidth = window.document.body.offsetWidth;
|
|
24081
|
-
var centerLeft = Math.max(0, bodyWidth / 2 - calendarWidth / 2);
|
|
24082
|
-
var centerBefore = ".flatpickr-calendar.centerMost:before";
|
|
24083
|
-
var centerAfter = ".flatpickr-calendar.centerMost:after";
|
|
24084
|
-
var centerIndex = doc.cssRules.length;
|
|
24085
|
-
var centerStyle = "{left:" + inputBounds.left + "px;right:auto;}";
|
|
24086
|
-
toggleClass(self.calendarContainer, "rightMost", false);
|
|
24087
|
-
toggleClass(self.calendarContainer, "centerMost", true);
|
|
24088
|
-
doc.insertRule(centerBefore + "," + centerAfter + centerStyle, centerIndex);
|
|
24089
|
-
self.calendarContainer.style.left = centerLeft + "px";
|
|
24090
|
-
self.calendarContainer.style.right = "auto";
|
|
24091
|
-
}
|
|
24092
|
-
}
|
|
24093
|
-
function getDocumentStyleSheet() {
|
|
24094
|
-
var editableSheet = null;
|
|
24095
|
-
for(var i = 0; i < document.styleSheets.length; i++){
|
|
24096
|
-
var sheet = document.styleSheets[i];
|
|
24097
|
-
if (!sheet.cssRules) continue;
|
|
24098
|
-
try {
|
|
24099
|
-
sheet.cssRules;
|
|
24100
|
-
} catch (err) {
|
|
24101
|
-
continue;
|
|
24102
|
-
}
|
|
24103
|
-
editableSheet = sheet;
|
|
24104
|
-
break;
|
|
24105
|
-
}
|
|
24106
|
-
return editableSheet != null ? editableSheet : createStyleSheet();
|
|
24107
|
-
}
|
|
24108
|
-
function createStyleSheet() {
|
|
24109
|
-
var style = document.createElement("style");
|
|
24110
|
-
document.head.appendChild(style);
|
|
24111
|
-
return style.sheet;
|
|
24112
|
-
}
|
|
24113
|
-
function redraw() {
|
|
24114
|
-
if (self.config.noCalendar || self.isMobile) return;
|
|
24115
|
-
buildMonthSwitch();
|
|
24116
|
-
updateNavigationCurrentMonth();
|
|
24117
|
-
buildDays();
|
|
24118
|
-
}
|
|
24119
|
-
function focusAndClose() {
|
|
24120
|
-
self._input.focus();
|
|
24121
|
-
if (window.navigator.userAgent.indexOf("MSIE") !== -1 || navigator.msMaxTouchPoints !== undefined) {
|
|
24122
|
-
setTimeout(self.close, 0);
|
|
24123
|
-
} else {
|
|
24124
|
-
self.close();
|
|
24125
|
-
}
|
|
24126
|
-
}
|
|
24127
|
-
function selectDate(e) {
|
|
24128
|
-
e.preventDefault();
|
|
24129
|
-
e.stopPropagation();
|
|
24130
|
-
var isSelectable = function isSelectable(day) {
|
|
24131
|
-
return day.classList && day.classList.contains("flatpickr-day") && !day.classList.contains("flatpickr-disabled") && !day.classList.contains("notAllowed");
|
|
24132
|
-
};
|
|
24133
|
-
var t = findParent(getEventTarget(e), isSelectable);
|
|
24134
|
-
if (t === undefined) return;
|
|
24135
|
-
var target = t;
|
|
24136
|
-
var selectedDate = self.latestSelectedDateObj = new Date(target.dateObj.getTime());
|
|
24137
|
-
var shouldChangeMonth = (selectedDate.getMonth() < self.currentMonth || selectedDate.getMonth() > self.currentMonth + self.config.showMonths - 1) && self.config.mode !== "range";
|
|
24138
|
-
self.selectedDateElem = target;
|
|
24139
|
-
if (self.config.mode === "single") self.selectedDates = [
|
|
24140
|
-
selectedDate
|
|
24141
|
-
];
|
|
24142
|
-
else if (self.config.mode === "multiple") {
|
|
24143
|
-
var selectedIndex = isDateSelected(selectedDate);
|
|
24144
|
-
if (selectedIndex) self.selectedDates.splice(parseInt(selectedIndex), 1);
|
|
24145
|
-
else self.selectedDates.push(selectedDate);
|
|
24146
|
-
} else if (self.config.mode === "range") {
|
|
24147
|
-
if (self.selectedDates.length === 2) {
|
|
24148
|
-
self.clear(false, false);
|
|
24149
|
-
}
|
|
24150
|
-
self.latestSelectedDateObj = selectedDate;
|
|
24151
|
-
self.selectedDates.push(selectedDate);
|
|
24152
|
-
if (compareDates(selectedDate, self.selectedDates[0], true) !== 0) self.selectedDates.sort(function(a, b) {
|
|
24153
|
-
return a.getTime() - b.getTime();
|
|
24154
|
-
});
|
|
24155
|
-
}
|
|
24156
|
-
setHoursFromInputs();
|
|
24157
|
-
if (shouldChangeMonth) {
|
|
24158
|
-
var isNewYear = self.currentYear !== selectedDate.getFullYear();
|
|
24159
|
-
self.currentYear = selectedDate.getFullYear();
|
|
24160
|
-
self.currentMonth = selectedDate.getMonth();
|
|
24161
|
-
if (isNewYear) {
|
|
24162
|
-
triggerEvent("onYearChange");
|
|
24163
|
-
buildMonthSwitch();
|
|
24164
|
-
}
|
|
24165
|
-
triggerEvent("onMonthChange");
|
|
24166
|
-
}
|
|
24167
|
-
updateNavigationCurrentMonth();
|
|
24168
|
-
buildDays();
|
|
24169
|
-
updateValue();
|
|
24170
|
-
if (!shouldChangeMonth && self.config.mode !== "range" && self.config.showMonths === 1) focusOnDayElem(target);
|
|
24171
|
-
else if (self.selectedDateElem !== undefined && self.hourElement === undefined) {
|
|
24172
|
-
self.selectedDateElem && self.selectedDateElem.focus();
|
|
24173
|
-
}
|
|
24174
|
-
if (self.hourElement !== undefined) self.hourElement !== undefined && self.hourElement.focus();
|
|
24175
|
-
if (self.config.closeOnSelect) {
|
|
24176
|
-
var single = self.config.mode === "single" && !self.config.enableTime;
|
|
24177
|
-
var range = self.config.mode === "range" && self.selectedDates.length === 2 && !self.config.enableTime;
|
|
24178
|
-
if (single || range) {
|
|
24179
|
-
focusAndClose();
|
|
24180
|
-
}
|
|
24181
|
-
}
|
|
24182
|
-
triggerChange();
|
|
24183
|
-
}
|
|
24184
|
-
var CALLBACKS = {
|
|
24185
|
-
locale: [
|
|
24186
|
-
setupLocale,
|
|
24187
|
-
updateWeekdays
|
|
24188
|
-
],
|
|
24189
|
-
showMonths: [
|
|
24190
|
-
buildMonths,
|
|
24191
|
-
setCalendarWidth,
|
|
24192
|
-
buildWeekdays
|
|
24193
|
-
],
|
|
24194
|
-
minDate: [
|
|
24195
|
-
jumpToDate
|
|
24196
|
-
],
|
|
24197
|
-
maxDate: [
|
|
24198
|
-
jumpToDate
|
|
24199
|
-
],
|
|
24200
|
-
positionElement: [
|
|
24201
|
-
updatePositionElement
|
|
24202
|
-
],
|
|
24203
|
-
clickOpens: [
|
|
24204
|
-
function() {
|
|
24205
|
-
if (self.config.clickOpens === true) {
|
|
24206
|
-
bind(self._input, "focus", self.open);
|
|
24207
|
-
bind(self._input, "click", self.open);
|
|
24208
|
-
} else {
|
|
24209
|
-
self._input.removeEventListener("focus", self.open);
|
|
24210
|
-
self._input.removeEventListener("click", self.open);
|
|
24211
|
-
}
|
|
24212
|
-
}
|
|
24213
|
-
]
|
|
24214
|
-
};
|
|
24215
|
-
function set(option, value) {
|
|
24216
|
-
if (option !== null && typeof option === "object") {
|
|
24217
|
-
Object.assign(self.config, option);
|
|
24218
|
-
for(var key in option){
|
|
24219
|
-
if (CALLBACKS[key] !== undefined) CALLBACKS[key].forEach(function(x) {
|
|
24220
|
-
return x();
|
|
24221
|
-
});
|
|
24222
|
-
}
|
|
24223
|
-
} else {
|
|
24224
|
-
self.config[option] = value;
|
|
24225
|
-
if (CALLBACKS[option] !== undefined) CALLBACKS[option].forEach(function(x) {
|
|
24226
|
-
return x();
|
|
24227
|
-
});
|
|
24228
|
-
else if (HOOKS.indexOf(option) > -1) self.config[option] = arrayify(value);
|
|
24229
|
-
}
|
|
24230
|
-
self.redraw();
|
|
24231
|
-
updateValue(true);
|
|
24232
|
-
}
|
|
24233
|
-
function setSelectedDate(inputDate, format) {
|
|
24234
|
-
var dates = [];
|
|
24235
|
-
if (_instanceof(inputDate, Array)) dates = inputDate.map(function(d) {
|
|
24236
|
-
return self.parseDate(d, format);
|
|
24237
|
-
});
|
|
24238
|
-
else if (_instanceof(inputDate, Date) || typeof inputDate === "number") dates = [
|
|
24239
|
-
self.parseDate(inputDate, format)
|
|
24240
|
-
];
|
|
24241
|
-
else if (typeof inputDate === "string") {
|
|
24242
|
-
switch(self.config.mode){
|
|
24243
|
-
case "single":
|
|
24244
|
-
case "time":
|
|
24245
|
-
dates = [
|
|
24246
|
-
self.parseDate(inputDate, format)
|
|
24247
|
-
];
|
|
24248
|
-
break;
|
|
24249
|
-
case "multiple":
|
|
24250
|
-
dates = inputDate.split(self.config.conjunction).map(function(date) {
|
|
24251
|
-
return self.parseDate(date, format);
|
|
24252
|
-
});
|
|
24253
|
-
break;
|
|
24254
|
-
case "range":
|
|
24255
|
-
dates = inputDate.split(self.l10n.rangeSeparator).map(function(date) {
|
|
24256
|
-
return self.parseDate(date, format);
|
|
24257
|
-
});
|
|
24258
|
-
break;
|
|
24259
|
-
}
|
|
24260
|
-
} else self.config.errorHandler(new Error("Invalid date supplied: " + JSON.stringify(inputDate)));
|
|
24261
|
-
self.selectedDates = self.config.allowInvalidPreload ? dates : dates.filter(function(d) {
|
|
24262
|
-
return _instanceof(d, Date) && isEnabled(d, false);
|
|
24263
|
-
});
|
|
24264
|
-
if (self.config.mode === "range") self.selectedDates.sort(function(a, b) {
|
|
24265
|
-
return a.getTime() - b.getTime();
|
|
24266
|
-
});
|
|
24267
|
-
}
|
|
24268
|
-
function setDate(date, triggerChange, format) {
|
|
24269
|
-
if (triggerChange === void 0) {
|
|
24270
|
-
triggerChange = false;
|
|
24271
|
-
}
|
|
24272
|
-
if (format === void 0) {
|
|
24273
|
-
format = self.config.dateFormat;
|
|
24274
|
-
}
|
|
24275
|
-
if (date !== 0 && !date || _instanceof(date, Array) && date.length === 0) return self.clear(triggerChange);
|
|
24276
|
-
setSelectedDate(date, format);
|
|
24277
|
-
self.latestSelectedDateObj = self.selectedDates[self.selectedDates.length - 1];
|
|
24278
|
-
self.redraw();
|
|
24279
|
-
jumpToDate(undefined, triggerChange);
|
|
24280
|
-
setHoursFromDate();
|
|
24281
|
-
if (self.selectedDates.length === 0) {
|
|
24282
|
-
self.clear(false);
|
|
24283
|
-
}
|
|
24284
|
-
updateValue(triggerChange);
|
|
24285
|
-
if (triggerChange) triggerEvent("onChange");
|
|
24286
|
-
}
|
|
24287
|
-
function parseDateRules(arr) {
|
|
24288
|
-
return arr.slice().map(function(rule) {
|
|
24289
|
-
if (typeof rule === "string" || typeof rule === "number" || _instanceof(rule, Date)) {
|
|
24290
|
-
return self.parseDate(rule, undefined, true);
|
|
24291
|
-
} else if (rule && typeof rule === "object" && rule.from && rule.to) return {
|
|
24292
|
-
from: self.parseDate(rule.from, undefined),
|
|
24293
|
-
to: self.parseDate(rule.to, undefined)
|
|
24294
|
-
};
|
|
24295
|
-
return rule;
|
|
24296
|
-
}).filter(function(x) {
|
|
24297
|
-
return x;
|
|
24298
|
-
});
|
|
24299
|
-
}
|
|
24300
|
-
function setupDates() {
|
|
24301
|
-
self.selectedDates = [];
|
|
24302
|
-
self.now = self.parseDate(self.config.now) || new Date();
|
|
24303
|
-
var preloadedDate = self.config.defaultDate || ((self.input.nodeName === "INPUT" || self.input.nodeName === "TEXTAREA") && self.input.placeholder && self.input.value === self.input.placeholder ? null : self.input.value);
|
|
24304
|
-
if (preloadedDate) setSelectedDate(preloadedDate, self.config.dateFormat);
|
|
24305
|
-
self._initialDate = self.selectedDates.length > 0 ? self.selectedDates[0] : self.config.minDate && self.config.minDate.getTime() > self.now.getTime() ? self.config.minDate : self.config.maxDate && self.config.maxDate.getTime() < self.now.getTime() ? self.config.maxDate : self.now;
|
|
24306
|
-
self.currentYear = self._initialDate.getFullYear();
|
|
24307
|
-
self.currentMonth = self._initialDate.getMonth();
|
|
24308
|
-
if (self.selectedDates.length > 0) self.latestSelectedDateObj = self.selectedDates[0];
|
|
24309
|
-
if (self.config.minTime !== undefined) self.config.minTime = self.parseDate(self.config.minTime, "H:i");
|
|
24310
|
-
if (self.config.maxTime !== undefined) self.config.maxTime = self.parseDate(self.config.maxTime, "H:i");
|
|
24311
|
-
self.minDateHasTime = !!self.config.minDate && (self.config.minDate.getHours() > 0 || self.config.minDate.getMinutes() > 0 || self.config.minDate.getSeconds() > 0);
|
|
24312
|
-
self.maxDateHasTime = !!self.config.maxDate && (self.config.maxDate.getHours() > 0 || self.config.maxDate.getMinutes() > 0 || self.config.maxDate.getSeconds() > 0);
|
|
24313
|
-
}
|
|
24314
|
-
function setupInputs() {
|
|
24315
|
-
self.input = getInputElem();
|
|
24316
|
-
if (!self.input) {
|
|
24317
|
-
self.config.errorHandler(new Error("Invalid input element specified"));
|
|
24318
|
-
return;
|
|
24319
|
-
}
|
|
24320
|
-
self.input._type = self.input.type;
|
|
24321
|
-
self.input.type = "text";
|
|
24322
|
-
self.input.classList.add("flatpickr-input");
|
|
24323
|
-
self._input = self.input;
|
|
24324
|
-
if (self.config.altInput) {
|
|
24325
|
-
self.altInput = createElement(self.input.nodeName, self.config.altInputClass);
|
|
24326
|
-
self._input = self.altInput;
|
|
24327
|
-
self.altInput.placeholder = self.input.placeholder;
|
|
24328
|
-
self.altInput.disabled = self.input.disabled;
|
|
24329
|
-
self.altInput.required = self.input.required;
|
|
24330
|
-
self.altInput.tabIndex = self.input.tabIndex;
|
|
24331
|
-
self.altInput.type = "text";
|
|
24332
|
-
self.input.setAttribute("type", "hidden");
|
|
24333
|
-
if (!self.config.static && self.input.parentNode) self.input.parentNode.insertBefore(self.altInput, self.input.nextSibling);
|
|
24334
|
-
}
|
|
24335
|
-
if (!self.config.allowInput) self._input.setAttribute("readonly", "readonly");
|
|
24336
|
-
updatePositionElement();
|
|
24337
|
-
}
|
|
24338
|
-
function updatePositionElement() {
|
|
24339
|
-
self._positionElement = self.config.positionElement || self._input;
|
|
24340
|
-
}
|
|
24341
|
-
function setupMobile() {
|
|
24342
|
-
var inputType = self.config.enableTime ? self.config.noCalendar ? "time" : "datetime-local" : "date";
|
|
24343
|
-
self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
|
|
24344
|
-
self.mobileInput.tabIndex = 1;
|
|
24345
|
-
self.mobileInput.type = inputType;
|
|
24346
|
-
self.mobileInput.disabled = self.input.disabled;
|
|
24347
|
-
self.mobileInput.required = self.input.required;
|
|
24348
|
-
self.mobileInput.placeholder = self.input.placeholder;
|
|
24349
|
-
self.mobileFormatStr = inputType === "datetime-local" ? "Y-m-d\\TH:i:S" : inputType === "date" ? "Y-m-d" : "H:i:S";
|
|
24350
|
-
if (self.selectedDates.length > 0) {
|
|
24351
|
-
self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(self.selectedDates[0], self.mobileFormatStr);
|
|
24352
|
-
}
|
|
24353
|
-
if (self.config.minDate) self.mobileInput.min = self.formatDate(self.config.minDate, "Y-m-d");
|
|
24354
|
-
if (self.config.maxDate) self.mobileInput.max = self.formatDate(self.config.maxDate, "Y-m-d");
|
|
24355
|
-
if (self.input.getAttribute("step")) self.mobileInput.step = String(self.input.getAttribute("step"));
|
|
24356
|
-
self.input.type = "hidden";
|
|
24357
|
-
if (self.altInput !== undefined) self.altInput.type = "hidden";
|
|
24358
|
-
try {
|
|
24359
|
-
if (self.input.parentNode) self.input.parentNode.insertBefore(self.mobileInput, self.input.nextSibling);
|
|
24360
|
-
} catch (_a) {}
|
|
24361
|
-
bind(self.mobileInput, "change", function(e) {
|
|
24362
|
-
self.setDate(getEventTarget(e).value, false, self.mobileFormatStr);
|
|
24363
|
-
triggerEvent("onChange");
|
|
24364
|
-
triggerEvent("onClose");
|
|
24365
|
-
});
|
|
24366
|
-
}
|
|
24367
|
-
function toggle(e) {
|
|
24368
|
-
if (self.isOpen === true) return self.close();
|
|
24369
|
-
self.open(e);
|
|
24370
|
-
}
|
|
24371
|
-
function triggerEvent(event, data) {
|
|
24372
|
-
if (self.config === undefined) return;
|
|
24373
|
-
var hooks = self.config[event];
|
|
24374
|
-
if (hooks !== undefined && hooks.length > 0) {
|
|
24375
|
-
for(var i = 0; hooks[i] && i < hooks.length; i++)hooks[i](self.selectedDates, self.input.value, self, data);
|
|
24376
|
-
}
|
|
24377
|
-
if (event === "onChange") {
|
|
24378
|
-
self.input.dispatchEvent(createEvent("change"));
|
|
24379
|
-
self.input.dispatchEvent(createEvent("input"));
|
|
24380
|
-
}
|
|
24381
|
-
}
|
|
24382
|
-
function createEvent(name) {
|
|
24383
|
-
var e = document.createEvent("Event");
|
|
24384
|
-
e.initEvent(name, true, true);
|
|
24385
|
-
return e;
|
|
24386
|
-
}
|
|
24387
|
-
function isDateSelected(date) {
|
|
24388
|
-
for(var i = 0; i < self.selectedDates.length; i++){
|
|
24389
|
-
var selectedDate = self.selectedDates[i];
|
|
24390
|
-
if (_instanceof(selectedDate, Date) && compareDates(selectedDate, date) === 0) return "" + i;
|
|
24391
|
-
}
|
|
24392
|
-
return false;
|
|
24393
|
-
}
|
|
24394
|
-
function isDateInRange(date) {
|
|
24395
|
-
if (self.config.mode !== "range" || self.selectedDates.length < 2) return false;
|
|
24396
|
-
return compareDates(date, self.selectedDates[0]) >= 0 && compareDates(date, self.selectedDates[1]) <= 0;
|
|
24397
|
-
}
|
|
24398
|
-
function updateNavigationCurrentMonth() {
|
|
24399
|
-
if (self.config.noCalendar || self.isMobile || !self.monthNav) return;
|
|
24400
|
-
self.yearElements.forEach(function(yearElement, i) {
|
|
24401
|
-
var d = new Date(self.currentYear, self.currentMonth, 1);
|
|
24402
|
-
d.setMonth(self.currentMonth + i);
|
|
24403
|
-
if (self.config.showMonths > 1 || self.config.monthSelectorType === "static") {
|
|
24404
|
-
self.monthElements[i].textContent = monthToStr(d.getMonth(), self.config.shorthandCurrentMonth, self.l10n) + " ";
|
|
24405
|
-
} else {
|
|
24406
|
-
self.monthsDropdownContainer.value = d.getMonth().toString();
|
|
24407
|
-
}
|
|
24408
|
-
yearElement.value = d.getFullYear().toString();
|
|
24409
|
-
});
|
|
24410
|
-
self._hidePrevMonthArrow = self.config.minDate !== undefined && (self.currentYear === self.config.minDate.getFullYear() ? self.currentMonth <= self.config.minDate.getMonth() : self.currentYear < self.config.minDate.getFullYear());
|
|
24411
|
-
self._hideNextMonthArrow = self.config.maxDate !== undefined && (self.currentYear === self.config.maxDate.getFullYear() ? self.currentMonth + 1 > self.config.maxDate.getMonth() : self.currentYear > self.config.maxDate.getFullYear());
|
|
24412
|
-
}
|
|
24413
|
-
function getDateStr(specificFormat) {
|
|
24414
|
-
var format = specificFormat || (self.config.altInput ? self.config.altFormat : self.config.dateFormat);
|
|
24415
|
-
return self.selectedDates.map(function(dObj) {
|
|
24416
|
-
return self.formatDate(dObj, format);
|
|
24417
|
-
}).filter(function(d, i, arr) {
|
|
24418
|
-
return self.config.mode !== "range" || self.config.enableTime || arr.indexOf(d) === i;
|
|
24419
|
-
}).join(self.config.mode !== "range" ? self.config.conjunction : self.l10n.rangeSeparator);
|
|
24420
|
-
}
|
|
24421
|
-
function updateValue(triggerChange) {
|
|
24422
|
-
if (triggerChange === void 0) {
|
|
24423
|
-
triggerChange = true;
|
|
24424
|
-
}
|
|
24425
|
-
if (self.mobileInput !== undefined && self.mobileFormatStr) {
|
|
24426
|
-
self.mobileInput.value = self.latestSelectedDateObj !== undefined ? self.formatDate(self.latestSelectedDateObj, self.mobileFormatStr) : "";
|
|
24427
|
-
}
|
|
24428
|
-
self.input.value = getDateStr(self.config.dateFormat);
|
|
24429
|
-
if (self.altInput !== undefined) {
|
|
24430
|
-
self.altInput.value = getDateStr(self.config.altFormat);
|
|
24431
|
-
}
|
|
24432
|
-
if (triggerChange !== false) triggerEvent("onValueUpdate");
|
|
24433
|
-
}
|
|
24434
|
-
function onMonthNavClick(e) {
|
|
24435
|
-
var eventTarget = getEventTarget(e);
|
|
24436
|
-
var isPrevMonth = self.prevMonthNav.contains(eventTarget);
|
|
24437
|
-
var isNextMonth = self.nextMonthNav.contains(eventTarget);
|
|
24438
|
-
if (isPrevMonth || isNextMonth) {
|
|
24439
|
-
changeMonth(isPrevMonth ? -1 : 1);
|
|
24440
|
-
} else if (self.yearElements.indexOf(eventTarget) >= 0) {
|
|
24441
|
-
eventTarget.select();
|
|
24442
|
-
} else if (eventTarget.classList.contains("arrowUp")) {
|
|
24443
|
-
self.changeYear(self.currentYear + 1);
|
|
24444
|
-
} else if (eventTarget.classList.contains("arrowDown")) {
|
|
24445
|
-
self.changeYear(self.currentYear - 1);
|
|
24446
|
-
}
|
|
24447
|
-
}
|
|
24448
|
-
function timeWrapper(e) {
|
|
24449
|
-
e.preventDefault();
|
|
24450
|
-
var isKeyDown = e.type === "keydown", eventTarget = getEventTarget(e), input = eventTarget;
|
|
24451
|
-
if (self.amPM !== undefined && eventTarget === self.amPM) {
|
|
24452
|
-
self.amPM.textContent = self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
|
|
24453
|
-
}
|
|
24454
|
-
var min = parseFloat(input.getAttribute("min")), max = parseFloat(input.getAttribute("max")), step = parseFloat(input.getAttribute("step")), curValue = parseInt(input.value, 10), delta = e.delta || (isKeyDown ? e.which === 38 ? 1 : -1 : 0);
|
|
24455
|
-
var newValue = curValue + step * delta;
|
|
24456
|
-
if (typeof input.value !== "undefined" && input.value.length === 2) {
|
|
24457
|
-
var isHourElem = input === self.hourElement, isMinuteElem = input === self.minuteElement;
|
|
24458
|
-
if (newValue < min) {
|
|
24459
|
-
newValue = max + newValue + int(!isHourElem) + (int(isHourElem) && int(!self.amPM));
|
|
24460
|
-
if (isMinuteElem) incrementNumInput(undefined, -1, self.hourElement);
|
|
24461
|
-
} else if (newValue > max) {
|
|
24462
|
-
newValue = input === self.hourElement ? newValue - max - int(!self.amPM) : min;
|
|
24463
|
-
if (isMinuteElem) incrementNumInput(undefined, 1, self.hourElement);
|
|
24464
|
-
}
|
|
24465
|
-
if (self.amPM && isHourElem && (step === 1 ? newValue + curValue === 23 : Math.abs(newValue - curValue) > step)) {
|
|
24466
|
-
self.amPM.textContent = self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
|
|
24467
|
-
}
|
|
24468
|
-
input.value = pad(newValue);
|
|
24469
|
-
}
|
|
24470
|
-
}
|
|
24471
|
-
init();
|
|
24472
|
-
return self;
|
|
24473
|
-
}
|
|
24474
|
-
function _flatpickr(nodeList, config) {
|
|
24475
|
-
var nodes = Array.prototype.slice.call(nodeList).filter(function(x) {
|
|
24476
|
-
return _instanceof(x, HTMLElement);
|
|
24477
|
-
});
|
|
24478
|
-
var instances = [];
|
|
24479
|
-
for(var i = 0; i < nodes.length; i++){
|
|
24480
|
-
var node = nodes[i];
|
|
24481
|
-
try {
|
|
24482
|
-
if (node.getAttribute("data-fp-omit") !== null) continue;
|
|
24483
|
-
if (node._flatpickr !== undefined) {
|
|
24484
|
-
node._flatpickr.destroy();
|
|
24485
|
-
node._flatpickr = undefined;
|
|
24486
|
-
}
|
|
24487
|
-
node._flatpickr = FlatpickrInstance(node, config || {});
|
|
24488
|
-
instances.push(node._flatpickr);
|
|
24489
|
-
} catch (e) {
|
|
24490
|
-
console.error(e);
|
|
24491
|
-
}
|
|
24492
|
-
}
|
|
24493
|
-
return instances.length === 1 ? instances[0] : instances;
|
|
24494
|
-
}
|
|
24495
|
-
if (typeof HTMLElement !== "undefined" && typeof HTMLCollection !== "undefined" && typeof NodeList !== "undefined") {
|
|
24496
|
-
HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function(config) {
|
|
24497
|
-
return _flatpickr(this, config);
|
|
24498
|
-
};
|
|
24499
|
-
HTMLElement.prototype.flatpickr = function(config) {
|
|
24500
|
-
return _flatpickr([
|
|
24501
|
-
this
|
|
24502
|
-
], config);
|
|
24503
|
-
};
|
|
24504
|
-
}
|
|
24505
|
-
var flatpickr = function flatpickr(selector, config) {
|
|
24506
|
-
if (typeof selector === "string") {
|
|
24507
|
-
return _flatpickr(window.document.querySelectorAll(selector), config);
|
|
24508
|
-
} else if (_instanceof(selector, Node)) {
|
|
24509
|
-
return _flatpickr([
|
|
24510
|
-
selector
|
|
24511
|
-
], config);
|
|
24512
|
-
} else {
|
|
24513
|
-
return _flatpickr(selector, config);
|
|
24514
|
-
}
|
|
24515
|
-
};
|
|
24516
|
-
flatpickr.defaultConfig = {};
|
|
24517
|
-
flatpickr.l10ns = {
|
|
24518
|
-
en: __assign({}, english),
|
|
24519
|
-
default: __assign({}, english)
|
|
24520
|
-
};
|
|
24521
|
-
flatpickr.localize = function(l10n) {
|
|
24522
|
-
flatpickr.l10ns.default = __assign(__assign({}, flatpickr.l10ns.default), l10n);
|
|
24523
|
-
};
|
|
24524
|
-
flatpickr.setDefaults = function(config) {
|
|
24525
|
-
flatpickr.defaultConfig = __assign(__assign({}, flatpickr.defaultConfig), config);
|
|
24526
|
-
};
|
|
24527
|
-
flatpickr.parseDate = createDateParser({});
|
|
24528
|
-
flatpickr.formatDate = createDateFormatter({});
|
|
24529
|
-
flatpickr.compareDates = compareDates;
|
|
24530
|
-
if (typeof jQuery !== "undefined" && typeof jQuery.fn !== "undefined") {
|
|
24531
|
-
jQuery.fn.flatpickr = function(config) {
|
|
24532
|
-
return _flatpickr(this, config);
|
|
24533
|
-
};
|
|
24534
|
-
}
|
|
24535
|
-
Date.prototype.fp_incr = function(days) {
|
|
24536
|
-
return new Date(this.getFullYear(), this.getMonth(), this.getDate() + (typeof days === "string" ? parseInt(days, 10) : days));
|
|
24537
|
-
};
|
|
24538
|
-
if (typeof window !== "undefined") {
|
|
24539
|
-
window.flatpickr = flatpickr;
|
|
24540
|
-
}
|
|
24541
|
-
|
|
24542
|
-
var zhTw = {
|
|
24543
|
-
exports: {}
|
|
24544
|
-
};
|
|
24545
|
-
|
|
24546
|
-
(function (module, exports) {
|
|
24547
|
-
(function(global, factory) {
|
|
24548
|
-
factory(exports) ;
|
|
24549
|
-
})(_commonjsHelpers.commonjsGlobal, function(exports1) {
|
|
24550
|
-
var fp = typeof window !== "undefined" && window.flatpickr !== undefined ? window.flatpickr : {
|
|
24551
|
-
l10ns: {}
|
|
24552
|
-
};
|
|
24553
|
-
var MandarinTraditional = {
|
|
24554
|
-
weekdays: {
|
|
24555
|
-
shorthand: [
|
|
24556
|
-
"週日",
|
|
24557
|
-
"週一",
|
|
24558
|
-
"週二",
|
|
24559
|
-
"週三",
|
|
24560
|
-
"週四",
|
|
24561
|
-
"週五",
|
|
24562
|
-
"週六"
|
|
24563
|
-
],
|
|
24564
|
-
longhand: [
|
|
24565
|
-
"星期日",
|
|
24566
|
-
"星期一",
|
|
24567
|
-
"星期二",
|
|
24568
|
-
"星期三",
|
|
24569
|
-
"星期四",
|
|
24570
|
-
"星期五",
|
|
24571
|
-
"星期六"
|
|
24572
|
-
]
|
|
24573
|
-
},
|
|
24574
|
-
months: {
|
|
24575
|
-
shorthand: [
|
|
24576
|
-
"一月",
|
|
24577
|
-
"二月",
|
|
24578
|
-
"三月",
|
|
24579
|
-
"四月",
|
|
24580
|
-
"五月",
|
|
24581
|
-
"六月",
|
|
24582
|
-
"七月",
|
|
24583
|
-
"八月",
|
|
24584
|
-
"九月",
|
|
24585
|
-
"十月",
|
|
24586
|
-
"十一月",
|
|
24587
|
-
"十二月"
|
|
24588
|
-
],
|
|
24589
|
-
longhand: [
|
|
24590
|
-
"一月",
|
|
24591
|
-
"二月",
|
|
24592
|
-
"三月",
|
|
24593
|
-
"四月",
|
|
24594
|
-
"五月",
|
|
24595
|
-
"六月",
|
|
24596
|
-
"七月",
|
|
24597
|
-
"八月",
|
|
24598
|
-
"九月",
|
|
24599
|
-
"十月",
|
|
24600
|
-
"十一月",
|
|
24601
|
-
"十二月"
|
|
24602
|
-
]
|
|
24603
|
-
},
|
|
24604
|
-
rangeSeparator: " 至 ",
|
|
24605
|
-
weekAbbreviation: "週",
|
|
24606
|
-
scrollTitle: "滾動切換",
|
|
24607
|
-
toggleTitle: "點擊切換 12/24 小時時制"
|
|
24608
|
-
};
|
|
24609
|
-
fp.l10ns.zh_tw = MandarinTraditional;
|
|
24610
|
-
var zhTw = fp.l10ns;
|
|
24611
|
-
exports1.MandarinTraditional = MandarinTraditional;
|
|
24612
|
-
exports1.default = zhTw;
|
|
24613
|
-
Object.defineProperty(exports1, "__esModule", {
|
|
24614
|
-
value: true
|
|
24615
|
-
});
|
|
24616
|
-
});
|
|
24617
|
-
}(zhTw, zhTw.exports));
|
|
24618
|
-
|
|
24619
|
-
var Mandarin = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(zhTw.exports);
|
|
24620
|
-
|
|
24621
22253
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
24622
22254
|
// @ts-nocheck
|
|
24623
22255
|
function _define_property$2(obj, key, value) {
|
|
@@ -24679,7 +22311,7 @@ var FlatpickrInput = /*#__PURE__*/ React.forwardRef(function(param, ref) {
|
|
|
24679
22311
|
var flatpickrInstance = React.useRef(null);
|
|
24680
22312
|
var defaultOptions = React.useMemo(function() {
|
|
24681
22313
|
var options = _object_spread$2({
|
|
24682
|
-
locale:
|
|
22314
|
+
locale: Mandarin__default["default"].zh_tw,
|
|
24683
22315
|
dateFormat: "Y-m-d",
|
|
24684
22316
|
enableTime: false,
|
|
24685
22317
|
mode: "single",
|
|
@@ -24710,7 +22342,7 @@ var FlatpickrInput = /*#__PURE__*/ React.forwardRef(function(param, ref) {
|
|
|
24710
22342
|
var _item_flatpickrOptions, _item_flatpickrOptions1;
|
|
24711
22343
|
var mode = (item === null || item === void 0 ? void 0 : (_item_flatpickrOptions = item.flatpickrOptions) === null || _item_flatpickrOptions === void 0 ? void 0 : _item_flatpickrOptions.mode) || "single";
|
|
24712
22344
|
var defaultDateValue = value || (item === null || item === void 0 ? void 0 : (_item_flatpickrOptions1 = item.flatpickrOptions) === null || _item_flatpickrOptions1 === void 0 ? void 0 : _item_flatpickrOptions1.defaultDate);
|
|
24713
|
-
flatpickrInstance.current =
|
|
22345
|
+
flatpickrInstance.current = flatpickr__default["default"](flatpickrRef.current, _object_spread_props$2(_object_spread$2({}, defaultOptions), {
|
|
24714
22346
|
defaultDate: defaultDateValue,
|
|
24715
22347
|
onChange: function(selectedDates, dateStr, instance) {
|
|
24716
22348
|
if (mode === "range") {
|
|
@@ -24733,6 +22365,7 @@ var FlatpickrInput = /*#__PURE__*/ React.forwardRef(function(param, ref) {
|
|
|
24733
22365
|
value,
|
|
24734
22366
|
item === null || item === void 0 ? void 0 : (_item_flatpickrOptions = item.flatpickrOptions) === null || _item_flatpickrOptions === void 0 ? void 0 : _item_flatpickrOptions.defaultDate,
|
|
24735
22367
|
item === null || item === void 0 ? void 0 : (_item_flatpickrOptions1 = item.flatpickrOptions) === null || _item_flatpickrOptions1 === void 0 ? void 0 : _item_flatpickrOptions1.mode,
|
|
22368
|
+
item === null || item === void 0 ? void 0 : item.flatpickrType,
|
|
24736
22369
|
onChange
|
|
24737
22370
|
]);
|
|
24738
22371
|
var destroyFlatpickr = React.useCallback(function() {
|