@rapidmx/web-client 0.6.0 → 0.8.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 +198 -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 +9 -2
  34. package/dist/apps/shared/components/admin/settings/MailboxPolicyForm.js +20 -4
  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,134 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ ///////////////////////////////////////////////////////////////////////////////
3
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
4
+ // SPDX-License-Identifier: MPL-2.0
5
+ ///////////////////////////////////////////////////////////////////////////////
6
+ import { useState } from "react";
7
+ import { HiOutlineTag } from "react-icons/hi2";
8
+ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
9
+ import { createLabel } from "@rapidmx/react-shared/mail/labelsApi.js";
10
+ import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
11
+ import Button from "@rapidmx/react-shared/components/buttons/Button.js";
12
+ import FormField from "@rapidmx/react-shared/components/forms/FormField.js";
13
+ import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
14
+ import MenuButton from "./MenuButton.js";
15
+ /** `a` and `b` hold the same uids, order ignored. */
16
+ function sameUids(a, b) {
17
+ return a.length === b.length && a.every((uid) => b.includes(uid));
18
+ }
19
+ /**
20
+ * Holds the ticked/partially-applied state of a label list while its menu is open, starting again from
21
+ * `applied`/`partial` every time the menu is reopened - so dismissing a menu (Escape, a click outside)
22
+ * discards the draft rather than silently keeping half a change.
23
+ */
24
+ export function useLabelDraft(applied, partial, open) {
25
+ const [state, setState] = useState(null);
26
+ const [wasOpen, setWasOpen] = useState(open);
27
+ if (wasOpen !== open) {
28
+ setWasOpen(open);
29
+ setState(open ? { draft: applied, mixed: partial } : null);
30
+ }
31
+ const current = state ?? { draft: applied, mixed: partial };
32
+ return {
33
+ draft: current.draft,
34
+ mixed: current.mixed,
35
+ toggle: (labelUid) => setState({
36
+ // Touching a partially-applied row settles it: it becomes a plain tick (apply to all).
37
+ draft: current.draft.includes(labelUid)
38
+ ? current.draft.filter((uid) => uid !== labelUid)
39
+ : [...current.draft, labelUid],
40
+ mixed: current.mixed.filter((uid) => uid !== labelUid),
41
+ }),
42
+ clear: () => setState({ draft: [], mixed: [] }),
43
+ dirty: !sameUids(current.draft, applied) || !sameUids(current.mixed, partial),
44
+ };
45
+ }
46
+ /**
47
+ * The label rows plus their commit/clear rows, as `MenuButton` sections - so the same list can be a menu of
48
+ * its own (`LabelMenuButton` below) or a submenu of another menu (the Filter menu's "Labels" row).
49
+ */
50
+ export function labelSections({ labels, state, commit, clear, emptyNote, note, busy, onCreate, managePath = "/settings/labels", }) {
51
+ const manageItem = {
52
+ key: "manage",
53
+ label: "Manage labels…",
54
+ onSelect: () => {
55
+ window.location.href = managePath;
56
+ },
57
+ };
58
+ const tailItems = [...(onCreate ? [{ key: "create", label: "New label…", onSelect: onCreate }] : []), manageItem];
59
+ if (labels.length === 0) {
60
+ return [{ key: "labels", label: "Labels", note: emptyNote, items: tailItems }];
61
+ }
62
+ return [
63
+ {
64
+ key: "labels",
65
+ label: "Labels",
66
+ note,
67
+ items: labels.map((label) => ({
68
+ key: label.uid,
69
+ label: label.name,
70
+ role: "menuitemcheckbox",
71
+ checked: state.mixed.includes(label.uid) ? "mixed" : state.draft.includes(label.uid),
72
+ swatchColor: label.color ?? "#6366f1",
73
+ disabled: busy,
74
+ // Several labels are ticked before anything is committed, so a tick never closes the menu.
75
+ keepOpen: true,
76
+ onSelect: () => state.toggle(label.uid),
77
+ })),
78
+ },
79
+ {
80
+ key: "commands",
81
+ items: [
82
+ {
83
+ key: "clear",
84
+ label: clear.label,
85
+ disabled: busy || clear.disabled || (state.draft.length === 0 && state.mixed.length === 0),
86
+ keepOpen: clear.keepOpen ?? true,
87
+ onSelect: () => (clear.onSelect ?? state.clear)(),
88
+ },
89
+ { key: "commit", label: commit.label, disabled: busy || commit.disabled, onSelect: commit.onSelect },
90
+ ...tailItems,
91
+ ],
92
+ },
93
+ ];
94
+ }
95
+ /** The "New label" form the menus open - a dialog rather than more menu rows, because a `role="menu"`
96
+ * has no place for a text field. Colour is left to Settings > Labels; this is the quick path from a
97
+ * message, so it only asks for the name. */
98
+ export function NewLabelDialog({ open, onClose, mailboxUid, onCreated }) {
99
+ const [name, setName] = useState("");
100
+ const [saving, setSaving] = useState(false);
101
+ const [error, setError] = useState(null);
102
+ async function save() {
103
+ setSaving(true);
104
+ setError(null);
105
+ try {
106
+ onCreated(await createLabel({ mailboxUid, name: name.trim() }));
107
+ setName("");
108
+ onClose();
109
+ }
110
+ catch (err) {
111
+ setError(err instanceof ApiRequestError ? err.message : "Could not create this label.");
112
+ }
113
+ finally {
114
+ setSaving(false);
115
+ }
116
+ }
117
+ return (_jsxs(Modal, { open: open, onClose: onClose, title: "New label", children: [error && _jsx(Alert, { children: error }), _jsx(FormField, { label: "Name", htmlFor: "new-label-name", children: _jsx("input", { id: "new-label-name", type: "text", value: name, onChange: (e) => setName(e.target.value), className: "w-full text-sm px-3 py-1.5 rounded-md border border-border bg-surface" }) }), _jsxs("div", { className: "flex justify-end gap-2 mt-2", children: [_jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", onClick: onClose, children: "Cancel" }), _jsx(Button, { type: "button", className: "!w-auto", loading: saving, disabled: saving || !name.trim(), onClick: () => void save(), children: "Create" })] })] }));
118
+ }
119
+ /** The label list as a menu button of its own - the bulk Apply label action and the reading pane's Labels. */
120
+ export default function LabelMenuButton({ applied, partial = [], onCommit, labels, commit, clear, emptyNote, note, busy, label, "aria-label": ariaLabel, disabled, title, className, mailboxUid, onLabelCreated, }) {
121
+ const [open, setOpen] = useState(false);
122
+ const [creating, setCreating] = useState(false);
123
+ const state = useLabelDraft(applied, partial, open);
124
+ return (_jsxs(_Fragment, { children: [_jsx(MenuButton, { "aria-label": ariaLabel, label: label, icon: _jsx(HiOutlineTag, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-muted" }), disabled: disabled, title: title, className: className, onOpenChange: setOpen, sections: labelSections({
125
+ labels,
126
+ state,
127
+ commit: { ...commit, disabled: commit.disabled || !state.dirty, onSelect: () => onCommit(state.draft, state.mixed) },
128
+ clear,
129
+ emptyNote,
130
+ note,
131
+ busy,
132
+ onCreate: mailboxUid && onLabelCreated ? () => setCreating(true) : undefined,
133
+ }) }), mailboxUid && onLabelCreated && (_jsx(NewLabelDialog, { open: creating, onClose: () => setCreating(false), mailboxUid: mailboxUid, onCreated: onLabelCreated }))] }));
134
+ }
@@ -33,6 +33,14 @@ export interface MailShellContextValue {
33
33
  /** Every accessible mailbox's own mail folders - replaces the old single-mailbox `folders: Folder[]`
34
34
  * now that every mailbox's tree renders at once (see `MailboxFolders`'s own doc comment). */
35
35
  mailboxFolders: MailboxFolders[];
36
+ /**
37
+ * Adds a folder a page has just created (the Move to prompt's "New folder") to the tree this shell
38
+ * already fetched, so it appears in the sidebar and in every folder picker without a reload - this
39
+ * framework has no client-side router, so a reload is a whole page load.
40
+ *
41
+ * A no-op on the default context value, which is only ever read outside a real shell.
42
+ */
43
+ onFolderCreated: (folder: Folder) => void;
36
44
  }
37
45
  /** Reads the mailbox/folder a page is currently showing, as resolved by the enclosing `MailShell`. */
38
46
  export declare function useMailShell(): MailShellContextValue;
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  // Copyright (C) 2026 Jean-Philippe Steinmetz
4
4
  // SPDX-License-Identifier: MPL-2.0
5
5
  ///////////////////////////////////////////////////////////////////////////////
6
- import { createContext, useContext, useEffect, useMemo, useState } from "react";
6
+ import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
7
7
  import { HiOutlineBars3 } from "react-icons/hi2";
8
8
  import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
9
9
  import Drawer from "@rapidmx/react-shared/components/overlays/Drawer.js";
@@ -24,7 +24,11 @@ export const AGGREGATE_FOLDER_TYPES = ["inbox", "sent_items", "drafts", "deleted
24
24
  function isAggregateFolderType(value) {
25
25
  return !!value && AGGREGATE_FOLDER_TYPES.includes(value);
26
26
  }
27
- const MailShellContext = createContext({ mailboxes: [], mailboxFolders: [] });
27
+ const MailShellContext = createContext({
28
+ mailboxes: [],
29
+ mailboxFolders: [],
30
+ onFolderCreated: () => undefined,
31
+ });
28
32
  /** Reads the mailbox/folder a page is currently showing, as resolved by the enclosing `MailShell`. */
29
33
  export function useMailShell() {
30
34
  return useContext(MailShellContext);
@@ -162,7 +166,15 @@ export default function MailShell({ userUid, authServerUrl, impersonating, imper
162
166
  // mailbox may still need that mailbox's own folder view opened directly to unlock/decrypt it.
163
167
  const defaultMailboxUid = mailboxes.find((mb) => mb.ownerUserUid === userUid)?.uid ?? mailboxes[0]?.uid;
164
168
  const activeMailboxUid = mailboxUid ?? defaultMailboxUid;
165
- const contextValue = useMemo(() => ({ mailboxUid, folderUid, aggregateFolderType, mailboxes, mailboxFolders }), [mailboxUid, folderUid, aggregateFolderType, mailboxes, mailboxFolders]);
169
+ /** Files a newly created folder under its own mailbox, leaving every other mailbox's list untouched -
170
+ * and ignoring a type this sidebar doesn't list at all, the same filter the fetch above applies. */
171
+ const onFolderCreated = useCallback((folder) => {
172
+ if (!MAIL_FOLDER_TYPES.has(folder.type)) {
173
+ return;
174
+ }
175
+ setMailboxFolders((prev) => prev.map((entry) => entry.mailbox.uid === folder.mailboxUid ? { ...entry, folders: [...entry.folders, folder] } : entry));
176
+ }, []);
177
+ const contextValue = useMemo(() => ({ mailboxUid, folderUid, aggregateFolderType, mailboxes, mailboxFolders, onFolderCreated }), [mailboxUid, folderUid, aggregateFolderType, mailboxes, mailboxFolders, onFolderCreated]);
166
178
  // A full-screen takeover, not nested inside the rest of the app's chrome — there's nothing else for a
167
179
  // mailbox-less caller to do here yet, so the icon rail/header/folder tree don't render at all. Checks
168
180
  // `mailboxes.length` directly (not `!mailboxUid`) since `mailboxUid` is legitimately undefined in
@@ -0,0 +1,101 @@
1
+ /**
2
+ * The mail list's own per-mailbox view preferences - what the Sort and Filter menus and the "Show as
3
+ * conversations" toggle are currently set to - persisted in `localStorage` so reopening the app lands on
4
+ * the arrangement the reader left it in, the way Outlook remembers its own per-folder arrangement.
5
+ *
6
+ * Per device, not synced to the server: this is the same posture `localIndexSizePreference.ts` and
7
+ * react-shared's `idleTimeout.ts` already take, and there is no server-side "mail view settings" record to
8
+ * write to. Keyed by mailbox because a shared mailbox someone triages ("unread only, oldest on top") is a
9
+ * genuinely different working set from their own inbox.
10
+ *
11
+ * Every read falls back to `DEFAULT_MAIL_LIST_PREFERENCES` for a never-configured mailbox, a corrupted or
12
+ * partially-unknown stored value, or a `localStorage` access that throws (private-browsing/storage-blocked
13
+ * contexts) - and every write swallows its own failure, so a blocked store only means the preference
14
+ * doesn't survive a reload.
15
+ */
16
+ import { MessageListFilter, MessageListSort, MessageSortOrder } from "@rapidmx/react-shared/mail/mailApi.js";
17
+ import { ConversationSummary } from "@rapidmx/react-shared/mail/conversationsApi.js";
18
+ export interface MailListPreferences {
19
+ sortBy: MessageListSort;
20
+ sortOrder: MessageSortOrder;
21
+ filter: MessageListFilter;
22
+ /** Labels the list is narrowed to, applied *alongside* `filter` with OR semantics between them: a
23
+ * message is listed when it carries any one of these. Empty means no label filter at all. Kept per
24
+ * mailbox because a label uid only means anything inside its own mailbox. */
25
+ labelUids: string[];
26
+ /** Outlook's "Show as conversations" - the nested conversation list rather than the flat message list. */
27
+ showAsConversations: boolean;
28
+ }
29
+ /** How many labels the list may be narrowed to at once. `@rapidmx/restapi` refuses a longer `?labelUids=`
30
+ * with a 400, so a stored selection is trimmed to the cap rather than sent. */
31
+ export declare const MAX_LABEL_FILTER_UIDS = 20;
32
+ /**
33
+ * What a mailbox nobody has configured yet opens on: newest received first, no label filter, and - like
34
+ * Outlook's own out-of-the-box arrangement - the Focused half of the Inbox, shown as conversations.
35
+ *
36
+ * Neither of those last two is `listMessages()`'s own default (`all`, and the flat list): they are this
37
+ * client's opinion about what a first-time reader should see, applied only where nothing has been stored
38
+ * (see `getMailListPreferences()`, which keeps a stored `false`/`all` exactly as it was). `focused` also
39
+ * only ever applies in an Inbox - every other folder falls back to `all` in `apps/www/index.tsx`, which is
40
+ * what `MessageListFilter`'s own "Inbox-only concept" note requires.
41
+ */
42
+ export declare const DEFAULT_MAIL_LIST_PREFERENCES: MailListPreferences;
43
+ /** Every sort key the server accepts, with the label the Sort menu shows for it - the order here is the
44
+ * order the menu lists them in. */
45
+ export declare const MAIL_LIST_SORTS: {
46
+ value: MessageListSort;
47
+ label: string;
48
+ }[];
49
+ /** Every named filter the server accepts, minus the Focused/Other pair (which the menu groups separately,
50
+ * and only offers in an Inbox - see `MessageListFilter`'s own doc comment). */
51
+ export declare const MAIL_LIST_FILTERS: {
52
+ value: MessageListFilter;
53
+ label: string;
54
+ }[];
55
+ /** The Focused Inbox half of the filter vocabulary, which the list also surfaces as its own tab row. */
56
+ export declare const MAIL_LIST_CLASSIFICATION_FILTERS: {
57
+ value: MessageListFilter;
58
+ label: string;
59
+ }[];
60
+ /** What "ascending"/"descending" actually mean for each sort key, since "Newest on top" and "A to Z" are
61
+ * the same `desc`/`asc` pair wearing different words - mirrors Outlook's own per-field order labels. */
62
+ export declare const SORT_ORDER_LABELS: Record<MessageListSort, {
63
+ desc: string;
64
+ asc: string;
65
+ }>;
66
+ /**
67
+ * The sort keys a *conversation* row can't be ordered by, and the reason the Sort menu shows beside each of
68
+ * them while the list is grouped into conversations.
69
+ *
70
+ * `GET /mail/messages/conversations` takes no `sortBy`/`sortOrder` at all - it returns one summary per
71
+ * thread, newest activity first - so every key here is applied to the rows this client has actually fetched
72
+ * (see `sortConversations()`). These two can't be applied even that far: a `ConversationSummary` describes
73
+ * a thread, and a thread has neither a sent date nor an importance - those belong to one message of it.
74
+ */
75
+ export declare const CONVERSATION_SORT_UNAVAILABLE: Partial<Record<MessageListSort, string>>;
76
+ /** The keys `sortConversations()` can actually order conversation rows by - `MAIL_LIST_SORTS` minus
77
+ * `CONVERSATION_SORT_UNAVAILABLE`'s. */
78
+ export declare const CONVERSATION_SORTS: MessageListSort[];
79
+ /** What the Sort menu says under its keys while conversations are shown - the honest scope of the ordering
80
+ * below, since the endpoint pages by latest activity and only the rows already fetched can be reordered. */
81
+ export declare const CONVERSATION_SORT_NOTE = "Conversations are ordered within the rows loaded so far - the server pages them by latest activity.";
82
+ /**
83
+ * Orders conversation rows by the arrangement the reader picked, as far as a `ConversationSummary` allows:
84
+ * the endpoint itself takes no sort parameters, so this reorders the rows already fetched rather than the
85
+ * folder (see `CONVERSATION_SORT_NOTE`, which says so on screen).
86
+ *
87
+ * A key the summaries carry no value for (see `CONVERSATION_SORT_UNAVAILABLE`, greyed out in the menu) is
88
+ * left alone, so the rows keep the server's own latest-activity order rather than being shuffled into an
89
+ * order that would mean nothing. Ties break newest first whichever direction is in force, so two rows the
90
+ * key can't tell apart still read in a stable, familiar order.
91
+ */
92
+ export declare function sortConversations(conversations: ConversationSummary[], sortBy: MessageListSort, sortOrder: MessageSortOrder): ConversationSummary[];
93
+ /** The direction the server itself would pick for a key if none were sent (see `MessageSortOrder`) - what
94
+ * this list switches to when the reader picks a different field, so changing "Date" to "Subject" reads A-Z
95
+ * rather than inheriting Date's newest-first as a surprising Z-A. */
96
+ export declare function defaultSortOrder(sortBy: MessageListSort): MessageSortOrder;
97
+ /** Reads one mailbox's stored preferences, merging them over the defaults field by field so an unknown or
98
+ * missing field falls back on its own rather than discarding the whole record. */
99
+ export declare function getMailListPreferences(mailboxUid: string): MailListPreferences;
100
+ /** Persists one mailbox's preferences. Best-effort - see this module's own doc comment. */
101
+ export declare function setMailListPreferences(mailboxUid: string, preferences: MailListPreferences): void;
@@ -0,0 +1,186 @@
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 { MAX_MESSAGE_LABEL_FILTER, } from "@rapidmx/react-shared/mail/mailApi.js";
21
+ const STORAGE_KEY_PREFIX = "rapidmx:mail-list-preferences:";
22
+ /** How many labels the list may be narrowed to at once. `@rapidmx/restapi` refuses a longer `?labelUids=`
23
+ * with a 400, so a stored selection is trimmed to the cap rather than sent. */
24
+ export const MAX_LABEL_FILTER_UIDS = MAX_MESSAGE_LABEL_FILTER;
25
+ /**
26
+ * What a mailbox nobody has configured yet opens on: newest received first, no label filter, and - like
27
+ * Outlook's own out-of-the-box arrangement - the Focused half of the Inbox, shown as conversations.
28
+ *
29
+ * Neither of those last two is `listMessages()`'s own default (`all`, and the flat list): they are this
30
+ * client's opinion about what a first-time reader should see, applied only where nothing has been stored
31
+ * (see `getMailListPreferences()`, which keeps a stored `false`/`all` exactly as it was). `focused` also
32
+ * only ever applies in an Inbox - every other folder falls back to `all` in `apps/www/index.tsx`, which is
33
+ * what `MessageListFilter`'s own "Inbox-only concept" note requires.
34
+ */
35
+ export const DEFAULT_MAIL_LIST_PREFERENCES = {
36
+ sortBy: "date",
37
+ sortOrder: "desc",
38
+ filter: "focused",
39
+ labelUids: [],
40
+ showAsConversations: true,
41
+ };
42
+ /** Every sort key the server accepts, with the label the Sort menu shows for it - the order here is the
43
+ * order the menu lists them in. */
44
+ export const MAIL_LIST_SORTS = [
45
+ { value: "date", label: "Date" },
46
+ { value: "sentDate", label: "Date sent" },
47
+ { value: "from", label: "From" },
48
+ { value: "subject", label: "Subject" },
49
+ { value: "importance", label: "Importance" },
50
+ { value: "flagged", label: "Flag status" },
51
+ ];
52
+ /** Every named filter the server accepts, minus the Focused/Other pair (which the menu groups separately,
53
+ * and only offers in an Inbox - see `MessageListFilter`'s own doc comment). */
54
+ export const MAIL_LIST_FILTERS = [
55
+ { value: "all", label: "All" },
56
+ { value: "unread", label: "Unread" },
57
+ { value: "read", label: "Read" },
58
+ { value: "flagged", label: "Flagged" },
59
+ { value: "hasAttachments", label: "Has attachments" },
60
+ ];
61
+ /** The Focused Inbox half of the filter vocabulary, which the list also surfaces as its own tab row. */
62
+ export const MAIL_LIST_CLASSIFICATION_FILTERS = [
63
+ { value: "focused", label: "Focused" },
64
+ { value: "other", label: "Other" },
65
+ ];
66
+ /** What "ascending"/"descending" actually mean for each sort key, since "Newest on top" and "A to Z" are
67
+ * the same `desc`/`asc` pair wearing different words - mirrors Outlook's own per-field order labels. */
68
+ export const SORT_ORDER_LABELS = {
69
+ date: { desc: "Newest on top", asc: "Oldest on top" },
70
+ sentDate: { desc: "Newest on top", asc: "Oldest on top" },
71
+ from: { asc: "A to Z", desc: "Z to A" },
72
+ subject: { asc: "A to Z", desc: "Z to A" },
73
+ importance: { desc: "Highest on top", asc: "Lowest on top" },
74
+ flagged: { desc: "Flagged on top", asc: "Unflagged on top" },
75
+ };
76
+ /**
77
+ * The sort keys a *conversation* row can't be ordered by, and the reason the Sort menu shows beside each of
78
+ * them while the list is grouped into conversations.
79
+ *
80
+ * `GET /mail/messages/conversations` takes no `sortBy`/`sortOrder` at all - it returns one summary per
81
+ * thread, newest activity first - so every key here is applied to the rows this client has actually fetched
82
+ * (see `sortConversations()`). These two can't be applied even that far: a `ConversationSummary` describes
83
+ * a thread, and a thread has neither a sent date nor an importance - those belong to one message of it.
84
+ */
85
+ export const CONVERSATION_SORT_UNAVAILABLE = {
86
+ sentDate: "A thread has no sent date",
87
+ importance: "A thread has no importance",
88
+ };
89
+ /** The keys `sortConversations()` can actually order conversation rows by - `MAIL_LIST_SORTS` minus
90
+ * `CONVERSATION_SORT_UNAVAILABLE`'s. */
91
+ export const CONVERSATION_SORTS = MAIL_LIST_SORTS.map((entry) => entry.value).filter((value) => !(value in CONVERSATION_SORT_UNAVAILABLE));
92
+ /** What the Sort menu says under its keys while conversations are shown - the honest scope of the ordering
93
+ * below, since the endpoint pages by latest activity and only the rows already fetched can be reordered. */
94
+ export const CONVERSATION_SORT_NOTE = "Conversations are ordered within the rows loaded so far - the server pages them by latest activity.";
95
+ /** The name a conversation row is ordered by for "From": the latest message's sender, which is also the one
96
+ * whose subject, preview and date the row shows. */
97
+ function latestSenderName(conversation) {
98
+ return conversation.latestFrom.displayName || conversation.latestFrom.address;
99
+ }
100
+ /** One conversation row against another on `sortBy`, ascending. */
101
+ function compareConversations(a, b, sortBy) {
102
+ switch (sortBy) {
103
+ case "from":
104
+ return latestSenderName(a).localeCompare(latestSenderName(b), undefined, { sensitivity: "base" });
105
+ case "subject":
106
+ return a.subject.localeCompare(b.subject, undefined, { sensitivity: "base" });
107
+ case "flagged":
108
+ return Number(a.flagged) - Number(b.flagged);
109
+ default:
110
+ // `date` - the thread's latest activity, which is what the row itself shows.
111
+ return Date.parse(a.latestDate) - Date.parse(b.latestDate);
112
+ }
113
+ }
114
+ /**
115
+ * Orders conversation rows by the arrangement the reader picked, as far as a `ConversationSummary` allows:
116
+ * the endpoint itself takes no sort parameters, so this reorders the rows already fetched rather than the
117
+ * folder (see `CONVERSATION_SORT_NOTE`, which says so on screen).
118
+ *
119
+ * A key the summaries carry no value for (see `CONVERSATION_SORT_UNAVAILABLE`, greyed out in the menu) is
120
+ * left alone, so the rows keep the server's own latest-activity order rather than being shuffled into an
121
+ * order that would mean nothing. Ties break newest first whichever direction is in force, so two rows the
122
+ * key can't tell apart still read in a stable, familiar order.
123
+ */
124
+ export function sortConversations(conversations, sortBy, sortOrder) {
125
+ if (!CONVERSATION_SORTS.includes(sortBy)) {
126
+ return conversations;
127
+ }
128
+ const direction = sortOrder === "asc" ? 1 : -1;
129
+ return [...conversations].sort((a, b) => {
130
+ const primary = direction * compareConversations(a, b, sortBy);
131
+ return primary !== 0 ? primary : Date.parse(b.latestDate) - Date.parse(a.latestDate);
132
+ });
133
+ }
134
+ /** The direction the server itself would pick for a key if none were sent (see `MessageSortOrder`) - what
135
+ * this list switches to when the reader picks a different field, so changing "Date" to "Subject" reads A-Z
136
+ * rather than inheriting Date's newest-first as a surprising Z-A. */
137
+ export function defaultSortOrder(sortBy) {
138
+ return sortBy === "from" || sortBy === "subject" ? "asc" : "desc";
139
+ }
140
+ function isKnown(value, known) {
141
+ return known.some((entry) => entry.value === value);
142
+ }
143
+ /** Reads one mailbox's stored preferences, merging them over the defaults field by field so an unknown or
144
+ * missing field falls back on its own rather than discarding the whole record. */
145
+ export function getMailListPreferences(mailboxUid) {
146
+ let stored;
147
+ try {
148
+ const raw = localStorage.getItem(`${STORAGE_KEY_PREFIX}${mailboxUid}`);
149
+ stored = raw === null ? null : JSON.parse(raw);
150
+ }
151
+ catch {
152
+ return DEFAULT_MAIL_LIST_PREFERENCES;
153
+ }
154
+ if (!stored || typeof stored !== "object") {
155
+ return DEFAULT_MAIL_LIST_PREFERENCES;
156
+ }
157
+ const record = stored;
158
+ const sortBy = isKnown(record.sortBy, MAIL_LIST_SORTS) ? record.sortBy : DEFAULT_MAIL_LIST_PREFERENCES.sortBy;
159
+ const filter = isKnown(record.filter, MAIL_LIST_FILTERS) || isKnown(record.filter, MAIL_LIST_CLASSIFICATION_FILTERS)
160
+ ? record.filter
161
+ : DEFAULT_MAIL_LIST_PREFERENCES.filter;
162
+ return {
163
+ sortBy,
164
+ sortOrder: record.sortOrder === "asc" || record.sortOrder === "desc" ? record.sortOrder : defaultSortOrder(sortBy),
165
+ filter,
166
+ labelUids: Array.isArray(record.labelUids)
167
+ ? record.labelUids.filter((uid) => typeof uid === "string").slice(0, MAX_LABEL_FILTER_UIDS)
168
+ : [],
169
+ // A stored `false` is a choice this reader made and is honoured; anything else (a record written
170
+ // before this field existed, or a corrupted value) falls back to the default like every other
171
+ // field here - which is what makes "Show as conversations" on by default only for a mailbox that
172
+ // has never been arranged.
173
+ showAsConversations: typeof record.showAsConversations === "boolean"
174
+ ? record.showAsConversations
175
+ : DEFAULT_MAIL_LIST_PREFERENCES.showAsConversations,
176
+ };
177
+ }
178
+ /** Persists one mailbox's preferences. Best-effort - see this module's own doc comment. */
179
+ export function setMailListPreferences(mailboxUid, preferences) {
180
+ try {
181
+ localStorage.setItem(`${STORAGE_KEY_PREFIX}${mailboxUid}`, JSON.stringify(preferences));
182
+ }
183
+ catch {
184
+ // Best-effort - see this module's own doc comment.
185
+ }
186
+ }
@@ -19,7 +19,6 @@ export const SETTINGS_SECTIONS = [
19
19
  { id: "filters", href: "/settings/filters", label: "Mail Filters" },
20
20
  { id: "signatures", href: "/settings/signatures", label: "Signatures" },
21
21
  { id: "labels", href: "/settings/labels", label: "Labels" },
22
- { id: "focused-inbox", href: "/settings/focused-inbox", label: "Focused Inbox" },
23
22
  { id: "read-receipts", href: "/settings/read-receipts", label: "Read Receipts" },
24
23
  { id: "encryption", href: "/settings/encryption", label: "Encryption" },
25
24
  { 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
+ }