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