@rapidmx/web-client 0.14.0 → 0.15.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/apps/admin/domains/[uid].tsx +3 -2
- package/apps/shared/appearance/AppearanceForm.tsx +9 -1
- package/apps/shared/calendar/bookingPlugin.ts +100 -0
- package/apps/shared/calendar/calendarLiveUpdates.ts +27 -0
- package/apps/shared/components/admin/layout/AdminShell.tsx +37 -5
- package/apps/shared/components/admin/settings/MailboxCreateForm.tsx +3 -1
- package/apps/shared/components/admin/settings/PluginsManager.tsx +1545 -1491
- package/apps/shared/components/calendar/AppointmentQuickForm.tsx +327 -0
- package/apps/shared/components/calendar/DescriptionEditor.tsx +274 -0
- package/apps/shared/components/calendar/EventDescriptionView.tsx +70 -0
- package/apps/shared/components/calendar/EventDetails.tsx +401 -0
- package/apps/shared/components/calendar/EventEditor.tsx +640 -0
- package/apps/shared/components/calendar/EventExpandedForm.tsx +210 -0
- package/apps/shared/components/calendar/EventFormParts.tsx +622 -0
- package/apps/shared/components/calendar/EventModal.tsx +126 -862
- package/apps/shared/components/calendar/EventQuickForm.tsx +116 -0
- package/apps/shared/components/calendar/EventShell.tsx +202 -0
- package/apps/shared/components/calendar/FindATime.tsx +379 -0
- package/apps/shared/components/calendar/LazyDescriptionEditor.tsx +70 -0
- package/apps/shared/components/calendar/MonthView.tsx +15 -3
- package/apps/shared/components/calendar/QuickCreateFaces.tsx +87 -0
- package/apps/shared/components/calendar/QuickCreateTabs.tsx +81 -0
- package/apps/shared/components/calendar/QuickFaceFrame.tsx +81 -0
- package/apps/shared/components/calendar/RecurrenceEditor.tsx +10 -5
- package/apps/shared/components/calendar/RequestChangeForm.tsx +271 -0
- package/apps/shared/components/calendar/SplitDayView.tsx +6 -5
- package/apps/shared/components/calendar/TaskQuickForm.tsx +289 -0
- package/apps/shared/components/calendar/TimeGridView.tsx +8 -6
- package/apps/shared/components/calendar/eventDialogFields.ts +86 -0
- package/apps/shared/components/calendar/eventForm.ts +108 -0
- package/apps/shared/components/calendar/eventFormat.ts +183 -0
- package/apps/shared/components/calendar/findTimeGrid.ts +90 -0
- package/apps/shared/components/calendar/swipeNavigation.ts +14 -0
- package/apps/shared/components/layout/UserMenu.tsx +80 -28
- package/apps/shared/components/mail/ConversationList.tsx +100 -48
- package/apps/shared/components/mail/ConversationThreadPane.tsx +490 -486
- package/apps/shared/components/mail/InviteCard.tsx +387 -0
- package/apps/shared/components/mail/MessageDetailPane.tsx +24 -2
- package/apps/shared/components/mail/SwipeRow.tsx +120 -0
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +7 -3
- package/apps/shared/components/mail/invite/InviteRowChip.tsx +104 -0
- package/apps/shared/components/mail/invite/InviteRsvpPopover.tsx +271 -0
- package/apps/shared/components/mail/invite/InviteTimeline.tsx +200 -0
- package/apps/shared/components/mail/invite/ProposeTimeForm.tsx +109 -0
- package/apps/shared/components/mail/invite/inviteFormat.ts +110 -0
- package/apps/shared/components/mail/invite/inviteStore.ts +114 -0
- package/apps/shared/components/mail/layout/MailShell.tsx +522 -490
- package/apps/shared/components/settings/layout/SettingsShell.tsx +1 -0
- package/apps/shared/gestures/useEnterSlide.ts +54 -0
- package/apps/shared/gestures/useSwipe.ts +114 -0
- package/apps/shared/gestures/useSwipeSlide.ts +113 -0
- package/apps/shared/gestures/useWheelPaging.ts +107 -0
- package/apps/shared/mail/newMailNotifications.ts +171 -183
- package/apps/shared/mail/useNewMailNotifications.ts +178 -178
- package/apps/shared/notifications/preferences.ts +36 -0
- package/apps/shared/notifications/store.ts +560 -551
- package/apps/www/_routes.ts +1 -0
- package/apps/www/calendar/index.tsx +139 -37
- package/apps/www/index.tsx +273 -126
- package/apps/www/messages/[uid].tsx +31 -4
- package/apps/www/settings/profile/index.tsx +248 -0
- package/dist/apps/admin/domains/[uid].js +4 -2
- package/dist/apps/shared/appearance/AppearanceForm.js +9 -1
- package/dist/apps/shared/calendar/bookingPlugin.d.ts +50 -0
- package/dist/apps/shared/calendar/bookingPlugin.js +57 -0
- package/dist/apps/shared/calendar/calendarLiveUpdates.d.ts +11 -0
- package/dist/apps/shared/calendar/calendarLiveUpdates.js +23 -0
- package/dist/apps/shared/components/admin/layout/AdminShell.d.ts +1 -1
- package/dist/apps/shared/components/admin/layout/AdminShell.js +7 -3
- package/dist/apps/shared/components/admin/settings/MailboxCreateForm.js +3 -1
- package/dist/apps/shared/components/admin/settings/PluginsManager.js +40 -6
- package/dist/apps/shared/components/calendar/AppointmentQuickForm.d.ts +47 -0
- package/dist/apps/shared/components/calendar/AppointmentQuickForm.js +135 -0
- package/dist/apps/shared/components/calendar/DescriptionEditor.d.ts +26 -0
- package/dist/apps/shared/components/calendar/DescriptionEditor.js +192 -0
- package/dist/apps/shared/components/calendar/EventDescriptionView.d.ts +14 -0
- package/dist/apps/shared/components/calendar/EventDescriptionView.js +39 -0
- package/dist/apps/shared/components/calendar/EventDetails.d.ts +33 -0
- package/dist/apps/shared/components/calendar/EventDetails.js +137 -0
- package/dist/apps/shared/components/calendar/EventEditor.d.ts +59 -0
- package/dist/apps/shared/components/calendar/EventEditor.js +549 -0
- package/dist/apps/shared/components/calendar/EventExpandedForm.d.ts +14 -0
- package/dist/apps/shared/components/calendar/EventExpandedForm.js +44 -0
- package/dist/apps/shared/components/calendar/EventFormParts.d.ts +69 -0
- package/dist/apps/shared/components/calendar/EventFormParts.js +202 -0
- package/dist/apps/shared/components/calendar/EventModal.d.ts +26 -13
- package/dist/apps/shared/components/calendar/EventModal.js +57 -455
- package/dist/apps/shared/components/calendar/EventQuickForm.d.ts +18 -0
- package/dist/apps/shared/components/calendar/EventQuickForm.js +25 -0
- package/dist/apps/shared/components/calendar/EventShell.d.ts +64 -0
- package/dist/apps/shared/components/calendar/EventShell.js +134 -0
- package/dist/apps/shared/components/calendar/FindATime.d.ts +18 -0
- package/dist/apps/shared/components/calendar/FindATime.js +190 -0
- package/dist/apps/shared/components/calendar/LazyDescriptionEditor.d.ts +8 -0
- package/dist/apps/shared/components/calendar/LazyDescriptionEditor.js +44 -0
- package/dist/apps/shared/components/calendar/MonthView.d.ts +5 -1
- package/dist/apps/shared/components/calendar/MonthView.js +11 -5
- package/dist/apps/shared/components/calendar/QuickCreateFaces.d.ts +30 -0
- package/dist/apps/shared/components/calendar/QuickCreateFaces.js +44 -0
- package/dist/apps/shared/components/calendar/QuickCreateTabs.d.ts +24 -0
- package/dist/apps/shared/components/calendar/QuickCreateTabs.js +46 -0
- package/dist/apps/shared/components/calendar/QuickFaceFrame.d.ts +25 -0
- package/dist/apps/shared/components/calendar/QuickFaceFrame.js +19 -0
- package/dist/apps/shared/components/calendar/RecurrenceEditor.d.ts +4 -1
- package/dist/apps/shared/components/calendar/RecurrenceEditor.js +2 -2
- package/dist/apps/shared/components/calendar/RequestChangeForm.d.ts +36 -0
- package/dist/apps/shared/components/calendar/RequestChangeForm.js +138 -0
- package/dist/apps/shared/components/calendar/SplitDayView.d.ts +3 -2
- package/dist/apps/shared/components/calendar/SplitDayView.js +3 -2
- package/dist/apps/shared/components/calendar/TaskQuickForm.d.ts +40 -0
- package/dist/apps/shared/components/calendar/TaskQuickForm.js +101 -0
- package/dist/apps/shared/components/calendar/TimeGridView.d.ts +4 -2
- package/dist/apps/shared/components/calendar/TimeGridView.js +3 -2
- package/dist/apps/shared/components/calendar/eventDialogFields.d.ts +28 -0
- package/dist/apps/shared/components/calendar/eventDialogFields.js +59 -0
- package/dist/apps/shared/components/calendar/eventForm.d.ts +98 -0
- package/dist/apps/shared/components/calendar/eventForm.js +1 -0
- package/dist/apps/shared/components/calendar/eventFormat.d.ts +67 -0
- package/dist/apps/shared/components/calendar/eventFormat.js +163 -0
- package/dist/apps/shared/components/calendar/findTimeGrid.d.ts +30 -0
- package/dist/apps/shared/components/calendar/findTimeGrid.js +83 -0
- package/dist/apps/shared/components/calendar/swipeNavigation.d.ts +9 -0
- package/dist/apps/shared/components/calendar/swipeNavigation.js +8 -0
- package/dist/apps/shared/components/layout/UserMenu.d.ts +10 -8
- package/dist/apps/shared/components/layout/UserMenu.js +70 -23
- package/dist/apps/shared/components/mail/ConversationList.d.ts +12 -1
- package/dist/apps/shared/components/mail/ConversationList.js +21 -4
- package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +4 -1
- package/dist/apps/shared/components/mail/InviteCard.d.ts +20 -0
- package/dist/apps/shared/components/mail/InviteCard.js +150 -0
- package/dist/apps/shared/components/mail/MessageDetailPane.js +13 -2
- package/dist/apps/shared/components/mail/SwipeRow.d.ts +22 -0
- package/dist/apps/shared/components/mail/SwipeRow.js +71 -0
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +8 -3
- package/dist/apps/shared/components/mail/invite/InviteRowChip.d.ts +23 -0
- package/dist/apps/shared/components/mail/invite/InviteRowChip.js +46 -0
- package/dist/apps/shared/components/mail/invite/InviteRsvpPopover.d.ts +20 -0
- package/dist/apps/shared/components/mail/invite/InviteRsvpPopover.js +141 -0
- package/dist/apps/shared/components/mail/invite/InviteTimeline.d.ts +27 -0
- package/dist/apps/shared/components/mail/invite/InviteTimeline.js +120 -0
- package/dist/apps/shared/components/mail/invite/ProposeTimeForm.d.ts +17 -0
- package/dist/apps/shared/components/mail/invite/ProposeTimeForm.js +45 -0
- package/dist/apps/shared/components/mail/invite/inviteFormat.d.ts +28 -0
- package/dist/apps/shared/components/mail/invite/inviteFormat.js +94 -0
- package/dist/apps/shared/components/mail/invite/inviteStore.d.ts +28 -0
- package/dist/apps/shared/components/mail/invite/inviteStore.js +95 -0
- package/dist/apps/shared/components/mail/layout/MailShell.d.ts +5 -0
- package/dist/apps/shared/components/mail/layout/MailShell.js +14 -3
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +1 -0
- package/dist/apps/shared/gestures/useEnterSlide.d.ts +14 -0
- package/dist/apps/shared/gestures/useEnterSlide.js +47 -0
- package/dist/apps/shared/gestures/useSwipe.d.ts +45 -0
- package/dist/apps/shared/gestures/useSwipe.js +90 -0
- package/dist/apps/shared/gestures/useSwipeSlide.d.ts +40 -0
- package/dist/apps/shared/gestures/useSwipeSlide.js +95 -0
- package/dist/apps/shared/gestures/useWheelPaging.d.ts +32 -0
- package/dist/apps/shared/gestures/useWheelPaging.js +85 -0
- package/dist/apps/shared/mail/newMailNotifications.d.ts +3 -8
- package/dist/apps/shared/mail/newMailNotifications.js +3 -12
- package/dist/apps/shared/mail/useNewMailNotifications.js +3 -2
- package/dist/apps/shared/notifications/preferences.d.ts +13 -0
- package/dist/apps/shared/notifications/preferences.js +36 -0
- package/dist/apps/shared/notifications/store.d.ts +1 -0
- package/dist/apps/shared/notifications/store.js +7 -23
- package/dist/apps/www/_routes.js +1 -0
- package/dist/apps/www/calendar/index.js +76 -6
- package/dist/apps/www/index.js +140 -39
- package/dist/apps/www/messages/[uid].js +13 -5
- package/dist/apps/www/settings/profile/index.d.ts +4 -0
- package/dist/apps/www/settings/profile/index.js +124 -0
- package/package.json +3 -3
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import React, { FormEvent, ReactNode, useEffect, useState } from "react";
|
|
6
|
+
import { parseISO } from "date-fns";
|
|
7
|
+
import {
|
|
8
|
+
HiOutlineBars3BottomLeft,
|
|
9
|
+
HiOutlineBell,
|
|
10
|
+
HiOutlineClock,
|
|
11
|
+
HiOutlineFlag,
|
|
12
|
+
HiOutlineFolder,
|
|
13
|
+
HiOutlineListBullet,
|
|
14
|
+
HiOutlineSun,
|
|
15
|
+
HiOutlineXMark,
|
|
16
|
+
} from "react-icons/hi2";
|
|
17
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
18
|
+
import { TaskList, TaskPriority, createTask, listTaskLists } from "@rapidmx/react-shared/tasks/tasksApi.js";
|
|
19
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
20
|
+
import { findWellKnownFolderUid } from "../../mail/findWellKnownFolderUid.js";
|
|
21
|
+
import { notify } from "../../notifications/store.js";
|
|
22
|
+
import { EventFormController } from "./eventForm.js";
|
|
23
|
+
import { INPUT_CLASS, IconRow, SELECT_CLASS } from "./EventFormParts.js";
|
|
24
|
+
import QuickFaceFrame from "./QuickFaceFrame.js";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* What the Task tab holds besides the title (which is the Event tab's): kept by `QuickCreateFaces`, so it survives a trip to another tab.
|
|
28
|
+
* `dueDate` and `reminder` are on the device's clock, as the Tasks app's own form reads them.
|
|
29
|
+
*/
|
|
30
|
+
export interface TaskDraft {
|
|
31
|
+
/** `yyyy-MM-dd`, or `""` for a task with no due date. */
|
|
32
|
+
dueDate: string;
|
|
33
|
+
/** A date-only due date (local midnight, what the Tasks app writes) rather than a time on it. */
|
|
34
|
+
allDay: boolean;
|
|
35
|
+
/** `HH:mm`, used when `allDay` is off. */
|
|
36
|
+
dueTime: string;
|
|
37
|
+
/** The `TaskList` chosen; `""` is the default "Tasks" list. */
|
|
38
|
+
listUid: string;
|
|
39
|
+
body: string;
|
|
40
|
+
priority: TaskPriority;
|
|
41
|
+
/** `yyyy-MM-ddTHH:mm`, or `""` for no reminder. */
|
|
42
|
+
reminder: string;
|
|
43
|
+
myDay: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A new task's starting values: due on the day of the slot or day that was clicked, all day, with the slot's time ready if a time is wanted. */
|
|
47
|
+
export function initialTaskDraft(start: string, allDayClick: boolean): TaskDraft {
|
|
48
|
+
return {
|
|
49
|
+
dueDate: start.slice(0, 10),
|
|
50
|
+
allDay: true,
|
|
51
|
+
dueTime: allDayClick ? "09:00" : start.slice(11, 16),
|
|
52
|
+
listUid: "",
|
|
53
|
+
body: "",
|
|
54
|
+
priority: "normal",
|
|
55
|
+
reminder: "",
|
|
56
|
+
myDay: false,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface TaskQuickFormProps {
|
|
61
|
+
c: EventFormController;
|
|
62
|
+
draft: TaskDraft;
|
|
63
|
+
onDraftChange: (patch: Partial<TaskDraft>) => void;
|
|
64
|
+
tabs: ReactNode;
|
|
65
|
+
/** The card: notes, priority, a reminder and My Day as well. */
|
|
66
|
+
expanded: boolean;
|
|
67
|
+
onExpand: () => void;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The Task tab of the New event popover (and, with More options, its card): creates a task in the chosen mailbox's Tasks folder with
|
|
72
|
+
* `POST /api/mail/tasks`. Title, due date (all day, or a time on it), which mailbox and - when the mailbox has any - which task list; the
|
|
73
|
+
* card adds notes, priority, a reminder and My Day - every field a `Task` has that a person can fill in (an assignee is chosen in the Tasks app).
|
|
74
|
+
* The calendar does not show tasks, so a save closes the popover with a "Task added" notification instead of reloading anything.
|
|
75
|
+
*/
|
|
76
|
+
export default function TaskQuickForm({ c, draft, onDraftChange, tabs, expanded, onExpand }: TaskQuickFormProps) {
|
|
77
|
+
const { values } = c;
|
|
78
|
+
const [lists, setLists] = useState<TaskList[]>([]);
|
|
79
|
+
const [error, setError] = useState<string | null>(null);
|
|
80
|
+
const [saving, setSaving] = useState(false);
|
|
81
|
+
|
|
82
|
+
// The chosen mailbox's task lists (a mailbox with none has just the default one, and no choice is shown).
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
let cancelled = false;
|
|
85
|
+
setLists([]);
|
|
86
|
+
void listTaskLists(values.targetMailboxUid)
|
|
87
|
+
.catch((): TaskList[] => [])
|
|
88
|
+
.then((result) => {
|
|
89
|
+
if (!cancelled) {
|
|
90
|
+
setLists(result);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return () => {
|
|
94
|
+
cancelled = true;
|
|
95
|
+
};
|
|
96
|
+
}, [values.targetMailboxUid]);
|
|
97
|
+
|
|
98
|
+
const mailboxChoices = c.mailboxOptions && c.mailboxOptions.length > 1 ? c.mailboxOptions : undefined;
|
|
99
|
+
// A list of another mailbox that was chosen before the mailbox changed is no longer one.
|
|
100
|
+
const listUid = lists.some((list) => list.uid === draft.listUid) ? draft.listUid : "";
|
|
101
|
+
|
|
102
|
+
async function handleSubmit(event: FormEvent) {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
setError(null);
|
|
105
|
+
const title = values.title.trim();
|
|
106
|
+
if (!title) {
|
|
107
|
+
setError("A title is required.");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (draft.dueDate && !draft.allDay && !draft.dueTime) {
|
|
111
|
+
setError("Pick a time, or choose All day.");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
setSaving(true);
|
|
115
|
+
try {
|
|
116
|
+
const mailboxUid = values.targetMailboxUid;
|
|
117
|
+
const folderUid = await findWellKnownFolderUid(mailboxUid, "tasks");
|
|
118
|
+
if (!folderUid) {
|
|
119
|
+
setError("That mailbox has no Tasks folder.");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
await createTask({
|
|
123
|
+
mailboxUid,
|
|
124
|
+
folderUid,
|
|
125
|
+
title,
|
|
126
|
+
body: draft.body.trim() || undefined,
|
|
127
|
+
// A date-only due date is the local day's midnight, the way the Tasks app writes one.
|
|
128
|
+
dueDate: draft.dueDate ? parseISO(draft.allDay ? draft.dueDate : `${draft.dueDate}T${draft.dueTime}`).toISOString() : undefined,
|
|
129
|
+
priority: draft.priority,
|
|
130
|
+
reminderDate: draft.reminder ? parseISO(draft.reminder).toISOString() : undefined,
|
|
131
|
+
taskListUid: listUid || undefined,
|
|
132
|
+
myDay: draft.myDay || undefined,
|
|
133
|
+
});
|
|
134
|
+
notify({ kind: "success", title: "Task added", message: `“${title}” was added to Tasks.` });
|
|
135
|
+
c.onCancel();
|
|
136
|
+
} catch (err) {
|
|
137
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not create this task.");
|
|
138
|
+
} finally {
|
|
139
|
+
setSaving(false);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<QuickFaceFrame
|
|
145
|
+
c={c}
|
|
146
|
+
tabs={tabs}
|
|
147
|
+
tab="task"
|
|
148
|
+
error={error}
|
|
149
|
+
onSubmit={(event) => void handleSubmit(event)}
|
|
150
|
+
footer={
|
|
151
|
+
<>
|
|
152
|
+
{!expanded && (
|
|
153
|
+
<Button type="button" variant="text" className="!w-auto" onClick={onExpand}>
|
|
154
|
+
More options
|
|
155
|
+
</Button>
|
|
156
|
+
)}
|
|
157
|
+
<Button type="submit" loading={saving} disabled={saving} className="!w-auto">
|
|
158
|
+
Save
|
|
159
|
+
</Button>
|
|
160
|
+
</>
|
|
161
|
+
}
|
|
162
|
+
>
|
|
163
|
+
<IconRow icon={<HiOutlineClock size={20} />}>
|
|
164
|
+
<div className="flex flex-wrap items-center gap-x-3 gap-y-2 text-sm">
|
|
165
|
+
<input
|
|
166
|
+
type="date"
|
|
167
|
+
aria-label="Due date"
|
|
168
|
+
className={`${SELECT_CLASS} min-w-0`}
|
|
169
|
+
value={draft.dueDate}
|
|
170
|
+
onChange={(e) => onDraftChange({ dueDate: e.target.value })}
|
|
171
|
+
/>
|
|
172
|
+
{draft.dueDate && !draft.allDay && (
|
|
173
|
+
<input
|
|
174
|
+
type="time"
|
|
175
|
+
aria-label="Due time"
|
|
176
|
+
className={`${SELECT_CLASS} min-w-0`}
|
|
177
|
+
value={draft.dueTime}
|
|
178
|
+
onChange={(e) => onDraftChange({ dueTime: e.target.value })}
|
|
179
|
+
/>
|
|
180
|
+
)}
|
|
181
|
+
{draft.dueDate && (
|
|
182
|
+
<label className="flex items-center gap-2">
|
|
183
|
+
<input type="checkbox" checked={draft.allDay} onChange={(e) => onDraftChange({ allDay: e.target.checked })} />
|
|
184
|
+
All day
|
|
185
|
+
</label>
|
|
186
|
+
)}
|
|
187
|
+
</div>
|
|
188
|
+
</IconRow>
|
|
189
|
+
|
|
190
|
+
{mailboxChoices && (
|
|
191
|
+
<IconRow icon={<HiOutlineFolder size={20} />}>
|
|
192
|
+
<select
|
|
193
|
+
aria-label="Mailbox"
|
|
194
|
+
className={`${SELECT_CLASS} max-w-full`}
|
|
195
|
+
value={values.targetMailboxUid}
|
|
196
|
+
onChange={(e) => c.onMailboxChange(e.target.value)}
|
|
197
|
+
>
|
|
198
|
+
{mailboxChoices.map(({ mailbox }) => (
|
|
199
|
+
<option key={mailbox.uid} value={mailbox.uid}>
|
|
200
|
+
{mailbox.displayName}
|
|
201
|
+
{mailbox.ownerUserUid ? "" : " (shared)"}
|
|
202
|
+
</option>
|
|
203
|
+
))}
|
|
204
|
+
</select>
|
|
205
|
+
</IconRow>
|
|
206
|
+
)}
|
|
207
|
+
|
|
208
|
+
{lists.length > 0 && (
|
|
209
|
+
<IconRow icon={<HiOutlineListBullet size={20} />}>
|
|
210
|
+
<select
|
|
211
|
+
aria-label="Task list"
|
|
212
|
+
className={`${SELECT_CLASS} max-w-full`}
|
|
213
|
+
value={listUid}
|
|
214
|
+
onChange={(e) => onDraftChange({ listUid: e.target.value })}
|
|
215
|
+
>
|
|
216
|
+
<option value="">Tasks</option>
|
|
217
|
+
{lists.map((list) => (
|
|
218
|
+
<option key={list.uid} value={list.uid}>
|
|
219
|
+
{list.name}
|
|
220
|
+
</option>
|
|
221
|
+
))}
|
|
222
|
+
</select>
|
|
223
|
+
</IconRow>
|
|
224
|
+
)}
|
|
225
|
+
|
|
226
|
+
{expanded && (
|
|
227
|
+
<>
|
|
228
|
+
<IconRow icon={<HiOutlineBars3BottomLeft size={20} />}>
|
|
229
|
+
<textarea
|
|
230
|
+
aria-label="Notes"
|
|
231
|
+
rows={3}
|
|
232
|
+
placeholder="Add notes"
|
|
233
|
+
className={INPUT_CLASS}
|
|
234
|
+
value={draft.body}
|
|
235
|
+
onChange={(e) => onDraftChange({ body: e.target.value })}
|
|
236
|
+
/>
|
|
237
|
+
</IconRow>
|
|
238
|
+
<IconRow icon={<HiOutlineFlag size={20} />}>
|
|
239
|
+
<select
|
|
240
|
+
aria-label="Priority"
|
|
241
|
+
className={`${SELECT_CLASS} max-w-full`}
|
|
242
|
+
value={draft.priority}
|
|
243
|
+
onChange={(e) => onDraftChange({ priority: e.target.value as TaskPriority })}
|
|
244
|
+
>
|
|
245
|
+
<option value="low">Low priority</option>
|
|
246
|
+
<option value="normal">Normal priority</option>
|
|
247
|
+
<option value="high">High priority</option>
|
|
248
|
+
</select>
|
|
249
|
+
</IconRow>
|
|
250
|
+
<IconRow icon={<HiOutlineBell size={20} />}>
|
|
251
|
+
{draft.reminder ? (
|
|
252
|
+
<div className="flex items-center gap-2 text-sm">
|
|
253
|
+
<input
|
|
254
|
+
type="datetime-local"
|
|
255
|
+
aria-label="Reminder"
|
|
256
|
+
className={`${SELECT_CLASS} min-w-0`}
|
|
257
|
+
value={draft.reminder}
|
|
258
|
+
onChange={(e) => onDraftChange({ reminder: e.target.value })}
|
|
259
|
+
/>
|
|
260
|
+
<button
|
|
261
|
+
type="button"
|
|
262
|
+
aria-label="Remove reminder"
|
|
263
|
+
className="w-7 h-7 flex items-center justify-center rounded-full text-text-muted hover:bg-surface-alt hover:text-text"
|
|
264
|
+
onClick={() => onDraftChange({ reminder: "" })}
|
|
265
|
+
>
|
|
266
|
+
<HiOutlineXMark size={16} aria-hidden="true" />
|
|
267
|
+
</button>
|
|
268
|
+
</div>
|
|
269
|
+
) : (
|
|
270
|
+
<button
|
|
271
|
+
type="button"
|
|
272
|
+
className="text-sm text-text-muted hover:text-text py-1.5"
|
|
273
|
+
onClick={() => onDraftChange({ reminder: `${draft.dueDate || values.start.slice(0, 10)}T09:00` })}
|
|
274
|
+
>
|
|
275
|
+
Add reminder
|
|
276
|
+
</button>
|
|
277
|
+
)}
|
|
278
|
+
</IconRow>
|
|
279
|
+
<IconRow icon={<HiOutlineSun size={20} />}>
|
|
280
|
+
<label className="flex items-center gap-2 text-sm py-1.5">
|
|
281
|
+
<input type="checkbox" checked={draft.myDay} onChange={(e) => onDraftChange({ myDay: e.target.checked })} />
|
|
282
|
+
Add to My Day
|
|
283
|
+
</label>
|
|
284
|
+
</IconRow>
|
|
285
|
+
</>
|
|
286
|
+
)}
|
|
287
|
+
</QuickFaceFrame>
|
|
288
|
+
);
|
|
289
|
+
}
|
|
@@ -8,6 +8,7 @@ import { addDays, addMinutes, format, isToday, startOfDay } from "date-fns";
|
|
|
8
8
|
import { dayDropId, eventDragId, resizeDragId, slotDropId } from "@rapidmx/react-shared/calendar/calendarDragIds.js";
|
|
9
9
|
import { CalendarOccurrence } from "@rapidmx/react-shared/calendar/recurrence.js";
|
|
10
10
|
import { occursOnDay, startsOnDay } from "./allDay.js";
|
|
11
|
+
import { EventAnchor, anchorOf } from "./EventShell.js";
|
|
11
12
|
|
|
12
13
|
const HOUR_HEIGHT_PX = 48;
|
|
13
14
|
const SLOT_MINUTES = 30;
|
|
@@ -22,8 +23,9 @@ export interface TimeGridViewProps {
|
|
|
22
23
|
/** Each occurrence's own calendar color, keyed by `folderUid` — see `calendarColors.ts`. */
|
|
23
24
|
folderColors: Record<string, string>;
|
|
24
25
|
onSelectEvent: (occurrence: CalendarOccurrence) => void;
|
|
25
|
-
/** Click on an empty slot — start/end default to a 30-minute block there, for the "New event" flow.
|
|
26
|
-
|
|
26
|
+
/** Click on an empty slot — start/end default to a 30-minute block there, for the "New event" flow. `anchor` is the slot, for the
|
|
27
|
+
* quick-create popover to open beside. */
|
|
28
|
+
onSelectSlot: (start: Date, end: Date, anchor: EventAnchor) => void;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
/** An hourly time grid (Week, Work Week, or Day view — they share all their rendering/drag logic and
|
|
@@ -34,7 +36,7 @@ export default function TimeGridView({ days, occurrences, folderColors, onSelect
|
|
|
34
36
|
const timedEvents = occurrences.filter((occ) => !occ.allDay);
|
|
35
37
|
|
|
36
38
|
return (
|
|
37
|
-
<div className="flex-1 flex flex-col min-h-0 overflow-y-auto">
|
|
39
|
+
<div data-calendar-scroller className="flex-1 flex flex-col min-h-0 overflow-y-auto">
|
|
38
40
|
<div className="flex border-b border-border shrink-0">
|
|
39
41
|
<div className="w-14 shrink-0" />
|
|
40
42
|
{days.map((day) => (
|
|
@@ -96,7 +98,7 @@ interface DayColumnProps {
|
|
|
96
98
|
occurrences: CalendarOccurrence[];
|
|
97
99
|
folderColors: Record<string, string>;
|
|
98
100
|
onSelectEvent: (occurrence: CalendarOccurrence) => void;
|
|
99
|
-
onSelectSlot: (start: Date, end: Date) => void;
|
|
101
|
+
onSelectSlot: (start: Date, end: Date, anchor: EventAnchor) => void;
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
function DayColumn({ day, occurrences, folderColors, onSelectEvent, onSelectSlot }: DayColumnProps) {
|
|
@@ -131,13 +133,13 @@ function DayColumn({ day, occurrences, folderColors, onSelectEvent, onSelectSlot
|
|
|
131
133
|
);
|
|
132
134
|
}
|
|
133
135
|
|
|
134
|
-
function TimeSlot({ start, onSelectSlot }: { start: Date; onSelectSlot: (start: Date, end: Date) => void }) {
|
|
136
|
+
function TimeSlot({ start, onSelectSlot }: { start: Date; onSelectSlot: (start: Date, end: Date, anchor: EventAnchor) => void }) {
|
|
135
137
|
const { setNodeRef, isOver } = useDroppable({ id: slotDropId(start) });
|
|
136
138
|
return (
|
|
137
139
|
<button
|
|
138
140
|
ref={setNodeRef}
|
|
139
141
|
type="button"
|
|
140
|
-
onClick={() => onSelectSlot(start, addMinutes(start, SLOT_MINUTES))}
|
|
142
|
+
onClick={(e) => onSelectSlot(start, addMinutes(start, SLOT_MINUTES), anchorOf(e.currentTarget))}
|
|
141
143
|
style={{ height: HOUR_HEIGHT_PX / 2 }}
|
|
142
144
|
className={["block w-full border-b border-border/50 text-left", isOver ? "bg-primary/10" : ""].join(" ")}
|
|
143
145
|
aria-label={`New event at ${format(start, "h:mm a, MMM d")}`}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import { EventVisibility, guestPermissionsOf, visibilityOf } from "@rapidmx/react-shared/calendar/calendarApi.js";
|
|
6
|
+
import {
|
|
7
|
+
MAX_EVENT_DESCRIPTION_HTML_LENGTH,
|
|
8
|
+
MAX_EVENT_DESCRIPTION_LENGTH,
|
|
9
|
+
htmlToPlainText,
|
|
10
|
+
sanitizeEventDescriptionHtml,
|
|
11
|
+
} from "@rapidmx/react-shared/calendar/eventDescription.js";
|
|
12
|
+
import { CalendarOccurrence } from "@rapidmx/react-shared/calendar/recurrence.js";
|
|
13
|
+
import { EventFormValues } from "./eventForm.js";
|
|
14
|
+
|
|
15
|
+
/** The event dialog's own fields of a `CalendarEventInput` - only the ones that differ from what the event has, so saving an event no one touched these on
|
|
16
|
+
* says nothing about them (and asks for no new invitations). */
|
|
17
|
+
export interface EventDialogFields {
|
|
18
|
+
/** `null` clears. */
|
|
19
|
+
description?: string | null;
|
|
20
|
+
descriptionHtml?: string | null;
|
|
21
|
+
visibility?: EventVisibility;
|
|
22
|
+
guestsCanModify?: boolean;
|
|
23
|
+
guestsCanInviteOthers?: boolean;
|
|
24
|
+
guestsCanSeeGuestList?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function escapeHtml(text: string): string {
|
|
28
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Whether the editor's HTML holds any text (an emptied editor writes `<p></p>`). */
|
|
32
|
+
export function hasDescriptionText(html: string): boolean {
|
|
33
|
+
return html.replace(/<[^>]*>/g, "").trim() !== "";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A plain-text description as the paragraphs the editor starts from: one for each line (an event whose description has no HTML). */
|
|
37
|
+
export function plainTextToHtml(text: string): string {
|
|
38
|
+
return text
|
|
39
|
+
.split(/\r\n|\r|\n/)
|
|
40
|
+
.map((line) => `<p>${escapeHtml(line)}</p>`)
|
|
41
|
+
.join("");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** What the description editor starts with for `occurrence`: its HTML, else its plain text as paragraphs, else nothing. */
|
|
45
|
+
export function initialDescriptionHtml(occurrence: Pick<CalendarOccurrence, "description" | "descriptionHtml"> | null): string {
|
|
46
|
+
if (occurrence?.descriptionHtml) {
|
|
47
|
+
return occurrence.descriptionHtml;
|
|
48
|
+
}
|
|
49
|
+
return occurrence?.description ? plainTextToHtml(occurrence.description) : "";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Why the description cannot be saved as it is - too long for the server (400) - or `undefined`. */
|
|
53
|
+
export function descriptionProblem(descriptionHtml: string): string | undefined {
|
|
54
|
+
const html = sanitizeEventDescriptionHtml(descriptionHtml);
|
|
55
|
+
return html.length > MAX_EVENT_DESCRIPTION_HTML_LENGTH || htmlToPlainText(html).length > MAX_EVENT_DESCRIPTION_LENGTH
|
|
56
|
+
? "The description is too long."
|
|
57
|
+
: undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* What the form says about the description, visibility and guest permissions that differs from `occurrence` (`null` for a new event, which starts from the
|
|
62
|
+
* defaults: no description, default visibility, guests cannot modify, can invite, can see the list). A description is sent as both its sanitized HTML and the
|
|
63
|
+
* plain text derived from it, or as `null` twice when it was emptied; one the user did not change is not sent.
|
|
64
|
+
*/
|
|
65
|
+
export function dialogFields(values: EventFormValues, occurrence: CalendarOccurrence | null): EventDialogFields {
|
|
66
|
+
const fields: EventDialogFields = {};
|
|
67
|
+
|
|
68
|
+
const initial = initialDescriptionHtml(occurrence);
|
|
69
|
+
const html = sanitizeEventDescriptionHtml(values.descriptionHtml);
|
|
70
|
+
if (values.descriptionHtml !== initial && html !== sanitizeEventDescriptionHtml(initial)) {
|
|
71
|
+
const plain = htmlToPlainText(html);
|
|
72
|
+
fields.description = plain || null;
|
|
73
|
+
fields.descriptionHtml = plain ? html : null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (values.visibility !== (occurrence ? visibilityOf(occurrence) : "default")) {
|
|
77
|
+
fields.visibility = values.visibility;
|
|
78
|
+
}
|
|
79
|
+
const permissions = guestPermissionsOf(occurrence ?? {});
|
|
80
|
+
for (const key of ["guestsCanModify", "guestsCanInviteOthers", "guestsCanSeeGuestList"] as const) {
|
|
81
|
+
if (values[key] !== permissions[key]) {
|
|
82
|
+
fields[key] = values[key];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return fields;
|
|
86
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import { FormEvent } from "react";
|
|
6
|
+
import { Attendee, BusyStatus, EventVisibility, RecurrenceRule, WeekdayCode } from "@rapidmx/react-shared/calendar/calendarApi.js";
|
|
7
|
+
import { Mailbox } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
8
|
+
import { CalendarOccurrence } from "@rapidmx/react-shared/calendar/recurrence.js";
|
|
9
|
+
|
|
10
|
+
/** Which occurrences of a recurring event an edit applies to. */
|
|
11
|
+
export type EditScope = "occurrence" | "series";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Everything the event form edits. The quick-create popover and the full form are two faces of the same values, so a title typed in the
|
|
15
|
+
* one is still there when "More options" opens the other.
|
|
16
|
+
*/
|
|
17
|
+
export interface EventFormValues {
|
|
18
|
+
title: string;
|
|
19
|
+
location: string;
|
|
20
|
+
/** `YYYY-MM-DDTHH:mm` on the wall clock of `formZone` (for an all-day event only the date part matters). */
|
|
21
|
+
start: string;
|
|
22
|
+
end: string;
|
|
23
|
+
allDay: boolean;
|
|
24
|
+
/** The zone `start` and `end` are read in: the device's own until the user picks another. */
|
|
25
|
+
formZone: string;
|
|
26
|
+
/** The IANA zone the event is stored with. */
|
|
27
|
+
timezone: string;
|
|
28
|
+
attendees: Attendee[];
|
|
29
|
+
/** What has been typed into the guests field but not added yet. */
|
|
30
|
+
guestDraft: string;
|
|
31
|
+
recurrenceRule: RecurrenceRule | null;
|
|
32
|
+
/** Minutes before the start, as typed; blank means no reminder. */
|
|
33
|
+
reminderMinutes: string;
|
|
34
|
+
busyStatus: BusyStatus;
|
|
35
|
+
/** Who may see the event's details. */
|
|
36
|
+
visibility: EventVisibility;
|
|
37
|
+
/** The description as the editor last wrote it: HTML, `""` when there is none (an emptied editor writes `<p></p>`, which counts as none). */
|
|
38
|
+
descriptionHtml: string;
|
|
39
|
+
/** What guests may do: ask for the event to change, ask for guests to be added, see who else is invited. */
|
|
40
|
+
guestsCanModify: boolean;
|
|
41
|
+
guestsCanInviteOthers: boolean;
|
|
42
|
+
guestsCanSeeGuestList: boolean;
|
|
43
|
+
autoReplyEnabled: boolean;
|
|
44
|
+
autoReplyMessage: string;
|
|
45
|
+
videoEnabled: boolean;
|
|
46
|
+
targetMailboxUid: string;
|
|
47
|
+
targetFolderUid: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** What `EventEditor` hands both faces of the form: the values, and every action and derived fact they need. */
|
|
51
|
+
export interface EventFormController {
|
|
52
|
+
/** The event being edited, `null` for a new one. */
|
|
53
|
+
occurrence: CalendarOccurrence | null;
|
|
54
|
+
values: EventFormValues;
|
|
55
|
+
update: (patch: Partial<EventFormValues>) => void;
|
|
56
|
+
|
|
57
|
+
// Date and time.
|
|
58
|
+
setStart: (next: string) => void;
|
|
59
|
+
setEnd: (next: string) => void;
|
|
60
|
+
onAllDayChange: (allDay: boolean) => void;
|
|
61
|
+
onTimeZoneChange: (zone: string) => void;
|
|
62
|
+
timeZones: string[];
|
|
63
|
+
startWeekday: WeekdayCode | undefined;
|
|
64
|
+
/** "This event only" of a recurring event: the copy it detaches has no rule of its own. */
|
|
65
|
+
editingSingleOccurrence: boolean;
|
|
66
|
+
|
|
67
|
+
// Find a time: whose calendar the grid shows as "you", and the zone the device's own clock is in.
|
|
68
|
+
/** The address the event is organized from (the chosen mailbox's, for a new event). */
|
|
69
|
+
organizerAddress: string;
|
|
70
|
+
deviceZone: string;
|
|
71
|
+
|
|
72
|
+
// Guests.
|
|
73
|
+
/** Adds the addresses in `text`; returns the ones that are not valid addresses. */
|
|
74
|
+
addGuests: (text: string) => string[];
|
|
75
|
+
updateAttendee: (index: number, patch: Partial<Attendee>) => void;
|
|
76
|
+
removeAttendee: (index: number) => void;
|
|
77
|
+
addResource: (mailbox: Mailbox) => void;
|
|
78
|
+
/** Addresses already on the list (lowercased), for the room/equipment picker to leave out. */
|
|
79
|
+
guestAddresses: string[];
|
|
80
|
+
|
|
81
|
+
// Where the event goes.
|
|
82
|
+
mailboxOptions: { mailbox: Mailbox; calendars: { uid: string; name: string }[] }[] | undefined;
|
|
83
|
+
onMailboxChange: (mailboxUid: string) => void;
|
|
84
|
+
/** The calendars to choose between when creating; `undefined` for an existing event, which keeps its own. */
|
|
85
|
+
calendarChoices: { uid: string; name: string }[] | undefined;
|
|
86
|
+
calendarName: string | undefined;
|
|
87
|
+
calendarColor: string | undefined;
|
|
88
|
+
|
|
89
|
+
// Video conferencing.
|
|
90
|
+
videoMeetingUid: string | undefined;
|
|
91
|
+
/** The organizer's own join link once it is known and safe to open. */
|
|
92
|
+
joinUrl: string | undefined;
|
|
93
|
+
/** `undefined` while it is being fetched, `null` once it is known there is none. */
|
|
94
|
+
organizerJoinUrl: string | null | undefined;
|
|
95
|
+
videoError: string | null;
|
|
96
|
+
|
|
97
|
+
// The form as a whole.
|
|
98
|
+
editScope: EditScope;
|
|
99
|
+
setEditScope: (scope: EditScope) => void;
|
|
100
|
+
/** Whether the "Apply changes to" choice is offered (editing an occurrence of a recurring event). */
|
|
101
|
+
showEditScope: boolean;
|
|
102
|
+
error: string | null;
|
|
103
|
+
saving: boolean;
|
|
104
|
+
/** Submits the form. */
|
|
105
|
+
onSubmit: (event: FormEvent) => void;
|
|
106
|
+
/** The X / Cancel: leaves the form (back to the details for an existing event). */
|
|
107
|
+
onCancel: () => void;
|
|
108
|
+
}
|