@burdenoff/microfe-calendar 2026.1124.2 → 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 +811 -69
- package/dist/generated/wspace-operations.js +173 -19
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +405 -6
- package/dist/pages/ResourcesPage.js.map +1 -1
- package/dist/translations/en.d.ts +250 -1
- 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/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/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/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 +35 -0
- package/dist/v2/event/EventDialog.js +388 -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 +118 -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 +215 -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 +91 -0
- package/dist/v2/event/RepeatField.js.map +1 -0
- package/dist/v2/event/dialogLogic.d.ts +97 -0
- package/dist/v2/event/dialogLogic.js +120 -0
- package/dist/v2/event/dialogLogic.js.map +1 -0
- package/dist/v2/event/dialogModel.d.ts +51 -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 +235 -0
- package/dist/v2/event/eventForm.js +450 -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 +160 -0
- package/dist/v2/event/savePlan.js +219 -0
- package/dist/v2/event/savePlan.js.map +1 -0
- package/dist/v2/event/useEventData.d.ts +96 -0
- package/dist/v2/event/useEventData.js +229 -0
- package/dist/v2/event/useEventData.js.map +1 -0
- package/dist/v2/event/useEventDialogModel.d.ts +50 -0
- package/dist/v2/event/useEventDialogModel.js +144 -0
- package/dist/v2/event/useEventDialogModel.js.map +1 -0
- package/dist/v2/event/useEventSave.d.ts +57 -0
- package/dist/v2/event/useEventSave.js +276 -0
- package/dist/v2/event/useEventSave.js.map +1 -0
- 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/format.d.ts +2 -0
- package/dist/v2/format.js +4 -0
- package/dist/v2/format.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/EventPeek.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/CalendarRail.js.map +1 -1
- package/dist/v2/rail/useMonthEventDates.js +1 -1
- package/dist/v2/rail/useMonthEventDates.js.map +1 -1
- package/dist/v2/runs/RunPeek.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 +32 -2
- package/package.json +1 -1
|
@@ -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"}
|
|
@@ -2,197 +2,199 @@ import { useCalendar as e } from "../../providers/CalendarProvider.js";
|
|
|
2
2
|
import { useTr as t } from "../../shared/hooks/useTr.js";
|
|
3
3
|
import { calendarHue as n } from "../colors.js";
|
|
4
4
|
import { useCalendarsV2 as r } from "../data/useCalendarsV2.js";
|
|
5
|
-
import { answerFor as i, useEventActions as
|
|
6
|
-
import { useEventsInRangeV2 as
|
|
7
|
-
import { useFreeBusy as
|
|
8
|
-
import { useRoomsV2 as
|
|
9
|
-
import { eventAriaLabel as
|
|
10
|
-
import { shownEvents as
|
|
11
|
-
import { withLocalChanges as
|
|
12
|
-
import { resolveCalendarLocale as
|
|
13
|
-
import { workingHoursOn as
|
|
14
|
-
import { useIsCompact as
|
|
15
|
-
import { useNowMs as
|
|
16
|
-
import { useCalendarPrefs as
|
|
17
|
-
import { useCalendarV2Store as
|
|
5
|
+
import { answerFor as i, useEventActions as a } from "../data/useEventActions.js";
|
|
6
|
+
import { useEventsInRangeV2 as ee } from "../data/useEventsInRangeV2.js";
|
|
7
|
+
import { useFreeBusy as te } from "../data/useFreeBusy.js";
|
|
8
|
+
import { useRoomsV2 as ne } from "../data/useRoomsV2.js";
|
|
9
|
+
import { eventAriaLabel as re, eventLook as ie } from "../events/eventLook.js";
|
|
10
|
+
import { editDraftFor as o, shownEvents as s, touchesDays as c, waitingInvitations as ae } from "../events/eventModel.js";
|
|
11
|
+
import { withLocalChanges as oe } from "../events/localChanges.js";
|
|
12
|
+
import { resolveCalendarLocale as se } from "../format.js";
|
|
13
|
+
import { workingHoursOn as l } from "../grid/workingHours.js";
|
|
14
|
+
import { useIsCompact as u } from "../hooks/useMediaQuery.js";
|
|
15
|
+
import { useNowMs as d } from "../hooks/useNow.js";
|
|
16
|
+
import { useCalendarPrefs as f, useCalendarTimeZone as ce } from "../prefs/CalendarPrefsProvider.js";
|
|
17
|
+
import { useCalendarV2Store as p } from "../state/calendarV2Store.js";
|
|
18
18
|
import { useCalendarV2Navigation as le } from "../state/useCalendarV2Navigation.js";
|
|
19
|
-
import { instantToZoned as ue, today as
|
|
20
|
-
import { mainState as
|
|
21
|
-
import { useCallback as
|
|
19
|
+
import { instantToZoned as ue, today as m, viewQueryRange as de } from "../time/calendarTime.js";
|
|
20
|
+
import { mainState as fe } from "./viewState.js";
|
|
21
|
+
import { useCallback as h, useEffect as pe, useMemo as g, useState as _ } from "react";
|
|
22
22
|
import { useI18n as me } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
23
23
|
// src/v2/page/useCalendarPageModel.ts
|
|
24
|
-
var
|
|
24
|
+
var v = [];
|
|
25
25
|
function he(e, t, n) {
|
|
26
26
|
if (t === null) return () => void 0;
|
|
27
|
-
let r = new Map(e.map((e) => [e,
|
|
28
|
-
return (e) => r.has(e) ? r.get(e) ?? null :
|
|
27
|
+
let r = new Map(e.map((e) => [e, l(e, t, n)]));
|
|
28
|
+
return (e) => r.has(e) ? r.get(e) ?? null : l(e, t, n);
|
|
29
29
|
}
|
|
30
30
|
function ge() {
|
|
31
31
|
return typeof navigator > "u" ? [] : navigator.languages?.length ? navigator.languages : navigator.language ? [navigator.language] : [];
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
let
|
|
35
|
-
locale:
|
|
36
|
-
hourCycle:
|
|
37
|
-
}), [
|
|
38
|
-
minutes:
|
|
39
|
-
hours:
|
|
40
|
-
hoursMinutes:
|
|
41
|
-
}), [
|
|
42
|
-
weekStart:
|
|
43
|
-
showWeekends:
|
|
44
|
-
compact:
|
|
33
|
+
function y() {
|
|
34
|
+
let l = t(), { locale: y } = me(), { currentUser: _e } = e(), b = _e?.id ?? null, { prefs: x } = f(), S = ce(), C = u(), w = le(), T = d(), E = g(() => new Date(T), [T]), ve = m(S, E), ye = ue(E, S).minutes, D = g(() => ({
|
|
35
|
+
locale: se(y, ge()),
|
|
36
|
+
hourCycle: x.hourCycle
|
|
37
|
+
}), [y, x.hourCycle]), O = g(() => ({
|
|
38
|
+
minutes: l("calendar.v2.durationMinutes", "{{minutes}} min"),
|
|
39
|
+
hours: l("calendar.v2.durationHours", "{{hours}} h"),
|
|
40
|
+
hoursMinutes: l("calendar.v2.durationHoursMinutes", "{{hours}} h {{minutes}} min")
|
|
41
|
+
}), [l]), k = g(() => ({
|
|
42
|
+
weekStart: x.weekStart,
|
|
43
|
+
showWeekends: x.showWeekends,
|
|
44
|
+
compact: C
|
|
45
45
|
}), [
|
|
46
|
+
C,
|
|
47
|
+
x.showWeekends,
|
|
48
|
+
x.weekStart
|
|
49
|
+
]), A = g(() => de(w.view, w.date, k, S), [
|
|
50
|
+
w.date,
|
|
51
|
+
w.view,
|
|
46
52
|
S,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
]), k = h(() => fe(C.view, C.date, O, x), [
|
|
50
|
-
C.date,
|
|
51
|
-
C.view,
|
|
52
|
-
x,
|
|
53
|
-
O
|
|
54
|
-
]), A = r(), j = f((e) => e.hiddenCalendarIds), M = h(() => new Set(j), [j]), N = h(() => new Map(A.calendars.map((e) => [e.id, e])), [A.calendars]), P = h(() => A.calendars.filter((e) => !M.has(e.id)).map((e) => e.id), [A.calendars, M]), F = h(() => A.calendars.filter((e) => !e.isReadOnly && e.section === "mine"), [A.calendars]), be = F.find((e) => e.isDefault)?.id ?? F[0]?.id ?? null, I = h(() => {
|
|
53
|
+
k
|
|
54
|
+
]), j = r(), M = p((e) => e.hiddenCalendarIds), N = g(() => new Set(M), [M]), P = g(() => new Map(j.calendars.map((e) => [e.id, e])), [j.calendars]), be = g(() => j.calendars.filter((e) => !N.has(e.id)).map((e) => e.id), [j.calendars, N]), F = g(() => j.calendars.filter((e) => !e.isReadOnly && e.section === "mine"), [j.calendars]), xe = F.find((e) => e.isDefault)?.id ?? F[0]?.id ?? null, I = g(() => {
|
|
55
55
|
let e = /* @__PURE__ */ new Map();
|
|
56
|
-
for (let t of
|
|
56
|
+
for (let t of j.calendars) e.set(t.id, n(t.color, t.id));
|
|
57
57
|
return e;
|
|
58
|
-
}, [
|
|
59
|
-
tr:
|
|
60
|
-
format:
|
|
61
|
-
durationWords:
|
|
62
|
-
timeZone:
|
|
63
|
-
me:
|
|
64
|
-
showDeclined:
|
|
65
|
-
defaultReminder:
|
|
66
|
-
reloadCalendars:
|
|
58
|
+
}, [j.calendars]), Se = h((e) => I.get(e) ?? n(null, e), [I]), L = ee(be, A.from, A.to, { skip: j.status !== "ready" }), R = a({
|
|
59
|
+
tr: l,
|
|
60
|
+
format: D,
|
|
61
|
+
durationWords: O,
|
|
62
|
+
timeZone: S,
|
|
63
|
+
me: b,
|
|
64
|
+
showDeclined: x.showDeclined,
|
|
65
|
+
defaultReminder: x.defaultReminder,
|
|
66
|
+
reloadCalendars: j.refetch
|
|
67
67
|
}), { settle: z } = R;
|
|
68
68
|
pe(() => {
|
|
69
69
|
z(L.events);
|
|
70
70
|
}, [L.events, z]);
|
|
71
|
-
let B =
|
|
71
|
+
let B = g(() => oe(L.events, R, b), [
|
|
72
72
|
R,
|
|
73
73
|
L.events,
|
|
74
|
-
|
|
75
|
-
]), V =
|
|
76
|
-
hiddenCalendarIds:
|
|
77
|
-
showDeclined:
|
|
78
|
-
me:
|
|
74
|
+
b
|
|
75
|
+
]), V = g(() => s(B, {
|
|
76
|
+
hiddenCalendarIds: N,
|
|
77
|
+
showDeclined: x.showDeclined,
|
|
78
|
+
me: b
|
|
79
79
|
}), [
|
|
80
80
|
B,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
]), H =
|
|
85
|
-
let e = new Set(
|
|
86
|
-
return !t || !n ? [] : V.filter((r) =>
|
|
81
|
+
N,
|
|
82
|
+
b,
|
|
83
|
+
x.showDeclined
|
|
84
|
+
]), H = g(() => {
|
|
85
|
+
let e = new Set(A.days), t = A.days[0], n = A.days[A.days.length - 1];
|
|
86
|
+
return !t || !n ? [] : V.filter((r) => c(r, e, t, n, S));
|
|
87
87
|
}, [
|
|
88
88
|
V,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
]),
|
|
89
|
+
A.days,
|
|
90
|
+
S
|
|
91
|
+
]), Ce = g(() => ae(H, E, b), [
|
|
92
92
|
H,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
]),
|
|
93
|
+
b,
|
|
94
|
+
E
|
|
95
|
+
]), we = H.length, Te = fe({
|
|
96
96
|
calendars: {
|
|
97
|
-
status:
|
|
98
|
-
count:
|
|
97
|
+
status: j.status,
|
|
98
|
+
count: j.calendars.length
|
|
99
99
|
},
|
|
100
|
-
hiddenCount:
|
|
100
|
+
hiddenCount: j.calendars.filter((e) => N.has(e.id)).length,
|
|
101
101
|
events: {
|
|
102
102
|
status: L.status,
|
|
103
|
-
failedCalendarIds: L.failedCalendarIds
|
|
103
|
+
failedCalendarIds: L.failedCalendarIds,
|
|
104
|
+
unreadableCalendarIds: L.unreadableCalendarIds,
|
|
105
|
+
truncated: L.truncated
|
|
104
106
|
},
|
|
105
|
-
eventCount:
|
|
106
|
-
}), U =
|
|
107
|
-
|
|
107
|
+
eventCount: we
|
|
108
|
+
}), U = te(b ? [b] : [], A.from, A.to, { skip: !b }), W = U.lastAnswer, G = g(() => b ? W ? W.get(b)?.workingHours ?? v : null : v, [W, b]), Ee = G === null ? U.status === "error" ? "error" : "loading" : "ready", De = g(() => he(A.days, G, S), [
|
|
109
|
+
A.days,
|
|
108
110
|
G,
|
|
109
|
-
|
|
110
|
-
]),
|
|
111
|
-
tr:
|
|
112
|
-
me:
|
|
113
|
-
now:
|
|
114
|
-
timeZone:
|
|
115
|
-
dimPast:
|
|
116
|
-
calendar:
|
|
117
|
-
answer: i(e, Y,
|
|
111
|
+
S
|
|
112
|
+
]), Oe = ne(), [ke, K] = _(null), [Ae, q] = _(null), [je, Me] = _(!1), [Ne, Pe] = _(!1), J = p((e) => e.setEventDraft), { answers: Y } = R, Fe = h((e) => i(e, Y, b), [Y, b]), X = h((e) => ie(e, {
|
|
113
|
+
tr: l,
|
|
114
|
+
me: b,
|
|
115
|
+
now: E,
|
|
116
|
+
timeZone: S,
|
|
117
|
+
dimPast: x.dimPast,
|
|
118
|
+
calendar: P.get(e.calendarId),
|
|
119
|
+
answer: i(e, Y, b)
|
|
118
120
|
}), [
|
|
119
121
|
Y,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
T,
|
|
123
|
-
b.dimPast,
|
|
124
|
-
x,
|
|
125
|
-
s
|
|
126
|
-
]), Fe = m((e) => ie(e, X(e), {
|
|
127
|
-
tr: s,
|
|
128
|
-
format: E,
|
|
129
|
-
timeZone: x,
|
|
130
|
-
calendarName: N.get(e.calendarId)?.name ?? null
|
|
131
|
-
}), [
|
|
132
|
-
N,
|
|
122
|
+
P,
|
|
123
|
+
b,
|
|
133
124
|
E,
|
|
125
|
+
x.dimPast,
|
|
126
|
+
S,
|
|
127
|
+
l
|
|
128
|
+
]), Ie = h((e) => re(e, X(e), {
|
|
129
|
+
tr: l,
|
|
130
|
+
format: D,
|
|
131
|
+
timeZone: S,
|
|
132
|
+
calendarName: P.get(e.calendarId)?.name ?? null
|
|
133
|
+
}), [
|
|
134
|
+
P,
|
|
135
|
+
D,
|
|
134
136
|
X,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
]), { openEvent: Z, closeEvent: Q, openDialog: $ } =
|
|
137
|
+
S,
|
|
138
|
+
l
|
|
139
|
+
]), { openEvent: Z, closeEvent: Q, openDialog: $ } = w, Le = h((e, t) => {
|
|
138
140
|
q(null), K(t), Z(e.id);
|
|
139
|
-
}, [Z]),
|
|
141
|
+
}, [Z]), Re = h(() => {
|
|
140
142
|
K(null), Q();
|
|
141
|
-
}, [Q]),
|
|
143
|
+
}, [Q]), ze = h((e) => {
|
|
142
144
|
q(null), K(null), J(e), $("event");
|
|
143
|
-
}, [$, J]),
|
|
144
|
-
q(null), K(null), J(e ?
|
|
145
|
+
}, [$, J]), Be = h((e) => {
|
|
146
|
+
q(null), K(null), J(e ? o(e) : null), $("findtime");
|
|
145
147
|
}, [$, J]);
|
|
146
148
|
return {
|
|
147
|
-
tr:
|
|
148
|
-
format:
|
|
149
|
-
durationWords:
|
|
150
|
-
prefs:
|
|
151
|
-
timeZone:
|
|
152
|
-
now:
|
|
149
|
+
tr: l,
|
|
150
|
+
format: D,
|
|
151
|
+
durationWords: O,
|
|
152
|
+
prefs: x,
|
|
153
|
+
timeZone: S,
|
|
154
|
+
now: E,
|
|
153
155
|
today: ve,
|
|
154
156
|
nowMinute: ye,
|
|
155
|
-
compact:
|
|
156
|
-
me:
|
|
157
|
-
nav:
|
|
158
|
-
days:
|
|
159
|
-
calendars:
|
|
160
|
-
calendarsById:
|
|
161
|
-
calendarsStatus:
|
|
162
|
-
calendarsError:
|
|
163
|
-
refetchCalendars:
|
|
164
|
-
hiddenCalendarIds:
|
|
165
|
-
defaultCalendarId:
|
|
157
|
+
compact: C,
|
|
158
|
+
me: b,
|
|
159
|
+
nav: w,
|
|
160
|
+
days: A.days,
|
|
161
|
+
calendars: j.calendars,
|
|
162
|
+
calendarsById: P,
|
|
163
|
+
calendarsStatus: j.status,
|
|
164
|
+
calendarsError: j.error,
|
|
165
|
+
refetchCalendars: j.refetch,
|
|
166
|
+
hiddenCalendarIds: N,
|
|
167
|
+
defaultCalendarId: xe,
|
|
166
168
|
writableCalendars: F,
|
|
167
|
-
hueOf:
|
|
169
|
+
hueOf: Se,
|
|
168
170
|
events: V,
|
|
169
171
|
allLoadedEvents: B,
|
|
170
172
|
eventsError: L.error,
|
|
171
173
|
refetchEvents: L.refetch,
|
|
172
|
-
state:
|
|
173
|
-
invitations:
|
|
174
|
-
workingHoursOn:
|
|
175
|
-
workingHoursStatus:
|
|
174
|
+
state: Te,
|
|
175
|
+
invitations: Ce,
|
|
176
|
+
workingHoursOn: De,
|
|
177
|
+
workingHoursStatus: Ee,
|
|
176
178
|
refetchWorkingHours: U.refetch,
|
|
177
|
-
rooms:
|
|
179
|
+
rooms: Oe,
|
|
178
180
|
actions: R,
|
|
179
|
-
answerOf:
|
|
181
|
+
answerOf: Fe,
|
|
180
182
|
lookOf: X,
|
|
181
|
-
labelOf:
|
|
182
|
-
openPeek:
|
|
183
|
-
peekAnchor:
|
|
184
|
-
closePeek:
|
|
185
|
-
quickDraft:
|
|
183
|
+
labelOf: Ie,
|
|
184
|
+
openPeek: Le,
|
|
185
|
+
peekAnchor: ke,
|
|
186
|
+
closePeek: Re,
|
|
187
|
+
quickDraft: Ae,
|
|
186
188
|
openQuickCreate: q,
|
|
187
189
|
closeQuickCreate: () => q(null),
|
|
188
|
-
openEventDialog:
|
|
189
|
-
openFindTime:
|
|
190
|
-
railSheetOpen:
|
|
191
|
-
setRailSheetOpen:
|
|
192
|
-
phoneSearchOpen:
|
|
193
|
-
setPhoneSearchOpen:
|
|
190
|
+
openEventDialog: ze,
|
|
191
|
+
openFindTime: Be,
|
|
192
|
+
railSheetOpen: je,
|
|
193
|
+
setRailSheetOpen: Me,
|
|
194
|
+
phoneSearchOpen: Ne,
|
|
195
|
+
setPhoneSearchOpen: Pe
|
|
194
196
|
};
|
|
195
197
|
}
|
|
196
|
-
export {
|
|
198
|
+
export { y as useCalendarPageModel };
|
|
197
199
|
|
|
198
200
|
//# sourceMappingURL=useCalendarPageModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCalendarPageModel.js","names":["hoursOn","today","todayIn","NO_RULES","hoursLookup","rules","byDay","days","day","workingHoursOn","timeZone","date","deviceLanguages","useCalendarPageModel","tr","useTr","appLocale","useI18n","useCalendar","me","currentUser","useCalendarPrefs","useCalendarTimeZone","compact","useIsCompact","nav","useCalendarV2Navigation","nowMs","useNowMs","now","useMemo","today$1","today","nowMinute","instantToZoned","format","resolveCalendarLocale","prefs","durationWords","viewOptions","range","viewQueryRange","calendarsQuery","useCalendarsV2","hiddenList","useCalendarV2Store","state","hiddenCalendarIds","calendarsById","calendar","shownCalendarIds","c","writableCalendars","defaultCalendarId","hues","map","calendarHue","hueOf","useCallback","calendarId","loaded","useEventsInRangeV2","actions","useEventActions","settle","allLoadedEvents","withLocalChanges","events","shownEvents","eventsOnShownDays","daySet","first","last","touchesDays","event","invitations","waitingInvitations","shownDayCount","mainState","freeBusy","useFreeBusy","lastAnswer","workingHoursStatus","rooms","useRoomsV2","peekAnchor","setPeekAnchor","useState","quickDraft","setQuickDraft","railSheetOpen","setRailSheetOpen","phoneSearchOpen","setPhoneSearchOpen","setEventDraft","store","answerOf","answerFor","answers","lookOf","eventLook","labelOf","eventAriaLabel","openPeek","opener","openEvent","closePeek","closeEvent","openEventDialog","draft","openDialog","openFindTime","eventId"],"sources":["../../../src/v2/page/useCalendarPageModel.ts"],"sourcesContent":["/**\n * Builds the calendar page's shared model (BOFF-15698 A1) from the A0 hooks: the person's\n * settings, the address (view and day), the calendars and the view's events, rooms, working\n * hours, and the actions. See `CalendarPageContext`.\n */\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport { useCalendar } from '../../providers/CalendarProvider';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { calendarHue, type CalendarHue } from '../colors';\nimport { useCalendarsV2 } from '../data/useCalendarsV2';\nimport { answerFor, useEventActions } from '../data/useEventActions';\nimport { useEventsInRangeV2 } from '../data/useEventsInRangeV2';\nimport { useFreeBusy } from '../data/useFreeBusy';\nimport { useRoomsV2 } from '../data/useRoomsV2';\nimport { eventAriaLabel, eventLook } from '../events/eventLook';\nimport { shownEvents, touchesDays, waitingInvitations } from '../events/eventModel';\nimport { withLocalChanges } from '../events/localChanges';\nimport { resolveCalendarLocale, type CalendarFormat, type DurationWords } from '../format';\nimport { workingHoursOn as hoursOn, type DayHours } from '../grid/workingHours';\nimport { useIsCompact } from '../hooks/useMediaQuery';\nimport { useNowMs } from '../hooks/useNow';\nimport { useCalendarPrefs, useCalendarTimeZone } from '../prefs/CalendarPrefsProvider';\nimport { useCalendarV2Store } from '../state/calendarV2Store';\nimport { useCalendarV2Navigation } from '../state/useCalendarV2Navigation';\nimport { instantToZoned, today as todayIn, viewQueryRange } from '../time/calendarTime';\nimport type { CalendarEventV2, CalendarV2EventDraft, WorkingHoursV2 } from '../types';\nimport type { CalendarPageModel, QuickDraft } from './CalendarPageContext';\nimport { mainState } from './viewState';\n\n/** No rules (or no person to ask): the default working week. */\nconst NO_RULES: readonly WorkingHoursV2[] = [];\n\n/**\n * The working hours on a day, worked out once for the shown days; undefined for every day while\n * the rules aren't known (null).\n */\nfunction hoursLookup(\n days: readonly DateValue[],\n rules: readonly WorkingHoursV2[] | null,\n timeZone: string\n): (date: DateValue) => DayHours | null | undefined {\n if (rules === null) return () => undefined;\n const byDay = new Map(days.map((day) => [day, hoursOn(day, rules, timeZone)]));\n return (date) => (byDay.has(date) ? (byDay.get(date) ?? null) : hoursOn(date, rules, timeZone));\n}\n\nfunction deviceLanguages(): readonly string[] {\n if (typeof navigator === 'undefined') return [];\n return navigator.languages?.length\n ? navigator.languages\n : navigator.language\n ? [navigator.language]\n : [];\n}\n\nexport function useCalendarPageModel(): CalendarPageModel {\n const tr = useTr();\n const { locale: appLocale } = useI18n();\n const { currentUser } = useCalendar();\n const me = currentUser?.id ?? null;\n const { prefs } = useCalendarPrefs();\n const timeZone = useCalendarTimeZone();\n const compact = useIsCompact();\n const nav = useCalendarV2Navigation();\n const nowMs = useNowMs();\n const now = useMemo(() => new Date(nowMs), [nowMs]);\n const today = todayIn(timeZone, now);\n const nowMinute = instantToZoned(now, timeZone).minutes;\n\n const format = useMemo<CalendarFormat>(\n () => ({\n locale: resolveCalendarLocale(appLocale, deviceLanguages()),\n hourCycle: prefs.hourCycle,\n }),\n [appLocale, prefs.hourCycle]\n );\n const durationWords = useMemo<DurationWords>(\n () => ({\n minutes: tr('calendar.v2.durationMinutes', '{{minutes}} min'),\n hours: tr('calendar.v2.durationHours', '{{hours}} h'),\n hoursMinutes: tr('calendar.v2.durationHoursMinutes', '{{hours}} h {{minutes}} min'),\n }),\n [tr]\n );\n\n // The view's days and what to load for them.\n const viewOptions = useMemo(\n () => ({ weekStart: prefs.weekStart, showWeekends: prefs.showWeekends, compact }),\n [compact, prefs.showWeekends, prefs.weekStart]\n );\n const range = useMemo(\n () => viewQueryRange(nav.view, nav.date, viewOptions, timeZone),\n [nav.date, nav.view, timeZone, viewOptions]\n );\n\n // Calendars.\n const calendarsQuery = useCalendarsV2();\n const hiddenList = useCalendarV2Store((state) => state.hiddenCalendarIds);\n const hiddenCalendarIds = useMemo(() => new Set(hiddenList), [hiddenList]);\n const calendarsById = useMemo(\n () => new Map(calendarsQuery.calendars.map((calendar) => [calendar.id, calendar])),\n [calendarsQuery.calendars]\n );\n const shownCalendarIds = useMemo(\n () => calendarsQuery.calendars.filter((c) => !hiddenCalendarIds.has(c.id)).map((c) => c.id),\n [calendarsQuery.calendars, hiddenCalendarIds]\n );\n const writableCalendars = useMemo(\n () =>\n calendarsQuery.calendars.filter(\n (calendar) => !calendar.isReadOnly && calendar.section === 'mine'\n ),\n [calendarsQuery.calendars]\n );\n const defaultCalendarId =\n writableCalendars.find((calendar) => calendar.isDefault)?.id ??\n writableCalendars[0]?.id ??\n null;\n const hues = useMemo(() => {\n const map = new Map<string, CalendarHue>();\n for (const calendar of calendarsQuery.calendars)\n map.set(calendar.id, calendarHue(calendar.color, calendar.id));\n return map;\n }, [calendarsQuery.calendars]);\n const hueOf = useCallback(\n (calendarId: string) => hues.get(calendarId) ?? calendarHue(null, calendarId),\n [hues]\n );\n\n // Events.\n const loaded = useEventsInRangeV2(shownCalendarIds, range.from, range.to, {\n skip: calendarsQuery.status !== 'ready',\n });\n const actions = useEventActions({\n tr,\n format,\n durationWords,\n timeZone,\n me,\n showDeclined: prefs.showDeclined,\n defaultReminder: prefs.defaultReminder,\n reloadCalendars: calendarsQuery.refetch,\n });\n const { settle } = actions;\n useEffect(() => {\n settle(loaded.events);\n }, [loaded.events, settle]);\n const allLoadedEvents = useMemo(\n () => withLocalChanges(loaded.events, actions, me),\n [actions, loaded.events, me]\n );\n const events = useMemo(\n () => shownEvents(allLoadedEvents, { hiddenCalendarIds, showDeclined: prefs.showDeclined, me }),\n [allLoadedEvents, hiddenCalendarIds, me, prefs.showDeclined]\n );\n // The range asked for runs a day past the shown days on each side: count only what shows.\n const eventsOnShownDays = useMemo(() => {\n const daySet = new Set(range.days);\n const first = range.days[0];\n const last = range.days[range.days.length - 1];\n if (!first || !last) return [];\n return events.filter((event) => touchesDays(event, daySet, first, last, timeZone));\n }, [events, range.days, timeZone]);\n const invitations = useMemo(\n () => waitingInvitations(eventsOnShownDays, now, me),\n [eventsOnShownDays, me, now]\n );\n const shownDayCount = eventsOnShownDays.length;\n\n const state = mainState({\n calendars: { status: calendarsQuery.status, count: calendarsQuery.calendars.length },\n hiddenCount: calendarsQuery.calendars.filter((calendar) => hiddenCalendarIds.has(calendar.id))\n .length,\n events: { status: loaded.status, failedCalendarIds: loaded.failedCalendarIds },\n eventCount: shownDayCount,\n });\n\n // Working hours: the person's availability rules, as free/busy returns them for themselves.\n // The rules are weekly, so the last answer serves while another range loads. Before the first\n // answer, or when free/busy fails before ever answering, they aren't known: no shading and no\n // free gaps, never the Monday-to-Friday default, which is only for someone with no rules.\n const freeBusy = useFreeBusy(me ? [me] : [], range.from, range.to, { skip: !me });\n const lastAnswer = freeBusy.lastAnswer;\n const rules = useMemo((): readonly WorkingHoursV2[] | null => {\n if (!me) return NO_RULES;\n return lastAnswer ? (lastAnswer.get(me)?.workingHours ?? NO_RULES) : null;\n }, [lastAnswer, me]);\n const workingHoursStatus: CalendarPageModel['workingHoursStatus'] =\n rules !== null ? 'ready' : freeBusy.status === 'error' ? 'error' : 'loading';\n const workingHoursOn = useMemo(\n () => hoursLookup(range.days, rules, timeZone),\n [range.days, rules, timeZone]\n );\n\n const rooms = useRoomsV2();\n\n // Peek, quick create, sheets.\n const [peekAnchor, setPeekAnchor] = useState<HTMLElement | null>(null);\n const [quickDraft, setQuickDraft] = useState<QuickDraft | null>(null);\n const [railSheetOpen, setRailSheetOpen] = useState(false);\n const [phoneSearchOpen, setPhoneSearchOpen] = useState(false);\n const setEventDraft = useCalendarV2Store((store) => store.setEventDraft);\n\n const { answers } = actions;\n const answerOf = useCallback(\n (event: CalendarEventV2) => answerFor(event, answers, me),\n [answers, me]\n );\n const lookOf = useCallback(\n (event: CalendarEventV2) =>\n eventLook(event, {\n tr,\n me,\n now,\n timeZone,\n dimPast: prefs.dimPast,\n calendar: calendarsById.get(event.calendarId),\n answer: answerFor(event, answers, me),\n }),\n [answers, calendarsById, me, now, prefs.dimPast, timeZone, tr]\n );\n const labelOf = useCallback(\n (event: CalendarEventV2) =>\n eventAriaLabel(event, lookOf(event), {\n tr,\n format,\n timeZone,\n calendarName: calendarsById.get(event.calendarId)?.name ?? null,\n }),\n [calendarsById, format, lookOf, timeZone, tr]\n );\n\n const { openEvent, closeEvent, openDialog } = nav;\n const openPeek = useCallback(\n (event: CalendarEventV2, opener: HTMLElement | null) => {\n setQuickDraft(null);\n setPeekAnchor(opener);\n openEvent(event.id);\n },\n [openEvent]\n );\n const closePeek = useCallback(() => {\n setPeekAnchor(null);\n closeEvent();\n }, [closeEvent]);\n // A dialog replaces the peek and the quick create (`openDialog` closes the peek).\n const openEventDialog = useCallback(\n (draft: CalendarV2EventDraft) => {\n setQuickDraft(null);\n setPeekAnchor(null);\n setEventDraft(draft);\n openDialog('event');\n },\n [openDialog, setEventDraft]\n );\n const openFindTime = useCallback(\n (eventId?: string) => {\n setQuickDraft(null);\n setPeekAnchor(null);\n setEventDraft(eventId ? { eventId } : null);\n openDialog('findtime');\n },\n [openDialog, setEventDraft]\n );\n\n return {\n tr,\n format,\n durationWords,\n prefs,\n timeZone,\n now,\n today,\n nowMinute,\n compact,\n me,\n nav,\n days: range.days,\n calendars: calendarsQuery.calendars,\n calendarsById,\n calendarsStatus: calendarsQuery.status,\n calendarsError: calendarsQuery.error,\n refetchCalendars: calendarsQuery.refetch,\n hiddenCalendarIds,\n defaultCalendarId,\n writableCalendars,\n hueOf,\n events,\n allLoadedEvents,\n eventsError: loaded.error,\n refetchEvents: loaded.refetch,\n state,\n invitations,\n workingHoursOn,\n workingHoursStatus,\n refetchWorkingHours: freeBusy.refetch,\n rooms,\n actions,\n answerOf,\n lookOf,\n labelOf,\n openPeek,\n peekAnchor,\n closePeek,\n quickDraft,\n openQuickCreate: setQuickDraft,\n closeQuickCreate: () => setQuickDraft(null),\n openEventDialog,\n openFindTime,\n railSheetOpen,\n setRailSheetOpen,\n phoneSearchOpen,\n setPhoneSearchOpen,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAMG,IAAsC,CAAC;AAM7C,SAASC,GACP,GACA,GACA,GACkD;CAClD,IAAIC,MAAU,MAAM,aAAa,KAAA;CACjC,IAAMC,IAAQ,IAAI,IAAIC,EAAK,KAAK,MAAQ,CAACC,GAAKR,EAAQQ,GAAKH,GAAOK,CAAQ,CAAC,CAAC,CAAC;CAC7E,QAAQ,MAAUJ,EAAM,IAAIK,CAAI,IAAKL,EAAM,IAAIK,CAAI,KAAK,OAAQX,EAAQW,GAAMN,GAAOK,CAAQ;AAC/F;AAEA,SAASE,KAAqC;CAE5C,OADI,OAAO,YAAc,MAAoB,CAAC,IACvC,UAAU,WAAW,SACxB,UAAU,YACV,UAAU,WACR,CAAC,UAAU,QAAQ,IACnB,CAAC;AACT;AAEA,SAAgBC,IAA0C;CACxD,IAAMC,IAAKC,EAAM,GACX,EAAE,QAAQC,MAAcC,GAAQ,GAChC,EAAE,oBAAgBC,EAAY,GAC9BC,IAAKC,IAAa,MAAM,MACxB,E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ACA;EACA,OAAA/D;EACA;EACA;EACA;EACA;EACA,MAAMS,EAAM;EACZ,WAAWE,EAAe;EAC1B;EACA,iBAAiBA,EAAe;EAChC,gBAAgBA,EAAe;EAC/B,kBAAkBA,EAAe;EACjC;EACA;EACA;EACA;EACA;EACA;EACA,aAAakB,EAAO;EACpB,eAAeA,EAAO;EACtB;EACA;EACA;EACA;EACA,qBAAqBmB,EAAS;EAC9B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiBU;EACjB,wBAAwBA,EAAc,IAAI;EAC1C;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useCalendarPageModel.js","names":["hoursOn","today","todayIn","NO_RULES","hoursLookup","rules","byDay","days","day","workingHoursOn","timeZone","date","deviceLanguages","useCalendarPageModel","tr","useTr","appLocale","useI18n","useCalendar","me","currentUser","useCalendarPrefs","useCalendarTimeZone","compact","useIsCompact","nav","useCalendarV2Navigation","nowMs","useNowMs","now","useMemo","today$1","today","nowMinute","instantToZoned","format","resolveCalendarLocale","prefs","durationWords","viewOptions","range","viewQueryRange","calendarsQuery","useCalendarsV2","hiddenList","useCalendarV2Store","state","hiddenCalendarIds","calendarsById","calendar","shownCalendarIds","c","writableCalendars","defaultCalendarId","hues","map","calendarHue","hueOf","useCallback","calendarId","loaded","useEventsInRangeV2","actions","useEventActions","settle","allLoadedEvents","withLocalChanges","events","shownEvents","eventsOnShownDays","daySet","first","last","touchesDays","event","invitations","waitingInvitations","shownDayCount","mainState","freeBusy","useFreeBusy","lastAnswer","workingHoursStatus","rooms","useRoomsV2","peekAnchor","setPeekAnchor","useState","quickDraft","setQuickDraft","railSheetOpen","setRailSheetOpen","phoneSearchOpen","setPhoneSearchOpen","setEventDraft","store","answerOf","answerFor","answers","lookOf","eventLook","labelOf","eventAriaLabel","openPeek","opener","openEvent","closePeek","closeEvent","openEventDialog","draft","openDialog","openFindTime","editDraftFor"],"sources":["../../../src/v2/page/useCalendarPageModel.ts"],"sourcesContent":["/**\n * Builds the calendar page's shared model (BOFF-15698 A1) from the A0 hooks: the person's\n * settings, the address (view and day), the calendars and the view's events, rooms, working\n * hours, and the actions. See `CalendarPageContext`.\n */\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport { useCalendar } from '../../providers/CalendarProvider';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { calendarHue, type CalendarHue } from '../colors';\nimport { useCalendarsV2 } from '../data/useCalendarsV2';\nimport { answerFor, useEventActions } from '../data/useEventActions';\nimport { useEventsInRangeV2 } from '../data/useEventsInRangeV2';\nimport { useFreeBusy } from '../data/useFreeBusy';\nimport { useRoomsV2 } from '../data/useRoomsV2';\nimport { eventAriaLabel, eventLook } from '../events/eventLook';\nimport { editDraftFor, shownEvents, touchesDays, waitingInvitations } from '../events/eventModel';\nimport { withLocalChanges } from '../events/localChanges';\nimport { resolveCalendarLocale, type CalendarFormat, type DurationWords } from '../format';\nimport { workingHoursOn as hoursOn, type DayHours } from '../grid/workingHours';\nimport { useIsCompact } from '../hooks/useMediaQuery';\nimport { useNowMs } from '../hooks/useNow';\nimport { useCalendarPrefs, useCalendarTimeZone } from '../prefs/CalendarPrefsProvider';\nimport { useCalendarV2Store } from '../state/calendarV2Store';\nimport { useCalendarV2Navigation } from '../state/useCalendarV2Navigation';\nimport { instantToZoned, today as todayIn, viewQueryRange } from '../time/calendarTime';\nimport type { CalendarEventV2, CalendarV2EventDraft, WorkingHoursV2 } from '../types';\nimport type { CalendarPageModel, QuickDraft } from './CalendarPageContext';\nimport { mainState } from './viewState';\n\n/** No rules (or no person to ask): the default working week. */\nconst NO_RULES: readonly WorkingHoursV2[] = [];\n\n/**\n * The working hours on a day, worked out once for the shown days; undefined for every day while\n * the rules aren't known (null).\n */\nfunction hoursLookup(\n days: readonly DateValue[],\n rules: readonly WorkingHoursV2[] | null,\n timeZone: string\n): (date: DateValue) => DayHours | null | undefined {\n if (rules === null) return () => undefined;\n const byDay = new Map(days.map((day) => [day, hoursOn(day, rules, timeZone)]));\n return (date) => (byDay.has(date) ? (byDay.get(date) ?? null) : hoursOn(date, rules, timeZone));\n}\n\nfunction deviceLanguages(): readonly string[] {\n if (typeof navigator === 'undefined') return [];\n return navigator.languages?.length\n ? navigator.languages\n : navigator.language\n ? [navigator.language]\n : [];\n}\n\nexport function useCalendarPageModel(): CalendarPageModel {\n const tr = useTr();\n const { locale: appLocale } = useI18n();\n const { currentUser } = useCalendar();\n const me = currentUser?.id ?? null;\n const { prefs } = useCalendarPrefs();\n const timeZone = useCalendarTimeZone();\n const compact = useIsCompact();\n const nav = useCalendarV2Navigation();\n const nowMs = useNowMs();\n const now = useMemo(() => new Date(nowMs), [nowMs]);\n const today = todayIn(timeZone, now);\n const nowMinute = instantToZoned(now, timeZone).minutes;\n\n const format = useMemo<CalendarFormat>(\n () => ({\n locale: resolveCalendarLocale(appLocale, deviceLanguages()),\n hourCycle: prefs.hourCycle,\n }),\n [appLocale, prefs.hourCycle]\n );\n const durationWords = useMemo<DurationWords>(\n () => ({\n minutes: tr('calendar.v2.durationMinutes', '{{minutes}} min'),\n hours: tr('calendar.v2.durationHours', '{{hours}} h'),\n hoursMinutes: tr('calendar.v2.durationHoursMinutes', '{{hours}} h {{minutes}} min'),\n }),\n [tr]\n );\n\n // The view's days and what to load for them.\n const viewOptions = useMemo(\n () => ({ weekStart: prefs.weekStart, showWeekends: prefs.showWeekends, compact }),\n [compact, prefs.showWeekends, prefs.weekStart]\n );\n const range = useMemo(\n () => viewQueryRange(nav.view, nav.date, viewOptions, timeZone),\n [nav.date, nav.view, timeZone, viewOptions]\n );\n\n // Calendars.\n const calendarsQuery = useCalendarsV2();\n const hiddenList = useCalendarV2Store((state) => state.hiddenCalendarIds);\n const hiddenCalendarIds = useMemo(() => new Set(hiddenList), [hiddenList]);\n const calendarsById = useMemo(\n () => new Map(calendarsQuery.calendars.map((calendar) => [calendar.id, calendar])),\n [calendarsQuery.calendars]\n );\n const shownCalendarIds = useMemo(\n () => calendarsQuery.calendars.filter((c) => !hiddenCalendarIds.has(c.id)).map((c) => c.id),\n [calendarsQuery.calendars, hiddenCalendarIds]\n );\n const writableCalendars = useMemo(\n () =>\n calendarsQuery.calendars.filter(\n (calendar) => !calendar.isReadOnly && calendar.section === 'mine'\n ),\n [calendarsQuery.calendars]\n );\n const defaultCalendarId =\n writableCalendars.find((calendar) => calendar.isDefault)?.id ??\n writableCalendars[0]?.id ??\n null;\n const hues = useMemo(() => {\n const map = new Map<string, CalendarHue>();\n for (const calendar of calendarsQuery.calendars)\n map.set(calendar.id, calendarHue(calendar.color, calendar.id));\n return map;\n }, [calendarsQuery.calendars]);\n const hueOf = useCallback(\n (calendarId: string) => hues.get(calendarId) ?? calendarHue(null, calendarId),\n [hues]\n );\n\n // Events.\n const loaded = useEventsInRangeV2(shownCalendarIds, range.from, range.to, {\n skip: calendarsQuery.status !== 'ready',\n });\n const actions = useEventActions({\n tr,\n format,\n durationWords,\n timeZone,\n me,\n showDeclined: prefs.showDeclined,\n defaultReminder: prefs.defaultReminder,\n reloadCalendars: calendarsQuery.refetch,\n });\n const { settle } = actions;\n useEffect(() => {\n settle(loaded.events);\n }, [loaded.events, settle]);\n const allLoadedEvents = useMemo(\n () => withLocalChanges(loaded.events, actions, me),\n [actions, loaded.events, me]\n );\n const events = useMemo(\n () => shownEvents(allLoadedEvents, { hiddenCalendarIds, showDeclined: prefs.showDeclined, me }),\n [allLoadedEvents, hiddenCalendarIds, me, prefs.showDeclined]\n );\n // The range asked for runs a day past the shown days on each side: count only what shows.\n const eventsOnShownDays = useMemo(() => {\n const daySet = new Set(range.days);\n const first = range.days[0];\n const last = range.days[range.days.length - 1];\n if (!first || !last) return [];\n return events.filter((event) => touchesDays(event, daySet, first, last, timeZone));\n }, [events, range.days, timeZone]);\n const invitations = useMemo(\n () => waitingInvitations(eventsOnShownDays, now, me),\n [eventsOnShownDays, me, now]\n );\n const shownDayCount = eventsOnShownDays.length;\n\n const state = mainState({\n calendars: { status: calendarsQuery.status, count: calendarsQuery.calendars.length },\n hiddenCount: calendarsQuery.calendars.filter((calendar) => hiddenCalendarIds.has(calendar.id))\n .length,\n events: {\n status: loaded.status,\n failedCalendarIds: loaded.failedCalendarIds,\n unreadableCalendarIds: loaded.unreadableCalendarIds,\n truncated: loaded.truncated,\n },\n eventCount: shownDayCount,\n });\n\n // Working hours: the person's availability rules, as free/busy returns them for themselves.\n // The rules are weekly, so the last answer serves while another range loads. Before the first\n // answer, or when free/busy fails before ever answering, they aren't known: no shading and no\n // free gaps, never the Monday-to-Friday default, which is only for someone with no rules.\n const freeBusy = useFreeBusy(me ? [me] : [], range.from, range.to, { skip: !me });\n const lastAnswer = freeBusy.lastAnswer;\n const rules = useMemo((): readonly WorkingHoursV2[] | null => {\n if (!me) return NO_RULES;\n return lastAnswer ? (lastAnswer.get(me)?.workingHours ?? NO_RULES) : null;\n }, [lastAnswer, me]);\n const workingHoursStatus: CalendarPageModel['workingHoursStatus'] =\n rules !== null ? 'ready' : freeBusy.status === 'error' ? 'error' : 'loading';\n const workingHoursOn = useMemo(\n () => hoursLookup(range.days, rules, timeZone),\n [range.days, rules, timeZone]\n );\n\n const rooms = useRoomsV2();\n\n // Peek, quick create, sheets.\n const [peekAnchor, setPeekAnchor] = useState<HTMLElement | null>(null);\n const [quickDraft, setQuickDraft] = useState<QuickDraft | null>(null);\n const [railSheetOpen, setRailSheetOpen] = useState(false);\n const [phoneSearchOpen, setPhoneSearchOpen] = useState(false);\n const setEventDraft = useCalendarV2Store((store) => store.setEventDraft);\n\n const { answers } = actions;\n const answerOf = useCallback(\n (event: CalendarEventV2) => answerFor(event, answers, me),\n [answers, me]\n );\n const lookOf = useCallback(\n (event: CalendarEventV2) =>\n eventLook(event, {\n tr,\n me,\n now,\n timeZone,\n dimPast: prefs.dimPast,\n calendar: calendarsById.get(event.calendarId),\n answer: answerFor(event, answers, me),\n }),\n [answers, calendarsById, me, now, prefs.dimPast, timeZone, tr]\n );\n const labelOf = useCallback(\n (event: CalendarEventV2) =>\n eventAriaLabel(event, lookOf(event), {\n tr,\n format,\n timeZone,\n calendarName: calendarsById.get(event.calendarId)?.name ?? null,\n }),\n [calendarsById, format, lookOf, timeZone, tr]\n );\n\n const { openEvent, closeEvent, openDialog } = nav;\n const openPeek = useCallback(\n (event: CalendarEventV2, opener: HTMLElement | null) => {\n setQuickDraft(null);\n setPeekAnchor(opener);\n openEvent(event.id);\n },\n [openEvent]\n );\n const closePeek = useCallback(() => {\n setPeekAnchor(null);\n closeEvent();\n }, [closeEvent]);\n // A dialog replaces the peek and the quick create (`openDialog` closes the peek).\n const openEventDialog = useCallback(\n (draft: CalendarV2EventDraft) => {\n setQuickDraft(null);\n setPeekAnchor(null);\n setEventDraft(draft);\n openDialog('event');\n },\n [openDialog, setEventDraft]\n );\n const openFindTime = useCallback(\n (event?: CalendarEventV2) => {\n setQuickDraft(null);\n setPeekAnchor(null);\n setEventDraft(event ? editDraftFor(event) : null);\n openDialog('findtime');\n },\n [openDialog, setEventDraft]\n );\n\n return {\n tr,\n format,\n durationWords,\n prefs,\n timeZone,\n now,\n today,\n nowMinute,\n compact,\n me,\n nav,\n days: range.days,\n calendars: calendarsQuery.calendars,\n calendarsById,\n calendarsStatus: calendarsQuery.status,\n calendarsError: calendarsQuery.error,\n refetchCalendars: calendarsQuery.refetch,\n hiddenCalendarIds,\n defaultCalendarId,\n writableCalendars,\n hueOf,\n events,\n allLoadedEvents,\n eventsError: loaded.error,\n refetchEvents: loaded.refetch,\n state,\n invitations,\n workingHoursOn,\n workingHoursStatus,\n refetchWorkingHours: freeBusy.refetch,\n rooms,\n actions,\n answerOf,\n lookOf,\n labelOf,\n openPeek,\n peekAnchor,\n closePeek,\n quickDraft,\n openQuickCreate: setQuickDraft,\n closeQuickCreate: () => setQuickDraft(null),\n openEventDialog,\n openFindTime,\n railSheetOpen,\n setRailSheetOp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CAAC,EAAE,QAAQ;CAC7D,CAAC,GACH;EAAC1B;EAAeb;EAAQgE;EAAQzF;EAAUI;CAAE,CAC9C,GAEM,EAAE,cAAW,eAAY,kBAAeW,GACxC8E,KAAW7C,GACd,GAAwB,MAA+B;EAGtD,AAFA+B,EAAc,IAAI,GAClBH,EAAckB,CAAM,GACpBC,EAAU/B,EAAM,EAAE;CACpB,GACA,CAAC+B,CAAS,CACZ,GACMC,KAAYhD,QAAkB;EAElC,AADA4B,EAAc,IAAI,GAClBqB,EAAW;CACb,GAAG,CAACA,CAAU,CAAC,GAETC,KAAkBlD,GACrB,MAAgC;EAI/B,AAHA+B,EAAc,IAAI,GAClBH,EAAc,IAAI,GAClBQ,EAAce,CAAK,GACnBC,EAAW,OAAO;CACpB,GACA,CAACA,GAAYhB,CAAa,CAC5B,GACMiB,KAAerD,GAClB,MAA4B;EAI3B,AAHA+B,EAAc,IAAI,GAClBH,EAAc,IAAI,GAClBQ,EAAcpB,IAAQsC,EAAatC,CAAK,IAAI,IAAI,GAChDoC,EAAW,UAAU;CACvB,GACA,CAACA,GAAYhB,CAAa,CAC5B;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA,OAAA/D;EACA;EACA;EACA;EACA;EACA,MAAMS,EAAM;EACZ,WAAWE,EAAe;EAC1B;EACA,iBAAiBA,EAAe;EAChC,gBAAgBA,EAAe;EAC/B,kBAAkBA,EAAe;EACjC;EACA;EACA;EACA;EACA;EACA;EACA,aAAakB,EAAO;EACpB,eAAeA,EAAO;EACtB;EACA;EACA;EACA;EACA,qBAAqBmB,EAAS;EAC9B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiBU;EACjB,wBAAwBA,EAAc,IAAI;EAC1C;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -15,6 +15,10 @@ export interface ViewStateInput {
|
|
|
15
15
|
events: {
|
|
16
16
|
status: LoadStatus;
|
|
17
17
|
failedCalendarIds: readonly string[];
|
|
18
|
+
/** Calendars the service won't read for this person (A4). */
|
|
19
|
+
unreadableCalendarIds?: readonly string[];
|
|
20
|
+
/** The service stopped at one of its limits: some dates may be missing (A4). */
|
|
21
|
+
truncated?: boolean;
|
|
18
22
|
};
|
|
19
23
|
/** Events in the shown days, on shown calendars. */
|
|
20
24
|
eventCount: number;
|
|
@@ -35,12 +39,16 @@ export type MainState =
|
|
|
35
39
|
}
|
|
36
40
|
/**
|
|
37
41
|
* The view. `empty`: every shown calendar answered with nothing for these days.
|
|
38
|
-
* `failedCalendarIds`: calendars that didn't answer
|
|
42
|
+
* `failedCalendarIds`: calendars that didn't answer; `unreadableCalendarIds`: calendars the
|
|
43
|
+
* service won't read; `truncated`: some dates may be missing. Each is named in a notice above
|
|
44
|
+
* the view, and any of them means the days aren't known to be empty.
|
|
39
45
|
*/
|
|
40
46
|
| {
|
|
41
47
|
kind: 'ready';
|
|
42
48
|
empty: boolean;
|
|
43
49
|
failedCalendarIds: readonly string[];
|
|
50
|
+
unreadableCalendarIds: readonly string[];
|
|
51
|
+
truncated: boolean;
|
|
44
52
|
};
|
|
45
53
|
export declare function mainState(input: ViewStateInput): MainState;
|
|
46
54
|
export type SearchState = {
|
|
@@ -12,11 +12,13 @@ function e(e) {
|
|
|
12
12
|
failed: "events"
|
|
13
13
|
};
|
|
14
14
|
if (n.status === "loading" || n.status === "idle" && t.count > 0) return { kind: "loading" };
|
|
15
|
-
let r = n.status === "partial" ? n.failedCalendarIds : [];
|
|
15
|
+
let r = n.status === "partial" ? n.failedCalendarIds : [], i = n.unreadableCalendarIds ?? [], a = n.truncated ?? !1;
|
|
16
16
|
return {
|
|
17
17
|
kind: "ready",
|
|
18
|
-
empty: e.eventCount === 0 && r.length === 0,
|
|
19
|
-
failedCalendarIds: r
|
|
18
|
+
empty: e.eventCount === 0 && r.length === 0 && i.length === 0 && !a,
|
|
19
|
+
failedCalendarIds: r,
|
|
20
|
+
unreadableCalendarIds: i,
|
|
21
|
+
truncated: a
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
function t(e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewState.js","names":["mainState","input","calendars","events","failedCalendarIds","searchState"],"sources":["../../../src/v2/page/viewState.ts"],"sourcesContent":["/**\n * What the calendar's main area shows (BOFF-15698 A1). One rule above all: **a failed load is\n * never shown as an empty calendar.** \"Nothing on these days\" is said only when every shown\n * calendar answered and none had anything; a load that failed shows the error, with Try again,\n * even when an earlier answer is still in hand. Pure.\n */\n\nexport type LoadStatus = 'idle' | 'loading' | 'ready' | 'partial' | 'error';\n\nexport interface ViewStateInput {\n calendars: { status: 'idle' | 'loading' | 'ready' | 'error'; count: number };\n /** Calendars the person unticked. */\n hiddenCount: number;\n events: {
|
|
1
|
+
{"version":3,"file":"viewState.js","names":["mainState","input","calendars","events","failedCalendarIds","unreadableCalendarIds","truncated","searchState"],"sources":["../../../src/v2/page/viewState.ts"],"sourcesContent":["/**\n * What the calendar's main area shows (BOFF-15698 A1). One rule above all: **a failed load is\n * never shown as an empty calendar.** \"Nothing on these days\" is said only when every shown\n * calendar answered and none had anything; a load that failed shows the error, with Try again,\n * even when an earlier answer is still in hand. Pure.\n */\n\nexport type LoadStatus = 'idle' | 'loading' | 'ready' | 'partial' | 'error';\n\nexport interface ViewStateInput {\n calendars: { status: 'idle' | 'loading' | 'ready' | 'error'; count: number };\n /** Calendars the person unticked. */\n hiddenCount: number;\n events: {\n status: LoadStatus;\n failedCalendarIds: readonly string[];\n /** Calendars the service won't read for this person (A4). */\n unreadableCalendarIds?: readonly string[];\n /** The service stopped at one of its limits: some dates may be missing (A4). */\n truncated?: boolean;\n };\n /** Events in the shown days, on shown calendars. */\n eventCount: number;\n}\n\nexport type MainState =\n /** Nothing to show yet: the frame without an empty message. */\n | { kind: 'loading' }\n /** The calendars or every calendar's events failed: the error state, never \"empty\". */\n | { kind: 'error'; failed: 'calendars' | 'events' }\n /** The person unticked every calendar. */\n | { kind: 'all-hidden' }\n /**\n * The view. `empty`: every shown calendar answered with nothing for these days.\n * `failedCalendarIds`: calendars that didn't answer; `unreadableCalendarIds`: calendars the\n * service won't read; `truncated`: some dates may be missing. Each is named in a notice above\n * the view, and any of them means the days aren't known to be empty.\n */\n | {\n kind: 'ready';\n empty: boolean;\n failedCalendarIds: readonly string[];\n unreadableCalendarIds: readonly string[];\n truncated: boolean;\n };\n\nexport function mainState(input: ViewStateInput): MainState {\n const { calendars, events } = input;\n if (calendars.status === 'error') return { kind: 'error', failed: 'calendars' };\n if (calendars.status === 'loading' || calendars.status === 'idle') return { kind: 'loading' };\n if (calendars.count > 0 && input.hiddenCount >= calendars.count) return { kind: 'all-hidden' };\n if (events.status === 'error') return { kind: 'error', failed: 'events' };\n if (events.status === 'loading' || (events.status === 'idle' && calendars.count > 0)) {\n return { kind: 'loading' };\n }\n const failedCalendarIds = events.status === 'partial' ? events.failedCalendarIds : [];\n const unreadableCalendarIds = events.unreadableCalendarIds ?? [];\n const truncated = events.truncated ?? false;\n return {\n kind: 'ready',\n // A calendar that didn't answer or can't be read may hold events, and a cut-off answer may\n // miss some: the days are not known to be empty.\n empty:\n input.eventCount === 0 &&\n failedCalendarIds.length === 0 &&\n unreadableCalendarIds.length === 0 &&\n !truncated,\n failedCalendarIds,\n unreadableCalendarIds,\n truncated,\n };\n}\n\nexport type SearchState =\n | { kind: 'loading' }\n /** `calendars`: the calendars list itself failed, so there was nothing to search in. */\n | { kind: 'error'; failed: 'calendars' | 'search' }\n | { kind: 'no-results'; failedCalendarIds: readonly string[] }\n | { kind: 'results'; failedCalendarIds: readonly string[] };\n\n/**\n * The same rule for search: a search that failed never says \"No events match\". Search looks\n * only in the shown calendars, so it waits for the calendars list, and a list that failed is\n * that error, not \"no results\".\n */\nexport function searchState(input: {\n calendars: ViewStateInput['calendars']['status'];\n status: LoadStatus;\n failedCalendarIds: readonly string[];\n resultCount: number;\n}): SearchState {\n if (input.calendars === 'error') return { kind: 'error', failed: 'calendars' };\n if (input.calendars !== 'ready') return { kind: 'loading' };\n if (input.status === 'error') return { kind: 'error', failed: 'search' };\n if (input.status === 'loading' || input.status === 'idle') return { kind: 'loading' };\n const failedCalendarIds = input.status === 'partial' ? input.failedCalendarIds : [];\n if (input.resultCount > 0) return { kind: 'results', failedCalendarIds };\n // Some calendars didn't answer: say so instead of \"no results\".\n if (failedCalendarIds.length > 0) return { kind: 'error', failed: 'search' };\n return { kind: 'no-results', failedCalendarIds };\n}\n"],"mappings":";AA8CA,SAAgBA,EAAU,GAAkC;CAC1D,IAAM,EAAE,cAAW,cAAWC;CAC9B,IAAIC,EAAU,WAAW,SAAS,OAAO;EAAE,MAAM;EAAS,QAAQ;CAAY;CAC9E,IAAIA,EAAU,WAAW,aAAaA,EAAU,WAAW,QAAQ,OAAO,EAAE,MAAM,UAAU;CAC5F,IAAIA,EAAU,QAAQ,KAAKD,EAAM,eAAeC,EAAU,OAAO,OAAO,EAAE,MAAM,aAAa;CAC7F,IAAIC,EAAO,WAAW,SAAS,OAAO;EAAE,MAAM;EAAS,QAAQ;CAAS;CACxE,IAAIA,EAAO,WAAW,aAAcA,EAAO,WAAW,UAAUD,EAAU,QAAQ,GAChF,OAAO,EAAE,MAAM,UAAU;CAE3B,IAAME,IAAoBD,EAAO,WAAW,YAAYA,EAAO,oBAAoB,CAAC,GAC9EE,IAAwBF,EAAO,yBAAyB,CAAC,GACzDG,IAAYH,EAAO,aAAa;CACtC,OAAO;EACL,MAAM;EAGN,OACEF,EAAM,eAAe,KACrBG,EAAkB,WAAW,KAC7BC,EAAsB,WAAW,KACjC,CAACC;EACH;EACA;EACA;CACF;AACF;AAcA,SAAgBC,EAAY,GAKZ;CACd,IAAIN,EAAM,cAAc,SAAS,OAAO;EAAE,MAAM;EAAS,QAAQ;CAAY;CAC7E,IAAIA,EAAM,cAAc,SAAS,OAAO,EAAE,MAAM,UAAU;CAC1D,IAAIA,EAAM,WAAW,SAAS,OAAO;EAAE,MAAM;EAAS,QAAQ;CAAS;CACvE,IAAIA,EAAM,WAAW,aAAaA,EAAM,WAAW,QAAQ,OAAO,EAAE,MAAM,UAAU;CACpF,IAAMG,IAAoBH,EAAM,WAAW,YAAYA,EAAM,oBAAoB,CAAC;CAIlF,OAHIA,EAAM,cAAc,IAAU;EAAE,MAAM;EAAW;CAAkB,IAEnEG,EAAkB,SAAS,IAAU;EAAE,MAAM;EAAS,QAAQ;CAAS,IACpE;EAAE,MAAM;EAAc;CAAkB;AACjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventPeek.js","names":["_Fragment","anchorFor","opener","eventId","EventPeekHost","page","useCalendarPage","found","useEventForPeek","virtualRef","useMemo","element","x","body","PeekContent","BottomSheet","open","BottomSheetContent","Popover","PopoverAnchor","PopoverContent","interaction","focusEvent","PeekEvent","PeekFrame","tr","Spinner","Button","Title","BottomSheetTitle","
|
|
1
|
+
{"version":3,"file":"EventPeek.js","names":["_Fragment","Fragment$1","anchorFor","opener","eventId","EventPeekHost","page","useCalendarPage","found","useEventForPeek","virtualRef","useMemo","element","x","body","PeekContent","BottomSheet","open","BottomSheetContent","Popover","PopoverAnchor","PopoverContent","interaction","focusEvent","PeekEvent","PeekFrame","tr","Spinner","Button","Title","BottomSheetTitle","title","CloseButton","children"],"sources":["../../../src/v2/peek/EventPeek.tsx"],"sourcesContent":["/**\n * The peek (BOFF-15698 A1): an event at a glance, a popover beside it on wide screens and a\n * sheet on phones. It opens from the address (`?event=`), so a link or a notification opens it\n * too; the event itself is drawn by `PeekEvent`. While the event loads, can't be found or fails,\n * the peek says so.\n */\nimport { useMemo, type ReactNode } from 'react';\nimport {\n BottomSheet,\n BottomSheetContent,\n BottomSheetTitle,\n Button,\n Popover,\n PopoverAnchor,\n PopoverContent,\n Spinner,\n} from '@burdenoff/fe-libs/ui';\nimport { useEventForPeek } from '../data/useEventForPeek';\nimport { useCalendarPage } from '../page/CalendarPageContext';\nimport { PeekEvent } from './PeekEvent';\nimport { CloseButton } from './PeekParts';\n\ntype Anchor = { current: { getBoundingClientRect: () => DOMRect } };\n\nfunction anchorFor(eventId: string, opener: HTMLElement | null): Element | null {\n if (opener?.isConnected) return opener;\n if (typeof document === 'undefined') return null;\n return document.querySelector(`[data-event-id=\"${CSS.escape(eventId)}\"]`);\n}\n\n/** Hosts the peek for the event the address names. */\nexport function EventPeekHost() {\n const page = useCalendarPage();\n const eventId = page.nav.eventId;\n const found = useEventForPeek(eventId, page.allLoadedEvents, page.state.kind === 'loading');\n const virtualRef = useMemo<Anchor>(\n () => ({\n current: {\n getBoundingClientRect: () => {\n const element = eventId ? anchorFor(eventId, page.peekAnchor) : null;\n if (element) return element.getBoundingClientRect();\n // No block to point at (another week, a hidden calendar): the middle of the window.\n const x = window.innerWidth / 2;\n return new DOMRect(x, 120, 0, 0);\n },\n },\n }),\n [eventId, page.peekAnchor]\n );\n if (!eventId) return null;\n\n const body = <PeekContent found={found} />;\n if (page.compact) {\n return (\n <BottomSheet open onOpenChange={(open) => (open ? undefined : page.closePeek())}>\n <BottomSheetContent\n className=\"max-h-[88dvh] gap-0 p-0\"\n showCloseButton={false}\n aria-describedby={undefined}\n >\n {body}\n </BottomSheetContent>\n </BottomSheet>\n );\n }\n return (\n <Popover open onOpenChange={(open) => (open ? undefined : page.closePeek())}>\n <PopoverAnchor virtualRef={virtualRef} />\n <PopoverContent\n side=\"right\"\n align=\"start\"\n sideOffset={8}\n collisionPadding={12}\n className=\"flex max-h-[min(640px,calc(100dvh-24px))] w-[380px] flex-col overflow-hidden p-0\"\n onInteractOutside={(interaction) => {\n // A click on another event switches the peek to it instead of closing it.\n const target = interaction.target instanceof Element ? interaction.target : null;\n if (target?.closest('[data-event-id]')) interaction.preventDefault();\n }}\n onCloseAutoFocus={(focusEvent) => {\n const opener = anchorFor(eventId, page.peekAnchor);\n if (opener instanceof HTMLElement) {\n focusEvent.preventDefault();\n opener.focus({ preventScroll: true });\n }\n }}\n >\n {body}\n </PopoverContent>\n </Popover>\n );\n}\n\nfunction PeekContent({ found }: { found: ReturnType<typeof useEventForPeek> }) {\n const page = useCalendarPage();\n const { tr } = page;\n if (found.status === 'ready') return <PeekEvent event={found.event} />;\n if (found.status === 'loading' || found.status === 'none') {\n return (\n <PeekFrame title={tr('calendar.v2.peekLoading', 'Opening the event…')}>\n <div className=\"grid place-items-center p-8\">\n <Spinner />\n </div>\n </PeekFrame>\n );\n }\n if (found.status === 'error') {\n return (\n <PeekFrame title={tr('calendar.v2.peekFailed', 'Couldn’t open the event')}>\n <div className=\"flex flex-col gap-3 p-4\">\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'calendar.v2.peekFailedBody',\n 'The calendar service didn’t answer. Nothing was changed.'\n )}\n </p>\n <Button type=\"button\" onClick={found.retry} className=\"self-start\">\n {tr('calendar.v2.tryAgain', 'Try again')}\n </Button>\n </div>\n </PeekFrame>\n );\n }\n return (\n <PeekFrame title={tr('calendar.v2.peekMissing', 'This event isn’t available')}>\n <p className=\"p-4 text-sm text-text-secondary\">\n {tr(\n 'calendar.v2.peekMissingBody',\n 'It may have been deleted, or it’s on a calendar you can’t see. Ask whoever sent the link.'\n )}\n </p>\n </PeekFrame>\n );\n}\n\n/** The peek's frame without an event (loading, missing, failed). */\nfunction PeekFrame({ title, children }: { title: string; children: ReactNode }) {\n const page = useCalendarPage();\n const Title = page.compact ? BottomSheetTitle : 'h3';\n return (\n <>\n <div className=\"flex items-center gap-2 border-b border-border-subtle p-3 ps-4\">\n <Title className=\"min-w-0 flex-1 text-base font-bold text-text-primary\">{title}</Title>\n <CloseButton />\n </div>\n {children}\n </>\n );\n}\n"],"mappings":";;;;;;;;AAwBA,SAASE,EAAU,GAAiB,GAA4C;CAG9E,OAFIC,GAAQ,cAAoBA,IAC5B,OAAO,WAAa,MAAoB,OACrC,SAAS,cAAc,mBAAmB,IAAI,OAAOC,CAAO,EAAE,GAAG;AAC1E;AAGA,SAAgBC,IAAgB;CAC9B,IAAMC,IAAOC,EAAgB,GACvBH,IAAUE,EAAK,IAAI,SACnBE,IAA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