@ironsource/shared-ui 2.1.12-test.97 → 2.1.12-test.98
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.
|
@@ -4,10 +4,10 @@ import { ref as r, computed as b, onMounted as de, onBeforeMount as ce, onUnmoun
|
|
|
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 pe = (
|
|
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),
|
|
9
|
-
ie(
|
|
10
|
-
|
|
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
|
+
ie(q, () => {
|
|
10
|
+
D.value = !1;
|
|
11
11
|
});
|
|
12
12
|
const L = (e, t) => {
|
|
13
13
|
const a = {
|
|
@@ -16,22 +16,22 @@ const pe = (l, D) => {
|
|
|
16
16
|
month: e,
|
|
17
17
|
year: t
|
|
18
18
|
};
|
|
19
|
-
let n,
|
|
19
|
+
let n, l;
|
|
20
20
|
const c = new Date(t, e, 1).getDay();
|
|
21
21
|
let v = 1;
|
|
22
22
|
const f = /* @__PURE__ */ new Date();
|
|
23
23
|
f.setHours(0, 0, 0, 0);
|
|
24
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 && 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,
|
|
29
|
-
a.weeks.push(
|
|
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
|
+
a.weeks.push(l);
|
|
30
30
|
}
|
|
31
31
|
return a;
|
|
32
32
|
}, T = () => {
|
|
33
33
|
let e = m.getCurrentTimeUTC();
|
|
34
|
-
if (s.value && s.value.toEnd ? e = s.value.toEnd :
|
|
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
35
|
u.value = {}, g.value = [];
|
|
36
36
|
for (let t = 0; t < _; t++) {
|
|
37
37
|
const a = new Date(e);
|
|
@@ -46,36 +46,32 @@ const pe = (l, D) => {
|
|
|
46
46
|
}, g.value.unshift(n);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
},
|
|
50
|
-
|
|
49
|
+
}, z = (e, t) => {
|
|
50
|
+
w.value = e;
|
|
51
51
|
let a = e;
|
|
52
|
-
e === "date" && (a =
|
|
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 = "", d.value = { started: !1, date: null }, i.value = "custom"),
|
|
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
|
-
i.value = e.id,
|
|
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.from && !e.to && e.preset ?
|
|
63
|
-
from: a.from,
|
|
64
|
-
to: a.to,
|
|
65
|
-
preset: e.preset
|
|
66
|
-
})) : (!e || !e.from && !e.to) && (a = k.value[E.value[0]]), l.maxDaysInRange && (K.value = t ? ge(a.from, l.maxDaysInRange) : null), C.value = !1, !a.from || !a.to || !(a.from instanceof Date) || !(a.to instanceof Date) ? (F.value = De, C.value = !0, !1) : a.from > a.to ? (F.value = `"From" date can't be bigger than "To" date`, C.value = !0, !1) : (s.value = z(a), S.value.from = X(
|
|
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(
|
|
67
63
|
s.value.fromStart,
|
|
68
|
-
|
|
69
|
-
), S.value.to = X(s.value.toEnd,
|
|
70
|
-
},
|
|
71
|
-
i.value === "custom" ?
|
|
64
|
+
o.dateFormat
|
|
65
|
+
), S.value.to = X(s.value.toEnd, o.dateFormat), !0);
|
|
66
|
+
}, F = () => {
|
|
67
|
+
i.value === "custom" ? P.value = m.getDateRangeString(s.value) : P.value = J.value, y("currentDateChanged", P.value);
|
|
72
68
|
}, te = () => {
|
|
73
69
|
if (s.value.fromStart == null || s.value.toEnd == null) {
|
|
74
|
-
C.value = !0,
|
|
70
|
+
C.value = !0, O.value = Me;
|
|
75
71
|
return;
|
|
76
72
|
}
|
|
77
73
|
const e = m.getCurrentTimeUTC();
|
|
78
|
-
s.value.toEnd > e && (s.value.toEnd = e),
|
|
74
|
+
s.value.toEnd > e && (s.value.toEnd = e), F(), p.value = i.value, y("rangeChanged", {
|
|
79
75
|
from: s.value.fromStart,
|
|
80
76
|
to: s.value.toEnd,
|
|
81
77
|
preset: p.value
|
|
@@ -83,7 +79,7 @@ const pe = (l, D) => {
|
|
|
83
79
|
}, ae = (e, t) => e ? Z : t ? V : null, ne = (e) => {
|
|
84
80
|
let t = null, a = null;
|
|
85
81
|
const n = _ - 1;
|
|
86
|
-
let
|
|
82
|
+
let l = "", h = null, c = null;
|
|
87
83
|
switch (e) {
|
|
88
84
|
case V:
|
|
89
85
|
Object.keys(u.value).forEach((v) => {
|
|
@@ -92,10 +88,10 @@ const pe = (l, D) => {
|
|
|
92
88
|
g.value.indexOf(v),
|
|
93
89
|
1
|
|
94
90
|
), delete u.value[v]) : f.order += 1;
|
|
95
|
-
}), t = h.parsedMonth.month + 1, a = h.parsedMonth.year, t > 11 && (t = 0, a += 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] = {
|
|
96
92
|
parsedMonth: L(t, a),
|
|
97
93
|
order: 0
|
|
98
|
-
}, g.value.push(
|
|
94
|
+
}, g.value.push(l);
|
|
99
95
|
break;
|
|
100
96
|
case Z:
|
|
101
97
|
Object.keys(u.value).forEach((v) => {
|
|
@@ -104,15 +100,15 @@ const pe = (l, D) => {
|
|
|
104
100
|
g.value.indexOf(v),
|
|
105
101
|
1
|
|
106
102
|
), delete u.value[v]) : f.order -= 1;
|
|
107
|
-
}), t = c.parsedMonth.month - 1, a = c.parsedMonth.year, t < 0 && (t = 11, a -= 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] = {
|
|
108
104
|
parsedMonth: L(t, a),
|
|
109
105
|
order: n
|
|
110
|
-
}, g.value.unshift(
|
|
106
|
+
}, g.value.unshift(l);
|
|
111
107
|
break;
|
|
112
108
|
}
|
|
113
|
-
},
|
|
109
|
+
}, R = (e) => {
|
|
114
110
|
let t;
|
|
115
|
-
switch (
|
|
111
|
+
switch (w.value) {
|
|
116
112
|
case "week":
|
|
117
113
|
t = {
|
|
118
114
|
fromStart: m.getFirstDayOfWeek(e.from),
|
|
@@ -151,75 +147,75 @@ const pe = (l, D) => {
|
|
|
151
147
|
}, U = (e, t) => e.getUTCFullYear() === t.getUTCFullYear() && e.getUTCMonth() === t.getUTCMonth() && e.getUTCDate() === t.getUTCDate(), $ = (e) => {
|
|
152
148
|
let t = !1;
|
|
153
149
|
if (!e.from && !e.to && e.preset) {
|
|
154
|
-
const
|
|
150
|
+
const l = E.value.find(
|
|
155
151
|
(h) => h.id === e.preset
|
|
156
152
|
);
|
|
157
|
-
i.value =
|
|
153
|
+
i.value = l.id, t = !0;
|
|
158
154
|
}
|
|
159
155
|
const a = {
|
|
160
156
|
from: new Date(e.from),
|
|
161
157
|
to: new Date(e.to)
|
|
162
158
|
};
|
|
163
159
|
a.from.setHours(0, 0, 0, 0), a.to.setHours(0, 0, 0, 0);
|
|
164
|
-
const n = E.value.map((
|
|
165
|
-
if (Object.keys(k.value).forEach((
|
|
166
|
-
const h = k.value[
|
|
167
|
-
if (
|
|
160
|
+
const n = E.value.map((l) => l.id);
|
|
161
|
+
if (Object.keys(k.value).forEach((l) => {
|
|
162
|
+
const h = k.value[l];
|
|
163
|
+
if (l !== "custom" && !t && n.indexOf(l) !== -1) {
|
|
168
164
|
const c = h.dates();
|
|
169
|
-
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 =
|
|
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);
|
|
170
166
|
}
|
|
171
167
|
}), t) {
|
|
172
|
-
const
|
|
168
|
+
const l = E.value.find(
|
|
173
169
|
(h) => h.id === i.value
|
|
174
170
|
);
|
|
175
|
-
|
|
171
|
+
y("dateRangePresetNameChanged", l.name);
|
|
176
172
|
} else
|
|
177
|
-
|
|
173
|
+
y("dateRangePresetNameChanged", null), i.value = "custom";
|
|
178
174
|
p.value = i.value;
|
|
179
175
|
}, A = (e, t, a) => {
|
|
180
176
|
if (!d.value.started)
|
|
181
|
-
i.value = "custom", d.value.started = !0, d.value.date = new Date(a, t, e.value),
|
|
177
|
+
i.value = "custom", d.value.started = !0, d.value.date = new Date(a, t, e.value), M(
|
|
182
178
|
{ from: d.value.date, to: d.value.date },
|
|
183
179
|
!0
|
|
184
180
|
);
|
|
185
181
|
else {
|
|
186
|
-
const n = new Date(a, t, e.value),
|
|
187
|
-
d.value.started = !1, d.value.date = null, n <
|
|
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 });
|
|
188
184
|
}
|
|
189
185
|
}, B = () => {
|
|
190
186
|
const e = N.value.offsetLeft;
|
|
191
187
|
return window.innerWidth - e > 930 ? "left" : "right";
|
|
192
188
|
}, W = (e = !0) => {
|
|
193
|
-
|
|
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"));
|
|
194
190
|
}, G = () => {
|
|
195
|
-
|
|
196
|
-
},
|
|
197
|
-
k.value = m.getPresetsFunctions(
|
|
198
|
-
dates: () =>
|
|
191
|
+
D.value && W();
|
|
192
|
+
}, le = () => {
|
|
193
|
+
k.value = m.getPresetsFunctions(o.includeToday), k.value.custom = {
|
|
194
|
+
dates: () => o.range
|
|
199
195
|
};
|
|
200
|
-
},
|
|
196
|
+
}, oe = b(() => (g.value || []).reduce((e, t) => {
|
|
201
197
|
const n = u.value[t].parsedMonth.weeks[u.value[t].parsedMonth.weeks.length - 1].filter(
|
|
202
|
-
(
|
|
198
|
+
(l) => l.value !== 0
|
|
203
199
|
).length;
|
|
204
200
|
return e && !n;
|
|
205
201
|
}, !0)), Y = () => {
|
|
206
|
-
|
|
202
|
+
o.range && (x.value = !0, z(o.initialType || o.types[0]), le(), $(o.range), M(o.range), T(), F());
|
|
207
203
|
};
|
|
208
204
|
de(() => {
|
|
209
205
|
Y();
|
|
210
206
|
}), ce(() => {
|
|
211
207
|
const e = (t) => {
|
|
212
|
-
t.key === "Escape" &&
|
|
208
|
+
t.key === "Escape" && D.value && G();
|
|
213
209
|
};
|
|
214
210
|
document.addEventListener("keyup", e), ve(() => {
|
|
215
211
|
document.removeEventListener("keyup", e);
|
|
216
212
|
});
|
|
217
213
|
}), Q(
|
|
218
|
-
() =>
|
|
214
|
+
() => o.range,
|
|
219
215
|
(e, t) => {
|
|
220
|
-
e && e !== t && (x.value ? ($(e),
|
|
216
|
+
e && e !== t && (x.value ? ($(e), M(e), F()) : Y());
|
|
221
217
|
}
|
|
222
|
-
), Q(
|
|
218
|
+
), Q(D, (e) => {
|
|
223
219
|
e || (d.value.started = !1);
|
|
224
220
|
});
|
|
225
221
|
const J = b(() => {
|
|
@@ -227,8 +223,8 @@ const pe = (l, D) => {
|
|
|
227
223
|
(t) => t.id === i.value
|
|
228
224
|
);
|
|
229
225
|
return e ? e.name : "";
|
|
230
|
-
}), re = b(() => `datepicker${
|
|
231
|
-
const e = [
|
|
226
|
+
}), re = b(() => `datepicker${o.uniqueId}`), se = b(() => {
|
|
227
|
+
const e = [o.maxDate, K.value].filter((t) => t);
|
|
232
228
|
return e.length ? me(e) : null;
|
|
233
229
|
});
|
|
234
230
|
return {
|
|
@@ -238,35 +234,35 @@ const pe = (l, D) => {
|
|
|
238
234
|
selectedPresetName: J,
|
|
239
235
|
selectedPreset: i,
|
|
240
236
|
displayError: C,
|
|
241
|
-
rangeType:
|
|
237
|
+
rangeType: w,
|
|
242
238
|
selectedRange: s,
|
|
243
239
|
placement: j,
|
|
244
|
-
currentDate:
|
|
245
|
-
error:
|
|
240
|
+
currentDate: P,
|
|
241
|
+
error: O,
|
|
246
242
|
presets: E,
|
|
247
|
-
isOpen:
|
|
248
|
-
popup:
|
|
243
|
+
isOpen: D,
|
|
244
|
+
popup: q,
|
|
249
245
|
selectionStart: d,
|
|
250
246
|
initialized: x,
|
|
251
247
|
textDates: S,
|
|
252
248
|
currentMonths: u,
|
|
253
249
|
displayedMonthsKeys: g,
|
|
254
250
|
initMonths: T,
|
|
255
|
-
changeType:
|
|
251
|
+
changeType: z,
|
|
256
252
|
presetChanged: ee,
|
|
257
|
-
initRange:
|
|
258
|
-
setCurrentDate:
|
|
253
|
+
initRange: M,
|
|
254
|
+
setCurrentDate: F,
|
|
259
255
|
apply: te,
|
|
260
256
|
getNavigation: ae,
|
|
261
257
|
navigationCallback: ne,
|
|
262
|
-
getSelectedRangeByType:
|
|
258
|
+
getSelectedRangeByType: R,
|
|
263
259
|
compareDates: U,
|
|
264
260
|
determinePreset: $,
|
|
265
261
|
selectionChanged: A,
|
|
266
262
|
checkPlacement: B,
|
|
267
263
|
toggle: W,
|
|
268
264
|
closeDatePicker: G,
|
|
269
|
-
isCompact:
|
|
265
|
+
isCompact: oe,
|
|
270
266
|
init: Y
|
|
271
267
|
};
|
|
272
268
|
};
|