@rapidmx/web-client 0.6.0 → 0.7.0

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 (79) hide show
  1. package/apps/shared/components/admin/settings/BrandingForm.tsx +398 -385
  2. package/apps/shared/components/admin/settings/EncryptionPolicyForm.tsx +119 -112
  3. package/apps/shared/components/admin/settings/MailboxPolicyForm.tsx +159 -152
  4. package/apps/shared/components/admin/settings/PluginsManager.tsx +1288 -1235
  5. package/apps/shared/components/admin/settings/RetentionPolicyForm.tsx +9 -1
  6. package/apps/shared/components/admin/setup/EscrowSetupStep.tsx +288 -290
  7. package/apps/shared/components/admin/setup/SetupWizard.tsx +443 -416
  8. package/apps/shared/components/layout/AppShell.tsx +288 -288
  9. package/apps/shared/components/mail/ConversationList.tsx +225 -33
  10. package/apps/shared/components/mail/ConversationThreadPane.tsx +434 -216
  11. package/apps/shared/components/mail/MailListToolbar.tsx +265 -0
  12. package/apps/shared/components/mail/MailSelectionBar.tsx +222 -0
  13. package/apps/shared/components/mail/MenuButton.tsx +384 -0
  14. package/apps/shared/components/mail/MessageDetailPane.tsx +280 -215
  15. package/apps/shared/components/mail/MoveToFolderDialog.tsx +263 -0
  16. package/apps/shared/components/mail/compose/ComposeContext.tsx +29 -2
  17. package/apps/shared/components/mail/compose/ComposeWindow.tsx +1700 -1652
  18. package/apps/shared/components/mail/compose/RecipientInput.tsx +356 -0
  19. package/apps/shared/components/mail/compose/RichTextEditor.tsx +38 -3
  20. package/apps/shared/components/mail/compose/quotedBody.ts +100 -0
  21. package/apps/shared/components/mail/compose/recipients.ts +104 -0
  22. package/apps/shared/components/mail/labelMenu.tsx +278 -0
  23. package/apps/shared/components/mail/layout/MailShell.tsx +445 -420
  24. package/apps/shared/components/mail/listPreferences.ts +228 -0
  25. package/apps/shared/components/settings/layout/SettingsShell.tsx +0 -1
  26. package/apps/shared/styles/app.css +28 -5
  27. package/apps/www/index.tsx +1854 -1314
  28. package/apps/www/messages/[uid].tsx +5 -4
  29. package/dist/apps/shared/components/admin/settings/BrandingForm.d.ts +7 -3
  30. package/dist/apps/shared/components/admin/settings/BrandingForm.js +6 -5
  31. package/dist/apps/shared/components/admin/settings/EncryptionPolicyForm.d.ts +4 -1
  32. package/dist/apps/shared/components/admin/settings/EncryptionPolicyForm.js +2 -2
  33. package/dist/apps/shared/components/admin/settings/MailboxPolicyForm.d.ts +4 -1
  34. package/dist/apps/shared/components/admin/settings/MailboxPolicyForm.js +2 -2
  35. package/dist/apps/shared/components/admin/settings/PluginsManager.d.ts +8 -1
  36. package/dist/apps/shared/components/admin/settings/PluginsManager.js +33 -14
  37. package/dist/apps/shared/components/admin/settings/RetentionPolicyForm.d.ts +4 -1
  38. package/dist/apps/shared/components/admin/settings/RetentionPolicyForm.js +2 -2
  39. package/dist/apps/shared/components/admin/setup/EscrowSetupStep.js +1 -1
  40. package/dist/apps/shared/components/admin/setup/SetupWizard.js +14 -10
  41. package/dist/apps/shared/components/mail/ConversationList.d.ts +42 -6
  42. package/dist/apps/shared/components/mail/ConversationList.js +84 -10
  43. package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +52 -13
  44. package/dist/apps/shared/components/mail/ConversationThreadPane.js +217 -60
  45. package/dist/apps/shared/components/mail/MailListToolbar.d.ts +55 -0
  46. package/dist/apps/shared/components/mail/MailListToolbar.js +149 -0
  47. package/dist/apps/shared/components/mail/MailSelectionBar.d.ts +59 -0
  48. package/dist/apps/shared/components/mail/MailSelectionBar.js +48 -0
  49. package/dist/apps/shared/components/mail/MenuButton.d.ts +71 -0
  50. package/dist/apps/shared/components/mail/MenuButton.js +211 -0
  51. package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +27 -19
  52. package/dist/apps/shared/components/mail/MessageDetailPane.js +126 -129
  53. package/dist/apps/shared/components/mail/MoveToFolderDialog.d.ts +57 -0
  54. package/dist/apps/shared/components/mail/MoveToFolderDialog.js +138 -0
  55. package/dist/apps/shared/components/mail/compose/ComposeContext.d.ts +16 -1
  56. package/dist/apps/shared/components/mail/compose/ComposeContext.js +3 -1
  57. package/dist/apps/shared/components/mail/compose/ComposeWindow.js +52 -20
  58. package/dist/apps/shared/components/mail/compose/RecipientInput.d.ts +36 -0
  59. package/dist/apps/shared/components/mail/compose/RecipientInput.js +203 -0
  60. package/dist/apps/shared/components/mail/compose/RichTextEditor.d.ts +10 -1
  61. package/dist/apps/shared/components/mail/compose/RichTextEditor.js +21 -3
  62. package/dist/apps/shared/components/mail/compose/quotedBody.d.ts +37 -0
  63. package/dist/apps/shared/components/mail/compose/quotedBody.js +85 -0
  64. package/dist/apps/shared/components/mail/compose/recipients.d.ts +24 -0
  65. package/dist/apps/shared/components/mail/compose/recipients.js +87 -0
  66. package/dist/apps/shared/components/mail/labelMenu.d.ts +97 -0
  67. package/dist/apps/shared/components/mail/labelMenu.js +134 -0
  68. package/dist/apps/shared/components/mail/layout/MailShell.d.ts +8 -0
  69. package/dist/apps/shared/components/mail/layout/MailShell.js +15 -3
  70. package/dist/apps/shared/components/mail/listPreferences.d.ts +101 -0
  71. package/dist/apps/shared/components/mail/listPreferences.js +186 -0
  72. package/dist/apps/shared/components/settings/layout/SettingsShell.js +0 -1
  73. package/dist/apps/shared/styles/app.css +28 -5
  74. package/dist/apps/www/index.js +506 -112
  75. package/dist/apps/www/messages/[uid].js +2 -3
  76. package/package.json +2 -2
  77. package/apps/www/settings/focused-inbox/index.tsx +0 -150
  78. package/dist/apps/www/settings/focused-inbox/index.d.ts +0 -4
  79. package/dist/apps/www/settings/focused-inbox/index.js +0 -71
@@ -0,0 +1,228 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ /**
6
+ * The mail list's own per-mailbox view preferences - what the Sort and Filter menus and the "Show as
7
+ * conversations" toggle are currently set to - persisted in `localStorage` so reopening the app lands on
8
+ * the arrangement the reader left it in, the way Outlook remembers its own per-folder arrangement.
9
+ *
10
+ * Per device, not synced to the server: this is the same posture `localIndexSizePreference.ts` and
11
+ * react-shared's `idleTimeout.ts` already take, and there is no server-side "mail view settings" record to
12
+ * write to. Keyed by mailbox because a shared mailbox someone triages ("unread only, oldest on top") is a
13
+ * genuinely different working set from their own inbox.
14
+ *
15
+ * Every read falls back to `DEFAULT_MAIL_LIST_PREFERENCES` for a never-configured mailbox, a corrupted or
16
+ * partially-unknown stored value, or a `localStorage` access that throws (private-browsing/storage-blocked
17
+ * contexts) - and every write swallows its own failure, so a blocked store only means the preference
18
+ * doesn't survive a reload.
19
+ */
20
+ import {
21
+ MAX_MESSAGE_LABEL_FILTER,
22
+ MessageListFilter,
23
+ MessageListSort,
24
+ MessageSortOrder,
25
+ } from "@rapidmx/react-shared/mail/mailApi.js";
26
+ import { ConversationSummary } from "@rapidmx/react-shared/mail/conversationsApi.js";
27
+
28
+ const STORAGE_KEY_PREFIX = "rapidmx:mail-list-preferences:";
29
+
30
+ export interface MailListPreferences {
31
+ sortBy: MessageListSort;
32
+ sortOrder: MessageSortOrder;
33
+ filter: MessageListFilter;
34
+ /** Labels the list is narrowed to, applied *alongside* `filter` with OR semantics between them: a
35
+ * message is listed when it carries any one of these. Empty means no label filter at all. Kept per
36
+ * mailbox because a label uid only means anything inside its own mailbox. */
37
+ labelUids: string[];
38
+ /** Outlook's "Show as conversations" - the nested conversation list rather than the flat message list. */
39
+ showAsConversations: boolean;
40
+ }
41
+
42
+ /** How many labels the list may be narrowed to at once. `@rapidmx/restapi` refuses a longer `?labelUids=`
43
+ * with a 400, so a stored selection is trimmed to the cap rather than sent. */
44
+ export const MAX_LABEL_FILTER_UIDS = MAX_MESSAGE_LABEL_FILTER;
45
+
46
+ /**
47
+ * What a mailbox nobody has configured yet opens on: newest received first, no label filter, and - like
48
+ * Outlook's own out-of-the-box arrangement - the Focused half of the Inbox, shown as conversations.
49
+ *
50
+ * Neither of those last two is `listMessages()`'s own default (`all`, and the flat list): they are this
51
+ * client's opinion about what a first-time reader should see, applied only where nothing has been stored
52
+ * (see `getMailListPreferences()`, which keeps a stored `false`/`all` exactly as it was). `focused` also
53
+ * only ever applies in an Inbox - every other folder falls back to `all` in `apps/www/index.tsx`, which is
54
+ * what `MessageListFilter`'s own "Inbox-only concept" note requires.
55
+ */
56
+ export const DEFAULT_MAIL_LIST_PREFERENCES: MailListPreferences = {
57
+ sortBy: "date",
58
+ sortOrder: "desc",
59
+ filter: "focused",
60
+ labelUids: [],
61
+ showAsConversations: true,
62
+ };
63
+
64
+ /** Every sort key the server accepts, with the label the Sort menu shows for it - the order here is the
65
+ * order the menu lists them in. */
66
+ export const MAIL_LIST_SORTS: { value: MessageListSort; label: string }[] = [
67
+ { value: "date", label: "Date" },
68
+ { value: "sentDate", label: "Date sent" },
69
+ { value: "from", label: "From" },
70
+ { value: "subject", label: "Subject" },
71
+ { value: "importance", label: "Importance" },
72
+ { value: "flagged", label: "Flag status" },
73
+ ];
74
+
75
+ /** Every named filter the server accepts, minus the Focused/Other pair (which the menu groups separately,
76
+ * and only offers in an Inbox - see `MessageListFilter`'s own doc comment). */
77
+ export const MAIL_LIST_FILTERS: { value: MessageListFilter; label: string }[] = [
78
+ { value: "all", label: "All" },
79
+ { value: "unread", label: "Unread" },
80
+ { value: "read", label: "Read" },
81
+ { value: "flagged", label: "Flagged" },
82
+ { value: "hasAttachments", label: "Has attachments" },
83
+ ];
84
+
85
+ /** The Focused Inbox half of the filter vocabulary, which the list also surfaces as its own tab row. */
86
+ export const MAIL_LIST_CLASSIFICATION_FILTERS: { value: MessageListFilter; label: string }[] = [
87
+ { value: "focused", label: "Focused" },
88
+ { value: "other", label: "Other" },
89
+ ];
90
+
91
+ /** What "ascending"/"descending" actually mean for each sort key, since "Newest on top" and "A to Z" are
92
+ * the same `desc`/`asc` pair wearing different words - mirrors Outlook's own per-field order labels. */
93
+ export const SORT_ORDER_LABELS: Record<MessageListSort, { desc: string; asc: string }> = {
94
+ date: { desc: "Newest on top", asc: "Oldest on top" },
95
+ sentDate: { desc: "Newest on top", asc: "Oldest on top" },
96
+ from: { asc: "A to Z", desc: "Z to A" },
97
+ subject: { asc: "A to Z", desc: "Z to A" },
98
+ importance: { desc: "Highest on top", asc: "Lowest on top" },
99
+ flagged: { desc: "Flagged on top", asc: "Unflagged on top" },
100
+ };
101
+
102
+ /**
103
+ * The sort keys a *conversation* row can't be ordered by, and the reason the Sort menu shows beside each of
104
+ * them while the list is grouped into conversations.
105
+ *
106
+ * `GET /mail/messages/conversations` takes no `sortBy`/`sortOrder` at all - it returns one summary per
107
+ * thread, newest activity first - so every key here is applied to the rows this client has actually fetched
108
+ * (see `sortConversations()`). These two can't be applied even that far: a `ConversationSummary` describes
109
+ * a thread, and a thread has neither a sent date nor an importance - those belong to one message of it.
110
+ */
111
+ export const CONVERSATION_SORT_UNAVAILABLE: Partial<Record<MessageListSort, string>> = {
112
+ sentDate: "A thread has no sent date",
113
+ importance: "A thread has no importance",
114
+ };
115
+
116
+ /** The keys `sortConversations()` can actually order conversation rows by - `MAIL_LIST_SORTS` minus
117
+ * `CONVERSATION_SORT_UNAVAILABLE`'s. */
118
+ export const CONVERSATION_SORTS: MessageListSort[] = MAIL_LIST_SORTS.map((entry) => entry.value).filter(
119
+ (value) => !(value in CONVERSATION_SORT_UNAVAILABLE),
120
+ );
121
+
122
+ /** What the Sort menu says under its keys while conversations are shown - the honest scope of the ordering
123
+ * below, since the endpoint pages by latest activity and only the rows already fetched can be reordered. */
124
+ export const CONVERSATION_SORT_NOTE =
125
+ "Conversations are ordered within the rows loaded so far - the server pages them by latest activity.";
126
+
127
+ /** The name a conversation row is ordered by for "From": the latest message's sender, which is also the one
128
+ * whose subject, preview and date the row shows. */
129
+ function latestSenderName(conversation: ConversationSummary): string {
130
+ return conversation.latestFrom.displayName || conversation.latestFrom.address;
131
+ }
132
+
133
+ /** One conversation row against another on `sortBy`, ascending. */
134
+ function compareConversations(a: ConversationSummary, b: ConversationSummary, sortBy: MessageListSort): number {
135
+ switch (sortBy) {
136
+ case "from":
137
+ return latestSenderName(a).localeCompare(latestSenderName(b), undefined, { sensitivity: "base" });
138
+ case "subject":
139
+ return a.subject.localeCompare(b.subject, undefined, { sensitivity: "base" });
140
+ case "flagged":
141
+ return Number(a.flagged) - Number(b.flagged);
142
+ default:
143
+ // `date` - the thread's latest activity, which is what the row itself shows.
144
+ return Date.parse(a.latestDate) - Date.parse(b.latestDate);
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Orders conversation rows by the arrangement the reader picked, as far as a `ConversationSummary` allows:
150
+ * the endpoint itself takes no sort parameters, so this reorders the rows already fetched rather than the
151
+ * folder (see `CONVERSATION_SORT_NOTE`, which says so on screen).
152
+ *
153
+ * A key the summaries carry no value for (see `CONVERSATION_SORT_UNAVAILABLE`, greyed out in the menu) is
154
+ * left alone, so the rows keep the server's own latest-activity order rather than being shuffled into an
155
+ * order that would mean nothing. Ties break newest first whichever direction is in force, so two rows the
156
+ * key can't tell apart still read in a stable, familiar order.
157
+ */
158
+ export function sortConversations(
159
+ conversations: ConversationSummary[],
160
+ sortBy: MessageListSort,
161
+ sortOrder: MessageSortOrder,
162
+ ): ConversationSummary[] {
163
+ if (!CONVERSATION_SORTS.includes(sortBy)) {
164
+ return conversations;
165
+ }
166
+ const direction = sortOrder === "asc" ? 1 : -1;
167
+ return [...conversations].sort((a, b) => {
168
+ const primary = direction * compareConversations(a, b, sortBy);
169
+ return primary !== 0 ? primary : Date.parse(b.latestDate) - Date.parse(a.latestDate);
170
+ });
171
+ }
172
+
173
+ /** The direction the server itself would pick for a key if none were sent (see `MessageSortOrder`) - what
174
+ * this list switches to when the reader picks a different field, so changing "Date" to "Subject" reads A-Z
175
+ * rather than inheriting Date's newest-first as a surprising Z-A. */
176
+ export function defaultSortOrder(sortBy: MessageListSort): MessageSortOrder {
177
+ return sortBy === "from" || sortBy === "subject" ? "asc" : "desc";
178
+ }
179
+
180
+ function isKnown<T extends string>(value: unknown, known: readonly { value: T }[]): value is T {
181
+ return known.some((entry) => entry.value === value);
182
+ }
183
+
184
+ /** Reads one mailbox's stored preferences, merging them over the defaults field by field so an unknown or
185
+ * missing field falls back on its own rather than discarding the whole record. */
186
+ export function getMailListPreferences(mailboxUid: string): MailListPreferences {
187
+ let stored: unknown;
188
+ try {
189
+ const raw = localStorage.getItem(`${STORAGE_KEY_PREFIX}${mailboxUid}`);
190
+ stored = raw === null ? null : JSON.parse(raw);
191
+ } catch {
192
+ return DEFAULT_MAIL_LIST_PREFERENCES;
193
+ }
194
+ if (!stored || typeof stored !== "object") {
195
+ return DEFAULT_MAIL_LIST_PREFERENCES;
196
+ }
197
+ const record = stored as Record<string, unknown>;
198
+ const sortBy = isKnown(record.sortBy, MAIL_LIST_SORTS) ? record.sortBy : DEFAULT_MAIL_LIST_PREFERENCES.sortBy;
199
+ const filter =
200
+ isKnown(record.filter, MAIL_LIST_FILTERS) || isKnown(record.filter, MAIL_LIST_CLASSIFICATION_FILTERS)
201
+ ? record.filter
202
+ : DEFAULT_MAIL_LIST_PREFERENCES.filter;
203
+ return {
204
+ sortBy,
205
+ sortOrder: record.sortOrder === "asc" || record.sortOrder === "desc" ? record.sortOrder : defaultSortOrder(sortBy),
206
+ filter,
207
+ labelUids: Array.isArray(record.labelUids)
208
+ ? record.labelUids.filter((uid): uid is string => typeof uid === "string").slice(0, MAX_LABEL_FILTER_UIDS)
209
+ : [],
210
+ // A stored `false` is a choice this reader made and is honoured; anything else (a record written
211
+ // before this field existed, or a corrupted value) falls back to the default like every other
212
+ // field here - which is what makes "Show as conversations" on by default only for a mailbox that
213
+ // has never been arranged.
214
+ showAsConversations:
215
+ typeof record.showAsConversations === "boolean"
216
+ ? record.showAsConversations
217
+ : DEFAULT_MAIL_LIST_PREFERENCES.showAsConversations,
218
+ };
219
+ }
220
+
221
+ /** Persists one mailbox's preferences. Best-effort - see this module's own doc comment. */
222
+ export function setMailListPreferences(mailboxUid: string, preferences: MailListPreferences): void {
223
+ try {
224
+ localStorage.setItem(`${STORAGE_KEY_PREFIX}${mailboxUid}`, JSON.stringify(preferences));
225
+ } catch {
226
+ // Best-effort - see this module's own doc comment.
227
+ }
228
+ }
@@ -25,7 +25,6 @@ export const SETTINGS_SECTIONS: SettingsSectionDef[] = [
25
25
  { id: "filters", href: "/settings/filters", label: "Mail Filters" },
26
26
  { id: "signatures", href: "/settings/signatures", label: "Signatures" },
27
27
  { id: "labels", href: "/settings/labels", label: "Labels" },
28
- { id: "focused-inbox", href: "/settings/focused-inbox", label: "Focused Inbox" },
29
28
  { id: "read-receipts", href: "/settings/read-receipts", label: "Read Receipts" },
30
29
  { id: "encryption", href: "/settings/encryption", label: "Encryption" },
31
30
  { id: "sharing", href: "/settings/sharing", label: "Sharing" },
@@ -12,11 +12,24 @@
12
12
 
13
13
  /*
14
14
  * Tailwind v4's automatic content scanning excludes `node_modules` by default, which is exactly where
15
- * `@rapidmx/react-shared`'s components live from every consumer's perspective (a `link:`-ed sibling) -
16
- * without this, none of its Tailwind classnames (Modal/Drawer/Button/Alert/Skeleton/FormField/
17
- * PopoverPortal/ContactAvatar/MiniDatePicker/BottomTabBar) would ever be scanned.
15
+ * `@rapidmx/react-shared`'s components live - without these, none of its Tailwind classnames (Modal/
16
+ * Drawer/Button/Alert/Skeleton/FormField/PopoverPortal/ContactAvatar/MiniDatePicker/BottomTabBar) are
17
+ * generated, and e.g. a Modal renders with no overlay, position or width. The published package ships
18
+ * only its compiled `dist` (no `src`), and `@source` paths resolve from this file's directory
19
+ * (`apps/shared/styles/`), so both install layouts are listed; a path that doesn't exist is skipped:
20
+ * - `../../../node_modules/...`: react-shared under this package's own `node_modules` - this repo's
21
+ * checkout, or a consumer install that nests it under web-client.
22
+ * - `../../../../react-shared/dist`: react-shared hoisted beside this package, i.e. this file at
23
+ * `<consumer>/node_modules/@rapidmx/web-client/apps/shared/styles/` and react-shared at
24
+ * `<consumer>/node_modules/@rapidmx/react-shared` - how `server` installs both, for its pages and
25
+ * for the plugin pages' `plugin-ui.css`, which imports this file from there.
26
+ * `electron-client` links `node_modules/@rapidmx/web-client` to a checkout of this repo, so one of the
27
+ * two matches whether this file is reached through the link or its real path. From a checkout, the
28
+ * second path can also find a sibling `react-shared` checkout's build, which only adds classes
29
+ * react-shared itself uses.
18
30
  */
19
- @source "../../node_modules/@rapidmx/react-shared/src";
31
+ @source "../../../node_modules/@rapidmx/react-shared/dist";
32
+ @source "../../../../react-shared/dist";
20
33
 
21
34
  /*
22
35
  * `server`'s own build (unlike `electron-client`, which already explicitly sourced this same tree in
@@ -30,7 +43,7 @@
30
43
  * silently absent from the built stylesheet, even though `AdminShell.tsx` itself was very much in the
31
44
  * bundle - verified directly by diffing every classname `AdminShell.tsx` uses against the actual built
32
45
  * CSS. An explicit `@source` here makes the scan independent of Vite's per-entry chunking, the same
33
- * fix this file already applies to `react-shared`, just for this package's own source too.
46
+ * fix this file applies to `react-shared` above, just for this package's own source too.
34
47
  */
35
48
  @source "../../";
36
49
 
@@ -263,3 +276,13 @@ h5,
263
276
  h6 {
264
277
  font-family: var(--rr-font-display);
265
278
  }
279
+
280
+ /* The compose editor's quoted original (`composeQuoting.ts`'s blockquote). TipTap keeps the element but not the
281
+ * inline style it was seeded with, and Tailwind's preflight resets the browser's own blockquote indent - without
282
+ * this the quote under a reply reads as if it were part of the new message. */
283
+ .tiptap blockquote {
284
+ margin: 0;
285
+ padding-left: 1em;
286
+ border-left: 2px solid var(--rr-color-border);
287
+ color: var(--rr-color-text-muted);
288
+ }