@tongziyang/uni-calendar-plugin
Version:
A comprehensive calendar plugin for uniapp with support for Gregorian and Lunar calendars, date selection, hotel booking, check-in functionality, and more.
1,737 lines • 63.1 kB
JavaScript
import { defineComponent as I, openBlock as u, createElementBlock as c, createElementVNode as k, createTextVNode as de, toDisplayString as T, normalizeClass as H, computed as R, withModifiers as he, Fragment as V, renderList as B, createCommentVNode as N, resolveComponent as A, createVNode as X, createBlock as ee, ref as O, onUnmounted as _e, renderSlot as Z, watch as pe, onMounted as Me, nextTick as ue, withCtx as K } from "vue";
const te = [
19416,
19168,
42352,
21717,
53856,
55632,
91476,
22176,
39632,
21970,
// 1900-1909
19168,
42422,
42192,
53840,
119381,
46400,
54944,
44450,
38320,
84343,
// 1910-1919
18800,
42160,
46261,
27216,
27968,
109396,
11104,
38256,
21234,
18800,
// 1920-1929
25958,
54432,
59984,
28309,
23248,
11104,
100067,
37600,
116951,
51536,
// 1930-1939
54432,
120998,
46416,
22176,
107956,
9680,
37584,
53938,
43344,
46423,
// 1940-1949
27808,
46416,
86869,
19872,
42416,
83315,
21168,
43432,
59728,
27296,
// 1950-1959
44710,
43856,
19296,
43748,
42352,
21088,
62051,
55632,
23383,
22176,
// 1960-1969
38608,
19925,
19152,
42192,
54484,
53840,
54616,
46400,
46752,
103846,
// 1970-1979
38320,
18864,
43380,
42160,
45690,
27216,
27968,
44870,
43872,
38256,
// 1980-1989
19189,
18800,
25776,
29859,
59984,
27480,
21952,
43872,
38613,
37600,
// 1990-1999
51552,
55636,
54432,
55888,
30034,
22176,
43959,
9680,
37584,
51893,
// 2000-2009
43344,
46240,
47780,
44368,
21977,
19360,
42416,
86390,
21168,
43312,
// 2010-2019
31060,
27296,
44368,
23378,
19296,
42726,
42208,
53856,
60005,
54576,
// 2020-2029 (2023年闰二月)
23200,
30371,
38608,
19195,
19152,
42192,
118966,
53840,
54560,
56645,
// 2030-2039
46496,
22224,
21938,
18864,
42359,
42160,
43600,
111189,
27936,
44448,
// 2040-2049
84835,
37744,
18936,
18800,
25776,
92326,
59984,
27424,
108228,
43744,
// 2050-2059
41696,
53987,
51552,
54615,
54432,
55888,
23893,
22176,
42704,
21972,
// 2060-2069
21200,
43448,
43344,
46240,
46758,
44368,
21920,
43940,
42416,
21168,
// 2070-2079
45683,
26928,
29495,
27296,
44368,
84821,
19296,
42352,
21732,
53600,
// 2080-2089
59752,
54560,
55968,
92838,
22224,
19168,
43476,
41680,
53584,
62034
// 2090-2099
], Ce = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"], Se = ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"], $e = ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"], ie = [
"正月",
"二月",
"三月",
"四月",
"五月",
"六月",
"七月",
"八月",
"九月",
"十月",
"冬月",
"腊月"
], be = [
"初一",
"初二",
"初三",
"初四",
"初五",
"初六",
"初七",
"初八",
"初九",
"初十",
"十一",
"十二",
"十三",
"十四",
"十五",
"十六",
"十七",
"十八",
"十九",
"二十",
"廿一",
"廿二",
"廿三",
"廿四",
"廿五",
"廿六",
"廿七",
"廿八",
"廿九",
"三十"
], Ye = {
正月初一: "春节",
正月十五: "元宵节",
二月初二: "龙抬头",
五月初五: "端午节",
七月初七: "七夕",
七月十五: "中元节",
八月十五: "中秋节",
九月初九: "重阳节",
腊月初八: "腊八节",
腊月廿三: "小年",
腊月三十: "除夕"
}, Te = {
"01-01": "元旦",
"02-14": "情人节",
"03-08": "妇女节",
"03-12": "植树节",
"04-01": "愚人节",
"04-05": "清明节",
"05-01": "劳动节",
"05-04": "青年节",
"06-01": "儿童节",
"07-01": "建党节",
"08-01": "建军节",
"09-10": "教师节",
"10-01": "国庆节",
"12-24": "平安夜",
"12-25": "圣诞节"
}, Re = [
"小寒",
"大寒",
"立春",
"雨水",
"惊蛰",
"春分",
"清明",
"谷雨",
"立夏",
"小满",
"芒种",
"夏至",
"小暑",
"大暑",
"立秋",
"处暑",
"白露",
"秋分",
"寒露",
"霜降",
"立冬",
"小雪",
"大雪",
"冬至"
], Pe = [
"0106",
"0120",
"0204",
"0219",
"0306",
"0321",
"0405",
"0420",
"0506",
"0521",
"0606",
"0621",
"0707",
"0723",
"0807",
"0823",
"0908",
"0923",
"1008",
"1023",
"1107",
"1122",
"1207",
"1222"
];
function Fe(e) {
e.getFullYear();
const a = e.getMonth() + 1, n = e.getDate(), i = `${a.toString().padStart(2, "0")}${n.toString().padStart(2, "0")}`, l = Pe.findIndex((s) => s === i);
return l !== -1 && Math.floor(l / 2) + 1 === a ? Re[l] : "";
}
function He(e) {
let a = 348;
for (let n = 32768; n > 8; n >>= 1)
a += te[e - 1900] & n ? 1 : 0;
return a + ye(e);
}
function ye(e) {
return De(e) ? te[e - 1900] & 65536 ? 30 : 29 : 0;
}
function De(e) {
return te[e - 1900] & 15;
}
function We(e, a) {
return te[e - 1900] & 65536 >> a ? 30 : 29;
}
function J(e) {
const a = e.getFullYear(), n = e.getMonth() + 1, i = e.getDate();
if (a < 1900 || a > 2100)
return {
lunarYear: "",
lunarMonth: "",
lunarDay: ""
};
const l = new Date(1900, 0, 31);
let s = Math.floor((e.getTime() - l.getTime()) / 864e5), t = 1900, r = 0;
for (let y = 1900; y < 2100 && s > 0; y++)
r = He(y), s -= r, t++;
s < 0 && (s += r, t--);
let d = !1, h = 1;
const L = De(t), P = [];
let E = 0;
for (let y = 1; y <= 12; y++)
P.push(We(t, y));
L > 0 && (E = ye(t));
let S = s + 1, M = 1, $ = !1;
for (let y = 1; y <= 12; y++) {
let z = P[y - 1];
if (S <= z) {
M = y;
break;
}
if (S -= z, y === L) {
if (S <= E) {
M = y, $ = !0;
break;
}
S -= E;
}
}
h = M, d = $;
const m = S, W = (t - 1900 + 36) % 60, C = Ce[W % 10] + Se[W % 12];
let F = ie[h - 1];
d && (F = "闰" + ie[h - 1]);
const b = be[m - 1], v = `${ie[h - 1]}${b}`, _ = Ye[v], f = `${n.toString().padStart(2, "0")}-${i.toString().padStart(2, "0")}`, p = Te[f], D = Fe(e);
return {
lunarYear: `${C}年 ${$e[(t - 4) % 12]}年`,
lunarMonth: F,
lunarDay: b,
lunarFestival: _,
solarFestival: p,
solarTerm: D
};
}
const Ee = [
// 2024年节假日
{ name: "春节", startDate: "2024-02-10", endDate: "2024-02-17", isRestDay: !0 },
{ name: "清明节", startDate: "2024-04-04", endDate: "2024-04-06", isRestDay: !0 },
{ name: "劳动节", startDate: "2024-05-01", endDate: "2024-05-05", isRestDay: !0 },
{ name: "端午节", startDate: "2024-06-08", endDate: "2024-06-10", isRestDay: !0 },
{ name: "中秋节", startDate: "2024-09-15", endDate: "2024-09-17", isRestDay: !0 },
{ name: "国庆节", startDate: "2024-10-01", endDate: "2024-10-07", isRestDay: !0 },
// 2024年调班工作日
{ name: "春节调班", startDate: "2024-02-04", endDate: "2024-02-04", isRestDay: !1 },
{ name: "春节调班", startDate: "2024-02-18", endDate: "2024-02-18", isRestDay: !1 },
{ name: "清明调班", startDate: "2024-04-07", endDate: "2024-04-07", isRestDay: !1 },
{ name: "劳动节调班", startDate: "2024-04-28", endDate: "2024-04-28", isRestDay: !1 },
{ name: "劳动节调班", startDate: "2024-05-11", endDate: "2024-05-11", isRestDay: !1 },
{ name: "中秋调班", startDate: "2024-09-14", endDate: "2024-09-14", isRestDay: !1 },
{ name: "国庆调班", startDate: "2024-09-29", endDate: "2024-09-29", isRestDay: !1 },
{ name: "国庆调班", startDate: "2024-10-12", endDate: "2024-10-12", isRestDay: !1 },
// 2025年节假日
{ name: "元旦", startDate: "2025-01-01", endDate: "2025-01-01", isRestDay: !0 },
{ name: "春节", startDate: "2025-01-28", endDate: "2025-02-04", isRestDay: !0 },
{ name: "清明节", startDate: "2025-04-04", endDate: "2025-04-06", isRestDay: !0 },
{ name: "劳动节", startDate: "2025-05-01", endDate: "2025-05-05", isRestDay: !0 },
{ name: "端午节", startDate: "2025-05-31", endDate: "2025-06-02", isRestDay: !0 },
{ name: "中秋节、国庆节", startDate: "2025-10-01", endDate: "2025-10-08", isRestDay: !0 },
// 2025年调班工作日
{ name: "春节调班", startDate: "2025-01-26", endDate: "2025-01-26", isRestDay: !1 },
{ name: "春节调班", startDate: "2025-02-08", endDate: "2025-02-08", isRestDay: !1 },
{ name: "劳动节调班", startDate: "2025-04-27", endDate: "2025-04-27", isRestDay: !1 },
{ name: "国庆、中秋调班", startDate: "2025-09-28", endDate: "2025-09-28", isRestDay: !1 },
{ name: "国庆、中秋调班", startDate: "2025-10-11", endDate: "2025-10-11", isRestDay: !1 }
];
function Oe(e, a, n) {
const i = `${e.getFullYear()}-${(e.getMonth() + 1).toString().padStart(2, "0")}-${e.getDate().toString().padStart(2, "0")}`;
return i >= a && i <= n;
}
function Ne() {
try {
const e = localStorage.getItem("holidayPeriods");
if (e)
return JSON.parse(e);
} catch (e) {
console.error("Failed to get holiday periods from cache:", e);
}
return Ee;
}
function G(e) {
e.getFullYear();
const a = e.getMonth() + 1, n = e.getDate(), i = e.getDay(), l = i === 0 || i === 6;
`${a.toString().padStart(2, "0")}${n.toString().padStart(2, "0")}`;
const s = J(e), t = !!(s.lunarFestival || s.solarFestival || s.solarTerm), d = Ne().find((h) => Oe(e, h.startDate, h.endDate));
return d ? d.name.includes("调班") ? {
name: d.name,
isHoliday: !0,
isRestDay: d.isRestDay,
isHolidayPeriod: !0
} : {
name: "",
// 返回空字符串
isHoliday: !0,
// 显式设置isHoliday为true
isRestDay: d.isRestDay,
isHolidayPeriod: !0
} : t ? {
name: s.lunarFestival || s.solarFestival || s.solarTerm,
isHoliday: !0,
isRestDay: l,
isHolidayPeriod: !1
} : {
isHoliday: !1,
isRestDay: l,
isHolidayPeriod: !1
};
}
function U(e, a = "YYYY-MM-DD") {
if (!e || !(e instanceof Date) || isNaN(e.getTime()))
return console.warn("Invalid date provided to formatDate"), "";
const n = e.getFullYear(), i = e.getMonth() + 1, l = e.getDate(), s = e.getHours(), t = e.getMinutes(), r = e.getSeconds();
return a.replace(/YYYY/g, n.toString()).replace(/YY/g, (n % 100).toString().padStart(2, "0")).replace(/MM/g, i.toString().padStart(2, "0")).replace(/M/g, i.toString()).replace(/DD/g, l.toString().padStart(2, "0")).replace(/D/g, l.toString()).replace(/HH/g, s.toString().padStart(2, "0")).replace(/H/g, s.toString()).replace(/mm/g, t.toString().padStart(2, "0")).replace(/m/g, t.toString()).replace(/ss/g, r.toString().padStart(2, "0")).replace(/s/g, r.toString());
}
function Y(e, a) {
return !e || !a || !(e instanceof Date) || !(a instanceof Date) || isNaN(e.getTime()) || isNaN(a.getTime()) ? !1 : e.getFullYear() === a.getFullYear() && e.getMonth() === a.getMonth() && e.getDate() === a.getDate();
}
function ae(e, a, n) {
if (!e || !a || !n || !(e instanceof Date) || !(a instanceof Date) || !(n instanceof Date) || isNaN(e.getTime()) || isNaN(a.getTime()) || isNaN(n.getTime()))
return !1;
const i = new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime(), l = new Date(a.getFullYear(), a.getMonth(), a.getDate()).getTime(), s = new Date(n.getFullYear(), n.getMonth(), n.getDate()).getTime();
return i >= l && i <= s;
}
function Le(e, a) {
return new Date(e, a, 1);
}
function ce(e, a) {
return new Date(e, a + 1, 0).getDate();
}
function Ae(e = 0, a = !0) {
const i = [...a ? ["日", "一", "二", "三", "四", "五", "六"] : ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]];
for (let l = 0; l < e; l++)
i.push(i.shift());
return i;
}
function Ve(e, a = {}) {
if (!e || !(e instanceof Date) || isNaN(e.getTime()))
return console.warn("Invalid date provided to getDayInfo"), {};
const {
selectedDate: n = null,
priceData: i = {},
checkInData: l = {},
disabledDate: s = null
} = a, t = /* @__PURE__ */ new Date(), r = U(e, "YYYY-MM-DD"), d = J(e), h = G(e);
return {
date: e,
day: e.getDate(),
month: e.getMonth(),
year: e.getFullYear(),
isCurrentMonth: !0,
// 默认为当前月
isToday: Y(e, t),
isSelected: n ? Y(e, n) : !1,
isInRange: !1,
// 默认不在范围内
isRangeStart: !1,
isRangeEnd: !1,
isWeekend: e.getDay() === 0 || e.getDay() === 6,
isHoliday: h.isHoliday !== void 0 ? h.isHoliday : !!h.name,
isRestDay: !!h.isRestDay,
isHolidayPeriod: !!h.isHolidayPeriod,
isCheckedIn: !!l[r],
isDisabled: s ? s(e) : !1,
price: i[r],
lunarDay: d == null ? void 0 : d.lunarDay,
lunarMonth: d == null ? void 0 : d.lunarMonth,
lunarYear: d == null ? void 0 : d.lunarYear,
lunarFestival: d == null ? void 0 : d.lunarFestival,
solarFestival: d == null ? void 0 : d.solarFestival,
solarTerm: d == null ? void 0 : d.solarTerm
};
}
function fe(e, a, n = {}) {
const {
firstDayOfWeek: i = 0,
selectedDate: l = null,
rangeStart: s = null,
rangeEnd: t = null,
priceData: r = {},
checkInData: d = {},
disabledDate: h = null
} = n, L = /* @__PURE__ */ new Date(), P = Le(e, a), E = ce(e, a);
let S = P.getDay() - i;
S < 0 && (S += 7);
const $ = Math.ceil((E + S) / 7) * 7 - E - S, m = a === 0 ? 11 : a - 1, W = a === 0 ? e - 1 : e, C = ce(W, m), F = a === 11 ? 0 : a + 1, b = a === 11 ? e + 1 : e, v = [];
for (let _ = 0; _ < S; _++) {
const f = C - S + _ + 1, p = new Date(W, m, f), D = U(p, "YYYY-MM-DD"), y = J(p), z = G(p);
v.push({
date: p,
day: f,
month: m,
year: W,
isCurrentMonth: !1,
isToday: Y(p, L),
isSelected: l ? Y(p, l) : !1,
isInRange: s && t ? ae(p, s, t) : !1,
isRangeStart: s ? Y(p, s) : !1,
isRangeEnd: t ? Y(p, t) : !1,
isWeekend: p.getDay() === 0 || p.getDay() === 6,
isHoliday: z.isHoliday !== void 0 ? z.isHoliday : !!z.name,
isRestDay: !!z.isRestDay,
isHolidayPeriod: !!z.isHolidayPeriod,
isCheckedIn: !!d[D],
isDisabled: h ? h(p) : !1,
price: r[D],
lunarDay: y == null ? void 0 : y.lunarDay,
lunarMonth: y == null ? void 0 : y.lunarMonth,
lunarYear: y == null ? void 0 : y.lunarYear,
lunarFestival: y == null ? void 0 : y.lunarFestival,
solarFestival: y == null ? void 0 : y.solarFestival,
solarTerm: y == null ? void 0 : y.solarTerm
});
}
for (let _ = 1; _ <= E; _++) {
const f = new Date(e, a, _), p = U(f, "YYYY-MM-DD"), D = J(f), y = G(f);
v.push({
date: f,
day: _,
month: a,
year: e,
isCurrentMonth: !0,
isToday: Y(f, L),
isSelected: l ? Y(f, l) : !1,
isInRange: s && t ? ae(f, s, t) : !1,
isRangeStart: s ? Y(f, s) : !1,
isRangeEnd: t ? Y(f, t) : !1,
isWeekend: f.getDay() === 0 || f.getDay() === 6,
isHoliday: y.isHoliday !== void 0 ? y.isHoliday : !!y.name,
isRestDay: !!y.isRestDay,
isHolidayPeriod: !!y.isHolidayPeriod,
isCheckedIn: !!d[p],
isDisabled: h ? h(f) : !1,
price: r[p],
lunarDay: D == null ? void 0 : D.lunarDay,
lunarMonth: D == null ? void 0 : D.lunarMonth,
lunarYear: D == null ? void 0 : D.lunarYear,
lunarFestival: D == null ? void 0 : D.lunarFestival,
solarFestival: D == null ? void 0 : D.solarFestival,
solarTerm: D == null ? void 0 : D.solarTerm
});
}
for (let _ = 1; _ <= $; _++) {
const f = new Date(b, F, _), p = U(f, "YYYY-MM-DD"), D = J(f), y = G(f);
v.push({
date: f,
day: _,
month: F,
year: b,
isCurrentMonth: !1,
isToday: Y(f, L),
isSelected: l ? Y(f, l) : !1,
isInRange: s && t ? ae(f, s, t) : !1,
isRangeStart: s ? Y(f, s) : !1,
isRangeEnd: t ? Y(f, t) : !1,
isWeekend: f.getDay() === 0 || f.getDay() === 6,
isHoliday: y.isHoliday !== void 0 ? y.isHoliday : !!y.name,
isRestDay: !!y.isRestDay,
isHolidayPeriod: !!y.isHolidayPeriod,
isCheckedIn: !!d[p],
isDisabled: h ? h(f) : !1,
price: r[p],
lunarDay: D == null ? void 0 : D.lunarDay,
lunarMonth: D == null ? void 0 : D.lunarMonth,
lunarYear: D == null ? void 0 : D.lunarYear,
lunarFestival: D == null ? void 0 : D.lunarFestival,
solarFestival: D == null ? void 0 : D.solarFestival,
solarTerm: D == null ? void 0 : D.solarTerm
});
}
return v;
}
function Be(e, a = {}) {
if (!e || !(e instanceof Date) || isNaN(e.getTime()))
return console.warn("Invalid date provided to getWeekDays"), [];
const {
firstDayOfWeek: n = 0,
selectedDate: i = null,
rangeStart: l = null,
rangeEnd: s = null,
priceData: t = {},
checkInData: r = {},
disabledDate: d = null
} = a, h = /* @__PURE__ */ new Date(), P = e.getDay() - n, E = P < 0 ? P + 7 : P, S = new Date(e);
S.setDate(e.getDate() - E);
const M = [];
for (let $ = 0; $ < 7; $++) {
const m = new Date(S);
m.setDate(S.getDate() + $);
const W = m.getFullYear(), C = m.getMonth(), F = m.getDate(), b = U(m, "YYYY-MM-DD"), v = J(m), _ = G(m);
M.push({
date: m,
day: F,
month: C,
year: W,
isCurrentMonth: m.getMonth() === e.getMonth(),
isToday: Y(m, h),
isSelected: i ? Y(m, i) : !1,
isInRange: l && s ? ae(m, l, s) : !1,
isRangeStart: l ? Y(m, l) : !1,
isRangeEnd: s ? Y(m, s) : !1,
isWeekend: m.getDay() === 0 || m.getDay() === 6,
isHoliday: _.isHoliday !== void 0 ? _.isHoliday : !!_.name,
isRestDay: !!_.isRestDay,
isHolidayPeriod: !!_.isHolidayPeriod,
isCheckedIn: !!r[b],
isDisabled: d ? d(m) : !1,
price: t[b],
lunarDay: v == null ? void 0 : v.lunarDay,
lunarMonth: v == null ? void 0 : v.lunarMonth,
lunarYear: v == null ? void 0 : v.lunarYear,
lunarFestival: v == null ? void 0 : v.lunarFestival,
solarFestival: v == null ? void 0 : v.solarFestival,
solarTerm: v == null ? void 0 : v.solarTerm
});
}
return M;
}
const Ie = I({
name: "CalendarHeader",
props: {
currentYear: {
type: Number,
required: !0
},
currentMonth: {
type: Number,
required: !0
},
mode: {
type: String,
default: "month"
},
showYearPicker: {
type: Boolean,
default: !1
},
showMonthPicker: {
type: Boolean,
default: !1
}
},
emits: ["prev", "next", "today", "toggle-year-picker", "toggle-month-picker"],
setup(e, { emit: a }) {
return {
handlePrev: () => {
a("prev");
},
handleNext: () => {
a("next");
},
goToToday: () => {
a("today");
},
toggleYearPicker: (r) => {
r.stopPropagation(), a("toggle-year-picker");
},
toggleMonthPicker: (r) => {
r.stopPropagation(), a("toggle-month-picker");
}
};
}
});
const j = (e, a) => {
const n = e.__vccOpts || e;
for (const [i, l] of a)
n[i] = l;
return n;
}, je = { class: "uni-calendar__header" }, qe = { class: "uni-calendar__header-wrapper" }, Xe = { class: "uni-calendar__header-title" }, ze = { class: "uni-calendar__header-btns" };
function Ue(e, a, n, i, l, s) {
return u(), c("div", je, [
k("div", qe, [
k("div", Xe, [
k("div", {
class: "uni-calendar__header-btn",
onClick: a[0] || (a[0] = (...t) => e.toggleYearPicker && e.toggleYearPicker(...t))
}, [
de(T(e.currentYear) + "年 ", 1),
k("div", {
class: H(["uni-calendar__header-btn-icon", { "uni-calendar__header-btn-icon--active": e.showYearPicker }])
}, null, 2)
]),
k("div", {
class: "uni-calendar__header-btn",
onClick: a[1] || (a[1] = (...t) => e.toggleMonthPicker && e.toggleMonthPicker(...t))
}, [
de(T(e.currentMonth + 1) + "月 ", 1),
k("div", {
class: H(["uni-calendar__header-btn-icon", { "uni-calendar__header-btn-icon--active": e.showMonthPicker }])
}, null, 2)
])
]),
k("div", ze, [
k("div", {
class: "uni-calendar__header-btn-arrow",
onClick: a[2] || (a[2] = (...t) => e.handlePrev && e.handlePrev(...t))
}, a[5] || (a[5] = [
k("div", { class: "uni-calendar__header-btn-arrow-icon uni-calendar__header-btn-arrow-icon--left" }, null, -1)
])),
k("div", {
class: "uni-calendar__header-btn-today",
onClick: a[3] || (a[3] = (...t) => e.goToToday && e.goToToday(...t))
}, "今天"),
k("div", {
class: "uni-calendar__header-btn-arrow",
onClick: a[4] || (a[4] = (...t) => e.handleNext && e.handleNext(...t))
}, a[6] || (a[6] = [
k("div", { class: "uni-calendar__header-btn-arrow-icon uni-calendar__header-btn-arrow-icon--right" }, null, -1)
]))
])
])
]);
}
const Je = /* @__PURE__ */ j(Ie, [["render", Ue]]), Ke = I({
name: "YearPicker",
props: {
currentYear: {
type: Number,
required: !0
},
range: {
type: [Number, Array],
default: 10
}
},
emits: ["year-select"],
setup(e, { emit: a }) {
return {
yearRange: R(() => {
if (Array.isArray(e.range))
return e.range;
const l = e.currentYear, s = [];
for (let t = l - e.range; t <= l + e.range; t++)
s.push(t);
return s;
}),
handleYearSelect: (l) => {
a("year-select", l);
}
};
}
});
const Ze = ["onClick"];
function Ge(e, a, n, i, l, s) {
return u(), c("div", {
class: "uni-calendar__picker uni-calendar__year-picker",
onClick: a[0] || (a[0] = he(() => {
}, ["stop"]))
}, [
(u(!0), c(V, null, B(e.yearRange, (t) => (u(), c("div", {
key: t,
class: H(["uni-calendar__picker-item", { "uni-calendar__picker-item--active": t === e.currentYear }]),
onClick: (r) => e.handleYearSelect(t)
}, T(t), 11, Ze))), 128))
]);
}
const Qe = /* @__PURE__ */ j(Ke, [["render", Ge]]), xe = I({
name: "MonthPicker",
props: {
currentMonth: {
type: Number,
required: !0
}
},
emits: ["month-select"],
setup(e, { emit: a }) {
return {
handleMonthSelect: (i) => {
a("month-select", i);
}
};
}
});
const ea = ["onClick"];
function aa(e, a, n, i, l, s) {
return u(), c("div", {
class: "uni-calendar__picker uni-calendar__month-picker",
onClick: a[0] || (a[0] = he(() => {
}, ["stop"]))
}, [
(u(), c(V, null, B(12, (t, r) => k("div", {
key: r,
class: H(["uni-calendar__picker-item", { "uni-calendar__picker-item--active": r === e.currentMonth }]),
onClick: (d) => e.handleMonthSelect(r)
}, T(t) + "月 ", 11, ea)), 64))
]);
}
const ta = /* @__PURE__ */ j(xe, [["render", aa]]), na = I({
name: "WeekHeader",
props: {
firstDayOfWeek: {
type: Number,
default: 0,
validator: (e) => [0, 1].includes(e)
},
abbreviated: {
type: Boolean,
default: !1
}
},
setup(e) {
return {
weekDays: R(() => {
const n = e.firstDayOfWeek === 0 ? ["日", "一", "二", "三", "四", "五", "六"] : ["一", "二", "三", "四", "五", "六", "日"];
return e.abbreviated ? n.map((i) => i.charAt(0)) : n;
})
};
}
});
const sa = { class: "uni-calendar__week-header" };
function ra(e, a, n, i, l, s) {
return u(), c("div", sa, [
(u(!0), c(V, null, B(e.weekDays, (t, r) => (u(), c("div", {
key: r,
class: H(["uni-calendar__week-day", { "uni-calendar__week-day--weekend": r === 0 || r === 6 }])
}, T(t), 3))), 128))
]);
}
const ge = /* @__PURE__ */ j(na, [["render", ra]]), la = I({
name: "DayCell",
props: {
day: {
type: Object,
required: !0
},
showLunar: {
type: Boolean,
default: !1
},
showPrice: {
type: Boolean,
default: !1
},
disabledDate: {
type: Function,
default: () => null
},
highlightWeekend: {
type: Boolean,
default: !0
}
},
emits: {
"day-click": (e, a) => !0
},
setup(e, { emit: a }) {
return {
dayClass: R(() => {
const { day: t } = e;
return {
"uni-calendar__day--not-current-month": !t.isCurrentMonth,
"uni-calendar__day--today": t.isToday,
"uni-calendar__day--selected": t.isSelected,
"uni-calendar__day--in-range": t.isInRange,
"uni-calendar__day--range-start": t.isRangeStart,
"uni-calendar__day--range-end": t.isRangeEnd,
"uni-calendar__day--weekend": e.highlightWeekend && t.isWeekend && t.isCurrentMonth,
"uni-calendar__day--holiday": t.isHoliday && t.isCurrentMonth,
"uni-calendar__day--rest-day": t.isHoliday && t.isRestDay && t.isCurrentMonth,
"uni-calendar__day--work-day": t.isHoliday && !t.isRestDay && t.isCurrentMonth,
"uni-calendar__day--checked-in": t.isCheckedIn,
"uni-calendar__day--disabled": e.disabledDate && e.disabledDate(t.date),
"uni-calendar__day--lunar-first-day": t.lunarDay === "初一" && t.isCurrentMonth,
"uni-calendar__day--solar-term": t.solarTerm && t.isCurrentMonth
};
}),
handleClick: (t, r) => {
e.disabledDate && e.disabledDate(r.date) || a("day-click", t, r);
},
handleTouchStart: (t) => {
if (e.disabledDate && e.disabledDate(e.day.date))
return;
const r = t.currentTarget;
r && (r.classList.add("uni-calendar__day--touch-active"), t.type === "touchstart" && t.preventDefault());
},
handleTouchEnd: (t) => {
if (e.disabledDate && e.disabledDate(e.day.date))
return;
const r = t.currentTarget;
r && r.classList.remove("uni-calendar__day--touch-active");
}
};
}
});
const ia = { class: "uni-calendar__day-content" }, oa = { class: "uni-calendar__day-text" }, da = {
key: 0,
class: "uni-calendar__day-lunar"
}, ua = { key: 0 }, ca = { key: 1 }, ha = {
key: 1,
class: "uni-calendar__day-price"
}, ya = {
key: 2,
class: "uni-calendar__day-checked-in"
}, Da = {
key: 3,
class: "uni-calendar__day-holiday"
}, fa = {
key: 0,
class: "uni-calendar__day-holiday-tag"
}, ga = {
key: 1,
class: "uni-calendar__day-holiday-tag"
};
function va(e, a, n, i, l, s) {
return u(), c("div", {
class: H([e.dayClass, "uni-calendar__day-wrapper"]),
onClick: a[0] || (a[0] = (t) => e.handleClick(t, e.day)),
onTouchstart: a[1] || (a[1] = (...t) => e.handleTouchStart && e.handleTouchStart(...t)),
onTouchend: a[2] || (a[2] = (...t) => e.handleTouchEnd && e.handleTouchEnd(...t)),
onTouchcancel: a[3] || (a[3] = (...t) => e.handleTouchEnd && e.handleTouchEnd(...t)),
onMousedown: a[4] || (a[4] = (...t) => e.handleTouchStart && e.handleTouchStart(...t)),
onMouseup: a[5] || (a[5] = (...t) => e.handleTouchEnd && e.handleTouchEnd(...t)),
onMouseleave: a[6] || (a[6] = (...t) => e.handleTouchEnd && e.handleTouchEnd(...t))
}, [
k("div", ia, [
k("div", oa, T(e.day.day), 1),
e.showLunar && e.day.lunarDay ? (u(), c("div", da, [
e.day.lunarDay === "初一" ? (u(), c("span", ua, T(e.day.lunarFestival || e.day.solarFestival || e.day.solarTerm || e.day.lunarMonth || e.day.lunarDay), 1)) : (u(), c("span", ca, T(e.day.lunarFestival || e.day.solarFestival || e.day.solarTerm || e.day.lunarDay), 1))
])) : N("", !0),
e.showPrice && e.day.price !== void 0 ? (u(), c("div", ha, " ¥" + T(e.day.price), 1)) : N("", !0),
e.day.isCheckedIn ? (u(), c("div", ya)) : N("", !0),
e.day.isHoliday ? (u(), c("div", Da, [
e.day.isHoliday && e.day.isRestDay && e.day.isHolidayPeriod ? (u(), c("div", fa, "休")) : N("", !0),
e.day.isHoliday && !e.day.isRestDay && e.day.isHolidayPeriod ? (u(), c("div", ga, "班")) : N("", !0)
])) : N("", !0)
])
], 34);
}
const oe = /* @__PURE__ */ j(la, [["render", va]]), ka = I({
name: "MonthView",
components: {
WeekHeader: ge,
DayCell: oe
},
props: {
year: {
type: Number,
required: !0
},
month: {
type: Number,
required: !0
},
selectedDate: {
type: Date,
default: null
},
rangeStart: {
type: Date,
default: null
},
rangeEnd: {
type: Date,
default: null
},
firstDayOfWeek: {
type: Number,
default: 0,
validator: (e) => e === 0 || e === 1
},
showLunar: {
type: Boolean,
default: !1
},
showHoliday: {
type: Boolean,
default: !1
},
showPrice: {
type: Boolean,
default: !1
},
priceData: {
type: Object,
default: () => ({})
},
checkInData: {
type: Object,
default: () => ({})
},
disabledDate: {
type: Function,
default: () => null
},
highlightWeekend: {
type: Boolean,
default: !0
},
rangeMode: {
type: Boolean,
default: !1
},
allowClickOtherMonthDay: {
type: Boolean,
default: !1
}
},
emits: {
"day-click": (e, a) => !0
},
setup(e, { emit: a }) {
return {
monthDays: R(() => fe(e.year, e.month, {
firstDayOfWeek: e.firstDayOfWeek,
selectedDate: e.selectedDate,
rangeStart: e.rangeStart,
rangeEnd: e.rangeEnd,
priceData: e.priceData,
checkInData: e.checkInData,
disabledDate: e.disabledDate
})),
getDayClass: (s) => {
const t = ["uni-calendar__day"];
return s.isCurrentMonth || t.push("uni-calendar__day--not-current-month"), s.isToday && t.push("uni-calendar__day--today"), s.isSelected && t.push("uni-calendar__day--selected"), s.isInRange && t.push("uni-calendar__day--in-range"), e.rangeMode && e.rangeStart && Y(s.date, e.rangeStart) && t.push("uni-calendar__day--range-start"), e.rangeMode && e.rangeEnd && Y(s.date, e.rangeEnd) && t.push("uni-calendar__day--range-end"), e.highlightWeekend && (s.day === 0 || s.day === 6) && t.push("uni-calendar__day--weekend"), s.isDisabled && t.push("uni-calendar__day--disabled"), t.join(" ");
},
handleDayClick: (s, t) => {
const r = t || s;
!r.isCurrentMonth && !e.allowClickOtherMonthDay || r.isDisabled || (t ? a("day-click", s, r) : a("day-click", new MouseEvent("click"), r));
}
};
}
});
const ma = { class: "uni-calendar__month-view" }, wa = { class: "uni-calendar__month-days" };
function _a(e, a, n, i, l, s) {
const t = A("WeekHeader"), r = A("DayCell");
return u(), c("div", ma, [
X(t, {
"first-day-of-week": e.firstDayOfWeek
}, null, 8, ["first-day-of-week"]),
k("div", wa, [
(u(!0), c(V, null, B(e.monthDays, (d, h) => (u(), c("div", {
key: h,
class: H(e.getDayClass(d))
}, [
X(r, {
day: d,
"show-lunar": e.showLunar,
"show-holiday": e.showHoliday,
"show-price": e.showPrice,
"disabled-date": e.disabledDate,
"highlight-weekend": e.highlightWeekend,
onDayClick: e.handleDayClick
}, null, 8, ["day", "show-lunar", "show-holiday", "show-price", "disabled-date", "highlight-weekend", "onDayClick"])
], 2))), 128))
])
]);
}
const pa = /* @__PURE__ */ j(ka, [["render", _a]]), Ma = I({
name: "WeekView",
components: {
WeekHeader: ge,
DayCell: oe
},
props: {
date: {
type: Date,
required: !0
},
selectedDate: {
type: Date,
default: null
},
rangeStart: {
type: Date,
default: null
},
rangeEnd: {
type: Date,
default: null
},
firstDayOfWeek: {
type: Number,
default: 0,
validator: (e) => [0, 1].includes(e)
},
showLunar: {
type: Boolean,
default: !1
},
showHoliday: {
type: Boolean,
default: !1
},
showPrice: {
type: Boolean,
default: !1
},
priceData: {
type: Object,
default: () => ({})
},
checkInData: {
type: Object,
default: () => ({})
},
disabledDate: {
type: Function,
default: null
},
highlightWeekend: {
type: Boolean,
default: !0
},
rangeMode: {
type: Boolean,
default: !1
},
allowClickOtherMonthDay: {
type: Boolean,
default: !1
}
},
emits: ["day-click"],
setup(e, { emit: a }) {
return {
weekDays: R(() => Be(e.date, {
firstDayOfWeek: e.firstDayOfWeek,
selectedDate: e.selectedDate,
rangeStart: e.rangeStart,
rangeEnd: e.rangeEnd,
priceData: e.priceData,
checkInData: e.checkInData,
disabledDate: e.disabledDate
})),
getDayClass: (s) => {
const t = ["uni-calendar__day"];
return s.isCurrentMonth || t.push("uni-calendar__day--not-current-month"), s.isToday && t.push("uni-calendar__day--today"), s.isSelected && t.push("uni-calendar__day--selected"), s.isInRange && t.push("uni-calendar__day--in-range"), e.rangeMode && e.rangeStart && Y(s.date, e.rangeStart) && t.push("uni-calendar__day--range-start"), e.rangeMode && e.rangeEnd && Y(s.date, e.rangeEnd) && t.push("uni-calendar__day--range-end"), e.highlightWeekend && (s.day === 0 || s.day === 6) && t.push("uni-calendar__day--weekend"), s.isDisabled && t.push("uni-calendar__day--disabled"), t.join(" ");
},
handleDayClick: (s, t) => {
const r = t || s;
!r.isCurrentMonth && !e.allowClickOtherMonthDay || r.isDisabled || (t ? a("day-click", s, r) : a("day-click", new MouseEvent("click"), r));
}
};
}
});
const Ca = { class: "uni-calendar__week-view" }, Sa = { class: "uni-calendar__week-days" };
function $a(e, a, n, i, l, s) {
const t = A("WeekHeader"), r = A("DayCell");
return u(), c("div", Ca, [
X(t, {
"first-day-of-week": e.firstDayOfWeek
}, null, 8, ["first-day-of-week"]),
k("div", Sa, [
(u(!0), c(V, null, B(e.weekDays, (d, h) => (u(), c("div", {
key: h,
class: H(e.getDayClass(d))
}, [
X(r, {
day: d,
"show-lunar": e.showLunar,
"show-holiday": e.showHoliday,
"show-price": e.showPrice,
"disabled-date": e.disabledDate,
"highlight-weekend": e.highlightWeekend,
onDayClick: e.handleDayClick
}, null, 8, ["day", "show-lunar", "show-holiday", "show-price", "disabled-date", "highlight-weekend", "onDayClick"])
], 2))), 128))
])
]);
}
const ba = /* @__PURE__ */ j(Ma, [["render", $a]]), Ya = I({
name: "DayDetail",
props: {
date: {
type: Date,
required: !0
},
dayInfo: {
type: Object,
required: !0
},
showLunar: {
type: Boolean,
default: !1
},
showPrice: {
type: Boolean,
default: !1
}
},
emits: ["check-in"],
setup(e, { emit: a }) {
return {
formattedDate: R(() => U(e.date, "YYYY年MM月DD日")),
handleCheckIn: () => {
a("check-in", e.date);
}
};
}
});
const Ta = { class: "uni-calendar__day-detail" }, Ra = { class: "uni-calendar__day-detail-header" }, Pa = { class: "uni-calendar__day-detail-date" }, Fa = {
key: 0,
class: "uni-calendar__day-detail-lunar"
}, Ha = { class: "uni-calendar__day-detail-content" }, Wa = {
key: 0,
class: "uni-calendar__day-detail-festival"
}, Ea = { class: "uni-calendar__day-detail-festival-item" }, Oa = {
key: 1,
class: "uni-calendar__day-detail-price"
}, Na = { class: "uni-calendar__day-detail-price-value" }, La = { class: "uni-calendar__day-detail-check-in" }, Aa = { class: "uni-calendar__day-detail-check-in-status" };
function Va(e, a, n, i, l, s) {
return u(), c("div", Ta, [
k("div", Ra, [
k("div", Pa, T(e.formattedDate), 1),
e.showLunar && e.dayInfo.lunarDay ? (u(), c("div", Fa, T(e.dayInfo.lunarYear) + " " + T(e.dayInfo.lunarMonth) + " " + T(e.dayInfo.lunarDay), 1)) : N("", !0)
]),
k("div", Ha, [
e.dayInfo.lunarFestival || e.dayInfo.solarFestival || e.dayInfo.solarTerm ? (u(), c("div", Wa, [
k("div", Ea, T(e.dayInfo.lunarFestival || e.dayInfo.solarFestival || (e.dayInfo.solarTerm ? e.dayInfo.solarTerm + "节气" : "")), 1)
])) : N("", !0),
e.showPrice && e.dayInfo.price !== void 0 ? (u(), c("div", Oa, [
a[1] || (a[1] = k("div", { class: "uni-calendar__day-detail-price-label" }, "价格:", -1)),
k("div", Na, "¥" + T(e.dayInfo.price), 1)
])) : N("", !0),
k("div", La, [
k("div", Aa, T(e.dayInfo.isCheckedIn ? "已打卡" : "未打卡"), 1),
e.dayInfo.isCheckedIn ? N("", !0) : (u(), c("div", {
key: 0,
class: "uni-calendar__day-detail-check-in-btn",
onClick: a[0] || (a[0] = (...t) => e.handleCheckIn && e.handleCheckIn(...t))
}, " 打卡 "))
])
])
]);
}
const Ba = /* @__PURE__ */ j(Ya, [["render", Va]]), Ia = I({
name: "DayView",
components: {
DayCell: oe,
DayDetail: Ba
},
props: {
date: {
type: Date,
required: !0
},
selectedDate: {
type: Date,
default: null
},
firstDayOfWeek: {
type: Number,
default: 0,
validator: (e) => e >= 0 && e <= 6
},
showLunar: {
type: Boolean,
default: !1
},
showHoliday: {
type: Boolean,
default: !1
},
showPrice: {
type: Boolean,
default: !1
},
priceData: {
type: Object,
default: () => ({})
},
checkInData: {
type: Object,
default: () => ({})
},
disabledDate: {
type: Function,
default: null
},
highlightWeekend: {
type: Boolean,
default: !0
},
allowClickOtherMonthDay: {
type: Boolean,
default: !1
}
},
emits: ["day-click", "check-in"],
setup(e, { emit: a }) {
const n = R(() => Ae(e.firstDayOfWeek)), i = R(() => Ve(e.date, {
selectedDate: e.selectedDate,
priceData: e.priceData,
checkInData: e.checkInData,
disabledDate: e.disabledDate
}));
return {
weekDays: n,
dayInfo: i,
getDayClass: (r) => {
const d = ["uni-calendar__day-view-day-cell"];
return r.isToday && d.push("uni-calendar__day-view-day-cell--today"), r.isSelected && d.push("uni-calendar__day-view-day-cell--selected"), e.highlightWeekend && (r.day === 0 || r.day === 6) && d.push("uni-calendar__day-view-day-cell--weekend"), r.isDisabled && d.push("uni-calendar__day-view-day-cell--disabled"), d.join(" ");
},
handleDayClick: (r, d) => {
const h = d || r;
!h.isCurrentMonth && !e.allowClickOtherMonthDay || h.isDisabled || (d ? a("day-click", r, h) : a("day-click", new MouseEvent("click"), h));
},
handleCheckIn: (r) => {
a("check-in", r);
}
};
}
});
const ja = { class: "uni-calendar__day-view" }, qa = { class: "uni-calendar__day-view-header" }, Xa = { class: "uni-calendar__day-view-content" }, za = { class: "uni-calendar__day-view-day" };
function Ua(e, a, n, i, l, s) {
const t = A("DayCell"), r = A("DayDetail");
return u(), c("div", ja, [
k("div", qa, [
(u(!0), c(V, null, B(e.weekDays, (d, h) => (u(), c("div", {
key: h,
class: H({
"uni-calendar__day-view-header-item": !0,
"uni-calendar__day-view-header-item--weekend": e.highlightWeekend && (h === 0 || h === 6)
})
}, T(d), 3))), 128))
]),
k("div", Xa, [
k("div", za, [
k("div", {
class: H(e.getDayClass(e.dayInfo))
}, [
X(t, {
day: e.dayInfo,
"show-lunar": e.showLunar,
"show-holiday": e.showHoliday,
"show-price": e.showPrice,
"disabled-date": e.disabledDate,
"highlight-weekend": e.highlightWeekend,
onDayClick: e.handleDayClick
}, null, 8, ["day", "show-lunar", "show-holiday", "show-price", "disabled-date", "highlight-weekend", "onDayClick"])
], 2)
]),
e.dayInfo ? (u(), ee(r, {
key: 0,
date: e.date,
"day-info": e.dayInfo,
"show-lunar": e.showLunar,
"show-price": e.showPrice,
onCheckIn: e.handleCheckIn
}, null, 8, ["date", "day-info", "show-lunar", "show-price", "onCheckIn"])) : N("", !0)
])
]);
}
const Ja = /* @__PURE__ */ j(Ia, [["render", Ua]]), Ka = I({
name: "YearView",
props: {
year: {
type: Number,
required: !0
},
selectedMonth: {
type: Number,
default: -1
}
},
emits: ["month-click"],
setup(e, { emit: a }) {
return {
handleMonthClick: (i) => {
a("month-click", { year: e.year, month: i });
}
};
}
});
const Za = { class: "uni-calendar__year-view" }, Ga = { class: "uni-calendar__year-months" }, Qa = ["onClick"];
function xa(e, a, n, i, l, s) {
return u(), c("div", Za, [
k("div", Ga, [
(u(), c(V, null, B(12, (t) => k("div", {
key: t,
class: H(["uni-calendar__year-month", {
"uni-calendar__year-month--selected": t - 1 === e.selectedMonth
}]),
onClick: (r) => e.handleMonthClick(t - 1)
}, T(t) + "月 ", 11, Qa)), 64))
])
]);
}
const et = /* @__PURE__ */ j(Ka, [["render", xa]]), at = I({
name: "CalendarSwiper",
emits: ["swipe-left", "swipe-right"],
setup(e, { emit: a }) {
const n = O(null), i = O(0), l = O(0), s = O(0), t = O(0), r = O(0), d = O(!1), h = O(null), L = (C) => {
i.value = C.touches[0].clientX, l.value = C.touches[0].clientY, d.value = !0, h.value !== null && cancelAnimationFrame(h.value);
}, P = (C) => {
if (!d.value)
return;
const b = C.touches[0].clientX - i.value;
s.value = b;
const v = window.innerWidth * 0.5;
let _ = b;
if (Math.abs(b) > v) {
const f = Math.abs(b) - v, p = 0.3;
_ = b > 0 ? v + f * p : -v - f * p;
}
t.value = r.value + _, S(), C.preventDefault();
}, E = () => {
if (!d.value)
return;
d.value = !1;
const C = t.value - r.value, F = window.innerWidth * 0.08;
C < -F ? n.value ? (n.value.style.transition = "transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)", n.value.style.transform = `translateX(${-window.innerWidth}px)`, setTimeout(() => {
a("swipe-left"), W();
}, 240)) : a("swipe-left") : C > F ? n.value ? (n.value.style.transition = "transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)", n.value.style.transform = `translateX(${window.innerWidth}px)`, setTimeout(() => {
a("swipe-right"), W();
}, 240)) : a("swipe-right") : n.value && (n.value.style.transition = "transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)", n.value.style.transform = "translateX(0)", setTimeout(() => {
n.value && (n.value.style.transition = "none");
}, 250));
}, S = () => {
n.value && (d.value && (n.value.style.transition = "none", n.value.style.willChange = "transform"), n.value.style.transform = `translateX(${t.value}px)`);
}, M = (C) => {
i.value = C.clientX, l.value = C.clientY, d.value = !0, h.value !== null && cancelAnimationFrame(h.value), document.addEventListener("mousemove", $), document.addEventListener("mouseup", m);
}, $ = (C) => {
if (!d.value)
return;
const b = C.clientX - i.value;
s.value = b;
const v = window.innerWidth * 0.5;
let _ = b;
if (Math.abs(b) > v) {
const f = Math.abs(b) - v, p = 0.3;
_ = b > 0 ? v + f * p : -v - f * p;
}
t.value = r.value + _, S(), C.preventDefault();
}, m = () => {
if (!d.value)
return;
d.value = !1;
const C = t.value - r.value, F = window.innerWidth * 0.08;
C < -F ? n.value ? (n.value.style.transition = "transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)", n.value.style.transform = `translateX(${-window.innerWidth}px)`, setTimeout(() => {
a("swipe-left"), W();
}, 240)) : a("swipe-left") : C > F ? n.value ? (n.value.style.transition = "transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)", n.value.style.transform = `translateX(${window.innerWidth}px)`, setTimeout(() => {
a("swipe-right"), W();
}, 240)) : a("swipe-right") : n.value && (n.value.style.transition = "transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)", n.value.style.transform = "translateX(0)", setTimeout(() => {
n.value && (n.value.style.transition = "none");
}, 250)), document.removeEventListener("mousemove", $), document.removeEventListener("mouseup", m);
}, W = () => {
n.value && (n.value.style.transition = "none", n.value.style.transform = "translateX(0)", t.value = 0, r.value = 0);
};
return _e(() => {
document.removeEventListener("mousemove", $), document.removeEventListener("mouseup", m), h.value !== null && cancelAnimationFrame(h.value);
}), {
swiperRef: n,
touchStart: L,
touchMove: P,
touchEnd: E,
mouseDown: M,
resetSwiper: W
};
}
});
function tt(e, a, n, i, l, s) {
return u(), c("div", {
class: "uni-calendar__swiper",
ref: "swiperRef",
onTouchstart: a[0] || (a[0] = (...t) => e.touchStart && e.touchStart(...t)),
onTouchmove: a[1] || (a[1] = (...t) => e.touchMove && e.touchMove(...t)),
onTouchend: a[2] || (a[2] = (...t) => e.touchEnd && e.touchEnd(...t)),
onMousedown: a[3] || (a[3] = (...t) => e.mouseDown && e.mouseDown(...t))
}, [
Z(e.$slots, "default")
], 544);
}
const nt = /* @__PURE__ */ j(at, [["render", tt]]), st = I({
name: "MonthMini",
props: {
year: {
type: Number,
required: !0
},
month: {
type: Number,
required: !0
},
selectedDate: {
type: Date,
default: null
},
rangeStart: {
type: Date,
default: null
},
rangeEnd: {
type: Date,
default: null
},
firstDayOfWeek: {
type: Number,
default: 0
}
},
setup(e) {
const a = R(() => (e.firstDayOfWeek === 0 ? ["日", "一", "二", "三", "四", "五", "六"] : ["一", "二", "三", "四", "五", "六", "日"]).map((s) => s.charAt(0))), n = R(() => {
const l = fe(
e.year,
e.month,
{
selectedDate: e.selectedDate,
rangeStart: e.rangeStart,
rangeEnd: e.rangeEnd,
firstDayOfWeek: e.firstDayOfWeek
}
), s = [];
for (let t = 0; t < l.length; t += 7)
s.push(l.slice(t, t + 7));
return s;
});
return {
weekDays: a,
monthDays: n,
getDayClass: (l) => l ? {
"month-mini__day--not-current-month": !l.isCurrentMonth,
"month-mini__day--today": l.isToday,
"month-mini__day--selected": l.isSelected,
"month-mini__day--in-range": l.isInRange,
"month-mini__day--range-start": l.isRangeStart,
"month-mini__day--range-end": l.isRangeEnd,
"month-mini__day--weekend": l.isWeekend
} : {}
};
}
});
const rt = { class: "month-mini" }, lt = { class: "month-mini__week-header" };
function it(e, a, n, i, l, s) {
return u(), c("div", rt, [
k("div", lt, [
(u(!0), c(V, null, B(e.weekDays, (t, r) => (u(), c("div", {
key: r,
class: H(["month-mini__week-day", { "month-mini__week-day--weekend": r === 0 || r === 6 }])
}, T(t), 3))), 128))
]),
(u(!0), c(V, null, B(e.monthDays, (t, r) => (u(), c("div", {
key: r,
class: "month-mini__week"
}, [
(u(!0), c(V, null, B(t, (d, h) => (u(), c("div", {
key: h,
class: H(["month-mini__day", e.getDayClass(d)])
}, T(d == null ? void 0 : d.day), 3))), 128))
]))), 128))
]);
}
const ot = /* @__PURE__ */ j(st, [["render", it]]), dt = I({
name: "Calendar",
components: {
CalendarHeader: Je,
YearPicker: Qe,
MonthPicker: ta,
MonthView: pa,
WeekView: ba,
DayView: Ja,
YearView: et,
CalendarSwiper: nt,
MonthMini: ot
},
props: {
modelValue: {
type: [Date, Array],
default: () => /* @__PURE__ */ new Date()
},
mode: {
type: String,
default: "month",
validator: (e) => ["year", "month", "week", "day"].includes(e)
},
allowClickOtherMonthDay: {
type: Boolean,
default: !1,
description: "是否允许点击非当月灰色格子"
},
showLunar: {
type: Boolean,
default: !1
},
showHoliday: {
type: Boolean,
default: !0
},
showPrice: {
type: Boolean,
default: !1
},
priceData: {
type: Object,
default: () => ({})
},
checkInData: {
type: Object,
default: () => ({})
},
rangeMode: {
type: Boolean,
default: !1
},
firstDayOfWeek: {
type: Number,
default: 0,
validator: (e) => e === 0 || e === 1
},
disabledDate: {
type: Function,
default: () => null
},
highlightWeekend: {
type: Boolean,
default: !0
},
autoHeight: {
type: Boolean,
default: !0
}
},
emits: {
"update:modelValue": (e) => !0,
"date-click": (e) => !0,
"range-change": (e) => !0,
"month-change": (e) => !0,
"check-in": (e) => !0
},
setup(e, { emit: a }) {
const n = O(/* @__PURE__ */ new Date()), i = R(() => n.value.getFullYear()), l = R(() => n.value.getMonth()), s = O(!1), t = O(!1), r = R(() => {
const o = i.value, g = [];
for (let w = o - 10; w <= o + 10; w++)
g.push(w);
return g;
}), d = R(() => Array.isArray(e.modelValue) ? e.modelValue[0] : e.modelValue), h = R(() => {
if (e.rangeMode && Array.isArray(e.modelValue))
return e.modelValue[0];
}), L = R(() => {
if (e.rangeMode && Array.isArray(e.modelValue))
return e.modelValue[1] || void 0;
}), P = O(1), E = O(null), S = O(null), M = O(null), $ = R(() => {
const o = n.value.getFullYear(), g = n.value.getMonth(), w = n.value.getDate();
let q = o, Q = g - 1;
Q < 0 && (q -= 1, Q = 11);
const ve = new Date(q, Q + 1, 0).getDate(), ke = Math.min(w, ve), ne = new Date(q, Q, ke), se = new Date(o, g, w);
let re = o, x = g + 1;
x > 11 && (re += 1, x = 0);
const me = new Date(re, x + 1, 0).getDate(), we = Math.min(w, me), le = new Date(re, x, we);
return [
{
date: ne,
year: ne.getFullYear(),
month: ne.getMonth()
},
{
date: se,
year: se.getFullYear(),
month: se.getMonth()
},
{
date: le,
year: le.getFullYear(),
month: le.getMonth()
}
];
}), m = R(() => {
const o = new Date(n.value);
o.setDate(o.getDate() - 7);
const g = new Date(n.valu