@ironsource/shared-ui 2.1.12-test.88 → 2.1.12-test.90
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { onClickOutside as ie } from "@vueuse/core";
|
|
2
2
|
import { useToggle as fe } from "../../../composables/useToggle.js";
|
|
3
|
-
import { ref as r, computed as b, onMounted as
|
|
3
|
+
import { ref as r, computed as b, onMounted as de, onBeforeMount as ce, onUnmounted as ve, watch as Q } from "vue";
|
|
4
4
|
import { min as me, addDays as ge, format as X } from "date-fns";
|
|
5
5
|
import { presetsList as he, formatError as De, mandatoryValuesError as Me, navigatePrev as Z, navigateNext as V } from "./consts.common.js";
|
|
6
6
|
import m from "./DateServices.common.js";
|
|
7
|
-
const
|
|
8
|
-
const N = r(null),
|
|
7
|
+
const pe = (o, y) => {
|
|
8
|
+
const N = r(null), d = r({ started: !1, date: null }), x = r(!1), _ = 2, S = r({ from: null, to: null }), u = r({}), g = r([]), k = r(null), i = r({}), p = r({}), C = r(!1), w = r(null), s = r(null), j = r("left"), P = r(null), O = r(null), E = r([]), K = r(null), [D] = fe({ initialValue: !1 }), q = r(null);
|
|
9
9
|
ie(q, () => {
|
|
10
|
-
|
|
10
|
+
D.value = !1;
|
|
11
11
|
});
|
|
12
12
|
const L = (e, t) => {
|
|
13
13
|
const a = {
|
|
@@ -17,27 +17,27 @@ const Te = (o, y) => {
|
|
|
17
17
|
year: t
|
|
18
18
|
};
|
|
19
19
|
let n, l;
|
|
20
|
-
const
|
|
20
|
+
const c = new Date(t, e, 1).getDay();
|
|
21
21
|
let v = 1;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const
|
|
22
|
+
const f = /* @__PURE__ */ new Date();
|
|
23
|
+
f.setHours(0, 0, 0, 0);
|
|
24
|
+
const ue = m.daysInMonth(e, t);
|
|
25
25
|
for (let I = 0; I < 6; I++) {
|
|
26
26
|
l = [];
|
|
27
27
|
for (let H = 0; H < 7; H++)
|
|
28
|
-
n = {}, I === 0 &&
|
|
28
|
+
n = {}, I === 0 && c > 0 && H < c && (n.value = 0), v > ue && (n.value = 0), !n.value && n.value !== 0 && (n.value = v, v += 1, a.days[n.value] = n, n.date = new Date(t, e, n.value), f < n.date ? n.isFuture = !0 : n.date.getTime() === f.getTime() && (n.isToday = !0, o.includeToday || (n.disabled = !0))), l.push(n);
|
|
29
29
|
a.weeks.push(l);
|
|
30
30
|
}
|
|
31
31
|
return a;
|
|
32
|
-
},
|
|
32
|
+
}, T = () => {
|
|
33
33
|
let e = m.getCurrentTimeUTC();
|
|
34
|
-
if (
|
|
35
|
-
|
|
34
|
+
if (s.value && s.value.toEnd ? e = s.value.toEnd : o.range && o.range.to && (e = o.range.to), !u.value[`${e.getFullYear().toString()}_${e.getMonth().toString()}`]) {
|
|
35
|
+
u.value = {}, g.value = [];
|
|
36
36
|
for (let t = 0; t < _; t++) {
|
|
37
37
|
const a = new Date(e);
|
|
38
38
|
a.setDate(1), a.setMonth(e.getMonth() - t);
|
|
39
39
|
const n = `${a.getFullYear().toString()}_${a.getMonth().toString()}`;
|
|
40
|
-
|
|
40
|
+
u.value[n] = {
|
|
41
41
|
parsedMonth: L(
|
|
42
42
|
a.getMonth(),
|
|
43
43
|
a.getFullYear()
|
|
@@ -47,60 +47,60 @@ const Te = (o, y) => {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}, z = (e, t) => {
|
|
50
|
-
|
|
50
|
+
w.value = e;
|
|
51
51
|
let a = e;
|
|
52
|
-
e === "date" && (a = o.datePresetList), E.value = he[a], t && (
|
|
52
|
+
e === "date" && (a = o.datePresetList), E.value = he[a], t && (s.value = {
|
|
53
53
|
fromStart: null,
|
|
54
54
|
fromEnd: null,
|
|
55
55
|
toStart: null,
|
|
56
56
|
toEnd: null
|
|
57
|
-
}, S.value.from = "", S.value.to = "",
|
|
57
|
+
}, S.value.from = "", S.value.to = "", d.value = { started: !1, date: null }, i.value = "custom"), y("rangeTypeChanged", w.value);
|
|
58
58
|
}, ee = (e) => {
|
|
59
|
-
|
|
60
|
-
},
|
|
59
|
+
i.value = e.id, M(k.value[e.id].dates()), T();
|
|
60
|
+
}, M = (e, t = !1) => {
|
|
61
61
|
let a = e;
|
|
62
|
-
return (!e || !e.from && !e.to) && (a = k.value[E.value[0]]), o.maxDaysInRange && (K.value = t ? ge(a.from, o.maxDaysInRange) : null),
|
|
63
|
-
|
|
62
|
+
return !e.from && !e.to && e.preset ? a = k.value[e.preset]?.dates() : (!e || !e.from && !e.to) && (a = k.value[E.value[0]]), o.maxDaysInRange && (K.value = t ? ge(a.from, o.maxDaysInRange) : null), C.value = !1, !a.from || !a.to || !(a.from instanceof Date) || !(a.to instanceof Date) ? (O.value = De, C.value = !0, !1) : a.from > a.to ? (O.value = `"From" date can't be bigger than "To" date`, C.value = !0, !1) : (s.value = R(a), S.value.from = X(
|
|
63
|
+
s.value.fromStart,
|
|
64
64
|
o.dateFormat
|
|
65
|
-
), S.value.to = X(
|
|
65
|
+
), S.value.to = X(s.value.toEnd, o.dateFormat), !0);
|
|
66
66
|
}, F = () => {
|
|
67
|
-
|
|
67
|
+
i.value === "custom" ? P.value = m.getDateRangeString(s.value) : P.value = J.value, y("currentDateChanged", P.value);
|
|
68
68
|
}, te = () => {
|
|
69
|
-
if (
|
|
70
|
-
|
|
69
|
+
if (s.value.fromStart == null || s.value.toEnd == null) {
|
|
70
|
+
C.value = !0, O.value = Me;
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
const e = m.getCurrentTimeUTC();
|
|
74
|
-
|
|
75
|
-
from:
|
|
76
|
-
to:
|
|
77
|
-
preset:
|
|
74
|
+
s.value.toEnd > e && (s.value.toEnd = e), F(), p.value = i.value, y("rangeChanged", {
|
|
75
|
+
from: s.value.fromStart,
|
|
76
|
+
to: s.value.toEnd,
|
|
77
|
+
preset: p.value
|
|
78
78
|
}), W(!1);
|
|
79
79
|
}, ae = (e, t) => e ? Z : t ? V : null, ne = (e) => {
|
|
80
80
|
let t = null, a = null;
|
|
81
81
|
const n = _ - 1;
|
|
82
|
-
let l = "",
|
|
82
|
+
let l = "", h = null, c = null;
|
|
83
83
|
switch (e) {
|
|
84
84
|
case V:
|
|
85
|
-
Object.keys(
|
|
86
|
-
const
|
|
87
|
-
|
|
85
|
+
Object.keys(u.value).forEach((v) => {
|
|
86
|
+
const f = u.value[v];
|
|
87
|
+
f.order === 0 && (h = f), f.order === n ? (g.value.splice(
|
|
88
88
|
g.value.indexOf(v),
|
|
89
89
|
1
|
|
90
|
-
), delete
|
|
91
|
-
}), t =
|
|
90
|
+
), delete u.value[v]) : f.order += 1;
|
|
91
|
+
}), t = h.parsedMonth.month + 1, a = h.parsedMonth.year, t > 11 && (t = 0, a += 1), l = `${a.toString()}_${t.toString()}`, u.value[l] = {
|
|
92
92
|
parsedMonth: L(t, a),
|
|
93
93
|
order: 0
|
|
94
94
|
}, g.value.push(l);
|
|
95
95
|
break;
|
|
96
96
|
case Z:
|
|
97
|
-
Object.keys(
|
|
98
|
-
const
|
|
99
|
-
|
|
97
|
+
Object.keys(u.value).forEach((v) => {
|
|
98
|
+
const f = u.value[v];
|
|
99
|
+
f.order === n && (c = f), f.order === 0 ? (g.value.splice(
|
|
100
100
|
g.value.indexOf(v),
|
|
101
101
|
1
|
|
102
|
-
), delete
|
|
103
|
-
}), t =
|
|
102
|
+
), delete u.value[v]) : f.order -= 1;
|
|
103
|
+
}), t = c.parsedMonth.month - 1, a = c.parsedMonth.year, t < 0 && (t = 11, a -= 1), l = `${a.toString()}_${t.toString()}`, u.value[l] = {
|
|
104
104
|
parsedMonth: L(t, a),
|
|
105
105
|
order: n
|
|
106
106
|
}, g.value.unshift(l);
|
|
@@ -108,7 +108,7 @@ const Te = (o, y) => {
|
|
|
108
108
|
}
|
|
109
109
|
}, R = (e) => {
|
|
110
110
|
let t;
|
|
111
|
-
switch (
|
|
111
|
+
switch (w.value) {
|
|
112
112
|
case "week":
|
|
113
113
|
t = {
|
|
114
114
|
fromStart: m.getFirstDayOfWeek(e.from),
|
|
@@ -146,6 +146,12 @@ const Te = (o, y) => {
|
|
|
146
146
|
return t;
|
|
147
147
|
}, U = (e, t) => e.getUTCFullYear() === t.getUTCFullYear() && e.getUTCMonth() === t.getUTCMonth() && e.getUTCDate() === t.getUTCDate(), $ = (e) => {
|
|
148
148
|
let t = !1;
|
|
149
|
+
if (!e.from && !e.to && e.preset) {
|
|
150
|
+
const l = E.value.find(
|
|
151
|
+
(h) => h.id === e.preset
|
|
152
|
+
);
|
|
153
|
+
i.value = l.id, t = !0;
|
|
154
|
+
}
|
|
149
155
|
const a = {
|
|
150
156
|
from: new Date(e.from),
|
|
151
157
|
to: new Date(e.to)
|
|
@@ -153,53 +159,53 @@ const Te = (o, y) => {
|
|
|
153
159
|
a.from.setHours(0, 0, 0, 0), a.to.setHours(0, 0, 0, 0);
|
|
154
160
|
const n = E.value.map((l) => l.id);
|
|
155
161
|
if (Object.keys(k.value).forEach((l) => {
|
|
156
|
-
const
|
|
162
|
+
const h = k.value[l];
|
|
157
163
|
if (l !== "custom" && !t && n.indexOf(l) !== -1) {
|
|
158
|
-
const
|
|
159
|
-
|
|
164
|
+
const c = h.dates();
|
|
165
|
+
c.from.setHours(0, 0, 0, 0), c.to.setHours(0, 0, 0, 0), U(c.from, a.from) && U(c.to, a.to) && (i.value = l, t = !0);
|
|
160
166
|
}
|
|
161
167
|
}), t) {
|
|
162
168
|
const l = E.value.find(
|
|
163
|
-
(
|
|
169
|
+
(h) => h.id === i.value
|
|
164
170
|
);
|
|
165
171
|
y("dateRangePresetNameChanged", l.name);
|
|
166
172
|
} else
|
|
167
|
-
y("dateRangePresetNameChanged", null),
|
|
168
|
-
|
|
173
|
+
y("dateRangePresetNameChanged", null), i.value = "custom";
|
|
174
|
+
p.value = i.value;
|
|
169
175
|
}, A = (e, t, a) => {
|
|
170
|
-
if (!
|
|
171
|
-
|
|
172
|
-
{ from:
|
|
176
|
+
if (!d.value.started)
|
|
177
|
+
i.value = "custom", d.value.started = !0, d.value.date = new Date(a, t, e.value), M(
|
|
178
|
+
{ from: d.value.date, to: d.value.date },
|
|
173
179
|
!0
|
|
174
180
|
);
|
|
175
181
|
else {
|
|
176
|
-
const n = new Date(a, t, e.value), l =
|
|
177
|
-
|
|
182
|
+
const n = new Date(a, t, e.value), l = d.value.date;
|
|
183
|
+
d.value.started = !1, d.value.date = null, n < l ? A(e, t, a) : M({ from: l, to: n });
|
|
178
184
|
}
|
|
179
185
|
}, B = () => {
|
|
180
186
|
const e = N.value.offsetLeft;
|
|
181
187
|
return window.innerWidth - e > 930 ? "left" : "right";
|
|
182
188
|
}, W = (e = !0) => {
|
|
183
|
-
|
|
189
|
+
D.value = !D.value, D.value ? (j.value = B(), M(o.range), T(), y("opened")) : (M(o.range), T(), i.value = p.value, e && y("dismissed"));
|
|
184
190
|
}, G = () => {
|
|
185
|
-
|
|
191
|
+
D.value && W();
|
|
186
192
|
}, le = () => {
|
|
187
193
|
k.value = m.getPresetsFunctions(o.includeToday), k.value.custom = {
|
|
188
194
|
dates: () => o.range
|
|
189
195
|
};
|
|
190
196
|
}, oe = b(() => (g.value || []).reduce((e, t) => {
|
|
191
|
-
const n =
|
|
197
|
+
const n = u.value[t].parsedMonth.weeks[u.value[t].parsedMonth.weeks.length - 1].filter(
|
|
192
198
|
(l) => l.value !== 0
|
|
193
199
|
).length;
|
|
194
200
|
return e && !n;
|
|
195
201
|
}, !0)), Y = () => {
|
|
196
|
-
o.range && (x.value = !0, z(o.initialType || o.types[0]), le(), $(o.range),
|
|
202
|
+
o.range && (x.value = !0, z(o.initialType || o.types[0]), le(), $(o.range), M(o.range), T(), F());
|
|
197
203
|
};
|
|
198
|
-
|
|
204
|
+
de(() => {
|
|
199
205
|
Y();
|
|
200
|
-
}),
|
|
206
|
+
}), ce(() => {
|
|
201
207
|
const e = (t) => {
|
|
202
|
-
t.key === "Escape" &&
|
|
208
|
+
t.key === "Escape" && D.value && G();
|
|
203
209
|
};
|
|
204
210
|
document.addEventListener("keyup", e), ve(() => {
|
|
205
211
|
document.removeEventListener("keyup", e);
|
|
@@ -207,44 +213,44 @@ const Te = (o, y) => {
|
|
|
207
213
|
}), Q(
|
|
208
214
|
() => o.range,
|
|
209
215
|
(e, t) => {
|
|
210
|
-
e && e !== t && (x.value ? ($(e),
|
|
216
|
+
e && e !== t && (x.value ? ($(e), M(e), F()) : Y());
|
|
211
217
|
}
|
|
212
|
-
), Q(
|
|
213
|
-
e || (
|
|
218
|
+
), Q(D, (e) => {
|
|
219
|
+
e || (d.value.started = !1);
|
|
214
220
|
});
|
|
215
221
|
const J = b(() => {
|
|
216
222
|
const e = E.value.find(
|
|
217
|
-
(t) => t.id ===
|
|
223
|
+
(t) => t.id === i.value
|
|
218
224
|
);
|
|
219
225
|
return e ? e.name : "";
|
|
220
|
-
}), re = b(() => `datepicker${o.uniqueId}`),
|
|
226
|
+
}), re = b(() => `datepicker${o.uniqueId}`), se = b(() => {
|
|
221
227
|
const e = [o.maxDate, K.value].filter((t) => t);
|
|
222
228
|
return e.length ? me(e) : null;
|
|
223
229
|
});
|
|
224
230
|
return {
|
|
225
231
|
datePicker: N,
|
|
226
232
|
datePickerId: re,
|
|
227
|
-
getMaxAllowedDate:
|
|
233
|
+
getMaxAllowedDate: se,
|
|
228
234
|
selectedPresetName: J,
|
|
229
|
-
selectedPreset:
|
|
230
|
-
displayError:
|
|
231
|
-
rangeType:
|
|
232
|
-
selectedRange:
|
|
235
|
+
selectedPreset: i,
|
|
236
|
+
displayError: C,
|
|
237
|
+
rangeType: w,
|
|
238
|
+
selectedRange: s,
|
|
233
239
|
placement: j,
|
|
234
|
-
currentDate:
|
|
240
|
+
currentDate: P,
|
|
235
241
|
error: O,
|
|
236
242
|
presets: E,
|
|
237
|
-
isOpen:
|
|
243
|
+
isOpen: D,
|
|
238
244
|
popup: q,
|
|
239
|
-
selectionStart:
|
|
245
|
+
selectionStart: d,
|
|
240
246
|
initialized: x,
|
|
241
247
|
textDates: S,
|
|
242
|
-
currentMonths:
|
|
248
|
+
currentMonths: u,
|
|
243
249
|
displayedMonthsKeys: g,
|
|
244
|
-
initMonths:
|
|
250
|
+
initMonths: T,
|
|
245
251
|
changeType: z,
|
|
246
252
|
presetChanged: ee,
|
|
247
|
-
initRange:
|
|
253
|
+
initRange: M,
|
|
248
254
|
setCurrentDate: F,
|
|
249
255
|
apply: te,
|
|
250
256
|
getNavigation: ae,
|
|
@@ -261,5 +267,5 @@ const Te = (o, y) => {
|
|
|
261
267
|
};
|
|
262
268
|
};
|
|
263
269
|
export {
|
|
264
|
-
|
|
270
|
+
pe as dateRangeCommon
|
|
265
271
|
};
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './AutocompleteDropdown.vue_vue_type_style_index_0_scoped_214ddaf4_lang.css';
|
|
2
2
|
import { AppTriggerTypes as eo } from "./components/appTrigger/index.js";
|
|
3
3
|
import { AutocompleteDropdownTypes as mo } from "./components/autocompleteDropdown/index.js";
|
|
4
4
|
import { MenuItemTypes as ao } from "./components/menuItem/index.js";
|