@remit/ui 0.0.224 → 0.0.226
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/components/app-shell-slotted.js +1 -1
- package/dist/components/app-switcher.d.ts +15 -0
- package/dist/components/app-switcher.js +31 -0
- package/dist/components/calendar-event-popup.d.ts +43 -0
- package/dist/components/calendar-event-popup.js +18 -0
- package/dist/components/calendar-event-sidebar.d.ts +45 -0
- package/dist/components/calendar-event-sidebar.js +19 -0
- package/dist/components/calendar-grid.d.ts +11 -7
- package/dist/components/calendar-grid.js +55 -109
- package/dist/components/calendar-guests.d.ts +80 -0
- package/dist/components/calendar-guests.js +102 -0
- package/dist/components/calendar-popover.d.ts +25 -0
- package/dist/components/calendar-popover.js +84 -0
- package/dist/components/calendar-quick-create.d.ts +53 -0
- package/dist/components/calendar-quick-create.js +43 -0
- package/dist/components/calendar-screen-toolbar.d.ts +30 -0
- package/dist/components/calendar-screen-toolbar.js +24 -0
- package/dist/components/calendar-sheet.d.ts +14 -0
- package/dist/components/calendar-sheet.js +34 -0
- package/dist/components/calendar-side-pane.d.ts +20 -0
- package/dist/components/calendar-side-pane.js +11 -0
- package/dist/components/calendar-suggestion-list.d.ts +11 -0
- package/dist/components/calendar-suggestion-list.js +9 -0
- package/dist/components/calendar-task-popup.d.ts +28 -0
- package/dist/components/calendar-task-popup.js +17 -0
- package/dist/components/calendar-time-grid.d.ts +70 -0
- package/dist/components/calendar-time-grid.js +701 -0
- package/dist/components/calendar-toolbar.d.ts +0 -31
- package/dist/components/calendar-toolbar.js +0 -27
- package/dist/components/calendar-types.d.ts +12 -2
- package/dist/components/calendar-types.js +0 -5
- package/dist/components/calendar-year.d.ts +11 -0
- package/dist/components/calendar-year.js +9 -0
- package/dist/components/compose-fab.js +3 -1
- package/dist/components/event-editor.js +2 -1
- package/dist/components/intelligence-calendar.d.ts +1 -1
- package/dist/components/intelligence-calendar.js +10 -16
- package/dist/components/mini-month.d.ts +19 -0
- package/dist/components/mini-month.js +34 -0
- package/dist/components/recurrence-scope-prompt.d.ts +3 -1
- package/dist/components/recurrence-scope-prompt.js +4 -2
- package/dist/index.d.ts +24 -5
- package/dist/index.js +23 -4
- package/dist/lib/calendar-range.d.ts +10 -0
- package/dist/lib/calendar-range.js +39 -0
- package/dist/lib/calendar-slot-pick.d.ts +29 -0
- package/dist/lib/calendar-slot-pick.js +67 -0
- package/dist/lib/event-drag.d.ts +20 -0
- package/dist/lib/event-drag.js +50 -0
- package/dist/lib/grid-keyboard.d.ts +15 -0
- package/dist/lib/grid-keyboard.js +46 -0
- package/dist/lib/guest-list.d.ts +17 -0
- package/dist/lib/guest-list.js +34 -0
- package/dist/lib/iso-week.d.ts +2 -0
- package/dist/lib/iso-week.js +13 -0
- package/dist/lib/long-press.d.ts +25 -0
- package/dist/lib/long-press.js +37 -0
- package/dist/lib/mini-month.d.ts +27 -0
- package/dist/lib/mini-month.js +33 -0
- package/dist/lib/popup-placement.d.ts +22 -0
- package/dist/lib/popup-placement.js +39 -0
- package/dist/lib/time-grid-layout.d.ts +38 -0
- package/dist/lib/time-grid-layout.js +94 -0
- package/package.json +1 -1
- package/dist/components/calendar-suggestion-deck.d.ts +0 -18
- package/dist/components/calendar-suggestion-deck.js +0 -51
- package/dist/components/event-detail.d.ts +0 -38
- package/dist/components/event-detail.js +0 -21
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check, CircleHelp, Clock3, Crown, X } from "lucide-react";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { parseGuest, withGuest } from "../lib/guest-list.js";
|
|
6
|
+
import { CalendarFailureBlock, } from "./calendar-event-popup.js";
|
|
7
|
+
const chip = "inline-flex max-w-full items-center gap-1 rounded-full border px-2 py-0.5 text-sm";
|
|
8
|
+
/**
|
|
9
|
+
* Guests as chips, added by typing an address or picking a contact. An entry
|
|
10
|
+
* that is not an address stays as a chip marked invalid and named under the
|
|
11
|
+
* field, so the reader fixes or removes it before the event can be saved.
|
|
12
|
+
*/
|
|
13
|
+
export function CalendarGuestsField({ value, onChange, suggestions, onQuery, touch = false, }) {
|
|
14
|
+
const listId = useId();
|
|
15
|
+
const noteId = useId();
|
|
16
|
+
const [draft, setDraft] = useState("");
|
|
17
|
+
const guests = value;
|
|
18
|
+
const invalid = guests.find((guest) => !guest.valid);
|
|
19
|
+
const commit = (text) => {
|
|
20
|
+
if (text.trim() === "")
|
|
21
|
+
return;
|
|
22
|
+
const picked = suggestions.find((suggestion) => suggestion.email === text.trim().toLowerCase());
|
|
23
|
+
const entry = picked
|
|
24
|
+
? parseGuest(picked.name === ""
|
|
25
|
+
? picked.email
|
|
26
|
+
: `${picked.name} <${picked.email}>`)
|
|
27
|
+
: parseGuest(text);
|
|
28
|
+
onChange(withGuest(guests, entry));
|
|
29
|
+
setDraft("");
|
|
30
|
+
onQuery("");
|
|
31
|
+
};
|
|
32
|
+
const remove = (guest) => onChange(guests.filter((other) => other !== guest));
|
|
33
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [guests.length > 0 && (_jsx("ul", { "aria-label": "Guests", className: "flex flex-wrap gap-1.5", children: guests.map((guest) => (_jsxs("li", { className: cn(chip, guest.valid
|
|
34
|
+
? "border-line bg-surface-sunken text-fg"
|
|
35
|
+
: "border-danger bg-danger-soft text-danger"), children: [_jsx("span", { className: "truncate", children: guest.valid ? guest.displayName : guest.text }), _jsx("button", { type: "button", "aria-label": `Remove ${guest.valid ? guest.email : guest.text}`, onClick: () => remove(guest), className: "rounded-full p-0.5 hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring", children: _jsx(X, { className: "size-3" }) })] }, guest.text))) })), _jsx("input", { "aria-label": "Guests", "aria-describedby": invalid ? noteId : undefined, "aria-invalid": invalid ? true : undefined, placeholder: "Add guests", list: listId, value: draft, onChange: (event) => {
|
|
36
|
+
const text = event.target.value;
|
|
37
|
+
if (/[,;]$/.test(text)) {
|
|
38
|
+
commit(text.slice(0, -1));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
setDraft(text);
|
|
42
|
+
onQuery(text);
|
|
43
|
+
}, onKeyDown: (event) => {
|
|
44
|
+
if (event.key !== "Enter" || draft.trim() === "")
|
|
45
|
+
return;
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
commit(draft);
|
|
48
|
+
}, onBlur: () => commit(draft), className: cn("h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30", touch && "h-11") }), _jsx("datalist", { id: listId, children: suggestions.map((suggestion) => (_jsx("option", { value: suggestion.email, children: suggestion.name }, suggestion.email))) }), invalid && (_jsxs("p", { id: noteId, role: "status", className: "text-sm text-danger", children: [invalid.text, " is not an email address. Fix or remove it to save."] }))] }));
|
|
49
|
+
}
|
|
50
|
+
/** The account an event's invitations go out from. */
|
|
51
|
+
export function CalendarSenderField({ label, senders, value, onChange, disabled = false, touch = false, }) {
|
|
52
|
+
return (_jsx("select", { "aria-label": label, value: value, disabled: disabled, onChange: (event) => onChange(event.target.value), className: cn("h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30 disabled:opacity-60", touch && "h-11"), children: senders.map((sender) => (_jsx("option", { value: sender.accountId, children: sender.email }, sender.accountId))) }));
|
|
53
|
+
}
|
|
54
|
+
const TALLY_WORDS = [
|
|
55
|
+
["accepted", "yes"],
|
|
56
|
+
["declined", "no"],
|
|
57
|
+
["tentative", "maybe"],
|
|
58
|
+
["needsAction", "awaiting"],
|
|
59
|
+
];
|
|
60
|
+
const tallyOf = (counts) => TALLY_WORDS.flatMap(([answer, word]) => counts[answer] === 0 ? [] : [`${counts[answer]} ${word}`]).join(", ");
|
|
61
|
+
const answerMark = (rsvp) => {
|
|
62
|
+
if (rsvp === "accepted")
|
|
63
|
+
return _jsx(Check, { className: "size-3.5 text-positive", "aria-label": "Yes" });
|
|
64
|
+
if (rsvp === "declined")
|
|
65
|
+
return _jsx(X, { className: "size-3.5 text-danger", "aria-label": "No" });
|
|
66
|
+
if (rsvp === "tentative")
|
|
67
|
+
return _jsx(CircleHelp, { className: "size-3.5 text-fg-muted", "aria-label": "Maybe" });
|
|
68
|
+
return _jsx(Clock3, { className: "size-3.5 text-fg-subtle", "aria-label": "Awaiting" });
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The guest list in the event popup: how many, how they answered, and who,
|
|
72
|
+
* with the organizer marked. Read-only: the guest list changes in the editor.
|
|
73
|
+
*/
|
|
74
|
+
export function CalendarEventGuests({ attendees, counts, }) {
|
|
75
|
+
if (attendees.length === 0)
|
|
76
|
+
return null;
|
|
77
|
+
return (_jsxs("section", { "aria-label": "Guests", className: "flex flex-col gap-1.5 px-2 text-sm", children: [_jsxs("p", { className: "font-medium text-fg", children: [attendees.length, " ", attendees.length === 1 ? "guest" : "guests"] }), _jsx("p", { className: "text-fg-muted", children: tallyOf(counts) }), _jsx("ul", { className: "flex flex-col gap-1", children: attendees.map((attendee) => (_jsxs("li", { className: "flex items-center gap-2", children: [answerMark(attendee.rsvp), _jsx("span", { className: "min-w-0 truncate", children: attendee.name === "" ? attendee.email : attendee.name }), attendee.role === "organizer" && (_jsxs("span", { className: "inline-flex items-center gap-0.5 text-xs text-fg-muted", children: [_jsx(Crown, { className: "size-3", "aria-hidden": "true" }), "Organizer"] }))] }, attendee.email))) })] }));
|
|
78
|
+
}
|
|
79
|
+
const ANSWERS = [
|
|
80
|
+
["accepted", "Yes"],
|
|
81
|
+
["declined", "No"],
|
|
82
|
+
["tentative", "Maybe"],
|
|
83
|
+
];
|
|
84
|
+
/** `Going?` with Yes, No and Maybe, the current answer pressed. */
|
|
85
|
+
export function CalendarReplyRow({ current, onAnswer, sending = false, failure, }) {
|
|
86
|
+
return (_jsxs("div", { className: "flex flex-col gap-2 border-t border-line px-2 pt-3", children: [_jsxs("fieldset", { className: "flex items-center gap-2", children: [_jsx("legend", { className: "sr-only", children: "Going?" }), _jsx("span", { "aria-hidden": "true", className: "mr-1 text-sm text-fg", children: "Going?" }), ANSWERS.map(([answer, label]) => (_jsx("button", { type: "button", "aria-pressed": current === answer, disabled: sending, onClick: () => onAnswer(answer), className: cn("h-8 rounded-full border px-3 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60", current === answer
|
|
87
|
+
? "border-accent bg-accent text-accent-fg"
|
|
88
|
+
: "border-line hover:bg-surface-sunken"), children: label }, answer)))] }), failure && _jsx(CalendarFailureBlock, { failure: failure })] }));
|
|
89
|
+
}
|
|
90
|
+
/** The event is saved; these guests were not reached. */
|
|
91
|
+
export function CalendarInvitationsNotSent({ missed, onRetry, reportHref, onDismiss, }) {
|
|
92
|
+
if (missed.length === 0)
|
|
93
|
+
return null;
|
|
94
|
+
const names = missed.join(", ");
|
|
95
|
+
return (_jsxs("div", { role: "alert", className: "flex flex-wrap items-center gap-3 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm", children: [_jsxs("p", { className: "text-danger", children: ["Saved, but the ", missed.length === 1 ? "invitation" : "invitations", " to", " ", names, " didn't go out."] }), _jsx("button", { type: "button", onClick: onRetry, className: "rounded-md border border-line bg-surface px-3 py-1 font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring", children: "Try again" }), _jsx("a", { href: reportHref, target: "_blank", rel: "noreferrer", className: "font-medium text-accent hover:underline", children: "Report an issue" }), _jsx("button", { type: "button", "aria-label": "Dismiss", onClick: onDismiss, className: "ml-auto rounded-full p-1 text-fg-muted hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring", children: _jsx(X, { className: "size-4" }) })] }));
|
|
96
|
+
}
|
|
97
|
+
/** The event is deleted; these guests are being told. */
|
|
98
|
+
export function CalendarCancellationsSent({ guests, onDismiss, }) {
|
|
99
|
+
if (guests.length === 0)
|
|
100
|
+
return null;
|
|
101
|
+
return (_jsxs("div", { role: "status", className: "flex flex-wrap items-center gap-3 rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm", children: [_jsxs("p", { className: "text-fg", children: ["Deleted. A cancellation is going to ", guests.join(", "), "."] }), _jsx("button", { type: "button", "aria-label": "Dismiss", onClick: onDismiss, className: "ml-auto rounded-full p-1 text-fg-muted hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring", children: _jsx(X, { className: "size-4" }) })] }));
|
|
102
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type PointerEvent, type ReactNode, type Ref } from "react";
|
|
2
|
+
export interface CalendarPopoverProps {
|
|
3
|
+
/**
|
|
4
|
+
* What the popover sits beside, or a selector for it read after each render;
|
|
5
|
+
* null or out of view centres it.
|
|
6
|
+
*/
|
|
7
|
+
anchor: HTMLElement | string | null;
|
|
8
|
+
/** Changes whenever the anchor moves, so the popover follows it. */
|
|
9
|
+
anchorKey: string;
|
|
10
|
+
labelledBy: string;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
/** A header drag moves the popover and leaves the anchor alone. */
|
|
13
|
+
header?: (dragHandle: {
|
|
14
|
+
onPointerDown: (event: PointerEvent<HTMLElement>) => void;
|
|
15
|
+
}) => ReactNode;
|
|
16
|
+
/** Tab wraps inside the popover, which traps nothing else. */
|
|
17
|
+
wrapTab?: boolean;
|
|
18
|
+
panelRef?: Ref<HTMLDivElement>;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A floating card beside a range or an event on the calendar grid: a
|
|
23
|
+
* non-modal `dialog`, placed on the side with room.
|
|
24
|
+
*/
|
|
25
|
+
export declare function CalendarPopover({ anchor, anchorKey, labelledBy, children, header, wrapTab, panelRef, className, }: CalendarPopoverProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect, useRef, useState, } from "react";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { placePopup } from "../lib/popup-placement.js";
|
|
5
|
+
const FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
6
|
+
/**
|
|
7
|
+
* A floating card beside a range or an event on the calendar grid: a
|
|
8
|
+
* non-modal `dialog`, placed on the side with room.
|
|
9
|
+
*/
|
|
10
|
+
export function CalendarPopover({ anchor, anchorKey, labelledBy, children, header, wrapTab = false, panelRef, className, }) {
|
|
11
|
+
const ownRef = useRef(null);
|
|
12
|
+
const [placement, setPlacement] = useState(null);
|
|
13
|
+
const [offset, setOffset] = useState({ key: anchorKey, x: 0, y: 0 });
|
|
14
|
+
const shift = offset.key === anchorKey ? offset : { x: 0, y: 0 };
|
|
15
|
+
useLayoutEffect(() => {
|
|
16
|
+
const panel = ownRef.current;
|
|
17
|
+
if (!panel || anchorKey === "")
|
|
18
|
+
return;
|
|
19
|
+
const place = () => {
|
|
20
|
+
const element = typeof anchor === "string"
|
|
21
|
+
? document.querySelector(anchor)
|
|
22
|
+
: anchor;
|
|
23
|
+
const rect = element?.getBoundingClientRect();
|
|
24
|
+
setPlacement(placePopup(rect
|
|
25
|
+
? {
|
|
26
|
+
left: rect.left,
|
|
27
|
+
top: rect.top,
|
|
28
|
+
width: rect.width,
|
|
29
|
+
height: rect.height,
|
|
30
|
+
}
|
|
31
|
+
: null, { width: panel.offsetWidth, height: panel.offsetHeight }, { width: window.innerWidth, height: window.innerHeight }));
|
|
32
|
+
};
|
|
33
|
+
place();
|
|
34
|
+
window.addEventListener("resize", place);
|
|
35
|
+
return () => window.removeEventListener("resize", place);
|
|
36
|
+
}, [anchor, anchorKey]);
|
|
37
|
+
const startDrag = (event) => {
|
|
38
|
+
if (event.button !== 0)
|
|
39
|
+
return;
|
|
40
|
+
if (event.target instanceof Element &&
|
|
41
|
+
event.target.closest("button, input, select, a"))
|
|
42
|
+
return;
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
const from = { x: event.clientX - shift.x, y: event.clientY - shift.y };
|
|
45
|
+
const move = (moved) => setOffset({
|
|
46
|
+
key: anchorKey,
|
|
47
|
+
x: moved.clientX - from.x,
|
|
48
|
+
y: moved.clientY - from.y,
|
|
49
|
+
});
|
|
50
|
+
const stop = () => {
|
|
51
|
+
window.removeEventListener("pointermove", move);
|
|
52
|
+
window.removeEventListener("pointerup", stop);
|
|
53
|
+
};
|
|
54
|
+
window.addEventListener("pointermove", move);
|
|
55
|
+
window.addEventListener("pointerup", stop);
|
|
56
|
+
};
|
|
57
|
+
const onKeyDown = (event) => {
|
|
58
|
+
if (!wrapTab || event.key !== "Tab")
|
|
59
|
+
return;
|
|
60
|
+
const items = Array.from(event.currentTarget.querySelectorAll(FOCUSABLE));
|
|
61
|
+
if (items.length === 0)
|
|
62
|
+
return;
|
|
63
|
+
const first = items[0];
|
|
64
|
+
const last = items[items.length - 1];
|
|
65
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
last.focus();
|
|
68
|
+
}
|
|
69
|
+
else if (!event.shiftKey && document.activeElement === last) {
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
first.focus();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return (_jsxs("div", { ref: (node) => {
|
|
75
|
+
ownRef.current = node;
|
|
76
|
+
if (typeof panelRef === "function")
|
|
77
|
+
panelRef(node);
|
|
78
|
+
else if (panelRef)
|
|
79
|
+
panelRef.current = node;
|
|
80
|
+
}, role: "dialog", "aria-modal": "false", "aria-labelledby": labelledBy, "data-calendar-popover": "", onKeyDown: onKeyDown, className: cn("fixed z-40 w-[26rem] max-w-[calc(100vw-1rem)] rounded-xl border border-line bg-surface-raised text-fg shadow-xl shadow-black/20", placement === null && "opacity-0", className), style: {
|
|
81
|
+
left: (placement?.left ?? 0) + shift.x,
|
|
82
|
+
top: (placement?.top ?? 0) + shift.y,
|
|
83
|
+
}, children: [header?.({ onPointerDown: startDrag }), children] }));
|
|
84
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PointerEvent, Ref } from "react";
|
|
2
|
+
import { type GuestEntry } from "../lib/guest-list.js";
|
|
3
|
+
import { type CalendarFailure } from "./calendar-event-popup.js";
|
|
4
|
+
import { type GuestSuggestion } from "./calendar-guests.js";
|
|
5
|
+
import type { CalendarTaskFields } from "./calendar-task-popup.js";
|
|
6
|
+
import type { CalendarDescriptor, CalendarSlotPick } from "./calendar-types.js";
|
|
7
|
+
export interface QuickCreateFields {
|
|
8
|
+
title: string;
|
|
9
|
+
range: CalendarSlotPick;
|
|
10
|
+
location: string;
|
|
11
|
+
calendarId: string;
|
|
12
|
+
guests: GuestEntry[];
|
|
13
|
+
}
|
|
14
|
+
/** A new task: a due date with an optional time, in a task list. */
|
|
15
|
+
export interface QuickTaskFields extends CalendarTaskFields {
|
|
16
|
+
calendarId: string;
|
|
17
|
+
}
|
|
18
|
+
/** What the card is making: an event over the range, or a task due on its day. */
|
|
19
|
+
export type QuickCreateMode = "event" | "task";
|
|
20
|
+
export interface CalendarQuickCreateCardProps {
|
|
21
|
+
headingId: string;
|
|
22
|
+
mode: QuickCreateMode;
|
|
23
|
+
onMode: (mode: QuickCreateMode) => void;
|
|
24
|
+
fields: QuickCreateFields;
|
|
25
|
+
taskFields: QuickTaskFields;
|
|
26
|
+
onTaskChange: (fields: QuickTaskFields) => void;
|
|
27
|
+
/** Only the calendars that accept writes. */
|
|
28
|
+
calendars: readonly CalendarDescriptor[];
|
|
29
|
+
/** The lists a task can go into. */
|
|
30
|
+
taskLists: readonly CalendarDescriptor[];
|
|
31
|
+
guestSuggestions: readonly GuestSuggestion[];
|
|
32
|
+
onGuestQuery: (query: string) => void;
|
|
33
|
+
onChange: (fields: QuickCreateFields) => void;
|
|
34
|
+
onSave: () => void;
|
|
35
|
+
onMoreOptions: () => void;
|
|
36
|
+
onClose: () => void;
|
|
37
|
+
saving?: boolean;
|
|
38
|
+
/** Why the draft cannot be saved yet, said in the form. */
|
|
39
|
+
problem?: string;
|
|
40
|
+
failure?: CalendarFailure;
|
|
41
|
+
failureRef?: Ref<HTMLDivElement>;
|
|
42
|
+
titleRef?: Ref<HTMLInputElement>;
|
|
43
|
+
/** Where the calendar settings live, for when no calendar accepts writes. */
|
|
44
|
+
settingsHref: string;
|
|
45
|
+
/** The header drag, from the popover around the card. */
|
|
46
|
+
dragHandle?: {
|
|
47
|
+
onPointerDown: (event: PointerEvent<HTMLElement>) => void;
|
|
48
|
+
};
|
|
49
|
+
/** A bottom sheet on a phone: thumb-sized controls, no drag header. */
|
|
50
|
+
touch?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** Google Calendar's small create popup: title, when, where, which calendar. */
|
|
53
|
+
export declare function CalendarQuickCreateCard({ headingId, mode, onMode, fields, taskFields, onTaskChange, calendars, taskLists, guestSuggestions, onGuestQuery, onChange, onSave, onMoreOptions, onClose, saving, problem, failure, failureRef, titleRef, settingsHref, dragHandle, touch, }: CalendarQuickCreateCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { GripHorizontal, X } from "lucide-react";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { invalidGuest } from "../lib/guest-list.js";
|
|
5
|
+
import { CalendarFailureBlock, } from "./calendar-event-popup.js";
|
|
6
|
+
import { CalendarGuestsField, } from "./calendar-guests.js";
|
|
7
|
+
const field = "h-9 rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30";
|
|
8
|
+
const withRange = (fields, patch) => {
|
|
9
|
+
const range = { ...fields.range, ...patch };
|
|
10
|
+
if (patch.date !== undefined && !range.allDay)
|
|
11
|
+
range.endDate = patch.date;
|
|
12
|
+
if (patch.date !== undefined && range.allDay && range.endDate < patch.date)
|
|
13
|
+
range.endDate = patch.date;
|
|
14
|
+
return { ...fields, range };
|
|
15
|
+
};
|
|
16
|
+
/** Google Calendar's small create popup: title, when, where, which calendar. */
|
|
17
|
+
export function CalendarQuickCreateCard({ headingId, mode, onMode, fields, taskFields, onTaskChange, calendars, taskLists, guestSuggestions, onGuestQuery, onChange, onSave, onMoreOptions, onClose, saving = false, problem = "", failure, failureRef, titleRef, settingsHref, dragHandle, touch = false, }) {
|
|
18
|
+
const isTask = mode === "task";
|
|
19
|
+
const lists = isTask ? taskLists : calendars;
|
|
20
|
+
const noWritable = lists.length === 0;
|
|
21
|
+
const blocked = !isTask && invalidGuest(fields.guests) !== undefined;
|
|
22
|
+
const control = cn(field, touch && "h-11");
|
|
23
|
+
const title = isTask ? taskFields.title : fields.title;
|
|
24
|
+
const setTitle = (next) => isTask
|
|
25
|
+
? onTaskChange({ ...taskFields, title: next })
|
|
26
|
+
: onChange({ ...fields, title: next });
|
|
27
|
+
return (_jsxs("form", { className: "relative flex flex-col", onSubmit: (event) => {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
if (!noWritable && !saving && !blocked)
|
|
30
|
+
onSave();
|
|
31
|
+
}, children: [_jsxs("div", { onPointerDown: dragHandle?.onPointerDown, className: cn("flex items-center justify-between rounded-t-xl bg-surface-sunken px-2 py-1", dragHandle && "cursor-grab"), children: [_jsx(GripHorizontal, { className: "size-4 text-fg-subtle", "aria-hidden": "true" }), _jsx("h2", { id: headingId, className: "sr-only", children: isTask ? "New task" : "New event" })] }), _jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsx("input", { ref: titleRef, "aria-label": "Title", placeholder: "Add title", value: title, onChange: (event) => setTitle(event.target.value), className: cn("border-b-2 border-line bg-transparent pb-1 text-xl text-fg outline-none placeholder:text-fg-subtle focus:border-accent") }), _jsxs("fieldset", { className: "flex gap-1 self-start rounded-md bg-surface-sunken p-0.5 text-sm", children: [_jsx("legend", { className: "sr-only", children: "Kind" }), ["event", "task"].map((kind) => (_jsxs("label", { className: cn("cursor-pointer rounded px-3 py-1 font-medium has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring", mode === kind
|
|
32
|
+
? "bg-surface text-fg shadow-sm"
|
|
33
|
+
: "text-fg-muted", touch && "min-h-11"), children: [_jsx("input", { type: "radio", name: `${headingId}-kind`, value: kind, checked: mode === kind, onChange: () => onMode(kind), className: "sr-only" }), kind === "event" ? "Event" : "Task"] }, kind)))] }), isTask ? (_jsxs("div", { className: "flex flex-wrap items-center gap-2 text-sm", children: [_jsx("span", { className: "text-fg-muted", children: "Due" }), _jsx("input", { type: "date", "aria-label": "Due date", value: taskFields.dueDate, onChange: (event) => event.target.value !== "" &&
|
|
34
|
+
onTaskChange({ ...taskFields, dueDate: event.target.value }), className: control }), taskFields.dueTime === "" ? (_jsx("button", { type: "button", onClick: () => onTaskChange({ ...taskFields, dueTime: "09:00" }), className: "rounded-md px-2 font-medium text-accent hover:bg-accent-soft", children: "Add time" })) : (_jsx("input", { type: "time", "aria-label": "Due time", step: 900, value: taskFields.dueTime, onChange: (event) => onTaskChange({ ...taskFields, dueTime: event.target.value }), className: control }))] })) : (_jsxs("div", { className: "flex flex-wrap items-center gap-2 text-sm", children: [_jsx("input", { type: "date", "aria-label": "Date", value: fields.range.date, onChange: (event) => event.target.value !== "" &&
|
|
35
|
+
onChange(withRange(fields, { date: event.target.value })), className: control }), fields.range.allDay ? (_jsx("span", { className: "text-fg-muted", children: "All day" })) : (_jsxs(_Fragment, { children: [_jsx("input", { type: "time", "aria-label": "Start time", step: 900, value: fields.range.startTime, onChange: (event) => event.target.value !== "" &&
|
|
36
|
+
onChange(withRange(fields, { startTime: event.target.value })), className: control }), _jsx("span", { "aria-hidden": "true", children: "\u2013" }), _jsx("input", { type: "time", "aria-label": "End time", step: 900, value: fields.range.endTime, onChange: (event) => event.target.value !== "" &&
|
|
37
|
+
onChange(withRange(fields, { endTime: event.target.value })), className: control })] }))] })), !isTask && (_jsx(CalendarGuestsField, { value: fields.guests, onChange: (guests) => onChange({ ...fields, guests }), suggestions: guestSuggestions, onQuery: onGuestQuery, touch: touch })), isTask ? (_jsx("textarea", { "aria-label": "Description", placeholder: "Add description", rows: 2, value: taskFields.description, onChange: (event) => onTaskChange({ ...taskFields, description: event.target.value }), className: "w-full rounded-md border border-line bg-surface-sunken px-2 py-1 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30" })) : (_jsx("input", { "aria-label": "Location", placeholder: "Add location", value: fields.location, onChange: (event) => onChange({ ...fields, location: event.target.value }), className: control })), noWritable ? (_jsxs("p", { role: "status", tabIndex: -1, className: "text-sm text-fg-muted", children: ["None of your calendars accepts new events.", " ", _jsx("a", { href: settingsHref, className: "font-medium text-accent hover:underline", children: "Calendar settings" })] })) : (_jsx("select", { "aria-label": isTask ? "Task list" : "Calendar", value: isTask ? taskFields.calendarId : fields.calendarId, onChange: (event) => isTask
|
|
38
|
+
? onTaskChange({
|
|
39
|
+
...taskFields,
|
|
40
|
+
calendarId: event.target.value,
|
|
41
|
+
})
|
|
42
|
+
: onChange({ ...fields, calendarId: event.target.value }), className: control, children: lists.map((calendar) => (_jsx("option", { value: calendar.id, children: calendar.name }, calendar.id))) })), problem !== "" && (_jsx("p", { className: "text-sm text-danger", role: "status", children: problem })), failure && (_jsx(CalendarFailureBlock, { failure: failure, focusRef: failureRef }))] }), _jsxs("div", { className: "flex items-center justify-between px-4 pb-4", children: [isTask ? (_jsx("span", {})) : (_jsx("button", { type: "button", onClick: onMoreOptions, className: cn("rounded-md px-3 text-sm font-medium text-accent outline-none hover:bg-accent-soft focus-visible:ring-2 focus-visible:ring-ring", touch ? "min-h-11" : "h-9"), children: "More options" })), _jsx("button", { type: "submit", disabled: noWritable || saving || blocked, className: cn("rounded-md bg-accent px-5 text-sm font-medium text-accent-fg outline-none hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50", touch ? "min-h-11" : "h-9"), children: saving ? "Saving…" : "Save" })] }), _jsx("button", { type: "button", "aria-label": "Close", onClick: onClose, className: cn("absolute top-0 right-1 flex items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring", touch ? "size-11" : "size-8"), children: _jsx(X, { className: "size-4" }) })] }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { CalendarViewId } from "./calendar-types.js";
|
|
3
|
+
export interface CalendarScreenToolbarProps {
|
|
4
|
+
view: CalendarViewId;
|
|
5
|
+
/** The range on screen, already formatted: "November 2026". */
|
|
6
|
+
title: string;
|
|
7
|
+
/** The ISO week the range starts in, shown as a chip; absent hides it. */
|
|
8
|
+
weekNumber?: number;
|
|
9
|
+
/** The views the dropdown offers. */
|
|
10
|
+
views?: CalendarViewId[];
|
|
11
|
+
onChangeView: (view: CalendarViewId) => void;
|
|
12
|
+
onPrev: () => void;
|
|
13
|
+
onNext: () => void;
|
|
14
|
+
onToday: () => void;
|
|
15
|
+
/** The side pane the hamburger shows and hides. */
|
|
16
|
+
sidePane?: {
|
|
17
|
+
open: boolean;
|
|
18
|
+
controls: string;
|
|
19
|
+
onToggle: () => void;
|
|
20
|
+
};
|
|
21
|
+
/** Controls the view owns, before the view dropdown. */
|
|
22
|
+
trailing?: ReactNode;
|
|
23
|
+
touch?: boolean;
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The calendar's top row, after Google Calendar: the hamburger, Today, the
|
|
28
|
+
* arrows, the month and year with the week number, and one view dropdown.
|
|
29
|
+
*/
|
|
30
|
+
export declare function CalendarScreenToolbar({ view, title, weekNumber, views, onChangeView, onPrev, onNext, onToday, sidePane, trailing, touch, className, }: CalendarScreenToolbarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronLeft, ChevronRight, Menu } from "lucide-react";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { Select } from "./select.js";
|
|
5
|
+
const VIEW_LABELS = {
|
|
6
|
+
year: "Year",
|
|
7
|
+
month: "Month",
|
|
8
|
+
week: "Week",
|
|
9
|
+
day: "Day",
|
|
10
|
+
agenda: "Agenda",
|
|
11
|
+
};
|
|
12
|
+
const ALL_VIEWS = ["day", "week", "month", "year", "agenda"];
|
|
13
|
+
/**
|
|
14
|
+
* The calendar's top row, after Google Calendar: the hamburger, Today, the
|
|
15
|
+
* arrows, the month and year with the week number, and one view dropdown.
|
|
16
|
+
*/
|
|
17
|
+
export function CalendarScreenToolbar({ view, title, weekNumber, views = ALL_VIEWS, onChangeView, onPrev, onNext, onToday, sidePane, trailing, touch = false, className, }) {
|
|
18
|
+
const iconButton = cn("flex shrink-0 items-center justify-center rounded-full text-fg-muted outline-none transition-colors hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring", touch ? "size-11" : "size-9");
|
|
19
|
+
return (_jsxs("div", { role: "toolbar", "aria-label": "Calendar", "data-calendar-toolbar": "", className: cn("flex shrink-0 items-center gap-1 border-b border-line bg-surface px-2", touch ? "h-14" : "h-14 gap-2", className), children: [sidePane && (_jsx("button", { type: "button", "aria-label": "Side pane", "aria-expanded": sidePane.open, "aria-controls": sidePane.controls, onClick: sidePane.onToggle, className: iconButton, children: _jsx(Menu, { className: "size-5" }) })), _jsx("button", { type: "button", onClick: onToday, className: cn("shrink-0 rounded-full border border-line px-4 text-sm font-medium text-fg outline-none transition-colors hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring", touch ? "min-h-11" : "h-9"), children: "Today" }), _jsx("button", { type: "button", onClick: onPrev, "aria-label": `Previous ${VIEW_LABELS[view].toLowerCase()}`, className: iconButton, children: _jsx(ChevronLeft, { className: "size-5" }) }), _jsx("button", { type: "button", onClick: onNext, "aria-label": `Next ${VIEW_LABELS[view].toLowerCase()}`, className: iconButton, children: _jsx(ChevronRight, { className: "size-5" }) }), _jsx("h1", { className: cn("min-w-0 truncate font-normal text-fg", touch ? "text-base" : "text-xl"), children: title }), weekNumber !== undefined && (_jsxs("span", { className: "shrink-0 rounded-md bg-surface-sunken px-2 py-0.5 text-xs font-medium text-fg-muted", children: ["Week ", weekNumber] })), _jsx("div", { className: "min-w-0 flex-1" }), !touch && trailing, _jsx(Select, { "aria-label": "View", value: view, onChange: (event) => {
|
|
20
|
+
const picked = views.find((option) => option === event.target.value);
|
|
21
|
+
if (picked)
|
|
22
|
+
onChangeView(picked);
|
|
23
|
+
}, className: cn("shrink-0", touch ? "h-11 w-24" : "w-28"), children: views.map((option) => (_jsx("option", { value: option, children: VIEW_LABELS[option] }, option))) })] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode, type Ref } from "react";
|
|
2
|
+
export interface CalendarSheetProps {
|
|
3
|
+
labelledBy: string;
|
|
4
|
+
onDismiss: () => void;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
sheetRef?: Ref<HTMLDivElement>;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A sheet along the bottom of a phone that leaves the grid above it in view
|
|
11
|
+
* and live: no scrim, so a tap above it reaches the grid. A swipe down on the
|
|
12
|
+
* grabber dismisses it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function CalendarSheet({ labelledBy, onDismiss, children, sheetRef, className, }: CalendarSheetProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState, } from "react";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
const DISMISS_PX = 80;
|
|
5
|
+
/**
|
|
6
|
+
* A sheet along the bottom of a phone that leaves the grid above it in view
|
|
7
|
+
* and live: no scrim, so a tap above it reaches the grid. A swipe down on the
|
|
8
|
+
* grabber dismisses it.
|
|
9
|
+
*/
|
|
10
|
+
export function CalendarSheet({ labelledBy, onDismiss, children, sheetRef, className, }) {
|
|
11
|
+
const start = useRef(null);
|
|
12
|
+
const [offset, setOffset] = useState(0);
|
|
13
|
+
const down = (event) => {
|
|
14
|
+
start.current = event.clientY;
|
|
15
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
16
|
+
};
|
|
17
|
+
const move = (event) => {
|
|
18
|
+
if (start.current === null)
|
|
19
|
+
return;
|
|
20
|
+
setOffset(Math.max(0, event.clientY - start.current));
|
|
21
|
+
};
|
|
22
|
+
const up = () => {
|
|
23
|
+
if (start.current === null)
|
|
24
|
+
return;
|
|
25
|
+
start.current = null;
|
|
26
|
+
if (offset > DISMISS_PX)
|
|
27
|
+
onDismiss();
|
|
28
|
+
setOffset(0);
|
|
29
|
+
};
|
|
30
|
+
return (_jsxs("div", { ref: sheetRef, role: "dialog", "aria-modal": "false", "aria-labelledby": labelledBy, "data-calendar-popover": "", className: cn("fixed inset-x-0 bottom-0 z-50 max-h-[70dvh] overflow-y-auto rounded-t-2xl border-t border-line bg-surface-raised pb-[env(safe-area-inset-bottom,0px)] shadow-2xl shadow-black/30", className), style: {
|
|
31
|
+
transform: `translateY(${offset}px)`,
|
|
32
|
+
transition: offset === 0 ? "transform 200ms ease-out" : "none",
|
|
33
|
+
}, children: [_jsx("div", { "aria-hidden": "true", "data-sheet-grabber": "", onPointerDown: down, onPointerMove: move, onPointerUp: up, onPointerCancel: up, className: "flex h-6 cursor-grab touch-none items-center justify-center", children: _jsx("span", { className: "h-1 w-10 rounded-full bg-line-strong" }) }), children] }));
|
|
34
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from "react";
|
|
2
|
+
export interface CalendarSidePaneProps {
|
|
3
|
+
id: string;
|
|
4
|
+
onNewEvent: () => void;
|
|
5
|
+
newEventRef?: Ref<HTMLButtonElement>;
|
|
6
|
+
/** The mini month. */
|
|
7
|
+
month: ReactNode;
|
|
8
|
+
/** The calendar list, or the failure that stands in for it. */
|
|
9
|
+
calendars: ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Google Calendar's left pane: New event, the mini month and My calendars. */
|
|
13
|
+
export declare function CalendarSidePane({ id, onNewEvent, newEventRef, month, calendars, className, }: CalendarSidePaneProps): import("react").JSX.Element;
|
|
14
|
+
export interface NewEventSquareProps {
|
|
15
|
+
onNewEvent: () => void;
|
|
16
|
+
newEventRef?: Ref<HTMLButtonElement>;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
/** What New event shrinks to while the side pane is hidden. */
|
|
20
|
+
export declare function NewEventSquare({ onNewEvent, newEventRef, className, }: NewEventSquareProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Plus } from "lucide-react";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
/** Google Calendar's left pane: New event, the mini month and My calendars. */
|
|
5
|
+
export function CalendarSidePane({ id, onNewEvent, newEventRef, month, calendars, className, }) {
|
|
6
|
+
return (_jsxs("section", { id: id, "aria-label": "Calendar side pane", className: cn("flex w-64 shrink-0 flex-col gap-4 overflow-y-auto bg-surface px-3 py-3", className), children: [_jsxs("button", { ref: newEventRef, type: "button", onClick: onNewEvent, className: "flex h-12 w-fit items-center gap-3 rounded-2xl bg-surface-raised px-5 text-sm font-medium text-fg shadow-md outline-none transition-shadow hover:shadow-lg focus-visible:ring-2 focus-visible:ring-ring", children: [_jsx(Plus, { className: "size-5 text-accent", "aria-hidden": "true" }), "New event"] }), month, _jsxs("section", { "aria-label": "My calendars", className: "flex flex-col gap-1", children: [_jsx("h2", { className: "px-1 text-sm font-medium text-fg", children: "My calendars" }), calendars] })] }));
|
|
7
|
+
}
|
|
8
|
+
/** What New event shrinks to while the side pane is hidden. */
|
|
9
|
+
export function NewEventSquare({ onNewEvent, newEventRef, className, }) {
|
|
10
|
+
return (_jsx("button", { ref: newEventRef, type: "button", "aria-label": "New event", onClick: onNewEvent, className: cn("flex size-12 items-center justify-center rounded-2xl bg-surface-raised text-accent shadow-md outline-none hover:shadow-lg focus-visible:ring-2 focus-visible:ring-ring", className), children: _jsx(Plus, { className: "size-6", "aria-hidden": "true" }) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface CalendarSuggestionListItem {
|
|
3
|
+
id: string;
|
|
4
|
+
card: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export interface CalendarSuggestionListProps {
|
|
7
|
+
items: readonly CalendarSuggestionListItem[];
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Readings waiting on a decision, one under the other, each with its own buttons. */
|
|
11
|
+
export declare function CalendarSuggestionList({ items, className, }: CalendarSuggestionListProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Sparkles } from "lucide-react";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
/** Readings waiting on a decision, one under the other, each with its own buttons. */
|
|
5
|
+
export function CalendarSuggestionList({ items, className, }) {
|
|
6
|
+
if (items.length === 0)
|
|
7
|
+
return (_jsxs("div", { className: cn("flex flex-col items-center gap-2 p-6 text-center", className), children: [_jsx(Sparkles, { className: "size-6 text-fg-subtle", "aria-hidden": true }), _jsx("p", { className: "text-sm text-fg-muted", children: "Nothing in your mail is waiting on a decision about time." })] }));
|
|
8
|
+
return (_jsx("ul", { "aria-label": "Suggested events", className: cn("flex min-h-0 flex-col gap-3 overflow-y-auto", className), children: items.map((item) => (_jsx("li", { children: item.card }, item.id))) }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Ref } from "react";
|
|
2
|
+
import { type CalendarFailure } from "./calendar-event-popup.js";
|
|
3
|
+
/** A task's editable fields, in the form the popup edits them. */
|
|
4
|
+
export interface CalendarTaskFields {
|
|
5
|
+
title: string;
|
|
6
|
+
/** `YYYY-MM-DD`. */
|
|
7
|
+
dueDate: string;
|
|
8
|
+
/** `HH:MM`, empty for a task due on a day. */
|
|
9
|
+
dueTime: string;
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CalendarTaskPopupCardProps {
|
|
13
|
+
headingId: string;
|
|
14
|
+
headingRef?: Ref<HTMLHeadingElement>;
|
|
15
|
+
fields: CalendarTaskFields;
|
|
16
|
+
/** "Due Thursday 5 November". */
|
|
17
|
+
dueText: string;
|
|
18
|
+
listName: string;
|
|
19
|
+
completed: boolean;
|
|
20
|
+
onToggle: () => void;
|
|
21
|
+
onSave: (fields: CalendarTaskFields) => void;
|
|
22
|
+
onDelete: () => void;
|
|
23
|
+
onClose: () => void;
|
|
24
|
+
busy?: boolean;
|
|
25
|
+
failure?: CalendarFailure;
|
|
26
|
+
}
|
|
27
|
+
/** A task's popup: title, due date, list and description, with Mark done, Edit and Delete. */
|
|
28
|
+
export declare function CalendarTaskPopupCard({ headingId, headingRef, fields, dueText, listName, completed, onToggle, onSave, onDelete, onClose, busy, failure, }: CalendarTaskPopupCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CalendarDays, CheckSquare, Square, Trash2, X } from "lucide-react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { CalendarFailureBlock, } from "./calendar-event-popup.js";
|
|
6
|
+
const iconButton = "flex size-9 items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40";
|
|
7
|
+
const field = "h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30";
|
|
8
|
+
/** A task's popup: title, due date, list and description, with Mark done, Edit and Delete. */
|
|
9
|
+
export function CalendarTaskPopupCard({ headingId, headingRef, fields, dueText, listName, completed, onToggle, onSave, onDelete, onClose, busy = false, failure, }) {
|
|
10
|
+
const [editing, setEditing] = useState(null);
|
|
11
|
+
return (_jsxs("div", { className: "flex flex-col gap-3 p-3", children: [_jsxs("div", { className: "flex justify-end gap-1", children: [editing === null && (_jsx("button", { type: "button", onClick: () => setEditing(fields), className: "rounded-md px-3 text-sm font-medium text-accent hover:bg-accent-soft focus-visible:ring-2 focus-visible:ring-ring", children: "Edit" })), _jsx("button", { type: "button", "aria-label": "Delete", onClick: onDelete, disabled: busy, className: iconButton, children: _jsx(Trash2, { className: "size-4" }) }), _jsx("button", { type: "button", "aria-label": "Close", onClick: onClose, className: iconButton, children: _jsx(X, { className: "size-4" }) })] }), editing === null ? (_jsxs("div", { className: "flex flex-col gap-2 px-2", children: [_jsx("h2", { id: headingId, ref: headingRef, tabIndex: -1, className: cn("text-xl font-normal break-words text-fg outline-none", completed && "text-fg-muted line-through"), children: fields.title === "" ? "(No title)" : fields.title }), _jsx("p", { className: "text-sm text-fg-muted", children: dueText }), _jsxs("p", { className: "flex items-center gap-2 text-sm", children: [_jsx(CalendarDays, { className: "size-4 text-fg-subtle", "aria-label": "List" }), listName] }), fields.description !== "" && (_jsx("p", { className: "text-sm whitespace-pre-wrap break-words", children: fields.description }))] })) : (_jsxs("form", { className: "flex flex-col gap-2 px-2", onSubmit: (event) => {
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
onSave(editing);
|
|
14
|
+
setEditing(null);
|
|
15
|
+
}, children: [_jsx("h2", { id: headingId, className: "sr-only", children: "Edit task" }), _jsx("input", { "aria-label": "Title", value: editing.title, onChange: (event) => setEditing({ ...editing, title: event.target.value }), className: field }), _jsxs("div", { className: "flex gap-2", children: [_jsx("input", { type: "date", "aria-label": "Due date", value: editing.dueDate, onChange: (event) => event.target.value !== "" &&
|
|
16
|
+
setEditing({ ...editing, dueDate: event.target.value }), className: field }), _jsx("input", { type: "time", "aria-label": "Due time", value: editing.dueTime, onChange: (event) => setEditing({ ...editing, dueTime: event.target.value }), className: field })] }), _jsx("textarea", { "aria-label": "Description", rows: 3, value: editing.description, onChange: (event) => setEditing({ ...editing, description: event.target.value }), className: "w-full rounded-md border border-line bg-surface-sunken px-2 py-1 text-sm" }), _jsxs("div", { className: "flex justify-end gap-2", children: [_jsx("button", { type: "button", onClick: () => setEditing(null), className: "h-9 rounded-md border border-line px-3 text-sm font-medium", children: "Cancel" }), _jsx("button", { type: "submit", disabled: busy, className: "h-9 rounded-md bg-accent px-4 text-sm font-medium text-accent-fg disabled:opacity-50", children: "Save" })] })] })), failure && _jsx(CalendarFailureBlock, { failure: failure }), editing === null && (_jsx("div", { className: "flex justify-end px-2", children: _jsxs("button", { type: "button", onClick: onToggle, disabled: busy, className: "inline-flex h-9 items-center gap-2 rounded-md border border-line px-3 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50", children: [completed ? (_jsx(Square, { className: "size-4", "aria-hidden": "true" })) : (_jsx(CheckSquare, { className: "size-4", "aria-hidden": "true" })), completed ? "Mark not done" : "Mark done"] }) }))] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Density } from "./app-shell-types.js";
|
|
2
|
+
import type { CalendarColorId, CalendarEventData, CalendarSlotPick, CalendarTaskData } from "./calendar-types.js";
|
|
3
|
+
/** What a reader did on the grid, for whoever holds the draft to decide. */
|
|
4
|
+
export type GridGesture = {
|
|
5
|
+
type: "drag";
|
|
6
|
+
range: CalendarSlotPick;
|
|
7
|
+
} | {
|
|
8
|
+
type: "drag-cancel";
|
|
9
|
+
} | {
|
|
10
|
+
type: "drag-end";
|
|
11
|
+
range: CalendarSlotPick;
|
|
12
|
+
} | {
|
|
13
|
+
type: "click";
|
|
14
|
+
range: CalendarSlotPick;
|
|
15
|
+
origin: HTMLElement | null;
|
|
16
|
+
} | {
|
|
17
|
+
type: "keyboard";
|
|
18
|
+
range: CalendarSlotPick;
|
|
19
|
+
origin: HTMLElement | null;
|
|
20
|
+
};
|
|
21
|
+
/** The one range the grid draws over the events: a selection, or the draft being edited. */
|
|
22
|
+
export interface GridDraft {
|
|
23
|
+
range: CalendarSlotPick;
|
|
24
|
+
title: string;
|
|
25
|
+
/** `selection` is solid, as a range being picked; `draft` is dashed and labelled. */
|
|
26
|
+
tone: "selection" | "draft";
|
|
27
|
+
/** A save of this draft failed. */
|
|
28
|
+
warning?: boolean;
|
|
29
|
+
/** Grab handles at both ends, which resize the range. */
|
|
30
|
+
handles?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface CalendarTimeGridProps {
|
|
33
|
+
/** The days in view, `YYYY-MM-DD`. */
|
|
34
|
+
days: readonly string[];
|
|
35
|
+
events: readonly CalendarEventData[];
|
|
36
|
+
colorByCalendarId: Readonly<Record<string, CalendarColorId>>;
|
|
37
|
+
density: Density;
|
|
38
|
+
/** The zone the grid's clock runs on. */
|
|
39
|
+
timeZone: string;
|
|
40
|
+
/** The instant the grid calls now. */
|
|
41
|
+
now: string;
|
|
42
|
+
selectedEventId?: string;
|
|
43
|
+
draft?: GridDraft;
|
|
44
|
+
onGesture: (gesture: GridGesture) => void;
|
|
45
|
+
onSelectEvent: (eventId: string, chip: HTMLElement) => void;
|
|
46
|
+
/** A day heading opens that day. */
|
|
47
|
+
onOpenDay?: (date: string) => void;
|
|
48
|
+
/** A finger selects by holding still, so a scroll never selects. */
|
|
49
|
+
touch?: boolean;
|
|
50
|
+
/** Whether an event may be dragged to a new time; its calendar takes writes. */
|
|
51
|
+
canMove?: (eventId: string) => boolean;
|
|
52
|
+
/** A stored event dropped at a new time or with a new end. */
|
|
53
|
+
onMoveEvent?: (eventId: string, range: CalendarSlotPick) => void;
|
|
54
|
+
/** Tasks due in the days on screen, drawn in the all-day row of their day. */
|
|
55
|
+
tasks?: readonly CalendarTaskData[];
|
|
56
|
+
selectedTaskId?: string;
|
|
57
|
+
onSelectTask?: (calendarTaskId: string) => void;
|
|
58
|
+
/** Ticks or unticks a task drawn on the grid. */
|
|
59
|
+
onToggleTask?: (calendarTaskId: string) => void;
|
|
60
|
+
className?: string;
|
|
61
|
+
}
|
|
62
|
+
/** "Wednesday 4 November, 08:00 to 09:45", for the live region and the focused slot. */
|
|
63
|
+
export declare function describeRange(range: CalendarSlotPick): string;
|
|
64
|
+
/**
|
|
65
|
+
* A day or a week of time, drawn by the kit rather than a calendar engine, so
|
|
66
|
+
* a press, a drag, a hold and the keyboard all reach the grid the same way.
|
|
67
|
+
* Every gesture leaves through `onGesture`; the grid only draws the draft it
|
|
68
|
+
* is handed.
|
|
69
|
+
*/
|
|
70
|
+
export declare function CalendarTimeGrid({ days, events, colorByCalendarId, density, timeZone, now, selectedEventId, draft, onGesture, onSelectEvent, onOpenDay, touch, canMove, onMoveEvent, tasks, selectedTaskId, onSelectTask, onToggleTask, className, }: CalendarTimeGridProps): import("react").JSX.Element;
|