@talkjs/react-components 0.0.29 → 0.0.30

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.
@@ -1,60 +1,52 @@
1
1
  "use client";
2
- import { createContext as n, useContext as o } from "react";
2
+ import { createContext as r, useContext as i } from "react";
3
3
  import { Schema as l } from "prosemirror-model";
4
- class i extends Error {
4
+ class o extends Error {
5
5
  }
6
- function r(t, e) {
7
- if (!t) throw new i(e != null ? e : "Assertion failed");
6
+ function n(t, e) {
7
+ if (!t) throw new o(e != null ? e : "Assertion failed");
8
8
  }
9
- const s = Object.assign(r, { is: function(t, e, c) {
10
- return r(e, c);
9
+ const c = Object.assign(n, { is: function(t, e, s) {
10
+ return n(e, s);
11
11
  }, unreachable: function() {
12
12
  throw new Error("Unreachable code");
13
13
  }, never: function(t) {
14
14
  throw new Error("Unreachable");
15
15
  }, defined: function(t) {
16
- if (t == null) throw new i("Value is not defined");
17
- } }), [g, x] = a(), [h, O] = a(), [C, D] = a(), [M, f] = a(), [j, b] = a(), m = n(void 0);
18
- function v() {
19
- const t = o(m);
20
- return s(t !== void 0), t;
21
- }
22
- const u = n(void 0);
23
- function w() {
24
- const t = o(u);
25
- return s(t !== void 0), t;
26
- }
27
- const [E, k] = a(), [P, A] = a();
16
+ if (t == null) throw new o("Value is not defined");
17
+ } }), [d, p] = a(), [g, x] = a(), [C, h] = a(), [O, D] = a(), [M, j] = a(), [b, f] = a(), [w, E] = a(), [P, k] = a(), [v, A] = a(), [S, I] = a();
28
18
  function a() {
29
- const t = n(void 0);
19
+ const t = r(void 0);
30
20
  return [t, () => {
31
- const e = o(t);
32
- return s(e !== void 0), e;
21
+ const e = i(t);
22
+ return c(e !== void 0), e;
33
23
  }];
34
24
  }
35
- const S = new l({ nodes: { doc: { content: "paragraph+" }, paragraph: { code: !0, content: "inline*", parseDOM: [{ tag: "p" }], toDOM: () => ["p", 0] }, text: { group: "inline" }, mention: { group: "inline", inline: !0, attrs: { id: {}, name: {} }, content: "text*", toDOM: (t) => ["span", { "data-mention-id": t.attrs.id, class: "t-mention" }, `@${t.attrs.name}`], parseDOM: [{ tag: "span[data-mention-id]", getAttrs: (t) => ({ id: t.dataset["mention-id"] }) }] }, customemoji: { group: "inline", inline: !0, attrs: { name: {}, url: {} }, content: "text*", selectable: !1, toDOM: (t) => ["img", { src: t.attrs.url, alt: t.attrs.name, "data-custom-emoji": t.attrs.name }], parseDOM: [{ tag: "img[data-custom-emoji]", getAttrs: (t) => {
25
+ const T = new l({ nodes: { doc: { content: "paragraph+" }, paragraph: { code: !0, content: "inline*", parseDOM: [{ tag: "p" }], toDOM: () => ["p", 0] }, text: { group: "inline" }, mention: { group: "inline", inline: !0, attrs: { id: {}, name: {} }, content: "text*", toDOM: (t) => ["span", { "data-mention-id": t.attrs.id, class: "t-mention" }, `@${t.attrs.name}`], parseDOM: [{ tag: "span[data-mention-id]", getAttrs: (t) => ({ id: t.dataset["mention-id"] }) }] }, customemoji: { group: "inline", inline: !0, attrs: { name: {}, url: {} }, content: "text*", selectable: !1, toDOM: (t) => ["img", { src: t.attrs.url, alt: t.attrs.name, "data-custom-emoji": t.attrs.name }], parseDOM: [{ tag: "img[data-custom-emoji]", getAttrs: (t) => {
36
26
  const e = t;
37
27
  return { name: e.dataset.customEmoji, url: e.src };
38
28
  } }] } }, marks: { literal: { toDOM: () => ["span", { "data-literal": "" }], parseDOM: [{ tag: "span[data-literal]" }] }, bold: { toDOM: () => ["b"], parseDOM: [{ tag: "b" }] }, italic: { toDOM: () => ["i"], parseDOM: [{ tag: "i" }] }, strikethrough: { toDOM: () => ["del"], parseDOM: [{ tag: "del" }] }, emoji: { attrs: { emoji: {} }, toDOM: (t) => ["span", { "data-emoji": t.attrs.emoji }, t.attrs.emoji], parseDOM: [{ tag: "span[data-emoji]", getAttrs: (t) => ({ emoji: t.dataset.emoji }) }] } } });
39
29
  export {
40
- j as ChatboxCallbacksContext,
41
- u as ControllerContext,
42
- h as EditorInternalsContext,
43
- E as EmojiPickerContext,
30
+ M as ChatboxCallbacksContext,
31
+ w as ControllerContext,
32
+ g as EditorInternalsContext,
33
+ v as EmojiPickerContext,
44
34
  C as PermissionContext,
45
- P as PopoverContext,
46
- M as SessionContext,
47
- m as StoreContext,
48
- g as ThemeContext,
49
- S as schema,
50
- b as useChatboxCallbacks,
51
- w as useController,
52
- O as useEditorInternals,
53
- k as useEmojiPicker,
54
- D as usePermission,
55
- A as usePopover,
56
- f as useSession,
57
- v as useStore,
58
- x as useTheme
35
+ S as PopoverContext,
36
+ P as PublicControllerContext,
37
+ O as SessionContext,
38
+ b as StoreContext,
39
+ d as ThemeContext,
40
+ T as schema,
41
+ j as useChatboxCallbacks,
42
+ E as useController,
43
+ x as useEditorInternals,
44
+ A as useEmojiPicker,
45
+ h as usePermission,
46
+ I as usePopover,
47
+ k as usePublicController,
48
+ D as useSession,
49
+ f as useStore,
50
+ p as useTheme
59
51
  };
60
52
  //# sourceMappingURL=globalConstants.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talkjs/react-components",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "bugs": {
5
5
  "url": "https://talkjs.com/?chat"
6
6
  },
package/theming.d.ts CHANGED
@@ -146,7 +146,8 @@ export declare interface AvatarProps {
146
146
  *
147
147
  * @public
148
148
  */
149
- export declare interface Chatbox {
149
+ export declare class ChatboxController {
150
+ #private;
150
151
  /**
151
152
  * Deletes the message with the given ID.
152
153
  *
@@ -193,9 +194,35 @@ export declare interface Chatbox {
193
194
  /**
194
195
  * Set/unset the message that's currently being replied to.
195
196
  *
196
- * @param messageId When `null` is provided, the "replying to" message is cleared
197
+ * @param messageId - When `null` is provided, the "replying to" message is cleared
197
198
  */
198
199
  setReferencedMessage(messageId: string | null): void;
200
+ /**
201
+ * Toggle the given emoji reaction for the given message. If the current user
202
+ * already added this reaction, it's removed, and otherwise, it's added.
203
+ *
204
+ * Called from the theme's Message component when the user clicks on an
205
+ * existing emoji reaction.
206
+ *
207
+ * @param messageId - The ID of the message you want to toggle the reaction on. This message must exist in the current conversation.
208
+ * @param emoji - The emoji you want to toggle. Must be a string of a single unicode emoji glyph, eg `"🎉"`.
209
+ */
210
+ toggleReaction(messageId: string, emoji: string): Promise<void>;
211
+ /**
212
+ * Get the plaintext from the message field
213
+ *
214
+ * @returns The text
215
+ */
216
+ getMessageFieldText(): string;
217
+ /**
218
+ * Set the plaintext in the message field
219
+ * @param text
220
+ */
221
+ setMessageFieldText(text: string): void;
222
+ /**
223
+ * Focus the message field
224
+ */
225
+ focusMessageField(): void;
199
226
  }
200
227
 
201
228
  /**
@@ -238,9 +265,9 @@ export declare interface CommonChatboxProps {
238
265
  */
239
266
  t: Translation;
240
267
  /**
241
- * The chatbox instance itself.
268
+ * Public interface of the chatbox instance.
242
269
  */
243
- chatbox: Chatbox;
270
+ chatbox: ChatboxController;
244
271
  /**
245
272
  * Arbitrary custom data passed down to the theme.
246
273
  *
@@ -312,9 +339,9 @@ export declare interface CommonConversationListProps {
312
339
  */
313
340
  theme: Theme;
314
341
  /**
315
- * The conversation list instance itself.
342
+ * Public interface of the conversation list instance.
316
343
  */
317
- conversationList: ConversationList;
344
+ conversationList: ConversationListController;
318
345
  /**
319
346
  * The underlying TalkJS session object that handles sending and receiving chat data.
320
347
  */
@@ -368,15 +395,23 @@ export declare interface ConversationImageProps {
368
395
  *
369
396
  * @public
370
397
  */
371
- export declare interface ConversationList {
398
+ export declare class ConversationListController {
399
+ #private;
372
400
  /**
373
- * Programatically select a conversation.
374
- *
375
- * @param conversationId
401
+ * Select a conversation.
376
402
  *
377
403
  * @remarks
378
- * Note that this **will not** trigger the
379
- * {@linkcode ConversationListProps.onSelectConversation} callback.
404
+ * This method is called from the theme's ConversationListItem component when
405
+ * the user clicks on the given conversation. You can also call it
406
+ * programmatically from elsewhere to simulate a user click.
407
+ *
408
+ * This method will trigger the
409
+ * {@linkcode ConversationListProps.onSelectConversation} event. In most
410
+ * cases, if you want to change the selected conversation programmatically
411
+ * from outside the conversation list, it's better to pass a different value
412
+ * to the {@linkcode ConversationListProps.selectedConversationId} prop
413
+ * instead, as that lets you keep your local state in sync with the props
414
+ * passed to the conversation list.
380
415
  */
381
416
  selectConversation(conversationId: string): void;
382
417
  }
@@ -1309,8 +1344,8 @@ export { }
1309
1344
 
1310
1345
  declare global {
1311
1346
  interface HTMLElementTagNameMap {
1312
- "t-chatbox": ChatboxHTMLElement;
1313
- "t-conversation-list": ConversationListHTMLElement;
1347
+ "t-chatbox": ChatboxElement;
1348
+ "t-conversation-list": ConversationListElement;
1314
1349
  }
1315
1350
  }
1316
1351