@cloudflare/realtimekit-ui 1.1.0-staging.6 → 1.1.0-staging.8
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/dist/browser.js +1 -1
- package/dist/cjs/rtk-avatar_24.cjs.entry.js +240 -213
- package/dist/cjs/rtk-chat-toggle.cjs.entry.js +1 -1
- package/dist/cjs/rtk-notifications.cjs.entry.js +4 -1
- package/dist/collection/components/rtk-chat/rtk-chat.js +16 -2
- package/dist/collection/components/rtk-chat-messages-ui-paginated/rtk-chat-messages-ui-paginated.js +36 -16
- package/dist/collection/components/rtk-chat-toggle/rtk-chat-toggle.js +1 -1
- package/dist/collection/components/rtk-notifications/rtk-notifications.js +4 -1
- package/dist/collection/components/rtk-paginated-list/rtk-paginated-list.js +213 -200
- package/dist/components/{p-85872241.js → p-7e90e964.js} +18 -4
- package/dist/components/{p-b6781e91.js → p-9213c3fc.js} +17 -17
- package/dist/components/{p-e7e2156a.js → p-ad8282dc.js} +208 -195
- package/dist/components/rtk-chat-messages-ui-paginated.js +1 -1
- package/dist/components/rtk-chat-search-results.js +1 -1
- package/dist/components/rtk-chat-toggle.js +1 -1
- package/dist/components/rtk-chat.js +1 -1
- package/dist/components/rtk-meeting.js +3 -3
- package/dist/components/rtk-notifications.js +4 -1
- package/dist/components/rtk-paginated-list.js +1 -1
- package/dist/docs/docs-components.json +29 -9
- package/dist/esm/loader.js +244 -214
- package/dist/esm/rtk-avatar_24.entry.js +240 -213
- package/dist/esm/rtk-chat-toggle.entry.js +1 -1
- package/dist/esm/rtk-notifications.entry.js +4 -1
- package/dist/realtimekit-ui/p-342b4926.entry.js +1 -0
- package/dist/realtimekit-ui/p-8f4f3160.entry.js +1 -0
- package/dist/realtimekit-ui/{p-421e4c6f.entry.js → p-ec5ed8a4.entry.js} +1 -1
- package/dist/realtimekit-ui/realtimekit-ui.esm.js +1 -1
- package/dist/types/components/rtk-chat/rtk-chat.d.ts +1 -0
- package/dist/types/components/rtk-chat-messages-ui-paginated/rtk-chat-messages-ui-paginated.d.ts +2 -0
- package/dist/types/components/rtk-paginated-list/rtk-paginated-list.d.ts +35 -48
- package/dist/types/components.d.ts +8 -3
- package/package.json +1 -1
- package/dist/realtimekit-ui/p-19587963.entry.js +0 -1
- package/dist/realtimekit-ui/p-a859d883.entry.js +0 -1
|
@@ -232,7 +232,10 @@ const RtkNotifications = class {
|
|
|
232
232
|
this.waitlistedParticipantLeftListener = (participant) => {
|
|
233
233
|
this.remove(`${participant.id}-joined-waitlist`);
|
|
234
234
|
};
|
|
235
|
-
this.chatUpdateListener = ({ message }) => {
|
|
235
|
+
this.chatUpdateListener = ({ message, action }) => {
|
|
236
|
+
// NOTE(ikabra): we only want notifications for new messages
|
|
237
|
+
if (action !== 'add')
|
|
238
|
+
return;
|
|
236
239
|
const parsedMessage = chat.parseMessageForTarget(message);
|
|
237
240
|
if (parsedMessage != null) {
|
|
238
241
|
if (parsedMessage.userId === meeting.self.userId) {
|
|
@@ -283,6 +283,13 @@ export class RtkChat {
|
|
|
283
283
|
const message = event.detail;
|
|
284
284
|
this.meeting.chat.deleteMessage(message.id);
|
|
285
285
|
};
|
|
286
|
+
this.onMessageEdit = (event) => {
|
|
287
|
+
const message = event.detail;
|
|
288
|
+
if (message.type !== 'text')
|
|
289
|
+
return;
|
|
290
|
+
this.replyMessage = null;
|
|
291
|
+
this.editingMessage = message;
|
|
292
|
+
};
|
|
286
293
|
this.getPrivateChatRecipients = () => {
|
|
287
294
|
const participants = this.getFilteredParticipants().map((participant) => {
|
|
288
295
|
const key = generateChatGroupKey([participant.userId, this.meeting.self.userId]);
|
|
@@ -467,14 +474,21 @@ export class RtkChat {
|
|
|
467
474
|
const uiProps = { iconPack: this.iconPack, t: this.t, size: this.size };
|
|
468
475
|
const message = this.editingMessage ? this.editingMessage.message : '';
|
|
469
476
|
const quotedMessage = this.replyMessage ? this.replyMessage.message : '';
|
|
470
|
-
|
|
477
|
+
const draftStorageKey = this.selectedChannelId
|
|
478
|
+
? `rtk-chat-draft-${this.selectedChannelId}`
|
|
479
|
+
: 'rtk-chat-draft';
|
|
480
|
+
const editStorageKey = this.editingMessage
|
|
481
|
+
? `rtk-chat-edit-${(_a = this.selectedChannelId) !== null && _a !== void 0 ? _a : 'no-channel'}-${this.editingMessage.id}`
|
|
482
|
+
: 'rtk-chat-edit';
|
|
483
|
+
const storageKey = this.editingMessage ? editStorageKey : draftStorageKey;
|
|
484
|
+
return (h("rtk-chat-composer-view", Object.assign({ message: message, storageKey: storageKey, quotedMessage: quotedMessage, isEditing: !!this.editingMessage, canSendTextMessage: this.isTextMessagingAllowed(), canSendFiles: this.isFileMessagingAllowed(), disableEmojiPicker: this.overrides.disableEmojiPicker, maxLength: this.meeting.chat.maxTextLimit, rateLimits: this.meeting.chat.rateLimits, inputTextPlaceholder: this.t('chat.message_placeholder'), onNewMessage: this.onNewMessageHandler, onEditMessage: this.onEditMessageHandler, onEditCancel: this.onEditCancel, onQuotedMessageDismiss: this.onQuotedMessageDismiss }, uiProps), h("slot", { name: "chat-addon", slot: "chat-addon" })));
|
|
471
485
|
}
|
|
472
486
|
render() {
|
|
473
487
|
var _a;
|
|
474
488
|
if (!this.meeting) {
|
|
475
489
|
return null;
|
|
476
490
|
}
|
|
477
|
-
return (h(Host, null, h("div", { class: "chat-container" }, h("div", { class: "chat" }, this.isFileMessagingAllowed() && (h("div", { id: "dropzone", class: { active: this.dropzoneActivated }, part: "dropzone" }, h("rtk-icon", { icon: this.iconPack.attach }), h("p", null, this.t('chat.send_attachment')))), this.renderPinnedMessagesHeader(), this.isPrivateChatSupported() && (h("rtk-channel-selector-view", { channels: this.getPrivateChatRecipients(), selectedChannelId: ((_a = this.selectedParticipant) === null || _a === void 0 ? void 0 : _a.userId) || 'everyone', onChannelChange: this.updateRecipients, t: this.t, viewAs: "dropdown" })), h("rtk-chat-messages-ui-paginated", { meeting: this.meeting, onPinMessage: this.onPinMessage, onDeleteMessage: this.onDeleteMessage, size: this.size, iconPack: this.iconPack, t: this.t }), this.renderComposerUI()))));
|
|
491
|
+
return (h(Host, null, h("div", { class: "chat-container" }, h("div", { class: "chat" }, this.isFileMessagingAllowed() && (h("div", { id: "dropzone", class: { active: this.dropzoneActivated }, part: "dropzone" }, h("rtk-icon", { icon: this.iconPack.attach }), h("p", null, this.t('chat.send_attachment')))), this.renderPinnedMessagesHeader(), this.isPrivateChatSupported() && (h("rtk-channel-selector-view", { channels: this.getPrivateChatRecipients(), selectedChannelId: ((_a = this.selectedParticipant) === null || _a === void 0 ? void 0 : _a.userId) || 'everyone', onChannelChange: this.updateRecipients, t: this.t, viewAs: "dropdown" })), h("rtk-chat-messages-ui-paginated", { meeting: this.meeting, onPinMessage: this.onPinMessage, onEditMessage: this.onMessageEdit, onDeleteMessage: this.onDeleteMessage, size: this.size, iconPack: this.iconPack, t: this.t }), this.renderComposerUI()))));
|
|
478
492
|
}
|
|
479
493
|
static get is() { return "rtk-chat"; }
|
|
480
494
|
static get encapsulation() { return "shadow"; }
|
package/dist/collection/components/rtk-chat-messages-ui-paginated/rtk-chat-messages-ui-paginated.js
CHANGED
|
@@ -62,22 +62,18 @@ export class RtkChatMessagesUiPaginated {
|
|
|
62
62
|
};
|
|
63
63
|
this.getMessageActions = (message) => {
|
|
64
64
|
const actions = [];
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const canDelete = message.userId === this.meeting.self.userId;
|
|
73
|
-
if (this.meeting.self.permissions.pinParticipant) {
|
|
65
|
+
const messageBelongsToSelf = message.userId === this.meeting.self.userId;
|
|
66
|
+
actions.push({
|
|
67
|
+
id: 'pin_message',
|
|
68
|
+
label: message.pinned ? this.t('unpin') : this.t('pin'),
|
|
69
|
+
icon: this.iconPack.pin,
|
|
70
|
+
});
|
|
71
|
+
if (messageBelongsToSelf) {
|
|
74
72
|
actions.push({
|
|
75
|
-
id: '
|
|
76
|
-
label:
|
|
77
|
-
icon: this.iconPack.
|
|
73
|
+
id: 'edit_message',
|
|
74
|
+
label: this.t('chat.edit_msg'),
|
|
75
|
+
icon: this.iconPack.edit,
|
|
78
76
|
});
|
|
79
|
-
}
|
|
80
|
-
if (canDelete) {
|
|
81
77
|
actions.push({
|
|
82
78
|
id: 'delete_message',
|
|
83
79
|
label: this.t('chat.delete_msg'),
|
|
@@ -91,6 +87,9 @@ export class RtkChatMessagesUiPaginated {
|
|
|
91
87
|
case 'pin_message':
|
|
92
88
|
this.onPinMessage.emit(message);
|
|
93
89
|
break;
|
|
90
|
+
case 'edit_message':
|
|
91
|
+
this.onEditMessage.emit(message);
|
|
92
|
+
break;
|
|
94
93
|
case 'delete_message':
|
|
95
94
|
this.onDeleteMessage.emit(message);
|
|
96
95
|
break;
|
|
@@ -121,7 +120,7 @@ export class RtkChatMessagesUiPaginated {
|
|
|
121
120
|
}
|
|
122
121
|
const isSelf = message.userId === this.meeting.self.userId;
|
|
123
122
|
const viewType = isSelf ? 'outgoing' : 'incoming';
|
|
124
|
-
return (h("div", null, h("div", { class: "message-wrapper" }, h("rtk-message-view", { pinned: message.pinned, time: message.time, actions: this.getMessageActions(message), authorName: message.displayName, isSelf: isSelf, avatarUrl: displayPicture, hideAuthorName: isContinued, viewType: viewType, variant: "bubble", onAction: (event) => this.onMessageActionHandler(event.detail, message) }, h("div", null, h("div", { class: "body" }, message.type === 'text' && (h("rtk-text-message-view", { text: message.message, isMarkdown: true })), message.type === 'file' && (h("rtk-file-message-view", { name: message.name, url: message.link, size: message.size })), message.type === 'image' && (h("rtk-image-message-view", { url: message.link, onPreview: () => {
|
|
123
|
+
return (h("div", null, h("div", { class: "message-wrapper", id: message.id }, h("rtk-message-view", { pinned: message.pinned, time: message.time, actions: this.getMessageActions(message), authorName: message.displayName, isSelf: isSelf, avatarUrl: displayPicture, hideAuthorName: isContinued, viewType: viewType, variant: "bubble", onAction: (event) => this.onMessageActionHandler(event.detail, message) }, h("div", null, h("div", { class: "body" }, message.type === 'text' && (h("rtk-text-message-view", { text: message.message, isMarkdown: true })), message.type === 'file' && (h("rtk-file-message-view", { name: message.name, url: message.link, size: message.size })), message.type === 'image' && (h("rtk-image-message-view", { url: message.link, onPreview: () => {
|
|
125
124
|
this.stateUpdate.emit({ image: message });
|
|
126
125
|
} }))))))));
|
|
127
126
|
};
|
|
@@ -169,7 +168,7 @@ export class RtkChatMessagesUiPaginated {
|
|
|
169
168
|
this.lastReadMessageIndex = -1;
|
|
170
169
|
}
|
|
171
170
|
render() {
|
|
172
|
-
return (h(Host, { key: '
|
|
171
|
+
return (h(Host, { key: '55b594d1fad2c164a70b71e297f63273ece0bc4f' }, h("rtk-paginated-list", { key: '1554ee896643feec72a02672f156f95c988813ce', ref: (el) => (this.$paginatedListRef = el), pageSize: this.pageSize, pagesAllowed: 3, fetchData: this.getChatMessages, createNodes: this.createChatNodes, selectedItemId: this.selectedChannelId, emptyListLabel: this.t('chat.empty_channel') }, h("slot", { key: '03aeb2069b87cb217b9759cabd3835c9bac81f11' }))));
|
|
173
172
|
}
|
|
174
173
|
static get is() { return "rtk-chat-messages-ui-paginated"; }
|
|
175
174
|
static get encapsulation() { return "shadow"; }
|
|
@@ -394,6 +393,27 @@ export class RtkChatMessagesUiPaginated {
|
|
|
394
393
|
}
|
|
395
394
|
}
|
|
396
395
|
}
|
|
396
|
+
}, {
|
|
397
|
+
"method": "onEditMessage",
|
|
398
|
+
"name": "editMessage",
|
|
399
|
+
"bubbles": true,
|
|
400
|
+
"cancelable": true,
|
|
401
|
+
"composed": true,
|
|
402
|
+
"docs": {
|
|
403
|
+
"tags": [],
|
|
404
|
+
"text": "Event emitted when a message is edited"
|
|
405
|
+
},
|
|
406
|
+
"complexType": {
|
|
407
|
+
"original": "Message",
|
|
408
|
+
"resolved": "CustomMessage | FileMessage | ImageMessage | TextMessage",
|
|
409
|
+
"references": {
|
|
410
|
+
"Message": {
|
|
411
|
+
"location": "import",
|
|
412
|
+
"path": "@cloudflare/realtimekit",
|
|
413
|
+
"id": "node_modules::Message"
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
397
417
|
}, {
|
|
398
418
|
"method": "onDeleteMessage",
|
|
399
419
|
"name": "deleteMessage",
|
|
@@ -98,7 +98,7 @@ export class RtkChatToggle {
|
|
|
98
98
|
const newMessages = messages.filter((m) => m.timeMs > meetingStartedTimeMs);
|
|
99
99
|
if (newMessages.length === this.pageSize && newMessages.length > 0) {
|
|
100
100
|
// all messages are new, so we can't know the exact count, but we know there are at least pageSize - 1 new messages
|
|
101
|
-
this.unreadMessageCount =
|
|
101
|
+
this.unreadMessageCount = newMessages.length;
|
|
102
102
|
}
|
|
103
103
|
else {
|
|
104
104
|
this.unreadMessageCount = newMessages.length;
|
|
@@ -197,7 +197,10 @@ export class RtkNotifications {
|
|
|
197
197
|
this.waitlistedParticipantLeftListener = (participant) => {
|
|
198
198
|
this.remove(`${participant.id}-joined-waitlist`);
|
|
199
199
|
};
|
|
200
|
-
this.chatUpdateListener = ({ message }) => {
|
|
200
|
+
this.chatUpdateListener = ({ message, action }) => {
|
|
201
|
+
// NOTE(ikabra): we only want notifications for new messages
|
|
202
|
+
if (action !== 'add')
|
|
203
|
+
return;
|
|
201
204
|
const parsedMessage = parseMessageForTarget(message);
|
|
202
205
|
if (parsedMessage != null) {
|
|
203
206
|
if (parsedMessage.userId === meeting.self.userId) {
|