@talkjs/react-components 0.0.18 → 0.0.20

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,3 +1,3 @@
1
1
  "use client";
2
- import{createContext as n,useContext as e}from"react";import{tracking as r}from"@legendapp/state";class o extends Error{}function i(n,e){if(!n)throw new o(e??"Assertion failed")}const t=Object.assign(i,{is:function(n,e,r){return i(e,r)},unreachable:function(){throw new Error("Unreachable code")},keyNonNullable:function(n,e){if(!(e in n))throw new o(`Missing key "${e}"`);const r=n[e];if(null==r)throw new o(`Key "${e}" is null or undefined`)},insideObservingContext:function(){if(!r.current)throw new Error("You aren't inside an observing context")},never:function(n){throw new Error("Unreachable")},defined:function(n){if(null==n)throw new o("Value is not defined")}}),c=n(void 0),s=h(c),u=n(void 0),f=h(u),d=n(void 0),a=h(d),l=n(void 0),w=n(l);function h(n){return()=>{const r=e(n);return t(void 0!==r),r}}export{u as EditorInternalsContext,l as PermissionContext,d as StoreContext,c as ThemeContext,f as useEditorInternals,w as usePermission,a as useStore,s as useTheme};
2
+ import{createContext as n,useContext as e}from"react";import{tracking as r}from"@legendapp/state";class o extends Error{}function t(n,e){if(!n)throw new o(e??"Assertion failed")}const i=Object.assign(t,{is:function(n,e,r){return t(e,r)},unreachable:function(){throw new Error("Unreachable code")},keyNonNullable:function(n,e){if(!(e in n))throw new o(`Missing key "${e}"`);const r=n[e];if(null==r)throw new o(`Key "${e}" is null or undefined`)},insideObservingContext:function(){if(!r.current)throw new Error("You aren't inside an observing context")},never:function(n){throw new Error("Unreachable")},defined:function(n){if(null==n)throw new o("Value is not defined")}}),[c,s]=x(),[u,f]=x(),[a,l]=x(),[d,w]=x(),[h,b]=x(),[g,p]=x(),[v,m]=x();function x(){const r=n(void 0);return[r,()=>{const n=e(r);return i(void 0!==n),n}]}export{v as ChatboxCallbacksContext,h as ChatboxControllerContext,u as EditorInternalsContext,d as PermissionContext,g as SessionContext,a as StoreContext,c as ThemeContext,m as useChatboxCallbacks,b as useChatboxController,f as useEditorInternals,w as usePermission,p as useSession,l as useStore,s as useTheme};
3
3
  //# sourceMappingURL=globalConstants.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talkjs/react-components",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "bugs": {
5
5
  "url": "https://talkjs.com/?chat"
6
6
  },
@@ -24,9 +24,11 @@
24
24
  "dependencies": {
25
25
  "@floating-ui/dom": "^1.6.5",
26
26
  "@legendapp/state": "3.0.0-alpha.9",
27
+ "@popperjs/core": "^2.11.8",
27
28
  "@radix-ui/react-dropdown-menu": "^2.1.15",
28
29
  "@talkjs/core": "^1.4.2",
29
30
  "autolinker": "^4.0.0",
31
+ "country-flag-emoji-polyfill": "^0.1.8",
30
32
  "emoji-picker-element": "1.8.2",
31
33
  "htm": "^3.1.1",
32
34
  "lodash.merge": "^4.6.2",
@@ -40,6 +42,8 @@
40
42
  "prosemirror-view": "^1.33.7",
41
43
  "react-error-boundary": "^5.0.0",
42
44
  "react-is": "^19.0.0",
45
+ "react-popper": "^2.3.0",
46
+ "react-transition-group": "4.4.2",
43
47
  "universal-base64": "^2.1.0",
44
48
  "wavesurfer.js": "^7.7.7"
45
49
  },
package/theming.d.ts CHANGED
@@ -13,6 +13,7 @@ import { ReactElement } from 'react';
13
13
  import { ReferencedMessageSnapshot } from '@talkjs/core';
14
14
  import { SendMessageParams } from '@talkjs/core';
15
15
  import { SendTextMessageParams } from '@talkjs/core';
16
+ import { TalkSession } from '@talkjs/core';
16
17
  import { TextBlock } from '@talkjs/core';
17
18
  import { TypingSnapshot } from '@talkjs/core';
18
19
  import { UserSnapshot } from '@talkjs/core';
@@ -56,6 +57,14 @@ export declare interface AudioPlayerProps {
56
57
  className?: string;
57
58
  }
58
59
 
60
+ export declare interface AvatarProps extends BaseChatboxProps {
61
+ photoUrl: string;
62
+ }
63
+
64
+ export declare interface BaseChatboxProps {
65
+ common: CommonChatboxProps;
66
+ }
67
+
59
68
  /**
60
69
  * Brands a base type `T`.
61
70
  *
@@ -75,63 +84,6 @@ declare interface Branding<B extends string> {
75
84
  __tag: Record<B, true>;
76
85
  }
77
86
 
78
- /**
79
- * @public
80
- *
81
- * A string that is one of `"notifications" | "microphone" | "geolocation"`.
82
- *
83
- * @remarks
84
- * Note that more possible values may be added in the future, so make sure your
85
- * handler can deal with unknown permission types gracefully.
86
- */
87
- export declare type BrowserPermission = "notifications" | "microphone" | "geolocation";
88
-
89
- /**
90
- * Passed to `chatbox.beforeBrowserPermissionPrompt` when a browser permission
91
- * dialog needs to be shown to the user.
92
- *
93
- * @public
94
- */
95
- export declare interface BrowserPermissionRequest {
96
- /**
97
- * The type of permission requested.
98
- *
99
- * @remarks
100
- * Note that more possible values may be added in the future, so make sure your
101
- * handler can deal with unknown permission types gracefully.
102
- */
103
- type: BrowserPermission;
104
- /**
105
- * Cancel whatever user action caused the permission to be requested.
106
- *
107
- * @remarks
108
- * For example, if a user wants to share their location for the first time so
109
- * that this event is triggered, then if you call `cancel()`, no permission
110
- * will be requested from the browser, the location sharing will be cancelled,
111
- * and TalkJS will continue as if the location sharing button had not been
112
- * clicked at all.
113
- *
114
- * This may be useful if you're using this event to show custom UI elements
115
- * that nudge users towards granting permission, and this UI has a "cancel"
116
- * button.
117
- */
118
- cancel(): void;
119
- /**
120
- * Show the browser permission prompt that lets the user allow or deny this
121
- * permission.
122
- *
123
- * @remarks
124
- * When the user clicks "Allow", then the user action that triggered the
125
- * browser permission request will proceed and the return value resolves to
126
- * `"granted"`.
127
- *
128
- * When the user clicks "Deny", then the user action is cancelled, the
129
- * `onMissingBrowserPermission` event is triggered, and the return value
130
- * resolves to `"denied"`.
131
- */
132
- showPrompt(): Promise<"granted" | "denied">;
133
- }
134
-
135
87
  export declare interface Chatbox {
136
88
  deleteMessage(messageId: string): Promise<void>;
137
89
  setEditing(messageId: string | null): void;
@@ -150,25 +102,31 @@ export declare interface Chatbox {
150
102
  setMessageFieldText: (text: string) => void;
151
103
  }
152
104
 
153
- export declare interface ChatHeaderProps {
154
- conversation: ConversationSnapshot;
155
- participants: ParticipantSnapshot[];
156
- currentUser: UserSnapshot;
157
- t: Translation;
158
- chatbox: Chatbox;
159
- themeCustom?: any;
105
+ export declare interface ChatHeaderProps extends BaseChatboxProps {
160
106
  isUserConnected: {
161
107
  [userId: string]: boolean;
162
108
  };
163
109
  permissions: UserPermissions;
164
- device: DeviceFeatures;
165
110
  }
166
111
 
167
- export declare interface ContentBlockProps {
168
- message: MessageSnapshot;
112
+ export declare interface CommonChatboxProps {
113
+ app: AppMetadata;
169
114
  currentUser: UserSnapshot;
170
115
  t: Translation;
116
+ chatbox: Chatbox;
171
117
  themeCustom?: any;
118
+ device: DeviceFeatures;
119
+ theme: Theme;
120
+ conversation: ConversationSnapshot;
121
+ participants: ParticipantSnapshot[];
122
+ typing: TypingSnapshot;
123
+ }
124
+
125
+ export declare interface ContentBlockProps extends BaseChatboxProps {
126
+ message: MessageSnapshot;
127
+ }
128
+
129
+ export declare interface ConversationImageProps extends BaseChatboxProps {
172
130
  }
173
131
 
174
132
  export { ConversationSnapshot }
@@ -178,11 +136,7 @@ export declare interface Coordinates {
178
136
  longitude: number;
179
137
  }
180
138
 
181
- export declare interface DeleteMessageEvent {
182
- currentUser: UserSnapshot;
183
- message: MessageSnapshot;
184
- conversation: ConversationSnapshot;
185
- }
139
+ export declare function daysBetween(from: number, to: number): number;
186
140
 
187
141
  export declare interface DeviceFeatures {
188
142
  /**
@@ -197,7 +151,12 @@ export declare interface DeviceFeatures {
197
151
 
198
152
  export declare function Editor({ placeholder, disabled, className, characterLimit, spellcheck, }: EditorProps): JSX.Element;
199
153
 
200
- export declare interface EditorController extends EditorState {
154
+ export declare interface EditorController {
155
+ isTyping: boolean;
156
+ atTextLimit: boolean;
157
+ isEmpty: boolean;
158
+ characterCount: number;
159
+ showEmojiPicker: boolean;
201
160
  send(): void;
202
161
  shareLocation(): void;
203
162
  attachFile(): void;
@@ -212,20 +171,23 @@ export declare interface EditorProps {
212
171
  spellcheck?: boolean;
213
172
  }
214
173
 
215
- declare interface EditorState {
216
- isTyping: boolean;
217
- atTextLimit: boolean;
218
- isEmpty: boolean;
219
- characterCount: number;
220
- showEmojiPicker: boolean;
221
- }
222
-
223
174
  export declare function EmojiPicker(props: EmojiPickerProps): JSX.Element;
224
175
 
225
- declare interface EmojiPickerProps {
176
+ export declare interface EmojiPickerProps {
226
177
  colorScheme: "light" | "dark";
227
178
  }
228
179
 
180
+ /**
181
+ * Shows a bar with emoji suggestions when the user types eg `:bla`. Shown if `query` is non-empty.
182
+ *
183
+ * Uses the IndexedDB-backed emoji database from "emoji-picker-element".
184
+ */
185
+ export declare function EmojiSuggestBar({ className }: EmojiSuggestBarProps): JSX.Element;
186
+
187
+ export declare interface EmojiSuggestBarProps {
188
+ className?: string;
189
+ }
190
+
229
191
  export { FileBlock }
230
192
 
231
193
  export declare interface FileBlockProps extends ContentBlockProps {
@@ -248,17 +210,14 @@ export declare function getPhotoUrlWithFallback(user: UserSnapshot): string;
248
210
 
249
211
  export declare function getRandomColor(id: string): string;
250
212
 
251
- export declare function html(strings: TemplateStringsArray, ...args: any[]): ReactElement;
213
+ export declare interface GroupChatImageProps extends BaseChatboxProps {
214
+ }
252
215
 
253
- /**
254
- * Finds the best-matching translation set for the given locale `code`.
255
- */
256
- export declare function i18n(code: string): Translation;
216
+ export declare function html(strings: TemplateStringsArray, ...args: any[]): ReactElement;
257
217
 
258
- export declare interface IconProps {
218
+ export declare interface IconProps extends BaseChatboxProps {
259
219
  type: "attach" | "chevronLeft" | "left" | "chevronRight" | "right" | "chevronUp" | "up" | "chevronDown" | "down" | "close" | "emoji" | "locationPin" | "more" | "plus" | "search" | "send" | "spinner" | "play" | "pause" | "updown" | "addEmoji" | "microphone" | "mic" | "stop" | "download" | "location" | "email" | "movie" | "image" | "attachment" | "horizontalDots" | "verticalDots" | "reply" | "back";
260
220
  className?: string;
261
- themeCustom?: any;
262
221
  }
263
222
 
264
223
  export { ImageBlock }
@@ -274,6 +233,16 @@ export declare interface LocationBlockProps extends ContentBlockProps {
274
233
  block: LocationBlock;
275
234
  }
276
235
 
236
+ export declare function MentionSuggestList(props: MentionSuggestListProps): JSX.Element | null;
237
+
238
+ export declare interface MentionSuggestList {
239
+ keydown(key: string): boolean;
240
+ }
241
+
242
+ export declare interface MentionSuggestListProps {
243
+ className?: string;
244
+ }
245
+
277
246
  /**
278
247
  * MenuButton component that renders a dropdown menu triggered by a button.
279
248
  *
@@ -312,50 +281,31 @@ export declare type MenuItemProps = React.HTMLAttributes<HTMLDivElement> & {
312
281
  textValue?: string;
313
282
  };
314
283
 
284
+ export declare interface MessageActionMenuProps extends BaseChatboxProps {
285
+ }
286
+
315
287
  export declare function MessageContent(props: MessageContentProps): JSX.Element;
316
288
 
317
- export declare interface MessageContentProps {
318
- currentUser: UserSnapshot;
289
+ export declare interface MessageContentProps extends BaseChatboxProps {
319
290
  message: MessageSnapshot;
320
- t: Translation;
321
291
  messageStatus: MessageStatus;
322
- themeCustom?: any;
323
292
  className?: string;
324
293
  }
325
294
 
326
- export declare interface MessageDividerProps {
295
+ export declare interface MessageDividerProps extends BaseChatboxProps {
327
296
  isReadMarker: boolean;
328
297
  isDayMarker: boolean;
329
298
  timestamp?: number;
330
- currentUser: UserSnapshot;
331
- conversation: ConversationSnapshot;
332
- app: AppMetadata;
333
- t: Translation;
334
- themeCustom?: any;
335
299
  }
336
300
 
337
- export declare interface MessageFieldProps {
338
- conversation: ConversationSnapshot;
339
- participants: ParticipantSnapshot[];
301
+ export declare interface MessageFieldProps extends BaseChatboxProps {
340
302
  referencedMessage: MessageSnapshot | undefined;
341
- currentUser: UserSnapshot;
342
303
  permissions: UserPermissions;
343
- t: Translation;
344
- chatbox: Chatbox;
345
304
  editor?: EditorController;
346
- themeCustom?: any;
347
- device: DeviceFeatures;
348
305
  editMessageId: string | undefined;
349
306
  }
350
307
 
351
- export declare interface MessageListFooterProps {
352
- typing: TypingSnapshot;
353
- conversation: ConversationSnapshot;
354
- participants: ParticipantSnapshot[];
355
- currentUser: UserSnapshot;
356
- t: Translation;
357
- chatbox: Chatbox;
358
- themeCustom?: any;
308
+ export declare interface MessageListFooterProps extends BaseChatboxProps {
359
309
  }
360
310
 
361
311
  export declare interface MessagePermissions extends UserPermissions {
@@ -364,65 +314,30 @@ export declare interface MessagePermissions extends UserPermissions {
364
314
  canEditMessage: boolean;
365
315
  }
366
316
 
367
- export declare interface MessageProps {
368
- app: AppMetadata;
369
- currentUser: UserSnapshot;
317
+ export declare interface MessageProps extends BaseChatboxProps {
370
318
  message: MessageSnapshot;
371
319
  messageStatus: MessageStatus;
372
- conversation: ConversationSnapshot;
373
- participants: ParticipantSnapshot[];
374
320
  permissions: MessagePermissions;
375
- t: Translation;
376
- chatbox: Chatbox;
377
- themeCustom?: any;
378
- device: DeviceFeatures;
379
321
  }
380
322
 
381
323
  export { MessageSnapshot }
382
324
 
383
325
  export declare type MessageStatus = "sending" | "sent" | "everyoneRead";
384
326
 
385
- /**
386
- * Sent by `onMissingBrowserPermission` when the user tried to do an action that
387
- * require explicit browser permission, but that permission has been denied.
388
- *
389
- * @remarks
390
- * This event is meant to let you show a message to the user if an action (eg
391
- * sharing a location, or enabling notifications) can't proceed because the
392
- * browser permission for that has been denied.
393
- *
394
- * If you want to control when to show the browser permissions prompt, use
395
- * `beforeBrowserPermissionPrompt`.
396
- *
397
- * This event is emitted both when the user has denied this permission in the
398
- * past, and when a user action just triggered a browser permissions prompt
399
- * which the user then denied. If you need to differentiate between these two
400
- * cases, use `beforeBrowserPermissionPrompt`, and inspect the return value of
401
- * {@link BrowserPermissionRequest.showPrompt}.
402
- *
403
- * @public
404
- */
405
- export declare interface MissingBrowserPermissionEvent {
406
- /**
407
- * The type of permission that was denied.
408
- *
409
- * @remarks
410
- * Note that more possible values may be added in the future, so make sure your
411
- * handler can deal with unknown permission types gracefully.
412
- */
413
- type: BrowserPermission;
414
- }
415
-
416
327
  export { ParticipantSnapshot }
417
328
 
329
+ export declare interface ReferencedMessageProps extends BaseChatboxProps {
330
+ referencedMessage: ReferencedMessageSnapshot;
331
+ }
332
+
418
333
  export { ReferencedMessageSnapshot }
419
334
 
420
- export declare interface SendMessageEvent {
421
- currentUser: UserSnapshot;
422
- message: MessageSnapshot;
423
- conversation: ConversationSnapshot;
335
+ export declare interface ReplyBarProps extends BaseChatboxProps {
336
+ referencedMessage: MessageSnapshot;
424
337
  }
425
338
 
339
+ export { TalkSession }
340
+
426
341
  declare function Text_2({ block, className }: TextProps): ReactElement;
427
342
  export { Text_2 as Text }
428
343
 
@@ -438,6 +353,13 @@ export declare interface TextProps {
438
353
  }
439
354
 
440
355
  export declare interface Theme {
356
+ Avatar: React_2.ComponentType<AvatarProps>;
357
+ ConversationImage: React_2.ComponentType<ConversationImageProps>;
358
+ GroupChatImage: React_2.ComponentType<GroupChatImageProps>;
359
+ ReferencedMessage: React_2.ComponentType<ReferencedMessageProps>;
360
+ ReplyBar: React_2.ComponentType<ReplyBarProps>;
361
+ TimeAgo: React_2.ComponentType<TimeAgoProps>;
362
+ MessageActionMenu: React_2.ComponentType<MessageActionMenuProps>;
441
363
  ChatHeader: React_2.ComponentType<ChatHeaderProps>;
442
364
  Message: React_2.ComponentType<MessageProps>;
443
365
  MessageField: React_2.ComponentType<MessageFieldProps>;
@@ -463,6 +385,10 @@ export declare interface TimeAgo {
463
385
  short: string;
464
386
  }
465
387
 
388
+ export declare interface TimeAgoProps extends BaseChatboxProps {
389
+ timestamp: number;
390
+ }
391
+
466
392
  export declare type Translation = TranslationData & TranslationStrings;
467
393
 
468
394
  declare interface TranslationData {
@@ -608,7 +534,7 @@ declare global {
608
534
  declare global {
609
535
  namespace JSX {
610
536
  interface IntrinsicElements {
611
- "t-chatbox": typeof Chatbox;
537
+ "t-chatbox": typeof UnthemedChatbox;
612
538
  }
613
539
  }
614
540
  }