behnoo-calendar 1.0.0
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/README.md +302 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +198 -0
- package/dist/index.js +1731 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/style.css +2 -0
- package/package.json +75 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1731 @@
|
|
|
1
|
+
import { Fragment as e, Transition as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createSlots as s, createVNode as c, defineComponent as l, guardReactiveProps as u, inject as d, mergeProps as f, nextTick as p, normalizeClass as m, normalizeProps as h, normalizeStyle as g, onMounted as _, onUnmounted as v, openBlock as y, provide as b, ref as x, renderList as S, renderSlot as C, resolveComponent as w, toDisplayString as T, unref as E, useTemplateRef as D, vShow as O, watch as k, withCtx as A, withDirectives as j, withModifiers as M } from "vue";
|
|
2
|
+
//#region src/composables/useCalendarPackage.js
|
|
3
|
+
var N = () => {
|
|
4
|
+
let e = x(typeof window < "u" ? window.innerWidth : 1024), t = x(typeof window < "u" ? window.innerHeight : 768), n = () => {
|
|
5
|
+
e.value = window.innerWidth, t.value = window.innerHeight;
|
|
6
|
+
};
|
|
7
|
+
return _(() => window.addEventListener("resize", n)), v(() => window.removeEventListener("resize", n)), {
|
|
8
|
+
width: e,
|
|
9
|
+
height: t
|
|
10
|
+
};
|
|
11
|
+
}, P = (e) => (typeof e == "object" && e && "value" in e ? String(e.value) : String(e || "fa-IR")).replace(/[^a-zA-Z-]/g, "-").split("-")[0] || "fa", F = () => {
|
|
12
|
+
let e = d("calendarConfig", x({
|
|
13
|
+
locale: "en",
|
|
14
|
+
calendar: "gregory",
|
|
15
|
+
startOfWeek: "sunday",
|
|
16
|
+
showHolidays: !1
|
|
17
|
+
}));
|
|
18
|
+
return {
|
|
19
|
+
t: (t, n) => {
|
|
20
|
+
let r = e.value.locale.startsWith("fa");
|
|
21
|
+
return {
|
|
22
|
+
"calendar.dayTimes.morning": r ? "صبح" : "Morning",
|
|
23
|
+
"calendar.dayTimes.noon": r ? "ظهر" : "Noon",
|
|
24
|
+
"calendar.dayTimes.afternoon": r ? "عصر" : "Afternoon",
|
|
25
|
+
"calendar.dayTimes.night": r ? "شب" : "Night",
|
|
26
|
+
"calendar.moreItems": r ? `${n?.count} مورد دیگر` : `${n?.count} More Items`,
|
|
27
|
+
"calendar.noEvents": r ? "رویدادی وجود ندارد" : "No events",
|
|
28
|
+
"calendar.allDay": r ? "تمام روز" : "All day",
|
|
29
|
+
"calendar.agenda": r ? "برنامه" : "Agenda"
|
|
30
|
+
}[t] || t;
|
|
31
|
+
},
|
|
32
|
+
config: e
|
|
33
|
+
};
|
|
34
|
+
}, I = (e) => {
|
|
35
|
+
let t = d("calendarConfig", x({
|
|
36
|
+
locale: "fa-IR",
|
|
37
|
+
calendar: "jalaali",
|
|
38
|
+
startOfWeek: "saturday",
|
|
39
|
+
showHolidays: !0
|
|
40
|
+
})), r = e || t, i = d("calendarHolidays", x({})), a = n(() => {
|
|
41
|
+
let e = r.value.calendar;
|
|
42
|
+
return e === "jalaali" ? "persian" : e === "islamic" ? "islamic-uma" : "gregory";
|
|
43
|
+
}), o = (e) => ({
|
|
44
|
+
sunday: 0,
|
|
45
|
+
monday: 1,
|
|
46
|
+
tuesday: 2,
|
|
47
|
+
wednesday: 3,
|
|
48
|
+
thursday: 4,
|
|
49
|
+
friday: 5,
|
|
50
|
+
saturday: 6
|
|
51
|
+
})[e.toLowerCase()] ?? 0, s = (e) => {
|
|
52
|
+
let t = new Date(e);
|
|
53
|
+
t.setHours(12, 0, 0, 0);
|
|
54
|
+
let n = a.value;
|
|
55
|
+
n === "islamic-uma" && (n = "islamic-civil", t.setDate(t.getDate() - 1));
|
|
56
|
+
let r = new Intl.DateTimeFormat(`en-u-ca-${n}`, {
|
|
57
|
+
year: "numeric",
|
|
58
|
+
month: "numeric",
|
|
59
|
+
day: "numeric"
|
|
60
|
+
}).formatToParts(t), i = (e) => parseInt(r.find((t) => t.type === e)?.value || "0");
|
|
61
|
+
return {
|
|
62
|
+
year: i("year"),
|
|
63
|
+
month: i("month"),
|
|
64
|
+
day: i("day")
|
|
65
|
+
};
|
|
66
|
+
}, c = n(() => r.value.calendar === "gregory" ? 1 : 6), l = (e) => String(e), u = (e) => {
|
|
67
|
+
let t = [
|
|
68
|
+
"۰",
|
|
69
|
+
"۱",
|
|
70
|
+
"۲",
|
|
71
|
+
"۳",
|
|
72
|
+
"۴",
|
|
73
|
+
"۵",
|
|
74
|
+
"۶",
|
|
75
|
+
"۷",
|
|
76
|
+
"۸",
|
|
77
|
+
"۹"
|
|
78
|
+
];
|
|
79
|
+
return String(e).replace(/\d/g, (e) => t[parseInt(e)] ?? e);
|
|
80
|
+
}, f = (e) => {
|
|
81
|
+
let t = P(r.value.locale), n = new Date(e);
|
|
82
|
+
n.setDate(n.getDate() + -1);
|
|
83
|
+
let o = (t, n = e) => {
|
|
84
|
+
let r = new Intl.DateTimeFormat(`en-u-ca-${t}`, {
|
|
85
|
+
year: "numeric",
|
|
86
|
+
month: "numeric",
|
|
87
|
+
day: "numeric"
|
|
88
|
+
}).formatToParts(n);
|
|
89
|
+
return parseInt(r.find((e) => e.type === "day")?.value || "0");
|
|
90
|
+
}, s = o("gregory"), c = o("persian"), d = o("islamic-civil", n), f = t === "fa" || t === "ar", p = l(s), m = f ? u(c) : l(c), h = f ? u(d) : l(d), g = r.value.calendar, _, v, y;
|
|
91
|
+
g === "jalaali" ? (_ = m, v = p, y = h) : g === "islamic" ? (_ = h, v = m, y = p) : (_ = p, v = m, y = h);
|
|
92
|
+
let b = /* @__PURE__ */ new Date(), x = e.getDate() === b.getDate() && e.getMonth() === b.getMonth() && e.getFullYear() === b.getFullYear(), S = `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`, C = i.value[S], w = C?.isHoliday || !1, T = C?.titles?.join(" - ") || null, E = e.getDay(), D = r.value.showHolidays ? g === "jalaali" || g === "islamic" ? E === 5 : E === 0 : !1, O = r.value.showHolidays ? D || w : !1, k = a.value, A = new Intl.DateTimeFormat(`${t}-u-ca-${k}`, { weekday: "long" }).format(e), j = new Intl.DateTimeFormat(`${t}-u-ca-${k}`, { weekday: "short" }).format(e);
|
|
93
|
+
return {
|
|
94
|
+
date: new Date(e),
|
|
95
|
+
primary: _,
|
|
96
|
+
secondary: v,
|
|
97
|
+
tertiary: y,
|
|
98
|
+
jalaali: c,
|
|
99
|
+
gregorian: s,
|
|
100
|
+
ghamari: d,
|
|
101
|
+
isToday: x,
|
|
102
|
+
isWeekend: D,
|
|
103
|
+
isHoliday: O,
|
|
104
|
+
holidayTitle: T,
|
|
105
|
+
name: A,
|
|
106
|
+
shortName: j,
|
|
107
|
+
dayOfWeek: E
|
|
108
|
+
};
|
|
109
|
+
}, p = (e, t) => {
|
|
110
|
+
if (!e) return [];
|
|
111
|
+
let n = [];
|
|
112
|
+
if (t === "monthly") {
|
|
113
|
+
let t = new Date(e.start);
|
|
114
|
+
t.setHours(12, 0, 0, 0);
|
|
115
|
+
let i = s(t), a = i.month, c = i.year, l = new Date(t);
|
|
116
|
+
for (; s(l).day !== 1;) l.setDate(l.getDate() - 1);
|
|
117
|
+
let u = new Date(l);
|
|
118
|
+
for (;;) {
|
|
119
|
+
u.setDate(u.getDate() + 1);
|
|
120
|
+
let e = s(u);
|
|
121
|
+
if (e.month !== a || e.year !== c) {
|
|
122
|
+
u.setDate(u.getDate() - 1);
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
let d = o(r.value.calendar === "gregory" ? "monday" : "saturday"), p = l.getDay() - d;
|
|
127
|
+
p < 0 && (p += 7);
|
|
128
|
+
let m = new Date(l);
|
|
129
|
+
m.setDate(m.getDate() - p);
|
|
130
|
+
let h = ((d + 6) % 7 - u.getDay() + 7) % 7, g = new Date(u);
|
|
131
|
+
g.setDate(g.getDate() + h);
|
|
132
|
+
let _ = new Date(m);
|
|
133
|
+
for (; _ <= g;) {
|
|
134
|
+
let e = f(new Date(_)), t = s(_);
|
|
135
|
+
n.push({
|
|
136
|
+
...e,
|
|
137
|
+
otherMonth: t.month !== a || t.year !== c
|
|
138
|
+
}), _.setDate(_.getDate() + 1);
|
|
139
|
+
}
|
|
140
|
+
} else if (t === "agenda") {
|
|
141
|
+
let t = new Date(e.start);
|
|
142
|
+
t.setHours(12, 0, 0, 0);
|
|
143
|
+
let r = s(t), i = r.month, a = r.year, o = new Date(t);
|
|
144
|
+
for (; s(o).day !== 1;) o.setDate(o.getDate() - 1);
|
|
145
|
+
let c = new Date(o);
|
|
146
|
+
for (;;) {
|
|
147
|
+
c.setDate(c.getDate() + 1);
|
|
148
|
+
let e = s(c);
|
|
149
|
+
if (e.month !== i || e.year !== a) {
|
|
150
|
+
c.setDate(c.getDate() - 1);
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
let l = new Date(o);
|
|
155
|
+
for (; l <= c;) {
|
|
156
|
+
let e = f(new Date(l));
|
|
157
|
+
n.push({
|
|
158
|
+
...e,
|
|
159
|
+
otherMonth: !1
|
|
160
|
+
}), l.setDate(l.getDate() + 1);
|
|
161
|
+
}
|
|
162
|
+
} else if (t === "weekly") {
|
|
163
|
+
let t = o(r.value.calendar === "gregory" ? "monday" : "saturday"), i = new Date(e.start), a = i.getDay() - t;
|
|
164
|
+
a < 0 && (a += 7), i.setDate(i.getDate() - a);
|
|
165
|
+
for (let e = 0; e < 7; e++) {
|
|
166
|
+
let t = new Date(i);
|
|
167
|
+
t.setDate(i.getDate() + e), n.push({
|
|
168
|
+
...f(t),
|
|
169
|
+
otherMonth: !1
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
} else if (t === "3days") for (let t = 0; t < 3; t++) {
|
|
173
|
+
let r = new Date(e.start);
|
|
174
|
+
r.setDate(r.getDate() + t), n.push({
|
|
175
|
+
...f(r),
|
|
176
|
+
otherMonth: !1
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
else n.push({
|
|
180
|
+
...f(new Date(e.start)),
|
|
181
|
+
otherMonth: !1
|
|
182
|
+
});
|
|
183
|
+
return n;
|
|
184
|
+
}, m = n(() => {
|
|
185
|
+
let e = P(r.value.locale), t = a.value, n = c.value, i = new Date(2025, 0, 12 + n), o = new Intl.DateTimeFormat(`${e}-u-ca-${t}`, { weekday: "narrow" }), s = new Intl.DateTimeFormat(`${e}-u-ca-${t}`, { weekday: "long" });
|
|
186
|
+
return Array.from({ length: 7 }, (e, t) => {
|
|
187
|
+
let n = new Date(i);
|
|
188
|
+
return n.setDate(i.getDate() + t), {
|
|
189
|
+
dayOfWeek: n.getDay(),
|
|
190
|
+
label: o.format(n),
|
|
191
|
+
fullName: s.format(n)
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
}), h = (e) => {
|
|
195
|
+
let t = P(r.value.locale), n = a.value;
|
|
196
|
+
return {
|
|
197
|
+
sunday: 0,
|
|
198
|
+
monday: 1,
|
|
199
|
+
tuesday: 2,
|
|
200
|
+
wednesday: 3,
|
|
201
|
+
thursday: 4,
|
|
202
|
+
friday: 5,
|
|
203
|
+
saturday: 6
|
|
204
|
+
}[new Intl.DateTimeFormat(`${t}-u-ca-${n}`, { weekday: "long" }).format(e).toLowerCase()] ?? 0;
|
|
205
|
+
}, g = () => {
|
|
206
|
+
let e = /* @__PURE__ */ new Date(), t = s(e), n = new Date(e);
|
|
207
|
+
for (n.setHours(0, 0, 0, 0); s(n).day !== t.day || s(n).month !== t.month || s(n).year !== t.year;) n.setDate(n.getDate() - 1);
|
|
208
|
+
return n;
|
|
209
|
+
}, _ = (e) => {
|
|
210
|
+
let t = new Date(e);
|
|
211
|
+
t.setHours(12, 0, 0, 0);
|
|
212
|
+
let n = s(t), r = n.month, i = n.year;
|
|
213
|
+
for (; n.day !== 1;) t.setDate(t.getDate() - 1), n = s(t);
|
|
214
|
+
let a = new Date(t);
|
|
215
|
+
for (;;) {
|
|
216
|
+
a.setDate(a.getDate() + 1);
|
|
217
|
+
let e = s(a);
|
|
218
|
+
if (e.month !== r || e.year !== i) {
|
|
219
|
+
a.setDate(a.getDate() - 1);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return a.setHours(23, 59, 59, 999), {
|
|
224
|
+
start: t,
|
|
225
|
+
end: a
|
|
226
|
+
};
|
|
227
|
+
}, v = (e) => {
|
|
228
|
+
let t = new Date(e);
|
|
229
|
+
return t.setHours(0, 0, 0, 0), t.setMilliseconds(0), t;
|
|
230
|
+
}, y = () => r.value.calendar === "gregory" ? 1 : 6, b = (e) => {
|
|
231
|
+
let t = g();
|
|
232
|
+
if (e === "daily" || e === "3days") return v(t);
|
|
233
|
+
if (e === "weekly") {
|
|
234
|
+
let e = y(), n = t.getDay() - e;
|
|
235
|
+
n < 0 && (n += 7);
|
|
236
|
+
let r = new Date(t);
|
|
237
|
+
return r.setDate(r.getDate() - n), v(r);
|
|
238
|
+
}
|
|
239
|
+
s(t);
|
|
240
|
+
let n = v(t);
|
|
241
|
+
for (n.setHours(12, 0, 0, 0); s(n).day !== 1;) n.setDate(n.getDate() - 1);
|
|
242
|
+
return v(n);
|
|
243
|
+
}, S = (e, t) => {
|
|
244
|
+
let n = P(e), r = t === "jalaali" ? "persian" : t === "islamic" ? "islamic-civil" : "gregory", i = s(/* @__PURE__ */ new Date()).year, a = w(1, i), o = [];
|
|
245
|
+
for (let e = 1; e <= 12; e++) {
|
|
246
|
+
let t = w(e, i, a);
|
|
247
|
+
a = new Date(t);
|
|
248
|
+
let s = new Intl.DateTimeFormat(`${n}-u-ca-${r}`, { month: "long" }).format(t);
|
|
249
|
+
o.push({
|
|
250
|
+
value: e,
|
|
251
|
+
label: s,
|
|
252
|
+
shortLabel: s
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return o;
|
|
256
|
+
}, C = (e = /* @__PURE__ */ new Date()) => {
|
|
257
|
+
let t = s(e);
|
|
258
|
+
return {
|
|
259
|
+
month: t.month,
|
|
260
|
+
year: t.year
|
|
261
|
+
};
|
|
262
|
+
}, w = (e, t, n) => {
|
|
263
|
+
let r = n ? new Date(n) : /* @__PURE__ */ new Date();
|
|
264
|
+
r.setHours(12, 0, 0, 0);
|
|
265
|
+
let i = s(r), a = 1e3, o = 0;
|
|
266
|
+
for (; (i.year !== t || i.month !== e) && o < a;) i.year < t || i.year === t && i.month < e ? r.setDate(r.getDate() + 1) : r.setDate(r.getDate() - 1), i = s(r), o++;
|
|
267
|
+
for (; i.day !== 1 && o < a;) r.setDate(r.getDate() - 1), i = s(r), o++;
|
|
268
|
+
return r.setHours(0, 0, 0, 0), r;
|
|
269
|
+
};
|
|
270
|
+
return {
|
|
271
|
+
getCalendarHeaders: p,
|
|
272
|
+
getDayDetails: f,
|
|
273
|
+
offsetPeriod: (e, t, n) => {
|
|
274
|
+
let r = new Date(e);
|
|
275
|
+
if (t === "daily") r.setDate(r.getDate() + n);
|
|
276
|
+
else if (t === "3days") r.setDate(r.getDate() + n * 3);
|
|
277
|
+
else if (t === "weekly") r.setDate(r.getDate() + n * 7);
|
|
278
|
+
else {
|
|
279
|
+
let e = s(r), t = e.month + n, i = e.year;
|
|
280
|
+
return t < 1 && (t += 12, i--), t > 12 && (t -= 12, i++), v(w(t, i));
|
|
281
|
+
}
|
|
282
|
+
return v(r);
|
|
283
|
+
},
|
|
284
|
+
getMonthBounds: _,
|
|
285
|
+
getWeekDayNames: m,
|
|
286
|
+
getParts: s,
|
|
287
|
+
resetToToday: b,
|
|
288
|
+
getTodayInActiveCalendar: g,
|
|
289
|
+
getCurrentPeriodStart: (e) => b(e),
|
|
290
|
+
getCurrentMonthYear: C,
|
|
291
|
+
getDayOfWeekIndex: h,
|
|
292
|
+
getMonthNames: S,
|
|
293
|
+
getFirstDayOfMonthInActiveCalendar: w
|
|
294
|
+
};
|
|
295
|
+
}, ee = l({
|
|
296
|
+
name: "CalendarDayBadge",
|
|
297
|
+
props: { day: {
|
|
298
|
+
type: Object,
|
|
299
|
+
required: !0
|
|
300
|
+
} },
|
|
301
|
+
setup(e) {
|
|
302
|
+
return {
|
|
303
|
+
getDayItemColor: n(() => {
|
|
304
|
+
let t = e.day, n = "border-outline-variant bg-surface", r = "text-on-surface/50";
|
|
305
|
+
return t.isToday && (n = "bg-today border-outline-variant/0", r = "text-surface"), (t.isWeekend || t.isHoliday) && (r = "text-error"), {
|
|
306
|
+
fill: n,
|
|
307
|
+
text: r
|
|
308
|
+
};
|
|
309
|
+
}),
|
|
310
|
+
getFont: (e, t) => {
|
|
311
|
+
if (String(t.gregorian) === t[e]) return "font-latin";
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
}), L = (e, t) => {
|
|
316
|
+
let n = e.__vccOpts || e;
|
|
317
|
+
for (let [e, r] of t) n[e] = r;
|
|
318
|
+
return n;
|
|
319
|
+
}, te = { class: "flex flex-col items-center" };
|
|
320
|
+
function ne(e, t, n, r, i, s) {
|
|
321
|
+
return y(), a("div", te, [o("div", { class: m(["w-7 h-7 sm:w-8 sm:h-8 md:w-9 md:h-9 select-none border flex flex-col justify-center items-center rounded-full", [e.getDayItemColor.fill, e.getDayItemColor.text]]) }, [
|
|
322
|
+
o("div", { class: m([[e.getFont("tertiary", e.day)], "leading-none opacity-70 text-[6px] sm:text-[7px] md:text-[8px]"]) }, T(e.day.tertiary), 3),
|
|
323
|
+
o("div", { class: m([[e.getFont("primary", e.day)], "leading-tight text-[11px] sm:text-xs md:text-label-md font-medium"]) }, T(e.day.primary), 3),
|
|
324
|
+
o("div", { class: m([[e.getFont("secondary", e.day)], "leading-none opacity-70 text-[6px] sm:text-[7px] md:text-[8px]"]) }, T(e.day.secondary), 3)
|
|
325
|
+
], 2)]);
|
|
326
|
+
}
|
|
327
|
+
var R = /* @__PURE__ */ L(ee, [["render", ne]]), re = l({
|
|
328
|
+
name: "CalendarHeaderItem",
|
|
329
|
+
components: { CalendarDayBadge: R },
|
|
330
|
+
props: {
|
|
331
|
+
days: {
|
|
332
|
+
type: Array,
|
|
333
|
+
default: () => []
|
|
334
|
+
},
|
|
335
|
+
mode: {
|
|
336
|
+
type: String,
|
|
337
|
+
default: "monthly"
|
|
338
|
+
},
|
|
339
|
+
todayColumnIndex: {
|
|
340
|
+
type: Number,
|
|
341
|
+
default: -1
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
setup(e) {
|
|
345
|
+
return { itemWidths: n(() => `${100 / (e.days.length + (e.mode === "monthly" ? 0 : 1))}%`) };
|
|
346
|
+
}
|
|
347
|
+
}), ie = { class: "w-full items-stretch flex justify-between" }, ae = {
|
|
348
|
+
key: 0,
|
|
349
|
+
class: "border shrink-0 w-8 sm:w-9 md:w-25 min-w-8 sm:min-w-9 md:min-w-25 max-w-8 sm:max-w-9 md:max-w-25 border-outline-variant"
|
|
350
|
+
}, oe = { class: "select-none text-on-surface/50 text-[9px] sm:text-[10px] md:text-label-md truncate max-w-full text-center px-0.5" }, se = { class: "sm:hidden" }, z = { class: "hidden sm:inline" };
|
|
351
|
+
function B(t, n, s, c, l, u) {
|
|
352
|
+
let d = w("CalendarDayBadge");
|
|
353
|
+
return y(), a("div", ie, [t.mode === "monthly" ? i("", !0) : (y(), a("div", ae)), (y(!0), a(e, null, S(t.days, (e, n) => (y(), a("div", {
|
|
354
|
+
class: m(["border-y rtl:border-l ltr:border-r border-outline-variant py-1.5 sm:py-2 md:py-4 flex-col flex-1 min-w-0 gap-y-1 sm:gap-y-1.5 md:gap-y-2.5 flex items-center justify-center transition-colors", { "bg-today-column": n === t.todayColumnIndex }]),
|
|
355
|
+
key: e.name + n
|
|
356
|
+
}, [t.mode === "monthly" ? i("", !0) : (y(), r(d, {
|
|
357
|
+
key: 0,
|
|
358
|
+
day: e
|
|
359
|
+
}, null, 8, ["day"])), o("div", oe, [o("span", se, T(e.shortName || e.name), 1), o("span", z, T(e.name), 1)])], 2))), 128))]);
|
|
360
|
+
}
|
|
361
|
+
var V = /* @__PURE__ */ L(re, [["render", B], ["__scopeId", "data-v-683574e2"]]), H = l({
|
|
362
|
+
name: "CalendarSideItem",
|
|
363
|
+
props: { range: {
|
|
364
|
+
type: Object,
|
|
365
|
+
required: !0
|
|
366
|
+
} },
|
|
367
|
+
setup(e) {
|
|
368
|
+
let { t, config: r } = F(), { width: i } = N(), a = n(() => i.value < 768), o = n(() => new Intl.NumberFormat(r.value.locale.startsWith("fa") ? "fa-IR" : "en-US")), s = n(() => `${100 / c.value.length}%`), c = n(() => {
|
|
369
|
+
let n = [], { start: r, end: i } = e.range;
|
|
370
|
+
for (let e = r; e < i; e++) if (a.value) n.push({
|
|
371
|
+
raw: e,
|
|
372
|
+
label: o.value.format(e)
|
|
373
|
+
});
|
|
374
|
+
else {
|
|
375
|
+
let r = "";
|
|
376
|
+
r = e >= 1 && e <= 11 ? "morning" : e === 12 ? "noon" : e >= 13 && e < 19 ? "afternoon" : "night";
|
|
377
|
+
let i = e;
|
|
378
|
+
e > 12 && (i = e - 12), e === 0 && (i = 12), n.push({
|
|
379
|
+
raw: e,
|
|
380
|
+
label: `${o.value.format(i)} ${t(`calendar.dayTimes.${r}`)}`
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
return n;
|
|
384
|
+
});
|
|
385
|
+
return {
|
|
386
|
+
hoursList: c,
|
|
387
|
+
itemHeights: s
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
}), U = { class: "w-8 sm:w-9 md:w-25 min-h-full flex flex-col ltr:border-r ltr:border-r-outline-variant rtl:border-l border-l-outline-variant" };
|
|
391
|
+
function W(t, n, r, i, o, s) {
|
|
392
|
+
return y(), a("div", U, [(y(!0), a(e, null, S(t.hoursList, (e) => (y(), a("div", {
|
|
393
|
+
key: e.raw,
|
|
394
|
+
style: g({ height: t.itemHeights }),
|
|
395
|
+
class: "flex items-center text-center justify-center text-[10px] sm:text-xs md:text-label-md text-on-surface/50 border-b min-h-20 border-b-outline-variant select-none"
|
|
396
|
+
}, T(e.label), 5))), 128))]);
|
|
397
|
+
}
|
|
398
|
+
var G = /* @__PURE__ */ L(H, [["render", W]]), K = l({
|
|
399
|
+
name: "CalendarPattern",
|
|
400
|
+
setup() {
|
|
401
|
+
return { getX: (e) => -50 + (e - 1) * 25 };
|
|
402
|
+
}
|
|
403
|
+
}), ce = {
|
|
404
|
+
width: "100%",
|
|
405
|
+
height: "120%",
|
|
406
|
+
viewBox: "0 0 440 221",
|
|
407
|
+
preserveAspectRatio: "xMidYMid slice",
|
|
408
|
+
class: "text-surface-variant",
|
|
409
|
+
fill: "none",
|
|
410
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
411
|
+
}, le = ["x", "transform"];
|
|
412
|
+
function ue(t, n, r, i, s, c) {
|
|
413
|
+
return y(), a("svg", ce, [(y(), a(e, null, S(25, (e) => o("rect", {
|
|
414
|
+
key: e,
|
|
415
|
+
x: t.getX(e),
|
|
416
|
+
y: "220.895",
|
|
417
|
+
width: "300",
|
|
418
|
+
height: "12",
|
|
419
|
+
transform: `rotate(-115 ${t.getX(e)} 220.895)`,
|
|
420
|
+
fill: "currentColor"
|
|
421
|
+
}, null, 8, le)), 64))]);
|
|
422
|
+
}
|
|
423
|
+
var de = /* @__PURE__ */ L(K, [["render", ue]]), q = {
|
|
424
|
+
"--cal-primary": {
|
|
425
|
+
light: {
|
|
426
|
+
r: 26,
|
|
427
|
+
g: 157,
|
|
428
|
+
b: 144
|
|
429
|
+
},
|
|
430
|
+
dark: {
|
|
431
|
+
r: 64,
|
|
432
|
+
g: 184,
|
|
433
|
+
b: 172
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
"--color-primary": {
|
|
437
|
+
light: {
|
|
438
|
+
r: 26,
|
|
439
|
+
g: 157,
|
|
440
|
+
b: 144
|
|
441
|
+
},
|
|
442
|
+
dark: {
|
|
443
|
+
r: 64,
|
|
444
|
+
g: 184,
|
|
445
|
+
b: 172
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
"--cal-surface": {
|
|
449
|
+
light: {
|
|
450
|
+
r: 255,
|
|
451
|
+
g: 255,
|
|
452
|
+
b: 255
|
|
453
|
+
},
|
|
454
|
+
dark: {
|
|
455
|
+
r: 21,
|
|
456
|
+
g: 24,
|
|
457
|
+
b: 35
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
"--color-surface": {
|
|
461
|
+
light: {
|
|
462
|
+
r: 255,
|
|
463
|
+
g: 255,
|
|
464
|
+
b: 255
|
|
465
|
+
},
|
|
466
|
+
dark: {
|
|
467
|
+
r: 21,
|
|
468
|
+
g: 24,
|
|
469
|
+
b: 35
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
"--cal-on-surface": {
|
|
473
|
+
light: {
|
|
474
|
+
r: 44,
|
|
475
|
+
g: 44,
|
|
476
|
+
b: 46
|
|
477
|
+
},
|
|
478
|
+
dark: {
|
|
479
|
+
r: 255,
|
|
480
|
+
g: 255,
|
|
481
|
+
b: 255
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
"--color-on-surface": {
|
|
485
|
+
light: {
|
|
486
|
+
r: 44,
|
|
487
|
+
g: 44,
|
|
488
|
+
b: 46
|
|
489
|
+
},
|
|
490
|
+
dark: {
|
|
491
|
+
r: 255,
|
|
492
|
+
g: 255,
|
|
493
|
+
b: 255
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
"--cal-error": {
|
|
497
|
+
light: {
|
|
498
|
+
r: 229,
|
|
499
|
+
g: 43,
|
|
500
|
+
b: 22
|
|
501
|
+
},
|
|
502
|
+
dark: {
|
|
503
|
+
r: 234,
|
|
504
|
+
g: 85,
|
|
505
|
+
b: 69
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
"--color-error": {
|
|
509
|
+
light: {
|
|
510
|
+
r: 229,
|
|
511
|
+
g: 43,
|
|
512
|
+
b: 22
|
|
513
|
+
},
|
|
514
|
+
dark: {
|
|
515
|
+
r: 234,
|
|
516
|
+
g: 85,
|
|
517
|
+
b: 69
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
function J(e) {
|
|
522
|
+
if (!e || typeof e != "string") return null;
|
|
523
|
+
let t = e.trim().toLowerCase();
|
|
524
|
+
if (t.startsWith("var(")) {
|
|
525
|
+
let e = t.match(/var\(\s*([^,\s)]+)/), n = e ? e[1] : "";
|
|
526
|
+
if (typeof document < "u" && n) try {
|
|
527
|
+
let e = getComputedStyle(document.documentElement).getPropertyValue(n).trim();
|
|
528
|
+
if (e) {
|
|
529
|
+
let t = J(e);
|
|
530
|
+
if (t) return t;
|
|
531
|
+
}
|
|
532
|
+
} catch {}
|
|
533
|
+
let r = t.match(/var\([^,]+,\s*([^)]+)\)/);
|
|
534
|
+
if (r && r[1]) {
|
|
535
|
+
let e = J(r[1].trim());
|
|
536
|
+
if (e) return e;
|
|
537
|
+
}
|
|
538
|
+
return n && q[n] ? typeof document < "u" && document.documentElement.classList.contains("dark") ? q[n].dark : q[n].light : {
|
|
539
|
+
r: 26,
|
|
540
|
+
g: 157,
|
|
541
|
+
b: 144
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
if (t.startsWith("#")) {
|
|
545
|
+
let e = t.slice(1);
|
|
546
|
+
if (e.length === 3 || e.length === 4) {
|
|
547
|
+
let t = e[0] || "0", n = e[1] || "0", r = e[2] || "0", i = parseInt(t + t, 16), a = parseInt(n + n, 16), o = parseInt(r + r, 16);
|
|
548
|
+
if (!Number.isNaN(i) && !Number.isNaN(a) && !Number.isNaN(o)) return {
|
|
549
|
+
r: i,
|
|
550
|
+
g: a,
|
|
551
|
+
b: o
|
|
552
|
+
};
|
|
553
|
+
} else if (e.length === 6 || e.length === 8) {
|
|
554
|
+
let t = parseInt(e.slice(0, 2), 16), n = parseInt(e.slice(2, 4), 16), r = parseInt(e.slice(4, 6), 16);
|
|
555
|
+
if (!Number.isNaN(t) && !Number.isNaN(n) && !Number.isNaN(r)) return {
|
|
556
|
+
r: t,
|
|
557
|
+
g: n,
|
|
558
|
+
b: r
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
return null;
|
|
562
|
+
}
|
|
563
|
+
if (t.startsWith("rgb")) {
|
|
564
|
+
let e = t.match(/\(([^)]+)\)/);
|
|
565
|
+
if (e && e[1]) {
|
|
566
|
+
let t = e[1].split(/[\s,/]+/).filter(Boolean), n = t[0], r = t[1], i = t[2];
|
|
567
|
+
if (n !== void 0 && r !== void 0 && i !== void 0) {
|
|
568
|
+
let e = n.endsWith("%") ? parseFloat(n) / 100 * 255 : parseFloat(n), t = r.endsWith("%") ? parseFloat(r) / 100 * 255 : parseFloat(r), a = i.endsWith("%") ? parseFloat(i) / 100 * 255 : parseFloat(i);
|
|
569
|
+
if (!Number.isNaN(e) && !Number.isNaN(t) && !Number.isNaN(a)) return {
|
|
570
|
+
r: Math.min(255, Math.max(0, Math.round(e))),
|
|
571
|
+
g: Math.min(255, Math.max(0, Math.round(t))),
|
|
572
|
+
b: Math.min(255, Math.max(0, Math.round(a)))
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
if (t.startsWith("hsl")) {
|
|
579
|
+
let e = t.match(/\(([^)]+)\)/);
|
|
580
|
+
if (e && e[1]) {
|
|
581
|
+
let t = e[1].split(/[\s,/]+/).filter(Boolean), n = t[0], r = t[1], i = t[2];
|
|
582
|
+
if (n !== void 0 && r !== void 0 && i !== void 0) {
|
|
583
|
+
let e = parseFloat(n), t = parseFloat(r) / 100, a = parseFloat(i) / 100;
|
|
584
|
+
if (!Number.isNaN(e) && !Number.isNaN(t) && !Number.isNaN(a)) return fe(e, t, a);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return null;
|
|
588
|
+
}
|
|
589
|
+
let n = {
|
|
590
|
+
white: {
|
|
591
|
+
r: 255,
|
|
592
|
+
g: 255,
|
|
593
|
+
b: 255
|
|
594
|
+
},
|
|
595
|
+
black: {
|
|
596
|
+
r: 0,
|
|
597
|
+
g: 0,
|
|
598
|
+
b: 0
|
|
599
|
+
},
|
|
600
|
+
transparent: {
|
|
601
|
+
r: 255,
|
|
602
|
+
g: 255,
|
|
603
|
+
b: 255
|
|
604
|
+
},
|
|
605
|
+
red: {
|
|
606
|
+
r: 255,
|
|
607
|
+
g: 0,
|
|
608
|
+
b: 0
|
|
609
|
+
},
|
|
610
|
+
green: {
|
|
611
|
+
r: 0,
|
|
612
|
+
g: 128,
|
|
613
|
+
b: 0
|
|
614
|
+
},
|
|
615
|
+
blue: {
|
|
616
|
+
r: 0,
|
|
617
|
+
g: 0,
|
|
618
|
+
b: 255
|
|
619
|
+
},
|
|
620
|
+
yellow: {
|
|
621
|
+
r: 255,
|
|
622
|
+
g: 255,
|
|
623
|
+
b: 0
|
|
624
|
+
},
|
|
625
|
+
orange: {
|
|
626
|
+
r: 255,
|
|
627
|
+
g: 165,
|
|
628
|
+
b: 0
|
|
629
|
+
},
|
|
630
|
+
purple: {
|
|
631
|
+
r: 128,
|
|
632
|
+
g: 0,
|
|
633
|
+
b: 128
|
|
634
|
+
},
|
|
635
|
+
teal: {
|
|
636
|
+
r: 0,
|
|
637
|
+
g: 128,
|
|
638
|
+
b: 128
|
|
639
|
+
},
|
|
640
|
+
gray: {
|
|
641
|
+
r: 128,
|
|
642
|
+
g: 128,
|
|
643
|
+
b: 128
|
|
644
|
+
},
|
|
645
|
+
grey: {
|
|
646
|
+
r: 128,
|
|
647
|
+
g: 128,
|
|
648
|
+
b: 128
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
return n[t] ? n[t] : null;
|
|
652
|
+
}
|
|
653
|
+
function fe(e, t, n) {
|
|
654
|
+
let r = (e % 360 + 360) % 360, i = (1 - Math.abs(2 * n - 1)) * t, a = i * (1 - Math.abs(r / 60 % 2 - 1)), o = n - i / 2, s = 0, c = 0, l = 0;
|
|
655
|
+
return r >= 0 && r < 60 ? (s = i, c = a) : r >= 60 && r < 120 ? (s = a, c = i) : r >= 120 && r < 180 ? (c = i, l = a) : r >= 180 && r < 240 ? (c = a, l = i) : r >= 240 && r < 300 ? (s = a, l = i) : (s = i, l = a), {
|
|
656
|
+
r: Math.round((s + o) * 255),
|
|
657
|
+
g: Math.round((c + o) * 255),
|
|
658
|
+
b: Math.round((l + o) * 255)
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
function Y(e, t, n) {
|
|
662
|
+
let r = (e) => {
|
|
663
|
+
let t = Math.max(0, Math.min(255, e)) / 255;
|
|
664
|
+
return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
665
|
+
}, i = r(e), a = r(t), o = r(n);
|
|
666
|
+
return .2126 * i + .7152 * a + .0722 * o;
|
|
667
|
+
}
|
|
668
|
+
function pe(e, t) {
|
|
669
|
+
let n = typeof e == "string" ? J(e) ?? {
|
|
670
|
+
r: 0,
|
|
671
|
+
g: 0,
|
|
672
|
+
b: 0
|
|
673
|
+
} : e, r = typeof t == "string" ? J(t) ?? {
|
|
674
|
+
r: 255,
|
|
675
|
+
g: 255,
|
|
676
|
+
b: 255
|
|
677
|
+
} : t, i = Y(n.r, n.g, n.b), a = Y(r.r, r.g, r.b), o = Math.max(i, a), s = Math.min(i, a);
|
|
678
|
+
return (o + .05) / (s + .05);
|
|
679
|
+
}
|
|
680
|
+
function X(e, t) {
|
|
681
|
+
let n = t?.darkColor ?? "#0f172a", r = t?.lightColor ?? "#ffffff";
|
|
682
|
+
if (!e) return r;
|
|
683
|
+
let i = J(e) ?? {
|
|
684
|
+
r: 26,
|
|
685
|
+
g: 157,
|
|
686
|
+
b: 144
|
|
687
|
+
}, a = J(n) ?? {
|
|
688
|
+
r: 15,
|
|
689
|
+
g: 23,
|
|
690
|
+
b: 42
|
|
691
|
+
}, o = J(r) ?? {
|
|
692
|
+
r: 255,
|
|
693
|
+
g: 255,
|
|
694
|
+
b: 255
|
|
695
|
+
}, s = Y(i.r, i.g, i.b), c = Y(a.r, a.g, a.b), l = Y(o.r, o.g, o.b), u = (Math.max(s, c) + .05) / (Math.min(s, c) + .05);
|
|
696
|
+
return (Math.max(s, l) + .05) / (Math.min(s, l) + .05) >= u ? r : n;
|
|
697
|
+
}
|
|
698
|
+
//#endregion
|
|
699
|
+
//#region src/components/CalendarItemDisplay.vue
|
|
700
|
+
var Z = /* @__PURE__ */ l({
|
|
701
|
+
__name: "CalendarItemDisplay",
|
|
702
|
+
props: {
|
|
703
|
+
event: {},
|
|
704
|
+
mode: {},
|
|
705
|
+
headers: {},
|
|
706
|
+
hours: {},
|
|
707
|
+
position: {},
|
|
708
|
+
isMobile: { type: Boolean },
|
|
709
|
+
overlapIndex: {},
|
|
710
|
+
overlapCount: {}
|
|
711
|
+
},
|
|
712
|
+
emits: ["event-click"],
|
|
713
|
+
setup(e) {
|
|
714
|
+
let t = e, r = n(() => t.event.color || "var(--cal-primary)"), i = n(() => X(r.value)), s = n(() => {
|
|
715
|
+
if (t.mode === "monthly") return {
|
|
716
|
+
zIndex: 10,
|
|
717
|
+
position: "relative"
|
|
718
|
+
};
|
|
719
|
+
if (t.position === "static") return {
|
|
720
|
+
width: "100%",
|
|
721
|
+
height: "36px",
|
|
722
|
+
position: "relative"
|
|
723
|
+
};
|
|
724
|
+
if (!t.headers?.length || !t.hours) return { display: "none" };
|
|
725
|
+
let e = new Date(t.event.date).toLocaleDateString("en-CA"), n = t.headers.findIndex((t) => new Date(t.date).toLocaleDateString("en-CA") === e);
|
|
726
|
+
if (n === -1 || t.hours.end - t.hours.start <= 0) return { display: "none" };
|
|
727
|
+
let r = t.event.time.split(":").map(Number), i = (r[0] ?? 0) + (r[1] ?? 0) / 60, a = (i - t.hours.start) * 80, o = 100 / t.headers.length, s = t.overlapCount ?? 1, c = t.overlapIndex ?? 0, l = o / s, u, d;
|
|
728
|
+
if (t.event.duration && t.event.duration > 0) {
|
|
729
|
+
let e = Math.min(i + t.event.duration / 60, t.hours.end);
|
|
730
|
+
u = `${Math.max(0, e - i) * 80}px`, d = "20px";
|
|
731
|
+
} else u = t.isMobile && t.mode === "weekly" ? "16px" : "36px";
|
|
732
|
+
return {
|
|
733
|
+
top: `${a}px`,
|
|
734
|
+
insetInlineStart: `${n * o + c * l}%`,
|
|
735
|
+
width: `${l}%`,
|
|
736
|
+
height: u,
|
|
737
|
+
minHeight: d,
|
|
738
|
+
zIndex: 10,
|
|
739
|
+
boxSizing: "border-box"
|
|
740
|
+
};
|
|
741
|
+
}), c = n(() => ({
|
|
742
|
+
backgroundColor: r.value,
|
|
743
|
+
color: i.value
|
|
744
|
+
})), l = n(() => {
|
|
745
|
+
let e = r.value, n = i.value;
|
|
746
|
+
return t.mode === "monthly" ? {
|
|
747
|
+
backgroundColor: e,
|
|
748
|
+
color: n,
|
|
749
|
+
opacity: .9,
|
|
750
|
+
borderLeft: `4px solid ${e}`
|
|
751
|
+
} : {
|
|
752
|
+
backgroundColor: e,
|
|
753
|
+
color: n
|
|
754
|
+
};
|
|
755
|
+
});
|
|
756
|
+
return (t, n) => (y(), a("div", {
|
|
757
|
+
id: "event-display",
|
|
758
|
+
style: g(s.value),
|
|
759
|
+
class: m([e.position === "static" ? "" : "absolute", e.mode === "monthly" ? "" : e.isMobile && e.mode === "weekly" ? "px-0.5" : "px-1 sm:px-2"]),
|
|
760
|
+
onClick: n[0] ||= M((n) => t.$emit("event-click", e.event, n), ["stop"])
|
|
761
|
+
}, [o("div", {
|
|
762
|
+
class: m(["flex whitespace-normal items-center rounded cursor-pointer transition-transform text-[10px] sm:text-[11px] leading-tight overflow-hidden", e.mode === "monthly" ? "px-2 relative mb-1 h-6 shrink-0 whitespace-nowrap text-ellipsis w-[calc(100%-16px)]" : e.isMobile && e.mode === "weekly" ? "absolute px-1 h-full w-[calc(100%-4px)] text-[9px] leading-none" : "absolute px-2 sm:px-4 h-full w-[calc(100%-8px)] sm:w-[calc(100%-16px)] sm:rounded-md"]),
|
|
763
|
+
style: g(l.value)
|
|
764
|
+
}, [C(t.$slots, "event", {
|
|
765
|
+
event: e.event,
|
|
766
|
+
mode: e.mode
|
|
767
|
+
}, () => [o("div", {
|
|
768
|
+
style: g(c.value),
|
|
769
|
+
class: "w-full h-full relative z-10 flex items-center gap-x-1 truncate font-medium"
|
|
770
|
+
}, T(e.event.title), 5)])], 6)], 6));
|
|
771
|
+
}
|
|
772
|
+
}), me = l({
|
|
773
|
+
name: "CalendarDayHolder",
|
|
774
|
+
props: {
|
|
775
|
+
day: {
|
|
776
|
+
type: Object,
|
|
777
|
+
required: !0
|
|
778
|
+
},
|
|
779
|
+
otherMonth: {
|
|
780
|
+
type: Boolean,
|
|
781
|
+
default: !1
|
|
782
|
+
},
|
|
783
|
+
events: {
|
|
784
|
+
type: Array,
|
|
785
|
+
default: () => []
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
components: {
|
|
789
|
+
CalendarDayBadge: R,
|
|
790
|
+
CalendarPattern: de,
|
|
791
|
+
CalendarItemDisplay: Z
|
|
792
|
+
},
|
|
793
|
+
emits: ["open-day", "event-click"],
|
|
794
|
+
setup(e, { emit: t }) {
|
|
795
|
+
let { t: r } = F();
|
|
796
|
+
return {
|
|
797
|
+
t: r,
|
|
798
|
+
displayedEvents: n(() => e.events.slice(0, 2)),
|
|
799
|
+
openDay: () => {
|
|
800
|
+
t("open-day", e.day);
|
|
801
|
+
},
|
|
802
|
+
remainingCount: n(() => e.events.length - 2)
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
}), he = { class: "relative top-0 left-0 w-full h-full p-4 flex flex-col" }, ge = {
|
|
806
|
+
key: 0,
|
|
807
|
+
class: "shrink-0"
|
|
808
|
+
}, _e = {
|
|
809
|
+
id: "holder",
|
|
810
|
+
class: "w-full flex-1 relative flex flex-col gap-y-1.5 mt-2"
|
|
811
|
+
}, ve = { class: "w-full h-full pointer-events-none absolute top-0 left-0" };
|
|
812
|
+
function ye(t, n, s, l, u, d) {
|
|
813
|
+
let p = w("CalendarDayBadge"), h = w("CalendarItemDisplay"), g = w("CalendarPattern");
|
|
814
|
+
return y(), a("div", { class: m(["border border-outline-variant/50 w-full relative h-full transition-colors", [t.otherMonth ? "overflow-hidden" : "overflow-visible", t.day.isToday && !t.otherMonth ? "bg-today-column" : ""]]) }, [o("div", he, [t.otherMonth ? i("", !0) : (y(), a("div", ge, [c(p, { day: t.day }, null, 8, ["day"])])), o("div", _e, [(y(!0), a(e, null, S(t.displayedEvents, (e) => (y(), r(h, {
|
|
815
|
+
key: e.id,
|
|
816
|
+
position: "static",
|
|
817
|
+
event: e,
|
|
818
|
+
onEventClick: n[0] ||= (e) => t.$emit("event-click", e)
|
|
819
|
+
}, {
|
|
820
|
+
event: A((e) => [C(t.$slots, "event", f({ ref_for: !0 }, e))]),
|
|
821
|
+
_: 3
|
|
822
|
+
}, 8, ["event"]))), 128)), t.remainingCount > 0 ? (y(), a("div", {
|
|
823
|
+
key: 0,
|
|
824
|
+
onClick: n[1] ||= (...e) => t.openDay && t.openDay(...e),
|
|
825
|
+
class: "w-full relative z-0 h-9 px-2 flex cursor-pointer items-center rounded-lg bg-surface-variant text-label-sm text-on-surface select-none"
|
|
826
|
+
}, T(t.t("calendar.moreItems", { count: t.remainingCount })), 1)) : i("", !0)])]), o("div", ve, [t.otherMonth ? (y(), r(g, {
|
|
827
|
+
key: 0,
|
|
828
|
+
class: "absolute inset-0 z-0 pointer-events-none"
|
|
829
|
+
})) : i("", !0)])], 2);
|
|
830
|
+
}
|
|
831
|
+
var be = /* @__PURE__ */ L(me, [["render", ye]]), xe = l({
|
|
832
|
+
name: "CalendarPointer",
|
|
833
|
+
props: {
|
|
834
|
+
mode: {
|
|
835
|
+
type: String,
|
|
836
|
+
required: !0
|
|
837
|
+
},
|
|
838
|
+
hours: {
|
|
839
|
+
type: Object,
|
|
840
|
+
required: !0
|
|
841
|
+
},
|
|
842
|
+
headers: {
|
|
843
|
+
type: Array,
|
|
844
|
+
required: !0
|
|
845
|
+
}
|
|
846
|
+
},
|
|
847
|
+
setup(e) {
|
|
848
|
+
let t = x(/* @__PURE__ */ new Date()), r;
|
|
849
|
+
_(() => {
|
|
850
|
+
r = setInterval(() => {
|
|
851
|
+
t.value = /* @__PURE__ */ new Date();
|
|
852
|
+
}, 6e4);
|
|
853
|
+
}), v(() => {
|
|
854
|
+
r && clearInterval(r);
|
|
855
|
+
});
|
|
856
|
+
let i = n(() => {
|
|
857
|
+
if (!e.headers || e.headers.length === 0) return { display: "none" };
|
|
858
|
+
let n = e.headers.findIndex((e) => e.isToday);
|
|
859
|
+
if (n === -1) return { display: "none" };
|
|
860
|
+
let r = t.value, i = r.getHours() + r.getMinutes() / 60;
|
|
861
|
+
if (e.mode === "monthly") {
|
|
862
|
+
let t = Math.ceil(e.headers.length / 7), r = Math.floor(n / 7), a = n % 7, o = 100 / t, s = i / 24 * o;
|
|
863
|
+
return {
|
|
864
|
+
width: `${100 / 7}%`,
|
|
865
|
+
top: `${r * o + s}%`,
|
|
866
|
+
insetInlineStart: `${a / 7 * 100}%`,
|
|
867
|
+
transition: ""
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
if (i < e.hours.start || i > e.hours.end) return { display: "none" };
|
|
871
|
+
let a = e.headers.length, o = e.hours.end - e.hours.start;
|
|
872
|
+
return {
|
|
873
|
+
width: `${100 / a}%`,
|
|
874
|
+
top: `${(i - e.hours.start) / o * 100}%`,
|
|
875
|
+
insetInlineStart: `${n / a * 100}%`,
|
|
876
|
+
transition: ""
|
|
877
|
+
};
|
|
878
|
+
});
|
|
879
|
+
return {
|
|
880
|
+
pointerStyle: i,
|
|
881
|
+
isVisible: n(() => i.value.display !== "none")
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
//#endregion
|
|
886
|
+
//#region src/components/CalendarPointer.vue
|
|
887
|
+
function Se(e, t, n, r, i, s) {
|
|
888
|
+
return j((y(), a("div", {
|
|
889
|
+
class: "absolute z-20 pointer-events-none -translate-y-1/2 flex items-center",
|
|
890
|
+
style: g(e.pointerStyle)
|
|
891
|
+
}, [...t[0] ||= [o("div", { class: "w-2.5 aspect-square rounded-full bg-error shrink-0" }, null, -1), o("div", { class: "h-0.5 flex-1 bg-error" }, null, -1)]], 4)), [[O, e.isVisible]]);
|
|
892
|
+
}
|
|
893
|
+
var Ce = /* @__PURE__ */ L(xe, [["render", Se]]), we = l({
|
|
894
|
+
name: "MobileDayHolder",
|
|
895
|
+
props: {
|
|
896
|
+
day: {
|
|
897
|
+
type: Object,
|
|
898
|
+
required: !0
|
|
899
|
+
},
|
|
900
|
+
isSelected: {
|
|
901
|
+
type: Boolean,
|
|
902
|
+
default: !1
|
|
903
|
+
},
|
|
904
|
+
events: {
|
|
905
|
+
type: Array,
|
|
906
|
+
default: () => []
|
|
907
|
+
},
|
|
908
|
+
expandProgress: {
|
|
909
|
+
type: Number,
|
|
910
|
+
default: 0
|
|
911
|
+
},
|
|
912
|
+
isDragging: {
|
|
913
|
+
type: Boolean,
|
|
914
|
+
default: !1
|
|
915
|
+
}
|
|
916
|
+
},
|
|
917
|
+
emits: ["select"],
|
|
918
|
+
setup(e, { emit: t }) {
|
|
919
|
+
return {
|
|
920
|
+
canSelect: n(() => e.events.length > 0),
|
|
921
|
+
displayedEvents: n(() => e.events.slice(0, 4)),
|
|
922
|
+
selectDay: () => {
|
|
923
|
+
t("select", e.day);
|
|
924
|
+
},
|
|
925
|
+
styles: n(() => e.isSelected ? {
|
|
926
|
+
border: "border-transparent",
|
|
927
|
+
bg: "opacity-100",
|
|
928
|
+
text: "text-surface"
|
|
929
|
+
} : e.day.isToday ? {
|
|
930
|
+
border: "border-primary",
|
|
931
|
+
bg: "opacity-0",
|
|
932
|
+
text: "text-primary"
|
|
933
|
+
} : {
|
|
934
|
+
border: "border-transparent",
|
|
935
|
+
bg: "opacity-0",
|
|
936
|
+
text: "text-on-surface/50"
|
|
937
|
+
})
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
}), Te = { class: "w-full h-full absolute inset-0 left-0 top-0 flex items-center justify-center" }, Ee = { class: "w-full flex-1 relative flex justify-center" };
|
|
941
|
+
function De(t, n, r, s, c, l) {
|
|
942
|
+
return y(), a("div", {
|
|
943
|
+
onClick: n[0] ||= (...e) => t.selectDay && t.selectDay(...e),
|
|
944
|
+
class: m(["flex flex-col items-center justify-start gap-y-0.5 w-full overflow-hidden hw-accel-height", [t.canSelect ? "cursor-pointer" : "cursor-default", t.isDragging ? "" : "transition-all duration-300 ease-out"]]),
|
|
945
|
+
style: g({ height: `${40 + t.expandProgress * 16}px` })
|
|
946
|
+
}, [o("div", { class: m(["relative w-8 h-8 shrink-0 rounded-full transition-all duration-200 ease-in-out aspect-square border", t.styles.border]) }, [o("div", { class: m(["rounded-full w-full h-full transition-all duration-200 ease-in-out bg-on-surface", t.styles.bg]) }, null, 2), o("div", Te, [o("div", { class: m(["select-none text-label-md transition-all duration-200 ease-in-out", t.styles.text]) }, T(t.day.primary), 3)])], 2), o("div", Ee, [t.canSelect ? (y(), a("div", {
|
|
947
|
+
key: 0,
|
|
948
|
+
class: m(["rounded-full aspect-square w-1.5 bg-error absolute hw-accel", [t.isDragging ? "" : "transition-all duration-300 ease-out"]]),
|
|
949
|
+
style: g({
|
|
950
|
+
opacity: Math.max(0, 1 - t.expandProgress * 2),
|
|
951
|
+
transform: `scale(${Math.max(0, 1 - t.expandProgress * 2)})`
|
|
952
|
+
})
|
|
953
|
+
}, null, 6)) : i("", !0), t.canSelect ? (y(), a("div", {
|
|
954
|
+
key: 1,
|
|
955
|
+
class: m(["w-full flex flex-col gap-y-px absolute top-0 px-0.5 hw-accel", [t.isDragging ? "" : "transition-all duration-300 ease-out"]]),
|
|
956
|
+
style: g({
|
|
957
|
+
opacity: t.expandProgress,
|
|
958
|
+
transform: `translateY(${(1 - t.expandProgress) * 6}px)`
|
|
959
|
+
})
|
|
960
|
+
}, [(y(!0), a(e, null, S(t.displayedEvents, (e) => (y(), a("div", {
|
|
961
|
+
key: e.id,
|
|
962
|
+
class: "w-full rounded-full shrink-0 min-h-1",
|
|
963
|
+
style: g({ backgroundColor: e.color || "var(--cal-primary)" })
|
|
964
|
+
}, null, 4))), 128))], 6)) : i("", !0)])], 6);
|
|
965
|
+
}
|
|
966
|
+
var Oe = /* @__PURE__ */ L(we, [["render", De], ["__scopeId", "data-v-d90e616f"]]), ke = { class: "flex flex-col gap-y-1 p-3 flex-1" }, Ae = { class: "text-label-md font-semibold text-on-surface" }, je = { class: "text-body-sm text-on-surface/60" }, Me = l({
|
|
967
|
+
name: "MobileCalendarGrid",
|
|
968
|
+
components: {
|
|
969
|
+
MobileDayHolder: Oe,
|
|
970
|
+
MobileEventListItem: /* @__PURE__ */ l({
|
|
971
|
+
__name: "MobileEventListItem",
|
|
972
|
+
props: { event: {} },
|
|
973
|
+
emits: ["event-click"],
|
|
974
|
+
setup(e) {
|
|
975
|
+
return (t, n) => (y(), a("div", {
|
|
976
|
+
class: "bg-surface-variant flex flex-col rounded-lg border cursor-pointer",
|
|
977
|
+
onClick: n[0] ||= M((n) => t.$emit("event-click", e.event, n), ["stop"])
|
|
978
|
+
}, [o("div", ke, [C(t.$slots, "event", { event: e.event }, () => [o("div", Ae, T(e.event.title), 1), o("div", je, T(e.event.time), 1)])]), o("div", {
|
|
979
|
+
class: "w-full h-1 shrink-0 rounded-b-full rounded-t-none",
|
|
980
|
+
style: g({ backgroundColor: e.event.color || "#3b82f6" })
|
|
981
|
+
}, null, 4)]));
|
|
982
|
+
}
|
|
983
|
+
})
|
|
984
|
+
},
|
|
985
|
+
props: {
|
|
986
|
+
days: {
|
|
987
|
+
type: Array,
|
|
988
|
+
default: () => []
|
|
989
|
+
},
|
|
990
|
+
eventsByDay: {
|
|
991
|
+
type: Object,
|
|
992
|
+
required: !0
|
|
993
|
+
},
|
|
994
|
+
loading: {
|
|
995
|
+
type: Boolean,
|
|
996
|
+
default: !1
|
|
997
|
+
}
|
|
998
|
+
},
|
|
999
|
+
emits: ["event-click"],
|
|
1000
|
+
setup(e) {
|
|
1001
|
+
let { getWeekDayNames: t } = I(), r = n(() => t.value), i = x(!1), a = x([]), o = x(""), s = (t) => {
|
|
1002
|
+
let n = new Date(t.date).toDateString();
|
|
1003
|
+
o.value = n;
|
|
1004
|
+
let r = e.eventsByDay.get(n);
|
|
1005
|
+
r && r.length > 0 ? (a.value = [...r], i.value = !0) : i.value = !1;
|
|
1006
|
+
};
|
|
1007
|
+
_(() => {
|
|
1008
|
+
let t = (/* @__PURE__ */ new Date()).toDateString();
|
|
1009
|
+
o.value = t;
|
|
1010
|
+
let n = e.eventsByDay.get(t);
|
|
1011
|
+
n && n.length > 0 && (a.value = [...n], i.value = !0);
|
|
1012
|
+
});
|
|
1013
|
+
let c = (e) => o.value === new Date(e.date).toDateString(), l = x(0), u = x(!1), d = 0, f = 0, p = !1;
|
|
1014
|
+
function m(e) {
|
|
1015
|
+
d = e, f = l.value, u.value = !0;
|
|
1016
|
+
}
|
|
1017
|
+
function h(e) {
|
|
1018
|
+
if (!u.value) return;
|
|
1019
|
+
let t = e - d;
|
|
1020
|
+
p ||= (requestAnimationFrame(() => {
|
|
1021
|
+
let e = f + t / 120;
|
|
1022
|
+
l.value = Math.max(0, Math.min(1, e)), p = !1;
|
|
1023
|
+
}), !0);
|
|
1024
|
+
}
|
|
1025
|
+
function g() {
|
|
1026
|
+
u.value = !1, l.value > .25 && f === 0 ? l.value = 1 : l.value < .75 && f === 1 ? l.value = 0 : l.value = f;
|
|
1027
|
+
}
|
|
1028
|
+
let v = (e) => {
|
|
1029
|
+
m(e.touches[0]?.clientY ?? 0);
|
|
1030
|
+
}, y = (e) => {
|
|
1031
|
+
let t = e.touches[0];
|
|
1032
|
+
t && h(t.clientY);
|
|
1033
|
+
}, b = () => {
|
|
1034
|
+
g();
|
|
1035
|
+
}, S = (e) => {
|
|
1036
|
+
m(e.clientY), document.addEventListener("mousemove", C), document.addEventListener("mouseup", w);
|
|
1037
|
+
}, C = (e) => {
|
|
1038
|
+
h(e.clientY);
|
|
1039
|
+
}, w = () => {
|
|
1040
|
+
g(), document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", w);
|
|
1041
|
+
};
|
|
1042
|
+
return {
|
|
1043
|
+
isDaySelected: c,
|
|
1044
|
+
weekDays: r,
|
|
1045
|
+
selectDay: s,
|
|
1046
|
+
handleMouseDown: S,
|
|
1047
|
+
handleMouseLeave: () => {
|
|
1048
|
+
u.value && (g(), document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", w));
|
|
1049
|
+
},
|
|
1050
|
+
selectedDate: o,
|
|
1051
|
+
showEventsList: i,
|
|
1052
|
+
progress: l,
|
|
1053
|
+
isDragging: u,
|
|
1054
|
+
handleTouchStart: v,
|
|
1055
|
+
handleTouchMove: y,
|
|
1056
|
+
handleTouchEnd: b,
|
|
1057
|
+
eventsList: a
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
}), Ne = { class: "w-full pt-6 px-4 relative flex flex-col flex-1 overflow-y-auto" }, Pe = { class: "select-none text-[10px] text-on-surface/50 w-full flex items-center justify-between" }, Fe = { class: "font-medium" }, Ie = { class: "w-full mt-4 grid grid-cols-7 gap-x-5 gap-y-4" }, Le = {
|
|
1061
|
+
key: 0,
|
|
1062
|
+
class: "transition-all duration-200 ease-in-out overflow-hidden w-full mt-4 flex-1 overflow-y-auto"
|
|
1063
|
+
}, Re = { class: "py-2 text-on-surface text-title-sm font-bold select-none border-b border-outline-variant mb-2" }, ze = { class: "w-full flex flex-col gap-y-2" };
|
|
1064
|
+
function Be(t, n, s, l, u, d) {
|
|
1065
|
+
let f = w("MobileDayHolder"), p = w("MobileEventListItem");
|
|
1066
|
+
return y(), a("div", Ne, [
|
|
1067
|
+
n[6] ||= o("div", { class: "w-full fixed right-0 -translate-y-6 pointer-events-none z-50 h-6 bg-gradient-to-b from-surface to-transparent" }, null, -1),
|
|
1068
|
+
o("div", {
|
|
1069
|
+
id: "mobile-grid",
|
|
1070
|
+
class: "w-full shrink-0 select-none",
|
|
1071
|
+
style: {
|
|
1072
|
+
"touch-action": "pan-x",
|
|
1073
|
+
"user-select": "none"
|
|
1074
|
+
},
|
|
1075
|
+
onTouchstart: n[0] ||= M((...e) => t.handleTouchStart && t.handleTouchStart(...e), ["prevent"]),
|
|
1076
|
+
onTouchmove: n[1] ||= M((...e) => t.handleTouchMove && t.handleTouchMove(...e), ["prevent"]),
|
|
1077
|
+
onTouchend: n[2] ||= (...e) => t.handleTouchEnd && t.handleTouchEnd(...e),
|
|
1078
|
+
onMousedown: n[3] ||= M((...e) => t.handleMouseDown && t.handleMouseDown(...e), ["prevent"]),
|
|
1079
|
+
onMouseleave: n[4] ||= (...e) => t.handleMouseLeave && t.handleMouseLeave(...e)
|
|
1080
|
+
}, [o("div", Pe, [(y(!0), a(e, null, S(t.weekDays, (e) => (y(), a("div", {
|
|
1081
|
+
class: "aspect-square w-8 shrink-0 flex items-center justify-center",
|
|
1082
|
+
key: e.dayOfWeek
|
|
1083
|
+
}, [o("div", Fe, T(e.label), 1)]))), 128))]), o("div", Ie, [(y(!0), a(e, null, S(t.days, (e, n) => (y(), a("div", {
|
|
1084
|
+
key: n,
|
|
1085
|
+
class: m([
|
|
1086
|
+
"transition-all duration-200 rounded-lg",
|
|
1087
|
+
e.otherMonth ? "opacity-0 pointer-events-none" : "opacity-100",
|
|
1088
|
+
e.isToday && !e.otherMonth ? "bg-today-column" : ""
|
|
1089
|
+
])
|
|
1090
|
+
}, [c(f, {
|
|
1091
|
+
"is-selected": t.isDaySelected(e),
|
|
1092
|
+
"expand-progress": t.progress,
|
|
1093
|
+
"is-dragging": t.isDragging,
|
|
1094
|
+
onSelect: t.selectDay,
|
|
1095
|
+
day: e,
|
|
1096
|
+
events: t.eventsByDay.get(new Date(e.date).toDateString()) || []
|
|
1097
|
+
}, null, 8, [
|
|
1098
|
+
"is-selected",
|
|
1099
|
+
"expand-progress",
|
|
1100
|
+
"is-dragging",
|
|
1101
|
+
"onSelect",
|
|
1102
|
+
"day",
|
|
1103
|
+
"events"
|
|
1104
|
+
])], 2))), 128))])], 32),
|
|
1105
|
+
t.showEventsList ? (y(), a("div", Le, [o("div", Re, T(t.selectedDate), 1), o("div", ze, [(y(!0), a(e, null, S(t.eventsList, (e) => (y(), r(p, {
|
|
1106
|
+
key: e.id,
|
|
1107
|
+
event: e,
|
|
1108
|
+
onEventClick: n[5] ||= (e, n) => t.$emit("event-click", e, n)
|
|
1109
|
+
}, {
|
|
1110
|
+
event: A(({ event: e }) => [C(t.$slots, "event-mobile", { event: e })]),
|
|
1111
|
+
_: 2
|
|
1112
|
+
}, 1032, ["event"]))), 128))])])) : i("", !0)
|
|
1113
|
+
]);
|
|
1114
|
+
}
|
|
1115
|
+
var Ve = /* @__PURE__ */ L(Me, [["render", Be]]), He = { class: "detail-wrapper-stub" }, Ue = l({
|
|
1116
|
+
components: {
|
|
1117
|
+
MobileCalendarGrid: Ve,
|
|
1118
|
+
CalendarHeaderItem: V,
|
|
1119
|
+
CalendarSideItem: G,
|
|
1120
|
+
CalendarDayHolder: be,
|
|
1121
|
+
CalendarPointer: Ce,
|
|
1122
|
+
CalendarItemDisplay: Z,
|
|
1123
|
+
CalendarEventDetailWrapper: /* @__PURE__ */ l({
|
|
1124
|
+
__name: "CalendarEventDetailWrapper",
|
|
1125
|
+
emits: ["lock-scroll"],
|
|
1126
|
+
setup(e) {
|
|
1127
|
+
return (e, t) => (y(), a("div", He));
|
|
1128
|
+
}
|
|
1129
|
+
})
|
|
1130
|
+
},
|
|
1131
|
+
props: {
|
|
1132
|
+
range: {
|
|
1133
|
+
type: Object,
|
|
1134
|
+
required: !0
|
|
1135
|
+
},
|
|
1136
|
+
mode: {
|
|
1137
|
+
type: String,
|
|
1138
|
+
default: "monthly"
|
|
1139
|
+
},
|
|
1140
|
+
hours: {
|
|
1141
|
+
type: Object,
|
|
1142
|
+
default: () => ({
|
|
1143
|
+
start: 0,
|
|
1144
|
+
end: 24
|
|
1145
|
+
})
|
|
1146
|
+
},
|
|
1147
|
+
events: {
|
|
1148
|
+
type: Array,
|
|
1149
|
+
default: () => []
|
|
1150
|
+
},
|
|
1151
|
+
loading: {
|
|
1152
|
+
type: Boolean,
|
|
1153
|
+
default: !1
|
|
1154
|
+
},
|
|
1155
|
+
dir: {
|
|
1156
|
+
type: String,
|
|
1157
|
+
default: ""
|
|
1158
|
+
}
|
|
1159
|
+
},
|
|
1160
|
+
emits: [
|
|
1161
|
+
"update:mode",
|
|
1162
|
+
"update:range",
|
|
1163
|
+
"event-click"
|
|
1164
|
+
],
|
|
1165
|
+
setup(e, { emit: t }) {
|
|
1166
|
+
let r = n(() => e.loading), { width: i } = N(), a = n(() => i.value < 768), { getCalendarHeaders: o } = I(), s = D("scrollContainer"), c = n(() => o(e.range, e.mode)), l = n(() => c.value), u = n(() => e.mode === "monthly" ? l.value.slice(0, 7) : l.value), d = n(() => e.mode === "daily" || e.mode === "monthly" ? -1 : l.value.findIndex((e) => e.isToday)), f = n(() => {
|
|
1167
|
+
let t = /* @__PURE__ */ new Map();
|
|
1168
|
+
return e.events.forEach((e) => {
|
|
1169
|
+
let n = new Date(e.date).toDateString();
|
|
1170
|
+
t.has(n) || t.set(n, []), t.get(n)?.push(e);
|
|
1171
|
+
}), t;
|
|
1172
|
+
}), m = n(() => {
|
|
1173
|
+
let t = /* @__PURE__ */ new Map(), n = c.value.filter((e) => !e.otherMonth), r = new Set(n.map((e) => new Date(e.date).toDateString()));
|
|
1174
|
+
return e.events.forEach((e) => {
|
|
1175
|
+
let n = new Date(e.date).toDateString();
|
|
1176
|
+
r.has(n) && (t.has(n) || t.set(n, []), t.get(n)?.push(e));
|
|
1177
|
+
}), t;
|
|
1178
|
+
});
|
|
1179
|
+
function h(e) {
|
|
1180
|
+
if (!e.duration || e.duration <= 0) return [e];
|
|
1181
|
+
let t = e.time.split(":").map(Number), n = (t[0] ?? 0) + (t[1] ?? 0) / 60;
|
|
1182
|
+
if (n + e.duration / 60 <= 24) return [e];
|
|
1183
|
+
let r = [], i = new Date(e.date), a = 0, o = n, s = e.duration;
|
|
1184
|
+
for (; s > 0;) {
|
|
1185
|
+
let t = Math.min(s, (24 - o) * 60), n = Math.floor(o), c = Math.round((o - n) * 60);
|
|
1186
|
+
r.push({
|
|
1187
|
+
...e,
|
|
1188
|
+
id: `${e.id}_d${a}`,
|
|
1189
|
+
date: new Date(i.getTime() + a * 864e5),
|
|
1190
|
+
time: `${String(n).padStart(2, "0")}:${String(c).padStart(2, "0")}`,
|
|
1191
|
+
duration: Math.round(t)
|
|
1192
|
+
}), s -= t, o = 0, a++;
|
|
1193
|
+
}
|
|
1194
|
+
return r;
|
|
1195
|
+
}
|
|
1196
|
+
let g = n(() => {
|
|
1197
|
+
if (e.mode === "monthly") return [];
|
|
1198
|
+
let t = new Set(l.value.map((e) => new Date(e.date).toLocaleDateString("en-CA")));
|
|
1199
|
+
return e.events.flatMap(h).filter((e) => {
|
|
1200
|
+
let n = new Date(e.date).toLocaleDateString("en-CA");
|
|
1201
|
+
return t.has(n);
|
|
1202
|
+
});
|
|
1203
|
+
}), _ = n(() => {
|
|
1204
|
+
let t = [], n = [], r = /* @__PURE__ */ new Map();
|
|
1205
|
+
for (let e of l.value) r.set(new Date(e.date).toLocaleDateString("en-CA"), []);
|
|
1206
|
+
for (let e of g.value) r.get(new Date(e.date).toLocaleDateString("en-CA"))?.push(e);
|
|
1207
|
+
for (let [i, a] of r.entries()) {
|
|
1208
|
+
if (!a.length) continue;
|
|
1209
|
+
let r = l.value.findIndex((e) => new Date(e.date).toLocaleDateString("en-CA") === i), o = a.map((e) => {
|
|
1210
|
+
let t = e.time.split(":").map(Number), n = (t[0] ?? 0) + (t[1] ?? 0) / 60;
|
|
1211
|
+
return {
|
|
1212
|
+
event: e,
|
|
1213
|
+
start: n,
|
|
1214
|
+
end: e.duration ? n + e.duration / 60 : n + .5,
|
|
1215
|
+
col: 0
|
|
1216
|
+
};
|
|
1217
|
+
}).sort((e, t) => e.start - t.start || t.end - e.end), s = [];
|
|
1218
|
+
for (let e of o) {
|
|
1219
|
+
let t = s.findIndex((t) => t <= e.start);
|
|
1220
|
+
e.col = t === -1 ? s.length : t, s[e.col] = e.end;
|
|
1221
|
+
}
|
|
1222
|
+
if (e.mode === "daily") for (let e of o) {
|
|
1223
|
+
let n = e.col;
|
|
1224
|
+
for (let t of o) t !== e && t.start < e.end && t.end > e.start && (n = Math.max(n, t.col));
|
|
1225
|
+
t.push({
|
|
1226
|
+
event: e.event,
|
|
1227
|
+
overlapIndex: e.col,
|
|
1228
|
+
overlapCount: n + 1
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
else {
|
|
1232
|
+
for (let e of o) {
|
|
1233
|
+
if (e.col >= 2) continue;
|
|
1234
|
+
let n = e.col;
|
|
1235
|
+
for (let t of o) t !== e && t.col < 2 && t.start < e.end && t.end > e.start && (n = Math.max(n, t.col));
|
|
1236
|
+
t.push({
|
|
1237
|
+
event: e.event,
|
|
1238
|
+
overlapIndex: e.col,
|
|
1239
|
+
overlapCount: n + 1
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
let e = o.filter((e) => e.col >= 2).sort((e, t) => e.start - t.start), i = [];
|
|
1243
|
+
for (let t of e) {
|
|
1244
|
+
let e = i[i.length - 1];
|
|
1245
|
+
!e || t.start >= e.end ? i.push({
|
|
1246
|
+
start: t.start,
|
|
1247
|
+
end: t.end,
|
|
1248
|
+
count: 1
|
|
1249
|
+
}) : (e.end = Math.max(e.end, t.end), e.count++);
|
|
1250
|
+
}
|
|
1251
|
+
for (let e of i) {
|
|
1252
|
+
let t = o.filter((t) => t.col < 2 && t.start < e.end && t.end > e.start).reduce((e, t) => Math.max(e, t.end), e.start);
|
|
1253
|
+
n.push({
|
|
1254
|
+
dayIndex: r,
|
|
1255
|
+
endDecimal: t,
|
|
1256
|
+
count: e.count
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
return {
|
|
1262
|
+
events: t,
|
|
1263
|
+
overflows: n
|
|
1264
|
+
};
|
|
1265
|
+
}), v = n(() => _.value.events), y = n(() => _.value.overflows), b = n(() => {
|
|
1266
|
+
if (e.mode === "monthly" || g.value.length === 0) return e.hours;
|
|
1267
|
+
let t = e.hours.start, n = e.hours.end;
|
|
1268
|
+
for (let e of g.value) {
|
|
1269
|
+
let r = e.time.split(":").map(Number), i = (r[0] ?? 0) + (r[1] ?? 0) / 60, a = e.duration ? i + e.duration / 60 : i;
|
|
1270
|
+
t = Math.min(t, Math.floor(i)), n = Math.max(n, Math.ceil(a));
|
|
1271
|
+
}
|
|
1272
|
+
return {
|
|
1273
|
+
start: Math.max(0, t),
|
|
1274
|
+
end: Math.min(24, n)
|
|
1275
|
+
};
|
|
1276
|
+
}), S = x(!1), C = (e) => {
|
|
1277
|
+
S.value = e;
|
|
1278
|
+
}, w = (e) => {
|
|
1279
|
+
let n = new Date(e.date);
|
|
1280
|
+
t("update:range", {
|
|
1281
|
+
start: new Date(n.getFullYear(), n.getMonth(), n.getDate(), 0, 0, 0, 0),
|
|
1282
|
+
end: new Date(n.getFullYear(), n.getMonth(), n.getDate(), 23, 59, 59, 999)
|
|
1283
|
+
}), t("update:mode", "daily", n);
|
|
1284
|
+
}, T = x(!0);
|
|
1285
|
+
k([a, () => e.mode], () => {
|
|
1286
|
+
T.value = a.value ? e.mode !== "monthly" : !0;
|
|
1287
|
+
}, { immediate: !0 });
|
|
1288
|
+
let E = n(() => {
|
|
1289
|
+
let e = [];
|
|
1290
|
+
for (let t = b.value.start; t < b.value.end; t++) e.push({ raw: t });
|
|
1291
|
+
return e;
|
|
1292
|
+
});
|
|
1293
|
+
return k(() => e.events, async () => {
|
|
1294
|
+
if (e.mode === "monthly" || !s.value) return;
|
|
1295
|
+
await p();
|
|
1296
|
+
let t = s.value, n = g.value.map((e) => parseInt(e.time.split(":")[0], 10));
|
|
1297
|
+
if (n.length === 0) return;
|
|
1298
|
+
n.sort((e, t) => e - t);
|
|
1299
|
+
let r = ((n[Math.floor(n.length / 2)] ?? b.value.start) - b.value.start) * 80 - t.clientHeight / 2 + 80 / 2;
|
|
1300
|
+
t.scrollTo({
|
|
1301
|
+
top: Math.max(0, r),
|
|
1302
|
+
behavior: "smooth"
|
|
1303
|
+
});
|
|
1304
|
+
}, { deep: !0 }), {
|
|
1305
|
+
isLoading: r,
|
|
1306
|
+
hoursList: E,
|
|
1307
|
+
effectiveHours: b,
|
|
1308
|
+
scrollContainer: s,
|
|
1309
|
+
headers: l,
|
|
1310
|
+
allHeaders: c,
|
|
1311
|
+
isMobile: a,
|
|
1312
|
+
displayedHeader: u,
|
|
1313
|
+
todayColumnIndex: d,
|
|
1314
|
+
monthlyEventsByDay: m,
|
|
1315
|
+
eventsByDay: f,
|
|
1316
|
+
gridEvents: v,
|
|
1317
|
+
overflowIndicators: y,
|
|
1318
|
+
scrollLocked: S,
|
|
1319
|
+
showMonthly: T,
|
|
1320
|
+
setLockScroll: C,
|
|
1321
|
+
openSpecificDay: w
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
}), We = ["dir"], Ge = {
|
|
1325
|
+
ref: "scrollContainer",
|
|
1326
|
+
class: "flex-1 w-full flex overflow-y-auto cal-scrollbar"
|
|
1327
|
+
}, Ke = { class: "flex-1 relative" }, qe = { class: "absolute inset-0 w-full flex flex-col pointer-events-none" }, Je = { class: "absolute inset-0 w-full flex pointer-events-none" }, Ye = { class: "relative min-h-full w-full" }, Xe = ["onClick"], Ze = {
|
|
1328
|
+
key: 2,
|
|
1329
|
+
class: "w-full"
|
|
1330
|
+
};
|
|
1331
|
+
function Qe(n, l, u, d, p, h) {
|
|
1332
|
+
let _ = w("CalendarEventDetailWrapper"), v = w("CalendarHeaderItem"), b = w("CalendarSideItem"), x = w("CalendarPointer"), E = w("CalendarItemDisplay"), D = w("CalendarDayHolder"), O = w("MobileCalendarGrid");
|
|
1333
|
+
return y(), a("div", {
|
|
1334
|
+
class: "w-full h-full flex flex-col bg-surface whitespace-normal",
|
|
1335
|
+
dir: n.dir
|
|
1336
|
+
}, [
|
|
1337
|
+
c(_, { onLockScroll: n.setLockScroll }, null, 8, ["onLockScroll"]),
|
|
1338
|
+
n.showMonthly ? (y(), r(v, {
|
|
1339
|
+
key: 0,
|
|
1340
|
+
class: "shrink-0 border-b border-surface-variant",
|
|
1341
|
+
mode: n.mode,
|
|
1342
|
+
days: n.displayedHeader,
|
|
1343
|
+
"today-column-index": n.todayColumnIndex
|
|
1344
|
+
}, null, 8, [
|
|
1345
|
+
"mode",
|
|
1346
|
+
"days",
|
|
1347
|
+
"today-column-index"
|
|
1348
|
+
])) : i("", !0),
|
|
1349
|
+
o("div", Ge, [o("div", { class: m(["shrink-0 transition-all duration-300", [n.mode === "monthly" ? "w-0 opacity-0 overflow-hidden" : "w-8 sm:w-9 md:w-25 opacity-100 h-full"]]) }, [c(b, {
|
|
1350
|
+
class: "w-8 sm:w-9 md:w-25 min-h-full",
|
|
1351
|
+
range: n.effectiveHours
|
|
1352
|
+
}, null, 8, ["range"])], 2), o("div", Ke, [c(t, {
|
|
1353
|
+
name: "calendar-view",
|
|
1354
|
+
mode: "out-in"
|
|
1355
|
+
}, {
|
|
1356
|
+
default: A(() => [n.mode === "monthly" ? n.isMobile ? n.mode === "monthly" && n.isMobile ? (y(), a("div", Ze, [c(O, {
|
|
1357
|
+
loading: n.isLoading,
|
|
1358
|
+
days: n.headers,
|
|
1359
|
+
mode: n.mode,
|
|
1360
|
+
"events-by-day": n.monthlyEventsByDay,
|
|
1361
|
+
"is-other-month-func": (e) => n.headers.find((t) => new Date(t.date).toDateString() === new Date(e).toDateString())?.otherMonth || !1,
|
|
1362
|
+
onEventClick: l[2] ||= (e) => n.$emit("event-click", e)
|
|
1363
|
+
}, s({ _: 2 }, [n.$slots["event-mobile"] ? {
|
|
1364
|
+
name: "event-mobile",
|
|
1365
|
+
fn: A(({ event: e }) => [C(n.$slots, "event-mobile", {
|
|
1366
|
+
event: e,
|
|
1367
|
+
mode: "monthly-mobile"
|
|
1368
|
+
}, void 0, !0)]),
|
|
1369
|
+
key: "0"
|
|
1370
|
+
} : void 0]), 1032, [
|
|
1371
|
+
"loading",
|
|
1372
|
+
"days",
|
|
1373
|
+
"mode",
|
|
1374
|
+
"events-by-day",
|
|
1375
|
+
"is-other-month-func"
|
|
1376
|
+
])])) : i("", !0) : (y(), a("div", {
|
|
1377
|
+
key: `month-${n.range?.start?.getTime()}`,
|
|
1378
|
+
class: "w-full grid grid-cols-7 auto-rows-[186px] overflow-hidden"
|
|
1379
|
+
}, [(y(!0), a(e, null, S(n.allHeaders, (e, t) => (y(), r(D, {
|
|
1380
|
+
key: t,
|
|
1381
|
+
day: e,
|
|
1382
|
+
"other-month": !!e.otherMonth,
|
|
1383
|
+
events: n.monthlyEventsByDay.get(new Date(e.date).toDateString()) || [],
|
|
1384
|
+
onOpenDay: (t) => n.openSpecificDay(e),
|
|
1385
|
+
onEventClick: l[1] ||= (e) => n.$emit("event-click", e)
|
|
1386
|
+
}, s({ _: 2 }, [n.$slots.event ? {
|
|
1387
|
+
name: "event",
|
|
1388
|
+
fn: A((e) => [C(n.$slots, "event", f({ ref_for: !0 }, e), void 0, !0)]),
|
|
1389
|
+
key: "0"
|
|
1390
|
+
} : void 0]), 1032, [
|
|
1391
|
+
"day",
|
|
1392
|
+
"other-month",
|
|
1393
|
+
"events",
|
|
1394
|
+
"onOpenDay"
|
|
1395
|
+
]))), 128))])) : (y(), a("div", {
|
|
1396
|
+
key: `time-${n.mode}-${n.range?.start?.getTime()}`,
|
|
1397
|
+
class: "w-full relative",
|
|
1398
|
+
style: g({ height: `${n.hoursList.length * 80}px` })
|
|
1399
|
+
}, [
|
|
1400
|
+
c(x, {
|
|
1401
|
+
mode: n.mode,
|
|
1402
|
+
hours: n.effectiveHours,
|
|
1403
|
+
headers: n.headers
|
|
1404
|
+
}, null, 8, [
|
|
1405
|
+
"mode",
|
|
1406
|
+
"hours",
|
|
1407
|
+
"headers"
|
|
1408
|
+
]),
|
|
1409
|
+
o("div", qe, [(y(!0), a(e, null, S(n.effectiveHours.end - n.effectiveHours.start, (e) => (y(), a("div", {
|
|
1410
|
+
key: e,
|
|
1411
|
+
class: "w-full border-b border-surface-variant box-border h-20"
|
|
1412
|
+
}))), 128))]),
|
|
1413
|
+
o("div", Je, [(y(!0), a(e, null, S(n.headers, (e, t) => (y(), a("div", {
|
|
1414
|
+
class: m(["h-full border-r border-surface-variant flex-1 transition-colors", { "bg-today-column": t === n.todayColumnIndex }]),
|
|
1415
|
+
key: "v" + t
|
|
1416
|
+
}, null, 2))), 128))]),
|
|
1417
|
+
o("div", Ye, [(y(!0), a(e, null, S(n.gridEvents, (e) => (y(), r(E, {
|
|
1418
|
+
key: e.event.id,
|
|
1419
|
+
event: e.event,
|
|
1420
|
+
mode: n.mode,
|
|
1421
|
+
headers: n.headers,
|
|
1422
|
+
hours: n.effectiveHours,
|
|
1423
|
+
isMobile: n.isMobile,
|
|
1424
|
+
"overlap-index": e.overlapIndex,
|
|
1425
|
+
"overlap-count": e.overlapCount,
|
|
1426
|
+
onEventClick: l[0] ||= (e) => n.$emit("event-click", e)
|
|
1427
|
+
}, s({ _: 2 }, [n.$slots.event ? {
|
|
1428
|
+
name: "event",
|
|
1429
|
+
fn: A((e) => [C(n.$slots, "event", f({ ref_for: !0 }, e), void 0, !0)]),
|
|
1430
|
+
key: "0"
|
|
1431
|
+
} : void 0]), 1032, [
|
|
1432
|
+
"event",
|
|
1433
|
+
"mode",
|
|
1434
|
+
"headers",
|
|
1435
|
+
"hours",
|
|
1436
|
+
"isMobile",
|
|
1437
|
+
"overlap-index",
|
|
1438
|
+
"overlap-count"
|
|
1439
|
+
]))), 128)), (y(!0), a(e, null, S(n.overflowIndicators, (e, t) => (y(), a("div", {
|
|
1440
|
+
key: `of-${t}`,
|
|
1441
|
+
class: "absolute px-0.5 sm:px-1 z-20 pointer-events-auto",
|
|
1442
|
+
style: g({
|
|
1443
|
+
top: `${(Math.min(e.endDecimal, n.effectiveHours.end) - n.effectiveHours.start) * 80}px`,
|
|
1444
|
+
insetInlineStart: `${e.dayIndex * (100 / n.headers.length)}%`,
|
|
1445
|
+
width: `${100 / n.headers.length}%`
|
|
1446
|
+
})
|
|
1447
|
+
}, [o("button", {
|
|
1448
|
+
class: "w-full text-[8px] sm:text-[10px] leading-none rounded bg-surface-variant hover:bg-surface-variant/80 text-on-surface/70 px-1 sm:px-2 py-0.5 sm:py-1 truncate transition-colors",
|
|
1449
|
+
onClick: (t) => n.openSpecificDay(n.headers[e.dayIndex])
|
|
1450
|
+
}, " +" + T(e.count) + " more ", 9, Xe)], 4))), 128))])
|
|
1451
|
+
], 4))]),
|
|
1452
|
+
_: 3
|
|
1453
|
+
})])], 512)
|
|
1454
|
+
], 8, We);
|
|
1455
|
+
}
|
|
1456
|
+
var $e = /* @__PURE__ */ L(Ue, [["render", Qe], ["__scopeId", "data-v-66575d8b"]]), et = ["dir"], tt = {
|
|
1457
|
+
ref: "scrollContainer",
|
|
1458
|
+
class: "flex-1 w-full overflow-y-auto cal-scrollbar px-2 sm:px-4 md:px-6 py-3 sm:py-5"
|
|
1459
|
+
}, nt = { class: "max-w-4xl mx-auto flex flex-col gap-6" }, rt = { class: "agenda-section-header sticky top-0 z-10 py-1.5 flex items-center gap-3 bg-surface/95 backdrop-blur-xs" }, it = { class: "rounded-full bg-surface-variant px-3 py-0.5 text-xs font-semibold text-on-surface/70 border border-outline-variant shadow-xs select-none" }, at = { class: "flex flex-col gap-3" }, ot = { class: "agenda-date-col shrink-0 flex flex-col items-start w-24 sm:w-32 md:w-36 pt-0.5 select-none" }, st = { class: "sm:hidden" }, ct = { class: "hidden sm:inline" }, lt = { class: "mt-1 flex items-center gap-1.5 sm:gap-2" }, ut = { class: "flex flex-col text-[10px] sm:text-xs leading-none text-on-surface/50 gap-0.5" }, dt = {
|
|
1460
|
+
key: 0,
|
|
1461
|
+
class: "opacity-70"
|
|
1462
|
+
}, ft = {
|
|
1463
|
+
key: 0,
|
|
1464
|
+
class: "mt-1 text-[10px] font-medium text-error truncate max-w-full"
|
|
1465
|
+
}, pt = { class: "agenda-events-col flex-1 min-w-0 flex flex-col gap-2" }, Q = ["onClick"], mt = { class: "min-w-0 flex-1 font-semibold text-xs sm:text-sm md:text-base leading-snug truncate" }, ht = {
|
|
1466
|
+
key: 0,
|
|
1467
|
+
class: "shrink-0 text-[11px] sm:text-xs md:text-sm font-medium opacity-90 flex items-center gap-1.5 whitespace-nowrap"
|
|
1468
|
+
}, gt = {
|
|
1469
|
+
key: 1,
|
|
1470
|
+
class: "agenda-no-events flex items-center text-xs text-on-surface/40 italic py-2 px-3 rounded-lg border border-dashed border-outline-variant select-none"
|
|
1471
|
+
}, $ = /* @__PURE__ */ L(/* @__PURE__ */ l({
|
|
1472
|
+
__name: "CalendarAgenda",
|
|
1473
|
+
props: {
|
|
1474
|
+
range: {},
|
|
1475
|
+
events: { default: () => [] },
|
|
1476
|
+
dir: { default: "" }
|
|
1477
|
+
},
|
|
1478
|
+
emits: ["event-click"],
|
|
1479
|
+
setup(t) {
|
|
1480
|
+
let r = t, s = d("calendarConfig", x({
|
|
1481
|
+
locale: "fa-IR",
|
|
1482
|
+
calendar: "jalaali",
|
|
1483
|
+
startOfWeek: "saturday",
|
|
1484
|
+
showHolidays: !1
|
|
1485
|
+
})), { t: c } = F(), { getCalendarHeaders: l } = I(), u = n(() => {
|
|
1486
|
+
let e = String(s.value.locale || "").toLowerCase();
|
|
1487
|
+
return e.startsWith("fa") || e.startsWith("ar");
|
|
1488
|
+
}), f = n(() => r.dir ? r.dir : u.value ? "rtl" : "ltr");
|
|
1489
|
+
function p(e) {
|
|
1490
|
+
if (!e || typeof e != "string") return 0;
|
|
1491
|
+
let t = e.split(":").map(Number), n = t[0] ?? 0, r = t[1] ?? 0;
|
|
1492
|
+
return Number.isNaN(n) || Number.isNaN(r) ? 0 : n * 60 + r;
|
|
1493
|
+
}
|
|
1494
|
+
let h = [
|
|
1495
|
+
"۰",
|
|
1496
|
+
"۱",
|
|
1497
|
+
"۲",
|
|
1498
|
+
"۳",
|
|
1499
|
+
"۴",
|
|
1500
|
+
"۵",
|
|
1501
|
+
"۶",
|
|
1502
|
+
"۷",
|
|
1503
|
+
"۸",
|
|
1504
|
+
"۹"
|
|
1505
|
+
];
|
|
1506
|
+
function _(e) {
|
|
1507
|
+
return u.value ? e.replace(/\d/g, (e) => h[parseInt(e, 10)] ?? e) : e;
|
|
1508
|
+
}
|
|
1509
|
+
function v(e) {
|
|
1510
|
+
if (e.isFullDay) return c("calendar.allDay") || (u.value ? "تمام روز" : "All day");
|
|
1511
|
+
if (!e.time) return "";
|
|
1512
|
+
if (!e.duration || e.duration <= 0) return _(e.time);
|
|
1513
|
+
let t = p(e.time) + e.duration, n = Math.floor(t % 1440 / 60), r = t % 60, i = `${String(n).padStart(2, "0")}:${String(r).padStart(2, "0")}`, a = _(e.time), o = _(i);
|
|
1514
|
+
return u.value ? `${a} تا ${o}` : `${a} – ${o}`;
|
|
1515
|
+
}
|
|
1516
|
+
function b(e) {
|
|
1517
|
+
let t = e.color || "var(--cal-primary, #1a9d90)";
|
|
1518
|
+
return {
|
|
1519
|
+
backgroundColor: t,
|
|
1520
|
+
color: X(t)
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
let w = n(() => l(r.range, "agenda"));
|
|
1524
|
+
function D(e, t) {
|
|
1525
|
+
if (!e.date) return !1;
|
|
1526
|
+
let n = new Date(t.date), r = new Date(n.getFullYear(), n.getMonth(), n.getDate(), 0, 0, 0, 0).getTime(), i = new Date(n.getFullYear(), n.getMonth(), n.getDate(), 23, 59, 59, 999).getTime(), a = new Date(e.date), o = p(e.time), s = new Date(a.getFullYear(), a.getMonth(), a.getDate(), 0, 0, 0, 0).getTime() + o * 60 * 1e3, c = s;
|
|
1527
|
+
return e.duration && e.duration > 0 ? c = s + e.duration * 60 * 1e3 : e.isFullDay && (c = new Date(a.getFullYear(), a.getMonth(), a.getDate(), 23, 59, 59, 999).getTime()), s <= i && c >= r;
|
|
1528
|
+
}
|
|
1529
|
+
function O(e) {
|
|
1530
|
+
return r.events.filter((t) => D(t, e)).sort((e, t) => {
|
|
1531
|
+
if (e.isFullDay && !t.isFullDay) return -1;
|
|
1532
|
+
if (!e.isFullDay && t.isFullDay) return 1;
|
|
1533
|
+
let n = p(e.time), r = p(t.time);
|
|
1534
|
+
return n === r ? String(e.title || "").localeCompare(String(t.title || "")) : n - r;
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
function k(e, t) {
|
|
1538
|
+
let n = u.value, r = n ? "fa-IR" : "en-US", i = s.value.calendar === "jalaali" ? "persian" : s.value.calendar === "islamic" ? "islamic-civil" : "gregory", a = new Intl.DateTimeFormat(`${r}-u-ca-${i}`, {
|
|
1539
|
+
day: "numeric",
|
|
1540
|
+
month: "short",
|
|
1541
|
+
year: "numeric"
|
|
1542
|
+
}).formatToParts(e), o = new Intl.DateTimeFormat(`${r}-u-ca-${i}`, {
|
|
1543
|
+
day: "numeric",
|
|
1544
|
+
month: "short",
|
|
1545
|
+
year: "numeric"
|
|
1546
|
+
}).formatToParts(t), c = a.find((e) => e.type === "day")?.value || "", l = a.find((e) => e.type === "month")?.value || "", d = a.find((e) => e.type === "year")?.value || "", f = o.find((e) => e.type === "day")?.value || "", p = o.find((e) => e.type === "month")?.value || "", m = o.find((e) => e.type === "year")?.value || "";
|
|
1547
|
+
return d === m && l === p ? n ? `${c} – ${f} ${l}` : `${l} ${c} – ${f}` : d === m ? n ? `${c} ${l} – ${f} ${p}` : `${l} ${c} – ${p} ${f}` : n ? `${c} ${l} ${d} – ${f} ${p} ${m}` : `${l} ${c}, ${d} – ${p} ${f}, ${d}`;
|
|
1548
|
+
}
|
|
1549
|
+
let A = n(() => {
|
|
1550
|
+
let e = w.value;
|
|
1551
|
+
if (!e.length) return [];
|
|
1552
|
+
let t = [];
|
|
1553
|
+
for (let n = 0; n < e.length; n += 7) {
|
|
1554
|
+
let r = e.slice(n, n + 7), i = r[0]?.date || /* @__PURE__ */ new Date(), a = r[r.length - 1]?.date || i;
|
|
1555
|
+
t.push({
|
|
1556
|
+
id: `section-${i.getTime()}-${a.getTime()}`,
|
|
1557
|
+
rangeLabel: k(i, a),
|
|
1558
|
+
days: r.map((e) => ({
|
|
1559
|
+
day: e,
|
|
1560
|
+
events: O(e)
|
|
1561
|
+
}))
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
return t;
|
|
1565
|
+
});
|
|
1566
|
+
return (t, n) => (y(), a("div", {
|
|
1567
|
+
class: "calendar-agenda w-full h-full flex flex-col bg-surface overflow-hidden",
|
|
1568
|
+
dir: f.value
|
|
1569
|
+
}, [o("div", tt, [o("div", nt, [(y(!0), a(e, null, S(A.value, (r) => (y(), a("div", {
|
|
1570
|
+
key: r.id,
|
|
1571
|
+
class: "agenda-section flex flex-col gap-3"
|
|
1572
|
+
}, [o("div", rt, [
|
|
1573
|
+
n[0] ||= o("div", { class: "h-px flex-1 bg-outline-variant" }, null, -1),
|
|
1574
|
+
o("span", it, T(r.rangeLabel), 1),
|
|
1575
|
+
n[1] ||= o("div", { class: "h-px flex-1 bg-outline-variant" }, null, -1)
|
|
1576
|
+
]), o("div", at, [(y(!0), a(e, null, S(r.days, (r) => (y(), a("div", {
|
|
1577
|
+
key: r.day.name + r.day.date.getTime(),
|
|
1578
|
+
class: m(["agenda-day-row flex flex-row items-start gap-3 sm:gap-5 p-2.5 sm:p-3.5 rounded-xl border border-outline-variant/60 transition-colors", {
|
|
1579
|
+
"bg-today-column ring-1 ring-primary/30 border-primary/40": r.day.isToday,
|
|
1580
|
+
"bg-surface": !r.day.isToday
|
|
1581
|
+
}])
|
|
1582
|
+
}, [o("div", ot, [
|
|
1583
|
+
o("span", { class: m(["text-xs sm:text-sm font-semibold truncate max-w-full", r.day.isToday ? "text-primary font-bold" : "text-on-surface/80"]) }, [o("span", st, T(r.day.shortName || r.day.name), 1), o("span", ct, T(r.day.name), 1)], 2),
|
|
1584
|
+
o("div", lt, [o("div", { class: m(["flex size-7 sm:size-8 items-center justify-center rounded-full text-xs sm:text-sm font-bold shadow-xs shrink-0", [r.day.isToday ? "bg-primary text-surface font-extrabold ring-2 ring-primary/30" : r.day.isWeekend || r.day.isHoliday ? "bg-surface-variant text-error border border-outline-variant" : "bg-surface-variant text-on-surface border border-outline-variant"]]) }, T(r.day.primary), 3), o("div", ut, [o("span", { class: m({ "text-error": r.day.isWeekend || r.day.isHoliday }) }, T(r.day.secondary), 3), r.day.tertiary ? (y(), a("span", dt, T(r.day.tertiary), 1)) : i("", !0)])]),
|
|
1585
|
+
r.day.holidayTitle ? (y(), a("span", ft, T(r.day.holidayTitle), 1)) : i("", !0)
|
|
1586
|
+
]), o("div", pt, [r.events.length > 0 ? (y(!0), a(e, { key: 0 }, S(r.events, (e) => (y(), a("div", {
|
|
1587
|
+
key: e.id,
|
|
1588
|
+
class: "agenda-event-card group flex items-center justify-between gap-3 rounded-lg sm:rounded-xl p-2.5 sm:px-4 sm:py-3 shadow-xs cursor-pointer transition-all hover:scale-[1.006] hover:shadow-md active:scale-[0.995]",
|
|
1589
|
+
style: g(b(e)),
|
|
1590
|
+
onClick: (n) => t.$emit("event-click", e)
|
|
1591
|
+
}, [C(t.$slots, "event", {
|
|
1592
|
+
event: e,
|
|
1593
|
+
mode: "agenda"
|
|
1594
|
+
}, () => [o("div", mt, T(e.title), 1), e.time || e.isFullDay ? (y(), a("div", ht, [n[2] ||= o("svg", {
|
|
1595
|
+
class: "size-3 sm:size-3.5 opacity-80",
|
|
1596
|
+
viewBox: "0 0 24 24",
|
|
1597
|
+
fill: "none",
|
|
1598
|
+
stroke: "currentColor",
|
|
1599
|
+
"stroke-width": "2"
|
|
1600
|
+
}, [o("circle", {
|
|
1601
|
+
cx: "12",
|
|
1602
|
+
cy: "12",
|
|
1603
|
+
r: "10"
|
|
1604
|
+
}), o("polyline", { points: "12 6 12 12 16 14" })], -1), o("span", null, T(v(e)), 1)])) : i("", !0)], !0)], 12, Q))), 128)) : (y(), a("div", gt, T(E(c)("calendar.noEvents") || "No events"), 1))])], 2))), 128))])]))), 128))])], 512)], 8, et));
|
|
1605
|
+
}
|
|
1606
|
+
}), [["__scopeId", "data-v-d9fbe1f4"]]), _t = {
|
|
1607
|
+
key: 0,
|
|
1608
|
+
class: "w-full h-full flex flex-col font-sans",
|
|
1609
|
+
style: {
|
|
1610
|
+
color: "var(--cal-on-surface)",
|
|
1611
|
+
background: "var(--cal-surface)"
|
|
1612
|
+
}
|
|
1613
|
+
}, vt = { class: "w-full flex-1 overflow-hidden relative" }, yt = /* @__PURE__ */ l({
|
|
1614
|
+
__name: "VueCalendar",
|
|
1615
|
+
props: {
|
|
1616
|
+
events: { default: () => [] },
|
|
1617
|
+
mode: { default: "monthly" },
|
|
1618
|
+
locale: { default: "en-US" },
|
|
1619
|
+
calendarType: { default: "gregory" },
|
|
1620
|
+
startOfWeek: {},
|
|
1621
|
+
hours: { default: () => ({
|
|
1622
|
+
start: 0,
|
|
1623
|
+
end: 24
|
|
1624
|
+
}) },
|
|
1625
|
+
initialDate: { default: () => /* @__PURE__ */ new Date() }
|
|
1626
|
+
},
|
|
1627
|
+
emits: [
|
|
1628
|
+
"update:mode",
|
|
1629
|
+
"range-change",
|
|
1630
|
+
"event-click"
|
|
1631
|
+
],
|
|
1632
|
+
setup(e, { expose: t, emit: c }) {
|
|
1633
|
+
let l = e, d = c, f = x(!1), p = x(new Date(l.initialDate)), m = {
|
|
1634
|
+
gregory: "gregory",
|
|
1635
|
+
persian: "jalaali",
|
|
1636
|
+
"islamic-uma": "islamic"
|
|
1637
|
+
}, g = [
|
|
1638
|
+
"sunday",
|
|
1639
|
+
"monday",
|
|
1640
|
+
"tuesday",
|
|
1641
|
+
"wednesday",
|
|
1642
|
+
"thursday",
|
|
1643
|
+
"friday",
|
|
1644
|
+
"saturday"
|
|
1645
|
+
], v = n(() => l.startOfWeek !== void 0 && l.startOfWeek >= 0 && l.startOfWeek <= 6 ? l.startOfWeek : l.calendarType === "gregory" ? 1 : 6), S = n(() => ({
|
|
1646
|
+
locale: l.locale,
|
|
1647
|
+
calendar: m[l.calendarType],
|
|
1648
|
+
startOfWeek: g[v.value] ?? "sunday",
|
|
1649
|
+
showHolidays: !1
|
|
1650
|
+
}));
|
|
1651
|
+
b("calendarConfig", S), b("calendarHolidays", x({}));
|
|
1652
|
+
let { getMonthBounds: w, offsetPeriod: T } = I(S), E = n(() => {
|
|
1653
|
+
let e = new Date(p.value), t = new Date(p.value);
|
|
1654
|
+
if (l.mode === "daily") return e.setHours(0, 0, 0, 0), t.setHours(23, 59, 59, 999), {
|
|
1655
|
+
start: e,
|
|
1656
|
+
end: t
|
|
1657
|
+
};
|
|
1658
|
+
if (l.mode === "3days") return e.setHours(0, 0, 0, 0), t.setTime(e.getTime()), t.setDate(e.getDate() + 2), t.setHours(23, 59, 59, 999), {
|
|
1659
|
+
start: e,
|
|
1660
|
+
end: t
|
|
1661
|
+
};
|
|
1662
|
+
if (l.mode === "weekly") {
|
|
1663
|
+
let n = v.value, r = e.getDay(), i = (r < n ? 7 : 0) + r - n;
|
|
1664
|
+
return e.setDate(e.getDate() - i), e.setHours(0, 0, 0, 0), t.setTime(e.getTime()), t.setDate(e.getDate() + 6), t.setHours(23, 59, 59, 999), {
|
|
1665
|
+
start: e,
|
|
1666
|
+
end: t
|
|
1667
|
+
};
|
|
1668
|
+
} else return w(p.value);
|
|
1669
|
+
}), D = () => {
|
|
1670
|
+
p.value = T(p.value, l.mode, 1), d("range-change", E.value);
|
|
1671
|
+
}, O = () => {
|
|
1672
|
+
p.value = T(p.value, l.mode, -1), d("range-change", E.value);
|
|
1673
|
+
}, j = (e, t) => {
|
|
1674
|
+
t && (p.value = new Date(t)), d("update:mode", e, t);
|
|
1675
|
+
}, M = (e, t) => {
|
|
1676
|
+
t && (p.value = new Date(t)), d("update:mode", e, t);
|
|
1677
|
+
};
|
|
1678
|
+
return k(() => l.initialDate, (e) => {
|
|
1679
|
+
e && (p.value = new Date(e), d("range-change", E.value));
|
|
1680
|
+
}), k(E, (e) => {
|
|
1681
|
+
f.value && d("range-change", e);
|
|
1682
|
+
}), _(() => {
|
|
1683
|
+
f.value = !0, d("range-change", E.value);
|
|
1684
|
+
}), t({
|
|
1685
|
+
goNext: D,
|
|
1686
|
+
goPrev: O,
|
|
1687
|
+
setMode: M,
|
|
1688
|
+
currentRange: E,
|
|
1689
|
+
handleModeUpdate: j
|
|
1690
|
+
}), (t, n) => f.value ? (y(), a("div", _t, [C(t.$slots, "header", {
|
|
1691
|
+
mode: e.mode,
|
|
1692
|
+
range: E.value,
|
|
1693
|
+
next: D,
|
|
1694
|
+
prev: O,
|
|
1695
|
+
setMode: M
|
|
1696
|
+
}), o("div", vt, [e.mode === "agenda" ? (y(), r($, {
|
|
1697
|
+
key: 0,
|
|
1698
|
+
range: E.value,
|
|
1699
|
+
events: e.events,
|
|
1700
|
+
onEventClick: n[0] ||= (e) => t.$emit("event-click", e)
|
|
1701
|
+
}, s({ _: 2 }, [t.$slots.event ? {
|
|
1702
|
+
name: "event",
|
|
1703
|
+
fn: A((e) => [C(t.$slots, "event", h(u(e)))]),
|
|
1704
|
+
key: "0"
|
|
1705
|
+
} : void 0]), 1032, ["range", "events"])) : (y(), r($e, {
|
|
1706
|
+
key: 1,
|
|
1707
|
+
range: E.value,
|
|
1708
|
+
mode: e.mode,
|
|
1709
|
+
events: e.events,
|
|
1710
|
+
hours: e.hours,
|
|
1711
|
+
"onUpdate:mode": n[1] ||= (e, t) => j(e, t),
|
|
1712
|
+
onEventClick: n[2] ||= (e) => t.$emit("event-click", e),
|
|
1713
|
+
"onUpdate:range": n[3] ||= (e) => t.$emit("range-change", e)
|
|
1714
|
+
}, s({ _: 2 }, [t.$slots.event ? {
|
|
1715
|
+
name: "event",
|
|
1716
|
+
fn: A((e) => [C(t.$slots, "event", h(u(e)))]),
|
|
1717
|
+
key: "0"
|
|
1718
|
+
} : void 0, t.$slots["event-mobile"] ? {
|
|
1719
|
+
name: "event-mobile",
|
|
1720
|
+
fn: A((e) => [C(t.$slots, "event-mobile", h(u(e)))]),
|
|
1721
|
+
key: "1"
|
|
1722
|
+
} : void 0]), 1032, [
|
|
1723
|
+
"range",
|
|
1724
|
+
"mode",
|
|
1725
|
+
"events",
|
|
1726
|
+
"hours"
|
|
1727
|
+
]))])])) : i("", !0);
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1730
|
+
//#endregion
|
|
1731
|
+
export { $ as CalendarAgenda, yt as VueCalendar, X as getAccessibleTextColor, pe as getContrastRatio, Y as getRelativeLuminance, J as parseColorToRgb };
|