@talkjs/react-components 0.0.19 → 0.0.21

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,54 @@
1
1
  "use client";
2
- import{createContext as n,useContext as e}from"react";import{tracking as o}from"@legendapp/state";class r extends Error{}function i(n,e){if(!n)throw new r(e??"Assertion failed")}const t=Object.assign(i,{is:function(n,e,o){return i(e,o)},unreachable:function(){throw new Error("Unreachable code")},keyNonNullable:function(n,e){if(!(e in n))throw new r(`Missing key "${e}"`);const o=n[e];if(null==o)throw new r(`Key "${e}" is null or undefined`)},insideObservingContext:function(){if(!o.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 r("Value is not defined")}}),c=n(void 0),s=p(c),u=n(void 0),d=p(u),f=n(void 0),a=p(f),l=n(void 0),w=n(l),h=n(void 0),v=p(h),b=n(void 0),g=p(b);function p(n){return()=>{const o=e(n);return t(void 0!==o),o}}export{h as ChatboxControllerContext,u as EditorInternalsContext,l as PermissionContext,b as SessionContext,f as StoreContext,c as ThemeContext,v as useChatboxController,d as useEditorInternals,w as usePermission,g as useSession,a as useStore,s as useTheme};
2
+ import { createContext as t, useContext as s } from "react";
3
+ class i extends Error {
4
+ }
5
+ function a(e, o) {
6
+ if (!e) throw new i(o ?? "Assertion failed");
7
+ }
8
+ const r = Object.assign(a, { is: function(e, o, c) {
9
+ return a(o, c);
10
+ }, unreachable: function() {
11
+ throw new Error("Unreachable code");
12
+ }, never: function(e) {
13
+ throw new Error("Unreachable");
14
+ }, defined: function(e) {
15
+ if (e == null) throw new i("Value is not defined");
16
+ } }), [d, x] = n(), [f, h] = n(), [v, b] = n(), [m, w] = n(), [E, P] = n(), u = t(void 0);
17
+ function p() {
18
+ const e = s(u);
19
+ return r(e !== void 0), e;
20
+ }
21
+ const l = t(void 0);
22
+ function j() {
23
+ const e = s(l);
24
+ return r(e !== void 0), e;
25
+ }
26
+ const [k, S] = n(), [U, g] = n();
27
+ function n() {
28
+ const e = t(void 0);
29
+ return [e, () => {
30
+ const o = s(e);
31
+ return r(o !== void 0), o;
32
+ }];
33
+ }
34
+ export {
35
+ E as ChatboxCallbacksContext,
36
+ l as ControllerContext,
37
+ f as EditorInternalsContext,
38
+ k as EmojiPickerContext,
39
+ v as PermissionContext,
40
+ U as PopoverContext,
41
+ m as SessionContext,
42
+ u as StoreContext,
43
+ d as ThemeContext,
44
+ P as useChatboxCallbacks,
45
+ j as useController,
46
+ h as useEditorInternals,
47
+ S as useEmojiPicker,
48
+ b as usePermission,
49
+ g as usePopover,
50
+ w as useSession,
51
+ p as useStore,
52
+ x as useTheme
53
+ };
3
54
  //# sourceMappingURL=globalConstants.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talkjs/react-components",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "bugs": {
5
5
  "url": "https://talkjs.com/?chat"
6
6
  },
@@ -24,9 +24,12 @@
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
- "@talkjs/core": "^1.4.2",
29
+ "@radix-ui/react-popover": "^1.1.15",
30
+ "@talkjs/core": "^1.5.0",
29
31
  "autolinker": "^4.0.0",
32
+ "country-flag-emoji-polyfill": "^0.1.8",
30
33
  "emoji-picker-element": "1.8.2",
31
34
  "htm": "^3.1.1",
32
35
  "lodash.merge": "^4.6.2",
@@ -40,6 +43,8 @@
40
43
  "prosemirror-view": "^1.33.7",
41
44
  "react-error-boundary": "^5.0.0",
42
45
  "react-is": "^19.0.0",
46
+ "react-popper": "^2.3.0",
47
+ "react-transition-group": "4.4.2",
43
48
  "universal-base64": "^2.1.0",
44
49
  "wavesurfer.js": "^7.7.7"
45
50
  },
package/theming.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AudioBlock } from '@talkjs/core';
2
2
  import { ConversationSnapshot } from '@talkjs/core';
3
+ import { default as default_2 } from 'react';
3
4
  import { EditMessageParams } from '@talkjs/core';
4
5
  import { EditTextMessageParams } from '@talkjs/core';
5
6
  import { FileBlock } from '@talkjs/core';
@@ -57,14 +58,11 @@ export declare interface AudioPlayerProps {
57
58
  className?: string;
58
59
  }
59
60
 
60
- export declare interface AvatarProps extends BaseChatboxProps {
61
+ export declare interface AvatarProps {
62
+ common: CommonChatboxProps | CommonConversationListProps;
61
63
  photoUrl: string;
62
64
  }
63
65
 
64
- export declare interface BaseChatboxProps {
65
- common: CommonChatboxProps;
66
- }
67
-
68
66
  /**
69
67
  * Brands a base type `T`.
70
68
  *
@@ -102,7 +100,8 @@ export declare interface Chatbox {
102
100
  setMessageFieldText: (text: string) => void;
103
101
  }
104
102
 
105
- export declare interface ChatHeaderProps extends BaseChatboxProps {
103
+ export declare interface ChatHeaderProps {
104
+ common: CommonChatboxProps;
106
105
  isUserConnected: {
107
106
  [userId: string]: boolean;
108
107
  };
@@ -120,13 +119,45 @@ export declare interface CommonChatboxProps {
120
119
  conversation: ConversationSnapshot;
121
120
  participants: ParticipantSnapshot[];
122
121
  typing: TypingSnapshot;
122
+ session: TalkSession;
123
+ }
124
+
125
+ export declare interface CommonConversationListProps {
126
+ app: AppMetadata;
127
+ currentUser: UserSnapshot;
128
+ t: Translation;
129
+ themeCustom?: any;
130
+ device: DeviceFeatures;
131
+ theme: Theme;
132
+ conversationList: ConversationList;
133
+ session: TalkSession;
123
134
  }
124
135
 
125
- export declare interface ContentBlockProps extends BaseChatboxProps {
136
+ export declare interface CompactMessageContentProps {
137
+ common: CommonChatboxProps | CommonConversationListProps;
138
+ message: MessageSnapshot | ReferencedMessageSnapshot;
139
+ }
140
+
141
+ export declare interface ContentBlockProps {
142
+ common: CommonChatboxProps;
126
143
  message: MessageSnapshot;
127
144
  }
128
145
 
129
- export declare interface ConversationImageProps extends BaseChatboxProps {
146
+ export declare interface ConversationImageProps {
147
+ common: CommonChatboxProps | CommonConversationListProps;
148
+ conversation: ConversationSnapshot;
149
+ participants: ParticipantSnapshot[];
150
+ }
151
+
152
+ export declare interface ConversationList {
153
+ selectConversation(conversationId: string): void;
154
+ }
155
+
156
+ export declare interface ConversationListItemProps {
157
+ common: CommonConversationListProps;
158
+ conversation: ConversationSnapshot;
159
+ participants: ParticipantSnapshot[];
160
+ isSelected: boolean;
130
161
  }
131
162
 
132
163
  export { ConversationSnapshot }
@@ -136,6 +167,11 @@ export declare interface Coordinates {
136
167
  longitude: number;
137
168
  }
138
169
 
170
+ export declare interface Coordinates {
171
+ latitude: number;
172
+ longitude: number;
173
+ }
174
+
139
175
  export declare function daysBetween(from: number, to: number): number;
140
176
 
141
177
  export declare interface DeviceFeatures {
@@ -149,9 +185,25 @@ export declare interface DeviceFeatures {
149
185
  isMobile: boolean;
150
186
  }
151
187
 
188
+ export declare interface DeviceFeatures {
189
+ /**
190
+ * True if the browser supports IndexedDB, which the emoji picker depends on.
191
+ */
192
+ supportsEmojiPicker: boolean;
193
+ /**
194
+ * True if the user agents reports this device as mobile (incl tablets).
195
+ */
196
+ isMobile: boolean;
197
+ }
198
+
152
199
  export declare function Editor({ placeholder, disabled, className, characterLimit, spellcheck, }: EditorProps): JSX.Element;
153
200
 
154
- export declare interface EditorController extends EditorState {
201
+ export declare interface EditorController {
202
+ isTyping: boolean;
203
+ atTextLimit: boolean;
204
+ isEmpty: boolean;
205
+ characterCount: number;
206
+ showEmojiPicker: boolean;
155
207
  send(): void;
156
208
  shareLocation(): void;
157
209
  attachFile(): void;
@@ -166,20 +218,23 @@ export declare interface EditorProps {
166
218
  spellcheck?: boolean;
167
219
  }
168
220
 
169
- declare interface EditorState {
170
- isTyping: boolean;
171
- atTextLimit: boolean;
172
- isEmpty: boolean;
173
- characterCount: number;
174
- showEmojiPicker: boolean;
175
- }
176
-
177
221
  export declare function EmojiPicker(props: EmojiPickerProps): JSX.Element;
178
222
 
179
223
  export declare interface EmojiPickerProps {
180
224
  colorScheme: "light" | "dark";
181
225
  }
182
226
 
227
+ /**
228
+ * Shows a bar with emoji suggestions when the user types eg `:bla`. Shown if `query` is non-empty.
229
+ *
230
+ * Uses the IndexedDB-backed emoji database from "emoji-picker-element".
231
+ */
232
+ export declare function EmojiSuggestBar({ className }: EmojiSuggestBarProps): JSX.Element;
233
+
234
+ export declare interface EmojiSuggestBarProps {
235
+ className?: string;
236
+ }
237
+
183
238
  export { FileBlock }
184
239
 
185
240
  export declare interface FileBlockProps extends ContentBlockProps {
@@ -202,12 +257,15 @@ export declare function getPhotoUrlWithFallback(user: UserSnapshot): string;
202
257
 
203
258
  export declare function getRandomColor(id: string): string;
204
259
 
205
- export declare interface GroupChatImageProps extends BaseChatboxProps {
260
+ export declare interface GroupChatImageProps {
261
+ common: CommonChatboxProps | CommonConversationListProps;
262
+ participants: ParticipantSnapshot[];
206
263
  }
207
264
 
208
265
  export declare function html(strings: TemplateStringsArray, ...args: any[]): ReactElement;
209
266
 
210
- export declare interface IconProps extends BaseChatboxProps {
267
+ export declare interface IconProps {
268
+ common: CommonChatboxProps | CommonConversationListProps;
211
269
  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";
212
270
  className?: string;
213
271
  }
@@ -225,35 +283,15 @@ export declare interface LocationBlockProps extends ContentBlockProps {
225
283
  block: LocationBlock;
226
284
  }
227
285
 
228
- /**
229
- * MenuButton component that renders a dropdown menu triggered by a button.
230
- *
231
- * Usage:
232
- * <MenuButton
233
- * menuComponent={YourMenuComponent}
234
- * menuProps={{ prop1: value1, prop2: value2 }}
235
- * aria-label="Message actions"
236
- * >
237
- * <Icon type="horizontalDots" />
238
- * </MenuButton>
239
- *
240
- * All props except for menuComponent and menuProps are passed to the button element.
241
- *
242
- * The menuComponent should be a component that renders the dropdown content.
243
- * The menuProps are passed to the menuComponent.
244
- *
245
- * The menu component shouod render the MenuItem component for each menu item it wants to include.
246
- *
247
- * This is meant as a reuseable and accessible dropdown menu. We're using Radix for this, because they fulli implement
248
- * the ARIA Menu Button pattern, but without adding any styles, so we can completely customise the look and feel.
249
- */
250
- export declare function MenuButton<T extends object>(props: MenuButtonProps<T>): JSX.Element;
286
+ export declare function MentionSuggestList(props: MentionSuggestListProps): JSX.Element | null;
251
287
 
252
- export declare type MenuButtonProps<T extends object> = {
253
- menuComponent: React.ComponentType<T>;
254
- menuProps: T;
255
- children: React.ReactNode;
256
- } & React.HTMLAttributes<HTMLButtonElement>;
288
+ export declare interface MentionSuggestList {
289
+ keydown(key: string): boolean;
290
+ }
291
+
292
+ export declare interface MentionSuggestListProps {
293
+ className?: string;
294
+ }
257
295
 
258
296
  export declare function MenuItem(props: MenuItemProps): JSX.Element;
259
297
 
@@ -263,40 +301,55 @@ export declare type MenuItemProps = React.HTMLAttributes<HTMLDivElement> & {
263
301
  textValue?: string;
264
302
  };
265
303
 
266
- export declare interface MessageActionMenuProps extends BaseChatboxProps {
304
+ export declare interface MessageActionMenuProps {
305
+ common: CommonChatboxProps;
306
+ message: MessageSnapshot;
307
+ permissions: MessagePermissions;
267
308
  }
268
309
 
269
310
  export declare function MessageContent(props: MessageContentProps): JSX.Element;
270
311
 
271
- export declare interface MessageContentProps extends BaseChatboxProps {
312
+ export declare interface MessageContentProps {
313
+ common: CommonChatboxProps;
272
314
  message: MessageSnapshot;
273
315
  messageStatus: MessageStatus;
274
316
  className?: string;
275
317
  }
276
318
 
277
- export declare interface MessageDividerProps extends BaseChatboxProps {
319
+ export declare interface MessageDividerProps {
320
+ common: CommonChatboxProps;
278
321
  isReadMarker: boolean;
279
322
  isDayMarker: boolean;
280
323
  timestamp?: number;
281
324
  }
282
325
 
283
- export declare interface MessageFieldProps extends BaseChatboxProps {
326
+ export declare interface MessageFieldProps {
327
+ common: CommonChatboxProps;
284
328
  referencedMessage: MessageSnapshot | undefined;
285
329
  permissions: UserPermissions;
286
- editor?: EditorController;
330
+ editor: EditorController;
287
331
  editMessageId: string | undefined;
288
332
  }
289
333
 
290
- export declare interface MessageListFooterProps extends BaseChatboxProps {
334
+ export declare interface MessageListFooterProps {
335
+ common: CommonChatboxProps;
291
336
  }
292
337
 
293
338
  export declare interface MessagePermissions extends UserPermissions {
294
339
  canDeleteMessage: boolean;
295
340
  canReplyToMessage: boolean;
296
341
  canEditMessage: boolean;
342
+ canAddReaction: boolean;
297
343
  }
298
344
 
299
- export declare interface MessageProps extends BaseChatboxProps {
345
+ export declare interface MessagePermissions extends UserPermissions {
346
+ canDeleteMessage: boolean;
347
+ canReplyToMessage: boolean;
348
+ canEditMessage: boolean;
349
+ }
350
+
351
+ export declare interface MessageProps {
352
+ common: CommonChatboxProps;
300
353
  message: MessageSnapshot;
301
354
  messageStatus: MessageStatus;
302
355
  permissions: MessagePermissions;
@@ -308,19 +361,53 @@ export declare type MessageStatus = "sending" | "sent" | "everyoneRead";
308
361
 
309
362
  export { ParticipantSnapshot }
310
363
 
311
- export declare interface ReferencedMessageProps extends BaseChatboxProps {
364
+ /**
365
+ * PopoverButton component that renders a popover triggered by a button.
366
+ *
367
+ * Usage:
368
+ * <PopoverButton
369
+ * popoverComponent={YourMenuComponent}
370
+ * popoverProps={{ prop1: value1, prop2: value2 }}
371
+ * aria-label="..."
372
+ * >
373
+ * <Icon type="horizontalDots" />
374
+ * </MenuButton>
375
+ *
376
+ * All props except for menuComponent and popoverProps are passed to the button element.
377
+ *
378
+ * the popoverComponent will also receive a closePopover prop. It's a function you can call to close the popover.
379
+ */
380
+ export declare function PopoverButton<T extends object>(props: PopoverButtonProps<T>): JSX.Element;
381
+
382
+ export declare type PopoverButtonProps<T extends object> = {
383
+ popoverComponent: React.ComponentType<T>;
384
+ popoverProps: T;
385
+ children: React.ReactNode;
386
+ type?: "menu" | "popover";
387
+ } & React.HTMLAttributes<HTMLButtonElement>;
388
+
389
+ export declare function ReactionPicker(props: ReactionPickerProps): JSX.Element;
390
+
391
+ export declare type ReactionPickerProps = default_2.HTMLAttributes<HTMLDivElement> & {
392
+ messageId: string;
393
+ colorScheme: "light" | "dark";
394
+ };
395
+
396
+ export declare interface ReferencedMessageProps {
397
+ common: CommonChatboxProps;
312
398
  referencedMessage: ReferencedMessageSnapshot;
313
399
  }
314
400
 
315
401
  export { ReferencedMessageSnapshot }
316
402
 
317
- export declare interface ReplyBarProps extends BaseChatboxProps {
403
+ export declare interface ReplyBarProps {
404
+ common: CommonChatboxProps;
318
405
  referencedMessage: MessageSnapshot;
319
406
  }
320
407
 
321
408
  export { TalkSession }
322
409
 
323
- declare function Text_2({ block, className }: TextProps): ReactElement;
410
+ declare function Text_2({ block, nonInteractive, className, }: TextProps): ReactElement;
324
411
  export { Text_2 as Text }
325
412
 
326
413
  export { TextBlock }
@@ -332,6 +419,7 @@ export declare interface TextBlockProps extends ContentBlockProps {
332
419
  export declare interface TextProps {
333
420
  block: TextBlock;
334
421
  className?: string;
422
+ nonInteractive?: boolean;
335
423
  }
336
424
 
337
425
  export declare interface Theme {
@@ -342,6 +430,7 @@ export declare interface Theme {
342
430
  ReplyBar: React_2.ComponentType<ReplyBarProps>;
343
431
  TimeAgo: React_2.ComponentType<TimeAgoProps>;
344
432
  MessageActionMenu: React_2.ComponentType<MessageActionMenuProps>;
433
+ CompactMessageContent: React_2.ComponentType<CompactMessageContentProps>;
345
434
  ChatHeader: React_2.ComponentType<ChatHeaderProps>;
346
435
  Message: React_2.ComponentType<MessageProps>;
347
436
  MessageField: React_2.ComponentType<MessageFieldProps>;
@@ -355,6 +444,7 @@ export declare interface Theme {
355
444
  AudioBlock: React_2.ComponentType<AudioBlockProps>;
356
445
  VoiceBlock: React_2.ComponentType<VoiceBlockProps>;
357
446
  VideoBlock: React_2.ComponentType<VideoBlockProps>;
447
+ ConversationListItem: React_2.ComponentType<ConversationListItemProps>;
358
448
  }
359
449
 
360
450
  export declare interface TimeAgo {
@@ -367,7 +457,8 @@ export declare interface TimeAgo {
367
457
  short: string;
368
458
  }
369
459
 
370
- export declare interface TimeAgoProps extends BaseChatboxProps {
460
+ export declare interface TimeAgoProps {
461
+ common: CommonChatboxProps;
371
462
  timestamp: number;
372
463
  }
373
464
 
@@ -461,6 +552,17 @@ export declare interface UserPermissions {
461
552
  canMarkConversationAsUnread: boolean;
462
553
  }
463
554
 
555
+ export declare interface UserPermissions {
556
+ showTypingIndicator: boolean;
557
+ canShareFile: boolean;
558
+ canShareLocation: boolean;
559
+ canMention: boolean;
560
+ showOnlineStatus: boolean;
561
+ canSendVoiceMessage: boolean;
562
+ canLeaveConversation: boolean;
563
+ canMarkConversationAsUnread: boolean;
564
+ }
565
+
464
566
  export { UserSnapshot }
465
567
 
466
568
  /**
@@ -509,6 +611,7 @@ declare global {
509
611
  declare global {
510
612
  interface HTMLElementTagNameMap {
511
613
  "t-chatbox": ChatboxHTMLElement;
614
+ "t-conversation-list": ConversationListHTMLElement;
512
615
  }
513
616
  }
514
617
 
@@ -517,6 +620,7 @@ declare global {
517
620
  namespace JSX {
518
621
  interface IntrinsicElements {
519
622
  "t-chatbox": typeof UnthemedChatbox;
623
+ "t-conversation-list": typeof UnthemedConversationList;
520
624
  }
521
625
  }
522
626
  }