@burdenoff/microfe-calendar 2026.1124.3 → 2026.1124.4
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 +342 -69
- package/dist/generated/wspace-operations.js +73 -31
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +405 -6
- package/dist/translations/en.d.ts +22 -4
- package/dist/v2/CalendarPageV2.js +45 -41
- package/dist/v2/CalendarPageV2.js.map +1 -1
- package/dist/v2/CalendarRoutesV2.js +64 -64
- package/dist/v2/CalendarRoutesV2.js.map +1 -1
- package/dist/v2/data/errors.d.ts +5 -0
- package/dist/v2/data/errors.js +6 -2
- package/dist/v2/data/errors.js.map +1 -1
- package/dist/v2/data/normalize.d.ts +31 -3
- package/dist/v2/data/normalize.js +57 -13
- package/dist/v2/data/normalize.js.map +1 -1
- package/dist/v2/data/seriesDateLookup.d.ts +9 -0
- package/dist/v2/data/seriesDateLookup.js +12 -0
- package/dist/v2/data/seriesDateLookup.js.map +1 -0
- package/dist/v2/data/useEventActions.d.ts +9 -3
- package/dist/v2/data/useEventActions.js +239 -186
- package/dist/v2/data/useEventActions.js.map +1 -1
- package/dist/v2/data/useEventForPeek.js +63 -21
- package/dist/v2/data/useEventForPeek.js.map +1 -1
- package/dist/v2/data/useEventsInRangeV2.d.ts +40 -2
- package/dist/v2/data/useEventsInRangeV2.js +76 -47
- package/dist/v2/data/useEventsInRangeV2.js.map +1 -1
- package/dist/v2/day/DayPanel.js +1 -1
- package/dist/v2/day/DayPanel.js.map +1 -1
- package/dist/v2/event/EventDialog.d.ts +13 -3
- package/dist/v2/event/EventDialog.js +189 -166
- package/dist/v2/event/EventDialog.js.map +1 -1
- package/dist/v2/event/EventDialogs.js +57 -50
- package/dist/v2/event/EventDialogs.js.map +1 -1
- package/dist/v2/event/EventMoreTab.js +8 -7
- package/dist/v2/event/EventMoreTab.js.map +1 -1
- package/dist/v2/event/EventPlaceTab.js +2 -2
- package/dist/v2/event/EventPlaceTab.js.map +1 -1
- package/dist/v2/event/FindTimeDialog.js +1 -1
- package/dist/v2/event/FindTimeDialog.js.map +1 -1
- package/dist/v2/event/RepeatField.js +10 -7
- package/dist/v2/event/RepeatField.js.map +1 -1
- package/dist/v2/event/dialogLogic.d.ts +10 -0
- package/dist/v2/event/dialogLogic.js +25 -22
- package/dist/v2/event/dialogLogic.js.map +1 -1
- package/dist/v2/event/dialogModel.d.ts +3 -0
- package/dist/v2/event/dialogModel.js.map +1 -1
- package/dist/v2/event/eventForm.d.ts +26 -0
- package/dist/v2/event/eventForm.js +145 -92
- package/dist/v2/event/eventForm.js.map +1 -1
- package/dist/v2/event/findTimeSource.js +44 -44
- package/dist/v2/event/findTimeSource.js.map +1 -1
- package/dist/v2/event/rrule.js.map +1 -1
- package/dist/v2/event/savePlan.d.ts +125 -15
- package/dist/v2/event/savePlan.js +162 -68
- package/dist/v2/event/savePlan.js.map +1 -1
- package/dist/v2/event/useEventData.d.ts +7 -2
- package/dist/v2/event/useEventData.js +107 -80
- package/dist/v2/event/useEventData.js.map +1 -1
- package/dist/v2/event/useEventDialogModel.d.ts +16 -3
- package/dist/v2/event/useEventDialogModel.js +82 -67
- package/dist/v2/event/useEventDialogModel.js.map +1 -1
- package/dist/v2/event/useEventSave.d.ts +20 -4
- package/dist/v2/event/useEventSave.js +181 -90
- package/dist/v2/event/useEventSave.js.map +1 -1
- package/dist/v2/events/eventLook.js +16 -16
- package/dist/v2/events/eventLook.js.map +1 -1
- package/dist/v2/events/eventModel.d.ts +17 -4
- package/dist/v2/events/eventModel.js +46 -34
- package/dist/v2/events/eventModel.js.map +1 -1
- package/dist/v2/events/localChanges.d.ts +4 -1
- package/dist/v2/events/localChanges.js +4 -2
- package/dist/v2/events/localChanges.js.map +1 -1
- package/dist/v2/page/CalendarPageContext.d.ts +2 -2
- package/dist/v2/page/CalendarPageContext.js.map +1 -1
- package/dist/v2/page/useCalendarPageModel.js +141 -139
- package/dist/v2/page/useCalendarPageModel.js.map +1 -1
- package/dist/v2/page/viewState.d.ts +9 -1
- package/dist/v2/page/viewState.js +5 -3
- package/dist/v2/page/viewState.js.map +1 -1
- package/dist/v2/peek/PeekEvent.js +210 -204
- package/dist/v2/peek/PeekEvent.js.map +1 -1
- package/dist/v2/rail/useMonthEventDates.js +1 -1
- package/dist/v2/rail/useMonthEventDates.js.map +1 -1
- package/dist/v2/states/CalendarStates.d.ts +15 -0
- package/dist/v2/states/CalendarStates.js +42 -11
- package/dist/v2/states/CalendarStates.js.map +1 -1
- package/dist/v2/types.d.ts +30 -2
- package/package.json +1 -1
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { DateValue } from '@burdenoff/fe-libs/ui';
|
|
2
|
-
import { CalendarEventV2, CalendarV2, EventBookingV2, TimedSegment } from '../types';
|
|
2
|
+
import { CalendarEventV2, CalendarV2, CalendarV2EventDraft, EventBookingV2, TimedSegment } from '../types';
|
|
3
3
|
/** The person's part in an event. */
|
|
4
4
|
export type MyPart = 'organizer' | 'invited' | 'going' | 'maybe' | 'declined' | 'none';
|
|
5
|
+
/**
|
|
6
|
+
* A regular date of a repeating event (A4): the series stands behind it, and "This event"
|
|
7
|
+
* names the date by its original start. A date moved on its own is an event of its own.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isSeriesDate(event: Pick<CalendarEventV2, 'isRecurring' | 'seriesId' | 'instanceDate' | 'isModified'>): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* What the event dialog and Find a time open with to change an event: the stored event, and for
|
|
12
|
+
* a regular date of a series the date ("This event" names it).
|
|
13
|
+
*/
|
|
14
|
+
export declare function editDraftFor(event: CalendarEventV2): CalendarV2EventDraft;
|
|
15
|
+
/** A date of a repeating event, as it stands or moved on its own: it shows "Repeats". */
|
|
16
|
+
export declare function inSeries(event: Pick<CalendarEventV2, 'isRecurring' | 'seriesId'>): boolean;
|
|
5
17
|
export declare function isOrganizer(event: CalendarEventV2, me: string | null): boolean;
|
|
6
18
|
export declare function myPart(event: CalendarEventV2, me: string | null): MyPart;
|
|
7
19
|
/**
|
|
@@ -16,9 +28,10 @@ export declare function isBusyOnly(event: CalendarEventV2, calendar: CalendarV2
|
|
|
16
28
|
export declare function canEditEvent(event: CalendarEventV2, calendar: CalendarV2 | undefined, me: string | null): boolean;
|
|
17
29
|
/**
|
|
18
30
|
* Drag and keyboard moves, which keep an event inside one day of the grid. Not for:
|
|
19
|
-
* - a repeating event:
|
|
20
|
-
*
|
|
21
|
-
* to change
|
|
31
|
+
* - a date of a repeating event: a move would change the series' own time (every date), and a
|
|
32
|
+
* date changed on its own is an event of its own that the event dialog makes, carrying its
|
|
33
|
+
* guests, reminders and room; so the dialog asks which events to change. A date already
|
|
34
|
+
* moved on its own is its own event and moves like one;
|
|
22
35
|
* - one that runs past midnight on the calendar's clock (23:00–01:00): kept inside one day it
|
|
23
36
|
* would lose its times, so it changes in the event dialog;
|
|
24
37
|
* - one that starts or ends in the second pass of an hour the clocks repeat (01:30 GMT on 25
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { dayDifference as e, eventDays as t, instantToZoned as n, timedSegments as r, zonedTimeToInstant as i } from "../time/calendarTime.js";
|
|
2
2
|
// src/v2/events/eventModel.ts
|
|
3
3
|
var a = 864e5;
|
|
4
|
-
function o(e
|
|
4
|
+
function o(e) {
|
|
5
|
+
return e.isRecurring && !e.isModified && e.seriesId !== null && e.instanceDate !== null;
|
|
6
|
+
}
|
|
7
|
+
function s(e) {
|
|
8
|
+
return o(e) && e.instanceDate ? {
|
|
9
|
+
eventId: e.eventId,
|
|
10
|
+
instanceDate: e.instanceDate
|
|
11
|
+
} : { eventId: e.eventId };
|
|
12
|
+
}
|
|
13
|
+
function c(e) {
|
|
14
|
+
return e.isRecurring || e.seriesId !== null;
|
|
15
|
+
}
|
|
16
|
+
function l(e, t) {
|
|
5
17
|
return t ? e.organizerId === t || e.guests.some((e) => e.organizer && e.userId === t) : !1;
|
|
6
18
|
}
|
|
7
|
-
function
|
|
8
|
-
if (
|
|
19
|
+
function u(e, t) {
|
|
20
|
+
if (l(e, t)) return "organizer";
|
|
9
21
|
switch (e.myResponse) {
|
|
10
22
|
case "NO_RESPONSE": return "invited";
|
|
11
23
|
case "ACCEPTED": return "going";
|
|
@@ -14,53 +26,53 @@ function s(e, t) {
|
|
|
14
26
|
default: return "none";
|
|
15
27
|
}
|
|
16
28
|
}
|
|
17
|
-
function
|
|
29
|
+
function d(e, t) {
|
|
18
30
|
return !e || !t || e.kind !== "PERSONAL" ? !1 : (e.ownerUserId ?? e.createdBy) === t;
|
|
19
31
|
}
|
|
20
|
-
function
|
|
21
|
-
return e.visibility !== "PUBLIC" &&
|
|
32
|
+
function f(e, t, n) {
|
|
33
|
+
return e.visibility !== "PUBLIC" && u(e, n) === "none" && !d(t, n);
|
|
22
34
|
}
|
|
23
|
-
function
|
|
24
|
-
return !t || t.isReadOnly || e.status === "CANCELLED" ? !1 :
|
|
35
|
+
function p(e, t, n) {
|
|
36
|
+
return !t || t.isReadOnly || e.status === "CANCELLED" ? !1 : l(e, n);
|
|
25
37
|
}
|
|
26
|
-
function
|
|
27
|
-
if (!
|
|
38
|
+
function m(e, n, r, i) {
|
|
39
|
+
if (!p(e, n, r) || e.isRecurring || g(e)) return !1;
|
|
28
40
|
let a = t(e, i);
|
|
29
|
-
return a.start === a.end &&
|
|
41
|
+
return a.start === a.end && h(e.start, i) && h(e.end, i);
|
|
30
42
|
}
|
|
31
|
-
function
|
|
43
|
+
function h(e, t) {
|
|
32
44
|
let r = n(e, t), a = Math.floor(e.getTime() / 6e4) * 6e4;
|
|
33
45
|
return i(r.date, r.minutes, t).getTime() === a;
|
|
34
46
|
}
|
|
35
|
-
function
|
|
47
|
+
function g(e) {
|
|
36
48
|
return e.allDay || e.end.getTime() - e.start.getTime() >= a;
|
|
37
49
|
}
|
|
38
|
-
function
|
|
50
|
+
function _(e, r, i) {
|
|
39
51
|
if (e.allDay) {
|
|
40
52
|
let a = n(r, i).date;
|
|
41
53
|
return t(e, i).end < a;
|
|
42
54
|
}
|
|
43
55
|
return e.end.getTime() <= r.getTime();
|
|
44
56
|
}
|
|
45
|
-
function
|
|
57
|
+
function v(e, t) {
|
|
46
58
|
if (e.allDay) return !1;
|
|
47
59
|
let n = t.getTime();
|
|
48
60
|
return e.start.getTime() <= n && e.end.getTime() > n;
|
|
49
61
|
}
|
|
50
|
-
function
|
|
51
|
-
return e.filter((e) => !t.hiddenCalendarIds.has(e.calendarId) && e.status !== "CANCELLED" && (t.showDeclined ||
|
|
62
|
+
function y(e, t) {
|
|
63
|
+
return e.filter((e) => !t.hiddenCalendarIds.has(e.calendarId) && e.status !== "CANCELLED" && (t.showDeclined || u(e, t.me) !== "declined"));
|
|
52
64
|
}
|
|
53
|
-
function
|
|
54
|
-
return e.filter((e) =>
|
|
65
|
+
function b(e, t, n) {
|
|
66
|
+
return e.filter((e) => u(e, n) === "invited" && e.end.getTime() > t.getTime()).sort((e, t) => e.start.getTime() - t.start.getTime());
|
|
55
67
|
}
|
|
56
|
-
function
|
|
68
|
+
function x(e) {
|
|
57
69
|
return e.resourceType === "ROOM" || e.resourceType === null;
|
|
58
70
|
}
|
|
59
|
-
function
|
|
60
|
-
let t = e.bookings.filter(
|
|
71
|
+
function S(e) {
|
|
72
|
+
let t = e.bookings.filter(x);
|
|
61
73
|
return t.find((e) => e.status === "PENDING" || e.status === "APPROVED") ?? t.find((e) => e.status === "COMPLETED") ?? t.find((e) => e.status === "REJECTED") ?? null;
|
|
62
74
|
}
|
|
63
|
-
function
|
|
75
|
+
function C(e) {
|
|
64
76
|
let t = e?.trim();
|
|
65
77
|
if (!t) return null;
|
|
66
78
|
let n = /^[a-z][a-z0-9+.-]*:/i.test(t) ? t : `https://${t}`;
|
|
@@ -71,22 +83,22 @@ function b(e) {
|
|
|
71
83
|
return null;
|
|
72
84
|
}
|
|
73
85
|
}
|
|
74
|
-
function
|
|
75
|
-
return
|
|
86
|
+
function w(e) {
|
|
87
|
+
return C(e.meeting?.url) ?? (e.locationType === "ONLINE" ? C(e.locationUrl) : null);
|
|
76
88
|
}
|
|
77
|
-
function
|
|
89
|
+
function T(e, t, n, i = {}) {
|
|
78
90
|
let a = new Map(t.map((e) => [e, []])), o = t[0], s = t[t.length - 1];
|
|
79
91
|
if (!o || !s) return a;
|
|
80
|
-
for (let t of e) if (!(t.allDay || !i.includeLong &&
|
|
92
|
+
for (let t of e) if (!(t.allDay || !i.includeLong && g(t))) for (let e of r(t.start, t.end, n, o, s)) a.get(e.date)?.push({
|
|
81
93
|
...e,
|
|
82
94
|
event: t
|
|
83
95
|
});
|
|
84
96
|
return a;
|
|
85
97
|
}
|
|
86
|
-
function
|
|
98
|
+
function E(e, n, r, i) {
|
|
87
99
|
let a = [];
|
|
88
100
|
for (let o of e) {
|
|
89
|
-
if (!
|
|
101
|
+
if (!g(o)) continue;
|
|
90
102
|
let e = t(o, i);
|
|
91
103
|
e.end < n || e.start > r || a.push({
|
|
92
104
|
event: o,
|
|
@@ -96,21 +108,21 @@ function C(e, n, r, i) {
|
|
|
96
108
|
}
|
|
97
109
|
return a;
|
|
98
110
|
}
|
|
99
|
-
function
|
|
111
|
+
function D(e, n, r) {
|
|
100
112
|
return e.filter((e) => {
|
|
101
113
|
let i = t(e, r);
|
|
102
114
|
return i.start <= n && i.end >= n;
|
|
103
|
-
}).sort((e, t) => Number(
|
|
115
|
+
}).sort((e, t) => Number(g(t)) - Number(g(e)) || e.start.getTime() - t.start.getTime() || e.title.localeCompare(t.title));
|
|
104
116
|
}
|
|
105
|
-
function
|
|
117
|
+
function O(t, n) {
|
|
106
118
|
return e(t.first, n) + 1;
|
|
107
119
|
}
|
|
108
|
-
function
|
|
120
|
+
function k(e, n, r, i, a) {
|
|
109
121
|
let o = t(e, a);
|
|
110
122
|
if (o.end < r || o.start > i) return !1;
|
|
111
123
|
for (let e of n) if (e >= o.start && e <= o.end) return !0;
|
|
112
124
|
return !1;
|
|
113
125
|
}
|
|
114
|
-
export {
|
|
126
|
+
export { E as allDayItems, p as canEditEvent, m as canMoveOnGrid, O as dayOfSpan, s as editDraftFor, S as eventRoom, D as eventsOnDay, c as inSeries, g as isAllDayRow, f as isBusyOnly, v as isHappeningNow, l as isOrganizer, _ as isPastEvent, o as isSeriesDate, w as joinUrl, u as myPart, h as readsBackOnClock, C as safeWebUrl, y as shownEvents, T as timedSegmentsByDay, k as touchesDays, b as waitingInvitations };
|
|
115
127
|
|
|
116
128
|
//# sourceMappingURL=eventModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventModel.js","names":["DAY_MS","isOrganizer","me","event","guest","myPart","isOwnCalendar","calendar","isBusyOnly","canEditEvent","canMoveOnGrid","isAllDayRow","days","eventDays","timeZone","readsBackOnClock","zoned","instantToZoned","instant","minute","zonedTimeToInstant","isPastEvent","today","now","isHappeningNow","at","shownEvents","events","options","waitingInvitations","a","b","isRoomBooking","booking","eventRoom","rooms","safeWebUrl","value","raw","withScheme","url","joinUrl","timedSegmentsByDay","byDay","day","first","last","segment","timedSegments","allDayItems","items","span","eventsOnDay","dayOfSpan","dayDifference","item","touchesDays"],"sources":["../../../src/v2/events/eventModel.ts"],"sourcesContent":["/**\n * What an event is to the person looking at it (BOFF-15698 A1): whose it is, their answer,\n * whether they may change it, whether only \"Busy\" may be shown, and which views and days it\n * belongs to. Pure, so the views and their tests share one reading.\n */\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport {\n dayDifference,\n eventDays,\n instantToZoned,\n timedSegments,\n zonedTimeToInstant,\n} from '../time/calendarTime';\nimport type { CalendarEventV2, CalendarV2, EventBookingV2, TimedSegment } from '../types';\n\nconst DAY_MS = 86_400_000;\n\n/** The person's part in an event. */\nexport type MyPart = 'organizer' | 'invited' | 'going' | 'maybe' | 'declined' | 'none';\n\nexport function isOrganizer(event: CalendarEventV2, me: string | null): boolean {\n if (!me) return false;\n return (\n event.organizerId === me || event.guests.some((guest) => guest.organizer && guest.userId === me)\n );\n}\n\nexport function myPart(event: CalendarEventV2, me: string | null): MyPart {\n if (isOrganizer(event, me)) return 'organizer';\n switch (event.myResponse) {\n case 'NO_RESPONSE':\n return 'invited';\n case 'ACCEPTED':\n return 'going';\n case 'TENTATIVE':\n return 'maybe';\n case 'DECLINED':\n return 'declined';\n default:\n return 'none';\n }\n}\n\n/** The person's own calendar: one only they hold. */\nfunction isOwnCalendar(calendar: CalendarV2 | undefined, me: string | null): boolean {\n if (!calendar || !me || calendar.kind !== 'PERSONAL') return false;\n return (calendar.ownerUserId ?? calendar.createdBy) === me;\n}\n\n/**\n * A private or confidential event of someone else's that the person is not invited to: the\n * views show only that the time is taken (\"Busy\"), never its title, place or guests.\n */\nexport function isBusyOnly(\n event: CalendarEventV2,\n calendar: CalendarV2 | undefined,\n me: string | null\n): boolean {\n if (event.visibility === 'PUBLIC') return false;\n return myPart(event, me) === 'none' && !isOwnCalendar(calendar, me);\n}\n\n/**\n * The person may move, resize, edit and delete it: they organise it, its calendar takes\n * changes (not a calendar followed by link), and it is not someone else's private time.\n */\nexport function canEditEvent(\n event: CalendarEventV2,\n calendar: CalendarV2 | undefined,\n me: string | null\n): boolean {\n if (!calendar || calendar.isReadOnly) return false;\n if (event.status === 'CANCELLED') return false;\n return isOrganizer(event, me);\n}\n\n/**\n * Drag and keyboard moves, which keep an event inside one day of the grid. Not for:\n * - a repeating event: it shows only its first occurrence until the series is expanded on the\n * server (B7), so moving it would move the whole series; the event dialog asks which events\n * to change;\n * - one that runs past midnight on the calendar's clock (23:00–01:00): kept inside one day it\n * would lose its times, so it changes in the event dialog;\n * - one that starts or ends in the second pass of an hour the clocks repeat (01:30 GMT on 25\n * October 2026 in London): the grid reads a clock time as its first pass, so a move would\n * shift it by the hour.\n */\nexport function canMoveOnGrid(\n event: CalendarEventV2,\n calendar: CalendarV2 | undefined,\n me: string | null,\n timeZone: string\n): boolean {\n if (!canEditEvent(event, calendar, me) || event.isRecurring || isAllDayRow(event)) return false;\n const days = eventDays(event, timeZone);\n if (days.start !== days.end) return false;\n return readsBackOnClock(event.start, timeZone) && readsBackOnClock(event.end, timeZone);\n}\n\n/**\n * Whether an instant's clock time on `timeZone` stands for that instant again (to the minute):\n * false in the second pass of a repeated hour, which the clock time reads as the first.\n */\nexport function readsBackOnClock(instant: Date, timeZone: string): boolean {\n const zoned = instantToZoned(instant, timeZone);\n const minute = Math.floor(instant.getTime() / 60_000) * 60_000;\n return zonedTimeToInstant(zoned.date, zoned.minutes, timeZone).getTime() === minute;\n}\n\n/** Shown in the all-day row: an all-day event, or one that lasts a day or more. */\nexport function isAllDayRow(event: CalendarEventV2): boolean {\n return event.allDay || event.end.getTime() - event.start.getTime() >= DAY_MS;\n}\n\n/** The event has ended (an all-day event: its last day is before today). */\nexport function isPastEvent(event: CalendarEventV2, now: Date, timeZone: string): boolean {\n if (event.allDay) {\n const today = instantToZoned(now, timeZone).date;\n return eventDays(event, timeZone).end < today;\n }\n return event.end.getTime() <= now.getTime();\n}\n\nexport function isHappeningNow(event: CalendarEventV2, now: Date): boolean {\n if (event.allDay) return false;\n const at = now.getTime();\n return event.start.getTime() <= at && event.end.getTime() > at;\n}\n\nexport interface ShownEventsOptions {\n hiddenCalendarIds: ReadonlySet<string>;\n showDeclined: boolean;\n me: string | null;\n}\n\n/**\n * The events the views show: on a shown calendar, not cancelled, and not declined unless the\n * person asked to see those.\n */\nexport function shownEvents(\n events: readonly CalendarEventV2[],\n options: ShownEventsOptions\n): CalendarEventV2[] {\n return events.filter(\n (event) =>\n !options.hiddenCalendarIds.has(event.calendarId) &&\n event.status !== 'CANCELLED' &&\n (options.showDeclined || myPart(event, options.me) !== 'declined')\n );\n}\n\n/** Invitations still waiting for the person's answer that haven't ended, soonest first. */\nexport function waitingInvitations(\n events: readonly CalendarEventV2[],\n now: Date,\n me: string | null\n): CalendarEventV2[] {\n return events\n .filter((event) => myPart(event, me) === 'invited' && event.end.getTime() > now.getTime())\n .sort((a, b) => a.start.getTime() - b.start.getTime());\n}\n\n/** A room booking: a room, or a resource of unknown type (rooms are what events book most). */\nfunction isRoomBooking(booking: EventBookingV2): boolean {\n return booking.resourceType === 'ROOM' || booking.resourceType === null;\n}\n\n/**\n * The room an event is in: its first room booking that wasn't cancelled or turned down, else a\n * turned-down one to warn about. Other resources (equipment) never stand in for the room, so a\n * refused room still shows next to approved equipment.\n */\nexport function eventRoom(event: CalendarEventV2): EventBookingV2 | null {\n const rooms = event.bookings.filter(isRoomBooking);\n return (\n rooms.find((booking) => booking.status === 'PENDING' || booking.status === 'APPROVED') ??\n rooms.find((booking) => booking.status === 'COMPLETED') ??\n rooms.find((booking) => booking.status === 'REJECTED') ??\n null\n );\n}\n\n/** A web address that is safe to open: http or https only. */\nexport function safeWebUrl(raw: string | null | undefined): string | null {\n const value = raw?.trim();\n if (!value) return null;\n const withScheme = /^[a-z][a-z0-9+.-]*:/i.test(value) ? value : `https://${value}`;\n try {\n const url = new URL(withScheme);\n return url.protocol === 'https:' || url.protocol === 'http:' ? url.toString() : null;\n } catch {\n return null;\n }\n}\n\n/** The video call to join: the meeting link, else a location that is a web address. */\nexport function joinUrl(event: CalendarEventV2): string | null {\n return (\n safeWebUrl(event.meeting?.url) ??\n (event.locationType === 'ONLINE' ? safeWebUrl(event.locationUrl) : null)\n );\n}\n\n/** A timed event's piece on one day. */\nexport interface DaySegment<T = CalendarEventV2> extends TimedSegment {\n event: T;\n}\n\n/**\n * Timed events' pieces on each of `days`, on the clock of `timeZone`. Events shown in the\n * all-day row (`isAllDayRow`) are left out, as the grid draws them there; `includeLong` keeps\n * the timed ones of a day or more, for what is busy (all-day events never are).\n */\nexport function timedSegmentsByDay(\n events: readonly CalendarEventV2[],\n days: readonly DateValue[],\n timeZone: string,\n options: { includeLong?: boolean } = {}\n): Map<DateValue, DaySegment[]> {\n const byDay = new Map<DateValue, DaySegment[]>(days.map((day) => [day, []]));\n const first = days[0];\n const last = days[days.length - 1];\n if (!first || !last) return byDay;\n for (const event of events) {\n if (event.allDay || (!options.includeLong && isAllDayRow(event))) continue;\n for (const segment of timedSegments(event.start, event.end, timeZone, first, last)) {\n byDay.get(segment.date)?.push({ ...segment, event });\n }\n }\n return byDay;\n}\n\n/** An event in the all-day row, from its first to its last day. */\nexport interface AllDayItem<T = CalendarEventV2> {\n event: T;\n first: DateValue;\n last: DateValue;\n}\n\n/** The all-day row's events that touch `first`..`last`. */\nexport function allDayItems(\n events: readonly CalendarEventV2[],\n first: DateValue,\n last: DateValue,\n timeZone: string\n): AllDayItem[] {\n const items: AllDayItem[] = [];\n for (const event of events) {\n if (!isAllDayRow(event)) continue;\n const span = eventDays(event, timeZone);\n if (span.end < first || span.start > last) continue;\n items.push({ event, first: span.start, last: span.end });\n }\n return items;\n}\n\n/**\n * The events on one day, for a day's list (Month's \"+N more\", phones' Month, the List view):\n * every event that touches the day (one over midnight on both its days, as the grid shows\n * it), all-day ones first, then by start.\n */\nexport function eventsOnDay(\n events: readonly CalendarEventV2[],\n day: DateValue,\n timeZone: string\n): CalendarEventV2[] {\n return events\n .filter((event) => {\n const span = eventDays(event, timeZone);\n return span.start <= day && span.end >= day;\n })\n .sort(\n (a, b) =>\n Number(isAllDayRow(b)) - Number(isAllDayRow(a)) ||\n a.start.getTime() - b.start.getTime() ||\n a.title.localeCompare(b.title)\n );\n}\n\n/** Which of an all-day item's days `day` is: 1 for its first. */\nexport function dayOfSpan(item: { first: DateValue }, day: DateValue): number {\n return dayDifference(item.first, day) + 1;\n}\n\n/** Whether an event falls on any of `days` (sorted), on the clock of `timeZone`. */\nexport function touchesDays(\n event: CalendarEventV2,\n days: ReadonlySet<DateValue>,\n first: DateValue,\n last: DateValue,\n timeZone: string\n): boolean {\n const span = eventDays(event, timeZone);\n if (span.end < first || span.start > last) return false;\n for (const day of days) if (day >= span.start && day <= span.end) return true;\n return false;\n}\n"],"mappings":";;AAeA,IAAMA,IAAS;AAKf,SAAgBC,EAAY,GAAwB,GAA4B;CAE9E,OADKC,IAEHC,EAAM,gBAAgBD,KAAMC,EAAM,OAAO,MAA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,EAAM,KAAK;GAAE;GAAO,OAAOC,EAAK;GAAO,MAAMA,EAAK;EAAI,CAAC;CACzD;CACA,OAAOD;AACT;AAOA,SAAgBE,EACd,GACA,GACA,GACmB;CACnB,OAAOzB,EACJ,QAAQ,MAAU;EACjB,IAAMwB,IAAOtC,EAAUV,GAAOW,CAAQ;EACtC,OAAOqC,EAAK,SAASP,KAAOO,EAAK,OAAOP;CAC1C,CAAC,CAAC,CACD,MACE,GAAG,MACF,OAAOjC,EAAYoB,CAAC,CAAC,IAAI,OAAOpB,EAAYmB,CAAC,CAAC,KAC9CA,EAAE,MAAM,QAAQ,IAAIC,EAAE,MAAM,QAAQ,KACpCD,EAAE,MAAM,cAAcC,EAAE,KAAK,CACjC;AACJ;AAGA,SAAgBsB,EAAU,GAA4B,GAAwB;CAC5E,OAAOC,EAAcC,EAAK,OAAOX,CAAG,IAAI;AAC1C;AAGA,SAAgBY,EACd,GACA,GACA,GACA,GACA,GACS;CACT,IAAML,IAAOtC,EAAUV,GAAOW,CAAQ;CACtC,IAAIqC,EAAK,MAAMN,KAASM,EAAK,QAAQL,GAAM,OAAO;CAClD,KAAK,IAAMF,KAAOhC,GAAM,IAAIgC,KAAOO,EAAK,SAASP,KAAOO,EAAK,KAAK,OAAO;CACzE,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"eventModel.js","names":["DAY_MS","isSeriesDate","event","editDraftFor","inSeries","isOrganizer","me","guest","myPart","isOwnCalendar","calendar","isBusyOnly","canEditEvent","canMoveOnGrid","isAllDayRow","days","eventDays","timeZone","readsBackOnClock","zoned","instantToZoned","instant","minute","zonedTimeToInstant","isPastEvent","today","now","isHappeningNow","at","shownEvents","events","options","waitingInvitations","a","b","isRoomBooking","booking","eventRoom","rooms","safeWebUrl","value","raw","withScheme","url","joinUrl","timedSegmentsByDay","byDay","day","first","last","segment","timedSegments","allDayItems","items","span","eventsOnDay","dayOfSpan","dayDifference","item","touchesDays"],"sources":["../../../src/v2/events/eventModel.ts"],"sourcesContent":["/**\n * What an event is to the person looking at it (BOFF-15698 A1): whose it is, their answer,\n * whether they may change it, whether only \"Busy\" may be shown, and which views and days it\n * belongs to. Pure, so the views and their tests share one reading.\n */\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport {\n dayDifference,\n eventDays,\n instantToZoned,\n timedSegments,\n zonedTimeToInstant,\n} from '../time/calendarTime';\nimport type {\n CalendarEventV2,\n CalendarV2,\n CalendarV2EventDraft,\n EventBookingV2,\n TimedSegment,\n} from '../types';\n\nconst DAY_MS = 86_400_000;\n\n/** The person's part in an event. */\nexport type MyPart = 'organizer' | 'invited' | 'going' | 'maybe' | 'declined' | 'none';\n\n/**\n * A regular date of a repeating event (A4): the series stands behind it, and \"This event\"\n * names the date by its original start. A date moved on its own is an event of its own.\n */\nexport function isSeriesDate(\n event: Pick<CalendarEventV2, 'isRecurring' | 'seriesId' | 'instanceDate' | 'isModified'>\n): boolean {\n return (\n event.isRecurring && !event.isModified && event.seriesId !== null && event.instanceDate !== null\n );\n}\n\n/**\n * What the event dialog and Find a time open with to change an event: the stored event, and for\n * a regular date of a series the date (\"This event\" names it).\n */\nexport function editDraftFor(event: CalendarEventV2): CalendarV2EventDraft {\n return isSeriesDate(event) && event.instanceDate\n ? { eventId: event.eventId, instanceDate: event.instanceDate }\n : { eventId: event.eventId };\n}\n\n/** A date of a repeating event, as it stands or moved on its own: it shows \"Repeats\". */\nexport function inSeries(event: Pick<CalendarEventV2, 'isRecurring' | 'seriesId'>): boolean {\n return event.isRecurring || event.seriesId !== null;\n}\n\nexport function isOrganizer(event: CalendarEventV2, me: string | null): boolean {\n if (!me) return false;\n return (\n event.organizerId === me || event.guests.some((guest) => guest.organizer && guest.userId === me)\n );\n}\n\nexport function myPart(event: CalendarEventV2, me: string | null): MyPart {\n if (isOrganizer(event, me)) return 'organizer';\n switch (event.myResponse) {\n case 'NO_RESPONSE':\n return 'invited';\n case 'ACCEPTED':\n return 'going';\n case 'TENTATIVE':\n return 'maybe';\n case 'DECLINED':\n return 'declined';\n default:\n return 'none';\n }\n}\n\n/** The person's own calendar: one only they hold. */\nfunction isOwnCalendar(calendar: CalendarV2 | undefined, me: string | null): boolean {\n if (!calendar || !me || calendar.kind !== 'PERSONAL') return false;\n return (calendar.ownerUserId ?? calendar.createdBy) === me;\n}\n\n/**\n * A private or confidential event of someone else's that the person is not invited to: the\n * views show only that the time is taken (\"Busy\"), never its title, place or guests.\n */\nexport function isBusyOnly(\n event: CalendarEventV2,\n calendar: CalendarV2 | undefined,\n me: string | null\n): boolean {\n if (event.visibility === 'PUBLIC') return false;\n return myPart(event, me) === 'none' && !isOwnCalendar(calendar, me);\n}\n\n/**\n * The person may move, resize, edit and delete it: they organise it, its calendar takes\n * changes (not a calendar followed by link), and it is not someone else's private time.\n */\nexport function canEditEvent(\n event: CalendarEventV2,\n calendar: CalendarV2 | undefined,\n me: string | null\n): boolean {\n if (!calendar || calendar.isReadOnly) return false;\n if (event.status === 'CANCELLED') return false;\n return isOrganizer(event, me);\n}\n\n/**\n * Drag and keyboard moves, which keep an event inside one day of the grid. Not for:\n * - a date of a repeating event: a move would change the series' own time (every date), and a\n * date changed on its own is an event of its own that the event dialog makes, carrying its\n * guests, reminders and room; so the dialog asks which events to change. A date already\n * moved on its own is its own event and moves like one;\n * - one that runs past midnight on the calendar's clock (23:00–01:00): kept inside one day it\n * would lose its times, so it changes in the event dialog;\n * - one that starts or ends in the second pass of an hour the clocks repeat (01:30 GMT on 25\n * October 2026 in London): the grid reads a clock time as its first pass, so a move would\n * shift it by the hour.\n */\nexport function canMoveOnGrid(\n event: CalendarEventV2,\n calendar: CalendarV2 | undefined,\n me: string | null,\n timeZone: string\n): boolean {\n if (!canEditEvent(event, calendar, me) || event.isRecurring || isAllDayRow(event)) return false;\n const days = eventDays(event, timeZone);\n if (days.start !== days.end) return false;\n return readsBackOnClock(event.start, timeZone) && readsBackOnClock(event.end, timeZone);\n}\n\n/**\n * Whether an instant's clock time on `timeZone` stands for that instant again (to the minute):\n * false in the second pass of a repeated hour, which the clock time reads as the first.\n */\nexport function readsBackOnClock(instant: Date, timeZone: string): boolean {\n const zoned = instantToZoned(instant, timeZone);\n const minute = Math.floor(instant.getTime() / 60_000) * 60_000;\n return zonedTimeToInstant(zoned.date, zoned.minutes, timeZone).getTime() === minute;\n}\n\n/** Shown in the all-day row: an all-day event, or one that lasts a day or more. */\nexport function isAllDayRow(event: CalendarEventV2): boolean {\n return event.allDay || event.end.getTime() - event.start.getTime() >= DAY_MS;\n}\n\n/** The event has ended (an all-day event: its last day is before today). */\nexport function isPastEvent(event: CalendarEventV2, now: Date, timeZone: string): boolean {\n if (event.allDay) {\n const today = instantToZoned(now, timeZone).date;\n return eventDays(event, timeZone).end < today;\n }\n return event.end.getTime() <= now.getTime();\n}\n\nexport function isHappeningNow(event: CalendarEventV2, now: Date): boolean {\n if (event.allDay) return false;\n const at = now.getTime();\n return event.start.getTime() <= at && event.end.getTime() > at;\n}\n\nexport interface ShownEventsOptions {\n hiddenCalendarIds: ReadonlySet<string>;\n showDeclined: boolean;\n me: string | null;\n}\n\n/**\n * The events the views show: on a shown calendar, not cancelled, and not declined unless the\n * person asked to see those.\n */\nexport function shownEvents(\n events: readonly CalendarEventV2[],\n options: ShownEventsOptions\n): CalendarEventV2[] {\n return events.filter(\n (event) =>\n !options.hiddenCalendarIds.has(event.calendarId) &&\n event.status !== 'CANCELLED' &&\n (options.showDeclined || myPart(event, options.me) !== 'declined')\n );\n}\n\n/** Invitations still waiting for the person's answer that haven't ended, soonest first. */\nexport function waitingInvitations(\n events: readonly CalendarEventV2[],\n now: Date,\n me: string | null\n): CalendarEventV2[] {\n return events\n .filter((event) => myPart(event, me) === 'invited' && event.end.getTime() > now.getTime())\n .sort((a, b) => a.start.getTime() - b.start.getTime());\n}\n\n/** A room booking: a room, or a resource of unknown type (rooms are what events book most). */\nfunction isRoomBooking(booking: EventBookingV2): boolean {\n return booking.resourceType === 'ROOM' || booking.resourceType === null;\n}\n\n/**\n * The room an event is in: its first room booking that wasn't cancelled or turned down, else a\n * turned-down one to warn about. Other resources (equipment) never stand in for the room, so a\n * refused room still shows next to approved equipment.\n */\nexport function eventRoom(event: CalendarEventV2): EventBookingV2 | null {\n const rooms = event.bookings.filter(isRoomBooking);\n return (\n rooms.find((booking) => booking.status === 'PENDING' || booking.status === 'APPROVED') ??\n rooms.find((booking) => booking.status === 'COMPLETED') ??\n rooms.find((booking) => booking.status === 'REJECTED') ??\n null\n );\n}\n\n/** A web address that is safe to open: http or https only. */\nexport function safeWebUrl(raw: string | null | undefined): string | null {\n const value = raw?.trim();\n if (!value) return null;\n const withScheme = /^[a-z][a-z0-9+.-]*:/i.test(value) ? value : `https://${value}`;\n try {\n const url = new URL(withScheme);\n return url.protocol === 'https:' || url.protocol === 'http:' ? url.toString() : null;\n } catch {\n return null;\n }\n}\n\n/** The video call to join: the meeting link, else a location that is a web address. */\nexport function joinUrl(event: CalendarEventV2): string | null {\n return (\n safeWebUrl(event.meeting?.url) ??\n (event.locationType === 'ONLINE' ? safeWebUrl(event.locationUrl) : null)\n );\n}\n\n/** A timed event's piece on one day. */\nexport interface DaySegment<T = CalendarEventV2> extends TimedSegment {\n event: T;\n}\n\n/**\n * Timed events' pieces on each of `days`, on the clock of `timeZone`. Events shown in the\n * all-day row (`isAllDayRow`) are left out, as the grid draws them there; `includeLong` keeps\n * the timed ones of a day or more, for what is busy (all-day events never are).\n */\nexport function timedSegmentsByDay(\n events: readonly CalendarEventV2[],\n days: readonly DateValue[],\n timeZone: string,\n options: { includeLong?: boolean } = {}\n): Map<DateValue, DaySegment[]> {\n const byDay = new Map<DateValue, DaySegment[]>(days.map((day) => [day, []]));\n const first = days[0];\n const last = days[days.length - 1];\n if (!first || !last) return byDay;\n for (const event of events) {\n if (event.allDay || (!options.includeLong && isAllDayRow(event))) continue;\n for (const segment of timedSegments(event.start, event.end, timeZone, first, last)) {\n byDay.get(segment.date)?.push({ ...segment, event });\n }\n }\n return byDay;\n}\n\n/** An event in the all-day row, from its first to its last day. */\nexport interface AllDayItem<T = CalendarEventV2> {\n event: T;\n first: DateValue;\n last: DateValue;\n}\n\n/** The all-day row's events that touch `first`..`last`. */\nexport function allDayItems(\n events: readonly CalendarEventV2[],\n first: DateValue,\n last: DateValue,\n timeZone: string\n): AllDayItem[] {\n const items: AllDayItem[] = [];\n for (const event of events) {\n if (!isAllDayRow(event)) continue;\n const span = eventDays(event, timeZone);\n if (span.end < first || span.start > last) continue;\n items.push({ event, first: span.start, last: span.end });\n }\n return items;\n}\n\n/**\n * The events on one day, for a day's list (Month's \"+N more\", phones' Month, the List view):\n * every event that touches the day (one over midnight on both its days, as the grid shows\n * it), all-day ones first, then by start.\n */\nexport function eventsOnDay(\n events: readonly CalendarEventV2[],\n day: DateValue,\n timeZone: string\n): CalendarEventV2[] {\n return events\n .filter((event) => {\n const span = eventDays(event, timeZone);\n return span.start <= day && span.end >= day;\n })\n .sort(\n (a, b) =>\n Number(isAllDayRow(b)) - Number(isAllDayRow(a)) ||\n a.start.getTime() - b.start.getTime() ||\n a.title.localeCompare(b.title)\n );\n}\n\n/** Which of an all-day item's days `day` is: 1 for its first. */\nexport function dayOfSpan(item: { first: DateValue }, day: DateValue): number {\n return dayDifference(item.first, day) + 1;\n}\n\n/** Whether an event falls on any of `days` (sorted), on the clock of `timeZone`. */\nexport function touchesDays(\n event: CalendarEventV2,\n days: ReadonlySet<DateValue>,\n first: DateValue,\n last: DateValue,\n timeZone: string\n): boolean {\n const span = eventDays(event, timeZone);\n if (span.end < first || span.start > last) return false;\n for (const day of days) if (day >= span.start && day <= span.end) return true;\n return false;\n}\n"],"mappings":";;AAqBA,IAAMA,IAAS;AASf,SAAgBC,EACd,GACS;CACT,OACEC,EAAM,eAAe,CAACA,EAAM,cAAcA,EAAM,aAAa,QAAQA,EAAM,iBAAiB;AAEhG;AAMA,SAAgBC,EAAa,GAA8C;CACzE,OAAOF,EAAaC,CAAK,KAAKA,EAAM,eAChC;EAAE,SAASA,EAAM;EAAS,cAAcA,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gBM,EACd,GACA,GACA,GACA,GACc;CACd,IAAMC,IAAsB,CAAC;CAC7B,KAAK,IAAMnD,KAAS4B,GAAQ;EAC1B,IAAI,CAAChB,EAAYZ,CAAK,GAAG;EACzB,IAAMoD,IAAOtC,EAAUd,GAAOe,CAAQ;EACtC,AAAIqC,EAAK,MAAMN,KAASM,EAAK,QAAQL,KACrCI,EAAM,KAAK;GAAE;GAAO,OAAOC,EAAK;GAAO,MAAMA,EAAK;EAAI,CAAC;CACzD;CACA,OAAOD;AACT;AAOA,SAAgBE,EACd,GACA,GACA,GACmB;CACnB,OAAOzB,EACJ,QAAQ,MAAU;EACjB,IAAMwB,IAAOtC,EAAUd,GAAOe,CAAQ;EACtC,OAAOqC,EAAK,SAASP,KAAOO,EAAK,OAAOP;CAC1C,CAAC,CAAC,CACD,MACE,GAAG,MACF,OAAOjC,EAAYoB,CAAC,CAAC,IAAI,OAAOpB,EAAYmB,CAAC,CAAC,KAC9CA,EAAE,MAAM,QAAQ,IAAIC,EAAE,MAAM,QAAQ,KACpCD,EAAE,MAAM,cAAcC,EAAE,KAAK,CACjC;AACJ;AAGA,SAAgBsB,EAAU,GAA4B,GAAwB;CAC5E,OAAOC,EAAcC,EAAK,OAAOX,CAAG,IAAI;AAC1C;AAGA,SAAgBY,EACd,GACA,GACA,GACA,GACA,GACS;CACT,IAAML,IAAOtC,EAAUd,GAAOe,CAAQ;CACtC,IAAIqC,EAAK,MAAMN,KAASM,EAAK,QAAQL,GAAM,OAAO;CAClD,KAAK,IAAMF,KAAOhC,GAAM,IAAIgC,KAAOO,EAAK,SAASP,KAAOO,EAAK,KAAK,OAAO;CACzE,OAAO;AACT"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { EventActions } from '../data/useEventActions';
|
|
2
2
|
import { CalendarEventV2 } from '../types';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Events with the changes made here laid over them: moved, answered, or deleted (one date, or a
|
|
5
|
+
* whole series by its id). An answer is the event's, so every date of a series shows it.
|
|
6
|
+
*/
|
|
4
7
|
export declare function withLocalChanges(events: readonly CalendarEventV2[], actions: Pick<EventActions, 'overrides' | 'removedIds' | 'answers'>, me: string | null): CalendarEventV2[];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// src/v2/events/localChanges.ts
|
|
2
2
|
function e(e, t, n) {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
if (t.overrides.size === 0 && t.removedIds.size === 0 && t.answers.size === 0) return [...e];
|
|
4
|
+
let r = t.removedIds;
|
|
5
|
+
return e.filter((e) => !r.has(e.id) && !(e.seriesId !== null && r.has(e.seriesId))).map((e) => {
|
|
6
|
+
let r = t.overrides.get(e.id), i = t.answers.get(e.eventId);
|
|
5
7
|
return !r && !i ? e : {
|
|
6
8
|
...e,
|
|
7
9
|
...r ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localChanges.js","names":["withLocalChanges","actions","events","event","times","answer","guest","me"],"sources":["../../../src/v2/events/localChanges.ts"],"sourcesContent":["/**\n * The changes made on this page that the service hasn't sent back yet (BOFF-15698 A1): moved\n * events show at their new times, answers as given, deleted events not at all. The views and\n * search lay them over what they loaded, so both agree until the next reload.\n */\nimport type { EventActions } from '../data/useEventActions';\nimport type { CalendarEventV2 } from '../types';\n\n
|
|
1
|
+
{"version":3,"file":"localChanges.js","names":["withLocalChanges","actions","events","removed","event","times","answer","guest","me"],"sources":["../../../src/v2/events/localChanges.ts"],"sourcesContent":["/**\n * The changes made on this page that the service hasn't sent back yet (BOFF-15698 A1): moved\n * events show at their new times, answers as given, deleted events not at all. The views and\n * search lay them over what they loaded, so both agree until the next reload.\n */\nimport type { EventActions } from '../data/useEventActions';\nimport type { CalendarEventV2 } from '../types';\n\n/**\n * Events with the changes made here laid over them: moved, answered, or deleted (one date, or a\n * whole series by its id). An answer is the event's, so every date of a series shows it.\n */\nexport function withLocalChanges(\n events: readonly CalendarEventV2[],\n actions: Pick<EventActions, 'overrides' | 'removedIds' | 'answers'>,\n me: string | null\n): CalendarEventV2[] {\n if (actions.overrides.size === 0 && actions.removedIds.size === 0 && actions.answers.size === 0) {\n return [...events];\n }\n const removed = actions.removedIds;\n return events\n .filter(\n (event) => !removed.has(event.id) && !(event.seriesId !== null && removed.has(event.seriesId))\n )\n .map((event) => {\n const times = actions.overrides.get(event.id);\n const answer = actions.answers.get(event.eventId);\n if (!times && !answer) return event;\n return {\n ...event,\n ...(times ? { start: times.start, end: times.end } : {}),\n ...(answer\n ? {\n myResponse: answer,\n guests: event.guests.map((guest) =>\n guest.userId === me ? { ...guest, response: answer } : guest\n ),\n }\n : {}),\n };\n });\n}\n"],"mappings":";AAYA,SAAgBA,EACd,GACA,GACA,GACmB;CACnB,IAAIC,EAAQ,UAAU,SAAS,KAAKA,EAAQ,WAAW,SAAS,KAAKA,EAAQ,QAAQ,SAAS,GAC5F,OAAO,CAAC,GAAGC,CAAM;CAEnB,IAAMC,IAAUF,EAAQ;CACxB,OAAOC,EACJ,QACE,MAAU,CAACC,EAAQ,IAAIC,EAAM,EAAE,KAAK,EAAEA,EAAM,aAAa,QAAQD,EAAQ,IAAIC,EAAM,QAAQ,EAC9F,CAAC,CACA,KAAK,MAAU;EACd,IAAMC,IAAQJ,EAAQ,UAAU,IAAIG,EAAM,EAAE,GACtCE,IAASL,EAAQ,QAAQ,IAAIG,EAAM,OAAO;EAEhD,OADI,CAACC,KAAS,CAACC,IAAeF,IACvB;GACL,GAAGA;GACH,GAAIC,IAAQ;IAAE,OAAOA,EAAM;IAAO,KAAKA,EAAM;GAAI,IAAI,CAAC;GACtD,GAAIC,IACA;IACE,YAAYA;IACZ,QAAQF,EAAM,OAAO,KAAK,MACxBG,EAAM,WAAWC,IAAK;KAAE,GAAGD;KAAO,UAAUD;IAAO,IAAIC,CACzD;GACF,IACA,CAAC;EACP;CACF,CAAC;AACL"}
|
|
@@ -80,8 +80,8 @@ export interface CalendarPageModel {
|
|
|
80
80
|
closeQuickCreate: () => void;
|
|
81
81
|
/** Opens the event dialog (A2) with what it should show. */
|
|
82
82
|
openEventDialog: (draft: CalendarV2EventDraft) => void;
|
|
83
|
-
/** Opens Find a time (A2), for an event when given (moving it). */
|
|
84
|
-
openFindTime: (
|
|
83
|
+
/** Opens Find a time (A2), for an event when given (moving it: one date of a series, A4). */
|
|
84
|
+
openFindTime: (event?: CalendarEventV2) => void;
|
|
85
85
|
railSheetOpen: boolean;
|
|
86
86
|
setRailSheetOpen: (open: boolean) => void;
|
|
87
87
|
/** Phones: the search field shows under the toolbar. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarPageContext.js","names":["CalendarPageContext","createContext","useCalendarPage","model","use"],"sources":["../../../src/v2/page/CalendarPageContext.tsx"],"sourcesContent":["/**\n * Everything the calendar page's parts share (BOFF-15698 A1): the settings, the clock, the\n * calendars and events the view shows, what can be done to them, and the open peek and quick\n * create. Built once per page by `useCalendarPageModel`.\n */\nimport { createContext, use } from 'react';\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport type { CalendarHue } from '../colors';\nimport type { EventActions, Tr } from '../data/useEventActions';\nimport type { EventLook } from '../events/eventLook';\nimport type { RoomsV2 } from '../data/useRoomsV2';\nimport type { CalendarFormat, DurationWords } from '../format';\nimport type { DayHours } from '../grid/workingHours';\nimport type { CalendarPrefs } from '../prefs/calendarPrefs';\nimport type { MainState } from './viewState';\nimport type { CalendarV2Navigation } from '../state/useCalendarV2Navigation';\nimport type { CalendarEventV2, CalendarV2, CalendarV2EventDraft, EventResponseV2 } from '../types';\n\n/** A new event being set up in the quick create popover. */\nexport interface QuickDraft {\n date: DateValue;\n /** Minutes on the calendar's clock; `end` up to 1440. */\n start: number;\n end: number;\n allDay: boolean;\n /** What the popover points at: the ghost block, a free gap, a day. */\n anchor: HTMLElement | null;\n}\n\nexport interface CalendarPageModel {\n tr: Tr;\n format: CalendarFormat;\n durationWords: DurationWords;\n prefs: CalendarPrefs;\n timeZone: string;\n /** Now, to the minute. */\n now: Date;\n today: DateValue;\n /** Now's minute on the calendar's clock. */\n nowMinute: number;\n /** A phone-sized window: 3 days, sheets, no dragging. */\n compact: boolean;\n me: string | null;\n nav: CalendarV2Navigation;\n /** The days the view shows. */\n days: DateValue[];\n\n calendars: CalendarV2[];\n calendarsById: ReadonlyMap<string, CalendarV2>;\n calendarsStatus: 'idle' | 'loading' | 'ready' | 'error';\n calendarsError: Error | null;\n refetchCalendars: () => void;\n hiddenCalendarIds: ReadonlySet<string>;\n /** The calendar new events go on: the default one the person can write to. */\n defaultCalendarId: string | null;\n /** Calendars the person can add events to. */\n writableCalendars: CalendarV2[];\n hueOf: (calendarId: string) => CalendarHue;\n\n /** The view's events, on shown calendars, with changes made here laid over them. */\n events: CalendarEventV2[];\n /** The view's events before the calendar filter (the peek finds hidden ones too). */\n allLoadedEvents: CalendarEventV2[];\n eventsError: Error | null;\n refetchEvents: () => void;\n state: MainState;\n /** Invitations in the view still waiting for an answer, soonest first. */\n invitations: CalendarEventV2[];\n\n /**\n * The working hours on a day: null for a day off, undefined while they aren't known (see\n * `workingHoursStatus`).\n */\n workingHoursOn: (date: DateValue) => DayHours | null | undefined;\n /** `loading` before free/busy first answers; `error` when it failed before ever answering. */\n workingHoursStatus: 'ready' | 'loading' | 'error';\n refetchWorkingHours: () => void;\n rooms: RoomsV2;\n\n actions: EventActions;\n /** The person's answer, with one given here winning until the views reload. */\n answerOf: (event: CalendarEventV2) => EventResponseV2 | null;\n /** How an event looks: its markers, title and place. */\n lookOf: (event: CalendarEventV2) => EventLook;\n /** What a screen reader hears for an event. */\n labelOf: (event: CalendarEventV2) => string;\n\n openPeek: (event: CalendarEventV2, opener: HTMLElement | null) => void;\n peekAnchor: HTMLElement | null;\n closePeek: () => void;\n\n quickDraft: QuickDraft | null;\n openQuickCreate: (draft: QuickDraft) => void;\n closeQuickCreate: () => void;\n /** Opens the event dialog (A2) with what it should show. */\n openEventDialog: (draft: CalendarV2EventDraft) => void;\n /** Opens Find a time (A2), for an event when given (moving it). */\n openFindTime: (
|
|
1
|
+
{"version":3,"file":"CalendarPageContext.js","names":["CalendarPageContext","createContext","useCalendarPage","model","use"],"sources":["../../../src/v2/page/CalendarPageContext.tsx"],"sourcesContent":["/**\n * Everything the calendar page's parts share (BOFF-15698 A1): the settings, the clock, the\n * calendars and events the view shows, what can be done to them, and the open peek and quick\n * create. Built once per page by `useCalendarPageModel`.\n */\nimport { createContext, use } from 'react';\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport type { CalendarHue } from '../colors';\nimport type { EventActions, Tr } from '../data/useEventActions';\nimport type { EventLook } from '../events/eventLook';\nimport type { RoomsV2 } from '../data/useRoomsV2';\nimport type { CalendarFormat, DurationWords } from '../format';\nimport type { DayHours } from '../grid/workingHours';\nimport type { CalendarPrefs } from '../prefs/calendarPrefs';\nimport type { MainState } from './viewState';\nimport type { CalendarV2Navigation } from '../state/useCalendarV2Navigation';\nimport type { CalendarEventV2, CalendarV2, CalendarV2EventDraft, EventResponseV2 } from '../types';\n\n/** A new event being set up in the quick create popover. */\nexport interface QuickDraft {\n date: DateValue;\n /** Minutes on the calendar's clock; `end` up to 1440. */\n start: number;\n end: number;\n allDay: boolean;\n /** What the popover points at: the ghost block, a free gap, a day. */\n anchor: HTMLElement | null;\n}\n\nexport interface CalendarPageModel {\n tr: Tr;\n format: CalendarFormat;\n durationWords: DurationWords;\n prefs: CalendarPrefs;\n timeZone: string;\n /** Now, to the minute. */\n now: Date;\n today: DateValue;\n /** Now's minute on the calendar's clock. */\n nowMinute: number;\n /** A phone-sized window: 3 days, sheets, no dragging. */\n compact: boolean;\n me: string | null;\n nav: CalendarV2Navigation;\n /** The days the view shows. */\n days: DateValue[];\n\n calendars: CalendarV2[];\n calendarsById: ReadonlyMap<string, CalendarV2>;\n calendarsStatus: 'idle' | 'loading' | 'ready' | 'error';\n calendarsError: Error | null;\n refetchCalendars: () => void;\n hiddenCalendarIds: ReadonlySet<string>;\n /** The calendar new events go on: the default one the person can write to. */\n defaultCalendarId: string | null;\n /** Calendars the person can add events to. */\n writableCalendars: CalendarV2[];\n hueOf: (calendarId: string) => CalendarHue;\n\n /** The view's events, on shown calendars, with changes made here laid over them. */\n events: CalendarEventV2[];\n /** The view's events before the calendar filter (the peek finds hidden ones too). */\n allLoadedEvents: CalendarEventV2[];\n eventsError: Error | null;\n refetchEvents: () => void;\n state: MainState;\n /** Invitations in the view still waiting for an answer, soonest first. */\n invitations: CalendarEventV2[];\n\n /**\n * The working hours on a day: null for a day off, undefined while they aren't known (see\n * `workingHoursStatus`).\n */\n workingHoursOn: (date: DateValue) => DayHours | null | undefined;\n /** `loading` before free/busy first answers; `error` when it failed before ever answering. */\n workingHoursStatus: 'ready' | 'loading' | 'error';\n refetchWorkingHours: () => void;\n rooms: RoomsV2;\n\n actions: EventActions;\n /** The person's answer, with one given here winning until the views reload. */\n answerOf: (event: CalendarEventV2) => EventResponseV2 | null;\n /** How an event looks: its markers, title and place. */\n lookOf: (event: CalendarEventV2) => EventLook;\n /** What a screen reader hears for an event. */\n labelOf: (event: CalendarEventV2) => string;\n\n openPeek: (event: CalendarEventV2, opener: HTMLElement | null) => void;\n peekAnchor: HTMLElement | null;\n closePeek: () => void;\n\n quickDraft: QuickDraft | null;\n openQuickCreate: (draft: QuickDraft) => void;\n closeQuickCreate: () => void;\n /** Opens the event dialog (A2) with what it should show. */\n openEventDialog: (draft: CalendarV2EventDraft) => void;\n /** Opens Find a time (A2), for an event when given (moving it: one date of a series, A4). */\n openFindTime: (event?: CalendarEventV2) => void;\n\n railSheetOpen: boolean;\n setRailSheetOpen: (open: boolean) => void;\n /** Phones: the search field shows under the toolbar. */\n phoneSearchOpen: boolean;\n setPhoneSearchOpen: (open: boolean) => void;\n}\n\nexport const CalendarPageContext = createContext<CalendarPageModel | null>(null);\n\nexport function useCalendarPage(): CalendarPageModel {\n const model = use(CalendarPageContext);\n if (!model) throw new Error('useCalendarPage must be used within the calendar page');\n return model;\n}\n"],"mappings":";;AA0GA,IAAaA,IAAsBC,EAAwC,IAAI;AAE/E,SAAgBC,IAAqC;CACnD,IAAMC,IAAQC,EAAIJ,CAAmB;CACrC,IAAI,CAACG,GAAO,MAAU,MAAM,uDAAuD;CACnF,OAAOA;AACT"}
|