@1agents/dsh-plugin-todo 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +48 -2
- package/bin/ios-agenda.mjs +11 -0
- package/cordis.patch.yml +3 -0
- package/dist/IosAgenda.app/Contents/Info.plist +30 -0
- package/dist/IosAgenda.app/Contents/MacOS/ios-agenda +0 -0
- package/dist/IosAgenda.app/Contents/_CodeSignature/CodeResources +115 -0
- package/dist/client.js +894 -0
- package/dist/host.js +172 -0
- package/package.json +60 -4
- package/skills/ios-agenda/SKILL.md +20 -0
package/dist/client.js
ADDED
|
@@ -0,0 +1,894 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({id:"@1agents/dsh-plugin-todo",dependencies:["react","react/jsx-runtime"],factory:(require)=>{var module={exports:{}};var exports=module.exports;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/client.jsx
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
apply: () => apply,
|
|
24
|
+
inject: () => inject
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(client_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
|
|
29
|
+
// src/contract.js
|
|
30
|
+
var SERVICE = "iosAgenda";
|
|
31
|
+
var PACKAGE = "@1agents/dsh-plugin-todo";
|
|
32
|
+
var PANEL_ID = "ios-agenda";
|
|
33
|
+
var METHODS = ["snapshot", "createReminder", "completeReminder", "deleteReminder", "createEvent", "deleteEvent"];
|
|
34
|
+
function objectOf(value) {
|
|
35
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
function resultOf(value) {
|
|
39
|
+
if (value && typeof value === "object" && (value.ok === true || value.ok === false)) return value;
|
|
40
|
+
throw new Error("\u539F\u751F\u7A0B\u5E8F\u8FD4\u56DE\u4E86\u65E0\u6CD5\u8BC6\u522B\u7684\u7ED3\u679C");
|
|
41
|
+
}
|
|
42
|
+
var codec = (name, parse) => ({
|
|
43
|
+
mode: "strict",
|
|
44
|
+
typeSymbol: `${PACKAGE}#${name}`,
|
|
45
|
+
create: () => ({ parse })
|
|
46
|
+
});
|
|
47
|
+
var contribution = {
|
|
48
|
+
package: PACKAGE,
|
|
49
|
+
descriptors: METHODS.map((method) => ({
|
|
50
|
+
id: `${PACKAGE}#${method}`,
|
|
51
|
+
service: SERVICE,
|
|
52
|
+
namespace: SERVICE,
|
|
53
|
+
method,
|
|
54
|
+
invocation: { kind: "direct" },
|
|
55
|
+
cancellation: { parameter: "signal" },
|
|
56
|
+
parameters: [
|
|
57
|
+
{ name: "input", wire: "input", source: "json", codec: codec("Input", objectOf) }
|
|
58
|
+
],
|
|
59
|
+
result: codec("Result", resultOf)
|
|
60
|
+
}))
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/client.jsx
|
|
64
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
65
|
+
var NS = "iosAgenda";
|
|
66
|
+
var zh = {
|
|
67
|
+
panel: "\u65E5\u7A0B",
|
|
68
|
+
refresh: "\u5237\u65B0",
|
|
69
|
+
loading: "\u6B63\u5728\u8BFB\u53D6\u672C\u673A\u6570\u636E\u2026",
|
|
70
|
+
unavailable: "\u9875\u9762\u8FD8\u6CA1\u6709\u8FDE\u4E0A\u672C\u673A\u8BFB\u5199\u7A0B\u5E8F",
|
|
71
|
+
newReminder: "\u65B0\u63D0\u9192",
|
|
72
|
+
newEvent: "\u65B0\u65E5\u7A0B",
|
|
73
|
+
titleField: "\u6807\u9898",
|
|
74
|
+
start: "\u5F00\u59CB",
|
|
75
|
+
end: "\u7ED3\u675F",
|
|
76
|
+
add: "\u6DFB\u52A0",
|
|
77
|
+
complete: "\u5B8C\u6210",
|
|
78
|
+
remove: "\u5220\u9664",
|
|
79
|
+
permission: "\u9700\u8981\u5728\u7CFB\u7EDF\u8BBE\u7F6E\u91CC\u5141\u8BB8 IosAgenda.app\uFF08work.1agents.ios-agenda\uFF09\u8BBF\u95EE\u63D0\u9192\u4E8B\u9879\u548C\u65E5\u5386\u3002",
|
|
80
|
+
allDay: "\u5168\u5929",
|
|
81
|
+
continues: "\u7EED",
|
|
82
|
+
overdue: "\u903E\u671F",
|
|
83
|
+
undated: "\u65E0\u65E5\u671F",
|
|
84
|
+
emptyDay: "\u8FD9\u4E00\u5929\u6CA1\u6709\u5B89\u6392",
|
|
85
|
+
today: "\u4ECA\u5929",
|
|
86
|
+
week: "\u672C\u5468",
|
|
87
|
+
prevMonth: "\u4E0A\u4E2A\u6708",
|
|
88
|
+
nextMonth: "\u4E0B\u4E2A\u6708",
|
|
89
|
+
untitled: "\u672A\u547D\u540D",
|
|
90
|
+
lists: "\u5217\u8868",
|
|
91
|
+
calendars: "\u65E5\u5386"
|
|
92
|
+
};
|
|
93
|
+
var en = {
|
|
94
|
+
panel: "Agenda",
|
|
95
|
+
refresh: "Refresh",
|
|
96
|
+
loading: "Reading local data\u2026",
|
|
97
|
+
unavailable: "The local agenda program is not connected",
|
|
98
|
+
newReminder: "New reminder",
|
|
99
|
+
newEvent: "New event",
|
|
100
|
+
titleField: "Title",
|
|
101
|
+
start: "Start",
|
|
102
|
+
end: "End",
|
|
103
|
+
add: "Add",
|
|
104
|
+
complete: "Complete",
|
|
105
|
+
remove: "Delete",
|
|
106
|
+
permission: "Allow IosAgenda.app (work.1agents.ios-agenda) to access Reminders and Calendar in System Settings.",
|
|
107
|
+
allDay: "All day",
|
|
108
|
+
continues: "Continues",
|
|
109
|
+
overdue: "Overdue",
|
|
110
|
+
undated: "No date",
|
|
111
|
+
emptyDay: "Nothing scheduled",
|
|
112
|
+
today: "Today",
|
|
113
|
+
week: "This week",
|
|
114
|
+
prevMonth: "Previous month",
|
|
115
|
+
nextMonth: "Next month",
|
|
116
|
+
untitled: "Untitled",
|
|
117
|
+
lists: "Lists",
|
|
118
|
+
calendars: "Calendars"
|
|
119
|
+
};
|
|
120
|
+
var VIEW_PREFERENCE_KEY = "dsh.ios-agenda.view";
|
|
121
|
+
function hexColor(value) {
|
|
122
|
+
return typeof value === "string" && /^#[0-9A-Fa-f]{6}$/.test(value) ? value : "";
|
|
123
|
+
}
|
|
124
|
+
function idList(value) {
|
|
125
|
+
if (!Array.isArray(value)) return [];
|
|
126
|
+
return value.filter((item) => typeof item === "string" && item);
|
|
127
|
+
}
|
|
128
|
+
function readViewPreference() {
|
|
129
|
+
const empty = { mode: "day", hiddenLists: [], hiddenCalendars: [] };
|
|
130
|
+
if (typeof localStorage === "undefined") return empty;
|
|
131
|
+
try {
|
|
132
|
+
const parsed = JSON.parse(localStorage.getItem(VIEW_PREFERENCE_KEY) || "null");
|
|
133
|
+
if (!parsed || typeof parsed !== "object") return empty;
|
|
134
|
+
return {
|
|
135
|
+
mode: parsed.mode === "week" ? "week" : "day",
|
|
136
|
+
hiddenLists: idList(parsed.hiddenLists),
|
|
137
|
+
hiddenCalendars: idList(parsed.hiddenCalendars)
|
|
138
|
+
};
|
|
139
|
+
} catch {
|
|
140
|
+
return empty;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function soleAccent(colors) {
|
|
144
|
+
const unique = new Set(colors.filter(Boolean));
|
|
145
|
+
return unique.size === 1 ? [...unique][0] : "";
|
|
146
|
+
}
|
|
147
|
+
function startOfDay(date) {
|
|
148
|
+
const next = new Date(date);
|
|
149
|
+
next.setHours(0, 0, 0, 0);
|
|
150
|
+
return next;
|
|
151
|
+
}
|
|
152
|
+
function addDays(date, days) {
|
|
153
|
+
const next = new Date(date);
|
|
154
|
+
next.setDate(next.getDate() + days);
|
|
155
|
+
return next;
|
|
156
|
+
}
|
|
157
|
+
function startOfWeek(date) {
|
|
158
|
+
const day = startOfDay(date);
|
|
159
|
+
const weekday = day.getDay();
|
|
160
|
+
return addDays(day, weekday === 0 ? -6 : 1 - weekday);
|
|
161
|
+
}
|
|
162
|
+
function monthGrid(year, month) {
|
|
163
|
+
const start = startOfWeek(new Date(year, month, 1));
|
|
164
|
+
return Array.from({ length: 42 }, (_, index) => addDays(start, index));
|
|
165
|
+
}
|
|
166
|
+
function sameDay(left, right) {
|
|
167
|
+
return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth() && left.getDate() === right.getDate();
|
|
168
|
+
}
|
|
169
|
+
function dayKey(date) {
|
|
170
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
171
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
172
|
+
return `${date.getFullYear()}-${month}-${day}`;
|
|
173
|
+
}
|
|
174
|
+
function parseDate(value) {
|
|
175
|
+
if (!value) return null;
|
|
176
|
+
const date = new Date(value);
|
|
177
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
178
|
+
}
|
|
179
|
+
function hasClock(date) {
|
|
180
|
+
return date.getHours() !== 0 || date.getMinutes() !== 0;
|
|
181
|
+
}
|
|
182
|
+
function clock(date) {
|
|
183
|
+
return new Intl.DateTimeFormat(void 0, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).format(date);
|
|
184
|
+
}
|
|
185
|
+
function monthHeading(year, month) {
|
|
186
|
+
return new Intl.DateTimeFormat(void 0, { year: "numeric", month: "long" }).format(new Date(year, month, 1));
|
|
187
|
+
}
|
|
188
|
+
function dayHeading(date) {
|
|
189
|
+
return new Intl.DateTimeFormat(void 0, { month: "long", day: "numeric", weekday: "short" }).format(date);
|
|
190
|
+
}
|
|
191
|
+
function shortDate(date) {
|
|
192
|
+
return new Intl.DateTimeFormat(void 0, { month: "short", day: "numeric" }).format(date);
|
|
193
|
+
}
|
|
194
|
+
function weekdayNarrow(index) {
|
|
195
|
+
const monday = new Date(2026, 0, 5);
|
|
196
|
+
return new Intl.DateTimeFormat(void 0, { weekday: "narrow" }).format(addDays(monday, index));
|
|
197
|
+
}
|
|
198
|
+
function weekdayShort(date) {
|
|
199
|
+
return new Intl.DateTimeFormat(void 0, { weekday: "short" }).format(date);
|
|
200
|
+
}
|
|
201
|
+
function localInputValue(date) {
|
|
202
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
203
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
204
|
+
const hour = String(date.getHours()).padStart(2, "0");
|
|
205
|
+
const minute = String(date.getMinutes()).padStart(2, "0");
|
|
206
|
+
return `${date.getFullYear()}-${month}-${day}T${hour}:${minute}`;
|
|
207
|
+
}
|
|
208
|
+
function eventOverlapsDay(event, day) {
|
|
209
|
+
const start = parseDate(event.start);
|
|
210
|
+
if (!start) return false;
|
|
211
|
+
const end = parseDate(event.end);
|
|
212
|
+
const dayStart = startOfDay(day);
|
|
213
|
+
const dayEnd = addDays(dayStart, 1);
|
|
214
|
+
const eventEnd = end && end > start ? end : new Date(start.getTime() + (event.allDay ? 864e5 : 0));
|
|
215
|
+
return start < dayEnd && eventEnd > dayStart;
|
|
216
|
+
}
|
|
217
|
+
function reminderOnDay(item, day) {
|
|
218
|
+
const due = parseDate(item.due);
|
|
219
|
+
return Boolean(due && sameDay(due, day));
|
|
220
|
+
}
|
|
221
|
+
function isOverdue(item, today) {
|
|
222
|
+
const due = parseDate(item.due);
|
|
223
|
+
return Boolean(due && startOfDay(due) < startOfDay(today));
|
|
224
|
+
}
|
|
225
|
+
function eventTimeLabel(event, day, t) {
|
|
226
|
+
if (event.allDay) return t("allDay");
|
|
227
|
+
const start = parseDate(event.start);
|
|
228
|
+
const end = parseDate(event.end);
|
|
229
|
+
if (!start) return "";
|
|
230
|
+
const startsToday = sameDay(start, day);
|
|
231
|
+
const endsToday = Boolean(end && sameDay(end, day));
|
|
232
|
+
if (startsToday && endsToday) return `${clock(start)}\u2013${clock(end)}`;
|
|
233
|
+
if (startsToday) return end ? `${clock(start)}\u2013` : clock(start);
|
|
234
|
+
if (endsToday) return `\u2013${clock(end)}`;
|
|
235
|
+
return t("continues");
|
|
236
|
+
}
|
|
237
|
+
function reminderTimeLabel(item) {
|
|
238
|
+
const due = parseDate(item.due);
|
|
239
|
+
if (!due || !hasClock(due)) return "";
|
|
240
|
+
return clock(due);
|
|
241
|
+
}
|
|
242
|
+
function overdueTimeLabel(item) {
|
|
243
|
+
const due = parseDate(item.due);
|
|
244
|
+
if (!due) return "";
|
|
245
|
+
return hasClock(due) ? `${shortDate(due)} ${clock(due)}` : shortDate(due);
|
|
246
|
+
}
|
|
247
|
+
function dayBlocks(day, events, reminders) {
|
|
248
|
+
const timed = [];
|
|
249
|
+
const later = [];
|
|
250
|
+
events.filter((event) => eventOverlapsDay(event, day)).forEach((event) => {
|
|
251
|
+
const block = { kind: "event", id: event.id, event, day, at: parseDate(event.start)?.getTime() ?? 0 };
|
|
252
|
+
(event.allDay ? later : timed).push(block);
|
|
253
|
+
});
|
|
254
|
+
reminders.filter((item) => reminderOnDay(item, day)).forEach((reminder) => {
|
|
255
|
+
const due = parseDate(reminder.due);
|
|
256
|
+
const block = { kind: "reminder", id: reminder.id, reminder, day, at: due?.getTime() ?? 0 };
|
|
257
|
+
(due && hasClock(due) ? timed : later).push(block);
|
|
258
|
+
});
|
|
259
|
+
timed.sort((left, right) => left.at - right.at || left.id.localeCompare(right.id));
|
|
260
|
+
return [...timed, ...later];
|
|
261
|
+
}
|
|
262
|
+
function visibleRange(year, month) {
|
|
263
|
+
const days = monthGrid(year, month);
|
|
264
|
+
const from = days[0];
|
|
265
|
+
const to = addDays(days[days.length - 1], 1);
|
|
266
|
+
return { from: from.toISOString(), to: to.toISOString(), key: `${dayKey(from)}/${dayKey(to)}`, days };
|
|
267
|
+
}
|
|
268
|
+
async function invoke(agenda, method, input) {
|
|
269
|
+
if (!agenda?.[method]) return { ok: false, error: { code: "UNAVAILABLE", message: "remote missing" } };
|
|
270
|
+
const result = await agenda[method](input, new AbortController().signal);
|
|
271
|
+
if (!result?.ok) return { ok: false, error: result?.error ?? { code: "FAILED", message: "\u8C03\u7528\u5931\u8D25" } };
|
|
272
|
+
return result.value;
|
|
273
|
+
}
|
|
274
|
+
var ENTRY_ICON = '<svg viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="5" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="1.6"></rect><path d="M3 10h18M8 3v4M16 3v4" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"></path></svg>';
|
|
275
|
+
var ENTRY_STYLE = `
|
|
276
|
+
[data-dsh-ios-agenda-entry] {
|
|
277
|
+
box-sizing: border-box; flex: none; min-height: 36px; margin: 0 2px 4px;
|
|
278
|
+
color: var(--dsw-alias-label-primary); cursor: pointer; white-space: nowrap;
|
|
279
|
+
background: transparent; border: none; border-radius: var(--dsw-radius-md);
|
|
280
|
+
align-items: center; gap: 8px; padding: 7px 8px; font: inherit; line-height: 22px;
|
|
281
|
+
text-align: left; display: flex;
|
|
282
|
+
}
|
|
283
|
+
[data-dsh-ios-agenda-entry]:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
284
|
+
[data-dsh-ios-agenda-entry]:focus-visible {
|
|
285
|
+
outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
|
|
286
|
+
outline-offset: -2px;
|
|
287
|
+
}
|
|
288
|
+
[data-dsh-ios-agenda-entry] .ia-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; }
|
|
289
|
+
[data-dsh-ios-agenda-entry] .ia-icon svg { width: 16px; height: 16px; }
|
|
290
|
+
[data-dsh-ios-agenda-entry] .ia-label { min-width: 0; text-overflow: ellipsis; overflow: hidden; }
|
|
291
|
+
[data-dsh-frame][data-sidebar-collapsed] [data-dsh-ios-agenda-entry],
|
|
292
|
+
[data-sidebar-collapsed] [data-dsh-ios-agenda-entry] {
|
|
293
|
+
justify-content: center; width: 36px; height: 36px; margin: 0 0 12px; padding: 0;
|
|
294
|
+
}
|
|
295
|
+
[data-sidebar-collapsed] [data-dsh-ios-agenda-entry] .ia-icon svg { width: 18px; height: 18px; }
|
|
296
|
+
[data-dsh-frame][data-sidebar-collapsed] [data-dsh-ios-agenda-entry] .ia-label,
|
|
297
|
+
[data-sidebar-collapsed] [data-dsh-ios-agenda-entry] .ia-label { display: none; }
|
|
298
|
+
`;
|
|
299
|
+
function escapeText(value) {
|
|
300
|
+
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
301
|
+
}
|
|
302
|
+
function mountSidebarEntry({ label, onOpen }) {
|
|
303
|
+
if (typeof document === "undefined") return () => {
|
|
304
|
+
};
|
|
305
|
+
if (document.getElementById("ios-agenda-sidebar-style") === null) {
|
|
306
|
+
const style = document.createElement("style");
|
|
307
|
+
style.id = "ios-agenda-sidebar-style";
|
|
308
|
+
style.textContent = ENTRY_STYLE;
|
|
309
|
+
(document.head ?? document.documentElement).appendChild(style);
|
|
310
|
+
}
|
|
311
|
+
const button = document.createElement("button");
|
|
312
|
+
button.type = "button";
|
|
313
|
+
button.setAttribute("data-dsh-ios-agenda-entry", "");
|
|
314
|
+
button.setAttribute("data-dsh-plugin", "ios-agenda");
|
|
315
|
+
button.setAttribute("data-dsh-part", "sidebar-entry");
|
|
316
|
+
button.addEventListener("click", onOpen);
|
|
317
|
+
const paint = () => {
|
|
318
|
+
const text = label();
|
|
319
|
+
button.title = text;
|
|
320
|
+
button.setAttribute("aria-label", text);
|
|
321
|
+
if (button.dataset.label === text) return;
|
|
322
|
+
button.dataset.label = text;
|
|
323
|
+
button.innerHTML = `<span class="ia-icon">${ENTRY_ICON}</span><span class="ia-label">${escapeText(text)}</span>`;
|
|
324
|
+
};
|
|
325
|
+
const place = () => {
|
|
326
|
+
const sidebar = document.querySelector('[data-pane="sidebar"], [class*="sidebarCol"]');
|
|
327
|
+
const column = sidebar?.querySelector('[class*="logoRow"]')?.parentElement ?? sidebar?.firstElementChild;
|
|
328
|
+
if (!column) return;
|
|
329
|
+
paint();
|
|
330
|
+
const history = column.querySelector("[data-dsh-session-reader-entry]");
|
|
331
|
+
if (history) {
|
|
332
|
+
if (button.nextElementSibling !== history) column.insertBefore(button, history);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const newer = column.querySelector('button[class*="newSession"]');
|
|
336
|
+
if (newer) {
|
|
337
|
+
if (button.previousElementSibling !== newer) newer.insertAdjacentElement("afterend", button);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (button.parentElement !== column) column.appendChild(button);
|
|
341
|
+
};
|
|
342
|
+
place();
|
|
343
|
+
const observer = new MutationObserver(place);
|
|
344
|
+
observer.observe(document.documentElement, { childList: true, subtree: true });
|
|
345
|
+
return () => {
|
|
346
|
+
observer.disconnect();
|
|
347
|
+
button.remove();
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function AgendaRow({ compact, time, title, source, location, notes, overdue, accent, onComplete, onDelete, t, busy }) {
|
|
351
|
+
const style = accent ? { "--ia-accent": accent } : void 0;
|
|
352
|
+
if (compact) {
|
|
353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: overdue ? "ia-compact is-overdue" : "ia-compact", style, children: [
|
|
354
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-compact-top", children: [
|
|
355
|
+
onComplete ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: false, "aria-label": t("complete"), disabled: busy, onChange: onComplete }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-time", children: time }),
|
|
356
|
+
onComplete ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-time", children: time }) : null,
|
|
357
|
+
onDelete ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ia-delete", disabled: busy, onClick: onDelete, children: t("remove") }) : null
|
|
358
|
+
] }),
|
|
359
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { className: "ia-title", children: title || t("untitled") }),
|
|
360
|
+
source ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-source", children: source }) : null
|
|
361
|
+
] });
|
|
362
|
+
}
|
|
363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: overdue ? "ia-row is-overdue" : "ia-row", style, children: [
|
|
364
|
+
onComplete ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: false, "aria-label": t("complete"), disabled: busy, onChange: onComplete }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-check-spacer" }),
|
|
365
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-time", children: time }),
|
|
366
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ia-main", children: [
|
|
367
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { className: "ia-title", children: title || t("untitled") }),
|
|
368
|
+
notes ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-detail", children: notes }) : null
|
|
369
|
+
] }),
|
|
370
|
+
source ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-source", children: source }) : null,
|
|
371
|
+
location ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-location", children: location }) : null,
|
|
372
|
+
onDelete ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ia-delete", disabled: busy, onClick: onDelete, children: t("remove") }) : null
|
|
373
|
+
] });
|
|
374
|
+
}
|
|
375
|
+
function AgendaBlocks({ blocks, overdueIds, listColors, calendarColors, t, busy, onComplete, onDelete, compact }) {
|
|
376
|
+
return blocks.map((block) => {
|
|
377
|
+
if (block.kind === "event") {
|
|
378
|
+
const { event, day } = block;
|
|
379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
380
|
+
AgendaRow,
|
|
381
|
+
{
|
|
382
|
+
compact,
|
|
383
|
+
time: eventTimeLabel(event, day, t),
|
|
384
|
+
title: event.title,
|
|
385
|
+
source: event.calendar,
|
|
386
|
+
location: compact ? "" : event.location,
|
|
387
|
+
notes: compact ? "" : event.notes,
|
|
388
|
+
accent: calendarColors.get(event.calendarId) || "",
|
|
389
|
+
onDelete: () => onDelete("deleteEvent", event.id),
|
|
390
|
+
t,
|
|
391
|
+
busy
|
|
392
|
+
},
|
|
393
|
+
`event:${event.id}:${dayKey(day)}`
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
const { reminder } = block;
|
|
397
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
398
|
+
AgendaRow,
|
|
399
|
+
{
|
|
400
|
+
compact,
|
|
401
|
+
time: reminderTimeLabel(reminder),
|
|
402
|
+
title: reminder.title,
|
|
403
|
+
source: reminder.list,
|
|
404
|
+
notes: compact ? "" : reminder.notes,
|
|
405
|
+
overdue: overdueIds.has(reminder.id),
|
|
406
|
+
accent: listColors.get(reminder.listId) || "",
|
|
407
|
+
onComplete: () => onComplete(reminder.id),
|
|
408
|
+
onDelete: () => onDelete("deleteReminder", reminder.id),
|
|
409
|
+
t,
|
|
410
|
+
busy
|
|
411
|
+
},
|
|
412
|
+
`reminder:${reminder.id}`
|
|
413
|
+
);
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
function FilterList({ label, items, hidden, onToggle }) {
|
|
417
|
+
const rowsRef = (0, import_react.useRef)(null);
|
|
418
|
+
const positions = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
419
|
+
const ordered = (0, import_react.useMemo)(() => {
|
|
420
|
+
const shown = [];
|
|
421
|
+
const concealed = [];
|
|
422
|
+
items.forEach((item) => (hidden.has(item.id) ? concealed : shown).push(item));
|
|
423
|
+
return [...shown, ...concealed];
|
|
424
|
+
}, [items, hidden]);
|
|
425
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
426
|
+
const root = rowsRef.current;
|
|
427
|
+
if (!root) return;
|
|
428
|
+
const next = /* @__PURE__ */ new Map();
|
|
429
|
+
root.querySelectorAll("[data-filter-id]").forEach((node) => {
|
|
430
|
+
const id = node.getAttribute("data-filter-id");
|
|
431
|
+
const top = node.getBoundingClientRect().top;
|
|
432
|
+
const previous = positions.current.get(id);
|
|
433
|
+
if (previous != null && previous !== top) {
|
|
434
|
+
const delta = previous - top;
|
|
435
|
+
node.style.transition = "none";
|
|
436
|
+
node.style.transform = `translateY(${delta}px)`;
|
|
437
|
+
node.getBoundingClientRect();
|
|
438
|
+
requestAnimationFrame(() => {
|
|
439
|
+
requestAnimationFrame(() => {
|
|
440
|
+
node.style.transition = "transform 220ms ease";
|
|
441
|
+
node.style.transform = "";
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
next.set(id, top);
|
|
446
|
+
});
|
|
447
|
+
positions.current = next;
|
|
448
|
+
}, [ordered]);
|
|
449
|
+
if (items.length === 0) return null;
|
|
450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-filter-block", children: [
|
|
451
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ia-filter-head", children: label }),
|
|
452
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: rowsRef, children: ordered.map((item) => {
|
|
453
|
+
const color = hexColor(item.color);
|
|
454
|
+
const checked = !hidden.has(item.id);
|
|
455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
456
|
+
"label",
|
|
457
|
+
{
|
|
458
|
+
"data-filter-id": item.id,
|
|
459
|
+
className: checked ? "ia-filter-row" : "ia-filter-row is-off",
|
|
460
|
+
title: item.title,
|
|
461
|
+
style: color ? { "--ia-swatch": color } : void 0,
|
|
462
|
+
children: [
|
|
463
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked, onChange: () => onToggle(item.id) }),
|
|
464
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "ia-swatch" }),
|
|
465
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ia-filter-name", children: item.title })
|
|
466
|
+
]
|
|
467
|
+
},
|
|
468
|
+
item.id
|
|
469
|
+
);
|
|
470
|
+
}) })
|
|
471
|
+
] });
|
|
472
|
+
}
|
|
473
|
+
function AgendaPage({ t, agenda }) {
|
|
474
|
+
const today = startOfDay(/* @__PURE__ */ new Date());
|
|
475
|
+
const [cursor, setCursor] = (0, import_react.useState)(() => startOfDay(/* @__PURE__ */ new Date()));
|
|
476
|
+
const [month, setMonth] = (0, import_react.useState)(() => {
|
|
477
|
+
const now = /* @__PURE__ */ new Date();
|
|
478
|
+
return { year: now.getFullYear(), month: now.getMonth() };
|
|
479
|
+
});
|
|
480
|
+
const [viewPreference] = (0, import_react.useState)(readViewPreference);
|
|
481
|
+
const [mode, setMode] = (0, import_react.useState)(viewPreference.mode);
|
|
482
|
+
const [data, setData] = (0, import_react.useState)(null);
|
|
483
|
+
const [loadedKey, setLoadedKey] = (0, import_react.useState)("");
|
|
484
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
485
|
+
const [busy, setBusy] = (0, import_react.useState)(false);
|
|
486
|
+
const [revision, setRevision] = (0, import_react.useState)(0);
|
|
487
|
+
const [hiddenLists, setHiddenLists] = (0, import_react.useState)(() => new Set(viewPreference.hiddenLists));
|
|
488
|
+
const [hiddenCalendars, setHiddenCalendars] = (0, import_react.useState)(() => new Set(viewPreference.hiddenCalendars));
|
|
489
|
+
const [reminderTitle, setReminderTitle] = (0, import_react.useState)("");
|
|
490
|
+
const [eventOpen, setEventOpen] = (0, import_react.useState)(false);
|
|
491
|
+
const [eventTitle, setEventTitle] = (0, import_react.useState)("");
|
|
492
|
+
const [eventStart, setEventStart] = (0, import_react.useState)("");
|
|
493
|
+
const [eventEnd, setEventEnd] = (0, import_react.useState)("");
|
|
494
|
+
const requestRef = (0, import_react.useRef)(0);
|
|
495
|
+
const overdueRef = (0, import_react.useRef)(null);
|
|
496
|
+
const undatedRef = (0, import_react.useRef)(null);
|
|
497
|
+
const range = (0, import_react.useMemo)(() => visibleRange(month.year, month.month), [month.year, month.month]);
|
|
498
|
+
(0, import_react.useEffect)(() => {
|
|
499
|
+
const requestId = ++requestRef.current;
|
|
500
|
+
let active = true;
|
|
501
|
+
(async () => {
|
|
502
|
+
setBusy(true);
|
|
503
|
+
const result = await invoke(agenda, "snapshot", { from: range.from, to: range.to, limit: 500 });
|
|
504
|
+
if (!active || requestId !== requestRef.current) return;
|
|
505
|
+
setBusy(false);
|
|
506
|
+
if (!result.ok) {
|
|
507
|
+
setError(result.error?.code === "ACCESS_DENIED" ? t("permission") : result.error?.message || t("unavailable"));
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
setError("");
|
|
511
|
+
setData(result.data);
|
|
512
|
+
setLoadedKey(range.key);
|
|
513
|
+
})();
|
|
514
|
+
return () => {
|
|
515
|
+
active = false;
|
|
516
|
+
};
|
|
517
|
+
}, [agenda, range.from, range.to, range.key, revision]);
|
|
518
|
+
(0, import_react.useEffect)(() => {
|
|
519
|
+
if (typeof localStorage === "undefined") return;
|
|
520
|
+
try {
|
|
521
|
+
localStorage.setItem(VIEW_PREFERENCE_KEY, JSON.stringify({
|
|
522
|
+
mode,
|
|
523
|
+
hiddenLists: [...hiddenLists],
|
|
524
|
+
hiddenCalendars: [...hiddenCalendars]
|
|
525
|
+
}));
|
|
526
|
+
} catch {
|
|
527
|
+
}
|
|
528
|
+
}, [mode, hiddenLists, hiddenCalendars]);
|
|
529
|
+
function selectDay(date) {
|
|
530
|
+
const day = startOfDay(date);
|
|
531
|
+
setCursor(day);
|
|
532
|
+
if (day.getFullYear() !== month.year || day.getMonth() !== month.month) {
|
|
533
|
+
setMonth({ year: day.getFullYear(), month: day.getMonth() });
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function shiftMonth(delta) {
|
|
537
|
+
const next = new Date(month.year, month.month + delta, 1);
|
|
538
|
+
const year = next.getFullYear();
|
|
539
|
+
const nextMonth = next.getMonth();
|
|
540
|
+
setMonth({ year, month: nextMonth });
|
|
541
|
+
const selectedHere = cursor.getFullYear() === year && cursor.getMonth() === nextMonth;
|
|
542
|
+
if (selectedHere) return;
|
|
543
|
+
const todayHere = today.getFullYear() === year && today.getMonth() === nextMonth;
|
|
544
|
+
setCursor(todayHere ? today : next);
|
|
545
|
+
}
|
|
546
|
+
async function submit(method, input, clear) {
|
|
547
|
+
setBusy(true);
|
|
548
|
+
const result = await invoke(agenda, method, input);
|
|
549
|
+
setBusy(false);
|
|
550
|
+
if (!result.ok) {
|
|
551
|
+
setError(result.error?.message || t("unavailable"));
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
clear();
|
|
555
|
+
setRevision((value) => value + 1);
|
|
556
|
+
}
|
|
557
|
+
function openEvent() {
|
|
558
|
+
if (!eventStart || !eventEnd) {
|
|
559
|
+
const start = new Date(cursor);
|
|
560
|
+
start.setHours(9, 0, 0, 0);
|
|
561
|
+
const end = new Date(cursor);
|
|
562
|
+
end.setHours(10, 0, 0, 0);
|
|
563
|
+
if (!eventStart) setEventStart(localInputValue(start));
|
|
564
|
+
if (!eventEnd) setEventEnd(localInputValue(end));
|
|
565
|
+
}
|
|
566
|
+
setEventOpen(true);
|
|
567
|
+
}
|
|
568
|
+
const ready = data && loadedKey === range.key ? data : null;
|
|
569
|
+
const lists = ready?.lists ?? [];
|
|
570
|
+
const calendars = ready?.calendars ?? [];
|
|
571
|
+
const listIdsKey = lists.map((list) => list.id).join("\n");
|
|
572
|
+
const calendarIdsKey = calendars.map((calendar) => calendar.id).join("\n");
|
|
573
|
+
const listColors = new Map(lists.map((list) => [list.id, hexColor(list.color)]));
|
|
574
|
+
const calendarColors = new Map(calendars.map((calendar) => [calendar.id, hexColor(calendar.color)]));
|
|
575
|
+
const reminders = (ready?.reminders ?? []).filter((item) => !item.completed && !hiddenLists.has(item.listId));
|
|
576
|
+
const events = (ready?.events ?? []).filter((item) => !hiddenCalendars.has(item.calendarId));
|
|
577
|
+
(0, import_react.useEffect)(() => {
|
|
578
|
+
if (!ready) return;
|
|
579
|
+
const listIds = new Set(listIdsKey ? listIdsKey.split("\n") : []);
|
|
580
|
+
const calendarIds = new Set(calendarIdsKey ? calendarIdsKey.split("\n") : []);
|
|
581
|
+
setHiddenLists((current) => {
|
|
582
|
+
const next = [...current].filter((id) => listIds.has(id));
|
|
583
|
+
return next.length === current.size ? current : new Set(next);
|
|
584
|
+
});
|
|
585
|
+
setHiddenCalendars((current) => {
|
|
586
|
+
const next = [...current].filter((id) => calendarIds.has(id));
|
|
587
|
+
return next.length === current.size ? current : new Set(next);
|
|
588
|
+
});
|
|
589
|
+
}, [ready, listIdsKey, calendarIdsKey]);
|
|
590
|
+
function toggleHidden(kind, id) {
|
|
591
|
+
const setter = kind === "list" ? setHiddenLists : setHiddenCalendars;
|
|
592
|
+
setter((current) => {
|
|
593
|
+
const next = new Set(current);
|
|
594
|
+
if (next.has(id)) next.delete(id);
|
|
595
|
+
else next.add(id);
|
|
596
|
+
return next;
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
const overdueIds = new Set(reminders.filter((item) => isOverdue(item, today)).map((item) => item.id));
|
|
600
|
+
const weekDays = Array.from({ length: 7 }, (_, index) => addDays(startOfWeek(cursor), index));
|
|
601
|
+
const visibleDays = mode === "week" ? weekDays : [cursor];
|
|
602
|
+
const shownIds = new Set(visibleDays.flatMap((day) => reminders.filter((item) => reminderOnDay(item, day)).map((item) => item.id)));
|
|
603
|
+
const overdueItems = reminders.filter((item) => overdueIds.has(item.id) && !shownIds.has(item.id)).sort((left, right) => (parseDate(left.due)?.getTime() ?? 0) - (parseDate(right.due)?.getTime() ?? 0));
|
|
604
|
+
const undatedItems = reminders.filter((item) => !item.due);
|
|
605
|
+
const marks = new Map(range.days.map((day) => {
|
|
606
|
+
const key = dayKey(day);
|
|
607
|
+
const dayEvents = events.filter((event) => eventOverlapsDay(event, day));
|
|
608
|
+
const dayReminders = reminders.filter((item) => reminderOnDay(item, day));
|
|
609
|
+
return [key, {
|
|
610
|
+
event: dayEvents.length > 0,
|
|
611
|
+
reminder: dayReminders.length > 0,
|
|
612
|
+
eventColor: soleAccent(dayEvents.map((event) => calendarColors.get(event.calendarId))),
|
|
613
|
+
reminderColor: soleAccent(dayReminders.map((item) => listColors.get(item.listId)))
|
|
614
|
+
}];
|
|
615
|
+
}));
|
|
616
|
+
function scrollTo(target) {
|
|
617
|
+
target.current?.scrollIntoView({ block: "start" });
|
|
618
|
+
}
|
|
619
|
+
const dayList = dayBlocks(cursor, events, reminders);
|
|
620
|
+
const weekLabel = `${shortDate(weekDays[0])} \u2013 ${shortDate(weekDays[6])}`;
|
|
621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "ios-agenda", "aria-busy": busy, children: [
|
|
622
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: css }),
|
|
623
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-body", children: [
|
|
624
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", { className: "ia-side", children: [
|
|
625
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-month", children: [
|
|
626
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-label": t("prevMonth"), onClick: () => shiftMonth(-1), children: "\u2039" }),
|
|
627
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: monthHeading(month.year, month.month) }),
|
|
628
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-label": t("nextMonth"), onClick: () => shiftMonth(1), children: "\u203A" })
|
|
629
|
+
] }),
|
|
630
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ia-weekdays", "aria-hidden": "true", children: Array.from({ length: 7 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: weekdayNarrow(index) }, index)) }),
|
|
631
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ia-cal", children: range.days.map((day) => {
|
|
632
|
+
const outside = day.getMonth() !== month.month;
|
|
633
|
+
const selected = sameDay(day, cursor);
|
|
634
|
+
const mark = marks.get(dayKey(day)) ?? { event: false, reminder: false };
|
|
635
|
+
const className = [
|
|
636
|
+
"ia-day",
|
|
637
|
+
outside ? "is-outside" : "",
|
|
638
|
+
sameDay(day, today) ? "is-today" : "",
|
|
639
|
+
selected ? "is-selected" : ""
|
|
640
|
+
].filter(Boolean).join(" ");
|
|
641
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
642
|
+
"button",
|
|
643
|
+
{
|
|
644
|
+
type: "button",
|
|
645
|
+
className,
|
|
646
|
+
"aria-current": sameDay(day, today) ? "date" : void 0,
|
|
647
|
+
"aria-pressed": selected,
|
|
648
|
+
onClick: () => selectDay(day),
|
|
649
|
+
children: [
|
|
650
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: day.getDate() }),
|
|
651
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ia-dots", children: [
|
|
652
|
+
mark.event ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "ia-dot ia-dot-event", style: mark.eventColor ? { background: mark.eventColor } : void 0 }) : null,
|
|
653
|
+
mark.reminder ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "ia-dot ia-dot-reminder", style: mark.reminderColor ? { background: mark.reminderColor } : void 0 }) : null
|
|
654
|
+
] })
|
|
655
|
+
]
|
|
656
|
+
},
|
|
657
|
+
dayKey(day)
|
|
658
|
+
);
|
|
659
|
+
}) }),
|
|
660
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-jumps", children: [
|
|
661
|
+
overdueItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "ia-jump-overdue", onClick: () => scrollTo(overdueRef), children: [
|
|
662
|
+
t("overdue"),
|
|
663
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: overdueItems.length })
|
|
664
|
+
] }),
|
|
665
|
+
undatedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", onClick: () => scrollTo(undatedRef), children: [
|
|
666
|
+
t("undated"),
|
|
667
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: undatedItems.length })
|
|
668
|
+
] })
|
|
669
|
+
] }),
|
|
670
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterList, { label: t("lists"), items: lists, hidden: hiddenLists, onToggle: (id) => toggleHidden("list", id) }),
|
|
671
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterList, { label: t("calendars"), items: calendars, hidden: hiddenCalendars, onToggle: (id) => toggleHidden("calendar", id) })
|
|
672
|
+
] }),
|
|
673
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-board", children: [
|
|
674
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-board-scroll", children: [
|
|
675
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "ia-board-head", children: [
|
|
676
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: mode === "week" ? weekLabel : dayHeading(cursor) }),
|
|
677
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ia-modes", role: "group", children: [
|
|
678
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-pressed": mode === "day" && sameDay(cursor, today), onClick: () => {
|
|
679
|
+
setMode("day");
|
|
680
|
+
selectDay(today);
|
|
681
|
+
}, children: t("today") }),
|
|
682
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-pressed": mode === "week", onClick: () => setMode("week"), children: t("week") })
|
|
683
|
+
] }),
|
|
684
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ia-refresh", onClick: () => setRevision((value) => value + 1), disabled: busy, children: t("refresh") })
|
|
685
|
+
] }),
|
|
686
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "ios-agenda-error", role: "alert", children: error }),
|
|
687
|
+
!ready && !error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "ios-agenda-muted", children: t("loading") }),
|
|
688
|
+
ready && mode === "day" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", { className: "ia-day-list", children: dayList.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgendaBlocks, { blocks: dayList, overdueIds, listColors, calendarColors, t, busy, onComplete: (id) => submit("completeReminder", { id, completed: true }, () => {
|
|
689
|
+
}), onDelete: (method, id) => submit(method, { id }, () => {
|
|
690
|
+
}) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "ios-agenda-muted", children: t("emptyDay") }) }),
|
|
691
|
+
ready && mode === "week" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ia-week-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ia-week", children: weekDays.map((day) => {
|
|
692
|
+
const blocks = dayBlocks(day, events, reminders);
|
|
693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: sameDay(day, cursor) ? "ia-week-col is-selected" : "ia-week-col", children: [
|
|
694
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: sameDay(day, today) ? "ia-week-head is-today" : "ia-week-head", onClick: () => selectDay(day), children: [
|
|
695
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: weekdayShort(day) }),
|
|
696
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: day.getDate() })
|
|
697
|
+
] }),
|
|
698
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgendaBlocks, { compact: true, blocks, overdueIds, listColors, calendarColors, t, busy, onComplete: (id) => submit("completeReminder", { id, completed: true }, () => {
|
|
699
|
+
}), onDelete: (method, id) => submit(method, { id }, () => {
|
|
700
|
+
}) })
|
|
701
|
+
] }, dayKey(day));
|
|
702
|
+
}) }) }),
|
|
703
|
+
ready && overdueItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "ia-group", ref: overdueRef, children: [
|
|
704
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: t("overdue") }),
|
|
705
|
+
overdueItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
706
|
+
AgendaRow,
|
|
707
|
+
{
|
|
708
|
+
time: overdueTimeLabel(item),
|
|
709
|
+
title: item.title,
|
|
710
|
+
source: item.list,
|
|
711
|
+
notes: item.notes,
|
|
712
|
+
overdue: true,
|
|
713
|
+
accent: listColors.get(item.listId) || "",
|
|
714
|
+
onComplete: () => submit("completeReminder", { id: item.id, completed: true }, () => {
|
|
715
|
+
}),
|
|
716
|
+
onDelete: () => submit("deleteReminder", { id: item.id }, () => {
|
|
717
|
+
}),
|
|
718
|
+
t,
|
|
719
|
+
busy
|
|
720
|
+
},
|
|
721
|
+
`overdue:${item.id}`
|
|
722
|
+
))
|
|
723
|
+
] }),
|
|
724
|
+
ready && undatedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "ia-group", ref: undatedRef, children: [
|
|
725
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: t("undated") }),
|
|
726
|
+
undatedItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
727
|
+
AgendaRow,
|
|
728
|
+
{
|
|
729
|
+
time: "",
|
|
730
|
+
title: item.title,
|
|
731
|
+
source: item.list,
|
|
732
|
+
notes: item.notes,
|
|
733
|
+
accent: listColors.get(item.listId) || "",
|
|
734
|
+
onComplete: () => submit("completeReminder", { id: item.id, completed: true }, () => {
|
|
735
|
+
}),
|
|
736
|
+
onDelete: () => submit("deleteReminder", { id: item.id }, () => {
|
|
737
|
+
}),
|
|
738
|
+
t,
|
|
739
|
+
busy
|
|
740
|
+
},
|
|
741
|
+
`undated:${item.id}`
|
|
742
|
+
))
|
|
743
|
+
] })
|
|
744
|
+
] }),
|
|
745
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: "ia-composer", onSubmit: (event) => {
|
|
746
|
+
event.preventDefault();
|
|
747
|
+
if (!reminderTitle.trim()) return;
|
|
748
|
+
submit("createReminder", { title: reminderTitle.trim() }, () => setReminderTitle(""));
|
|
749
|
+
}, children: [
|
|
750
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { "aria-label": t("titleField"), value: reminderTitle, placeholder: t("newReminder"), onChange: (event) => setReminderTitle(event.target.value) }),
|
|
751
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", disabled: busy || !reminderTitle.trim(), children: t("add") }),
|
|
752
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => eventOpen ? setEventOpen(false) : openEvent(), children: t("newEvent") })
|
|
753
|
+
] }),
|
|
754
|
+
eventOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: "ia-event-form", onSubmit: (event) => {
|
|
755
|
+
event.preventDefault();
|
|
756
|
+
if (!eventTitle.trim() || !eventStart || !eventEnd) return;
|
|
757
|
+
submit("createEvent", {
|
|
758
|
+
title: eventTitle.trim(),
|
|
759
|
+
start: new Date(eventStart).toISOString(),
|
|
760
|
+
end: new Date(eventEnd).toISOString()
|
|
761
|
+
}, () => {
|
|
762
|
+
setEventTitle("");
|
|
763
|
+
setEventStart("");
|
|
764
|
+
setEventEnd("");
|
|
765
|
+
setEventOpen(false);
|
|
766
|
+
});
|
|
767
|
+
}, children: [
|
|
768
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { "aria-label": t("titleField"), value: eventTitle, placeholder: t("newEvent"), onChange: (event) => setEventTitle(event.target.value) }),
|
|
769
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { "aria-label": t("start"), type: "datetime-local", value: eventStart, onChange: (event) => setEventStart(event.target.value) }),
|
|
770
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { "aria-label": t("end"), type: "datetime-local", value: eventEnd, onChange: (event) => setEventEnd(event.target.value) }),
|
|
771
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", disabled: busy || !eventTitle.trim() || !eventStart || !eventEnd, children: t("add") })
|
|
772
|
+
] })
|
|
773
|
+
] })
|
|
774
|
+
] })
|
|
775
|
+
] });
|
|
776
|
+
}
|
|
777
|
+
var css = `
|
|
778
|
+
.ios-agenda { --ia-danger: var(--dsw-alias-state-danger, #d14343); box-sizing: border-box; height: 100%; overflow: hidden; color: var(--dsw-alias-label-primary); background: var(--dsw-alias-bg-base); }
|
|
779
|
+
.ios-agenda * { box-sizing: border-box; }
|
|
780
|
+
.ios-agenda button, .ios-agenda input { font: inherit; color: inherit; }
|
|
781
|
+
.ia-body { height: 100%; display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: 0; }
|
|
782
|
+
.ia-side { min-height: 0; overflow: auto; padding: 16px 16px 20px; border-right: 1px solid var(--dsw-alias-border-default); }
|
|
783
|
+
.ia-month { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
|
|
784
|
+
.ia-month strong { font-size: 15px; font-weight: 600; }
|
|
785
|
+
.ia-month button, .ia-refresh, .ia-composer button, .ia-event-form button { border: 1px solid var(--dsw-alias-border-default); background: var(--dsw-alias-bg-layer-1); border-radius: 8px; padding: 4px 10px; cursor: pointer; }
|
|
786
|
+
.ia-month button { width: 32px; height: 32px; padding: 0; border: none; background: transparent; }
|
|
787
|
+
.ia-month button:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
788
|
+
.ia-composer button[type="submit"], .ia-event-form button[type="submit"] { border-color: transparent; background: var(--dsw-alias-state-business-primary); color: var(--dsw-alias-bg-base); }
|
|
789
|
+
.ia-weekdays, .ia-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
|
|
790
|
+
.ia-weekdays { margin-bottom: 4px; color: var(--dsw-alias-label-secondary); font-size: 12px; text-align: center; }
|
|
791
|
+
.ia-day { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; aspect-ratio: 1; border: none; border-radius: 8px; background: transparent; cursor: pointer; padding: 0; }
|
|
792
|
+
.ia-day:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
793
|
+
.ia-day.is-outside { color: var(--dsw-alias-label-secondary); opacity: 0.45; }
|
|
794
|
+
.ia-day.is-today > span:first-child { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--dsw-alias-state-business-primary); color: var(--dsw-alias-bg-base); font-weight: 600; }
|
|
795
|
+
.ia-day.is-selected { background: var(--dsw-alias-bg-layer-1); box-shadow: inset 0 0 0 1.5px var(--dsw-alias-state-business-primary); color: var(--dsw-alias-label-primary); opacity: 1; }
|
|
796
|
+
.ia-day:focus-visible, .ia-week-head:focus-visible, .ia-modes button:focus-visible, .ia-filter-row:focus-visible { outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); outline-offset: -2px; }
|
|
797
|
+
.ia-dots { display: flex; gap: 3px; height: 5px; }
|
|
798
|
+
.ia-dot { width: 5px; height: 5px; border-radius: 50%; }
|
|
799
|
+
.ia-dot-event { background: var(--dsw-alias-state-business-primary); }
|
|
800
|
+
.ia-dot-reminder { background: var(--dsw-alias-label-secondary); }
|
|
801
|
+
.ia-jumps { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
|
|
802
|
+
.ia-jumps button, .ia-modes button, .ia-filter-row { border: none; background: transparent; border-radius: 8px; cursor: pointer; }
|
|
803
|
+
.ia-jumps button { display: flex; justify-content: space-between; width: 100%; padding: 6px 8px; text-align: left; }
|
|
804
|
+
.ia-jumps button:hover, .ia-modes button:hover, .ia-filter-row:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
805
|
+
.ia-jumps strong { font-weight: 600; }
|
|
806
|
+
.ia-jump-overdue strong { color: var(--ia-danger); }
|
|
807
|
+
.ia-filter-block { margin-top: 16px; }
|
|
808
|
+
.ia-filter-head { margin: 0 8px 4px; color: var(--dsw-alias-label-secondary); font-size: 12px; }
|
|
809
|
+
.ia-filter-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; text-align: left; color: var(--dsw-alias-label-primary); cursor: pointer; }
|
|
810
|
+
.ia-filter-row.is-off { color: var(--dsw-alias-label-secondary); }
|
|
811
|
+
.ia-filter-row.is-off .ia-swatch { opacity: 0.4; }
|
|
812
|
+
.ia-filter-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
813
|
+
.ia-swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ia-swatch, var(--dsw-alias-label-secondary)); }
|
|
814
|
+
.ia-board { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
|
|
815
|
+
.ia-board-scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px 24px 8px; }
|
|
816
|
+
.ia-board-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-bottom: 10px; background: var(--dsw-alias-bg-base); }
|
|
817
|
+
.ia-board-head h1 { margin: 0; flex: 1; min-width: 0; font-size: 22px; font-weight: 600; }
|
|
818
|
+
.ia-modes { display: flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--dsw-alias-bg-layer-1); }
|
|
819
|
+
.ia-modes button { padding: 6px 10px; color: var(--dsw-alias-label-secondary); }
|
|
820
|
+
.ia-modes button[aria-pressed="true"] { background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); box-shadow: inset 0 0 0 1px var(--dsw-alias-border-default); }
|
|
821
|
+
.ia-row, .ia-compact { box-shadow: inset 3px 0 0 var(--ia-accent, transparent); }
|
|
822
|
+
.ia-row { display: grid; grid-template-columns: 16px 9.5rem minmax(0, 1fr) auto auto auto; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 8px; }
|
|
823
|
+
.ia-row:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
824
|
+
.ia-check-spacer { width: 16px; height: 16px; }
|
|
825
|
+
.ia-time { font-variant-numeric: tabular-nums; color: var(--dsw-alias-label-secondary); white-space: nowrap; }
|
|
826
|
+
.ia-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
|
|
827
|
+
.ia-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
|
|
828
|
+
.ia-source, .ia-location, .ia-detail, .ios-agenda-muted { color: var(--dsw-alias-label-secondary); }
|
|
829
|
+
.ia-source, .ia-location { white-space: nowrap; font-size: 13px; }
|
|
830
|
+
.ia-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 400; }
|
|
831
|
+
.ia-delete { opacity: 0; border: none; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; padding: 4px 6px; }
|
|
832
|
+
.ia-row:hover .ia-delete, .ia-compact:hover .ia-delete, .ia-delete:focus-visible { opacity: 1; }
|
|
833
|
+
.is-overdue .ia-time { color: var(--ia-danger); }
|
|
834
|
+
.ia-group { margin-top: 22px; scroll-margin-top: 64px; }
|
|
835
|
+
.ia-group h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--dsw-alias-label-secondary); }
|
|
836
|
+
.ia-week-scroll { overflow-x: auto; }
|
|
837
|
+
.ia-week { display: grid; grid-template-columns: repeat(7, minmax(160px, 1fr)); gap: 8px; min-width: 100%; }
|
|
838
|
+
.ia-week-col { min-width: 0; padding: 8px; border-radius: 10px; background: var(--dsw-alias-bg-layer-1); }
|
|
839
|
+
.ia-week-col.is-selected { box-shadow: inset 0 0 0 1.5px var(--dsw-alias-state-business-primary); }
|
|
840
|
+
.ia-week-head { display: flex; justify-content: space-between; width: 100%; margin-bottom: 8px; border: none; background: transparent; cursor: pointer; padding: 2px 2px 6px; color: var(--dsw-alias-label-secondary); }
|
|
841
|
+
.ia-week-head strong { color: var(--dsw-alias-label-primary); }
|
|
842
|
+
.ia-week-head.is-today strong { color: var(--dsw-alias-state-business-primary); }
|
|
843
|
+
.ia-compact { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; border-radius: 8px; }
|
|
844
|
+
.ia-compact:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
845
|
+
.ia-compact-top { display: flex; align-items: center; gap: 6px; min-height: 18px; }
|
|
846
|
+
.ia-compact .ia-title, .ia-compact .ia-source { display: block; }
|
|
847
|
+
.ia-compact .ia-source { font-size: 12px; }
|
|
848
|
+
.ia-compact .ia-delete { position: absolute; top: 2px; right: 0; }
|
|
849
|
+
.ia-composer, .ia-event-form { display: flex; gap: 8px; align-items: center; padding: 10px 24px; }
|
|
850
|
+
.ia-composer { border-top: 1px solid var(--dsw-alias-border-default); }
|
|
851
|
+
.ia-event-form { padding-top: 0; padding-bottom: 14px; }
|
|
852
|
+
.ia-composer input, .ia-event-form input { flex: 1; min-width: 0; border: 1px solid var(--dsw-alias-border-default); background: var(--dsw-alias-bg-layer-1); border-radius: 8px; padding: 8px 10px; }
|
|
853
|
+
.ios-agenda-error { margin: 0 0 12px; padding: 8px 10px; border-radius: 8px; background: var(--dsw-alias-bg-layer-1); }
|
|
854
|
+
.ios-agenda input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--dsw-alias-state-business-primary); }
|
|
855
|
+
.ia-filter-row input[type="checkbox"] { flex: none; accent-color: var(--ia-swatch, var(--dsw-alias-state-business-primary)); }
|
|
856
|
+
button:disabled { cursor: default; opacity: 0.6; }
|
|
857
|
+
@media (max-width: 860px) {
|
|
858
|
+
.ia-body { grid-template-columns: 1fr; }
|
|
859
|
+
.ia-side { border-right: none; border-bottom: 1px solid var(--dsw-alias-border-default); }
|
|
860
|
+
.ia-cal { max-width: 320px; }
|
|
861
|
+
}
|
|
862
|
+
`;
|
|
863
|
+
var inject = ["slots", "locale", "remote"];
|
|
864
|
+
async function apply(ctx) {
|
|
865
|
+
const release = await ctx.remote.$mount(contribution);
|
|
866
|
+
ctx.effect(() => release);
|
|
867
|
+
await ctx.plugin({
|
|
868
|
+
name: `${contribution.package}/page`,
|
|
869
|
+
inject: ["slots", "locale", "layout", `remote.${SERVICE}`],
|
|
870
|
+
apply(pageCtx) {
|
|
871
|
+
const agenda = pageCtx.remote[SERVICE];
|
|
872
|
+
pageCtx.effect(() => pageCtx.locale.register(NS, { zh, en }));
|
|
873
|
+
const t = pageCtx.locale.bind(NS);
|
|
874
|
+
pageCtx.effect(() => pageCtx.slots.inject("main", () => pageCtx.slots.register({
|
|
875
|
+
name: "main",
|
|
876
|
+
key: PANEL_ID,
|
|
877
|
+
locale: NS,
|
|
878
|
+
inject: () => ({ agenda })
|
|
879
|
+
}, AgendaPage)));
|
|
880
|
+
pageCtx.effect(() => mountSidebarEntry({
|
|
881
|
+
label: () => t("panel"),
|
|
882
|
+
onOpen: () => {
|
|
883
|
+
try {
|
|
884
|
+
pageCtx.layout.selectPanel(PANEL_ID);
|
|
885
|
+
} catch (error) {
|
|
886
|
+
console.error("[ios-agenda] \u65E0\u6CD5\u6253\u5F00\u9875\u9762", error);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}));
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
return module.exports;}});
|