@remit/ui 0.0.192 → 0.0.194
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/package.json +1 -1
- package/src/components/account-service-change-dialog.render.test.ts +73 -0
- package/src/components/account-service-change-dialog.stories.tsx +66 -0
- package/src/components/account-service-change-dialog.tsx +117 -0
- package/src/components/account-service-choice.tsx +4 -3
- package/src/components/account-service-status.render.test.ts +82 -0
- package/src/components/account-service-status.stories.tsx +61 -0
- package/src/components/account-service-status.tsx +89 -0
- package/src/components/account-service-toggles.render.test.ts +123 -0
- package/src/components/account-service-toggles.stories.tsx +121 -0
- package/src/components/account-service-toggles.tsx +125 -0
- package/src/components/agenda-composer.render.test.ts +1 -0
- package/src/components/agenda-composer.stories.tsx +1 -0
- package/src/components/agenda-flow.tsx +3 -0
- package/src/components/app-shell-types.ts +7 -0
- package/src/components/calendar-list.render.test.ts +34 -0
- package/src/components/calendar-list.stories.tsx +32 -0
- package/src/components/calendar-list.tsx +43 -30
- package/src/components/calendar-slot-offers.render.test.ts +7 -1
- package/src/components/calendar-slot-offers.stories.tsx +7 -1
- package/src/components/calendar-types.ts +9 -0
- package/src/components/event-editor.render.test.ts +23 -0
- package/src/components/event-editor.stories.tsx +31 -4
- package/src/components/event-editor.tsx +78 -50
- package/src/components/intelligence-calendar-fixtures.ts +7 -1
- package/src/components/nav-sidebar.render.test.ts +40 -0
- package/src/components/nav-sidebar.tsx +13 -0
- package/src/index.ts +27 -0
- package/src/lib/agenda-time.ts +15 -0
- package/src/lib/calendar-slot-pick.test.ts +25 -5
- package/src/lib/calendar-slot-pick.ts +13 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { expect, userEvent, within } from "storybook/test";
|
|
3
|
+
import type { AccountService } from "./account-service-choice.js";
|
|
4
|
+
import { ACCOUNT_NO_SERVICE_TOGGLES_MESSAGE } from "./account-service-status.js";
|
|
5
|
+
import {
|
|
6
|
+
type AccountServiceIntent,
|
|
7
|
+
AccountServiceToggles,
|
|
8
|
+
} from "./account-service-toggles.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* What an account syncs, on its settings screen (#1179). The switch asks; the
|
|
12
|
+
* host confirms and commits.
|
|
13
|
+
*/
|
|
14
|
+
const meta: Meta<typeof AccountServiceToggles> = {
|
|
15
|
+
title: "Components/AccountServiceToggles",
|
|
16
|
+
component: AccountServiceToggles,
|
|
17
|
+
parameters: { layout: "padded" },
|
|
18
|
+
decorators: [
|
|
19
|
+
(Story) => (
|
|
20
|
+
<div className="mx-auto max-w-sm rounded-xl border border-line bg-surface p-4">
|
|
21
|
+
<Story />
|
|
22
|
+
</div>
|
|
23
|
+
),
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
export default meta;
|
|
27
|
+
|
|
28
|
+
type Story = StoryObj<typeof AccountServiceToggles>;
|
|
29
|
+
|
|
30
|
+
const bothServices: AccountService[] = ["Mail", "Calendar"];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Stands in for the host that owns the change: the switch reports the ask and
|
|
34
|
+
* nothing moves until the host answers it, which is what these stories show.
|
|
35
|
+
*/
|
|
36
|
+
function Toggles({
|
|
37
|
+
enabled,
|
|
38
|
+
consented = bothServices,
|
|
39
|
+
offered = bothServices,
|
|
40
|
+
onRequestChange = () => {},
|
|
41
|
+
}: {
|
|
42
|
+
enabled: AccountService[];
|
|
43
|
+
consented?: AccountService[];
|
|
44
|
+
offered?: AccountService[];
|
|
45
|
+
onRequestChange?: (
|
|
46
|
+
service: AccountService,
|
|
47
|
+
intent: AccountServiceIntent,
|
|
48
|
+
) => void;
|
|
49
|
+
}) {
|
|
50
|
+
return (
|
|
51
|
+
<AccountServiceToggles
|
|
52
|
+
providerName="Microsoft"
|
|
53
|
+
offered={offered}
|
|
54
|
+
enabled={enabled}
|
|
55
|
+
consented={consented}
|
|
56
|
+
onRequestChange={onRequestChange}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Both services on: the state an Outlook account arrives in from onboarding. */
|
|
62
|
+
export const BothOn: Story = {
|
|
63
|
+
render: () => <Toggles enabled={bothServices} />,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Mail off. The switch is the only thing that changed — the account keeps its
|
|
68
|
+
* place and its stored mail, which the other surfaces say for themselves.
|
|
69
|
+
*/
|
|
70
|
+
export const MailOff: Story = {
|
|
71
|
+
render: () => <Toggles enabled={["Calendar"]} />,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Calendar was never consented to. The row says what turning it on costs before
|
|
76
|
+
* it is pressed, because no saved setting can grant a scope.
|
|
77
|
+
*/
|
|
78
|
+
export const CalendarNeedsConsent: Story = {
|
|
79
|
+
render: () => <Toggles enabled={["Mail"]} consented={["Mail"]} />,
|
|
80
|
+
play: async ({ canvasElement }) => {
|
|
81
|
+
const canvas = within(canvasElement);
|
|
82
|
+
await expect(
|
|
83
|
+
canvas.getByText(/signing in with Microsoft again/),
|
|
84
|
+
).toBeVisible();
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Pressing a running service asks to switch it off. Nothing moves on screen:
|
|
90
|
+
* the host raises the confirmation and owns the change.
|
|
91
|
+
*/
|
|
92
|
+
export const AsksBeforeItMoves: Story = {
|
|
93
|
+
render: () => <Toggles enabled={bothServices} />,
|
|
94
|
+
play: async ({ canvasElement }) => {
|
|
95
|
+
const canvas = within(canvasElement);
|
|
96
|
+
const mail = canvas.getByRole("switch", { name: "Sync mail" });
|
|
97
|
+
await userEvent.click(mail);
|
|
98
|
+
await expect(mail).toBeChecked();
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* An IMAP account. It syncs mail and nothing else, so there is nothing to
|
|
104
|
+
* switch — the border below is the whole render.
|
|
105
|
+
*/
|
|
106
|
+
export const ImapAccount: Story = {
|
|
107
|
+
render: () => (
|
|
108
|
+
<>
|
|
109
|
+
<AccountServiceToggles
|
|
110
|
+
providerName="Fastmail"
|
|
111
|
+
offered={["Mail"]}
|
|
112
|
+
enabled={["Mail"]}
|
|
113
|
+
consented={["Mail"]}
|
|
114
|
+
onRequestChange={() => {}}
|
|
115
|
+
/>
|
|
116
|
+
<p className="border-t border-line pt-2 text-2xs text-fg-subtle">
|
|
117
|
+
{ACCOUNT_NO_SERVICE_TOGGLES_MESSAGE}
|
|
118
|
+
</p>
|
|
119
|
+
</>
|
|
120
|
+
),
|
|
121
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { useId } from "react";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import {
|
|
4
|
+
ACCOUNT_SERVICE_ROWS,
|
|
5
|
+
type AccountService,
|
|
6
|
+
} from "./account-service-choice.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A service switch on the account settings screen. Switching off always asks,
|
|
10
|
+
* because it stops a sync. Switching on asks only when the grant does not cover
|
|
11
|
+
* the service yet, because granting it leaves for the provider; a service the
|
|
12
|
+
* consent already covers comes back on without a question.
|
|
13
|
+
*/
|
|
14
|
+
export type AccountServiceIntent = "on" | "off";
|
|
15
|
+
|
|
16
|
+
export interface AccountServiceTogglesProps {
|
|
17
|
+
/** Provider named in the consent note, e.g. "Microsoft". */
|
|
18
|
+
providerName: string;
|
|
19
|
+
/** Services this account's connector carries. Under two, nothing renders. */
|
|
20
|
+
offered: AccountService[];
|
|
21
|
+
/** Services the account syncs today. */
|
|
22
|
+
enabled: AccountService[];
|
|
23
|
+
/** Services the account's grant already covers. The rest cost a sign-in. */
|
|
24
|
+
consented: AccountService[];
|
|
25
|
+
/** Asks the host for a change. The host owns the question and the commit. */
|
|
26
|
+
onRequestChange: (
|
|
27
|
+
service: AccountService,
|
|
28
|
+
intent: AccountServiceIntent,
|
|
29
|
+
) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function ServiceSwitch({
|
|
33
|
+
checked,
|
|
34
|
+
label,
|
|
35
|
+
describedBy,
|
|
36
|
+
onToggle,
|
|
37
|
+
}: {
|
|
38
|
+
checked: boolean;
|
|
39
|
+
label: string;
|
|
40
|
+
describedBy: string;
|
|
41
|
+
onToggle: () => void;
|
|
42
|
+
}) {
|
|
43
|
+
return (
|
|
44
|
+
<button
|
|
45
|
+
type="button"
|
|
46
|
+
role="switch"
|
|
47
|
+
aria-checked={checked}
|
|
48
|
+
aria-label={label}
|
|
49
|
+
aria-describedby={describedBy}
|
|
50
|
+
onClick={onToggle}
|
|
51
|
+
className={cn(
|
|
52
|
+
"relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors",
|
|
53
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",
|
|
54
|
+
checked
|
|
55
|
+
? "border-positive bg-positive"
|
|
56
|
+
: "border-line-strong bg-surface-sunken",
|
|
57
|
+
)}
|
|
58
|
+
>
|
|
59
|
+
<span
|
|
60
|
+
aria-hidden
|
|
61
|
+
className={cn(
|
|
62
|
+
"size-4 rounded-full bg-canvas transition-transform",
|
|
63
|
+
checked ? "translate-x-6" : "translate-x-1",
|
|
64
|
+
)}
|
|
65
|
+
/>
|
|
66
|
+
</button>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* What an account syncs, on the account settings screen (#1179). One switch per
|
|
72
|
+
* service the connector carries, mail first.
|
|
73
|
+
*
|
|
74
|
+
* An IMAP account carries mail and nothing else, so it gets no switches at all
|
|
75
|
+
* rather than one it can never move — the same rule the onboarding choice
|
|
76
|
+
* follows for a single-service provider.
|
|
77
|
+
*/
|
|
78
|
+
export function AccountServiceToggles({
|
|
79
|
+
providerName,
|
|
80
|
+
offered,
|
|
81
|
+
enabled,
|
|
82
|
+
consented,
|
|
83
|
+
onRequestChange,
|
|
84
|
+
}: AccountServiceTogglesProps) {
|
|
85
|
+
const groupId = useId();
|
|
86
|
+
const rows = ACCOUNT_SERVICE_ROWS.filter((row) => offered.includes(row.id));
|
|
87
|
+
|
|
88
|
+
if (rows.length < 2) return null;
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<fieldset>
|
|
92
|
+
<legend className="text-sm font-semibold text-fg">
|
|
93
|
+
What this account syncs
|
|
94
|
+
</legend>
|
|
95
|
+
<div className="mt-1 divide-y divide-line">
|
|
96
|
+
{rows.map((row) => {
|
|
97
|
+
const on = enabled.includes(row.id);
|
|
98
|
+
const noteId = `${groupId}-${row.id}`;
|
|
99
|
+
const needsConsent = !on && !consented.includes(row.id);
|
|
100
|
+
return (
|
|
101
|
+
<div
|
|
102
|
+
key={row.id}
|
|
103
|
+
className="flex min-h-11 items-center gap-3 py-2 text-left"
|
|
104
|
+
>
|
|
105
|
+
<span className="flex min-w-0 flex-1 flex-col">
|
|
106
|
+
<span className="text-sm text-fg">{row.label}</span>
|
|
107
|
+
<span id={noteId} className="text-xs text-fg-subtle">
|
|
108
|
+
{needsConsent
|
|
109
|
+
? `${row.description} Turning this on means signing in with ${providerName} again.`
|
|
110
|
+
: row.description}
|
|
111
|
+
</span>
|
|
112
|
+
</span>
|
|
113
|
+
<ServiceSwitch
|
|
114
|
+
checked={on}
|
|
115
|
+
label={`Sync ${row.label.toLowerCase()}`}
|
|
116
|
+
describedBy={noteId}
|
|
117
|
+
onToggle={() => onRequestChange(row.id, on ? "off" : "on")}
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
})}
|
|
122
|
+
</div>
|
|
123
|
+
</fieldset>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
@@ -545,6 +545,7 @@ function EmptyRun({
|
|
|
545
545
|
onClick={() =>
|
|
546
546
|
onPickSlot({
|
|
547
547
|
date: from,
|
|
548
|
+
endDate: from,
|
|
548
549
|
startTime: "10:00",
|
|
549
550
|
endTime: "11:00",
|
|
550
551
|
allDay: false,
|
|
@@ -762,6 +763,7 @@ function DayBlock({
|
|
|
762
763
|
onPick={() =>
|
|
763
764
|
onPickSlot({
|
|
764
765
|
date: stretch.date,
|
|
766
|
+
endDate: stretch.date,
|
|
765
767
|
startTime: formatMinute(stretch.startMinute),
|
|
766
768
|
endTime: formatMinute(
|
|
767
769
|
Math.min(stretch.startMinute + 60, stretch.endMinute),
|
|
@@ -896,6 +898,7 @@ function ClearDayLine({
|
|
|
896
898
|
onClick={() =>
|
|
897
899
|
onPickSlot({
|
|
898
900
|
date: day.date,
|
|
901
|
+
endDate: day.date,
|
|
899
902
|
startTime: "10:00",
|
|
900
903
|
endTime: "11:00",
|
|
901
904
|
allDay: false,
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
} from "../category-presentation.js";
|
|
13
13
|
import type { TriageHandlers } from "../lib/keymap.js";
|
|
14
14
|
import type { SelectionModifiers } from "../lib/use-selection.js";
|
|
15
|
+
import type { AccountService } from "./account-service-choice.js";
|
|
15
16
|
import type {
|
|
16
17
|
IntelligenceData,
|
|
17
18
|
SenderTrustLevel,
|
|
@@ -198,6 +199,12 @@ export interface NavAccount {
|
|
|
198
199
|
email: string;
|
|
199
200
|
/** Muted: excluded from unified views, still syncing. Rendered dimmed. */
|
|
200
201
|
muted?: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Services this account syncs. Absent is the account that syncs mail, which
|
|
204
|
+
* is every IMAP account. An account without `Mail` keeps its place in the
|
|
205
|
+
* nav with every mailbox it already synced, labelled rather than dropped.
|
|
206
|
+
*/
|
|
207
|
+
syncedServices?: AccountService[];
|
|
201
208
|
mailboxes: NavMailbox[];
|
|
202
209
|
/**
|
|
203
210
|
* Number of outbox messages pending send. When provided, an Outbox entry
|
|
@@ -75,3 +75,37 @@ describe("CalendarList", () => {
|
|
|
75
75
|
assert.match(html, /Family/);
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A provider calendar whose account has calendar sync off. Nothing was deleted,
|
|
81
|
+
* so the row stays, its tick keeps drawing the stored events, and the pause is
|
|
82
|
+
* a label on the row (#1179).
|
|
83
|
+
*/
|
|
84
|
+
describe("CalendarList with a paused calendar", () => {
|
|
85
|
+
const paused: CalendarDescriptor[] = calendars.map((calendar) =>
|
|
86
|
+
calendar.id === "c1" ? { ...calendar, sync: "paused" } : calendar,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const renderPaused = (visible: string[]) =>
|
|
90
|
+
renderToString(
|
|
91
|
+
createElement(CalendarList, {
|
|
92
|
+
calendars: paused,
|
|
93
|
+
visible: new Set(visible),
|
|
94
|
+
onToggle: () => undefined,
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
it("keeps the row and labels the pause", () => {
|
|
99
|
+
const html = renderPaused(["c1"]);
|
|
100
|
+
assert.match(html, /Northwind/);
|
|
101
|
+
assert.match(html, /calendar sync off/);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("leaves a live calendar unlabelled", () => {
|
|
105
|
+
assert.doesNotMatch(render(["c1"]), /calendar sync off/);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("keeps a paused calendar tickable, so its events stay drawable", () => {
|
|
109
|
+
assert.match(renderPaused(["c1"]), /checked=""/);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
@@ -169,6 +169,38 @@ export const SingleCalendar: Story = {
|
|
|
169
169
|
},
|
|
170
170
|
};
|
|
171
171
|
|
|
172
|
+
/**
|
|
173
|
+
* A paused provider calendar. Sync stopped; the calendar is still listed, still
|
|
174
|
+
* coloured and still tickable, so the pause icon is decoration and the words
|
|
175
|
+
* that carry it sit beside the row rather than inside the tick's name.
|
|
176
|
+
*/
|
|
177
|
+
export const Paused: Story = {
|
|
178
|
+
render: () => {
|
|
179
|
+
const paused = calendars.map((calendar) =>
|
|
180
|
+
calendar.id === "c1"
|
|
181
|
+
? { ...calendar, sync: "paused" as const }
|
|
182
|
+
: calendar,
|
|
183
|
+
);
|
|
184
|
+
return (
|
|
185
|
+
<CalendarList
|
|
186
|
+
calendars={paused}
|
|
187
|
+
visible={new Set(calendars.map((c) => c.id))}
|
|
188
|
+
onToggle={() => {}}
|
|
189
|
+
onToggleAccount={() => {}}
|
|
190
|
+
/>
|
|
191
|
+
);
|
|
192
|
+
},
|
|
193
|
+
play: async ({ canvasElement }) => {
|
|
194
|
+
const canvas = within(canvasElement);
|
|
195
|
+
await expect(
|
|
196
|
+
canvas.getByRole("checkbox", { name: "Northwind" }),
|
|
197
|
+
).toBeChecked();
|
|
198
|
+
await expect(
|
|
199
|
+
canvas.getByText("Northwind: calendar sync off"),
|
|
200
|
+
).toBeInTheDocument();
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
172
204
|
/**
|
|
173
205
|
* The same control on a surface with no room for a rail: a scrolling row of
|
|
174
206
|
* chips at thumb size. It is laid out differently and it is not a popover —
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Check, ChevronDown, ChevronRight } from "lucide-react";
|
|
1
|
+
import { Check, ChevronDown, ChevronRight, PauseCircle } from "lucide-react";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { calendarColorClasses } from "../lib/calendar-color.js";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { ACCOUNT_SERVICE_OFF_LABEL } from "./account-service-status.js";
|
|
5
6
|
import type { CalendarDescriptor } from "./calendar-types.js";
|
|
6
7
|
|
|
7
8
|
export interface CalendarListProps {
|
|
@@ -187,39 +188,51 @@ function CalendarListRow({
|
|
|
187
188
|
onToggle: () => void;
|
|
188
189
|
}) {
|
|
189
190
|
const hue = calendarColorClasses(calendar.color);
|
|
191
|
+
const paused = calendar.sync === "paused";
|
|
190
192
|
return (
|
|
191
|
-
<
|
|
192
|
-
|
|
193
|
-
"flex cursor-pointer items-center gap-2.5 rounded-sm px-row-inset hover:bg-surface-sunken",
|
|
194
|
-
touch ? "min-h-11" : "min-h-9",
|
|
195
|
-
)}
|
|
196
|
-
>
|
|
197
|
-
<input
|
|
198
|
-
type="checkbox"
|
|
199
|
-
checked={checked}
|
|
200
|
-
onChange={onToggle}
|
|
201
|
-
className="peer sr-only"
|
|
202
|
-
/>
|
|
203
|
-
<span
|
|
204
|
-
aria-hidden
|
|
193
|
+
<div className="flex flex-col">
|
|
194
|
+
<label
|
|
205
195
|
className={cn(
|
|
206
|
-
"flex
|
|
207
|
-
"
|
|
208
|
-
checked
|
|
209
|
-
? cn(hue.solid, hue.border)
|
|
210
|
-
: cn("bg-transparent", hue.border),
|
|
196
|
+
"flex cursor-pointer items-center gap-2.5 rounded-sm px-row-inset hover:bg-surface-sunken",
|
|
197
|
+
touch ? "min-h-11" : "min-h-9",
|
|
211
198
|
)}
|
|
212
199
|
>
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
"
|
|
218
|
-
|
|
200
|
+
<input
|
|
201
|
+
type="checkbox"
|
|
202
|
+
checked={checked}
|
|
203
|
+
onChange={onToggle}
|
|
204
|
+
className="peer sr-only"
|
|
205
|
+
/>
|
|
206
|
+
<span
|
|
207
|
+
aria-hidden
|
|
208
|
+
className={cn(
|
|
209
|
+
"flex size-4 shrink-0 items-center justify-center rounded-xs border transition-colors",
|
|
210
|
+
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-1 peer-focus-visible:ring-offset-surface",
|
|
211
|
+
checked
|
|
212
|
+
? cn(hue.solid, hue.border)
|
|
213
|
+
: cn("bg-transparent", hue.border),
|
|
214
|
+
)}
|
|
215
|
+
>
|
|
216
|
+
{checked && <Check className="size-3 text-canvas" strokeWidth={3} />}
|
|
217
|
+
</span>
|
|
218
|
+
<span
|
|
219
|
+
className={cn(
|
|
220
|
+
"min-w-0 flex-1 truncate text-sm",
|
|
221
|
+
checked ? "text-fg" : "text-fg-subtle",
|
|
222
|
+
)}
|
|
223
|
+
>
|
|
224
|
+
{calendar.name}
|
|
225
|
+
</span>
|
|
226
|
+
{paused && (
|
|
227
|
+
<PauseCircle
|
|
228
|
+
className="size-3.5 shrink-0 text-fg-subtle"
|
|
229
|
+
aria-hidden
|
|
230
|
+
/>
|
|
219
231
|
)}
|
|
220
|
-
>
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
232
|
+
</label>
|
|
233
|
+
{paused && (
|
|
234
|
+
<span className="sr-only">{`${calendar.name}: ${ACCOUNT_SERVICE_OFF_LABEL.Calendar}`}</span>
|
|
235
|
+
)}
|
|
236
|
+
</div>
|
|
224
237
|
);
|
|
225
238
|
}
|
|
@@ -11,7 +11,13 @@ import type { CalendarSlotPick } from "./calendar-types.js";
|
|
|
11
11
|
const THURSDAY = "2026-06-11";
|
|
12
12
|
|
|
13
13
|
function slot(startTime: string, endTime: string): CalendarSlotPick {
|
|
14
|
-
return {
|
|
14
|
+
return {
|
|
15
|
+
date: THURSDAY,
|
|
16
|
+
endDate: THURSDAY,
|
|
17
|
+
startTime,
|
|
18
|
+
endTime,
|
|
19
|
+
allDay: false,
|
|
20
|
+
};
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
const thursday: CalendarSlotPick[] = [
|
|
@@ -19,7 +19,13 @@ type Story = StoryObj<typeof CalendarSlotOffers>;
|
|
|
19
19
|
const THURSDAY = "2026-06-11";
|
|
20
20
|
|
|
21
21
|
function slot(startTime: string, endTime: string): CalendarSlotPick {
|
|
22
|
-
return {
|
|
22
|
+
return {
|
|
23
|
+
date: THURSDAY,
|
|
24
|
+
endDate: THURSDAY,
|
|
25
|
+
startTime,
|
|
26
|
+
endTime,
|
|
27
|
+
allDay: false,
|
|
28
|
+
};
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
const thursday: CalendarSlotPick[] = [
|
|
@@ -39,6 +39,13 @@ export interface CalendarDescriptor {
|
|
|
39
39
|
accountLabel: string;
|
|
40
40
|
name: string;
|
|
41
41
|
color: CalendarColorId;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the provider still fills this calendar. `paused` is a provider
|
|
44
|
+
* calendar whose account has calendar sync off: its stored events stay on the
|
|
45
|
+
* grid and its tick keeps working, and only new changes have stopped.
|
|
46
|
+
* Defaults to `live`.
|
|
47
|
+
*/
|
|
48
|
+
sync?: "live" | "paused";
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
/**
|
|
@@ -111,6 +118,7 @@ export interface CalendarDay {
|
|
|
111
118
|
export interface CalendarSlotPick {
|
|
112
119
|
/** `YYYY-MM-DD`. */
|
|
113
120
|
date: string;
|
|
121
|
+
endDate: string;
|
|
114
122
|
/** `HH:MM`, empty when the pick landed in the all-day band. */
|
|
115
123
|
startTime: string;
|
|
116
124
|
endTime: string;
|
|
@@ -292,6 +300,7 @@ export interface EventDraft {
|
|
|
292
300
|
date: string;
|
|
293
301
|
/** `HH:MM`, empty when the entry is all day. */
|
|
294
302
|
startTime: string;
|
|
303
|
+
endDate: string;
|
|
295
304
|
endTime: string;
|
|
296
305
|
allDay: boolean;
|
|
297
306
|
calendarId: string;
|
|
@@ -27,6 +27,7 @@ const draft: EventDraft = {
|
|
|
27
27
|
title: "Coffee",
|
|
28
28
|
date: "2026-06-12",
|
|
29
29
|
startTime: "13:00",
|
|
30
|
+
endDate: "2026-06-12",
|
|
30
31
|
endTime: "14:00",
|
|
31
32
|
allDay: false,
|
|
32
33
|
calendarId: "c1",
|
|
@@ -134,6 +135,28 @@ describe("EventEditor", () => {
|
|
|
134
135
|
assert.equal(field(dom, "End time")?.value, "01:00");
|
|
135
136
|
});
|
|
136
137
|
|
|
138
|
+
it("lets a night that ends on the next day save", () => {
|
|
139
|
+
const dom = parse({
|
|
140
|
+
draft: {
|
|
141
|
+
...draft,
|
|
142
|
+
startTime: "23:00",
|
|
143
|
+
endDate: "2026-06-13",
|
|
144
|
+
endTime: "01:00",
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
assert.equal(alertText(dom), "");
|
|
148
|
+
assert.equal(saveControl(dom)?.disabled, false);
|
|
149
|
+
assert.equal(field(dom, "End date")?.value, "2026-06-13");
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("refuses an all-day entry whose last day is before its first", () => {
|
|
153
|
+
const dom = parse({
|
|
154
|
+
draft: { ...draft, allDay: true, endDate: "2026-06-11" },
|
|
155
|
+
});
|
|
156
|
+
assert.match(alertText(dom), /Ends before it starts/);
|
|
157
|
+
assert.equal(saveControl(dom)?.disabled, true);
|
|
158
|
+
});
|
|
159
|
+
|
|
137
160
|
it("lets a normal range save", () => {
|
|
138
161
|
const dom = parse({});
|
|
139
162
|
assert.equal(alertText(dom), "");
|
|
@@ -44,6 +44,7 @@ const seed: EventDraft = {
|
|
|
44
44
|
title: "",
|
|
45
45
|
date: "2026-06-12",
|
|
46
46
|
startTime: "13:00",
|
|
47
|
+
endDate: "2026-06-12",
|
|
47
48
|
endTime: "14:00",
|
|
48
49
|
allDay: false,
|
|
49
50
|
calendarId: "c1",
|
|
@@ -53,7 +54,7 @@ const seed: EventDraft = {
|
|
|
53
54
|
repeat: "",
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
/** 23:00 to 01:00, which
|
|
57
|
+
/** 23:00 to 01:00 on the same day, which runs backwards. */
|
|
57
58
|
const backwards: EventDraft = {
|
|
58
59
|
...seed,
|
|
59
60
|
title: "Release window",
|
|
@@ -61,6 +62,22 @@ const backwards: EventDraft = {
|
|
|
61
62
|
endTime: "01:00",
|
|
62
63
|
};
|
|
63
64
|
|
|
65
|
+
/** 23:00 to 01:00 the next morning: one night, not a backwards hour. */
|
|
66
|
+
const overnight: EventDraft = {
|
|
67
|
+
...backwards,
|
|
68
|
+
endDate: "2026-06-13",
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** Three whole days, Friday through Sunday. */
|
|
72
|
+
const weekend: EventDraft = {
|
|
73
|
+
...seed,
|
|
74
|
+
title: "Offsite",
|
|
75
|
+
startTime: "",
|
|
76
|
+
endTime: "",
|
|
77
|
+
allDay: true,
|
|
78
|
+
endDate: "2026-06-14",
|
|
79
|
+
};
|
|
80
|
+
|
|
64
81
|
function Live({
|
|
65
82
|
startExpanded,
|
|
66
83
|
seed: initial = seed,
|
|
@@ -97,14 +114,24 @@ export const Folded: Story = { render: () => <Live startExpanded={false} /> };
|
|
|
97
114
|
export const Unfolded: Story = { render: () => <Live startExpanded /> };
|
|
98
115
|
|
|
99
116
|
/**
|
|
100
|
-
* An end before the start
|
|
101
|
-
*
|
|
102
|
-
*
|
|
117
|
+
* An end before the start reads the span backwards. The form keeps what was
|
|
118
|
+
* typed, names the problem under the fields and holds the save until it is
|
|
119
|
+
* fixed.
|
|
103
120
|
*/
|
|
104
121
|
export const EndBeforeStart: Story = {
|
|
105
122
|
render: () => <Live startExpanded={false} seed={backwards} />,
|
|
106
123
|
};
|
|
107
124
|
|
|
125
|
+
/** A night that runs past midnight ends on the next day, and saves. */
|
|
126
|
+
export const RunsPastMidnight: Story = {
|
|
127
|
+
render: () => <Live startExpanded={false} seed={overnight} />,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/** An all-day event reads from its first day to its last. */
|
|
131
|
+
export const AllDaySpan: Story = {
|
|
132
|
+
render: () => <Live startExpanded={false} seed={weekend} />,
|
|
133
|
+
};
|
|
134
|
+
|
|
108
135
|
/**
|
|
109
136
|
* Guests are opt-in. A store with nowhere to put them leaves the field out, so
|
|
110
137
|
* the default form has none: a box that takes names and drops them is worse
|