@remit/ui 0.0.211 → 0.0.213

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/ui",
3
- "version": "0.0.211",
3
+ "version": "0.0.213",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * The readings beside the strip. Each one exists because a list can answer a
3
3
  * question a grid answers badly, so what is asserted here is the answer — the
4
- * sentence about what is next, the open time named as time, the shape of the
5
- * two months you are somewhere inside of.
4
+ * sentence about what is next.
6
5
  */
7
6
  import "@remit/test-dom";
8
7
  import assert from "node:assert/strict";
@@ -11,17 +10,10 @@ import { createElement } from "react";
11
10
  import { renderToString } from "react-dom/server";
12
11
  import {
13
12
  buildCalendarDay,
14
- type FreeStretch,
15
13
  type NextUp,
16
14
  readNextUp,
17
15
  } from "../lib/agenda-time.js";
18
- import {
19
- AgendaDensityControl,
20
- FreeTimeList,
21
- NextUpCard,
22
- type NextUpCardProps,
23
- PositionMap,
24
- } from "./agenda-panels.js";
16
+ import { NextUpCard, type NextUpCardProps } from "./agenda-panels.js";
25
17
  import type {
26
18
  CalendarDescriptor,
27
19
  CalendarEventData,
@@ -143,110 +135,3 @@ describe("NextUpCard", () => {
143
135
  assert.match(renderNextUp({ calendars: [] }), /bg-cal-1-soft/);
144
136
  });
145
137
  });
146
-
147
- describe("AgendaDensityControl", () => {
148
- const render = (icons?: boolean) =>
149
- renderToString(
150
- createElement(AgendaDensityControl, {
151
- value: "pills" as const,
152
- onChange: () => {},
153
- icons,
154
- }),
155
- );
156
-
157
- it("is a labelled group of radios, not a row of unlabelled buttons", () => {
158
- const html = render();
159
- assert.match(html, /Agenda density/);
160
- assert.match(html, /type="radio"/);
161
- assert.match(html, /checked=""/);
162
- });
163
-
164
- it("keeps every step named when the words are replaced by icons", () => {
165
- const html = render(true);
166
- assert.match(html, /aria-label="Dots"/);
167
- assert.match(html, /aria-label="Rows"/);
168
- assert.match(html, /aria-label="Detail"/);
169
- });
170
- });
171
-
172
- describe("FreeTimeList", () => {
173
- const stretches: FreeStretch[] = [
174
- {
175
- date: TODAY,
176
- startMinute: 11 * 60 + 30,
177
- endMinute: 16 * 60,
178
- minutes: 270,
179
- wholeDay: false,
180
- },
181
- {
182
- date: "2026-06-12",
183
- startMinute: 8 * 60,
184
- endMinute: 22 * 60,
185
- minutes: 840,
186
- wholeDay: true,
187
- },
188
- ];
189
-
190
- const render = (list: FreeStretch[]) =>
191
- renderToString(
192
- createElement(FreeTimeList, {
193
- stretches: list,
194
- today: TODAY,
195
- onPick: () => {},
196
- }),
197
- );
198
-
199
- it("lists open time as time, with the day it falls on", () => {
200
- const html = words(render(stretches));
201
- assert.match(html, /4h 30m/);
202
- assert.match(html, /today/);
203
- assert.match(html, /Fri 12 Jun/);
204
- });
205
-
206
- it("says the days on screen are full rather than showing nothing", () => {
207
- assert.match(render([]), /Nothing open in the days on screen\./);
208
- });
209
- });
210
-
211
- describe("PositionMap", () => {
212
- const render = () =>
213
- renderToString(
214
- createElement(PositionMap, {
215
- anchorDate: TODAY,
216
- visibleDate: "2026-06-11",
217
- today: TODAY,
218
- dayOf: (date: string) => buildCalendarDay(date, events, TODAY),
219
- onGoTo: () => {},
220
- }),
221
- );
222
-
223
- it("draws the anchor month and the one after it", () => {
224
- const html = render();
225
- assert.match(html, /Jun/);
226
- assert.match(html, /Jul/);
227
- });
228
-
229
- it("marks today and where the strip is parked apart from each other", () => {
230
- const html = render();
231
- assert.match(html, /text-accent/);
232
- assert.match(html, /ring-line-strong/);
233
- });
234
-
235
- it("shows a day's load and flags the ones that clash", () => {
236
- const busy = renderToString(
237
- createElement(PositionMap, {
238
- anchorDate: TODAY,
239
- visibleDate: TODAY,
240
- today: TODAY,
241
- dayOf: (date: string) =>
242
- buildCalendarDay(
243
- date,
244
- [...events, event("evt_clash", "Clash", TODAY, "10:30", "11:00")],
245
- TODAY,
246
- ),
247
- onGoTo: () => {},
248
- }),
249
- );
250
- assert.match(busy, /bg-warning/);
251
- });
252
- });
@@ -1,17 +1,6 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react-vite";
2
- import { useState } from "react";
3
- import {
4
- buildCalendarDay,
5
- type FreeStretch,
6
- freeAhead,
7
- readNextUp,
8
- } from "../lib/agenda-time.js";
9
- import {
10
- AgendaDensityControl,
11
- FreeTimeList,
12
- NextUpCard,
13
- PositionMap,
14
- } from "./agenda-panels.js";
2
+ import { buildCalendarDay, readNextUp } from "../lib/agenda-time.js";
3
+ import { NextUpCard } from "./agenda-panels.js";
15
4
  import type {
16
5
  CalendarDescriptor,
17
6
  CalendarEventData,
@@ -105,7 +94,6 @@ const dates = [
105
94
  "2026-06-14",
106
95
  ];
107
96
  const days = dates.map((date) => buildCalendarDay(date, events, TODAY));
108
- const dayOf = (date: string) => buildCalendarDay(date, events, TODAY);
109
97
 
110
98
  const nextUpProps = {
111
99
  calendars,
@@ -147,61 +135,3 @@ export const NextUpTouch: Story = {
147
135
  />
148
136
  ),
149
137
  };
150
-
151
- /** Three readings, not two, and the control never leaves the screen. */
152
- export const Density: Story = {
153
- render: () => {
154
- const [value, setValue] = useState<"dots" | "pills" | "detail">("pills");
155
- return (
156
- <div className="flex flex-col gap-4">
157
- <AgendaDensityControl value={value} onChange={setValue} />
158
- <AgendaDensityControl value={value} onChange={setValue} icons />
159
- <AgendaDensityControl value={value} onChange={setValue} touch icons />
160
- </div>
161
- );
162
- },
163
- };
164
-
165
- /** Empty time, listed like anything else that is on the calendar. */
166
- export const OpenTime: Story = {
167
- render: () => (
168
- <div className="max-w-80">
169
- <FreeTimeList
170
- stretches={freeAhead(days, NOW, 5)}
171
- today={TODAY}
172
- onPick={() => {}}
173
- />
174
- </div>
175
- ),
176
- };
177
-
178
- /** Nothing open is a sentence, never an empty box. */
179
- export const NoOpenTime: Story = {
180
- render: () => (
181
- <div className="max-w-80">
182
- <FreeTimeList
183
- stretches={[] as FreeStretch[]}
184
- today={TODAY}
185
- onPick={() => {}}
186
- />
187
- </div>
188
- ),
189
- };
190
-
191
- /** A scrollbar with meaning: how full each day is, and where you are parked. */
192
- export const WhereYouAre: Story = {
193
- render: () => {
194
- const [visible, setVisible] = useState("2026-06-11");
195
- return (
196
- <div className="max-w-64">
197
- <PositionMap
198
- anchorDate={TODAY}
199
- visibleDate={visible}
200
- today={TODAY}
201
- dayOf={dayOf}
202
- onGoTo={setVisible}
203
- />
204
- </div>
205
- );
206
- },
207
- };
@@ -1,112 +1,15 @@
1
- /**
2
- * The readings that sit beside the strip.
3
- *
4
- * A wide screen given to a single column of days wastes it as badly as a grid
5
- * wastes a sparse week, so the width goes to the questions the list is good at:
6
- * what is next, where the free time is, and where in the strip you currently
7
- * are. None of them is a second copy of the list — each one answers something
8
- * the rows cannot answer at a glance.
9
- */
10
-
11
- import type { LucideIcon } from "lucide-react";
12
- import {
13
- AlignJustify,
14
- CalendarOff,
15
- Clock,
16
- LayoutList,
17
- MoreHorizontal,
18
- Radio,
19
- Sun,
20
- } from "lucide-react";
21
- import { type ReactNode, useId, useMemo } from "react";
1
+ import { Clock, Radio, Sun } from "lucide-react";
2
+ import { type ReactNode, useMemo } from "react";
22
3
  import {
23
4
  addDays,
24
- DAY_END_MINUTE,
25
- DAY_START_MINUTE,
26
- datesBetween,
27
- type FreeStretch,
28
5
  formatMinute,
29
6
  formatShortDay,
30
7
  formatSpan,
31
8
  type NextUp,
32
- shortMonthLabel,
33
9
  } from "../lib/agenda-time.js";
34
10
  import { calendarColorClasses } from "../lib/calendar-color.js";
35
11
  import { cn } from "../lib/cn.js";
36
- import type { AgendaDensity } from "./agenda-flow.js";
37
- import { segmentClassName } from "./calendar-toolbar.js";
38
- import type {
39
- CalendarColorId,
40
- CalendarDay,
41
- CalendarDescriptor,
42
- } from "./calendar-types.js";
43
-
44
- /* ------------------------------------------------------------------ */
45
- /* Density */
46
- /* ------------------------------------------------------------------ */
47
-
48
- const DENSITY_OPTIONS: {
49
- value: AgendaDensity;
50
- label: string;
51
- Icon: LucideIcon;
52
- }[] = [
53
- { value: "dots", label: "Dots", Icon: MoreHorizontal },
54
- { value: "pills", label: "Rows", Icon: AlignJustify },
55
- { value: "detail", label: "Detail", Icon: LayoutList },
56
- ];
57
-
58
- export interface AgendaDensityControlProps {
59
- value: AgendaDensity;
60
- onChange: (density: AgendaDensity) => void;
61
- /** Where the words do not fit — a phone's bottom bar. */
62
- icons?: boolean;
63
- touch?: boolean;
64
- className?: string;
65
- }
66
-
67
- /**
68
- * Three steps, not two. A list can be read as a month of coloured dots or as a
69
- * stack of cards, and which one is right depends on the day and the person, so
70
- * the control is on screen at every width rather than in a settings page.
71
- */
72
- export function AgendaDensityControl({
73
- value,
74
- onChange,
75
- icons,
76
- touch,
77
- className,
78
- }: AgendaDensityControlProps) {
79
- const group = useId();
80
- return (
81
- <fieldset className={cn("inline-flex items-center gap-0.5", className)}>
82
- <legend className="sr-only">Agenda density</legend>
83
- {DENSITY_OPTIONS.map((option) => (
84
- <label
85
- key={option.value}
86
- aria-label={option.label}
87
- className={cn(
88
- segmentClassName(value === option.value),
89
- touch ? "min-h-11 flex-1 text-sm" : "h-7 text-xs",
90
- )}
91
- >
92
- <input
93
- type="radio"
94
- name={group}
95
- value={option.value}
96
- checked={value === option.value}
97
- onChange={() => onChange(option.value)}
98
- className="sr-only"
99
- />
100
- {icons ? <option.Icon className="size-4" /> : option.label}
101
- </label>
102
- ))}
103
- </fieldset>
104
- );
105
- }
106
-
107
- /* ------------------------------------------------------------------ */
108
- /* What's next */
109
- /* ------------------------------------------------------------------ */
12
+ import type { CalendarColorId, CalendarDescriptor } from "./calendar-types.js";
110
13
 
111
14
  export interface NextUpCardProps {
112
15
  nextUp: NextUp;
@@ -266,156 +169,3 @@ function dayPrefix(date: string, today: string): string {
266
169
  if (date === addDays(today, 1)) return "tomorrow · ";
267
170
  return `${formatShortDay(date)} · `;
268
171
  }
269
-
270
- /* ------------------------------------------------------------------ */
271
- /* Free time */
272
- /* ------------------------------------------------------------------ */
273
-
274
- export interface FreeTimeListProps {
275
- stretches: FreeStretch[];
276
- today: string;
277
- onPick: (stretch: FreeStretch) => void;
278
- touch?: boolean;
279
- }
280
-
281
- /** Empty time, listed like anything else that is on the calendar. */
282
- export function FreeTimeList({
283
- stretches,
284
- today,
285
- onPick,
286
- touch,
287
- }: FreeTimeListProps) {
288
- return (
289
- <section className="flex flex-col gap-1.5">
290
- <Caption icon={<CalendarOff className="size-3" />}>Open time</Caption>
291
- {stretches.length === 0 ? (
292
- <p className="text-xs text-fg-subtle">
293
- Nothing open in the days on screen.
294
- </p>
295
- ) : (
296
- stretches.map((stretch) => (
297
- <button
298
- key={`${stretch.date}_${stretch.startMinute}`}
299
- type="button"
300
- onClick={() => onPick(stretch)}
301
- className={cn(
302
- "flex items-center gap-2 rounded-md border border-line px-2 text-left outline-none transition-colors hover:border-accent hover:text-accent focus-visible:ring-2 focus-visible:ring-ring",
303
- touch ? "min-h-11" : "min-h-8",
304
- )}
305
- >
306
- <span className="text-xs font-medium text-fg">
307
- {formatSpan(stretch.minutes)}
308
- </span>
309
- <span className="min-w-0 flex-1 truncate text-2xs text-fg-subtle">
310
- {stretch.date === today ? "today" : formatShortDay(stretch.date)}{" "}
311
- · {formatMinute(stretch.startMinute)} –{" "}
312
- {formatMinute(stretch.endMinute)}
313
- </span>
314
- </button>
315
- ))
316
- )}
317
- </section>
318
- );
319
- }
320
-
321
- /* ------------------------------------------------------------------ */
322
- /* Where you are in the strip */
323
- /* ------------------------------------------------------------------ */
324
-
325
- export interface PositionMapProps {
326
- /** The month to draw, and the one after it. */
327
- anchorDate: string;
328
- visibleDate: string;
329
- today: string;
330
- dayOf: (date: string) => CalendarDay;
331
- onGoTo: (date: string) => void;
332
- className?: string;
333
- }
334
-
335
- /**
336
- * Two months as a heat strip: how full each day is, and where the strip is
337
- * currently parked. It is a scrollbar with meaning — the empty days are as
338
- * legible as the full ones, which is the whole argument in miniature.
339
- */
340
- export function PositionMap({
341
- anchorDate,
342
- visibleDate,
343
- today,
344
- dayOf,
345
- onGoTo,
346
- className,
347
- }: PositionMapProps) {
348
- const months = [
349
- monthStart(anchorDate),
350
- monthStart(addDays(monthEnd(anchorDate), 1)),
351
- ];
352
- const span = DAY_END_MINUTE - DAY_START_MINUTE;
353
-
354
- return (
355
- <div className={cn("flex flex-col gap-3", className)}>
356
- {months.map((first) => (
357
- <section key={first} className="flex flex-col gap-1">
358
- <h3 className="px-row-inset text-2xs font-semibold uppercase tracking-wider text-fg-subtle">
359
- {shortMonthLabel(first)}
360
- </h3>
361
- <div className="grid grid-cols-7 gap-0.5 px-row-inset">
362
- {leadingBlanks(first).map((key) => (
363
- <span key={key} />
364
- ))}
365
- {datesBetween(first, monthEnd(first)).map((date) => {
366
- const day = dayOf(date);
367
- const fill = Math.min(1, day.busyMinutes / span);
368
- return (
369
- <button
370
- key={date}
371
- type="button"
372
- onClick={() => onGoTo(date)}
373
- className={cn(
374
- "relative flex h-6 items-center justify-center rounded-sm text-2xs tabular-nums outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",
375
- date === visibleDate
376
- ? "bg-surface-raised font-semibold text-fg ring-1 ring-line-strong"
377
- : "text-fg-muted hover:bg-surface-sunken",
378
- date === today && "font-semibold text-accent",
379
- )}
380
- >
381
- {Number(date.slice(8))}
382
- {fill > 0 && (
383
- <span
384
- aria-hidden
385
- className="absolute inset-x-1 bottom-0.5 h-0.5 rounded-full bg-fg-subtle"
386
- style={{ opacity: 0.35 + fill * 0.65 }}
387
- />
388
- )}
389
- {day.conflicts.length > 0 && (
390
- <span
391
- aria-hidden
392
- className="absolute right-0.5 top-0.5 size-1 rounded-full bg-warning"
393
- />
394
- )}
395
- </button>
396
- );
397
- })}
398
- </div>
399
- </section>
400
- ))}
401
- </div>
402
- );
403
- }
404
-
405
- function monthStart(date: string): string {
406
- return `${date.slice(0, 8)}01`;
407
- }
408
-
409
- function monthEnd(date: string): string {
410
- const [year, month] = date.split("-").map(Number);
411
- const last = new Date(Date.UTC(year, month, 0));
412
- return last.toISOString().slice(0, 10);
413
- }
414
-
415
- /** Monday-first padding cells before the first of the month. */
416
- function leadingBlanks(first: string): string[] {
417
- const [year, month, day] = first.split("-").map(Number);
418
- const weekday = new Date(year, month - 1, day).getDay();
419
- const count = (weekday + 6) % 7;
420
- return Array.from({ length: count }, (_, index) => `blank_${first}_${index}`);
421
- }
@@ -148,6 +148,7 @@ describe("CalendarInviteCard", () => {
148
148
  return upTo.slice(upTo.lastIndexOf("<button"));
149
149
  };
150
150
  assert.match(before("Add to calendar"), /disabled=""/);
151
+ assert.match(before("Maybe"), /disabled=""/);
151
152
  assert.doesNotMatch(before("Decline"), /disabled=""/);
152
153
  assert.doesNotMatch(before("Stop offering"), /disabled=""/);
153
154
  });
@@ -75,6 +75,11 @@ export const AlreadyOnTheCalendar: Story = {
75
75
  args: { ...base, rsvp: "accepted", clashes: [] },
76
76
  };
77
77
 
78
+ /** Answered maybe. On the calendar as tentative, and the organiser was not told. */
79
+ export const AnsweredMaybe: Story = {
80
+ args: { ...base, rsvp: "tentative", clashes: [] },
81
+ };
82
+
78
83
  /** Declined, with the way back to offering other times still open. */
79
84
  export const Declined: Story = {
80
85
  args: { ...base, rsvp: "declined", clashes: [] },
@@ -78,7 +78,7 @@ export interface CalendarInviteCardProps {
78
78
  reportHref?: string;
79
79
  /**
80
80
  * Why nothing can be written to a calendar yet, and the way to fix it. Set,
81
- * it holds Add and Remove; the answers that write nothing stay live.
81
+ * it holds Add, Maybe and Remove; the answers that write nothing stay live.
82
82
  */
83
83
  addBlocked?: ReactNode;
84
84
  touch?: boolean;
@@ -271,7 +271,7 @@ export function CalendarInviteCard({
271
271
  variant="secondary"
272
272
  size={touch ? "md" : "sm"}
273
273
  onClick={onTentative}
274
- disabled={busy}
274
+ disabled={busy || addBlocked !== undefined}
275
275
  className={cn(touch && "min-h-11 flex-1")}
276
276
  >
277
277
  Maybe
@@ -129,56 +129,6 @@ export interface CalendarSlotPick {
129
129
  allDay: boolean;
130
130
  }
131
131
 
132
- /** One reading of a phrase the parser could not settle on its own. */
133
- export interface PhraseChoiceOption {
134
- id: string;
135
- label: string;
136
- /** Empty leaves the reading from the rest of the sentence alone. */
137
- date: string;
138
- startTime: string;
139
- }
140
-
141
- export interface PhraseChoice {
142
- id: string;
143
- question: string;
144
- /** The words the question is about. */
145
- source: string;
146
- options: PhraseChoiceOption[];
147
- chosenId: string;
148
- }
149
-
150
- /**
151
- * What a reader made of a typed sentence, with the words each reading came
152
- * from. Every field is presentational: the composer renders it and never parses
153
- * anything itself, so a parser can be swapped without touching the surface.
154
- */
155
- export interface AgendaParse {
156
- title: string;
157
- date: string;
158
- dateText: string;
159
- startTime: string;
160
- startTimeText: string;
161
- endTime: string;
162
- durationMinutes: number;
163
- durationText: string;
164
- attendees: string[];
165
- attendeesText: string;
166
- location: string;
167
- locationText: string;
168
- /** Human-readable rule, empty for a one-off. */
169
- repeat: string;
170
- repeatText: string;
171
- /** Defaults the reader applied on its own authority. */
172
- assumptions: string[];
173
- /** What the sentence never said. */
174
- unresolved: string[];
175
- /** What the sentence said two ways. */
176
- choices: PhraseChoice[];
177
- }
178
-
179
- /** Choice id → option id, as answered by the person typing. */
180
- export type ChoicePicks = Readonly<Record<string, string>>;
181
-
182
132
  /**
183
133
  * One clock a zoneless time could be on. Present only when the source genuinely
184
134
  * did not say which, and the reader is the one who settles it.
@@ -36,7 +36,7 @@ import { IntelligencePanel } from "./intelligence-panel.js";
36
36
  * sends no reply, so the card says so where the press happens.
37
37
  */
38
38
  const meta: Meta = {
39
- title: "Design System/Calendar/Intelligence panel calendar tab",
39
+ title: "Playground/Shipped/Mail/IntelligencePanel calendar tab",
40
40
  parameters: { layout: "centered" },
41
41
  };
42
42
  export default meta;
@@ -110,6 +110,10 @@ function PanelDemo({
110
110
  selectedEventId,
111
111
  actions: {
112
112
  onAddInvite: () => setRsvp("accepted"),
113
+ onTentativeInvite:
114
+ calendar.invite?.invite.state === "cancelled"
115
+ ? undefined
116
+ : () => setRsvp("tentative"),
113
117
  onDeclineInvite: () => setRsvp("declined"),
114
118
  onReopenInvite:
115
119
  calendar.invite?.invite.state === "cancelled"
@@ -319,7 +323,19 @@ export const Declined = rail(KICKOFF, organiserSender, {
319
323
  });
320
324
 
321
325
  /**
322
- * No calendar to write to yet. Adding waits for one, with the way to make it;
326
+ * Answered maybe. The event is on the calendar as tentative, and the organiser
327
+ * was not told.
328
+ */
329
+ export const AnsweredMaybe = rail(KICKOFF, organiserSender, {
330
+ ...inviteWithClash,
331
+ invite: inviteWithClash.invite && {
332
+ ...inviteWithClash.invite,
333
+ rsvp: "tentative",
334
+ },
335
+ });
336
+
337
+ /**
338
+ * No calendar to write to yet. Adding and maybe wait for one, with the way to make it;
323
339
  * declining and muting write nothing to a calendar and stay live.
324
340
  */
325
341
  export const NoCalendarYet = rail(KICKOFF, organiserSender, {