@burdenoff/microfe-calendar 2026.1124.1 → 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 +658 -0
- package/dist/generated/wspace-operations.js +179 -6
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +1243 -10
- package/dist/hooks/useSafePermissions.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/pages/ResourcesPage.js.map +1 -1
- package/dist/providers/CalendarProvider.d.ts +3 -1
- package/dist/providers/CalendarProvider.js +12 -10
- package/dist/providers/CalendarProvider.js.map +1 -1
- package/dist/translations/en.d.ts +291 -1
- package/dist/types/index.d.ts +9 -0
- package/dist/v2/CalendarPageV2.js +44 -39
- 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/grid/GridParts.js +100 -94
- package/dist/v2/grid/GridParts.js.map +1 -1
- package/dist/v2/grid/TimeGrid.js +98 -89
- package/dist/v2/grid/TimeGrid.js.map +1 -1
- package/dist/v2/list/ListViewV2.d.ts +6 -2
- package/dist/v2/list/ListViewV2.js +50 -44
- package/dist/v2/list/ListViewV2.js.map +1 -1
- package/dist/v2/month/MonthView.js +130 -126
- package/dist/v2/month/MonthView.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 +54 -80
- package/dist/v2/rail/CalendarRail.js.map +1 -1
- package/dist/v2/runs/RunPeek.d.ts +2 -0
- package/dist/v2/runs/RunPeek.js +382 -0
- package/dist/v2/runs/RunPeek.js.map +1 -0
- package/dist/v2/runs/RunPills.d.ts +28 -0
- package/dist/v2/runs/RunPills.js +179 -0
- package/dist/v2/runs/RunPills.js.map +1 -0
- package/dist/v2/runs/RunRows.d.ts +21 -0
- package/dist/v2/runs/RunRows.js +140 -0
- package/dist/v2/runs/RunRows.js.map +1 -0
- package/dist/v2/runs/RunsNotices.d.ts +1 -0
- package/dist/v2/runs/RunsNotices.js +37 -0
- package/dist/v2/runs/RunsNotices.js.map +1 -0
- package/dist/v2/runs/RunsSwitch.d.ts +1 -0
- package/dist/v2/runs/RunsSwitch.js +54 -0
- package/dist/v2/runs/RunsSwitch.js.map +1 -0
- package/dist/v2/runs/WorkflowRunsLayer.d.ts +4 -0
- package/dist/v2/runs/WorkflowRunsLayer.js +82 -0
- package/dist/v2/runs/WorkflowRunsLayer.js.map +1 -0
- package/dist/v2/runs/runAccess.d.ts +37 -0
- package/dist/v2/runs/runAccess.js +14 -0
- package/dist/v2/runs/runAccess.js.map +1 -0
- package/dist/v2/runs/runLayout.d.ts +76 -0
- package/dist/v2/runs/runLayout.js +129 -0
- package/dist/v2/runs/runLayout.js.map +1 -0
- package/dist/v2/runs/runLinks.d.ts +32 -0
- package/dist/v2/runs/runLinks.js +50 -0
- package/dist/v2/runs/runLinks.js.map +1 -0
- package/dist/v2/runs/runModel.d.ts +97 -0
- package/dist/v2/runs/runModel.js +132 -0
- package/dist/v2/runs/runModel.js.map +1 -0
- package/dist/v2/runs/runPeekState.d.ts +53 -0
- package/dist/v2/runs/runPeekState.js +62 -0
- package/dist/v2/runs/runPeekState.js.map +1 -0
- package/dist/v2/runs/runTypes.d.ts +60 -0
- package/dist/v2/runs/runWords.d.ts +23 -0
- package/dist/v2/runs/runWords.js +83 -0
- package/dist/v2/runs/runWords.js.map +1 -0
- package/dist/v2/runs/runsLayerContext.d.ts +26 -0
- package/dist/v2/runs/runsLayerContext.js +33 -0
- package/dist/v2/runs/runsLayerContext.js.map +1 -0
- package/dist/v2/runs/useRunHrefs.d.ts +10 -0
- package/dist/v2/runs/useRunHrefs.js +60 -0
- package/dist/v2/runs/useRunHrefs.js.map +1 -0
- package/dist/v2/runs/useRunLabels.d.ts +6 -0
- package/dist/v2/runs/useRunLabels.js +27 -0
- package/dist/v2/runs/useRunLabels.js.map +1 -0
- package/dist/v2/runs/useRunsAccess.d.ts +2 -0
- package/dist/v2/runs/useRunsAccess.js +14 -0
- package/dist/v2/runs/useRunsAccess.js.map +1 -0
- package/dist/v2/runs/useWorkflowRuns.d.ts +61 -0
- package/dist/v2/runs/useWorkflowRuns.js +119 -0
- package/dist/v2/runs/useWorkflowRuns.js.map +1 -0
- 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,MAAS,OAAOH,EAAQC,GAAOG,GAAMF,IAAQ,CAAC,IAAIC;AAC3D;AASA,SAASE,EAAU,GAAgB,GAAgB;CACjD,OACEf,EAAeE,CAAK,KACpBc,EAAG,gCAAgC,4DAA4D;AAEnG;AAGA,SAASC,EAAc,GAAyB,GAA+B;CAC7E,OAAOC,EAAS,kBAAkB,IAC9BC,EAAI,GAAG,+BAA+B,g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,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;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,CAEvE,KAAYH;AACrB;AAE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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,CAEvE,KAAYH;AACrB;AAEA,IAAMI,oBAAU,IAAI,IAAiC;AAErD,SAASC,EACP,GACA,GACqB;CACrB,IAAMC,IAAM,GAAGC,KAAU,GAAG,GAAG,KAAK,UAAUC,CAAO,KACjDC,IAASL,EAAQ,IAAIE,CAAG;CAC5B,IAAI,CAACG,GAAQ;EACX,IAAI;GACF,IAAS,IAAI,KAAK,eAAeF,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AC,QAAQ,eAAe,OAAOhB,CAAO,CAAC,EAC7D,CAApBgB,MAAU,IAAeE,EAAM,UAC5BlB,MAAY,IAASkB,EAAM,QAAcA,EAAM,YADZ;AAE5C"}
|
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
import { calendarHueStyle as e } from "../colors.js";
|
|
2
2
|
import { formatDay as t, formatDuration as n, formatMinuteRange as r, formatMinutes as i } from "../format.js";
|
|
3
3
|
import { useCalendarPage as a } from "../page/CalendarPageContext.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
4
|
+
import { DayRunPills as o } from "../runs/RunPills.js";
|
|
5
|
+
import { FOCUS_RING as s } from "../styles.js";
|
|
6
|
+
import { isWeekendDay as c } from "../time/calendarTime.js";
|
|
7
|
+
import { EventBlock as l } from "./EventBlock.js";
|
|
8
|
+
import { minuteOffset as u } from "./geometry.js";
|
|
9
|
+
import { offHours as d } from "./workingHours.js";
|
|
10
|
+
import { CalendarPlus as f, Plus as p } from "lucide-react";
|
|
11
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
12
|
+
import { Button as _, EmptyState as v, formatTimeZoneOffset as y } from "@burdenoff/fe-libs/ui";
|
|
13
|
+
import { cn as b } from "@burdenoff/fe-libs/utils";
|
|
13
14
|
// src/v2/grid/GridParts.tsx
|
|
14
|
-
var
|
|
15
|
-
function
|
|
16
|
-
let t = a(), { tr: n, format: r, timeZone: i, compact:
|
|
17
|
-
return /* @__PURE__ */
|
|
15
|
+
var x = Array.from({ length: 24 }, (e, t) => t);
|
|
16
|
+
function S({ columnsStyle: e }) {
|
|
17
|
+
let t = a(), { tr: n, format: r, timeZone: i, compact: o, days: c, today: l, nav: u } = t, d = y(i, t.now, r.locale), f = n("calendar.v2.timeZoneButton", "Time zone: {{zone}}", { zone: i });
|
|
18
|
+
return /* @__PURE__ */ g("div", {
|
|
18
19
|
className: "grid border-b border-border-subtle",
|
|
19
20
|
style: e,
|
|
20
|
-
children: [/* @__PURE__ */
|
|
21
|
+
children: [/* @__PURE__ */ h("div", {
|
|
21
22
|
className: "flex items-end justify-end pe-1 pb-1.5",
|
|
22
|
-
children: /* @__PURE__ */
|
|
23
|
+
children: /* @__PURE__ */ h("button", {
|
|
23
24
|
type: "button",
|
|
24
25
|
onClick: () => u.openDialog("settings"),
|
|
25
26
|
title: f,
|
|
26
27
|
"aria-label": f,
|
|
27
|
-
className:
|
|
28
|
-
children:
|
|
28
|
+
className: b("rounded px-[3px] py-0.5 text-[10px] whitespace-nowrap tabular-nums text-text-muted hover:bg-bg-sunken hover:text-text-primary", s),
|
|
29
|
+
children: o ? d.replace(/^[^+−-]*/, "") : d
|
|
29
30
|
})
|
|
30
|
-
}), c.map((e) => /* @__PURE__ */
|
|
31
|
+
}), c.map((e) => /* @__PURE__ */ h(C, {
|
|
31
32
|
day: e,
|
|
32
33
|
isToday: e === l
|
|
33
34
|
}, e))]
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
-
let { tr: r, format: i, compact:
|
|
38
|
-
return /* @__PURE__ */
|
|
37
|
+
function C({ day: e, isToday: n }) {
|
|
38
|
+
let { tr: r, format: i, compact: o, nav: l } = a(), u = c(e), d = n ? "today" : u ? "weekend" : "day";
|
|
39
|
+
return /* @__PURE__ */ g("button", {
|
|
39
40
|
type: "button",
|
|
40
41
|
onClick: () => l.goTo({
|
|
41
42
|
view: "day",
|
|
@@ -43,143 +44,148 @@ function S({ day: e, isToday: n }) {
|
|
|
43
44
|
}),
|
|
44
45
|
"aria-current": n ? "date" : void 0,
|
|
45
46
|
"aria-label": r("calendar.v2.openDay", "{{day}}. Open the day", { day: t(e, i, "full") }),
|
|
46
|
-
className:
|
|
47
|
-
children: [/* @__PURE__ */
|
|
48
|
-
className:
|
|
47
|
+
className: b("flex min-w-0 items-center justify-center gap-1.5 border-s border-border-subtle px-0.5 py-[7px] hover:bg-bg-sunken", o && "flex-col gap-px py-[5px]", s),
|
|
48
|
+
children: [/* @__PURE__ */ h("span", {
|
|
49
|
+
className: b("text-[11px] font-semibold uppercase tracking-[0.06em]", d === "today" && "text-action-primary-bg", d === "weekend" && "text-text-muted", d === "day" && "text-text-secondary"),
|
|
49
50
|
children: t(e, i, "weekday")
|
|
50
|
-
}), /* @__PURE__ */
|
|
51
|
-
className:
|
|
51
|
+
}), /* @__PURE__ */ h("span", {
|
|
52
|
+
className: b("grid h-[30px] min-w-[30px] place-items-center rounded-full px-1 text-lg font-semibold tabular-nums", o && "h-7 min-w-7 text-base", d === "today" && "bg-action-primary-bg text-action-primary-text", d === "weekend" && "text-text-muted", d === "day" && "text-text-primary"),
|
|
52
53
|
children: t(e, i, "dayNumber")
|
|
53
54
|
})]
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
+
function w({ hourHeight: e }) {
|
|
57
58
|
let { format: t, days: n, today: r, nowMinute: o } = a(), s = n.includes(r);
|
|
58
|
-
return /* @__PURE__ */
|
|
59
|
+
return /* @__PURE__ */ g("div", {
|
|
59
60
|
className: "relative",
|
|
60
61
|
"aria-hidden": "true",
|
|
61
|
-
children: [
|
|
62
|
+
children: [x.map((n) => n === 0 || s && Math.abs(n * 60 - o) < 13 ? null : /* @__PURE__ */ h("span", {
|
|
62
63
|
className: "absolute end-[7px] -translate-y-1/2 text-[11px] leading-none whitespace-nowrap tabular-nums text-text-muted",
|
|
63
64
|
style: { top: n * e },
|
|
64
65
|
children: i(n * 60, t)
|
|
65
|
-
}, n)), s ? /* @__PURE__ */
|
|
66
|
+
}, n)), s ? /* @__PURE__ */ h("span", {
|
|
66
67
|
className: "absolute end-[3px] z-[4] -translate-y-1/2 rounded-full bg-action-primary-bg px-[5px] py-[3px] text-[10.5px] leading-none font-bold whitespace-nowrap tabular-nums text-action-primary-text",
|
|
67
|
-
style: { top:
|
|
68
|
+
style: { top: u(o, e) },
|
|
68
69
|
children: i(o, t)
|
|
69
70
|
}) : null]
|
|
70
71
|
});
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
+
function T({ day: e, hourHeight: t }) {
|
|
73
74
|
let { workingHoursOn: n } = a(), r = n(e);
|
|
74
|
-
return r === void 0 ? null : /* @__PURE__ */ m
|
|
75
|
+
return r === void 0 ? null : /* @__PURE__ */ h(m, { children: d(r).map((e) => /* @__PURE__ */ h("div", {
|
|
75
76
|
className: "pointer-events-none absolute inset-x-0 bg-bg-sunken/70",
|
|
76
77
|
style: {
|
|
77
|
-
top:
|
|
78
|
-
height:
|
|
78
|
+
top: u(e.start, t),
|
|
79
|
+
height: u(e.end - e.start, t)
|
|
79
80
|
}
|
|
80
81
|
}, e.start)) });
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function E({ isToday: e, hourHeight: t }) {
|
|
83
84
|
let { nowMinute: n } = a();
|
|
84
|
-
return /* @__PURE__ */
|
|
85
|
+
return /* @__PURE__ */ h("div", {
|
|
85
86
|
"aria-hidden": "true",
|
|
86
|
-
className:
|
|
87
|
-
style: { top:
|
|
87
|
+
className: b("pointer-events-none absolute inset-x-0", e ? "-start-px z-[5] -mt-px h-0.5 bg-action-primary-bg before:absolute before:-start-[5px] before:-top-1 before:size-2.5 before:rounded-full before:bg-action-primary-bg" : "z-[2] h-px bg-[color-mix(in_oklab,var(--color-action-primary-bg)_40%,transparent)]"),
|
|
88
|
+
style: { top: u(n, t) }
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
-
let
|
|
91
|
+
function D({ day: i, placed: s, hourHeight: c, selectedId: d, onOpen: f, onKeyDown: p, consumeClick: m, ghost: _, quick: v, cursorMinute: y }) {
|
|
92
|
+
let x = a(), { tr: S, format: C, compact: w, today: D, days: k } = x, A = i === D, j = {
|
|
92
93
|
backgroundImage: "linear-gradient(to bottom, var(--color-border-subtle) 1px, transparent 1px), linear-gradient(to bottom, color-mix(in oklab, var(--color-border-subtle) 45%, transparent) 1px, transparent 1px)",
|
|
93
|
-
backgroundSize: `100% ${
|
|
94
|
-
backgroundPosition: `0 0, 0 ${
|
|
94
|
+
backgroundSize: `100% ${c}px, 100% ${c}px`,
|
|
95
|
+
backgroundPosition: `0 0, 0 ${c / 2}px`
|
|
95
96
|
};
|
|
96
|
-
return /* @__PURE__ */
|
|
97
|
+
return /* @__PURE__ */ g("div", {
|
|
97
98
|
"data-grid-day": i,
|
|
98
99
|
role: "group",
|
|
99
|
-
"aria-label":
|
|
100
|
-
day: t(i,
|
|
101
|
-
count:
|
|
100
|
+
"aria-label": S("calendar.v2.dayColumn", "{{day}}: {{count}} events", {
|
|
101
|
+
day: t(i, C, "full"),
|
|
102
|
+
count: s.length
|
|
102
103
|
}),
|
|
103
|
-
className:
|
|
104
|
-
style:
|
|
104
|
+
className: b("relative border-s border-border-subtle", A && "bg-accent-soft/30"),
|
|
105
|
+
style: j,
|
|
105
106
|
children: [
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
+
/* @__PURE__ */ h(T, {
|
|
107
108
|
day: i,
|
|
108
|
-
hourHeight:
|
|
109
|
+
hourHeight: c
|
|
109
110
|
}),
|
|
110
|
-
|
|
111
|
-
let t =
|
|
112
|
-
return /* @__PURE__ */
|
|
111
|
+
s.map((e) => {
|
|
112
|
+
let t = x.lookOf(e.event);
|
|
113
|
+
return /* @__PURE__ */ h(l, {
|
|
113
114
|
placed: e,
|
|
114
|
-
hourHeight:
|
|
115
|
+
hourHeight: c,
|
|
115
116
|
look: t,
|
|
116
|
-
hue:
|
|
117
|
-
label:
|
|
118
|
-
format:
|
|
119
|
-
selected:
|
|
120
|
-
resizable: t.movable && !
|
|
121
|
-
onOpen:
|
|
122
|
-
onKeyDown:
|
|
123
|
-
consumeClick:
|
|
117
|
+
hue: x.hueOf(e.event.calendarId),
|
|
118
|
+
label: x.labelOf(e.event),
|
|
119
|
+
format: C,
|
|
120
|
+
selected: d === e.event.id,
|
|
121
|
+
resizable: t.movable && !w && !e.continuesAfter,
|
|
122
|
+
onOpen: f,
|
|
123
|
+
onKeyDown: p,
|
|
124
|
+
consumeClick: m
|
|
124
125
|
}, `${e.event.id}|${e.date}`);
|
|
125
126
|
}),
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
hourHeight:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
hourHeight:
|
|
134
|
-
hueStyle: g.event ? e(b.hueOf(g.event.calendarId)) : void 0,
|
|
135
|
-
label: g.event ? `${g.event.title} · ${r(g.start, g.end, S)}` : `${r(g.start, g.end, S)} · ${n(g.end - g.start, b.durationWords)}`
|
|
127
|
+
/* @__PURE__ */ h(o, {
|
|
128
|
+
day: i,
|
|
129
|
+
hourHeight: c,
|
|
130
|
+
placed: s
|
|
131
|
+
}),
|
|
132
|
+
k.includes(D) ? /* @__PURE__ */ h(E, {
|
|
133
|
+
isToday: A,
|
|
134
|
+
hourHeight: c
|
|
136
135
|
}) : null,
|
|
137
|
-
_ ? /* @__PURE__ */
|
|
136
|
+
_ ? /* @__PURE__ */ h(O, {
|
|
138
137
|
start: _.start,
|
|
139
138
|
end: _.end,
|
|
140
|
-
hourHeight:
|
|
141
|
-
|
|
139
|
+
hourHeight: c,
|
|
140
|
+
hueStyle: _.event ? e(x.hueOf(_.event.calendarId)) : void 0,
|
|
141
|
+
label: _.event ? `${_.event.title} · ${r(_.start, _.end, C)}` : `${r(_.start, _.end, C)} · ${n(_.end - _.start, x.durationWords)}`
|
|
142
|
+
}) : null,
|
|
143
|
+
v ? /* @__PURE__ */ h(O, {
|
|
144
|
+
start: v.start,
|
|
145
|
+
end: v.end,
|
|
146
|
+
hourHeight: c,
|
|
147
|
+
label: r(v.start, v.end, C),
|
|
142
148
|
quickAnchor: !0
|
|
143
149
|
}) : null,
|
|
144
|
-
|
|
150
|
+
y === null ? null : /* @__PURE__ */ h("div", {
|
|
145
151
|
"aria-hidden": "true",
|
|
146
152
|
className: "pointer-events-none absolute inset-x-0.5 z-[8] rounded-md border-2 border-[var(--color-focus-ring)] bg-accent-soft/40 px-1.5 text-[11px] font-semibold text-text-primary",
|
|
147
153
|
style: {
|
|
148
|
-
top:
|
|
149
|
-
height:
|
|
154
|
+
top: u(y, c),
|
|
155
|
+
height: u(30, c) - 2
|
|
150
156
|
},
|
|
151
|
-
children: r(
|
|
157
|
+
children: r(y, y + 30, C)
|
|
152
158
|
})
|
|
153
159
|
]
|
|
154
160
|
});
|
|
155
161
|
}
|
|
156
|
-
function
|
|
157
|
-
return /* @__PURE__ */
|
|
162
|
+
function O({ start: e, end: t, hourHeight: n, label: r, hueStyle: i, quickAnchor: a = !1 }) {
|
|
163
|
+
return /* @__PURE__ */ h("div", {
|
|
158
164
|
"aria-hidden": "true",
|
|
159
165
|
"data-quick-ghost": a || void 0,
|
|
160
|
-
className:
|
|
166
|
+
className: b("pointer-events-none absolute inset-x-0.5 z-[9] overflow-hidden rounded-md border border-dashed px-1.5 py-0.5 text-[11px] font-semibold text-text-primary", i ? "border-[var(--cal-hue)] bg-[color-mix(in_oklab,var(--cal-hue)_22%,var(--color-bg-surface))]" : "border-action-primary-bg bg-accent-soft/70"),
|
|
161
167
|
style: {
|
|
162
168
|
...i,
|
|
163
|
-
top:
|
|
164
|
-
height: Math.max(18,
|
|
169
|
+
top: u(e, n),
|
|
170
|
+
height: Math.max(18, u(t - e, n) - 2)
|
|
165
171
|
},
|
|
166
172
|
children: r
|
|
167
173
|
});
|
|
168
174
|
}
|
|
169
|
-
function
|
|
175
|
+
function k() {
|
|
170
176
|
let e = a(), { tr: t, compact: n } = e, r = e.days.includes(e.today) ? e.today : e.days[0] ?? e.today;
|
|
171
|
-
return /* @__PURE__ */
|
|
177
|
+
return /* @__PURE__ */ h("div", {
|
|
172
178
|
className: "pointer-events-none absolute inset-0 z-30 grid place-items-center p-4",
|
|
173
|
-
children: /* @__PURE__ */
|
|
179
|
+
children: /* @__PURE__ */ h("div", {
|
|
174
180
|
className: "pointer-events-auto w-full max-w-sm rounded-card border border-border-default bg-bg-elevated shadow-elevation-3",
|
|
175
|
-
children: /* @__PURE__ */
|
|
181
|
+
children: /* @__PURE__ */ h(v, {
|
|
176
182
|
compact: !0,
|
|
177
183
|
size: "panel",
|
|
178
184
|
kind: "first-use",
|
|
179
185
|
illustration: "calendar",
|
|
180
186
|
title: t("calendar.v2.emptyDays", "Nothing on these days"),
|
|
181
187
|
description: n ? t("calendar.v2.emptyDaysPhone", "Add an event, or bring in a team, holiday or other calendar.") : t("calendar.v2.emptyDaysDesktop", "Click and drag on the grid to add an event, or bring in a team, holiday or other calendar."),
|
|
182
|
-
action: /* @__PURE__ */
|
|
188
|
+
action: /* @__PURE__ */ g(_, {
|
|
183
189
|
type: "button",
|
|
184
190
|
onClick: () => e.openEventDialog({
|
|
185
191
|
date: r,
|
|
@@ -187,18 +193,18 @@ function O() {
|
|
|
187
193
|
end: (e.workingHoursOn(r)?.start ?? 540) + e.prefs.defaultDuration,
|
|
188
194
|
allDay: !1
|
|
189
195
|
}),
|
|
190
|
-
children: [/* @__PURE__ */
|
|
196
|
+
children: [/* @__PURE__ */ h(p, { "aria-hidden": "true" }), t("calendar.v2.newEvent", "New event")]
|
|
191
197
|
}),
|
|
192
|
-
secondaryAction: /* @__PURE__ */
|
|
198
|
+
secondaryAction: /* @__PURE__ */ g(_, {
|
|
193
199
|
type: "button",
|
|
194
200
|
variant: "outline",
|
|
195
201
|
onClick: () => e.nav.openDialog("share"),
|
|
196
|
-
children: [/* @__PURE__ */
|
|
202
|
+
children: [/* @__PURE__ */ h(f, { "aria-hidden": "true" }), t("calendar.v2.addCalendar", "Add a calendar")]
|
|
197
203
|
})
|
|
198
204
|
})
|
|
199
205
|
})
|
|
200
206
|
});
|
|
201
207
|
}
|
|
202
|
-
export {
|
|
208
|
+
export { D as DayColumn, S as DayHeaderRow, k as GridEmpty, O as GridGhost, w as HourGutter };
|
|
203
209
|
|
|
204
210
|
//# sourceMappingURL=GridParts.js.map
|