@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,368 @@
|
|
|
1
|
+
import { instantToZoned as e, weekdayOf as t, zonedTimeToInstant as n } from "../time/calendarTime.js";
|
|
2
|
+
import { addDays as r, parseDateValue as i } from "@burdenoff/fe-libs/ui";
|
|
3
|
+
// src/v2/event/rrule.ts
|
|
4
|
+
var a = [
|
|
5
|
+
"SU",
|
|
6
|
+
"MO",
|
|
7
|
+
"TU",
|
|
8
|
+
"WE",
|
|
9
|
+
"TH",
|
|
10
|
+
"FR",
|
|
11
|
+
"SA"
|
|
12
|
+
], o = [
|
|
13
|
+
"MO",
|
|
14
|
+
"TU",
|
|
15
|
+
"WE",
|
|
16
|
+
"TH",
|
|
17
|
+
"FR"
|
|
18
|
+
], s = [
|
|
19
|
+
"MO",
|
|
20
|
+
"TU",
|
|
21
|
+
"WE",
|
|
22
|
+
"TH",
|
|
23
|
+
"FR",
|
|
24
|
+
"SA",
|
|
25
|
+
"SU"
|
|
26
|
+
], c = [
|
|
27
|
+
"DAILY",
|
|
28
|
+
"WEEKLY",
|
|
29
|
+
"MONTHLY",
|
|
30
|
+
"YEARLY"
|
|
31
|
+
], l = 1e3;
|
|
32
|
+
function u(e) {
|
|
33
|
+
return a.some((t) => t === e);
|
|
34
|
+
}
|
|
35
|
+
function d(e) {
|
|
36
|
+
return c.some((t) => t === e);
|
|
37
|
+
}
|
|
38
|
+
function f(e) {
|
|
39
|
+
return a[t(e)] ?? "MO";
|
|
40
|
+
}
|
|
41
|
+
function p(e) {
|
|
42
|
+
return i(e)?.day ?? 1;
|
|
43
|
+
}
|
|
44
|
+
function m(e) {
|
|
45
|
+
let t = i(e);
|
|
46
|
+
return t ? new Date(Date.UTC(t.year, t.month, 0)).getUTCDate() : 31;
|
|
47
|
+
}
|
|
48
|
+
function h(e) {
|
|
49
|
+
return Math.ceil(p(e) / 7);
|
|
50
|
+
}
|
|
51
|
+
function g(e) {
|
|
52
|
+
return p(e) + 7 > m(e);
|
|
53
|
+
}
|
|
54
|
+
function _(e) {
|
|
55
|
+
let t = new Set(e);
|
|
56
|
+
return s.filter((e) => t.has(e));
|
|
57
|
+
}
|
|
58
|
+
function v(e, t) {
|
|
59
|
+
let n = _(e), r = _(t);
|
|
60
|
+
return n.length === r.length && n.every((e, t) => e === r[t]);
|
|
61
|
+
}
|
|
62
|
+
function y(e) {
|
|
63
|
+
let t = ["daily", "weekly"];
|
|
64
|
+
return h(e.start) <= 4 && t.push("monthlyNth"), g(e.start) && t.push("monthlyLast"), t.push("yearly"), o.includes(f(e.start)) && t.push("weekdays"), t;
|
|
65
|
+
}
|
|
66
|
+
function b(e, t) {
|
|
67
|
+
let n = { kind: "never" }, r = f(t.start);
|
|
68
|
+
switch (e) {
|
|
69
|
+
case "daily": return {
|
|
70
|
+
frequency: "DAILY",
|
|
71
|
+
interval: 1,
|
|
72
|
+
weekdays: [],
|
|
73
|
+
monthly: null,
|
|
74
|
+
end: n
|
|
75
|
+
};
|
|
76
|
+
case "weekly": return {
|
|
77
|
+
frequency: "WEEKLY",
|
|
78
|
+
interval: 1,
|
|
79
|
+
weekdays: [r],
|
|
80
|
+
monthly: null,
|
|
81
|
+
end: n
|
|
82
|
+
};
|
|
83
|
+
case "monthlyNth": return {
|
|
84
|
+
frequency: "MONTHLY",
|
|
85
|
+
interval: 1,
|
|
86
|
+
weekdays: [],
|
|
87
|
+
monthly: "nthWeekday",
|
|
88
|
+
end: n
|
|
89
|
+
};
|
|
90
|
+
case "monthlyLast": return {
|
|
91
|
+
frequency: "MONTHLY",
|
|
92
|
+
interval: 1,
|
|
93
|
+
weekdays: [],
|
|
94
|
+
monthly: "lastWeekday",
|
|
95
|
+
end: n
|
|
96
|
+
};
|
|
97
|
+
case "yearly": return {
|
|
98
|
+
frequency: "YEARLY",
|
|
99
|
+
interval: 1,
|
|
100
|
+
weekdays: [],
|
|
101
|
+
monthly: null,
|
|
102
|
+
end: n
|
|
103
|
+
};
|
|
104
|
+
case "weekdays": return {
|
|
105
|
+
frequency: "WEEKLY",
|
|
106
|
+
interval: 1,
|
|
107
|
+
weekdays: [...o],
|
|
108
|
+
monthly: null,
|
|
109
|
+
end: n
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function x(e, t) {
|
|
114
|
+
for (let n of y(t)) {
|
|
115
|
+
let r = b(n, t);
|
|
116
|
+
if (r.frequency === e.frequency && r.interval === e.interval && v(r.weekdays, e.weekdays) && r.monthly === e.monthly && e.end.kind === "never") return n;
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
function S(e, t, n) {
|
|
121
|
+
return e.frequency === t ? e : {
|
|
122
|
+
...e,
|
|
123
|
+
frequency: t,
|
|
124
|
+
weekdays: t === "WEEKLY" ? [f(n.start)] : [],
|
|
125
|
+
monthly: t === "MONTHLY" ? "monthDay" : null
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function C(e, t, n) {
|
|
129
|
+
if (e.frequency !== "WEEKLY" || t === f(n.start)) return e;
|
|
130
|
+
let r = e.weekdays.includes(t) ? e.weekdays.filter((e) => e !== t) : [...e.weekdays, t];
|
|
131
|
+
return {
|
|
132
|
+
...e,
|
|
133
|
+
weekdays: _(r)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function w(e, t, n) {
|
|
137
|
+
if (e.frequency === "WEEKLY") {
|
|
138
|
+
let r = f(t.start), i = f(n.start);
|
|
139
|
+
if (r === i) return e;
|
|
140
|
+
let a = e.weekdays.length === 1 && e.weekdays[0] === r ? [] : e.weekdays;
|
|
141
|
+
return {
|
|
142
|
+
...e,
|
|
143
|
+
weekdays: _([...a, i])
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (e.frequency === "MONTHLY") {
|
|
147
|
+
if (e.monthly === "nthWeekday" && h(n.start) > 4) return {
|
|
148
|
+
...e,
|
|
149
|
+
monthly: "lastWeekday"
|
|
150
|
+
};
|
|
151
|
+
if (e.monthly === "lastWeekday" && !g(n.start)) return {
|
|
152
|
+
...e,
|
|
153
|
+
monthly: "nthWeekday"
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return e;
|
|
157
|
+
}
|
|
158
|
+
function T(e, t) {
|
|
159
|
+
return !Number.isInteger(e.interval) || e.interval < 1 || e.interval > 99 ? "interval" : e.frequency === "WEEKLY" && e.weekdays.length === 0 ? "noWeekdays" : e.end.kind === "count" && (!Number.isInteger(e.end.count) || e.end.count < 1 || e.end.count > 999) ? "count" : e.end.kind === "until" && e.end.date < t.start ? "untilBeforeStart" : null;
|
|
160
|
+
}
|
|
161
|
+
function E(e) {
|
|
162
|
+
return e.toISOString().replace(/\.\d{3}Z$/, "Z").replace(/[-:]/g, "");
|
|
163
|
+
}
|
|
164
|
+
function D(e, t) {
|
|
165
|
+
if (t.allDay) return `${e.replace(/-/g, "")}T235959Z`;
|
|
166
|
+
let i = n(r(e, 1), 0, t.timeZone);
|
|
167
|
+
return E(/* @__PURE__ */ new Date(i.getTime() - l));
|
|
168
|
+
}
|
|
169
|
+
function O(e, t) {
|
|
170
|
+
let n = f(t.start);
|
|
171
|
+
return e === "lastWeekday" ? `-1${n}` : `${h(t.start)}${n}`;
|
|
172
|
+
}
|
|
173
|
+
function k(e, t) {
|
|
174
|
+
let n = [`FREQ=${e.frequency}`];
|
|
175
|
+
if (e.interval > 1 && n.push(`INTERVAL=${e.interval}`), e.frequency === "WEEKLY") {
|
|
176
|
+
let r = _(e.weekdays), i = r.length === 1 && r[0] === f(t.start);
|
|
177
|
+
r.length > 0 && !i && n.push(`BYDAY=${r.join(",")}`);
|
|
178
|
+
}
|
|
179
|
+
return e.frequency === "MONTHLY" && e.monthly && e.monthly !== "monthDay" && n.push(`BYDAY=${O(e.monthly, t)}`), e.end.kind === "count" && n.push(`COUNT=${e.end.count}`), e.end.kind === "until" && n.push(`UNTIL=${D(e.end.date, t)}`), n.join(";");
|
|
180
|
+
}
|
|
181
|
+
function A(e) {
|
|
182
|
+
let t = e.split(/\r?\n/).map((e) => e.trim()).filter((e) => e !== "").filter((e) => !/^DTSTART[:;]/i.test(e));
|
|
183
|
+
if (t.length !== 1) return null;
|
|
184
|
+
let [n] = t;
|
|
185
|
+
return n ? /^RRULE:/i.test(n) ? n.slice(6) : /^[A-Z-]+[:;]/i.test(n) && !/^[A-Z]+=/i.test(n) ? null : n : null;
|
|
186
|
+
}
|
|
187
|
+
function j(t, a) {
|
|
188
|
+
let o = /^(\d{4})(\d{2})(\d{2})(?:T(\d{2})(\d{2})(\d{2})(Z)?)?$/.exec(t);
|
|
189
|
+
if (!o) return null;
|
|
190
|
+
let [, s, c, l, u, d, f, p] = o, m = `${s}-${c}-${l}`;
|
|
191
|
+
if (!i(m)) return null;
|
|
192
|
+
if (u === void 0 || !p) return m;
|
|
193
|
+
let h = new Date(Date.UTC(Number(s), Number(c) - 1, Number(l), Number(u), Number(d), Number(f))), g = a.allDay ? "UTC" : a.timeZone, _ = a.allDay ? 0 : a.startMinutes, v = e(h, g).date;
|
|
194
|
+
return n(v, _, g).getTime() > h.getTime() && (v = r(v, -1)), v;
|
|
195
|
+
}
|
|
196
|
+
function M(e) {
|
|
197
|
+
let t = [];
|
|
198
|
+
for (let n of e.split(",")) {
|
|
199
|
+
let e = /^([+-]?\d{1,2})?(SU|MO|TU|WE|TH|FR|SA)$/.exec(n.trim().toUpperCase()), r = e?.[2];
|
|
200
|
+
if (!e || !u(r)) return null;
|
|
201
|
+
let i = e[1] === void 0 ? null : Number(e[1]);
|
|
202
|
+
t.push({
|
|
203
|
+
ordinal: i,
|
|
204
|
+
day: r
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return t;
|
|
208
|
+
}
|
|
209
|
+
function N(e, t) {
|
|
210
|
+
return e.day === f(t.start) ? e.ordinal === -1 && g(t.start) ? "lastWeekday" : e.ordinal === h(t.start) && e.ordinal <= 4 ? "nthWeekday" : null : null;
|
|
211
|
+
}
|
|
212
|
+
function P(e, t) {
|
|
213
|
+
let n = (e ?? "").trim();
|
|
214
|
+
if (n === "") return { kind: "none" };
|
|
215
|
+
let r = {
|
|
216
|
+
kind: "kept",
|
|
217
|
+
text: n
|
|
218
|
+
}, a = A(n);
|
|
219
|
+
if (a === null) return r;
|
|
220
|
+
let o = /* @__PURE__ */ new Map();
|
|
221
|
+
for (let e of a.split(";")) {
|
|
222
|
+
if (e.trim() === "") continue;
|
|
223
|
+
let t = e.indexOf("=");
|
|
224
|
+
if (t <= 0) return r;
|
|
225
|
+
let n = e.slice(0, t).trim().toUpperCase();
|
|
226
|
+
if (o.has(n)) return r;
|
|
227
|
+
o.set(n, e.slice(t + 1).trim());
|
|
228
|
+
}
|
|
229
|
+
o.delete("DTSTART");
|
|
230
|
+
let s = o.get("FREQ")?.toUpperCase();
|
|
231
|
+
if (!d(s)) return r;
|
|
232
|
+
o.delete("FREQ");
|
|
233
|
+
let c = 1, l = o.get("INTERVAL");
|
|
234
|
+
if (l !== void 0) {
|
|
235
|
+
if (c = Number(l), !/^\d+$/.test(l) || c < 1 || c > 99) return r;
|
|
236
|
+
o.delete("INTERVAL");
|
|
237
|
+
}
|
|
238
|
+
let u = o.get("WKST");
|
|
239
|
+
if (u !== void 0) {
|
|
240
|
+
if (u.toUpperCase() !== "MO" && s === "WEEKLY" && c > 1) return r;
|
|
241
|
+
o.delete("WKST");
|
|
242
|
+
}
|
|
243
|
+
let m = { kind: "never" }, h = o.get("COUNT"), g = o.get("UNTIL");
|
|
244
|
+
if (h !== void 0 && g !== void 0) return r;
|
|
245
|
+
if (h !== void 0) {
|
|
246
|
+
let e = Number(h);
|
|
247
|
+
if (!/^\d+$/.test(h) || e < 1 || e > 999) return r;
|
|
248
|
+
m = {
|
|
249
|
+
kind: "count",
|
|
250
|
+
count: e
|
|
251
|
+
}, o.delete("COUNT");
|
|
252
|
+
}
|
|
253
|
+
if (g !== void 0) {
|
|
254
|
+
let e = j(g.toUpperCase(), t);
|
|
255
|
+
if (!e) return r;
|
|
256
|
+
m = {
|
|
257
|
+
kind: "until",
|
|
258
|
+
date: e
|
|
259
|
+
}, o.delete("UNTIL");
|
|
260
|
+
}
|
|
261
|
+
let v = o.get("BYDAY"), y = v === void 0 ? null : M(v);
|
|
262
|
+
if (v !== void 0 && y === null) return r;
|
|
263
|
+
o.delete("BYDAY");
|
|
264
|
+
let b = o.get("BYSETPOS");
|
|
265
|
+
o.delete("BYSETPOS");
|
|
266
|
+
let x = o.get("BYMONTHDAY");
|
|
267
|
+
o.delete("BYMONTHDAY");
|
|
268
|
+
let S = o.get("BYMONTH");
|
|
269
|
+
if (o.delete("BYMONTH"), o.size > 0) return r;
|
|
270
|
+
let C = f(t.start), w = {
|
|
271
|
+
interval: c,
|
|
272
|
+
end: m
|
|
273
|
+
};
|
|
274
|
+
switch (s) {
|
|
275
|
+
case "DAILY": {
|
|
276
|
+
if (b !== void 0 || x !== void 0 || S !== void 0) return r;
|
|
277
|
+
if (!y) return {
|
|
278
|
+
kind: "rule",
|
|
279
|
+
rule: {
|
|
280
|
+
...w,
|
|
281
|
+
frequency: s,
|
|
282
|
+
weekdays: [],
|
|
283
|
+
monthly: null
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
let e = y.map((e) => e.day);
|
|
287
|
+
return c !== 1 || y.some((e) => e.ordinal !== null) || !e.includes(C) ? r : {
|
|
288
|
+
kind: "rule",
|
|
289
|
+
rule: {
|
|
290
|
+
...w,
|
|
291
|
+
frequency: "WEEKLY",
|
|
292
|
+
weekdays: _(e),
|
|
293
|
+
monthly: null
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
case "WEEKLY": {
|
|
298
|
+
if (b !== void 0 || x !== void 0 || S !== void 0) return r;
|
|
299
|
+
let e = y ? y.map((e) => e.day) : [C];
|
|
300
|
+
return y?.some((e) => e.ordinal !== null) || !e.includes(C) ? r : {
|
|
301
|
+
kind: "rule",
|
|
302
|
+
rule: {
|
|
303
|
+
...w,
|
|
304
|
+
frequency: s,
|
|
305
|
+
weekdays: _(e),
|
|
306
|
+
monthly: null
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
case "MONTHLY": {
|
|
311
|
+
if (S !== void 0) return r;
|
|
312
|
+
if (x !== void 0) return y || b !== void 0 || Number(x) !== p(t.start) ? r : {
|
|
313
|
+
kind: "rule",
|
|
314
|
+
rule: {
|
|
315
|
+
...w,
|
|
316
|
+
frequency: s,
|
|
317
|
+
weekdays: [],
|
|
318
|
+
monthly: "monthDay"
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
if (!y) return b === void 0 ? {
|
|
322
|
+
kind: "rule",
|
|
323
|
+
rule: {
|
|
324
|
+
...w,
|
|
325
|
+
frequency: s,
|
|
326
|
+
weekdays: [],
|
|
327
|
+
monthly: "monthDay"
|
|
328
|
+
}
|
|
329
|
+
} : r;
|
|
330
|
+
let [e] = y;
|
|
331
|
+
if (y.length !== 1 || !e) return r;
|
|
332
|
+
let n = e;
|
|
333
|
+
if (b !== void 0) {
|
|
334
|
+
if (e.ordinal !== null || !/^-?\d{1,2}$/.test(b)) return r;
|
|
335
|
+
n = {
|
|
336
|
+
ordinal: Number(b),
|
|
337
|
+
day: e.day
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
let i = N(n, t);
|
|
341
|
+
return i ? {
|
|
342
|
+
kind: "rule",
|
|
343
|
+
rule: {
|
|
344
|
+
...w,
|
|
345
|
+
frequency: s,
|
|
346
|
+
weekdays: [],
|
|
347
|
+
monthly: i
|
|
348
|
+
}
|
|
349
|
+
} : r;
|
|
350
|
+
}
|
|
351
|
+
case "YEARLY": {
|
|
352
|
+
if (y || b !== void 0) return r;
|
|
353
|
+
let e = i(t.start);
|
|
354
|
+
return S !== void 0 && Number(S) !== e?.month || x !== void 0 && Number(x) !== e?.day ? r : {
|
|
355
|
+
kind: "rule",
|
|
356
|
+
rule: {
|
|
357
|
+
...w,
|
|
358
|
+
frequency: s,
|
|
359
|
+
weekdays: [],
|
|
360
|
+
monthly: null
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
export { a as WEEKDAYS, o as WORKWEEK, k as buildRRule, w as followStart, g as isLastOfMonth, h as nthOfMonth, P as parseRRule, x as presetOf, b as presetRule, y as presetsFor, T as ruleProblem, E as utcStamp, f as weekdayCode, S as withFrequency, C as withWeekdayToggled };
|
|
367
|
+
|
|
368
|
+
//# sourceMappingURL=rrule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rrule.js","names":["WEEKDAYS","WORKWEEK","WEEK_ORDER","FREQUENCIES","SECOND_MS","isWeekday","day","value","isFrequency","frequency","weekdayCode","weekdayOf","date","dayOfMonth","parseDateValue","daysInMonth","parts","nthOfMonth","isLastOfMonth","inWeekOrder","set","days","sameDays","left","a","right","b","index","presetsFor","presets","anchor","presetRule","never","start","preset","presetOf","candidate","rule","withFrequency","withWeekdayToggled","item","followStart","oldDay","before","newDay","after","kept","ruleProblem","utcStamp","instant","untilStamp","last","nextMidnight","zonedTimeToInstant","addDays","monthlyWeekday","pattern","buildRRule","onlyStart","ruleLine","rules","text","line","untilDate","match","year","month","hours","minutes","seconds","utc","zone","minute","instantToZoned","weekdayEntries","entries","raw","ordinal","monthlyPatternOf","entry","parseRRule","fields","part","at","name","interval","intervalText","weekStart","end","countText","untilText","count","byDayText","byDay","setPosText","monthDayText","monthText","startDay","base","named","monthly"],"sources":["../../../src/v2/event/rrule.ts"],"sourcesContent":["/**\n * Repeat rules for the event dialog (BOFF-15698 A2): the RRULE the Repeat menu and its Custom\n * builder write, and a stored one read back into them. Pure.\n *\n * - A rule is always tied to the event's start (`RuleAnchor`): the weekly days include the\n * start's weekday, and a monthly rule is on the start's day of the month, its nth weekday or\n * its last weekday. So the start is always an occurrence, as RFC 5545 asks.\n * - What follows from the start is left to DTSTART rather than written out: weekly on the\n * start's day alone has no BYDAY, monthly on its day no BYMONTHDAY, yearly nothing more. The\n * service expanded series in UTC before B7 (it now expands in the event's own zone), and a\n * reader that walks in UTC puts a written-out weekday a day early or late for an event whose\n * UTC date isn't its own (01:00 in Tokyo is the day before in UTC).\n * - UNTIL is a UTC time: the end of the last day on the event's clock, or for an all-day event\n * (stored at UTC midnights) the end of that day in UTC. Read back, it is the last day an\n * occurrence can start on.\n * - A stored rule this can't hold (BYHOUR, BYWEEKNO, EXDATE lines, several rules, a monthly day\n * other than the start's …) is `kept`: the menu names it, and saving leaves it as it is\n * unless the person picks another.\n */\nimport { addDays, parseDateValue, type DateValue } from '@burdenoff/fe-libs/ui';\nimport { instantToZoned, weekdayOf, zonedTimeToInstant } from '../time/calendarTime';\n\nexport type Weekday = 'SU' | 'MO' | 'TU' | 'WE' | 'TH' | 'FR' | 'SA';\n\n/** By JavaScript's day number: 0 Sunday to 6 Saturday. */\nexport const WEEKDAYS: readonly Weekday[] = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'];\n\n/** Monday to Friday. */\nexport const WORKWEEK: readonly Weekday[] = ['MO', 'TU', 'WE', 'TH', 'FR'];\n\nexport type RepeatFrequency = 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';\n\n/** A monthly rule: on the start's day of the month, its nth weekday, or its last weekday. */\nexport type MonthlyPattern = 'monthDay' | 'nthWeekday' | 'lastWeekday';\n\nexport type RepeatEnd =\n | { kind: 'never' }\n | { kind: 'count'; count: number }\n /** The last day an occurrence may start on, on the event's clock. */\n | { kind: 'until'; date: DateValue };\n\nexport interface RepeatRule {\n frequency: RepeatFrequency;\n /** Every `interval` days, weeks, months or years. */\n interval: number;\n /** Weekly: the days, in week order from Monday, the start's among them. Otherwise empty. */\n weekdays: Weekday[];\n /** Monthly: which day of each month. Otherwise null. */\n monthly: MonthlyPattern | null;\n end: RepeatEnd;\n}\n\n/** What a rule is tied to: the event's start, on its own clock. */\nexport interface RuleAnchor {\n start: DateValue;\n /** Minutes after midnight on the event's clock (0 for an all-day event). */\n startMinutes: number;\n timeZone: string;\n allDay: boolean;\n}\n\nexport type ParsedRepeat =\n { kind: 'none' } | { kind: 'rule'; rule: RepeatRule } | { kind: 'kept'; text: string };\n\n/** The menu's ready-made rules. */\nexport type RepeatPreset =\n 'daily' | 'weekly' | 'monthlyNth' | 'monthlyLast' | 'yearly' | 'weekdays';\n\n/** The longest interval and count the builder offers. */\nexport const MAX_INTERVAL = 99;\nexport const MAX_COUNT = 999;\n\nconst WEEK_ORDER: readonly Weekday[] = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU'];\nconst FREQUENCIES: readonly RepeatFrequency[] = ['DAILY', 'WEEKLY', 'MONTHLY', 'YEARLY'];\nconst SECOND_MS = 1000;\n\nfunction isWeekday(value: string | undefined): value is Weekday {\n return WEEKDAYS.some((day) => day === value);\n}\n\nfunction isFrequency(value: string | undefined): value is RepeatFrequency {\n return FREQUENCIES.some((frequency) => frequency === value);\n}\n\n/** The start's weekday. */\nexport function weekdayCode(date: DateValue): Weekday {\n return WEEKDAYS[weekdayOf(date)] ?? 'MO';\n}\n\nfunction dayOfMonth(date: DateValue): number {\n return parseDateValue(date)?.day ?? 1;\n}\n\nfunction daysInMonth(date: DateValue): number {\n const parts = parseDateValue(date);\n if (!parts) return 31;\n return new Date(Date.UTC(parts.year, parts.month, 0)).getUTCDate();\n}\n\n/** Which of its weekday the date is in its month: 1 for the first … 5 for a fifth. */\nexport function nthOfMonth(date: DateValue): number {\n return Math.ceil(dayOfMonth(date) / 7);\n}\n\n/** The date is the last of its weekday in its month. */\nexport function isLastOfMonth(date: DateValue): boolean {\n return dayOfMonth(date) + 7 > daysInMonth(date);\n}\n\n/** Days in week order from Monday, each once. */\nfunction inWeekOrder(days: readonly Weekday[]): Weekday[] {\n const set = new Set(days);\n return WEEK_ORDER.filter((day) => set.has(day));\n}\n\nfunction sameDays(a: readonly Weekday[], b: readonly Weekday[]): boolean {\n const left = inWeekOrder(a);\n const right = inWeekOrder(b);\n return left.length === right.length && left.every((day, index) => day === right[index]);\n}\n\n// ── The menu's rules ─────────────────────────────────────────────────────────\n\n/**\n * The presets the menu offers for this start: \"on the last …\" only in a month's last week,\n * \"every weekday\" only from a weekday (the start is always an occurrence).\n */\nexport function presetsFor(anchor: RuleAnchor): RepeatPreset[] {\n const presets: RepeatPreset[] = ['daily', 'weekly'];\n if (nthOfMonth(anchor.start) <= 4) presets.push('monthlyNth');\n if (isLastOfMonth(anchor.start)) presets.push('monthlyLast');\n presets.push('yearly');\n if (WORKWEEK.includes(weekdayCode(anchor.start))) presets.push('weekdays');\n return presets;\n}\n\n/** A preset's rule for this start, repeating for ever. */\nexport function presetRule(preset: RepeatPreset, anchor: RuleAnchor): RepeatRule {\n const never: RepeatEnd = { kind: 'never' };\n const start = weekdayCode(anchor.start);\n switch (preset) {\n case 'daily':\n return { frequency: 'DAILY', interval: 1, weekdays: [], monthly: null, end: never };\n case 'weekly':\n return { frequency: 'WEEKLY', interval: 1, weekdays: [start], monthly: null, end: never };\n case 'monthlyNth':\n return { frequency: 'MONTHLY', interval: 1, weekdays: [], monthly: 'nthWeekday', end: never };\n case 'monthlyLast':\n return {\n frequency: 'MONTHLY',\n interval: 1,\n weekdays: [],\n monthly: 'lastWeekday',\n end: never,\n };\n case 'yearly':\n return { frequency: 'YEARLY', interval: 1, weekdays: [], monthly: null, end: never };\n case 'weekdays':\n return {\n frequency: 'WEEKLY',\n interval: 1,\n weekdays: [...WORKWEEK],\n monthly: null,\n end: never,\n };\n }\n}\n\n/** The preset a rule is, for this start; null for anything else (a custom rule). */\nexport function presetOf(rule: RepeatRule, anchor: RuleAnchor): RepeatPreset | null {\n for (const preset of presetsFor(anchor)) {\n const candidate = presetRule(preset, anchor);\n if (\n candidate.frequency === rule.frequency &&\n candidate.interval === rule.interval &&\n sameDays(candidate.weekdays, rule.weekdays) &&\n candidate.monthly === rule.monthly &&\n rule.end.kind === 'never'\n ) {\n return preset;\n }\n }\n return null;\n}\n\n// ── The Custom builder's changes ─────────────────────────────────────────────\n\n/** A new frequency: weekly starts on the start's day, monthly on its day of the month. */\nexport function withFrequency(\n rule: RepeatRule,\n frequency: RepeatFrequency,\n anchor: RuleAnchor\n): RepeatRule {\n if (rule.frequency === frequency) return rule;\n return {\n ...rule,\n frequency,\n weekdays: frequency === 'WEEKLY' ? [weekdayCode(anchor.start)] : [],\n monthly: frequency === 'MONTHLY' ? 'monthDay' : null,\n };\n}\n\n/** Turns a weekly day on or off; the start's own day stays on. */\nexport function withWeekdayToggled(rule: RepeatRule, day: Weekday, anchor: RuleAnchor): RepeatRule {\n if (rule.frequency !== 'WEEKLY' || day === weekdayCode(anchor.start)) return rule;\n const days = rule.weekdays.includes(day)\n ? rule.weekdays.filter((item) => item !== day)\n : [...rule.weekdays, day];\n return { ...rule, weekdays: inWeekOrder(days) };\n}\n\n/**\n * The rule after the event's start moved, so the start stays an occurrence: a weekly rule\n * takes the new start's day (the old start's day goes when it was the only one); a monthly\n * nth weekday past the fourth becomes the last, and a last weekday no longer last the nth.\n */\nexport function followStart(rule: RepeatRule, before: RuleAnchor, after: RuleAnchor): RepeatRule {\n if (rule.frequency === 'WEEKLY') {\n const oldDay = weekdayCode(before.start);\n const newDay = weekdayCode(after.start);\n if (oldDay === newDay) return rule;\n const kept = rule.weekdays.length === 1 && rule.weekdays[0] === oldDay ? [] : rule.weekdays;\n return { ...rule, weekdays: inWeekOrder([...kept, newDay]) };\n }\n if (rule.frequency === 'MONTHLY') {\n if (rule.monthly === 'nthWeekday' && nthOfMonth(after.start) > 4) {\n return { ...rule, monthly: 'lastWeekday' };\n }\n if (rule.monthly === 'lastWeekday' && !isLastOfMonth(after.start)) {\n return { ...rule, monthly: 'nthWeekday' };\n }\n }\n return rule;\n}\n\nexport type RuleProblem = 'interval' | 'count' | 'untilBeforeStart' | 'noWeekdays';\n\n/** What is wrong with a rule the builder holds; null when it can be saved. */\nexport function ruleProblem(rule: RepeatRule, anchor: RuleAnchor): RuleProblem | null {\n if (!Number.isInteger(rule.interval) || rule.interval < 1 || rule.interval > MAX_INTERVAL) {\n return 'interval';\n }\n if (rule.frequency === 'WEEKLY' && rule.weekdays.length === 0) return 'noWeekdays';\n if (\n rule.end.kind === 'count' &&\n (!Number.isInteger(rule.end.count) || rule.end.count < 1 || rule.end.count > MAX_COUNT)\n ) {\n return 'count';\n }\n if (rule.end.kind === 'until' && rule.end.date < anchor.start) return 'untilBeforeStart';\n return null;\n}\n\n// ── Writing ──────────────────────────────────────────────────────────────────\n\n/** `20261231T182959Z`: an instant as RFC 5545 writes a UTC time. */\nexport function utcStamp(instant: Date): string {\n return instant\n .toISOString()\n .replace(/\\.\\d{3}Z$/, 'Z')\n .replace(/[-:]/g, '');\n}\n\n/** The UNTIL of a last day: the end of that day on the event's clock, in UTC. */\nfunction untilStamp(last: DateValue, anchor: RuleAnchor): string {\n if (anchor.allDay) return `${last.replace(/-/g, '')}T235959Z`;\n const nextMidnight = zonedTimeToInstant(addDays(last, 1), 0, anchor.timeZone);\n return utcStamp(new Date(nextMidnight.getTime() - SECOND_MS));\n}\n\n/** `3TU`, `-1FR`: the start's nth or last weekday of the month. */\nfunction monthlyWeekday(pattern: 'nthWeekday' | 'lastWeekday', anchor: RuleAnchor): string {\n const day = weekdayCode(anchor.start);\n return pattern === 'lastWeekday' ? `-1${day}` : `${nthOfMonth(anchor.start)}${day}`;\n}\n\n/** The RRULE value of a rule (without the `RRULE:` prefix), tied to `anchor`. */\nexport function buildRRule(rule: RepeatRule, anchor: RuleAnchor): string {\n const parts = [`FREQ=${rule.frequency}`];\n if (rule.interval > 1) parts.push(`INTERVAL=${rule.interval}`);\n if (rule.frequency === 'WEEKLY') {\n const days = inWeekOrder(rule.weekdays);\n const onlyStart = days.length === 1 && days[0] === weekdayCode(anchor.start);\n if (days.length > 0 && !onlyStart) parts.push(`BYDAY=${days.join(',')}`);\n }\n if (rule.frequency === 'MONTHLY' && rule.monthly && rule.monthly !== 'monthDay') {\n parts.push(`BYDAY=${monthlyWeekday(rule.monthly, anchor)}`);\n }\n if (rule.end.kind === 'count') parts.push(`COUNT=${rule.end.count}`);\n if (rule.end.kind === 'until') parts.push(`UNTIL=${untilStamp(rule.end.date, anchor)}`);\n return parts.join(';');\n}\n\n// ── Reading ──────────────────────────────────────────────────────────────────\n\n/** The rule's line: one line, or the RRULE line among DTSTART lines; null for anything more. */\nfunction ruleLine(text: string): string | null {\n const lines = text\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter((line) => line !== '');\n const rules = lines.filter((line) => !/^DTSTART[:;]/i.test(line));\n if (rules.length !== 1) return null;\n const [line] = rules;\n if (!line) return null;\n if (/^RRULE:/i.test(line)) return line.slice('RRULE:'.length);\n // A one-line value with another property name (EXDATE:, RDATE:, EXRULE:) isn't a rule.\n return /^[A-Z-]+[:;]/i.test(line) && !/^[A-Z]+=/i.test(line) ? null : line;\n}\n\n/** The day an UNTIL names, on the event's clock: the last day an occurrence can start. */\nfunction untilDate(value: string, anchor: RuleAnchor): DateValue | null {\n const match = /^(\\d{4})(\\d{2})(\\d{2})(?:T(\\d{2})(\\d{2})(\\d{2})(Z)?)?$/.exec(value);\n if (!match) return null;\n const [, year, month, day, hours, minutes, seconds, utc] = match;\n const date: DateValue = `${year}-${month}-${day}`;\n if (!parseDateValue(date)) return null;\n // A date, or a floating time: the day as written.\n if (hours === undefined || !utc) return date;\n const instant = new Date(\n Date.UTC(\n Number(year),\n Number(month) - 1,\n Number(day),\n Number(hours),\n Number(minutes),\n Number(seconds)\n )\n );\n const zone = anchor.allDay ? 'UTC' : anchor.timeZone;\n const minute = anchor.allDay ? 0 : anchor.startMinutes;\n let last = instantToZoned(instant, zone).date;\n // An UNTIL before that day's occurrence (an end of day in UTC, read east of UTC) ends a day\n // earlier.\n if (zonedTimeToInstant(last, minute, zone).getTime() > instant.getTime())\n last = addDays(last, -1);\n return last;\n}\n\ninterface WeekdayEntry {\n ordinal: number | null;\n day: Weekday;\n}\n\nfunction weekdayEntries(value: string): WeekdayEntry[] | null {\n const entries: WeekdayEntry[] = [];\n for (const raw of value.split(',')) {\n const match = /^([+-]?\\d{1,2})?(SU|MO|TU|WE|TH|FR|SA)$/.exec(raw.trim().toUpperCase());\n const day = match?.[2];\n if (!match || !isWeekday(day)) return null;\n const ordinal = match[1] === undefined ? null : Number(match[1]);\n entries.push({ ordinal, day });\n }\n return entries;\n}\n\n/** The monthly pattern a weekday entry names for this start; null when it isn't the start's. */\nfunction monthlyPatternOf(entry: WeekdayEntry, anchor: RuleAnchor): MonthlyPattern | null {\n if (entry.day !== weekdayCode(anchor.start)) return null;\n if (entry.ordinal === -1 && isLastOfMonth(anchor.start)) return 'lastWeekday';\n if (entry.ordinal === nthOfMonth(anchor.start) && entry.ordinal <= 4) return 'nthWeekday';\n return null;\n}\n\n/**\n * Reads a stored rule: one line, with or without `RRULE:`, with an inline `DTSTART=` (the\n * service writes one) or DTSTART lines around it. What the builder can't hold for this start is\n * `kept`, never changed or dropped.\n */\nexport function parseRRule(text: string | null | undefined, anchor: RuleAnchor): ParsedRepeat {\n const raw = (text ?? '').trim();\n if (raw === '') return { kind: 'none' };\n const kept: ParsedRepeat = { kind: 'kept', text: raw };\n const line = ruleLine(raw);\n if (line === null) return kept;\n\n const fields = new Map<string, string>();\n for (const part of line.split(';')) {\n if (part.trim() === '') continue;\n const at = part.indexOf('=');\n if (at <= 0) return kept;\n const name = part.slice(0, at).trim().toUpperCase();\n if (fields.has(name)) return kept;\n fields.set(name, part.slice(at + 1).trim());\n }\n // The service's inline start; the start is the event's own.\n fields.delete('DTSTART');\n\n const frequency = fields.get('FREQ')?.toUpperCase();\n if (!isFrequency(frequency)) return kept;\n fields.delete('FREQ');\n\n let interval = 1;\n const intervalText = fields.get('INTERVAL');\n if (intervalText !== undefined) {\n interval = Number(intervalText);\n if (!/^\\d+$/.test(intervalText) || interval < 1 || interval > MAX_INTERVAL) return kept;\n fields.delete('INTERVAL');\n }\n\n // A week starting on Monday is the default; another start only matters every 2+ weeks.\n const weekStart = fields.get('WKST');\n if (weekStart !== undefined) {\n if (weekStart.toUpperCase() !== 'MO' && frequency === 'WEEKLY' && interval > 1) return kept;\n fields.delete('WKST');\n }\n\n let end: RepeatEnd = { kind: 'never' };\n const countText = fields.get('COUNT');\n const untilText = fields.get('UNTIL');\n if (countText !== undefined && untilText !== undefined) return kept;\n if (countText !== undefined) {\n const count = Number(countText);\n if (!/^\\d+$/.test(countText) || count < 1 || count > MAX_COUNT) return kept;\n end = { kind: 'count', count };\n fields.delete('COUNT');\n }\n if (untilText !== undefined) {\n const date = untilDate(untilText.toUpperCase(), anchor);\n if (!date) return kept;\n end = { kind: 'until', date };\n fields.delete('UNTIL');\n }\n\n const byDayText = fields.get('BYDAY');\n const byDay = byDayText === undefined ? null : weekdayEntries(byDayText);\n if (byDayText !== undefined && byDay === null) return kept;\n fields.delete('BYDAY');\n const setPosText = fields.get('BYSETPOS');\n fields.delete('BYSETPOS');\n const monthDayText = fields.get('BYMONTHDAY');\n fields.delete('BYMONTHDAY');\n const monthText = fields.get('BYMONTH');\n fields.delete('BYMONTH');\n // Anything else (BYHOUR, BYWEEKNO, BYYEARDAY, TZID …) is beyond the builder.\n if (fields.size > 0) return kept;\n\n const startDay = weekdayCode(anchor.start);\n const base = { interval, end };\n switch (frequency) {\n case 'DAILY': {\n if (setPosText !== undefined || monthDayText !== undefined || monthText !== undefined) {\n return kept;\n }\n if (!byDay) {\n return { kind: 'rule', rule: { ...base, frequency, weekdays: [], monthly: null } };\n }\n // \"Daily on weekdays\", as some apps write every weekday: the same as weekly on those days.\n const days = byDay.map((entry) => entry.day);\n if (\n interval !== 1 ||\n byDay.some((entry) => entry.ordinal !== null) ||\n !days.includes(startDay)\n ) {\n return kept;\n }\n return {\n kind: 'rule',\n rule: { ...base, frequency: 'WEEKLY', weekdays: inWeekOrder(days), monthly: null },\n };\n }\n case 'WEEKLY': {\n if (setPosText !== undefined || monthDayText !== undefined || monthText !== undefined) {\n return kept;\n }\n const days = byDay ? byDay.map((entry) => entry.day) : [startDay];\n if (byDay?.some((entry) => entry.ordinal !== null) || !days.includes(startDay)) return kept;\n return {\n kind: 'rule',\n rule: { ...base, frequency, weekdays: inWeekOrder(days), monthly: null },\n };\n }\n case 'MONTHLY': {\n if (monthText !== undefined) return kept;\n if (monthDayText !== undefined) {\n if (\n byDay ||\n setPosText !== undefined ||\n Number(monthDayText) !== dayOfMonth(anchor.start)\n ) {\n return kept;\n }\n return { kind: 'rule', rule: { ...base, frequency, weekdays: [], monthly: 'monthDay' } };\n }\n if (!byDay) {\n if (setPosText !== undefined) return kept;\n return { kind: 'rule', rule: { ...base, frequency, weekdays: [], monthly: 'monthDay' } };\n }\n const [entry] = byDay;\n if (byDay.length !== 1 || !entry) return kept;\n let named: WeekdayEntry = entry;\n if (setPosText !== undefined) {\n // BYDAY=TU;BYSETPOS=3 is the third Tuesday, as 3TU.\n if (entry.ordinal !== null || !/^-?\\d{1,2}$/.test(setPosText)) return kept;\n named = { ordinal: Number(setPosText), day: entry.day };\n }\n const monthly = monthlyPatternOf(named, anchor);\n if (!monthly) return kept;\n return { kind: 'rule', rule: { ...base, frequency, weekdays: [], monthly } };\n }\n case 'YEARLY': {\n if (byDay || setPosText !== undefined) return kept;\n const parts = parseDateValue(anchor.start);\n if (monthText !== undefined && Number(monthText) !== parts?.month) return kept;\n if (monthDayText !== undefined && Number(monthDayText) !== parts?.day) return kept;\n return { kind: 'rule', rule: { ...base, frequency, weekdays: [], monthly: null } };\n }\n }\n}\n"],"mappings":";;;AAyBA,IAAaA,IAA+B;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI,GAGxEC,IAA+B;CAAC;CAAM;CAAM;CAAM;CAAM;AAAI,GA4CnEC,IAAiC;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI,GAC1EC,IAA0C;CAAC;CAAS;CAAU;CAAW;AAAQ,GACjFC,IAAY;AAElB,SAASC,EAAU,GAA6C;CAC9D,OAAOL,EAAS,MAAM,MAAQM,MAAQC,CAAK;AAC7C;AAEA,SAASC,EAAY,GAAqD;CACxE,OAAOL,EAAY,MAAM,MAAcM,MAAcF,CAAK;AAC5D;AAGA,SAAgBG,EAAY,GAA0B;CACpD,OAAOV,EAASW,EAAUC,CAAI,MAAM;AACtC;AAEA,SAASC,EAAW,GAAyB;CAC3C,OAAOC,EAAeF,CAAI,CAAC,EAAE,OAAO;AACtC;AAEA,SAASG,EAAY,GAAyB;CAC5C,IAAMC,IAAQF,EAAeF,CAAI;CAEjC,OADKI,IACE,IAAI,KAAK,KAAK,IAAIA,EAAM,MAAMA,EAAM,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,IAD9C;AAErB;AAGA,SAAgBC,EAAW,GAAyB;CAClD,OAAO,KAAK,KAAKJ,EAAWD,CAAI,IAAI,CAAC;AACvC;AAGA,SAAgBM,EAAc,GAA0B;CACtD,OAAOL,EAAWD,CAAI,IAAI,IAAIG,EAAYH,CAAI;AAChD;AAGA,SAASO,EAAY,GAAqC;CACxD,IAAMC,IAAM,IAAI,IAAIC,CAAI;CACxB,OAAOnB,EAAW,QAAQ,MAAQkB,EAAI,IAAId,CAAG,CAAC;AAChD;AAEA,SAASgB,EAAS,GAAuB,GAAgC;CACvE,IAAMC,IAAOJ,EAAYK,CAAC,GACpBC,IAAQN,EAAYO,CAAC;CAC3B,OAAOH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AAOgD,CAAU;KAAG,KAAKf,EAAM;IAAI;GACxD;GACA,IAAMqB,IAAUtB,EAAiBqB,GAAOrE,CAAM;GAE9C,OADKsE,IACE;IAAE,MAAM;IAAQ,MAAM;KAAE,GAAGF;KAAM;KAAW,UAAU,CAAC;KAAG;IAAQ;GAAE,IADtDpD;EAEvB;EACA,KAAK,UAAU;GACb,IAAI+C,KAASC,MAAe,KAAA,GAAW,OAAOhD;GAC9C,IAAM9B,IAAQF,EAAegB,EAAO,KAAK;GAGzC,OAFIkE,MAAc,KAAA,KAAa,OAAOA,CAAS,MAAMhF,GAAO,SACxD+E,MAAiB,KAAA,KAAa,OAAOA,CAAY,MAAM/E,GAAO,MAAY8B,IACvE;IAAE,MAAM;IAAQ,MAAM;KAAE,GAAGoD;KAAM;KAAW,UAAU,CAAC;KAAG,SAAS;IAAK;GAAE;EACnF;CACF;AACF"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { CreateEventInput, ModifyRecurringInstanceInput, UpdateEventInput, UpdateScope } from '../../generated/wspace-types';
|
|
2
|
+
import { CalendarEventV2 } from '../types';
|
|
3
|
+
import { EventForm, GuestDraft, ReminderDraft } from './eventForm';
|
|
4
|
+
/**
|
|
5
|
+
* The footer's question when a date of a repeating event is edited (A4): that date on its own,
|
|
6
|
+
* that date and the later ones, or every event in the series.
|
|
7
|
+
*/
|
|
8
|
+
export type ScopeChoice = 'this' | 'later' | 'all';
|
|
9
|
+
export interface RoomBookingPlan {
|
|
10
|
+
resourceId: string;
|
|
11
|
+
start: Date;
|
|
12
|
+
end: Date;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Dates to cancel on a series (`cancelRecurringInstance`, A4), as instants of the series as it
|
|
16
|
+
* stands. The service adds each to the series' list on its own, so they go one after another.
|
|
17
|
+
*/
|
|
18
|
+
export interface SeriesCancels {
|
|
19
|
+
seriesId: string;
|
|
20
|
+
dates: Date[];
|
|
21
|
+
}
|
|
22
|
+
/** An event's tags, given on their own (`updateEvent`), so one that fails is known. */
|
|
23
|
+
export interface TagsWrite {
|
|
24
|
+
eventId: string;
|
|
25
|
+
input: UpdateEventInput;
|
|
26
|
+
scope: UpdateScope | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* What a save that stopped part way left undone and the event read back can't show, so a plan
|
|
30
|
+
* made from it again wouldn't send it (A4): the booking a series held for a date made an event
|
|
31
|
+
* of its own (still holding the room), the tags of the series such an event comes without, and a
|
|
32
|
+
* series' dates still to cancel. The dialog keeps it, and the next save sends it with the rest.
|
|
33
|
+
*/
|
|
34
|
+
export interface SaveCarry {
|
|
35
|
+
releaseBookingIds: string[];
|
|
36
|
+
tags: TagsWrite | null;
|
|
37
|
+
cancels: SeriesCancels[];
|
|
38
|
+
}
|
|
39
|
+
/** Whether the carry holds anything still to send. */
|
|
40
|
+
export declare function carriesWork(carry: SaveCarry | null): boolean;
|
|
41
|
+
export interface SavePlan {
|
|
42
|
+
/** A new event: what `createEvent` takes. */
|
|
43
|
+
create: CreateEventInput | null;
|
|
44
|
+
/** An edit: the `updateEvent` calls, in order; none when the event itself didn't change. */
|
|
45
|
+
updates: {
|
|
46
|
+
input: UpdateEventInput;
|
|
47
|
+
scope: UpdateScope | null;
|
|
48
|
+
}[];
|
|
49
|
+
addGuests: GuestDraft[];
|
|
50
|
+
/** Guests the event has that the form doesn't (each with its `attendeeId`). */
|
|
51
|
+
removeGuests: GuestDraft[];
|
|
52
|
+
/** The booking to cancel first: the room changed, or the event's time did. */
|
|
53
|
+
cancelBookingId: string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Bookings a series held for the date made an event of its own (A4): let go before the room
|
|
56
|
+
* is booked for that event, else the room would be held twice for the same time.
|
|
57
|
+
*/
|
|
58
|
+
releaseBookingIds: string[];
|
|
59
|
+
bookRoom: RoomBookingPlan | null;
|
|
60
|
+
addReminders: ReminderDraft[];
|
|
61
|
+
/** Reminders the event has that the form doesn't (each with its `reminderId`). */
|
|
62
|
+
removeReminders: ReminderDraft[];
|
|
63
|
+
/**
|
|
64
|
+
* Series' dates to cancel (A4): a series' cancelled dates where they land after its times
|
|
65
|
+
* moved, or on the new series a split starts, which comes without them; and those a save
|
|
66
|
+
* before couldn't cancel.
|
|
67
|
+
*/
|
|
68
|
+
cancels: SeriesCancels[];
|
|
69
|
+
/** The tags of the series an event was made from, which it comes without (A4). */
|
|
70
|
+
tags: TagsWrite | null;
|
|
71
|
+
}
|
|
72
|
+
/** A new event's plan: always with what `createEvent` takes. */
|
|
73
|
+
export type NewEventPlan = SavePlan & {
|
|
74
|
+
create: CreateEventInput;
|
|
75
|
+
};
|
|
76
|
+
/** A new event's plan. The form must have a calendar (the dialog checks). */
|
|
77
|
+
export declare function planNewEvent(form: EventForm): NewEventPlan;
|
|
78
|
+
/** The event's times differ from the form's: a day for an all-day event, else the instants. */
|
|
79
|
+
export declare function timesChanged(form: EventForm, event: CalendarEventV2, calendarTimeZone: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* An edit's plan: what differs between the form and the event as the service last returned it.
|
|
82
|
+
* A series (on its first date) changes as a whole (`ALL_EVENTS`).
|
|
83
|
+
*/
|
|
84
|
+
export declare function planEdit(form: EventForm, event: CalendarEventV2, calendarTimeZone: string): SavePlan;
|
|
85
|
+
/** How a save goes: what is written first, and what the rest is planned on. */
|
|
86
|
+
export type SaveRoute =
|
|
87
|
+
/** A new event: `createEvent`, then its guests, reminders and room. */
|
|
88
|
+
{
|
|
89
|
+
kind: 'create';
|
|
90
|
+
plan: NewEventPlan;
|
|
91
|
+
}
|
|
92
|
+
/** An event changed in place: one that doesn't repeat, or a whole series on its first date. */
|
|
93
|
+
| {
|
|
94
|
+
kind: 'edit';
|
|
95
|
+
eventId: string;
|
|
96
|
+
plan: SavePlan;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* One date of a series changed on its own ("This event"): the service makes it an event of
|
|
100
|
+
* its own (`modifyRecurringInstance`), and the rest is planned on that (`planOnNewEvent`).
|
|
101
|
+
*/
|
|
102
|
+
| {
|
|
103
|
+
kind: 'thisDate';
|
|
104
|
+
input: ModifyRecurringInstanceInput;
|
|
105
|
+
form: EventForm;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* That date and the later ones ("This and later"): the series is split at the date's original
|
|
109
|
+
* start (`updateEvent` with THIS_AND_FUTURE ends the series before it and starts a new one
|
|
110
|
+
* there), and the rest is planned on the new series (`planOnNewEvent`). Splitting at the date
|
|
111
|
+
* itself, not at its new time, keeps the date from staying behind in the old series.
|
|
112
|
+
*/
|
|
113
|
+
| {
|
|
114
|
+
kind: 'split';
|
|
115
|
+
seriesId: string;
|
|
116
|
+
input: UpdateEventInput;
|
|
117
|
+
form: EventForm;
|
|
118
|
+
};
|
|
119
|
+
export interface SaveFacts {
|
|
120
|
+
form: EventForm;
|
|
121
|
+
/** The form as the dialog opened: for a series' date, at that date. */
|
|
122
|
+
initial: EventForm;
|
|
123
|
+
/** The event as the dialog shows it (a series' date at that date); null for a new one. */
|
|
124
|
+
event: CalendarEventV2 | null;
|
|
125
|
+
/** The stored event behind it: for a series' date, the series at its first date. */
|
|
126
|
+
row: CalendarEventV2 | null;
|
|
127
|
+
scope: ScopeChoice;
|
|
128
|
+
/** What a save before left undone (`SaveCarry`); null when nothing. */
|
|
129
|
+
carry: SaveCarry | null;
|
|
130
|
+
}
|
|
131
|
+
/** A rule that ends after a number of times (the service's split would start the count again). */
|
|
132
|
+
export declare function endsAfterCount(rrule: string | null): boolean;
|
|
133
|
+
/** Whether a series' date is its first one (where "this and later" is every event). */
|
|
134
|
+
export declare function isFirstDate(event: CalendarEventV2, row: CalendarEventV2): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Whether "This and later" can be offered for a series' date: always on its first date (where
|
|
137
|
+
* it is every event); elsewhere not for a rule that ends after a number of times, which the
|
|
138
|
+
* service's split would count again from the date, making the series longer.
|
|
139
|
+
*/
|
|
140
|
+
export declare function canChangeLater(event: CalendarEventV2, row: CalendarEventV2): boolean;
|
|
141
|
+
/** How saving the dialog goes, by what is edited and the footer's answer. */
|
|
142
|
+
export declare function saveRouteFor(facts: SaveFacts, calendarTimeZone: string): SaveRoute;
|
|
143
|
+
/**
|
|
144
|
+
* The rest of a save, on the event the service just made from a series (`made`: a date changed
|
|
145
|
+
* on its own, or the later part of a split): what the form holds that it doesn't yet.
|
|
146
|
+
*
|
|
147
|
+
* - Its guests, reminders and room are added to it (the form is `detachedForm`).
|
|
148
|
+
* - A room the series had booked for that date (`date`, the date as the dialog showed it) is let
|
|
149
|
+
* go before the made event books it again, so the room isn't held twice (the made event's own
|
|
150
|
+
* booking would clash with the series' for the same time).
|
|
151
|
+
* - Its repeat is sent only when the person changed it: a split series keeps the service's rule,
|
|
152
|
+
* with its new start.
|
|
153
|
+
* - A date made its own event gets the series' tags back (`modifyRecurringInstance` leaves them
|
|
154
|
+
* behind), in a write of their own.
|
|
155
|
+
* - A split series gets the old one's cancelled dates from the split on (`cancels`), with those
|
|
156
|
+
* a save before couldn't cancel there (`carry`); the old series keeps the ones before it.
|
|
157
|
+
*/
|
|
158
|
+
export declare function planOnNewEvent(form: EventForm, initial: EventForm, made: CalendarEventV2, date: CalendarEventV2, row: CalendarEventV2, calendarTimeZone: string, carry?: SaveCarry | null): SavePlan;
|
|
159
|
+
/** Nothing to send. */
|
|
160
|
+
export declare function isEmptyPlan(plan: SavePlan): boolean;
|