@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
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { technicalDetails as e } from "../data/errors.js";
|
|
2
|
+
import { useCalendarPage as t } from "../page/CalendarPageContext.js";
|
|
3
|
+
import { TITLE_INPUT_ID as n, issueTarget as r } from "./dialogLogic.js";
|
|
4
|
+
import { EventDetailsTab as i } from "./EventDetailsTab.js";
|
|
5
|
+
import { detachedForm as a } from "./eventForm.js";
|
|
6
|
+
import { EventMoreTab as o } from "./EventMoreTab.js";
|
|
7
|
+
import { EventPeopleTab as s, GUEST_INPUT_SELECTOR as c } from "./EventPeopleTab.js";
|
|
8
|
+
import { EventPlaceTab as l } from "./EventPlaceTab.js";
|
|
9
|
+
import { canChangeLater as u, isFirstDate as d } from "./savePlan.js";
|
|
10
|
+
import { useEventDialogModel as f } from "./useEventDialogModel.js";
|
|
11
|
+
import { useEventSave as p } from "./useEventSave.js";
|
|
12
|
+
import { useState as m } from "react";
|
|
13
|
+
import { CalendarDays as h, ChevronDown as g, FileText as _, Loader2 as v, Lock as y, MapPin as b, SlidersHorizontal as x, Users as S } from "lucide-react";
|
|
14
|
+
import { jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
15
|
+
import { Button as T, DropdownMenu as E, DropdownMenuContent as D, DropdownMenuRadioGroup as O, DropdownMenuRadioItem as k, DropdownMenuTrigger as A, IconTile as j, Notice as M, ShowTechnicalDetails as N, Spinner as P, TabbedDialog as F, TabbedDialogContent as I, TabbedDialogFooter as L, TabbedDialogHeader as R, TabbedDialogTabs as z, useConfirm as B } from "@burdenoff/fe-libs/ui";
|
|
16
|
+
import { cn as V } from "@burdenoff/fe-libs/utils";
|
|
17
|
+
// src/v2/event/EventDialog.tsx
|
|
18
|
+
var H = {
|
|
19
|
+
details: _,
|
|
20
|
+
people: S,
|
|
21
|
+
place: b,
|
|
22
|
+
more: x
|
|
23
|
+
};
|
|
24
|
+
function U({ session: e, edited: t, onChange: n, onClose: r, onFindTime: i }) {
|
|
25
|
+
return e ? /* @__PURE__ */ C(q, {
|
|
26
|
+
session: e,
|
|
27
|
+
edited: t,
|
|
28
|
+
onChange: n,
|
|
29
|
+
onClose: r,
|
|
30
|
+
onFindTime: i
|
|
31
|
+
}) : /* @__PURE__ */ C(G, {
|
|
32
|
+
edited: t,
|
|
33
|
+
onClose: r
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function W({ heading: e, description: n, locked: r, onOpenChange: i, onOpenAutoFocus: a, children: o }) {
|
|
37
|
+
let { tr: s } = t();
|
|
38
|
+
return /* @__PURE__ */ C(F, {
|
|
39
|
+
open: !0,
|
|
40
|
+
onOpenChange: i,
|
|
41
|
+
children: /* @__PURE__ */ w(I, {
|
|
42
|
+
size: "form",
|
|
43
|
+
className: "sm:max-w-[640px]",
|
|
44
|
+
"aria-describedby": void 0,
|
|
45
|
+
onOpenAutoFocus: a,
|
|
46
|
+
children: [/* @__PURE__ */ C(R, {
|
|
47
|
+
icon: /* @__PURE__ */ C(j, {
|
|
48
|
+
size: "sm",
|
|
49
|
+
"aria-hidden": "true",
|
|
50
|
+
children: C(r ? y : h, {})
|
|
51
|
+
}),
|
|
52
|
+
title: e,
|
|
53
|
+
description: n,
|
|
54
|
+
closeLabel: s("calendar.v2.close", "Close")
|
|
55
|
+
}), o]
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function G({ edited: n, onClose: r }) {
|
|
60
|
+
let { tr: i } = t(), a = /* @__PURE__ */ w("div", {
|
|
61
|
+
className: "flex items-center gap-2 text-sm text-text-secondary",
|
|
62
|
+
children: [/* @__PURE__ */ C(P, { size: "sm" }), i("calendar.v2.openingEvent", "Opening the event…")]
|
|
63
|
+
});
|
|
64
|
+
return n.status === "missing" ? a = /* @__PURE__ */ w("div", {
|
|
65
|
+
className: "flex max-w-sm flex-col gap-2",
|
|
66
|
+
children: [/* @__PURE__ */ C("b", {
|
|
67
|
+
className: "text-base text-text-primary",
|
|
68
|
+
children: i("calendar.v2.peekMissing", "This event isn’t available")
|
|
69
|
+
}), /* @__PURE__ */ C("p", {
|
|
70
|
+
className: "text-sm text-text-secondary",
|
|
71
|
+
children: i("calendar.v2.actionGone", "It may have been deleted or moved by someone else.")
|
|
72
|
+
})]
|
|
73
|
+
}) : n.status === "error" && (a = /* @__PURE__ */ w("div", {
|
|
74
|
+
className: "flex max-w-sm flex-col items-center gap-3",
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ C("b", {
|
|
77
|
+
className: "text-base text-text-primary",
|
|
78
|
+
children: i("calendar.v2.peekFailed", "Couldn’t open the event")
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ C("p", {
|
|
81
|
+
className: "text-sm text-text-secondary",
|
|
82
|
+
children: i("calendar.v2.peekFailedBody", "The calendar service didn’t answer. Nothing was changed.")
|
|
83
|
+
}),
|
|
84
|
+
/* @__PURE__ */ C(T, {
|
|
85
|
+
type: "button",
|
|
86
|
+
variant: "outline",
|
|
87
|
+
onClick: n.retry,
|
|
88
|
+
children: i("calendar.v2.tryAgain", "Try again")
|
|
89
|
+
}),
|
|
90
|
+
/* @__PURE__ */ C(N, {
|
|
91
|
+
copyable: !0,
|
|
92
|
+
children: e(n.error)
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
})), /* @__PURE__ */ w(W, {
|
|
96
|
+
heading: i("calendar.v2.evEditTitle", "Edit event"),
|
|
97
|
+
onOpenChange: (e) => e ? void 0 : r(),
|
|
98
|
+
children: [/* @__PURE__ */ C("div", {
|
|
99
|
+
className: "grid min-h-0 flex-1 place-items-center p-6 text-center",
|
|
100
|
+
children: a
|
|
101
|
+
}), /* @__PURE__ */ C(L, { children: /* @__PURE__ */ C(T, {
|
|
102
|
+
type: "button",
|
|
103
|
+
variant: "outline",
|
|
104
|
+
onClick: r,
|
|
105
|
+
children: i("calendar.v2.close", "Close")
|
|
106
|
+
}) })]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function K(e, t) {
|
|
110
|
+
requestAnimationFrame(() => {
|
|
111
|
+
let n = (e instanceof HTMLElement ? e : document).querySelector(t);
|
|
112
|
+
n instanceof HTMLElement && n.focus();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function q({ session: e, edited: h, onChange: g, onClose: _, onFindTime: v }) {
|
|
116
|
+
let b = t(), { tr: x, format: S, timeZone: E } = b, D = B(), [O, k] = m(!1), [A, j] = m(!1), [N, P] = m(!1), F = f({
|
|
117
|
+
session: e,
|
|
118
|
+
edited: h,
|
|
119
|
+
onChange: g,
|
|
120
|
+
onFindTime: v,
|
|
121
|
+
onGuestsPending: P,
|
|
122
|
+
showIssues: O
|
|
123
|
+
}), { model: I, event: R, row: V, readOnly: U } = F, G = p({
|
|
124
|
+
tr: x,
|
|
125
|
+
format: S,
|
|
126
|
+
durationWords: b.durationWords,
|
|
127
|
+
timeZone: E,
|
|
128
|
+
calendarName: (e) => b.calendarsById.get(e)?.name ?? null,
|
|
129
|
+
roomName: (e) => I.rooms.rooms.find((t) => t.id === e)?.name ?? null,
|
|
130
|
+
guestName: I.guestName,
|
|
131
|
+
me: b.me
|
|
132
|
+
}), q = async () => {
|
|
133
|
+
A || (U || !F.dirty || await D({
|
|
134
|
+
title: x("calendar.v2.evDiscardTitle", "Discard your changes?"),
|
|
135
|
+
description: x("calendar.v2.evDiscardBody", "What you changed in this event isn’t saved."),
|
|
136
|
+
tone: "danger",
|
|
137
|
+
confirmLabel: x("calendar.v2.evDiscard", "Discard"),
|
|
138
|
+
cancelLabel: x("calendar.v2.evKeepEditing", "Keep editing")
|
|
139
|
+
})) && _();
|
|
140
|
+
}, Q = async () => {
|
|
141
|
+
if (A || U || F.readBack || N) return;
|
|
142
|
+
k(!0);
|
|
143
|
+
let t = r(I.issues);
|
|
144
|
+
if (t || !F.calendarId) t && g((e) => ({
|
|
145
|
+
...e,
|
|
146
|
+
tab: t.tab
|
|
147
|
+
})), t?.field && K(null, `#${t.field}`);
|
|
148
|
+
else if (!F.toSave) _();
|
|
149
|
+
else {
|
|
150
|
+
j(!0);
|
|
151
|
+
try {
|
|
152
|
+
let t = {
|
|
153
|
+
...I.form,
|
|
154
|
+
calendarId: F.calendarId
|
|
155
|
+
}, n = await G({
|
|
156
|
+
form: t,
|
|
157
|
+
initial: F.baseline,
|
|
158
|
+
event: R,
|
|
159
|
+
row: V,
|
|
160
|
+
scope: e.scope,
|
|
161
|
+
carry: e.carry
|
|
162
|
+
});
|
|
163
|
+
if (n.kind === "saved" && _(), n.kind === "partial") {
|
|
164
|
+
let t = n.madeNew && F.seriesDate && e.scope === "this";
|
|
165
|
+
g((e) => ({
|
|
166
|
+
...e,
|
|
167
|
+
eventId: n.eventId,
|
|
168
|
+
instanceDate: n.instanceDate,
|
|
169
|
+
form: n.madeNew ? a(t ? {
|
|
170
|
+
...e.form,
|
|
171
|
+
repeat: { kind: "none" }
|
|
172
|
+
} : e.form) : e.form,
|
|
173
|
+
partlySaved: !0,
|
|
174
|
+
carry: n.carry
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
} finally {
|
|
178
|
+
j(!1);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, $ = [
|
|
182
|
+
{
|
|
183
|
+
value: "details",
|
|
184
|
+
label: x("calendar.v2.evDetails", "Details"),
|
|
185
|
+
icon: H.details
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
value: "people",
|
|
189
|
+
label: x("calendar.v2.evPeopleTab", "People"),
|
|
190
|
+
icon: H.people
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
value: "place",
|
|
194
|
+
label: x("calendar.v2.evPlace", "Place"),
|
|
195
|
+
icon: H.place
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
value: "more",
|
|
199
|
+
label: x("calendar.v2.evMore", "More"),
|
|
200
|
+
icon: H.more
|
|
201
|
+
}
|
|
202
|
+
], ee = {
|
|
203
|
+
details: `#${n}`,
|
|
204
|
+
people: c
|
|
205
|
+
};
|
|
206
|
+
return /* @__PURE__ */ w(W, {
|
|
207
|
+
heading: F.heading,
|
|
208
|
+
description: F.description,
|
|
209
|
+
locked: U,
|
|
210
|
+
onOpenChange: (e) => e ? void 0 : void q(),
|
|
211
|
+
onOpenAutoFocus: (t) => {
|
|
212
|
+
let n = U ? void 0 : ee[e.tab];
|
|
213
|
+
n && (t.preventDefault(), K(t.currentTarget, n));
|
|
214
|
+
},
|
|
215
|
+
children: [/* @__PURE__ */ C(z, {
|
|
216
|
+
tabs: $,
|
|
217
|
+
value: e.tab,
|
|
218
|
+
onValueChange: (e) => g((t) => ({
|
|
219
|
+
...t,
|
|
220
|
+
tab: e
|
|
221
|
+
})),
|
|
222
|
+
"aria-label": x("calendar.v2.evSections", "Event sections"),
|
|
223
|
+
renderPanel: (e) => /* @__PURE__ */ w("fieldset", {
|
|
224
|
+
disabled: A,
|
|
225
|
+
className: "m-0 flex min-w-0 flex-col gap-4 border-0 p-0",
|
|
226
|
+
children: [
|
|
227
|
+
F.lock ? /* @__PURE__ */ C(M, {
|
|
228
|
+
tone: "lock",
|
|
229
|
+
icon: y,
|
|
230
|
+
children: F.lock
|
|
231
|
+
}) : null,
|
|
232
|
+
F.readBack ? /* @__PURE__ */ C(Y, {
|
|
233
|
+
readBack: F.readBack,
|
|
234
|
+
edited: h
|
|
235
|
+
}) : null,
|
|
236
|
+
e === "details" ? /* @__PURE__ */ C(i, { model: I }) : null,
|
|
237
|
+
e === "people" ? /* @__PURE__ */ C(s, { model: I }) : null,
|
|
238
|
+
e === "place" ? /* @__PURE__ */ C(l, { model: I }) : null,
|
|
239
|
+
e === "more" ? /* @__PURE__ */ C(o, { model: I }) : null
|
|
240
|
+
]
|
|
241
|
+
})
|
|
242
|
+
}), /* @__PURE__ */ w(L, {
|
|
243
|
+
className: "gap-2",
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ C(J, { note: N && !U ? {
|
|
246
|
+
tone: "info",
|
|
247
|
+
text: x("calendar.v2.evAddingTeam", "Adding the team’s people…")
|
|
248
|
+
} : F.note }),
|
|
249
|
+
F.seriesDate && R && V && !U ? /* @__PURE__ */ C(Z, {
|
|
250
|
+
scope: e.scope,
|
|
251
|
+
disabled: A,
|
|
252
|
+
firstDate: d(R, V),
|
|
253
|
+
laterAllowed: u(R, V),
|
|
254
|
+
onScope: (e) => g((t) => ({
|
|
255
|
+
...t,
|
|
256
|
+
scope: e,
|
|
257
|
+
form: e === "this" ? {
|
|
258
|
+
...t.form,
|
|
259
|
+
repeat: F.baseline.repeat
|
|
260
|
+
} : t.form
|
|
261
|
+
}))
|
|
262
|
+
}) : null,
|
|
263
|
+
/* @__PURE__ */ C(T, {
|
|
264
|
+
type: "button",
|
|
265
|
+
variant: "outline",
|
|
266
|
+
onClick: () => void q(),
|
|
267
|
+
disabled: A,
|
|
268
|
+
children: U ? x("calendar.v2.close", "Close") : x("calendar.v2.evCancel", "Cancel")
|
|
269
|
+
}),
|
|
270
|
+
U ? null : /* @__PURE__ */ C(X, {
|
|
271
|
+
saving: A,
|
|
272
|
+
waiting: F.readBack !== null || N,
|
|
273
|
+
editing: e.eventId !== null,
|
|
274
|
+
onSave: () => void Q()
|
|
275
|
+
})
|
|
276
|
+
]
|
|
277
|
+
})]
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function J({ note: e }) {
|
|
281
|
+
if (!e) return /* @__PURE__ */ C("span", { className: "flex-1" });
|
|
282
|
+
let t = {
|
|
283
|
+
bad: "font-medium text-status-error-text",
|
|
284
|
+
warn: "font-medium text-status-warning-text",
|
|
285
|
+
info: "text-text-secondary"
|
|
286
|
+
}[e.tone];
|
|
287
|
+
return /* @__PURE__ */ C("span", {
|
|
288
|
+
className: V("min-w-0 flex-1 truncate text-xs max-sm:basis-full", t),
|
|
289
|
+
role: e.tone === "bad" ? "alert" : void 0,
|
|
290
|
+
children: e.text
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
function Y({ readBack: e, edited: n }) {
|
|
294
|
+
let { tr: r } = t();
|
|
295
|
+
if (e === "missing") return /* @__PURE__ */ C(M, {
|
|
296
|
+
tone: "bad",
|
|
297
|
+
children: r("calendar.v2.evSavedGone", "This event isn’t available any more. It may have been deleted by someone else.")
|
|
298
|
+
});
|
|
299
|
+
if (e !== "failed") return null;
|
|
300
|
+
let i = n.status === "ready" || n.status === "error" ? n.retry : null;
|
|
301
|
+
return /* @__PURE__ */ C(M, {
|
|
302
|
+
tone: "bad",
|
|
303
|
+
action: i ? /* @__PURE__ */ C(T, {
|
|
304
|
+
type: "button",
|
|
305
|
+
variant: "outline",
|
|
306
|
+
size: "sm",
|
|
307
|
+
onClick: i,
|
|
308
|
+
children: r("calendar.v2.tryAgain", "Try again")
|
|
309
|
+
}) : void 0,
|
|
310
|
+
children: r("calendar.v2.evSavedUnread", "Couldn’t read the event back from the calendar service, so saving waits. Try again.")
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function X({ saving: e, waiting: n, editing: r, onSave: i }) {
|
|
314
|
+
let { tr: a } = t(), o = a("calendar.v2.evCreate", "Create event");
|
|
315
|
+
return r && (o = a("calendar.v2.evSaveChanges", "Save changes")), e && (o = a("calendar.v2.evSaving", "Saving…")), /* @__PURE__ */ w(T, {
|
|
316
|
+
type: "button",
|
|
317
|
+
onClick: i,
|
|
318
|
+
disabled: e || n,
|
|
319
|
+
"aria-busy": e || void 0,
|
|
320
|
+
children: [e ? /* @__PURE__ */ C(v, {
|
|
321
|
+
className: "motion-safe:animate-spin",
|
|
322
|
+
"aria-hidden": "true"
|
|
323
|
+
}) : null, o]
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function Z({ scope: e, disabled: n, firstDate: r, laterAllowed: i, onScope: a }) {
|
|
327
|
+
let { tr: o } = t(), s = {
|
|
328
|
+
this: o("calendar.v2.evScopeThis", "This event"),
|
|
329
|
+
later: o("calendar.v2.evScopeLater", "This and later events"),
|
|
330
|
+
all: o("calendar.v2.evScopeAll", "Every event in the series")
|
|
331
|
+
};
|
|
332
|
+
return /* @__PURE__ */ w(E, { children: [/* @__PURE__ */ C(A, {
|
|
333
|
+
asChild: !0,
|
|
334
|
+
children: /* @__PURE__ */ w(T, {
|
|
335
|
+
type: "button",
|
|
336
|
+
variant: "ghost",
|
|
337
|
+
size: "sm",
|
|
338
|
+
disabled: n,
|
|
339
|
+
children: [
|
|
340
|
+
/* @__PURE__ */ C("span", {
|
|
341
|
+
className: "text-text-secondary",
|
|
342
|
+
children: o("calendar.v2.evChange", "Change:")
|
|
343
|
+
}),
|
|
344
|
+
s[e],
|
|
345
|
+
/* @__PURE__ */ C(g, { "aria-hidden": "true" })
|
|
346
|
+
]
|
|
347
|
+
})
|
|
348
|
+
}), /* @__PURE__ */ C(D, {
|
|
349
|
+
align: "end",
|
|
350
|
+
className: "w-72",
|
|
351
|
+
children: /* @__PURE__ */ w(O, {
|
|
352
|
+
value: e,
|
|
353
|
+
onValueChange: (e) => {
|
|
354
|
+
(e === "this" || e === "all" || e === "later" && i) && a(e);
|
|
355
|
+
},
|
|
356
|
+
children: [
|
|
357
|
+
/* @__PURE__ */ C(k, {
|
|
358
|
+
value: "this",
|
|
359
|
+
children: /* @__PURE__ */ w("span", {
|
|
360
|
+
className: "flex flex-col",
|
|
361
|
+
children: [s.this, /* @__PURE__ */ C("span", {
|
|
362
|
+
className: "text-xs text-text-secondary",
|
|
363
|
+
children: o("calendar.v2.evScopeThisNote", "Only this date. The rest of the series stays as it is.")
|
|
364
|
+
})]
|
|
365
|
+
})
|
|
366
|
+
}),
|
|
367
|
+
/* @__PURE__ */ C(k, {
|
|
368
|
+
value: "later",
|
|
369
|
+
disabled: !i,
|
|
370
|
+
children: /* @__PURE__ */ w("span", {
|
|
371
|
+
className: "flex flex-col",
|
|
372
|
+
children: [s.later, r || !i ? /* @__PURE__ */ C("span", {
|
|
373
|
+
className: "text-xs text-text-secondary",
|
|
374
|
+
children: r ? o("calendar.v2.evScopeLaterFirst", "This is the series’ first date, so every event changes.") : o("calendar.v2.evScopeLaterCount", "Not for a series that ends after a number of times yet. Change this event or every event.")
|
|
375
|
+
}) : null]
|
|
376
|
+
})
|
|
377
|
+
}),
|
|
378
|
+
/* @__PURE__ */ C(k, {
|
|
379
|
+
value: "all",
|
|
380
|
+
children: s.all
|
|
381
|
+
})
|
|
382
|
+
]
|
|
383
|
+
})
|
|
384
|
+
})] });
|
|
385
|
+
}
|
|
386
|
+
export { U as EventDialog };
|
|
387
|
+
|
|
388
|
+
//# sourceMappingURL=EventDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventDialog.js","names":["TAB_ICONS","FileText","Users","MapPin","SlidersHorizontal","EventDialog","session","EventDialogForm","EventDialogState","DialogFrame","useCalendarPage","TabbedDialog","TabbedDialogContent","TabbedDialogHeader","IconTile","jsx","locked","Lock","CalendarDays","heading","tr","children","body","Spinner","edited","Button","ShowTechnicalDetails","technicalDetails","open","onClose","TabbedDialogFooter","focusSoon","target","container","selector","page","confirm","useConfirm","showIssues","setShowIssues","useState","saving","setSaving","addingGuests","setAddingGuests","state","useEventDialogModel","save","useEventSave","id","model","room","requestClose","readOnly","onSave","issueTarget","onChange","current","form","outcome","detachedDate","detachedForm","tabs","firstField","TITLE_INPUT_ID","GUEST_INPUT_SELECTOR","field","focus","TabbedDialogTabs","Notice","ReloadNotice","tab","EventDetailsTab","EventPeopleTab","EventPlaceTab","EventMoreTab","FooterText","event","row","ScopeMenu","isFirstDate","canChangeLater","scope","SaveButton","note","tone","cn","readBack","retry","label","editing","waiting","Loader2","words","DropdownMenu","DropdownMenuTrigger","ChevronDown","DropdownMenuContent","DropdownMenuRadioGroup","value","laterAllowed","onScope","DropdownMenuRadioItem","firstDate"],"sources":["../../../src/v2/event/EventDialog.tsx"],"sourcesContent":["/**\n * The event dialog (BOFF-15698 A2): new and edit, on fe-libs' tabbed dialog as a form (fixed\n * height, at most 640 px wide; a sheet on phones). Details · People · Place · More.\n *\n * - The form lives in `EventDialogs` (the host), so Find a time can open over it and come back\n * with a time without losing what was typed.\n * - Someone else's event, or one on a calendar followed by link, opens read-only, with the\n * reason, as the peek locks Edit: nothing can be changed or saved.\n * - Save: what stops it is named on its field (and its tab opens). The fields are locked while\n * it runs. A failed save keeps every field as typed; a partial one keeps the dialog open on the\n * saved event (`useEventSave`), which saves nothing more until it is read back.\n * - Editing a date of a repeating event, the footer asks which events change (A4): this event,\n * this and later events, or every event in the series.\n * - Closing with unsaved changes asks first.\n */\nimport { useState, type ReactNode } from 'react';\nimport {\n CalendarDays,\n ChevronDown,\n FileText,\n Loader2,\n Lock,\n MapPin,\n SlidersHorizontal,\n Users,\n} from 'lucide-react';\nimport {\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuTrigger,\n IconTile,\n Notice,\n ShowTechnicalDetails,\n Spinner,\n TabbedDialog,\n TabbedDialogContent,\n TabbedDialogFooter,\n TabbedDialogHeader,\n TabbedDialogTabs,\n useConfirm,\n type TabbedDialogTab,\n} from '@burdenoff/fe-libs/ui';\nimport { cn } from '@burdenoff/fe-libs/utils';\nimport { technicalDetails } from '../data/errors';\nimport { useCalendarPage } from '../page/CalendarPageContext';\nimport type { EventTab } from './dialogModel';\nimport { issueTarget, TITLE_INPUT_ID, type FooterNote, type ReadBack } from './dialogLogic';\nimport { EventDetailsTab } from './EventDetailsTab';\nimport { detachedForm, type EventForm } from './eventForm';\nimport { EventMoreTab } from './EventMoreTab';\nimport { EventPeopleTab, GUEST_INPUT_SELECTOR } from './EventPeopleTab';\nimport { EventPlaceTab } from './EventPlaceTab';\nimport { canChangeLater, isFirstDate, type SaveCarry, type ScopeChoice } from './savePlan';\nimport type { EditedEvent } from './useEventData';\nimport { useEventDialogModel } from './useEventDialogModel';\nimport { useEventSave } from './useEventSave';\n\n/** What the event dialog is working on; the host keeps it while Find a time is open. */\nexport interface EventSession {\n /** The stored event edited (a series, for one of its dates); null for a new one (until it saves). */\n eventId: string | null;\n /** A date of a series being edited (A4): its original start; null otherwise. */\n instanceDate: Date | null;\n form: EventForm;\n /** The form as it opened, to tell whether anything changed (a series' date: at that date). */\n initial: EventForm;\n tab: EventTab;\n /** A series' date: which events change. */\n scope: ScopeChoice;\n /**\n * A save stopped part way (A4): from then on what the person changed is told from the event\n * as read back (`baselineOf`), not from `initial`.\n */\n partlySaved: boolean;\n /** What that save left undone and the event read back can't show, for the next save. */\n carry: SaveCarry | null;\n}\n\ntype SessionChange = (change: (session: EventSession) => EventSession) => void;\n\nconst TAB_ICONS = {\n details: FileText,\n people: Users,\n place: MapPin,\n more: SlidersHorizontal,\n} as const;\n\nexport function EventDialog({\n session,\n edited,\n onChange,\n onClose,\n onFindTime,\n}: {\n /** Null while the event to edit loads (or can't be read). */\n session: EventSession | null;\n edited: EditedEvent;\n /** Changes the session, from its latest state (a save's answer can come after more typing). */\n onChange: SessionChange;\n onClose: () => void;\n onFindTime: (session: EventSession) => void;\n}) {\n if (!session) return <EventDialogState edited={edited} onClose={onClose} />;\n return (\n <EventDialogForm\n session={session}\n edited={edited}\n onChange={onChange}\n onClose={onClose}\n onFindTime={onFindTime}\n />\n );\n}\n\n/** The frame and its header, shared by the form and its loading state. */\nfunction DialogFrame({\n heading,\n description,\n locked,\n onOpenChange,\n onOpenAutoFocus,\n children,\n}: {\n heading: string;\n description?: string;\n locked?: boolean;\n onOpenChange: (open: boolean) => void;\n onOpenAutoFocus?: (event: Event) => void;\n children: ReactNode;\n}) {\n const { tr } = useCalendarPage();\n return (\n <TabbedDialog open onOpenChange={onOpenChange}>\n <TabbedDialogContent\n size=\"form\"\n className=\"sm:max-w-[640px]\"\n aria-describedby={undefined}\n onOpenAutoFocus={onOpenAutoFocus}\n >\n <TabbedDialogHeader\n icon={\n <IconTile size=\"sm\" aria-hidden=\"true\">\n {locked ? <Lock /> : <CalendarDays />}\n </IconTile>\n }\n title={heading}\n description={description}\n closeLabel={tr('calendar.v2.close', 'Close')}\n />\n {children}\n </TabbedDialogContent>\n </TabbedDialog>\n );\n}\n\n/** The dialog while the event to edit loads, or when it can't be read. */\nfunction EventDialogState({ edited, onClose }: { edited: EditedEvent; onClose: () => void }) {\n const { tr } = useCalendarPage();\n let body = (\n <div className=\"flex items-center gap-2 text-sm text-text-secondary\">\n <Spinner size=\"sm\" />\n {tr('calendar.v2.openingEvent', 'Opening the event…')}\n </div>\n );\n if (edited.status === 'missing') {\n body = (\n <div className=\"flex max-w-sm flex-col gap-2\">\n <b className=\"text-base text-text-primary\">\n {tr('calendar.v2.peekMissing', 'This event isn’t available')}\n </b>\n <p className=\"text-sm text-text-secondary\">\n {tr('calendar.v2.actionGone', 'It may have been deleted or moved by someone else.')}\n </p>\n </div>\n );\n } else if (edited.status === 'error') {\n body = (\n <div className=\"flex max-w-sm flex-col items-center gap-3\">\n <b className=\"text-base text-text-primary\">\n {tr('calendar.v2.peekFailed', 'Couldn’t open the event')}\n </b>\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\" variant=\"outline\" onClick={edited.retry}>\n {tr('calendar.v2.tryAgain', 'Try again')}\n </Button>\n <ShowTechnicalDetails copyable>{technicalDetails(edited.error)}</ShowTechnicalDetails>\n </div>\n );\n }\n return (\n <DialogFrame\n heading={tr('calendar.v2.evEditTitle', 'Edit event')}\n onOpenChange={(open) => (open ? undefined : onClose())}\n >\n <div className=\"grid min-h-0 flex-1 place-items-center p-6 text-center\">{body}</div>\n <TabbedDialogFooter>\n <Button type=\"button\" variant=\"outline\" onClick={onClose}>\n {tr('calendar.v2.close', 'Close')}\n </Button>\n </TabbedDialogFooter>\n </DialogFrame>\n );\n}\n\n/** Puts the focus on a field once the dialog is open (after the tab's panel shows). */\nfunction focusSoon(container: EventTarget | null, selector: string) {\n requestAnimationFrame(() => {\n const scope = container instanceof HTMLElement ? container : document;\n const target = scope.querySelector(selector);\n if (target instanceof HTMLElement) target.focus();\n });\n}\n\nfunction EventDialogForm({\n session,\n edited,\n onChange,\n onClose,\n onFindTime,\n}: {\n session: EventSession;\n edited: EditedEvent;\n onChange: SessionChange;\n onClose: () => void;\n onFindTime: (session: EventSession) => void;\n}) {\n const page = useCalendarPage();\n const { tr, format, timeZone } = page;\n const confirm = useConfirm();\n const [showIssues, setShowIssues] = useState(false);\n const [saving, setSaving] = useState(false);\n // A team's members being looked up to be added: saving waits for them.\n const [addingGuests, setAddingGuests] = useState(false);\n const state = useEventDialogModel({\n session,\n edited,\n onChange,\n onFindTime,\n onGuestsPending: setAddingGuests,\n showIssues,\n });\n const { model, event, row, readOnly } = state;\n const save = useEventSave({\n tr,\n format,\n durationWords: page.durationWords,\n timeZone,\n calendarName: (id) => page.calendarsById.get(id)?.name ?? null,\n roomName: (id) => model.rooms.rooms.find((room) => room.id === id)?.name ?? null,\n guestName: model.guestName,\n me: page.me,\n });\n\n const requestClose = async () => {\n if (saving) return;\n const discard =\n readOnly ||\n !state.dirty ||\n (await confirm({\n title: tr('calendar.v2.evDiscardTitle', 'Discard your changes?'),\n description: tr('calendar.v2.evDiscardBody', 'What you changed in this event isn’t saved.'),\n tone: 'danger',\n confirmLabel: tr('calendar.v2.evDiscard', 'Discard'),\n cancelLabel: tr('calendar.v2.evKeepEditing', 'Keep editing'),\n }));\n if (discard) onClose();\n };\n\n const onSave = async () => {\n if (saving || readOnly || state.readBack || addingGuests) return;\n setShowIssues(true);\n const target = issueTarget(model.issues);\n if (target || !state.calendarId) {\n if (target) onChange((current) => ({ ...current, tab: target.tab }));\n if (target?.field) focusSoon(null, `#${target.field}`);\n return;\n }\n if (!state.toSave) {\n onClose();\n return;\n }\n setSaving(true);\n try {\n const form = { ...model.form, calendarId: state.calendarId };\n const outcome = await save({\n form,\n initial: state.baseline,\n event,\n row,\n scope: session.scope,\n carry: session.carry,\n });\n if (outcome.kind === 'saved') onClose();\n if (outcome.kind === 'partial') {\n // Saving again goes on with what saved: the event the service made from the series\n // takes the form's guests and reminders as new to it (and a date made its own event\n // doesn't repeat).\n const detachedDate = outcome.madeNew && state.seriesDate && session.scope === 'this';\n onChange((current) => ({\n ...current,\n eventId: outcome.eventId,\n instanceDate: outcome.instanceDate,\n form: outcome.madeNew\n ? detachedForm(\n detachedDate ? { ...current.form, repeat: { kind: 'none' } } : current.form\n )\n : current.form,\n partlySaved: true,\n carry: outcome.carry,\n }));\n }\n } finally {\n setSaving(false);\n }\n };\n\n const tabs: TabbedDialogTab<EventTab>[] = [\n { value: 'details', label: tr('calendar.v2.evDetails', 'Details'), icon: TAB_ICONS.details },\n { value: 'people', label: tr('calendar.v2.evPeopleTab', 'People'), icon: TAB_ICONS.people },\n { value: 'place', label: tr('calendar.v2.evPlace', 'Place'), icon: TAB_ICONS.place },\n { value: 'more', label: tr('calendar.v2.evMore', 'More'), icon: TAB_ICONS.more },\n ];\n const firstField: Partial<Record<EventTab, string>> = {\n details: `#${TITLE_INPUT_ID}`,\n people: GUEST_INPUT_SELECTOR,\n };\n\n return (\n <DialogFrame\n heading={state.heading}\n description={state.description}\n locked={readOnly}\n onOpenChange={(open) => (open ? undefined : void requestClose())}\n onOpenAutoFocus={(focus) => {\n const field = readOnly ? undefined : firstField[session.tab];\n if (!field) return;\n focus.preventDefault();\n focusSoon(focus.currentTarget, field);\n }}\n >\n <TabbedDialogTabs<EventTab>\n tabs={tabs}\n value={session.tab}\n onValueChange={(tab) => onChange((current) => ({ ...current, tab }))}\n aria-label={tr('calendar.v2.evSections', 'Event sections')}\n renderPanel={(tab) => (\n // Locked while a save runs: what's typed then would never be sent.\n <fieldset disabled={saving} className=\"m-0 flex min-w-0 flex-col gap-4 border-0 p-0\">\n {state.lock ? (\n <Notice tone=\"lock\" icon={Lock}>\n {state.lock}\n </Notice>\n ) : null}\n {state.readBack ? <ReloadNotice readBack={state.readBack} edited={edited} /> : null}\n {tab === 'details' ? <EventDetailsTab model={model} /> : null}\n {tab === 'people' ? <EventPeopleTab model={model} /> : null}\n {tab === 'place' ? <EventPlaceTab model={model} /> : null}\n {tab === 'more' ? <EventMoreTab model={model} /> : null}\n </fieldset>\n )}\n />\n <TabbedDialogFooter className=\"gap-2\">\n <FooterText\n note={\n addingGuests && !readOnly\n ? { tone: 'info', text: tr('calendar.v2.evAddingTeam', 'Adding the team’s people…') }\n : state.note\n }\n />\n {state.seriesDate && event && row && !readOnly ? (\n <ScopeMenu\n scope={session.scope}\n disabled={saving}\n firstDate={isFirstDate(event, row)}\n laterAllowed={canChangeLater(event, row)}\n onScope={(scope) =>\n onChange((current) => ({\n ...current,\n scope,\n // One date can't repeat on its own: its repeat goes back to the series'.\n form:\n scope === 'this'\n ? { ...current.form, repeat: state.baseline.repeat }\n : current.form,\n }))\n }\n />\n ) : null}\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void requestClose()}\n disabled={saving}\n >\n {readOnly ? tr('calendar.v2.close', 'Close') : tr('calendar.v2.evCancel', 'Cancel')}\n </Button>\n {readOnly ? null : (\n <SaveButton\n saving={saving}\n waiting={state.readBack !== null || addingGuests}\n editing={session.eventId !== null}\n onSave={() => void onSave()}\n />\n )}\n </TabbedDialogFooter>\n </DialogFrame>\n );\n}\n\n/** The footer's note, in its tone. */\nfunction FooterText({ note }: { note: FooterNote | null }) {\n if (!note) return <span className=\"flex-1\" />;\n const tone = {\n bad: 'font-medium text-status-error-text',\n warn: 'font-medium text-status-warning-text',\n info: 'text-text-secondary',\n }[note.tone];\n return (\n <span\n className={cn('min-w-0 flex-1 truncate text-xs max-sm:basis-full', tone)}\n role={note.tone === 'bad' ? 'alert' : undefined}\n >\n {note.text}\n </span>\n );\n}\n\n/**\n * Why saving waits for the event to be read back: it couldn't be (with Try again), or it is\n * gone. While it is being read, the footer says so.\n */\nfunction ReloadNotice({ readBack, edited }: { readBack: ReadBack; edited: EditedEvent }) {\n const { tr } = useCalendarPage();\n if (readBack === 'missing') {\n return (\n <Notice tone=\"bad\">\n {tr(\n 'calendar.v2.evSavedGone',\n 'This event isn’t available any more. It may have been deleted by someone else.'\n )}\n </Notice>\n );\n }\n if (readBack !== 'failed') return null;\n const retry = edited.status === 'ready' || edited.status === 'error' ? edited.retry : null;\n return (\n <Notice\n tone=\"bad\"\n action={\n retry ? (\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={retry}>\n {tr('calendar.v2.tryAgain', 'Try again')}\n </Button>\n ) : undefined\n }\n >\n {tr(\n 'calendar.v2.evSavedUnread',\n 'Couldn’t read the event back from the calendar service, so saving waits. Try again.'\n )}\n </Notice>\n );\n}\n\n/** \"Create event\" or \"Save changes\", and \"Saving…\" while it runs. */\nfunction SaveButton({\n saving,\n waiting,\n editing,\n onSave,\n}: {\n saving: boolean;\n /** Not yet: the saved event is being read back. */\n waiting: boolean;\n editing: boolean;\n onSave: () => void;\n}) {\n const { tr } = useCalendarPage();\n let label = tr('calendar.v2.evCreate', 'Create event');\n if (editing) label = tr('calendar.v2.evSaveChanges', 'Save changes');\n if (saving) label = tr('calendar.v2.evSaving', 'Saving…');\n return (\n <Button\n type=\"button\"\n onClick={onSave}\n disabled={saving || waiting}\n aria-busy={saving || undefined}\n >\n {saving ? <Loader2 className=\"motion-safe:animate-spin\" aria-hidden=\"true\" /> : null}\n {label}\n </Button>\n );\n}\n\n/**\n * \"Change: …\" for a date of a repeating event (A4): this event on its own, this and the later\n * events, or every event in the series. From the first date, \"this and later\" is every event;\n * elsewhere it isn't offered for a series that ends after a number of times, which a split\n * would count again from this date.\n */\nfunction ScopeMenu({\n scope,\n disabled,\n firstDate,\n laterAllowed,\n onScope,\n}: {\n scope: ScopeChoice;\n disabled: boolean;\n firstDate: boolean;\n laterAllowed: boolean;\n onScope: (scope: ScopeChoice) => void;\n}) {\n const { tr } = useCalendarPage();\n const words: Record<ScopeChoice, string> = {\n this: tr('calendar.v2.evScopeThis', 'This event'),\n later: tr('calendar.v2.evScopeLater', 'This and later events'),\n all: tr('calendar.v2.evScopeAll', 'Every event in the series'),\n };\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button type=\"button\" variant=\"ghost\" size=\"sm\" disabled={disabled}>\n <span className=\"text-text-secondary\">{tr('calendar.v2.evChange', 'Change:')}</span>\n {words[scope]}\n <ChevronDown aria-hidden=\"true\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"w-72\">\n <DropdownMenuRadioGroup\n value={scope}\n onValueChange={(value) => {\n if (value === 'this' || value === 'all' || (value === 'later' && laterAllowed)) {\n onScope(value);\n }\n }}\n >\n <DropdownMenuRadioItem value=\"this\">\n <span className=\"flex flex-col\">\n {words.this}\n <span className=\"text-xs text-text-secondary\">\n {tr(\n 'calendar.v2.evScopeThisNote',\n 'Only this date. The rest of the series stays as it is.'\n )}\n </span>\n </span>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"later\" disabled={!laterAllowed}>\n <span className=\"flex flex-col\">\n {words.later}\n {firstDate || !laterAllowed ? (\n <span className=\"text-xs text-text-secondary\">\n {firstDate\n ? tr(\n 'calendar.v2.evScopeLaterFirst',\n 'This is the series’ first date, so every event changes.'\n )\n : tr(\n 'calendar.v2.evScopeLaterCount',\n 'Not for a series that ends after a number of times yet. Change this event or every event.'\n )}\n </span>\n ) : null}\n </span>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"all\">{words.all}</DropdownMenuRadioItem>\n </DropdownMenuRadioGroup>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmFA,IAAMA,IAAY;CAChB,SAASC;CACT,QAAQC;CACR,OAAOC;CACP,MAAMC;AACR;AAEA,SAAgBC,EAAY,EAC1B,YACA,WACA,aACA,YACA,iBASC;CAED,OADKC,IAEH,kBAACC,GAAD;EACW;EACD;EACE;EACD;EACG;CACb,CAAA,IARkB,kBAACC,GAAD;EAA0B;EAAiB;CAAU,CAAA;AAU5E;AAGA,SAASC,EAAY,EACnB,YACA,gBACA,WACA,iBACA,oBACA,eAQC;CACD,IAAM,EAAE,UAAOC,EAAgB;CAC/B,OACE,kBAACC,GAAD;EAAc,MAAA;EAAmB;EAC/B,UAAA,kBAACC,GAAD;GACE,MAAK;GACL,WAAU;GACV,oBAAkB,KAAA;GACD;GAJnB,UAAA,CAME,kBAACC,GAAD;IACE,MACE,kBAACC,GAAD;KAAU,MAAK;KAAK,eAAY;KAC7B,UAASC,EAATC,IAAUC,IAAWC,GAAZ,CAAO,CAAmB;IAC5B,CAAA;IAEZ,OAAOC;IACM;IACb,YAAYC,EAAG,qBAAqB,OAAO;GAC5C,CAAA,GACAC,CACkB;;CACT,CAAA;AAElB;AAGA,SAASb,EAAiB,EAAE,WAAQ,cAAyD;CAC3F,IAAM,EAAE,UAAOE,EAAgB,GAC3BY,IACF,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACC,GAAD,EAAS,MAAK,KAAM,CAAA,GACnBH,EAAG,4BAA4B,oBAAoB,CACjD;;CAgCP,OA9BII,EAAO,WAAW,YACpB,IACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAAC,KAAD;GAAG,WAAU;GACV,UAAAJ,EAAG,2BAA2B,4BAA4B;EAC1D,CAAA,GACH,kBAAC,KAAD;GAAG,WAAU;GACV,UAAAA,EAAG,0BAA0B,oDAAoD;EACjF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AAO,UAAAT,EAAM;IAA2B,CAAA;GAC/C;;CACL,CAAA,CACT,EAAA,CAAA;AAElB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { useCalendarPage as e } from "../page/CalendarPageContext.js";
|
|
2
|
+
import { useCalendarV2Store as t } from "../state/calendarV2Store.js";
|
|
3
|
+
import { isSeriesDate as n } from "../events/eventModel.js";
|
|
4
|
+
import { isEventTab as r } from "./dialogModel.js";
|
|
5
|
+
import { EventDialog as i } from "./EventDialog.js";
|
|
6
|
+
import { formFromEvent as a, newEventForm as o } from "./eventForm.js";
|
|
7
|
+
import { FindTimeDialog as s } from "./FindTimeDialog.js";
|
|
8
|
+
import { stepForPick as c } from "./findTimeSource.js";
|
|
9
|
+
import { useEditedEvent as l } from "./useEventData.js";
|
|
10
|
+
import { useCallback as u, useEffect as d, useRef as f, useState as p } from "react";
|
|
11
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
12
|
+
// src/v2/event/EventDialogs.tsx
|
|
13
|
+
function h(e, t, i) {
|
|
14
|
+
let s = r(e?.tab) ? e.tab : "details";
|
|
15
|
+
if (e?.eventId) {
|
|
16
|
+
if (t.status !== "ready") return null;
|
|
17
|
+
let r = n(t.event), o = a(t.event, i.timeZone), c = a(t.event, i.timeZone, e);
|
|
18
|
+
return {
|
|
19
|
+
eventId: e.eventId,
|
|
20
|
+
instanceDate: r ? t.event.instanceDate : null,
|
|
21
|
+
form: c,
|
|
22
|
+
initial: o,
|
|
23
|
+
tab: s,
|
|
24
|
+
scope: r ? "this" : "all",
|
|
25
|
+
partlySaved: !1,
|
|
26
|
+
carry: null
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
let c = o(e, i);
|
|
30
|
+
return {
|
|
31
|
+
eventId: null,
|
|
32
|
+
instanceDate: null,
|
|
33
|
+
form: c,
|
|
34
|
+
initial: c,
|
|
35
|
+
tab: s,
|
|
36
|
+
scope: "all",
|
|
37
|
+
partlySaved: !1,
|
|
38
|
+
carry: null
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function g(e, t, n) {
|
|
42
|
+
return e ? {
|
|
43
|
+
kind: "form",
|
|
44
|
+
session: e,
|
|
45
|
+
event: e.eventId && n.status === "ready" ? n.event : null
|
|
46
|
+
} : t ? {
|
|
47
|
+
kind: "event",
|
|
48
|
+
edited: n
|
|
49
|
+
} : { kind: "none" };
|
|
50
|
+
}
|
|
51
|
+
function _(e, t) {
|
|
52
|
+
let n = f(e);
|
|
53
|
+
return d(() => {
|
|
54
|
+
n.current = e;
|
|
55
|
+
}), u((e) => {
|
|
56
|
+
t((t) => {
|
|
57
|
+
let r = t ?? n.current;
|
|
58
|
+
return r ? e(r) : t;
|
|
59
|
+
});
|
|
60
|
+
}, [t]);
|
|
61
|
+
}
|
|
62
|
+
function v({ source: t, onFill: n, onBack: r, onOpen: i, onClose: a }) {
|
|
63
|
+
let o = e();
|
|
64
|
+
return /* @__PURE__ */ m(s, {
|
|
65
|
+
source: t,
|
|
66
|
+
onUse: (e, t) => {
|
|
67
|
+
let r = t.kind === "event" ? o.calendarsById.get(t.event.calendarId) : void 0, s = c(e, t, r, o.me, o.timeZone);
|
|
68
|
+
s.kind === "fillForm" ? n(s.form) : s.kind === "move" ? (o.actions.changeTimes(s.event, {
|
|
69
|
+
start: s.start,
|
|
70
|
+
end: s.end
|
|
71
|
+
}, "move"), a()) : i(s.draft);
|
|
72
|
+
},
|
|
73
|
+
onBack: r,
|
|
74
|
+
onClose: a
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function y({ which: n }) {
|
|
78
|
+
let r = e(), a = t((e) => e.eventDraft), o = t((e) => e.setEventDraft), [s, c] = p(null), [u, d] = p(!1), f = l(s ? s.eventId : a?.eventId ?? null, s ? s.instanceDate : a?.instanceDate ?? null), y = s ?? h(a, f, {
|
|
79
|
+
timeZone: r.timeZone,
|
|
80
|
+
today: r.today,
|
|
81
|
+
defaultLength: r.prefs.defaultDuration,
|
|
82
|
+
defaultReminder: r.prefs.defaultReminder,
|
|
83
|
+
defaultCalendarId: r.defaultCalendarId
|
|
84
|
+
}), b = _(y, c), x = () => {
|
|
85
|
+
c(null), d(!1), o(null), r.nav.closeDialog();
|
|
86
|
+
}, S = () => {
|
|
87
|
+
d(!1), r.nav.openDialog("event");
|
|
88
|
+
};
|
|
89
|
+
if (n === "findtime") {
|
|
90
|
+
let e = u ? s : null;
|
|
91
|
+
return /* @__PURE__ */ m(v, {
|
|
92
|
+
source: g(e, a?.eventId ?? null, f),
|
|
93
|
+
onFill: (e) => {
|
|
94
|
+
b((t) => ({
|
|
95
|
+
...t,
|
|
96
|
+
form: e
|
|
97
|
+
})), S();
|
|
98
|
+
},
|
|
99
|
+
onBack: e ? S : null,
|
|
100
|
+
onOpen: (e) => {
|
|
101
|
+
c(null), o(e), S();
|
|
102
|
+
},
|
|
103
|
+
onClose: x
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return /* @__PURE__ */ m(i, {
|
|
107
|
+
session: y,
|
|
108
|
+
edited: f,
|
|
109
|
+
onChange: b,
|
|
110
|
+
onClose: x,
|
|
111
|
+
onFindTime: (e) => {
|
|
112
|
+
c(e), d(!0), r.nav.openDialog("findtime");
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export { y as EventDialogs };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=EventDialogs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventDialogs.js","names":["openingSession","tab","isEventTab","open","edited","seriesDate","isSeriesDate","initial","formFromEvent","defaults","form","newEventForm","findTimeSourceOf","fromDialog","draftEventId","useSessionChange","currentRef","useRef","current","useEffect","useCallback","base","stored","update","setSession","FindTimeHost","page","useCalendarPage","FindTimeDialog","calendar","basis","step","stepForPick","time","onFill","onClose","onOpen","EventDialogs","draft","useCalendarV2Store","state","setEventDraft","session","useState","findTimeFromDialog","setFindTimeFromDialog","useEditedEvent","change","closeAll","toDialog","which","work","next","EventDialog"],"sources":["../../../src/v2/event/EventDialogs.tsx"],"sourcesContent":["/**\n * The event dialog and Find a time together (BOFF-15698 A2), for `?dialog=event` and\n * `?dialog=findtime`. One host for both keeps the event dialog's work while Find a time is open\n * over it: \"Use this time\" and Back return to the dialog as it was.\n *\n * What they open with is the store's `eventDraft`, set by the view that opened them (New event,\n * quick create's More options, the peek's Edit and \"See all\", ⋯ Find a time, the peek's \"Find a\n * better time\"). Closing clears it. A date of a series opens at that date (A4), asking \"This\n * event\" first.\n */\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n type Dispatch,\n type SetStateAction,\n} from 'react';\nimport { useCalendarPage } from '../page/CalendarPageContext';\nimport { useCalendarV2Store } from '../state/calendarV2Store';\nimport { isSeriesDate } from '../events/eventModel';\nimport type { CalendarV2EventDraft } from '../types';\nimport { isEventTab } from './dialogModel';\nimport { EventDialog, type EventSession } from './EventDialog';\nimport { formFromEvent, newEventForm, type EventForm, type NewFormDefaults } from './eventForm';\nimport { FindTimeDialog, type FindTimeSource } from './FindTimeDialog';\nimport { stepForPick, type FindTimeBasis, type PickedTime } from './findTimeSource';\nimport { useEditedEvent, type EditedEvent } from './useEventData';\n\n/** The dialog as it opens from `open`; null while the event it edits loads. */\nfunction openingSession(\n open: CalendarV2EventDraft | null,\n edited: EditedEvent,\n defaults: NewFormDefaults\n): EventSession | null {\n const tab = isEventTab(open?.tab) ? open.tab : 'details';\n if (open?.eventId) {\n if (edited.status !== 'ready') return null;\n const seriesDate = isSeriesDate(edited.event);\n // The form as the date opened, before a time from Find a time: what \"every event\" and\n // \"this and later\" compare with to tell what the person changed.\n const initial = formFromEvent(edited.event, defaults.timeZone);\n const form = formFromEvent(edited.event, defaults.timeZone, open);\n return {\n eventId: open.eventId,\n instanceDate: seriesDate ? edited.event.instanceDate : null,\n form,\n initial,\n tab,\n scope: seriesDate ? 'this' : 'all',\n partlySaved: false,\n carry: null,\n };\n }\n const form = newEventForm(open, defaults);\n return {\n eventId: null,\n instanceDate: null,\n form,\n initial: form,\n tab,\n scope: 'all',\n partlySaved: false,\n carry: null,\n };\n}\n\n/** Whose time Find a time looks at: the dialog's work, an event's, or the person's alone. */\nfunction findTimeSourceOf(\n fromDialog: EventSession | null,\n draftEventId: string | null,\n edited: EditedEvent\n): FindTimeSource {\n if (fromDialog) {\n const event = fromDialog.eventId && edited.status === 'ready' ? edited.event : null;\n return { kind: 'form', session: fromDialog, event };\n }\n return draftEventId ? { kind: 'event', edited } : { kind: 'none' };\n}\n\n/**\n * Changes to the session, each from the latest: the stored one, else what the dialog shows\n * (until its first change it follows what it opened with, the event as it loads).\n */\nfunction useSessionChange(\n current: EventSession | null,\n setSession: Dispatch<SetStateAction<EventSession | null>>\n): (update: (work: EventSession) => EventSession) => void {\n const currentRef = useRef(current);\n useEffect(() => {\n currentRef.current = current;\n });\n return useCallback(\n (update) => {\n setSession((stored) => {\n const base = stored ?? currentRef.current;\n return base ? update(base) : stored;\n });\n },\n [setSession]\n );\n}\n\n/** Find a time, and what \"Use this time\" does (`stepForPick`). */\nfunction FindTimeHost({\n source,\n onFill,\n onBack,\n onOpen,\n onClose,\n}: {\n source: FindTimeSource;\n /** Back to the event dialog with the time in its form. */\n onFill: (form: EventForm) => void;\n onBack: (() => void) | null;\n /** The event dialog with a new draft: the event's, or a new one. */\n onOpen: (draft: CalendarV2EventDraft) => void;\n onClose: () => void;\n}) {\n const page = useCalendarPage();\n const handleUse = (time: PickedTime, basis: FindTimeBasis) => {\n const calendar =\n basis.kind === 'event' ? page.calendarsById.get(basis.event.calendarId) : undefined;\n const step = stepForPick(time, basis, calendar, page.me, page.timeZone);\n if (step.kind === 'fillForm') {\n onFill(step.form);\n } else if (step.kind === 'move') {\n void page.actions.changeTimes(step.event, { start: step.start, end: step.end }, 'move');\n onClose();\n } else {\n onOpen(step.draft);\n }\n };\n return <FindTimeDialog source={source} onUse={handleUse} onBack={onBack} onClose={onClose} />;\n}\n\nexport function EventDialogs({ which }: { which: 'event' | 'findtime' }) {\n const page = useCalendarPage();\n const draft = useCalendarV2Store((state) => state.eventDraft);\n const setEventDraft = useCalendarV2Store((state) => state.setEventDraft);\n // The dialog's work, kept from its first change on (and while Find a time is open over it).\n const [session, setSession] = useState<EventSession | null>(null);\n const [findTimeFromDialog, setFindTimeFromDialog] = useState(false);\n const edited = useEditedEvent(\n session ? session.eventId : (draft?.eventId ?? null),\n session ? session.instanceDate : (draft?.instanceDate ?? null)\n );\n const current =\n session ??\n openingSession(draft, edited, {\n timeZone: page.timeZone,\n today: page.today,\n defaultLength: page.prefs.defaultDuration,\n defaultReminder: page.prefs.defaultReminder,\n defaultCalendarId: page.defaultCalendarId,\n });\n const change = useSessionChange(current, setSession);\n\n const closeAll = () => {\n setSession(null);\n setFindTimeFromDialog(false);\n setEventDraft(null);\n page.nav.closeDialog();\n };\n const toDialog = () => {\n setFindTimeFromDialog(false);\n page.nav.openDialog('event');\n };\n\n if (which === 'findtime') {\n const fromDialog = findTimeFromDialog ? session : null;\n return (\n <FindTimeHost\n source={findTimeSourceOf(fromDialog, draft?.eventId ?? null, edited)}\n onFill={(form) => {\n change((work) => ({ ...work, form }));\n toDialog();\n }}\n onBack={fromDialog ? toDialog : null}\n onOpen={(next) => {\n setSession(null);\n setEventDraft(next);\n toDialog();\n }}\n onClose={closeAll}\n />\n );\n }\n\n return (\n <EventDialog\n session={current}\n edited={edited}\n onChange={change}\n onClose={closeAll}\n onFindTime={(work) => {\n setSession(work);\n setFindTimeFromDialog(true);\n page.nav.openDialog('findtime');\n }}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAASA,EACP,GACA,GACA,GACqB;CACrB,IAAMC,IAAMC,EAAWC,GAAM,GAAG,IAAIA,EAAK,MAAM;CAC/C,IAAIA,GAAM,SAAS;EACjB,IAAIC,EAAO,WAAW,SAAS,OAAO;EACtC,IAAMC,IAAaC,EAAaF,EAAO,KAAK,GAGtCG,IAAUC,EAAcJ,EAAO,OAAOK,EAAS,QAAQ,GACvDC,I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