@wpwp/schedule-calendar 0.1.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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.sc-header{display:flex;align-items:center;justify-content:space-between;padding-bottom:12px;gap:8px}.sc-header__left{display:flex;align-items:center;gap:8px}.sc-header__title{font-size:16px;font-weight:600;color:var(--sc-text, #333);min-width:120px;text-align:center}.sc-header__right{display:flex;align-items:center;gap:8px}.sc-header__tabs{display:flex;border:1px solid var(--sc-border, #ddd);border-radius:var(--sc-radius, 8px);overflow:hidden}.sc-header__tab{padding:4px 12px;font-size:13px;border:none;background:var(--sc-bg, #fff);color:var(--sc-text-secondary, #666);cursor:pointer;transition:all .15s}.sc-header__tab--active{background:var(--sc-primary, #4f6ef7);color:#fff}.sc-btn{border:none;cursor:pointer;border-radius:var(--sc-radius, 8px);font-size:13px;transition:all .15s;font-family:inherit}.sc-btn--icon{width:28px;height:28px;display:flex;align-items:center;justify-content:center;background:var(--sc-bg, #fff);border:1px solid var(--sc-border, #ddd);color:var(--sc-text, #333)}.sc-btn--icon:hover{background:var(--sc-hover-bg, #f5f5f5)}.sc-btn--text{background:none;color:var(--sc-primary, #4f6ef7);padding:4px 8px}.sc-btn--text:hover{background:var(--sc-hover-bg, #f5f5f5)}.sc-btn--primary{background:var(--sc-primary, #4f6ef7);color:#fff;padding:4px 12px}.sc-btn--primary:hover{background:var(--sc-primary-hover, #3b5de7)}.sc-btn--primary:disabled{opacity:.5;cursor:not-allowed}.sc-btn--small{font-size:12px;padding:3px 10px}.sc-day-cell{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:4px 0;min-height:48px;cursor:pointer;border-radius:var(--sc-radius, 8px);transition:background-color .15s;position:relative}.sc-day-cell:hover{background-color:var(--sc-hover-bg, #f5f5f5)}.sc-day-cell--other-month .sc-day-cell__number{color:var(--sc-text-muted, #bbb)}.sc-day-cell--today .sc-day-cell__number{color:var(--sc-primary, #4f6ef7);font-weight:700}.sc-day-cell--selected{background-color:var(--sc-primary, #4f6ef7)}.sc-day-cell--selected .sc-day-cell__number{color:#fff!important}.sc-day-cell--selected:hover{background-color:var(--sc-primary-hover, #3b5de7)}.sc-day-cell__number{font-size:14px;line-height:1;color:var(--sc-text, #333)}.sc-day-cell__dots{display:flex;gap:3px;margin-top:4px}.sc-day-cell__dot{width:5px;height:5px;border-radius:50%}.sc-month-view{width:100%}.sc-month-view__weekdays{display:grid;grid-template-columns:repeat(7,1fr);text-align:center;padding-bottom:8px;border-bottom:1px solid var(--sc-border, #eee);margin-bottom:4px}.sc-month-view__weekday{font-size:12px;color:var(--sc-text-secondary, #999);font-weight:500}.sc-month-view__row{display:grid;grid-template-columns:repeat(7,1fr)}.sc-week-view{width:100%}.sc-week-view__weekdays{display:grid;grid-template-columns:repeat(7,1fr);text-align:center;padding-bottom:8px;border-bottom:1px solid var(--sc-border, #eee);margin-bottom:4px}.sc-week-view__weekday{font-size:12px;color:var(--sc-text-secondary, #999);font-weight:500}.sc-week-view__row{display:grid;grid-template-columns:repeat(7,1fr)}.sc-schedule-form{padding:12px 0;display:flex;flex-direction:column;gap:10px}.sc-schedule-form__field{display:flex;flex-direction:column;gap:4px;flex:1}.sc-schedule-form__field label{font-size:12px;color:var(--sc-text-secondary, #999)}.sc-schedule-form__row{display:flex;gap:12px}.sc-schedule-form__input,.sc-schedule-form__textarea{border:1px solid var(--sc-border, #ddd);border-radius:var(--sc-radius, 8px);padding:6px 10px;font-size:14px;color:var(--sc-text, #333);background:var(--sc-bg, #fff);outline:none;transition:border-color .15s;font-family:inherit}.sc-schedule-form__input:focus,.sc-schedule-form__textarea:focus{border-color:var(--sc-primary, #4f6ef7)}.sc-schedule-form__textarea{resize:vertical}.sc-schedule-form__actions{display:flex;justify-content:flex-end;gap:8px;padding-top:4px}.sc-schedule-panel{border-top:1px solid var(--sc-border, #eee);padding:12px 0 0;margin-top:8px}.sc-schedule-panel__header{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}.sc-schedule-panel__date{font-size:14px;font-weight:600;color:var(--sc-text, #333)}.sc-schedule-panel__empty{text-align:center;padding:20px 0;color:var(--sc-text-muted, #bbb);font-size:13px}.sc-schedule-panel__list{display:flex;flex-direction:column;gap:8px}.sc-schedule-panel__item{display:flex;align-items:flex-start;gap:10px;padding:8px;border-radius:var(--sc-radius, 8px);background:var(--sc-item-bg, #f9f9fb);transition:background-color .15s}.sc-schedule-panel__item:hover{background:var(--sc-hover-bg, #f0f0f5)}.sc-schedule-panel__item-bar{width:3px;min-height:32px;border-radius:2px;flex-shrink:0}.sc-schedule-panel__item-content{flex:1;min-width:0}.sc-schedule-panel__item-title{font-size:14px;font-weight:500;color:var(--sc-text, #333)}.sc-schedule-panel__item-time,.sc-schedule-panel__item-desc{font-size:12px;color:var(--sc-text-secondary, #999);margin-top:2px}.sc-schedule-panel__item-delete{background:none;border:none;color:var(--sc-text-muted, #bbb);cursor:pointer;font-size:18px;line-height:1;padding:0 4px;transition:color .15s}.sc-schedule-panel__item-delete:hover{color:var(--sc-danger, #e74c3c)}.sc-calendar{--sc-primary: #4f6ef7;--sc-primary-hover: #3b5de7;--sc-bg: #fff;--sc-text: #333;--sc-text-secondary: #666;--sc-text-muted: #bbb;--sc-border: #eee;--sc-hover-bg: #f5f5f5;--sc-item-bg: #f9f9fb;--sc-radius: 8px;--sc-danger: #e74c3c;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;background:var(--sc-bg);padding:16px;border-radius:12px;box-sizing:border-box;width:100%;max-width:400px}.sc-calendar *,.sc-calendar *:before,.sc-calendar *:after{box-sizing:border-box}
|
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
import { ref as W, computed as w, defineComponent as N, openBlock as i, createElementBlock as u, createElementVNode as r, toDisplayString as h, normalizeClass as B, Fragment as T, renderList as C, normalizeStyle as Y, createCommentVNode as S, toRef as $, unref as p, createBlock as E, reactive as Q, withDirectives as O, vModelText as V, watch as J, createVNode as X } from "vue";
|
|
2
|
+
function P(e) {
|
|
3
|
+
const n = e.getFullYear(), s = String(e.getMonth() + 1).padStart(2, "0"), l = String(e.getDate()).padStart(2, "0");
|
|
4
|
+
return `${n}-${s}-${l}`;
|
|
5
|
+
}
|
|
6
|
+
function Z(e) {
|
|
7
|
+
const [n, s, l] = e.split("-").map(Number);
|
|
8
|
+
return new Date(n, s - 1, l);
|
|
9
|
+
}
|
|
10
|
+
function ee(e, n) {
|
|
11
|
+
return e.getFullYear() === n.getFullYear() && e.getMonth() === n.getMonth() && e.getDate() === n.getDate();
|
|
12
|
+
}
|
|
13
|
+
function L(e) {
|
|
14
|
+
return ee(e, /* @__PURE__ */ new Date());
|
|
15
|
+
}
|
|
16
|
+
function U(e, n) {
|
|
17
|
+
const s = new Date(e);
|
|
18
|
+
return s.setDate(s.getDate() + n), s;
|
|
19
|
+
}
|
|
20
|
+
function te(e, n) {
|
|
21
|
+
return new Date(e, n, 1);
|
|
22
|
+
}
|
|
23
|
+
function G(e, n = 0) {
|
|
24
|
+
const s = new Date(e), a = (s.getDay() - n + 7) % 7;
|
|
25
|
+
return s.setDate(s.getDate() - a), s;
|
|
26
|
+
}
|
|
27
|
+
function ne(e, n, s = 0) {
|
|
28
|
+
const l = te(e, n), a = G(l, s), t = [];
|
|
29
|
+
for (let d = 0; d < 42; d++)
|
|
30
|
+
t.push(U(a, d));
|
|
31
|
+
return t;
|
|
32
|
+
}
|
|
33
|
+
function se(e, n = 0) {
|
|
34
|
+
const s = G(e, n), l = [];
|
|
35
|
+
for (let a = 0; a < 7; a++)
|
|
36
|
+
l.push(U(s, a));
|
|
37
|
+
return l;
|
|
38
|
+
}
|
|
39
|
+
const R = {
|
|
40
|
+
weekDays: ["日", "一", "二", "三", "四", "五", "六"],
|
|
41
|
+
weekDaysShort: ["日", "一", "二", "三", "四", "五", "六"],
|
|
42
|
+
months: [
|
|
43
|
+
"一月",
|
|
44
|
+
"二月",
|
|
45
|
+
"三月",
|
|
46
|
+
"四月",
|
|
47
|
+
"五月",
|
|
48
|
+
"六月",
|
|
49
|
+
"七月",
|
|
50
|
+
"八月",
|
|
51
|
+
"九月",
|
|
52
|
+
"十月",
|
|
53
|
+
"十一月",
|
|
54
|
+
"十二月"
|
|
55
|
+
],
|
|
56
|
+
today: "今天",
|
|
57
|
+
month: "月",
|
|
58
|
+
week: "周",
|
|
59
|
+
noEvents: "暂无日程",
|
|
60
|
+
addEvent: "新建日程",
|
|
61
|
+
title: "标题",
|
|
62
|
+
date: "日期",
|
|
63
|
+
startTime: "开始时间",
|
|
64
|
+
endTime: "结束时间",
|
|
65
|
+
description: "描述",
|
|
66
|
+
cancel: "取消",
|
|
67
|
+
confirm: "确定",
|
|
68
|
+
delete: "删除"
|
|
69
|
+
}, ae = {
|
|
70
|
+
weekDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
71
|
+
weekDaysShort: ["S", "M", "T", "W", "T", "F", "S"],
|
|
72
|
+
months: [
|
|
73
|
+
"January",
|
|
74
|
+
"February",
|
|
75
|
+
"March",
|
|
76
|
+
"April",
|
|
77
|
+
"May",
|
|
78
|
+
"June",
|
|
79
|
+
"July",
|
|
80
|
+
"August",
|
|
81
|
+
"September",
|
|
82
|
+
"October",
|
|
83
|
+
"November",
|
|
84
|
+
"December"
|
|
85
|
+
],
|
|
86
|
+
today: "Today",
|
|
87
|
+
month: "Month",
|
|
88
|
+
week: "Week",
|
|
89
|
+
noEvents: "No events",
|
|
90
|
+
addEvent: "New Event",
|
|
91
|
+
title: "Title",
|
|
92
|
+
date: "Date",
|
|
93
|
+
startTime: "Start",
|
|
94
|
+
endTime: "End",
|
|
95
|
+
description: "Description",
|
|
96
|
+
cancel: "Cancel",
|
|
97
|
+
confirm: "OK",
|
|
98
|
+
delete: "Delete"
|
|
99
|
+
}, le = {
|
|
100
|
+
"zh-CN": R,
|
|
101
|
+
"en-US": ae
|
|
102
|
+
};
|
|
103
|
+
function F(e) {
|
|
104
|
+
return le[e] || R;
|
|
105
|
+
}
|
|
106
|
+
function H(e, n = 0) {
|
|
107
|
+
const s = F(e).weekDays;
|
|
108
|
+
return n === 1 ? [...s.slice(1), s[0]] : s;
|
|
109
|
+
}
|
|
110
|
+
function oe(e, n = "month", s = "zh-CN", l = 0) {
|
|
111
|
+
const a = /* @__PURE__ */ new Date(), t = W(e ? /* @__PURE__ */ new Date(e + "T00:00:00") : a), d = W(n), m = W(P(e ? /* @__PURE__ */ new Date(e + "T00:00:00") : a)), o = w(() => t.value.getFullYear()), c = w(() => t.value.getMonth()), v = w(() => F(s)), D = w(() => {
|
|
112
|
+
const f = o.value, x = c.value;
|
|
113
|
+
return s === "zh-CN" ? `${f}年${x + 1}月` : `${v.value.months[x]} ${f}`;
|
|
114
|
+
});
|
|
115
|
+
function M() {
|
|
116
|
+
t.value = /* @__PURE__ */ new Date(), m.value = P(/* @__PURE__ */ new Date());
|
|
117
|
+
}
|
|
118
|
+
function y() {
|
|
119
|
+
if (d.value === "month") {
|
|
120
|
+
const f = new Date(t.value);
|
|
121
|
+
f.setMonth(f.getMonth() - 1), t.value = f;
|
|
122
|
+
} else
|
|
123
|
+
t.value = U(t.value, -7);
|
|
124
|
+
}
|
|
125
|
+
function g() {
|
|
126
|
+
if (d.value === "month") {
|
|
127
|
+
const f = new Date(t.value);
|
|
128
|
+
f.setMonth(f.getMonth() + 1), t.value = f;
|
|
129
|
+
} else
|
|
130
|
+
t.value = U(t.value, 7);
|
|
131
|
+
}
|
|
132
|
+
function _(f) {
|
|
133
|
+
m.value = f;
|
|
134
|
+
}
|
|
135
|
+
function b(f) {
|
|
136
|
+
d.value = f;
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
currentDate: t,
|
|
140
|
+
viewMode: d,
|
|
141
|
+
selectedDate: m,
|
|
142
|
+
currentYear: o,
|
|
143
|
+
currentMonth: c,
|
|
144
|
+
headerTitle: D,
|
|
145
|
+
localeStrings: v,
|
|
146
|
+
goToday: M,
|
|
147
|
+
goPrev: y,
|
|
148
|
+
goNext: g,
|
|
149
|
+
selectDate: _,
|
|
150
|
+
setViewMode: b
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function ce(e, n) {
|
|
154
|
+
return { selectedEvents: w(() => e.value.filter((l) => l.date === n.value).sort((l, a) => l.startTime ? a.startTime ? l.startTime.localeCompare(a.startTime) : -1 : 1)) };
|
|
155
|
+
}
|
|
156
|
+
const re = { class: "sc-header" }, de = { class: "sc-header__left" }, ie = { class: "sc-header__title" }, ue = { class: "sc-header__right" }, ve = { class: "sc-header__tabs" }, me = /* @__PURE__ */ N({
|
|
157
|
+
__name: "CalendarHeader",
|
|
158
|
+
props: {
|
|
159
|
+
title: {},
|
|
160
|
+
viewMode: {},
|
|
161
|
+
locale: {}
|
|
162
|
+
},
|
|
163
|
+
emits: ["prev", "next", "today", "view-change"],
|
|
164
|
+
setup(e) {
|
|
165
|
+
const n = e, s = w(() => F(n.locale));
|
|
166
|
+
return (l, a) => (i(), u("div", re, [
|
|
167
|
+
r("div", de, [
|
|
168
|
+
r("button", {
|
|
169
|
+
class: "sc-btn sc-btn--icon",
|
|
170
|
+
onClick: a[0] || (a[0] = (t) => l.$emit("prev"))
|
|
171
|
+
}, "<"),
|
|
172
|
+
r("span", ie, h(e.title), 1),
|
|
173
|
+
r("button", {
|
|
174
|
+
class: "sc-btn sc-btn--icon",
|
|
175
|
+
onClick: a[1] || (a[1] = (t) => l.$emit("next"))
|
|
176
|
+
}, ">")
|
|
177
|
+
]),
|
|
178
|
+
r("div", ue, [
|
|
179
|
+
r("button", {
|
|
180
|
+
class: "sc-btn sc-btn--text",
|
|
181
|
+
onClick: a[2] || (a[2] = (t) => l.$emit("today"))
|
|
182
|
+
}, h(s.value.today), 1),
|
|
183
|
+
r("div", ve, [
|
|
184
|
+
r("button", {
|
|
185
|
+
class: B(["sc-header__tab", { "sc-header__tab--active": e.viewMode === "month" }]),
|
|
186
|
+
onClick: a[3] || (a[3] = (t) => l.$emit("view-change", "month"))
|
|
187
|
+
}, h(s.value.month), 3),
|
|
188
|
+
r("button", {
|
|
189
|
+
class: B(["sc-header__tab", { "sc-header__tab--active": e.viewMode === "week" }]),
|
|
190
|
+
onClick: a[4] || (a[4] = (t) => l.$emit("view-change", "week"))
|
|
191
|
+
}, h(s.value.week), 3)
|
|
192
|
+
])
|
|
193
|
+
])
|
|
194
|
+
]));
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
function he(e, n, s, l, a, t = 0) {
|
|
198
|
+
const d = w(() => ne(e.value, n.value, t).map((c) => {
|
|
199
|
+
const v = P(c), D = l.value.filter((_) => _.date === v), M = a.value.filter((_) => _.date === v), y = /* @__PURE__ */ new Map();
|
|
200
|
+
for (const _ of M)
|
|
201
|
+
y.set(_.color, { color: _.color, label: _.label });
|
|
202
|
+
for (const _ of D) {
|
|
203
|
+
const b = _.color || "var(--sc-primary)";
|
|
204
|
+
y.has(b) || y.set(b, { color: b });
|
|
205
|
+
}
|
|
206
|
+
const g = Array.from(y.values()).slice(0, 3);
|
|
207
|
+
return {
|
|
208
|
+
date: c,
|
|
209
|
+
dateStr: v,
|
|
210
|
+
day: c.getDate(),
|
|
211
|
+
isCurrentMonth: c.getMonth() === n.value,
|
|
212
|
+
isToday: L(c),
|
|
213
|
+
isSelected: v === s.value,
|
|
214
|
+
dots: g,
|
|
215
|
+
events: D
|
|
216
|
+
};
|
|
217
|
+
})), m = w(() => {
|
|
218
|
+
const o = [];
|
|
219
|
+
for (let c = 0; c < d.value.length; c += 7)
|
|
220
|
+
o.push(d.value.slice(c, c + 7));
|
|
221
|
+
return o;
|
|
222
|
+
});
|
|
223
|
+
return { days: d, rows: m };
|
|
224
|
+
}
|
|
225
|
+
const ye = { class: "sc-day-cell__number" }, fe = {
|
|
226
|
+
key: 0,
|
|
227
|
+
class: "sc-day-cell__dots"
|
|
228
|
+
}, ke = ["title"], K = /* @__PURE__ */ N({
|
|
229
|
+
__name: "DayCell",
|
|
230
|
+
props: {
|
|
231
|
+
day: {}
|
|
232
|
+
},
|
|
233
|
+
emits: ["click"],
|
|
234
|
+
setup(e) {
|
|
235
|
+
return (n, s) => (i(), u("div", {
|
|
236
|
+
class: B(["sc-day-cell", {
|
|
237
|
+
"sc-day-cell--other-month": !e.day.isCurrentMonth,
|
|
238
|
+
"sc-day-cell--today": e.day.isToday,
|
|
239
|
+
"sc-day-cell--selected": e.day.isSelected
|
|
240
|
+
}]),
|
|
241
|
+
onClick: s[0] || (s[0] = (l) => n.$emit("click", e.day.dateStr))
|
|
242
|
+
}, [
|
|
243
|
+
r("span", ye, h(e.day.day), 1),
|
|
244
|
+
e.day.dots.length ? (i(), u("div", fe, [
|
|
245
|
+
(i(!0), u(T, null, C(e.day.dots, (l, a) => (i(), u("span", {
|
|
246
|
+
key: a,
|
|
247
|
+
class: "sc-day-cell__dot",
|
|
248
|
+
style: Y({ backgroundColor: l.color }),
|
|
249
|
+
title: l.label
|
|
250
|
+
}, null, 12, ke))), 128))
|
|
251
|
+
])) : S("", !0)
|
|
252
|
+
], 2));
|
|
253
|
+
}
|
|
254
|
+
}), we = { class: "sc-month-view" }, _e = { class: "sc-month-view__weekdays" }, De = /* @__PURE__ */ N({
|
|
255
|
+
__name: "MonthView",
|
|
256
|
+
props: {
|
|
257
|
+
year: {},
|
|
258
|
+
month: {},
|
|
259
|
+
selectedDate: {},
|
|
260
|
+
events: {},
|
|
261
|
+
dotMarkers: {},
|
|
262
|
+
locale: {},
|
|
263
|
+
weekStartsOn: {}
|
|
264
|
+
},
|
|
265
|
+
emits: ["date-click"],
|
|
266
|
+
setup(e) {
|
|
267
|
+
const n = e, { rows: s } = he(
|
|
268
|
+
$(n, "year"),
|
|
269
|
+
$(n, "month"),
|
|
270
|
+
$(n, "selectedDate"),
|
|
271
|
+
$(n, "events"),
|
|
272
|
+
$(n, "dotMarkers"),
|
|
273
|
+
n.weekStartsOn
|
|
274
|
+
), l = w(
|
|
275
|
+
() => H(n.locale, n.weekStartsOn)
|
|
276
|
+
);
|
|
277
|
+
return (a, t) => (i(), u("div", we, [
|
|
278
|
+
r("div", _e, [
|
|
279
|
+
(i(!0), u(T, null, C(l.value, (d) => (i(), u("div", {
|
|
280
|
+
key: d,
|
|
281
|
+
class: "sc-month-view__weekday"
|
|
282
|
+
}, h(d), 1))), 128))
|
|
283
|
+
]),
|
|
284
|
+
(i(!0), u(T, null, C(p(s), (d, m) => (i(), u("div", {
|
|
285
|
+
key: m,
|
|
286
|
+
class: "sc-month-view__row"
|
|
287
|
+
}, [
|
|
288
|
+
(i(!0), u(T, null, C(d, (o) => (i(), E(K, {
|
|
289
|
+
key: o.dateStr,
|
|
290
|
+
day: o,
|
|
291
|
+
onClick: t[0] || (t[0] = (c) => a.$emit("date-click", c))
|
|
292
|
+
}, null, 8, ["day"]))), 128))
|
|
293
|
+
]))), 128))
|
|
294
|
+
]));
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
function pe(e, n, s, l, a = 0) {
|
|
298
|
+
return { days: w(() => se(e.value, a).map((m) => {
|
|
299
|
+
const o = P(m), c = s.value.filter((y) => y.date === o), v = l.value.filter((y) => y.date === o), D = /* @__PURE__ */ new Map();
|
|
300
|
+
for (const y of v)
|
|
301
|
+
D.set(y.color, { color: y.color, label: y.label });
|
|
302
|
+
for (const y of c) {
|
|
303
|
+
const g = y.color || "var(--sc-primary)";
|
|
304
|
+
D.has(g) || D.set(g, { color: g });
|
|
305
|
+
}
|
|
306
|
+
const M = Array.from(D.values()).slice(0, 3);
|
|
307
|
+
return {
|
|
308
|
+
date: m,
|
|
309
|
+
dateStr: o,
|
|
310
|
+
day: m.getDate(),
|
|
311
|
+
isCurrentMonth: !0,
|
|
312
|
+
isToday: L(m),
|
|
313
|
+
isSelected: o === n.value,
|
|
314
|
+
dots: M,
|
|
315
|
+
events: c
|
|
316
|
+
};
|
|
317
|
+
})) };
|
|
318
|
+
}
|
|
319
|
+
const $e = { class: "sc-week-view" }, ge = { class: "sc-week-view__weekdays" }, Me = { class: "sc-week-view__row" }, be = /* @__PURE__ */ N({
|
|
320
|
+
__name: "WeekView",
|
|
321
|
+
props: {
|
|
322
|
+
currentDate: {},
|
|
323
|
+
selectedDate: {},
|
|
324
|
+
events: {},
|
|
325
|
+
dotMarkers: {},
|
|
326
|
+
locale: {},
|
|
327
|
+
weekStartsOn: {}
|
|
328
|
+
},
|
|
329
|
+
emits: ["date-click"],
|
|
330
|
+
setup(e) {
|
|
331
|
+
const n = e, { days: s } = pe(
|
|
332
|
+
$(n, "currentDate"),
|
|
333
|
+
$(n, "selectedDate"),
|
|
334
|
+
$(n, "events"),
|
|
335
|
+
$(n, "dotMarkers"),
|
|
336
|
+
n.weekStartsOn
|
|
337
|
+
), l = w(
|
|
338
|
+
() => H(n.locale, n.weekStartsOn)
|
|
339
|
+
);
|
|
340
|
+
return (a, t) => (i(), u("div", $e, [
|
|
341
|
+
r("div", ge, [
|
|
342
|
+
(i(!0), u(T, null, C(l.value, (d) => (i(), u("div", {
|
|
343
|
+
key: d,
|
|
344
|
+
class: "sc-week-view__weekday"
|
|
345
|
+
}, h(d), 1))), 128))
|
|
346
|
+
]),
|
|
347
|
+
r("div", Me, [
|
|
348
|
+
(i(!0), u(T, null, C(p(s), (d) => (i(), E(K, {
|
|
349
|
+
key: d.dateStr,
|
|
350
|
+
day: d,
|
|
351
|
+
onClick: t[0] || (t[0] = (m) => a.$emit("date-click", m))
|
|
352
|
+
}, null, 8, ["day"]))), 128))
|
|
353
|
+
])
|
|
354
|
+
]));
|
|
355
|
+
}
|
|
356
|
+
}), Se = { class: "sc-schedule-form" }, Te = { class: "sc-schedule-form__field" }, Ce = { class: "sc-schedule-form__field" }, Ne = { class: "sc-schedule-form__row" }, Ee = { class: "sc-schedule-form__field" }, Oe = { class: "sc-schedule-form__field" }, Ve = { class: "sc-schedule-form__field" }, Fe = { class: "sc-schedule-form__actions" }, xe = ["disabled"], ze = /* @__PURE__ */ N({
|
|
357
|
+
__name: "ScheduleForm",
|
|
358
|
+
props: {
|
|
359
|
+
selectedDate: {},
|
|
360
|
+
locale: {}
|
|
361
|
+
},
|
|
362
|
+
emits: ["submit", "cancel"],
|
|
363
|
+
setup(e, { emit: n }) {
|
|
364
|
+
const s = e, l = n, a = w(() => F(s.locale)), t = Q({
|
|
365
|
+
title: "",
|
|
366
|
+
date: s.selectedDate,
|
|
367
|
+
startTime: "",
|
|
368
|
+
endTime: "",
|
|
369
|
+
description: ""
|
|
370
|
+
});
|
|
371
|
+
function d() {
|
|
372
|
+
t.title.trim() && (l("submit", {
|
|
373
|
+
title: t.title.trim(),
|
|
374
|
+
date: t.date,
|
|
375
|
+
startTime: t.startTime || void 0,
|
|
376
|
+
endTime: t.endTime || void 0,
|
|
377
|
+
description: t.description.trim() || void 0
|
|
378
|
+
}), t.title = "", t.startTime = "", t.endTime = "", t.description = "");
|
|
379
|
+
}
|
|
380
|
+
return (m, o) => (i(), u("div", Se, [
|
|
381
|
+
r("div", Te, [
|
|
382
|
+
r("label", null, h(a.value.title), 1),
|
|
383
|
+
O(r("input", {
|
|
384
|
+
"onUpdate:modelValue": o[0] || (o[0] = (c) => t.title = c),
|
|
385
|
+
type: "text",
|
|
386
|
+
class: "sc-schedule-form__input"
|
|
387
|
+
}, null, 512), [
|
|
388
|
+
[V, t.title]
|
|
389
|
+
])
|
|
390
|
+
]),
|
|
391
|
+
r("div", Ce, [
|
|
392
|
+
r("label", null, h(a.value.date), 1),
|
|
393
|
+
O(r("input", {
|
|
394
|
+
"onUpdate:modelValue": o[1] || (o[1] = (c) => t.date = c),
|
|
395
|
+
type: "date",
|
|
396
|
+
class: "sc-schedule-form__input"
|
|
397
|
+
}, null, 512), [
|
|
398
|
+
[V, t.date]
|
|
399
|
+
])
|
|
400
|
+
]),
|
|
401
|
+
r("div", Ne, [
|
|
402
|
+
r("div", Ee, [
|
|
403
|
+
r("label", null, h(a.value.startTime), 1),
|
|
404
|
+
O(r("input", {
|
|
405
|
+
"onUpdate:modelValue": o[2] || (o[2] = (c) => t.startTime = c),
|
|
406
|
+
type: "time",
|
|
407
|
+
class: "sc-schedule-form__input"
|
|
408
|
+
}, null, 512), [
|
|
409
|
+
[V, t.startTime]
|
|
410
|
+
])
|
|
411
|
+
]),
|
|
412
|
+
r("div", Oe, [
|
|
413
|
+
r("label", null, h(a.value.endTime), 1),
|
|
414
|
+
O(r("input", {
|
|
415
|
+
"onUpdate:modelValue": o[3] || (o[3] = (c) => t.endTime = c),
|
|
416
|
+
type: "time",
|
|
417
|
+
class: "sc-schedule-form__input"
|
|
418
|
+
}, null, 512), [
|
|
419
|
+
[V, t.endTime]
|
|
420
|
+
])
|
|
421
|
+
])
|
|
422
|
+
]),
|
|
423
|
+
r("div", Ve, [
|
|
424
|
+
r("label", null, h(a.value.description), 1),
|
|
425
|
+
O(r("textarea", {
|
|
426
|
+
"onUpdate:modelValue": o[4] || (o[4] = (c) => t.description = c),
|
|
427
|
+
class: "sc-schedule-form__textarea",
|
|
428
|
+
rows: "2"
|
|
429
|
+
}, null, 512), [
|
|
430
|
+
[V, t.description]
|
|
431
|
+
])
|
|
432
|
+
]),
|
|
433
|
+
r("div", Fe, [
|
|
434
|
+
r("button", {
|
|
435
|
+
class: "sc-btn sc-btn--text",
|
|
436
|
+
onClick: o[5] || (o[5] = (c) => m.$emit("cancel"))
|
|
437
|
+
}, h(a.value.cancel), 1),
|
|
438
|
+
r("button", {
|
|
439
|
+
class: "sc-btn sc-btn--primary",
|
|
440
|
+
disabled: !t.title.trim(),
|
|
441
|
+
onClick: d
|
|
442
|
+
}, h(a.value.confirm), 9, xe)
|
|
443
|
+
])
|
|
444
|
+
]));
|
|
445
|
+
}
|
|
446
|
+
}), We = { class: "sc-schedule-panel" }, Pe = { class: "sc-schedule-panel__header" }, Ue = { class: "sc-schedule-panel__date" }, Ae = {
|
|
447
|
+
key: 1,
|
|
448
|
+
class: "sc-schedule-panel__empty"
|
|
449
|
+
}, Be = {
|
|
450
|
+
key: 2,
|
|
451
|
+
class: "sc-schedule-panel__list"
|
|
452
|
+
}, Je = { class: "sc-schedule-panel__item-content" }, Ye = { class: "sc-schedule-panel__item-title" }, Le = {
|
|
453
|
+
key: 0,
|
|
454
|
+
class: "sc-schedule-panel__item-time"
|
|
455
|
+
}, Ge = {
|
|
456
|
+
key: 1,
|
|
457
|
+
class: "sc-schedule-panel__item-desc"
|
|
458
|
+
}, Re = ["title", "onClick"], He = /* @__PURE__ */ N({
|
|
459
|
+
__name: "SchedulePanel",
|
|
460
|
+
props: {
|
|
461
|
+
events: {},
|
|
462
|
+
selectedDate: {},
|
|
463
|
+
locale: {},
|
|
464
|
+
readonly: { type: Boolean }
|
|
465
|
+
},
|
|
466
|
+
emits: ["event-create", "event-delete"],
|
|
467
|
+
setup(e, { emit: n }) {
|
|
468
|
+
const s = e, l = n, a = W(!1), t = w(() => F(s.locale)), d = w(() => {
|
|
469
|
+
const o = Z(s.selectedDate);
|
|
470
|
+
return s.locale === "zh-CN" ? `${o.getMonth() + 1}月${o.getDate()}日` : `${["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][o.getMonth()]} ${o.getDate()}`;
|
|
471
|
+
});
|
|
472
|
+
function m(o) {
|
|
473
|
+
l("event-create", o), a.value = !1;
|
|
474
|
+
}
|
|
475
|
+
return (o, c) => (i(), u("div", We, [
|
|
476
|
+
r("div", Pe, [
|
|
477
|
+
r("span", Ue, h(d.value), 1),
|
|
478
|
+
!e.readonly && !a.value ? (i(), u("button", {
|
|
479
|
+
key: 0,
|
|
480
|
+
class: "sc-btn sc-btn--small sc-btn--primary",
|
|
481
|
+
onClick: c[0] || (c[0] = (v) => a.value = !0)
|
|
482
|
+
}, h(t.value.addEvent), 1)) : S("", !0)
|
|
483
|
+
]),
|
|
484
|
+
a.value ? (i(), E(ze, {
|
|
485
|
+
key: 0,
|
|
486
|
+
"selected-date": e.selectedDate,
|
|
487
|
+
locale: e.locale,
|
|
488
|
+
onSubmit: m,
|
|
489
|
+
onCancel: c[1] || (c[1] = (v) => a.value = !1)
|
|
490
|
+
}, null, 8, ["selected-date", "locale"])) : S("", !0),
|
|
491
|
+
e.events.length === 0 && !a.value ? (i(), u("div", Ae, h(t.value.noEvents), 1)) : (i(), u("div", Be, [
|
|
492
|
+
(i(!0), u(T, null, C(e.events, (v) => (i(), u("div", {
|
|
493
|
+
key: v.id,
|
|
494
|
+
class: "sc-schedule-panel__item"
|
|
495
|
+
}, [
|
|
496
|
+
r("div", {
|
|
497
|
+
class: "sc-schedule-panel__item-bar",
|
|
498
|
+
style: Y({ backgroundColor: v.color || "var(--sc-primary, #4f6ef7)" })
|
|
499
|
+
}, null, 4),
|
|
500
|
+
r("div", Je, [
|
|
501
|
+
r("div", Ye, h(v.title), 1),
|
|
502
|
+
v.startTime ? (i(), u("div", Le, h(v.startTime) + h(v.endTime ? " - " + v.endTime : ""), 1)) : S("", !0),
|
|
503
|
+
v.description ? (i(), u("div", Ge, h(v.description), 1)) : S("", !0)
|
|
504
|
+
]),
|
|
505
|
+
e.readonly ? S("", !0) : (i(), u("button", {
|
|
506
|
+
key: 0,
|
|
507
|
+
class: "sc-schedule-panel__item-delete",
|
|
508
|
+
title: t.value.delete,
|
|
509
|
+
onClick: (D) => o.$emit("event-delete", v.id)
|
|
510
|
+
}, " × ", 8, Re))
|
|
511
|
+
]))), 128))
|
|
512
|
+
]))
|
|
513
|
+
]));
|
|
514
|
+
}
|
|
515
|
+
}), Ke = { class: "sc-calendar" }, je = /* @__PURE__ */ N({
|
|
516
|
+
__name: "ScheduleCalendar",
|
|
517
|
+
props: {
|
|
518
|
+
events: { default: () => [] },
|
|
519
|
+
dotMarkers: { default: () => [] },
|
|
520
|
+
viewMode: { default: "month" },
|
|
521
|
+
selectedDate: { default: void 0 },
|
|
522
|
+
locale: { default: "zh-CN" },
|
|
523
|
+
weekStartsOn: { default: 0 },
|
|
524
|
+
showSchedulePanel: { type: Boolean, default: !0 },
|
|
525
|
+
readonly: { type: Boolean, default: !1 }
|
|
526
|
+
},
|
|
527
|
+
emits: ["date-click", "event-create", "event-delete", "view-change", "month-change", "update:viewMode", "update:selectedDate"],
|
|
528
|
+
setup(e, { emit: n }) {
|
|
529
|
+
const s = e, l = n, {
|
|
530
|
+
currentDate: a,
|
|
531
|
+
viewMode: t,
|
|
532
|
+
selectedDate: d,
|
|
533
|
+
currentYear: m,
|
|
534
|
+
currentMonth: o,
|
|
535
|
+
headerTitle: c,
|
|
536
|
+
goToday: v,
|
|
537
|
+
goPrev: D,
|
|
538
|
+
goNext: M,
|
|
539
|
+
selectDate: y,
|
|
540
|
+
setViewMode: g
|
|
541
|
+
} = oe(s.selectedDate, s.viewMode, s.locale, s.weekStartsOn), _ = $(s, "events"), { selectedEvents: b } = ce(_, d);
|
|
542
|
+
J(
|
|
543
|
+
() => s.viewMode,
|
|
544
|
+
(k) => {
|
|
545
|
+
k !== t.value && (t.value = k);
|
|
546
|
+
}
|
|
547
|
+
), J(
|
|
548
|
+
() => s.selectedDate,
|
|
549
|
+
(k) => {
|
|
550
|
+
k && k !== d.value && (d.value = k);
|
|
551
|
+
}
|
|
552
|
+
);
|
|
553
|
+
function f(k) {
|
|
554
|
+
y(k), l("update:selectedDate", k), l("date-click", k);
|
|
555
|
+
}
|
|
556
|
+
function x(k) {
|
|
557
|
+
g(k), l("update:viewMode", k), l("view-change", k);
|
|
558
|
+
}
|
|
559
|
+
function j() {
|
|
560
|
+
D(), l("month-change", { year: m.value, month: o.value + 1 });
|
|
561
|
+
}
|
|
562
|
+
function q() {
|
|
563
|
+
M(), l("month-change", { year: m.value, month: o.value + 1 });
|
|
564
|
+
}
|
|
565
|
+
function I() {
|
|
566
|
+
v(), l("update:selectedDate", d.value), l("month-change", { year: m.value, month: o.value + 1 });
|
|
567
|
+
}
|
|
568
|
+
return (k, z) => (i(), u("div", Ke, [
|
|
569
|
+
X(me, {
|
|
570
|
+
title: p(c),
|
|
571
|
+
"view-mode": p(t),
|
|
572
|
+
locale: e.locale,
|
|
573
|
+
onPrev: j,
|
|
574
|
+
onNext: q,
|
|
575
|
+
onToday: I,
|
|
576
|
+
onViewChange: x
|
|
577
|
+
}, null, 8, ["title", "view-mode", "locale"]),
|
|
578
|
+
p(t) === "month" ? (i(), E(De, {
|
|
579
|
+
key: 0,
|
|
580
|
+
year: p(m),
|
|
581
|
+
month: p(o),
|
|
582
|
+
"selected-date": p(d),
|
|
583
|
+
events: e.events,
|
|
584
|
+
"dot-markers": e.dotMarkers,
|
|
585
|
+
locale: e.locale,
|
|
586
|
+
"week-starts-on": e.weekStartsOn,
|
|
587
|
+
onDateClick: f
|
|
588
|
+
}, null, 8, ["year", "month", "selected-date", "events", "dot-markers", "locale", "week-starts-on"])) : (i(), E(be, {
|
|
589
|
+
key: 1,
|
|
590
|
+
"current-date": p(a),
|
|
591
|
+
"selected-date": p(d),
|
|
592
|
+
events: e.events,
|
|
593
|
+
"dot-markers": e.dotMarkers,
|
|
594
|
+
locale: e.locale,
|
|
595
|
+
"week-starts-on": e.weekStartsOn,
|
|
596
|
+
onDateClick: f
|
|
597
|
+
}, null, 8, ["current-date", "selected-date", "events", "dot-markers", "locale", "week-starts-on"])),
|
|
598
|
+
e.showSchedulePanel ? (i(), E(He, {
|
|
599
|
+
key: 2,
|
|
600
|
+
events: p(b),
|
|
601
|
+
"selected-date": p(d),
|
|
602
|
+
locale: e.locale,
|
|
603
|
+
readonly: e.readonly,
|
|
604
|
+
onEventCreate: z[0] || (z[0] = (A) => k.$emit("event-create", A)),
|
|
605
|
+
onEventDelete: z[1] || (z[1] = (A) => k.$emit("event-delete", A))
|
|
606
|
+
}, null, 8, ["events", "selected-date", "locale", "readonly"])) : S("", !0)
|
|
607
|
+
]));
|
|
608
|
+
}
|
|
609
|
+
}), Ie = {
|
|
610
|
+
install(e) {
|
|
611
|
+
e.component("ScheduleCalendar", je);
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
export {
|
|
615
|
+
je as ScheduleCalendar,
|
|
616
|
+
Ie as default
|
|
617
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(w,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(w=typeof globalThis<"u"?globalThis:w||self,e(w.VueScheduleCalendar={},w.Vue))})(this,(function(w,e){"use strict";function E(t){const o=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${o}-${l}-${s}`}function O(t){const[o,l,s]=t.split("-").map(Number);return new Date(o,l-1,s)}function x(t,o){return t.getFullYear()===o.getFullYear()&&t.getMonth()===o.getMonth()&&t.getDate()===o.getDate()}function N(t){return x(t,new Date)}function S(t,o){const l=new Date(t);return l.setDate(l.getDate()+o),l}function z(t,o){return new Date(t,o,1)}function V(t,o=0){const l=new Date(t),a=(l.getDay()-o+7)%7;return l.setDate(l.getDate()-a),l}function L(t,o,l=0){const s=z(t,o),a=V(s,l),n=[];for(let d=0;d<42;d++)n.push(S(a,d));return n}function R(t,o=0){const l=V(t,o),s=[];for(let a=0;a<7;a++)s.push(S(l,a));return s}const C={weekDays:["日","一","二","三","四","五","六"],weekDaysShort:["日","一","二","三","四","五","六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],today:"今天",month:"月",week:"周",noEvents:"暂无日程",addEvent:"新建日程",title:"标题",date:"日期",startTime:"开始时间",endTime:"结束时间",description:"描述",cancel:"取消",confirm:"确定",delete:"删除"},P={"zh-CN":C,"en-US":{weekDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],weekDaysShort:["S","M","T","W","T","F","S"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],today:"Today",month:"Month",week:"Week",noEvents:"No events",addEvent:"New Event",title:"Title",date:"Date",startTime:"Start",endTime:"End",description:"Description",cancel:"Cancel",confirm:"OK",delete:"Delete"}};function g(t){return P[t]||C}function b(t,o=0){const l=g(t).weekDays;return o===1?[...l.slice(1),l[0]]:l}function U(t,o="month",l="zh-CN",s=0){const a=new Date,n=e.ref(t?new Date(t+"T00:00:00"):a),d=e.ref(o),m=e.ref(E(t?new Date(t+"T00:00:00"):a)),c=e.computed(()=>n.value.getFullYear()),r=e.computed(()=>n.value.getMonth()),i=e.computed(()=>g(l)),y=e.computed(()=>{const f=c.value,B=r.value;return l==="zh-CN"?`${f}年${B+1}月`:`${i.value.months[B]} ${f}`});function D(){n.value=new Date,m.value=E(new Date)}function k(){if(d.value==="month"){const f=new Date(n.value);f.setMonth(f.getMonth()-1),n.value=f}else n.value=S(n.value,-7)}function p(){if(d.value==="month"){const f=new Date(n.value);f.setMonth(f.getMonth()+1),n.value=f}else n.value=S(n.value,7)}function u(f){m.value=f}function _(f){d.value=f}return{currentDate:n,viewMode:d,selectedDate:m,currentYear:c,currentMonth:r,headerTitle:y,localeStrings:i,goToday:D,goPrev:k,goNext:p,selectDate:u,setViewMode:_}}function W(t,o){return{selectedEvents:e.computed(()=>t.value.filter(s=>s.date===o.value).sort((s,a)=>s.startTime?a.startTime?s.startTime.localeCompare(a.startTime):-1:1))}}const A={class:"sc-header"},J={class:"sc-header__left"},Y={class:"sc-header__title"},G={class:"sc-header__right"},j={class:"sc-header__tabs"},q=e.defineComponent({__name:"CalendarHeader",props:{title:{},viewMode:{},locale:{}},emits:["prev","next","today","view-change"],setup(t){const o=t,l=e.computed(()=>g(o.locale));return(s,a)=>(e.openBlock(),e.createElementBlock("div",A,[e.createElementVNode("div",J,[e.createElementVNode("button",{class:"sc-btn sc-btn--icon",onClick:a[0]||(a[0]=n=>s.$emit("prev"))},"<"),e.createElementVNode("span",Y,e.toDisplayString(t.title),1),e.createElementVNode("button",{class:"sc-btn sc-btn--icon",onClick:a[1]||(a[1]=n=>s.$emit("next"))},">")]),e.createElementVNode("div",G,[e.createElementVNode("button",{class:"sc-btn sc-btn--text",onClick:a[2]||(a[2]=n=>s.$emit("today"))},e.toDisplayString(l.value.today),1),e.createElementVNode("div",j,[e.createElementVNode("button",{class:e.normalizeClass(["sc-header__tab",{"sc-header__tab--active":t.viewMode==="month"}]),onClick:a[3]||(a[3]=n=>s.$emit("view-change","month"))},e.toDisplayString(l.value.month),3),e.createElementVNode("button",{class:e.normalizeClass(["sc-header__tab",{"sc-header__tab--active":t.viewMode==="week"}]),onClick:a[4]||(a[4]=n=>s.$emit("view-change","week"))},e.toDisplayString(l.value.week),3)])])]))}});function H(t,o,l,s,a,n=0){const d=e.computed(()=>L(t.value,o.value,n).map(r=>{const i=E(r),y=s.value.filter(u=>u.date===i),D=a.value.filter(u=>u.date===i),k=new Map;for(const u of D)k.set(u.color,{color:u.color,label:u.label});for(const u of y){const _=u.color||"var(--sc-primary)";k.has(_)||k.set(_,{color:_})}const p=Array.from(k.values()).slice(0,3);return{date:r,dateStr:i,day:r.getDate(),isCurrentMonth:r.getMonth()===o.value,isToday:N(r),isSelected:i===l.value,dots:p,events:y}})),m=e.computed(()=>{const c=[];for(let r=0;r<d.value.length;r+=7)c.push(d.value.slice(r,r+7));return c});return{days:d,rows:m}}const K={class:"sc-day-cell__number"},I={key:0,class:"sc-day-cell__dots"},Q=["title"],T=e.defineComponent({__name:"DayCell",props:{day:{}},emits:["click"],setup(t){return(o,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["sc-day-cell",{"sc-day-cell--other-month":!t.day.isCurrentMonth,"sc-day-cell--today":t.day.isToday,"sc-day-cell--selected":t.day.isSelected}]),onClick:l[0]||(l[0]=s=>o.$emit("click",t.day.dateStr))},[e.createElementVNode("span",K,e.toDisplayString(t.day.day),1),t.day.dots.length?(e.openBlock(),e.createElementBlock("div",I,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.day.dots,(s,a)=>(e.openBlock(),e.createElementBlock("span",{key:a,class:"sc-day-cell__dot",style:e.normalizeStyle({backgroundColor:s.color}),title:s.label},null,12,Q))),128))])):e.createCommentVNode("",!0)],2))}}),X={class:"sc-month-view"},Z={class:"sc-month-view__weekdays"},v=e.defineComponent({__name:"MonthView",props:{year:{},month:{},selectedDate:{},events:{},dotMarkers:{},locale:{},weekStartsOn:{}},emits:["date-click"],setup(t){const o=t,{rows:l}=H(e.toRef(o,"year"),e.toRef(o,"month"),e.toRef(o,"selectedDate"),e.toRef(o,"events"),e.toRef(o,"dotMarkers"),o.weekStartsOn),s=e.computed(()=>b(o.locale,o.weekStartsOn));return(a,n)=>(e.openBlock(),e.createElementBlock("div",X,[e.createElementVNode("div",Z,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,d=>(e.openBlock(),e.createElementBlock("div",{key:d,class:"sc-month-view__weekday"},e.toDisplayString(d),1))),128))]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l),(d,m)=>(e.openBlock(),e.createElementBlock("div",{key:m,class:"sc-month-view__row"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d,c=>(e.openBlock(),e.createBlock(T,{key:c.dateStr,day:c,onClick:n[0]||(n[0]=r=>a.$emit("date-click",r))},null,8,["day"]))),128))]))),128))]))}});function ee(t,o,l,s,a=0){return{days:e.computed(()=>R(t.value,a).map(m=>{const c=E(m),r=l.value.filter(k=>k.date===c),i=s.value.filter(k=>k.date===c),y=new Map;for(const k of i)y.set(k.color,{color:k.color,label:k.label});for(const k of r){const p=k.color||"var(--sc-primary)";y.has(p)||y.set(p,{color:p})}const D=Array.from(y.values()).slice(0,3);return{date:m,dateStr:c,day:m.getDate(),isCurrentMonth:!0,isToday:N(m),isSelected:c===o.value,dots:D,events:r}}))}}const te={class:"sc-week-view"},ne={class:"sc-week-view__weekdays"},oe={class:"sc-week-view__row"},le=e.defineComponent({__name:"WeekView",props:{currentDate:{},selectedDate:{},events:{},dotMarkers:{},locale:{},weekStartsOn:{}},emits:["date-click"],setup(t){const o=t,{days:l}=ee(e.toRef(o,"currentDate"),e.toRef(o,"selectedDate"),e.toRef(o,"events"),e.toRef(o,"dotMarkers"),o.weekStartsOn),s=e.computed(()=>b(o.locale,o.weekStartsOn));return(a,n)=>(e.openBlock(),e.createElementBlock("div",te,[e.createElementVNode("div",ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,d=>(e.openBlock(),e.createElementBlock("div",{key:d,class:"sc-week-view__weekday"},e.toDisplayString(d),1))),128))]),e.createElementVNode("div",oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l),d=>(e.openBlock(),e.createBlock(T,{key:d.dateStr,day:d,onClick:n[0]||(n[0]=m=>a.$emit("date-click",m))},null,8,["day"]))),128))])]))}}),ae={class:"sc-schedule-form"},se={class:"sc-schedule-form__field"},ce={class:"sc-schedule-form__field"},re={class:"sc-schedule-form__row"},de={class:"sc-schedule-form__field"},ie={class:"sc-schedule-form__field"},me={class:"sc-schedule-form__field"},ke={class:"sc-schedule-form__actions"},fe=["disabled"],he=e.defineComponent({__name:"ScheduleForm",props:{selectedDate:{},locale:{}},emits:["submit","cancel"],setup(t,{emit:o}){const l=t,s=o,a=e.computed(()=>g(l.locale)),n=e.reactive({title:"",date:l.selectedDate,startTime:"",endTime:"",description:""});function d(){n.title.trim()&&(s("submit",{title:n.title.trim(),date:n.date,startTime:n.startTime||void 0,endTime:n.endTime||void 0,description:n.description.trim()||void 0}),n.title="",n.startTime="",n.endTime="",n.description="")}return(m,c)=>(e.openBlock(),e.createElementBlock("div",ae,[e.createElementVNode("div",se,[e.createElementVNode("label",null,e.toDisplayString(a.value.title),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[0]||(c[0]=r=>n.title=r),type:"text",class:"sc-schedule-form__input"},null,512),[[e.vModelText,n.title]])]),e.createElementVNode("div",ce,[e.createElementVNode("label",null,e.toDisplayString(a.value.date),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[1]||(c[1]=r=>n.date=r),type:"date",class:"sc-schedule-form__input"},null,512),[[e.vModelText,n.date]])]),e.createElementVNode("div",re,[e.createElementVNode("div",de,[e.createElementVNode("label",null,e.toDisplayString(a.value.startTime),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[2]||(c[2]=r=>n.startTime=r),type:"time",class:"sc-schedule-form__input"},null,512),[[e.vModelText,n.startTime]])]),e.createElementVNode("div",ie,[e.createElementVNode("label",null,e.toDisplayString(a.value.endTime),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[3]||(c[3]=r=>n.endTime=r),type:"time",class:"sc-schedule-form__input"},null,512),[[e.vModelText,n.endTime]])])]),e.createElementVNode("div",me,[e.createElementVNode("label",null,e.toDisplayString(a.value.description),1),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":c[4]||(c[4]=r=>n.description=r),class:"sc-schedule-form__textarea",rows:"2"},null,512),[[e.vModelText,n.description]])]),e.createElementVNode("div",ke,[e.createElementVNode("button",{class:"sc-btn sc-btn--text",onClick:c[5]||(c[5]=r=>m.$emit("cancel"))},e.toDisplayString(a.value.cancel),1),e.createElementVNode("button",{class:"sc-btn sc-btn--primary",disabled:!n.title.trim(),onClick:d},e.toDisplayString(a.value.confirm),9,fe)])]))}}),ue={class:"sc-schedule-panel"},ye={class:"sc-schedule-panel__header"},pe={class:"sc-schedule-panel__date"},we={key:1,class:"sc-schedule-panel__empty"},De={key:2,class:"sc-schedule-panel__list"},_e={class:"sc-schedule-panel__item-content"},ge={class:"sc-schedule-panel__item-title"},Ee={key:0,class:"sc-schedule-panel__item-time"},Se={key:1,class:"sc-schedule-panel__item-desc"},Be=["title","onClick"],$e=e.defineComponent({__name:"SchedulePanel",props:{events:{},selectedDate:{},locale:{},readonly:{type:Boolean}},emits:["event-create","event-delete"],setup(t,{emit:o}){const l=t,s=o,a=e.ref(!1),n=e.computed(()=>g(l.locale)),d=e.computed(()=>{const c=O(l.selectedDate);return l.locale==="zh-CN"?`${c.getMonth()+1}月${c.getDate()}日`:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getMonth()]} ${c.getDate()}`});function m(c){s("event-create",c),a.value=!1}return(c,r)=>(e.openBlock(),e.createElementBlock("div",ue,[e.createElementVNode("div",ye,[e.createElementVNode("span",pe,e.toDisplayString(d.value),1),!t.readonly&&!a.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"sc-btn sc-btn--small sc-btn--primary",onClick:r[0]||(r[0]=i=>a.value=!0)},e.toDisplayString(n.value.addEvent),1)):e.createCommentVNode("",!0)]),a.value?(e.openBlock(),e.createBlock(he,{key:0,"selected-date":t.selectedDate,locale:t.locale,onSubmit:m,onCancel:r[1]||(r[1]=i=>a.value=!1)},null,8,["selected-date","locale"])):e.createCommentVNode("",!0),t.events.length===0&&!a.value?(e.openBlock(),e.createElementBlock("div",we,e.toDisplayString(n.value.noEvents),1)):(e.openBlock(),e.createElementBlock("div",De,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.events,i=>(e.openBlock(),e.createElementBlock("div",{key:i.id,class:"sc-schedule-panel__item"},[e.createElementVNode("div",{class:"sc-schedule-panel__item-bar",style:e.normalizeStyle({backgroundColor:i.color||"var(--sc-primary, #4f6ef7)"})},null,4),e.createElementVNode("div",_e,[e.createElementVNode("div",ge,e.toDisplayString(i.title),1),i.startTime?(e.openBlock(),e.createElementBlock("div",Ee,e.toDisplayString(i.startTime)+e.toDisplayString(i.endTime?" - "+i.endTime:""),1)):e.createCommentVNode("",!0),i.description?(e.openBlock(),e.createElementBlock("div",Se,e.toDisplayString(i.description),1)):e.createCommentVNode("",!0)]),t.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"sc-schedule-panel__item-delete",title:n.value.delete,onClick:y=>c.$emit("event-delete",i.id)}," × ",8,Be))]))),128))]))]))}}),Me={class:"sc-calendar"},F=e.defineComponent({__name:"ScheduleCalendar",props:{events:{default:()=>[]},dotMarkers:{default:()=>[]},viewMode:{default:"month"},selectedDate:{default:void 0},locale:{default:"zh-CN"},weekStartsOn:{default:0},showSchedulePanel:{type:Boolean,default:!0},readonly:{type:Boolean,default:!1}},emits:["date-click","event-create","event-delete","view-change","month-change","update:viewMode","update:selectedDate"],setup(t,{emit:o}){const l=t,s=o,{currentDate:a,viewMode:n,selectedDate:d,currentYear:m,currentMonth:c,headerTitle:r,goToday:i,goPrev:y,goNext:D,selectDate:k,setViewMode:p}=U(l.selectedDate,l.viewMode,l.locale,l.weekStartsOn),u=e.toRef(l,"events"),{selectedEvents:_}=W(u,d);e.watch(()=>l.viewMode,h=>{h!==n.value&&(n.value=h)}),e.watch(()=>l.selectedDate,h=>{h&&h!==d.value&&(d.value=h)});function f(h){k(h),s("update:selectedDate",h),s("date-click",h)}function B(h){p(h),s("update:viewMode",h),s("view-change",h)}function Ve(){y(),s("month-change",{year:m.value,month:c.value+1})}function Ce(){D(),s("month-change",{year:m.value,month:c.value+1})}function be(){i(),s("update:selectedDate",d.value),s("month-change",{year:m.value,month:c.value+1})}return(h,$)=>(e.openBlock(),e.createElementBlock("div",Me,[e.createVNode(q,{title:e.unref(r),"view-mode":e.unref(n),locale:t.locale,onPrev:Ve,onNext:Ce,onToday:be,onViewChange:B},null,8,["title","view-mode","locale"]),e.unref(n)==="month"?(e.openBlock(),e.createBlock(v,{key:0,year:e.unref(m),month:e.unref(c),"selected-date":e.unref(d),events:t.events,"dot-markers":t.dotMarkers,locale:t.locale,"week-starts-on":t.weekStartsOn,onDateClick:f},null,8,["year","month","selected-date","events","dot-markers","locale","week-starts-on"])):(e.openBlock(),e.createBlock(le,{key:1,"current-date":e.unref(a),"selected-date":e.unref(d),events:t.events,"dot-markers":t.dotMarkers,locale:t.locale,"week-starts-on":t.weekStartsOn,onDateClick:f},null,8,["current-date","selected-date","events","dot-markers","locale","week-starts-on"])),t.showSchedulePanel?(e.openBlock(),e.createBlock($e,{key:2,events:e.unref(_),"selected-date":e.unref(d),locale:t.locale,readonly:t.readonly,onEventCreate:$[0]||($[0]=M=>h.$emit("event-create",M)),onEventDelete:$[1]||($[1]=M=>h.$emit("event-delete",M))},null,8,["events","selected-date","locale","readonly"])):e.createCommentVNode("",!0)]))}}),Ne={install(t){t.component("ScheduleCalendar",F)}};w.ScheduleCalendar=F,w.default=Ne,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wpwp/schedule-calendar",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A Vue 3 schedule calendar component with month/week views, dot markers, and event management",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/vue-schedule-calendar.umd.cjs",
|
|
7
|
+
"module": "./dist/vue-schedule-calendar.es.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/vue-schedule-calendar.es.js",
|
|
13
|
+
"require": "./dist/vue-schedule-calendar.umd.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./style.css": "./dist/style.css"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "vite serve dev",
|
|
22
|
+
"build": "vite build && vue-tsc --declaration --emitDeclarationOnly --outDir dist",
|
|
23
|
+
"preview": "vite preview"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"vue": "^3.3.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
30
|
+
"typescript": "^5.7.0",
|
|
31
|
+
"vite": "^6.0.0",
|
|
32
|
+
"vue": "^3.5.0",
|
|
33
|
+
"vue-tsc": "^2.2.0"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"vue",
|
|
37
|
+
"vue3",
|
|
38
|
+
"calendar",
|
|
39
|
+
"schedule",
|
|
40
|
+
"datepicker",
|
|
41
|
+
"component"
|
|
42
|
+
],
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": ""
|
|
47
|
+
}
|
|
48
|
+
}
|