@remit/ui 0.0.163 → 0.0.165
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/calendar-clash-strip.render.test.ts +51 -0
- package/src/components/calendar-clash-strip.stories.tsx +56 -0
- package/src/components/calendar-clash-strip.tsx +64 -0
- package/src/components/calendar-invite-card.render.test.ts +110 -0
- package/src/components/calendar-invite-card.stories.tsx +132 -0
- package/src/components/calendar-invite-card.tsx +288 -0
- package/src/components/calendar-list.stories.tsx +78 -0
- package/src/components/calendar-parse-badge.render.test.ts +40 -0
- package/src/components/calendar-parse-badge.stories.tsx +46 -0
- package/src/components/calendar-parse-badge.tsx +59 -0
- package/src/components/calendar-slot-offers.render.test.ts +67 -0
- package/src/components/calendar-slot-offers.stories.tsx +79 -0
- package/src/components/calendar-slot-offers.tsx +67 -0
- package/src/components/calendar-suggestion-deck.render.test.ts +69 -0
- package/src/components/calendar-suggestion-deck.stories.tsx +165 -0
- package/src/components/calendar-suggestion-deck.tsx +116 -0
- package/src/components/calendar-toolbar.stories.tsx +73 -0
- package/src/components/calendar-types.ts +57 -0
- package/src/components/event-suggestion-card.tsx +8 -1
- package/src/components/intelligence-calendar-fixtures.ts +384 -0
- package/src/components/intelligence-calendar.deck-zone-gate.test.ts +142 -0
- package/src/components/intelligence-calendar.render.test.ts +122 -0
- package/src/components/intelligence-calendar.tsx +288 -0
- package/src/components/intelligence-panel-calendar.stories.tsx +401 -0
- package/src/components/intelligence-panel.render.test.ts +64 -1
- package/src/components/intelligence-panel.tab-strip.test.ts +163 -0
- package/src/components/intelligence-panel.tsx +239 -174
- package/src/components/intelligence-section.tsx +24 -0
- package/src/index.ts +40 -0
package/package.json
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
import { renderToString } from "react-dom/server";
|
|
5
|
+
import { CalendarClashStrip } from "./calendar-clash-strip.js";
|
|
6
|
+
import type { CalendarClash } from "./calendar-types.js";
|
|
7
|
+
|
|
8
|
+
const dentist: CalendarClash = {
|
|
9
|
+
id: "evt_dentist",
|
|
10
|
+
label: "Dentist · 14:30 – 15:15 · Personal (matthijs@)",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const planning: CalendarClash = {
|
|
14
|
+
id: "evt_planning",
|
|
15
|
+
label: "Sprint planning · 14:00 – 15:00 · Work (work@)",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const render = (clashes: CalendarClash[], clearText?: string) =>
|
|
19
|
+
renderToString(createElement(CalendarClashStrip, { clashes, clearText }));
|
|
20
|
+
|
|
21
|
+
describe("CalendarClashStrip", () => {
|
|
22
|
+
it("says the span is clear rather than rendering nothing", () => {
|
|
23
|
+
const html = render([]);
|
|
24
|
+
assert.match(html, /Nothing else is booked over it/);
|
|
25
|
+
assert.match(html, /text-positive/);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("takes the caller's words for the clear case", () => {
|
|
29
|
+
assert.match(
|
|
30
|
+
render([], "Thursday afternoon is empty from 15:15."),
|
|
31
|
+
/empty from 15:15/,
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("names every clash, with the calendar it came from", () => {
|
|
36
|
+
const html = render([dentist, planning]);
|
|
37
|
+
assert.match(html, /Dentist/);
|
|
38
|
+
assert.match(html, /Sprint planning/);
|
|
39
|
+
assert.match(html, /Personal \(matthijs@\)/);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("counts the collisions rather than leaving the tally to the eye", () => {
|
|
43
|
+
assert.match(render([dentist]), /clashes with something/);
|
|
44
|
+
assert.match(render([dentist, planning]), /clashes with 2 things/);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("draws a collision as danger and a clear span as neither", () => {
|
|
48
|
+
assert.match(render([dentist]), /bg-danger-soft/);
|
|
49
|
+
assert.doesNotMatch(render([]), /danger/);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { CalendarClashStrip } from "./calendar-clash-strip.js";
|
|
3
|
+
import type { CalendarClash } from "./calendar-types.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The cost of saying yes, drawn before the answer. The clear case is drawn too:
|
|
7
|
+
* an empty space where the check should be reads as "not checked".
|
|
8
|
+
*/
|
|
9
|
+
const meta: Meta<typeof CalendarClashStrip> = {
|
|
10
|
+
title: "Calendar/Clash strip",
|
|
11
|
+
component: CalendarClashStrip,
|
|
12
|
+
parameters: { layout: "padded" },
|
|
13
|
+
decorators: [
|
|
14
|
+
(Story) => (
|
|
15
|
+
<div className="max-w-sm">
|
|
16
|
+
<Story />
|
|
17
|
+
</div>
|
|
18
|
+
),
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
export default meta;
|
|
22
|
+
|
|
23
|
+
type Story = StoryObj<typeof CalendarClashStrip>;
|
|
24
|
+
|
|
25
|
+
const dentist: CalendarClash = {
|
|
26
|
+
id: "evt_dentist",
|
|
27
|
+
label: "Dentist · 14:30 – 15:15 · Personal (matthijs@)",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const standup: CalendarClash = {
|
|
31
|
+
id: "evt_standup",
|
|
32
|
+
label: "Sprint planning · 14:00 – 15:00 · Work (work@)",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Nothing booked, said out loud. */
|
|
36
|
+
export const Clear: Story = {
|
|
37
|
+
args: { clashes: [] },
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** One collision, named with the calendar and the account it came from. */
|
|
41
|
+
export const OneClash: Story = {
|
|
42
|
+
args: { clashes: [dentist] },
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** Several, counted in the sentence so the tally is not left to the eye. */
|
|
46
|
+
export const SeveralClashes: Story = {
|
|
47
|
+
args: { clashes: [dentist, standup] },
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** The caller knows which span was checked, so it words the clear case. */
|
|
51
|
+
export const ClearWithItsOwnWords: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
clashes: [],
|
|
54
|
+
clearText: "Thursday afternoon is empty from 15:15.",
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Check, TriangleAlert } from "lucide-react";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import type { CalendarClash } from "./calendar-types.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* What a span would cost, stated before the answer rather than after it. Every
|
|
7
|
+
* mail client offers Accept; none of them can say what saying yes runs into,
|
|
8
|
+
* because none of them owns the calendar the answer lands in. The clear case is
|
|
9
|
+
* drawn too — silence there would read as "not checked".
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export interface CalendarClashStripProps {
|
|
13
|
+
clashes: CalendarClash[];
|
|
14
|
+
/** What the clear case says. The caller knows which span was checked. */
|
|
15
|
+
clearText?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function CalendarClashStrip({
|
|
20
|
+
clashes,
|
|
21
|
+
clearText = "Nothing else is booked over it.",
|
|
22
|
+
className,
|
|
23
|
+
}: CalendarClashStripProps) {
|
|
24
|
+
if (clashes.length === 0)
|
|
25
|
+
return (
|
|
26
|
+
<p
|
|
27
|
+
className={cn(
|
|
28
|
+
"flex items-center gap-2 rounded-md border border-line bg-surface-sunken p-2 text-xs text-fg-muted",
|
|
29
|
+
className,
|
|
30
|
+
)}
|
|
31
|
+
>
|
|
32
|
+
<Check className="size-3.5 shrink-0 text-positive" aria-hidden />
|
|
33
|
+
{clearText}
|
|
34
|
+
</p>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
className={cn(
|
|
40
|
+
"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft p-2",
|
|
41
|
+
className,
|
|
42
|
+
)}
|
|
43
|
+
>
|
|
44
|
+
<TriangleAlert
|
|
45
|
+
className="mt-0.5 size-4 shrink-0 text-danger"
|
|
46
|
+
aria-hidden
|
|
47
|
+
/>
|
|
48
|
+
<div className="min-w-0 flex-1">
|
|
49
|
+
<p className="text-xs font-semibold text-danger">
|
|
50
|
+
{clashes.length === 1
|
|
51
|
+
? "This clashes with something you have already agreed to."
|
|
52
|
+
: `This clashes with ${clashes.length} things you have already agreed to.`}
|
|
53
|
+
</p>
|
|
54
|
+
<ul className="mt-1 flex flex-col gap-0.5">
|
|
55
|
+
{clashes.map((clash) => (
|
|
56
|
+
<li key={clash.id} className="text-xs text-fg">
|
|
57
|
+
{clash.label}
|
|
58
|
+
</li>
|
|
59
|
+
))}
|
|
60
|
+
</ul>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
import { renderToString } from "react-dom/server";
|
|
5
|
+
import {
|
|
6
|
+
CalendarInviteCard,
|
|
7
|
+
type CalendarInviteCardProps,
|
|
8
|
+
} from "./calendar-invite-card.js";
|
|
9
|
+
import {
|
|
10
|
+
dentistClash,
|
|
11
|
+
kickoffInvite,
|
|
12
|
+
} from "./intelligence-calendar-fixtures.js";
|
|
13
|
+
|
|
14
|
+
const base: CalendarInviteCardProps = {
|
|
15
|
+
invite: kickoffInvite,
|
|
16
|
+
whenText: "Thursday 11 June, 14:00 – 15:00",
|
|
17
|
+
calendarName: "Work",
|
|
18
|
+
color: "cal-2",
|
|
19
|
+
clashes: dentistClash,
|
|
20
|
+
rsvp: "noReply",
|
|
21
|
+
onAdd: () => undefined,
|
|
22
|
+
onTentative: () => undefined,
|
|
23
|
+
onDecline: () => undefined,
|
|
24
|
+
onReopen: () => undefined,
|
|
25
|
+
onOfferOtherTimes: () => undefined,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const render = (props: Partial<CalendarInviteCardProps> = {}) =>
|
|
29
|
+
renderToString(createElement(CalendarInviteCard, { ...base, ...props }));
|
|
30
|
+
|
|
31
|
+
describe("CalendarInviteCard", () => {
|
|
32
|
+
it("names the organiser, the calendar and the span", () => {
|
|
33
|
+
const html = render();
|
|
34
|
+
assert.match(html, /Priya Natarajan/);
|
|
35
|
+
assert.match(html, /Work/);
|
|
36
|
+
assert.match(html, /Thursday 11 June, 14:00 – 15:00/);
|
|
37
|
+
assert.match(html, /Billing migration kickoff/);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("states the clash above the button that would accept it", () => {
|
|
41
|
+
const html = render();
|
|
42
|
+
const clash = html.indexOf("Dentist");
|
|
43
|
+
const accept = html.indexOf("Add to calendar");
|
|
44
|
+
assert.notEqual(clash, -1);
|
|
45
|
+
assert.notEqual(accept, -1);
|
|
46
|
+
assert.ok(clash < accept, "the clash must be stated before the answer");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("says which rung of the ladder read the invitation", () => {
|
|
50
|
+
assert.match(render(), /Attached invitation/);
|
|
51
|
+
assert.match(
|
|
52
|
+
render({ invite: { ...kickoffInvite, method: "pattern" } }),
|
|
53
|
+
/Read from the words/,
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("never implies a reply was sent, before or after the answer", () => {
|
|
58
|
+
assert.match(render(), /is not notified/);
|
|
59
|
+
assert.match(render({ rsvp: "accepted" }), /was not notified/);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("counts the guests by what they answered", () => {
|
|
63
|
+
assert.match(render(), /2 coming · 1 maybe · 1 no reply/);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("takes a host's own guest surface instead of the tally", () => {
|
|
67
|
+
const html = render({ guests: createElement("p", null, "Three of four") });
|
|
68
|
+
assert.match(html, /Three of four/);
|
|
69
|
+
assert.doesNotMatch(html, /guests/);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("offers the newer revision rather than an answer to a stale one", () => {
|
|
73
|
+
const html = render({
|
|
74
|
+
invite: { ...kickoffInvite, state: "superseded", sequence: 1 },
|
|
75
|
+
onOpenNewer: () => undefined,
|
|
76
|
+
});
|
|
77
|
+
assert.match(html, /has sent a newer version of this/);
|
|
78
|
+
assert.match(html, /Open the newer invitation/);
|
|
79
|
+
assert.doesNotMatch(html, /Add to calendar/);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("leaves a cancellation on the calendar until the reader acts", () => {
|
|
83
|
+
const html = render({
|
|
84
|
+
invite: { ...kickoffInvite, state: "cancelled", sequence: 2 },
|
|
85
|
+
rsvp: "accepted",
|
|
86
|
+
onRemove: () => undefined,
|
|
87
|
+
});
|
|
88
|
+
assert.match(html, /cancelled this/);
|
|
89
|
+
assert.match(html, /Nothing comes off it until you say so/);
|
|
90
|
+
assert.match(html, /Remove from calendar/);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("drops the clash check for an invitation that is no longer the question", () => {
|
|
94
|
+
assert.doesNotMatch(
|
|
95
|
+
render({ invite: { ...kickoffInvite, state: "superseded" } }),
|
|
96
|
+
/Dentist/,
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("offers other times to someone who has already declined", () => {
|
|
101
|
+
const html = render({ rsvp: "declined" });
|
|
102
|
+
assert.match(html, /You declined/);
|
|
103
|
+
assert.match(html, /Offer other times/);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("gives a thumb targets it can hit", () => {
|
|
107
|
+
assert.match(render({ touch: true }), /min-h-11/);
|
|
108
|
+
assert.doesNotMatch(render(), /min-h-11/);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { CalendarInviteCard } from "./calendar-invite-card.js";
|
|
4
|
+
import type { CalendarInvite, RsvpState } from "./calendar-types.js";
|
|
5
|
+
import {
|
|
6
|
+
dentistClash,
|
|
7
|
+
kickoffInvite,
|
|
8
|
+
} from "./intelligence-calendar-fixtures.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The invitation as the thing it is, rather than an attachment nobody opens.
|
|
12
|
+
* What saying yes runs into is stated above the button, and the card says the
|
|
13
|
+
* organiser hears nothing — this plan sends no reply at all.
|
|
14
|
+
*/
|
|
15
|
+
const meta: Meta<typeof CalendarInviteCard> = {
|
|
16
|
+
title: "Calendar/Invite card",
|
|
17
|
+
component: CalendarInviteCard,
|
|
18
|
+
parameters: { layout: "padded" },
|
|
19
|
+
decorators: [
|
|
20
|
+
(Story) => (
|
|
21
|
+
<div className="max-w-md">
|
|
22
|
+
<Story />
|
|
23
|
+
</div>
|
|
24
|
+
),
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
export default meta;
|
|
28
|
+
|
|
29
|
+
type Story = StoryObj<typeof CalendarInviteCard>;
|
|
30
|
+
|
|
31
|
+
const inert = {
|
|
32
|
+
onAdd: () => undefined,
|
|
33
|
+
onTentative: () => undefined,
|
|
34
|
+
onDecline: () => undefined,
|
|
35
|
+
onReopen: () => undefined,
|
|
36
|
+
onOfferOtherTimes: () => undefined,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const base = {
|
|
40
|
+
invite: kickoffInvite,
|
|
41
|
+
whenText: "Thursday 11 June, 14:00 – 15:00",
|
|
42
|
+
calendarName: "Work",
|
|
43
|
+
color: "cal-2",
|
|
44
|
+
clashes: dentistClash,
|
|
45
|
+
rsvp: "noReply",
|
|
46
|
+
...inert,
|
|
47
|
+
} as const;
|
|
48
|
+
|
|
49
|
+
const superseded: CalendarInvite = {
|
|
50
|
+
...kickoffInvite,
|
|
51
|
+
state: "superseded",
|
|
52
|
+
sequence: 1,
|
|
53
|
+
evidence: "invite.ics · METHOD:REQUEST · SEQUENCE:1",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const cancelled: CalendarInvite = {
|
|
57
|
+
...kickoffInvite,
|
|
58
|
+
state: "cancelled",
|
|
59
|
+
sequence: 2,
|
|
60
|
+
evidence: "cancel.ics · METHOD:CANCEL · STATUS:CANCELLED",
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** The clash stated before the answer, which is the whole point of the card. */
|
|
64
|
+
export const WithAClash: Story = {
|
|
65
|
+
args: base,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/** The same invitation on an empty afternoon. Silence would read as unchecked. */
|
|
69
|
+
export const NothingBooked: Story = {
|
|
70
|
+
args: { ...base, clashes: [] },
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** Answered. The card keeps saying the organiser was never told. */
|
|
74
|
+
export const AlreadyOnTheCalendar: Story = {
|
|
75
|
+
args: { ...base, rsvp: "accepted", clashes: [] },
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** Declined, with the way back to offering other times still open. */
|
|
79
|
+
export const Declined: Story = {
|
|
80
|
+
args: { ...base, rsvp: "declined", clashes: [] },
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** A later message carried a higher SEQUENCE, so this one is not the question. */
|
|
84
|
+
export const OvertakenByANewerRevision: Story = {
|
|
85
|
+
args: { ...base, invite: superseded, onOpenNewer: () => undefined },
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/** Cancelled, and still on the calendar until the reader takes it off. */
|
|
89
|
+
export const Cancelled: Story = {
|
|
90
|
+
args: {
|
|
91
|
+
...base,
|
|
92
|
+
invite: cancelled,
|
|
93
|
+
rsvp: "accepted",
|
|
94
|
+
onRemove: () => undefined,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/** A host with its own guest surface passes it in rather than growing a second. */
|
|
99
|
+
export const WithTheHostsGuestList: Story = {
|
|
100
|
+
args: {
|
|
101
|
+
...base,
|
|
102
|
+
guests: (
|
|
103
|
+
<ul className="flex flex-col gap-0.5 text-xs text-fg-muted">
|
|
104
|
+
<li>Priya Natarajan — organiser</li>
|
|
105
|
+
<li>Marcus Webb — coming</li>
|
|
106
|
+
<li>Dana Okafor — no reply</li>
|
|
107
|
+
</ul>
|
|
108
|
+
),
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** Thumb-sized targets, wrapped so three answers fit a phone. */
|
|
113
|
+
export const Touch: Story = {
|
|
114
|
+
args: { ...base, touch: true },
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/** The card answering for real, so the review is a click-through. */
|
|
118
|
+
export const Answering: Story = {
|
|
119
|
+
render: () => {
|
|
120
|
+
const [rsvp, setRsvp] = useState<RsvpState>("noReply");
|
|
121
|
+
return (
|
|
122
|
+
<CalendarInviteCard
|
|
123
|
+
{...base}
|
|
124
|
+
rsvp={rsvp}
|
|
125
|
+
onAdd={() => setRsvp("accepted")}
|
|
126
|
+
onTentative={() => setRsvp("tentative")}
|
|
127
|
+
onDecline={() => setRsvp("declined")}
|
|
128
|
+
onReopen={() => setRsvp("noReply")}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
},
|
|
132
|
+
};
|