@calenderjs/calendar 0.0.2 → 0.3.1
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 +56 -0
- package/dist/index.cjs +531 -400
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +531 -400
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/event-runtime-integration.d.ts +16 -0
- package/dist/utils/event-runtime-integration.d.ts.map +1 -0
- package/dist/utils/event-utils.d.ts.map +1 -1
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/state-date.d.ts +37 -0
- package/dist/utils/state-date.d.ts.map +1 -0
- package/dist/utils/upgrade-property.d.ts +12 -0
- package/dist/utils/upgrade-property.d.ts.map +1 -0
- package/package.json +10 -9
package/dist/index.mjs
CHANGED
|
@@ -1,92 +1,128 @@
|
|
|
1
1
|
import { autoRegister, WebComponent, jsx } from "@wsxjs/wsx-core";
|
|
2
|
+
import { parseEventDSL, EventDSLCompiler } from "@calenderjs/event-dsl";
|
|
3
|
+
import { isSameDay, formatDateKey, getDayHours, getTimeString, getMonthDates, isSameMonth, getWeekDates } from "@calenderjs/date-time";
|
|
4
|
+
import { EventRuntime } from "@calenderjs/event-runtime";
|
|
2
5
|
export * from "@calenderjs/core";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const e = new Date(t);
|
|
11
|
-
if (isNaN(e.getTime()))
|
|
12
|
-
throw new Error(`Invalid date: ${t}`);
|
|
13
|
-
return e;
|
|
14
|
-
}
|
|
15
|
-
throw new Error(`Invalid date type: expected Date or string, got ${typeof t}`);
|
|
6
|
+
const styles$3 = '/* Calendar Component Styles - Google Calendar Inspired */\n\n:host {\n display: block;\n width: 100%;\n height: 100%;\n font-family: var(\n --calender-font-family,\n "Google Sans",\n Roboto,\n Arial,\n sans-serif\n );\n font-size: var(--calender-font-size, 14px);\n color: var(--calender-text-color, #202124);\n background: var(--calender-bg-color, #fff);\n}\n\n.calendar {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: var(--calender-bg-color, #fff);\n}\n\n/* Toolbar Styles */\n.calendar-toolbar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--calender-toolbar-padding, 8px 16px);\n border-bottom: 1px solid var(--calender-border-color, #dadce0);\n background: var(--calender-bg-color, #fff);\n min-height: var(--calender-toolbar-min-height, 48px);\n}\n\n.calendar-toolbar-left {\n display: flex;\n align-items: center;\n gap: var(--calender-toolbar-gap, 8px);\n}\n\n.calendar-toolbar-right {\n display: flex;\n align-items: center;\n gap: var(--calender-toolbar-gap, 8px);\n}\n\n.calendar-nav-button {\n display: flex;\n align-items: center;\n justify-content: center;\n width: var(--calender-nav-button-size, 40px);\n height: var(--calender-nav-button-size, 40px);\n border: none;\n background: transparent;\n border-radius: 50%;\n cursor: pointer;\n color: var(--calender-text-secondary-color, #5f6368);\n transition: background-color var(--calender-transition-duration, 0.2s);\n}\n\n.calendar-nav-button:hover {\n background-color: var(--calender-hover-bg-color, #f1f3f4);\n}\n\n.calendar-nav-button:active {\n background-color: var(--calender-active-bg-color, #e8eaed);\n}\n\n.calendar-nav-button svg {\n width: var(--calender-icon-size, 24px);\n height: var(--calender-icon-size, 24px);\n fill: currentColor;\n}\n\n.calendar-today-button {\n padding: var(--calender-button-padding, 8px 16px);\n border: 1px solid var(--calender-border-color, #dadce0);\n border-radius: var(--calender-border-radius, 4px);\n background: var(--calender-bg-color, #fff);\n color: var(--calender-text-color, #202124);\n font-size: var(--calender-font-size, 14px);\n font-weight: var(--calender-button-font-weight, 500);\n cursor: pointer;\n transition:\n background-color var(--calender-transition-duration, 0.2s),\n border-color var(--calender-transition-duration, 0.2s);\n}\n\n.calendar-today-button:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n border-color: var(--calender-border-hover-color, #c4c7c5);\n}\n\n.calendar-today-button:active {\n background-color: var(--calender-active-bg-color, #f1f3f4);\n}\n\n.calendar-toolbar-date {\n font-size: var(--calender-toolbar-date-font-size, 22px);\n font-weight: var(--calender-toolbar-date-font-weight, 400);\n color: var(--calender-text-color, #202124);\n margin-left: var(--calender-toolbar-gap, 8px);\n min-width: var(--calender-toolbar-date-min-width, 200px);\n}\n\n.calendar-view-buttons {\n display: flex;\n gap: 0;\n border: 1px solid var(--calender-border-color, #dadce0);\n border-radius: var(--calender-border-radius, 4px);\n overflow: hidden;\n}\n\n.calendar-view-button {\n padding: var(--calender-button-padding, 8px 16px);\n border: none;\n background: var(--calender-bg-color, #fff);\n color: var(--calender-text-secondary-color, #5f6368);\n font-size: var(--calender-font-size, 14px);\n font-weight: var(--calender-button-font-weight, 500);\n cursor: pointer;\n transition:\n background-color var(--calender-transition-duration, 0.2s),\n color var(--calender-transition-duration, 0.2s);\n border-right: 1px solid var(--calender-border-color, #dadce0);\n}\n\n.calendar-view-button:last-child {\n border-right: none;\n}\n\n.calendar-view-button:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n}\n\n.calendar-view-button.active {\n background-color: var(--calender-primary-color, #1a73e8);\n color: var(--calender-primary-text-color, #fff);\n}\n\n.calendar-view-button.active:hover {\n background-color: var(--calender-primary-hover-color, #1765cc);\n}\n';
|
|
7
|
+
function createRuntimeMap(dataModel) {
|
|
8
|
+
const map = /* @__PURE__ */ new Map();
|
|
9
|
+
for (const typeModel of dataModel.types) {
|
|
10
|
+
map.set(typeModel.id, new EventRuntime(typeModel));
|
|
11
|
+
}
|
|
12
|
+
return map;
|
|
16
13
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
function mergeRenderedIntoEvent(event, rendered) {
|
|
15
|
+
return {
|
|
16
|
+
...event,
|
|
17
|
+
title: rendered.title ?? event.title,
|
|
18
|
+
color: rendered.color ?? event.color,
|
|
19
|
+
icon: rendered.icon ?? event.icon
|
|
20
|
+
};
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
function getDisplayEvents(events, runtimeByType, user) {
|
|
23
|
+
if (!runtimeByType || runtimeByType.size === 0) {
|
|
24
|
+
return events;
|
|
25
|
+
}
|
|
26
|
+
const renderContext = { user };
|
|
27
|
+
return events.map((event) => {
|
|
28
|
+
const runtime = runtimeByType.get(event.type);
|
|
29
|
+
if (!runtime) {
|
|
30
|
+
return event;
|
|
31
|
+
}
|
|
32
|
+
return mergeRenderedIntoEvent(event, runtime.render(event, renderContext));
|
|
33
|
+
});
|
|
24
34
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
function buildValidationContext(events, user) {
|
|
36
|
+
return {
|
|
37
|
+
events,
|
|
38
|
+
now: /* @__PURE__ */ new Date(),
|
|
39
|
+
user
|
|
40
|
+
};
|
|
31
41
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
function validateEventWithRuntime(event, runtimeByType, allEvents, user) {
|
|
43
|
+
if (!runtimeByType || runtimeByType.size === 0) {
|
|
44
|
+
return { valid: true, errors: [] };
|
|
45
|
+
}
|
|
46
|
+
const runtime = runtimeByType.get(event.type);
|
|
47
|
+
if (!runtime) {
|
|
48
|
+
return { valid: true, errors: [] };
|
|
49
|
+
}
|
|
50
|
+
return runtime.validate(event, buildValidationContext(allEvents, user));
|
|
35
51
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
function canPerformEventAction(action, event, runtimeByType, user) {
|
|
53
|
+
if (!runtimeByType || runtimeByType.size === 0 || !user) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
const runtime = runtimeByType.get(event.type);
|
|
57
|
+
if (!runtime) {
|
|
58
|
+
return true;
|
|
41
59
|
}
|
|
42
|
-
return
|
|
60
|
+
return runtime.canPerform(action, event, user);
|
|
43
61
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
const INVALID_STATE_DATE = "Invalid date for WSX @state";
|
|
63
|
+
const UNSELECTED_DATE_ISO = (/* @__PURE__ */ new Date(0)).toISOString();
|
|
64
|
+
function toStateIso(value) {
|
|
65
|
+
if (typeof value === "string") {
|
|
66
|
+
const parsed = new Date(value);
|
|
67
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
68
|
+
throw new Error(`${INVALID_STATE_DATE}: ${value}`);
|
|
69
|
+
}
|
|
70
|
+
return parsed.toISOString();
|
|
71
|
+
}
|
|
72
|
+
const time = value.getTime();
|
|
73
|
+
if (Number.isNaN(time)) {
|
|
74
|
+
throw new Error(INVALID_STATE_DATE);
|
|
49
75
|
}
|
|
50
|
-
return
|
|
76
|
+
return new Date(time).toISOString();
|
|
51
77
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
return n.getFullYear() === r.getFullYear() && n.getMonth() === r.getMonth() && n.getDate() === r.getDate();
|
|
78
|
+
function fromStateIso(iso) {
|
|
79
|
+
return new Date(iso);
|
|
55
80
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
function toStateIsoOrUnselected(value) {
|
|
82
|
+
if (value === null || value === void 0) {
|
|
83
|
+
return UNSELECTED_DATE_ISO;
|
|
84
|
+
}
|
|
85
|
+
if (typeof value === "string") {
|
|
86
|
+
const parsed = new Date(value);
|
|
87
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
88
|
+
return UNSELECTED_DATE_ISO;
|
|
89
|
+
}
|
|
90
|
+
return parsed.toISOString();
|
|
91
|
+
}
|
|
92
|
+
return toStateIso(value);
|
|
59
93
|
}
|
|
60
|
-
function
|
|
61
|
-
return
|
|
94
|
+
function normalizeEventForState(event) {
|
|
95
|
+
return {
|
|
96
|
+
...event,
|
|
97
|
+
startTime: toStateIso(event.startTime),
|
|
98
|
+
endTime: toStateIso(event.endTime)
|
|
99
|
+
};
|
|
62
100
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
if (isNaN(t.getTime()))
|
|
66
|
-
throw new Error(`Invalid date: ${t}`);
|
|
67
|
-
return t;
|
|
68
|
-
}
|
|
69
|
-
if (typeof t == "string") {
|
|
70
|
-
const e = new Date(t);
|
|
71
|
-
if (isNaN(e.getTime()))
|
|
72
|
-
throw new Error(`Invalid date: ${t}`);
|
|
73
|
-
return e;
|
|
74
|
-
}
|
|
75
|
-
throw new Error(`Invalid date type: expected Date or string, got ${typeof t}`);
|
|
101
|
+
function normalizeEventsForState(events) {
|
|
102
|
+
return events.map((event) => normalizeEventForState(event));
|
|
76
103
|
}
|
|
77
|
-
function
|
|
78
|
-
|
|
79
|
-
|
|
104
|
+
function upgradeProperty(target, prop) {
|
|
105
|
+
if (!Object.prototype.hasOwnProperty.call(target, prop)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, prop);
|
|
109
|
+
if (!descriptor || descriptor.get || descriptor.set) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const record = target;
|
|
113
|
+
const value = record[prop];
|
|
114
|
+
delete record[prop];
|
|
115
|
+
record[prop] = value;
|
|
80
116
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
117
|
+
function upgradeProperties(target, props) {
|
|
118
|
+
for (const prop of props) {
|
|
119
|
+
upgradeProperty(target, prop);
|
|
120
|
+
}
|
|
84
121
|
}
|
|
85
|
-
const styles$3 = '/* Calendar Component Styles - Google Calendar Inspired */\n\n:host {\n display: block;\n width: 100%;\n height: 100%;\n font-family: var(\n --calender-font-family,\n "Google Sans",\n Roboto,\n Arial,\n sans-serif\n );\n font-size: var(--calender-font-size, 14px);\n color: var(--calender-text-color, #202124);\n background: var(--calender-bg-color, #fff);\n}\n\n.calendar {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: var(--calender-bg-color, #fff);\n}\n\n/* Toolbar Styles */\n.calendar-toolbar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--calender-toolbar-padding, 8px 16px);\n border-bottom: 1px solid var(--calender-border-color, #dadce0);\n background: var(--calender-bg-color, #fff);\n min-height: var(--calender-toolbar-min-height, 48px);\n}\n\n.calendar-toolbar-left {\n display: flex;\n align-items: center;\n gap: var(--calender-toolbar-gap, 8px);\n}\n\n.calendar-toolbar-right {\n display: flex;\n align-items: center;\n gap: var(--calender-toolbar-gap, 8px);\n}\n\n.calendar-nav-button {\n display: flex;\n align-items: center;\n justify-content: center;\n width: var(--calender-nav-button-size, 40px);\n height: var(--calender-nav-button-size, 40px);\n border: none;\n background: transparent;\n border-radius: 50%;\n cursor: pointer;\n color: var(--calender-text-secondary-color, #5f6368);\n transition: background-color var(--calender-transition-duration, 0.2s);\n}\n\n.calendar-nav-button:hover {\n background-color: var(--calender-hover-bg-color, #f1f3f4);\n}\n\n.calendar-nav-button:active {\n background-color: var(--calender-active-bg-color, #e8eaed);\n}\n\n.calendar-nav-button svg {\n width: var(--calender-icon-size, 24px);\n height: var(--calender-icon-size, 24px);\n fill: currentColor;\n}\n\n.calendar-today-button {\n padding: var(--calender-button-padding, 8px 16px);\n border: 1px solid var(--calender-border-color, #dadce0);\n border-radius: var(--calender-border-radius, 4px);\n background: var(--calender-bg-color, #fff);\n color: var(--calender-text-color, #202124);\n font-size: var(--calender-font-size, 14px);\n font-weight: var(--calender-button-font-weight, 500);\n cursor: pointer;\n transition: background-color var(--calender-transition-duration, 0.2s),\n border-color var(--calender-transition-duration, 0.2s);\n}\n\n.calendar-today-button:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n border-color: var(--calender-border-hover-color, #c4c7c5);\n}\n\n.calendar-today-button:active {\n background-color: var(--calender-active-bg-color, #f1f3f4);\n}\n\n.calendar-toolbar-date {\n font-size: var(--calender-toolbar-date-font-size, 22px);\n font-weight: var(--calender-toolbar-date-font-weight, 400);\n color: var(--calender-text-color, #202124);\n margin-left: var(--calender-toolbar-gap, 8px);\n min-width: var(--calender-toolbar-date-min-width, 200px);\n}\n\n.calendar-view-buttons {\n display: flex;\n gap: 0;\n border: 1px solid var(--calender-border-color, #dadce0);\n border-radius: var(--calender-border-radius, 4px);\n overflow: hidden;\n}\n\n.calendar-view-button {\n padding: var(--calender-button-padding, 8px 16px);\n border: none;\n background: var(--calender-bg-color, #fff);\n color: var(--calender-text-secondary-color, #5f6368);\n font-size: var(--calender-font-size, 14px);\n font-weight: var(--calender-button-font-weight, 500);\n cursor: pointer;\n transition: background-color var(--calender-transition-duration, 0.2s),\n color var(--calender-transition-duration, 0.2s);\n border-right: 1px solid var(--calender-border-color, #dadce0);\n}\n\n.calendar-view-button:last-child {\n border-right: none;\n}\n\n.calendar-view-button:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n}\n\n.calendar-view-button.active {\n background-color: var(--calender-primary-color, #1a73e8);\n color: var(--calender-primary-text-color, #fff);\n}\n\n.calendar-view-button.active:hover {\n background-color: var(--calender-primary-hover-color, #1765cc);\n}\n';
|
|
86
122
|
function groupEventsByDate(events) {
|
|
87
123
|
const grouped = /* @__PURE__ */ new Map();
|
|
88
124
|
for (const event of events) {
|
|
89
|
-
const dateKey =
|
|
125
|
+
const dateKey = formatDateKey(event.startTime);
|
|
90
126
|
if (!grouped.has(dateKey)) {
|
|
91
127
|
grouped.set(dateKey, []);
|
|
92
128
|
}
|
|
@@ -97,7 +133,7 @@ function groupEventsByDate(events) {
|
|
|
97
133
|
function getEventsForDate(events, date) {
|
|
98
134
|
return events.filter((event) => {
|
|
99
135
|
const eventDate = event.startTime instanceof Date ? event.startTime : new Date(event.startTime);
|
|
100
|
-
return
|
|
136
|
+
return isSameDay(eventDate, date);
|
|
101
137
|
});
|
|
102
138
|
}
|
|
103
139
|
function sortEventsByTime(events) {
|
|
@@ -126,14 +162,14 @@ function calculateEventPosition(event, dayStart, dayEnd) {
|
|
|
126
162
|
const height = (eventEndMs - eventStartMs) / dayDuration * 100;
|
|
127
163
|
return { top, height };
|
|
128
164
|
}
|
|
129
|
-
const styles$2 = '/* Day View Styles - Google Calendar Inspired */\n\n:host {\n
|
|
165
|
+
const styles$2 = '/* Day View Styles - Google Calendar Inspired */\n\n:host {\n display: block;\n width: 100%;\n height: 100%;\n overflow: auto;\n}\n\n.day-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: var(--calender-bg-color, #fff);\n}\n\n.day-view-header {\n padding: var(--calender-day-header-padding, 16px 24px);\n border-bottom: 1px solid var(--calender-border-color, #dadce0);\n background: var(--calender-bg-color, #fff);\n position: sticky;\n top: 0;\n z-index: 10;\n}\n\n.day-view-date {\n font-size: var(--calender-day-header-date-font-size, 22px);\n font-weight: var(--calender-day-header-date-font-weight, 400);\n color: var(--calender-text-color, #202124);\n display: flex;\n align-items: center;\n}\n\n.day-view-date.today {\n color: var(--calender-primary-color, #1a73e8);\n font-weight: var(--calender-day-header-date-font-weight-today, 500);\n}\n\n.day-view-date.today::after {\n content: "今天";\n font-size: 12px;\n background-color: var(--calender-primary-color, #1a73e8);\n color: #fff;\n padding: 2px 6px;\n border-radius: 4px;\n margin-left: 8px;\n font-weight: 500;\n line-height: 1.2;\n}\n\n.day-view-body {\n display: grid;\n grid-template-columns: var(--calender-day-time-gutter-width, 60px) 1fr;\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.day-view-time-column {\n border-right: 1px solid var(--calender-border-color, #dadce0);\n position: sticky;\n left: 0;\n background: var(--calender-bg-color, #fff);\n z-index: 5;\n grid-column: 1;\n width: var(--calender-day-time-gutter-width, 60px);\n min-width: var(--calender-day-time-gutter-width, 60px);\n}\n\n.day-view-events-column {\n position: relative;\n grid-column: 2;\n}\n\n.day-view-hour-label {\n height: var(--calender-hour-cell-height, 48px);\n border-bottom: 1px solid var(--calender-border-light-color, #e8eaed);\n padding: 0;\n display: flex;\n align-items: flex-start;\n justify-content: flex-end;\n font-size: var(--calender-time-label-font-size, 12px);\n color: var(--calender-text-secondary-color, #70757a);\n position: relative;\n box-sizing: border-box;\n padding-right: var(--calender-time-label-padding-right, 8px);\n padding-top: var(--calender-time-label-padding-top, 4px);\n}\n\n.day-view-hour::before {\n content: "";\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 1px;\n background: var(--calender-border-light-color, #e8eaed);\n}\n\n/* 保留旧的类名以兼容 */\n.day-view-time-slot {\n height: var(--calender-hour-cell-height, 48px);\n border-bottom: 1px solid var(--calender-border-light-color, #e8eaed);\n padding: 0 var(--calender-time-label-padding-right, 8px);\n display: flex;\n align-items: flex-start;\n font-size: var(--calender-time-label-font-size, 12px);\n color: var(--calender-text-secondary-color, #70757a);\n position: relative;\n}\n\n.day-view-time-slot::before {\n content: "";\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 1px;\n background: var(--calender-border-light-color, #e8eaed);\n}\n\n.day-view-main-column {\n position: relative;\n}\n\n.day-view-hour-cell {\n height: var(--calender-hour-cell-height, 48px);\n border-bottom: 1px solid var(--calender-border-light-color, #e8eaed);\n cursor: pointer;\n transition: background-color var(--calender-transition-duration-fast, 0.15s);\n position: relative;\n box-sizing: border-box;\n}\n\n.day-view-hour-cell:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n}\n\n.day-view-hour-cell.selected {\n background-color: var(--calender-selected-bg-color, #e8f0fe);\n}\n\n/* 保留旧的类名以兼容 */\n.day-view-time-slot-cell {\n height: var(--calender-hour-cell-height, 48px);\n border-bottom: 1px solid var(--calender-border-light-color, #e8eaed);\n cursor: pointer;\n transition: background-color var(--calender-transition-duration-fast, 0.15s);\n position: relative;\n}\n\n.day-view-time-slot-cell:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n}\n\n.day-view-time-slot-cell.selected {\n background-color: var(--calender-selected-bg-color, #e8f0fe);\n}\n\n.day-view-event {\n position: absolute;\n left: var(--calender-day-event-margin, 2px);\n right: var(--calender-day-event-margin, 2px);\n padding: var(--calender-day-event-padding, 6px 10px);\n border-radius: var(--calender-event-border-radius, 3px);\n font-size: var(--calender-day-event-font-size, 13px);\n color: var(--calender-event-text-color, #fff);\n cursor: pointer;\n overflow: hidden;\n z-index: 2;\n box-shadow: var(--calender-event-box-shadow, 0 1px 2px rgba(0, 0, 0, 0.1));\n transition:\n box-shadow var(--calender-transition-duration, 0.2s),\n z-index var(--calender-transition-duration, 0.2s);\n line-height: var(--calender-day-event-line-height, 1.4);\n}\n\n.day-view-event:hover {\n box-shadow: var(\n --calender-event-hover-box-shadow,\n 0 2px 4px rgba(0, 0, 0, 0.15)\n );\n z-index: 3;\n}\n\n.day-view-event-title {\n font-weight: var(--calender-event-title-font-weight, 500);\n margin-bottom: var(--calender-day-event-title-margin-bottom, 4px);\n}\n\n.day-view-event-time {\n font-size: var(--calender-event-time-font-size, 12px);\n opacity: var(--calender-event-time-opacity, 0.9);\n}\n\n.day-view-event-description {\n font-size: var(--calender-event-description-font-size, 12px);\n opacity: var(--calender-event-description-opacity, 0.85);\n margin-top: var(--calender-event-description-margin-top, 4px);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n';
|
|
130
166
|
var _DayView2;
|
|
131
167
|
let _initClass$3, _classDecs$3;
|
|
132
168
|
function _defineProperty$3(e, r, t) {
|
|
133
169
|
return (r = _toPropertyKey$3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
134
170
|
}
|
|
135
171
|
function _applyDecs$3(e, t, r, n, o, a) {
|
|
136
|
-
function
|
|
172
|
+
function i(e2, t2, r2) {
|
|
137
173
|
return function(n2, o2) {
|
|
138
174
|
return r2 && r2(n2), e2[t2].call(n2, o2);
|
|
139
175
|
};
|
|
@@ -146,93 +182,93 @@ function _applyDecs$3(e, t, r, n, o, a) {
|
|
|
146
182
|
if ("function" != typeof e2 && (n2 || void 0 !== e2)) throw new TypeError(t2 + " must " + (r2 || "be") + " a function" + (n2 ? "" : " or undefined"));
|
|
147
183
|
return e2;
|
|
148
184
|
}
|
|
149
|
-
function applyDec(e2, t2, r2, n2, o2, a2, c2, u2,
|
|
150
|
-
function
|
|
151
|
-
if (!
|
|
185
|
+
function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l2, f2, p2, d, h) {
|
|
186
|
+
function m(e3) {
|
|
187
|
+
if (!h(e3)) throw new TypeError("Attempted to access private element on non-instance");
|
|
152
188
|
}
|
|
153
189
|
var y, v = t2[0], g = t2[3], b = !u2;
|
|
154
190
|
if (!b) {
|
|
155
191
|
r2 || Array.isArray(v) || (v = [v]);
|
|
156
|
-
var
|
|
157
|
-
f2 ? (
|
|
192
|
+
var w = {}, S = [], A = 3 === o2 ? "get" : 4 === o2 || d ? "set" : "value";
|
|
193
|
+
f2 ? (p2 || d ? w = { get: _setFunctionName$3(function() {
|
|
158
194
|
return g(this);
|
|
159
195
|
}, n2, "get"), set: function(e3) {
|
|
160
196
|
t2[4](this, e3);
|
|
161
|
-
} } :
|
|
197
|
+
} } : w[A] = g, p2 || _setFunctionName$3(w[A], n2, 2 === o2 ? "" : A)) : p2 || (w = Object.getOwnPropertyDescriptor(e2, n2));
|
|
162
198
|
}
|
|
163
199
|
for (var P = e2, j = v.length - 1; j >= 0; j -= r2 ? 2 : 1) {
|
|
164
|
-
var
|
|
200
|
+
var D = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
|
|
165
201
|
if (e3.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
166
202
|
s(t3, "An initializer", "be", true), c2.push(t3);
|
|
167
203
|
}).bind(null, I) };
|
|
168
204
|
try {
|
|
169
|
-
if (b) (y = s(
|
|
205
|
+
if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);
|
|
170
206
|
else {
|
|
171
|
-
var k,
|
|
172
|
-
O.static =
|
|
173
|
-
return
|
|
174
|
-
} : (o2 < 4 && (k =
|
|
207
|
+
var k, F;
|
|
208
|
+
O.static = l2, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
|
|
209
|
+
return m(e3), w.value;
|
|
210
|
+
} : (o2 < 4 && (k = i(w, "get", m)), 3 !== o2 && (F = i(w, "set", m))) : (k = function(e3) {
|
|
175
211
|
return e3[n2];
|
|
176
|
-
}, (o2 < 2 || 4 === o2) && (
|
|
212
|
+
}, (o2 < 2 || 4 === o2) && (F = function(e3, t3) {
|
|
177
213
|
e3[n2] = t3;
|
|
178
214
|
}));
|
|
179
|
-
var N = O.access = { has: f2 ?
|
|
215
|
+
var N = O.access = { has: f2 ? h.bind() : function(e3) {
|
|
180
216
|
return n2 in e3;
|
|
181
217
|
} };
|
|
182
|
-
if (k && (N.get = k),
|
|
183
|
-
if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (
|
|
218
|
+
if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) {
|
|
219
|
+
if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);
|
|
184
220
|
else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
185
|
-
} else s(P, (
|
|
221
|
+
} else s(P, (p2 ? "field" : "method") + " decorators", "return") && (p2 ? S.push(P) : w[A] = P);
|
|
186
222
|
}
|
|
187
223
|
} finally {
|
|
188
224
|
I.v = true;
|
|
189
225
|
}
|
|
190
226
|
}
|
|
191
|
-
return (
|
|
227
|
+
return (p2 || d) && u2.push(function(e3, t3) {
|
|
192
228
|
for (var r3 = S.length - 1; r3 >= 0; r3--) t3 = S[r3].call(e3, t3);
|
|
193
229
|
return t3;
|
|
194
|
-
}),
|
|
230
|
+
}), p2 || b || (f2 ? d ? u2.push(i(w, "get"), i(w, "set")) : u2.push(2 === o2 ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e2, n2, w)), P;
|
|
195
231
|
}
|
|
196
232
|
function u(e2, t2) {
|
|
197
233
|
return Object.defineProperty(e2, Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata"), { configurable: true, enumerable: true, value: t2 });
|
|
198
234
|
}
|
|
199
|
-
if (arguments.length >= 6) var
|
|
200
|
-
var f = Object.create(null ==
|
|
201
|
-
var o2, a2,
|
|
235
|
+
if (arguments.length >= 6) var l = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
|
|
236
|
+
var f = Object.create(null == l ? null : l), p = (function(e2, t2, r2, n2) {
|
|
237
|
+
var o2, a2, i2 = [], s2 = function(t3) {
|
|
202
238
|
return _checkInRHS$3(t3) === e2;
|
|
203
239
|
}, u2 = /* @__PURE__ */ new Map();
|
|
204
|
-
function
|
|
205
|
-
e3 &&
|
|
240
|
+
function l2(e3) {
|
|
241
|
+
e3 && i2.push(c.bind(null, e3));
|
|
206
242
|
}
|
|
207
243
|
for (var f2 = 0; f2 < t2.length; f2++) {
|
|
208
|
-
var
|
|
209
|
-
if (Array.isArray(
|
|
210
|
-
var
|
|
211
|
-
if (!g && !
|
|
212
|
-
var
|
|
213
|
-
if (true ===
|
|
214
|
-
u2.set(b, !(
|
|
244
|
+
var p2 = t2[f2];
|
|
245
|
+
if (Array.isArray(p2)) {
|
|
246
|
+
var d = p2[1], h = p2[2], m = p2.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v;
|
|
247
|
+
if (!g && !m) {
|
|
248
|
+
var w = u2.get(b);
|
|
249
|
+
if (true === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
|
|
250
|
+
u2.set(b, !(d > 2) || d);
|
|
215
251
|
}
|
|
216
|
-
applyDec(v ? e2 : e2.prototype,
|
|
252
|
+
applyDec(v ? e2 : e2.prototype, p2, y, m ? "#" + h : _toPropertyKey$3(h), d, n2, v ? a2 = a2 || [] : o2 = o2 || [], i2, v, m, g, 1 === d, v && m ? s2 : r2);
|
|
217
253
|
}
|
|
218
254
|
}
|
|
219
|
-
return
|
|
255
|
+
return l2(o2), l2(a2), i2;
|
|
220
256
|
})(e, t, o, f);
|
|
221
|
-
return r.length || u(e, f), { e:
|
|
257
|
+
return r.length || u(e, f), { e: p, get c() {
|
|
222
258
|
var t2 = [];
|
|
223
259
|
return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t2), f), c.bind(null, t2, e)];
|
|
224
260
|
} };
|
|
225
261
|
}
|
|
226
262
|
function _toPropertyKey$3(t) {
|
|
227
|
-
var
|
|
228
|
-
return "symbol" == typeof
|
|
263
|
+
var i = _toPrimitive$3(t, "string");
|
|
264
|
+
return "symbol" == typeof i ? i : i + "";
|
|
229
265
|
}
|
|
230
266
|
function _toPrimitive$3(t, r) {
|
|
231
267
|
if ("object" != typeof t || !t) return t;
|
|
232
268
|
var e = t[Symbol.toPrimitive];
|
|
233
269
|
if (void 0 !== e) {
|
|
234
|
-
var
|
|
235
|
-
if ("object" != typeof
|
|
270
|
+
var i = e.call(t, r);
|
|
271
|
+
if ("object" != typeof i) return i;
|
|
236
272
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
237
273
|
}
|
|
238
274
|
return String(t);
|
|
@@ -249,6 +285,7 @@ function _checkInRHS$3(e) {
|
|
|
249
285
|
if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null"));
|
|
250
286
|
return e;
|
|
251
287
|
}
|
|
288
|
+
const UPGRADABLE_PROPS$3 = ["viewDate", "events", "user"];
|
|
252
289
|
_classDecs$3 = [autoRegister({
|
|
253
290
|
tagName: "wsx-day-view"
|
|
254
291
|
})];
|
|
@@ -259,18 +296,15 @@ class DayView extends WebComponent {
|
|
|
259
296
|
return ["view-date", "events", "user"];
|
|
260
297
|
}
|
|
261
298
|
// ========== 内部状态 ==========
|
|
299
|
+
// 日期存 ISO:避免 WSX reactive Proxy 破坏 Date
|
|
262
300
|
// ========== Property 访问器(WSX 组件之间使用) ==========
|
|
263
301
|
get viewDate() {
|
|
264
|
-
return this.
|
|
302
|
+
return fromStateIso(this._viewDateIso);
|
|
265
303
|
}
|
|
266
304
|
set viewDate(value) {
|
|
267
|
-
|
|
268
|
-
this.
|
|
269
|
-
}
|
|
270
|
-
const date = new Date(value);
|
|
271
|
-
if (!isNaN(date.getTime())) {
|
|
272
|
-
this._viewDate = date;
|
|
273
|
-
}
|
|
305
|
+
try {
|
|
306
|
+
this._viewDateIso = toStateIso(value);
|
|
307
|
+
} catch {
|
|
274
308
|
}
|
|
275
309
|
}
|
|
276
310
|
get events() {
|
|
@@ -278,10 +312,11 @@ class DayView extends WebComponent {
|
|
|
278
312
|
}
|
|
279
313
|
set events(value) {
|
|
280
314
|
if (Array.isArray(value)) {
|
|
281
|
-
this._events = value;
|
|
315
|
+
this._events = normalizeEventsForState(value);
|
|
282
316
|
} else if (typeof value === "string") {
|
|
283
317
|
try {
|
|
284
|
-
|
|
318
|
+
const parsed = JSON.parse(value);
|
|
319
|
+
this._events = Array.isArray(parsed) ? normalizeEventsForState(parsed) : [];
|
|
285
320
|
} catch (e) {
|
|
286
321
|
console.error("Invalid events JSON:", value);
|
|
287
322
|
this._events = [];
|
|
@@ -311,9 +346,10 @@ class DayView extends WebComponent {
|
|
|
311
346
|
styleName: "wsx-day-view"
|
|
312
347
|
});
|
|
313
348
|
_defineProperty$3(this, "_autoStyles", styles$2);
|
|
314
|
-
_defineProperty$3(this, "
|
|
349
|
+
_defineProperty$3(this, "_viewDateIso", void 0);
|
|
315
350
|
_defineProperty$3(this, "_events", void 0);
|
|
316
351
|
_defineProperty$3(this, "_user", void 0);
|
|
352
|
+
_defineProperty$3(this, "_today", void 0);
|
|
317
353
|
_defineProperty$3(this, "onEventClick", void 0);
|
|
318
354
|
_defineProperty$3(this, "handleEventClick", (event) => {
|
|
319
355
|
if (this.onEventClick) {
|
|
@@ -326,10 +362,13 @@ class DayView extends WebComponent {
|
|
|
326
362
|
bubbles: true
|
|
327
363
|
}));
|
|
328
364
|
});
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
365
|
+
const today = /* @__PURE__ */ new Date();
|
|
366
|
+
today.setHours(0, 0, 0, 0);
|
|
367
|
+
this._today = today;
|
|
368
|
+
const [_get_viewDateIso, _set_viewDateIso] = this.useState("_viewDateIso", (/* @__PURE__ */ new Date()).toISOString());
|
|
369
|
+
Object.defineProperty(this, "_viewDateIso", {
|
|
370
|
+
get: _get_viewDateIso,
|
|
371
|
+
set: _set_viewDateIso,
|
|
333
372
|
enumerable: true,
|
|
334
373
|
configurable: true
|
|
335
374
|
});
|
|
@@ -361,6 +400,7 @@ class DayView extends WebComponent {
|
|
|
361
400
|
// ========== 生命周期 ==========
|
|
362
401
|
onConnected() {
|
|
363
402
|
super.onConnected?.();
|
|
403
|
+
upgradeProperties(this, UPGRADABLE_PROPS$3);
|
|
364
404
|
this.initializeFromAttributes();
|
|
365
405
|
}
|
|
366
406
|
onAttributeChanged(name, oldValue, newValue) {
|
|
@@ -405,7 +445,7 @@ class DayView extends WebComponent {
|
|
|
405
445
|
return sortEventsByTime(getEventsForDate(this.events, this.viewDate));
|
|
406
446
|
}
|
|
407
447
|
get hours() {
|
|
408
|
-
return
|
|
448
|
+
return getDayHours();
|
|
409
449
|
}
|
|
410
450
|
get dayStart() {
|
|
411
451
|
const dayStart = new Date(this.viewDate);
|
|
@@ -419,31 +459,31 @@ class DayView extends WebComponent {
|
|
|
419
459
|
}
|
|
420
460
|
// ========== 渲染 ==========
|
|
421
461
|
render() {
|
|
422
|
-
return /* @__PURE__ */ jsx("div", { class: "day-view" }, /* @__PURE__ */ jsx("div", { class: "day-view-header" }, /* @__PURE__ */ jsx("div", { class:
|
|
462
|
+
return /* @__PURE__ */ jsx("div", { class: "day-view" }, /* @__PURE__ */ jsx("div", { class: "day-view-header" }, /* @__PURE__ */ jsx("div", { class: `day-view-date ${isSameDay(this.viewDate, this._today) ? "today" : ""}` }, this.viewDate.getFullYear(), "年", this.viewDate.getMonth() + 1, "月", this.viewDate.getDate(), "日"), /* @__PURE__ */ jsx("div", { class: "day-view-events-count" }, this.dayEvents.length, " 个事件")), /* @__PURE__ */ jsx("div", { class: "day-view-body" }, /* @__PURE__ */ jsx("div", { class: "day-view-time-column" }, this.hours.map((hour) => {
|
|
423
463
|
const hourStr = hour < 10 ? `0${hour}` : `${hour}`;
|
|
424
464
|
const timeStr = `${hourStr}:00`;
|
|
425
|
-
return /* @__PURE__ */ jsx("div", { class: "day-view-hour", key: hour,
|
|
465
|
+
return /* @__PURE__ */ jsx("div", { class: "day-view-hour-label", key: `left-hour-${hour}` }, timeStr);
|
|
426
466
|
})), /* @__PURE__ */ jsx("div", { class: "day-view-events-column" }, this.hours.map((hour) => {
|
|
427
|
-
return /* @__PURE__ */ jsx("div", { class: "day-view-hour-cell", key: hour });
|
|
467
|
+
return /* @__PURE__ */ jsx("div", { class: "day-view-hour-cell", key: `right-hour-${hour}` });
|
|
428
468
|
}), this.dayEvents.map((event) => {
|
|
429
469
|
const position = calculateEventPosition(event, this.dayStart, this.dayEnd);
|
|
430
470
|
const eventColor = event.color || "#4285f4";
|
|
431
|
-
const eventDescription = event.
|
|
432
|
-
return /* @__PURE__ */ jsx("div", { class: "day-view-event", key: event.id, style: `top: ${position.top}%; height: ${position.height}%; background-color: ${eventColor}`, onClick: () => this.handleEventClick(event), title: event.title }, /* @__PURE__ */ jsx("div", { class: "day-view-event-time" },
|
|
471
|
+
const eventDescription = event.data?.description;
|
|
472
|
+
return /* @__PURE__ */ jsx("div", { class: "day-view-event", key: event.id, style: `top: ${position.top}%; height: ${position.height}%; background-color: ${eventColor}`, onClick: () => this.handleEventClick(event), title: event.title }, /* @__PURE__ */ jsx("div", { class: "day-view-event-time" }, getTimeString(event.startTime), " -", " ", getTimeString(event.endTime)), /* @__PURE__ */ jsx("div", { class: "day-view-event-title" }, event.title), eventDescription && /* @__PURE__ */ jsx("div", { class: "day-view-event-description" }, eventDescription));
|
|
433
473
|
}))));
|
|
434
474
|
}
|
|
435
475
|
}
|
|
436
476
|
_DayView2 = DayView;
|
|
437
477
|
[_DayView, _initClass$3] = _applyDecs$3(_DayView2, [], _classDecs$3, 0, void 0, WebComponent).c;
|
|
438
478
|
_initClass$3();
|
|
439
|
-
const styles$1 = "/* Month View Styles - Google Calendar Inspired */\n\n:host {\n
|
|
479
|
+
const styles$1 = "/* Month View Styles - Google Calendar Inspired */\n\n:host {\n display: block;\n width: 100%;\n height: 100%;\n overflow: auto;\n}\n\n.month-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: var(--calender-bg-color, #fff);\n}\n\n.month-view-header {\n display: grid;\n grid-template-columns: repeat(7, 1fr);\n border-bottom: 1px solid var(--calender-border-color, #dadce0);\n background: var(--calender-bg-color, #fff);\n position: sticky;\n top: 0;\n z-index: 10;\n}\n\n.month-view-day-header {\n padding: var(--calender-month-header-padding, 12px 8px);\n text-align: center;\n font-size: var(--calender-month-header-font-size, 11px);\n font-weight: var(--calender-month-header-font-weight, 500);\n color: var(--calender-text-secondary-color, #70757a);\n text-transform: uppercase;\n border-right: 1px solid var(--calender-border-color, #dadce0);\n}\n\n.month-view-day-header:last-child {\n border-right: none;\n}\n\n.month-view-grid {\n display: grid;\n grid-template-columns: repeat(7, 1fr);\n flex: 1;\n overflow: auto;\n}\n\n.month-view-cell {\n min-height: var(--calender-month-cell-min-height, 100px);\n border-right: 1px solid var(--calender-border-color, #dadce0);\n border-bottom: 1px solid var(--calender-border-color, #dadce0);\n padding: var(--calender-month-cell-padding, 4px);\n cursor: pointer;\n transition: background-color var(--calender-transition-duration-fast, 0.15s);\n position: relative;\n}\n\n.month-view-cell:last-child {\n border-right: none;\n}\n\n.month-view-cell:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n}\n\n.month-view-cell.other-month {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n color: var(--calender-text-secondary-color, #70757a);\n}\n\n.month-view-cell.today {\n background-color: var(--calender-today-bg-color, #e8f0fe);\n}\n\n.month-view-cell.today .month-view-cell-date {\n color: var(--calender-primary-color, #1a73e8);\n font-weight: var(--calender-today-font-weight, 500);\n}\n\n.month-view-cell.selected {\n background-color: var(--calender-selected-bg-color, #e8f0fe);\n}\n\n.month-view-cell.selected .month-view-cell-date {\n color: var(--calender-primary-color, #1a73e8);\n font-weight: var(--calender-selected-font-weight, 500);\n}\n\n.month-view-cell-date {\n font-size: var(--calender-month-cell-date-font-size, 13px);\n padding: var(--calender-month-cell-date-padding, 4px 8px);\n margin-bottom: var(--calender-month-cell-date-margin-bottom, 4px);\n color: var(--calender-text-color, #202124);\n}\n\n.month-view-cell-events {\n display: flex;\n flex-direction: column;\n gap: var(--calender-event-gap, 2px);\n min-height: 0;\n}\n\n.month-view-event {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--calender-event-padding, 2px 6px);\n border-radius: var(--calender-event-border-radius, 3px);\n font-size: var(--calender-event-font-size, 12px);\n color: var(--calender-event-text-color, #fff);\n cursor: pointer;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n min-height: var(--calender-event-min-height, 18px);\n transition: opacity var(--calender-transition-duration, 0.2s);\n}\n\n.month-view-event:hover {\n opacity: var(--calender-event-hover-opacity, 0.9);\n}\n\n.month-view-event-title {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.month-view-event-delete {\n display: none;\n background: transparent;\n border: none;\n color: var(--calender-event-text-color, #fff);\n cursor: pointer;\n padding: var(--calender-event-delete-padding, 0 4px);\n font-size: var(--calender-event-delete-font-size, 16px);\n line-height: 1;\n opacity: var(--calender-event-delete-opacity, 0.8);\n}\n\n.month-view-event:hover .month-view-event-delete {\n display: block;\n}\n\n.month-view-event-delete:hover {\n opacity: 1;\n}\n\n.month-view-more {\n font-size: var(--calender-month-more-font-size, 11px);\n color: var(--calender-text-secondary-color, #5f6368);\n padding: var(--calender-month-more-padding, 2px 6px);\n cursor: pointer;\n margin-top: var(--calender-month-more-margin-top, 2px);\n}\n\n.month-view-more:hover {\n color: var(--calender-text-color, #202124);\n background-color: var(--calender-hover-bg-color, #f1f3f4);\n border-radius: var(--calender-event-border-radius, 3px);\n}\n";
|
|
440
480
|
var _MonthView2;
|
|
441
481
|
let _initClass$2, _classDecs$2;
|
|
442
482
|
function _defineProperty$2(e, r, t) {
|
|
443
483
|
return (r = _toPropertyKey$2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
444
484
|
}
|
|
445
485
|
function _applyDecs$2(e, t, r, n, o, a) {
|
|
446
|
-
function
|
|
486
|
+
function i(e2, t2, r2) {
|
|
447
487
|
return function(n2, o2) {
|
|
448
488
|
return r2 && r2(n2), e2[t2].call(n2, o2);
|
|
449
489
|
};
|
|
@@ -456,93 +496,93 @@ function _applyDecs$2(e, t, r, n, o, a) {
|
|
|
456
496
|
if ("function" != typeof e2 && (n2 || void 0 !== e2)) throw new TypeError(t2 + " must " + (r2 || "be") + " a function" + (n2 ? "" : " or undefined"));
|
|
457
497
|
return e2;
|
|
458
498
|
}
|
|
459
|
-
function applyDec(e2, t2, r2, n2, o2, a2, c2, u2,
|
|
460
|
-
function
|
|
461
|
-
if (!
|
|
499
|
+
function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l2, f2, p2, d, h) {
|
|
500
|
+
function m(e3) {
|
|
501
|
+
if (!h(e3)) throw new TypeError("Attempted to access private element on non-instance");
|
|
462
502
|
}
|
|
463
503
|
var y, v = t2[0], g = t2[3], b = !u2;
|
|
464
504
|
if (!b) {
|
|
465
505
|
r2 || Array.isArray(v) || (v = [v]);
|
|
466
|
-
var
|
|
467
|
-
f2 ? (
|
|
506
|
+
var w = {}, S = [], A = 3 === o2 ? "get" : 4 === o2 || d ? "set" : "value";
|
|
507
|
+
f2 ? (p2 || d ? w = { get: _setFunctionName$2(function() {
|
|
468
508
|
return g(this);
|
|
469
509
|
}, n2, "get"), set: function(e3) {
|
|
470
510
|
t2[4](this, e3);
|
|
471
|
-
} } :
|
|
511
|
+
} } : w[A] = g, p2 || _setFunctionName$2(w[A], n2, 2 === o2 ? "" : A)) : p2 || (w = Object.getOwnPropertyDescriptor(e2, n2));
|
|
472
512
|
}
|
|
473
513
|
for (var P = e2, j = v.length - 1; j >= 0; j -= r2 ? 2 : 1) {
|
|
474
|
-
var
|
|
514
|
+
var D = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
|
|
475
515
|
if (e3.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
476
516
|
s(t3, "An initializer", "be", true), c2.push(t3);
|
|
477
517
|
}).bind(null, I) };
|
|
478
518
|
try {
|
|
479
|
-
if (b) (y = s(
|
|
519
|
+
if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);
|
|
480
520
|
else {
|
|
481
|
-
var k,
|
|
482
|
-
O.static =
|
|
483
|
-
return
|
|
484
|
-
} : (o2 < 4 && (k =
|
|
521
|
+
var k, F;
|
|
522
|
+
O.static = l2, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
|
|
523
|
+
return m(e3), w.value;
|
|
524
|
+
} : (o2 < 4 && (k = i(w, "get", m)), 3 !== o2 && (F = i(w, "set", m))) : (k = function(e3) {
|
|
485
525
|
return e3[n2];
|
|
486
|
-
}, (o2 < 2 || 4 === o2) && (
|
|
526
|
+
}, (o2 < 2 || 4 === o2) && (F = function(e3, t3) {
|
|
487
527
|
e3[n2] = t3;
|
|
488
528
|
}));
|
|
489
|
-
var N = O.access = { has: f2 ?
|
|
529
|
+
var N = O.access = { has: f2 ? h.bind() : function(e3) {
|
|
490
530
|
return n2 in e3;
|
|
491
531
|
} };
|
|
492
|
-
if (k && (N.get = k),
|
|
493
|
-
if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (
|
|
532
|
+
if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) {
|
|
533
|
+
if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);
|
|
494
534
|
else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
495
|
-
} else s(P, (
|
|
535
|
+
} else s(P, (p2 ? "field" : "method") + " decorators", "return") && (p2 ? S.push(P) : w[A] = P);
|
|
496
536
|
}
|
|
497
537
|
} finally {
|
|
498
538
|
I.v = true;
|
|
499
539
|
}
|
|
500
540
|
}
|
|
501
|
-
return (
|
|
541
|
+
return (p2 || d) && u2.push(function(e3, t3) {
|
|
502
542
|
for (var r3 = S.length - 1; r3 >= 0; r3--) t3 = S[r3].call(e3, t3);
|
|
503
543
|
return t3;
|
|
504
|
-
}),
|
|
544
|
+
}), p2 || b || (f2 ? d ? u2.push(i(w, "get"), i(w, "set")) : u2.push(2 === o2 ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e2, n2, w)), P;
|
|
505
545
|
}
|
|
506
546
|
function u(e2, t2) {
|
|
507
547
|
return Object.defineProperty(e2, Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata"), { configurable: true, enumerable: true, value: t2 });
|
|
508
548
|
}
|
|
509
|
-
if (arguments.length >= 6) var
|
|
510
|
-
var f = Object.create(null ==
|
|
511
|
-
var o2, a2,
|
|
549
|
+
if (arguments.length >= 6) var l = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
|
|
550
|
+
var f = Object.create(null == l ? null : l), p = (function(e2, t2, r2, n2) {
|
|
551
|
+
var o2, a2, i2 = [], s2 = function(t3) {
|
|
512
552
|
return _checkInRHS$2(t3) === e2;
|
|
513
553
|
}, u2 = /* @__PURE__ */ new Map();
|
|
514
|
-
function
|
|
515
|
-
e3 &&
|
|
554
|
+
function l2(e3) {
|
|
555
|
+
e3 && i2.push(c.bind(null, e3));
|
|
516
556
|
}
|
|
517
557
|
for (var f2 = 0; f2 < t2.length; f2++) {
|
|
518
|
-
var
|
|
519
|
-
if (Array.isArray(
|
|
520
|
-
var
|
|
521
|
-
if (!g && !
|
|
522
|
-
var
|
|
523
|
-
if (true ===
|
|
524
|
-
u2.set(b, !(
|
|
558
|
+
var p2 = t2[f2];
|
|
559
|
+
if (Array.isArray(p2)) {
|
|
560
|
+
var d = p2[1], h = p2[2], m = p2.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v;
|
|
561
|
+
if (!g && !m) {
|
|
562
|
+
var w = u2.get(b);
|
|
563
|
+
if (true === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
|
|
564
|
+
u2.set(b, !(d > 2) || d);
|
|
525
565
|
}
|
|
526
|
-
applyDec(v ? e2 : e2.prototype,
|
|
566
|
+
applyDec(v ? e2 : e2.prototype, p2, y, m ? "#" + h : _toPropertyKey$2(h), d, n2, v ? a2 = a2 || [] : o2 = o2 || [], i2, v, m, g, 1 === d, v && m ? s2 : r2);
|
|
527
567
|
}
|
|
528
568
|
}
|
|
529
|
-
return
|
|
569
|
+
return l2(o2), l2(a2), i2;
|
|
530
570
|
})(e, t, o, f);
|
|
531
|
-
return r.length || u(e, f), { e:
|
|
571
|
+
return r.length || u(e, f), { e: p, get c() {
|
|
532
572
|
var t2 = [];
|
|
533
573
|
return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t2), f), c.bind(null, t2, e)];
|
|
534
574
|
} };
|
|
535
575
|
}
|
|
536
576
|
function _toPropertyKey$2(t) {
|
|
537
|
-
var
|
|
538
|
-
return "symbol" == typeof
|
|
577
|
+
var i = _toPrimitive$2(t, "string");
|
|
578
|
+
return "symbol" == typeof i ? i : i + "";
|
|
539
579
|
}
|
|
540
580
|
function _toPrimitive$2(t, r) {
|
|
541
581
|
if ("object" != typeof t || !t) return t;
|
|
542
582
|
var e = t[Symbol.toPrimitive];
|
|
543
583
|
if (void 0 !== e) {
|
|
544
|
-
var
|
|
545
|
-
if ("object" != typeof
|
|
584
|
+
var i = e.call(t, r);
|
|
585
|
+
if ("object" != typeof i) return i;
|
|
546
586
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
547
587
|
}
|
|
548
588
|
return String(t);
|
|
@@ -559,6 +599,7 @@ function _checkInRHS$2(e) {
|
|
|
559
599
|
if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null"));
|
|
560
600
|
return e;
|
|
561
601
|
}
|
|
602
|
+
const UPGRADABLE_PROPS$2 = ["viewDate", "events", "selectedDate", "user"];
|
|
562
603
|
_classDecs$2 = [autoRegister({
|
|
563
604
|
tagName: "wsx-month-view"
|
|
564
605
|
})];
|
|
@@ -569,18 +610,15 @@ class MonthView extends WebComponent {
|
|
|
569
610
|
return ["view-date", "events", "selected-date", "user"];
|
|
570
611
|
}
|
|
571
612
|
// ========== 内部状态 ==========
|
|
613
|
+
// 日期存 ISO:避免 WSX reactive Proxy 破坏 Date
|
|
572
614
|
// ========== Property 访问器(WSX 组件之间使用) ==========
|
|
573
615
|
get viewDate() {
|
|
574
|
-
return this.
|
|
616
|
+
return fromStateIso(this._viewDateIso);
|
|
575
617
|
}
|
|
576
618
|
set viewDate(value) {
|
|
577
|
-
|
|
578
|
-
this.
|
|
579
|
-
}
|
|
580
|
-
const date = new Date(value);
|
|
581
|
-
if (!isNaN(date.getTime())) {
|
|
582
|
-
this._viewDate = date;
|
|
583
|
-
}
|
|
619
|
+
try {
|
|
620
|
+
this._viewDateIso = toStateIso(value);
|
|
621
|
+
} catch {
|
|
584
622
|
}
|
|
585
623
|
}
|
|
586
624
|
get events() {
|
|
@@ -588,10 +626,11 @@ class MonthView extends WebComponent {
|
|
|
588
626
|
}
|
|
589
627
|
set events(value) {
|
|
590
628
|
if (Array.isArray(value)) {
|
|
591
|
-
this._events = value;
|
|
629
|
+
this._events = normalizeEventsForState(value);
|
|
592
630
|
} else if (typeof value === "string") {
|
|
593
631
|
try {
|
|
594
|
-
|
|
632
|
+
const parsed = JSON.parse(value);
|
|
633
|
+
this._events = Array.isArray(parsed) ? normalizeEventsForState(parsed) : [];
|
|
595
634
|
} catch (e) {
|
|
596
635
|
console.error("Invalid events JSON:", value);
|
|
597
636
|
this._events = [];
|
|
@@ -601,21 +640,10 @@ class MonthView extends WebComponent {
|
|
|
601
640
|
}
|
|
602
641
|
}
|
|
603
642
|
get selectedDate() {
|
|
604
|
-
return this.
|
|
643
|
+
return fromStateIso(this._selectedDateIso);
|
|
605
644
|
}
|
|
606
645
|
set selectedDate(value) {
|
|
607
|
-
|
|
608
|
-
this._selectedDate = value;
|
|
609
|
-
} else if (typeof value === "string") {
|
|
610
|
-
const date = new Date(value);
|
|
611
|
-
if (!isNaN(date.getTime())) {
|
|
612
|
-
this._selectedDate = date;
|
|
613
|
-
} else {
|
|
614
|
-
this._selectedDate = /* @__PURE__ */ new Date(0);
|
|
615
|
-
}
|
|
616
|
-
} else if (value === void 0 || value === null) {
|
|
617
|
-
this._selectedDate = /* @__PURE__ */ new Date(0);
|
|
618
|
-
}
|
|
646
|
+
this._selectedDateIso = toStateIsoOrUnselected(value);
|
|
619
647
|
}
|
|
620
648
|
get user() {
|
|
621
649
|
return this._user;
|
|
@@ -638,9 +666,9 @@ class MonthView extends WebComponent {
|
|
|
638
666
|
styleName: "wsx-month-view"
|
|
639
667
|
});
|
|
640
668
|
_defineProperty$2(this, "_autoStyles", styles$1);
|
|
641
|
-
_defineProperty$2(this, "
|
|
669
|
+
_defineProperty$2(this, "_viewDateIso", void 0);
|
|
642
670
|
_defineProperty$2(this, "_events", void 0);
|
|
643
|
-
_defineProperty$2(this, "
|
|
671
|
+
_defineProperty$2(this, "_selectedDateIso", void 0);
|
|
644
672
|
_defineProperty$2(this, "_user", void 0);
|
|
645
673
|
_defineProperty$2(this, "_today", void 0);
|
|
646
674
|
_defineProperty$2(this, "onDateClick", void 0);
|
|
@@ -700,10 +728,10 @@ class MonthView extends WebComponent {
|
|
|
700
728
|
const today = /* @__PURE__ */ new Date();
|
|
701
729
|
today.setHours(0, 0, 0, 0);
|
|
702
730
|
this._today = today;
|
|
703
|
-
const [
|
|
704
|
-
Object.defineProperty(this, "
|
|
705
|
-
get:
|
|
706
|
-
set:
|
|
731
|
+
const [_get_viewDateIso, _set_viewDateIso] = this.useState("_viewDateIso", (/* @__PURE__ */ new Date()).toISOString());
|
|
732
|
+
Object.defineProperty(this, "_viewDateIso", {
|
|
733
|
+
get: _get_viewDateIso,
|
|
734
|
+
set: _set_viewDateIso,
|
|
707
735
|
enumerable: true,
|
|
708
736
|
configurable: true
|
|
709
737
|
});
|
|
@@ -717,10 +745,10 @@ class MonthView extends WebComponent {
|
|
|
717
745
|
enumerable: true,
|
|
718
746
|
configurable: true
|
|
719
747
|
});
|
|
720
|
-
const [
|
|
721
|
-
Object.defineProperty(this, "
|
|
722
|
-
get:
|
|
723
|
-
set:
|
|
748
|
+
const [_get_selectedDateIso, _set_selectedDateIso] = this.useState("_selectedDateIso", UNSELECTED_DATE_ISO);
|
|
749
|
+
Object.defineProperty(this, "_selectedDateIso", {
|
|
750
|
+
get: _get_selectedDateIso,
|
|
751
|
+
set: _set_selectedDateIso,
|
|
724
752
|
enumerable: true,
|
|
725
753
|
configurable: true
|
|
726
754
|
});
|
|
@@ -742,6 +770,7 @@ class MonthView extends WebComponent {
|
|
|
742
770
|
// ========== 生命周期 ==========
|
|
743
771
|
onConnected() {
|
|
744
772
|
super.onConnected?.();
|
|
773
|
+
upgradeProperties(this, UPGRADABLE_PROPS$2);
|
|
745
774
|
this.initializeFromAttributes();
|
|
746
775
|
}
|
|
747
776
|
onAttributeChanged(name, oldValue, newValue) {
|
|
@@ -796,11 +825,13 @@ class MonthView extends WebComponent {
|
|
|
796
825
|
}
|
|
797
826
|
// ========== Getters ==========
|
|
798
827
|
get monthDates() {
|
|
799
|
-
|
|
800
|
-
|
|
828
|
+
let viewDate = this.viewDate;
|
|
829
|
+
if (Number.isNaN(viewDate.getTime())) {
|
|
830
|
+
this._viewDateIso = toStateIso(/* @__PURE__ */ new Date());
|
|
831
|
+
viewDate = this.viewDate;
|
|
801
832
|
}
|
|
802
833
|
try {
|
|
803
|
-
return
|
|
834
|
+
return getMonthDates(viewDate, 0);
|
|
804
835
|
} catch (e) {
|
|
805
836
|
console.error("Error getting month dates:", e);
|
|
806
837
|
return [];
|
|
@@ -822,14 +853,14 @@ class MonthView extends WebComponent {
|
|
|
822
853
|
}
|
|
823
854
|
const normalizedDate = new Date(date);
|
|
824
855
|
normalizedDate.setHours(0, 0, 0, 0);
|
|
825
|
-
const dateKey =
|
|
856
|
+
const dateKey = formatDateKey(normalizedDate);
|
|
826
857
|
const dayEvents = sortEventsByTime(this.eventsByDate.get(dateKey) || []);
|
|
827
|
-
const isCurrentMonth =
|
|
828
|
-
|
|
829
|
-
const isToday =
|
|
830
|
-
return /* @__PURE__ */ jsx("div", { key: dateKey, class: `month-view-cell ${!isCurrentMonth ? "other-month" : ""} ${
|
|
858
|
+
const isCurrentMonth = !Number.isNaN(this.viewDate.getTime()) ? isSameMonth(normalizedDate, this.viewDate) : false;
|
|
859
|
+
this.selectedDate.getTime() !== 0 && isSameDay(normalizedDate, this.selectedDate);
|
|
860
|
+
const isToday = isSameDay(normalizedDate, this._today);
|
|
861
|
+
return /* @__PURE__ */ jsx("div", { key: dateKey, class: `month-view-cell ${!isCurrentMonth ? "other-month" : ""} ${isToday && isCurrentMonth ? "today" : ""}`, onClick: () => this.handleDateClick(normalizedDate), onDblClick: () => this.handleDateDoubleClick(normalizedDate) }, /* @__PURE__ */ jsx("div", { class: "month-view-cell-date" }, normalizedDate.getDate()), /* @__PURE__ */ jsx("div", { class: "month-view-cell-events" }, dayEvents.slice(0, 3).map((event) => {
|
|
831
862
|
const eventColor = event.color || "#4285f4";
|
|
832
|
-
return /* @__PURE__ */ jsx("div", { class: "month-view-event", key: event.id, style: `background-color: ${eventColor}`, onClick: (evt) => this.handleEventClick(event, evt) }, /* @__PURE__ */ jsx("span", { class: "month-view-event-title" }, event.title), this.onEventDelete && /* @__PURE__ */ jsx("button", { class: "month-view-event-delete", onClick: (evt) => this.handleEventDelete(event, evt)
|
|
863
|
+
return /* @__PURE__ */ jsx("div", { class: "month-view-event", key: event.id, style: `background-color: ${eventColor}`, onClick: (evt) => this.handleEventClick(event, evt) }, /* @__PURE__ */ jsx("span", { class: "month-view-event-title" }, event.title), this.onEventDelete && /* @__PURE__ */ jsx("button", { class: "month-view-event-delete", onClick: (evt) => this.handleEventDelete(event, evt) }, "×"));
|
|
833
864
|
}), dayEvents.length > 3 && /* @__PURE__ */ jsx("div", { class: "month-view-more" }, "+", dayEvents.length - 3, " 更多")));
|
|
834
865
|
})));
|
|
835
866
|
}
|
|
@@ -837,14 +868,14 @@ class MonthView extends WebComponent {
|
|
|
837
868
|
_MonthView2 = MonthView;
|
|
838
869
|
[_MonthView, _initClass$2] = _applyDecs$2(_MonthView2, [], _classDecs$2, 0, void 0, WebComponent).c;
|
|
839
870
|
_initClass$2();
|
|
840
|
-
const styles = "/* Week View Styles - Google Calendar Inspired */\n\n:host {\n
|
|
871
|
+
const styles = "/* Week View Styles - Google Calendar Inspired */\n\n:host {\n display: block;\n width: 100%;\n height: 100%;\n overflow: auto;\n}\n\n.week-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: var(--calender-bg-color, #fff);\n}\n\n.week-view-header {\n display: grid;\n grid-template-columns: var(--calender-week-time-gutter-width, 60px) repeat(\n 7,\n 1fr\n );\n border-bottom: 1px solid var(--calender-border-color, #dadce0);\n background: var(--calender-bg-color, #fff);\n position: sticky;\n top: 0;\n z-index: 10;\n}\n\n/* Header 中的时间列(空占位) */\n.week-view-header > .week-view-time-gutter {\n border-right: 1px solid var(--calender-border-color, #dadce0);\n background: var(--calender-bg-color, #fff);\n}\n\n.week-view-day-header {\n padding: var(--calender-week-header-padding, 12px 4px);\n text-align: center;\n border-right: 1px solid var(--calender-border-color, #dadce0);\n background: var(--calender-bg-color, #fff);\n cursor: pointer;\n transition: background-color var(--calender-transition-duration-fast, 0.15s);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: var(--calender-week-header-gap, 2px);\n}\n\n.week-view-day-header:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n}\n\n.week-view-day-header.today {\n background-color: var(--calender-today-bg-color, #e8f0fe);\n}\n\n.week-view-day-header.today .week-view-day-date {\n background-color: var(--calender-primary-color, #1a73e8);\n color: var(--calender-primary-text-color, #fff);\n width: var(--calender-week-today-indicator-size, 40px);\n height: var(--calender-week-today-indicator-size, 40px);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.week-view-day-header.selected {\n background-color: var(--calender-selected-bg-color, #e8f0fe);\n}\n\n.week-view-day-header:last-child {\n border-right: none;\n}\n\n.week-view-day-name {\n font-size: var(--calender-week-day-name-font-size, 11px);\n font-weight: var(--calender-week-day-name-font-weight, 500);\n color: var(--calender-text-secondary-color, #70757a);\n text-transform: uppercase;\n letter-spacing: var(--calender-week-day-name-letter-spacing, 0.8px);\n}\n\n.week-view-day-date {\n font-size: var(--calender-week-day-date-font-size, 26px);\n font-weight: var(--calender-week-day-date-font-weight, 400);\n color: var(--calender-text-color, #3c4043);\n line-height: 1;\n /* 默认为inline,当是today时会变为flex容器 */\n display: inline-block;\n}\n\n/* 选中状态的日期(非今日) */\n.week-view-day-header.selected:not(.today) .week-view-day-date {\n color: var(--calender-primary-color, #1a73e8);\n font-weight: var(--calender-selected-font-weight, 500);\n}\n\n.week-view-day-events-count {\n font-size: var(--calender-week-events-count-font-size, 11px);\n color: var(--calender-text-secondary-color, #70757a);\n margin-top: var(--calender-week-events-count-margin-top, 4px);\n line-height: 1.2;\n}\n\n.week-view-body {\n display: flex;\n flex-direction: row; /* 明确指定从左到右 */\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n/* 时间轴(左侧) */\n.week-view-time-gutter {\n width: var(--calender-week-time-gutter-width, 60px);\n min-width: var(--calender-week-time-gutter-width, 60px);\n border-right: 1px solid var(--calender-border-color, #dadce0);\n background: var(--calender-bg-color, #fff);\n position: sticky;\n left: 0;\n z-index: 5;\n order: 0; /* 明确指定为第一个 */\n flex-shrink: 0; /* 防止被压缩 */\n}\n\n.week-view-time-label {\n height: var(--calender-hour-cell-height, 48px);\n padding-top: var(--calender-time-label-padding-top, 4px);\n padding-right: var(--calender-time-label-padding-right, 8px);\n text-align: right;\n font-size: var(--calender-time-label-font-size, 12px);\n color: var(--calender-text-secondary-color, #70757a);\n border-bottom: 1px solid var(--calender-border-light-color, #e8eaed);\n box-sizing: border-box;\n}\n\n/* 日期列容器 */\n.week-view-columns {\n display: grid;\n grid-template-columns: repeat(7, 1fr);\n flex: 1;\n order: 1; /* 明确指定为第二个 */\n}\n\n/* 单个日期列 */\n.week-view-day-column {\n border-right: 1px solid var(--calender-border-color, #dadce0);\n position: relative;\n min-width: 0;\n}\n\n.week-view-day-column:last-child {\n border-right: none;\n}\n\n.week-view-hour-cell {\n height: var(--calender-hour-cell-height, 48px);\n border-bottom: 1px solid var(--calender-border-light-color, #e8eaed);\n cursor: pointer;\n transition: background-color var(--calender-transition-duration-fast, 0.15s);\n position: relative;\n box-sizing: border-box;\n}\n\n.week-view-hour-cell:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n}\n\n.week-view-hour-cell.selected {\n background-color: var(--calender-selected-bg-color, #e8f0fe);\n}\n\n.week-view-time-slot-cell {\n height: var(--calender-hour-cell-height, 48px);\n border-bottom: 1px solid var(--calender-border-light-color, #e8eaed);\n cursor: pointer;\n transition: background-color var(--calender-transition-duration-fast, 0.15s);\n position: relative;\n}\n\n.week-view-time-slot-cell:hover {\n background-color: var(--calender-hover-bg-color-light, #f8f9fa);\n}\n\n.week-view-time-slot-cell.selected {\n background-color: var(--calender-selected-bg-color, #e8f0fe);\n}\n\n.week-view-event {\n position: absolute;\n left: var(--calender-week-event-margin, 1px);\n right: var(--calender-week-event-margin, 1px);\n padding: var(--calender-week-event-padding, 2px 4px);\n border-radius: var(--calender-event-border-radius, 3px);\n font-size: var(--calender-event-font-size, 12px);\n color: var(--calender-event-text-color, #fff);\n cursor: pointer;\n overflow: hidden;\n z-index: 2;\n box-shadow: var(--calender-event-box-shadow, 0 1px 2px rgba(0, 0, 0, 0.1));\n transition:\n box-shadow var(--calender-transition-duration, 0.2s),\n z-index var(--calender-transition-duration, 0.2s);\n line-height: var(--calender-week-event-line-height, 1.3);\n}\n\n.week-view-event:hover {\n box-shadow: var(\n --calender-event-hover-box-shadow,\n 0 2px 4px rgba(0, 0, 0, 0.15)\n );\n z-index: 3;\n}\n\n.week-view-event-time {\n font-size: var(--calender-event-time-font-size, 11px);\n opacity: var(--calender-event-time-opacity, 0.95);\n margin-bottom: var(--calender-event-time-margin-bottom, 2px);\n line-height: 1.2;\n}\n\n.week-view-event-title {\n font-weight: var(--calender-event-title-font-weight, 500);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n line-height: var(--calender-week-event-line-height, 1.3);\n margin-bottom: var(--calender-event-title-margin-bottom, 2px);\n}\n";
|
|
841
872
|
var _WeekView2;
|
|
842
873
|
let _initClass$1, _classDecs$1;
|
|
843
874
|
function _defineProperty$1(e, r, t) {
|
|
844
875
|
return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
845
876
|
}
|
|
846
877
|
function _applyDecs$1(e, t, r, n, o, a) {
|
|
847
|
-
function
|
|
878
|
+
function i(e2, t2, r2) {
|
|
848
879
|
return function(n2, o2) {
|
|
849
880
|
return r2 && r2(n2), e2[t2].call(n2, o2);
|
|
850
881
|
};
|
|
@@ -857,93 +888,93 @@ function _applyDecs$1(e, t, r, n, o, a) {
|
|
|
857
888
|
if ("function" != typeof e2 && (n2 || void 0 !== e2)) throw new TypeError(t2 + " must " + (r2 || "be") + " a function" + (n2 ? "" : " or undefined"));
|
|
858
889
|
return e2;
|
|
859
890
|
}
|
|
860
|
-
function applyDec(e2, t2, r2, n2, o2, a2, c2, u2,
|
|
861
|
-
function
|
|
862
|
-
if (!
|
|
891
|
+
function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l2, f2, p2, d, h) {
|
|
892
|
+
function m(e3) {
|
|
893
|
+
if (!h(e3)) throw new TypeError("Attempted to access private element on non-instance");
|
|
863
894
|
}
|
|
864
895
|
var y, v = t2[0], g = t2[3], b = !u2;
|
|
865
896
|
if (!b) {
|
|
866
897
|
r2 || Array.isArray(v) || (v = [v]);
|
|
867
|
-
var
|
|
868
|
-
f2 ? (
|
|
898
|
+
var w = {}, S = [], A = 3 === o2 ? "get" : 4 === o2 || d ? "set" : "value";
|
|
899
|
+
f2 ? (p2 || d ? w = { get: _setFunctionName$1(function() {
|
|
869
900
|
return g(this);
|
|
870
901
|
}, n2, "get"), set: function(e3) {
|
|
871
902
|
t2[4](this, e3);
|
|
872
|
-
} } :
|
|
903
|
+
} } : w[A] = g, p2 || _setFunctionName$1(w[A], n2, 2 === o2 ? "" : A)) : p2 || (w = Object.getOwnPropertyDescriptor(e2, n2));
|
|
873
904
|
}
|
|
874
905
|
for (var P = e2, j = v.length - 1; j >= 0; j -= r2 ? 2 : 1) {
|
|
875
|
-
var
|
|
906
|
+
var D = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
|
|
876
907
|
if (e3.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
877
908
|
s(t3, "An initializer", "be", true), c2.push(t3);
|
|
878
909
|
}).bind(null, I) };
|
|
879
910
|
try {
|
|
880
|
-
if (b) (y = s(
|
|
911
|
+
if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);
|
|
881
912
|
else {
|
|
882
|
-
var k,
|
|
883
|
-
O.static =
|
|
884
|
-
return
|
|
885
|
-
} : (o2 < 4 && (k =
|
|
913
|
+
var k, F;
|
|
914
|
+
O.static = l2, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
|
|
915
|
+
return m(e3), w.value;
|
|
916
|
+
} : (o2 < 4 && (k = i(w, "get", m)), 3 !== o2 && (F = i(w, "set", m))) : (k = function(e3) {
|
|
886
917
|
return e3[n2];
|
|
887
|
-
}, (o2 < 2 || 4 === o2) && (
|
|
918
|
+
}, (o2 < 2 || 4 === o2) && (F = function(e3, t3) {
|
|
888
919
|
e3[n2] = t3;
|
|
889
920
|
}));
|
|
890
|
-
var N = O.access = { has: f2 ?
|
|
921
|
+
var N = O.access = { has: f2 ? h.bind() : function(e3) {
|
|
891
922
|
return n2 in e3;
|
|
892
923
|
} };
|
|
893
|
-
if (k && (N.get = k),
|
|
894
|
-
if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (
|
|
924
|
+
if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) {
|
|
925
|
+
if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);
|
|
895
926
|
else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
896
|
-
} else s(P, (
|
|
927
|
+
} else s(P, (p2 ? "field" : "method") + " decorators", "return") && (p2 ? S.push(P) : w[A] = P);
|
|
897
928
|
}
|
|
898
929
|
} finally {
|
|
899
930
|
I.v = true;
|
|
900
931
|
}
|
|
901
932
|
}
|
|
902
|
-
return (
|
|
933
|
+
return (p2 || d) && u2.push(function(e3, t3) {
|
|
903
934
|
for (var r3 = S.length - 1; r3 >= 0; r3--) t3 = S[r3].call(e3, t3);
|
|
904
935
|
return t3;
|
|
905
|
-
}),
|
|
936
|
+
}), p2 || b || (f2 ? d ? u2.push(i(w, "get"), i(w, "set")) : u2.push(2 === o2 ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e2, n2, w)), P;
|
|
906
937
|
}
|
|
907
938
|
function u(e2, t2) {
|
|
908
939
|
return Object.defineProperty(e2, Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata"), { configurable: true, enumerable: true, value: t2 });
|
|
909
940
|
}
|
|
910
|
-
if (arguments.length >= 6) var
|
|
911
|
-
var f = Object.create(null ==
|
|
912
|
-
var o2, a2,
|
|
941
|
+
if (arguments.length >= 6) var l = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
|
|
942
|
+
var f = Object.create(null == l ? null : l), p = (function(e2, t2, r2, n2) {
|
|
943
|
+
var o2, a2, i2 = [], s2 = function(t3) {
|
|
913
944
|
return _checkInRHS$1(t3) === e2;
|
|
914
945
|
}, u2 = /* @__PURE__ */ new Map();
|
|
915
|
-
function
|
|
916
|
-
e3 &&
|
|
946
|
+
function l2(e3) {
|
|
947
|
+
e3 && i2.push(c.bind(null, e3));
|
|
917
948
|
}
|
|
918
949
|
for (var f2 = 0; f2 < t2.length; f2++) {
|
|
919
|
-
var
|
|
920
|
-
if (Array.isArray(
|
|
921
|
-
var
|
|
922
|
-
if (!g && !
|
|
923
|
-
var
|
|
924
|
-
if (true ===
|
|
925
|
-
u2.set(b, !(
|
|
950
|
+
var p2 = t2[f2];
|
|
951
|
+
if (Array.isArray(p2)) {
|
|
952
|
+
var d = p2[1], h = p2[2], m = p2.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v;
|
|
953
|
+
if (!g && !m) {
|
|
954
|
+
var w = u2.get(b);
|
|
955
|
+
if (true === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
|
|
956
|
+
u2.set(b, !(d > 2) || d);
|
|
926
957
|
}
|
|
927
|
-
applyDec(v ? e2 : e2.prototype,
|
|
958
|
+
applyDec(v ? e2 : e2.prototype, p2, y, m ? "#" + h : _toPropertyKey$1(h), d, n2, v ? a2 = a2 || [] : o2 = o2 || [], i2, v, m, g, 1 === d, v && m ? s2 : r2);
|
|
928
959
|
}
|
|
929
960
|
}
|
|
930
|
-
return
|
|
961
|
+
return l2(o2), l2(a2), i2;
|
|
931
962
|
})(e, t, o, f);
|
|
932
|
-
return r.length || u(e, f), { e:
|
|
963
|
+
return r.length || u(e, f), { e: p, get c() {
|
|
933
964
|
var t2 = [];
|
|
934
965
|
return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t2), f), c.bind(null, t2, e)];
|
|
935
966
|
} };
|
|
936
967
|
}
|
|
937
968
|
function _toPropertyKey$1(t) {
|
|
938
|
-
var
|
|
939
|
-
return "symbol" == typeof
|
|
969
|
+
var i = _toPrimitive$1(t, "string");
|
|
970
|
+
return "symbol" == typeof i ? i : i + "";
|
|
940
971
|
}
|
|
941
972
|
function _toPrimitive$1(t, r) {
|
|
942
973
|
if ("object" != typeof t || !t) return t;
|
|
943
974
|
var e = t[Symbol.toPrimitive];
|
|
944
975
|
if (void 0 !== e) {
|
|
945
|
-
var
|
|
946
|
-
if ("object" != typeof
|
|
976
|
+
var i = e.call(t, r);
|
|
977
|
+
if ("object" != typeof i) return i;
|
|
947
978
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
948
979
|
}
|
|
949
980
|
return String(t);
|
|
@@ -960,6 +991,7 @@ function _checkInRHS$1(e) {
|
|
|
960
991
|
if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null"));
|
|
961
992
|
return e;
|
|
962
993
|
}
|
|
994
|
+
const UPGRADABLE_PROPS$1 = ["viewDate", "events", "selectedDate", "user"];
|
|
963
995
|
_classDecs$1 = [autoRegister({
|
|
964
996
|
tagName: "wsx-week-view"
|
|
965
997
|
})];
|
|
@@ -970,18 +1002,15 @@ class WeekView extends WebComponent {
|
|
|
970
1002
|
return ["view-date", "events", "selected-date", "user"];
|
|
971
1003
|
}
|
|
972
1004
|
// ========== 内部状态 ==========
|
|
1005
|
+
// 日期存 ISO:避免 WSX reactive Proxy 破坏 Date
|
|
973
1006
|
// ========== Property 访问器(WSX 组件之间使用) ==========
|
|
974
1007
|
get viewDate() {
|
|
975
|
-
return this.
|
|
1008
|
+
return fromStateIso(this._viewDateIso);
|
|
976
1009
|
}
|
|
977
1010
|
set viewDate(value) {
|
|
978
|
-
|
|
979
|
-
this.
|
|
980
|
-
}
|
|
981
|
-
const date = new Date(value);
|
|
982
|
-
if (!isNaN(date.getTime())) {
|
|
983
|
-
this._viewDate = date;
|
|
984
|
-
}
|
|
1011
|
+
try {
|
|
1012
|
+
this._viewDateIso = toStateIso(value);
|
|
1013
|
+
} catch {
|
|
985
1014
|
}
|
|
986
1015
|
}
|
|
987
1016
|
get events() {
|
|
@@ -989,10 +1018,11 @@ class WeekView extends WebComponent {
|
|
|
989
1018
|
}
|
|
990
1019
|
set events(value) {
|
|
991
1020
|
if (Array.isArray(value)) {
|
|
992
|
-
this._events = value;
|
|
1021
|
+
this._events = normalizeEventsForState(value);
|
|
993
1022
|
} else if (typeof value === "string") {
|
|
994
1023
|
try {
|
|
995
|
-
|
|
1024
|
+
const parsed = JSON.parse(value);
|
|
1025
|
+
this._events = Array.isArray(parsed) ? normalizeEventsForState(parsed) : [];
|
|
996
1026
|
} catch (e) {
|
|
997
1027
|
console.error("Invalid events JSON:", value);
|
|
998
1028
|
this._events = [];
|
|
@@ -1002,21 +1032,10 @@ class WeekView extends WebComponent {
|
|
|
1002
1032
|
}
|
|
1003
1033
|
}
|
|
1004
1034
|
get selectedDate() {
|
|
1005
|
-
return this.
|
|
1035
|
+
return fromStateIso(this._selectedDateIso);
|
|
1006
1036
|
}
|
|
1007
1037
|
set selectedDate(value) {
|
|
1008
|
-
|
|
1009
|
-
this._selectedDate = value;
|
|
1010
|
-
} else if (typeof value === "string") {
|
|
1011
|
-
const date = new Date(value);
|
|
1012
|
-
if (!isNaN(date.getTime())) {
|
|
1013
|
-
this._selectedDate = date;
|
|
1014
|
-
} else {
|
|
1015
|
-
this._selectedDate = /* @__PURE__ */ new Date(0);
|
|
1016
|
-
}
|
|
1017
|
-
} else if (value === void 0 || value === null) {
|
|
1018
|
-
this._selectedDate = /* @__PURE__ */ new Date(0);
|
|
1019
|
-
}
|
|
1038
|
+
this._selectedDateIso = toStateIsoOrUnselected(value);
|
|
1020
1039
|
}
|
|
1021
1040
|
get user() {
|
|
1022
1041
|
return this._user;
|
|
@@ -1039,9 +1058,9 @@ class WeekView extends WebComponent {
|
|
|
1039
1058
|
styleName: "wsx-week-view"
|
|
1040
1059
|
});
|
|
1041
1060
|
_defineProperty$1(this, "_autoStyles", styles);
|
|
1042
|
-
_defineProperty$1(this, "
|
|
1061
|
+
_defineProperty$1(this, "_viewDateIso", void 0);
|
|
1043
1062
|
_defineProperty$1(this, "_events", void 0);
|
|
1044
|
-
_defineProperty$1(this, "
|
|
1063
|
+
_defineProperty$1(this, "_selectedDateIso", void 0);
|
|
1045
1064
|
_defineProperty$1(this, "_user", void 0);
|
|
1046
1065
|
_defineProperty$1(this, "_today", void 0);
|
|
1047
1066
|
_defineProperty$1(this, "onDateClick", void 0);
|
|
@@ -1084,10 +1103,10 @@ class WeekView extends WebComponent {
|
|
|
1084
1103
|
const today = /* @__PURE__ */ new Date();
|
|
1085
1104
|
today.setHours(0, 0, 0, 0);
|
|
1086
1105
|
this._today = today;
|
|
1087
|
-
const [
|
|
1088
|
-
Object.defineProperty(this, "
|
|
1089
|
-
get:
|
|
1090
|
-
set:
|
|
1106
|
+
const [_get_viewDateIso, _set_viewDateIso] = this.useState("_viewDateIso", (/* @__PURE__ */ new Date()).toISOString());
|
|
1107
|
+
Object.defineProperty(this, "_viewDateIso", {
|
|
1108
|
+
get: _get_viewDateIso,
|
|
1109
|
+
set: _set_viewDateIso,
|
|
1091
1110
|
enumerable: true,
|
|
1092
1111
|
configurable: true
|
|
1093
1112
|
});
|
|
@@ -1101,10 +1120,10 @@ class WeekView extends WebComponent {
|
|
|
1101
1120
|
enumerable: true,
|
|
1102
1121
|
configurable: true
|
|
1103
1122
|
});
|
|
1104
|
-
const [
|
|
1105
|
-
Object.defineProperty(this, "
|
|
1106
|
-
get:
|
|
1107
|
-
set:
|
|
1123
|
+
const [_get_selectedDateIso, _set_selectedDateIso] = this.useState("_selectedDateIso", UNSELECTED_DATE_ISO);
|
|
1124
|
+
Object.defineProperty(this, "_selectedDateIso", {
|
|
1125
|
+
get: _get_selectedDateIso,
|
|
1126
|
+
set: _set_selectedDateIso,
|
|
1108
1127
|
enumerable: true,
|
|
1109
1128
|
configurable: true
|
|
1110
1129
|
});
|
|
@@ -1126,6 +1145,7 @@ class WeekView extends WebComponent {
|
|
|
1126
1145
|
// ========== 生命周期 ==========
|
|
1127
1146
|
onConnected() {
|
|
1128
1147
|
super.onConnected?.();
|
|
1148
|
+
upgradeProperties(this, UPGRADABLE_PROPS$1);
|
|
1129
1149
|
this.initializeFromAttributes();
|
|
1130
1150
|
}
|
|
1131
1151
|
onAttributeChanged(name, oldValue, newValue) {
|
|
@@ -1180,22 +1200,22 @@ class WeekView extends WebComponent {
|
|
|
1180
1200
|
}
|
|
1181
1201
|
// ========== Getters ==========
|
|
1182
1202
|
get weekDates() {
|
|
1183
|
-
return
|
|
1203
|
+
return getWeekDates(this.viewDate, 0);
|
|
1184
1204
|
}
|
|
1185
1205
|
get hours() {
|
|
1186
1206
|
return Array.from({
|
|
1187
1207
|
length: 24
|
|
1188
|
-
}, (_,
|
|
1208
|
+
}, (_, i) => i);
|
|
1189
1209
|
}
|
|
1190
1210
|
// ========== 渲染 ==========
|
|
1191
1211
|
render() {
|
|
1192
1212
|
return /* @__PURE__ */ jsx("div", { class: "week-view" }, /* @__PURE__ */ jsx("div", { class: "week-view-header" }, /* @__PURE__ */ jsx("div", { class: "week-view-time-gutter" }), this.weekDates.map((date) => {
|
|
1193
1213
|
const normalizedDate = new Date(date);
|
|
1194
1214
|
normalizedDate.setHours(0, 0, 0, 0);
|
|
1195
|
-
|
|
1196
|
-
const isToday =
|
|
1215
|
+
this.selectedDate.getTime() !== 0 && isSameDay(normalizedDate, this.selectedDate);
|
|
1216
|
+
const isToday = isSameDay(normalizedDate, this._today);
|
|
1197
1217
|
const dayEvents = sortEventsByTime(getEventsForDate(this.events, normalizedDate));
|
|
1198
|
-
return /* @__PURE__ */ jsx("div", { class: `week-view-day-header ${
|
|
1218
|
+
return /* @__PURE__ */ jsx("div", { class: `week-view-day-header ${isToday ? "today" : ""}`, onClick: () => this.handleDateClick(normalizedDate) }, /* @__PURE__ */ jsx("div", { class: "week-view-day-name" }, ["日", "一", "二", "三", "四", "五", "六"][normalizedDate.getDay()]), /* @__PURE__ */ jsx("div", { class: "week-view-day-date" }, normalizedDate.getDate()), /* @__PURE__ */ jsx("div", { class: "week-view-day-events-count" }, dayEvents.length, " 个事件"));
|
|
1199
1219
|
})), /* @__PURE__ */ jsx("div", { class: "week-view-body" }, /* @__PURE__ */ jsx("div", { class: "week-view-time-gutter" }, this.hours.map((hour) => {
|
|
1200
1220
|
const hourStr = hour < 10 ? `0${hour}` : `${hour}`;
|
|
1201
1221
|
const timeStr = `${hourStr}:00`;
|
|
@@ -1213,8 +1233,8 @@ class WeekView extends WebComponent {
|
|
|
1213
1233
|
}), dayEvents.map((event) => {
|
|
1214
1234
|
const position = calculateEventPosition(event, dayStart, dayEnd);
|
|
1215
1235
|
const eventColor = event.color || "#4285f4";
|
|
1216
|
-
const eventDescription = event.
|
|
1217
|
-
return /* @__PURE__ */ jsx("div", { class: "week-view-event", key: "time-slot-event-" + event.id, style: `top: ${position.top}%; height: ${position.height}%; background-color: ${eventColor}`, onClick: () => this.handleEventClick(event) }, /* @__PURE__ */ jsx("div", { class: "week-view-event-time" },
|
|
1236
|
+
const eventDescription = event.data?.description;
|
|
1237
|
+
return /* @__PURE__ */ jsx("div", { class: "week-view-event", key: "time-slot-event-" + event.id, style: `top: ${position.top}%; height: ${position.height}%; background-color: ${eventColor}`, onClick: () => this.handleEventClick(event) }, /* @__PURE__ */ jsx("div", { class: "week-view-event-time" }, getTimeString(event.startTime), " ", "-", " ", getTimeString(event.endTime)), /* @__PURE__ */ jsx("div", { class: "week-view-event-title" }, event.title), eventDescription && /* @__PURE__ */ jsx("div", { class: "week-view-event-description" }, eventDescription));
|
|
1218
1238
|
}));
|
|
1219
1239
|
}))));
|
|
1220
1240
|
}
|
|
@@ -1228,7 +1248,7 @@ function _defineProperty(e, r, t) {
|
|
|
1228
1248
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
1229
1249
|
}
|
|
1230
1250
|
function _applyDecs(e, t, r, n, o, a) {
|
|
1231
|
-
function
|
|
1251
|
+
function i(e2, t2, r2) {
|
|
1232
1252
|
return function(n2, o2) {
|
|
1233
1253
|
return r2 && r2(n2), e2[t2].call(n2, o2);
|
|
1234
1254
|
};
|
|
@@ -1241,93 +1261,93 @@ function _applyDecs(e, t, r, n, o, a) {
|
|
|
1241
1261
|
if ("function" != typeof e2 && (n2 || void 0 !== e2)) throw new TypeError(t2 + " must " + (r2 || "be") + " a function" + (n2 ? "" : " or undefined"));
|
|
1242
1262
|
return e2;
|
|
1243
1263
|
}
|
|
1244
|
-
function applyDec(e2, t2, r2, n2, o2, a2, c2, u2,
|
|
1245
|
-
function
|
|
1246
|
-
if (!
|
|
1264
|
+
function applyDec(e2, t2, r2, n2, o2, a2, c2, u2, l2, f2, p2, d, h) {
|
|
1265
|
+
function m(e3) {
|
|
1266
|
+
if (!h(e3)) throw new TypeError("Attempted to access private element on non-instance");
|
|
1247
1267
|
}
|
|
1248
1268
|
var y, v = t2[0], g = t2[3], b = !u2;
|
|
1249
1269
|
if (!b) {
|
|
1250
1270
|
r2 || Array.isArray(v) || (v = [v]);
|
|
1251
|
-
var
|
|
1252
|
-
f2 ? (
|
|
1271
|
+
var w = {}, S = [], A = 3 === o2 ? "get" : 4 === o2 || d ? "set" : "value";
|
|
1272
|
+
f2 ? (p2 || d ? w = { get: _setFunctionName(function() {
|
|
1253
1273
|
return g(this);
|
|
1254
1274
|
}, n2, "get"), set: function(e3) {
|
|
1255
1275
|
t2[4](this, e3);
|
|
1256
|
-
} } :
|
|
1276
|
+
} } : w[A] = g, p2 || _setFunctionName(w[A], n2, 2 === o2 ? "" : A)) : p2 || (w = Object.getOwnPropertyDescriptor(e2, n2));
|
|
1257
1277
|
}
|
|
1258
1278
|
for (var P = e2, j = v.length - 1; j >= 0; j -= r2 ? 2 : 1) {
|
|
1259
|
-
var
|
|
1279
|
+
var D = v[j], E = r2 ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o2], name: n2, metadata: a2, addInitializer: (function(e3, t3) {
|
|
1260
1280
|
if (e3.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
1261
1281
|
s(t3, "An initializer", "be", true), c2.push(t3);
|
|
1262
1282
|
}).bind(null, I) };
|
|
1263
1283
|
try {
|
|
1264
|
-
if (b) (y = s(
|
|
1284
|
+
if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);
|
|
1265
1285
|
else {
|
|
1266
|
-
var k,
|
|
1267
|
-
O.static =
|
|
1268
|
-
return
|
|
1269
|
-
} : (o2 < 4 && (k =
|
|
1286
|
+
var k, F;
|
|
1287
|
+
O.static = l2, O.private = f2, f2 ? 2 === o2 ? k = function(e3) {
|
|
1288
|
+
return m(e3), w.value;
|
|
1289
|
+
} : (o2 < 4 && (k = i(w, "get", m)), 3 !== o2 && (F = i(w, "set", m))) : (k = function(e3) {
|
|
1270
1290
|
return e3[n2];
|
|
1271
|
-
}, (o2 < 2 || 4 === o2) && (
|
|
1291
|
+
}, (o2 < 2 || 4 === o2) && (F = function(e3, t3) {
|
|
1272
1292
|
e3[n2] = t3;
|
|
1273
1293
|
}));
|
|
1274
|
-
var N = O.access = { has: f2 ?
|
|
1294
|
+
var N = O.access = { has: f2 ? h.bind() : function(e3) {
|
|
1275
1295
|
return n2 in e3;
|
|
1276
1296
|
} };
|
|
1277
|
-
if (k && (N.get = k),
|
|
1278
|
-
if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (
|
|
1297
|
+
if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) {
|
|
1298
|
+
if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);
|
|
1279
1299
|
else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
1280
|
-
} else s(P, (
|
|
1300
|
+
} else s(P, (p2 ? "field" : "method") + " decorators", "return") && (p2 ? S.push(P) : w[A] = P);
|
|
1281
1301
|
}
|
|
1282
1302
|
} finally {
|
|
1283
1303
|
I.v = true;
|
|
1284
1304
|
}
|
|
1285
1305
|
}
|
|
1286
|
-
return (
|
|
1306
|
+
return (p2 || d) && u2.push(function(e3, t3) {
|
|
1287
1307
|
for (var r3 = S.length - 1; r3 >= 0; r3--) t3 = S[r3].call(e3, t3);
|
|
1288
1308
|
return t3;
|
|
1289
|
-
}),
|
|
1309
|
+
}), p2 || b || (f2 ? d ? u2.push(i(w, "get"), i(w, "set")) : u2.push(2 === o2 ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e2, n2, w)), P;
|
|
1290
1310
|
}
|
|
1291
1311
|
function u(e2, t2) {
|
|
1292
1312
|
return Object.defineProperty(e2, Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata"), { configurable: true, enumerable: true, value: t2 });
|
|
1293
1313
|
}
|
|
1294
|
-
if (arguments.length >= 6) var
|
|
1295
|
-
var f = Object.create(null ==
|
|
1296
|
-
var o2, a2,
|
|
1314
|
+
if (arguments.length >= 6) var l = a[Symbol.metadata || /* @__PURE__ */ Symbol.for("Symbol.metadata")];
|
|
1315
|
+
var f = Object.create(null == l ? null : l), p = (function(e2, t2, r2, n2) {
|
|
1316
|
+
var o2, a2, i2 = [], s2 = function(t3) {
|
|
1297
1317
|
return _checkInRHS(t3) === e2;
|
|
1298
1318
|
}, u2 = /* @__PURE__ */ new Map();
|
|
1299
|
-
function
|
|
1300
|
-
e3 &&
|
|
1319
|
+
function l2(e3) {
|
|
1320
|
+
e3 && i2.push(c.bind(null, e3));
|
|
1301
1321
|
}
|
|
1302
1322
|
for (var f2 = 0; f2 < t2.length; f2++) {
|
|
1303
|
-
var
|
|
1304
|
-
if (Array.isArray(
|
|
1305
|
-
var
|
|
1306
|
-
if (!g && !
|
|
1307
|
-
var
|
|
1308
|
-
if (true ===
|
|
1309
|
-
u2.set(b, !(
|
|
1323
|
+
var p2 = t2[f2];
|
|
1324
|
+
if (Array.isArray(p2)) {
|
|
1325
|
+
var d = p2[1], h = p2[2], m = p2.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v;
|
|
1326
|
+
if (!g && !m) {
|
|
1327
|
+
var w = u2.get(b);
|
|
1328
|
+
if (true === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
|
|
1329
|
+
u2.set(b, !(d > 2) || d);
|
|
1310
1330
|
}
|
|
1311
|
-
applyDec(v ? e2 : e2.prototype,
|
|
1331
|
+
applyDec(v ? e2 : e2.prototype, p2, y, m ? "#" + h : _toPropertyKey(h), d, n2, v ? a2 = a2 || [] : o2 = o2 || [], i2, v, m, g, 1 === d, v && m ? s2 : r2);
|
|
1312
1332
|
}
|
|
1313
1333
|
}
|
|
1314
|
-
return
|
|
1334
|
+
return l2(o2), l2(a2), i2;
|
|
1315
1335
|
})(e, t, o, f);
|
|
1316
|
-
return r.length || u(e, f), { e:
|
|
1336
|
+
return r.length || u(e, f), { e: p, get c() {
|
|
1317
1337
|
var t2 = [];
|
|
1318
1338
|
return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t2), f), c.bind(null, t2, e)];
|
|
1319
1339
|
} };
|
|
1320
1340
|
}
|
|
1321
1341
|
function _toPropertyKey(t) {
|
|
1322
|
-
var
|
|
1323
|
-
return "symbol" == typeof
|
|
1342
|
+
var i = _toPrimitive(t, "string");
|
|
1343
|
+
return "symbol" == typeof i ? i : i + "";
|
|
1324
1344
|
}
|
|
1325
1345
|
function _toPrimitive(t, r) {
|
|
1326
1346
|
if ("object" != typeof t || !t) return t;
|
|
1327
1347
|
var e = t[Symbol.toPrimitive];
|
|
1328
1348
|
if (void 0 !== e) {
|
|
1329
|
-
var
|
|
1330
|
-
if ("object" != typeof
|
|
1349
|
+
var i = e.call(t, r);
|
|
1350
|
+
if ("object" != typeof i) return i;
|
|
1331
1351
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1332
1352
|
}
|
|
1333
1353
|
return String(t);
|
|
@@ -1344,6 +1364,8 @@ function _checkInRHS(e) {
|
|
|
1344
1364
|
if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null"));
|
|
1345
1365
|
return e;
|
|
1346
1366
|
}
|
|
1367
|
+
const UPGRADABLE_PROPS = ["view", "date", "defaultView", "events", "user", "eventDSL", "eventRuntime"];
|
|
1368
|
+
const VALID_VIEWS = ["month", "week", "day"];
|
|
1347
1369
|
_classDecs = [autoRegister({
|
|
1348
1370
|
tagName: "wsx-calendar"
|
|
1349
1371
|
})];
|
|
@@ -1354,16 +1376,73 @@ class Calendar extends WebComponent {
|
|
|
1354
1376
|
return ["view", "date", "events", "user"];
|
|
1355
1377
|
}
|
|
1356
1378
|
// ========== 内部状态(@state 装饰器) ==========
|
|
1357
|
-
//
|
|
1379
|
+
// 日期存 ISO:WSX reactive Proxy 会破坏 Date 品牌方法
|
|
1380
|
+
// ========== 属性访问器(支持 property 和 attribute 两种设置方式) ==========
|
|
1381
|
+
get currentDate() {
|
|
1382
|
+
return fromStateIso(this._currentDateIso);
|
|
1383
|
+
}
|
|
1384
|
+
set currentDate(value) {
|
|
1385
|
+
this._currentDateIso = toStateIso(value);
|
|
1386
|
+
}
|
|
1387
|
+
get defaultView() {
|
|
1388
|
+
return this.currentView;
|
|
1389
|
+
}
|
|
1390
|
+
set defaultView(value) {
|
|
1391
|
+
this.currentView = value;
|
|
1392
|
+
}
|
|
1393
|
+
/** 与 observedAttributes 的 "view" 对应的 property(框架包装器使用) */
|
|
1394
|
+
get view() {
|
|
1395
|
+
return this.currentView;
|
|
1396
|
+
}
|
|
1397
|
+
set view(value) {
|
|
1398
|
+
if (VALID_VIEWS.includes(value)) {
|
|
1399
|
+
this.currentView = value;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
/** 与 observedAttributes 的 "date" 对应的 property(框架包装器使用) */
|
|
1403
|
+
get date() {
|
|
1404
|
+
return this.currentDate;
|
|
1405
|
+
}
|
|
1406
|
+
set date(value) {
|
|
1407
|
+
try {
|
|
1408
|
+
this.currentDate = value;
|
|
1409
|
+
} catch {
|
|
1410
|
+
console.error("Invalid date value:", value);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
get eventDSL() {
|
|
1414
|
+
return this._eventDSL;
|
|
1415
|
+
}
|
|
1416
|
+
set eventDSL(value) {
|
|
1417
|
+
this._eventDSL = value;
|
|
1418
|
+
this.rebuildRuntimeFromDSL();
|
|
1419
|
+
}
|
|
1420
|
+
get eventRuntime() {
|
|
1421
|
+
return this._eventRuntime;
|
|
1422
|
+
}
|
|
1423
|
+
set eventRuntime(value) {
|
|
1424
|
+
this._eventRuntime = value;
|
|
1425
|
+
if (value) {
|
|
1426
|
+
const typeId = value.getDataModel().id;
|
|
1427
|
+
this._runtimeByType = /* @__PURE__ */ new Map([[typeId, value]]);
|
|
1428
|
+
} else if (!this._eventDSL) {
|
|
1429
|
+
this._runtimeByType = null;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
/** 经 EventRuntime 增强后的显示用事件列表 */
|
|
1433
|
+
get displayEvents() {
|
|
1434
|
+
return getDisplayEvents(this._events, this._runtimeByType, this._user);
|
|
1435
|
+
}
|
|
1358
1436
|
get events() {
|
|
1359
1437
|
return this._events;
|
|
1360
1438
|
}
|
|
1361
1439
|
set events(value) {
|
|
1362
1440
|
if (Array.isArray(value)) {
|
|
1363
|
-
this._events = value;
|
|
1441
|
+
this._events = normalizeEventsForState(value);
|
|
1364
1442
|
} else if (typeof value === "string") {
|
|
1365
1443
|
try {
|
|
1366
|
-
|
|
1444
|
+
const parsed = JSON.parse(value);
|
|
1445
|
+
this._events = Array.isArray(parsed) ? normalizeEventsForState(parsed) : [];
|
|
1367
1446
|
} catch (e) {
|
|
1368
1447
|
console.error("Invalid events JSON:", value);
|
|
1369
1448
|
this._events = [];
|
|
@@ -1372,7 +1451,20 @@ class Calendar extends WebComponent {
|
|
|
1372
1451
|
this._events = [];
|
|
1373
1452
|
}
|
|
1374
1453
|
}
|
|
1375
|
-
|
|
1454
|
+
get user() {
|
|
1455
|
+
return this._user;
|
|
1456
|
+
}
|
|
1457
|
+
set user(value) {
|
|
1458
|
+
if (typeof value === "string") {
|
|
1459
|
+
try {
|
|
1460
|
+
this._user = JSON.parse(value);
|
|
1461
|
+
} catch (e) {
|
|
1462
|
+
console.error("Invalid user JSON:", value);
|
|
1463
|
+
}
|
|
1464
|
+
} else if (value && typeof value === "object") {
|
|
1465
|
+
this._user = value;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1376
1468
|
constructor() {
|
|
1377
1469
|
super({
|
|
1378
1470
|
styles: styles$3,
|
|
@@ -1380,10 +1472,12 @@ class Calendar extends WebComponent {
|
|
|
1380
1472
|
});
|
|
1381
1473
|
_defineProperty(this, "_autoStyles", styles$3);
|
|
1382
1474
|
_defineProperty(this, "currentView", void 0);
|
|
1383
|
-
_defineProperty(this, "
|
|
1475
|
+
_defineProperty(this, "_currentDateIso", void 0);
|
|
1384
1476
|
_defineProperty(this, "_events", void 0);
|
|
1385
|
-
_defineProperty(this, "
|
|
1386
|
-
_defineProperty(this, "
|
|
1477
|
+
_defineProperty(this, "_user", void 0);
|
|
1478
|
+
_defineProperty(this, "_eventDSL", void 0);
|
|
1479
|
+
_defineProperty(this, "_eventRuntime", null);
|
|
1480
|
+
_defineProperty(this, "_runtimeByType", null);
|
|
1387
1481
|
_defineProperty(this, "handleChildDateClick", (e) => {
|
|
1388
1482
|
const customEvent = e;
|
|
1389
1483
|
const date = new Date(customEvent.detail.date);
|
|
@@ -1414,10 +1508,10 @@ class Calendar extends WebComponent {
|
|
|
1414
1508
|
enumerable: true,
|
|
1415
1509
|
configurable: true
|
|
1416
1510
|
});
|
|
1417
|
-
const [
|
|
1418
|
-
Object.defineProperty(this, "
|
|
1419
|
-
get:
|
|
1420
|
-
set:
|
|
1511
|
+
const [_get_currentDateIso, _set_currentDateIso] = this.useState("_currentDateIso", (/* @__PURE__ */ new Date()).toISOString());
|
|
1512
|
+
Object.defineProperty(this, "_currentDateIso", {
|
|
1513
|
+
get: _get_currentDateIso,
|
|
1514
|
+
set: _set_currentDateIso,
|
|
1421
1515
|
enumerable: true,
|
|
1422
1516
|
configurable: true
|
|
1423
1517
|
});
|
|
@@ -1431,25 +1525,32 @@ class Calendar extends WebComponent {
|
|
|
1431
1525
|
enumerable: true,
|
|
1432
1526
|
configurable: true
|
|
1433
1527
|
});
|
|
1434
|
-
let
|
|
1528
|
+
let __userReactive = this.reactive({
|
|
1435
1529
|
id: "1",
|
|
1436
1530
|
email: "john.doe@example.com",
|
|
1437
1531
|
role: "user"
|
|
1438
1532
|
});
|
|
1439
|
-
Object.defineProperty(this, "
|
|
1440
|
-
get: () =>
|
|
1533
|
+
Object.defineProperty(this, "_user", {
|
|
1534
|
+
get: () => __userReactive,
|
|
1441
1535
|
set: (newValue) => {
|
|
1442
|
-
|
|
1536
|
+
__userReactive = newValue !== null && typeof newValue !== "undefined" && (Array.isArray(newValue) || typeof newValue === "object") ? this.reactive(newValue) : newValue;
|
|
1443
1537
|
this.scheduleRerender();
|
|
1444
1538
|
},
|
|
1445
1539
|
enumerable: true,
|
|
1446
1540
|
configurable: true
|
|
1447
1541
|
});
|
|
1542
|
+
const [_get_eventDSL, _set_eventDSL] = this.useState("_eventDSL", null);
|
|
1543
|
+
Object.defineProperty(this, "_eventDSL", {
|
|
1544
|
+
get: _get_eventDSL,
|
|
1545
|
+
set: _set_eventDSL,
|
|
1546
|
+
enumerable: true,
|
|
1547
|
+
configurable: true
|
|
1548
|
+
});
|
|
1448
1549
|
}
|
|
1449
1550
|
// ========== Web Components 生命周期 ==========
|
|
1450
1551
|
onConnected() {
|
|
1451
1552
|
super.onConnected?.();
|
|
1452
|
-
this
|
|
1553
|
+
upgradeProperties(this, UPGRADABLE_PROPS);
|
|
1453
1554
|
this.setupEventListeners();
|
|
1454
1555
|
}
|
|
1455
1556
|
onDisconnected() {
|
|
@@ -1515,47 +1616,12 @@ class Calendar extends WebComponent {
|
|
|
1515
1616
|
break;
|
|
1516
1617
|
}
|
|
1517
1618
|
}
|
|
1518
|
-
// ========== 初始化 ==========
|
|
1519
|
-
initializeComponent() {
|
|
1520
|
-
const viewAttr = this.getAttribute("view");
|
|
1521
|
-
if (viewAttr && ["month", "week", "day"].includes(viewAttr)) {
|
|
1522
|
-
this.currentView = viewAttr;
|
|
1523
|
-
}
|
|
1524
|
-
const dateAttr = this.getAttribute("date");
|
|
1525
|
-
if (dateAttr) {
|
|
1526
|
-
try {
|
|
1527
|
-
const date = new Date(dateAttr);
|
|
1528
|
-
if (!isNaN(date.getTime())) {
|
|
1529
|
-
this.currentDate = date;
|
|
1530
|
-
}
|
|
1531
|
-
} catch (e) {
|
|
1532
|
-
console.error("Invalid date format:", dateAttr);
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
const eventsAttr = this.getAttribute("events");
|
|
1536
|
-
if (eventsAttr) {
|
|
1537
|
-
try {
|
|
1538
|
-
this.events = JSON.parse(eventsAttr);
|
|
1539
|
-
} catch (e) {
|
|
1540
|
-
console.error("Invalid events JSON:", eventsAttr);
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
const userAttr = this.getAttribute("user");
|
|
1544
|
-
if (userAttr) {
|
|
1545
|
-
try {
|
|
1546
|
-
this.user = JSON.parse(userAttr);
|
|
1547
|
-
} catch (e) {
|
|
1548
|
-
console.error("Invalid user JSON:", userAttr);
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
this._initialized = true;
|
|
1552
|
-
}
|
|
1553
1619
|
// ========== 渲染 ==========
|
|
1554
1620
|
render() {
|
|
1555
1621
|
return /* @__PURE__ */ jsx("div", { class: "calendar" }, this.renderToolbar(), this.renderView());
|
|
1556
1622
|
}
|
|
1557
1623
|
renderToolbar() {
|
|
1558
|
-
return /* @__PURE__ */ jsx("div", { class: "calendar-toolbar" }, /* @__PURE__ */ jsx("div", { class: "calendar-toolbar-left" }, /* @__PURE__ */ jsx("button", { class: "calendar-nav-button", onClick: () => this.handleNavigate(-1), "aria-label": "上一页"
|
|
1624
|
+
return /* @__PURE__ */ jsx("div", { class: "calendar-toolbar" }, /* @__PURE__ */ jsx("div", { class: "calendar-toolbar-left" }, /* @__PURE__ */ jsx("button", { class: "calendar-nav-button", onClick: () => this.handleNavigate(-1), "aria-label": "上一页" }, /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24" }, /* @__PURE__ */ jsx("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }))), /* @__PURE__ */ jsx("button", { class: "calendar-nav-button", onClick: () => this.handleNavigate(1), "aria-label": "下一页" }, /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24" }, /* @__PURE__ */ jsx("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" }))), /* @__PURE__ */ jsx("button", { class: "calendar-today-button", onClick: () => this.handleToday() }, "今天"), /* @__PURE__ */ jsx("div", { class: "calendar-toolbar-date" }, this.formatViewDate())), /* @__PURE__ */ jsx("div", { class: "calendar-toolbar-right" }, /* @__PURE__ */ jsx("div", { class: "calendar-view-buttons" }, /* @__PURE__ */ jsx("button", { class: `calendar-view-button ${this.currentView === "month" ? "active" : ""}`, onClick: () => this.handleViewChange("month") }, "月"), /* @__PURE__ */ jsx("button", { class: `calendar-view-button ${this.currentView === "week" ? "active" : ""}`, onClick: () => this.handleViewChange("week") }, "周"), /* @__PURE__ */ jsx("button", { class: `calendar-view-button ${this.currentView === "day" ? "active" : ""}`, onClick: () => this.handleViewChange("day") }, "日"))));
|
|
1559
1625
|
}
|
|
1560
1626
|
renderView() {
|
|
1561
1627
|
const view = this.currentView || "month";
|
|
@@ -1574,15 +1640,15 @@ class Calendar extends WebComponent {
|
|
|
1574
1640
|
}
|
|
1575
1641
|
// ========== 月视图 ==========
|
|
1576
1642
|
renderMonthView() {
|
|
1577
|
-
return /* @__PURE__ */ jsx("wsx-month-view", { "view-date": this.currentDate.toISOString(), events: JSON.stringify(this.
|
|
1643
|
+
return /* @__PURE__ */ jsx("wsx-month-view", { "view-date": this.currentDate.toISOString(), events: JSON.stringify(this.displayEvents), "selected-date": this.currentDate.toISOString(), user: this.user ? JSON.stringify(this.user) : void 0 });
|
|
1578
1644
|
}
|
|
1579
1645
|
// ========== 周视图 ==========
|
|
1580
1646
|
renderWeekView() {
|
|
1581
|
-
return /* @__PURE__ */ jsx("wsx-week-view", { "view-date": this.currentDate.toISOString(), events: JSON.stringify(this.
|
|
1647
|
+
return /* @__PURE__ */ jsx("wsx-week-view", { "view-date": this.currentDate.toISOString(), events: JSON.stringify(this.displayEvents), "selected-date": this.currentDate.toISOString(), user: this.user ? JSON.stringify(this.user) : void 0 });
|
|
1582
1648
|
}
|
|
1583
1649
|
// ========== 日视图 ==========
|
|
1584
1650
|
renderDayView() {
|
|
1585
|
-
return /* @__PURE__ */ jsx("wsx-day-view", { "view-date": this.currentDate.toISOString(), events: JSON.stringify(this.
|
|
1651
|
+
return /* @__PURE__ */ jsx("wsx-day-view", { "view-date": this.currentDate.toISOString(), events: JSON.stringify(this.displayEvents), user: this.user ? JSON.stringify(this.user) : void 0 });
|
|
1586
1652
|
}
|
|
1587
1653
|
// ========== 工具方法 ==========
|
|
1588
1654
|
formatViewDate() {
|
|
@@ -1591,8 +1657,8 @@ class Calendar extends WebComponent {
|
|
|
1591
1657
|
case "month":
|
|
1592
1658
|
return `${date.getFullYear()}年${date.getMonth() + 1}月`;
|
|
1593
1659
|
case "week":
|
|
1594
|
-
const weekStart =
|
|
1595
|
-
const weekEnd =
|
|
1660
|
+
const weekStart = getWeekDates(date)[0];
|
|
1661
|
+
const weekEnd = getWeekDates(date)[6];
|
|
1596
1662
|
return `${weekStart.getMonth() + 1}/${weekStart.getDate()} - ${weekEnd.getMonth() + 1}/${weekEnd.getDate()}`;
|
|
1597
1663
|
case "day":
|
|
1598
1664
|
return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`;
|
|
@@ -1605,7 +1671,9 @@ class Calendar extends WebComponent {
|
|
|
1605
1671
|
const newDate = new Date(this.currentDate);
|
|
1606
1672
|
switch (this.currentView) {
|
|
1607
1673
|
case "month":
|
|
1608
|
-
newDate.
|
|
1674
|
+
const targetMonth = newDate.getMonth() + direction;
|
|
1675
|
+
const targetYear = newDate.getFullYear();
|
|
1676
|
+
newDate.setFullYear(targetYear, targetMonth, 1);
|
|
1609
1677
|
break;
|
|
1610
1678
|
case "week":
|
|
1611
1679
|
newDate.setDate(newDate.getDate() + direction * 7);
|
|
@@ -1640,25 +1708,88 @@ class Calendar extends WebComponent {
|
|
|
1640
1708
|
bubbles: true
|
|
1641
1709
|
}));
|
|
1642
1710
|
}
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
this.currentDate = clickedDate;
|
|
1647
|
-
this.dispatchEvent(new CustomEvent("date-change", {
|
|
1711
|
+
handleViewChange(view) {
|
|
1712
|
+
this.currentView = view;
|
|
1713
|
+
this.dispatchEvent(new CustomEvent("view-change", {
|
|
1648
1714
|
detail: {
|
|
1649
|
-
|
|
1715
|
+
view
|
|
1650
1716
|
},
|
|
1651
1717
|
bubbles: true
|
|
1652
1718
|
}));
|
|
1653
1719
|
}
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
this.
|
|
1720
|
+
/** 从 eventDSL 重新编译 Runtime 映射 */
|
|
1721
|
+
rebuildRuntimeFromDSL() {
|
|
1722
|
+
if (!this._eventDSL) {
|
|
1723
|
+
this._runtimeByType = this._eventRuntime ? /* @__PURE__ */ new Map([[this._eventRuntime.getDataModel().id, this._eventRuntime]]) : null;
|
|
1724
|
+
return;
|
|
1725
|
+
}
|
|
1726
|
+
try {
|
|
1727
|
+
const asts = typeof this._eventDSL === "string" ? [parseEventDSL(this._eventDSL)] : Array.isArray(this._eventDSL) ? this._eventDSL : [this._eventDSL];
|
|
1728
|
+
const compiler = new EventDSLCompiler();
|
|
1729
|
+
this._runtimeByType = createRuntimeMap(compiler.compileFromAST(asts));
|
|
1730
|
+
} catch (error) {
|
|
1731
|
+
console.error("Invalid event DSL:", error);
|
|
1732
|
+
this._runtimeByType = null;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
/** 验证待创建的事件(有 Runtime 时) */
|
|
1736
|
+
validateEventForCreate(event) {
|
|
1737
|
+
return validateEventWithRuntime(event, this._runtimeByType, [...this._events, event], this._user);
|
|
1738
|
+
}
|
|
1739
|
+
/** 验证待更新的事件(有 Runtime 时) */
|
|
1740
|
+
validateEventForUpdate(event) {
|
|
1741
|
+
const others = this._events.filter((item) => item.id !== event.id);
|
|
1742
|
+
return validateEventWithRuntime(event, this._runtimeByType, [...others, event], this._user);
|
|
1743
|
+
}
|
|
1744
|
+
/** 检查是否允许对事件执行某操作 */
|
|
1745
|
+
canPerformAction(action, event) {
|
|
1746
|
+
return canPerformEventAction(action, event, this._runtimeByType, this._user);
|
|
1747
|
+
}
|
|
1748
|
+
/**
|
|
1749
|
+
* 提议创建事件:先验证,成功派发 event-create,失败派发 event-create-error
|
|
1750
|
+
*/
|
|
1751
|
+
proposeEventCreate(event) {
|
|
1752
|
+
const validation = this.validateEventForCreate(event);
|
|
1753
|
+
if (!validation.valid) {
|
|
1754
|
+
this.dispatchEvent(new CustomEvent("event-create-error", {
|
|
1755
|
+
detail: {
|
|
1756
|
+
event,
|
|
1757
|
+
errors: validation.errors ?? []
|
|
1758
|
+
},
|
|
1759
|
+
bubbles: true
|
|
1760
|
+
}));
|
|
1761
|
+
return false;
|
|
1762
|
+
}
|
|
1763
|
+
this.dispatchEvent(new CustomEvent("event-create", {
|
|
1657
1764
|
detail: {
|
|
1658
|
-
|
|
1765
|
+
event
|
|
1766
|
+
},
|
|
1767
|
+
bubbles: true
|
|
1768
|
+
}));
|
|
1769
|
+
return true;
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* 提议更新事件:先验证,成功派发 event-update,失败派发 event-update-error
|
|
1773
|
+
*/
|
|
1774
|
+
proposeEventUpdate(event) {
|
|
1775
|
+
const validation = this.validateEventForUpdate(event);
|
|
1776
|
+
if (!validation.valid) {
|
|
1777
|
+
this.dispatchEvent(new CustomEvent("event-update-error", {
|
|
1778
|
+
detail: {
|
|
1779
|
+
event,
|
|
1780
|
+
errors: validation.errors ?? []
|
|
1781
|
+
},
|
|
1782
|
+
bubbles: true
|
|
1783
|
+
}));
|
|
1784
|
+
return false;
|
|
1785
|
+
}
|
|
1786
|
+
this.dispatchEvent(new CustomEvent("event-update", {
|
|
1787
|
+
detail: {
|
|
1788
|
+
event
|
|
1659
1789
|
},
|
|
1660
1790
|
bubbles: true
|
|
1661
1791
|
}));
|
|
1792
|
+
return true;
|
|
1662
1793
|
}
|
|
1663
1794
|
}
|
|
1664
1795
|
_Calendar2 = Calendar;
|