@remit/ui 0.0.222 → 0.0.223

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.
Files changed (200) hide show
  1. package/package.json +12 -3
  2. package/src/components/DropdownMenu.tsx +100 -0
  3. package/src/components/EmptyState.tsx +11 -0
  4. package/src/components/ErrorBanner.render.test.ts +107 -0
  5. package/src/components/ErrorBanner.stories.tsx +132 -0
  6. package/src/components/ErrorBanner.tsx +122 -0
  7. package/src/components/ErrorBannerStack.tsx +34 -0
  8. package/src/components/ErrorState.render.test.ts +82 -0
  9. package/src/components/ErrorState.tsx +80 -0
  10. package/src/components/KeyboardShortcutsModal.tsx +111 -0
  11. package/src/components/account-service-change-dialog.render.test.ts +1 -41
  12. package/src/components/account-service-choice.render.test.ts +0 -26
  13. package/src/components/account-service-toggles.render.test.ts +0 -6
  14. package/src/components/address-display.render.test.ts +1 -38
  15. package/src/components/address-tag.render.test.ts +0 -11
  16. package/src/components/agenda-flow.reach.test.ts +0 -8
  17. package/src/components/agenda-flow.render.test.ts +0 -31
  18. package/src/components/agenda-panels.render.test.ts +0 -5
  19. package/src/components/app-shell-slotted.render.test.ts +0 -118
  20. package/src/components/attachment-list.render.test.ts +41 -24
  21. package/src/components/attachment-list.stories.tsx +67 -0
  22. package/src/components/attachment-list.tsx +112 -35
  23. package/src/components/attendee-row.render.test.ts +0 -41
  24. package/src/components/attention-dot.stories.tsx +46 -0
  25. package/src/components/attention-dot.tsx +23 -0
  26. package/src/components/banner.render.test.ts +0 -7
  27. package/src/components/bottom-sheet.render.test.ts +0 -42
  28. package/src/components/brief-section.render.test.ts +0 -13
  29. package/src/components/brief-sections.keyboard.test.ts +0 -13
  30. package/src/components/brief-sections.render.test.ts +0 -22
  31. package/src/components/calendar-clash-strip.render.test.ts +0 -19
  32. package/src/components/calendar-grid.render.test.ts +0 -79
  33. package/src/components/calendar-invite-card.render.test.ts +0 -19
  34. package/src/components/calendar-list.render.test.ts +0 -21
  35. package/src/components/calendar-slot-offers.render.test.ts +0 -24
  36. package/src/components/calendar-suggestion-deck.render.test.ts +0 -18
  37. package/src/components/calendar-toolbar.render.test.ts +1 -53
  38. package/src/components/category-badge.render.test.ts +1 -24
  39. package/src/components/compose-action-bar.render.test.ts +0 -5
  40. package/src/components/compose-attachments.render.test.ts +0 -38
  41. package/src/components/event-detail.render.test.ts +0 -27
  42. package/src/components/event-editor.render.test.ts +0 -4
  43. package/src/components/event-suggestion-card.render.test.ts +0 -61
  44. package/src/components/event-suggestion-card.zone-gate.test.ts +1 -7
  45. package/src/components/filter-clause-chip.tsx +1 -60
  46. package/src/components/filter-rule-editor.create.test.ts +0 -6
  47. package/src/components/filter-rule-editor.stories.tsx +24 -138
  48. package/src/components/filter-rule-editor.tsx +7 -93
  49. package/src/components/filter-rule.render.test.ts +9 -299
  50. package/src/components/filter-rule.ts +20 -85
  51. package/src/components/filter-sheet.render.test.ts +0 -7
  52. package/src/components/folder-manage-actions.render.test.ts +0 -13
  53. package/src/components/folder-manager.render.test.ts +0 -31
  54. package/src/components/folder-mutation-dialog.render.test.ts +0 -83
  55. package/src/components/folder-rename-dialog.render.test.ts +0 -14
  56. package/src/components/folder-row.render.test.ts +0 -30
  57. package/src/components/folder-sync-state.test.ts +0 -61
  58. package/src/components/folder-tree-picker.create.test.ts +0 -30
  59. package/src/components/folder-tree-picker.render.test.ts +0 -35
  60. package/src/components/intelligence-calendar-fixtures.ts +0 -2
  61. package/src/components/intelligence-calendar.render.test.ts +0 -4
  62. package/src/components/intelligence-panel.render.test.ts +1 -62
  63. package/src/components/intelligence-panel.stories.tsx +0 -76
  64. package/src/components/intelligence-panel.tab-strip.test.ts +0 -1
  65. package/src/components/intelligence-panel.tsx +6 -176
  66. package/src/components/intelligence-toggle.render.test.ts +0 -5
  67. package/src/components/isolated-email-frame.render.test.ts +0 -122
  68. package/src/components/isolated-email-frame.tsx +1 -1
  69. package/src/components/keyboard-hint-bar.render.test.ts +0 -7
  70. package/src/components/label-chip.render.test.ts +0 -28
  71. package/src/components/label-chip.tsx +1 -1
  72. package/src/components/mail-header.render.test.ts +0 -20
  73. package/src/components/mcp-connected-apps-page.stories.tsx +58 -0
  74. package/src/components/mcp-connected-apps-page.tsx +79 -0
  75. package/src/components/mcp-consent-page.stories.tsx +39 -0
  76. package/src/components/mcp-consent-page.tsx +47 -0
  77. package/src/components/mcp-device-page.stories.tsx +57 -0
  78. package/src/components/mcp-device-page.tsx +107 -0
  79. package/src/components/mcp-error-notice.stories.tsx +34 -0
  80. package/src/components/mcp-error-notice.tsx +23 -0
  81. package/src/components/mcp-error-page.stories.tsx +17 -0
  82. package/src/components/mcp-error-page.tsx +15 -0
  83. package/src/components/mcp-fixtures.ts +16 -0
  84. package/src/components/mcp-login-page.stories.tsx +37 -0
  85. package/src/components/mcp-login-page.tsx +58 -0
  86. package/src/components/mcp-page.stories.tsx +27 -0
  87. package/src/components/mcp-page.tsx +35 -0
  88. package/src/components/mcp-permission-list.stories.tsx +21 -0
  89. package/src/components/mcp-permission-list.tsx +22 -0
  90. package/src/components/message-body-view.render.test.ts +0 -21
  91. package/src/components/message-list-pane.brief-filter.test.ts +0 -6
  92. package/src/components/message-list-pane.render.test.ts +0 -54
  93. package/src/components/message-list-state.render.test.ts +0 -84
  94. package/src/components/{quarantine-bug-dialog.tsx → message-report-dialog.tsx} +9 -14
  95. package/src/components/message-row.render.test.ts +1 -98
  96. package/src/components/mobile-message-action-bar.render.test.ts +0 -59
  97. package/src/components/mobile-reading-pane.render.test.ts +0 -48
  98. package/src/components/mobile-search-view.render.test.ts +0 -16
  99. package/src/components/mobile-search-view.stories.tsx +8 -11
  100. package/src/components/mobile-search-view.tsx +1 -1
  101. package/src/components/nav-sidebar.keyboard.test.ts +0 -8
  102. package/src/components/nav-sidebar.render.test.ts +2 -133
  103. package/src/components/new-folder-form.render.test.ts +0 -26
  104. package/src/components/outbox-row.render.test.ts +0 -9
  105. package/src/components/pane-layout.render.test.ts +0 -18
  106. package/src/components/plain-text-editor.mount.test.ts +0 -16
  107. package/src/components/popover-menu.render.test.ts +0 -11
  108. package/src/components/progress-bar.render.test.ts +0 -14
  109. package/src/components/quarantine-report.test.ts +0 -8
  110. package/src/components/quarantine-section.render.test.ts +16 -13
  111. package/src/components/quarantine-section.stories.tsx +11 -8
  112. package/src/components/reading-pane.render.test.ts +2 -106
  113. package/src/components/reading-pane.stories.tsx +3 -0
  114. package/src/components/refresh-button.render.test.ts +0 -9
  115. package/src/components/rescue-from-spam-flow.render.test.ts +0 -24
  116. package/src/components/rich-text-editor.mount.test.ts +0 -19
  117. package/src/components/rich-text-image-node.ts +11 -9
  118. package/src/components/role-appointment-list.render.test.ts +0 -49
  119. package/src/components/role-appointment-prompt.render.test.ts +0 -79
  120. package/src/components/row-actions.render.test.ts +0 -34
  121. package/src/components/search-bar.render.test.ts +0 -44
  122. package/src/components/search-chip-input.render.test.ts +0 -71
  123. package/src/components/search-conversion-notice.stories.tsx +0 -6
  124. package/src/components/search-conversion-notice.tsx +3 -9
  125. package/src/components/search-conversion.render.test.ts +0 -52
  126. package/src/components/search-conversion.ts +2 -18
  127. package/src/components/search-result-row.tsx +5 -26
  128. package/src/components/search-results.render.test.ts +0 -68
  129. package/src/components/search-results.stories.tsx +0 -30
  130. package/src/components/search-results.tsx +1 -1
  131. package/src/components/security-select.render.test.ts +1 -14
  132. package/src/components/selection-top-bar.render.test.ts +0 -180
  133. package/src/components/selection-wizard-fixtures.ts +0 -2
  134. package/src/components/selection-wizard.render.test.ts +7 -212
  135. package/src/components/selection-wizard.stories.tsx +24 -164
  136. package/src/components/selection-wizard.tsx +10 -86
  137. package/src/components/self-update.render.test.ts +0 -113
  138. package/src/components/sender-trust-indicator.render.test.ts +0 -30
  139. package/src/components/shell-top-bar.render.test.ts +0 -31
  140. package/src/components/shell-top-bar.stories.tsx +7 -0
  141. package/src/components/shell-top-bar.tsx +11 -2
  142. package/src/components/slide-panel.render.test.ts +0 -18
  143. package/src/components/suggest-list.render.test.ts +0 -6
  144. package/src/components/swipeable-row.gesture.test.ts +0 -15
  145. package/src/components/swipeable-row.render.test.ts +0 -7
  146. package/src/components/sync-warning-fixtures.ts +22 -0
  147. package/src/components/sync-warning-report.ts +38 -0
  148. package/src/components/sync-warning-row.tsx +51 -0
  149. package/src/components/sync-warning-section.render.test.ts +19 -0
  150. package/src/components/sync-warning-section.stories.tsx +94 -0
  151. package/src/components/sync-warning-section.tsx +56 -0
  152. package/src/components/touch-list-body.render.test.ts +0 -29
  153. package/src/components/wizard.render.test.ts +0 -22
  154. package/src/filter-presets.test.ts +1 -107
  155. package/src/index.ts +40 -30
  156. package/src/lib/compose-language.test.ts +0 -11
  157. package/src/lib/email-render-treatment.test.ts +0 -21
  158. package/src/lib/keymap.test.ts +0 -32
  159. package/src/lib/property-prefill.ts +2 -2
  160. package/src/lib/search-rule.test.ts +0 -4
  161. package/src/lib/search-rule.ts +0 -9
  162. package/src/lib/sender-derivation.ts +3 -5
  163. package/src/lib/use-list-cursor.test.ts +0 -7
  164. package/src/lib/use-list-keyboard.test.ts +0 -14
  165. package/src/lib/use-modal-focus.test.ts +0 -20
  166. package/src/lib/use-selection.hook.test.ts +0 -13
  167. package/src/lib/use-selection.test.ts +0 -101
  168. package/src/lib/wizard-steps.test.ts +18 -79
  169. package/src/lib/wizard-steps.ts +27 -67
  170. package/src/mcp-pages.ts +36 -0
  171. package/src/category-presentation.test.ts +0 -76
  172. package/src/components/account-service-status.render.test.ts +0 -82
  173. package/src/components/app-password-hint.render.test.ts +0 -23
  174. package/src/components/app-top-bar.render.test.ts +0 -59
  175. package/src/components/auth-card.render.test.ts +0 -24
  176. package/src/components/auth-footer.render.test.ts +0 -17
  177. package/src/components/auth-hero.render.test.ts +0 -31
  178. package/src/components/auto-moved-badge.render.test.ts +0 -65
  179. package/src/components/button.render.test.ts +0 -29
  180. package/src/components/calendar-event-chip.render.test.ts +0 -67
  181. package/src/components/calendar-parse-badge.render.test.ts +0 -40
  182. package/src/components/checkbox.render.test.ts +0 -65
  183. package/src/components/compose-form-shell.render.test.ts +0 -106
  184. package/src/components/dialog.render.test.ts +0 -51
  185. package/src/components/field-label.render.test.ts +0 -16
  186. package/src/components/mail-action-toolbar.render.test.ts +0 -43
  187. package/src/components/nav-link-surface.render.test.ts +0 -126
  188. package/src/components/new-folder-action.render.test.ts +0 -44
  189. package/src/components/pane-header.render.test.ts +0 -22
  190. package/src/components/pull-to-refresh.render.test.ts +0 -46
  191. package/src/components/recurrence-scope-prompt.render.test.ts +0 -36
  192. package/src/components/rescue-banner.render.test.ts +0 -32
  193. package/src/components/rescue-candidate-row.render.test.ts +0 -68
  194. package/src/components/search-token-chip.render.test.ts +0 -42
  195. package/src/components/self-update-dot.tsx +0 -32
  196. package/src/components/settings-primitives.render.test.ts +0 -160
  197. package/src/lib/email-layout-clamp.test.ts +0 -139
  198. package/src/lib/label-color.test.ts +0 -25
  199. package/src/lib/semantic-off.ts +0 -20
  200. package/src/stories-viewport-globals.test.ts +0 -77
@@ -4,13 +4,19 @@ import { createElement } from "react";
4
4
  import { renderToString } from "react-dom/server";
5
5
  import { AttachmentList, type AttachmentListProps } from "./attachment-list.js";
6
6
 
7
- const render = (props: AttachmentListProps): string =>
8
- renderToString(createElement(AttachmentList, props));
7
+ const render = (
8
+ props: Omit<AttachmentListProps, "onToggleOpen"> &
9
+ Partial<Pick<AttachmentListProps, "onToggleOpen">>,
10
+ ): string =>
11
+ renderToString(
12
+ createElement(AttachmentList, { onToggleOpen: () => undefined, ...props }),
13
+ );
9
14
 
10
15
  const item = (
11
16
  overrides: Partial<AttachmentListProps["attachments"][number]>,
12
17
  ) => ({
13
18
  attachmentId: "part-1",
19
+ kind: "file" as const,
14
20
  filename: "Quarterly report.pdf",
15
21
  typeLabel: "PDF",
16
22
  sizeOctets: 1024 * 512,
@@ -19,20 +25,6 @@ const item = (
19
25
  });
20
26
 
21
27
  describe("AttachmentList", () => {
22
- it("renders nothing when the message has no attachments", () => {
23
- assert.equal(render({ attachments: [], onDownload: () => undefined }), "");
24
- });
25
-
26
- it("names the file, its type and its size", () => {
27
- const html = render({
28
- attachments: [item({})],
29
- onDownload: () => undefined,
30
- });
31
- assert.match(html, /Quarterly report\.pdf/);
32
- assert.match(html, /PDF/);
33
- assert.match(html, /512 KB/);
34
- });
35
-
36
28
  it("gives every attachment a labelled download control", () => {
37
29
  const html = render({
38
30
  attachments: [
@@ -54,14 +46,6 @@ describe("AttachmentList", () => {
54
46
  assert.match(html, /1 attachment</);
55
47
  });
56
48
 
57
- it("isolates the filename's text direction", () => {
58
- const html = render({
59
- attachments: [item({})],
60
- onDownload: () => undefined,
61
- });
62
- assert.match(html, /<bdi/);
63
- });
64
-
65
49
  it("disables the control while a download is in flight", () => {
66
50
  const html = render({
67
51
  attachments: [item({ download: { status: "downloading" } })],
@@ -117,4 +101,37 @@ describe("AttachmentList", () => {
117
101
  assert.match(html, /carries an attachment, but none of/);
118
102
  assert.match(html, /Attachment</);
119
103
  });
104
+
105
+ it("opens a forwarded message in place and still offers to save it", () => {
106
+ const forwarded = item({
107
+ attachmentId: "part-2",
108
+ kind: "message",
109
+ filename: "forwarded.eml",
110
+ });
111
+ const closed = render({
112
+ attachments: [forwarded],
113
+ onDownload: () => undefined,
114
+ onToggleOpen: () => undefined,
115
+ });
116
+ assert.match(closed, /aria-label="Open forwarded\.eml"/);
117
+ assert.match(closed, /aria-expanded="false"/);
118
+ assert.match(closed, /aria-label="Download forwarded\.eml"/);
119
+ assert.doesNotMatch(closed, /data-testid="forwarded-message"/);
120
+
121
+ const open = render({
122
+ attachments: [forwarded],
123
+ onDownload: () => undefined,
124
+ onToggleOpen: () => undefined,
125
+ opened: {
126
+ attachmentId: "part-2",
127
+ content: createElement("p", null, "Original message body"),
128
+ },
129
+ });
130
+ assert.match(open, /aria-label="Close forwarded\.eml"/);
131
+ assert.match(open, /aria-expanded="true"/);
132
+ assert.match(
133
+ open,
134
+ /data-testid="forwarded-message"[^>]*>.*Original message body/,
135
+ );
136
+ });
120
137
  });
@@ -20,6 +20,7 @@ type Story = StoryObj<typeof AttachmentList>;
20
20
 
21
21
  const report: AttachmentItem = {
22
22
  attachmentId: "part-2",
23
+ kind: "file",
23
24
  filename: "Q3 board pack.pdf",
24
25
  typeLabel: "PDF",
25
26
  sizeOctets: 2_411_724,
@@ -28,12 +29,46 @@ const report: AttachmentItem = {
28
29
 
29
30
  const sitePlan: AttachmentItem = {
30
31
  attachmentId: "part-3",
32
+ kind: "file",
31
33
  filename: "site-plan.png",
32
34
  typeLabel: "PNG",
33
35
  sizeOctets: 486_120,
34
36
  download: { status: "idle" },
35
37
  };
36
38
 
39
+ const forwarded: AttachmentItem = {
40
+ attachmentId: "part-9",
41
+ kind: "message",
42
+ filename: "forwarded.eml",
43
+ typeLabel: "MESSAGE",
44
+ sizeOctets: 617,
45
+ download: { status: "idle" },
46
+ };
47
+
48
+ const innerPdf: AttachmentItem = {
49
+ attachmentId: "part-9-2",
50
+ kind: "file",
51
+ filename: "original.pdf",
52
+ typeLabel: "PDF",
53
+ sizeOctets: 33,
54
+ download: { status: "idle" },
55
+ };
56
+
57
+ /**
58
+ * Stands in for the app's body renderer: the forwarded message's own body,
59
+ * and its own attachment list underneath.
60
+ */
61
+ const ForwardedBody = () => (
62
+ <div className="space-y-3 text-sm text-fg">
63
+ <p>Original message body before forwarding.</p>
64
+ <AttachmentList
65
+ attachments={[innerPdf]}
66
+ onDownload={() => {}}
67
+ onToggleOpen={() => {}}
68
+ />
69
+ </div>
70
+ );
71
+
37
72
  /** How long the app's own fetch takes on a small attachment, near enough. */
38
73
  const DOWNLOAD_MS = 900;
39
74
 
@@ -46,11 +81,14 @@ const DOWNLOAD_MS = 900;
46
81
  const Harness = ({
47
82
  attachments,
48
83
  hasUnlistedAttachment,
84
+ initiallyOpen = null,
49
85
  }: {
50
86
  attachments: readonly AttachmentItem[];
51
87
  hasUnlistedAttachment?: boolean;
88
+ initiallyOpen?: string | null;
52
89
  }) => {
53
90
  const [rows, setRows] = useState<readonly AttachmentItem[]>(attachments);
91
+ const [openId, setOpenId] = useState<string | null>(initiallyOpen);
54
92
 
55
93
  const setDownload = (attachmentId: string, item: AttachmentItem) =>
56
94
  setRows((current) =>
@@ -72,6 +110,14 @@ const Harness = ({
72
110
  attachments={rows}
73
111
  onDownload={download}
74
112
  hasUnlistedAttachment={hasUnlistedAttachment}
113
+ onToggleOpen={(attachmentId) =>
114
+ setOpenId((current) => (current === attachmentId ? null : attachmentId))
115
+ }
116
+ opened={
117
+ openId === null
118
+ ? undefined
119
+ : { attachmentId: openId, content: <ForwardedBody /> }
120
+ }
75
121
  />
76
122
  );
77
123
  };
@@ -88,6 +134,7 @@ export const SeveralAttachments: Story = {
88
134
  sitePlan,
89
135
  {
90
136
  attachmentId: "part-4",
137
+ kind: "file",
91
138
  filename: "notes.txt",
92
139
  typeLabel: "PLAIN",
93
140
  sizeOctets: 812,
@@ -95,6 +142,7 @@ export const SeveralAttachments: Story = {
95
142
  },
96
143
  {
97
144
  attachmentId: "part-5",
145
+ kind: "file",
98
146
  filename: "archive",
99
147
  typeLabel: "FILE",
100
148
  sizeOctets: 1024 ** 3 + 1024 ** 2 * 200,
@@ -156,6 +204,7 @@ export const HostileFilename: Story = {
156
204
  attachments={[
157
205
  {
158
206
  attachmentId: "part-6",
207
+ kind: "file",
159
208
  filename: "passwd",
160
209
  typeLabel: "FILE",
161
210
  sizeOctets: 3_120,
@@ -163,6 +212,7 @@ export const HostileFilename: Story = {
163
212
  },
164
213
  {
165
214
  attachmentId: "part-7",
215
+ kind: "file",
166
216
  filename: "invoicegnp.exe",
167
217
  typeLabel: "FILE",
168
218
  sizeOctets: 118_400,
@@ -170,6 +220,7 @@ export const HostileFilename: Story = {
170
220
  },
171
221
  {
172
222
  attachmentId: "part-8",
223
+ kind: "file",
173
224
  filename: `${"long-name-".repeat(11)}report.pdf`,
174
225
  typeLabel: "PDF",
175
226
  sizeOctets: 44_000,
@@ -188,3 +239,19 @@ export const HostileFilename: Story = {
188
239
  export const UnlistedAttachment: Story = {
189
240
  render: () => <Harness attachments={[]} hasUnlistedAttachment />,
190
241
  };
242
+
243
+ /**
244
+ * A forwarded message, carried whole (message/rfc822). It is listed under its
245
+ * own name and opens in place; the PDF it carries belongs to it, so it is not
246
+ * a row of the outer list.
247
+ */
248
+ export const ForwardedMessage: Story = {
249
+ render: () => <Harness attachments={[forwarded, report]} />,
250
+ };
251
+
252
+ /** The forwarded message opened: its body and its own attachment list. */
253
+ export const ForwardedMessageOpen: Story = {
254
+ render: () => (
255
+ <Harness attachments={[forwarded, report]} initiallyOpen="part-9" />
256
+ ),
257
+ };
@@ -1,4 +1,13 @@
1
- import { AlertCircle, Download, Loader2, Paperclip } from "lucide-react";
1
+ import {
2
+ AlertCircle,
3
+ ChevronDown,
4
+ ChevronRight,
5
+ Download,
6
+ Loader2,
7
+ Mail,
8
+ Paperclip,
9
+ } from "lucide-react";
10
+ import type { ReactNode } from "react";
2
11
  import { formatByteSize } from "../lib/attachment-file.js";
3
12
  import { cn } from "../lib/cn.js";
4
13
 
@@ -7,8 +16,15 @@ export type AttachmentDownloadState =
7
16
  | { status: "downloading" }
8
17
  | { status: "failed"; title: string; detail: string; reportUrl?: string };
9
18
 
19
+ /**
20
+ * `message` is a forwarded message carried whole (message/rfc822): it opens
21
+ * in place as well as saving as an `.eml`.
22
+ */
23
+ export type AttachmentKind = "file" | "message";
24
+
10
25
  export interface AttachmentItem {
11
26
  attachmentId: string;
27
+ kind: AttachmentKind;
12
28
  /**
13
29
  * The name shown and the name saved — one string for both, already reduced
14
30
  * by `sanitizeAttachmentFilename`. Anything that displays a different name
@@ -31,6 +47,10 @@ export interface AttachmentListProps {
31
47
  * in the list.
32
48
  */
33
49
  hasUnlistedAttachment?: boolean;
50
+ /** Opens or closes a `message` row. */
51
+ onToggleOpen: (attachmentId: string) => void;
52
+ /** The open `message` row and the forwarded message rendered under it. */
53
+ opened?: { attachmentId: string; content: ReactNode };
34
54
  className?: string;
35
55
  }
36
56
 
@@ -77,6 +97,34 @@ function DownloadFailure({
77
97
  </div>
78
98
  );
79
99
  }
100
+ function AttachmentLabel({ attachment }: { attachment: AttachmentItem }) {
101
+ return (
102
+ <span className="min-w-0 flex-1">
103
+ {/* <bdi> isolates the name's own direction so a right-to-left
104
+ filename cannot reorder the label around it. */}
105
+ <bdi
106
+ className="block truncate text-sm text-fg"
107
+ title={attachment.filename}
108
+ >
109
+ {attachment.filename}
110
+ </bdi>
111
+ <span className="block truncate text-2xs text-fg-subtle">
112
+ {attachment.typeLabel} · {formatByteSize(attachment.sizeOctets)}
113
+ </span>
114
+ </span>
115
+ );
116
+ }
117
+
118
+ function DownloadGlyph({ isDownloading }: { isDownloading: boolean }) {
119
+ return isDownloading ? (
120
+ <Loader2
121
+ className="size-4 shrink-0 animate-spin text-fg-subtle"
122
+ aria-hidden
123
+ />
124
+ ) : (
125
+ <Download className="size-4 shrink-0 text-fg-subtle" aria-hidden />
126
+ );
127
+ }
80
128
 
81
129
  /**
82
130
  * The attachments carried by an open message: what each one is, how big it is,
@@ -91,6 +139,8 @@ export function AttachmentList({
91
139
  attachments,
92
140
  onDownload,
93
141
  hasUnlistedAttachment = false,
142
+ onToggleOpen,
143
+ opened,
94
144
  className,
95
145
  }: AttachmentListProps) {
96
146
  if (attachments.length === 0 && !hasUnlistedAttachment) return null;
@@ -114,46 +164,73 @@ export function AttachmentList({
114
164
  <ul className="overflow-hidden rounded-sm border border-line bg-surface">
115
165
  {attachments.map((attachment) => {
116
166
  const isDownloading = attachment.download.status === "downloading";
167
+ const isOpenable = attachment.kind === "message";
168
+ const isOpen =
169
+ isOpenable && opened?.attachmentId === attachment.attachmentId;
170
+ const download = (className: string) => (
171
+ <button
172
+ type="button"
173
+ onClick={() => onDownload(attachment.attachmentId)}
174
+ disabled={isDownloading}
175
+ data-testid="attachment-download"
176
+ aria-label={`Download ${attachment.filename}`}
177
+ className={cn(
178
+ "px-2 py-2 transition-colors hover:bg-surface-sunken disabled:cursor-progress disabled:opacity-60",
179
+ className,
180
+ )}
181
+ >
182
+ {isOpenable ? null : (
183
+ <AttachmentLabel attachment={attachment} />
184
+ )}
185
+ <DownloadGlyph isDownloading={isDownloading} />
186
+ </button>
187
+ );
117
188
  return (
118
189
  <li
119
190
  key={attachment.attachmentId}
120
191
  className="border-t border-line first:border-t-0"
121
192
  >
122
- <button
123
- type="button"
124
- onClick={() => onDownload(attachment.attachmentId)}
125
- disabled={isDownloading}
126
- data-testid="attachment-download"
127
- aria-label={`Download ${attachment.filename}`}
128
- className="flex w-full items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-surface-sunken disabled:cursor-progress disabled:opacity-60"
129
- >
130
- <span className="min-w-0 flex-1">
131
- {/* <bdi> isolates the name's own direction so a
132
- right-to-left filename cannot reorder the label
133
- around it. */}
134
- <bdi
135
- className="block truncate text-sm text-fg"
136
- title={attachment.filename}
193
+ {isOpenable ? (
194
+ <div className="flex items-center">
195
+ <button
196
+ type="button"
197
+ onClick={() => onToggleOpen(attachment.attachmentId)}
198
+ aria-expanded={isOpen}
199
+ data-testid="attachment-open"
200
+ aria-label={`${isOpen ? "Close" : "Open"} ${attachment.filename}`}
201
+ className="flex min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-surface-sunken"
137
202
  >
138
- {attachment.filename}
139
- </bdi>
140
- <span className="block truncate text-2xs text-fg-subtle">
141
- {attachment.typeLabel} ·{" "}
142
- {formatByteSize(attachment.sizeOctets)}
143
- </span>
144
- </span>
145
- {isDownloading ? (
146
- <Loader2
147
- className="size-4 shrink-0 animate-spin text-fg-subtle"
148
- aria-hidden
149
- />
150
- ) : (
151
- <Download
152
- className="size-4 shrink-0 text-fg-subtle"
153
- aria-hidden
154
- />
155
- )}
156
- </button>
203
+ {isOpen ? (
204
+ <ChevronDown
205
+ className="size-4 shrink-0 text-fg-subtle"
206
+ aria-hidden
207
+ />
208
+ ) : (
209
+ <ChevronRight
210
+ className="size-4 shrink-0 text-fg-subtle"
211
+ aria-hidden
212
+ />
213
+ )}
214
+ <Mail
215
+ className="size-4 shrink-0 text-fg-subtle"
216
+ aria-hidden
217
+ />
218
+ <AttachmentLabel attachment={attachment} />
219
+ </button>
220
+ {download("shrink-0")}
221
+ </div>
222
+ ) : (
223
+ download("flex w-full items-center gap-2 text-left")
224
+ )}
225
+ {isOpen && opened && (
226
+ <section
227
+ aria-label={`Forwarded message ${attachment.filename}`}
228
+ data-testid="forwarded-message"
229
+ className="border-t border-line px-3 py-3"
230
+ >
231
+ {opened.content}
232
+ </section>
233
+ )}
157
234
  {attachment.download.status === "failed" && (
158
235
  <DownloadFailure
159
236
  state={attachment.download}
@@ -55,18 +55,6 @@ describe("AttendeeRow", () => {
55
55
  assert.doesNotMatch(html, /Organiser/);
56
56
  });
57
57
 
58
- it("renders exactly what it always did for a caller with nothing to open", () => {
59
- const html = renderToString(
60
- createElement(AttendeeRow, { attendee: attendees[1] }),
61
- );
62
- assert.match(html, /^<div class="flex min-h-9 items-center gap-2\.5">/);
63
- assert.match(html, /<span class="min-w-0 flex-1">/);
64
- assert.doesNotMatch(
65
- html,
66
- /<button|aria-expanded|w-full|text-left|relative/,
67
- );
68
- });
69
-
70
58
  it("becomes a control where a name leads somewhere", () => {
71
59
  const html = renderToString(
72
60
  createElement(AttendeeRow, {
@@ -88,18 +76,6 @@ describe("AttendeeRow", () => {
88
76
  );
89
77
  assert.match(html, /aria-expanded="true"/);
90
78
  });
91
-
92
- it("gives a thumb a row it can hit", () => {
93
- const html = renderToString(
94
- createElement(AttendeeRow, {
95
- attendee: attendees[0],
96
- onActivate: () => undefined,
97
- touch: true,
98
- }),
99
- );
100
- assert.match(html, /min-h-11/);
101
- assert.doesNotMatch(html, /min-h-9/);
102
- });
103
79
  });
104
80
 
105
81
  describe("AttendeeList", () => {
@@ -110,23 +86,6 @@ describe("AttendeeList", () => {
110
86
  assert.match(html, /1 not coming/);
111
87
  });
112
88
 
113
- it("renders nothing when nobody is invited", () => {
114
- assert.equal(
115
- renderToString(createElement(AttendeeList, { attendees: [] })),
116
- "",
117
- );
118
- });
119
-
120
- it("leaves the markup it always had when nothing can be opened", () => {
121
- const html = renderToString(createElement(AttendeeList, { attendees }));
122
- assert.doesNotMatch(html, /<button|aria-expanded|w-full/);
123
- assert.doesNotMatch(html, /<div>/);
124
- assert.equal(
125
- html.match(/<div class="flex min-h-9 items-center gap-2\.5">/g)?.length,
126
- attendees.length,
127
- );
128
- });
129
-
130
89
  it("makes every row a control when a guest can be opened", () => {
131
90
  const html = renderToString(
132
91
  createElement(AttendeeList, { attendees, onActivate: () => undefined }),
@@ -0,0 +1,46 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { Settings, TriangleAlert, Wrench } from "lucide-react";
3
+ import { AttentionDot } from "./attention-dot.js";
4
+
5
+ const meta: Meta<typeof AttentionDot> = {
6
+ title: "Design System/Settings/AttentionDot",
7
+ component: AttentionDot,
8
+ parameters: { layout: "centered" },
9
+ };
10
+ export default meta;
11
+
12
+ type Story = StoryObj<typeof AttentionDot>;
13
+
14
+ export const SyncWarnings: Story = {
15
+ args: {
16
+ label: "Sync warnings",
17
+ children: <Settings className="size-4" />,
18
+ },
19
+ };
20
+
21
+ export const WarningsNavItem: Story = {
22
+ args: {
23
+ label: "Sync warnings",
24
+ children: <TriangleAlert className="size-4" />,
25
+ },
26
+ };
27
+
28
+ export const ReadFailed: Story = {
29
+ args: {
30
+ label: "Warnings could not be read",
31
+ children: <Settings className="size-4" />,
32
+ },
33
+ };
34
+
35
+ export const UpdateAvailable: Story = {
36
+ args: {
37
+ label: "Update available",
38
+ children: <Wrench className="size-4" />,
39
+ },
40
+ };
41
+
42
+ export const Hidden: Story = {
43
+ args: {
44
+ children: <Settings className="size-4" />,
45
+ },
46
+ };
@@ -0,0 +1,23 @@
1
+ import type { ReactNode } from "react";
2
+
3
+ export interface AttentionDotProps {
4
+ children?: ReactNode;
5
+ label?: string;
6
+ }
7
+
8
+ export function AttentionDot({ children, label }: AttentionDotProps) {
9
+ return (
10
+ <span className="relative inline-flex">
11
+ {children}
12
+ {label !== undefined && (
13
+ <>
14
+ <span
15
+ data-testid="attention-dot"
16
+ className="absolute -right-1 -top-1 size-2 rounded-full bg-accent-2"
17
+ />
18
+ <span className="sr-only">{label}</span>
19
+ </>
20
+ )}
21
+ </span>
22
+ );
23
+ }
@@ -13,13 +13,6 @@ describe("Banner", () => {
13
13
  assert.match(html, /heads up/);
14
14
  });
15
15
 
16
- it("applies the warning tone classes", () => {
17
- const html = renderToString(
18
- createElement(Banner, { tone: "warning" }, "x"),
19
- );
20
- assert.match(html, /text-warning/);
21
- });
22
-
23
16
  it("renders a dismiss button only when onDismiss is supplied", () => {
24
17
  const withDismiss = renderToString(
25
18
  createElement(Banner, { tone: "info", onDismiss: () => undefined }, "x"),
@@ -7,21 +7,6 @@ import { BottomSheet } from "./bottom-sheet.js";
7
7
  const noop = () => {};
8
8
 
9
9
  describe("BottomSheet", () => {
10
- it("renders its children and a drag-to-dismiss grabber when open", () => {
11
- const html = renderToString(
12
- createElement(BottomSheet, {
13
- open: true,
14
- onClose: noop,
15
- label: "Sheet",
16
- // biome-ignore lint/correctness/noChildrenProp: React 19 types require children in props object when using createElement
17
- children: "Sheet body",
18
- }),
19
- );
20
- assert.match(html, /Sheet body/);
21
- assert.match(html, /role="slider"/);
22
- assert.match(html, /Drag down to dismiss/);
23
- });
24
-
25
10
  it("takes the grabber out of the tab order, since it has no keyboard operation", () => {
26
11
  const html = renderToString(
27
12
  createElement(BottomSheet, {
@@ -79,31 +64,4 @@ describe("BottomSheet", () => {
79
64
  assert.match(html, /aria-hidden="true"/);
80
65
  assert.match(html, /inert=""/);
81
66
  });
82
-
83
- it("uses the provided dismiss label on the scrim", () => {
84
- const html = renderToString(
85
- createElement(BottomSheet, {
86
- open: true,
87
- onClose: noop,
88
- label: "Sheet",
89
- dismissLabel: "Close rescue",
90
- // biome-ignore lint/correctness/noChildrenProp: React 19 types require children in props object when using createElement
91
- children: "x",
92
- }),
93
- );
94
- assert.match(html, /aria-label="Close rescue"/);
95
- });
96
-
97
- it("renders translated off-screen when closed", () => {
98
- const html = renderToString(
99
- createElement(BottomSheet, {
100
- open: false,
101
- onClose: noop,
102
- label: "Sheet",
103
- // biome-ignore lint/correctness/noChildrenProp: React 19 types require children in props object when using createElement
104
- children: "x",
105
- }),
106
- );
107
- assert.match(html, /pointer-events-none/);
108
- });
109
67
  });
@@ -160,11 +160,6 @@ describe("BriefSection", () => {
160
160
  assert.doesNotMatch(html, /Show \d+ more/);
161
161
  });
162
162
 
163
- it("renders rows by default — sections start expanded", () => {
164
- const html = render({ count: 3 });
165
- assert.strictEqual(rowCount(html), 3);
166
- });
167
-
168
163
  it("keeps the total when the reader collapses the section", () => {
169
164
  const html = render({
170
165
  count: 18,
@@ -221,12 +216,4 @@ describe("BriefSection", () => {
221
216
  );
222
217
  assert.doesNotMatch(html, /No Marketing mail in this brief\./);
223
218
  });
224
-
225
- // D6 / issue #45: unclassified mail is its own section with its own label,
226
- // never folded into Personal.
227
- it("renders the unclassified section under its own label", () => {
228
- const html = render({ count: 2, label: "Unclassified", total: exact(2) });
229
- assert.match(html, /Unclassified/);
230
- assert.doesNotMatch(html, /Personal/);
231
- });
232
219
  });
@@ -142,19 +142,6 @@ describe("BriefSections arrow-key traversal", () => {
142
142
  act(() => pressKey(items[1] as Element, "Home"));
143
143
  assert.equal(document.activeElement, items[0]);
144
144
  });
145
-
146
- it("steps over the section headers between rows", () => {
147
- mount();
148
- const headers = Array.from(
149
- container.querySelectorAll<HTMLElement>("button[aria-expanded]"),
150
- );
151
- assert.ok(headers.length > 0);
152
- const items = rows();
153
-
154
- act(() => items[1]?.focus());
155
- act(() => pressKey(items[1] as Element, "ArrowDown"));
156
- assert.equal(document.activeElement, items[2]);
157
- });
158
145
  });
159
146
 
160
147
  let list: ListKeyboard | undefined;