@rapidmx/web-client 0.9.0 → 0.11.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 (443) hide show
  1. package/README.md +373 -88
  2. package/apps/admin/_layout.tsx +8 -2
  3. package/apps/admin/index.tsx +7 -1
  4. package/apps/admin/ingest-queue/index.tsx +2 -1
  5. package/apps/admin/mailboxes/[uid].tsx +23 -10
  6. package/apps/admin/quarantine/index.tsx +2 -1
  7. package/apps/admin/signing-certificates/index.tsx +343 -0
  8. package/apps/escrow/_layout.tsx +8 -2
  9. package/apps/shared/appearance/AppearanceForm.tsx +392 -0
  10. package/apps/shared/appearance/AppearanceHead.tsx +49 -0
  11. package/apps/shared/appearance/AppearanceProvider.tsx +470 -0
  12. package/apps/shared/appearance/ColorField.tsx +107 -0
  13. package/apps/shared/appearance/appearanceCache.ts +106 -0
  14. package/apps/shared/appearance/appearanceContext.ts +77 -0
  15. package/apps/shared/appearance/bootScript.ts +35 -0
  16. package/apps/shared/appearance/color.ts +169 -0
  17. package/apps/shared/appearance/photo.ts +88 -0
  18. package/apps/shared/appearance/resolvedTheme.ts +67 -0
  19. package/apps/shared/appearance/theme.ts +355 -0
  20. package/apps/shared/auth/accountUrl.ts +9 -0
  21. package/apps/shared/auth/adminAccess.ts +99 -0
  22. package/apps/shared/components/admin/layout/AdminShell.tsx +22 -10
  23. package/apps/shared/components/admin/mailboxes/ShareAccessCard.tsx +107 -60
  24. package/apps/shared/components/admin/settings/BrandingForm.tsx +24 -0
  25. package/apps/shared/components/admin/settings/DomainDnsSetup.tsx +2 -1
  26. package/apps/shared/components/admin/settings/PluginsManager.tsx +228 -25
  27. package/apps/shared/components/admin/setup/SetupWizard.tsx +2 -1
  28. package/apps/shared/components/calendar/CalendarListSidebar.tsx +4 -5
  29. package/apps/shared/components/calendar/layout/CalendarShell.tsx +8 -2
  30. package/apps/shared/components/contacts/ContactForm.tsx +11 -5
  31. package/apps/shared/components/contacts/ContactsSidebar.tsx +5 -3
  32. package/apps/shared/components/contacts/ContactsToolbar.tsx +98 -115
  33. package/apps/shared/components/contacts/layout/ContactsShell.tsx +25 -8
  34. package/apps/shared/components/escrow/layout/EscrowShell.tsx +13 -6
  35. package/apps/shared/components/layout/AppShell.tsx +477 -288
  36. package/apps/shared/components/layout/BrandingChrome.tsx +200 -13
  37. package/apps/shared/components/layout/KeyEnrollmentGate.tsx +398 -389
  38. package/apps/shared/components/layout/MailboxProvisioning.tsx +168 -164
  39. package/apps/shared/components/layout/RailIcon.tsx +100 -0
  40. package/apps/shared/components/layout/ResponsiveToolbar.tsx +315 -0
  41. package/apps/shared/components/layout/ThemeSwitch.tsx +84 -0
  42. package/apps/shared/components/layout/UserMenu.tsx +372 -185
  43. package/apps/shared/components/mail/ConversationList.tsx +271 -262
  44. package/apps/shared/components/mail/ConversationThreadPane.tsx +147 -94
  45. package/apps/shared/components/mail/LazyReadingPane.tsx +113 -0
  46. package/apps/shared/components/mail/MailSelectionBar.tsx +227 -222
  47. package/apps/shared/components/mail/MessageDetailPane.tsx +1537 -1387
  48. package/apps/shared/components/mail/OutboxBadge.tsx +44 -0
  49. package/apps/shared/components/mail/OutboxRowStatus.tsx +31 -0
  50. package/apps/shared/components/mail/compose/ComposeContext.tsx +312 -160
  51. package/apps/shared/components/mail/compose/ComposeToolbar.tsx +422 -418
  52. package/apps/shared/components/mail/compose/ComposeWindow.tsx +1644 -1736
  53. package/apps/shared/components/mail/compose/ComposeWindowPlaceholder.tsx +111 -0
  54. package/apps/shared/components/mail/compose/RichTextEditor.tsx +147 -118
  55. package/apps/shared/components/mail/compose/composePerf.ts +46 -0
  56. package/apps/shared/components/mail/compose/encryptionRequirement.ts +86 -0
  57. package/apps/shared/components/mail/compose/quotedBody.ts +161 -100
  58. package/apps/shared/components/mail/layout/MailShell.tsx +490 -472
  59. package/apps/shared/components/mail/reading/EncryptedBody.tsx +65 -0
  60. package/apps/shared/components/mail/reading/EncryptedPreview.tsx +35 -0
  61. package/apps/shared/components/mail/reading/MessageBody.tsx +240 -0
  62. package/apps/shared/components/mail/reading/MessageCard.tsx +174 -0
  63. package/apps/shared/components/mail/reading/bodyContent.ts +100 -0
  64. package/apps/shared/components/mail/reading/bodyHtml.ts +298 -0
  65. package/apps/shared/components/mail/reading/color.ts +245 -0
  66. package/apps/shared/components/mail/reading/frameControl.ts +142 -0
  67. package/apps/shared/components/mail/reading/frameDocument.ts +123 -0
  68. package/apps/shared/components/mail/reading/safeDocument.ts +24 -0
  69. package/apps/shared/components/mail/reading/themeAdaptation.ts +221 -0
  70. package/apps/shared/components/mail/reading/themeSurface.ts +90 -0
  71. package/apps/shared/components/mail/reading/viewOriginal.ts +38 -0
  72. package/apps/shared/components/mail/unreadStyle.tsx +75 -0
  73. package/apps/shared/components/settings/SigningCertificateCard.tsx +344 -0
  74. package/apps/shared/components/settings/layout/SettingsShell.tsx +253 -240
  75. package/apps/shared/components/sharing/PrincipalPicker.tsx +145 -0
  76. package/apps/shared/components/tasks/TasksSidebar.tsx +5 -3
  77. package/apps/shared/components/tasks/layout/TasksShell.tsx +24 -8
  78. package/apps/shared/keyboard/GlobalShortcuts.tsx +51 -0
  79. package/apps/shared/keyboard/ShortcutProvider.tsx +62 -0
  80. package/apps/shared/keyboard/ShortcutsDialog.tsx +84 -0
  81. package/apps/shared/keyboard/dispatch.ts +124 -0
  82. package/apps/shared/keyboard/format.ts +89 -0
  83. package/apps/shared/keyboard/keymap.ts +114 -0
  84. package/apps/shared/keyboard/match.ts +44 -0
  85. package/apps/shared/keyboard/parse.ts +136 -0
  86. package/apps/shared/keyboard/platform.ts +34 -0
  87. package/apps/shared/keyboard/registry.ts +65 -0
  88. package/apps/shared/keyboard/targets.ts +79 -0
  89. package/apps/shared/keyboard/useShortcut.ts +50 -0
  90. package/apps/shared/keyboard/useShortcutProps.ts +17 -0
  91. package/apps/shared/mail/folderCounts.ts +308 -0
  92. package/apps/shared/mail/folderTree.ts +143 -0
  93. package/apps/shared/mail/listSnapshots.ts +87 -0
  94. package/apps/shared/mail/messageReadState.ts +85 -0
  95. package/apps/shared/mail/newMailNotifications.ts +183 -0
  96. package/apps/shared/mail/outbox/UnlockBridge.tsx +23 -0
  97. package/apps/shared/mail/outbox/composeBridge.ts +69 -0
  98. package/apps/shared/mail/outbox/outboxState.ts +88 -0
  99. package/apps/shared/mail/outbox/pendingSends.ts +146 -0
  100. package/apps/shared/mail/outbox/sendDecision.ts +157 -0
  101. package/apps/shared/mail/outbox/sendJob.ts +427 -0
  102. package/apps/shared/mail/outbox/sendOutcomes.ts +146 -0
  103. package/apps/shared/mail/outbox/sendState.ts +35 -0
  104. package/apps/shared/mail/outbox/useOutboxStatus.ts +61 -0
  105. package/apps/shared/mail/useMailConnection.ts +203 -0
  106. package/apps/shared/mail/useMailLiveUpdates.ts +277 -224
  107. package/apps/shared/mail/useMarkMessageRead.ts +47 -0
  108. package/apps/shared/mail/useNewMailNotifications.ts +178 -0
  109. package/apps/shared/mail/useUnreadTitle.ts +42 -0
  110. package/apps/shared/navigation/AppRouter.tsx +300 -0
  111. package/apps/shared/navigation/appHrefs.ts +23 -0
  112. package/apps/shared/navigation/frameContext.tsx +35 -0
  113. package/apps/shared/navigation/idle.ts +45 -0
  114. package/apps/shared/navigation/routerContext.tsx +83 -0
  115. package/apps/shared/navigation/routes.ts +72 -0
  116. package/apps/shared/notifications/NotificationCenter.tsx +215 -0
  117. package/apps/shared/notifications/NotificationHistoryDialog.tsx +90 -0
  118. package/apps/shared/notifications/apiErrors.ts +98 -0
  119. package/apps/shared/notifications/headerOffset.ts +35 -0
  120. package/apps/shared/notifications/pushStatus.ts +56 -0
  121. package/apps/shared/notifications/store.ts +549 -0
  122. package/apps/shared/notifications/systemErrors.ts +63 -0
  123. package/apps/shared/notifications/useNotifications.ts +41 -0
  124. package/apps/shared/search/LocalIndexLifecycle.tsx +114 -98
  125. package/apps/shared/signing/enrollmentStorage.ts +33 -0
  126. package/apps/shared/signing/enrollmentTracker.ts +385 -0
  127. package/apps/shared/signing/enrollmentView.ts +251 -0
  128. package/apps/shared/signing/signingInfo.ts +58 -0
  129. package/apps/shared/signing/useNow.ts +19 -0
  130. package/apps/shared/signing/useSigningEnrollmentWatcher.ts +90 -0
  131. package/apps/shared/styles/app.css +108 -10
  132. package/apps/www/_layout.tsx +8 -2
  133. package/apps/www/_routedPage.tsx +24 -0
  134. package/apps/www/_routes.ts +36 -0
  135. package/apps/www/calendar/index.tsx +64 -33
  136. package/apps/www/contacts/[uid].tsx +109 -107
  137. package/apps/www/contacts/index.tsx +62 -42
  138. package/apps/www/index.tsx +2291 -1917
  139. package/apps/www/messages/[uid].tsx +108 -101
  140. package/apps/www/settings/appearance/index.tsx +21 -0
  141. package/apps/www/settings/auto-reply/index.tsx +7 -8
  142. package/apps/www/settings/encryption/index.tsx +1287 -1249
  143. package/apps/www/settings/filters/[uid].tsx +7 -2
  144. package/apps/www/settings/filters/index.tsx +102 -99
  145. package/apps/www/settings/filters/new/index.tsx +140 -133
  146. package/apps/www/settings/labels/index.tsx +204 -201
  147. package/apps/www/settings/privacy/index.tsx +7 -9
  148. package/apps/www/settings/read-receipts/index.tsx +7 -8
  149. package/apps/www/settings/sharing/index.tsx +256 -274
  150. package/apps/www/settings/signatures/[uid].tsx +172 -167
  151. package/apps/www/settings/signatures/index.tsx +88 -85
  152. package/apps/www/settings/signatures/new/index.tsx +135 -129
  153. package/apps/www/tasks/index.tsx +29 -18
  154. package/dist/apps/admin/_layout.d.ts +5 -1
  155. package/dist/apps/admin/_layout.js +3 -2
  156. package/dist/apps/admin/index.js +3 -2
  157. package/dist/apps/admin/ingest-queue/index.js +2 -1
  158. package/dist/apps/admin/mailboxes/[uid].js +9 -6
  159. package/dist/apps/admin/quarantine/index.js +2 -1
  160. package/dist/apps/admin/signing-certificates/index.d.ts +3 -0
  161. package/dist/apps/admin/signing-certificates/index.js +161 -0
  162. package/dist/apps/escrow/_layout.d.ts +5 -1
  163. package/dist/apps/escrow/_layout.js +3 -2
  164. package/dist/apps/shared/appearance/AppearanceForm.d.ts +7 -0
  165. package/dist/apps/shared/appearance/AppearanceForm.js +131 -0
  166. package/dist/apps/shared/appearance/AppearanceHead.d.ts +15 -0
  167. package/dist/apps/shared/appearance/AppearanceHead.js +31 -0
  168. package/dist/apps/shared/appearance/AppearanceProvider.d.ts +32 -0
  169. package/dist/apps/shared/appearance/AppearanceProvider.js +390 -0
  170. package/dist/apps/shared/appearance/ColorField.d.ts +22 -0
  171. package/dist/apps/shared/appearance/ColorField.js +40 -0
  172. package/dist/apps/shared/appearance/appearanceCache.d.ts +45 -0
  173. package/dist/apps/shared/appearance/appearanceCache.js +80 -0
  174. package/dist/apps/shared/appearance/appearanceContext.d.ts +45 -0
  175. package/dist/apps/shared/appearance/appearanceContext.js +29 -0
  176. package/dist/apps/shared/appearance/bootScript.d.ts +16 -0
  177. package/dist/apps/shared/appearance/bootScript.js +33 -0
  178. package/dist/apps/shared/appearance/color.d.ts +65 -0
  179. package/dist/apps/shared/appearance/color.js +132 -0
  180. package/dist/apps/shared/appearance/photo.d.ts +17 -0
  181. package/dist/apps/shared/appearance/photo.js +79 -0
  182. package/dist/apps/shared/appearance/resolvedTheme.d.ts +21 -0
  183. package/dist/apps/shared/appearance/resolvedTheme.js +55 -0
  184. package/dist/apps/shared/appearance/theme.d.ts +111 -0
  185. package/dist/apps/shared/appearance/theme.js +251 -0
  186. package/dist/apps/shared/auth/accountUrl.d.ts +2 -0
  187. package/dist/apps/shared/auth/accountUrl.js +8 -0
  188. package/dist/apps/shared/auth/adminAccess.d.ts +30 -0
  189. package/dist/apps/shared/auth/adminAccess.js +89 -0
  190. package/dist/apps/shared/components/admin/layout/AdminShell.d.ts +1 -1
  191. package/dist/apps/shared/components/admin/layout/AdminShell.js +16 -6
  192. package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.d.ts +10 -5
  193. package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.js +49 -34
  194. package/dist/apps/shared/components/admin/settings/BrandingForm.d.ts +2 -0
  195. package/dist/apps/shared/components/admin/settings/BrandingForm.js +7 -1
  196. package/dist/apps/shared/components/admin/settings/DomainDnsSetup.js +1 -1
  197. package/dist/apps/shared/components/admin/settings/PluginsManager.js +106 -20
  198. package/dist/apps/shared/components/admin/setup/SetupWizard.js +2 -1
  199. package/dist/apps/shared/components/calendar/CalendarListSidebar.js +8 -8
  200. package/dist/apps/shared/components/calendar/layout/CalendarShell.d.ts +1 -1
  201. package/dist/apps/shared/components/calendar/layout/CalendarShell.js +8 -4
  202. package/dist/apps/shared/components/contacts/ContactForm.js +1 -1
  203. package/dist/apps/shared/components/contacts/ContactsSidebar.js +4 -2
  204. package/dist/apps/shared/components/contacts/ContactsToolbar.d.ts +6 -2
  205. package/dist/apps/shared/components/contacts/ContactsToolbar.js +28 -10
  206. package/dist/apps/shared/components/contacts/layout/ContactsShell.d.ts +1 -1
  207. package/dist/apps/shared/components/contacts/layout/ContactsShell.js +19 -6
  208. package/dist/apps/shared/components/escrow/layout/EscrowShell.js +7 -4
  209. package/dist/apps/shared/components/layout/AppShell.d.ts +34 -4
  210. package/dist/apps/shared/components/layout/AppShell.js +122 -17
  211. package/dist/apps/shared/components/layout/BrandingChrome.d.ts +69 -10
  212. package/dist/apps/shared/components/layout/BrandingChrome.js +140 -12
  213. package/dist/apps/shared/components/layout/KeyEnrollmentGate.js +10 -9
  214. package/dist/apps/shared/components/layout/MailboxProvisioning.js +3 -1
  215. package/dist/apps/shared/components/layout/RailIcon.d.ts +21 -0
  216. package/dist/apps/shared/components/layout/RailIcon.js +85 -0
  217. package/dist/apps/shared/components/layout/ResponsiveToolbar.d.ts +55 -0
  218. package/dist/apps/shared/components/layout/ResponsiveToolbar.js +199 -0
  219. package/dist/apps/shared/components/layout/ThemeSwitch.d.ts +9 -0
  220. package/dist/apps/shared/components/layout/ThemeSwitch.js +54 -0
  221. package/dist/apps/shared/components/layout/UserMenu.d.ts +25 -3
  222. package/dist/apps/shared/components/layout/UserMenu.js +88 -7
  223. package/dist/apps/shared/components/mail/ConversationList.js +5 -11
  224. package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +6 -2
  225. package/dist/apps/shared/components/mail/ConversationThreadPane.js +87 -40
  226. package/dist/apps/shared/components/mail/LazyReadingPane.d.ts +9 -0
  227. package/dist/apps/shared/components/mail/LazyReadingPane.js +83 -0
  228. package/dist/apps/shared/components/mail/MailSelectionBar.d.ts +6 -4
  229. package/dist/apps/shared/components/mail/MailSelectionBar.js +11 -4
  230. package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +25 -8
  231. package/dist/apps/shared/components/mail/MessageDetailPane.js +167 -73
  232. package/dist/apps/shared/components/mail/OutboxBadge.d.ts +17 -0
  233. package/dist/apps/shared/components/mail/OutboxBadge.js +18 -0
  234. package/dist/apps/shared/components/mail/OutboxRowStatus.d.ts +10 -0
  235. package/dist/apps/shared/components/mail/OutboxRowStatus.js +19 -0
  236. package/dist/apps/shared/components/mail/compose/ComposeContext.d.ts +38 -0
  237. package/dist/apps/shared/components/mail/compose/ComposeContext.js +97 -6
  238. package/dist/apps/shared/components/mail/compose/ComposeToolbar.js +4 -3
  239. package/dist/apps/shared/components/mail/compose/ComposeWindow.d.ts +3 -2
  240. package/dist/apps/shared/components/mail/compose/ComposeWindow.js +316 -339
  241. package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.d.ts +19 -0
  242. package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.js +33 -0
  243. package/dist/apps/shared/components/mail/compose/RichTextEditor.d.ts +9 -1
  244. package/dist/apps/shared/components/mail/compose/RichTextEditor.js +20 -2
  245. package/dist/apps/shared/components/mail/compose/composePerf.d.ts +16 -0
  246. package/dist/apps/shared/components/mail/compose/composePerf.js +41 -0
  247. package/dist/apps/shared/components/mail/compose/encryptionRequirement.d.ts +49 -0
  248. package/dist/apps/shared/components/mail/compose/encryptionRequirement.js +35 -0
  249. package/dist/apps/shared/components/mail/compose/quotedBody.d.ts +13 -0
  250. package/dist/apps/shared/components/mail/compose/quotedBody.js +67 -11
  251. package/dist/apps/shared/components/mail/layout/MailShell.d.ts +14 -4
  252. package/dist/apps/shared/components/mail/layout/MailShell.js +90 -104
  253. package/dist/apps/shared/components/mail/reading/EncryptedBody.d.ts +21 -0
  254. package/dist/apps/shared/components/mail/reading/EncryptedBody.js +22 -0
  255. package/dist/apps/shared/components/mail/reading/EncryptedPreview.d.ts +18 -0
  256. package/dist/apps/shared/components/mail/reading/EncryptedPreview.js +22 -0
  257. package/dist/apps/shared/components/mail/reading/MessageBody.d.ts +32 -0
  258. package/dist/apps/shared/components/mail/reading/MessageBody.js +136 -0
  259. package/dist/apps/shared/components/mail/reading/MessageCard.d.ts +62 -0
  260. package/dist/apps/shared/components/mail/reading/MessageCard.js +58 -0
  261. package/dist/apps/shared/components/mail/reading/bodyContent.d.ts +38 -0
  262. package/dist/apps/shared/components/mail/reading/bodyContent.js +84 -0
  263. package/dist/apps/shared/components/mail/reading/bodyHtml.d.ts +47 -0
  264. package/dist/apps/shared/components/mail/reading/bodyHtml.js +267 -0
  265. package/dist/apps/shared/components/mail/reading/color.d.ts +63 -0
  266. package/dist/apps/shared/components/mail/reading/color.js +201 -0
  267. package/dist/apps/shared/components/mail/reading/frameControl.d.ts +33 -0
  268. package/dist/apps/shared/components/mail/reading/frameControl.js +120 -0
  269. package/dist/apps/shared/components/mail/reading/frameDocument.d.ts +52 -0
  270. package/dist/apps/shared/components/mail/reading/frameDocument.js +98 -0
  271. package/dist/apps/shared/components/mail/reading/safeDocument.d.ts +3 -0
  272. package/dist/apps/shared/components/mail/reading/safeDocument.js +12 -0
  273. package/dist/apps/shared/components/mail/reading/themeAdaptation.d.ts +56 -0
  274. package/dist/apps/shared/components/mail/reading/themeAdaptation.js +144 -0
  275. package/dist/apps/shared/components/mail/reading/themeSurface.d.ts +17 -0
  276. package/dist/apps/shared/components/mail/reading/themeSurface.js +83 -0
  277. package/dist/apps/shared/components/mail/reading/viewOriginal.d.ts +9 -0
  278. package/dist/apps/shared/components/mail/reading/viewOriginal.js +32 -0
  279. package/dist/apps/shared/components/mail/unreadStyle.d.ts +45 -0
  280. package/dist/apps/shared/components/mail/unreadStyle.js +61 -0
  281. package/dist/apps/shared/components/settings/SigningCertificateCard.d.ts +32 -0
  282. package/dist/apps/shared/components/settings/SigningCertificateCard.js +98 -0
  283. package/dist/apps/shared/components/settings/layout/SettingsShell.d.ts +1 -1
  284. package/dist/apps/shared/components/settings/layout/SettingsShell.js +16 -5
  285. package/dist/apps/shared/components/sharing/PrincipalPicker.d.ts +26 -0
  286. package/dist/apps/shared/components/sharing/PrincipalPicker.js +77 -0
  287. package/dist/apps/shared/components/tasks/TasksSidebar.js +4 -2
  288. package/dist/apps/shared/components/tasks/layout/TasksShell.d.ts +1 -1
  289. package/dist/apps/shared/components/tasks/layout/TasksShell.js +18 -6
  290. package/dist/apps/shared/keyboard/GlobalShortcuts.d.ts +14 -0
  291. package/dist/apps/shared/keyboard/GlobalShortcuts.js +37 -0
  292. package/dist/apps/shared/keyboard/ShortcutProvider.d.ts +20 -0
  293. package/dist/apps/shared/keyboard/ShortcutProvider.js +52 -0
  294. package/dist/apps/shared/keyboard/ShortcutsDialog.d.ts +14 -0
  295. package/dist/apps/shared/keyboard/ShortcutsDialog.js +42 -0
  296. package/dist/apps/shared/keyboard/dispatch.d.ts +16 -0
  297. package/dist/apps/shared/keyboard/dispatch.js +109 -0
  298. package/dist/apps/shared/keyboard/format.d.ts +12 -0
  299. package/dist/apps/shared/keyboard/format.js +74 -0
  300. package/dist/apps/shared/keyboard/keymap.d.ts +294 -0
  301. package/dist/apps/shared/keyboard/keymap.js +84 -0
  302. package/dist/apps/shared/keyboard/match.d.ts +20 -0
  303. package/dist/apps/shared/keyboard/match.js +31 -0
  304. package/dist/apps/shared/keyboard/parse.d.ts +31 -0
  305. package/dist/apps/shared/keyboard/parse.js +107 -0
  306. package/dist/apps/shared/keyboard/platform.d.ts +15 -0
  307. package/dist/apps/shared/keyboard/platform.js +22 -0
  308. package/dist/apps/shared/keyboard/registry.d.ts +39 -0
  309. package/dist/apps/shared/keyboard/registry.js +33 -0
  310. package/dist/apps/shared/keyboard/targets.d.ts +14 -0
  311. package/dist/apps/shared/keyboard/targets.js +67 -0
  312. package/dist/apps/shared/keyboard/useShortcut.d.ts +19 -0
  313. package/dist/apps/shared/keyboard/useShortcut.js +35 -0
  314. package/dist/apps/shared/keyboard/useShortcutProps.d.ts +10 -0
  315. package/dist/apps/shared/keyboard/useShortcutProps.js +15 -0
  316. package/dist/apps/shared/mail/folderCounts.d.ts +78 -0
  317. package/dist/apps/shared/mail/folderCounts.js +218 -0
  318. package/dist/apps/shared/mail/folderTree.d.ts +55 -0
  319. package/dist/apps/shared/mail/folderTree.js +116 -0
  320. package/dist/apps/shared/mail/listSnapshots.d.ts +46 -0
  321. package/dist/apps/shared/mail/listSnapshots.js +43 -0
  322. package/dist/apps/shared/mail/messageReadState.d.ts +32 -0
  323. package/dist/apps/shared/mail/messageReadState.js +63 -0
  324. package/dist/apps/shared/mail/newMailNotifications.d.ts +62 -0
  325. package/dist/apps/shared/mail/newMailNotifications.js +138 -0
  326. package/dist/apps/shared/mail/outbox/UnlockBridge.d.ts +5 -0
  327. package/dist/apps/shared/mail/outbox/UnlockBridge.js +18 -0
  328. package/dist/apps/shared/mail/outbox/composeBridge.d.ts +34 -0
  329. package/dist/apps/shared/mail/outbox/composeBridge.js +32 -0
  330. package/dist/apps/shared/mail/outbox/outboxState.d.ts +41 -0
  331. package/dist/apps/shared/mail/outbox/outboxState.js +42 -0
  332. package/dist/apps/shared/mail/outbox/pendingSends.d.ts +39 -0
  333. package/dist/apps/shared/mail/outbox/pendingSends.js +109 -0
  334. package/dist/apps/shared/mail/outbox/sendDecision.d.ts +80 -0
  335. package/dist/apps/shared/mail/outbox/sendDecision.js +94 -0
  336. package/dist/apps/shared/mail/outbox/sendJob.d.ts +68 -0
  337. package/dist/apps/shared/mail/outbox/sendJob.js +319 -0
  338. package/dist/apps/shared/mail/outbox/sendOutcomes.d.ts +3 -0
  339. package/dist/apps/shared/mail/outbox/sendOutcomes.js +141 -0
  340. package/dist/apps/shared/mail/outbox/sendState.d.ts +25 -0
  341. package/dist/apps/shared/mail/outbox/sendState.js +8 -0
  342. package/dist/apps/shared/mail/outbox/useOutboxStatus.d.ts +11 -0
  343. package/dist/apps/shared/mail/outbox/useOutboxStatus.js +49 -0
  344. package/dist/apps/shared/mail/useMailConnection.d.ts +56 -0
  345. package/dist/apps/shared/mail/useMailConnection.js +138 -0
  346. package/dist/apps/shared/mail/useMailLiveUpdates.d.ts +29 -9
  347. package/dist/apps/shared/mail/useMailLiveUpdates.js +60 -32
  348. package/dist/apps/shared/mail/useMarkMessageRead.d.ts +12 -0
  349. package/dist/apps/shared/mail/useMarkMessageRead.js +44 -0
  350. package/dist/apps/shared/mail/useNewMailNotifications.d.ts +35 -0
  351. package/dist/apps/shared/mail/useNewMailNotifications.js +130 -0
  352. package/dist/apps/shared/mail/useUnreadTitle.d.ts +18 -0
  353. package/dist/apps/shared/mail/useUnreadTitle.js +31 -0
  354. package/dist/apps/shared/navigation/AppRouter.d.ts +52 -0
  355. package/dist/apps/shared/navigation/AppRouter.js +242 -0
  356. package/dist/apps/shared/navigation/appHrefs.d.ts +14 -0
  357. package/dist/apps/shared/navigation/appHrefs.js +20 -0
  358. package/dist/apps/shared/navigation/frameContext.d.ts +19 -0
  359. package/dist/apps/shared/navigation/frameContext.js +24 -0
  360. package/dist/apps/shared/navigation/idle.d.ts +14 -0
  361. package/dist/apps/shared/navigation/idle.js +43 -0
  362. package/dist/apps/shared/navigation/routerContext.d.ts +37 -0
  363. package/dist/apps/shared/navigation/routerContext.js +56 -0
  364. package/dist/apps/shared/navigation/routes.d.ts +32 -0
  365. package/dist/apps/shared/navigation/routes.js +37 -0
  366. package/dist/apps/shared/notifications/NotificationCenter.d.ts +19 -0
  367. package/dist/apps/shared/notifications/NotificationCenter.js +90 -0
  368. package/dist/apps/shared/notifications/NotificationHistoryDialog.d.ts +10 -0
  369. package/dist/apps/shared/notifications/NotificationHistoryDialog.js +36 -0
  370. package/dist/apps/shared/notifications/apiErrors.d.ts +19 -0
  371. package/dist/apps/shared/notifications/apiErrors.js +86 -0
  372. package/dist/apps/shared/notifications/headerOffset.d.ts +8 -0
  373. package/dist/apps/shared/notifications/headerOffset.js +33 -0
  374. package/dist/apps/shared/notifications/pushStatus.d.ts +9 -0
  375. package/dist/apps/shared/notifications/pushStatus.js +54 -0
  376. package/dist/apps/shared/notifications/store.d.ts +136 -0
  377. package/dist/apps/shared/notifications/store.js +416 -0
  378. package/dist/apps/shared/notifications/systemErrors.d.ts +9 -0
  379. package/dist/apps/shared/notifications/systemErrors.js +58 -0
  380. package/dist/apps/shared/notifications/useNotifications.d.ts +17 -0
  381. package/dist/apps/shared/notifications/useNotifications.js +18 -0
  382. package/dist/apps/shared/search/LocalIndexLifecycle.js +17 -3
  383. package/dist/apps/shared/signing/enrollmentStorage.d.ts +10 -0
  384. package/dist/apps/shared/signing/enrollmentStorage.js +33 -0
  385. package/dist/apps/shared/signing/enrollmentTracker.d.ts +73 -0
  386. package/dist/apps/shared/signing/enrollmentTracker.js +307 -0
  387. package/dist/apps/shared/signing/enrollmentView.d.ts +57 -0
  388. package/dist/apps/shared/signing/enrollmentView.js +214 -0
  389. package/dist/apps/shared/signing/signingInfo.d.ts +11 -0
  390. package/dist/apps/shared/signing/signingInfo.js +48 -0
  391. package/dist/apps/shared/signing/useNow.d.ts +2 -0
  392. package/dist/apps/shared/signing/useNow.js +18 -0
  393. package/dist/apps/shared/signing/useSigningEnrollmentWatcher.d.ts +16 -0
  394. package/dist/apps/shared/signing/useSigningEnrollmentWatcher.js +87 -0
  395. package/dist/apps/shared/styles/app.css +108 -10
  396. package/dist/apps/www/_layout.d.ts +5 -1
  397. package/dist/apps/www/_layout.js +3 -2
  398. package/dist/apps/www/_routedPage.d.ts +12 -0
  399. package/dist/apps/www/_routedPage.js +19 -0
  400. package/dist/apps/www/_routes.d.ts +11 -0
  401. package/dist/apps/www/_routes.js +30 -0
  402. package/dist/apps/www/calendar/index.d.ts +2 -2
  403. package/dist/apps/www/calendar/index.js +41 -11
  404. package/dist/apps/www/contacts/[uid].d.ts +3 -9
  405. package/dist/apps/www/contacts/[uid].js +11 -9
  406. package/dist/apps/www/contacts/index.d.ts +2 -2
  407. package/dist/apps/www/contacts/index.js +30 -24
  408. package/dist/apps/www/index.d.ts +2 -2
  409. package/dist/apps/www/index.js +332 -48
  410. package/dist/apps/www/messages/[uid].d.ts +3 -7
  411. package/dist/apps/www/messages/[uid].js +10 -5
  412. package/dist/apps/www/settings/appearance/index.d.ts +4 -0
  413. package/dist/apps/www/settings/appearance/index.js +13 -0
  414. package/dist/apps/www/settings/auto-reply/index.d.ts +2 -2
  415. package/dist/apps/www/settings/auto-reply/index.js +6 -7
  416. package/dist/apps/www/settings/encryption/index.d.ts +2 -2
  417. package/dist/apps/www/settings/encryption/index.js +106 -96
  418. package/dist/apps/www/settings/filters/[uid].d.ts +2 -2
  419. package/dist/apps/www/settings/filters/[uid].js +6 -2
  420. package/dist/apps/www/settings/filters/index.d.ts +2 -2
  421. package/dist/apps/www/settings/filters/index.js +3 -1
  422. package/dist/apps/www/settings/filters/new/index.d.ts +2 -2
  423. package/dist/apps/www/settings/filters/new/index.js +9 -3
  424. package/dist/apps/www/settings/labels/index.d.ts +2 -2
  425. package/dist/apps/www/settings/labels/index.js +3 -1
  426. package/dist/apps/www/settings/privacy/index.d.ts +2 -2
  427. package/dist/apps/www/settings/privacy/index.js +8 -9
  428. package/dist/apps/www/settings/read-receipts/index.d.ts +2 -2
  429. package/dist/apps/www/settings/read-receipts/index.js +6 -7
  430. package/dist/apps/www/settings/sharing/index.d.ts +2 -2
  431. package/dist/apps/www/settings/sharing/index.js +22 -34
  432. package/dist/apps/www/settings/signatures/[uid].d.ts +2 -2
  433. package/dist/apps/www/settings/signatures/[uid].js +6 -2
  434. package/dist/apps/www/settings/signatures/index.d.ts +2 -2
  435. package/dist/apps/www/settings/signatures/index.js +3 -1
  436. package/dist/apps/www/settings/signatures/new/index.d.ts +2 -2
  437. package/dist/apps/www/settings/signatures/new/index.js +9 -4
  438. package/dist/apps/www/tasks/index.d.ts +2 -2
  439. package/dist/apps/www/tasks/index.js +22 -16
  440. package/package.json +2 -2
  441. package/apps/shared/components/mail/compose/SendFailureAlert.tsx +0 -48
  442. package/dist/apps/shared/components/mail/compose/SendFailureAlert.d.ts +0 -14
  443. package/dist/apps/shared/components/mail/compose/SendFailureAlert.js +0 -11
@@ -1,240 +1,253 @@
1
- ///////////////////////////////////////////////////////////////////////////////
2
- // Copyright (C) 2026 Jean-Philippe Steinmetz
3
- // SPDX-License-Identifier: MPL-2.0
4
- ///////////////////////////////////////////////////////////////////////////////
5
- import React, { createContext, PropsWithChildren, ReactNode, useContext, useEffect, useMemo, useState } from "react";
6
- import { HiOutlineBars3 } from "react-icons/hi2";
7
- import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
8
- import Drawer from "@rapidmx/react-shared/components/overlays/Drawer.js";
9
- import { Mailbox, listMailboxes } from "@rapidmx/react-shared/mail/mailApi.js";
10
- import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
11
- import Skeleton, { SkeletonList } from "@rapidmx/react-shared/components/feedback/Skeleton.js";
12
- import AppShell, { AppShellProps } from "../../layout/AppShell.js";
13
- import MailboxProvisioning from "../../layout/MailboxProvisioning.js";
14
- import { mergePluginNavItems, PluginNav } from "../../../plugins/pluginNav.js";
15
-
16
- export interface SettingsSectionDef {
17
- id: string;
18
- href: string;
19
- label: string;
20
- }
21
-
22
- /** Every settings section with its own sidebar entry. */
23
- export const SETTINGS_SECTIONS: SettingsSectionDef[] = [
24
- { id: "auto-reply", href: "/settings/auto-reply", label: "Automatic Replies" },
25
- { id: "filters", href: "/settings/filters", label: "Mail Filters" },
26
- { id: "signatures", href: "/settings/signatures", label: "Signatures" },
27
- { id: "labels", href: "/settings/labels", label: "Labels" },
28
- { id: "read-receipts", href: "/settings/read-receipts", label: "Read Receipts" },
29
- { id: "encryption", href: "/settings/encryption", label: "Encryption" },
30
- { id: "sharing", href: "/settings/sharing", label: "Sharing" },
31
- { id: "privacy", href: "/settings/privacy", label: "Privacy & Data" },
32
- ];
33
-
34
- /** A `SETTINGS_SECTIONS` id, or a plugin's `settingsSections` item id (see `PluginNav`). */
35
- export type SettingsSectionId = string;
36
-
37
- /** `SETTINGS_SECTIONS` followed by the plugins' `settingsSections` items, core ids winning - see
38
- * `mergePluginNavItems`. */
39
- export function settingsSections(pluginNav?: PluginNav): SettingsSectionDef[] {
40
- return mergePluginNavItems<SettingsSectionDef>(SETTINGS_SECTIONS, pluginNav?.settingsSections, ({ id, href, label }) => ({
41
- id,
42
- href,
43
- label,
44
- }));
45
- }
46
-
47
- export interface SettingsShellProps extends Omit<AppShellProps, "active"> {
48
- /** Which entry in `SETTINGS_SECTIONS` (or plugin `settingsSections` item) is highlighted in this shell's own sidebar — distinct from
49
- * `AppShell`'s own `active` (always hardcoded to `"settings"` below), since Settings isn't a rail
50
- * icon (see `AppShell.tsx`'s `AppShellApp` doc comment) but still needs its own section
51
- * highlighting. Each settings page passes its own section id explicitly, the same "gotcha" this
52
- * plan already calls out for every shell's `active` prop. */
53
- active: SettingsSectionId;
54
- }
55
-
56
- export interface SettingsShellContextValue {
57
- /** The mailbox currently selected (`?mailboxUid=`, or the caller's first accessible mailbox) —
58
- * every settings section so far (Automatic Replies) edits mailbox-scoped fields. */
59
- mailboxUid?: string;
60
- mailboxes: Mailbox[];
61
- }
62
-
63
- const SettingsShellContext = createContext<SettingsShellContextValue>({ mailboxes: [] });
64
-
65
- /** Reads the mailbox Settings is currently scoped to, as resolved by the enclosing `SettingsShell`. */
66
- export function useSettingsShell(): SettingsShellContextValue {
67
- return useContext(SettingsShellContext);
68
- }
69
-
70
- type Status = "checking" | "error" | "ready";
71
-
72
- /**
73
- * The Settings area's shell — reached via a `UserMenu` entry rather than a 5th `AppShell` icon (per
74
- * this plan's own confirmed decision), so it always passes `active="settings"` to `AppShell` regardless
75
- * of which section is showing. Unlike `ContactsShell`/`TasksShell` (whose sidebar is just a mailbox
76
- * switcher, since each has exactly one well-known folder), this shell's sidebar is a real list of
77
- * settings sections (`SETTINGS_SECTIONS`) — full-page navigation between them, same as the top-level
78
- * app rail, since this framework has no client-side router.
79
- */
80
- export default function SettingsShell({
81
- active,
82
- userUid,
83
- authServerUrl,
84
- impersonating,
85
- impersonationBaseUrl,
86
- trusted,
87
- pluginNav,
88
- children,
89
- }: PropsWithChildren<SettingsShellProps>) {
90
- const [status, setStatus] = useState<Status>("checking");
91
- const [error, setError] = useState<string | null>(null);
92
- const [mailboxes, setMailboxes] = useState<Mailbox[]>([]);
93
- const [requestedMailboxUid, setRequestedMailboxUid] = useState<string | null>(null);
94
- const [drawerOpen, setDrawerOpen] = useState(false);
95
-
96
- useEffect(() => {
97
- setRequestedMailboxUid(new URLSearchParams(window.location.search).get("mailboxUid"));
98
- }, []);
99
-
100
- useEffect(() => {
101
- if (!userUid) {
102
- return;
103
- }
104
- listMailboxes({ limit: 100 })
105
- .then((result) => {
106
- setMailboxes(result);
107
- setStatus("ready");
108
- })
109
- .catch((err) => {
110
- setError(err instanceof ApiRequestError ? err.message : "Could not load your mailboxes.");
111
- setStatus("error");
112
- });
113
- }, [userUid]);
114
-
115
- const mailboxUid: string | undefined =
116
- (requestedMailboxUid && mailboxes.some((mb) => mb.uid === requestedMailboxUid) ? requestedMailboxUid : undefined) ??
117
- mailboxes[0]?.uid;
118
-
119
- const contextValue = useMemo<SettingsShellContextValue>(() => ({ mailboxUid, mailboxes }), [mailboxUid, mailboxes]);
120
-
121
- // A full-screen takeover, not nested inside the rest of the app's chrome — same as ContactsShell/
122
- // TasksShell, there's nothing else for a mailbox-less caller to configure here yet.
123
- if (userUid && status === "ready" && !mailboxUid) {
124
- return <MailboxProvisioning />;
125
- }
126
-
127
- let inner: ReactNode = null;
128
- if (userUid && status === "checking") {
129
- inner = (
130
- <div className="w-56 shrink-0 border-r border-border flex flex-col gap-4 p-3">
131
- <Skeleton height="h-9" />
132
- <SkeletonList count={3} />
133
- </div>
134
- );
135
- } else if (userUid && status === "error") {
136
- inner = (
137
- <div className="flex-1 flex items-center justify-center p-8">
138
- <div className="w-full max-w-md">
139
- <Alert>{error}</Alert>
140
- </div>
141
- </div>
142
- );
143
- } else if (userUid && status === "ready") {
144
- const sections = settingsSections(pluginNav);
145
- // A function, not a plain JSX constant — same reasoning as ContactsShell's identical comment:
146
- // rendered twice (desktop `<aside>` + mobile `Drawer`), possibly simultaneously mounted, so the
147
- // `<select>`'s `id`/its `<label>`'s `htmlFor` need a distinct value per instance.
148
- const sidebarContent = (idPrefix: string) => (
149
- <>
150
- {mailboxes.length > 1 && (
151
- <div>
152
- <label
153
- className="block text-xs font-bold uppercase tracking-wide text-text-muted mb-1"
154
- htmlFor={`${idPrefix}-settings-mailbox-switcher`}
155
- >
156
- Mailbox
157
- </label>
158
- <select
159
- id={`${idPrefix}-settings-mailbox-switcher`}
160
- className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
161
- value={mailboxUid}
162
- onChange={(e) => {
163
- // Every core settings page passes its own section id (see
164
- // `SettingsShellProps.active`), but a plugin page's section is missing when the
165
- // server didn't send its nav item, so that falls back to the current path.
166
- const href = sections.find((s) => s.id === active)?.href ?? window.location.pathname;
167
- window.location.href = `${href}?mailboxUid=${encodeURIComponent(e.target.value)}`;
168
- }}
169
- >
170
- {mailboxes.map((mb) => (
171
- <option key={mb.uid} value={mb.uid}>
172
- {mb.displayName}
173
- {mb.ownerUserUid ? "" : " (shared)"}
174
- </option>
175
- ))}
176
- </select>
177
- </div>
178
- )}
179
- <nav aria-label="Settings sections" className="flex flex-col gap-0.5">
180
- {sections.map((section) => (
181
- <a
182
- key={section.id}
183
- // `inner` (this whole branch) is only ever computed once `status === "ready"`
184
- // and `mailboxUid` has already resolved truthy — a falsy `mailboxUid` returns
185
- // `<MailboxProvisioning />` above instead (and TypeScript's own narrowing of
186
- // this `const` already reflects that, no `!` needed) — so no fallback is
187
- // needed here, matching this plan's established "dead guard the UI
188
- // structurally can't trigger" removal precedent (e.g.
189
- // `DomainDetailContent.handleVerify`).
190
- href={`${section.href}?mailboxUid=${encodeURIComponent(mailboxUid)}`}
191
- aria-current={section.id === active ? "page" : undefined}
192
- className={[
193
- "block px-2.5 py-1.5 rounded-sm text-sm",
194
- section.id === active ? "bg-primary/10 text-primary-dark font-medium" : "text-text hover:bg-surface-alt",
195
- ].join(" ")}
196
- >
197
- {section.label}
198
- </a>
199
- ))}
200
- </nav>
201
- </>
202
- );
203
-
204
- inner = (
205
- <>
206
- <aside className="hidden md:flex w-56 shrink-0 bg-surface border-r border-border flex-col p-3 gap-3">
207
- {sidebarContent("desktop")}
208
- </aside>
209
- <Drawer open={drawerOpen} onClose={() => setDrawerOpen(false)} title="Settings">
210
- <div className="flex flex-col gap-3">{sidebarContent("mobile")}</div>
211
- </Drawer>
212
- <main className="flex-1 min-w-0 flex flex-col">
213
- <button
214
- type="button"
215
- className="md:hidden m-3 self-start w-9 h-9 flex items-center justify-center rounded-sm text-text-muted hover:bg-surface-alt hover:text-text"
216
- aria-label="Open settings menu"
217
- onClick={() => setDrawerOpen(true)}
218
- >
219
- <HiOutlineBars3 size={20} aria-hidden="true" />
220
- </button>
221
- <SettingsShellContext.Provider value={contextValue}>{children}</SettingsShellContext.Provider>
222
- </main>
223
- </>
224
- );
225
- }
226
-
227
- return (
228
- <AppShell
229
- active="settings"
230
- userUid={userUid}
231
- authServerUrl={authServerUrl}
232
- impersonating={impersonating}
233
- impersonationBaseUrl={impersonationBaseUrl}
234
- trusted={trusted}
235
- pluginNav={pluginNav}
236
- >
237
- {inner}
238
- </AppShell>
239
- );
240
- }
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import React, { createContext, PropsWithChildren, ReactNode, useContext, useEffect, useMemo, useState } from "react";
6
+ import { HiOutlineBars3 } from "react-icons/hi2";
7
+ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
8
+ import Drawer from "@rapidmx/react-shared/components/overlays/Drawer.js";
9
+ import { Mailbox, listMailboxes } from "@rapidmx/react-shared/mail/mailApi.js";
10
+ import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
11
+ import Skeleton, { SkeletonList } from "@rapidmx/react-shared/components/feedback/Skeleton.js";
12
+ import AppShell, { AppShellProps } from "../../layout/AppShell.js";
13
+ import { useLocationSearch, useNavigate } from "../../../navigation/AppRouter.js";
14
+ import MailboxProvisioning from "../../layout/MailboxProvisioning.js";
15
+ import { mergePluginNavItems, PluginNav } from "../../../plugins/pluginNav.js";
16
+
17
+ export interface SettingsSectionDef {
18
+ id: string;
19
+ href: string;
20
+ label: string;
21
+ }
22
+
23
+ /** Every settings section with its own sidebar entry. */
24
+ export const SETTINGS_SECTIONS: SettingsSectionDef[] = [
25
+ { id: "appearance", href: "/settings/appearance", label: "Appearance" },
26
+ { id: "auto-reply", href: "/settings/auto-reply", label: "Automatic Replies" },
27
+ { id: "filters", href: "/settings/filters", label: "Mail Filters" },
28
+ { id: "signatures", href: "/settings/signatures", label: "Signatures" },
29
+ { id: "labels", href: "/settings/labels", label: "Labels" },
30
+ { id: "read-receipts", href: "/settings/read-receipts", label: "Read Receipts" },
31
+ { id: "encryption", href: "/settings/encryption", label: "Encryption" },
32
+ { id: "sharing", href: "/settings/sharing", label: "Sharing" },
33
+ { id: "privacy", href: "/settings/privacy", label: "Privacy & Data" },
34
+ ];
35
+
36
+ /** A `SETTINGS_SECTIONS` id, or a plugin's `settingsSections` item id (see `PluginNav`). */
37
+ export type SettingsSectionId = string;
38
+
39
+ /** `SETTINGS_SECTIONS` followed by the plugins' `settingsSections` items, core ids winning - see
40
+ * `mergePluginNavItems`. */
41
+ export function settingsSections(pluginNav?: PluginNav): SettingsSectionDef[] {
42
+ return mergePluginNavItems<SettingsSectionDef>(SETTINGS_SECTIONS, pluginNav?.settingsSections, ({ id, href, label }) => ({
43
+ id,
44
+ href,
45
+ label,
46
+ }));
47
+ }
48
+
49
+ export interface SettingsShellProps extends Omit<AppShellProps, "active"> {
50
+ /** Which entry in `SETTINGS_SECTIONS` (or plugin `settingsSections` item) is highlighted in this shell's own sidebar — distinct from
51
+ * `AppShell`'s own `active` (always hardcoded to `"settings"` below), since Settings isn't a rail
52
+ * icon (see `AppShell.tsx`'s `AppShellApp` doc comment) but still needs its own section
53
+ * highlighting. Each settings page passes its own section id explicitly, the same "gotcha" this
54
+ * plan already calls out for every shell's `active` prop. */
55
+ active: SettingsSectionId;
56
+ }
57
+
58
+ export interface SettingsShellContextValue {
59
+ /** The mailbox currently selected (`?mailboxUid=`, or the caller's first accessible mailbox) —
60
+ * every settings section so far (Automatic Replies) edits mailbox-scoped fields. */
61
+ mailboxUid?: string;
62
+ mailboxes: Mailbox[];
63
+ }
64
+
65
+ const SettingsShellContext = createContext<SettingsShellContextValue>({ mailboxes: [] });
66
+
67
+ /** Reads the mailbox Settings is currently scoped to, as resolved by the enclosing `SettingsShell`. */
68
+ export function useSettingsShell(): SettingsShellContextValue {
69
+ return useContext(SettingsShellContext);
70
+ }
71
+
72
+ type Status = "checking" | "error" | "ready";
73
+
74
+ /**
75
+ * The Settings area's shell — reached via a `UserMenu` entry rather than a 5th `AppShell` icon (per
76
+ * this plan's own confirmed decision), so it always passes `active="settings"` to `AppShell` regardless
77
+ * of which section is showing. Unlike `ContactsShell`/`TasksShell` (whose sidebar is just a mailbox
78
+ * switcher, since each has exactly one well-known folder), this shell's sidebar is a real list of
79
+ * settings sections (`SETTINGS_SECTIONS`) — full-page navigation between them, same as the top-level
80
+ * app rail, since this framework has no client-side router.
81
+ */
82
+ export default function SettingsShell({
83
+ active,
84
+ userUid,
85
+ authServerUrl,
86
+ impersonating,
87
+ impersonationBaseUrl,
88
+ trusted,
89
+ trustedRoles,
90
+ pluginNav,
91
+ children,
92
+ }: PropsWithChildren<SettingsShellProps>) {
93
+ const [status, setStatus] = useState<Status>("checking");
94
+ const [error, setError] = useState<string | null>(null);
95
+ const [mailboxes, setMailboxes] = useState<Mailbox[]>([]);
96
+ const [requestedMailboxUid, setRequestedMailboxUid] = useState<string | null>(null);
97
+ const [drawerOpen, setDrawerOpen] = useState(false);
98
+
99
+ // Read from the router's location, so a mailbox change (a link, or `navigate()`) takes effect without a page load - and in an
100
+ // effect, not during render, so the server render and the hydrating render agree.
101
+ const search = useLocationSearch();
102
+ const navigate = useNavigate();
103
+ useEffect(() => {
104
+ setRequestedMailboxUid(new URLSearchParams(search).get("mailboxUid"));
105
+ }, [search]);
106
+ // Choosing a folder (or mailbox) changes the URL without a page load now, so the drawer that held the choice - which used to go
107
+ // with the page - is closed here.
108
+ useEffect(() => {
109
+ setDrawerOpen(false);
110
+ }, [search]);
111
+
112
+ useEffect(() => {
113
+ if (!userUid) {
114
+ return;
115
+ }
116
+ listMailboxes({ limit: 100 })
117
+ .then((result) => {
118
+ setMailboxes(result);
119
+ setStatus("ready");
120
+ })
121
+ .catch((err) => {
122
+ setError(err instanceof ApiRequestError ? err.message : "Could not load your mailboxes.");
123
+ setStatus("error");
124
+ });
125
+ }, [userUid]);
126
+
127
+ const mailboxUid: string | undefined =
128
+ (requestedMailboxUid && mailboxes.some((mb) => mb.uid === requestedMailboxUid) ? requestedMailboxUid : undefined) ??
129
+ mailboxes[0]?.uid;
130
+
131
+ const contextValue = useMemo<SettingsShellContextValue>(() => ({ mailboxUid, mailboxes }), [mailboxUid, mailboxes]);
132
+
133
+ // A full-screen takeover, not nested inside the rest of the app's chrome — same as ContactsShell/
134
+ // TasksShell, there's nothing else for a mailbox-less caller to configure here yet.
135
+ if (userUid && status === "ready" && !mailboxUid) {
136
+ return <MailboxProvisioning />;
137
+ }
138
+
139
+ let inner: ReactNode = null;
140
+ if (userUid && status === "checking") {
141
+ inner = (
142
+ <div className="w-56 shrink-0 border-r border-border flex flex-col gap-4 p-3">
143
+ <Skeleton height="h-9" />
144
+ <SkeletonList count={3} />
145
+ </div>
146
+ );
147
+ } else if (userUid && status === "error") {
148
+ inner = (
149
+ <div className="flex-1 flex items-center justify-center p-8">
150
+ <div className="w-full max-w-md">
151
+ <Alert>{error}</Alert>
152
+ </div>
153
+ </div>
154
+ );
155
+ } else if (userUid && status === "ready") {
156
+ const sections = settingsSections(pluginNav);
157
+ // A function, not a plain JSX constant — same reasoning as ContactsShell's identical comment:
158
+ // rendered twice (desktop `<aside>` + mobile `Drawer`), possibly simultaneously mounted, so the
159
+ // `<select>`'s `id`/its `<label>`'s `htmlFor` need a distinct value per instance.
160
+ const sidebarContent = (idPrefix: string) => (
161
+ <>
162
+ {mailboxes.length > 1 && (
163
+ <div>
164
+ <label
165
+ className="block text-xs font-bold uppercase tracking-wide text-text-muted mb-1"
166
+ htmlFor={`${idPrefix}-settings-mailbox-switcher`}
167
+ >
168
+ Mailbox
169
+ </label>
170
+ <select
171
+ id={`${idPrefix}-settings-mailbox-switcher`}
172
+ className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
173
+ value={mailboxUid}
174
+ onChange={(e) => {
175
+ // Every core settings page passes its own section id (see
176
+ // `SettingsShellProps.active`), but a plugin page's section is missing when the
177
+ // server didn't send its nav item, so that falls back to the current path.
178
+ const href = sections.find((s) => s.id === active)?.href ?? window.location.pathname;
179
+ navigate(`${href}?mailboxUid=${encodeURIComponent(e.target.value)}`);
180
+ }}
181
+ >
182
+ {mailboxes.map((mb) => (
183
+ <option key={mb.uid} value={mb.uid}>
184
+ {mb.displayName}
185
+ {mb.ownerUserUid ? "" : " (shared)"}
186
+ </option>
187
+ ))}
188
+ </select>
189
+ </div>
190
+ )}
191
+ <nav aria-label="Settings sections" className="flex flex-col gap-0.5">
192
+ {sections.map((section) => (
193
+ <a
194
+ key={section.id}
195
+ // `inner` (this whole branch) is only ever computed once `status === "ready"`
196
+ // and `mailboxUid` has already resolved truthy — a falsy `mailboxUid` returns
197
+ // `<MailboxProvisioning />` above instead (and TypeScript's own narrowing of
198
+ // this `const` already reflects that, no `!` needed) — so no fallback is
199
+ // needed here, matching this plan's established "dead guard the UI
200
+ // structurally can't trigger" removal precedent (e.g.
201
+ // `DomainDetailContent.handleVerify`).
202
+ href={`${section.href}?mailboxUid=${encodeURIComponent(mailboxUid)}`}
203
+ aria-current={section.id === active ? "page" : undefined}
204
+ className={[
205
+ "block px-2.5 py-1.5 rounded-sm text-sm",
206
+ section.id === active ? "bg-primary/10 text-primary-dark font-medium" : "text-text hover:bg-surface-alt",
207
+ ].join(" ")}
208
+ >
209
+ {section.label}
210
+ </a>
211
+ ))}
212
+ </nav>
213
+ </>
214
+ );
215
+
216
+ inner = (
217
+ <>
218
+ <aside className="hidden md:flex w-56 shrink-0 bg-surface border-r border-border flex-col p-3 gap-3">
219
+ {sidebarContent("desktop")}
220
+ </aside>
221
+ <Drawer open={drawerOpen} onClose={() => setDrawerOpen(false)} title="Settings">
222
+ <div className="flex flex-col gap-3">{sidebarContent("mobile")}</div>
223
+ </Drawer>
224
+ <main className="flex-1 min-w-0 flex flex-col">
225
+ <button
226
+ type="button"
227
+ className="md:hidden m-3 self-start w-9 h-9 flex items-center justify-center rounded-sm text-text-muted hover:bg-surface-alt hover:text-text"
228
+ aria-label="Open settings menu"
229
+ onClick={() => setDrawerOpen(true)}
230
+ >
231
+ <HiOutlineBars3 size={20} aria-hidden="true" />
232
+ </button>
233
+ <SettingsShellContext.Provider value={contextValue}>{children}</SettingsShellContext.Provider>
234
+ </main>
235
+ </>
236
+ );
237
+ }
238
+
239
+ return (
240
+ <AppShell
241
+ active="settings"
242
+ userUid={userUid}
243
+ authServerUrl={authServerUrl}
244
+ impersonating={impersonating}
245
+ impersonationBaseUrl={impersonationBaseUrl}
246
+ trusted={trusted}
247
+ trustedRoles={trustedRoles}
248
+ pluginNav={pluginNav}
249
+ >
250
+ {inner}
251
+ </AppShell>
252
+ );
253
+ }