@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
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { MailboxAccessRole, ResolvedPrincipal } from "@rapidmx/react-shared/mail/mailboxAccessApi.js";
3
+ export interface PrincipalPickerProps {
4
+ mailboxUid: string;
5
+ /** What each access level is called on this page. */
6
+ roleLabels: Record<MailboxAccessRole, string>;
7
+ /** Text put in the box to start with - a stored entry being replaced, say. */
8
+ initialPrincipal?: string;
9
+ /** The access level pre-selected. */
10
+ defaultRole?: MailboxAccessRole;
11
+ /** What the box asks for. */
12
+ placeholder?: string;
13
+ /** Called once the grant is saved, with the person it went to. */
14
+ onGranted: (person: ResolvedPrincipal, role: MailboxAccessRole) => void | Promise<void>;
15
+ /** Shown as a Cancel button next to the box when set (replacing an entry). */
16
+ onCancel?: () => void;
17
+ }
18
+ /** Who a resolved person is, for a person to check before saving: their name and address, else their uid. */
19
+ export declare function describePerson(person: ResolvedPrincipal): string;
20
+ /**
21
+ * "Who?" for a sharing screen. What is typed - a mailbox address, an auth-server username or e-mail alias, or a user id -
22
+ * is RESOLVED by the server (`resolveMailboxPrincipal()`) to the person it names before anything is saved, and the person
23
+ * is shown (name and address) for the caller to confirm; only then is the grant made, against that person's uid. Free text
24
+ * is never stored: an ACL record matches a user uid and nothing else, so a grant to a typed username applies to nobody.
25
+ */
26
+ export default function PrincipalPicker({ mailboxUid, roleLabels, initialPrincipal, defaultRole, placeholder, onGranted, onCancel }: PrincipalPickerProps): React.JSX.Element;
@@ -0,0 +1,77 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ ///////////////////////////////////////////////////////////////////////////////
3
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
4
+ // SPDX-License-Identifier: MPL-2.0
5
+ ///////////////////////////////////////////////////////////////////////////////
6
+ import { useEffect, useState } from "react";
7
+ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
8
+ import { resolveMailboxPrincipal, setMailboxAccess, } from "@rapidmx/react-shared/mail/mailboxAccessApi.js";
9
+ import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
10
+ import Button from "@rapidmx/react-shared/components/buttons/Button.js";
11
+ /** Who a resolved person is, for a person to check before saving: their name and address, else their uid. */
12
+ export function describePerson(person) {
13
+ if (person.displayName && person.address)
14
+ return `${person.displayName} <${person.address}>`;
15
+ return person.displayName ?? person.address ?? `user ${person.userUid}`;
16
+ }
17
+ /**
18
+ * "Who?" for a sharing screen. What is typed - a mailbox address, an auth-server username or e-mail alias, or a user id -
19
+ * is RESOLVED by the server (`resolveMailboxPrincipal()`) to the person it names before anything is saved, and the person
20
+ * is shown (name and address) for the caller to confirm; only then is the grant made, against that person's uid. Free text
21
+ * is never stored: an ACL record matches a user uid and nothing else, so a grant to a typed username applies to nobody.
22
+ */
23
+ export default function PrincipalPicker({ mailboxUid, roleLabels, initialPrincipal, defaultRole = "viewer", placeholder, onGranted, onCancel }) {
24
+ const [typed, setTyped] = useState(initialPrincipal ?? "");
25
+ const [role, setRole] = useState(defaultRole);
26
+ const [person, setPerson] = useState(null);
27
+ const [busy, setBusy] = useState(false);
28
+ const [error, setError] = useState(null);
29
+ // A stored entry being replaced is looked up straight away, so its person is shown without a click.
30
+ useEffect(() => {
31
+ if (initialPrincipal) {
32
+ void find(initialPrincipal);
33
+ }
34
+ }, [initialPrincipal]);
35
+ async function find(principal) {
36
+ setBusy(true);
37
+ setError(null);
38
+ setPerson(null);
39
+ try {
40
+ setPerson(await resolveMailboxPrincipal(mailboxUid, principal));
41
+ }
42
+ catch (err) {
43
+ setError(err instanceof ApiRequestError ? err.message : "Could not look that person up.");
44
+ }
45
+ finally {
46
+ setBusy(false);
47
+ }
48
+ }
49
+ function handleFind(e) {
50
+ e.preventDefault();
51
+ const principal = typed.trim();
52
+ if (principal) {
53
+ void find(principal);
54
+ }
55
+ }
56
+ // Only reachable from the confirm button, which only renders once `person` is set.
57
+ async function handleGrant() {
58
+ setBusy(true);
59
+ setError(null);
60
+ try {
61
+ await setMailboxAccess(mailboxUid, person.userUid, role);
62
+ await onGranted(person, role);
63
+ setTyped("");
64
+ setPerson(null);
65
+ }
66
+ catch (err) {
67
+ setError(err instanceof ApiRequestError ? err.message : "Could not grant access.");
68
+ }
69
+ finally {
70
+ setBusy(false);
71
+ }
72
+ }
73
+ return (_jsxs("div", { className: "flex flex-col gap-2", children: [error && _jsx(Alert, { children: error }), _jsxs("form", { onSubmit: handleFind, className: "flex gap-2", children: [_jsx("input", { type: "text", "aria-label": "Who to share with", placeholder: placeholder ?? "Email address, username or user id", className: "flex-1 text-sm border border-border rounded-sm py-1.5 px-2 bg-surface text-text", value: typed, onChange: (e) => {
74
+ setTyped(e.target.value);
75
+ setPerson(null);
76
+ }, disabled: busy }), _jsx("select", { "aria-label": "Access level", className: "text-sm border border-border rounded-sm py-1.5 px-2 bg-surface text-text", value: role, onChange: (e) => setRole(e.target.value), disabled: busy, children: Object.keys(roleLabels).map((value) => (_jsx("option", { value: value, children: roleLabels[value] }, value))) }), _jsx(Button, { type: "submit", variant: "secondary", loading: busy && !person, disabled: busy, className: "!w-auto", children: "Find" }), onCancel && (_jsx(Button, { type: "button", variant: "text", className: "!w-auto", onClick: onCancel, children: "Cancel" }))] }), person && (_jsxs("div", { className: "flex items-center justify-between gap-3 text-sm py-2 px-3 border border-border rounded-sm", children: [_jsxs("span", { children: ["Share with ", _jsx("strong", { className: "break-all", children: describePerson(person) }), " as ", _jsx("em", { children: roleLabels[role] }), "?"] }), _jsx(Button, { type: "button", loading: busy, disabled: busy, className: "!w-auto", onClick: () => void handleGrant(), children: "Grant" })] }))] }));
77
+ }
@@ -8,6 +8,7 @@ import { HiOutlineBars3 } from "react-icons/hi2";
8
8
  import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
9
9
  import { createTaskList, listTaskLists } from "@rapidmx/react-shared/tasks/tasksApi.js";
10
10
  import Drawer from "@rapidmx/react-shared/components/overlays/Drawer.js";
11
+ import { notifyApiError } from "../../notifications/apiErrors.js";
11
12
  export function tasksViewKey(view) {
12
13
  return view.type === "list" ? `list:${view.uid}` : view.type;
13
14
  }
@@ -66,7 +67,8 @@ export default function TasksSidebar({ mailboxUid, tasks, userUid, active, onSel
66
67
  setAddingList(false);
67
68
  }
68
69
  catch (err) {
69
- setListsError(err instanceof ApiRequestError ? err.message : "Could not create this list.");
70
+ // A pop-up: `listsError` is only the lists' own load failure.
71
+ notifyApiError(err, "Couldn't create the list");
70
72
  }
71
73
  }
72
74
  function handleSelect(view) {
@@ -77,5 +79,5 @@ export default function TasksSidebar({ mailboxUid, tasks, userUid, active, onSel
77
79
  // `Drawer` (see `ContactsSidebar` for the identical pattern and the duplicate-id reasoning behind
78
80
  // the `idPrefix`).
79
81
  const navContent = (idPrefix) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex flex-col gap-0.5", children: [_jsx(NavItem, { label: "My Day", count: myDayCount, active: active.type === "myDay", onClick: () => handleSelect({ type: "myDay" }) }), _jsx(NavItem, { label: "Important", count: importantCount, active: active.type === "important", onClick: () => handleSelect({ type: "important" }) }), _jsx(NavItem, { label: "Planned", count: plannedCount, active: active.type === "planned", onClick: () => handleSelect({ type: "planned" }) }), _jsx(NavItem, { label: "Assigned to me", count: assignedToMeCount, active: active.type === "assignedToMe", onClick: () => handleSelect({ type: "assignedToMe" }) }), _jsx(NavItem, { label: "Flagged email", active: active.type === "flagged", onClick: () => handleSelect({ type: "flagged" }) })] }), _jsx(NavItem, { label: "Tasks", count: tasks.length, active: active.type === "all", onClick: () => handleSelect({ type: "all" }) }), _jsxs("div", { children: [_jsxs("div", { className: "flex items-center justify-between px-2.5 mb-1", children: [_jsx("h2", { className: "text-xs font-bold uppercase tracking-wide text-text-muted", children: "Lists" }), _jsx("button", { type: "button", onClick: () => setAddingList(true), "aria-label": "New list", className: "text-xs font-bold text-primary-dark hover:underline", children: "+" })] }), listsError && _jsx("p", { className: "px-2.5 text-xs text-danger", children: listsError }), _jsx("div", { className: "flex flex-col gap-0.5", children: lists.map((list) => (_jsx(NavItem, { label: list.name, count: listCounts.get(list.uid) ?? 0, active: active.type === "list" && active.uid === list.uid, onClick: () => handleSelect({ type: "list", uid: list.uid, name: list.name }) }, list.uid))) }), addingList && (_jsxs("form", { onSubmit: handleAddList, className: "flex items-center gap-1 px-2.5 mt-1", children: [_jsx("input", { type: "text", autoFocus: true, "aria-label": "New list name", id: `${idPrefix}-new-list-name`, value: newListName, onChange: (e) => setNewListName(e.target.value), className: "flex-1 text-xs py-1 px-1.5 border border-border rounded-sm bg-surface" }), _jsx("button", { type: "submit", className: "text-xs font-semibold text-primary-dark", children: "Add" })] }))] })] }));
80
- return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "md:hidden m-3 w-9 h-9 flex items-center justify-center rounded-sm text-text-muted hover:bg-surface-alt hover:text-text", "aria-label": "Open tasks menu", onClick: () => setDrawerOpen(true), children: _jsx(HiOutlineBars3, { size: 20, "aria-hidden": "true" }) }), _jsx("nav", { "aria-label": "Tasks", className: "hidden md:flex w-56 shrink-0 border-r border-border flex-col gap-4 p-3 overflow-y-auto", children: navContent("desktop") }), _jsx(Drawer, { open: drawerOpen, onClose: () => setDrawerOpen(false), title: "Tasks", children: _jsx("div", { className: "flex flex-col gap-4", children: navContent("mobile") }) })] }));
82
+ return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "lg:hidden m-3 mb-0 w-9 h-9 flex items-center justify-center rounded-sm text-text-muted hover:bg-surface-alt hover:text-text", "aria-label": "Open tasks menu", onClick: () => setDrawerOpen(true), children: _jsx(HiOutlineBars3, { size: 20, "aria-hidden": "true" }) }), _jsx("nav", { "aria-label": "Tasks", className: "hidden lg:flex w-56 shrink-0 border-r border-border flex-col gap-4 p-3 overflow-y-auto", children: navContent("desktop") }), _jsx(Drawer, { open: drawerOpen, onClose: () => setDrawerOpen(false), title: "Tasks", children: _jsx("div", { className: "flex flex-col gap-4", children: navContent("mobile") }) })] }));
81
83
  }
@@ -21,4 +21,4 @@ export declare function useTasksShell(): TasksShellContextValue;
21
21
  * (rather than a single generic "SingleFolderShell" parameterized by type) so each app's sidebar can
22
22
  * grow its own app-specific controls later without threading extra props through a shared one.
23
23
  */
24
- export default function TasksShell({ userUid, authServerUrl, impersonating, impersonationBaseUrl, trusted, pluginNav, children, }: PropsWithChildren<TasksShellProps>): React.JSX.Element;
24
+ export default function TasksShell({ userUid, authServerUrl, impersonating, impersonationBaseUrl, trusted, trustedRoles, pluginNav, children, }: PropsWithChildren<TasksShellProps>): React.JSX.Element;
@@ -11,6 +11,7 @@ import { listFolders, listMailboxes } from "@rapidmx/react-shared/mail/mailApi.j
11
11
  import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
12
12
  import Skeleton, { SkeletonList } from "@rapidmx/react-shared/components/feedback/Skeleton.js";
13
13
  import AppShell from "../../layout/AppShell.js";
14
+ import { useLocationSearch, useNavigate } from "../../../navigation/AppRouter.js";
14
15
  import MailboxProvisioning from "../../layout/MailboxProvisioning.js";
15
16
  const TasksShellContext = createContext({ mailboxes: [] });
16
17
  /** Reads the mailbox/folder Tasks is currently showing, as resolved by the enclosing `TasksShell`. */
@@ -24,7 +25,7 @@ export function useTasksShell() {
24
25
  * (rather than a single generic "SingleFolderShell" parameterized by type) so each app's sidebar can
25
26
  * grow its own app-specific controls later without threading extra props through a shared one.
26
27
  */
27
- export default function TasksShell({ userUid, authServerUrl, impersonating, impersonationBaseUrl, trusted, pluginNav, children, }) {
28
+ export default function TasksShell({ userUid, authServerUrl, impersonating, impersonationBaseUrl, trusted, trustedRoles, pluginNav, children, }) {
28
29
  const [status, setStatus] = useState("checking");
29
30
  const [error, setError] = useState(null);
30
31
  const [mailboxes, setMailboxes] = useState([]);
@@ -32,9 +33,18 @@ export default function TasksShell({ userUid, authServerUrl, impersonating, impe
32
33
  const [folderError, setFolderError] = useState(null);
33
34
  const [requestedMailboxUid, setRequestedMailboxUid] = useState(null);
34
35
  const [drawerOpen, setDrawerOpen] = useState(false);
36
+ // Read from the router's location, so a mailbox change (a link, or `navigate()`) takes effect without a page load - and in an
37
+ // effect, not during render, so the server render and the hydrating render agree.
38
+ const search = useLocationSearch();
39
+ const navigate = useNavigate();
35
40
  useEffect(() => {
36
- setRequestedMailboxUid(new URLSearchParams(window.location.search).get("mailboxUid"));
37
- }, []);
41
+ setRequestedMailboxUid(new URLSearchParams(search).get("mailboxUid"));
42
+ }, [search]);
43
+ // Choosing a folder (or mailbox) changes the URL without a page load now, so the drawer that held the choice - which used to go
44
+ // with the page - is closed here.
45
+ useEffect(() => {
46
+ setDrawerOpen(false);
47
+ }, [search]);
38
48
  useEffect(() => {
39
49
  if (!userUid) {
40
50
  return;
@@ -84,9 +94,11 @@ export default function TasksShell({ userUid, authServerUrl, impersonating, impe
84
94
  // comment: it's rendered twice (desktop `<aside>` + mobile `Drawer`), possibly simultaneously
85
95
  // mounted, so the `<select>`'s `id`/its `<label>`'s `htmlFor` need a distinct value per instance.
86
96
  const sidebarContent = (idPrefix) => (_jsxs(_Fragment, { children: [mailboxes.length > 1 && (_jsxs("div", { children: [_jsx("label", { className: "block text-xs font-bold uppercase tracking-wide text-text-muted mb-1", htmlFor: `${idPrefix}-tasks-mailbox-switcher`, children: "Mailbox" }), _jsx("select", { id: `${idPrefix}-tasks-mailbox-switcher`, className: "w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface", value: mailboxUid, onChange: (e) => {
87
- window.location.href = `/tasks?mailboxUid=${encodeURIComponent(e.target.value)}`;
97
+ navigate(`/tasks?mailboxUid=${encodeURIComponent(e.target.value)}`);
88
98
  }, children: mailboxes.map((mb) => (_jsxs("option", { value: mb.uid, children: [mb.displayName, mb.ownerUserUid ? "" : " (shared)"] }, mb.uid))) })] })), folderError && _jsx(Alert, { children: folderError })] }));
89
- inner = (_jsxs(_Fragment, { children: [_jsx("aside", { className: "hidden md:flex w-56 shrink-0 bg-surface border-r border-border flex-col p-3 gap-3", children: sidebarContent("desktop") }), _jsx(Drawer, { open: drawerOpen, onClose: () => setDrawerOpen(false), title: "Mailbox", children: _jsx("div", { className: "flex flex-col gap-3", children: sidebarContent("mobile") }) }), _jsxs("main", { className: "flex-1 min-w-0 flex flex-col", children: [(mailboxes.length > 1 || folderError) && (_jsx("button", { type: "button", className: "md:hidden m-3 w-9 h-9 flex items-center justify-center rounded-sm text-text-muted hover:bg-surface-alt hover:text-text", "aria-label": "Open mailbox switcher", onClick: () => setDrawerOpen(true), children: _jsx(HiOutlineBars3, { size: 20, "aria-hidden": "true" }) })), _jsx(TasksShellContext.Provider, { value: contextValue, children: children })] })] }));
99
+ // With a single mailbox and no error this column would be empty: no 224 px of nothing beside the tasks' own menu.
100
+ const hasSidebar = mailboxes.length > 1 || !!folderError;
101
+ inner = (_jsxs(_Fragment, { children: [hasSidebar && (_jsx("aside", { className: "hidden lg:flex w-56 shrink-0 bg-surface border-r border-border flex-col p-3 gap-3", children: sidebarContent("desktop") })), _jsx(Drawer, { open: drawerOpen, onClose: () => setDrawerOpen(false), title: "Mailbox", children: _jsx("div", { className: "flex flex-col gap-3", children: sidebarContent("mobile") }) }), _jsxs("main", { className: "flex-1 min-w-0 flex flex-col", children: [hasSidebar && (_jsx("button", { type: "button", className: "lg:hidden m-3 w-9 h-9 flex items-center justify-center rounded-sm text-text-muted hover:bg-surface-alt hover:text-text", "aria-label": "Open mailbox switcher", onClick: () => setDrawerOpen(true), children: _jsx(HiOutlineBars3, { size: 20, "aria-hidden": "true" }) })), _jsx(TasksShellContext.Provider, { value: contextValue, children: children })] })] }));
90
102
  }
91
- return (_jsx(AppShell, { active: "tasks", userUid: userUid, authServerUrl: authServerUrl, impersonating: impersonating, impersonationBaseUrl: impersonationBaseUrl, trusted: trusted, pluginNav: pluginNav, children: inner }));
103
+ return (_jsx(AppShell, { active: "tasks", userUid: userUid, authServerUrl: authServerUrl, impersonating: impersonating, impersonationBaseUrl: impersonationBaseUrl, trusted: trusted, trustedRoles: trustedRoles, pluginNav: pluginNav, children: inner }));
92
104
  }
@@ -0,0 +1,14 @@
1
+ export interface GlobalShortcutsProps {
2
+ /** auth-server's base URL - "Go to Account" is offered only when it is set. */
3
+ authServerUrl?: string;
4
+ /** Opens the keyboard shortcuts dialog, or closes it if it is open. */
5
+ onToggleHelp: () => void;
6
+ }
7
+ /**
8
+ * The shortcuts that work in every view: the "Go to ..." navigation set and the keyboard help. Mounted once by `AppChrome`, next to the
9
+ * `ShortcutProvider`, so it works from Settings and every app alike. Renders nothing.
10
+ *
11
+ * In-app places go through the client-side router (`useNavigate()`); Account is another origin, so it is a plain navigation. Asking for the
12
+ * page you are already on does nothing - but the key is still taken, so the browser doesn't act on it either.
13
+ */
14
+ export declare function GlobalShortcuts({ authServerUrl, onToggleHelp }: GlobalShortcutsProps): null;
@@ -0,0 +1,37 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import { accountUrlOf } from "../auth/accountUrl.js";
6
+ import { APP_HREFS, SETTINGS_HREF, isSettingsPath } from "../navigation/appHrefs.js";
7
+ import { useNavigate } from "../navigation/routerContext.js";
8
+ import { SHORTCUTS } from "./keymap.js";
9
+ import { useShortcut } from "./useShortcut.js";
10
+ /**
11
+ * The shortcuts that work in every view: the "Go to ..." navigation set and the keyboard help. Mounted once by `AppChrome`, next to the
12
+ * `ShortcutProvider`, so it works from Settings and every app alike. Renders nothing.
13
+ *
14
+ * In-app places go through the client-side router (`useNavigate()`); Account is another origin, so it is a plain navigation. Asking for the
15
+ * page you are already on does nothing - but the key is still taken, so the browser doesn't act on it either.
16
+ */
17
+ export function GlobalShortcuts({ authServerUrl, onToggleHelp }) {
18
+ const navigate = useNavigate();
19
+ const accountUrl = accountUrlOf(authServerUrl);
20
+ /** A handler that goes to `href` unless the address bar's path says it is already there. */
21
+ const goTo = (href, isHere) => () => {
22
+ if (!isHere(window.location.pathname)) {
23
+ navigate(href);
24
+ }
25
+ };
26
+ const isPath = (path) => (pathname) => pathname === path;
27
+ useShortcut(SHORTCUTS.global.mail, goTo(APP_HREFS.mail, isPath(APP_HREFS.mail)));
28
+ useShortcut(SHORTCUTS.global.calendar, goTo(APP_HREFS.calendar, isPath(APP_HREFS.calendar)));
29
+ useShortcut(SHORTCUTS.global.contacts, goTo(APP_HREFS.contacts, isPath(APP_HREFS.contacts)));
30
+ useShortcut(SHORTCUTS.global.tasks, goTo(APP_HREFS.tasks, isPath(APP_HREFS.tasks)));
31
+ useShortcut(SHORTCUTS.global.settings, goTo(SETTINGS_HREF, isSettingsPath));
32
+ useShortcut(SHORTCUTS.global.account, () => {
33
+ window.location.href = accountUrl;
34
+ }, { enabled: !!accountUrl });
35
+ useShortcut(SHORTCUTS.global.help, onToggleHelp);
36
+ return null;
37
+ }
@@ -0,0 +1,20 @@
1
+ import React, { PropsWithChildren } from "react";
2
+ import { KeyEnvironment } from "./platform.js";
3
+ import { Registration, ShortcutRegistry } from "./registry.js";
4
+ /**
5
+ * The web client's one keyboard layer. Mounted once, by `AppChrome` (the frame that stays mounted as the router swaps pages), so shortcuts
6
+ * work in every view - mail, calendar, contacts, tasks, settings - and a page change only changes which handlers are registered.
7
+ *
8
+ * One `keydown` listener on `document` (bubbling, so what a widget handles itself and `preventDefault()`s is left alone) hands each key to
9
+ * `dispatchKeyEvent()`. Views claim keys with `useShortcut()`. Outside a provider - an admin page, a component rendered on its own - that
10
+ * hook does nothing.
11
+ *
12
+ * The platform (macOS, the desktop client) is read after mount, never during render, so the server render and hydration agree.
13
+ */
14
+ export declare function ShortcutProvider({ children }: PropsWithChildren): React.JSX.Element;
15
+ /** The registry, or `null` outside a `ShortcutProvider`. */
16
+ export declare function useShortcutRegistry(): ShortcutRegistry | null;
17
+ /** The platform as the keyboard layer sees it - `SERVER_ENVIRONMENT` until the client has mounted, and outside a provider. */
18
+ export declare function useKeyEnvironment(): KeyEnvironment;
19
+ /** Everything registered right now, updating as views mount and unmount - what the help dialog lists. Empty outside a provider. */
20
+ export declare function useRegisteredShortcuts(): readonly Registration[];
@@ -0,0 +1,52 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ ///////////////////////////////////////////////////////////////////////////////
3
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
4
+ // SPDX-License-Identifier: MPL-2.0
5
+ ///////////////////////////////////////////////////////////////////////////////
6
+ import { createContext, useContext, useEffect, useMemo, useState, useSyncExternalStore } from "react";
7
+ import { dispatchKeyEvent } from "./dispatch.js";
8
+ import { SERVER_ENVIRONMENT, currentEnvironment } from "./platform.js";
9
+ import { ShortcutRegistry } from "./registry.js";
10
+ const ShortcutContext = createContext(null);
11
+ /**
12
+ * The web client's one keyboard layer. Mounted once, by `AppChrome` (the frame that stays mounted as the router swaps pages), so shortcuts
13
+ * work in every view - mail, calendar, contacts, tasks, settings - and a page change only changes which handlers are registered.
14
+ *
15
+ * One `keydown` listener on `document` (bubbling, so what a widget handles itself and `preventDefault()`s is left alone) hands each key to
16
+ * `dispatchKeyEvent()`. Views claim keys with `useShortcut()`. Outside a provider - an admin page, a component rendered on its own - that
17
+ * hook does nothing.
18
+ *
19
+ * The platform (macOS, the desktop client) is read after mount, never during render, so the server render and hydration agree.
20
+ */
21
+ export function ShortcutProvider({ children }) {
22
+ const registry = useMemo(() => new ShortcutRegistry(), []);
23
+ const [env, setEnv] = useState(SERVER_ENVIRONMENT);
24
+ useEffect(() => {
25
+ setEnv(currentEnvironment());
26
+ }, []);
27
+ useEffect(() => {
28
+ function handleKeyDown(event) {
29
+ dispatchKeyEvent(registry, event, currentEnvironment(), document);
30
+ }
31
+ document.addEventListener("keydown", handleKeyDown);
32
+ return () => document.removeEventListener("keydown", handleKeyDown);
33
+ }, [registry]);
34
+ const value = useMemo(() => ({ registry, env }), [registry, env]);
35
+ return _jsx(ShortcutContext.Provider, { value: value, children: children });
36
+ }
37
+ /** The registry, or `null` outside a `ShortcutProvider`. */
38
+ export function useShortcutRegistry() {
39
+ return useContext(ShortcutContext)?.registry ?? null;
40
+ }
41
+ /** The platform as the keyboard layer sees it - `SERVER_ENVIRONMENT` until the client has mounted, and outside a provider. */
42
+ export function useKeyEnvironment() {
43
+ return useContext(ShortcutContext)?.env ?? SERVER_ENVIRONMENT;
44
+ }
45
+ const NO_REGISTRATIONS = [];
46
+ const getNoRegistrations = () => NO_REGISTRATIONS;
47
+ const NEVER = () => () => undefined;
48
+ /** Everything registered right now, updating as views mount and unmount - what the help dialog lists. Empty outside a provider. */
49
+ export function useRegisteredShortcuts() {
50
+ const registry = useShortcutRegistry();
51
+ return useSyncExternalStore(registry?.subscribe ?? NEVER, registry?.getSnapshot ?? getNoRegistrations, getNoRegistrations);
52
+ }
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ export interface ShortcutsDialogProps {
3
+ open: boolean;
4
+ onClose: () => void;
5
+ }
6
+ /**
7
+ * The keyboard shortcuts help dialog: what can be done from the keyboard *here*. It lists what is registered right now (see
8
+ * `useRegisteredShortcuts()`), so it shows the global shortcuts and those of the view that is on screen - and the compose window's while one
9
+ * is open - in groups, with the platform's own key names (Ctrl or Cmd, Alt or Option), and in the desktop client also the keys only it has.
10
+ * A shortcut a view cannot do at the moment (no message selected) is not registered, and so not listed.
11
+ *
12
+ * Built on `Modal`: focus moves into the dialog and stays there, Escape closes it, and it has an accessible name. `?` and Ctrl+/ close it too.
13
+ */
14
+ export default function ShortcutsDialog({ open, onClose }: ShortcutsDialogProps): React.JSX.Element | null;
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ ///////////////////////////////////////////////////////////////////////////////
3
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
4
+ // SPDX-License-Identifier: MPL-2.0
5
+ ///////////////////////////////////////////////////////////////////////////////
6
+ import React from "react";
7
+ import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
8
+ import { formatSpec, specsFor } from "./format.js";
9
+ import { HELP_SCOPES, SCOPE_LABELS, SHORTCUTS, shortcutRank } from "./keymap.js";
10
+ import { useKeyEnvironment, useRegisteredShortcuts } from "./ShortcutProvider.js";
11
+ import { useShortcut } from "./useShortcut.js";
12
+ function Keys({ shortcut }) {
13
+ const env = useKeyEnvironment();
14
+ return (_jsx("span", { className: "flex flex-wrap justify-end gap-x-1.5 gap-y-1 shrink-0", children: specsFor(shortcut, env).map((spec, index) => (_jsxs(React.Fragment, { children: [index > 0 && _jsx("span", { className: "text-xs text-text-muted self-center", children: "or" }), _jsx("kbd", { className: "px-1.5 py-0.5 rounded-sm border border-border bg-surface-alt text-xs font-sans font-semibold whitespace-nowrap", children: formatSpec(spec, env) })] }, spec))) }));
15
+ }
16
+ /**
17
+ * The keyboard shortcuts help dialog: what can be done from the keyboard *here*. It lists what is registered right now (see
18
+ * `useRegisteredShortcuts()`), so it shows the global shortcuts and those of the view that is on screen - and the compose window's while one
19
+ * is open - in groups, with the platform's own key names (Ctrl or Cmd, Alt or Option), and in the desktop client also the keys only it has.
20
+ * A shortcut a view cannot do at the moment (no message selected) is not registered, and so not listed.
21
+ *
22
+ * Built on `Modal`: focus moves into the dialog and stays there, Escape closes it, and it has an accessible name. `?` and Ctrl+/ close it too.
23
+ */
24
+ export default function ShortcutsDialog({ open, onClose }) {
25
+ // Mounted only while open: the body subscribes to the registry, which every view's shortcuts change as it mounts - not something the
26
+ // whole app should re-render for while the dialog is closed.
27
+ return open ? _jsx(ShortcutsDialogBody, { onClose: onClose }) : null;
28
+ }
29
+ function ShortcutsDialogBody({ onClose }) {
30
+ const registrations = useRegisteredShortcuts();
31
+ useShortcut(SHORTCUTS.global.help, onClose, { scope: "dialog" });
32
+ const groups = HELP_SCOPES.map((scope) => {
33
+ const listed = new Map();
34
+ for (const registration of registrations) {
35
+ if (registration.scope === scope) {
36
+ listed.set(registration.shortcut.id, registration.shortcut);
37
+ }
38
+ }
39
+ return { scope, shortcuts: [...listed.values()].sort((a, b) => shortcutRank(a) - shortcutRank(b)) };
40
+ }).filter((group) => group.shortcuts.length > 0);
41
+ return (_jsx(Modal, { open: true, onClose: onClose, title: "Keyboard shortcuts", children: _jsxs("div", { className: "flex flex-col gap-5", children: [groups.map(({ scope, shortcuts }) => (_jsxs("section", { "aria-labelledby": `shortcuts-${scope}`, children: [_jsx("h3", { id: `shortcuts-${scope}`, className: "text-xs font-bold uppercase tracking-wide text-text-muted mb-2", children: SCOPE_LABELS[scope] }), _jsx("ul", { className: "flex flex-col gap-1.5", children: shortcuts.map((shortcut) => (_jsxs("li", { className: "flex items-start justify-between gap-4 text-sm", children: [_jsx("span", { children: shortcut.label }), _jsx(Keys, { shortcut: shortcut })] }, shortcut.id))) })] }, scope))), _jsx("p", { className: "text-xs text-text-muted border-t border-border pt-3", children: "Some browsers keep a few keys for themselves, so a shortcut may not work everywhere." })] }) }));
42
+ }
@@ -0,0 +1,16 @@
1
+ import type { KeyEnvironment } from "./platform.js";
2
+ import type { ShortcutRegistry } from "./registry.js";
3
+ /**
4
+ * Handles one `keydown`: finds the registered shortcut it is, and runs its handler. Returns whether a handler ran - and only then is the
5
+ * event's default prevented and its propagation stopped, so a key nobody claims (or a handler that declines) behaves exactly as if this layer
6
+ * did not exist.
7
+ *
8
+ * Skipped outright: an event some other handler already `defaultPrevented` (a menu, the rich-text editor's own bindings), one from an IME
9
+ * composition, a bare modifier key, and the Copy/Cut/Paste/Select all/Undo/Redo/Find chords. A held key repeats: an action that is not
10
+ * marked `repeat` runs on the first press only, and the repeats are swallowed (so a browser doesn't reload on a held Ctrl+R) without running it.
11
+ *
12
+ * Which registration wins: the dialog scope alone while a modal is open; else, inside a compose window, `compose` then `global`; else
13
+ * whichever view is mounted, then `global`. Within a scope the most recently mounted registration goes first, and one that returns
14
+ * `false` passes the key on to the next.
15
+ */
16
+ export declare function dispatchKeyEvent(registry: ShortcutRegistry, event: KeyboardEvent, env: KeyEnvironment, doc: Document): boolean;
@@ -0,0 +1,109 @@
1
+ import { matchesEvent } from "./match.js";
2
+ import { resolveModifiers } from "./parse.js";
3
+ import { isActivatable, isInPopoverDialog, isInWidget, isModalOpen, isPopupOpenAt, isTextEntry, regionScopeOf } from "./targets.js";
4
+ /** The keys of the four view scopes: only the mounted view has registrations, so precedence among them is moot. */
5
+ const VIEW_SCOPES = ["mail", "calendar", "contacts", "tasks"];
6
+ /** Keys that move the caret or delete text, which a text field owns even with Ctrl or Alt held (word jumps, delete-word). */
7
+ const EDITING_KEYS = new Set(["arrowup", "arrowdown", "arrowleft", "arrowright", "home", "end", "pageup", "pagedown", "backspace", "delete"]);
8
+ /** The Copy / Cut / Paste / Select all / Undo / Redo / Find chords: never a shortcut, anywhere - they act on the page's selection, not on a view. */
9
+ function isReservedChord(parsed, env) {
10
+ const modifiers = resolveModifiers(parsed, env);
11
+ return (modifiers.ctrl || modifiers.meta) && !modifiers.alt && !modifiers.shift && ["a", "c", "v", "x", "z", "y", "f"].includes(parsed.key);
12
+ }
13
+ /** Paste as plain text (Ctrl+Shift+V) and Redo (Ctrl+Shift+Z): text-editing chords in a field, free everywhere else (Ctrl+Shift+V is Move to). */
14
+ function isShiftedEditingChord(parsed, env) {
15
+ const modifiers = resolveModifiers(parsed, env);
16
+ return (modifiers.ctrl || modifiers.meta) && !modifiers.alt && modifiers.shift && ["z", "v"].includes(parsed.key);
17
+ }
18
+ /**
19
+ * Whether `parsed` may fire with the event on this target.
20
+ *
21
+ * A text field (input, textarea, select, contenteditable - the rich-text editor) keeps everything that types or edits: bare keys
22
+ * (`j`, `?`, Delete), the caret keys with any modifier, and paste-as-plain-text and redo. A chord with Ctrl/Cmd/Alt works from one (that is how Ctrl+Enter sends from
23
+ * the body), except that Option on a Mac and Ctrl+Alt (AltGr) elsewhere type characters, so those don't. Escape works from a field unless a
24
+ * popup it owns is open (or it is in a popover dialog of its own). Outside a field, a bare key still isn't taken from a widget that reads keys itself (an open menu, a list box), and
25
+ * Enter/Space are left to the button or link that has the focus - unless the shortcut asked for them.
26
+ */
27
+ function allowedOnTarget(registration, parsed, target, env) {
28
+ const modifiers = resolveModifiers(parsed, env);
29
+ const command = modifiers.ctrl || modifiers.meta || modifiers.alt;
30
+ if (parsed.key === "escape" && (isPopupOpenAt(target) || isInPopoverDialog(target))) {
31
+ return false;
32
+ }
33
+ if (isTextEntry(target)) {
34
+ if (parsed.key === "escape") {
35
+ return true;
36
+ }
37
+ if (!command || EDITING_KEYS.has(parsed.key) || isShiftedEditingChord(parsed, env)) {
38
+ return false;
39
+ }
40
+ return !(modifiers.alt && !modifiers.meta && (env.mac || modifiers.ctrl));
41
+ }
42
+ if (!command) {
43
+ if (isInWidget(target)) {
44
+ return false;
45
+ }
46
+ if ((parsed.key === "enter" || parsed.key === " ") && !registration.shortcut.allowOnActivatable && isActivatable(target)) {
47
+ return false;
48
+ }
49
+ }
50
+ return true;
51
+ }
52
+ /** The scopes that may act on this event, highest precedence first. */
53
+ function activeScopes(event, doc) {
54
+ if (isModalOpen(doc)) {
55
+ return ["dialog"];
56
+ }
57
+ if (regionScopeOf(event.target) === "compose") {
58
+ return ["compose", "global"];
59
+ }
60
+ return [...VIEW_SCOPES, "global"];
61
+ }
62
+ /** Whether the registration applies to where the event happened (a compose window's shortcuts only inside it). */
63
+ function inContainer(registration, event) {
64
+ if (!registration.container) {
65
+ return true;
66
+ }
67
+ return !!registration.container.current?.contains(event.target);
68
+ }
69
+ /**
70
+ * Handles one `keydown`: finds the registered shortcut it is, and runs its handler. Returns whether a handler ran - and only then is the
71
+ * event's default prevented and its propagation stopped, so a key nobody claims (or a handler that declines) behaves exactly as if this layer
72
+ * did not exist.
73
+ *
74
+ * Skipped outright: an event some other handler already `defaultPrevented` (a menu, the rich-text editor's own bindings), one from an IME
75
+ * composition, a bare modifier key, and the Copy/Cut/Paste/Select all/Undo/Redo/Find chords. A held key repeats: an action that is not
76
+ * marked `repeat` runs on the first press only, and the repeats are swallowed (so a browser doesn't reload on a held Ctrl+R) without running it.
77
+ *
78
+ * Which registration wins: the dialog scope alone while a modal is open; else, inside a compose window, `compose` then `global`; else
79
+ * whichever view is mounted, then `global`. Within a scope the most recently mounted registration goes first, and one that returns
80
+ * `false` passes the key on to the next.
81
+ */
82
+ export function dispatchKeyEvent(registry, event, env, doc) {
83
+ if (event.defaultPrevented || event.isComposing || event.key === "Process" || ["Control", "Shift", "Alt", "Meta"].includes(event.key)) {
84
+ return false;
85
+ }
86
+ const scopes = activeScopes(event, doc);
87
+ const candidates = registry
88
+ .getSnapshot()
89
+ .filter((registration) => scopes.includes(registration.scope) && inContainer(registration, event))
90
+ .sort((a, b) => scopes.indexOf(a.scope) - scopes.indexOf(b.scope) || b.order - a.order);
91
+ for (const registration of candidates) {
92
+ const specs = env.electron ? [...registration.keys, ...registration.electronKeys] : registration.keys;
93
+ const parsed = specs.find((spec) => matchesEvent(spec, event, env));
94
+ if (!parsed || isReservedChord(parsed, env) || !allowedOnTarget(registration, parsed, event.target, env)) {
95
+ continue;
96
+ }
97
+ if (event.repeat && !registration.shortcut.repeat) {
98
+ event.preventDefault();
99
+ event.stopPropagation();
100
+ return true;
101
+ }
102
+ if (registration.run(event) !== false) {
103
+ event.preventDefault();
104
+ event.stopPropagation();
105
+ return true;
106
+ }
107
+ }
108
+ return false;
109
+ }
@@ -0,0 +1,12 @@
1
+ import type { ShortcutDef } from "./keymap.js";
2
+ import type { KeyEnvironment } from "./platform.js";
3
+ /** A spec as a person reads it: `Ctrl+Shift+R`, or `⌃⇧R`-style glyphs on a Mac (`⌘` for Cmd, `⌥` for Option). */
4
+ export declare function formatSpec(spec: string, env: KeyEnvironment): string;
5
+ /** A spec in `aria-keyshortcuts` syntax: `Control+Shift+R`, `Meta+R`. */
6
+ export declare function ariaSpec(spec: string, env: KeyEnvironment): string;
7
+ /** Every spec that triggers a shortcut here: its keys, and in the desktop client also its desktop-only ones. */
8
+ export declare function specsFor(shortcut: ShortcutDef, env: KeyEnvironment): string[];
9
+ /** The `aria-keyshortcuts` value for a control that runs a shortcut: every alternative, space separated. */
10
+ export declare function ariaKeyShortcuts(shortcut: ShortcutDef, env: KeyEnvironment): string;
11
+ /** A tooltip/name suffix such as `Reply (Ctrl+R)`: the label with the shortcut's first key. */
12
+ export declare function withHint(label: string, shortcut: ShortcutDef, env: KeyEnvironment): string;
@@ -0,0 +1,74 @@
1
+ import { parseSpec, resolveModifiers } from "./parse.js";
2
+ const KEY_NAMES = {
3
+ escape: "Esc",
4
+ enter: "Enter",
5
+ tab: "Tab",
6
+ backspace: "Backspace",
7
+ delete: "Delete",
8
+ insert: "Insert",
9
+ home: "Home",
10
+ end: "End",
11
+ pageup: "Page Up",
12
+ pagedown: "Page Down",
13
+ arrowup: "↑",
14
+ arrowdown: "↓",
15
+ arrowleft: "←",
16
+ arrowright: "→",
17
+ " ": "Space",
18
+ };
19
+ const MAC_KEY_NAMES = { ...KEY_NAMES, enter: "↩", backspace: "⌫", delete: "⌦" };
20
+ /** The key as it is printed on a key cap: `R`, `F5`, `Enter`, an arrow. */
21
+ function keyLabel(key, mac) {
22
+ return (mac ? MAC_KEY_NAMES : KEY_NAMES)[key] ?? key.toUpperCase();
23
+ }
24
+ /** A spec as a person reads it: `Ctrl+Shift+R`, or `⌃⇧R`-style glyphs on a Mac (`⌘` for Cmd, `⌥` for Option). */
25
+ export function formatSpec(spec, env) {
26
+ const parsed = parseSpec(spec);
27
+ const modifiers = resolveModifiers(parsed, env);
28
+ if (env.mac) {
29
+ return [modifiers.ctrl && "⌃", modifiers.alt && "⌥", modifiers.shift && "⇧", modifiers.meta && "⌘", keyLabel(parsed.key, true)]
30
+ .filter(Boolean)
31
+ .join("");
32
+ }
33
+ return [modifiers.ctrl && "Ctrl", modifiers.shift && "Shift", modifiers.alt && "Alt", modifiers.meta && "Meta", keyLabel(parsed.key, false)]
34
+ .filter(Boolean)
35
+ .join("+");
36
+ }
37
+ const ARIA_NAMED_KEYS = {
38
+ escape: "Escape",
39
+ enter: "Enter",
40
+ tab: "Tab",
41
+ backspace: "Backspace",
42
+ delete: "Delete",
43
+ insert: "Insert",
44
+ home: "Home",
45
+ end: "End",
46
+ pageup: "PageUp",
47
+ pagedown: "PageDown",
48
+ arrowup: "ArrowUp",
49
+ arrowdown: "ArrowDown",
50
+ arrowleft: "ArrowLeft",
51
+ arrowright: "ArrowRight",
52
+ " ": "Space",
53
+ };
54
+ /** A spec in `aria-keyshortcuts` syntax: `Control+Shift+R`, `Meta+R`. */
55
+ export function ariaSpec(spec, env) {
56
+ const parsed = parseSpec(spec);
57
+ const modifiers = resolveModifiers(parsed, env);
58
+ const key = ARIA_NAMED_KEYS[parsed.key] ?? parsed.key.toUpperCase();
59
+ return [modifiers.ctrl && "Control", modifiers.alt && "Alt", modifiers.shift && "Shift", modifiers.meta && "Meta", key].filter(Boolean).join("+");
60
+ }
61
+ /** Every spec that triggers a shortcut here: its keys, and in the desktop client also its desktop-only ones. */
62
+ export function specsFor(shortcut, env) {
63
+ return env.electron && shortcut.electronKeys ? [...shortcut.keys, ...shortcut.electronKeys] : [...shortcut.keys];
64
+ }
65
+ /** The `aria-keyshortcuts` value for a control that runs a shortcut: every alternative, space separated. */
66
+ export function ariaKeyShortcuts(shortcut, env) {
67
+ return specsFor(shortcut, env)
68
+ .map((spec) => ariaSpec(spec, env))
69
+ .join(" ");
70
+ }
71
+ /** A tooltip/name suffix such as `Reply (Ctrl+R)`: the label with the shortcut's first key. */
72
+ export function withHint(label, shortcut, env) {
73
+ return `${label} (${formatSpec(shortcut.keys[0], env)})`;
74
+ }