@burdenoff/microfe-calendar 2026.1124.2 → 2026.1124.3
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 +469 -0
- package/dist/generated/wspace-operations.js +121 -9
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/pages/ResourcesPage.js.map +1 -1
- package/dist/translations/en.d.ts +231 -0
- package/dist/v2/CalendarPageV2.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/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 +25 -0
- package/dist/v2/event/EventDialog.js +365 -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 +111 -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 +214 -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 +88 -0
- package/dist/v2/event/RepeatField.js.map +1 -0
- package/dist/v2/event/dialogLogic.d.ts +87 -0
- package/dist/v2/event/dialogLogic.js +117 -0
- package/dist/v2/event/dialogLogic.js.map +1 -0
- package/dist/v2/event/dialogModel.d.ts +48 -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 +209 -0
- package/dist/v2/event/eventForm.js +397 -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 +50 -0
- package/dist/v2/event/savePlan.js +125 -0
- package/dist/v2/event/savePlan.js.map +1 -0
- package/dist/v2/event/useEventData.d.ts +91 -0
- package/dist/v2/event/useEventData.js +202 -0
- package/dist/v2/event/useEventData.js.map +1 -0
- package/dist/v2/event/useEventDialogModel.d.ts +37 -0
- package/dist/v2/event/useEventDialogModel.js +129 -0
- package/dist/v2/event/useEventDialogModel.js.map +1 -0
- package/dist/v2/event/useEventSave.d.ts +41 -0
- package/dist/v2/event/useEventSave.js +185 -0
- package/dist/v2/event/useEventSave.js.map +1 -0
- 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/peek/EventPeek.js.map +1 -1
- package/dist/v2/peek/PeekEvent.js.map +1 -1
- package/dist/v2/rail/CalendarRail.js.map +1 -1
- package/dist/v2/runs/RunPeek.js.map +1 -1
- package/dist/v2/states/CalendarStates.js.map +1 -1
- package/dist/v2/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export declare function Field({ label, labelFor, labelId, required, hint, hintId, error, errorId, children, className, }: {
|
|
3
|
+
label: ReactNode;
|
|
4
|
+
/** The control's id, for a `<label>`; without it the label is a plain heading (`labelId`). */
|
|
5
|
+
labelFor?: string;
|
|
6
|
+
labelId?: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
hint?: ReactNode;
|
|
9
|
+
hintId?: string;
|
|
10
|
+
error?: ReactNode;
|
|
11
|
+
errorId?: string;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
}): import('react').JSX.Element;
|
|
15
|
+
/** A small note under a control that isn't available yet, or a plain hint with an icon. */
|
|
16
|
+
export declare function SoonNote({ id, children }: {
|
|
17
|
+
id?: string;
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}): import('react').JSX.Element;
|
|
20
|
+
export interface RadioCardOption<V extends string> {
|
|
21
|
+
value: V;
|
|
22
|
+
title: ReactNode;
|
|
23
|
+
description?: ReactNode;
|
|
24
|
+
icon?: ReactNode;
|
|
25
|
+
/** Below the text: pills, a status. */
|
|
26
|
+
extra?: ReactNode;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Cards that pick one value: role="radio" buttons in a radiogroup. Tab reaches the checked one;
|
|
31
|
+
* the arrow keys move and pick, as a radio group does.
|
|
32
|
+
*/
|
|
33
|
+
export declare function RadioCards<V extends string>({ options, value, onValueChange, label, labelledBy, disabled, className, cardClassName, }: {
|
|
34
|
+
options: readonly RadioCardOption<V>[];
|
|
35
|
+
value: V | null;
|
|
36
|
+
onValueChange: (value: V) => void;
|
|
37
|
+
label?: string;
|
|
38
|
+
labelledBy?: string;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
className?: string;
|
|
41
|
+
cardClassName?: string;
|
|
42
|
+
}): import('react').JSX.Element;
|
|
43
|
+
/** A small rounded word ("Screen", "Whiteboard"). */
|
|
44
|
+
export declare function Pill({ children }: {
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}): import('react').JSX.Element;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { FOCUS_RING as e } from "../styles.js";
|
|
2
|
+
import { useRef as t } from "react";
|
|
3
|
+
import { Check as n, Info as r } from "lucide-react";
|
|
4
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
|
+
import { cn as o } from "@burdenoff/fe-libs/utils";
|
|
6
|
+
// src/v2/event/parts.tsx
|
|
7
|
+
function s({ label: e, labelFor: t, labelId: n, required: r, hint: s, hintId: c, error: l, errorId: u, children: d, className: f }) {
|
|
8
|
+
let p = "text-sm font-semibold text-text-primary";
|
|
9
|
+
return /* @__PURE__ */ a("div", {
|
|
10
|
+
className: o("flex min-w-0 flex-col gap-1.5", f),
|
|
11
|
+
children: [
|
|
12
|
+
t ? /* @__PURE__ */ a("label", {
|
|
13
|
+
htmlFor: t,
|
|
14
|
+
id: n,
|
|
15
|
+
className: p,
|
|
16
|
+
children: [e, r ? /* @__PURE__ */ i("span", {
|
|
17
|
+
"aria-hidden": "true",
|
|
18
|
+
className: "ms-1 text-status-error-text",
|
|
19
|
+
children: "*"
|
|
20
|
+
}) : null]
|
|
21
|
+
}) : /* @__PURE__ */ i("span", {
|
|
22
|
+
id: n,
|
|
23
|
+
className: p,
|
|
24
|
+
children: e
|
|
25
|
+
}),
|
|
26
|
+
d,
|
|
27
|
+
l ? /* @__PURE__ */ i("p", {
|
|
28
|
+
id: u,
|
|
29
|
+
className: "text-xs font-medium text-status-error-text",
|
|
30
|
+
children: l
|
|
31
|
+
}) : s ? /* @__PURE__ */ i("div", {
|
|
32
|
+
id: c,
|
|
33
|
+
className: "text-xs text-text-secondary",
|
|
34
|
+
children: s
|
|
35
|
+
}) : null
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function c({ id: e, children: t }) {
|
|
40
|
+
return /* @__PURE__ */ a("p", {
|
|
41
|
+
id: e,
|
|
42
|
+
className: "flex items-start gap-1.5 text-xs text-text-secondary",
|
|
43
|
+
children: [/* @__PURE__ */ i(r, {
|
|
44
|
+
className: "mt-px size-3.5 shrink-0 text-text-muted",
|
|
45
|
+
"aria-hidden": "true"
|
|
46
|
+
}), /* @__PURE__ */ i("span", { children: t })]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function l({ options: r, value: s, onValueChange: c, label: l, labelledBy: u, disabled: d, className: f, cardClassName: p }) {
|
|
50
|
+
let m = t([]), h = r.filter((e) => !e.disabled && !d), g = s !== null && h.some((e) => e.value === s) ? s : h[0]?.value ?? null, _ = (e, t) => {
|
|
51
|
+
let n = e.key === "ArrowDown" || e.key === "ArrowRight" ? 1 : e.key === "ArrowUp" || e.key === "ArrowLeft" ? -1 : 0;
|
|
52
|
+
if (n === 0) return;
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
let i = getComputedStyle(e.currentTarget).direction === "rtl" && (e.key === "ArrowLeft" || e.key === "ArrowRight") ? -n : n;
|
|
55
|
+
for (let e = 1; e <= r.length; e += 1) {
|
|
56
|
+
let n = (t + i * e + r.length) % r.length, a = r[n];
|
|
57
|
+
if (a && !a.disabled) {
|
|
58
|
+
m.current[n]?.focus(), c(a.value);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return /* @__PURE__ */ i("div", {
|
|
64
|
+
role: "radiogroup",
|
|
65
|
+
"aria-label": l,
|
|
66
|
+
"aria-labelledby": u,
|
|
67
|
+
"aria-disabled": d || void 0,
|
|
68
|
+
className: o("grid gap-2", f),
|
|
69
|
+
children: r.map((t, r) => {
|
|
70
|
+
let l = t.value === s, u = d || t.disabled;
|
|
71
|
+
return /* @__PURE__ */ a("button", {
|
|
72
|
+
ref: (e) => {
|
|
73
|
+
m.current[r] = e;
|
|
74
|
+
},
|
|
75
|
+
type: "button",
|
|
76
|
+
role: "radio",
|
|
77
|
+
"aria-checked": l,
|
|
78
|
+
"aria-disabled": u || void 0,
|
|
79
|
+
tabIndex: t.value === g ? 0 : -1,
|
|
80
|
+
onClick: () => {
|
|
81
|
+
u || c(t.value);
|
|
82
|
+
},
|
|
83
|
+
onKeyDown: (e) => _(e, r),
|
|
84
|
+
className: o("relative flex min-w-0 flex-col gap-1 rounded-card border p-3 text-start motion-safe:transition-colors", l ? "border-action-primary-bg bg-accent-soft shadow-[inset_0_0_0_1px_var(--color-action-primary-bg)]" : "border-border-default bg-bg-surface hover:border-border-strong", u && "cursor-not-allowed opacity-60 hover:border-border-default", e, p),
|
|
85
|
+
children: [/* @__PURE__ */ a("span", {
|
|
86
|
+
className: "flex min-w-0 items-start gap-2.5",
|
|
87
|
+
children: [
|
|
88
|
+
t.icon ? /* @__PURE__ */ i("span", {
|
|
89
|
+
"aria-hidden": "true",
|
|
90
|
+
className: "mt-0.5 shrink-0 text-text-secondary [&_svg]:size-4",
|
|
91
|
+
children: t.icon
|
|
92
|
+
}) : null,
|
|
93
|
+
/* @__PURE__ */ a("span", {
|
|
94
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
95
|
+
children: [/* @__PURE__ */ i("span", {
|
|
96
|
+
className: "text-sm font-semibold break-words text-text-primary",
|
|
97
|
+
children: t.title
|
|
98
|
+
}), t.description ? /* @__PURE__ */ i("span", {
|
|
99
|
+
className: "text-xs break-words text-text-secondary",
|
|
100
|
+
children: t.description
|
|
101
|
+
}) : null]
|
|
102
|
+
}),
|
|
103
|
+
/* @__PURE__ */ i(n, {
|
|
104
|
+
"aria-hidden": "true",
|
|
105
|
+
className: o("size-4 shrink-0 text-action-primary-bg", l ? "visible" : "invisible")
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
}), t.extra ? /* @__PURE__ */ i("span", {
|
|
109
|
+
className: "flex min-w-0 flex-col gap-1.5",
|
|
110
|
+
children: t.extra
|
|
111
|
+
}) : null]
|
|
112
|
+
}, t.value);
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function u({ children: e }) {
|
|
117
|
+
return /* @__PURE__ */ i("span", {
|
|
118
|
+
className: "inline-flex items-center rounded-full border border-border-subtle bg-bg-sunken px-2 py-0.5 text-xs text-text-secondary",
|
|
119
|
+
children: e
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
export { s as Field, u as Pill, l as RadioCards, c as SoonNote };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.js","names":["Field","labelClass","cn","className","labelFor","labelId","label","required","children","error","errorId","hint","hintId","SoonNote","Info","RadioCards","refs","useRef","enabled","options","option","disabled","focusable","value","onKeyDown","step","event","direction","offset","next","index","onValueChange","labelledBy","checked","off","element","FOCUS_RING","cardClassName","Check","Pill"],"sources":["../../../src/v2/event/parts.tsx"],"sourcesContent":["/**\n * Small pieces the event dialog and Find a time share (BOFF-15698 A2): a labelled field, radio\n * cards (role=\"radio\", arrow keys move between them), and the note under a control that isn't\n * available yet.\n */\nimport { useRef, type KeyboardEvent, type ReactNode } from 'react';\nimport { Check, Info } from 'lucide-react';\nimport { cn } from '@burdenoff/fe-libs/utils';\nimport { FOCUS_RING } from '../styles';\n\nexport function Field({\n label,\n labelFor,\n labelId,\n required,\n hint,\n hintId,\n error,\n errorId,\n children,\n className,\n}: {\n label: ReactNode;\n /** The control's id, for a `<label>`; without it the label is a plain heading (`labelId`). */\n labelFor?: string;\n labelId?: string;\n required?: boolean;\n hint?: ReactNode;\n hintId?: string;\n error?: ReactNode;\n errorId?: string;\n children: ReactNode;\n className?: string;\n}) {\n const labelClass = 'text-sm font-semibold text-text-primary';\n return (\n <div className={cn('flex min-w-0 flex-col gap-1.5', className)}>\n {labelFor ? (\n <label htmlFor={labelFor} id={labelId} className={labelClass}>\n {label}\n {required ? (\n <span aria-hidden=\"true\" className=\"ms-1 text-status-error-text\">\n *\n </span>\n ) : null}\n </label>\n ) : (\n <span id={labelId} className={labelClass}>\n {label}\n </span>\n )}\n {children}\n {error ? (\n <p id={errorId} className=\"text-xs font-medium text-status-error-text\">\n {error}\n </p>\n ) : hint ? (\n // A div: a hint may hold its own paragraph (`SoonNote`).\n <div id={hintId} className=\"text-xs text-text-secondary\">\n {hint}\n </div>\n ) : null}\n </div>\n );\n}\n\n/** A small note under a control that isn't available yet, or a plain hint with an icon. */\nexport function SoonNote({ id, children }: { id?: string; children: ReactNode }) {\n return (\n <p id={id} className=\"flex items-start gap-1.5 text-xs text-text-secondary\">\n <Info className=\"mt-px size-3.5 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n <span>{children}</span>\n </p>\n );\n}\n\nexport interface RadioCardOption<V extends string> {\n value: V;\n title: ReactNode;\n description?: ReactNode;\n icon?: ReactNode;\n /** Below the text: pills, a status. */\n extra?: ReactNode;\n disabled?: boolean;\n}\n\n/**\n * Cards that pick one value: role=\"radio\" buttons in a radiogroup. Tab reaches the checked one;\n * the arrow keys move and pick, as a radio group does.\n */\nexport function RadioCards<V extends string>({\n options,\n value,\n onValueChange,\n label,\n labelledBy,\n disabled,\n className,\n cardClassName,\n}: {\n options: readonly RadioCardOption<V>[];\n value: V | null;\n onValueChange: (value: V) => void;\n label?: string;\n labelledBy?: string;\n disabled?: boolean;\n className?: string;\n cardClassName?: string;\n}) {\n const refs = useRef<(HTMLButtonElement | null)[]>([]);\n const enabled = options.filter((option) => !option.disabled && !disabled);\n const focusable =\n value !== null && enabled.some((option) => option.value === value)\n ? value\n : (enabled[0]?.value ?? null);\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>, index: number) => {\n const step =\n event.key === 'ArrowDown' || event.key === 'ArrowRight'\n ? 1\n : event.key === 'ArrowUp' || event.key === 'ArrowLeft'\n ? -1\n : 0;\n if (step === 0) return;\n event.preventDefault();\n const rtl = getComputedStyle(event.currentTarget).direction === 'rtl';\n const direction =\n rtl && (event.key === 'ArrowLeft' || event.key === 'ArrowRight') ? -step : step;\n for (let offset = 1; offset <= options.length; offset += 1) {\n const next = (index + direction * offset + options.length) % options.length;\n const option = options[next];\n if (option && !option.disabled) {\n refs.current[next]?.focus();\n onValueChange(option.value);\n return;\n }\n }\n };\n return (\n <div\n role=\"radiogroup\"\n aria-label={label}\n aria-labelledby={labelledBy}\n aria-disabled={disabled || undefined}\n className={cn('grid gap-2', className)}\n >\n {options.map((option, index) => {\n const checked = option.value === value;\n const off = disabled || option.disabled;\n return (\n <button\n key={option.value}\n ref={(element) => {\n refs.current[index] = element;\n }}\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n aria-disabled={off || undefined}\n tabIndex={option.value === focusable ? 0 : -1}\n onClick={() => {\n if (!off) onValueChange(option.value);\n }}\n onKeyDown={(event) => onKeyDown(event, index)}\n className={cn(\n 'relative flex min-w-0 flex-col gap-1 rounded-card border p-3 text-start motion-safe:transition-colors',\n checked\n ? 'border-action-primary-bg bg-accent-soft shadow-[inset_0_0_0_1px_var(--color-action-primary-bg)]'\n : 'border-border-default bg-bg-surface hover:border-border-strong',\n off && 'cursor-not-allowed opacity-60 hover:border-border-default',\n FOCUS_RING,\n cardClassName\n )}\n >\n <span className=\"flex min-w-0 items-start gap-2.5\">\n {option.icon ? (\n <span\n aria-hidden=\"true\"\n className=\"mt-0.5 shrink-0 text-text-secondary [&_svg]:size-4\"\n >\n {option.icon}\n </span>\n ) : null}\n <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n <span className=\"text-sm font-semibold break-words text-text-primary\">\n {option.title}\n </span>\n {option.description ? (\n <span className=\"text-xs break-words text-text-secondary\">\n {option.description}\n </span>\n ) : null}\n </span>\n <Check\n aria-hidden=\"true\"\n className={cn(\n 'size-4 shrink-0 text-action-primary-bg',\n checked ? 'visible' : 'invisible'\n )}\n />\n </span>\n {option.extra ? (\n <span className=\"flex min-w-0 flex-col gap-1.5\">{option.extra}</span>\n ) : null}\n </button>\n );\n })}\n </div>\n );\n}\n\n/** A small rounded word (\"Screen\", \"Whiteboard\"). */\nexport function Pill({ children }: { children: ReactNode }) {\n return (\n <span className=\"inline-flex items-center rounded-full border border-border-subtle bg-bg-sunken px-2 py-0.5 text-xs text-text-secondary\">\n {children}\n </span>\n );\n}\n"],"mappings":";;;;;;AAUA,SAAgBA,EAAM,EACpB,UACA,aACA,YACA,aACA,SACA,WACA,UACA,YACA,aACA,gBAaC;CACD,IAAMC,IAAa;CACnB,OACE,kBAAC,OAAD;EAAK,WAAWC,EAAG,iCAAiCC,CAAS;EAA7D,UAAA;GACGC,IACC,kBAAC,SAAD;IAAO,SAASA;IAAU,IAAIC;IAAS,WAAWJ;IAAlD,UAAA,CACGK,GACAC,IACC,kBAAC,QAAD;KAAM,eAAY;KAAO,WAAU;KAA8B,UAAA;IAE3D,CAAA,IACJ,IACC;GAEP,CAAA,IAAA,kBAAC,QAAD;IAAM,IAAIF;IAAS,WAAWJ;IAC3B,UAAAK;GACG,CAAA;GAEPE;GACAC,IACC,kBAAC,KAAD;IAAG,IAAIC;IAAS,WAAU;IACvB,UAAAD;GACA,CAAA,IACDE,IAEF,kBAAC,OAAD;IAAK,IAAIC;IAAQ,WAAU;IACxB,UAAAD;GACE,CAAA,IACH;EACD;;AAET;AAGA,SAAgBE,EAAS,EAAE,OAAI,eAAkD;CAC/E,OACE,kBAAC,KAAD;EAAO;EAAI,WAAU;EAArB,UAAA,CACE,kBAACC,GAAD;GAA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B,EAAK,QAAQU,KAASK;IACxB;IACA,MAAK;IACL,MAAK;IACL,gBAAcF;IACd,iBAAeC,KAAO,KAAA;IACtB,UAAUd,EAAO,UAAUE,IAAY,IAAI;IAC3C,eAAe;KACb,AAAKY,KAAKH,EAAcX,EAAO,KAAK;IACtC;IACA,YAAY,MAAUI,EAAUE,GAAOI,CAAK;IAC5C,WAAW5B,EACT,yGACA+B,IACI,oGACA,kEACJC,KAAO,6DACPE,GACAC,CACF;IAtBF,UAAA,CAwBE,kBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA;MACGjB,EAAO,OACN,kBAAC,QAAD;OACE,eAAY;OACZ,WAAU;OAET,UAAAA,EAAO;MACJ,CAAA,IACJ;MACJ,kBAAC,QAAD;OAAM,WAAU;OAAhB,UAAA,CACE,kBAAC,QAAD;QAAM,WAAU;QACb,UAAAA,EAAO;OACJ,CAAA,GACLA,EAAO,cACN,kBAAC,QAAD;QAAM,WAAU;QACb,UAAAA,EAAO;OACJ,CAAA,IACJ,IACA;;MACN,kBAACkB,GAAD;OACE,eAAY;OACZ,WAAWpC,EACT,0CACA+B,IAAU,YAAY,WACxB;MACD,CAAA;KACG;IACL,CAAA,GAAAb,EAAO,QACN,kBAAC,QAAD;KAAM,WAAU;KAAiC,UAAAA,EAAO;IAAY,CAAA,IAClE,IACE;GArDD,GAAAA,EAAO,KAqDN;EAEZ,CAAC;CACE,CAAA;AAET;AAGA,SAAgBmB,EAAK,EAAE,eAAqC;CAC1D,OACE,kBAAC,QAAD;EAAM,WAAU;EACb;CACG,CAAA;AAEV"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** The services the dialog names from a link: Meet, Zoom, Teams, otherwise "Link". */
|
|
2
|
+
export type VideoService = 'GOOGLE_MEET' | 'ZOOM' | 'MICROSOFT_TEAMS' | 'CUSTOM';
|
|
3
|
+
/** The service a meeting link belongs to, from its address. */
|
|
4
|
+
export declare function videoServiceOf(url: string): VideoService;
|
|
5
|
+
export interface RoomBookingForEvent {
|
|
6
|
+
id: string;
|
|
7
|
+
/** The event the booking is for. */
|
|
8
|
+
eventId: string;
|
|
9
|
+
start: Date;
|
|
10
|
+
end: Date;
|
|
11
|
+
/** Waiting for approval (it still holds the room). */
|
|
12
|
+
pending: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** A room as the Place tab and Find a time show it. */
|
|
15
|
+
export interface RoomForEvent {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
/** "Floor 2 · North wing". */
|
|
19
|
+
place: string | null;
|
|
20
|
+
capacity: number | null;
|
|
21
|
+
/** Open for bookings (a paused room is closed). */
|
|
22
|
+
bookable: boolean;
|
|
23
|
+
needsApproval: boolean;
|
|
24
|
+
/** "Screen", "Whiteboard": what the room has. */
|
|
25
|
+
features: string[];
|
|
26
|
+
/** Minutes kept free before and after each booking. */
|
|
27
|
+
bufferBefore: number;
|
|
28
|
+
bufferAfter: number;
|
|
29
|
+
/** Approved and waiting bookings that haven't ended, by start. */
|
|
30
|
+
bookings: RoomBookingForEvent[];
|
|
31
|
+
/** Bookings starting from here on may be missing; null when every one is known. */
|
|
32
|
+
knownUntil: Date | null;
|
|
33
|
+
}
|
|
34
|
+
export type RoomState = {
|
|
35
|
+
kind: 'free';
|
|
36
|
+
}
|
|
37
|
+
/** Another booking holds the room then (its buffers included). */
|
|
38
|
+
| {
|
|
39
|
+
kind: 'booked';
|
|
40
|
+
booking: RoomBookingForEvent;
|
|
41
|
+
}
|
|
42
|
+
/** Paused: it takes no bookings. */
|
|
43
|
+
| {
|
|
44
|
+
kind: 'closed';
|
|
45
|
+
}
|
|
46
|
+
/** Its bookings that late aren't loaded yet. */
|
|
47
|
+
| {
|
|
48
|
+
kind: 'unknown';
|
|
49
|
+
};
|
|
50
|
+
/** The bookings a list answer holds are every one up to `knownUntil` (see the module note). */
|
|
51
|
+
export declare function knownUntilOf(bookings: readonly RoomBookingForEvent[], listLimit: number): Date | null;
|
|
52
|
+
/** The room's bookings are all known for a time ending at `end`. */
|
|
53
|
+
export declare function roomKnownFor(room: RoomForEvent, end: Date): boolean;
|
|
54
|
+
/** The booking that keeps the room from `start`–`end`, ignoring the event's own (`ownEventId`). */
|
|
55
|
+
export declare function clashingBooking(room: RoomForEvent, start: Date, end: Date, ownEventId: string | null): RoomBookingForEvent | null;
|
|
56
|
+
/** The room's state for an event from `start` to `end`. */
|
|
57
|
+
export declare function roomStateAt(room: RoomForEvent, start: Date, end: Date, ownEventId: string | null): RoomState;
|
|
58
|
+
/** The room fits `people` (a room with no capacity set fits anyone). */
|
|
59
|
+
export declare function roomFits(room: RoomForEvent, people: number): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* A room free then, other than `chosenId`, for a booked or closed choice: big enough for
|
|
62
|
+
* `people` when one is, the smallest that fits first, else the biggest free one.
|
|
63
|
+
*/
|
|
64
|
+
export declare function freeAlternative(rooms: readonly RoomForEvent[], chosenId: string | null, start: Date, end: Date, people: number, ownEventId: string | null): RoomForEvent | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/v2/event/place.ts
|
|
2
|
+
var e = 6e4;
|
|
3
|
+
function t(e) {
|
|
4
|
+
let t = e.trim();
|
|
5
|
+
if (!t) return null;
|
|
6
|
+
try {
|
|
7
|
+
return new URL(/^[a-z][a-z0-9+.-]*:/i.test(t) ? t : `https://${t}`).hostname.toLowerCase();
|
|
8
|
+
} catch {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function n(e, t) {
|
|
13
|
+
return e === t || e.endsWith(`.${t}`);
|
|
14
|
+
}
|
|
15
|
+
function r(e) {
|
|
16
|
+
let r = t(e);
|
|
17
|
+
return r ? n(r, "meet.google.com") ? "GOOGLE_MEET" : n(r, "zoom.us") || n(r, "zoomgov.com") ? "ZOOM" : n(r, "teams.microsoft.com") || n(r, "teams.live.com") ? "MICROSOFT_TEAMS" : "CUSTOM" : "CUSTOM";
|
|
18
|
+
}
|
|
19
|
+
function i(e, t) {
|
|
20
|
+
if (e.length < t) return null;
|
|
21
|
+
let n = e[e.length - 1];
|
|
22
|
+
return n ? n.start : null;
|
|
23
|
+
}
|
|
24
|
+
function a(t, n) {
|
|
25
|
+
return t.knownUntil === null || n.getTime() + t.bufferAfter * e <= t.knownUntil.getTime();
|
|
26
|
+
}
|
|
27
|
+
function o(t, n, r, i) {
|
|
28
|
+
let a = n.getTime() - t.bufferBefore * e, o = r.getTime() + t.bufferAfter * e;
|
|
29
|
+
return t.bookings.find((e) => e.eventId !== i && e.start.getTime() < o && e.end.getTime() > a) ?? null;
|
|
30
|
+
}
|
|
31
|
+
function s(e, t, n, r) {
|
|
32
|
+
if (!e.bookable) return { kind: "closed" };
|
|
33
|
+
let i = o(e, t, n, r);
|
|
34
|
+
return i ? {
|
|
35
|
+
kind: "booked",
|
|
36
|
+
booking: i
|
|
37
|
+
} : a(e, n) ? { kind: "free" } : { kind: "unknown" };
|
|
38
|
+
}
|
|
39
|
+
function c(e, t) {
|
|
40
|
+
return e.capacity === null || e.capacity >= t;
|
|
41
|
+
}
|
|
42
|
+
function l(e, t, n, r, i, a) {
|
|
43
|
+
let o = e.filter((e) => e.id !== t && s(e, n, r, a).kind === "free"), l = o.filter((e) => c(e, i)).sort((e, t) => (e.capacity ?? Infinity) - (t.capacity ?? Infinity) || e.name.localeCompare(t.name));
|
|
44
|
+
return l[0] ? l[0] : o.sort((e, t) => (t.capacity ?? 0) - (e.capacity ?? 0))[0] ?? null;
|
|
45
|
+
}
|
|
46
|
+
export { o as clashingBooking, l as freeAlternative, i as knownUntilOf, c as roomFits, a as roomKnownFor, s as roomStateAt, r as videoServiceOf };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=place.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"place.js","names":["MINUTE_MS","hostOf","value","url","onDomain","host","domain","videoServiceOf","knownUntilOf","bookings","listLimit","last","roomKnownFor","room","end","clashingBooking","from","start","to","booking","ownEventId","roomStateAt","roomFits","people","freeAlternative","free","rooms","chosenId","fitting","a","b"],"sources":["../../../src/v2/event/place.ts"],"sourcesContent":["/**\n * Where an event happens (BOFF-15698 A2): the video service a pasted link belongs to, and each\n * room's state at the event's time. Pure.\n *\n * Rooms come from `getCalendarResources`, which lists each room's next five approved or waiting\n * bookings. That is every booking up to the fifth one's start (any other starts later), so a\n * room's bookings are known up to there (`knownUntil`); past it the room's full list is read\n * (`getCalendarResource`) before its state is told. A booking blocks its room with the room's\n * buffers either side, as the service checks when it books.\n */\nconst MINUTE_MS = 60_000;\n\n/** The services the dialog names from a link: Meet, Zoom, Teams, otherwise \"Link\". */\nexport type VideoService = 'GOOGLE_MEET' | 'ZOOM' | 'MICROSOFT_TEAMS' | 'CUSTOM';\n\nfunction hostOf(url: string): string | null {\n const value = url.trim();\n if (!value) return null;\n try {\n return new URL(\n /^[a-z][a-z0-9+.-]*:/i.test(value) ? value : `https://${value}`\n ).hostname.toLowerCase();\n } catch {\n return null;\n }\n}\n\nfunction onDomain(host: string, domain: string): boolean {\n return host === domain || host.endsWith(`.${domain}`);\n}\n\n/** The service a meeting link belongs to, from its address. */\nexport function videoServiceOf(url: string): VideoService {\n const host = hostOf(url);\n if (!host) return 'CUSTOM';\n if (onDomain(host, 'meet.google.com')) return 'GOOGLE_MEET';\n if (onDomain(host, 'zoom.us') || onDomain(host, 'zoomgov.com')) return 'ZOOM';\n if (onDomain(host, 'teams.microsoft.com') || onDomain(host, 'teams.live.com')) {\n return 'MICROSOFT_TEAMS';\n }\n return 'CUSTOM';\n}\n\nexport interface RoomBookingForEvent {\n id: string;\n /** The event the booking is for. */\n eventId: string;\n start: Date;\n end: Date;\n /** Waiting for approval (it still holds the room). */\n pending: boolean;\n}\n\n/** A room as the Place tab and Find a time show it. */\nexport interface RoomForEvent {\n id: string;\n name: string;\n /** \"Floor 2 · North wing\". */\n place: string | null;\n capacity: number | null;\n /** Open for bookings (a paused room is closed). */\n bookable: boolean;\n needsApproval: boolean;\n /** \"Screen\", \"Whiteboard\": what the room has. */\n features: string[];\n /** Minutes kept free before and after each booking. */\n bufferBefore: number;\n bufferAfter: number;\n /** Approved and waiting bookings that haven't ended, by start. */\n bookings: RoomBookingForEvent[];\n /** Bookings starting from here on may be missing; null when every one is known. */\n knownUntil: Date | null;\n}\n\nexport type RoomState =\n | { kind: 'free' }\n /** Another booking holds the room then (its buffers included). */\n | { kind: 'booked'; booking: RoomBookingForEvent }\n /** Paused: it takes no bookings. */\n | { kind: 'closed' }\n /** Its bookings that late aren't loaded yet. */\n | { kind: 'unknown' };\n\n/** The bookings a list answer holds are every one up to `knownUntil` (see the module note). */\nexport function knownUntilOf(\n bookings: readonly RoomBookingForEvent[],\n listLimit: number\n): Date | null {\n if (bookings.length < listLimit) return null;\n const last = bookings[bookings.length - 1];\n return last ? last.start : null;\n}\n\n/** The room's bookings are all known for a time ending at `end`. */\nexport function roomKnownFor(room: RoomForEvent, end: Date): boolean {\n if (room.knownUntil === null) return true;\n // A booking starting before `end` plus the buffer after the event can still clash (as\n // `clashingBooking` checks), so the list must reach past that.\n return end.getTime() + room.bufferAfter * MINUTE_MS <= room.knownUntil.getTime();\n}\n\n/** The booking that keeps the room from `start`–`end`, ignoring the event's own (`ownEventId`). */\nexport function clashingBooking(\n room: RoomForEvent,\n start: Date,\n end: Date,\n ownEventId: string | null\n): RoomBookingForEvent | null {\n const from = start.getTime() - room.bufferBefore * MINUTE_MS;\n const to = end.getTime() + room.bufferAfter * MINUTE_MS;\n return (\n room.bookings.find(\n (booking) =>\n booking.eventId !== ownEventId &&\n booking.start.getTime() < to &&\n booking.end.getTime() > from\n ) ?? null\n );\n}\n\n/** The room's state for an event from `start` to `end`. */\nexport function roomStateAt(\n room: RoomForEvent,\n start: Date,\n end: Date,\n ownEventId: string | null\n): RoomState {\n if (!room.bookable) return { kind: 'closed' };\n const booking = clashingBooking(room, start, end, ownEventId);\n if (booking) return { kind: 'booked', booking };\n return roomKnownFor(room, end) ? { kind: 'free' } : { kind: 'unknown' };\n}\n\n/** The room fits `people` (a room with no capacity set fits anyone). */\nexport function roomFits(room: RoomForEvent, people: number): boolean {\n return room.capacity === null || room.capacity >= people;\n}\n\n/**\n * A room free then, other than `chosenId`, for a booked or closed choice: big enough for\n * `people` when one is, the smallest that fits first, else the biggest free one.\n */\nexport function freeAlternative(\n rooms: readonly RoomForEvent[],\n chosenId: string | null,\n start: Date,\n end: Date,\n people: number,\n ownEventId: string | null\n): RoomForEvent | null {\n const free = rooms.filter(\n (room) => room.id !== chosenId && roomStateAt(room, start, end, ownEventId).kind === 'free'\n );\n const fitting = free\n .filter((room) => roomFits(room, people))\n .sort(\n (a, b) => (a.capacity ?? Infinity) - (b.capacity ?? Infinity) || a.name.localeCompare(b.name)\n );\n if (fitting[0]) return fitting[0];\n return free.sort((a, b) => (b.capacity ?? 0) - (a.capacity ?? 0))[0] ?? null;\n}\n"],"mappings":";AAUA,IAAMA,IAAY;AAKlB,SAASC,EAAO,GAA4B;CAC1C,IAAMC,IAAQC,EAAI,KAAK;CACvB,IAAI,CAACD,GAAO,OAAO;CACnB,IAAI;EACF,OAAO,IAAI,IACT,uBAAuB,KAAKA,CAAK,IAAIA,IAAQ,WAAWA,GAC1D,CAAC,CAAC,SAAS,YAAY;CACzB,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAASE,EAAS,GAAc,GAAyB;CACvD,OAAOC,MAASC,KAAUD,EAAK,SAAS,IAAIC,GAAQ;AACtD;AAGA,SAAgBC,EAAe,GAA2B;CACxD,IAAMF,IAAOJ,EAAOE,CAAG;CAOvB,OANKE,IACDD,EAASC,GAAM,iBAAiB,IAAU,gBAC1CD,EAASC,GAAM,SAAS,KAAKD,EAASC,GAAM,aAAa,IAAU,SACnED,EAASC,GAAM,qBAAqB,KAAKD,EAASC,GAAM,gBAAgB,IACnE,oBAEF,WANW;AAOpB;AA2CA,SAAgBG,EACd,GACA,GACa;CACb,IAAIC,EAAS,SAASC,GAAW,OAAO;CACxC,IAAMC,IAAOF,EAASA,E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K,EAAE,YAAY,MAAMD,EAAE,YAAY,EAAE,CAAC,CAAC,MAAM;AAC1E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CalendarFormat } from '../format';
|
|
2
|
+
import { Tr } from '../data/useEventActions';
|
|
3
|
+
import { EventForm, RepeatState } from './eventForm';
|
|
4
|
+
import { RepeatPreset, RepeatRule, RuleAnchor, RuleProblem, Weekday } from './rrule';
|
|
5
|
+
/** A Monday to Sunday week, to name each weekday in the locale. */
|
|
6
|
+
export declare const WEEKDAY_DATES: Readonly<Record<Weekday, string>>;
|
|
7
|
+
export declare function weekdayName(day: Weekday, format: CalendarFormat): string;
|
|
8
|
+
export declare function ordinal(nth: number, tr: Tr): string;
|
|
9
|
+
/** A rule in words: "Every 2 weeks on Monday and Wednesday, 10 times". */
|
|
10
|
+
export declare function describeRule(rule: RepeatRule, anchor: RuleAnchor, tr: Tr, format: CalendarFormat): string;
|
|
11
|
+
export type MenuValue = 'none' | RepeatPreset | 'custom' | 'kept';
|
|
12
|
+
export declare function isMenuValue(value: string): value is MenuValue;
|
|
13
|
+
export declare function menuValueOf(repeat: RepeatState): MenuValue;
|
|
14
|
+
/** The repeat a menu choice makes; Custom starts from what the event repeats by now. */
|
|
15
|
+
export declare function repeatFor(value: MenuValue, form: EventForm): RepeatState;
|
|
16
|
+
/** What stops a custom rule from saving, in words. */
|
|
17
|
+
export declare function ruleProblemWords(problem: RuleProblem, tr: Tr): string;
|
|
18
|
+
/** What the Repeat menu's button says for the form's repeat. */
|
|
19
|
+
export declare function repeatLabel(form: EventForm, tr: Tr, format: CalendarFormat): string;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { formatDay as e } from "../format.js";
|
|
2
|
+
import { anchorOf as t, repeatRuleOf as n } from "./eventForm.js";
|
|
3
|
+
import { WORKWEEK as r, nthOfMonth as i, presetRule as a, weekdayCode as o } from "./rrule.js";
|
|
4
|
+
// src/v2/event/repeatWords.ts
|
|
5
|
+
var s = {
|
|
6
|
+
MO: "2026-11-16",
|
|
7
|
+
TU: "2026-11-17",
|
|
8
|
+
WE: "2026-11-18",
|
|
9
|
+
TH: "2026-11-19",
|
|
10
|
+
FR: "2026-11-20",
|
|
11
|
+
SA: "2026-11-21",
|
|
12
|
+
SU: "2026-11-22"
|
|
13
|
+
}, c = /* @__PURE__ */ new Map();
|
|
14
|
+
function l(e, t) {
|
|
15
|
+
let n = t ?? "", r = c.get(n);
|
|
16
|
+
if (!r) {
|
|
17
|
+
try {
|
|
18
|
+
r = new Intl.ListFormat(t, {
|
|
19
|
+
style: "long",
|
|
20
|
+
type: "conjunction"
|
|
21
|
+
});
|
|
22
|
+
} catch {
|
|
23
|
+
r = new Intl.ListFormat(void 0, {
|
|
24
|
+
style: "long",
|
|
25
|
+
type: "conjunction"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
c.set(n, r);
|
|
29
|
+
}
|
|
30
|
+
return r.format(e);
|
|
31
|
+
}
|
|
32
|
+
function u(t, n) {
|
|
33
|
+
return e(s[t], n, "weekdayLong");
|
|
34
|
+
}
|
|
35
|
+
function d(e, t) {
|
|
36
|
+
switch (e) {
|
|
37
|
+
case 1: return t("calendar.v2.rrFirst", "first");
|
|
38
|
+
case 2: return t("calendar.v2.rrSecond", "second");
|
|
39
|
+
case 3: return t("calendar.v2.rrThird", "third");
|
|
40
|
+
default: return t("calendar.v2.rrFourth", "fourth");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function f(e, t) {
|
|
44
|
+
let n = e.interval, r = n === 1;
|
|
45
|
+
switch (e.frequency) {
|
|
46
|
+
case "DAILY": return r ? t("calendar.v2.rrEveryDay", "Every day") : t("calendar.v2.rrEveryDays", "Every {{count}} days", { count: n });
|
|
47
|
+
case "WEEKLY": return r ? t("calendar.v2.rrEveryWeek", "Every week") : t("calendar.v2.rrEveryWeeks", "Every {{count}} weeks", { count: n });
|
|
48
|
+
case "MONTHLY": return r ? t("calendar.v2.rrEveryMonth", "Every month") : t("calendar.v2.rrEveryMonths", "Every {{count}} months", { count: n });
|
|
49
|
+
case "YEARLY": return r ? t("calendar.v2.rrEveryYear", "Every year") : t("calendar.v2.rrEveryYears", "Every {{count}} years", { count: n });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function p(t, n, a, s) {
|
|
53
|
+
let c = f(t, a), p = u(o(n.start), s), m = c;
|
|
54
|
+
if (t.frequency === "WEEKLY") {
|
|
55
|
+
let e = t.weekdays.length === r.length && r.every((e) => t.weekdays.includes(e));
|
|
56
|
+
if (e && t.interval === 1 && t.end.kind === "never") return a("calendar.v2.rrWeekdays", "Every weekday (Monday to Friday)");
|
|
57
|
+
m = e ? a("calendar.v2.rrOnWeekdays", "{{every}} on weekdays", { every: c }) : a("calendar.v2.rrOnDays", "{{every}} on {{days}}", {
|
|
58
|
+
every: c,
|
|
59
|
+
days: l(t.weekdays.map((e) => u(e, s)), s.locale)
|
|
60
|
+
});
|
|
61
|
+
} else t.frequency === "MONTHLY" ? m = t.monthly === "lastWeekday" ? a("calendar.v2.rrOnLast", "{{every}} on the last {{weekday}}", {
|
|
62
|
+
every: c,
|
|
63
|
+
weekday: p
|
|
64
|
+
}) : t.monthly === "nthWeekday" ? a("calendar.v2.rrOnNth", "{{every}} on the {{nth}} {{weekday}}", {
|
|
65
|
+
every: c,
|
|
66
|
+
nth: d(i(n.start), a),
|
|
67
|
+
weekday: p
|
|
68
|
+
}) : a("calendar.v2.rrOnMonthDay", "{{every}} on day {{day}}", {
|
|
69
|
+
every: c,
|
|
70
|
+
day: e(n.start, s, "dayNumber")
|
|
71
|
+
}) : t.frequency === "YEARLY" && (m = a("calendar.v2.rrOnDate", "{{every}} on {{date}}", {
|
|
72
|
+
every: c,
|
|
73
|
+
date: e(n.start, s, "dayMonth")
|
|
74
|
+
}));
|
|
75
|
+
return t.end.kind === "count" ? a("calendar.v2.rrTimes", "{{rule}}, {{count}} times", {
|
|
76
|
+
rule: m,
|
|
77
|
+
count: t.end.count
|
|
78
|
+
}) : t.end.kind === "until" ? a("calendar.v2.rrUntil", "{{rule}}, until {{date}}", {
|
|
79
|
+
rule: m,
|
|
80
|
+
date: e(t.end.date, s, "date")
|
|
81
|
+
}) : m;
|
|
82
|
+
}
|
|
83
|
+
var m = [
|
|
84
|
+
"none",
|
|
85
|
+
"daily",
|
|
86
|
+
"weekly",
|
|
87
|
+
"monthlyNth",
|
|
88
|
+
"monthlyLast",
|
|
89
|
+
"yearly",
|
|
90
|
+
"weekdays",
|
|
91
|
+
"custom",
|
|
92
|
+
"kept"
|
|
93
|
+
];
|
|
94
|
+
function h(e) {
|
|
95
|
+
return m.includes(e);
|
|
96
|
+
}
|
|
97
|
+
function g(e) {
|
|
98
|
+
switch (e.kind) {
|
|
99
|
+
case "none": return "none";
|
|
100
|
+
case "preset": return e.preset;
|
|
101
|
+
case "custom": return "custom";
|
|
102
|
+
case "kept": return "kept";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function _(e, r) {
|
|
106
|
+
let i = t(r);
|
|
107
|
+
return e === "none" ? { kind: "none" } : e === "kept" ? r.repeat : e === "custom" ? r.repeat.kind === "custom" ? r.repeat : {
|
|
108
|
+
kind: "custom",
|
|
109
|
+
rule: n(r) ?? a("weekly", i)
|
|
110
|
+
} : {
|
|
111
|
+
kind: "preset",
|
|
112
|
+
preset: e
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function v(e, t) {
|
|
116
|
+
switch (e) {
|
|
117
|
+
case "interval": return t("calendar.v2.rrBadInterval", "Repeat every 1 to {{max}}.", { max: 99 });
|
|
118
|
+
case "count": return t("calendar.v2.rrBadCount", "End after 1 to {{max}} times.", { max: 999 });
|
|
119
|
+
case "untilBeforeStart": return t("calendar.v2.rrBadUntil", "The last date can’t be before the first.");
|
|
120
|
+
case "noWeekdays": return t("calendar.v2.rrNoDays", "Pick at least one day.");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function y(e, r, i) {
|
|
124
|
+
if (e.repeat.kind === "kept") return r("calendar.v2.rrKept", "A rule from another app (kept)");
|
|
125
|
+
let a = n(e);
|
|
126
|
+
return a ? p(a, t(e), r, i) : r("calendar.v2.rrNone", "Doesn’t repeat");
|
|
127
|
+
}
|
|
128
|
+
export { s as WEEKDAY_DATES, p as describeRule, h as isMenuValue, g as menuValueOf, d as ordinal, _ as repeatFor, y as repeatLabel, v as ruleProblemWords, u as weekdayName };
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=repeatWords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repeatWords.js","names":["WEEKDAY_DATES","lists","listOf","key","locale","list","items","weekdayName","formatDay","day","format","ordinal","nth","tr","everyWords","count","rule","one","describeRule","every","weekday","weekdayCode","anchor","words","workweek","WORKWEEK","nthOfMonth","MENU_VALUES","isMenuValue","value","menuValueOf","repeat","repeatFor","anchorOf","form","repeatRuleOf","presetRule","ruleProblemWords","problem","repeatLabel"],"sources":["../../../src/v2/event/repeatWords.ts"],"sourcesContent":["/**\n * Repeat rules in words (BOFF-15698 A2), and the Repeat menu's choices. Pure.\n *\n * \"Every 2 weeks on Monday and Wednesday, 10 times\": day and weekday names come from `Intl` in\n * the calendar's locale; the rest are the translated templates.\n */\nimport { formatDay, type CalendarFormat } from '../format';\nimport type { Tr } from '../data/useEventActions';\nimport { anchorOf, repeatRuleOf, type EventForm, type RepeatState } from './eventForm';\nimport {\n MAX_COUNT,\n MAX_INTERVAL,\n nthOfMonth,\n presetRule,\n weekdayCode,\n WORKWEEK,\n type RepeatPreset,\n type RepeatRule,\n type RuleAnchor,\n type RuleProblem,\n type Weekday,\n} from './rrule';\n\n/** A Monday to Sunday week, to name each weekday in the locale. */\nexport const WEEKDAY_DATES: Readonly<Record<Weekday, string>> = {\n MO: '2026-11-16',\n TU: '2026-11-17',\n WE: '2026-11-18',\n TH: '2026-11-19',\n FR: '2026-11-20',\n SA: '2026-11-21',\n SU: '2026-11-22',\n};\n\nconst lists = new Map<string, Intl.ListFormat>();\n\n/** \"Monday, Wednesday and Friday\" in the locale. */\nfunction listOf(items: readonly string[], locale: string | undefined): string {\n const key = locale ?? '';\n let list = lists.get(key);\n if (!list) {\n try {\n list = new Intl.ListFormat(locale, { style: 'long', type: 'conjunction' });\n } catch {\n list = new Intl.ListFormat(undefined, { style: 'long', type: 'conjunction' });\n }\n lists.set(key, list);\n }\n return list.format(items);\n}\n\nexport function weekdayName(day: Weekday, format: CalendarFormat): string {\n return formatDay(WEEKDAY_DATES[day], format, 'weekdayLong');\n}\n\nexport function ordinal(nth: number, tr: Tr): string {\n switch (nth) {\n case 1:\n return tr('calendar.v2.rrFirst', 'first');\n case 2:\n return tr('calendar.v2.rrSecond', 'second');\n case 3:\n return tr('calendar.v2.rrThird', 'third');\n default:\n return tr('calendar.v2.rrFourth', 'fourth');\n }\n}\n\n/** \"Every 2 weeks\", \"Every month\". */\nfunction everyWords(rule: RepeatRule, tr: Tr): string {\n const count = rule.interval;\n const one = count === 1;\n switch (rule.frequency) {\n case 'DAILY':\n return one\n ? tr('calendar.v2.rrEveryDay', 'Every day')\n : tr('calendar.v2.rrEveryDays', 'Every {{count}} days', { count });\n case 'WEEKLY':\n return one\n ? tr('calendar.v2.rrEveryWeek', 'Every week')\n : tr('calendar.v2.rrEveryWeeks', 'Every {{count}} weeks', { count });\n case 'MONTHLY':\n return one\n ? tr('calendar.v2.rrEveryMonth', 'Every month')\n : tr('calendar.v2.rrEveryMonths', 'Every {{count}} months', { count });\n case 'YEARLY':\n return one\n ? tr('calendar.v2.rrEveryYear', 'Every year')\n : tr('calendar.v2.rrEveryYears', 'Every {{count}} years', { count });\n }\n}\n\n/** A rule in words: \"Every 2 weeks on Monday and Wednesday, 10 times\". */\nexport function describeRule(\n rule: RepeatRule,\n anchor: RuleAnchor,\n tr: Tr,\n format: CalendarFormat\n): string {\n const every = everyWords(rule, tr);\n const weekday = weekdayName(weekdayCode(anchor.start), format);\n let words = every;\n if (rule.frequency === 'WEEKLY') {\n const workweek =\n rule.weekdays.length === WORKWEEK.length &&\n WORKWEEK.every((day) => rule.weekdays.includes(day));\n if (workweek && rule.interval === 1 && rule.end.kind === 'never') {\n return tr('calendar.v2.rrWeekdays', 'Every weekday (Monday to Friday)');\n }\n words = workweek\n ? tr('calendar.v2.rrOnWeekdays', '{{every}} on weekdays', { every })\n : tr('calendar.v2.rrOnDays', '{{every}} on {{days}}', {\n every,\n days: listOf(\n rule.weekdays.map((day) => weekdayName(day, format)),\n format.locale\n ),\n });\n } else if (rule.frequency === 'MONTHLY') {\n words =\n rule.monthly === 'lastWeekday'\n ? tr('calendar.v2.rrOnLast', '{{every}} on the last {{weekday}}', { every, weekday })\n : rule.monthly === 'nthWeekday'\n ? tr('calendar.v2.rrOnNth', '{{every}} on the {{nth}} {{weekday}}', {\n every,\n nth: ordinal(nthOfMonth(anchor.start), tr),\n weekday,\n })\n : tr('calendar.v2.rrOnMonthDay', '{{every}} on day {{day}}', {\n every,\n day: formatDay(anchor.start, format, 'dayNumber'),\n });\n } else if (rule.frequency === 'YEARLY') {\n words = tr('calendar.v2.rrOnDate', '{{every}} on {{date}}', {\n every,\n date: formatDay(anchor.start, format, 'dayMonth'),\n });\n }\n if (rule.end.kind === 'count') {\n return tr('calendar.v2.rrTimes', '{{rule}}, {{count}} times', {\n rule: words,\n count: rule.end.count,\n });\n }\n if (rule.end.kind === 'until') {\n return tr('calendar.v2.rrUntil', '{{rule}}, until {{date}}', {\n rule: words,\n date: formatDay(rule.end.date, format, 'date'),\n });\n }\n return words;\n}\n\nexport type MenuValue = 'none' | RepeatPreset | 'custom' | 'kept';\n\nconst MENU_VALUES: readonly string[] = [\n 'none',\n 'daily',\n 'weekly',\n 'monthlyNth',\n 'monthlyLast',\n 'yearly',\n 'weekdays',\n 'custom',\n 'kept',\n];\n\nexport function isMenuValue(value: string): value is MenuValue {\n return MENU_VALUES.includes(value);\n}\n\nexport function menuValueOf(repeat: RepeatState): MenuValue {\n switch (repeat.kind) {\n case 'none':\n return 'none';\n case 'preset':\n return repeat.preset;\n case 'custom':\n return 'custom';\n case 'kept':\n return 'kept';\n }\n}\n\n/** The repeat a menu choice makes; Custom starts from what the event repeats by now. */\nexport function repeatFor(value: MenuValue, form: EventForm): RepeatState {\n const anchor = anchorOf(form);\n if (value === 'none') return { kind: 'none' };\n if (value === 'kept') return form.repeat;\n if (value === 'custom') {\n if (form.repeat.kind === 'custom') return form.repeat;\n return { kind: 'custom', rule: repeatRuleOf(form) ?? presetRule('weekly', anchor) };\n }\n return { kind: 'preset', preset: value };\n}\n\n/** What stops a custom rule from saving, in words. */\nexport function ruleProblemWords(problem: RuleProblem, tr: Tr): string {\n switch (problem) {\n case 'interval':\n return tr('calendar.v2.rrBadInterval', 'Repeat every 1 to {{max}}.', { max: MAX_INTERVAL });\n case 'count':\n return tr('calendar.v2.rrBadCount', 'End after 1 to {{max}} times.', { max: MAX_COUNT });\n case 'untilBeforeStart':\n return tr('calendar.v2.rrBadUntil', 'The last date can’t be before the first.');\n case 'noWeekdays':\n return tr('calendar.v2.rrNoDays', 'Pick at least one day.');\n }\n}\n\n/** What the Repeat menu's button says for the form's repeat. */\nexport function repeatLabel(form: EventForm, tr: Tr, format: CalendarFormat): string {\n if (form.repeat.kind === 'kept')\n return tr('calendar.v2.rrKept', 'A rule from another app (kept)');\n const rule = repeatRuleOf(form);\n return rule\n ? describeRule(rule, anchorOf(form), tr, format)\n : tr('calendar.v2.rrNone', 'Doesn’t repeat');\n}\n"],"mappings":";;;;AAwBA,IAAaA,IAAmD;CAC9D,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN,GAEMC,oBAAQ,IAAI,IAA6B;AAG/C,SAASC,EAAO,GAA0B,GAAoC;CAC5E,IAAMC,IAAMC,KAAU,IAClBC,IAAOJ,EAAM,IAAIE,CAAG;CACxB,IAAI,CAACE,GAAM;EACT,IAAI;GACF,IAAO,IAAI,KAAK,WAAWD,GAAQ;IAAE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;AACnC;AAEA,SAAgBC,EAAY,GAAgC;CAC1D,QAAQC,EAAO,MAAf;EACE,KAAK,QACH,OAAO;EACT,KAAK,UACH,OAAOA,EAAO;EAChB,KAAK,UACH,OAAO;EACT,KAAK,QACH,OAAO;CACX;AACF;AAGA,SAAgBC,EAAU,GAAkB,GAA8B;CACxE,IAAMV,IAASW,EAASC,CAAI;CAO5B,OANIL,MAAU,SAAe,EAAE,MAAM,OAAO,IACxCA,MAAU,SAAeK,EAAK,SAC9BL,MAAU,WACRK,EAAK,OAAO,SAAS,WAAiBA,EAAK,SACxC;EAAE,MAAM;EAAU,MAAMC,EAAaD,CAAI,KAAKE,EAAW,UAAUd,CAAM;CAAE,IAE7E;EAAE,MAAM;EAAU,QAAQO;CAAM;AACzC;AAGA,SAAgBQ,EAAiB,GAAsB,GAAgB;CACrE,QAAQC,GAAR;EACE,KAAK,YACH,OAAOzB,EAAG,6BAA6B,8BAA8B,EAAE,KAAA,GAAkB,CAAC;EAC5F,KAAK,SACH,OAAOA,EAAG,0BAA0B,iCAAiC,EAAE,KAAA,IAAe,CAAC;EACzF,KAAK,oBACH,OAAOA,EAAG,0BAA0B,0CAA0C;EAChF,KAAK,cACH,OAAOA,EAAG,wBAAwB,wBAAwB;CAC9D;AACF;AAGA,SAAgB0B,EAAY,GAAiB,GAAQ,GAAgC;CACnF,IAAIL,EAAK,OAAO,SAAS,QACvB,OAAOrB,EAAG,sBAAsB,gCAAgC;CAClE,IAAMG,IAAOmB,EAAaD,CAAI;CAC9B,OAAOlB,IACHE,EAAaF,GAAMiB,EAASC,CAAI,GAAGrB,GAAIH,CAAM,IAC7CG,EAAG,sBAAsB,gBAAgB;AAC/C"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { DateValue } from '@burdenoff/fe-libs/ui';
|
|
2
|
+
export type Weekday = 'SU' | 'MO' | 'TU' | 'WE' | 'TH' | 'FR' | 'SA';
|
|
3
|
+
/** By JavaScript's day number: 0 Sunday to 6 Saturday. */
|
|
4
|
+
export declare const WEEKDAYS: readonly Weekday[];
|
|
5
|
+
/** Monday to Friday. */
|
|
6
|
+
export declare const WORKWEEK: readonly Weekday[];
|
|
7
|
+
export type RepeatFrequency = 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
|
|
8
|
+
/** A monthly rule: on the start's day of the month, its nth weekday, or its last weekday. */
|
|
9
|
+
export type MonthlyPattern = 'monthDay' | 'nthWeekday' | 'lastWeekday';
|
|
10
|
+
export type RepeatEnd = {
|
|
11
|
+
kind: 'never';
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'count';
|
|
14
|
+
count: number;
|
|
15
|
+
}
|
|
16
|
+
/** The last day an occurrence may start on, on the event's clock. */
|
|
17
|
+
| {
|
|
18
|
+
kind: 'until';
|
|
19
|
+
date: DateValue;
|
|
20
|
+
};
|
|
21
|
+
export interface RepeatRule {
|
|
22
|
+
frequency: RepeatFrequency;
|
|
23
|
+
/** Every `interval` days, weeks, months or years. */
|
|
24
|
+
interval: number;
|
|
25
|
+
/** Weekly: the days, in week order from Monday, the start's among them. Otherwise empty. */
|
|
26
|
+
weekdays: Weekday[];
|
|
27
|
+
/** Monthly: which day of each month. Otherwise null. */
|
|
28
|
+
monthly: MonthlyPattern | null;
|
|
29
|
+
end: RepeatEnd;
|
|
30
|
+
}
|
|
31
|
+
/** What a rule is tied to: the event's start, on its own clock. */
|
|
32
|
+
export interface RuleAnchor {
|
|
33
|
+
start: DateValue;
|
|
34
|
+
/** Minutes after midnight on the event's clock (0 for an all-day event). */
|
|
35
|
+
startMinutes: number;
|
|
36
|
+
timeZone: string;
|
|
37
|
+
allDay: boolean;
|
|
38
|
+
}
|
|
39
|
+
export type ParsedRepeat = {
|
|
40
|
+
kind: 'none';
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'rule';
|
|
43
|
+
rule: RepeatRule;
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'kept';
|
|
46
|
+
text: string;
|
|
47
|
+
};
|
|
48
|
+
/** The menu's ready-made rules. */
|
|
49
|
+
export type RepeatPreset = 'daily' | 'weekly' | 'monthlyNth' | 'monthlyLast' | 'yearly' | 'weekdays';
|
|
50
|
+
/** The longest interval and count the builder offers. */
|
|
51
|
+
export declare const MAX_INTERVAL = 99;
|
|
52
|
+
export declare const MAX_COUNT = 999;
|
|
53
|
+
/** The start's weekday. */
|
|
54
|
+
export declare function weekdayCode(date: DateValue): Weekday;
|
|
55
|
+
/** Which of its weekday the date is in its month: 1 for the first … 5 for a fifth. */
|
|
56
|
+
export declare function nthOfMonth(date: DateValue): number;
|
|
57
|
+
/** The date is the last of its weekday in its month. */
|
|
58
|
+
export declare function isLastOfMonth(date: DateValue): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The presets the menu offers for this start: "on the last …" only in a month's last week,
|
|
61
|
+
* "every weekday" only from a weekday (the start is always an occurrence).
|
|
62
|
+
*/
|
|
63
|
+
export declare function presetsFor(anchor: RuleAnchor): RepeatPreset[];
|
|
64
|
+
/** A preset's rule for this start, repeating for ever. */
|
|
65
|
+
export declare function presetRule(preset: RepeatPreset, anchor: RuleAnchor): RepeatRule;
|
|
66
|
+
/** The preset a rule is, for this start; null for anything else (a custom rule). */
|
|
67
|
+
export declare function presetOf(rule: RepeatRule, anchor: RuleAnchor): RepeatPreset | null;
|
|
68
|
+
/** A new frequency: weekly starts on the start's day, monthly on its day of the month. */
|
|
69
|
+
export declare function withFrequency(rule: RepeatRule, frequency: RepeatFrequency, anchor: RuleAnchor): RepeatRule;
|
|
70
|
+
/** Turns a weekly day on or off; the start's own day stays on. */
|
|
71
|
+
export declare function withWeekdayToggled(rule: RepeatRule, day: Weekday, anchor: RuleAnchor): RepeatRule;
|
|
72
|
+
/**
|
|
73
|
+
* The rule after the event's start moved, so the start stays an occurrence: a weekly rule
|
|
74
|
+
* takes the new start's day (the old start's day goes when it was the only one); a monthly
|
|
75
|
+
* nth weekday past the fourth becomes the last, and a last weekday no longer last the nth.
|
|
76
|
+
*/
|
|
77
|
+
export declare function followStart(rule: RepeatRule, before: RuleAnchor, after: RuleAnchor): RepeatRule;
|
|
78
|
+
export type RuleProblem = 'interval' | 'count' | 'untilBeforeStart' | 'noWeekdays';
|
|
79
|
+
/** What is wrong with a rule the builder holds; null when it can be saved. */
|
|
80
|
+
export declare function ruleProblem(rule: RepeatRule, anchor: RuleAnchor): RuleProblem | null;
|
|
81
|
+
/** `20261231T182959Z`: an instant as RFC 5545 writes a UTC time. */
|
|
82
|
+
export declare function utcStamp(instant: Date): string;
|
|
83
|
+
/** The RRULE value of a rule (without the `RRULE:` prefix), tied to `anchor`. */
|
|
84
|
+
export declare function buildRRule(rule: RepeatRule, anchor: RuleAnchor): string;
|
|
85
|
+
/**
|
|
86
|
+
* Reads a stored rule: one line, with or without `RRULE:`, with an inline `DTSTART=` (the
|
|
87
|
+
* service writes one) or DTSTART lines around it. What the builder can't hold for this start is
|
|
88
|
+
* `kept`, never changed or dropped.
|
|
89
|
+
*/
|
|
90
|
+
export declare function parseRRule(text: string | null | undefined, anchor: RuleAnchor): ParsedRepeat;
|