@burdenoff/microfe-calendar 2026.1124.2 → 2026.1124.3
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/dist/generated/wspace-operations.d.ts +469 -0
- package/dist/generated/wspace-operations.js +121 -9
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/pages/ResourcesPage.js.map +1 -1
- package/dist/translations/en.d.ts +231 -0
- package/dist/v2/CalendarPageV2.js.map +1 -1
- package/dist/v2/data/enums.d.ts +1 -0
- package/dist/v2/data/enums.js +6 -2
- package/dist/v2/data/enums.js.map +1 -1
- package/dist/v2/dialogs/CalendarDialogsV2.js +12 -9
- package/dist/v2/dialogs/CalendarDialogsV2.js.map +1 -1
- package/dist/v2/event/CustomRepeat.d.ts +5 -0
- package/dist/v2/event/CustomRepeat.js +246 -0
- package/dist/v2/event/CustomRepeat.js.map +1 -0
- package/dist/v2/event/EventDetailsTab.d.ts +6 -0
- package/dist/v2/event/EventDetailsTab.js +291 -0
- package/dist/v2/event/EventDetailsTab.js.map +1 -0
- package/dist/v2/event/EventDialog.d.ts +25 -0
- package/dist/v2/event/EventDialog.js +365 -0
- package/dist/v2/event/EventDialog.js.map +1 -0
- package/dist/v2/event/EventDialogs.d.ts +3 -0
- package/dist/v2/event/EventDialogs.js +111 -0
- package/dist/v2/event/EventDialogs.js.map +1 -0
- package/dist/v2/event/EventMoreTab.d.ts +4 -0
- package/dist/v2/event/EventMoreTab.js +214 -0
- package/dist/v2/event/EventMoreTab.js.map +1 -0
- package/dist/v2/event/EventPeopleTab.d.ts +8 -0
- package/dist/v2/event/EventPeopleTab.js +422 -0
- package/dist/v2/event/EventPeopleTab.js.map +1 -0
- package/dist/v2/event/EventPlaceTab.d.ts +6 -0
- package/dist/v2/event/EventPlaceTab.js +264 -0
- package/dist/v2/event/EventPlaceTab.js.map +1 -0
- package/dist/v2/event/FindTimeDialog.d.ts +26 -0
- package/dist/v2/event/FindTimeDialog.js +667 -0
- package/dist/v2/event/FindTimeDialog.js.map +1 -0
- package/dist/v2/event/RepeatField.d.ts +5 -0
- package/dist/v2/event/RepeatField.js +88 -0
- package/dist/v2/event/RepeatField.js.map +1 -0
- package/dist/v2/event/dialogLogic.d.ts +87 -0
- package/dist/v2/event/dialogLogic.js +117 -0
- package/dist/v2/event/dialogLogic.js.map +1 -0
- package/dist/v2/event/dialogModel.d.ts +48 -0
- package/dist/v2/event/dialogModel.js +13 -0
- package/dist/v2/event/dialogModel.js.map +1 -0
- package/dist/v2/event/eventForm.d.ts +209 -0
- package/dist/v2/event/eventForm.js +397 -0
- package/dist/v2/event/eventForm.js.map +1 -0
- package/dist/v2/event/findTime.d.ts +120 -0
- package/dist/v2/event/findTime.js +149 -0
- package/dist/v2/event/findTime.js.map +1 -0
- package/dist/v2/event/findTimeSource.d.ts +102 -0
- package/dist/v2/event/findTimeSource.js +107 -0
- package/dist/v2/event/findTimeSource.js.map +1 -0
- package/dist/v2/event/parts.d.ts +46 -0
- package/dist/v2/event/parts.js +124 -0
- package/dist/v2/event/parts.js.map +1 -0
- package/dist/v2/event/place.d.ts +64 -0
- package/dist/v2/event/place.js +48 -0
- package/dist/v2/event/place.js.map +1 -0
- package/dist/v2/event/repeatWords.d.ts +19 -0
- package/dist/v2/event/repeatWords.js +130 -0
- package/dist/v2/event/repeatWords.js.map +1 -0
- package/dist/v2/event/rrule.d.ts +90 -0
- package/dist/v2/event/rrule.js +368 -0
- package/dist/v2/event/rrule.js.map +1 -0
- package/dist/v2/event/savePlan.d.ts +50 -0
- package/dist/v2/event/savePlan.js +125 -0
- package/dist/v2/event/savePlan.js.map +1 -0
- package/dist/v2/event/useEventData.d.ts +91 -0
- package/dist/v2/event/useEventData.js +202 -0
- package/dist/v2/event/useEventData.js.map +1 -0
- package/dist/v2/event/useEventDialogModel.d.ts +37 -0
- package/dist/v2/event/useEventDialogModel.js +129 -0
- package/dist/v2/event/useEventDialogModel.js.map +1 -0
- package/dist/v2/event/useEventSave.d.ts +41 -0
- package/dist/v2/event/useEventSave.js +185 -0
- package/dist/v2/event/useEventSave.js.map +1 -0
- package/dist/v2/format.d.ts +2 -0
- package/dist/v2/format.js +4 -0
- package/dist/v2/format.js.map +1 -1
- package/dist/v2/peek/EventPeek.js.map +1 -1
- package/dist/v2/peek/PeekEvent.js.map +1 -1
- package/dist/v2/rail/CalendarRail.js.map +1 -1
- package/dist/v2/runs/RunPeek.js.map +1 -1
- package/dist/v2/states/CalendarStates.js.map +1 -1
- package/dist/v2/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { CalendarV2AddGuestDocument as e, CalendarV2BookRoomDocument as t, CalendarV2CancelRoomBookingDocument as n, CalendarV2CreateEventDocument as r, CalendarV2CreateReminderDocument as i, CalendarV2DeleteReminderDocument as a, CalendarV2RemoveGuestDocument as o, CalendarV2UpdateEventDocument as s } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { REMINDER_CHANNEL as c } from "../data/enums.js";
|
|
3
|
+
import { invalidateCalendarEvents as l } from "../data/invalidation.js";
|
|
4
|
+
import { formatDay as u, formatDuration as d, formatInstantRange as f } from "../format.js";
|
|
5
|
+
import { instantToZoned as p } from "../time/calendarTime.js";
|
|
6
|
+
import { endInstant as m, startInstant as h } from "./eventForm.js";
|
|
7
|
+
import { planEdit as g, planNewEvent as _ } from "./savePlan.js";
|
|
8
|
+
import { useCallback as v, useEffect as y, useRef as b } from "react";
|
|
9
|
+
import { useNotify as x } from "@burdenoff/fe-libs/ui";
|
|
10
|
+
import { CombinedGraphQLErrors as S } from "@apollo/client";
|
|
11
|
+
import { useApolloClient as C } from "@apollo/client/react";
|
|
12
|
+
// src/v2/event/useEventSave.ts
|
|
13
|
+
var w = 4;
|
|
14
|
+
function T(e) {
|
|
15
|
+
return S.is(e) ? e.errors.map((e) => e.message.trim()).find(Boolean) ?? null : null;
|
|
16
|
+
}
|
|
17
|
+
async function E(e, t) {
|
|
18
|
+
let n = 0, r = async () => {
|
|
19
|
+
let t = e[n];
|
|
20
|
+
n += 1, t && (await t(), await r());
|
|
21
|
+
};
|
|
22
|
+
await Promise.all(Array.from({ length: Math.min(t, e.length) }, r));
|
|
23
|
+
}
|
|
24
|
+
async function D(e, t, n = 0) {
|
|
25
|
+
let r = e[n];
|
|
26
|
+
if (r === void 0) return null;
|
|
27
|
+
let i = await t(r, n);
|
|
28
|
+
return i === null ? D(e, t, n + 1) : i;
|
|
29
|
+
}
|
|
30
|
+
function O(e, t) {
|
|
31
|
+
return T(e) ?? t("calendar.v2.eventSaveOffline", "The calendar service didn’t answer. Check your connection.");
|
|
32
|
+
}
|
|
33
|
+
function k(e, t) {
|
|
34
|
+
return e.minutesBefore === 0 ? t.tr("calendar.v2.reminderAtStart", "When it starts") : t.tr("calendar.v2.reminderBefore", "{{time}} before", { time: d(e.minutesBefore, t.durationWords) });
|
|
35
|
+
}
|
|
36
|
+
function A(e, t, n, r) {
|
|
37
|
+
return async () => {
|
|
38
|
+
try {
|
|
39
|
+
return await n(), e.wrote = !0, !0;
|
|
40
|
+
} catch (n) {
|
|
41
|
+
return e.problems.push(r(O(n, t.tr))), !1;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async function j(e, t) {
|
|
46
|
+
let n = (await e.mutate({
|
|
47
|
+
mutation: r,
|
|
48
|
+
variables: { input: t }
|
|
49
|
+
})).data?.createEvent.id;
|
|
50
|
+
if (!n) throw Error("No event came back");
|
|
51
|
+
return n;
|
|
52
|
+
}
|
|
53
|
+
async function M(e, t, n, r, i) {
|
|
54
|
+
return D(n.updates, async (n, a) => {
|
|
55
|
+
try {
|
|
56
|
+
return await e.mutate({
|
|
57
|
+
mutation: s,
|
|
58
|
+
variables: {
|
|
59
|
+
id: t,
|
|
60
|
+
input: n.input,
|
|
61
|
+
scope: n.scope
|
|
62
|
+
}
|
|
63
|
+
}), r.wrote = !0, null;
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return a === 0 ? { error: e } : (r.problems.push(i.tr("calendar.v2.eventRuleFailed", "The new repeat didn’t save: {{reason}}", { reason: O(e, i.tr) })), null);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function N(t, n, r, i, a) {
|
|
70
|
+
let { tr: s } = a;
|
|
71
|
+
return [...r.removeGuests.map((e) => A(i, a, () => t.mutate({
|
|
72
|
+
mutation: o,
|
|
73
|
+
variables: { attendeeId: e.attendeeId ?? "" }
|
|
74
|
+
}), (t) => s("calendar.v2.guestRemoveFailed", "Couldn’t remove {{name}}: {{reason}}", {
|
|
75
|
+
name: a.guestName(e),
|
|
76
|
+
reason: t
|
|
77
|
+
}))), ...r.addGuests.map((r) => A(i, a, () => t.mutate({
|
|
78
|
+
mutation: e,
|
|
79
|
+
variables: {
|
|
80
|
+
eventId: n,
|
|
81
|
+
userId: r.userId,
|
|
82
|
+
email: r.email,
|
|
83
|
+
name: r.name
|
|
84
|
+
}
|
|
85
|
+
}), (e) => s("calendar.v2.guestAddFailed", "Couldn’t invite {{name}}: {{reason}}", {
|
|
86
|
+
name: a.guestName(r),
|
|
87
|
+
reason: e
|
|
88
|
+
})))];
|
|
89
|
+
}
|
|
90
|
+
function P(e, t, n, r, o) {
|
|
91
|
+
let { tr: s } = o;
|
|
92
|
+
return [...n.removeReminders.map((t) => A(r, o, () => e.mutate({
|
|
93
|
+
mutation: a,
|
|
94
|
+
variables: { id: t.reminderId ?? "" }
|
|
95
|
+
}), (e) => s("calendar.v2.reminderRemoveFailed", "Couldn’t remove the reminder {{when}}: {{reason}}", {
|
|
96
|
+
when: k(t, o),
|
|
97
|
+
reason: e
|
|
98
|
+
}))), ...n.addReminders.map((n) => A(r, o, () => e.mutate({
|
|
99
|
+
mutation: i,
|
|
100
|
+
variables: { input: {
|
|
101
|
+
eventId: t,
|
|
102
|
+
minutesBefore: n.minutesBefore,
|
|
103
|
+
channel: c[n.channel]
|
|
104
|
+
} }
|
|
105
|
+
}), (e) => s("calendar.v2.reminderAddFailed", "Couldn’t add the reminder {{when}}: {{reason}}", {
|
|
106
|
+
when: k(n, o),
|
|
107
|
+
reason: e
|
|
108
|
+
})))];
|
|
109
|
+
}
|
|
110
|
+
function F(e, r, i, a, o) {
|
|
111
|
+
let { tr: s } = o, c = i.cancelBookingId, l = i.bookRoom, u = c ? A(a, o, () => e.mutate({
|
|
112
|
+
mutation: n,
|
|
113
|
+
variables: { bookingId: c }
|
|
114
|
+
}), (e) => l ? s("calendar.v2.roomMoveFailed", "Couldn’t move the room booking, so it stays as it was: {{reason}}", { reason: e }) : s("calendar.v2.roomReleaseFailed", "Couldn’t let go of the room booked before: {{reason}}", { reason: e })) : null, d = l ? A(a, o, () => e.mutate({
|
|
115
|
+
mutation: t,
|
|
116
|
+
variables: { input: {
|
|
117
|
+
eventId: r,
|
|
118
|
+
resourceId: l.resourceId,
|
|
119
|
+
startTime: l.start.toISOString(),
|
|
120
|
+
endTime: l.end.toISOString()
|
|
121
|
+
} }
|
|
122
|
+
}), (e) => s("calendar.v2.roomBookFailed", "Couldn’t book {{room}}: {{reason}}", {
|
|
123
|
+
room: o.roomName(l.resourceId) ?? s("calendar.v2.theRoom", "The room"),
|
|
124
|
+
reason: e
|
|
125
|
+
})) : null;
|
|
126
|
+
return !u && !d ? [] : [async () => {
|
|
127
|
+
(!u || await u()) && d && await d();
|
|
128
|
+
}];
|
|
129
|
+
}
|
|
130
|
+
function I(e, t, n, r) {
|
|
131
|
+
let { tr: i } = r, a = e.title.trim();
|
|
132
|
+
if (!n) return t?.isRecurring ? i("calendar.v2.eventSavedSeries", "Saved every event in “{{title}}”.", { title: a }) : i("calendar.v2.eventSaved", "Saved “{{title}}”.", { title: a });
|
|
133
|
+
let o = h(e), s = e.allDay ? e.firstDay : p(o, r.timeZone).date, c = e.allDay ? i("calendar.v2.allDayLower", "all day") : f(o, m(e), r.timeZone, r.format);
|
|
134
|
+
return i("calendar.v2.eventAdded", "Added “{{title}}” to {{calendar}}, {{day}} {{time}}.", {
|
|
135
|
+
title: a,
|
|
136
|
+
calendar: r.calendarName(e.calendarId ?? "") ?? i("calendar.v2.aCalendar", "a calendar"),
|
|
137
|
+
day: u(s, r.format, "short"),
|
|
138
|
+
time: c
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function L(e) {
|
|
142
|
+
let t = C(), n = x(), r = b(e);
|
|
143
|
+
return y(() => {
|
|
144
|
+
r.current = e;
|
|
145
|
+
}), v(async ({ form: e, event: i, scope: a }) => {
|
|
146
|
+
let o = r.current, { tr: s } = o, c = e.title.trim(), u = i ? g(e, i, o.timeZone, a) : _(e), d = (e) => (n({
|
|
147
|
+
title: u.create ? s("calendar.v2.eventAddFailed", "Couldn’t add “{{title}}”", { title: c }) : s("calendar.v2.eventSaveFailed", "Couldn’t save “{{title}}”", { title: c }),
|
|
148
|
+
description: O(e, s),
|
|
149
|
+
tone: "error",
|
|
150
|
+
urgent: !0
|
|
151
|
+
}), { kind: "failed" }), f = i?.id ?? null;
|
|
152
|
+
if (u.create) try {
|
|
153
|
+
f = await j(t, u.create);
|
|
154
|
+
} catch (e) {
|
|
155
|
+
return d(e);
|
|
156
|
+
}
|
|
157
|
+
if (!f) return { kind: "failed" };
|
|
158
|
+
let p = {
|
|
159
|
+
wrote: u.create !== null,
|
|
160
|
+
problems: []
|
|
161
|
+
}, m = await M(t, f, u, p, o);
|
|
162
|
+
return m ? d(m.error) : (await E([
|
|
163
|
+
...N(t, f, u, p, o),
|
|
164
|
+
...P(t, f, u, p, o),
|
|
165
|
+
...F(t, f, u, p, o)
|
|
166
|
+
], w), p.wrote && l(), p.problems.length > 0 ? (n({
|
|
167
|
+
title: u.create ? s("calendar.v2.eventAddedPartly", "Added “{{title}}”, but not all of it", { title: c }) : s("calendar.v2.eventSavedPartly", "Saved “{{title}}”, but not all of it", { title: c }),
|
|
168
|
+
description: `${p.problems.join(" ")} ${s("calendar.v2.eventSaveAgain", "Save again to try the rest.")}`,
|
|
169
|
+
tone: "warning",
|
|
170
|
+
urgent: !0
|
|
171
|
+
}), {
|
|
172
|
+
kind: "partial",
|
|
173
|
+
eventId: f
|
|
174
|
+
}) : (n({
|
|
175
|
+
title: I(e, i, u.create !== null, o),
|
|
176
|
+
tone: "success"
|
|
177
|
+
}), {
|
|
178
|
+
kind: "saved",
|
|
179
|
+
eventId: f
|
|
180
|
+
}));
|
|
181
|
+
}, [t, n]);
|
|
182
|
+
}
|
|
183
|
+
export { T as serviceMessage, L as useEventSave };
|
|
184
|
+
|
|
185
|
+
//# sourceMappingURL=useEventSave.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEventSave.js","names":["PARALLEL_WRITES","serviceMessage","CombinedGraphQLErrors","error","item","inTurns","next","worker","task","tasks","size","inOrder","items","index","stop","step","reasonFor","tr","reminderWords","reminder","ctx","formatDuration","attempt","work","run","failed","createEvent","id","client","CalendarV2CreateEventDocument","applyUpdates","plan","CalendarV2UpdateEventDocument","update","guestTasks","CalendarV2RemoveGuestDocument","guest","why","CalendarV2AddGuestDocument","reminderTasks","CalendarV2DeleteReminderDocument","CalendarV2CreateReminderDocument","REMINDER_CHANNEL","roomTask","cancelId","book","release","CalendarV2CancelRoomBookingDocument","reserve","CalendarV2BookRoomDocument","savedWords","title","form","created","event","start","startInstant","day","instantToZoned","when","formatInstantRange","endInstant","formatDay","useEventSave","useApolloClient","notify","useNotify","contextRef","useRef","context","useEffect","useCallback","planEdit","scope","planNewEvent","firstUpdate","invalidateCalendarEvents"],"sources":["../../../src/v2/event/useEventSave.ts"],"sourcesContent":["/**\n * Saving the event dialog (BOFF-15698 A2): runs the plan (`savePlan.ts`) against the service\n * and says how it went in a themed toast.\n *\n * - The event itself first: `createEvent`, or the `updateEvent` calls. If that fails nothing\n * else is sent, the service's words are shown, and the dialog keeps everything typed.\n * - Then its guests, reminders and room, a few at a time. Whatever of those fails is named with\n * the service's words, and the dialog stays open on the saved event (an edit from then on),\n * so saving again sends only what is still missing.\n * - After any write the views, free/busy and the dialog's own copy of the event reload\n * (`invalidateCalendarEvents`).\n */\nimport { useCallback, useEffect, useRef } from 'react';\nimport { CombinedGraphQLErrors } from '@apollo/client';\nimport { useApolloClient } from '@apollo/client/react';\nimport { useNotify } from '@burdenoff/fe-libs/ui';\nimport {\n CalendarV2AddGuestDocument,\n CalendarV2BookRoomDocument,\n CalendarV2CancelRoomBookingDocument,\n CalendarV2CreateEventDocument,\n CalendarV2CreateReminderDocument,\n CalendarV2DeleteReminderDocument,\n CalendarV2RemoveGuestDocument,\n CalendarV2UpdateEventDocument,\n type CalendarV2AddGuestMutation,\n type CalendarV2AddGuestMutationVariables,\n type CalendarV2BookRoomMutation,\n type CalendarV2BookRoomMutationVariables,\n type CalendarV2CancelRoomBookingMutation,\n type CalendarV2CancelRoomBookingMutationVariables,\n type CalendarV2CreateEventMutation,\n type CalendarV2CreateEventMutationVariables,\n type CalendarV2CreateReminderMutation,\n type CalendarV2CreateReminderMutationVariables,\n type CalendarV2DeleteReminderMutation,\n type CalendarV2DeleteReminderMutationVariables,\n type CalendarV2RemoveGuestMutation,\n type CalendarV2RemoveGuestMutationVariables,\n type CalendarV2UpdateEventMutation,\n type CalendarV2UpdateEventMutationVariables,\n} from '../../generated/wspace-operations';\nimport type { CreateEventInput } from '../../generated/wspace-types';\nimport { REMINDER_CHANNEL } from '../data/enums';\nimport { invalidateCalendarEvents } from '../data/invalidation';\nimport type { Tr } from '../data/useEventActions';\nimport {\n formatDay,\n formatDuration,\n formatInstantRange,\n type CalendarFormat,\n type DurationWords,\n} from '../format';\nimport { instantToZoned } from '../time/calendarTime';\nimport type { CalendarEventV2 } from '../types';\nimport {\n startInstant,\n endInstant,\n type EventForm,\n type GuestDraft,\n type ReminderDraft,\n} from './eventForm';\nimport { planEdit, planNewEvent, type SavePlan, type ScopeChoice } from './savePlan';\n\nexport interface EventSaveContext {\n tr: Tr;\n format: CalendarFormat;\n durationWords: DurationWords;\n /** The calendar's zone: where the toast says the event is. */\n timeZone: string;\n /** A calendar's name, for \"Added … to Customer calls\". */\n calendarName: (calendarId: string) => string | null;\n /** A room's name, for \"Couldn't book Atlas\". */\n roomName: (roomId: string) => string | null;\n /** A guest's name, for \"Couldn't add Priya Raman\". */\n guestName: (guest: GuestDraft) => string;\n}\n\nexport interface SaveRequest {\n form: EventForm;\n /** The event as the service last returned it; null for a new event. */\n event: CalendarEventV2 | null;\n /** A repeating event's answer to \"Change …\". */\n scope: ScopeChoice;\n}\n\nexport type SaveOutcome =\n | { kind: 'saved'; eventId: string }\n /** The event saved but some of its guests, reminders or room didn't. */\n | { kind: 'partial'; eventId: string }\n /** Nothing changed on the service. */\n | { kind: 'failed' };\n\n/** How many guest, reminder and room writes run at once. */\nconst PARALLEL_WRITES = 4;\n\ntype Client = ReturnType<typeof useApolloClient>;\n\n/** The service's own words for a failed write; null when it never answered. */\nexport function serviceMessage(error: unknown): string | null {\n if (CombinedGraphQLErrors.is(error)) {\n const message = error.errors.map((item) => item.message.trim()).find(Boolean);\n return message ?? null;\n }\n return null;\n}\n\n/** Runs `tasks`, at most `size` at a time, each as soon as one before it is done. */\nasync function inTurns(tasks: readonly (() => Promise<unknown>)[], size: number): Promise<void> {\n let next = 0;\n const worker = async (): Promise<void> => {\n const task = tasks[next];\n next += 1;\n if (!task) return;\n await task();\n await worker();\n };\n await Promise.all(Array.from({ length: Math.min(size, tasks.length) }, worker));\n}\n\n/**\n * Runs `step` on each item in order, the next only once the one before is done. A step that\n * returns something stops there, and that is returned; null when every step ran.\n */\nasync function inOrder<T, R>(\n items: readonly T[],\n step: (item: T, index: number) => Promise<R | null>,\n index = 0\n): Promise<R | null> {\n const item = items[index];\n if (item === undefined) return null;\n const stop = await step(item, index);\n return stop === null ? inOrder(items, step, index + 1) : stop;\n}\n\n/** What a save has done so far: whether anything was written, and what failed. */\ninterface SaveRun {\n wrote: boolean;\n problems: string[];\n}\n\n/** Why a write failed: the service's words, or that it never answered. */\nfunction reasonFor(error: unknown, tr: Tr): string {\n return (\n serviceMessage(error) ??\n tr('calendar.v2.eventSaveOffline', 'The calendar service didn’t answer. Check your connection.')\n );\n}\n\n/** \"10 min before\", \"When it starts\". */\nfunction reminderWords(reminder: ReminderDraft, ctx: EventSaveContext): string {\n return reminder.minutesBefore === 0\n ? ctx.tr('calendar.v2.reminderAtStart', 'When it starts')\n : ctx.tr('calendar.v2.reminderBefore', '{{time}} before', {\n time: formatDuration(reminder.minutesBefore, ctx.durationWords),\n });\n}\n\n/**\n * A write whose failure is noted (in the service's words) rather than thrown; it says whether\n * it went through.\n */\nfunction attempt(\n run: SaveRun,\n ctx: EventSaveContext,\n work: () => Promise<unknown>,\n failed: (why: string) => string\n): () => Promise<boolean> {\n return async () => {\n try {\n await work();\n run.wrote = true;\n return true;\n } catch (error) {\n run.problems.push(failed(reasonFor(error, ctx.tr)));\n return false;\n }\n };\n}\n\n/** Creates the event; its id. */\nasync function createEvent(client: Client, input: CreateEventInput): Promise<string> {\n const created = await client.mutate<\n CalendarV2CreateEventMutation,\n CalendarV2CreateEventMutationVariables\n >({\n mutation: CalendarV2CreateEventDocument,\n variables: { input },\n });\n const id = created.data?.createEvent.id;\n if (!id) throw new Error('No event came back');\n return id;\n}\n\n/**\n * The event's updates, one after the other (a new rule first, then the series' new start). If\n * the first fails nothing has changed: its error is returned. A later one that fails is noted.\n */\nasync function applyUpdates(\n client: Client,\n id: string,\n plan: SavePlan,\n run: SaveRun,\n ctx: EventSaveContext\n): Promise<{ error: unknown } | null> {\n return inOrder(plan.updates, async (update, index) => {\n try {\n await client.mutate<CalendarV2UpdateEventMutation, CalendarV2UpdateEventMutationVariables>({\n mutation: CalendarV2UpdateEventDocument,\n variables: { id, input: update.input, scope: update.scope },\n });\n run.wrote = true;\n return null;\n } catch (error) {\n if (index === 0) return { error };\n run.problems.push(\n ctx.tr('calendar.v2.eventRuleFailed', 'The new repeat didn’t save: {{reason}}', {\n reason: reasonFor(error, ctx.tr),\n })\n );\n return null;\n }\n });\n}\n\n/** Guests out and in. */\nfunction guestTasks(\n client: Client,\n id: string,\n plan: SavePlan,\n run: SaveRun,\n ctx: EventSaveContext\n): (() => Promise<boolean>)[] {\n const { tr } = ctx;\n return [\n ...plan.removeGuests.map((guest) =>\n attempt(\n run,\n ctx,\n () =>\n client.mutate<CalendarV2RemoveGuestMutation, CalendarV2RemoveGuestMutationVariables>({\n mutation: CalendarV2RemoveGuestDocument,\n variables: { attendeeId: guest.attendeeId ?? '' },\n }),\n (why) =>\n tr('calendar.v2.guestRemoveFailed', 'Couldn’t remove {{name}}: {{reason}}', {\n name: ctx.guestName(guest),\n reason: why,\n })\n )\n ),\n ...plan.addGuests.map((guest: GuestDraft) =>\n attempt(\n run,\n ctx,\n () =>\n client.mutate<CalendarV2AddGuestMutation, CalendarV2AddGuestMutationVariables>({\n mutation: CalendarV2AddGuestDocument,\n variables: { eventId: id, userId: guest.userId, email: guest.email, name: guest.name },\n }),\n (why) =>\n tr('calendar.v2.guestAddFailed', 'Couldn’t invite {{name}}: {{reason}}', {\n name: ctx.guestName(guest),\n reason: why,\n })\n )\n ),\n ];\n}\n\n/** Reminders out and in. */\nfunction reminderTasks(\n client: Client,\n id: string,\n plan: SavePlan,\n run: SaveRun,\n ctx: EventSaveContext\n): (() => Promise<boolean>)[] {\n const { tr } = ctx;\n return [\n ...plan.removeReminders.map((reminder) =>\n attempt(\n run,\n ctx,\n () =>\n client.mutate<\n CalendarV2DeleteReminderMutation,\n CalendarV2DeleteReminderMutationVariables\n >({\n mutation: CalendarV2DeleteReminderDocument,\n variables: { id: reminder.reminderId ?? '' },\n }),\n (why) =>\n tr(\n 'calendar.v2.reminderRemoveFailed',\n 'Couldn’t remove the reminder {{when}}: {{reason}}',\n {\n when: reminderWords(reminder, ctx),\n reason: why,\n }\n )\n )\n ),\n ...plan.addReminders.map((reminder) =>\n attempt(\n run,\n ctx,\n () =>\n client.mutate<\n CalendarV2CreateReminderMutation,\n CalendarV2CreateReminderMutationVariables\n >({\n mutation: CalendarV2CreateReminderDocument,\n variables: {\n input: {\n eventId: id,\n minutesBefore: reminder.minutesBefore,\n channel: REMINDER_CHANNEL[reminder.channel],\n },\n },\n }),\n (why) =>\n tr('calendar.v2.reminderAddFailed', 'Couldn’t add the reminder {{when}}: {{reason}}', {\n when: reminderWords(reminder, ctx),\n reason: why,\n })\n )\n ),\n ];\n}\n\n/**\n * The room, as one task: a room moving to a new time (or another room) is let go before it is\n * booked again, and booked only once it is let go; else the event would hold two bookings. The\n * old one then stands, and saving again tries both again.\n */\nfunction roomTask(\n client: Client,\n id: string,\n plan: SavePlan,\n run: SaveRun,\n ctx: EventSaveContext\n): (() => Promise<void>)[] {\n const { tr } = ctx;\n const cancelId = plan.cancelBookingId;\n const book = plan.bookRoom;\n const release = cancelId\n ? attempt(\n run,\n ctx,\n () =>\n client.mutate<\n CalendarV2CancelRoomBookingMutation,\n CalendarV2CancelRoomBookingMutationVariables\n >({\n mutation: CalendarV2CancelRoomBookingDocument,\n variables: { bookingId: cancelId },\n }),\n (why) =>\n book\n ? tr(\n 'calendar.v2.roomMoveFailed',\n 'Couldn’t move the room booking, so it stays as it was: {{reason}}',\n { reason: why }\n )\n : tr(\n 'calendar.v2.roomReleaseFailed',\n 'Couldn’t let go of the room booked before: {{reason}}',\n { reason: why }\n )\n )\n : null;\n const reserve = book\n ? attempt(\n run,\n ctx,\n () =>\n client.mutate<CalendarV2BookRoomMutation, CalendarV2BookRoomMutationVariables>({\n mutation: CalendarV2BookRoomDocument,\n variables: {\n input: {\n eventId: id,\n resourceId: book.resourceId,\n startTime: book.start.toISOString(),\n endTime: book.end.toISOString(),\n },\n },\n }),\n (why) =>\n tr('calendar.v2.roomBookFailed', 'Couldn’t book {{room}}: {{reason}}', {\n room: ctx.roomName(book.resourceId) ?? tr('calendar.v2.theRoom', 'The room'),\n reason: why,\n })\n )\n : null;\n if (!release && !reserve) return [];\n return [\n async () => {\n if (release && !(await release())) return;\n if (reserve) await reserve();\n },\n ];\n}\n\n/** The success toast's title: \"Added “Sync” to Customer calls, Fri 20 Nov 13:00 – 14:00.\" */\nfunction savedWords(\n form: EventForm,\n event: CalendarEventV2 | null,\n created: boolean,\n ctx: EventSaveContext\n): string {\n const { tr } = ctx;\n const title = form.title.trim();\n if (!created) {\n return event?.isRecurring\n ? tr('calendar.v2.eventSavedSeries', 'Saved every event in “{{title}}”.', { title })\n : tr('calendar.v2.eventSaved', 'Saved “{{title}}”.', { title });\n }\n const start = startInstant(form);\n const day = form.allDay ? form.firstDay : instantToZoned(start, ctx.timeZone).date;\n const when = form.allDay\n ? tr('calendar.v2.allDayLower', 'all day')\n : formatInstantRange(start, endInstant(form), ctx.timeZone, ctx.format);\n return tr('calendar.v2.eventAdded', 'Added “{{title}}” to {{calendar}}, {{day}} {{time}}.', {\n title,\n calendar: ctx.calendarName(form.calendarId ?? '') ?? tr('calendar.v2.aCalendar', 'a calendar'),\n day: formatDay(day, ctx.format, 'short'),\n time: when,\n });\n}\n\nexport function useEventSave(\n context: EventSaveContext\n): (request: SaveRequest) => Promise<SaveOutcome> {\n const client = useApolloClient();\n const notify = useNotify();\n const contextRef = useRef(context);\n useEffect(() => {\n contextRef.current = context;\n });\n\n return useCallback(\n async ({ form, event, scope }: SaveRequest): Promise<SaveOutcome> => {\n const ctx = contextRef.current;\n const { tr } = ctx;\n const title = form.title.trim();\n const plan: SavePlan = event\n ? planEdit(form, event, ctx.timeZone, scope)\n : planNewEvent(form);\n const failed = (error: unknown): SaveOutcome => {\n notify({\n title: plan.create\n ? tr('calendar.v2.eventAddFailed', 'Couldn’t add “{{title}}”', { title })\n : tr('calendar.v2.eventSaveFailed', 'Couldn’t save “{{title}}”', { title }),\n description: reasonFor(error, tr),\n tone: 'error',\n urgent: true,\n });\n return { kind: 'failed' };\n };\n\n // ── The event itself ──\n let id = event?.id ?? null;\n if (plan.create) {\n try {\n id = await createEvent(client, plan.create);\n } catch (error) {\n return failed(error);\n }\n }\n if (!id) return { kind: 'failed' };\n const run: SaveRun = { wrote: plan.create !== null, problems: [] };\n const firstUpdate = await applyUpdates(client, id, plan, run, ctx);\n if (firstUpdate) return failed(firstUpdate.error);\n\n // ── Its guests, reminders and room ──\n await inTurns(\n [\n ...guestTasks(client, id, plan, run, ctx),\n ...reminderTasks(client, id, plan, run, ctx),\n ...roomTask(client, id, plan, run, ctx),\n ],\n PARALLEL_WRITES\n );\n if (run.wrote) invalidateCalendarEvents();\n\n if (run.problems.length > 0) {\n notify({\n title: plan.create\n ? tr('calendar.v2.eventAddedPartly', 'Added “{{title}}”, but not all of it', { title })\n : tr('calendar.v2.eventSavedPartly', 'Saved “{{title}}”, but not all of it', { title }),\n description: `${run.problems.join(' ')} ${tr(\n 'calendar.v2.eventSaveAgain',\n 'Save again to try the rest.'\n )}`,\n tone: 'warning',\n urgent: true,\n });\n return { kind: 'partial', eventId: id };\n }\n notify({ title: savedWords(form, event, plan.create !== null, ctx), tone: 'success' });\n return { kind: 'saved', eventId: id };\n },\n [client, notify]\n );\n}\n"],"mappings":";;;;;;;;;;;;AA8FA,IAAMA,IAAkB;AAKxB,SAAgBC,EAAe,GAA+B;CAK5D,OAJIC,EAAsB,GAAGC,CAAK,IAChBA,EAAM,OAAO,KAAK,MAASC,EAAK,QAAQ,KAAK,CAAC,CAAC,CAAC,KAAK,OAC9D,KAAW,OAEb;AACT;AAGA,eAAeC,EAAQ,GAA4C,GAA6B;CAC9F,IAAIC,IAAO,GACLC,IAAS,YAA2B;EACxC,IAAMC,IAAOC,EAAMH;EAEnB,AADA,KAAQ,GACHE,MACL,MAAMA,EAAK,GACX,MAAMD,EAAO;CACf;CACA,MAAM,QAAQ,IAAI,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAIG,GAAMD,EAAM,MAAM,EAAE,GAAGF,CAAM,CAAC;AAChF;AAMA,eAAeI,EACb,GACA,GACA,IAAQ,GACW;CACnB,IAAMP,IAAOQ,EAAMC;CACnB,IAAIT,MAAS,KAAA,GAAW,OAAO;CAC/B,IAAMU,IAAO,MAAMC,EAAKX,GAAMS,CAAK;CACnC,OAAOC,MA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oBlD,EAAOkD,EAAY,KAAK,KAGhD,MAAMtE,EACJ;GACE,GAAG6B,EAAWN,GAAQD,GAAII,GAAMP,GAAKJ,CAAG;GACxC,GAAGmB,EAAcX,GAAQD,GAAII,GAAMP,GAAKJ,CAAG;GAC3C,GAAGuB,EAASf,GAAQD,GAAII,GAAMP,GAAKJ,CAAG;EACxC,GACApB,CACF,GACIwB,EAAI,SAAOoD,EAAyB,GAEpCpD,EAAI,SAAS,SAAS,KACxByC,EAAO;GACL,OAAOlC,EAAK,SACRd,EAAG,gCAAgC,wCAAwC,EAAE,SAAM,CAAC,IACpFA,EAAG,gCAAgC,wCAAwC,EAAE,SAAM,CAAC;GACxF,aAAa,GAAGO,EAAI,SAAS,KAAK,GAAG,EAAE,GAAGP,EACxC,8BACA,6BACF;GACA,MAAM;GACN,QAAQ;EACV,CAAC,GACM;GAAE,MAAM;GAAW,SAASU;EAAG,MAExCsC,EAAO;GAAE,OAAOf,EAAWE,GAAME,GAAOvB,EAAK,WAAW,MAAMX,CAAG;GAAG,MAAM;EAAU,CAAC,GAC9E;GAAE,MAAM;GAAS,SAASO;EAAG;CACtC,GACA,CAACC,GAAQqC,CAAM,CACjB;AACF"}
|
package/dist/v2/format.d.ts
CHANGED
package/dist/v2/format.js
CHANGED
package/dist/v2/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","names":["resolveCalendarLocale","appLocale","deviceLanguages","language","tag","formats","dayFormat","key","locale","options","format","utcMidnight","parts","parseDateValue","date","DAY_STYLES","formatDay","style","formatDaySpan","withYear","formatter","first","last","formatMinutes","wrapped","minutes","formatTimeOfDay","formatMinuteRange","start","end","formatInstantTime","instantToZoned","instant","timeZone","formatInstantRange","formatDayTimeSpan","at","zoned","formatDuration","rounded","totalMinutes","hours","template","words"],"sources":["../../src/v2/format.ts"],"sourcesContent":["/**\n * How the redesigned calendar writes days and times (BOFF-15698 A1): in the person's locale,\n * on their clock (24-hour unless they pick 12-hour in Calendar settings).\n *\n * - The locale is the app's language with this device's region when the device speaks that\n * language (\"en\" in a British browser writes \"Fri 20 Nov\", in an American one \"Fri, Nov 20\").\n * - A day is a floating `YYYY-MM-DD`, written at its UTC midnight with `timeZone: 'UTC'`, so it\n * never reads as the day before or after.\n * - A time is minutes after midnight on the calendar's clock (`instantToZoned`), written with\n * fe-libs' `formatTimeOfDay`.\n */\nimport {\n formatTimeOfDay,\n parseDateValue,\n type DateValue,\n type HourCycle,\n} from '@burdenoff/fe-libs/ui';\nimport { instantToZoned } from './time/calendarTime';\n\nexport interface CalendarFormat {\n /** A BCP 47 tag (\"en-GB\"), or undefined for the runtime's. */\n locale: string | undefined;\n hourCycle: HourCycle;\n}\n\n/**\n * The locale the calendar writes in: the first of the device's languages that is the app's\n * language (so its region decides the order of day and month), else the app's language.\n */\nexport function resolveCalendarLocale(\n appLocale: string | undefined,\n deviceLanguages: readonly string[]\n): string | undefined {\n if (!appLocale) return deviceLanguages[0];\n const language = appLocale.toLowerCase().split(/[-_]/)[0];\n const regional = deviceLanguages.find(\n (tag) => tag.toLowerCase().split(/[-_]/)[0] === language && tag.includes('-')\n );\n return regional ?? appLocale;\n}\n\nconst formats = new Map<string, Intl.DateTimeFormat>();\n\nfunction dayFormat(\n locale: string | undefined,\n options: Intl.DateTimeFormatOptions\n): Intl.DateTimeFormat {\n const key = `${locale ?? ''}|${JSON.stringify(options)}`;\n let format = formats.get(key);\n if (!format) {\n try {\n format = new Intl.DateTimeFormat(locale, { ...options, timeZone: 'UTC' });\n } catch {\n format = new Intl.DateTimeFormat(undefined, { ...options, timeZone: 'UTC' });\n }\n formats.set(key, format);\n }\n return format;\n}\n\n/** The UTC midnight of a day, for `Intl` with `timeZone: 'UTC'`. */\nexport function utcMidnight(date: DateValue): Date {\n const parts = parseDateValue(date);\n if (!parts) return new Date(Number.NaN);\n return new Date(Date.UTC(parts.year, parts.month - 1, parts.day));\n}\n\nexport type DayStyle =\n /** \"Fri 20 Nov\" */\n | 'short'\n /** \"Friday 20 Nov\" */\n | 'mid'\n /** \"Friday 20 November\" */\n | 'long'\n /** \"Friday 20 November 2026\" */\n | 'full'\n /** \"20 Nov 2026\" */\n | 'date'\n /** \"Fri\" */\n | 'weekday'\n /** \"Friday\" */\n | 'weekdayLong'\n /** \"20\" */\n | 'dayNumber'\n /** \"Nov\" */\n | 'monthShort'\n /** \"November 2026\" */\n | 'monthYear'\n /** \"Nov 2026\" */\n | 'monthYearShort';\n\nconst DAY_STYLES: Readonly<Record<DayStyle, Intl.DateTimeFormatOptions>> = {\n short: { weekday: 'short', day: 'numeric', month: 'short' },\n mid: { weekday: 'long', day: 'numeric', month: 'short' },\n long: { weekday: 'long', day: 'numeric', month: 'long' },\n full: { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' },\n date: { day: 'numeric', month: 'short', year: 'numeric' },\n weekday: { weekday: 'short' },\n weekdayLong: { weekday: 'long' },\n dayNumber: { day: 'numeric' },\n monthShort: { month: 'short' },\n monthYear: { month: 'long', year: 'numeric' },\n monthYearShort: { month: 'short', year: 'numeric' },\n};\n\n/** A day in the locale; commas the locale puts between weekday and day are kept. */\nexport function formatDay(date: DateValue, format: CalendarFormat, style: DayStyle): string {\n return dayFormat(format.locale, DAY_STYLES[style]).format(utcMidnight(date));\n}\n\n/**\n * Two days as the locale writes a range: \"16–22 Nov 2026\", \"30 Nov – 6 Dec 2026\",\n * \"28 Dec 2026 – 3 Jan 2027\". `withYear: false` leaves the year out (phones).\n */\nexport function formatDaySpan(\n first: DateValue,\n last: DateValue,\n format: CalendarFormat,\n withYear = true\n): string {\n const options: Intl.DateTimeFormatOptions = withYear\n ? { day: 'numeric', month: 'short', year: 'numeric' }\n : { day: 'numeric', month: 'short' };\n const formatter = dayFormat(format.locale, options);\n if (first === last) return formatter.format(utcMidnight(first));\n return formatter.formatRange(utcMidnight(first), utcMidnight(last));\n}\n\n/** A time of day, `minutes` after midnight (1440 reads as midnight). */\nexport function formatMinutes(minutes: number, format: CalendarFormat): string {\n const wrapped = ((Math.round(minutes) % 1440) + 1440) % 1440;\n return formatTimeOfDay(wrapped, format.locale, format.hourCycle);\n}\n\n/** \"10:15 – 11:15\". */\nexport function formatMinuteRange(start: number, end: number, format: CalendarFormat): string {\n return `${formatMinutes(start, format)} – ${formatMinutes(end, format)}`;\n}\n\n/** The time an instant shows on the clock of `timeZone`. */\nexport function formatInstantTime(instant: Date, timeZone: string, format: CalendarFormat): string {\n return formatMinutes(instantToZoned(instant, timeZone).minutes, format);\n}\n\n/** \"10:15 – 11:15\", both ends on the clock of `timeZone`. */\nexport function formatInstantRange(\n start: Date,\n end: Date,\n timeZone: string,\n format: CalendarFormat\n): string {\n return `${formatInstantTime(start, timeZone, format)} – ${formatInstantTime(end, timeZone, format)}`;\n}\n\n/**\n * A timed span over more than one day, with its days: \"Mon 16 Nov, 10:00 – Tue 17 Nov, 10:00\",\n * both ends on the clock of `timeZone`.\n */\nexport function formatDayTimeSpan(\n start: Date,\n end: Date,\n timeZone: string,\n format: CalendarFormat\n): string {\n const at = (instant: Date) => {\n const zoned = instantToZoned(instant, timeZone);\n return `${formatDay(zoned.date, format, 'short')}, ${formatMinutes(zoned.minutes, format)}`;\n };\n return `${at(start)} – ${at(end)}`;\n}\n\n/** The words of a length of time, already translated by the caller. */\nexport interface DurationWords {\n /** \"{{minutes}} min\" */\n minutes: string;\n /** \"{{hours}} h\" */\n hours: string;\n /** \"{{hours}} h {{minutes}} min\" */\n hoursMinutes: string;\n}\n\n/** \"45 min\", \"1 h\", \"2 h 30 min\". */\nexport function formatDuration(totalMinutes: number, words: DurationWords): string {\n const rounded = Math.max(0, Math.round(totalMinutes));\n const hours = Math.floor(rounded / 60);\n const minutes = rounded % 60;\n const fill = (template: string) =>\n template.replace('{{hours}}', String(hours)).replace('{{minutes}}', String(minutes));\n if (hours === 0) return fill(words.minutes);\n return minutes === 0 ? fill(words.hours) : fill(words.hoursMinutes);\n}\n"],"mappings":";;;AA6BA,SAAgBA,EACd,GACA,GACoB;CACp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AQN,EAAeC,GAASC,CAAQ;EAC9C,OAAO,GAAGjB,EAAUqB,EAAM,MAAM3B,GAAQ,OAAO,EAAE,IAAIa,EAAcc,EAAM,SAAS3B,CAAM;CAC1F;CACA,OAAO,GAAG0B,EAAGR,CAAK,EAAE,KAAKQ,EAAGP,CAAG;AACjC;AAaA,SAAgBS,EAAe,GAAsB,GAA8B;CACjF,IAAMC,IAAU,KAAK,IAAI,GAAG,KAAK,MAAMC,CAAY,CAAC,GAC9CC,IAAQ,KAAK,MAAMF,IAAU,EAAE,GAC/Bd,IAAUc,IAAU;CAI1B,SAHc,MACZG,EAAS,QAAQ,aAAa,OAAOD,CAAK,CAAC,CAAC,CAAC,QAAQ,eAAe,OAAOhB,CAAO,CAAC,EAC7D,CAApBgB,MAAU,IAAeE,EAAM,UAC5BlB,MAAY,IAASkB,EAAM,QAAcA,EAAM,YADZ;AAE5C"}
|
|
1
|
+
{"version":3,"file":"format.js","names":["resolveCalendarLocale","appLocale","deviceLanguages","language","tag","formats","dayFormat","key","locale","options","format","utcMidnight","parts","parseDateValue","date","DAY_STYLES","formatDay","style","formatDaySpan","withYear","formatter","first","last","formatMinutes","wrapped","minutes","formatTimeOfDay","formatMinuteRange","start","end","formatInstantTime","instantToZoned","instant","timeZone","formatInstantRange","formatDayTimeSpan","at","zoned","formatDuration","rounded","totalMinutes","hours","template","words"],"sources":["../../src/v2/format.ts"],"sourcesContent":["/**\n * How the redesigned calendar writes days and times (BOFF-15698 A1): in the person's locale,\n * on their clock (24-hour unless they pick 12-hour in Calendar settings).\n *\n * - The locale is the app's language with this device's region when the device speaks that\n * language (\"en\" in a British browser writes \"Fri 20 Nov\", in an American one \"Fri, Nov 20\").\n * - A day is a floating `YYYY-MM-DD`, written at its UTC midnight with `timeZone: 'UTC'`, so it\n * never reads as the day before or after.\n * - A time is minutes after midnight on the calendar's clock (`instantToZoned`), written with\n * fe-libs' `formatTimeOfDay`.\n */\nimport {\n formatTimeOfDay,\n parseDateValue,\n type DateValue,\n type HourCycle,\n} from '@burdenoff/fe-libs/ui';\nimport { instantToZoned } from './time/calendarTime';\n\nexport interface CalendarFormat {\n /** A BCP 47 tag (\"en-GB\"), or undefined for the runtime's. */\n locale: string | undefined;\n hourCycle: HourCycle;\n}\n\n/**\n * The locale the calendar writes in: the first of the device's languages that is the app's\n * language (so its region decides the order of day and month), else the app's language.\n */\nexport function resolveCalendarLocale(\n appLocale: string | undefined,\n deviceLanguages: readonly string[]\n): string | undefined {\n if (!appLocale) return deviceLanguages[0];\n const language = appLocale.toLowerCase().split(/[-_]/)[0];\n const regional = deviceLanguages.find(\n (tag) => tag.toLowerCase().split(/[-_]/)[0] === language && tag.includes('-')\n );\n return regional ?? appLocale;\n}\n\nconst formats = new Map<string, Intl.DateTimeFormat>();\n\nfunction dayFormat(\n locale: string | undefined,\n options: Intl.DateTimeFormatOptions\n): Intl.DateTimeFormat {\n const key = `${locale ?? ''}|${JSON.stringify(options)}`;\n let format = formats.get(key);\n if (!format) {\n try {\n format = new Intl.DateTimeFormat(locale, { ...options, timeZone: 'UTC' });\n } catch {\n format = new Intl.DateTimeFormat(undefined, { ...options, timeZone: 'UTC' });\n }\n formats.set(key, format);\n }\n return format;\n}\n\n/** The UTC midnight of a day, for `Intl` with `timeZone: 'UTC'`. */\nexport function utcMidnight(date: DateValue): Date {\n const parts = parseDateValue(date);\n if (!parts) return new Date(Number.NaN);\n return new Date(Date.UTC(parts.year, parts.month - 1, parts.day));\n}\n\nexport type DayStyle =\n /** \"Fri 20 Nov\" */\n | 'short'\n /** \"Friday 20 Nov\" */\n | 'mid'\n /** \"Friday 20 November\" */\n | 'long'\n /** \"Friday 20 November 2026\" */\n | 'full'\n /** \"20 Nov 2026\" */\n | 'date'\n /** \"20 November\" */\n | 'dayMonth'\n /** \"Fri\" */\n | 'weekday'\n /** \"Friday\" */\n | 'weekdayLong'\n /** \"20\" */\n | 'dayNumber'\n /** \"Nov\" */\n | 'monthShort'\n /** \"November 2026\" */\n | 'monthYear'\n /** \"Nov 2026\" */\n | 'monthYearShort';\n\nconst DAY_STYLES: Readonly<Record<DayStyle, Intl.DateTimeFormatOptions>> = {\n short: { weekday: 'short', day: 'numeric', month: 'short' },\n mid: { weekday: 'long', day: 'numeric', month: 'short' },\n long: { weekday: 'long', day: 'numeric', month: 'long' },\n full: { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' },\n date: { day: 'numeric', month: 'short', year: 'numeric' },\n dayMonth: { day: 'numeric', month: 'long' },\n weekday: { weekday: 'short' },\n weekdayLong: { weekday: 'long' },\n dayNumber: { day: 'numeric' },\n monthShort: { month: 'short' },\n monthYear: { month: 'long', year: 'numeric' },\n monthYearShort: { month: 'short', year: 'numeric' },\n};\n\n/** A day in the locale; commas the locale puts between weekday and day are kept. */\nexport function formatDay(date: DateValue, format: CalendarFormat, style: DayStyle): string {\n return dayFormat(format.locale, DAY_STYLES[style]).format(utcMidnight(date));\n}\n\n/**\n * Two days as the locale writes a range: \"16–22 Nov 2026\", \"30 Nov – 6 Dec 2026\",\n * \"28 Dec 2026 – 3 Jan 2027\". `withYear: false` leaves the year out (phones).\n */\nexport function formatDaySpan(\n first: DateValue,\n last: DateValue,\n format: CalendarFormat,\n withYear = true\n): string {\n const options: Intl.DateTimeFormatOptions = withYear\n ? { day: 'numeric', month: 'short', year: 'numeric' }\n : { day: 'numeric', month: 'short' };\n const formatter = dayFormat(format.locale, options);\n if (first === last) return formatter.format(utcMidnight(first));\n return formatter.formatRange(utcMidnight(first), utcMidnight(last));\n}\n\n/** A time of day, `minutes` after midnight (1440 reads as midnight). */\nexport function formatMinutes(minutes: number, format: CalendarFormat): string {\n const wrapped = ((Math.round(minutes) % 1440) + 1440) % 1440;\n return formatTimeOfDay(wrapped, format.locale, format.hourCycle);\n}\n\n/** \"10:15 – 11:15\". */\nexport function formatMinuteRange(start: number, end: number, format: CalendarFormat): string {\n return `${formatMinutes(start, format)} – ${formatMinutes(end, format)}`;\n}\n\n/** The time an instant shows on the clock of `timeZone`. */\nexport function formatInstantTime(instant: Date, timeZone: string, format: CalendarFormat): string {\n return formatMinutes(instantToZoned(instant, timeZone).minutes, format);\n}\n\n/** \"10:15 – 11:15\", both ends on the clock of `timeZone`. */\nexport function formatInstantRange(\n start: Date,\n end: Date,\n timeZone: string,\n format: CalendarFormat\n): string {\n return `${formatInstantTime(start, timeZone, format)} – ${formatInstantTime(end, timeZone, format)}`;\n}\n\n/**\n * A timed span over more than one day, with its days: \"Mon 16 Nov, 10:00 – Tue 17 Nov, 10:00\",\n * both ends on the clock of `timeZone`.\n */\nexport function formatDayTimeSpan(\n start: Date,\n end: Date,\n timeZone: string,\n format: CalendarFormat\n): string {\n const at = (instant: Date) => {\n const zoned = instantToZoned(instant, timeZone);\n return `${formatDay(zoned.date, format, 'short')}, ${formatMinutes(zoned.minutes, format)}`;\n };\n return `${at(start)} – ${at(end)}`;\n}\n\n/** The words of a length of time, already translated by the caller. */\nexport interface DurationWords {\n /** \"{{minutes}} min\" */\n minutes: string;\n /** \"{{hours}} h\" */\n hours: string;\n /** \"{{hours}} h {{minutes}} min\" */\n hoursMinutes: string;\n}\n\n/** \"45 min\", \"1 h\", \"2 h 30 min\". */\nexport function formatDuration(totalMinutes: number, words: DurationWords): string {\n const rounded = Math.max(0, Math.round(totalMinutes));\n const hours = Math.floor(rounded / 60);\n const minutes = rounded % 60;\n const fill = (template: string) =>\n template.replace('{{hours}}', String(hours)).replace('{{minutes}}', String(minutes));\n if (hours === 0) return fill(words.minutes);\n return minutes === 0 ? fill(words.hours) : fill(words.hoursMinutes);\n}\n"],"mappings":";;;AA6BA,SAAgBA,EACd,GACA,GACoB;CACpB,IAAI,CAACC,GAAW,OAAOC,EAAgB;CACvC,IAAMC,IAAWF,EAAU,YAAY,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC;CAIvD,OAHiBC,EAAgB,MAC9B,MAAQE,EAAI,YAAY,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,OAAOD,KAAYC,EAAI,SAAS,GAAG,C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AAGP,CAAG;AACjC;AAaA,SAAgBS,EAAe,GAAsB,GAA8B;CACjF,IAAMC,IAAU,KAAK,IAAI,GAAG,KAAK,MAAMC,CAAY,CAAC,GAC9CC,IAAQ,KAAK,MAAMF,IAAU,EAAE,GAC/Bd,IAAUc,IAAU;CAI1B,SAHc,MACZG,EAAS,QAAQ,aAAa,OAAOD,CAAK,CAAC,CAAC,CAAC,QAAQ,eAAe,OAAOhB,CAAO,CAAC,EAC7D,CAApBgB,MAAU,IAAeE,EAAM,UAC5BlB,MAAY,IAASkB,EAAM,QAAcA,EAAM,YADZ;AAE5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventPeek.js","names":["_Fragment","anchorFor","opener","eventId","EventPeekHost","page","useCalendarPage","found","useEventForPeek","virtualRef","useMemo","element","x","body","PeekContent","BottomSheet","open","BottomSheetContent","Popover","PopoverAnchor","PopoverContent","interaction","focusEvent","PeekEvent","PeekFrame","tr","Spinner","Button","Title","BottomSheetTitle","
|
|
1
|
+
{"version":3,"file":"EventPeek.js","names":["_Fragment","Fragment$1","anchorFor","opener","eventId","EventPeekHost","page","useCalendarPage","found","useEventForPeek","virtualRef","useMemo","element","x","body","PeekContent","BottomSheet","open","BottomSheetContent","Popover","PopoverAnchor","PopoverContent","interaction","focusEvent","PeekEvent","PeekFrame","tr","Spinner","Button","Title","BottomSheetTitle","title","CloseButton","children"],"sources":["../../../src/v2/peek/EventPeek.tsx"],"sourcesContent":["/**\n * The peek (BOFF-15698 A1): an event at a glance, a popover beside it on wide screens and a\n * sheet on phones. It opens from the address (`?event=`), so a link or a notification opens it\n * too; the event itself is drawn by `PeekEvent`. While the event loads, can't be found or fails,\n * the peek says so.\n */\nimport { useMemo, type ReactNode } from 'react';\nimport {\n BottomSheet,\n BottomSheetContent,\n BottomSheetTitle,\n Button,\n Popover,\n PopoverAnchor,\n PopoverContent,\n Spinner,\n} from '@burdenoff/fe-libs/ui';\nimport { useEventForPeek } from '../data/useEventForPeek';\nimport { useCalendarPage } from '../page/CalendarPageContext';\nimport { PeekEvent } from './PeekEvent';\nimport { CloseButton } from './PeekParts';\n\ntype Anchor = { current: { getBoundingClientRect: () => DOMRect } };\n\nfunction anchorFor(eventId: string, opener: HTMLElement | null): Element | null {\n if (opener?.isConnected) return opener;\n if (typeof document === 'undefined') return null;\n return document.querySelector(`[data-event-id=\"${CSS.escape(eventId)}\"]`);\n}\n\n/** Hosts the peek for the event the address names. */\nexport function EventPeekHost() {\n const page = useCalendarPage();\n const eventId = page.nav.eventId;\n const found = useEventForPeek(eventId, page.allLoadedEvents, page.state.kind === 'loading');\n const virtualRef = useMemo<Anchor>(\n () => ({\n current: {\n getBoundingClientRect: () => {\n const element = eventId ? anchorFor(eventId, page.peekAnchor) : null;\n if (element) return element.getBoundingClientRect();\n // No block to point at (another week, a hidden calendar): the middle of the window.\n const x = window.innerWidth / 2;\n return new DOMRect(x, 120, 0, 0);\n },\n },\n }),\n [eventId, page.peekAnchor]\n );\n if (!eventId) return null;\n\n const body = <PeekContent found={found} />;\n if (page.compact) {\n return (\n <BottomSheet open onOpenChange={(open) => (open ? undefined : page.closePeek())}>\n <BottomSheetContent\n className=\"max-h-[88dvh] gap-0 p-0\"\n showCloseButton={false}\n aria-describedby={undefined}\n >\n {body}\n </BottomSheetContent>\n </BottomSheet>\n );\n }\n return (\n <Popover open onOpenChange={(open) => (open ? undefined : page.closePeek())}>\n <PopoverAnchor virtualRef={virtualRef} />\n <PopoverContent\n side=\"right\"\n align=\"start\"\n sideOffset={8}\n collisionPadding={12}\n className=\"flex max-h-[min(640px,calc(100dvh-24px))] w-[380px] flex-col overflow-hidden p-0\"\n onInteractOutside={(interaction) => {\n // A click on another event switches the peek to it instead of closing it.\n const target = interaction.target instanceof Element ? interaction.target : null;\n if (target?.closest('[data-event-id]')) interaction.preventDefault();\n }}\n onCloseAutoFocus={(focusEvent) => {\n const opener = anchorFor(eventId, page.peekAnchor);\n if (opener instanceof HTMLElement) {\n focusEvent.preventDefault();\n opener.focus({ preventScroll: true });\n }\n }}\n >\n {body}\n </PopoverContent>\n </Popover>\n );\n}\n\nfunction PeekContent({ found }: { found: ReturnType<typeof useEventForPeek> }) {\n const page = useCalendarPage();\n const { tr } = page;\n if (found.status === 'ready') return <PeekEvent event={found.event} />;\n if (found.status === 'loading' || found.status === 'none') {\n return (\n <PeekFrame title={tr('calendar.v2.peekLoading', 'Opening the event…')}>\n <div className=\"grid place-items-center p-8\">\n <Spinner />\n </div>\n </PeekFrame>\n );\n }\n if (found.status === 'error') {\n return (\n <PeekFrame title={tr('calendar.v2.peekFailed', 'Couldn’t open the event')}>\n <div className=\"flex flex-col gap-3 p-4\">\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'calendar.v2.peekFailedBody',\n 'The calendar service didn’t answer. Nothing was changed.'\n )}\n </p>\n <Button type=\"button\" onClick={found.retry} className=\"self-start\">\n {tr('calendar.v2.tryAgain', 'Try again')}\n </Button>\n </div>\n </PeekFrame>\n );\n }\n return (\n <PeekFrame title={tr('calendar.v2.peekMissing', 'This event isn’t available')}>\n <p className=\"p-4 text-sm text-text-secondary\">\n {tr(\n 'calendar.v2.peekMissingBody',\n 'It may have been deleted, or it’s on a calendar you can’t see. Ask whoever sent the link.'\n )}\n </p>\n </PeekFrame>\n );\n}\n\n/** The peek's frame without an event (loading, missing, failed). */\nfunction PeekFrame({ title, children }: { title: string; children: ReactNode }) {\n const page = useCalendarPage();\n const Title = page.compact ? BottomSheetTitle : 'h3';\n return (\n <>\n <div className=\"flex items-center gap-2 border-b border-border-subtle p-3 ps-4\">\n <Title className=\"min-w-0 flex-1 text-base font-bold text-text-primary\">{title}</Title>\n <CloseButton />\n </div>\n {children}\n </>\n );\n}\n"],"mappings":";;;;;;;;AAwBA,SAASE,EAAU,GAAiB,GAA4C;CAG9E,OAFIC,GAAQ,cAAoBA,IAC5B,OAAO,WAAa,MAAoB,OACrC,SAAS,cAAc,mBAAmB,IAAI,OAAOC,CAAO,EAAE,GAAG;A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","useCalendarPage","useCalendar","calendar","event","userIds","useMemo","guest","id","profiles","useActorProfiles","nameOf","carried","profile","userId","organizerGuest","span","eventDays","timeZone","when","formatDayTimeSpan","format","tr","formatDay","instantToZoned","formatInstantRange","isOrganizer","me","PeekTitle","jsx","compact","BottomSheetTitle","PeekTools","notify","useNotify","model","lockReason","more","Download","Link2","calendarV2Href","basePath","SEARCH_PARAMS","look","Trash2","ICON_BUTTON","Pencil","Lock","Copy","ActionMenu","CloseButton","PeekWhen","ownZone","Repeat","PeekNotices","room","eventRoom","roomName","Fragment","Notice","AlertTriangle","Clock3","PeekJoin","url","joinUrl","Button","Video","PeekPlace","Row","Building2","MapPin","PeekPeople","answerOf","answer","response","counts","people","b","a","tally","part","hidden","Users","GuestRow","cn","FOCUS_RING","PeekReminders","channelWords","channel","Bell","reminder","formatDuration","durationWords","PeekCalendarLine","parts","CalendarDays","PeekNotes","FileText","PeekFooter","value","Segmented","next","CircleHelp","Crown","BusyPeek","calendarHueStyle","EyeOff","PeekEvent","BottomSheetDescription"],"sources":["../../../src/v2/peek/PeekEvent.tsx"],"sourcesContent":["/**\n * An event's peek (BOFF-15698 A1), built from one small part per section: the header and its\n * tools (Edit or Edit locked with the organiser's name, Duplicate, Delete, ⋯), when, notices,\n * Join, the place, the people and their answers, reminders, the calendar line, the notes, and\n * the footer (Yes · Maybe · No for a guest, Find a better time for the organiser). Someone\n * else's private time shows only \"Busy\".\n */\nimport { useMemo } from 'react';\nimport {\n AlertTriangle,\n Bell,\n Building2,\n CalendarDays,\n CircleHelp,\n Clock3,\n Copy,\n Crown,\n Download,\n EyeOff,\n FileText,\n Link2,\n Lock,\n MapPin,\n Pencil,\n Repeat,\n Trash2,\n Users,\n Video,\n} from 'lucide-react';\nimport { useActorProfiles } from '@burdenoff/fe-libs/shared';\nimport {\n ActionMenu,\n BottomSheetDescription,\n BottomSheetTitle,\n Button,\n Notice,\n Segmented,\n useNotify,\n type ActionMenuItem,\n} from '@burdenoff/fe-libs/ui';\nimport { cn } from '@burdenoff/fe-libs/utils';\nimport { useCalendar } from '../../providers/CalendarProvider';\nimport { calendarHueStyle } from '../colors';\nimport type { Answer } from '../data/useEventActions';\nimport type { EventLook } from '../events/eventLook';\nimport { eventRoom, isOrganizer, joinUrl } from '../events/eventModel';\nimport { formatDay, formatDayTimeSpan, formatDuration, formatInstantRange } from '../format';\nimport { useCalendarPage } from '../page/CalendarPageContext';\nimport { calendarV2Href, SEARCH_PARAMS } from '../routes';\nimport { FOCUS_RING, ICON_BUTTON } from '../styles';\nimport { eventDays, instantToZoned } from '../time/calendarTime';\nimport type { CalendarEventV2, CalendarV2, EventResponseV2 } from '../types';\nimport { CloseButton, GuestRow, Row } from './PeekParts';\n\n/** Guests listed before \"See all\". */\nconst PEOPLE_SHOWN = 6;\n\n/** What every part of an event's peek reads. */\ninterface PeekModel {\n event: CalendarEventV2;\n look: EventLook;\n calendar: CalendarV2 | undefined;\n calendarName: string;\n /** The person's answer (one given here first); null when they organise it or aren't asked. */\n answer: EventResponseV2 | null;\n iOrganise: boolean;\n organizerName: string;\n /** A person's name: the one the event carries, else their workspace profile's. */\n nameOf: (userId: string | null, carried: string | null) => string | null;\n /**\n * \"Friday 20 Nov · 14:30 – 15:30\", \"Fri 20 Nov, 23:00 – Sat 21 Nov, 01:00\",\n * \"Mon 16 Nov – Fri 20 Nov · all day\".\n */\n when: string;\n}\n\nfunction usePeekModel(event: CalendarEventV2): PeekModel {\n const page = useCalendarPage();\n const { tr, format, timeZone, me } = page;\n const { apiGatewayUrl, authToken, workspaceId } = useCalendar();\n const calendar = page.calendarsById.get(event.calendarId);\n const userIds = useMemo(\n () =>\n [...new Set([event.organizerId, ...event.guests.map((guest) => guest.userId)])]\n .filter((id): id is string => Boolean(id))\n .map((actorId) => ({ actorId, actorType: 'user' })),\n [event.guests, event.organizerId]\n );\n const profiles = useActorProfiles(userIds, { apiGatewayUrl, authToken, workspaceId });\n const nameOf = (userId: string | null, carried: string | null): string | null => {\n if (carried) return carried;\n const profile = userId ? profiles[userId] : undefined;\n return profile?.resolved ? profile.displayName : null;\n };\n const organizerGuest = event.guests.find((guest) => guest.organizer) ?? null;\n const span = eventDays(event, timeZone);\n let when: string;\n if (!event.allDay && span.start !== span.end) {\n // Over midnight, or a day or more: both ends with their days.\n when = formatDayTimeSpan(event.start, event.end, timeZone, format);\n } else if (!event.allDay) {\n when = `${formatDay(instantToZoned(event.start, timeZone).date, format, 'mid')} · ${formatInstantRange(event.start, event.end, timeZone, format)}`;\n } else if (span.start === span.end) {\n when = tr('calendar.v2.whenAllDay', '{{day}} · all day', {\n day: formatDay(span.start, format, 'mid'),\n });\n } else {\n when = tr('calendar.v2.whenAllDays', '{{from}} – {{to}} · all day', {\n from: formatDay(span.start, format, 'short'),\n to: formatDay(span.end, format, 'short'),\n });\n }\n return {\n event,\n look: page.lookOf(event),\n calendar,\n calendarName: calendar?.name ?? tr('calendar.v2.aCalendar', 'a calendar'),\n answer: page.answerOf(event),\n iOrganise: isOrganizer(event, me),\n organizerName:\n nameOf(event.organizerId, organizerGuest?.name ?? null) ??\n tr('calendar.v2.theOrganiser', 'the organiser'),\n nameOf,\n when,\n };\n}\n\n/** The peek's heading: the sheet's title on phones (it names the dialog), else an h3. */\nfunction PeekTitle({ children, className }: { children: string; className: string }) {\n const { compact } = useCalendarPage();\n return compact ? (\n <BottomSheetTitle className={className}>{children}</BottomSheetTitle>\n ) : (\n <h3 className={className}>{children}</h3>\n );\n}\n\n/** Edit (or Edit locked, saying who can), Duplicate, Delete, ⋯ and close. */\nfunction PeekTools({ model }: { model: PeekModel }) {\n const page = useCalendarPage();\n const { tr } = page;\n const { basePath } = useCalendar();\n const notify = useNotify();\n const { event, look, calendar } = model;\n const lockReason = calendar?.isReadOnly\n ? tr(\n 'calendar.v2.lockedFollowed',\n 'It comes from {{calendar}}, a calendar you follow. Change it where it lives.',\n { calendar: model.calendarName }\n )\n : tr('calendar.v2.lockedOrganiser', 'Only {{name}}, the organiser, can change this event.', {\n name: model.organizerName,\n });\n const more: ActionMenuItem[] = [\n {\n id: 'ics',\n label: tr('calendar.v2.downloadEvent', 'Download (.ics)'),\n icon: Download,\n onSelect: () => void page.actions.downloadIcs(event),\n },\n {\n id: 'link',\n label: tr('calendar.v2.copyEventLink', 'Copy a link to it'),\n icon: Link2,\n onSelect: () =>\n void page.actions.copyText(\n `${window.location.origin}${calendarV2Href(basePath, 'week', {\n [SEARCH_PARAMS.event]: event.id,\n [SEARCH_PARAMS.date]: eventDays(event, page.timeZone).start,\n })}`,\n tr('calendar.v2.linkCopied', 'Link copied.')\n ),\n },\n ];\n if (event.isRecurring && look.editable) {\n more.push({\n id: 'series',\n label: tr('calendar.v2.deleteSeriesMenu', 'Delete the whole series…'),\n icon: Trash2,\n danger: true,\n separatorBefore: true,\n onSelect: () => {\n page.closePeek();\n void page.actions.remove(event);\n },\n });\n }\n return (\n <div className=\"flex shrink-0 items-center\">\n {look.editable ? (\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={tr('calendar.v2.edit', 'Edit')}\n title={tr('calendar.v2.edit', 'Edit')}\n onClick={() => page.openEventDialog({ eventId: event.id })}\n >\n <Pencil aria-hidden=\"true\" />\n </button>\n ) : (\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={tr('calendar.v2.editLocked', 'Edit (locked): {{reason}}', {\n reason: lockReason,\n })}\n title={lockReason}\n onClick={() => notify({ title: lockReason, tone: 'info' })}\n >\n <Lock aria-hidden=\"true\" />\n </button>\n )}\n {calendar && !calendar.isReadOnly ? (\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={tr('calendar.v2.duplicate', 'Duplicate')}\n title={tr('calendar.v2.duplicate', 'Duplicate')}\n onClick={() => {\n page.closePeek();\n void page.actions.duplicate(event);\n }}\n >\n <Copy aria-hidden=\"true\" />\n </button>\n ) : null}\n {look.editable ? (\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={tr('calendar.v2.delete', 'Delete')}\n title={tr('calendar.v2.delete', 'Delete')}\n onClick={() => {\n page.closePeek();\n void page.actions.remove(event);\n }}\n >\n <Trash2 aria-hidden=\"true\" />\n </button>\n ) : null}\n <ActionMenu\n items={more}\n placement=\"row\"\n label={tr('calendar.v2.moreForEvent', 'More for this event')}\n />\n <CloseButton />\n </div>\n );\n}\n\n/** When, \"Repeats\", and the time in the event's own zone when it isn't the calendar's. */\nfunction PeekWhen({ model }: { model: PeekModel }) {\n const { tr, format, timeZone } = useCalendarPage();\n const { event } = model;\n const ownZone =\n event.timeZone && event.timeZone !== timeZone && !event.allDay ? event.timeZone : null;\n return (\n <p className=\"mb-3 ps-[26px] text-sm text-text-secondary\">\n {model.when}\n {event.isRecurring ? (\n <span className=\"ms-1 inline-flex items-center gap-1\">\n · <Repeat className=\"size-3\" aria-hidden=\"true\" />\n {tr('calendar.v2.repeats', 'Repeats')}\n </span>\n ) : null}\n {ownZone ? (\n <span className=\"mt-0.5 block text-xs text-text-muted\">\n {tr('calendar.v2.inItsZone', '{{time}} in {{zone}}', {\n time: formatInstantRange(event.start, event.end, ownZone, format),\n zone: ownZone,\n })}\n </span>\n ) : null}\n </p>\n );\n}\n\n/** A room turned down or waiting, and a calendar followed by link (read-only). */\nfunction PeekNotices({ model }: { model: PeekModel }) {\n const { tr } = useCalendarPage();\n const room = eventRoom(model.event);\n const roomName = room?.name ?? tr('calendar.v2.theRoom', 'The room');\n return (\n <>\n {model.look.roomRefused && room ? (\n <Notice tone=\"warn\" icon={AlertTriangle}>\n <b>{tr('calendar.v2.roomRefusedTitle', 'Room not available.')}</b>{' '}\n {tr(\n 'calendar.v2.roomRefusedBody',\n '{{room}} turned down the booking. Pick another room in the event.',\n { room: roomName }\n )}\n </Notice>\n ) : null}\n {model.look.roomPending && room ? (\n <Notice tone=\"info\" icon={Clock3}>\n {tr('calendar.v2.roomPendingBody', '{{room}} is waiting for approval.', {\n room: roomName,\n })}\n </Notice>\n ) : null}\n {model.calendar?.isReadOnly ? (\n <Notice tone=\"lock\" icon={Lock}>\n {tr(\n 'calendar.v2.readOnlyNote',\n 'From {{calendar}}, a calendar you follow. You can’t change it here.',\n { calendar: model.calendarName }\n )}\n </Notice>\n ) : null}\n </>\n );\n}\n\n/** Join the call, its link, and Copy. */\nfunction PeekJoin({ event }: { event: CalendarEventV2 }) {\n const page = useCalendarPage();\n const { tr } = page;\n const url = joinUrl(event);\n if (!url) return null;\n return (\n <div className=\"flex items-center gap-2\">\n <Button asChild>\n <a href={url} target=\"_blank\" rel=\"noopener noreferrer\">\n <Video aria-hidden=\"true\" />\n {tr('calendar.v2.joinCall', 'Join the call')}\n </a>\n </Button>\n <span className=\"min-w-0 flex-1 truncate font-mono text-xs text-text-secondary\">\n {url.replace(/^https?:\\/\\//, '')}\n </span>\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={tr('calendar.v2.copyMeetingLink', 'Copy the meeting link')}\n onClick={() =>\n void page.actions.copyText(\n url,\n tr('calendar.v2.meetingLinkCopied', 'Meeting link copied.')\n )\n }\n >\n <Copy aria-hidden=\"true\" />\n </button>\n </div>\n );\n}\n\n/** The room, else the address. */\nfunction PeekPlace({ event }: { event: CalendarEventV2 }) {\n const { tr } = useCalendarPage();\n const room = eventRoom(event);\n if (room) {\n return (\n <Row icon={<Building2 aria-hidden=\"true\" />}>\n <b className=\"font-semibold\">{room.name ?? tr('calendar.v2.theRoom', 'The room')}</b>\n {room.location ? ` · ${room.location}` : ''}\n {room.capacity\n ? ` · ${tr('calendar.v2.seats', '{{count}} seats', { count: room.capacity })}`\n : ''}\n </Row>\n );\n }\n const physical = event.locationAddress || (event.location && event.locationType !== 'ONLINE');\n if (!physical) return null;\n return (\n <Row icon={<MapPin aria-hidden=\"true\" />}>\n {[event.location, event.locationAddress].filter(Boolean).join(', ')}\n </Row>\n );\n}\n\n/** How many people, how they answered, and the first few with their answers. */\nfunction PeekPeople({ model }: { model: PeekModel }) {\n const page = useCalendarPage();\n const { tr, me } = page;\n const { event, answer } = model;\n if (event.guests.length === 0) return null;\n const answerOf = (userId: string | null, response: EventResponseV2) =>\n userId === me && answer ? answer : response;\n const counts: Record<EventResponseV2, number> = {\n ACCEPTED: 0,\n TENTATIVE: 0,\n DECLINED: 0,\n NO_RESPONSE: 0,\n };\n for (const guest of event.guests) {\n counts[guest.organizer ? 'ACCEPTED' : answerOf(guest.userId, guest.response)] += 1;\n }\n const people = [...event.guests].sort((a, b) => Number(b.organizer) - Number(a.organizer));\n const tally = [\n counts.ACCEPTED\n ? tr('calendar.v2.countGoing', '{{count}} going', { count: counts.ACCEPTED })\n : '',\n counts.TENTATIVE\n ? tr('calendar.v2.countMaybe', '{{count}} maybe', { count: counts.TENTATIVE })\n : '',\n counts.NO_RESPONSE\n ? tr('calendar.v2.countWaiting', '{{count}} waiting', { count: counts.NO_RESPONSE })\n : '',\n counts.DECLINED\n ? tr('calendar.v2.countNotGoing', '{{count}} not going', { count: counts.DECLINED })\n : '',\n ]\n .filter(Boolean)\n .map((part) => ` · ${part}`)\n .join('');\n const hidden = people.length - PEOPLE_SHOWN;\n return (\n <Row icon={<Users aria-hidden=\"true\" />}>\n <div className=\"mb-1.5\">\n <b className=\"font-semibold\">\n {people.length === 1\n ? tr('calendar.v2.peopleOne', '1 person')\n : tr('calendar.v2.peopleMany', '{{count}} people', { count: people.length })}\n </b>\n <span className=\"text-text-secondary\">{tally}</span>\n </div>\n <ul className=\"flex flex-col gap-1.5\">\n {people.slice(0, PEOPLE_SHOWN).map((guest) => (\n <GuestRow\n key={guest.id}\n guest={guest}\n name={\n model.nameOf(guest.userId, guest.name) ??\n guest.email ??\n tr('calendar.v2.guest', 'Guest')\n }\n you={guest.userId === me}\n answer={answerOf(guest.userId, guest.response)}\n />\n ))}\n </ul>\n {hidden > 0 && model.look.editable ? (\n <button\n type=\"button\"\n className={cn('mt-1 text-xs font-semibold text-text-link hover:underline', FOCUS_RING)}\n onClick={() => page.openEventDialog({ eventId: event.id, tab: 'people' })}\n >\n {tr('calendar.v2.seeAll', 'See all {{count}}', { count: people.length })}\n </button>\n ) : null}\n {hidden > 0 && !model.look.editable ? (\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr('calendar.v2.andMore', 'and {{count}} more', { count: hidden })}\n </p>\n ) : null}\n </Row>\n );\n}\n\nfunction PeekReminders({ event }: { event: CalendarEventV2 }) {\n const { tr, durationWords } = useCalendarPage();\n if (event.reminders.length === 0) return null;\n const channelWords = (channel: string) => {\n if (channel === 'EMAIL') return tr('calendar.v2.channelEmail', 'Email');\n if (channel === 'SMS') return tr('calendar.v2.channelSms', 'Text message');\n return tr('calendar.v2.channelInApp', 'In app');\n };\n return (\n <Row icon={<Bell aria-hidden=\"true\" />}>\n {event.reminders.map((reminder) => (\n <div key={reminder.id}>\n {reminder.minutesBefore === 0\n ? tr('calendar.v2.reminderAtStart', 'When it starts')\n : tr('calendar.v2.reminderBefore', '{{time}} before', {\n time: formatDuration(reminder.minutesBefore, durationWords),\n })}\n {' · '}\n {channelWords(reminder.channel)}\n </div>\n ))}\n </Row>\n );\n}\n\n/** The calendar, who organises it, who sees its details, and \"Draft\". */\nfunction PeekCalendarLine({ model }: { model: PeekModel }) {\n const { tr } = useCalendarPage();\n const { event } = model;\n const parts = [\n model.calendarName,\n model.iOrganise\n ? tr('calendar.v2.youOrganise', 'you organise it')\n : tr('calendar.v2.organisedBy', 'organised by {{name}}', { name: model.organizerName }),\n ];\n if (event.visibility === 'PRIVATE') parts.push(tr('calendar.v2.private', 'Private'));\n if (event.visibility === 'CONFIDENTIAL') parts.push(tr('calendar.v2.busyOnlyLabel', 'Busy only'));\n if (event.status === 'DRAFT') parts.push(tr('calendar.v2.draft', 'Draft'));\n return <Row icon={<CalendarDays aria-hidden=\"true\" />}>{parts.join(' · ')}</Row>;\n}\n\n/** The notes (as plain text), and a word on repeating events until B7 expands them. */\nfunction PeekNotes({ event }: { event: CalendarEventV2 }) {\n const { tr } = useCalendarPage();\n return (\n <>\n {event.description ? (\n <Row icon={<FileText aria-hidden=\"true\" />}>\n <p className=\"break-words whitespace-pre-wrap\">{event.description}</p>\n </Row>\n ) : null}\n {event.isRecurring ? (\n <p className=\"text-xs text-text-muted\">\n {tr(\n 'calendar.v2.firstOccurrenceNote',\n 'Repeating events show their first date for now. Edit opens the whole series.'\n )}\n </p>\n ) : null}\n </>\n );\n}\n\n/** A guest answers Yes · Maybe · No; the organiser can look for a better time. */\nfunction PeekFooter({ model }: { model: PeekModel }) {\n const page = useCalendarPage();\n const { tr } = page;\n const { event, answer } = model;\n if (!model.iOrganise && answer !== null) {\n const value: Answer | 'none' = answer !== 'NO_RESPONSE' ? answer : 'none';\n return (\n <div className=\"flex flex-wrap items-center gap-2 border-t border-border-subtle p-3 ps-4\">\n <span className=\"text-sm font-semibold text-text-primary\">\n {tr('calendar.v2.goingQuestion', 'Going?')}\n </span>\n <Segmented<Answer | 'none'>\n aria-label={tr('calendar.v2.yourAnswer', 'Your answer')}\n fillOnPhone={false}\n value={value}\n onValueChange={(next) => {\n if (next !== 'none') void page.actions.respond(event, next);\n }}\n options={[\n { value: 'ACCEPTED', label: tr('calendar.v2.yes', 'Yes') },\n { value: 'TENTATIVE', label: tr('calendar.v2.maybe', 'Maybe') },\n { value: 'DECLINED', label: tr('calendar.v2.no', 'No') },\n ]}\n />\n {answer === 'NO_RESPONSE' ? (\n <span className=\"inline-flex items-center gap-1 text-xs text-text-secondary\">\n <CircleHelp className=\"size-3\" aria-hidden=\"true\" />\n {tr('calendar.v2.notAnswered', 'Not answered')}\n </span>\n ) : null}\n </div>\n );\n }\n if (!model.iOrganise || !model.look.editable) return null;\n return (\n <div className=\"flex flex-wrap items-center gap-2 border-t border-border-subtle p-3 ps-4\">\n <span className=\"inline-flex items-center gap-1.5 text-sm font-semibold text-text-primary\">\n <Crown className=\"size-3.5 text-action-primary-bg\" aria-hidden=\"true\" />\n {tr('calendar.v2.youOrganiseThis', 'You organise this')}\n </span>\n <span className=\"flex-1\" />\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => page.openFindTime(event.id)}>\n <Users aria-hidden=\"true\" />\n {tr('calendar.v2.findBetterTime', 'Find a better time')}\n </Button>\n </div>\n );\n}\n\n/** Someone else's private time: when, and that its details are private. */\nfunction BusyPeek({ model }: { model: PeekModel }) {\n const page = useCalendarPage();\n const { tr } = page;\n return (\n <>\n <div\n className=\"flex items-center gap-3 p-3 ps-4\"\n style={calendarHueStyle(page.hueOf(model.event.calendarId))}\n >\n <span aria-hidden=\"true\" className=\"size-3.5 shrink-0 rounded-[4px] bg-[var(--cal-hue)]\" />\n <PeekTitle className=\"min-w-0 flex-1 text-base font-bold text-text-primary\">\n {model.look.title}\n </PeekTitle>\n <CloseButton />\n </div>\n <div className=\"flex flex-col gap-3 px-4 pb-4\">\n <p className=\"ps-[26px] text-sm text-text-secondary\">{model.when}</p>\n <Row icon={<EyeOff aria-hidden=\"true\" />}>\n {tr(\n 'calendar.v2.privateDetails',\n 'Details are private. {{calendar}} shares only that this time is taken.',\n { calendar: model.calendarName }\n )}\n </Row>\n </div>\n </>\n );\n}\n\nexport function PeekEvent({ event }: { event: CalendarEventV2 }) {\n const page = useCalendarPage();\n const model = usePeekModel(event);\n if (model.look.busyOnly) return <BusyPeek model={model} />;\n return (\n <>\n <div\n className=\"flex items-start gap-3 p-3 ps-4\"\n style={calendarHueStyle(page.hueOf(event.calendarId))}\n >\n <span\n aria-hidden=\"true\"\n className=\"mt-1 size-3.5 shrink-0 rounded-[4px] bg-[var(--cal-hue)]\"\n />\n <PeekTitle className=\"min-w-0 flex-1 text-base leading-snug font-bold break-words text-text-primary\">\n {model.look.title}\n </PeekTitle>\n <PeekTools model={model} />\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto px-4 pb-4\">\n <PeekWhen model={model} />\n <div className=\"flex flex-col gap-3\">\n <PeekNotices model={model} />\n <PeekJoin event={event} />\n <PeekPlace event={event} />\n <PeekPeople model={model} />\n <PeekReminders event={event} />\n <PeekCalendarLine model={model} />\n <PeekNotes event={event} />\n </div>\n </div>\n <PeekFooter model={model} />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AE,UAAUa,EAAM,aAAa,CACjC;EACG,CAAA,CACF;CACL,CAAA,CAAA,EAAA,CAAA;AAEN;AAEA,SAAgBwE,GAAU,EAAE,YAAqC;CAC/D,IAAM3G,IAAOC,EAAgB,GACvBkC,IAAQpC,EAAaK,CAAK;CAEhC,OADI+B,EAAM,KAAK,WAAiB,kBAACqE,IAAD,EAAiB,SAAQ,CAAA,IAEvD,kBAAA3G,GAAA,EAAA,UAAA;EACE,kBAAC,OAAD;GACE,WAAU;GACV,OAAO4G,EAAiBzG,EAAK,MAAMI,EAAM,UAAU,CAAC;GAFtD,UAAA;IAIE,kBAAC,QAAD;KACE,eAAY;KACZ,WAAU;IACX,CAAA;IACD,kBAACwB,GAAD;KAAW,WAAU;KAClB,UAAAO,EAAM,KAAK;IACH,CAAA;IACX,kBAACH,IAAD,EAAkB,SAAQ,CAAA;GACvB;;EACL,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACmB,IAAD,EAAiB,SAAQ,CAAA,GACzB,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,kBAACG,IAAD,EAAoB,SAAQ,CAAA;KAC5B,kBAACQ,IAAD,EAAiB,SAAQ,CAAA;KACzB,kBAACK,IAAD,EAAkB,SAAQ,CAAA;KAC1B,kBAACI,IAAD,EAAmB,SAAQ,CAAA;KAC3B,kBAACe,IAAD,EAAsB,SAAQ,CAAA;KAC9B,kBAACO,GAAD,EAAyB,SAAQ,CAAA;KACjC,kBAACG,IAAD,EAAkB,SAAQ,CAAA;IACvB;GACF,CAAA,CAAA;;EACL,kBAACE,IAAD,EAAmB,SAAQ,CAAA;EAC1BlG,EAAK,UACJ,kBAAC4G,GAAD;GAAwB,WAAU;GAAW,UAAAzE,EAAM;EAA6B,CAAA,IAC9E;CACJ,EAAA,CAAA;AAEN"}
|
|
1
|
+
{"version":3,"file":"PeekEvent.js","names":["_Fragment","Fragment$1","PEOPLE_SHOWN","usePeekModel","page","useCalendarPage","useCalendar","calendar","event","userIds","useMemo","guest","id","profiles","useActorProfiles","nameOf","carried","profile","userId","organizerGuest","span","eventDays","timeZone","when","formatDayTimeSpan","format","tr","formatDay","instantToZoned","formatInstantRange","isOrganizer","me","PeekTitle","jsx","compact","BottomSheetTitle","PeekTools","notify","useNotify","model","lockReason","more","Download","Link2","calendarV2Href","basePath","SEARCH_PARAMS","look","Trash2","ICON_BUTTON","Pencil","Lock","Copy","ActionMenu","CloseButton","PeekWhen","ownZone","Repeat","PeekNotices","room","eventRoom","roomName","Notice","AlertTriangle","Clock3","PeekJoin","url","joinUrl","Button","Video","PeekPlace","Row","Building2","MapPin","PeekPeople","answerOf","answer","response","counts","people","b","a","tally","part","hidden","Users","GuestRow","cn","FOCUS_RING","PeekReminders","channelWords","channel","Bell","reminder","formatDuration","durationWords","PeekCalendarLine","parts","CalendarDays","PeekNotes","FileText","PeekFooter","value","Segmented","next","CircleHelp","Crown","BusyPeek","calendarHueStyle","EyeOff","PeekEvent","BottomSheetDescription"],"sources":["../../../src/v2/peek/PeekEvent.tsx"],"sourcesContent":["/**\n * An event's peek (BOFF-15698 A1), built from one small part per section: the header and its\n * tools (Edit or Edit locked with the organiser's name, Duplicate, Delete, ⋯), when, notices,\n * Join, the place, the people and their answers, reminders, the calendar line, the notes, and\n * the footer (Yes · Maybe · No for a guest, Find a better time for the organiser). Someone\n * else's private time shows only \"Busy\".\n */\nimport { useMemo } from 'react';\nimport {\n AlertTriangle,\n Bell,\n Building2,\n CalendarDays,\n CircleHelp,\n Clock3,\n Copy,\n Crown,\n Download,\n EyeOff,\n FileText,\n Link2,\n Lock,\n MapPin,\n Pencil,\n Repeat,\n Trash2,\n Users,\n Video,\n} from 'lucide-react';\nimport { useActorProfiles } from '@burdenoff/fe-libs/shared';\nimport {\n ActionMenu,\n BottomSheetDescription,\n BottomSheetTitle,\n Button,\n Notice,\n Segmented,\n useNotify,\n type ActionMenuItem,\n} from '@burdenoff/fe-libs/ui';\nimport { cn } from '@burdenoff/fe-libs/utils';\nimport { useCalendar } from '../../providers/CalendarProvider';\nimport { calendarHueStyle } from '../colors';\nimport type { Answer } from '../data/useEventActions';\nimport type { EventLook } from '../events/eventLook';\nimport { eventRoom, isOrganizer, joinUrl } from '../events/eventModel';\nimport { formatDay, formatDayTimeSpan, formatDuration, formatInstantRange } from '../format';\nimport { useCalendarPage } from '../page/CalendarPageContext';\nimport { calendarV2Href, SEARCH_PARAMS } from '../routes';\nimport { FOCUS_RING, ICON_BUTTON } from '../styles';\nimport { eventDays, instantToZoned } from '../time/calendarTime';\nimport type { CalendarEventV2, CalendarV2, EventResponseV2 } from '../types';\nimport { CloseButton, GuestRow, Row } from './PeekParts';\n\n/** Guests listed before \"See all\". */\nconst PEOPLE_SHOWN = 6;\n\n/** What every part of an event's peek reads. */\ninterface PeekModel {\n event: CalendarEventV2;\n look: EventLook;\n calendar: CalendarV2 | undefined;\n calendarName: string;\n /** The person's answer (one given here first); null when they organise it or aren't asked. */\n answer: EventResponseV2 | null;\n iOrganise: boolean;\n organizerName: string;\n /** A person's name: the one the event carries, else their workspace profile's. */\n nameOf: (userId: string | null, carried: string | null) => string | null;\n /**\n * \"Friday 20 Nov · 14:30 – 15:30\", \"Fri 20 Nov, 23:00 – Sat 21 Nov, 01:00\",\n * \"Mon 16 Nov – Fri 20 Nov · all day\".\n */\n when: string;\n}\n\nfunction usePeekModel(event: CalendarEventV2): PeekModel {\n const page = useCalendarPage();\n const { tr, format, timeZone, me } = page;\n const { apiGatewayUrl, authToken, workspaceId } = useCalendar();\n const calendar = page.calendarsById.get(event.calendarId);\n const userIds = useMemo(\n () =>\n [...new Set([event.organizerId, ...event.guests.map((guest) => guest.userId)])]\n .filter((id): id is string => Boolean(id))\n .map((actorId) => ({ actorId, actorType: 'user' })),\n [event.guests, event.organizerId]\n );\n const profiles = useActorProfiles(userIds, { apiGatewayUrl, authToken, workspaceId });\n const nameOf = (userId: string | null, carried: string | null): string | null => {\n if (carried) return carried;\n const profile = userId ? profiles[userId] : undefined;\n return profile?.resolved ? profile.displayName : null;\n };\n const organizerGuest = event.guests.find((guest) => guest.organizer) ?? null;\n const span = eventDays(event, timeZone);\n let when: string;\n if (!event.allDay && span.start !== span.end) {\n // Over midnight, or a day or more: both ends with their days.\n when = formatDayTimeSpan(event.start, event.end, timeZone, format);\n } else if (!event.allDay) {\n when = `${formatDay(instantToZoned(event.start, timeZone).date, format, 'mid')} · ${formatInstantRange(event.start, event.end, timeZone, format)}`;\n } else if (span.start === span.end) {\n when = tr('calendar.v2.whenAllDay', '{{day}} · all day', {\n day: formatDay(span.start, format, 'mid'),\n });\n } else {\n when = tr('calendar.v2.whenAllDays', '{{from}} – {{to}} · all day', {\n from: formatDay(span.start, format, 'short'),\n to: formatDay(span.end, format, 'short'),\n });\n }\n return {\n event,\n look: page.lookOf(event),\n calendar,\n calendarName: calendar?.name ?? tr('calendar.v2.aCalendar', 'a calendar'),\n answer: page.answerOf(event),\n iOrganise: isOrganizer(event, me),\n organizerName:\n nameOf(event.organizerId, organizerGuest?.name ?? null) ??\n tr('calendar.v2.theOrganiser', 'the organiser'),\n nameOf,\n when,\n };\n}\n\n/** The peek's heading: the sheet's title on phones (it names the dialog), else an h3. */\nfunction PeekTitle({ children, className }: { children: string; className: string }) {\n const { compact } = useCalendarPage();\n return compact ? (\n <BottomSheetTitle className={className}>{children}</BottomSheetTitle>\n ) : (\n <h3 className={className}>{children}</h3>\n );\n}\n\n/** Edit (or Edit locked, saying who can), Duplicate, Delete, ⋯ and close. */\nfunction PeekTools({ model }: { model: PeekModel }) {\n const page = useCalendarPage();\n const { tr } = page;\n const { basePath } = useCalendar();\n const notify = useNotify();\n const { event, look, calendar } = model;\n const lockReason = calendar?.isReadOnly\n ? tr(\n 'calendar.v2.lockedFollowed',\n 'It comes from {{calendar}}, a calendar you follow. Change it where it lives.',\n { calendar: model.calendarName }\n )\n : tr('calendar.v2.lockedOrganiser', 'Only {{name}}, the organiser, can change this event.', {\n name: model.organizerName,\n });\n const more: ActionMenuItem[] = [\n {\n id: 'ics',\n label: tr('calendar.v2.downloadEvent', 'Download (.ics)'),\n icon: Download,\n onSelect: () => void page.actions.downloadIcs(event),\n },\n {\n id: 'link',\n label: tr('calendar.v2.copyEventLink', 'Copy a link to it'),\n icon: Link2,\n onSelect: () =>\n void page.actions.copyText(\n `${window.location.origin}${calendarV2Href(basePath, 'week', {\n [SEARCH_PARAMS.event]: event.id,\n [SEARCH_PARAMS.date]: eventDays(event, page.timeZone).start,\n })}`,\n tr('calendar.v2.linkCopied', 'Link copied.')\n ),\n },\n ];\n if (event.isRecurring && look.editable) {\n more.push({\n id: 'series',\n label: tr('calendar.v2.deleteSeriesMenu', 'Delete the whole series…'),\n icon: Trash2,\n danger: true,\n separatorBefore: true,\n onSelect: () => {\n page.closePeek();\n void page.actions.remove(event);\n },\n });\n }\n return (\n <div className=\"flex shrink-0 items-center\">\n {look.editable ? (\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={tr('calendar.v2.edit', 'Edit')}\n title={tr('calendar.v2.edit', 'Edit')}\n onClick={() => page.openEventDialog({ eventId: event.id })}\n >\n <Pencil aria-hidden=\"true\" />\n </button>\n ) : (\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={tr('calendar.v2.editLocked', 'Edit (locked): {{reason}}', {\n reason: lockReason,\n })}\n title={lockReason}\n onClick={() => notify({ title: lockReason, tone: 'info' })}\n >\n <Lock aria-hidden=\"true\" />\n </button>\n )}\n {calendar && !calendar.isReadOnly ? (\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={tr('calendar.v2.duplicate', 'Duplicate')}\n title={tr('calendar.v2.duplicate', 'Duplicate')}\n onClick={() => {\n page.closePeek();\n void page.actions.duplicate(event);\n }}\n >\n <Copy aria-hidden=\"true\" />\n </button>\n ) : null}\n {look.editable ? (\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={tr('calendar.v2.delete', 'Delete')}\n title={tr('calendar.v2.delete', 'Delete')}\n onClick={() => {\n page.closePeek();\n void page.actions.remove(event);\n }}\n >\n <Trash2 aria-hidden=\"true\" />\n </button>\n ) : null}\n <ActionMenu\n items={more}\n placement=\"row\"\n label={tr('calendar.v2.moreForEvent', 'More for this event')}\n />\n <CloseButton />\n </div>\n );\n}\n\n/** When, \"Repeats\", and the time in the event's own zone when it isn't the calendar's. */\nfunction PeekWhen({ model }: { model: PeekModel }) {\n const { tr, format, timeZone } = useCalendarPage();\n const { event } = model;\n const ownZone =\n event.timeZone && event.timeZone !== timeZone && !event.allDay ? event.timeZone : null;\n return (\n <p className=\"mb-3 ps-[26px] text-sm text-text-secondary\">\n {model.when}\n {event.isRecurring ? (\n <span className=\"ms-1 inline-flex items-center gap-1\">\n · <Repeat className=\"size-3\" aria-hidden=\"true\" />\n {tr('calendar.v2.repeats', 'Repeats')}\n </span>\n ) : null}\n {ownZone ? (\n <span className=\"mt-0.5 block text-xs text-text-muted\">\n {tr('calendar.v2.inItsZone', '{{time}} in {{zone}}', {\n time: formatInstantRange(event.start, event.end, ownZone, format),\n zone: ownZone,\n })}\n </span>\n ) : null}\n </p>\n );\n}\n\n/** A room turned down or waiting, and a calendar followed by link (read-only). */\nfunction PeekNotices({ model }: { model: PeekModel }) {\n const { tr } = useCalendarPage();\n const room = eventRoom(model.event);\n const roomName = room?.name ?? tr('calendar.v2.theRoom', 'The room');\n return (\n <>\n {model.look.roomRefused && room ? (\n <Notice tone=\"warn\" icon={AlertTriangle}>\n <b>{tr('calendar.v2.roomRefusedTitle', 'Room not available.')}</b>{' '}\n {tr(\n 'calendar.v2.roomRefusedBody',\n '{{room}} turned down the booking. Pick another room in the event.',\n { room: roomName }\n )}\n </Notice>\n ) : null}\n {model.look.roomPending && room ? (\n <Notice tone=\"info\" icon={Clock3}>\n {tr('calendar.v2.roomPendingBody', '{{room}} is waiting for approval.', {\n room: roomName,\n })}\n </Notice>\n ) : null}\n {model.calendar?.isReadOnly ? (\n <Notice tone=\"lock\" icon={Lock}>\n {tr(\n 'calendar.v2.readOnlyNote',\n 'From {{calendar}}, a calendar you follow. You can’t change it here.',\n { calendar: model.calendarName }\n )}\n </Notice>\n ) : null}\n </>\n );\n}\n\n/** Join the call, its link, and Copy. */\nfunction PeekJoin({ event }: { event: CalendarEventV2 }) {\n const page = useCalendarPage();\n const { tr } = page;\n const url = joinUrl(event);\n if (!url) return null;\n return (\n <div className=\"flex items-center gap-2\">\n <Button asChild>\n <a href={url} target=\"_blank\" rel=\"noopener noreferrer\">\n <Video aria-hidden=\"true\" />\n {tr('calendar.v2.joinCall', 'Join the call')}\n </a>\n </Button>\n <span className=\"min-w-0 flex-1 truncate font-mono text-xs text-text-secondary\">\n {url.replace(/^https?:\\/\\//, '')}\n </span>\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={tr('calendar.v2.copyMeetingLink', 'Copy the meeting link')}\n onClick={() =>\n void page.actions.copyText(\n url,\n tr('calendar.v2.meetingLinkCopied', 'Meeting link copied.')\n )\n }\n >\n <Copy aria-hidden=\"true\" />\n </button>\n </div>\n );\n}\n\n/** The room, else the address. */\nfunction PeekPlace({ event }: { event: CalendarEventV2 }) {\n const { tr } = useCalendarPage();\n const room = eventRoom(event);\n if (room) {\n return (\n <Row icon={<Building2 aria-hidden=\"true\" />}>\n <b className=\"font-semibold\">{room.name ?? tr('calendar.v2.theRoom', 'The room')}</b>\n {room.location ? ` · ${room.location}` : ''}\n {room.capacity\n ? ` · ${tr('calendar.v2.seats', '{{count}} seats', { count: room.capacity })}`\n : ''}\n </Row>\n );\n }\n const physical = event.locationAddress || (event.location && event.locationType !== 'ONLINE');\n if (!physical) return null;\n return (\n <Row icon={<MapPin aria-hidden=\"true\" />}>\n {[event.location, event.locationAddress].filter(Boolean).join(', ')}\n </Row>\n );\n}\n\n/** How many people, how they answered, and the first few with their answers. */\nfunction PeekPeople({ model }: { model: PeekModel }) {\n const page = useCalendarPage();\n const { tr, me } = page;\n const { event, answer } = model;\n if (event.guests.length === 0) return null;\n const answerOf = (userId: string | null, response: EventResponseV2) =>\n userId === me && answer ? answer : response;\n const counts: Record<EventResponseV2, number> = {\n ACCEPTED: 0,\n TENTATIVE: 0,\n DECLINED: 0,\n NO_RESPONSE: 0,\n };\n for (const guest of event.guests) {\n counts[guest.organizer ? 'ACCEPTED' : answerOf(guest.userId, guest.response)] += 1;\n }\n const people = [...event.guests].sort((a, b) => Number(b.organizer) - Number(a.organizer));\n const tally = [\n counts.ACCEPTED\n ? tr('calendar.v2.countGoing', '{{count}} going', { count: counts.ACCEPTED })\n : '',\n counts.TENTATIVE\n ? tr('calendar.v2.countMaybe', '{{count}} maybe', { count: counts.TENTATIVE })\n : '',\n counts.NO_RESPONSE\n ? tr('calendar.v2.countWaiting', '{{count}} waiting', { count: counts.NO_RESPONSE })\n : '',\n counts.DECLINED\n ? tr('calendar.v2.countNotGoing', '{{count}} not going', { count: counts.DECLINED })\n : '',\n ]\n .filter(Boolean)\n .map((part) => ` · ${part}`)\n .join('');\n const hidden = people.length - PEOPLE_SHOWN;\n return (\n <Row icon={<Users aria-hidden=\"true\" />}>\n <div className=\"mb-1.5\">\n <b className=\"font-semibold\">\n {people.length === 1\n ? tr('calendar.v2.peopleOne', '1 person')\n : tr('calendar.v2.peopleMany', '{{count}} people', { count: people.length })}\n </b>\n <span className=\"text-text-secondary\">{tally}</span>\n </div>\n <ul className=\"flex flex-col gap-1.5\">\n {people.slice(0, PEOPLE_SHOWN).map((guest) => (\n <GuestRow\n key={guest.id}\n guest={guest}\n name={\n model.nameOf(guest.userId, guest.name) ??\n guest.email ??\n tr('calendar.v2.guest', 'Guest')\n }\n you={guest.userId === me}\n answer={answerOf(guest.userId, guest.response)}\n />\n ))}\n </ul>\n {hidden > 0 && model.look.editable ? (\n <button\n type=\"button\"\n className={cn('mt-1 text-xs font-semibold text-text-link hover:underline', FOCUS_RING)}\n onClick={() => page.openEventDialog({ eventId: event.id, tab: 'people' })}\n >\n {tr('calendar.v2.seeAll', 'See all {{count}}', { count: people.length })}\n </button>\n ) : null}\n {hidden > 0 && !model.look.editable ? (\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr('calendar.v2.andMore', 'and {{count}} more', { count: hidden })}\n </p>\n ) : null}\n </Row>\n );\n}\n\nfunction PeekReminders({ event }: { event: CalendarEventV2 }) {\n const { tr, durationWords } = useCalendarPage();\n if (event.reminders.length === 0) return null;\n const channelWords = (channel: string) => {\n if (channel === 'EMAIL') return tr('calendar.v2.channelEmail', 'Email');\n if (channel === 'SMS') return tr('calendar.v2.channelSms', 'Text message');\n return tr('calendar.v2.channelInApp', 'In app');\n };\n return (\n <Row icon={<Bell aria-hidden=\"true\" />}>\n {event.reminders.map((reminder) => (\n <div key={reminder.id}>\n {reminder.minutesBefore === 0\n ? tr('calendar.v2.reminderAtStart', 'When it starts')\n : tr('calendar.v2.reminderBefore', '{{time}} before', {\n time: formatDuration(reminder.minutesBefore, durationWords),\n })}\n {' · '}\n {channelWords(reminder.channel)}\n </div>\n ))}\n </Row>\n );\n}\n\n/** The calendar, who organises it, who sees its details, and \"Draft\". */\nfunction PeekCalendarLine({ model }: { model: PeekModel }) {\n const { tr } = useCalendarPage();\n const { event } = model;\n const parts = [\n model.calendarName,\n model.iOrganise\n ? tr('calendar.v2.youOrganise', 'you organise it')\n : tr('calendar.v2.organisedBy', 'organised by {{name}}', { name: model.organizerName }),\n ];\n if (event.visibility === 'PRIVATE') parts.push(tr('calendar.v2.private', 'Private'));\n if (event.visibility === 'CONFIDENTIAL') parts.push(tr('calendar.v2.busyOnlyLabel', 'Busy only'));\n if (event.status === 'DRAFT') parts.push(tr('calendar.v2.draft', 'Draft'));\n return <Row icon={<CalendarDays aria-hidden=\"true\" />}>{parts.join(' · ')}</Row>;\n}\n\n/** The notes (as plain text), and a word on repeating events until B7 expands them. */\nfunction PeekNotes({ event }: { event: CalendarEventV2 }) {\n const { tr } = useCalendarPage();\n return (\n <>\n {event.description ? (\n <Row icon={<FileText aria-hidden=\"true\" />}>\n <p className=\"break-words whitespace-pre-wrap\">{event.description}</p>\n </Row>\n ) : null}\n {event.isRecurring ? (\n <p className=\"text-xs text-text-muted\">\n {tr(\n 'calendar.v2.firstOccurrenceNote',\n 'Repeating events show their first date for now. Edit opens the whole series.'\n )}\n </p>\n ) : null}\n </>\n );\n}\n\n/** A guest answers Yes · Maybe · No; the organiser can look for a better time. */\nfunction PeekFooter({ model }: { model: PeekModel }) {\n const page = useCalendarPage();\n const { tr } = page;\n const { event, answer } = model;\n if (!model.iOrganise && answer !== null) {\n const value: Answer | 'none' = answer !== 'NO_RESPONSE' ? answer : 'none';\n return (\n <div className=\"flex flex-wrap items-center gap-2 border-t border-border-subtle p-3 ps-4\">\n <span className=\"text-sm font-semibold text-text-primary\">\n {tr('calendar.v2.goingQuestion', 'Going?')}\n </span>\n <Segmented<Answer | 'none'>\n aria-label={tr('calendar.v2.yourAnswer', 'Your answer')}\n fillOnPhone={false}\n value={value}\n onValueChange={(next) => {\n if (next !== 'none') void page.actions.respond(event, next);\n }}\n options={[\n { value: 'ACCEPTED', label: tr('calendar.v2.yes', 'Yes') },\n { value: 'TENTATIVE', label: tr('calendar.v2.maybe', 'Maybe') },\n { value: 'DECLINED', label: tr('calendar.v2.no', 'No') },\n ]}\n />\n {answer === 'NO_RESPONSE' ? (\n <span className=\"inline-flex items-center gap-1 text-xs text-text-secondary\">\n <CircleHelp className=\"size-3\" aria-hidden=\"true\" />\n {tr('calendar.v2.notAnswered', 'Not answered')}\n </span>\n ) : null}\n </div>\n );\n }\n if (!model.iOrganise || !model.look.editable) return null;\n return (\n <div className=\"flex flex-wrap items-center gap-2 border-t border-border-subtle p-3 ps-4\">\n <span className=\"inline-flex items-center gap-1.5 text-sm font-semibold text-text-primary\">\n <Crown className=\"size-3.5 text-action-primary-bg\" aria-hidden=\"true\" />\n {tr('calendar.v2.youOrganiseThis', 'You organise this')}\n </span>\n <span className=\"flex-1\" />\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => page.openFindTime(event.id)}>\n <Users aria-hidden=\"true\" />\n {tr('calendar.v2.findBetterTime', 'Find a better time')}\n </Button>\n </div>\n );\n}\n\n/** Someone else's private time: when, and that its details are private. */\nfunction BusyPeek({ model }: { model: PeekModel }) {\n const page = useCalendarPage();\n const { tr } = page;\n return (\n <>\n <div\n className=\"flex items-center gap-3 p-3 ps-4\"\n style={calendarHueStyle(page.hueOf(model.event.calendarId))}\n >\n <span aria-hidden=\"true\" className=\"size-3.5 shrink-0 rounded-[4px] bg-[var(--cal-hue)]\" />\n <PeekTitle className=\"min-w-0 flex-1 text-base font-bold text-text-primary\">\n {model.look.title}\n </PeekTitle>\n <CloseButton />\n </div>\n <div className=\"flex flex-col gap-3 px-4 pb-4\">\n <p className=\"ps-[26px] text-sm text-text-secondary\">{model.when}</p>\n <Row icon={<EyeOff aria-hidden=\"true\" />}>\n {tr(\n 'calendar.v2.privateDetails',\n 'Details are private. {{calendar}} shares only that this time is taken.',\n { calendar: model.calendarName }\n )}\n </Row>\n </div>\n </>\n );\n}\n\nexport function PeekEvent({ event }: { event: CalendarEventV2 }) {\n const page = useCalendarPage();\n const model = usePeekModel(event);\n if (model.look.busyOnly) return <BusyPeek model={model} />;\n return (\n <>\n <div\n className=\"flex items-start gap-3 p-3 ps-4\"\n style={calendarHueStyle(page.hueOf(event.calendarId))}\n >\n <span\n aria-hidden=\"true\"\n className=\"mt-1 size-3.5 shrink-0 rounded-[4px] bg-[var(--cal-hue)]\"\n />\n <PeekTitle className=\"min-w-0 flex-1 text-base leading-snug font-bold break-words text-text-primary\">\n {model.look.title}\n </PeekTitle>\n <PeekTools model={model} />\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto px-4 pb-4\">\n <PeekWhen model={model} />\n <div className=\"flex flex-col gap-3\">\n <PeekNotices model={model} />\n <PeekJoin event={event} />\n <PeekPlace event={event} />\n <PeekPeople model={model} />\n <PeekReminders event={event} />\n <PeekCalendarLine model={model} />\n <PeekNotes event={event} />\n </div>\n </div>\n <PeekFooter model={model} />\n {page.compact ? (\n <BottomSheetDescription className=\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