@rapidmx/web-client 0.25.1 → 0.27.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 (85) hide show
  1. package/README.md +15 -3
  2. package/apps/shared/components/admin/layout/AdminShell.tsx +3 -2
  3. package/apps/shared/components/calendar/EventDetails.tsx +5 -2
  4. package/apps/shared/components/contacts/ContactCard.tsx +356 -0
  5. package/apps/shared/components/contacts/ContactCardProvider.tsx +72 -0
  6. package/apps/shared/components/contacts/ContactDetailPane.tsx +25 -5
  7. package/apps/shared/components/contacts/ContactForm.tsx +36 -5
  8. package/apps/shared/components/contacts/ContactPhotoField.tsx +86 -0
  9. package/apps/shared/components/contacts/FavoriteStarButton.tsx +36 -0
  10. package/apps/shared/components/contacts/ParticipantLink.tsx +42 -0
  11. package/apps/shared/components/contacts/contactCardData.ts +220 -0
  12. package/apps/shared/components/contacts/participantDetails.ts +169 -0
  13. package/apps/shared/components/layout/AppShell.tsx +18 -6
  14. package/apps/shared/components/mail/InviteCard.tsx +27 -5
  15. package/apps/shared/components/mail/MailAddress.tsx +8 -3
  16. package/apps/shared/components/mail/MessageDetailPane.tsx +72 -27
  17. package/apps/shared/components/mail/VCardAttachmentChip.tsx +85 -0
  18. package/apps/shared/components/mail/compose/ComposeWindow.tsx +112 -1
  19. package/apps/shared/components/mail/compose/RecipientInput.tsx +1 -0
  20. package/apps/shared/components/mail/compose/RichTextEditor.tsx +15 -2
  21. package/apps/shared/components/mail/compose/dropFiles.ts +21 -0
  22. package/apps/shared/components/settings/layout/SettingsShell.tsx +3 -3
  23. package/apps/shared/plugins/pluginIcons.ts +124 -0
  24. package/apps/shared/plugins/pluginNav.ts +8 -0
  25. package/apps/shared/plugins/useResolvedRailItems.ts +54 -0
  26. package/apps/www/contacts/[uid].tsx +1 -0
  27. package/apps/www/contacts/index.tsx +3 -1
  28. package/dist/apps/shared/components/admin/layout/AdminShell.d.ts +1 -1
  29. package/dist/apps/shared/components/admin/layout/AdminShell.js +3 -2
  30. package/dist/apps/shared/components/calendar/EventDetails.js +2 -1
  31. package/dist/apps/shared/components/contacts/ContactCard.d.ts +19 -0
  32. package/dist/apps/shared/components/contacts/ContactCard.js +148 -0
  33. package/dist/apps/shared/components/contacts/ContactCardProvider.d.ts +25 -0
  34. package/dist/apps/shared/components/contacts/ContactCardProvider.js +41 -0
  35. package/dist/apps/shared/components/contacts/ContactDetailPane.d.ts +3 -1
  36. package/dist/apps/shared/components/contacts/ContactDetailPane.js +17 -2
  37. package/dist/apps/shared/components/contacts/ContactForm.js +20 -2
  38. package/dist/apps/shared/components/contacts/ContactPhotoField.d.ts +21 -0
  39. package/dist/apps/shared/components/contacts/ContactPhotoField.js +46 -0
  40. package/dist/apps/shared/components/contacts/FavoriteStarButton.d.ts +9 -0
  41. package/dist/apps/shared/components/contacts/FavoriteStarButton.js +12 -0
  42. package/dist/apps/shared/components/contacts/ParticipantLink.d.ts +18 -0
  43. package/dist/apps/shared/components/contacts/ParticipantLink.js +16 -0
  44. package/dist/apps/shared/components/contacts/contactCardData.d.ts +69 -0
  45. package/dist/apps/shared/components/contacts/contactCardData.js +158 -0
  46. package/dist/apps/shared/components/contacts/participantDetails.d.ts +64 -0
  47. package/dist/apps/shared/components/contacts/participantDetails.js +129 -0
  48. package/dist/apps/shared/components/layout/AppShell.d.ts +3 -2
  49. package/dist/apps/shared/components/layout/AppShell.js +24 -15
  50. package/dist/apps/shared/components/mail/InviteCard.js +5 -3
  51. package/dist/apps/shared/components/mail/MailAddress.d.ts +5 -2
  52. package/dist/apps/shared/components/mail/MailAddress.js +5 -3
  53. package/dist/apps/shared/components/mail/MessageDetailPane.js +19 -7
  54. package/dist/apps/shared/components/mail/VCardAttachmentChip.d.ts +18 -0
  55. package/dist/apps/shared/components/mail/VCardAttachmentChip.js +53 -0
  56. package/dist/apps/shared/components/mail/compose/ComposeWindow.js +81 -4
  57. package/dist/apps/shared/components/mail/compose/RecipientInput.js +1 -0
  58. package/dist/apps/shared/components/mail/compose/RichTextEditor.d.ts +5 -2
  59. package/dist/apps/shared/components/mail/compose/RichTextEditor.js +10 -1
  60. package/dist/apps/shared/components/mail/compose/dropFiles.d.ts +8 -0
  61. package/dist/apps/shared/components/mail/compose/dropFiles.js +18 -0
  62. package/dist/apps/shared/components/settings/layout/SettingsShell.js +4 -3
  63. package/dist/apps/shared/plugins/pluginIcons.d.ts +10 -0
  64. package/dist/apps/shared/plugins/pluginIcons.js +64 -0
  65. package/dist/apps/shared/plugins/pluginNav.d.ts +8 -0
  66. package/dist/apps/shared/plugins/useResolvedRailItems.d.ts +12 -0
  67. package/dist/apps/shared/plugins/useResolvedRailItems.js +47 -0
  68. package/dist/apps/www/contacts/[uid].js +1 -1
  69. package/dist/apps/www/contacts/index.js +2 -2
  70. package/dist/lib/components/avatar/ContactAvatar.d.ts +9 -3
  71. package/dist/lib/components/avatar/ContactAvatar.js +29 -6
  72. package/dist/lib/components/buttons/CopyIconButton.d.ts +13 -0
  73. package/dist/lib/components/buttons/CopyIconButton.js +16 -0
  74. package/dist/lib/contacts/contactsApi.d.ts +15 -0
  75. package/dist/lib/contacts/contactsApi.js +31 -2
  76. package/dist/lib/contacts/gravatar.d.ts +12 -0
  77. package/dist/lib/contacts/gravatar.js +43 -0
  78. package/dist/lib/mail/directoryApi.d.ts +16 -10
  79. package/dist/lib/mail/directoryApi.js +20 -12
  80. package/lib/components/avatar/ContactAvatar.tsx +43 -7
  81. package/lib/components/buttons/CopyIconButton.tsx +49 -0
  82. package/lib/contacts/contactsApi.ts +35 -2
  83. package/lib/contacts/gravatar.ts +47 -0
  84. package/lib/mail/directoryApi.ts +30 -12
  85. package/package.json +1 -1
@@ -5,13 +5,15 @@
5
5
  /**
6
6
  * Typed wrappers over `@rapidmx/restapi`'s `BaseDirectoryRoute` - recipient suggestions for compose. `GET
7
7
  * /mail/directory` searches the server's mailboxes (people, shared mailboxes, rooms and equipment) and distribution
8
- * lists; `GET /mail/directory/contacts` searches the caller's own contacts. Both match every word of the query against
9
- * the start of a name word or of an address, and return only a display name, an address and a kind.
8
+ * lists; `GET /mail/directory/contacts` searches the caller's own contacts; `GET /mail/directory/correspondents` searches
9
+ * everyone the caller's mailboxes have exchanged mail or shared an event with, address book or not. All match every word of
10
+ * the query against the start of a name word or of an address, and return only a display name, an address and a kind.
10
11
  */
11
12
  import { ApiClient, ApiRequestError, withClient } from "../util/api.js";
12
13
 
13
- /** What a suggestion names. `"contact"` comes from the caller's contacts, everything else from the server directory. */
14
- export type RecipientSuggestionKind = "user" | "shared" | "room" | "equipment" | "list" | "contact";
14
+ /** What a suggestion names. `"contact"` comes from the caller's contacts, `"correspondent"` from the people they have written to, heard from or
15
+ * met with, everything else from the server directory. */
16
+ export type RecipientSuggestionKind = "user" | "shared" | "room" | "equipment" | "list" | "contact" | "correspondent";
15
17
 
16
18
  export interface RecipientSuggestion {
17
19
  displayName: string;
@@ -104,16 +106,29 @@ export function searchContactSuggestions(
104
106
  );
105
107
  }
106
108
 
107
- /** Contacts first, then directory entries, without repeating an address (compared case-insensitively; the first
108
- * occurrence wins), at most `limit`. */
109
+ /** Searches the people the caller's mailboxes have exchanged mail or shared an event with, whether or not they are in the address book. Rejects like
110
+ * `searchDirectory()`; a server that predates the endpoint answers 404, which `fetchRecipientSuggestions()` treats as "none". */
111
+ export function searchCorrespondents(query: string, options: ContactSuggestionOptions = {}, client?: ApiClient): Promise<RecipientSuggestion[]> {
112
+ return fetchSuggestions(
113
+ "/mail/directory/correspondents",
114
+ query,
115
+ { limit: options.limit?.toString(), mailboxUid: options.mailboxUid },
116
+ options.signal,
117
+ client,
118
+ );
119
+ }
120
+
121
+ /** Contacts first, then directory entries, then the people the caller has corresponded with, without repeating an address (compared
122
+ * case-insensitively; the first occurrence wins), at most `limit`. */
109
123
  export function mergeRecipientSuggestions(
110
124
  contacts: RecipientSuggestion[],
111
125
  directory: RecipientSuggestion[],
112
126
  limit: number = RECIPIENT_SUGGESTION_DEFAULT_LIMIT,
127
+ correspondents: RecipientSuggestion[] = [],
113
128
  ): RecipientSuggestion[] {
114
129
  const seen = new Set<string>();
115
130
  const result: RecipientSuggestion[] = [];
116
- for (const entry of [...contacts, ...directory]) {
131
+ for (const entry of [...contacts, ...directory, ...correspondents]) {
117
132
  const key = entry.address.trim().toLowerCase();
118
133
  if (result.length >= limit) {
119
134
  break;
@@ -131,9 +146,10 @@ function isAbort(error: unknown): boolean {
131
146
  }
132
147
 
133
148
  /**
134
- * Contacts and directory suggestions for `query`, merged by `mergeRecipientSuggestions()`. Either source failing (a 403
135
- * directory for a caller with no mailbox here, a 429, a network error) still returns the other's entries; only when
136
- * both fail does this reject, with the contacts error. An aborted `signal` always rejects with the `AbortError`.
149
+ * Contacts, directory and correspondent suggestions for `query`, merged by `mergeRecipientSuggestions()`. Any source failing (a 403
150
+ * directory for a caller with no mailbox here, a 429, a network error, a server without the correspondents endpoint) still returns
151
+ * the others' entries; only when the contacts and the directory both fail does this reject, with the contacts error - the
152
+ * correspondents are a bonus and never turn a working search into an error. An aborted `signal` always rejects with the `AbortError`.
137
153
  */
138
154
  export async function fetchRecipientSuggestions(
139
155
  query: string,
@@ -141,11 +157,12 @@ export async function fetchRecipientSuggestions(
141
157
  client?: ApiClient,
142
158
  ): Promise<RecipientSuggestion[]> {
143
159
  const limit = options.limit ?? RECIPIENT_SUGGESTION_DEFAULT_LIMIT;
144
- const [contacts, directory] = await Promise.allSettled([
160
+ const [contacts, directory, correspondents] = await Promise.allSettled([
145
161
  searchContactSuggestions(query, { ...options, limit }, client),
146
162
  searchDirectory(query, { limit, signal: options.signal }, client),
163
+ searchCorrespondents(query, { ...options, limit }, client),
147
164
  ]);
148
- for (const outcome of [contacts, directory]) {
165
+ for (const outcome of [contacts, directory, correspondents]) {
149
166
  if (outcome.status === "rejected" && isAbort(outcome.reason)) {
150
167
  throw outcome.reason;
151
168
  }
@@ -157,5 +174,6 @@ export async function fetchRecipientSuggestions(
157
174
  contacts.status === "fulfilled" ? contacts.value : [],
158
175
  directory.status === "fulfilled" ? directory.value : [],
159
176
  limit,
177
+ correspondents.status === "fulfilled" ? correspondents.value : [],
160
178
  );
161
179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rapidmx/web-client",
3
- "version": "0.25.1",
3
+ "version": "0.27.0",
4
4
  "description": "RapidMX's webmail and admin console React UI for web-based clients.",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/rapidmx/web-client",