@chat-leo/chatleo 0.0.0-stage → 2.0.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.
- package/LICENSE +21 -0
- package/dist/chatleo/chatleo.esm.js +1 -0
- package/dist/chatleo/index.esm.js +1 -0
- package/dist/chatleo/p-43ada232.entry.js +1 -0
- package/dist/chatleo/p-4485e141.entry.js +1 -0
- package/dist/chatleo/p-BnCPdbII.js +1 -0
- package/dist/chatleo/p-C-l90Wre.js +1 -0
- package/dist/chatleo/p-DQuL1Twl.js +1 -0
- package/dist/chatleo/p-DmL518NK.js +3 -0
- package/dist/chatleo/p-aed60255.entry.js +1 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/chatleo-avatar_13.cjs.entry.js +2986 -0
- package/dist/cjs/chatleo-call-adapter-B2OfC0VZ.js +35 -0
- package/dist/cjs/chatleo-chat-input.cjs.entry.js +67 -0
- package/dist/cjs/chatleo.cjs.js +25 -0
- package/dist/cjs/index-DkSDLR0y.js +56 -0
- package/dist/cjs/index-Dxw4YCA_.js +1741 -0
- package/dist/cjs/index.cjs.js +7 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/my-component.cjs.entry.js +33 -0
- package/dist/collection/__mocks__/stencil-core.js +26 -0
- package/dist/collection/collection-manifest.json +27 -0
- package/dist/collection/components/chatleo-avatar/chatleo-avatar.css +40 -0
- package/dist/collection/components/chatleo-avatar/chatleo-avatar.js +116 -0
- package/dist/collection/components/chatleo-chat/chatleo-chat.css +108 -0
- package/dist/collection/components/chatleo-chat/chatleo-chat.js +459 -0
- package/dist/collection/components/chatleo-chat-header/chatleo-chat-header.css +22 -0
- package/dist/collection/components/chatleo-chat-header/chatleo-chat-header.js +105 -0
- package/dist/collection/components/chatleo-chat-input/chatleo-chat-input.css +84 -0
- package/dist/collection/components/chatleo-chat-input/chatleo-chat-input.js +141 -0
- package/dist/collection/components/chatleo-chat-message/chatleo-chat-message.css +149 -0
- package/dist/collection/components/chatleo-chat-message/chatleo-chat-message.js +259 -0
- package/dist/collection/components/chatleo-component/chatleo-component.css +271 -0
- package/dist/collection/components/chatleo-component/chatleo-component.js +1366 -0
- package/dist/collection/components/chatleo-new-message-selector/chatleo-new-message-selector.css +96 -0
- package/dist/collection/components/chatleo-new-message-selector/chatleo-new-message-selector.js +231 -0
- package/dist/collection/components/chatleo-rich-input/chatleo-rich-input.css +352 -0
- package/dist/collection/components/chatleo-rich-input/chatleo-rich-input.js +976 -0
- package/dist/collection/components/chatleo-rich-message-renderer/chatleo-rich-message-renderer.css +169 -0
- package/dist/collection/components/chatleo-rich-message-renderer/chatleo-rich-message-renderer.js +400 -0
- package/dist/collection/components/chatleo-room-list/chatleo-room-list.css +111 -0
- package/dist/collection/components/chatleo-room-list/chatleo-room-list.js +180 -0
- package/dist/collection/components/chatleo-room-tile-component/chatleo-room-tile-component.css +110 -0
- package/dist/collection/components/chatleo-room-tile-component/chatleo-room-tile-component.js +241 -0
- package/dist/collection/components/chatleo-room-view/chatleo-room-view.css +93 -0
- package/dist/collection/components/chatleo-room-view/chatleo-room-view.js +593 -0
- package/dist/collection/components/chatleo-tray-component/chatleo-tray-component.css +284 -0
- package/dist/collection/components/chatleo-tray-component/chatleo-tray-component.js +391 -0
- package/dist/collection/components/chatleo-user-tile/chatleo-user-tile.css +56 -0
- package/dist/collection/components/chatleo-user-tile/chatleo-user-tile.js +149 -0
- package/dist/collection/components/my-component/my-component.css +4 -0
- package/dist/collection/components/my-component/my-component.js +95 -0
- package/dist/collection/index.js +10 -0
- package/dist/collection/utils/call-entry.js +34 -0
- package/dist/collection/utils/delivery.js +7 -0
- package/dist/collection/utils/utils.js +51 -0
- package/dist/components/chatleo-avatar.d.ts +11 -0
- package/dist/components/chatleo-avatar.js +1 -0
- package/dist/components/chatleo-chat-header.d.ts +11 -0
- package/dist/components/chatleo-chat-header.js +1 -0
- package/dist/components/chatleo-chat-input.d.ts +11 -0
- package/dist/components/chatleo-chat-input.js +1 -0
- package/dist/components/chatleo-chat-message.d.ts +11 -0
- package/dist/components/chatleo-chat-message.js +1 -0
- package/dist/components/chatleo-chat.d.ts +11 -0
- package/dist/components/chatleo-chat.js +1 -0
- package/dist/components/chatleo-component.d.ts +11 -0
- package/dist/components/chatleo-component.js +1 -0
- package/dist/components/chatleo-new-message-selector.d.ts +11 -0
- package/dist/components/chatleo-new-message-selector.js +1 -0
- package/dist/components/chatleo-rich-input.d.ts +11 -0
- package/dist/components/chatleo-rich-input.js +1 -0
- package/dist/components/chatleo-rich-message-renderer.d.ts +11 -0
- package/dist/components/chatleo-rich-message-renderer.js +1 -0
- package/dist/components/chatleo-room-list.d.ts +11 -0
- package/dist/components/chatleo-room-list.js +1 -0
- package/dist/components/chatleo-room-tile-component.d.ts +11 -0
- package/dist/components/chatleo-room-tile-component.js +1 -0
- package/dist/components/chatleo-room-view.d.ts +11 -0
- package/dist/components/chatleo-room-view.js +1 -0
- package/dist/components/chatleo-tray-component.d.ts +11 -0
- package/dist/components/chatleo-tray-component.js +1 -0
- package/dist/components/chatleo-user-tile.d.ts +11 -0
- package/dist/components/chatleo-user-tile.js +1 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/my-component.d.ts +11 -0
- package/dist/components/my-component.js +1 -0
- package/dist/components/p-8kvQ-Uh-.js +1 -0
- package/dist/components/p-B7cdqAgv.js +1 -0
- package/dist/components/p-BdiOcOYZ.js +1 -0
- package/dist/components/p-BlbDSb7D.js +1 -0
- package/dist/components/p-BnCPdbII.js +1 -0
- package/dist/components/p-C-v19aUJ.js +1 -0
- package/dist/components/p-C1mF0s8g.js +1 -0
- package/dist/components/p-CRtBdzP3.js +1 -0
- package/dist/components/p-CfayCm9O.js +1 -0
- package/dist/components/p-DGjAxoQy.js +1 -0
- package/dist/components/p-Exj_2-yI.js +1 -0
- package/dist/components/p-XlwGxsqT.js +1 -0
- package/dist/components/p-fjMaTJam.js +1 -0
- package/dist/components/p-xt4kzz3B.js +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/chatleo-avatar_13.entry.js +2972 -0
- package/dist/esm/chatleo-call-adapter-BnCPdbII.js +33 -0
- package/dist/esm/chatleo-chat-input.entry.js +65 -0
- package/dist/esm/chatleo.js +21 -0
- package/dist/esm/index-C-l90Wre.js +53 -0
- package/dist/esm/index-DmL518NK.js +1733 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/my-component.entry.js +31 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/__mocks__/stencil-core.d.ts +24 -0
- package/dist/types/components/chatleo-avatar/chatleo-avatar.d.ts +27 -0
- package/dist/types/components/chatleo-chat/chatleo-chat.d.ts +75 -0
- package/dist/types/components/chatleo-chat-header/chatleo-chat-header.d.ts +27 -0
- package/dist/types/components/chatleo-chat-input/chatleo-chat-input.d.ts +31 -0
- package/dist/types/components/chatleo-chat-message/chatleo-chat-message.d.ts +22 -0
- package/dist/types/components/chatleo-component/chatleo-component.d.ts +278 -0
- package/dist/types/components/chatleo-new-message-selector/chatleo-new-message-selector.d.ts +68 -0
- package/dist/types/components/chatleo-rich-input/chatleo-rich-input.d.ts +216 -0
- package/dist/types/components/chatleo-rich-message-renderer/chatleo-rich-message-renderer.d.ts +77 -0
- package/dist/types/components/chatleo-room-list/chatleo-room-list.d.ts +52 -0
- package/dist/types/components/chatleo-room-tile-component/chatleo-room-tile-component.d.ts +59 -0
- package/dist/types/components/chatleo-room-view/chatleo-room-view.d.ts +91 -0
- package/dist/types/components/chatleo-tray-component/chatleo-tray-component.d.ts +112 -0
- package/dist/types/components/chatleo-user-tile/chatleo-user-tile.d.ts +36 -0
- package/dist/types/components/my-component/my-component.d.ts +16 -0
- package/dist/types/components.d.ts +1593 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/stencil-public-runtime.d.ts +1879 -0
- package/dist/types/utils/call-entry.d.ts +9 -0
- package/dist/types/utils/delivery.d.ts +7 -0
- package/dist/types/utils/utils.d.ts +24 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +70 -3
- package/readme.md +111 -0
- package/README.md +0 -3
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
/**
|
|
3
|
+
* @component ChatleoChat
|
|
4
|
+
* @description This is the main component for the chat interface. It orchestrates the different parts of the chat, including the room list, chat header, message display, and input area. It listens for events from child components to handle message sending and room selection.
|
|
5
|
+
* @property {ChatStore} chatStore - An instance of the `ChatStore` class, which manages the application's state, including rooms, messages, and user profiles.
|
|
6
|
+
* @property {boolean} isOnline - Indicates the current user's online status.
|
|
7
|
+
* @property {boolean} pending - If `true`, the component will display a loading state instead of the message list.
|
|
8
|
+
* @fires messageChatSent - This event is emitted when a user sends a message. The event detail contains the message payload, including the room ID, content, and sender information.
|
|
9
|
+
*/
|
|
10
|
+
export class ChatleoChat {
|
|
11
|
+
/**
|
|
12
|
+
* An instance of the `ChatStore` class, which manages the application's state, including rooms, messages, and user profiles.
|
|
13
|
+
*/
|
|
14
|
+
chatStore;
|
|
15
|
+
/**
|
|
16
|
+
* Indicates the current user's online status.
|
|
17
|
+
*/
|
|
18
|
+
isOnline = false;
|
|
19
|
+
// TODO: needed?
|
|
20
|
+
/**
|
|
21
|
+
* If `true`, the component will display a loading state instead of the message list.
|
|
22
|
+
*/
|
|
23
|
+
pending = false;
|
|
24
|
+
/** Calls are available and enabled for this host. */
|
|
25
|
+
callsAvailable = false;
|
|
26
|
+
/** This client is currently in the room's call. */
|
|
27
|
+
inCall = false;
|
|
28
|
+
selectedRoomId;
|
|
29
|
+
_version = 0;
|
|
30
|
+
_showRoomDetail = false;
|
|
31
|
+
roomViewRef;
|
|
32
|
+
handleToggleMobileView() {
|
|
33
|
+
this._showRoomDetail = !this._showRoomDetail;
|
|
34
|
+
}
|
|
35
|
+
isMobileViewport() {
|
|
36
|
+
return window.innerWidth < 768;
|
|
37
|
+
}
|
|
38
|
+
// --- Host API (used by the app shell for navigation, drafts and shares) ---
|
|
39
|
+
/** Opens a room regardless of the current pane, and shows the conversation on a phone. */
|
|
40
|
+
async openRoom(roomId) {
|
|
41
|
+
if (!roomId)
|
|
42
|
+
return;
|
|
43
|
+
this.selectedRoomId = roomId;
|
|
44
|
+
this.chatStore?.setActiveRoomId(roomId);
|
|
45
|
+
this.chatStore?.markRoomAsRead(roomId);
|
|
46
|
+
if (this.isMobileViewport())
|
|
47
|
+
this._showRoomDetail = true;
|
|
48
|
+
}
|
|
49
|
+
/** Returns to the room list (device back / app back button). */
|
|
50
|
+
async closeRoom() {
|
|
51
|
+
this._showRoomDetail = false;
|
|
52
|
+
this.chatStore?.setActiveRoomId(null);
|
|
53
|
+
}
|
|
54
|
+
async getDraft() {
|
|
55
|
+
return (await this.roomViewRef?.getDraft?.()) ?? '';
|
|
56
|
+
}
|
|
57
|
+
async setDraft(text) {
|
|
58
|
+
if (text)
|
|
59
|
+
await this.roomViewRef?.setDraft?.(text);
|
|
60
|
+
}
|
|
61
|
+
async addFiles(files) {
|
|
62
|
+
await this.roomViewRef?.addFiles?.(files ?? []);
|
|
63
|
+
}
|
|
64
|
+
async focusComposer() {
|
|
65
|
+
await this.roomViewRef?.focusComposer?.();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @function onChatStoreChange
|
|
69
|
+
* @description This watcher is triggered whenever the `chatStore` prop changes. It is responsible for setting up event listeners on the new store to update the component when data changes, such as when a new room is added or a message is received.
|
|
70
|
+
* @param {ChatStore} newStore - The new `ChatStore` instance.
|
|
71
|
+
* @param {ChatStore} oldStore - The previous `ChatStore` instance.
|
|
72
|
+
*/
|
|
73
|
+
onChatStoreChange(newStore, oldStore) {
|
|
74
|
+
console.debug('onChatStoreChange', newStore, oldStore);
|
|
75
|
+
// TODO: unbind oldStore listeners
|
|
76
|
+
newStore.addEventListener('roomAdded', r => {
|
|
77
|
+
console.debug('roomAdded', r);
|
|
78
|
+
this._version++;
|
|
79
|
+
});
|
|
80
|
+
newStore.addEventListener('roomMessageAdded', e => {
|
|
81
|
+
console.debug('roomMessageAdded', e);
|
|
82
|
+
this._version++;
|
|
83
|
+
const detail = e.detail;
|
|
84
|
+
if (detail?.roomId && detail.roomId === this.selectedRoomId) {
|
|
85
|
+
newStore.markRoomAsRead(detail.roomId);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
newStore.addEventListener('roomReadCountChanged', () => {
|
|
89
|
+
this._version++;
|
|
90
|
+
});
|
|
91
|
+
newStore.addEventListener('presenceChanged', e => {
|
|
92
|
+
console.debug('onPresenceChange', e);
|
|
93
|
+
this._version++;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
messageChatSent;
|
|
97
|
+
// old
|
|
98
|
+
/**
|
|
99
|
+
* @function handleSendMessage
|
|
100
|
+
* @description This is a listener for the `messageInputSent` event, which is fired by the `chatleo-chat-input` component. It takes the plain text from the event, constructs a `ChatMessageSent` object, and emits it as a `messageChatSent` event.
|
|
101
|
+
* @param {CustomEvent<string>} event - The custom event containing the message text.
|
|
102
|
+
*/
|
|
103
|
+
handleSendMessage(event) {
|
|
104
|
+
this.messageChatSent.emit({
|
|
105
|
+
room_id: this.selectedRoomId,
|
|
106
|
+
content: event.detail,
|
|
107
|
+
sender: this.chatStore?.profile?.id,
|
|
108
|
+
content_type: 'text/plain',
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
// new
|
|
112
|
+
/**
|
|
113
|
+
* @function messageSendHandler
|
|
114
|
+
* @description This listener handles the `messageSend` event from the `chatleo-rich-input` component. It processes the rich content payload, sanitizing it by removing base64 image previews from attachments to reduce payload size. It then constructs a `ChatMessageSent` object and emits it.
|
|
115
|
+
* @param {CustomEvent<any>} event - The custom event containing the structured message content.
|
|
116
|
+
*/
|
|
117
|
+
messageSendHandler(event) {
|
|
118
|
+
console.log('Received the messageSend event: ', JSON.stringify(event.detail));
|
|
119
|
+
// Sanitize blocks: remove preview from each attachment object
|
|
120
|
+
const inputBlocks = event.detail?.blocks ?? [];
|
|
121
|
+
const sanitizedBlocks = inputBlocks.map((block) => {
|
|
122
|
+
if (block?.type === 'attachment' && Array.isArray(block.attachments)) {
|
|
123
|
+
const sanitizedAttachments = block.attachments.map((att) => {
|
|
124
|
+
const { preview, ...rest } = att ?? {};
|
|
125
|
+
return rest;
|
|
126
|
+
});
|
|
127
|
+
return { ...block, attachments: sanitizedAttachments };
|
|
128
|
+
}
|
|
129
|
+
return block;
|
|
130
|
+
});
|
|
131
|
+
this.messageChatSent.emit({
|
|
132
|
+
room_id: this.selectedRoomId,
|
|
133
|
+
// TODO: change to ChatMessageSent type
|
|
134
|
+
content: { blocks: sanitizedBlocks, version: event.detail.version },
|
|
135
|
+
content_type: 'application/json+blocks',
|
|
136
|
+
sender: this.chatStore?.profile?.id,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
//
|
|
140
|
+
/**
|
|
141
|
+
* @function handleRoomClicked
|
|
142
|
+
* @description This listener is triggered when a user clicks on a room in the `chatleo-room-list` component. It updates the `selectedRoomId` state, which causes the component to re-render and display the messages for the newly selected room.
|
|
143
|
+
* @param {CustomEvent<RoomSummary>} event - The custom event containing the summary of the clicked room.
|
|
144
|
+
*/
|
|
145
|
+
async handleRoomClicked(event) {
|
|
146
|
+
console.debug(`ChatleoChat.roomClicked`, event);
|
|
147
|
+
await this.openRoom(event.detail.id);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @function render
|
|
151
|
+
* @description The render method for the `ChatleoChat` component. It assembles the chat interface, including the room list and the room view. It uses the new `chatleo-room-view` component to display the selected room.
|
|
152
|
+
* @returns {any} A VNode representing the component's UI.
|
|
153
|
+
*/
|
|
154
|
+
render() {
|
|
155
|
+
const mobileViewClass = this._showRoomDetail ? 'show-room-view' : 'show-room-list';
|
|
156
|
+
return (h("div", { key: '759aa942b6cfba0635119d0064afe7bc4e2ef901', class: `chat-container-list-and-chat ${mobileViewClass}` }, h("chatleo-room-list", { key: 'feecf22c1ab746ec5af8cb1e61708f131946a260', rooms: this.chatStore?.rooms, chatStore: this.chatStore, selectedRoomId: this.selectedRoomId }), h("chatleo-room-view", { key: 'c90a58b6946c949288176b3aa5a411b3d7722e7e', ref: el => (this.roomViewRef = el), chatStore: this.chatStore, roomId: this.selectedRoomId, isOnline: this.isOnline, pending: this.pending, callsAvailable: this.callsAvailable, inCall: this.inCall }), h("button", { key: 'd1ccaa37c2135f5a0f2945d82cc5becda60ea6e0', class: "toggle-btn", onClick: () => this.handleToggleMobileView() }, h("svg", { key: 'e5af148d5cfd19d7bc44cdd76fea530bc6683ea9', viewBox: "0 0 24 24" }, this._showRoomDetail ? h("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }) : h("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" })))));
|
|
157
|
+
}
|
|
158
|
+
static get is() { return "chatleo-chat"; }
|
|
159
|
+
static get encapsulation() { return "shadow"; }
|
|
160
|
+
static get originalStyleUrls() {
|
|
161
|
+
return {
|
|
162
|
+
"$": ["chatleo-chat.css"]
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
static get styleUrls() {
|
|
166
|
+
return {
|
|
167
|
+
"$": ["chatleo-chat.css"]
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
static get properties() {
|
|
171
|
+
return {
|
|
172
|
+
"chatStore": {
|
|
173
|
+
"type": "unknown",
|
|
174
|
+
"mutable": false,
|
|
175
|
+
"complexType": {
|
|
176
|
+
"original": "ChatStore",
|
|
177
|
+
"resolved": "ChatStore",
|
|
178
|
+
"references": {
|
|
179
|
+
"ChatStore": {
|
|
180
|
+
"location": "import",
|
|
181
|
+
"path": "@chat-leo/chatleolib",
|
|
182
|
+
"id": "../chatleolib/dist/ChatStore.d.ts::ChatStore",
|
|
183
|
+
"referenceLocation": "ChatStore"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"required": false,
|
|
188
|
+
"optional": true,
|
|
189
|
+
"docs": {
|
|
190
|
+
"tags": [],
|
|
191
|
+
"text": "An instance of the `ChatStore` class, which manages the application's state, including rooms, messages, and user profiles."
|
|
192
|
+
},
|
|
193
|
+
"getter": false,
|
|
194
|
+
"setter": false
|
|
195
|
+
},
|
|
196
|
+
"isOnline": {
|
|
197
|
+
"type": "boolean",
|
|
198
|
+
"mutable": false,
|
|
199
|
+
"complexType": {
|
|
200
|
+
"original": "boolean",
|
|
201
|
+
"resolved": "boolean",
|
|
202
|
+
"references": {}
|
|
203
|
+
},
|
|
204
|
+
"required": false,
|
|
205
|
+
"optional": false,
|
|
206
|
+
"docs": {
|
|
207
|
+
"tags": [],
|
|
208
|
+
"text": "Indicates the current user's online status."
|
|
209
|
+
},
|
|
210
|
+
"getter": false,
|
|
211
|
+
"setter": false,
|
|
212
|
+
"reflect": false,
|
|
213
|
+
"attribute": "is-online",
|
|
214
|
+
"defaultValue": "false"
|
|
215
|
+
},
|
|
216
|
+
"pending": {
|
|
217
|
+
"type": "boolean",
|
|
218
|
+
"mutable": false,
|
|
219
|
+
"complexType": {
|
|
220
|
+
"original": "boolean",
|
|
221
|
+
"resolved": "boolean",
|
|
222
|
+
"references": {}
|
|
223
|
+
},
|
|
224
|
+
"required": false,
|
|
225
|
+
"optional": true,
|
|
226
|
+
"docs": {
|
|
227
|
+
"tags": [],
|
|
228
|
+
"text": "If `true`, the component will display a loading state instead of the message list."
|
|
229
|
+
},
|
|
230
|
+
"getter": false,
|
|
231
|
+
"setter": false,
|
|
232
|
+
"reflect": false,
|
|
233
|
+
"attribute": "pending",
|
|
234
|
+
"defaultValue": "false"
|
|
235
|
+
},
|
|
236
|
+
"callsAvailable": {
|
|
237
|
+
"type": "boolean",
|
|
238
|
+
"mutable": false,
|
|
239
|
+
"complexType": {
|
|
240
|
+
"original": "boolean",
|
|
241
|
+
"resolved": "boolean",
|
|
242
|
+
"references": {}
|
|
243
|
+
},
|
|
244
|
+
"required": false,
|
|
245
|
+
"optional": false,
|
|
246
|
+
"docs": {
|
|
247
|
+
"tags": [],
|
|
248
|
+
"text": "Calls are available and enabled for this host."
|
|
249
|
+
},
|
|
250
|
+
"getter": false,
|
|
251
|
+
"setter": false,
|
|
252
|
+
"reflect": false,
|
|
253
|
+
"attribute": "calls-available",
|
|
254
|
+
"defaultValue": "false"
|
|
255
|
+
},
|
|
256
|
+
"inCall": {
|
|
257
|
+
"type": "boolean",
|
|
258
|
+
"mutable": false,
|
|
259
|
+
"complexType": {
|
|
260
|
+
"original": "boolean",
|
|
261
|
+
"resolved": "boolean",
|
|
262
|
+
"references": {}
|
|
263
|
+
},
|
|
264
|
+
"required": false,
|
|
265
|
+
"optional": false,
|
|
266
|
+
"docs": {
|
|
267
|
+
"tags": [],
|
|
268
|
+
"text": "This client is currently in the room's call."
|
|
269
|
+
},
|
|
270
|
+
"getter": false,
|
|
271
|
+
"setter": false,
|
|
272
|
+
"reflect": false,
|
|
273
|
+
"attribute": "in-call",
|
|
274
|
+
"defaultValue": "false"
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
static get states() {
|
|
279
|
+
return {
|
|
280
|
+
"selectedRoomId": {},
|
|
281
|
+
"_version": {},
|
|
282
|
+
"_showRoomDetail": {}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
static get events() {
|
|
286
|
+
return [{
|
|
287
|
+
"method": "messageChatSent",
|
|
288
|
+
"name": "messageChatSent",
|
|
289
|
+
"bubbles": true,
|
|
290
|
+
"cancelable": true,
|
|
291
|
+
"composed": true,
|
|
292
|
+
"docs": {
|
|
293
|
+
"tags": [],
|
|
294
|
+
"text": ""
|
|
295
|
+
},
|
|
296
|
+
"complexType": {
|
|
297
|
+
"original": "ChatMessageSent",
|
|
298
|
+
"resolved": "{ room_id: string; content: any; content_type: string; sender: string; }",
|
|
299
|
+
"references": {
|
|
300
|
+
"ChatMessageSent": {
|
|
301
|
+
"location": "import",
|
|
302
|
+
"path": "@chat-leo/chatleolib",
|
|
303
|
+
"id": "../chatleolib/dist/index.d.ts::ChatMessageSent",
|
|
304
|
+
"referenceLocation": "ChatMessageSent"
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}];
|
|
309
|
+
}
|
|
310
|
+
static get methods() {
|
|
311
|
+
return {
|
|
312
|
+
"openRoom": {
|
|
313
|
+
"complexType": {
|
|
314
|
+
"signature": "(roomId: string) => Promise<void>",
|
|
315
|
+
"parameters": [{
|
|
316
|
+
"name": "roomId",
|
|
317
|
+
"type": "string",
|
|
318
|
+
"docs": ""
|
|
319
|
+
}],
|
|
320
|
+
"references": {
|
|
321
|
+
"Promise": {
|
|
322
|
+
"location": "global",
|
|
323
|
+
"id": "global::Promise"
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"return": "Promise<void>"
|
|
327
|
+
},
|
|
328
|
+
"docs": {
|
|
329
|
+
"text": "Opens a room regardless of the current pane, and shows the conversation on a phone.",
|
|
330
|
+
"tags": []
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
"closeRoom": {
|
|
334
|
+
"complexType": {
|
|
335
|
+
"signature": "() => Promise<void>",
|
|
336
|
+
"parameters": [],
|
|
337
|
+
"references": {
|
|
338
|
+
"Promise": {
|
|
339
|
+
"location": "global",
|
|
340
|
+
"id": "global::Promise"
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
"return": "Promise<void>"
|
|
344
|
+
},
|
|
345
|
+
"docs": {
|
|
346
|
+
"text": "Returns to the room list (device back / app back button).",
|
|
347
|
+
"tags": []
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
"getDraft": {
|
|
351
|
+
"complexType": {
|
|
352
|
+
"signature": "() => Promise<string>",
|
|
353
|
+
"parameters": [],
|
|
354
|
+
"references": {
|
|
355
|
+
"Promise": {
|
|
356
|
+
"location": "global",
|
|
357
|
+
"id": "global::Promise"
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
"return": "Promise<string>"
|
|
361
|
+
},
|
|
362
|
+
"docs": {
|
|
363
|
+
"text": "",
|
|
364
|
+
"tags": []
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
"setDraft": {
|
|
368
|
+
"complexType": {
|
|
369
|
+
"signature": "(text: string) => Promise<void>",
|
|
370
|
+
"parameters": [{
|
|
371
|
+
"name": "text",
|
|
372
|
+
"type": "string",
|
|
373
|
+
"docs": ""
|
|
374
|
+
}],
|
|
375
|
+
"references": {
|
|
376
|
+
"Promise": {
|
|
377
|
+
"location": "global",
|
|
378
|
+
"id": "global::Promise"
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
"return": "Promise<void>"
|
|
382
|
+
},
|
|
383
|
+
"docs": {
|
|
384
|
+
"text": "",
|
|
385
|
+
"tags": []
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
"addFiles": {
|
|
389
|
+
"complexType": {
|
|
390
|
+
"signature": "(files: File[]) => Promise<void>",
|
|
391
|
+
"parameters": [{
|
|
392
|
+
"name": "files",
|
|
393
|
+
"type": "File[]",
|
|
394
|
+
"docs": ""
|
|
395
|
+
}],
|
|
396
|
+
"references": {
|
|
397
|
+
"Promise": {
|
|
398
|
+
"location": "global",
|
|
399
|
+
"id": "global::Promise"
|
|
400
|
+
},
|
|
401
|
+
"File": {
|
|
402
|
+
"location": "global",
|
|
403
|
+
"id": "global::File"
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
"return": "Promise<void>"
|
|
407
|
+
},
|
|
408
|
+
"docs": {
|
|
409
|
+
"text": "",
|
|
410
|
+
"tags": []
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
"focusComposer": {
|
|
414
|
+
"complexType": {
|
|
415
|
+
"signature": "() => Promise<void>",
|
|
416
|
+
"parameters": [],
|
|
417
|
+
"references": {
|
|
418
|
+
"Promise": {
|
|
419
|
+
"location": "global",
|
|
420
|
+
"id": "global::Promise"
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
"return": "Promise<void>"
|
|
424
|
+
},
|
|
425
|
+
"docs": {
|
|
426
|
+
"text": "",
|
|
427
|
+
"tags": []
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
static get watchers() {
|
|
433
|
+
return [{
|
|
434
|
+
"propName": "chatStore",
|
|
435
|
+
"methodName": "onChatStoreChange"
|
|
436
|
+
}];
|
|
437
|
+
}
|
|
438
|
+
static get listeners() {
|
|
439
|
+
return [{
|
|
440
|
+
"name": "messageInputSent",
|
|
441
|
+
"method": "handleSendMessage",
|
|
442
|
+
"target": undefined,
|
|
443
|
+
"capture": false,
|
|
444
|
+
"passive": false
|
|
445
|
+
}, {
|
|
446
|
+
"name": "messageSend",
|
|
447
|
+
"method": "messageSendHandler",
|
|
448
|
+
"target": undefined,
|
|
449
|
+
"capture": false,
|
|
450
|
+
"passive": false
|
|
451
|
+
}, {
|
|
452
|
+
"name": "roomClicked",
|
|
453
|
+
"method": "handleRoomClicked",
|
|
454
|
+
"target": undefined,
|
|
455
|
+
"capture": false,
|
|
456
|
+
"passive": false
|
|
457
|
+
}];
|
|
458
|
+
}
|
|
459
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
/* Component-specific variables */
|
|
3
|
+
--header-padding: 16px;
|
|
4
|
+
--header-gap: 16px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.chat-header {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
gap: var(--header-gap);
|
|
11
|
+
padding: var(--header-padding);
|
|
12
|
+
/*border-bottom: 1px solid var(--border-color);*/
|
|
13
|
+
background: var(--bg-primary);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.header-name {
|
|
17
|
+
font-family: var(--font-primary);
|
|
18
|
+
font-weight: 700;
|
|
19
|
+
font-size: 16px;
|
|
20
|
+
line-height: 1.6;
|
|
21
|
+
color: var(--text-primary);
|
|
22
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
/**
|
|
3
|
+
* @component ChatleoChatHeader
|
|
4
|
+
* @description This component displays the header for a chat window. It includes the user's avatar, name, and online status. It is a simple presentational component that receives all its data via props.
|
|
5
|
+
* @property {string} name - The name of the user to be displayed in the header.
|
|
6
|
+
* @property {string} avatar - The URL of the user's avatar image. This is passed to the `chatleo-avatar` component.
|
|
7
|
+
* @property {boolean} isOnline - A boolean indicating the user's online status, which is also passed to the `chatleo-avatar` component to show a status indicator.
|
|
8
|
+
*/
|
|
9
|
+
export class ChatleoChatHeader {
|
|
10
|
+
/**
|
|
11
|
+
* The name of the user to be displayed in the header.
|
|
12
|
+
*/
|
|
13
|
+
name = "";
|
|
14
|
+
/**
|
|
15
|
+
* The URL of the user's avatar image. This is passed to the `chatleo-avatar` component.
|
|
16
|
+
*/
|
|
17
|
+
avatar;
|
|
18
|
+
/**
|
|
19
|
+
* A boolean indicating the user's online status, which is also passed to the `chatleo-avatar` component to show a status indicator.
|
|
20
|
+
*/
|
|
21
|
+
isOnline = false;
|
|
22
|
+
/**
|
|
23
|
+
* @function render
|
|
24
|
+
* @description The render method for the `ChatleoChatHeader` component. It renders the user's avatar and name within a container.
|
|
25
|
+
* @returns {any} A VNode representing the component's UI.
|
|
26
|
+
*/
|
|
27
|
+
render() {
|
|
28
|
+
return (h("div", { key: 'ff841f251f2e9a0065ac166e09e08fa5e0d9dd33', class: "chat-header" }, h("chatleo-avatar", { key: '9f3a6ee1fdae519dec06bc28c345440e410f8571', name: this.name, url: this.avatar, isOnline: this.isOnline }), h("div", { key: 'ab55b0c38ed957115a34fe5dda24e5f0fa888514', class: "header-name" }, this.name)));
|
|
29
|
+
}
|
|
30
|
+
static get is() { return "chatleo-chat-header"; }
|
|
31
|
+
static get encapsulation() { return "shadow"; }
|
|
32
|
+
static get originalStyleUrls() {
|
|
33
|
+
return {
|
|
34
|
+
"$": ["chatleo-chat-header.css"]
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
static get styleUrls() {
|
|
38
|
+
return {
|
|
39
|
+
"$": ["chatleo-chat-header.css"]
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
static get properties() {
|
|
43
|
+
return {
|
|
44
|
+
"name": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"mutable": false,
|
|
47
|
+
"complexType": {
|
|
48
|
+
"original": "string",
|
|
49
|
+
"resolved": "string",
|
|
50
|
+
"references": {}
|
|
51
|
+
},
|
|
52
|
+
"required": false,
|
|
53
|
+
"optional": false,
|
|
54
|
+
"docs": {
|
|
55
|
+
"tags": [],
|
|
56
|
+
"text": "The name of the user to be displayed in the header."
|
|
57
|
+
},
|
|
58
|
+
"getter": false,
|
|
59
|
+
"setter": false,
|
|
60
|
+
"reflect": false,
|
|
61
|
+
"attribute": "name",
|
|
62
|
+
"defaultValue": "\"\""
|
|
63
|
+
},
|
|
64
|
+
"avatar": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"mutable": false,
|
|
67
|
+
"complexType": {
|
|
68
|
+
"original": "string",
|
|
69
|
+
"resolved": "string",
|
|
70
|
+
"references": {}
|
|
71
|
+
},
|
|
72
|
+
"required": false,
|
|
73
|
+
"optional": false,
|
|
74
|
+
"docs": {
|
|
75
|
+
"tags": [],
|
|
76
|
+
"text": "The URL of the user's avatar image. This is passed to the `chatleo-avatar` component."
|
|
77
|
+
},
|
|
78
|
+
"getter": false,
|
|
79
|
+
"setter": false,
|
|
80
|
+
"reflect": false,
|
|
81
|
+
"attribute": "avatar"
|
|
82
|
+
},
|
|
83
|
+
"isOnline": {
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"mutable": false,
|
|
86
|
+
"complexType": {
|
|
87
|
+
"original": "boolean",
|
|
88
|
+
"resolved": "boolean",
|
|
89
|
+
"references": {}
|
|
90
|
+
},
|
|
91
|
+
"required": false,
|
|
92
|
+
"optional": false,
|
|
93
|
+
"docs": {
|
|
94
|
+
"tags": [],
|
|
95
|
+
"text": "A boolean indicating the user's online status, which is also passed to the `chatleo-avatar` component to show a status indicator."
|
|
96
|
+
},
|
|
97
|
+
"getter": false,
|
|
98
|
+
"setter": false,
|
|
99
|
+
"reflect": false,
|
|
100
|
+
"attribute": "is-online",
|
|
101
|
+
"defaultValue": "false"
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
/* Component-specific variables */
|
|
3
|
+
--input-radius: 100px;
|
|
4
|
+
--button-radius: 4px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.chat-input-container {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
gap: 16px;
|
|
11
|
+
padding: 16px;
|
|
12
|
+
border-top: 1px solid var(--border-color);
|
|
13
|
+
background: var(--bg-primary);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.input-wrapper {
|
|
17
|
+
flex: 1;
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: 8px;
|
|
21
|
+
background: var(--bg-secondary);
|
|
22
|
+
border-radius: var(--input-radius);
|
|
23
|
+
padding: 8px 16px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.chat-input {
|
|
27
|
+
flex: 1;
|
|
28
|
+
border: none;
|
|
29
|
+
outline: none;
|
|
30
|
+
background: transparent;
|
|
31
|
+
font-family: var(--font-primary);
|
|
32
|
+
font-weight: 400;
|
|
33
|
+
font-size: 14px;
|
|
34
|
+
line-height: 1.6;
|
|
35
|
+
color: var(--text-primary);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.chat-input::placeholder {
|
|
39
|
+
color: var(--text-secondary);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.emoji-button {
|
|
43
|
+
border: none;
|
|
44
|
+
background: transparent;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
font-size: 16px;
|
|
47
|
+
padding: 0;
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.action-buttons {
|
|
54
|
+
display: flex;
|
|
55
|
+
gap: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.action-button {
|
|
59
|
+
width: 32px;
|
|
60
|
+
height: 32px;
|
|
61
|
+
border: none;
|
|
62
|
+
background: transparent;
|
|
63
|
+
border-radius: var(--button-radius);
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
font-size: 14px;
|
|
69
|
+
/*color: var(--accent-color);*/
|
|
70
|
+
transition: background-color var(--transition-duration) ease;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.action-button:hover {
|
|
74
|
+
background: var(--bg-secondary);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/*.action-button:first-child {*/
|
|
78
|
+
/* background: var(--accent-color);*/
|
|
79
|
+
/* color: var(--bg-primary);*/
|
|
80
|
+
/*}*/
|
|
81
|
+
|
|
82
|
+
/*.action-button:first-child:hover {*/
|
|
83
|
+
/* background: var(--accent-hover);*/
|
|
84
|
+
/*}*/
|