@acorex/components 22.4.42 → 22.4.44
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.
- package/conversation/README.md +120 -24
- package/fesm2022/{acorex-components-conversation-acorex-components-conversation-CYl7g07g.mjs → acorex-components-conversation-acorex-components-conversation-C7ilacTf.mjs} +3197 -1315
- package/fesm2022/acorex-components-conversation-acorex-components-conversation-C7ilacTf.mjs.map +1 -0
- package/fesm2022/{acorex-components-conversation-picker-rename-file-dialog.component-7W9bu_5L.mjs → acorex-components-conversation-picker-rename-file-dialog.component-B_OSm0vS.mjs} +2 -2
- package/fesm2022/{acorex-components-conversation-picker-rename-file-dialog.component-7W9bu_5L.mjs.map → acorex-components-conversation-picker-rename-file-dialog.component-B_OSm0vS.mjs.map} +1 -1
- package/fesm2022/acorex-components-conversation.mjs +1 -1
- package/fesm2022/acorex-components-emoji.mjs +2 -2
- package/fesm2022/acorex-components-emoji.mjs.map +1 -1
- package/fesm2022/acorex-components-emojipicker.mjs +22 -5
- package/fesm2022/acorex-components-emojipicker.mjs.map +1 -1
- package/fesm2022/acorex-components-image.mjs +2 -2
- package/fesm2022/acorex-components-image.mjs.map +1 -1
- package/fesm2022/acorex-components-menu.mjs +6 -4
- package/fesm2022/acorex-components-menu.mjs.map +1 -1
- package/fesm2022/acorex-components-popover.mjs +21 -12
- package/fesm2022/acorex-components-popover.mjs.map +1 -1
- package/package.json +3 -3
- package/types/acorex-components-conversation.d.ts +2201 -1900
- package/types/acorex-components-emojipicker.d.ts +4 -0
- package/types/acorex-components-menu.d.ts +4 -2
- package/types/acorex-components-popover.d.ts +2 -0
- package/fesm2022/acorex-components-conversation-acorex-components-conversation-CYl7g07g.mjs.map +0 -1
package/conversation/README.md
CHANGED
|
@@ -16,6 +16,95 @@ A modern, fully-featured conversation/chat component for Angular 18+. Built with
|
|
|
16
16
|
- **Responsive** - Mobile-friendly design
|
|
17
17
|
- **Accessibility** - ARIA labels and keyboard navigation
|
|
18
18
|
|
|
19
|
+
## Composer mentions
|
|
20
|
+
|
|
21
|
+
Typing `@` at the beginning of a message or after whitespace opens an Acorex popover above the composer. Group conversations use their participants by default. Type to search names, use Up/Down to move the active option, Enter to insert `@Full Name`, or click a person. Escape and Tab dismiss the picker. Focus stays in the textarea so typing continues to filter results; Enter selects a person without sending the message. Email addresses do not open the picker.
|
|
22
|
+
|
|
23
|
+
Configure all conversations, including groups, through `provideConversation({ config: { mentions: ... } })`:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
config: {
|
|
27
|
+
mentions: {
|
|
28
|
+
people: [
|
|
29
|
+
{ id: 'user-1', name: 'Ali Reza', icon: 'fa-light fa-user' },
|
|
30
|
+
{ id: 'user-2', name: 'Sara', avatar: '/avatars/sara.png' },
|
|
31
|
+
],
|
|
32
|
+
limit: 20,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
For remote search, supply `search` instead of `people`. The callback receives the active conversation, the query without `@`, and an AbortSignal. Return already filtered people synchronously or as a Promise. Older results are ignored when the query changes or the picker closes.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
mentions: {
|
|
41
|
+
debounce: 150,
|
|
42
|
+
search: async ({ conversation, query, signal }) => {
|
|
43
|
+
const params = new URLSearchParams({ conversationId: conversation.id, query });
|
|
44
|
+
const response = await fetch(`/api/people?${params}`, { signal });
|
|
45
|
+
if (!response.ok) throw new Error('People search failed');
|
|
46
|
+
return response.json(); // Array<{ id, name, icon?, avatar? }>
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Override settings for one conversation with `conversation.metadata.mentions`. For example, `{ people: teamMembers }` replaces the global source for that conversation, `{ enabled: false }` disables mentions, and `{ search: undefined, people: undefined }` restores the group participant fallback. Other settings inherit the global values. `label` overrides the localized accessible picker label.
|
|
52
|
+
|
|
53
|
+
Text messages and edits carry the existing `AXConversationTextPayload.mentions` entries (`userId`, `userName`, `start`, `end`). Offsets use UTF-16, include the `@`, exclude the inserted trailing space, and refer to the final trimmed text. Edits move untouched spans and discard a mention when its contents change; manually typing a matching name does not assign an identity. Local text drafts preserve mention metadata across reloads and conversation switches. Attachment captions currently remain plain text.
|
|
54
|
+
|
|
55
|
+
Sent mentions render as visually distinct inline text alongside the normal phone, email and website links. Mentions are not clickable and do not open a profile popover. Search highlighting and stored identity metadata are preserved. Stale, malformed and overlapping mention spans are displayed as ordinary text.
|
|
56
|
+
|
|
57
|
+
## Pinned messages
|
|
58
|
+
|
|
59
|
+
The info bar renders message pins in a separate row below the media playback banner. Pin navigation, hiding the pin row, and opening the list do not replace, stop or dismiss that banner.
|
|
60
|
+
|
|
61
|
+
- Multiple pins are ordered by pin time, newest first. Clicking the preview navigates to that message and advances the preview to the next pin.
|
|
62
|
+
- View all opens an in-chat pinned-message feed in message-time order, using the normal renderers and date separators. Its header provides Back to chat, a count and search; the pin bar and composer are hidden. Each row links back to the original message.
|
|
63
|
+
- Unpin all (in the pinned feed footer or the pin bar close button) asks for one confirmation, clears the pins and returns to the normal chat. Cancelled or failed operations keep the current view.
|
|
64
|
+
- Private-chat members can manage pins. In groups and channels, admins, owners and the room creator can manage them. Override the UI policy with config.canPinMessages; the Message API must also enforce authorization.
|
|
65
|
+
- The conversation menu also offers the pinned feed. The optional setHidden API remains available for applications that implement personal hiding; the built-in close button performs Unpin all.
|
|
66
|
+
- Unloaded messages are located through the existing paged Message API. A bounded history window is displayed near the target; Scroll to bottom returns to the latest messages.
|
|
67
|
+
- System, sending and failed messages cannot be pinned. Selection Pin/Unpin processes the eligible subset in source order, with one confirmation and an API call per message.
|
|
68
|
+
|
|
69
|
+
Register AX_CONVERSATION_MESSAGE_PIN_ACTION and AX_CONVERSATION_MESSAGE_UNPIN_ACTION in registry.messageActions for the normal message context menu. Bulk Pin/Unpin is registered with the selection service and also appears in the selection context menu. Applications can replace those bulk actions by id.
|
|
70
|
+
|
|
71
|
+
AXConversationMessagePinsService exposes pins, current, currentIndex, hidden, canManage, busy, loading and error signals, plus setPinned, unpinAll, navigate, reload, setHidden, openList and closeList. viewingPinned and visibleMessages expose the current pinned feed. getPinnedMessages returns messageId, pinnedBy and pinnedAt records; getMessage supplies the full message previews. The showcase IndexedDB API persists pin metadata and emits realtime message updates.
|
|
72
|
+
|
|
73
|
+
## Message selection
|
|
74
|
+
|
|
75
|
+
On desktop, drag vertically from the empty area in front of a bubble to select a range. Reversing the drag shrinks the range; dragging from a selected row removes that range from the initial selection. The feed scrolls near its edges. Bubble text selection and media interactions remain available outside selection mode.
|
|
76
|
+
|
|
77
|
+
On touch devices, hold a message for 450 ms to select it. Moving before the hold completes scrolls normally. Once selection starts, click or tap any message or its checkbox to toggle it. Message context menus are captured over the full row, including links, controls and custom renderer content. Albums are selected as complete messages. Escape, Cancel, or switching conversations clears selection. System messages and renderers with supportsSelection: false are skipped.
|
|
78
|
+
|
|
79
|
+
The header shows a count, Cancel, Forward and Delete. Delete asks for one confirmation and calls the message API for each selected message in chronological order, awaiting each call. Failed deletions are restored and an error is displayed; successful deletions stay deleted. Forward uses the existing recipient picker and sends complete messages sequentially in source order for each recipient. The selection gutter uses AXCheckBoxComponent and transitions smoothly in and out. Escape clears selection before it can reach a parent chat-close handler; a subsequent Escape keeps the normal chat-close behavior.
|
|
80
|
+
|
|
81
|
+
Register the optional context-menu action and custom bulk actions through provideConversation:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
provideConversation({
|
|
85
|
+
// userApi, conversationApi, messageApi, ...
|
|
86
|
+
registry: {
|
|
87
|
+
messageActions: [AX_CONVERSATION_MESSAGE_SELECT_ACTION],
|
|
88
|
+
selectionActions: [
|
|
89
|
+
{
|
|
90
|
+
id: 'export',
|
|
91
|
+
label: 'Export selected messages',
|
|
92
|
+
icon: 'fa-light fa-download',
|
|
93
|
+
priority: 10,
|
|
94
|
+
visible: ({ messages }) => messages.every((message) => message.type === 'text'),
|
|
95
|
+
enabled: ({ messages }) => messages.length <= 100,
|
|
96
|
+
handler: async ({ messages, conversation, currentUser, selection }) => {
|
|
97
|
+
await exportMessages(messages);
|
|
98
|
+
selection.clear();
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
AXConversationMessageSelectionService exposes readonly selectedMessages, selectedIds, count, active and executing signals; select, toggle, clear, register and unregister methods; and an error signal. Action predicates and handlers run in an Angular injection context. Messages are passed in chronological order. Matching action ids replace built-ins; unregister('delete') removes the default. Custom handlers decide whether to clear selection after success. Cancelled or failed deletion keeps the remaining selection.
|
|
107
|
+
|
|
19
108
|
## 📦 Installation
|
|
20
109
|
|
|
21
110
|
```bash
|
|
@@ -125,7 +214,9 @@ import {
|
|
|
125
214
|
conversationApi: AXIndexedDBConversationApi,
|
|
126
215
|
messageApi: AXIndexedDBMessageApi,
|
|
127
216
|
realtimeApi: AXIndexedDBRealtimeApi,
|
|
128
|
-
config: {
|
|
217
|
+
config: {
|
|
218
|
+
/* ... */
|
|
219
|
+
},
|
|
129
220
|
}),
|
|
130
221
|
],
|
|
131
222
|
})
|
|
@@ -145,7 +236,11 @@ You must provide an API implementation that extends `AXConversationApi`:
|
|
|
145
236
|
```typescript
|
|
146
237
|
import { Injectable } from '@angular/core';
|
|
147
238
|
import { HttpClient } from '@angular/common/http';
|
|
148
|
-
import {
|
|
239
|
+
import {
|
|
240
|
+
AXConversationApi,
|
|
241
|
+
AXConversationPagination,
|
|
242
|
+
AXConversationPaginatedResult,
|
|
243
|
+
} from '@acorex/components/conversation';
|
|
149
244
|
|
|
150
245
|
@Injectable()
|
|
151
246
|
export class MyConversationApi extends AXConversationApi {
|
|
@@ -157,10 +252,14 @@ export class MyConversationApi extends AXConversationApi {
|
|
|
157
252
|
// Initialize WebSocket connection
|
|
158
253
|
}
|
|
159
254
|
|
|
160
|
-
async fetchConversations(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
255
|
+
async fetchConversations(
|
|
256
|
+
pagination: AXConversationPagination,
|
|
257
|
+
): Promise<AXConversationPaginatedResult<AXConversation>> {
|
|
258
|
+
const response = await this.http
|
|
259
|
+
.get('/api/conversations', {
|
|
260
|
+
params: { page: pagination.page, pageSize: pagination.pageSize },
|
|
261
|
+
})
|
|
262
|
+
.toPromise();
|
|
164
263
|
return response;
|
|
165
264
|
}
|
|
166
265
|
|
|
@@ -220,14 +319,14 @@ provideConversation({
|
|
|
220
319
|
```typescript
|
|
221
320
|
interface AXConversationConfig {
|
|
222
321
|
// Pagination
|
|
223
|
-
messagePageSize?: number;
|
|
224
|
-
conversationPageSize?: number;
|
|
225
|
-
infiniteScrollThreshold?: number;
|
|
226
|
-
scrollThreshold?: number;
|
|
322
|
+
messagePageSize?: number; // Default: 50
|
|
323
|
+
conversationPageSize?: number; // Default: 30
|
|
324
|
+
infiniteScrollThreshold?: number; // Default: 200px
|
|
325
|
+
scrollThreshold?: number; // Default: 100px
|
|
227
326
|
|
|
228
327
|
// UI Behavior
|
|
229
|
-
messageHighlightDuration?: number;
|
|
230
|
-
typingIndicatorTimeout?: number;
|
|
328
|
+
messageHighlightDuration?: number; // Default: 2000ms
|
|
329
|
+
typingIndicatorTimeout?: number; // Default: 3000ms
|
|
231
330
|
}
|
|
232
331
|
```
|
|
233
332
|
|
|
@@ -255,7 +354,7 @@ import { AXConversationMessageRenderer } from '@acorex/components/conversation';
|
|
|
255
354
|
|
|
256
355
|
@Component({
|
|
257
356
|
selector: 'my-custom-renderer',
|
|
258
|
-
template: `<div>{{ message().payload.customData }}</div
|
|
357
|
+
template: `<div>{{ message().payload.customData }}</div>`,
|
|
259
358
|
})
|
|
260
359
|
export class MyCustomRendererComponent {
|
|
261
360
|
message = input.required<AXConversationMessage>();
|
|
@@ -264,15 +363,15 @@ export class MyCustomRendererComponent {
|
|
|
264
363
|
const myRenderer: AXConversationMessageRenderer = {
|
|
265
364
|
type: 'custom',
|
|
266
365
|
component: MyCustomRendererComponent,
|
|
267
|
-
priority: 100
|
|
366
|
+
priority: 100,
|
|
268
367
|
};
|
|
269
368
|
|
|
270
369
|
// Register in config
|
|
271
370
|
provideConversation({
|
|
272
371
|
api: MyApi,
|
|
273
372
|
registry: {
|
|
274
|
-
messageRenderers: [myRenderer]
|
|
275
|
-
}
|
|
373
|
+
messageRenderers: [myRenderer],
|
|
374
|
+
},
|
|
276
375
|
});
|
|
277
376
|
```
|
|
278
377
|
|
|
@@ -287,14 +386,14 @@ const forwardAction: AXConversationMessageAction = {
|
|
|
287
386
|
enabled: (message, user) => message.senderId === user.id,
|
|
288
387
|
execute: async (message, service) => {
|
|
289
388
|
// Forward logic
|
|
290
|
-
}
|
|
389
|
+
},
|
|
291
390
|
};
|
|
292
391
|
|
|
293
392
|
provideConversation({
|
|
294
393
|
api: MyApi,
|
|
295
394
|
registry: {
|
|
296
|
-
messageActions: [forwardAction]
|
|
297
|
-
}
|
|
395
|
+
messageActions: [forwardAction],
|
|
396
|
+
},
|
|
298
397
|
});
|
|
299
398
|
```
|
|
300
399
|
|
|
@@ -342,15 +441,12 @@ export class MyComponent {
|
|
|
342
441
|
await this.conversationService.sendMessage({
|
|
343
442
|
conversationId: 'conv-123',
|
|
344
443
|
type: 'text',
|
|
345
|
-
payload: { text: 'Hello!' }
|
|
444
|
+
payload: { text: 'Hello!' },
|
|
346
445
|
});
|
|
347
446
|
}
|
|
348
447
|
|
|
349
448
|
async createConversation() {
|
|
350
|
-
const conv = await this.conversationService.createConversation(
|
|
351
|
-
['user-1', 'user-2'],
|
|
352
|
-
'private'
|
|
353
|
-
);
|
|
449
|
+
const conv = await this.conversationService.createConversation(['user-1', 'user-2'], 'private');
|
|
354
450
|
}
|
|
355
451
|
}
|
|
356
452
|
```
|