@7pmlabs/design-system 0.5.5 → 0.5.6
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/dist/design-system102.js +1 -1
- package/dist/design-system102.js.map +1 -1
- package/dist/design-system102.mjs +2172 -17
- package/dist/design-system102.mjs.map +1 -1
- package/dist/design-system103.js +1 -1
- package/dist/design-system103.js.map +1 -1
- package/dist/design-system103.mjs +1103 -68
- package/dist/design-system103.mjs.map +1 -1
- package/dist/design-system104.js +1 -1
- package/dist/design-system104.js.map +1 -1
- package/dist/design-system104.mjs +16 -5
- package/dist/design-system104.mjs.map +1 -1
- package/dist/design-system105.js +1 -1
- package/dist/design-system105.js.map +1 -1
- package/dist/design-system105.mjs +25 -67
- package/dist/design-system105.mjs.map +1 -1
- package/dist/design-system106.js +1 -1
- package/dist/design-system106.js.map +1 -1
- package/dist/design-system106.mjs +60 -2165
- package/dist/design-system106.mjs.map +1 -1
- package/dist/design-system107.js +1 -1
- package/dist/design-system107.js.map +1 -1
- package/dist/design-system107.mjs +68 -1103
- package/dist/design-system107.mjs.map +1 -1
- package/dist/design-system108.js +1 -1
- package/dist/design-system108.js.map +1 -1
- package/dist/design-system108.mjs +5 -24
- package/dist/design-system108.mjs.map +1 -1
- package/dist/design-system114.js +1 -1
- package/dist/design-system114.mjs +1 -1
- package/dist/design-system115.js +1 -1
- package/dist/design-system115.js.map +1 -1
- package/dist/design-system115.mjs +2 -4
- package/dist/design-system115.mjs.map +1 -1
- package/dist/design-system116.js +1 -1
- package/dist/design-system116.js.map +1 -1
- package/dist/design-system116.mjs +2 -8
- package/dist/design-system116.mjs.map +1 -1
- package/dist/design-system117.js +1 -1
- package/dist/design-system117.js.map +1 -1
- package/dist/design-system117.mjs +2 -7
- package/dist/design-system117.mjs.map +1 -1
- package/dist/design-system118.js +1 -1
- package/dist/design-system118.js.map +1 -1
- package/dist/design-system118.mjs +4 -2
- package/dist/design-system118.mjs.map +1 -1
- package/dist/design-system119.js +1 -1
- package/dist/design-system119.js.map +1 -1
- package/dist/design-system119.mjs +8 -2
- package/dist/design-system119.mjs.map +1 -1
- package/dist/design-system120.js +1 -1
- package/dist/design-system120.js.map +1 -1
- package/dist/design-system120.mjs +7 -2
- package/dist/design-system120.mjs.map +1 -1
- package/dist/design-system121.js +1 -1
- package/dist/design-system121.mjs +1 -1
- package/dist/design-system13.js +1 -1
- package/dist/design-system13.mjs +3 -3
- package/dist/design-system15.js +1 -1
- package/dist/design-system15.mjs +3 -3
- package/dist/design-system151.js +1 -1
- package/dist/design-system151.js.map +1 -1
- package/dist/design-system151.mjs +7 -11
- package/dist/design-system151.mjs.map +1 -1
- package/dist/design-system152.js +1 -1
- package/dist/design-system152.js.map +1 -1
- package/dist/design-system152.mjs +9 -7
- package/dist/design-system152.mjs.map +1 -1
- package/dist/design-system153.js +1 -1
- package/dist/design-system153.js.map +1 -1
- package/dist/design-system153.mjs +11 -9
- package/dist/design-system153.mjs.map +1 -1
- package/dist/design-system157.js +1 -1
- package/dist/design-system157.mjs +1 -1
- package/dist/design-system158.js +1 -1
- package/dist/design-system158.mjs +1 -1
- package/dist/design-system16.js +1 -1
- package/dist/design-system16.mjs +1 -1
- package/dist/design-system161.js +1 -1
- package/dist/design-system161.mjs +1 -1
- package/dist/design-system162.js +1 -1
- package/dist/design-system162.mjs +1 -1
- package/dist/design-system18.js +1 -1
- package/dist/design-system18.mjs +1 -1
- package/dist/design-system19.js +1 -1
- package/dist/design-system19.mjs +1 -1
- package/dist/design-system20.js +1 -1
- package/dist/design-system20.mjs +3 -3
- package/dist/design-system22.js +1 -1
- package/dist/design-system22.mjs +1 -1
- package/dist/design-system23.js +1 -1
- package/dist/design-system23.mjs +1 -1
- package/dist/design-system26.js +1 -1
- package/dist/design-system26.mjs +1 -1
- package/dist/design-system59.js +1 -1
- package/dist/design-system59.mjs +1 -1
- package/dist/design-system76.js +1 -1
- package/dist/design-system76.mjs +1 -1
- package/dist/design-system80.js +1 -1
- package/dist/design-system80.mjs +1 -1
- package/dist/design-system83.js +1 -1
- package/dist/design-system83.mjs +1 -1
- package/dist/design-system89.js +1 -1
- package/dist/design-system89.mjs +2 -2
- package/dist/design-system92.js +1 -1
- package/dist/design-system92.mjs +2 -2
- package/dist/design-system94.js +1 -1
- package/dist/design-system94.mjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/types/playground/PlaygroundView.vue.d.ts +0 -2
|
@@ -1,71 +1,1106 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
()
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
1
|
+
import { getDefaultExportFromCjs as De, commonjsGlobal as ve } from "./design-system111.mjs";
|
|
2
|
+
import { __module as ne } from "./design-system117.mjs";
|
|
3
|
+
(function(re, fe) {
|
|
4
|
+
(function(U, j) {
|
|
5
|
+
re.exports = j();
|
|
6
|
+
})(ve, function() {
|
|
7
|
+
return function() {
|
|
8
|
+
var U = { d: function(r, e) {
|
|
9
|
+
for (var t in e)
|
|
10
|
+
U.o(e, t) && !U.o(r, t) && Object.defineProperty(r, t, { enumerable: !0, get: e[t] });
|
|
11
|
+
}, o: function(r, e) {
|
|
12
|
+
return Object.prototype.hasOwnProperty.call(r, e);
|
|
13
|
+
} }, j = {};
|
|
14
|
+
U.d(j, { default: function() {
|
|
15
|
+
return T;
|
|
16
|
+
} });
|
|
17
|
+
var l = { days: "days", months: "months", years: "years", day: "day", month: "month", year: "year", eventChangeViewDate: "changeViewDate", eventChangeCurrentView: "changeCurrentView", eventChangeFocusDate: "changeFocusDate", eventChangeSelectedDate: "changeSelectedDate", eventChangeTime: "changeTime", eventChangeLastSelectedDate: "changeLastSelectedDate", actionSelectDate: "selectDate", actionUnselectDate: "unselectDate", cssClassWeekend: "-weekend-" }, Q = { classes: "", inline: !1, locale: { days: ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"], daysShort: ["Вос", "Пон", "Вто", "Сре", "Чет", "Пят", "Суб"], daysMin: ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"], months: ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"], monthsShort: ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"], today: "Сегодня", clear: "Очистить", dateFormat: "dd.MM.yyyy", timeFormat: "HH:mm", firstDay: 1 }, startDate: /* @__PURE__ */ new Date(), firstDay: "", weekends: [6, 0], dateFormat: "", altField: "", altFieldDateFormat: "T", toggleSelected: !0, keyboardNav: !0, selectedDates: !1, container: "", isMobile: !1, visible: !1, position: "bottom left", offset: 12, view: l.days, minView: l.days, showOtherMonths: !0, selectOtherMonths: !0, moveToOtherMonthsOnSelect: !0, showOtherYears: !0, selectOtherYears: !0, moveToOtherYearsOnSelect: !0, minDate: "", maxDate: "", disableNavWhenOutOfRange: !0, multipleDates: !1, multipleDatesSeparator: ", ", range: !1, dynamicRange: !0, buttons: !1, monthsField: "monthsShort", showEvent: "focus", autoClose: !1, prevHtml: '<svg><path d="M 17,12 l -5,5 l 5,5"></path></svg>', nextHtml: '<svg><path d="M 14,12 l 5,5 l -5,5"></path></svg>', navTitles: { days: "MMMM, <i>yyyy</i>", months: "yyyy", years: "yyyy1 - yyyy2" }, timepicker: !1, onlyTimepicker: !1, dateTimeSeparator: " ", timeFormat: "", minHours: 0, maxHours: 24, minMinutes: 0, maxMinutes: 59, hoursStep: 1, minutesStep: 1, onSelect: !1, onChangeViewDate: !1, onChangeView: !1, onRenderCell: !1, onShow: !1, onHide: !1, onClickDayName: !1 };
|
|
18
|
+
function y(r) {
|
|
19
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : document;
|
|
20
|
+
return typeof r == "string" ? e.querySelector(r) : r;
|
|
21
|
+
}
|
|
22
|
+
function b() {
|
|
23
|
+
let { tagName: r = "div", className: e = "", innerHtml: t = "", id: s = "", attrs: a = {} } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = document.createElement(r);
|
|
24
|
+
return e && n.classList.add(...e.split(" ")), s && (n.id = s), t && (n.innerHTML = t), a && q(n, a), n;
|
|
25
|
+
}
|
|
26
|
+
function q(r, e) {
|
|
27
|
+
for (let [t, s] of Object.entries(e))
|
|
28
|
+
s !== void 0 && r.setAttribute(t, s);
|
|
29
|
+
return r;
|
|
30
|
+
}
|
|
31
|
+
function Z(r) {
|
|
32
|
+
return new Date(r.getFullYear(), r.getMonth() + 1, 0).getDate();
|
|
33
|
+
}
|
|
34
|
+
function D(r) {
|
|
35
|
+
let e = r.getHours(), t = e % 12 == 0 ? 12 : e % 12;
|
|
36
|
+
return { year: r.getFullYear(), month: r.getMonth(), fullMonth: r.getMonth() + 1 < 10 ? "0" + (r.getMonth() + 1) : r.getMonth() + 1, date: r.getDate(), fullDate: r.getDate() < 10 ? "0" + r.getDate() : r.getDate(), day: r.getDay(), hours: e, fullHours: O(e), hours12: t, fullHours12: O(t), minutes: r.getMinutes(), fullMinutes: r.getMinutes() < 10 ? "0" + r.getMinutes() : r.getMinutes() };
|
|
37
|
+
}
|
|
38
|
+
function O(r) {
|
|
39
|
+
return r < 10 ? "0" + r : r;
|
|
40
|
+
}
|
|
41
|
+
function F(r) {
|
|
42
|
+
let e = 10 * Math.floor(r.getFullYear() / 10);
|
|
43
|
+
return [e, e + 9];
|
|
44
|
+
}
|
|
45
|
+
function M() {
|
|
46
|
+
let r = [];
|
|
47
|
+
for (var e = arguments.length, t = new Array(e), s = 0; s < e; s++)
|
|
48
|
+
t[s] = arguments[s];
|
|
49
|
+
return t.forEach((a) => {
|
|
50
|
+
if (typeof a == "object")
|
|
51
|
+
for (let n in a)
|
|
52
|
+
a[n] && r.push(n);
|
|
53
|
+
else
|
|
54
|
+
a && r.push(a);
|
|
55
|
+
}), r.join(" ");
|
|
56
|
+
}
|
|
57
|
+
function v(r, e) {
|
|
58
|
+
let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : l.days;
|
|
59
|
+
if (!r || !e)
|
|
60
|
+
return !1;
|
|
61
|
+
let s = D(r), a = D(e);
|
|
62
|
+
return { [l.days]: s.date === a.date && s.month === a.month && s.year === a.year, [l.months]: s.month === a.month && s.year === a.year, [l.years]: s.year === a.year }[t];
|
|
63
|
+
}
|
|
64
|
+
function $(r, e, t) {
|
|
65
|
+
let s = J(r, !1).getTime(), a = J(e, !1).getTime();
|
|
66
|
+
return t ? s >= a : s > a;
|
|
67
|
+
}
|
|
68
|
+
function E(r, e) {
|
|
69
|
+
return !$(r, e, !0);
|
|
70
|
+
}
|
|
71
|
+
function J(r) {
|
|
72
|
+
let e = !(arguments.length > 1 && arguments[1] !== void 0) || arguments[1], t = new Date(r.getTime());
|
|
73
|
+
return typeof e != "boolean" || e || he(t), t;
|
|
74
|
+
}
|
|
75
|
+
function he(r) {
|
|
76
|
+
return r.setHours(0, 0, 0, 0), r;
|
|
77
|
+
}
|
|
78
|
+
function w(r, e, t) {
|
|
79
|
+
r.length ? r.forEach((s) => {
|
|
80
|
+
s.addEventListener(e, t);
|
|
81
|
+
}) : r.addEventListener(e, t);
|
|
82
|
+
}
|
|
83
|
+
function R(r, e) {
|
|
84
|
+
return !(!r || r === document || r instanceof DocumentFragment) && (r.matches(e) ? r : R(r.parentNode, e));
|
|
85
|
+
}
|
|
86
|
+
function A(r, e, t) {
|
|
87
|
+
return r > t ? t : r < e ? e : r;
|
|
88
|
+
}
|
|
89
|
+
function Y(r) {
|
|
90
|
+
for (var e = arguments.length, t = new Array(e > 1 ? e - 1 : 0), s = 1; s < e; s++)
|
|
91
|
+
t[s - 1] = arguments[s];
|
|
92
|
+
return t.filter((a) => a).forEach((a) => {
|
|
93
|
+
for (let [n, i] of Object.entries(a))
|
|
94
|
+
if (i !== void 0 && i.toString() === "[object Object]") {
|
|
95
|
+
let h = r[n] !== void 0 ? r[n].toString() : void 0, o = i.toString(), d = Array.isArray(i) ? [] : {};
|
|
96
|
+
r[n] = r[n] ? h !== o ? d : r[n] : d, Y(r[n], i);
|
|
97
|
+
} else
|
|
98
|
+
r[n] = i;
|
|
99
|
+
}), r;
|
|
100
|
+
}
|
|
101
|
+
function C(r) {
|
|
102
|
+
let e = r;
|
|
103
|
+
return r instanceof Date || (e = new Date(r)), isNaN(e.getTime()) && (console.log('Unable to convert value "'.concat(r, '" to Date object')), e = !1), e;
|
|
104
|
+
}
|
|
105
|
+
function G(r) {
|
|
106
|
+
let e = "\\s|\\.|-|/|\\\\|,|\\$|\\!|\\?|:|;";
|
|
107
|
+
return new RegExp("(^|>|" + e + ")(" + r + ")($|<|" + e + ")", "g");
|
|
108
|
+
}
|
|
109
|
+
function V(r, e, t) {
|
|
110
|
+
return e in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
|
|
111
|
+
}
|
|
112
|
+
class oe {
|
|
113
|
+
constructor() {
|
|
114
|
+
let { type: e, date: t, dp: s, opts: a, body: n } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
115
|
+
V(this, "focus", () => {
|
|
116
|
+
this.$cell.classList.add("-focus-"), this.focused = !0;
|
|
117
|
+
}), V(this, "removeFocus", () => {
|
|
118
|
+
this.$cell.classList.remove("-focus-"), this.focused = !1;
|
|
119
|
+
}), V(this, "select", () => {
|
|
120
|
+
this.$cell.classList.add("-selected-"), this.selected = !0;
|
|
121
|
+
}), V(this, "removeSelect", () => {
|
|
122
|
+
this.$cell.classList.remove("-selected-", "-range-from-", "-range-to-"), this.selected = !1;
|
|
123
|
+
}), V(this, "onChangeSelectedDate", () => {
|
|
124
|
+
this.isDisabled || (this._handleSelectedStatus(), this.opts.range && this._handleRangeStatus());
|
|
125
|
+
}), V(this, "onChangeFocusDate", (i) => {
|
|
126
|
+
if (!i)
|
|
127
|
+
return void (this.focused && this.removeFocus());
|
|
128
|
+
let h = v(i, this.date, this.type);
|
|
129
|
+
h ? this.focus() : !h && this.focused && this.removeFocus(), this.opts.range && this._handleRangeStatus();
|
|
130
|
+
}), V(this, "render", () => (this.$cell.innerHTML = this._getHtml(), this.$cell.adpCell = this, this.$cell)), this.type = e, this.singleType = this.type.slice(0, -1), this.date = t, this.dp = s, this.opts = a, this.body = n, this.customData = !1, this.init();
|
|
131
|
+
}
|
|
132
|
+
init() {
|
|
133
|
+
let { range: e, onRenderCell: t } = this.opts;
|
|
134
|
+
t && (this.customData = t({ date: this.date, cellType: this.singleType, datepicker: this.dp })), this._createElement(), this._bindDatepickerEvents(), this._handleInitialFocusStatus(), this.dp.hasSelectedDates && (this._handleSelectedStatus(), e && this._handleRangeStatus());
|
|
135
|
+
}
|
|
136
|
+
_bindDatepickerEvents() {
|
|
137
|
+
this.dp.on(l.eventChangeSelectedDate, this.onChangeSelectedDate), this.dp.on(l.eventChangeFocusDate, this.onChangeFocusDate);
|
|
138
|
+
}
|
|
139
|
+
unbindDatepickerEvents() {
|
|
140
|
+
this.dp.off(l.eventChangeSelectedDate, this.onChangeSelectedDate), this.dp.off(l.eventChangeFocusDate, this.onChangeFocusDate);
|
|
141
|
+
}
|
|
142
|
+
_createElement() {
|
|
143
|
+
var e;
|
|
144
|
+
let { year: t, month: s, date: a } = D(this.date), n = ((e = this.customData) === null || e === void 0 ? void 0 : e.attrs) || {};
|
|
145
|
+
this.$cell = b({ className: this._getClassName(), attrs: { "data-year": t, "data-month": s, "data-date": a, ...n } });
|
|
146
|
+
}
|
|
147
|
+
_getClassName() {
|
|
148
|
+
var e, t;
|
|
149
|
+
let s = /* @__PURE__ */ new Date(), { selectOtherMonths: a, selectOtherYears: n } = this.opts, { minDate: i, maxDate: h } = this.dp, { day: o } = D(this.date), d = this._isOutOfMinMaxRange(), c = (e = this.customData) === null || e === void 0 ? void 0 : e.disabled, u = M("air-datepicker-cell", "-".concat(this.singleType, "-"), { "-current-": v(s, this.date, this.type), "-min-date-": i && v(i, this.date, this.type), "-max-date-": h && v(h, this.date, this.type) }), p = "";
|
|
150
|
+
switch (this.type) {
|
|
151
|
+
case l.days:
|
|
152
|
+
p = M({ "-weekend-": this.dp.isWeekend(o), "-other-month-": this.isOtherMonth, "-disabled-": this.isOtherMonth && !a || d || c });
|
|
153
|
+
break;
|
|
154
|
+
case l.months:
|
|
155
|
+
p = M({ "-disabled-": d || c });
|
|
156
|
+
break;
|
|
157
|
+
case l.years:
|
|
158
|
+
p = M({ "-other-decade-": this.isOtherDecade, "-disabled-": d || this.isOtherDecade && !n || c });
|
|
159
|
+
}
|
|
160
|
+
return M(u, p, (t = this.customData) === null || t === void 0 ? void 0 : t.classes);
|
|
161
|
+
}
|
|
162
|
+
_getHtml() {
|
|
163
|
+
var e;
|
|
164
|
+
let { year: t, month: s, date: a } = D(this.date), { showOtherMonths: n, showOtherYears: i } = this.opts;
|
|
165
|
+
if ((e = this.customData) !== null && e !== void 0 && e.html)
|
|
166
|
+
return this.customData.html;
|
|
167
|
+
switch (this.type) {
|
|
168
|
+
case l.days:
|
|
169
|
+
return !n && this.isOtherMonth ? "" : a;
|
|
170
|
+
case l.months:
|
|
171
|
+
return this.dp.locale[this.opts.monthsField][s];
|
|
172
|
+
case l.years:
|
|
173
|
+
return !i && this.isOtherDecade ? "" : t;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
_isOutOfMinMaxRange() {
|
|
177
|
+
let { minDate: e, maxDate: t } = this.dp, { type: s, date: a } = this, { month: n, year: i, date: h } = D(a), o = s === l.days, d = s === l.years, c = !!e && new Date(i, d ? e.getMonth() : n, o ? h : e.getDate()), u = !!t && new Date(i, d ? t.getMonth() : n, o ? h : t.getDate());
|
|
178
|
+
return e && t ? E(c, e) || $(u, t) : e ? E(c, e) : t ? $(u, t) : void 0;
|
|
179
|
+
}
|
|
180
|
+
destroy() {
|
|
181
|
+
this.unbindDatepickerEvents();
|
|
182
|
+
}
|
|
183
|
+
_handleRangeStatus() {
|
|
184
|
+
let { rangeDateFrom: e, rangeDateTo: t } = this.dp, s = M({ "-in-range-": e && t && (a = this.date, n = e, i = t, $(a, n) && E(a, i)), "-range-from-": e && v(this.date, e, this.type), "-range-to-": t && v(this.date, t, this.type) });
|
|
185
|
+
var a, n, i;
|
|
186
|
+
this.$cell.classList.remove("-range-from-", "-range-to-", "-in-range-"), s && this.$cell.classList.add(...s.split(" "));
|
|
187
|
+
}
|
|
188
|
+
_handleSelectedStatus() {
|
|
189
|
+
let e = this.dp._checkIfDateIsSelected(this.date, this.type);
|
|
190
|
+
e ? this.select() : !e && this.selected && this.removeSelect();
|
|
191
|
+
}
|
|
192
|
+
_handleInitialFocusStatus() {
|
|
193
|
+
v(this.dp.focusDate, this.date, this.type) && this.focus();
|
|
194
|
+
}
|
|
195
|
+
get isDisabled() {
|
|
196
|
+
return this.$cell.matches(".-disabled-");
|
|
197
|
+
}
|
|
198
|
+
get isOtherMonth() {
|
|
199
|
+
return this.dp.isOtherMonth(this.date);
|
|
200
|
+
}
|
|
201
|
+
get isOtherDecade() {
|
|
202
|
+
return this.dp.isOtherDecade(this.date);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function k(r, e, t) {
|
|
206
|
+
return e in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
|
|
207
|
+
}
|
|
208
|
+
let le = { [l.days]: '<div class="air-datepicker-body--day-names"></div>' + '<div class="air-datepicker-body--cells -'.concat(l.days, '-"></div>'), [l.months]: '<div class="air-datepicker-body--cells -'.concat(l.months, '-"></div>'), [l.years]: '<div class="air-datepicker-body--cells -'.concat(l.years, '-"></div>') };
|
|
209
|
+
const P = ".air-datepicker-cell";
|
|
210
|
+
class ee {
|
|
211
|
+
constructor(e) {
|
|
212
|
+
let { dp: t, type: s, opts: a } = e;
|
|
213
|
+
k(this, "handleClick", (n) => {
|
|
214
|
+
let i = n.target.closest(P).adpCell;
|
|
215
|
+
if (i.isDisabled)
|
|
216
|
+
return;
|
|
217
|
+
if (!this.dp.isMinViewReached)
|
|
218
|
+
return void this.dp.down();
|
|
219
|
+
let h = this.dp._checkIfDateIsSelected(i.date, i.type);
|
|
220
|
+
h ? this.dp._handleAlreadySelectedDates(h, i.date) : this.dp.selectDate(i.date);
|
|
221
|
+
}), k(this, "handleDayNameClick", (n) => {
|
|
222
|
+
let i = n.target.getAttribute("data-day-index");
|
|
223
|
+
this.opts.onClickDayName({ dayIndex: Number(i), datepicker: this.dp });
|
|
224
|
+
}), k(this, "onChangeCurrentView", (n) => {
|
|
225
|
+
n !== this.type ? this.hide() : (this.show(), this.render());
|
|
226
|
+
}), k(this, "onMouseOverCell", (n) => {
|
|
227
|
+
let i = R(n.target, P);
|
|
228
|
+
this.dp.setFocusDate(!!i && i.adpCell.date);
|
|
229
|
+
}), k(this, "onMouseOutCell", () => {
|
|
230
|
+
this.dp.setFocusDate(!1);
|
|
231
|
+
}), k(this, "onClickBody", (n) => {
|
|
232
|
+
let { onClickDayName: i } = this.opts, h = n.target;
|
|
233
|
+
h.closest(P) && this.handleClick(n), i && h.closest(".air-datepicker-body--day-name") && this.handleDayNameClick(n);
|
|
234
|
+
}), k(this, "onMouseDown", (n) => {
|
|
235
|
+
this.pressed = !0;
|
|
236
|
+
let i = R(n.target, P), h = i && i.adpCell;
|
|
237
|
+
v(h.date, this.dp.rangeDateFrom) && (this.rangeFromFocused = !0), v(h.date, this.dp.rangeDateTo) && (this.rangeToFocused = !0);
|
|
238
|
+
}), k(this, "onMouseMove", (n) => {
|
|
239
|
+
if (!this.pressed || !this.dp.isMinViewReached)
|
|
240
|
+
return;
|
|
241
|
+
n.preventDefault();
|
|
242
|
+
let i = R(n.target, P), h = i && i.adpCell, { selectedDates: o, rangeDateTo: d, rangeDateFrom: c } = this.dp;
|
|
243
|
+
if (!h || h.isDisabled)
|
|
244
|
+
return;
|
|
245
|
+
let { date: u } = h;
|
|
246
|
+
if (o.length === 2) {
|
|
247
|
+
if (this.rangeFromFocused && !$(u, d)) {
|
|
248
|
+
let { hours: p, minutes: g } = D(c);
|
|
249
|
+
u.setHours(p), u.setMinutes(g), this.dp.rangeDateFrom = u, this.dp.replaceDate(c, u);
|
|
250
|
+
}
|
|
251
|
+
if (this.rangeToFocused && !E(u, c)) {
|
|
252
|
+
let { hours: p, minutes: g } = D(d);
|
|
253
|
+
u.setHours(p), u.setMinutes(g), this.dp.rangeDateTo = u, this.dp.replaceDate(d, u);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}), k(this, "onMouseUp", () => {
|
|
257
|
+
this.pressed = !1, this.rangeFromFocused = !1, this.rangeToFocused = !1;
|
|
258
|
+
}), k(this, "onChangeViewDate", (n, i) => {
|
|
259
|
+
if (!this.isVisible)
|
|
260
|
+
return;
|
|
261
|
+
let h = F(n), o = F(i);
|
|
262
|
+
switch (this.dp.currentView) {
|
|
263
|
+
case l.days:
|
|
264
|
+
if (v(n, i, l.months))
|
|
265
|
+
return;
|
|
266
|
+
break;
|
|
267
|
+
case l.months:
|
|
268
|
+
if (v(n, i, l.years))
|
|
269
|
+
return;
|
|
270
|
+
break;
|
|
271
|
+
case l.years:
|
|
272
|
+
if (h[0] === o[0] && h[1] === o[1])
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
this.render();
|
|
276
|
+
}), k(this, "render", () => {
|
|
277
|
+
this.destroyCells(), this._generateCells(), this.cells.forEach((n) => {
|
|
278
|
+
this.$cells.appendChild(n.render());
|
|
279
|
+
});
|
|
280
|
+
}), this.dp = t, this.type = s, this.opts = a, this.cells = [], this.$el = "", this.pressed = !1, this.isVisible = !0, this.init();
|
|
281
|
+
}
|
|
282
|
+
init() {
|
|
283
|
+
this._buildBaseHtml(), this.type === l.days && this.renderDayNames(), this.render(), this._bindEvents(), this._bindDatepickerEvents();
|
|
284
|
+
}
|
|
285
|
+
_bindEvents() {
|
|
286
|
+
let { range: e, dynamicRange: t } = this.opts;
|
|
287
|
+
w(this.$el, "mouseover", this.onMouseOverCell), w(this.$el, "mouseout", this.onMouseOutCell), w(this.$el, "click", this.onClickBody), e && t && (w(this.$el, "mousedown", this.onMouseDown), w(this.$el, "mousemove", this.onMouseMove), w(window.document, "mouseup", this.onMouseUp));
|
|
288
|
+
}
|
|
289
|
+
_bindDatepickerEvents() {
|
|
290
|
+
this.dp.on(l.eventChangeViewDate, this.onChangeViewDate), this.dp.on(l.eventChangeCurrentView, this.onChangeCurrentView);
|
|
291
|
+
}
|
|
292
|
+
_buildBaseHtml() {
|
|
293
|
+
this.$el = b({ className: "air-datepicker-body -".concat(this.type, "-"), innerHtml: le[this.type] }), this.$names = y(".air-datepicker-body--day-names", this.$el), this.$cells = y(".air-datepicker-body--cells", this.$el);
|
|
294
|
+
}
|
|
295
|
+
_getDayNamesHtml() {
|
|
296
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.dp.locale.firstDay, t = "", s = this.dp.isWeekend, { onClickDayName: a } = this.opts, n = e, i = 0;
|
|
297
|
+
for (; i < 7; ) {
|
|
298
|
+
let h = n % 7, o = M("air-datepicker-body--day-name", { [l.cssClassWeekend]: s(h), "-clickable-": !!a }), d = this.dp.locale.daysMin[h];
|
|
299
|
+
t += '<div class="'.concat(o, `" data-day-index='`).concat(h, "'>").concat(d, "</div>"), i++, n++;
|
|
300
|
+
}
|
|
301
|
+
return t;
|
|
302
|
+
}
|
|
303
|
+
_getDaysCells() {
|
|
304
|
+
let { viewDate: e, locale: { firstDay: t } } = this.dp, s = Z(e), { year: a, month: n } = D(e), i = new Date(a, n, 1), h = new Date(a, n, s), o = i.getDay() - t, d = 6 - h.getDay() + t;
|
|
305
|
+
o = o < 0 ? o + 7 : o, d = d > 6 ? d - 7 : d;
|
|
306
|
+
let c = function(N, B) {
|
|
307
|
+
let { year: K, month: I, date: z } = D(N);
|
|
308
|
+
return new Date(K, I, z - B);
|
|
309
|
+
}(i, o), u = s + o + d, p = c.getDate(), { year: g, month: f } = D(c), _ = 0;
|
|
310
|
+
for (; _ < u; ) {
|
|
311
|
+
let N = new Date(g, f, p + _);
|
|
312
|
+
this._generateCell(N), _++;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
_generateCell(e) {
|
|
316
|
+
let { type: t, dp: s, opts: a } = this, n = new oe({ type: t, dp: s, opts: a, date: e, body: this });
|
|
317
|
+
return this.cells.push(n), n;
|
|
318
|
+
}
|
|
319
|
+
_generateDayCells() {
|
|
320
|
+
this._getDaysCells();
|
|
321
|
+
}
|
|
322
|
+
_generateMonthCells() {
|
|
323
|
+
let { year: e } = this.dp.parsedViewDate, t = 0;
|
|
324
|
+
for (; t < 12; )
|
|
325
|
+
this.cells.push(this._generateCell(new Date(e, t))), t++;
|
|
326
|
+
}
|
|
327
|
+
_generateYearCells() {
|
|
328
|
+
let e = F(this.dp.viewDate), t = e[0] - 1, s = e[1] + 1, a = t;
|
|
329
|
+
for (; a <= s; )
|
|
330
|
+
this.cells.push(this._generateCell(new Date(a, 0))), a++;
|
|
331
|
+
}
|
|
332
|
+
renderDayNames() {
|
|
333
|
+
this.$names.innerHTML = this._getDayNamesHtml();
|
|
334
|
+
}
|
|
335
|
+
_generateCells() {
|
|
336
|
+
switch (this.type) {
|
|
337
|
+
case l.days:
|
|
338
|
+
this._generateDayCells();
|
|
339
|
+
break;
|
|
340
|
+
case l.months:
|
|
341
|
+
this._generateMonthCells();
|
|
342
|
+
break;
|
|
343
|
+
case l.years:
|
|
344
|
+
this._generateYearCells();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
show() {
|
|
348
|
+
this.isVisible = !0, this.$el.classList.remove("-hidden-");
|
|
349
|
+
}
|
|
350
|
+
hide() {
|
|
351
|
+
this.isVisible = !1, this.$el.classList.add("-hidden-");
|
|
352
|
+
}
|
|
353
|
+
destroyCells() {
|
|
354
|
+
this.cells.forEach((e) => e.destroy()), this.cells = [], this.$cells.innerHTML = "";
|
|
355
|
+
}
|
|
356
|
+
destroy() {
|
|
357
|
+
this.destroyCells(), this.dp.off(l.eventChangeViewDate, this.onChangeViewDate), this.dp.off(l.eventChangeCurrentView, this.onChangeCurrentView);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function x(r, e, t) {
|
|
361
|
+
return e in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
|
|
362
|
+
}
|
|
363
|
+
class de {
|
|
364
|
+
constructor(e) {
|
|
365
|
+
let { dp: t, opts: s } = e;
|
|
366
|
+
x(this, "onClickNav", (a) => {
|
|
367
|
+
let n = R(a.target, ".air-datepicker-nav--action");
|
|
368
|
+
if (!n)
|
|
369
|
+
return;
|
|
370
|
+
let i = n.dataset.action;
|
|
371
|
+
this.dp[i]();
|
|
372
|
+
}), x(this, "onChangeViewDate", () => {
|
|
373
|
+
this.render(), this._resetNavStatus(), this.handleNavStatus();
|
|
374
|
+
}), x(this, "onChangeCurrentView", () => {
|
|
375
|
+
this.render(), this._resetNavStatus(), this.handleNavStatus();
|
|
376
|
+
}), x(this, "onClickNavTitle", () => {
|
|
377
|
+
this.dp.isFinalView || this.dp.up();
|
|
378
|
+
}), x(this, "update", () => {
|
|
379
|
+
let { prevHtml: a, nextHtml: n } = this.opts;
|
|
380
|
+
this.$prev.innerHTML = a, this.$next.innerHTML = n, this._resetNavStatus(), this.render(), this.handleNavStatus();
|
|
381
|
+
}), x(this, "renderDelay", () => {
|
|
382
|
+
setTimeout(this.render);
|
|
383
|
+
}), x(this, "render", () => {
|
|
384
|
+
this.$title.innerHTML = this._getTitle(), function(a, n) {
|
|
385
|
+
for (let i in n)
|
|
386
|
+
n[i] ? a.classList.add(i) : a.classList.remove(i);
|
|
387
|
+
}(this.$title, { "-disabled-": this.dp.isFinalView });
|
|
388
|
+
}), this.dp = t, this.opts = s, this.init();
|
|
389
|
+
}
|
|
390
|
+
init() {
|
|
391
|
+
this._createElement(), this._buildBaseHtml(), this._defineDOM(), this.render(), this.handleNavStatus(), this._bindEvents(), this._bindDatepickerEvents();
|
|
392
|
+
}
|
|
393
|
+
_defineDOM() {
|
|
394
|
+
this.$title = y(".air-datepicker-nav--title", this.$el), this.$prev = y('[data-action="prev"]', this.$el), this.$next = y('[data-action="next"]', this.$el);
|
|
395
|
+
}
|
|
396
|
+
_bindEvents() {
|
|
397
|
+
this.$el.addEventListener("click", this.onClickNav), this.$title.addEventListener("click", this.onClickNavTitle);
|
|
398
|
+
}
|
|
399
|
+
_bindDatepickerEvents() {
|
|
400
|
+
this.dp.on(l.eventChangeViewDate, this.onChangeViewDate), this.dp.on(l.eventChangeCurrentView, this.onChangeCurrentView), this.isNavIsFunction && (this.dp.on(l.eventChangeSelectedDate, this.renderDelay), this.dp.opts.timepicker && this.dp.on(l.eventChangeTime, this.render));
|
|
401
|
+
}
|
|
402
|
+
destroy() {
|
|
403
|
+
this.dp.off(l.eventChangeViewDate, this.onChangeViewDate), this.dp.off(l.eventChangeCurrentView, this.onChangeCurrentView), this.isNavIsFunction && (this.dp.off(l.eventChangeSelectedDate, this.renderDelay), this.dp.opts.timepicker && this.dp.off(l.eventChangeTime, this.render));
|
|
404
|
+
}
|
|
405
|
+
_createElement() {
|
|
406
|
+
this.$el = b({ tagName: "nav", className: "air-datepicker-nav" });
|
|
407
|
+
}
|
|
408
|
+
_getTitle() {
|
|
409
|
+
let { dp: e, opts: t } = this, s = t.navTitles[e.currentView];
|
|
410
|
+
return typeof s == "function" ? s(e) : e.formatDate(e.viewDate, s);
|
|
411
|
+
}
|
|
412
|
+
handleNavStatus() {
|
|
413
|
+
let { disableNavWhenOutOfRange: e } = this.opts, { minDate: t, maxDate: s } = this.dp;
|
|
414
|
+
if (!t && !s || !e)
|
|
415
|
+
return;
|
|
416
|
+
let { year: a, month: n } = this.dp.parsedViewDate, i = !!t && D(t), h = !!s && D(s);
|
|
417
|
+
switch (this.dp.currentView) {
|
|
418
|
+
case l.days:
|
|
419
|
+
t && i.month >= n && i.year >= a && this._disableNav("prev"), s && h.month <= n && h.year <= a && this._disableNav("next");
|
|
420
|
+
break;
|
|
421
|
+
case l.months:
|
|
422
|
+
t && i.year >= a && this._disableNav("prev"), s && h.year <= a && this._disableNav("next");
|
|
423
|
+
break;
|
|
424
|
+
case l.years: {
|
|
425
|
+
let o = F(this.dp.viewDate);
|
|
426
|
+
t && i.year >= o[0] && this._disableNav("prev"), s && h.year <= o[1] && this._disableNav("next");
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
_disableNav(e) {
|
|
432
|
+
y('[data-action="' + e + '"]', this.$el).classList.add("-disabled-");
|
|
433
|
+
}
|
|
434
|
+
_resetNavStatus() {
|
|
435
|
+
(function(e) {
|
|
436
|
+
for (var t = arguments.length, s = new Array(t > 1 ? t - 1 : 0), a = 1; a < t; a++)
|
|
437
|
+
s[a - 1] = arguments[a];
|
|
438
|
+
e.length ? e.forEach((n) => {
|
|
439
|
+
n.classList.remove(...s);
|
|
440
|
+
}) : e.classList.remove(...s);
|
|
441
|
+
})(this.$el.querySelectorAll(".air-datepicker-nav--action"), "-disabled-");
|
|
442
|
+
}
|
|
443
|
+
_buildBaseHtml() {
|
|
444
|
+
let { prevHtml: e, nextHtml: t } = this.opts;
|
|
445
|
+
this.$el.innerHTML = '<div class="air-datepicker-nav--action" data-action="prev">'.concat(e, "</div>") + '<div class="air-datepicker-nav--title"></div>' + '<div class="air-datepicker-nav--action" data-action="next">'.concat(t, "</div>");
|
|
446
|
+
}
|
|
447
|
+
get isNavIsFunction() {
|
|
448
|
+
let { navTitles: e } = this.opts;
|
|
449
|
+
return Object.keys(e).find((t) => typeof e[t] == "function");
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
var te = { today: { content: (r) => r.locale.today, onClick: (r) => r.setViewDate(/* @__PURE__ */ new Date()) }, clear: { content: (r) => r.locale.clear, onClick: (r) => r.clear() } };
|
|
453
|
+
class ce {
|
|
454
|
+
constructor(e) {
|
|
455
|
+
let { dp: t, opts: s } = e;
|
|
456
|
+
this.dp = t, this.opts = s, this.init();
|
|
457
|
+
}
|
|
458
|
+
init() {
|
|
459
|
+
this.createElement(), this.render();
|
|
460
|
+
}
|
|
461
|
+
createElement() {
|
|
462
|
+
this.$el = b({ className: "air-datepicker-buttons" });
|
|
463
|
+
}
|
|
464
|
+
destroy() {
|
|
465
|
+
this.$el.parentNode.removeChild(this.$el);
|
|
466
|
+
}
|
|
467
|
+
clearHtml() {
|
|
468
|
+
return this.$el.innerHTML = "", this;
|
|
469
|
+
}
|
|
470
|
+
generateButtons() {
|
|
471
|
+
let { buttons: e } = this.opts;
|
|
472
|
+
Array.isArray(e) || (e = [e]), e.forEach((t) => {
|
|
473
|
+
let s = t;
|
|
474
|
+
typeof t == "string" && te[t] && (s = te[t]);
|
|
475
|
+
let a = this.createButton(s);
|
|
476
|
+
s.onClick && this.attachEventToButton(a, s.onClick), this.$el.appendChild(a);
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
attachEventToButton(e, t) {
|
|
480
|
+
e.addEventListener("click", () => {
|
|
481
|
+
t(this.dp);
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
createButton(e) {
|
|
485
|
+
let { content: t, className: s, tagName: a = "button", attrs: n = {} } = e, i = typeof t == "function" ? t(this.dp) : t;
|
|
486
|
+
return b({ tagName: a, innerHtml: "<span tabindex='-1'>".concat(i, "</span>"), className: M("air-datepicker-button", s), attrs: n });
|
|
487
|
+
}
|
|
488
|
+
render() {
|
|
489
|
+
this.generateButtons();
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function H(r, e, t) {
|
|
493
|
+
return e in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
|
|
494
|
+
}
|
|
495
|
+
class ue {
|
|
496
|
+
constructor() {
|
|
497
|
+
let { opts: e, dp: t } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
498
|
+
H(this, "toggleTimepickerIsActive", (a) => {
|
|
499
|
+
this.dp.timepickerIsActive = a;
|
|
500
|
+
}), H(this, "onChangeSelectedDate", (a) => {
|
|
501
|
+
let { date: n, updateTime: i = !1 } = a;
|
|
502
|
+
n && (this.setMinMaxTime(n), this.setCurrentTime(!!i && n), this.addTimeToDate(n));
|
|
503
|
+
}), H(this, "onChangeLastSelectedDate", (a) => {
|
|
504
|
+
a && (this.setTime(a), this.render());
|
|
505
|
+
}), H(this, "onChangeInputRange", (a) => {
|
|
506
|
+
let n = a.target;
|
|
507
|
+
this[n.getAttribute("name")] = n.value, this.updateText(), this.dp.trigger(l.eventChangeTime, { hours: this.hours, minutes: this.minutes });
|
|
508
|
+
}), H(this, "onMouseEnterLeave", (a) => {
|
|
509
|
+
let n = a.target.getAttribute("name"), i = this.$minutesText;
|
|
510
|
+
n === "hours" && (i = this.$hoursText), i.classList.toggle("-focus-");
|
|
511
|
+
}), H(this, "onFocus", () => {
|
|
512
|
+
this.toggleTimepickerIsActive(!0);
|
|
513
|
+
}), H(this, "onBlur", () => {
|
|
514
|
+
this.toggleTimepickerIsActive(!1);
|
|
515
|
+
}), this.opts = e, this.dp = t;
|
|
516
|
+
let { timeFormat: s } = this.dp.locale;
|
|
517
|
+
s && (s.match(G("h")) || s.match(G("hh"))) && (this.ampm = !0), this.init();
|
|
518
|
+
}
|
|
519
|
+
init() {
|
|
520
|
+
this.setTime(this.dp.lastSelectedDate || this.dp.viewDate), this.createElement(), this.buildHtml(), this.defineDOM(), this.render(), this.bindDatepickerEvents(), this.bindDOMEvents();
|
|
521
|
+
}
|
|
522
|
+
bindDatepickerEvents() {
|
|
523
|
+
this.dp.on(l.eventChangeSelectedDate, this.onChangeSelectedDate), this.dp.on(l.eventChangeLastSelectedDate, this.onChangeLastSelectedDate);
|
|
524
|
+
}
|
|
525
|
+
bindDOMEvents() {
|
|
526
|
+
let e = "input";
|
|
527
|
+
navigator.userAgent.match(/trident/gi) && (e = "change"), w(this.$ranges, e, this.onChangeInputRange), w(this.$ranges, "mouseenter", this.onMouseEnterLeave), w(this.$ranges, "mouseleave", this.onMouseEnterLeave), w(this.$ranges, "focus", this.onFocus), w(this.$ranges, "mousedown", this.onFocus), w(this.$ranges, "blur", this.onBlur);
|
|
528
|
+
}
|
|
529
|
+
createElement() {
|
|
530
|
+
this.$el = b({ className: M("air-datepicker-time", { "-am-pm-": this.dp.ampm }) });
|
|
531
|
+
}
|
|
532
|
+
destroy() {
|
|
533
|
+
this.dp.off(l.eventChangeSelectedDate, this.onChangeSelectedDate), this.dp.off(l.eventChangeLastSelectedDate, this.onChangeLastSelectedDate), this.$el.parentNode.removeChild(this.$el);
|
|
534
|
+
}
|
|
535
|
+
buildHtml() {
|
|
536
|
+
let { ampm: e, hours: t, displayHours: s, minutes: a, minHours: n, minMinutes: i, maxHours: h, maxMinutes: o, dayPeriod: d, opts: { hoursStep: c, minutesStep: u } } = this;
|
|
537
|
+
this.$el.innerHTML = '<div class="air-datepicker-time--current">' + ' <span class="air-datepicker-time--current-hours">'.concat(O(s), "</span>") + ' <span class="air-datepicker-time--current-colon">:</span>' + ' <span class="air-datepicker-time--current-minutes">'.concat(O(a), "</span>") + " ".concat(e ? "<span class='air-datepicker-time--current-ampm'>".concat(d, "</span>") : "") + '</div><div class="air-datepicker-time--sliders"> <div class="air-datepicker-time--row">' + ' <input type="range" name="hours" value="'.concat(t, '" min="').concat(n, '" max="').concat(h, '" step="').concat(c, '"/>') + ' </div> <div class="air-datepicker-time--row">' + ' <input type="range" name="minutes" value="'.concat(a, '" min="').concat(i, '" max="').concat(o, '" step="').concat(u, '"/>') + " </div></div>";
|
|
538
|
+
}
|
|
539
|
+
defineDOM() {
|
|
540
|
+
let e = (t) => y(t, this.$el);
|
|
541
|
+
this.$ranges = this.$el.querySelectorAll('[type="range"]'), this.$hours = e('[name="hours"]'), this.$minutes = e('[name="minutes"]'), this.$hoursText = e(".air-datepicker-time--current-hours"), this.$minutesText = e(".air-datepicker-time--current-minutes"), this.$ampm = e(".air-datepicker-time--current-ampm");
|
|
542
|
+
}
|
|
543
|
+
setTime(e) {
|
|
544
|
+
this.setMinMaxTime(e), this.setCurrentTime(e);
|
|
545
|
+
}
|
|
546
|
+
addTimeToDate(e) {
|
|
547
|
+
e && (e.setHours(this.hours), e.setMinutes(this.minutes));
|
|
548
|
+
}
|
|
549
|
+
setMinMaxTime(e) {
|
|
550
|
+
if (this.setMinMaxTimeFromOptions(), e) {
|
|
551
|
+
let { minDate: t, maxDate: s } = this.dp;
|
|
552
|
+
t && v(e, t) && this.setMinTimeFromMinDate(t), s && v(e, s) && this.setMaxTimeFromMaxDate(s);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
setCurrentTime(e) {
|
|
556
|
+
let { hours: t, minutes: s } = e ? D(e) : this;
|
|
557
|
+
this.hours = A(t, this.minHours, this.maxHours), this.minutes = A(s, this.minMinutes, this.maxMinutes);
|
|
558
|
+
}
|
|
559
|
+
setMinMaxTimeFromOptions() {
|
|
560
|
+
let { minHours: e, minMinutes: t, maxHours: s, maxMinutes: a } = this.opts;
|
|
561
|
+
this.minHours = A(e, 0, 23), this.minMinutes = A(t, 0, 59), this.maxHours = A(s, 0, 23), this.maxMinutes = A(a, 0, 59);
|
|
562
|
+
}
|
|
563
|
+
setMinTimeFromMinDate(e) {
|
|
564
|
+
let { lastSelectedDate: t } = this.dp;
|
|
565
|
+
this.minHours = e.getHours(), t && t.getHours() > e.getHours() ? this.minMinutes = this.opts.minMinutes : this.minMinutes = e.getMinutes();
|
|
566
|
+
}
|
|
567
|
+
setMaxTimeFromMaxDate(e) {
|
|
568
|
+
let { lastSelectedDate: t } = this.dp;
|
|
569
|
+
this.maxHours = e.getHours(), t && t.getHours() < e.getHours() ? this.maxMinutes = this.opts.maxMinutes : this.maxMinutes = e.getMinutes();
|
|
570
|
+
}
|
|
571
|
+
getDayPeriod(e, t) {
|
|
572
|
+
let s = e, a = Number(e);
|
|
573
|
+
e instanceof Date && (s = D(e), a = Number(s.hours));
|
|
574
|
+
let n = "am";
|
|
575
|
+
if (t || this.ampm) {
|
|
576
|
+
switch (!0) {
|
|
577
|
+
case a === 12:
|
|
578
|
+
case a > 11:
|
|
579
|
+
n = "pm";
|
|
580
|
+
}
|
|
581
|
+
a = a % 12 == 0 ? 12 : a % 12;
|
|
582
|
+
}
|
|
583
|
+
return { hours: a, dayPeriod: n };
|
|
584
|
+
}
|
|
585
|
+
updateSliders() {
|
|
586
|
+
q(this.$hours, { min: this.minHours, max: this.maxHours }).value = this.hours, q(this.$minutes, { min: this.minMinutes, max: this.maxMinutes }).value = this.minutes;
|
|
587
|
+
}
|
|
588
|
+
updateText() {
|
|
589
|
+
this.$hoursText.innerHTML = O(this.displayHours), this.$minutesText.innerHTML = O(this.minutes), this.ampm && (this.$ampm.innerHTML = this.dayPeriod);
|
|
590
|
+
}
|
|
591
|
+
set hours(e) {
|
|
592
|
+
this._hours = e;
|
|
593
|
+
let { hours: t, dayPeriod: s } = this.getDayPeriod(e);
|
|
594
|
+
this.displayHours = t, this.dayPeriod = s;
|
|
595
|
+
}
|
|
596
|
+
get hours() {
|
|
597
|
+
return this._hours;
|
|
598
|
+
}
|
|
599
|
+
render() {
|
|
600
|
+
this.updateSliders(), this.updateText();
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
function L(r, e, t) {
|
|
604
|
+
return e in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
|
|
605
|
+
}
|
|
606
|
+
class pe {
|
|
607
|
+
constructor(e) {
|
|
608
|
+
let { dp: t, opts: s } = e;
|
|
609
|
+
L(this, "pressedKeys", /* @__PURE__ */ new Set()), L(this, "hotKeys", /* @__PURE__ */ new Map([[[["Control", "ArrowRight"], ["Control", "ArrowUp"]], (a) => a.month++], [[["Control", "ArrowLeft"], ["Control", "ArrowDown"]], (a) => a.month--], [[["Shift", "ArrowRight"], ["Shift", "ArrowUp"]], (a) => a.year++], [[["Shift", "ArrowLeft"], ["Shift", "ArrowDown"]], (a) => a.year--], [[["Alt", "ArrowRight"], ["Alt", "ArrowUp"]], (a) => a.year += 10], [[["Alt", "ArrowLeft"], ["Alt", "ArrowDown"]], (a) => a.year -= 10], [["Control", "Shift", "ArrowUp"], (a, n) => n.up()]])), L(this, "handleHotKey", (a) => {
|
|
610
|
+
let n = this.hotKeys.get(a), i = D(this.getInitialFocusDate());
|
|
611
|
+
n(i, this.dp);
|
|
612
|
+
let { year: h, month: o, date: d } = i, c = Z(new Date(h, o));
|
|
613
|
+
c < d && (d = c);
|
|
614
|
+
let u = this.dp.getClampedDate(new Date(h, o, d));
|
|
615
|
+
this.dp.setFocusDate(u, { viewDateTransition: !0 });
|
|
616
|
+
}), L(this, "isHotKeyPressed", () => {
|
|
617
|
+
let a = !1, n = this.pressedKeys.size, i = (h) => this.pressedKeys.has(h);
|
|
618
|
+
for (let [h] of this.hotKeys) {
|
|
619
|
+
if (a)
|
|
620
|
+
break;
|
|
621
|
+
if (Array.isArray(h[0]))
|
|
622
|
+
h.forEach((o) => {
|
|
623
|
+
a || n !== o.length || (a = o.every(i) && h);
|
|
624
|
+
});
|
|
625
|
+
else {
|
|
626
|
+
if (n !== h.length)
|
|
627
|
+
continue;
|
|
628
|
+
a = h.every(i) && h;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
return a;
|
|
632
|
+
}), L(this, "isArrow", (a) => a >= 37 && a <= 40), L(this, "onKeyDown", (a) => {
|
|
633
|
+
let { key: n, which: i } = a, { dp: h, dp: { focusDate: o }, opts: d } = this;
|
|
634
|
+
this.registerKey(n);
|
|
635
|
+
let c = this.isHotKeyPressed();
|
|
636
|
+
if (c)
|
|
637
|
+
return a.preventDefault(), void this.handleHotKey(c);
|
|
638
|
+
if (this.isArrow(i))
|
|
639
|
+
return a.preventDefault(), void this.focusNextCell(n);
|
|
640
|
+
if (n === "Enter") {
|
|
641
|
+
if (h.currentView !== d.minView)
|
|
642
|
+
return void h.down();
|
|
643
|
+
if (o) {
|
|
644
|
+
let u = h._checkIfDateIsSelected(o);
|
|
645
|
+
return void (u ? h._handleAlreadySelectedDates(u, o) : h.selectDate(o));
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
n === "Escape" && this.dp.hide();
|
|
649
|
+
}), L(this, "onKeyUp", (a) => {
|
|
650
|
+
this.removeKey(a.key);
|
|
651
|
+
}), this.dp = t, this.opts = s, this.init();
|
|
652
|
+
}
|
|
653
|
+
init() {
|
|
654
|
+
this.bindKeyboardEvents();
|
|
655
|
+
}
|
|
656
|
+
bindKeyboardEvents() {
|
|
657
|
+
let { $el: e } = this.dp;
|
|
658
|
+
e.addEventListener("keydown", this.onKeyDown), e.addEventListener("keyup", this.onKeyUp);
|
|
659
|
+
}
|
|
660
|
+
destroy() {
|
|
661
|
+
let { $el: e } = this.dp;
|
|
662
|
+
e.removeEventListener("keydown", this.onKeyDown), e.removeEventListener("keyup", this.onKeyUp), this.hotKeys = null, this.pressedKeys = null;
|
|
663
|
+
}
|
|
664
|
+
getInitialFocusDate() {
|
|
665
|
+
let { focusDate: e, currentView: t, selectedDates: s, parsedViewDate: { year: a, month: n } } = this.dp, i = e || s[s.length - 1];
|
|
666
|
+
if (!i)
|
|
667
|
+
switch (t) {
|
|
668
|
+
case l.days:
|
|
669
|
+
i = new Date(a, n, (/* @__PURE__ */ new Date()).getDate());
|
|
670
|
+
break;
|
|
671
|
+
case l.months:
|
|
672
|
+
i = new Date(a, n, 1);
|
|
673
|
+
break;
|
|
674
|
+
case l.years:
|
|
675
|
+
i = new Date(a, 0, 1);
|
|
676
|
+
}
|
|
677
|
+
return i;
|
|
678
|
+
}
|
|
679
|
+
focusNextCell(e) {
|
|
680
|
+
let t = this.getInitialFocusDate(), { currentView: s } = this.dp, { days: a, months: n, years: i } = l, h = D(t), o = h.year, d = h.month, c = h.date;
|
|
681
|
+
switch (e) {
|
|
682
|
+
case "ArrowLeft":
|
|
683
|
+
s === a && (c -= 1), s === n && (d -= 1), s === i && (o -= 1);
|
|
684
|
+
break;
|
|
685
|
+
case "ArrowUp":
|
|
686
|
+
s === a && (c -= 7), s === n && (d -= 3), s === i && (o -= 4);
|
|
687
|
+
break;
|
|
688
|
+
case "ArrowRight":
|
|
689
|
+
s === a && (c += 1), s === n && (d += 1), s === i && (o += 1);
|
|
690
|
+
break;
|
|
691
|
+
case "ArrowDown":
|
|
692
|
+
s === a && (c += 7), s === n && (d += 3), s === i && (o += 4);
|
|
693
|
+
}
|
|
694
|
+
let u = this.dp.getClampedDate(new Date(o, d, c));
|
|
695
|
+
this.dp.setFocusDate(u, { viewDateTransition: !0 });
|
|
696
|
+
}
|
|
697
|
+
registerKey(e) {
|
|
698
|
+
this.pressedKeys.add(e);
|
|
699
|
+
}
|
|
700
|
+
removeKey(e) {
|
|
701
|
+
this.pressedKeys.delete(e);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
let me = { on(r, e) {
|
|
705
|
+
this.__events || (this.__events = {}), this.__events[r] ? this.__events[r].push(e) : this.__events[r] = [e];
|
|
706
|
+
}, off(r, e) {
|
|
707
|
+
this.__events && this.__events[r] && (this.__events[r] = this.__events[r].filter((t) => t !== e));
|
|
708
|
+
}, removeAllEvents() {
|
|
709
|
+
this.__events = {};
|
|
710
|
+
}, trigger(r) {
|
|
711
|
+
for (var e = arguments.length, t = new Array(e > 1 ? e - 1 : 0), s = 1; s < e; s++)
|
|
712
|
+
t[s - 1] = arguments[s];
|
|
713
|
+
this.__events && this.__events[r] && this.__events[r].forEach((a) => {
|
|
714
|
+
a(...t);
|
|
715
|
+
});
|
|
716
|
+
} };
|
|
717
|
+
function m(r, e, t) {
|
|
718
|
+
return e in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
|
|
719
|
+
}
|
|
720
|
+
let X = "", W = "", S = "", se = !1;
|
|
721
|
+
class T {
|
|
722
|
+
constructor(e, t) {
|
|
723
|
+
var s = this;
|
|
724
|
+
if (m(this, "viewIndexes", [l.days, l.months, l.years]), m(this, "next", () => {
|
|
725
|
+
let { year: i, month: h } = this.parsedViewDate;
|
|
726
|
+
switch (this.currentView) {
|
|
727
|
+
case l.days:
|
|
728
|
+
this.setViewDate(new Date(i, h + 1, 1));
|
|
729
|
+
break;
|
|
730
|
+
case l.months:
|
|
731
|
+
this.setViewDate(new Date(i + 1, h, 1));
|
|
732
|
+
break;
|
|
733
|
+
case l.years:
|
|
734
|
+
this.setViewDate(new Date(i + 10, 0, 1));
|
|
735
|
+
}
|
|
736
|
+
}), m(this, "prev", () => {
|
|
737
|
+
let { year: i, month: h } = this.parsedViewDate;
|
|
738
|
+
switch (this.currentView) {
|
|
739
|
+
case l.days:
|
|
740
|
+
this.setViewDate(new Date(i, h - 1, 1));
|
|
741
|
+
break;
|
|
742
|
+
case l.months:
|
|
743
|
+
this.setViewDate(new Date(i - 1, h, 1));
|
|
744
|
+
break;
|
|
745
|
+
case l.years:
|
|
746
|
+
this.setViewDate(new Date(i - 10, 0, 1));
|
|
747
|
+
}
|
|
748
|
+
}), m(this, "_finishHide", () => {
|
|
749
|
+
this.hideAnimation = !1, this._destroyComponents(), this.$container.removeChild(this.$datepicker);
|
|
750
|
+
}), m(this, "setPosition", function(i) {
|
|
751
|
+
let h = arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
|
|
752
|
+
if (typeof (i = i || s.opts.position) == "function")
|
|
753
|
+
return void (s.customHide = i({ $datepicker: s.$datepicker, $target: s.$el, $pointer: s.$pointer, isViewChange: h, done: s._finishHide }));
|
|
754
|
+
let o, d, { isMobile: c } = s.opts, u = s.$el.getBoundingClientRect(), p = s.$el.getBoundingClientRect(), g = s.$datepicker.offsetParent, f = s.$el.offsetParent, _ = s.$datepicker.getBoundingClientRect(), N = i.split(" "), B = window.scrollY, K = window.scrollX, I = s.opts.offset, z = N[0], ge = N[1];
|
|
755
|
+
if (c)
|
|
756
|
+
s.$datepicker.style.cssText = "left: 50%; top: 50%";
|
|
757
|
+
else {
|
|
758
|
+
if (g === f && g !== document.body && (p = { top: s.$el.offsetTop, left: s.$el.offsetLeft, width: u.width, height: s.$el.offsetHeight }, B = 0, K = 0), g !== f && g !== document.body) {
|
|
759
|
+
let ae = g.getBoundingClientRect();
|
|
760
|
+
p = { top: u.top - ae.top, left: u.left - ae.left, width: u.width, height: u.height }, B = 0, K = 0;
|
|
761
|
+
}
|
|
762
|
+
switch (z) {
|
|
763
|
+
case "top":
|
|
764
|
+
o = p.top - _.height - I;
|
|
765
|
+
break;
|
|
766
|
+
case "right":
|
|
767
|
+
d = p.left + p.width + I;
|
|
768
|
+
break;
|
|
769
|
+
case "bottom":
|
|
770
|
+
o = p.top + p.height + I;
|
|
771
|
+
break;
|
|
772
|
+
case "left":
|
|
773
|
+
d = p.left - _.width - I;
|
|
774
|
+
}
|
|
775
|
+
switch (ge) {
|
|
776
|
+
case "top":
|
|
777
|
+
o = p.top;
|
|
778
|
+
break;
|
|
779
|
+
case "right":
|
|
780
|
+
d = p.left + p.width - _.width;
|
|
781
|
+
break;
|
|
782
|
+
case "bottom":
|
|
783
|
+
o = p.top + p.height - _.height;
|
|
784
|
+
break;
|
|
785
|
+
case "left":
|
|
786
|
+
d = p.left;
|
|
787
|
+
break;
|
|
788
|
+
case "center":
|
|
789
|
+
/left|right/.test(z) ? o = p.top + p.height / 2 - _.height / 2 : d = p.left + p.width / 2 - _.width / 2;
|
|
790
|
+
}
|
|
791
|
+
s.$datepicker.style.cssText = "left: ".concat(d + K, "px; top: ").concat(o + B, "px");
|
|
792
|
+
}
|
|
793
|
+
}), m(this, "_setInputValue", () => {
|
|
794
|
+
let { opts: i, $altField: h, locale: { dateFormat: o } } = this, { altFieldDateFormat: d, altField: c } = i;
|
|
795
|
+
c && h && (h.value = this._getInputValue(d)), this.$el.value = this._getInputValue(o);
|
|
796
|
+
}), m(this, "_getInputValue", (i) => {
|
|
797
|
+
let { selectedDates: h, opts: o } = this, { multipleDates: d, multipleDatesSeparator: c } = o;
|
|
798
|
+
if (!h.length)
|
|
799
|
+
return "";
|
|
800
|
+
let u = typeof i == "function", p = u ? i(d ? h : h[0]) : h.map((g) => this.formatDate(g, i));
|
|
801
|
+
return p = u ? p : p.join(c), p;
|
|
802
|
+
}), m(this, "_checkIfDateIsSelected", function(i) {
|
|
803
|
+
let h = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : l.days, o = !1;
|
|
804
|
+
return s.selectedDates.some((d) => {
|
|
805
|
+
let c = v(i, d, h);
|
|
806
|
+
return o = c && d, c;
|
|
807
|
+
}), o;
|
|
808
|
+
}), m(this, "_scheduleCallAfterTransition", (i) => {
|
|
809
|
+
this._cancelScheduledCall(), i && i(!1), this._onTransitionEnd = () => {
|
|
810
|
+
i && i(!0);
|
|
811
|
+
}, this.$datepicker.addEventListener("transitionend", this._onTransitionEnd, { once: !0 });
|
|
812
|
+
}), m(this, "_cancelScheduledCall", () => {
|
|
813
|
+
this.$datepicker.removeEventListener("transitionend", this._onTransitionEnd);
|
|
814
|
+
}), m(this, "setViewDate", (i) => {
|
|
815
|
+
if (!((i = C(i)) instanceof Date) || v(i, this.viewDate))
|
|
816
|
+
return;
|
|
817
|
+
let h = this.viewDate;
|
|
818
|
+
this.viewDate = i;
|
|
819
|
+
let { onChangeViewDate: o } = this.opts;
|
|
820
|
+
if (o) {
|
|
821
|
+
let { month: d, year: c } = this.parsedViewDate;
|
|
822
|
+
o({ month: d, year: c, decade: this.curDecade });
|
|
823
|
+
}
|
|
824
|
+
this.trigger(l.eventChangeViewDate, i, h);
|
|
825
|
+
}), m(this, "setFocusDate", function(i) {
|
|
826
|
+
let h = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
827
|
+
(!i || (i = C(i)) instanceof Date) && (s.focusDate = i, s.opts.range && i && s._handleRangeOnFocus(), s.trigger(l.eventChangeFocusDate, i, h));
|
|
828
|
+
}), m(this, "setCurrentView", (i) => {
|
|
829
|
+
if (this.viewIndexes.includes(i)) {
|
|
830
|
+
if (this.currentView = i, this.elIsInput && this.visible && this.setPosition(void 0, !0), this.trigger(l.eventChangeCurrentView, i), !this.views[i]) {
|
|
831
|
+
let h = this.views[i] = new ee({ dp: this, opts: this.opts, type: i });
|
|
832
|
+
this.shouldUpdateDOM && this.$content.appendChild(h.$el);
|
|
833
|
+
}
|
|
834
|
+
this.opts.onChangeView && this.opts.onChangeView(i);
|
|
835
|
+
}
|
|
836
|
+
}), m(this, "_updateLastSelectedDate", (i) => {
|
|
837
|
+
this.lastSelectedDate = i, this.trigger(l.eventChangeLastSelectedDate, i);
|
|
838
|
+
}), m(this, "destroy", () => {
|
|
839
|
+
let { showEvent: i, isMobile: h } = this.opts, o = this.$datepicker.parentNode;
|
|
840
|
+
o && o.removeChild(this.$datepicker), this.$el.removeEventListener(i, this._onFocus), this.$el.removeEventListener("blur", this._onBlur), window.removeEventListener("resize", this._onResize), h && this._removeMobileAttributes(), this.keyboardNav && this.keyboardNav.destroy(), this.views = null, this.nav = null, this.$datepicker = null, this.opts = null, this.$customContainer = null, this.viewDate = null, this.focusDate = null, this.selectedDates = null, this.rangeDateFrom = null, this.rangeDateTo = null;
|
|
841
|
+
}), m(this, "update", (i) => {
|
|
842
|
+
let h = Y({}, this.opts);
|
|
843
|
+
Y(this.opts, i);
|
|
844
|
+
let { timepicker: o, buttons: d, range: c, selectedDates: u, isMobile: p } = this.opts, g = this.visible || this.treatAsInline;
|
|
845
|
+
this._createMinMaxDates(), this._limitViewDateByMaxMinDates(), this._handleLocale(), !h.selectedDates && u && this.selectDate(u), i.view && this.setCurrentView(i.view), this._setInputValue(), h.range && !c ? (this.rangeDateTo = !1, this.rangeDateFrom = !1) : !h.range && c && this.selectedDates.length && (this.rangeDateFrom = this.selectedDates[0], this.rangeDateTo = this.selectedDates[1]), h.timepicker && !o ? (g && this.timepicker.destroy(), this.timepicker = !1, this.$timepicker.parentNode.removeChild(this.$timepicker)) : !h.timepicker && o && this._addTimepicker(), !h.buttons && d ? this._addButtons() : h.buttons && !d ? (this.buttons.destroy(), this.$buttons.parentNode.removeChild(this.$buttons)) : g && h.buttons && d && this.buttons.clearHtml().render(), !h.isMobile && p ? (this.treatAsInline || S || this._createMobileOverlay(), this._addMobileAttributes(), this.visible && this._showMobileOverlay()) : h.isMobile && !p && (this._removeMobileAttributes(), this.visible && (S.classList.remove("-active-"), typeof this.opts.position != "function" && this.setPosition())), g && (this.nav.update(), this.views[this.currentView].render(), this.currentView === l.days && this.views[this.currentView].renderDayNames());
|
|
846
|
+
}), m(this, "isOtherMonth", (i) => {
|
|
847
|
+
let { month: h } = D(i);
|
|
848
|
+
return h !== this.parsedViewDate.month;
|
|
849
|
+
}), m(this, "isOtherYear", (i) => {
|
|
850
|
+
let { year: h } = D(i);
|
|
851
|
+
return h !== this.parsedViewDate.year;
|
|
852
|
+
}), m(this, "isOtherDecade", (i) => {
|
|
853
|
+
let { year: h } = D(i), [o, d] = F(this.viewDate);
|
|
854
|
+
return h < o || h > d;
|
|
855
|
+
}), m(this, "_onChangeSelectedDate", (i) => {
|
|
856
|
+
let { silent: h } = i;
|
|
857
|
+
setTimeout(() => {
|
|
858
|
+
this._setInputValue(), this.opts.onSelect && !h && this._triggerOnSelect();
|
|
859
|
+
});
|
|
860
|
+
}), m(this, "_onChangeFocusedDate", function(i) {
|
|
861
|
+
let { viewDateTransition: h } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
862
|
+
if (!i)
|
|
863
|
+
return;
|
|
864
|
+
let o = !1;
|
|
865
|
+
h && (o = s.isOtherMonth(i) || s.isOtherYear(i) || s.isOtherDecade(i)), o && s.setViewDate(i);
|
|
866
|
+
}), m(this, "_onChangeTime", (i) => {
|
|
867
|
+
let { hours: h, minutes: o } = i, d = /* @__PURE__ */ new Date(), { lastSelectedDate: c, opts: { onSelect: u } } = this, p = c;
|
|
868
|
+
c || (p = d);
|
|
869
|
+
let g = this.getCell(p, this.currentViewSingular), f = g && g.adpCell;
|
|
870
|
+
f && f.isDisabled || (p.setHours(h), p.setMinutes(o), c ? (this._setInputValue(), u && this._triggerOnSelect()) : this.selectDate(p));
|
|
871
|
+
}), m(this, "_onFocus", (i) => {
|
|
872
|
+
this.visible || this.show();
|
|
873
|
+
}), m(this, "_onBlur", (i) => {
|
|
874
|
+
this.inFocus || !this.visible || this.opts.isMobile || this.hide();
|
|
875
|
+
}), m(this, "_onMouseDown", (i) => {
|
|
876
|
+
this.inFocus = !0;
|
|
877
|
+
}), m(this, "_onMouseUp", (i) => {
|
|
878
|
+
this.inFocus = !1, this.$el.focus();
|
|
879
|
+
}), m(this, "_onResize", () => {
|
|
880
|
+
this.visible && typeof this.opts.position != "function" && this.setPosition();
|
|
881
|
+
}), m(this, "_onClickOverlay", () => {
|
|
882
|
+
this.visible && this.hide();
|
|
883
|
+
}), m(this, "isWeekend", (i) => this.opts.weekends.includes(i)), m(this, "getClampedDate", (i) => {
|
|
884
|
+
let { minDate: h, maxDate: o } = this, d = i;
|
|
885
|
+
return o && $(i, o) ? d = o : h && E(i, h) && (d = h), d;
|
|
886
|
+
}), this.$el = y(e), !this.$el)
|
|
887
|
+
return;
|
|
888
|
+
this.$datepicker = b({ className: "air-datepicker" }), this.opts = Y({}, Q, t), this.$customContainer = !!this.opts.container && y(this.opts.container), this.$altField = y(this.opts.altField || !1), X || (X = y("body"));
|
|
889
|
+
let { view: a, startDate: n } = this.opts;
|
|
890
|
+
n || (this.opts.startDate = /* @__PURE__ */ new Date()), this.$el.nodeName === "INPUT" && (this.elIsInput = !0), this.inited = !1, this.visible = !1, this.viewDate = C(this.opts.startDate), this.focusDate = !1, this.initialReadonly = this.$el.getAttribute("readonly"), this.customHide = !1, this.currentView = a, this.selectedDates = [], this.views = {}, this.keys = [], this.rangeDateFrom = "", this.rangeDateTo = "", this.timepickerIsActive = !1, this.treatAsInline = this.opts.inline || !this.elIsInput, this.init();
|
|
891
|
+
}
|
|
892
|
+
init() {
|
|
893
|
+
let { opts: e, treatAsInline: t, opts: { inline: s, isMobile: a, selectedDates: n, keyboardNav: i, onlyTimepicker: h } } = this;
|
|
894
|
+
var o;
|
|
895
|
+
se || s || !this.elIsInput || (se = !0, W = b({ className: o = T.defaultContainerId, id: o }), X.appendChild(W)), !a || S || t || this._createMobileOverlay(), this._handleLocale(), this._bindSubEvents(), this._createMinMaxDates(), this._limitViewDateByMaxMinDates(), this.elIsInput && (s || this._bindEvents(), i && !h && (this.keyboardNav = new pe({ dp: this, opts: e }))), n && this.selectDate(n, { silent: !0 }), this.opts.visible && !t && this.show(), a && !t && this.$el.setAttribute("readonly", !0), t && this._createComponents();
|
|
896
|
+
}
|
|
897
|
+
_createMobileOverlay() {
|
|
898
|
+
S = b({ className: "air-datepicker-overlay" }), W.appendChild(S);
|
|
899
|
+
}
|
|
900
|
+
_createComponents() {
|
|
901
|
+
let { opts: e, treatAsInline: t, opts: { inline: s, buttons: a, timepicker: n, position: i, classes: h, onlyTimepicker: o, isMobile: d } } = this;
|
|
902
|
+
this._buildBaseHtml(), this.elIsInput && (s || this._setPositionClasses(i)), !s && this.elIsInput || this.$datepicker.classList.add("-inline-"), h && this.$datepicker.classList.add(...h.split(" ")), o && this.$datepicker.classList.add("-only-timepicker-"), d && !t && this._addMobileAttributes(), this.views[this.currentView] = new ee({ dp: this, type: this.currentView, opts: e }), this.nav = new de({ dp: this, opts: e }), n && this._addTimepicker(), a && this._addButtons(), this.$content.appendChild(this.views[this.currentView].$el), this.$nav.appendChild(this.nav.$el);
|
|
903
|
+
}
|
|
904
|
+
_destroyComponents() {
|
|
905
|
+
for (let e in this.views)
|
|
906
|
+
this.views[e].destroy();
|
|
907
|
+
this.views = {}, this.nav.destroy(), this.timepicker && this.timepicker.destroy();
|
|
908
|
+
}
|
|
909
|
+
_addMobileAttributes() {
|
|
910
|
+
S.addEventListener("click", this._onClickOverlay), this.$datepicker.classList.add("-is-mobile-"), this.$el.setAttribute("readonly", !0);
|
|
911
|
+
}
|
|
912
|
+
_removeMobileAttributes() {
|
|
913
|
+
S.removeEventListener("click", this._onClickOverlay), this.$datepicker.classList.remove("-is-mobile-"), this.initialReadonly || this.initialReadonly === "" || this.$el.removeAttribute("readonly");
|
|
914
|
+
}
|
|
915
|
+
_createMinMaxDates() {
|
|
916
|
+
let { minDate: e, maxDate: t } = this.opts;
|
|
917
|
+
this.minDate = !!e && C(e), this.maxDate = !!t && C(t);
|
|
918
|
+
}
|
|
919
|
+
_addTimepicker() {
|
|
920
|
+
this.$timepicker = b({ className: "air-datepicker--time" }), this.$datepicker.appendChild(this.$timepicker), this.timepicker = new ue({ dp: this, opts: this.opts }), this.$timepicker.appendChild(this.timepicker.$el);
|
|
921
|
+
}
|
|
922
|
+
_addButtons() {
|
|
923
|
+
this.$buttons = b({ className: "air-datepicker--buttons" }), this.$datepicker.appendChild(this.$buttons), this.buttons = new ce({ dp: this, opts: this.opts }), this.$buttons.appendChild(this.buttons.$el);
|
|
924
|
+
}
|
|
925
|
+
_bindSubEvents() {
|
|
926
|
+
this.on(l.eventChangeSelectedDate, this._onChangeSelectedDate), this.on(l.eventChangeFocusDate, this._onChangeFocusedDate), this.on(l.eventChangeTime, this._onChangeTime);
|
|
927
|
+
}
|
|
928
|
+
_buildBaseHtml() {
|
|
929
|
+
let { inline: e } = this.opts;
|
|
930
|
+
var t, s;
|
|
931
|
+
this.elIsInput ? e ? (t = this.$datepicker, (s = this.$el).parentNode.insertBefore(t, s.nextSibling)) : this.$container.appendChild(this.$datepicker) : this.$el.appendChild(this.$datepicker), this.$datepicker.innerHTML = '<i class="air-datepicker--pointer"></i><div class="air-datepicker--navigation"></div><div class="air-datepicker--content"></div>', this.$content = y(".air-datepicker--content", this.$datepicker), this.$pointer = y(".air-datepicker--pointer", this.$datepicker), this.$nav = y(".air-datepicker--navigation", this.$datepicker);
|
|
932
|
+
}
|
|
933
|
+
_handleLocale() {
|
|
934
|
+
let { locale: e, dateFormat: t, firstDay: s, timepicker: a, onlyTimepicker: n, timeFormat: i, dateTimeSeparator: h } = this.opts;
|
|
935
|
+
var o;
|
|
936
|
+
this.locale = (o = e, JSON.parse(JSON.stringify(o))), t && (this.locale.dateFormat = t), i !== void 0 && i !== "" && (this.locale.timeFormat = i);
|
|
937
|
+
let { timeFormat: d } = this.locale;
|
|
938
|
+
if (s !== "" && (this.locale.firstDay = s), a && typeof t != "function") {
|
|
939
|
+
let c = d ? h : "";
|
|
940
|
+
this.locale.dateFormat = [this.locale.dateFormat, d || ""].join(c);
|
|
941
|
+
}
|
|
942
|
+
n && typeof t != "function" && (this.locale.dateFormat = this.locale.timeFormat);
|
|
943
|
+
}
|
|
944
|
+
_setPositionClasses(e) {
|
|
945
|
+
if (typeof e == "function")
|
|
946
|
+
return void this.$datepicker.classList.add("-custom-position-");
|
|
947
|
+
let t = (e = e.split(" "))[0], s = e[1], a = "air-datepicker -".concat(t, "-").concat(s, "- -from-").concat(t, "-");
|
|
948
|
+
this.$datepicker.classList.add(...a.split(" "));
|
|
949
|
+
}
|
|
950
|
+
_bindEvents() {
|
|
951
|
+
this.$el.addEventListener(this.opts.showEvent, this._onFocus), this.$el.addEventListener("blur", this._onBlur), this.$datepicker.addEventListener("mousedown", this._onMouseDown), this.$datepicker.addEventListener("mouseup", this._onMouseUp), window.addEventListener("resize", this._onResize);
|
|
952
|
+
}
|
|
953
|
+
_limitViewDateByMaxMinDates() {
|
|
954
|
+
let { viewDate: e, minDate: t, maxDate: s } = this;
|
|
955
|
+
s && $(e, s) && this.setViewDate(s), t && E(e, t) && this.setViewDate(t);
|
|
956
|
+
}
|
|
957
|
+
formatDate() {
|
|
958
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.viewDate, t = arguments.length > 1 ? arguments[1] : void 0;
|
|
959
|
+
if (e = C(e), !(e instanceof Date))
|
|
960
|
+
return;
|
|
961
|
+
let s = t, a = this.locale, n = D(e), i = F(e), h = T.replacer, o = "am";
|
|
962
|
+
this.opts.timepicker && this.timepicker && (o = this.timepicker.getDayPeriod(e).dayPeriod);
|
|
963
|
+
let d = { T: e.getTime(), m: n.minutes, mm: n.fullMinutes, h: n.hours12, hh: n.fullHours12, H: n.hours, HH: n.fullHours, aa: o, AA: o.toUpperCase(), E: a.daysShort[n.day], EEEE: a.days[n.day], d: n.date, dd: n.fullDate, M: n.month + 1, MM: n.fullMonth, MMM: a.monthsShort[n.month], MMMM: a.months[n.month], yy: n.year.toString().slice(-2), yyyy: n.year, yyyy1: i[0], yyyy2: i[1] };
|
|
964
|
+
for (let [c, u] of Object.entries(d))
|
|
965
|
+
s = h(s, G(c), u);
|
|
966
|
+
return s;
|
|
967
|
+
}
|
|
968
|
+
down(e) {
|
|
969
|
+
this._handleUpDownActions(e, "down");
|
|
970
|
+
}
|
|
971
|
+
up(e) {
|
|
972
|
+
this._handleUpDownActions(e, "up");
|
|
973
|
+
}
|
|
974
|
+
selectDate(e) {
|
|
975
|
+
let t, s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, { currentView: a, parsedViewDate: n, selectedDates: i } = this, { updateTime: h } = s, { moveToOtherMonthsOnSelect: o, moveToOtherYearsOnSelect: d, multipleDates: c, range: u, autoClose: p } = this.opts, g = i.length;
|
|
976
|
+
if (Array.isArray(e))
|
|
977
|
+
return e.forEach((f) => {
|
|
978
|
+
this.selectDate(f, s);
|
|
979
|
+
}), new Promise((f) => {
|
|
980
|
+
setTimeout(f);
|
|
981
|
+
});
|
|
982
|
+
if ((e = C(e)) instanceof Date) {
|
|
983
|
+
if (a === l.days && e.getMonth() !== n.month && o && (t = new Date(e.getFullYear(), e.getMonth(), 1)), a === l.years && e.getFullYear() !== n.year && d && (t = new Date(e.getFullYear(), 0, 1)), t && this.setViewDate(t), c && !u) {
|
|
984
|
+
if (g === c)
|
|
985
|
+
return;
|
|
986
|
+
this._checkIfDateIsSelected(e) || i.push(e);
|
|
987
|
+
} else if (u)
|
|
988
|
+
switch (g) {
|
|
989
|
+
case 1:
|
|
990
|
+
i.push(e), this.rangeDateTo || (this.rangeDateTo = e), $(this.rangeDateFrom, this.rangeDateTo) && (this.rangeDateTo = this.rangeDateFrom, this.rangeDateFrom = e), this.selectedDates = [this.rangeDateFrom, this.rangeDateTo];
|
|
991
|
+
break;
|
|
992
|
+
case 2:
|
|
993
|
+
this.selectedDates = [e], this.rangeDateFrom = e, this.rangeDateTo = "";
|
|
994
|
+
break;
|
|
995
|
+
default:
|
|
996
|
+
this.selectedDates = [e], this.rangeDateFrom = e;
|
|
997
|
+
}
|
|
998
|
+
else
|
|
999
|
+
this.selectedDates = [e];
|
|
1000
|
+
return this.trigger(l.eventChangeSelectedDate, { action: l.actionSelectDate, silent: s == null ? void 0 : s.silent, date: e, updateTime: h }), this._updateLastSelectedDate(e), p && !this.timepickerIsActive && this.visible && (c || u ? u && g === 1 && this.hide() : this.hide()), new Promise((f) => {
|
|
1001
|
+
setTimeout(f);
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
unselectDate(e) {
|
|
1006
|
+
let t = this.selectedDates, s = this;
|
|
1007
|
+
if ((e = C(e)) instanceof Date)
|
|
1008
|
+
return t.some((a, n) => {
|
|
1009
|
+
if (v(a, e))
|
|
1010
|
+
return t.splice(n, 1), s.selectedDates.length ? s._updateLastSelectedDate(s.selectedDates[s.selectedDates.length - 1]) : (s.rangeDateFrom = "", s.rangeDateTo = "", s._updateLastSelectedDate(!1)), this.trigger(l.eventChangeSelectedDate, { action: l.actionUnselectDate, date: e }), !0;
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
replaceDate(e, t) {
|
|
1014
|
+
let s = this.selectedDates.find((n) => v(n, e, this.currentView)), a = this.selectedDates.indexOf(s);
|
|
1015
|
+
a < 0 || v(this.selectedDates[a], t, this.currentView) || (this.selectedDates[a] = t, this.trigger(l.eventChangeSelectedDate, { action: l.actionSelectDate, date: t, updateTime: !0 }), this._updateLastSelectedDate(t));
|
|
1016
|
+
}
|
|
1017
|
+
clear() {
|
|
1018
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1019
|
+
return this.selectedDates = [], this.rangeDateFrom = !1, this.rangeDateTo = !1, this.trigger(l.eventChangeSelectedDate, { action: l.actionUnselectDate, silent: e.silent }), new Promise((t) => {
|
|
1020
|
+
setTimeout(t);
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
show() {
|
|
1024
|
+
let { onShow: e, isMobile: t } = this.opts;
|
|
1025
|
+
this._cancelScheduledCall(), this.visible || this.hideAnimation || this._createComponents(), this.setPosition(this.opts.position), this.$datepicker.classList.add("-active-"), this.visible = !0, e && this._scheduleCallAfterTransition(e), t && this._showMobileOverlay();
|
|
1026
|
+
}
|
|
1027
|
+
hide() {
|
|
1028
|
+
let { onHide: e, isMobile: t } = this.opts, s = this._hasTransition();
|
|
1029
|
+
this.visible = !1, this.hideAnimation = !0, this.$datepicker.classList.remove("-active-"), this.customHide && this.customHide(), this.elIsInput && this.$el.blur(), this._scheduleCallAfterTransition((a) => {
|
|
1030
|
+
!this.customHide && (a && s || !a && !s) && this._finishHide(), e && e(a);
|
|
1031
|
+
}), t && S.classList.remove("-active-");
|
|
1032
|
+
}
|
|
1033
|
+
_triggerOnSelect() {
|
|
1034
|
+
let e = [], t = [], { selectedDates: s, locale: a, opts: { onSelect: n, multipleDates: i, range: h } } = this, o = i || h, d = typeof a.dateFormat == "function";
|
|
1035
|
+
s.length && (e = s.map(J), t = d ? i ? a.dateFormat(e) : e.map((c) => a.dateFormat(c)) : e.map((c) => this.formatDate(c, a.dateFormat))), n({ date: o ? e : e[0], formattedDate: o ? t : t[0], datepicker: this });
|
|
1036
|
+
}
|
|
1037
|
+
_handleAlreadySelectedDates(e, t) {
|
|
1038
|
+
let { range: s, toggleSelected: a } = this.opts;
|
|
1039
|
+
s ? a ? this.unselectDate(t) : this.selectedDates.length !== 2 && this.selectDate(t) : a && this.unselectDate(t), a || this._updateLastSelectedDate(e);
|
|
1040
|
+
}
|
|
1041
|
+
_handleUpDownActions(e, t) {
|
|
1042
|
+
if (!((e = C(e || this.focusDate || this.viewDate)) instanceof Date))
|
|
1043
|
+
return;
|
|
1044
|
+
let s = t === "up" ? this.viewIndex + 1 : this.viewIndex - 1;
|
|
1045
|
+
s > 2 && (s = 2), s < 0 && (s = 0), this.setViewDate(new Date(e.getFullYear(), e.getMonth(), 1)), this.setCurrentView(this.viewIndexes[s]);
|
|
1046
|
+
}
|
|
1047
|
+
_handleRangeOnFocus() {
|
|
1048
|
+
this.selectedDates.length === 1 && ($(this.selectedDates[0], this.focusDate) ? (this.rangeDateTo = this.selectedDates[0], this.rangeDateFrom = this.focusDate) : (this.rangeDateTo = this.focusDate, this.rangeDateFrom = this.selectedDates[0]));
|
|
1049
|
+
}
|
|
1050
|
+
getCell(e) {
|
|
1051
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : l.day;
|
|
1052
|
+
if (!((e = C(e)) instanceof Date))
|
|
1053
|
+
return;
|
|
1054
|
+
let { year: s, month: a, date: n } = D(e), i = '[data-year="'.concat(s, '"]'), h = '[data-month="'.concat(a, '"]'), o = '[data-date="'.concat(n, '"]'), d = { [l.day]: "".concat(i).concat(h).concat(o), [l.month]: "".concat(i).concat(h), [l.year]: "".concat(i) };
|
|
1055
|
+
return this.views[this.currentView].$el.querySelector(d[t]);
|
|
1056
|
+
}
|
|
1057
|
+
_showMobileOverlay() {
|
|
1058
|
+
S.classList.add("-active-");
|
|
1059
|
+
}
|
|
1060
|
+
_hasTransition() {
|
|
1061
|
+
return window.getComputedStyle(this.$datepicker).getPropertyValue("transition-duration").split(", ").reduce((e, t) => parseFloat(t) + e, 0) > 0;
|
|
1062
|
+
}
|
|
1063
|
+
get shouldUpdateDOM() {
|
|
1064
|
+
return this.visible || this.treatAsInline;
|
|
1065
|
+
}
|
|
1066
|
+
get parsedViewDate() {
|
|
1067
|
+
return D(this.viewDate);
|
|
1068
|
+
}
|
|
1069
|
+
get currentViewSingular() {
|
|
1070
|
+
return this.currentView.slice(0, -1);
|
|
1071
|
+
}
|
|
1072
|
+
get curDecade() {
|
|
1073
|
+
return F(this.viewDate);
|
|
1074
|
+
}
|
|
1075
|
+
get viewIndex() {
|
|
1076
|
+
return this.viewIndexes.indexOf(this.currentView);
|
|
1077
|
+
}
|
|
1078
|
+
get isFinalView() {
|
|
1079
|
+
return this.currentView === l.years;
|
|
1080
|
+
}
|
|
1081
|
+
get hasSelectedDates() {
|
|
1082
|
+
return this.selectedDates.length > 0;
|
|
1083
|
+
}
|
|
1084
|
+
get isMinViewReached() {
|
|
1085
|
+
return this.currentView === this.opts.minView || this.currentView === l.days;
|
|
1086
|
+
}
|
|
1087
|
+
get $container() {
|
|
1088
|
+
return this.$customContainer || W;
|
|
1089
|
+
}
|
|
1090
|
+
static replacer(e, t, s) {
|
|
1091
|
+
return e.replace(t, function(a, n, i, h) {
|
|
1092
|
+
return n + s + h;
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
var ie;
|
|
1097
|
+
return m(T, "defaults", Q), m(T, "version", "3.3.0"), m(T, "defaultContainerId", "air-datepicker-global-container"), ie = T.prototype, Object.assign(ie, me), j.default;
|
|
1098
|
+
}();
|
|
1099
|
+
});
|
|
1100
|
+
})(ne);
|
|
1101
|
+
var ye = ne.exports;
|
|
1102
|
+
const ke = /* @__PURE__ */ De(ye);
|
|
68
1103
|
export {
|
|
69
|
-
|
|
1104
|
+
ke as default
|
|
70
1105
|
};
|
|
71
1106
|
//# sourceMappingURL=design-system103.mjs.map
|