@burdenoff/microfe-calendar 2026.1123.1 → 2026.1123.2
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/CalendarRoutes.d.ts +3 -0
- package/dist/CalendarRoutes.js +37 -32
- package/dist/CalendarRoutes.js.map +1 -1
- package/dist/generated/global-operations.d.ts +74 -0
- package/dist/generated/global-operations.js +20 -0
- package/dist/generated/global-operations.js.map +1 -0
- package/dist/generated/global-types.d.ts +8 -1
- package/dist/generated/wspace-operations.d.ts +298 -0
- package/dist/generated/wspace-operations.js +126 -1
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +204825 -48049
- package/dist/providers/CalendarProvider.d.ts +2 -0
- package/dist/providers/CalendarProvider.js +12 -10
- package/dist/providers/CalendarProvider.js.map +1 -1
- package/dist/translations/en.d.ts +5 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/v2/CalendarPageV2.d.ts +1 -0
- package/dist/v2/CalendarPageV2.js +19 -0
- package/dist/v2/CalendarPageV2.js.map +1 -0
- package/dist/v2/CalendarRoutesV2.d.ts +1 -0
- package/dist/v2/CalendarRoutesV2.js +117 -0
- package/dist/v2/CalendarRoutesV2.js.map +1 -0
- package/dist/v2/data/invalidation.d.ts +4 -0
- package/dist/v2/data/normalize.d.ts +26 -0
- package/dist/v2/data/normalize.js +87 -0
- package/dist/v2/data/normalize.js.map +1 -0
- package/dist/v2/data/useCalendarsV2.d.ts +16 -0
- package/dist/v2/data/useCalendarsV2.js +25 -0
- package/dist/v2/data/useCalendarsV2.js.map +1 -0
- package/dist/v2/data/useEventsInRangeV2.d.ts +18 -0
- package/dist/v2/data/useFreeBusy.d.ts +22 -0
- package/dist/v2/data/useKeyedLoad.d.ts +17 -0
- package/dist/v2/prefs/CalendarPrefsProvider.d.ts +25 -0
- package/dist/v2/prefs/CalendarPrefsProvider.js +52 -0
- package/dist/v2/prefs/CalendarPrefsProvider.js.map +1 -0
- package/dist/v2/prefs/calendarPrefs.d.ts +73 -0
- package/dist/v2/prefs/calendarPrefs.js +71 -0
- package/dist/v2/prefs/calendarPrefs.js.map +1 -0
- package/dist/v2/prefs/prefsApi.d.ts +16 -0
- package/dist/v2/prefs/prefsApi.js +46 -0
- package/dist/v2/prefs/prefsApi.js.map +1 -0
- package/dist/v2/prefs/prefsSession.d.ts +55 -0
- package/dist/v2/prefs/prefsSession.js +94 -0
- package/dist/v2/prefs/prefsSession.js.map +1 -0
- package/dist/v2/prefs/prefsStorage.d.ts +17 -0
- package/dist/v2/prefs/prefsStorage.js +56 -0
- package/dist/v2/prefs/prefsStorage.js.map +1 -0
- package/dist/v2/routes.d.ts +43 -0
- package/dist/v2/routes.js +60 -0
- package/dist/v2/routes.js.map +1 -0
- package/dist/v2/state/calendarV2Store.d.ts +54 -0
- package/dist/v2/state/calendarV2Store.js +78 -0
- package/dist/v2/state/calendarV2Store.js.map +1 -0
- package/dist/v2/state/useCalendarV2Navigation.d.ts +25 -0
- package/dist/v2/state/useCalendarV2Navigation.js +52 -0
- package/dist/v2/state/useCalendarV2Navigation.js.map +1 -0
- package/dist/v2/state/useCalendarV2PrefsBridge.d.ts +1 -0
- package/dist/v2/state/useCalendarV2PrefsBridge.js +28 -0
- package/dist/v2/state/useCalendarV2PrefsBridge.js.map +1 -0
- package/dist/v2/time/calendarTime.d.ts +115 -0
- package/dist/v2/time/calendarTime.js +59 -0
- package/dist/v2/time/calendarTime.js.map +1 -0
- package/dist/v2/types.d.ts +202 -0
- package/package.json +12 -5
|
@@ -17,6 +17,8 @@ interface CalendarContextValue {
|
|
|
17
17
|
defaultView?: CalendarViewType;
|
|
18
18
|
defaultTimeZone?: string;
|
|
19
19
|
taskOverlay?: TaskOverlayConfig;
|
|
20
|
+
/** The redesigned calendar (BOFF-15698); false renders today's pages. */
|
|
21
|
+
calendarRedesign: boolean;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Hook to access Calendar context
|
|
@@ -7,8 +7,8 @@ var o = e(null), s = () => {
|
|
|
7
7
|
let e = t(o);
|
|
8
8
|
if (!e) throw Error("useCalendar must be used within CalendarProvider");
|
|
9
9
|
return e;
|
|
10
|
-
}, c = ({ children: e, basePath: t = "/", navigate: s, currentUser: c, workspaceId: l, tenantId: u, apiGatewayUrl: d, authToken: f, onEventSelect: p, onEventCreate: m, onResourceBook: h, defaultView: g = "week", defaultTimeZone: _, taskOverlay: v }) => {
|
|
11
|
-
let
|
|
10
|
+
}, c = ({ children: e, basePath: t = "/", navigate: s, currentUser: c, workspaceId: l, tenantId: u, apiGatewayUrl: d, authToken: f, onEventSelect: p, onEventCreate: m, onResourceBook: h, defaultView: g = "week", defaultTimeZone: _, taskOverlay: v, calendarRedesign: y = !1 }) => {
|
|
11
|
+
let b = n(() => ({
|
|
12
12
|
basePath: t,
|
|
13
13
|
navigate: s,
|
|
14
14
|
currentUser: c,
|
|
@@ -21,7 +21,8 @@ var o = e(null), s = () => {
|
|
|
21
21
|
onResourceBook: h,
|
|
22
22
|
defaultView: g,
|
|
23
23
|
defaultTimeZone: _,
|
|
24
|
-
taskOverlay: v
|
|
24
|
+
taskOverlay: v,
|
|
25
|
+
calendarRedesign: y
|
|
25
26
|
}), [
|
|
26
27
|
t,
|
|
27
28
|
s,
|
|
@@ -35,19 +36,20 @@ var o = e(null), s = () => {
|
|
|
35
36
|
h,
|
|
36
37
|
g,
|
|
37
38
|
_,
|
|
38
|
-
v
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
v,
|
|
40
|
+
y
|
|
41
|
+
]), x = t && t !== "/", S = /* @__PURE__ */ a(o.Provider, {
|
|
42
|
+
value: b,
|
|
41
43
|
children: e
|
|
42
|
-
}),
|
|
43
|
-
value:
|
|
44
|
+
}), C = x ? /* @__PURE__ */ a(o.Provider, {
|
|
45
|
+
value: b,
|
|
44
46
|
children: /* @__PURE__ */ a(i, {
|
|
45
47
|
scopeId: l ?? null,
|
|
46
48
|
gateway: "workspace",
|
|
47
49
|
children: e
|
|
48
50
|
})
|
|
49
|
-
}) :
|
|
50
|
-
return
|
|
51
|
+
}) : S;
|
|
52
|
+
return x ? C : /* @__PURE__ */ a(r, { children: C });
|
|
51
53
|
};
|
|
52
54
|
export { c as CalendarProvider, s as useCalendar };
|
|
53
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarProvider.js","names":["CalendarContext","createContext","useCalendar","context","use","CalendarProvider","contextValue","useMemo","basePath","navigate","currentUser","workspaceId","tenantId","apiGatewayUrl","authToken","onEventSelect","onEventCreate","onResourceBook","defaultView","defaultTimeZone","taskOverlay","isIntegrated","contextContent","content","PermissionProvider","MemoryRouter"],"sources":["../../src/providers/CalendarProvider.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from 'react';\nimport { createContext, use, useMemo } from 'react';\nimport { MemoryRouter } from 'react-router';\nimport { PermissionProvider } from '@burdenoff/fe-libs/shared/providers/shell';\nimport type {\n CalendarRootProps,\n CalendarEventSummary,\n ResourceBookingSummary,\n CalendarViewType,\n TaskOverlayConfig,\n} from '../types';\n\n/**\n * Context value for Calendar microfrontend\n */\ninterface CalendarContextValue {\n basePath: string;\n navigate: (path: string) => void;\n currentUser?: CalendarRootProps['currentUser'];\n workspaceId?: string;\n tenantId?: string;\n apiGatewayUrl?: string;\n authToken?: string;\n onEventSelect?: (event: CalendarEventSummary) => void;\n onEventCreate?: (event: CalendarEventSummary) => void;\n onResourceBook?: (booking: ResourceBookingSummary) => void;\n defaultView?: CalendarViewType;\n defaultTimeZone?: string;\n taskOverlay?: TaskOverlayConfig;\n}\n\nconst CalendarContext = createContext<CalendarContextValue | null>(null);\n\n/**\n * Hook to access Calendar context\n */\nexport const useCalendar = () => {\n const context = use(CalendarContext);\n if (!context) {\n throw new Error('useCalendar must be used within CalendarProvider');\n }\n return context;\n};\n\n/**\n * Provider component for Calendar microfrontend\n * Sets up routing and context\n */\nexport const CalendarProvider: FC<PropsWithChildren<CalendarRootProps>> = ({\n children,\n basePath = '/',\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n apiGatewayUrl,\n authToken,\n onEventSelect,\n onEventCreate,\n onResourceBook,\n defaultView = 'week',\n defaultTimeZone,\n taskOverlay,\n}) => {\n const contextValue: CalendarContextValue = useMemo(\n () => ({\n basePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n apiGatewayUrl,\n authToken,\n onEventSelect,\n onEventCreate,\n onResourceBook,\n defaultView,\n defaultTimeZone,\n taskOverlay,\n }),\n [\n basePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n apiGatewayUrl,\n authToken,\n onEventSelect,\n onEventCreate,\n onResourceBook,\n defaultView,\n defaultTimeZone,\n taskOverlay,\n ]\n );\n\n const isIntegrated = basePath && basePath !== '/';\n\n // PermissionProvider requires the shell's AuthProvider — only mount it in integrated mode.\n // In standalone/dev mode (MemoryRouter path), there's no AuthProvider, so we skip it\n // and pages will use a fallback that allows access (dev-only behaviour).\n const contextContent = (\n <CalendarContext.Provider value={contextValue}>{children}</CalendarContext.Provider>\n );\n const content = isIntegrated ? (\n <CalendarContext.Provider value={contextValue}>\n <PermissionProvider scopeId={workspaceId ?? null} gateway=\"workspace\">\n {children}\n </PermissionProvider>\n </CalendarContext.Provider>\n ) : (\n contextContent\n );\n\n // When integrated into a shell (basePath provided), the shell already has a router\n // so we don't create another one. When standalone (basePath === '/'), use MemoryRouter.\n if (isIntegrated) {\n return content;\n }\n\n // Standalone mode: create MemoryRouter for independent operation\n return <MemoryRouter>{content}</MemoryRouter>;\n};\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"CalendarProvider.js","names":["CalendarContext","createContext","useCalendar","context","use","CalendarProvider","contextValue","useMemo","basePath","navigate","currentUser","workspaceId","tenantId","apiGatewayUrl","authToken","onEventSelect","onEventCreate","onResourceBook","defaultView","defaultTimeZone","taskOverlay","calendarRedesign","isIntegrated","contextContent","content","PermissionProvider","MemoryRouter"],"sources":["../../src/providers/CalendarProvider.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from 'react';\nimport { createContext, use, useMemo } from 'react';\nimport { MemoryRouter } from 'react-router';\nimport { PermissionProvider } from '@burdenoff/fe-libs/shared/providers/shell';\nimport type {\n CalendarRootProps,\n CalendarEventSummary,\n ResourceBookingSummary,\n CalendarViewType,\n TaskOverlayConfig,\n} from '../types';\n\n/**\n * Context value for Calendar microfrontend\n */\ninterface CalendarContextValue {\n basePath: string;\n navigate: (path: string) => void;\n currentUser?: CalendarRootProps['currentUser'];\n workspaceId?: string;\n tenantId?: string;\n apiGatewayUrl?: string;\n authToken?: string;\n onEventSelect?: (event: CalendarEventSummary) => void;\n onEventCreate?: (event: CalendarEventSummary) => void;\n onResourceBook?: (booking: ResourceBookingSummary) => void;\n defaultView?: CalendarViewType;\n defaultTimeZone?: string;\n taskOverlay?: TaskOverlayConfig;\n /** The redesigned calendar (BOFF-15698); false renders today's pages. */\n calendarRedesign: boolean;\n}\n\nconst CalendarContext = createContext<CalendarContextValue | null>(null);\n\n/**\n * Hook to access Calendar context\n */\nexport const useCalendar = () => {\n const context = use(CalendarContext);\n if (!context) {\n throw new Error('useCalendar must be used within CalendarProvider');\n }\n return context;\n};\n\n/**\n * Provider component for Calendar microfrontend\n * Sets up routing and context\n */\nexport const CalendarProvider: FC<PropsWithChildren<CalendarRootProps>> = ({\n children,\n basePath = '/',\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n apiGatewayUrl,\n authToken,\n onEventSelect,\n onEventCreate,\n onResourceBook,\n defaultView = 'week',\n defaultTimeZone,\n taskOverlay,\n calendarRedesign = false,\n}) => {\n const contextValue: CalendarContextValue = useMemo(\n () => ({\n basePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n apiGatewayUrl,\n authToken,\n onEventSelect,\n onEventCreate,\n onResourceBook,\n defaultView,\n defaultTimeZone,\n taskOverlay,\n calendarRedesign,\n }),\n [\n basePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n apiGatewayUrl,\n authToken,\n onEventSelect,\n onEventCreate,\n onResourceBook,\n defaultView,\n defaultTimeZone,\n taskOverlay,\n calendarRedesign,\n ]\n );\n\n const isIntegrated = basePath && basePath !== '/';\n\n // PermissionProvider requires the shell's AuthProvider — only mount it in integrated mode.\n // In standalone/dev mode (MemoryRouter path), there's no AuthProvider, so we skip it\n // and pages will use a fallback that allows access (dev-only behaviour).\n const contextContent = (\n <CalendarContext.Provider value={contextValue}>{children}</CalendarContext.Provider>\n );\n const content = isIntegrated ? (\n <CalendarContext.Provider value={contextValue}>\n <PermissionProvider scopeId={workspaceId ?? null} gateway=\"workspace\">\n {children}\n </PermissionProvider>\n </CalendarContext.Provider>\n ) : (\n contextContent\n );\n\n // When integrated into a shell (basePath provided), the shell already has a router\n // so we don't create another one. When standalone (basePath === '/'), use MemoryRouter.\n if (isIntegrated) {\n return content;\n }\n\n // Standalone mode: create MemoryRouter for independent operation\n return <MemoryRouter>{content}</MemoryRouter>;\n};\n"],"mappings":";;;;;AAiCA,IAAMA,IAAkBC,EAA2C,IAAI,GAK1DC,UAAoB;CAC/B,IAAMC,IAAUC,EAAIJ,CAAe;CACnC,IAAI,CAACG,GACH,MAAU,MAAM,kDAAkD;CAEpE,OAAOA;AACT,GAMaE,KAA8D,EACzE,aACA,cAAW,KACX,aACA,gBACA,gBACA,aACA,kBACA,cACA,kBACA,kBACA,mBACA,iBAAc,QACd,oBACA,gBACA,sBAAmB,SACf;CACJ,IAAMC,IAAqCC,SAClC;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACEC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;CACF,CACF,GAEMC,IAAed,KAAYA,MAAa,KAKxCe,IACJ,kBAACvB,EAAgB,UAAjB;EAA0B,OAAOM;EAAe;CAAmC,CAAA,GAE/EkB,IAAUF,IACd,kBAACtB,EAAgB,UAAjB;EAA0B,OAAOM;EAC/B,UAAA,kBAACmB,GAAD;GAAoB,SAASd,KAAe;GAAM,SAAQ;GACvD;EACiB,CAAA;CACI,CAAA,IAE1BY;CAUF,OALID,IACKE,IAIF,kBAACE,GAAD,EAAA,UAAeF,EAAsB,CAAA;AAC9C"}
|
|
@@ -337,6 +337,11 @@ export declare const enTranslations: {
|
|
|
337
337
|
unassigned: string;
|
|
338
338
|
unknownShareTarget: string;
|
|
339
339
|
updateEvent: string;
|
|
340
|
+
v2: {
|
|
341
|
+
openingCalendar: string;
|
|
342
|
+
openingEvent: string;
|
|
343
|
+
title: string;
|
|
344
|
+
};
|
|
340
345
|
vehicle: string;
|
|
341
346
|
videoCall: string;
|
|
342
347
|
visibility: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -31,6 +31,12 @@ export interface CalendarRootProps extends MicrofrontendRootProps {
|
|
|
31
31
|
* route). Omit for no task overlay.
|
|
32
32
|
*/
|
|
33
33
|
taskOverlay?: TaskOverlayConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Opt into the redesigned calendar (BOFF-15698): Day · Week · Month · List, settings and
|
|
36
|
+
* rooms in dialogs, today's addresses redirected. FluidGrids only. Default false: without it
|
|
37
|
+
* the calendar renders exactly today's pages, so every other product sees no change.
|
|
38
|
+
*/
|
|
39
|
+
calendarRedesign?: boolean;
|
|
34
40
|
/**
|
|
35
41
|
* Optional function to register navigation items with the shell
|
|
36
42
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CalendarPageV2(): import('react').JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useTr as e } from "../shared/hooks/useTr.js";
|
|
2
|
+
import { useCalendarV2Navigation as t } from "./state/useCalendarV2Navigation.js";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
// src/v2/CalendarPageV2.tsx
|
|
5
|
+
function r() {
|
|
6
|
+
let r = e(), { view: i, date: a } = t();
|
|
7
|
+
return /* @__PURE__ */ n("main", {
|
|
8
|
+
className: "flex min-h-0 flex-1 flex-col bg-bg-canvas p-6",
|
|
9
|
+
"data-calendar-view": i,
|
|
10
|
+
"data-calendar-date": a,
|
|
11
|
+
children: /* @__PURE__ */ n("h1", {
|
|
12
|
+
className: "font-heading-lg text-text-primary",
|
|
13
|
+
children: r("calendar.v2.title", "Calendar")
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { r as CalendarPageV2 };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=CalendarPageV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalendarPageV2.js","names":["CalendarPageV2","tr","useTr","useCalendarV2Navigation","view","date"],"sources":["../../src/v2/CalendarPageV2.tsx"],"sourcesContent":["/**\n * The redesigned calendar page (BOFF-15698). A0 ships the frame the routes open; A1 builds the\n * page itself here (header, toolbar, rail, the Day · Week · Month · List views and the peek),\n * on the shared hooks (`useCalendarsV2`, `useEventsInRangeV2`, `useCalendarPrefs`,\n * `useFreeBusy`), the store (`useCalendarV2Store`) and `useCalendarV2Navigation`.\n *\n * No product shows it yet: FluidGrids passes `calendarRedesign` once A1–A3 have shipped (§7).\n */\nimport { useTr } from '../shared/hooks/useTr';\nimport { useCalendarV2Navigation } from './state/useCalendarV2Navigation';\n\nexport function CalendarPageV2() {\n const tr = useTr();\n const { view, date } = useCalendarV2Navigation();\n return (\n <main\n className=\"flex min-h-0 flex-1 flex-col bg-bg-canvas p-6\"\n data-calendar-view={view}\n data-calendar-date={date}\n >\n <h1 className=\"font-heading-lg text-text-primary\">{tr('calendar.v2.title', 'Calendar')}</h1>\n </main>\n );\n}\n"],"mappings":";;;;AAWA,SAAgBA,IAAiB;CAC/B,IAAMC,IAAKC,EAAM,GACX,EAAE,SAAM,YAASC,EAAwB;CAC/C,OACE,kBAAC,QAAD;EACE,WAAU;EACV,sBAAoBC;EACpB,sBAAoBC;EAEpB,UAAA,kBAAC,MAAD;GAAI,WAAU;GAAqC,UAAAJ,EAAG,qBAAqB,UAAU;EAAM,CAAA;CACvF,CAAA;AAEV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CalendarRoutesV2(): import('react').JSX.Element;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { CalendarV2EventDayDocument as e } from "../generated/wspace-operations.js";
|
|
2
|
+
import { useCalendar as t } from "../providers/CalendarProvider.js";
|
|
3
|
+
import { useTr as n } from "../shared/hooks/useTr.js";
|
|
4
|
+
import { CalendarPageV2 as r } from "./CalendarPageV2.js";
|
|
5
|
+
import { parseInstant as i } from "./data/normalize.js";
|
|
6
|
+
import { CalendarPrefsProvider as a, useCalendarPrefs as o, useCalendarTimeZone as s, usePrefsSettled as c } from "./prefs/CalendarPrefsProvider.js";
|
|
7
|
+
import { DEFAULT_VIEW as l, LEGACY_PAGE_DIALOGS as u, SEARCH_PARAMS as d, calendarV2Href as f, viewForName as p, viewPath as m } from "./routes.js";
|
|
8
|
+
import { useCalendarV2Store as h } from "./state/calendarV2Store.js";
|
|
9
|
+
import { useCalendarV2Navigation as g } from "./state/useCalendarV2Navigation.js";
|
|
10
|
+
import { useCalendarV2PrefsBridge as _ } from "./state/useCalendarV2PrefsBridge.js";
|
|
11
|
+
import { eventDays as v } from "./time/calendarTime.js";
|
|
12
|
+
import { useEffect as y } from "react";
|
|
13
|
+
import { Navigate as b, Route as x, Routes as S, useLocation as C, useParams as w } from "react-router";
|
|
14
|
+
import { jsx as T, jsxs as E } from "react/jsx-runtime";
|
|
15
|
+
import { WorkspacePagesV2Provider as D } from "@burdenoff/fe-libs/ui";
|
|
16
|
+
import { useQuery as O } from "@apollo/client/react";
|
|
17
|
+
// src/v2/CalendarRoutesV2.tsx
|
|
18
|
+
function k() {
|
|
19
|
+
let { currentUser: e } = t();
|
|
20
|
+
return /* @__PURE__ */ T(D, {
|
|
21
|
+
enabled: !0,
|
|
22
|
+
children: /* @__PURE__ */ T(a, { children: /* @__PURE__ */ T(A, { children: /* @__PURE__ */ E(S, { children: [
|
|
23
|
+
/* @__PURE__ */ T(x, {
|
|
24
|
+
index: !0,
|
|
25
|
+
element: /* @__PURE__ */ T(N, {})
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ T(x, {
|
|
28
|
+
path: "view/:viewType",
|
|
29
|
+
element: /* @__PURE__ */ T(P, {})
|
|
30
|
+
}),
|
|
31
|
+
/* @__PURE__ */ T(x, {
|
|
32
|
+
path: "event/:eventId",
|
|
33
|
+
element: /* @__PURE__ */ T(L, {})
|
|
34
|
+
}),
|
|
35
|
+
Object.entries(u).map(([e, t]) => /* @__PURE__ */ T(x, {
|
|
36
|
+
path: e,
|
|
37
|
+
element: /* @__PURE__ */ T(I, { dialog: t })
|
|
38
|
+
}, e)),
|
|
39
|
+
/* @__PURE__ */ T(x, {
|
|
40
|
+
path: "*",
|
|
41
|
+
element: /* @__PURE__ */ T(R, {})
|
|
42
|
+
})
|
|
43
|
+
] }) }) }, e?.id ?? "")
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function A({ children: e }) {
|
|
47
|
+
return _(), y(() => () => h.getState().reset(), []), e;
|
|
48
|
+
}
|
|
49
|
+
function j({ label: e }) {
|
|
50
|
+
return /* @__PURE__ */ T("div", {
|
|
51
|
+
className: "min-h-screen bg-bg-canvas flex items-center justify-center",
|
|
52
|
+
role: "status",
|
|
53
|
+
"aria-live": "polite",
|
|
54
|
+
children: /* @__PURE__ */ T("div", {
|
|
55
|
+
className: "text-text-secondary font-text-md",
|
|
56
|
+
children: e
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function M({ view: e, changes: n }) {
|
|
61
|
+
let { basePath: r } = t(), { search: i } = C();
|
|
62
|
+
return /* @__PURE__ */ T(b, {
|
|
63
|
+
replace: !0,
|
|
64
|
+
to: f(r, e, n, i)
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function N() {
|
|
68
|
+
let e = n(), { prefs: t } = o();
|
|
69
|
+
return c() ? /* @__PURE__ */ T(M, { view: t.defaultView }) : /* @__PURE__ */ T(j, { label: e("calendar.v2.openingCalendar", "Opening the calendar…") });
|
|
70
|
+
}
|
|
71
|
+
function P() {
|
|
72
|
+
let { viewType: e } = w(), t = p(e);
|
|
73
|
+
return t === null ? /* @__PURE__ */ T(M, { view: l }) : T(t === e ? F : M, { view: t });
|
|
74
|
+
}
|
|
75
|
+
function F({ view: e }) {
|
|
76
|
+
let { date: t } = g();
|
|
77
|
+
return y(() => {
|
|
78
|
+
h.getState().syncRoute(e, t);
|
|
79
|
+
}, [e, t]), /* @__PURE__ */ T(r, {});
|
|
80
|
+
}
|
|
81
|
+
function I({ dialog: e }) {
|
|
82
|
+
return /* @__PURE__ */ T(M, {
|
|
83
|
+
view: "week",
|
|
84
|
+
changes: { [d.dialog]: e }
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function L() {
|
|
88
|
+
let { eventId: t = "" } = w(), r = n(), a = s(), o = c(), { data: l, loading: u } = O(e, {
|
|
89
|
+
variables: { id: t },
|
|
90
|
+
skip: t === "",
|
|
91
|
+
fetchPolicy: "network-only"
|
|
92
|
+
});
|
|
93
|
+
if (!o || t !== "" && u && !l) return /* @__PURE__ */ T(j, { label: r("calendar.v2.openingEvent", "Opening the event…") });
|
|
94
|
+
let f = l?.event, p = i(f?.startTime), m = i(f?.endTime), h = f && p && m ? v({
|
|
95
|
+
start: p,
|
|
96
|
+
end: m,
|
|
97
|
+
allDay: f.allDay,
|
|
98
|
+
timeZone: f.timezone
|
|
99
|
+
}, a).start : null;
|
|
100
|
+
return /* @__PURE__ */ T(M, {
|
|
101
|
+
view: "week",
|
|
102
|
+
changes: {
|
|
103
|
+
[d.event]: t || null,
|
|
104
|
+
[d.date]: h
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function R() {
|
|
109
|
+
let { basePath: e } = t();
|
|
110
|
+
return /* @__PURE__ */ T(b, {
|
|
111
|
+
replace: !0,
|
|
112
|
+
to: m(e, l)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
export { k as CalendarRoutesV2 };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=CalendarRoutesV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalendarRoutesV2.js","names":["CalendarRoutesV2","useCalendar","WorkspacePagesV2Provider","CalendarPrefsProvider","CalendarV2Session","Routes","Route","OpeningViewRedirect","ViewRoute","EventRedirect","LEGACY_PAGE_DIALOGS","path","dialog","DialogRedirect","UnknownAddressRedirect","currentUser","useCalendarV2PrefsBridge","useEffect","useCalendarV2Store","children","CalendarV2Loading","label","RedirectToView","useLocation","Navigate","calendarV2Href","basePath","view","changes","search","tr","useTr","useCalendarPrefs","usePrefsSettled","prefs","useParams","viewForName","viewType","DEFAULT_VIEW","jsx","ViewPage","useCalendarV2Navigation","date","CalendarPageV2","SEARCH_PARAMS","timeZone","useCalendarTimeZone","prefsSettled","useQuery","CalendarV2EventDayDocument","eventId","loading","data","event","start","parseInstant","end","day","eventDays","viewPath"],"sources":["../../src/v2/CalendarRoutesV2.tsx"],"sourcesContent":["/**\n * The redesigned calendar's routes (BOFF-15698), rendered instead of today's when the host\n * passes `calendarRedesign` (FluidGrids only). Today's addresses keep working (§2):\n *\n * /calendar → view/<opening view> (the person's setting; Week by default)\n * /calendar/view/year → view/month\n * /calendar/view/timeline → view/week\n * /calendar/view/agenda → view/list\n * /calendar/resources → view/week?dialog=rooms\n * /calendar/subscriptions → view/week?dialog=share\n * /calendar/settings → view/week?dialog=settings\n * /calendar/event/:id → view/week?event=:id&date=<its day> (opens the peek)\n * anything else → view/week\n *\n * A redirect keeps the query parameters a link carried. The tree renders under\n * `WorkspacePagesV2Provider enabled` (BOFF-15645), so the shared v2 parts take their new look\n * before the app turns `workspacePagesV2` on everywhere.\n */\nimport { useEffect, type ReactNode } from 'react';\nimport { Navigate, Route, Routes, useLocation, useParams } from 'react-router';\nimport { useQuery } from '@apollo/client/react';\nimport { WorkspacePagesV2Provider } from '@burdenoff/fe-libs/ui';\nimport {\n CalendarV2EventDayDocument,\n type CalendarV2EventDayQuery,\n type CalendarV2EventDayQueryVariables,\n} from '../generated/wspace-operations';\nimport { useCalendar } from '../providers/CalendarProvider';\nimport { useTr } from '../shared/hooks/useTr';\nimport { CalendarPageV2 } from './CalendarPageV2';\nimport { parseInstant } from './data/normalize';\nimport {\n CalendarPrefsProvider,\n useCalendarPrefs,\n useCalendarTimeZone,\n usePrefsSettled,\n} from './prefs/CalendarPrefsProvider';\nimport {\n calendarV2Href,\n DEFAULT_VIEW,\n LEGACY_PAGE_DIALOGS,\n SEARCH_PARAMS,\n viewForName,\n viewPath,\n} from './routes';\nimport { useCalendarV2Store } from './state/calendarV2Store';\nimport { useCalendarV2Navigation } from './state/useCalendarV2Navigation';\nimport { useCalendarV2PrefsBridge } from './state/useCalendarV2PrefsBridge';\nimport { eventDays } from './time/calendarTime';\nimport type { CalendarV2Dialog, CalendarV2View } from './types';\n\nexport function CalendarRoutesV2() {\n const { currentUser } = useCalendar();\n return (\n <WorkspacePagesV2Provider enabled>\n {/* One settings session per person: another person signing in starts afresh. */}\n <CalendarPrefsProvider key={currentUser?.id ?? ''}>\n <CalendarV2Session>\n <Routes>\n <Route index element={<OpeningViewRedirect />} />\n <Route path=\"view/:viewType\" element={<ViewRoute />} />\n <Route path=\"event/:eventId\" element={<EventRedirect />} />\n {Object.entries(LEGACY_PAGE_DIALOGS).map(([path, dialog]) => (\n <Route key={path} path={path} element={<DialogRedirect dialog={dialog} />} />\n ))}\n <Route path=\"*\" element={<UnknownAddressRedirect />} />\n </Routes>\n </CalendarV2Session>\n </CalendarPrefsProvider>\n </WorkspacePagesV2Provider>\n );\n}\n\n/** What lives for the visit: the settings bridge; the visit's state is cleared on leaving. */\nfunction CalendarV2Session({ children }: { children: ReactNode }) {\n useCalendarV2PrefsBridge();\n useEffect(() => () => useCalendarV2Store.getState().reset(), []);\n return children;\n}\n\nfunction CalendarV2Loading({ label }: { label: string }) {\n return (\n <div\n className=\"min-h-screen bg-bg-canvas flex items-center justify-center\"\n role=\"status\"\n aria-live=\"polite\"\n >\n <div className=\"text-text-secondary font-text-md\">{label}</div>\n </div>\n );\n}\n\n/** Replaces the address with a view of the redesign, keeping the query the link carried. */\nfunction RedirectToView({\n view,\n changes,\n}: {\n view: CalendarV2View;\n changes?: Readonly<Record<string, string | null>>;\n}) {\n const { basePath } = useCalendar();\n const { search } = useLocation();\n return <Navigate replace to={calendarV2Href(basePath, view, changes, search)} />;\n}\n\n/** The person's opening view, once the account has said which (not a stale device copy's). */\nfunction OpeningViewRedirect() {\n const tr = useTr();\n const { prefs } = useCalendarPrefs();\n if (!usePrefsSettled()) {\n return <CalendarV2Loading label={tr('calendar.v2.openingCalendar', 'Opening the calendar…')} />;\n }\n return <RedirectToView view={prefs.defaultView} />;\n}\n\nfunction ViewRoute() {\n const { viewType } = useParams();\n const view = viewForName(viewType);\n if (view === null) return <RedirectToView view={DEFAULT_VIEW} />;\n if (view !== viewType) return <RedirectToView view={view} />;\n return <ViewPage view={view} />;\n}\n\n/** A view of the redesign: mirrors the address into the store, then shows the page. */\nfunction ViewPage({ view }: { view: CalendarV2View }) {\n const { date } = useCalendarV2Navigation();\n useEffect(() => {\n useCalendarV2Store.getState().syncRoute(view, date);\n }, [view, date]);\n return <CalendarPageV2 />;\n}\n\nfunction DialogRedirect({ dialog }: { dialog: CalendarV2Dialog }) {\n return <RedirectToView view=\"week\" changes={{ [SEARCH_PARAMS.dialog]: dialog }} />;\n}\n\n/**\n * Today's event page: the event's week with its peek open. The day is the event's in the\n * calendar's zone (an all-day event's own day), read once the account has said which zone; an\n * event that can't be read (deleted, not shared) opens the peek without a day, and the peek\n * says what happened.\n */\nfunction EventRedirect() {\n const { eventId = '' } = useParams();\n const tr = useTr();\n const timeZone = useCalendarTimeZone();\n const prefsSettled = usePrefsSettled();\n const { data, loading } = useQuery<CalendarV2EventDayQuery, CalendarV2EventDayQueryVariables>(\n CalendarV2EventDayDocument,\n { variables: { id: eventId }, skip: eventId === '', fetchPolicy: 'network-only' }\n );\n if (!prefsSettled || (eventId !== '' && loading && !data)) {\n return <CalendarV2Loading label={tr('calendar.v2.openingEvent', 'Opening the event…')} />;\n }\n const event = data?.event;\n const start = parseInstant(event?.startTime);\n const end = parseInstant(event?.endTime);\n const day =\n event && start && end\n ? eventDays({ start, end, allDay: event.allDay, timeZone: event.timezone }, timeZone).start\n : null;\n return (\n <RedirectToView\n view=\"week\"\n changes={{ [SEARCH_PARAMS.event]: eventId || null, [SEARCH_PARAMS.date]: day }}\n />\n );\n}\n\nfunction UnknownAddressRedirect() {\n const { basePath } = useCalendar();\n return <Navigate replace to={viewPath(basePath, DEFAULT_VIEW)} />;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CalendarV2CalendarsQuery, CalendarV2EventsInRangeQuery, CalendarV2FreeBusyQuery } from '../../generated/wspace-operations';
|
|
2
|
+
import { CalendarEventV2, CalendarV2, PersonFreeBusyV2 } from '../types';
|
|
3
|
+
export type RawCalendarV2 = CalendarV2CalendarsQuery['calendars']['calendars'][number];
|
|
4
|
+
export type RawEventV2 = CalendarV2EventsInRangeQuery['eventsInRange'][number];
|
|
5
|
+
export type RawPersonFreeBusyV2 = CalendarV2FreeBusyQuery['freeBusy'][number];
|
|
6
|
+
/** The instant an API time names; null when it doesn't parse. */
|
|
7
|
+
export declare function parseInstant(value: string | null | undefined): Date | null;
|
|
8
|
+
/**
|
|
9
|
+
* A calendar for the rail. "Other calendars" are the ones that come from outside (a link,
|
|
10
|
+
* Google, Outlook) and another person's own calendar shared with you; the rest are yours:
|
|
11
|
+
* the workspace's, your own, and your teams' and projects'.
|
|
12
|
+
*/
|
|
13
|
+
export declare function toCalendarV2(raw: RawCalendarV2, myUserId: string | null): CalendarV2;
|
|
14
|
+
/**
|
|
15
|
+
* The rail's order: your calendars first (the workspace's, your own, teams, projects; the
|
|
16
|
+
* default first in each), then the others; by name within each.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sortCalendarsV2(calendars: readonly CalendarV2[]): CalendarV2[];
|
|
19
|
+
/** An event for the views; null when its times don't parse (it can't be placed). */
|
|
20
|
+
export declare function toCalendarEventV2(raw: RawEventV2, myUserId: string | null): CalendarEventV2 | null;
|
|
21
|
+
/** Events by start (all-day first on a tie, then longer first), each once. */
|
|
22
|
+
export declare function sortEventsV2(events: readonly CalendarEventV2[]): CalendarEventV2[];
|
|
23
|
+
/** Minutes after midnight of an "HH:MM" time ("24:00" is 1440); null for anything else. */
|
|
24
|
+
export declare function clockMinutes(value: string): number | null;
|
|
25
|
+
/** One person's free/busy: blocks by start (timed before all-day on a tie). */
|
|
26
|
+
export declare function toPersonFreeBusyV2(raw: RawPersonFreeBusyV2): PersonFreeBusyV2;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { canonicalTimeZone as e } from "@burdenoff/fe-libs/ui";
|
|
2
|
+
// src/v2/data/normalize.ts
|
|
3
|
+
function t(e, t) {
|
|
4
|
+
return new Set(t).has(e);
|
|
5
|
+
}
|
|
6
|
+
function n(e, n, r) {
|
|
7
|
+
return t(e, n) ? e : r;
|
|
8
|
+
}
|
|
9
|
+
function r(e, n) {
|
|
10
|
+
return t(e, n) ? e : null;
|
|
11
|
+
}
|
|
12
|
+
function i(e) {
|
|
13
|
+
if (!e) return null;
|
|
14
|
+
let t = new Date(e);
|
|
15
|
+
return Number.isNaN(t.getTime()) ? null : t;
|
|
16
|
+
}
|
|
17
|
+
var a = [
|
|
18
|
+
"WORKSPACE",
|
|
19
|
+
"GROUP",
|
|
20
|
+
"PROJECT",
|
|
21
|
+
"PERSONAL"
|
|
22
|
+
], o = [
|
|
23
|
+
"LOCAL",
|
|
24
|
+
"ICS_URL",
|
|
25
|
+
"GOOGLE_CALENDAR",
|
|
26
|
+
"OUTLOOK_CALENDAR"
|
|
27
|
+
], s = [
|
|
28
|
+
"ICS_URL",
|
|
29
|
+
"GOOGLE_CALENDAR",
|
|
30
|
+
"OUTLOOK_CALENDAR",
|
|
31
|
+
"CALDAV",
|
|
32
|
+
"APPLE_ICAL"
|
|
33
|
+
], c = [
|
|
34
|
+
"ACTIVE",
|
|
35
|
+
"PAUSED",
|
|
36
|
+
"ERROR",
|
|
37
|
+
"DISCONNECTED"
|
|
38
|
+
];
|
|
39
|
+
function l(e) {
|
|
40
|
+
return {
|
|
41
|
+
id: e.id,
|
|
42
|
+
provider: n(e.provider, s, "ICS_URL"),
|
|
43
|
+
status: n(e.status, c, "ERROR"),
|
|
44
|
+
enabled: e.syncEnabled,
|
|
45
|
+
lastSyncAt: i(e.lastSyncAt),
|
|
46
|
+
lastSuccessAt: i(e.lastSuccessAt),
|
|
47
|
+
lastProblem: e.lastProblem ?? null,
|
|
48
|
+
consecutiveFailures: Math.max(0, e.consecutiveFailures),
|
|
49
|
+
slow: e.slow,
|
|
50
|
+
refresh: r(e.refresh, ["HOURLY", "DAILY"]),
|
|
51
|
+
scope: r(e.subscriptionScope, ["PERSONAL", "WORKSPACE"])
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function u(t, r) {
|
|
55
|
+
let i = n(t.calendarType, a, "PERSONAL"), s = n(t.source, o, "LOCAL"), c = t.ownerUserId ?? t.createdBy, u = i === "PERSONAL" && r !== null && c !== r, d = t.externalSyncs.find((e) => e.syncEnabled) ?? t.externalSyncs[0] ?? null;
|
|
56
|
+
return {
|
|
57
|
+
id: t.id,
|
|
58
|
+
name: t.name,
|
|
59
|
+
description: t.description ?? null,
|
|
60
|
+
color: t.color ?? null,
|
|
61
|
+
kind: i,
|
|
62
|
+
source: s,
|
|
63
|
+
isDefault: t.isDefault,
|
|
64
|
+
isPublic: t.isPublic,
|
|
65
|
+
isReadOnly: t.isReadOnly,
|
|
66
|
+
createdBy: t.createdBy,
|
|
67
|
+
ownerUserId: t.ownerUserId ?? null,
|
|
68
|
+
ownerWorkspaceId: t.ownerWorkspaceId ?? null,
|
|
69
|
+
ownerGroupId: t.ownerGroupId ?? null,
|
|
70
|
+
ownerProjectId: t.ownerProjectId ?? null,
|
|
71
|
+
timeZone: e(t.timezone),
|
|
72
|
+
section: s !== "LOCAL" || u ? "other" : "mine",
|
|
73
|
+
sync: d ? l(d) : null
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
var d = {
|
|
77
|
+
WORKSPACE: 0,
|
|
78
|
+
PERSONAL: 1,
|
|
79
|
+
GROUP: 2,
|
|
80
|
+
PROJECT: 3
|
|
81
|
+
};
|
|
82
|
+
function f(e) {
|
|
83
|
+
return [...e].sort((e, t) => Number(e.section === "other") - Number(t.section === "other") || d[e.kind] - d[t.kind] || Number(t.isDefault) - Number(e.isDefault) || e.name.localeCompare(t.name, void 0, { sensitivity: "base" }) || e.id.localeCompare(t.id));
|
|
84
|
+
}
|
|
85
|
+
export { i as parseInstant, f as sortCalendarsV2, u as toCalendarV2 };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","names":["isOneOf","allowed","value","oneOf","fallback","oneOfOrNull","parseInstant","date","KINDS","SOURCES","PROVIDERS","SYNC_STATUSES","toSyncV2","raw","toCalendarV2","kind","source","owner","someoneElses","myUserId","sync","item","canonicalTimeZone","KIND_ORDER","sortCalendarsV2","calendars","a","b"],"sources":["../../../src/v2/data/normalize.ts"],"sourcesContent":["/**\n * The API's calendars, events and free/busy as the redesigned pages use them (BOFF-15698 A0).\n *\n * Every value from the API is checked: an enum value this version doesn't know falls back to\n * a safe one, a time that doesn't parse drops the item (it can't be placed), and a time zone\n * is kept only when it names a real one. Nothing here throws on an odd answer.\n */\nimport { canonicalTimeZone } from '@burdenoff/fe-libs/ui';\nimport type {\n CalendarV2CalendarsQuery,\n CalendarV2EventsInRangeQuery,\n CalendarV2FreeBusyQuery,\n} from '../../generated/wspace-operations';\nimport type {\n BusyBlockV2,\n CalendarEventV2,\n CalendarKindV2,\n CalendarSourceV2,\n CalendarSyncV2,\n CalendarV2,\n EventBookingV2,\n EventGuestV2,\n EventResponseV2,\n PersonFreeBusyV2,\n WorkingHoursV2,\n} from '../types';\n\nexport type RawCalendarV2 = CalendarV2CalendarsQuery['calendars']['calendars'][number];\nexport type RawEventV2 = CalendarV2EventsInRangeQuery['eventsInRange'][number];\nexport type RawPersonFreeBusyV2 = CalendarV2FreeBusyQuery['freeBusy'][number];\n\n/** Whether `value` is one of `allowed`. */\nfunction isOneOf<T extends string>(\n value: string | null | undefined,\n allowed: readonly T[]\n): value is T {\n return new Set<unknown>(allowed).has(value);\n}\n\n/** `value` when it is one of `allowed`, else `fallback`. */\nfunction oneOf<T extends string>(\n value: string | null | undefined,\n allowed: readonly T[],\n fallback: T\n): T {\n return isOneOf(value, allowed) ? value : fallback;\n}\n\n/** `value` when it is one of `allowed`, else null. */\nfunction oneOfOrNull<T extends string>(\n value: string | null | undefined,\n allowed: readonly T[]\n): T | null {\n return isOneOf(value, allowed) ? value : null;\n}\n\n/** The instant an API time names; null when it doesn't parse. */\nexport function parseInstant(value: string | null | undefined): Date | null {\n if (!value) return null;\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n// ── Calendars ────────────────────────────────────────────────────────────────\n\nconst KINDS: readonly CalendarKindV2[] = ['WORKSPACE', 'GROUP', 'PROJECT', 'PERSONAL'];\nconst SOURCES: readonly CalendarSourceV2[] = [\n 'LOCAL',\n 'ICS_URL',\n 'GOOGLE_CALENDAR',\n 'OUTLOOK_CALENDAR',\n];\nconst PROVIDERS = [\n 'ICS_URL',\n 'GOOGLE_CALENDAR',\n 'OUTLOOK_CALENDAR',\n 'CALDAV',\n 'APPLE_ICAL',\n] as const;\nconst SYNC_STATUSES = ['ACTIVE', 'PAUSED', 'ERROR', 'DISCONNECTED'] as const;\n\nfunction toSyncV2(raw: RawCalendarV2['externalSyncs'][number]): CalendarSyncV2 {\n return {\n id: raw.id,\n provider: oneOf(raw.provider, PROVIDERS, 'ICS_URL'),\n status: oneOf(raw.status, SYNC_STATUSES, 'ERROR'),\n enabled: raw.syncEnabled,\n lastSyncAt: parseInstant(raw.lastSyncAt),\n lastSuccessAt: parseInstant(raw.lastSuccessAt),\n lastProblem: raw.lastProblem ?? null,\n consecutiveFailures: Math.max(0, raw.consecutiveFailures),\n slow: raw.slow,\n refresh: oneOfOrNull(raw.refresh, ['HOURLY', 'DAILY'] as const),\n scope: oneOfOrNull(raw.subscriptionScope, ['PERSONAL', 'WORKSPACE'] as const),\n };\n}\n\n/**\n * A calendar for the rail. \"Other calendars\" are the ones that come from outside (a link,\n * Google, Outlook) and another person's own calendar shared with you; the rest are yours:\n * the workspace's, your own, and your teams' and projects'.\n */\nexport function toCalendarV2(raw: RawCalendarV2, myUserId: string | null): CalendarV2 {\n const kind = oneOf(raw.calendarType, KINDS, 'PERSONAL');\n const source = oneOf(raw.source, SOURCES, 'LOCAL');\n const owner = raw.ownerUserId ?? raw.createdBy;\n const someoneElses = kind === 'PERSONAL' && myUserId !== null && owner !== myUserId;\n // An enabled sync says more about the calendar than a paused or removed one.\n const sync = raw.externalSyncs.find((item) => item.syncEnabled) ?? raw.externalSyncs[0] ?? null;\n return {\n id: raw.id,\n name: raw.name,\n description: raw.description ?? null,\n color: raw.color ?? null,\n kind,\n source,\n isDefault: raw.isDefault,\n isPublic: raw.isPublic,\n isReadOnly: raw.isReadOnly,\n createdBy: raw.createdBy,\n ownerUserId: raw.ownerUserId ?? null,\n ownerWorkspaceId: raw.ownerWorkspaceId ?? null,\n ownerGroupId: raw.ownerGroupId ?? null,\n ownerProjectId: raw.ownerProjectId ?? null,\n timeZone: canonicalTimeZone(raw.timezone),\n section: source !== 'LOCAL' || someoneElses ? 'other' : 'mine',\n sync: sync ? toSyncV2(sync) : null,\n };\n}\n\nconst KIND_ORDER: Readonly<Record<CalendarKindV2, number>> = {\n WORKSPACE: 0,\n PERSONAL: 1,\n GROUP: 2,\n PROJECT: 3,\n};\n\n/**\n * The rail's order: your calendars first (the workspace's, your own, teams, projects; the\n * default first in each), then the others; by name within each.\n */\nexport function sortCalendarsV2(calendars: readonly CalendarV2[]): CalendarV2[] {\n return [...calendars].sort(\n (a, b) =>\n Number(a.section === 'other') - Number(b.section === 'other') ||\n KIND_ORDER[a.kind] - KIND_ORDER[b.kind] ||\n Number(b.isDefault) - Number(a.isDefault) ||\n a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }) ||\n a.id.localeCompare(b.id)\n );\n}\n\n// ── Events ───────────────────────────────────────────────────────────────────\n\nconst EVENT_STATUSES = ['CONFIRMED', 'TENTATIVE', 'CANCELLED', 'DRAFT'] as const;\nconst VISIBILITIES = ['PUBLIC', 'PRIVATE', 'CONFIDENTIAL'] as const;\nconst EVENT_TYPES = ['MEETING', 'TASK', 'MILESTONE', 'PROMPT'] as const;\nconst RESPONSES: readonly EventResponseV2[] = ['ACCEPTED', 'TENTATIVE', 'DECLINED', 'NO_RESPONSE'];\nconst LOCATION_TYPES = ['PHYSICAL', 'ONLINE', 'HYBRID', 'TBD'] as const;\nconst MEETING_PROVIDERS = ['ZOOM', 'GOOGLE_MEET', 'MICROSOFT_TEAMS', 'WEBEX', 'CUSTOM'] as const;\nconst REMINDER_CHANNELS = ['IN_APP', 'EMAIL', 'SMS'] as const;\nconst BOOKING_STATUSES = ['PENDING', 'APPROVED', 'REJECTED', 'CANCELLED', 'COMPLETED'] as const;\n\nfunction toGuestV2(raw: RawEventV2['attendees'][number]): EventGuestV2 {\n return {\n id: raw.id,\n userId: raw.userId ?? null,\n email: raw.email ?? null,\n name: raw.name ?? null,\n response: oneOf(raw.rsvpStatus, RESPONSES, 'NO_RESPONSE'),\n optional: raw.isOptional,\n organizer: raw.isOrganizer,\n };\n}\n\nfunction toBookingV2(raw: RawEventV2['resourceBookings'][number]): EventBookingV2 | null {\n const start = parseInstant(raw.startTime);\n const end = parseInstant(raw.endTime);\n if (!start || !end) return null;\n return {\n id: raw.id,\n resourceId: raw.resourceId,\n name: raw.resource?.name ?? null,\n resourceType: raw.resource?.resourceType ?? null,\n location: raw.resource?.location ?? null,\n capacity: raw.resource?.capacity ?? null,\n status: oneOf(raw.status, BOOKING_STATUSES, 'PENDING'),\n start,\n end,\n };\n}\n\n/** An event for the views; null when its times don't parse (it can't be placed). */\nexport function toCalendarEventV2(\n raw: RawEventV2,\n myUserId: string | null\n): CalendarEventV2 | null {\n const start = parseInstant(raw.startTime);\n const end = parseInstant(raw.endTime);\n if (!start || !end) return null;\n const guests = raw.attendees.map(toGuestV2);\n const mine = myUserId ? guests.find((guest) => guest.userId === myUserId) : undefined;\n const meetingUrl = raw.onlineMeetingUrl?.trim();\n return {\n id: raw.id,\n calendarId: raw.calendarId,\n title: raw.title,\n description: raw.description ?? null,\n start,\n end: end.getTime() < start.getTime() ? start : end,\n allDay: raw.allDay,\n timeZone: canonicalTimeZone(raw.timezone),\n status: oneOf(raw.status, EVENT_STATUSES, 'CONFIRMED'),\n visibility: oneOf(raw.visibility, VISIBILITIES, 'PRIVATE'),\n type: oneOf(raw.eventType, EVENT_TYPES, 'MEETING'),\n isRecurring: raw.isRecurring,\n rrule: raw.rrule ?? null,\n organizerId: raw.createdBy,\n guests,\n myResponse: mine?.response ?? null,\n location: raw.location ?? null,\n locationAddress: raw.locationAddress ?? null,\n locationType: oneOfOrNull(raw.locationType, LOCATION_TYPES),\n locationUrl: raw.locationUrl ?? null,\n meeting: meetingUrl\n ? { provider: oneOfOrNull(raw.onlineMeetingProvider, MEETING_PROVIDERS), url: meetingUrl }\n : null,\n reminders: raw.reminders.map((reminder) => ({\n id: reminder.id,\n minutesBefore: reminder.minutesBefore,\n channel: oneOf(reminder.channel, REMINDER_CHANNELS, 'IN_APP'),\n })),\n bookings: raw.resourceBookings.flatMap((booking) => {\n const parsed = toBookingV2(booking);\n return parsed ? [parsed] : [];\n }),\n tags: raw.tags ?? [],\n metadata: isRecord(raw.metadata) ? raw.metadata : null,\n createdAt: parseInstant(raw.createdAt) ?? start,\n updatedAt: parseInstant(raw.updatedAt) ?? start,\n };\n}\n\n/** Events by start (all-day first on a tie, then longer first), each once. */\nexport function sortEventsV2(events: readonly CalendarEventV2[]): CalendarEventV2[] {\n const seen = new Set<string>();\n return [...events]\n .sort(\n (a, b) =>\n a.start.getTime() - b.start.getTime() ||\n Number(b.allDay) - Number(a.allDay) ||\n b.end.getTime() - a.end.getTime() ||\n a.id.localeCompare(b.id)\n )\n .filter((event) => {\n if (seen.has(event.id)) return false;\n seen.add(event.id);\n return true;\n });\n}\n\n// ── Free/busy ────────────────────────────────────────────────────────────────\n\nconst FREE_BUSY_KINDS = ['BUSY', 'TENTATIVE', 'OUT_OF_OFFICE'] as const;\nconst WEEKDAYS: Readonly<Record<string, number>> = {\n SUNDAY: 0,\n MONDAY: 1,\n TUESDAY: 2,\n WEDNESDAY: 3,\n THURSDAY: 4,\n FRIDAY: 5,\n SATURDAY: 6,\n};\n\n/** Minutes after midnight of an \"HH:MM\" time (\"24:00\" is 1440); null for anything else. */\nexport function clockMinutes(value: string): number | null {\n const match = /^(\\d{1,2}):(\\d{2})$/.exec(value.trim());\n if (!match) return null;\n const hours = Number(match[1]);\n const minutes = Number(match[2]);\n if (minutes > 59 || hours > 24 || (hours === 24 && minutes > 0)) return null;\n return hours * 60 + minutes;\n}\n\nfunction toWorkingHoursV2(raw: RawPersonFreeBusyV2['workingHours'][number]): WorkingHoursV2 | null {\n const weekday = WEEKDAYS[raw.dayOfWeek];\n const start = clockMinutes(raw.start);\n const end = clockMinutes(raw.end);\n const timeZone = canonicalTimeZone(raw.timezone);\n if (weekday === undefined || start === null || end === null || !timeZone || start === end) {\n return null;\n }\n return { weekday, start, end, timeZone };\n}\n\n/** One person's free/busy: blocks by start (timed before all-day on a tie). */\nexport function toPersonFreeBusyV2(raw: RawPersonFreeBusyV2): PersonFreeBusyV2 {\n const blocks: BusyBlockV2[] = raw.busy.flatMap((block) => {\n const start = parseInstant(block.start);\n const end = parseInstant(block.end);\n if (!start || !end || end.getTime() < start.getTime()) return [];\n return [{ start, end, kind: oneOf(block.kind, FREE_BUSY_KINDS, 'BUSY'), allDay: block.allDay }];\n });\n blocks.sort(\n (a, b) => a.start.getTime() - b.start.getTime() || Number(a.allDay) - Number(b.allDay)\n );\n return {\n userId: raw.userId,\n blocks,\n workingHours: raw.workingHours.flatMap((hours) => {\n const parsed = toWorkingHoursV2(hours);\n return parsed ? [parsed] : [];\n }),\n truncated: raw.truncated,\n };\n}\n"],"mappings":";;AAgCA,SAASA,EACP,GACA,GACY;CACZ,OAAO,IAAI,IAAaC,CAAO,CAAC,CAAC,IAAIC,CAAK;AAC5C;AAGA,SAASC,EACP,GACA,GACA,GACG;CACH,OAAOH,EAAQE,GAAOD,CAAO,IAAIC,IAAQE;AAC3C;AAGA,SAASC,EACP,GACA,GACU;CACV,OAAOL,EAAQE,GAAOD,CAAO,IAAIC,IAAQ;AAC3C;AAGA,SAAgBI,EAAa,GAA+C;CAC1E,IAAI,CAACJ,GAAO,OAAO;CACnB,IAAMK,IAAO,IAAI,KAAKL,CAAK;CAC3B,OAAO,OAAO,MAAMK,EAAK,QAAQ,CAAC,IAAI,OAAOA;AAC/C;AAQA,IAAMC,IAAmC;CAAC;CAAa;CAAS;CAAW;AAAU,GAC/EC,IAAuC;CAC3C;CACA;CACA;CACA;AACF,GACMC,IAAY;CAChB;CACA;CACA;CACA;CACA;AACF,GACMC,IAAgB;CAAC;CAAU;CAAU;CAAS;AAAc;AAElE,SAASC,EAAS,GAA6D;CAC7E,OAAO;EACL,IAAIC,EAAI;EACR,UAAUV,EAAMU,EAAI,UAAUH,GAAW,SAAS;EAClD,QAAQP,EAAMU,EAAI,QAAQF,GAAe,OAAO;EAChD,SAASE,EAAI;EACb,YAAYP,EAAaO,EAAI,UAAU;EACvC,eAAeP,EAAaO,EAAI,aAAa;EAC7C,aAAaA,EAAI,eAAe;EAChC,qBAAqB,KAAK,IAAI,GAAGA,EAAI,mBAAmB;EACxD,MAAMA,EAAI;EACV,SAASR,EAAYQ,EAAI,SAAS,CAAC,UAAU,OAAO,CAAU;EAC9D,OAAOR,EAAYQ,EAAI,mBAAmB,CAAC,YAAY,WAAW,CAAU;CAC9E;AACF;AAOA,SAAgBC,EAAa,GAAoB,GAAqC;CACpF,IAAMC,IAAOZ,EAAMU,EAAI,cAAcL,GAAO,UAAU,GAChDQ,IAASb,EAAMU,EAAI,QAAQJ,GAAS,OAAO,GAC3CQ,IAAQJ,EAAI,eAAeA,EAAI,WAC/BK,IAAeH,MAAS,cAAcI,MAAa,QAAQF,MAAUE,GAErEC,IAAOP,EAAI,cAAc,MAAM,MAASQ,EAAK,WAAW,KAAKR,EAAI,cAAc,MAAM;CAC3F,OAAO;EACL,IAAIA,EAAI;EACR,MAAMA,EAAI;EACV,aAAaA,EAAI,eAAe;EAChC,OAAOA,EAAI,SAAS;EACpB;EACA;EACA,WAAWA,EAAI;EACf,UAAUA,EAAI;EACd,YAAYA,EAAI;EAChB,WAAWA,EAAI;EACf,aAAaA,EAAI,eAAe;EAChC,kBAAkBA,EAAI,oBAAoB;EAC1C,cAAcA,EAAI,gBAAgB;EAClC,gBAAgBA,EAAI,kBAAkB;EACtC,UAAUS,EAAkBT,EAAI,QAAQ;EACxC,SAASG,MAAW,WAAWE,IAAe,UAAU;EACxD,MAAME,IAAOR,EAASQ,CAAI,IAAI;CAChC;AACF;AAEA,IAAMG,IAAuD;CAC3D,WAAW;CACX,UAAU;CACV,OAAO;CACP,SAAS;AACX;AAMA,SAAgBC,EAAgB,GAAgD;CAC9E,OAAO,CAAC,GAAGC,CAAS,CAAC,CAAC,MACnB,GAAG,MACF,OAAOC,EAAE,YAAY,OAAO,IAAI,OAAOC,EAAE,YAAY,OAAO,KAC5DJ,EAAWG,EAAE,QAAQH,EAAWI,EAAE,SAClC,OAAOA,EAAE,SAAS,IAAI,OAAOD,EAAE,SAAS,KACxCA,EAAE,KAAK,cAAcC,EAAE,MAAM,KAAA,GAAW,EAAE,aAAa,OAAO,CAAC,KAC/DD,EAAE,GAAG,cAAcC,EAAE,EAAE,CAC3B;AACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CalendarV2 } from '../types';
|
|
2
|
+
/** The most calendars one list asks for (the service's page limit). */
|
|
3
|
+
export declare const CALENDARS_PAGE_SIZE = 200;
|
|
4
|
+
export interface CalendarsV2 {
|
|
5
|
+
calendars: CalendarV2[];
|
|
6
|
+
/** `idle` when skipped; `error` only when there is nothing to show. */
|
|
7
|
+
status: 'idle' | 'loading' | 'ready' | 'error';
|
|
8
|
+
error: Error | null;
|
|
9
|
+
/** More calendars exist than one list holds. */
|
|
10
|
+
hasMore: boolean;
|
|
11
|
+
total: number;
|
|
12
|
+
refetch: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function useCalendarsV2(options?: {
|
|
15
|
+
skip?: boolean;
|
|
16
|
+
}): CalendarsV2;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CalendarV2CalendarsDocument as e } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { useCalendar as t } from "../../providers/CalendarProvider.js";
|
|
3
|
+
import { sortCalendarsV2 as n, toCalendarV2 as r } from "./normalize.js";
|
|
4
|
+
import { useCallback as i, useMemo as a } from "react";
|
|
5
|
+
import { useQuery as o } from "@apollo/client/react";
|
|
6
|
+
function s(s = {}) {
|
|
7
|
+
let { currentUser: c } = t(), l = c?.id ?? null, { data: u, error: d, loading: f, refetch: p } = o(e, {
|
|
8
|
+
variables: { pagination: { limit: 200 } },
|
|
9
|
+
fetchPolicy: "cache-and-network",
|
|
10
|
+
skip: s.skip
|
|
11
|
+
}), m = u?.calendars, h = a(() => n((m?.calendars ?? []).map((e) => r(e, l))), [m, l]), g = i(() => {
|
|
12
|
+
p().catch(() => void 0);
|
|
13
|
+
}, [p]);
|
|
14
|
+
return {
|
|
15
|
+
calendars: h,
|
|
16
|
+
status: s.skip ? "idle" : m ? "ready" : d ? "error" : f ? "loading" : "ready",
|
|
17
|
+
error: d ?? null,
|
|
18
|
+
hasMore: m?.hasMore ?? !1,
|
|
19
|
+
total: m?.total ?? h.length,
|
|
20
|
+
refetch: g
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export { s as useCalendarsV2 };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=useCalendarsV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCalendarsV2.js","names":["useCalendarsV2","useCalendar","myUserId","currentUser","useQuery","CalendarV2CalendarsDocument","options","connection","data","calendars","useMemo","sortCalendarsV2","toCalendarV2","raw","reload","useCallback","refetch","error","loading"],"sources":["../../../src/v2/data/useCalendarsV2.ts"],"sourcesContent":["/**\n * The calendars the redesigned calendar lists (BOFF-15698 A0): the workspace's calendars the\n * person can see, in the rail's order, each with its section (\"My calendars\" or \"Other\n * calendars\") and what its sync says. A watched query: a write that refetches\n * `CalendarV2Calendars` updates every list on the page.\n */\nimport { useCallback, useMemo } from 'react';\nimport { useQuery } from '@apollo/client/react';\nimport {\n CalendarV2CalendarsDocument,\n type CalendarV2CalendarsQuery,\n type CalendarV2CalendarsQueryVariables,\n} from '../../generated/wspace-operations';\nimport { useCalendar } from '../../providers/CalendarProvider';\nimport type { CalendarV2 } from '../types';\nimport { sortCalendarsV2, toCalendarV2 } from './normalize';\n\n/** The most calendars one list asks for (the service's page limit). */\nexport const CALENDARS_PAGE_SIZE = 200;\n\nexport interface CalendarsV2 {\n calendars: CalendarV2[];\n /** `idle` when skipped; `error` only when there is nothing to show. */\n status: 'idle' | 'loading' | 'ready' | 'error';\n error: Error | null;\n /** More calendars exist than one list holds. */\n hasMore: boolean;\n total: number;\n refetch: () => void;\n}\n\nexport function useCalendarsV2(options: { skip?: boolean } = {}): CalendarsV2 {\n const { currentUser } = useCalendar();\n const myUserId = currentUser?.id ?? null;\n const { data, error, loading, refetch } = useQuery<\n CalendarV2CalendarsQuery,\n CalendarV2CalendarsQueryVariables\n >(CalendarV2CalendarsDocument, {\n variables: { pagination: { limit: CALENDARS_PAGE_SIZE } },\n fetchPolicy: 'cache-and-network',\n skip: options.skip,\n });\n const connection = data?.calendars;\n const calendars = useMemo(\n () => sortCalendarsV2((connection?.calendars ?? []).map((raw) => toCalendarV2(raw, myUserId))),\n [connection, myUserId]\n );\n const reload = useCallback(() => {\n // A failed refetch shows through `error`.\n refetch().catch(() => undefined);\n }, [refetch]);\n\n const status: CalendarsV2['status'] = options.skip\n ? 'idle'\n : connection\n ? 'ready'\n : error\n ? 'error'\n : loading\n ? 'loading'\n : 'ready';\n\n return {\n calendars,\n status,\n error: error ?? null,\n hasMore: connection?.hasMore ?? false,\n total: connection?.total ?? calendars.length,\n refetch: reload,\n };\n}\n"],"mappings":";;;;;AA+BA,SAAgBA,EAAe,IAA8B,CAAC,GAAgB;CAC5E,IAAM,EAAE,mBAAgBC,EAAY,GAC9BC,IAAWC,GAAa,MAAM,MAC9B,EAAE,SAAM,UAAO,YAAS,eAAYC,EAGxCC,GAA6B;EAC7B,WAAW,EAAE,YAAY,EAAE,OAAA,IAA2B,EAAE;EACxD,aAAa;EACb,MAAMC,EAAQ;CAChB,CAAC,GACKC,IAAaC,GAAM,WACnBC,IAAYC,QACVC,GAAiBJ,GAAY,aAAa,CAAC,EAAA,CAAG,KAAK,MAAQK,EAAaC,GAAKX,CAAQ,CAAC,CAAC,GAC7F,CAACK,GAAYL,CAAQ,CACvB,GACMY,IAASC,QAAkB;EAE/B,EAAQ,CAAC,CAAC,YAAY,KAAA,CAAS;CACjC,GAAG,CAACC,CAAO,CAAC;CAYZ,OAAO;EACL;EACA,QAZoCV,EAAQ,OAC1C,SACAC,IACE,UACAU,IACE,UACAC,IACE,YACA;EAKR,OAAOD,KAAS;EAChB,SAASV,GAAY,WAAW;EAChC,OAAOA,GAAY,SAASE,EAAU;EACtC,SAASK;CACX;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CalendarEventV2 } from '../types';
|
|
2
|
+
export interface EventsInRangeV2 {
|
|
3
|
+
events: CalendarEventV2[];
|
|
4
|
+
/**
|
|
5
|
+
* `idle`: skipped. `loading`: this range hasn't answered yet. `ready`. `partial`: some
|
|
6
|
+
* calendars failed (`failedCalendarIds`). `error`: every calendar failed (`error`); `events`
|
|
7
|
+
* then holds this range's last good answer, if a refresh failed, else nothing.
|
|
8
|
+
*/
|
|
9
|
+
status: 'idle' | 'loading' | 'ready' | 'partial' | 'error';
|
|
10
|
+
/** A load is running: the first one for this range, or a refresh. */
|
|
11
|
+
isFetching: boolean;
|
|
12
|
+
failedCalendarIds: string[];
|
|
13
|
+
error: Error | null;
|
|
14
|
+
refetch: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function useEventsInRangeV2(calendarIds: readonly string[], from: Date, to: Date, options?: {
|
|
17
|
+
skip?: boolean;
|
|
18
|
+
}): EventsInRangeV2;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PersonFreeBusyV2 } from '../types';
|
|
2
|
+
/** The most people one free/busy question may ask about (the service's limit). */
|
|
3
|
+
export declare const FREE_BUSY_PEOPLE_PER_QUESTION = 20;
|
|
4
|
+
/** The longest range one free/busy question may cover, in days (the service's limit). */
|
|
5
|
+
export declare const MAX_FREE_BUSY_DAYS = 62;
|
|
6
|
+
export interface FreeBusyV2 {
|
|
7
|
+
/** In the order asked, each person once. */
|
|
8
|
+
people: PersonFreeBusyV2[];
|
|
9
|
+
byUserId: ReadonlyMap<string, PersonFreeBusyV2>;
|
|
10
|
+
/** `idle`: skipped, or nobody to ask about. `error`: see `error`; `people` is then empty. */
|
|
11
|
+
status: 'idle' | 'loading' | 'ready' | 'error';
|
|
12
|
+
isFetching: boolean;
|
|
13
|
+
error: Error | null;
|
|
14
|
+
refetch: () => void;
|
|
15
|
+
}
|
|
16
|
+
/** The ids to ask about: trimmed, without blanks or repeats, in the order given. */
|
|
17
|
+
export declare function freeBusyUserIds(userIds: readonly string[]): string[];
|
|
18
|
+
/** Why a range can't be asked about; null when it can. */
|
|
19
|
+
export declare function freeBusyRangeProblem(from: Date, to: Date): string | null;
|
|
20
|
+
export declare function useFreeBusy(userIds: readonly string[], from: Date, to: Date, options?: {
|
|
21
|
+
skip?: boolean;
|
|
22
|
+
}): FreeBusyV2;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface KeyedLoadState<T> {
|
|
2
|
+
/** The latest answer, for `dataKey`. */
|
|
3
|
+
data: T | undefined;
|
|
4
|
+
/** The key `data` answers. */
|
|
5
|
+
dataKey: string | null;
|
|
6
|
+
/** The error of the latest load for the current key. */
|
|
7
|
+
error: Error | null;
|
|
8
|
+
/** A load for the current key is running. */
|
|
9
|
+
loading: boolean;
|
|
10
|
+
/** Load the current key again. */
|
|
11
|
+
reload: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `refresh`: a value whose change loads the current key again (as `reload` does) while its
|
|
15
|
+
* answer stays current, e.g. the events revision after a write.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useKeyedLoad<T>(key: string | null, load: (signal: AbortSignal) => Promise<T>, refresh?: number | string): KeyedLoadState<T>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CalendarPrefs } from './calendarPrefs';
|
|
3
|
+
import { CalendarPrefsApi } from './prefsApi';
|
|
4
|
+
import { PrefsSnapshot } from './prefsSession';
|
|
5
|
+
export interface CalendarPrefsContextValue extends PrefsSnapshot {
|
|
6
|
+
/** Changes settings at once; they are written to the account shortly after. */
|
|
7
|
+
update: (patch: Partial<CalendarPrefs>) => void;
|
|
8
|
+
/** Call once today's ticked calendars have been turned into hidden ones. */
|
|
9
|
+
clearLegacyVisibleCalendarIds: () => void;
|
|
10
|
+
}
|
|
11
|
+
export interface CalendarPrefsProviderProps {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
/** The account calls; the global gateway's by default (tests pass their own). */
|
|
14
|
+
api?: CalendarPrefsApi;
|
|
15
|
+
}
|
|
16
|
+
export declare function CalendarPrefsProvider({ children, api }: CalendarPrefsProviderProps): import('react').JSX.Element;
|
|
17
|
+
/** The person's calendar settings. Only inside the redesigned calendar (`CalendarRoutesV2`). */
|
|
18
|
+
export declare function useCalendarPrefs(): CalendarPrefsContextValue;
|
|
19
|
+
/** The time zone the calendar shows: the person's choice, else this device's. */
|
|
20
|
+
export declare function useCalendarTimeZone(): string;
|
|
21
|
+
/**
|
|
22
|
+
* True once the account's settings have been read (or couldn't be), or after `maxWaitMs`: for
|
|
23
|
+
* one-time decisions, such as where an address redirects, that a stale device copy must not make.
|
|
24
|
+
*/
|
|
25
|
+
export declare function usePrefsSettled(maxWaitMs?: number): boolean;
|