@talkjs/react-components 0.0.20 → 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 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};
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.20",
3
+ "version": "0.0.21",
4
4
  "bugs": {
5
5
  "url": "https://talkjs.com/?chat"
6
6
  },
@@ -26,7 +26,8 @@
26
26
  "@legendapp/state": "3.0.0-alpha.9",
27
27
  "@popperjs/core": "^2.11.8",
28
28
  "@radix-ui/react-dropdown-menu": "^2.1.15",
29
- "@talkjs/core": "^1.4.2",
29
+ "@radix-ui/react-popover": "^1.1.15",
30
+ "@talkjs/core": "^1.5.0",
30
31
  "autolinker": "^4.0.0",
31
32
  "country-flag-emoji-polyfill": "^0.1.8",
32
33
  "emoji-picker-element": "1.8.2",
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
123
  }
124
124
 
125
- export declare interface ContentBlockProps extends BaseChatboxProps {
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;
134
+ }
135
+
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,6 +185,17 @@ 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
201
  export declare interface EditorController {
@@ -210,12 +257,15 @@ export declare function getPhotoUrlWithFallback(user: UserSnapshot): string;
210
257
 
211
258
  export declare function getRandomColor(id: string): string;
212
259
 
213
- export declare interface GroupChatImageProps extends BaseChatboxProps {
260
+ export declare interface GroupChatImageProps {
261
+ common: CommonChatboxProps | CommonConversationListProps;
262
+ participants: ParticipantSnapshot[];
214
263
  }
215
264
 
216
265
  export declare function html(strings: TemplateStringsArray, ...args: any[]): ReactElement;
217
266
 
218
- export declare interface IconProps extends BaseChatboxProps {
267
+ export declare interface IconProps {
268
+ common: CommonChatboxProps | CommonConversationListProps;
219
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";
220
270
  className?: string;
221
271
  }
@@ -243,36 +293,6 @@ export declare interface MentionSuggestListProps {
243
293
  className?: string;
244
294
  }
245
295
 
246
- /**
247
- * MenuButton component that renders a dropdown menu triggered by a button.
248
- *
249
- * Usage:
250
- * <MenuButton
251
- * menuComponent={YourMenuComponent}
252
- * menuProps={{ prop1: value1, prop2: value2 }}
253
- * aria-label="Message actions"
254
- * >
255
- * <Icon type="horizontalDots" />
256
- * </MenuButton>
257
- *
258
- * All props except for menuComponent and menuProps are passed to the button element.
259
- *
260
- * The menuComponent should be a component that renders the dropdown content.
261
- * The menuProps are passed to the menuComponent.
262
- *
263
- * The menu component shouod render the MenuItem component for each menu item it wants to include.
264
- *
265
- * This is meant as a reuseable and accessible dropdown menu. We're using Radix for this, because they fulli implement
266
- * the ARIA Menu Button pattern, but without adding any styles, so we can completely customise the look and feel.
267
- */
268
- export declare function MenuButton<T extends object>(props: MenuButtonProps<T>): JSX.Element;
269
-
270
- export declare type MenuButtonProps<T extends object> = {
271
- menuComponent: React.ComponentType<T>;
272
- menuProps: T;
273
- children: React.ReactNode;
274
- } & React.HTMLAttributes<HTMLButtonElement>;
275
-
276
296
  export declare function MenuItem(props: MenuItemProps): JSX.Element;
277
297
 
278
298
  export declare type MenuItemProps = React.HTMLAttributes<HTMLDivElement> & {
@@ -281,40 +301,55 @@ export declare type MenuItemProps = React.HTMLAttributes<HTMLDivElement> & {
281
301
  textValue?: string;
282
302
  };
283
303
 
284
- export declare interface MessageActionMenuProps extends BaseChatboxProps {
304
+ export declare interface MessageActionMenuProps {
305
+ common: CommonChatboxProps;
306
+ message: MessageSnapshot;
307
+ permissions: MessagePermissions;
285
308
  }
286
309
 
287
310
  export declare function MessageContent(props: MessageContentProps): JSX.Element;
288
311
 
289
- export declare interface MessageContentProps extends BaseChatboxProps {
312
+ export declare interface MessageContentProps {
313
+ common: CommonChatboxProps;
290
314
  message: MessageSnapshot;
291
315
  messageStatus: MessageStatus;
292
316
  className?: string;
293
317
  }
294
318
 
295
- export declare interface MessageDividerProps extends BaseChatboxProps {
319
+ export declare interface MessageDividerProps {
320
+ common: CommonChatboxProps;
296
321
  isReadMarker: boolean;
297
322
  isDayMarker: boolean;
298
323
  timestamp?: number;
299
324
  }
300
325
 
301
- export declare interface MessageFieldProps extends BaseChatboxProps {
326
+ export declare interface MessageFieldProps {
327
+ common: CommonChatboxProps;
302
328
  referencedMessage: MessageSnapshot | undefined;
303
329
  permissions: UserPermissions;
304
- editor?: EditorController;
330
+ editor: EditorController;
305
331
  editMessageId: string | undefined;
306
332
  }
307
333
 
308
- export declare interface MessageListFooterProps extends BaseChatboxProps {
334
+ export declare interface MessageListFooterProps {
335
+ common: CommonChatboxProps;
309
336
  }
310
337
 
311
338
  export declare interface MessagePermissions extends UserPermissions {
312
339
  canDeleteMessage: boolean;
313
340
  canReplyToMessage: boolean;
314
341
  canEditMessage: boolean;
342
+ canAddReaction: boolean;
315
343
  }
316
344
 
317
- 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;
318
353
  message: MessageSnapshot;
319
354
  messageStatus: MessageStatus;
320
355
  permissions: MessagePermissions;
@@ -326,19 +361,53 @@ export declare type MessageStatus = "sending" | "sent" | "everyoneRead";
326
361
 
327
362
  export { ParticipantSnapshot }
328
363
 
329
- 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;
330
398
  referencedMessage: ReferencedMessageSnapshot;
331
399
  }
332
400
 
333
401
  export { ReferencedMessageSnapshot }
334
402
 
335
- export declare interface ReplyBarProps extends BaseChatboxProps {
403
+ export declare interface ReplyBarProps {
404
+ common: CommonChatboxProps;
336
405
  referencedMessage: MessageSnapshot;
337
406
  }
338
407
 
339
408
  export { TalkSession }
340
409
 
341
- declare function Text_2({ block, className }: TextProps): ReactElement;
410
+ declare function Text_2({ block, nonInteractive, className, }: TextProps): ReactElement;
342
411
  export { Text_2 as Text }
343
412
 
344
413
  export { TextBlock }
@@ -350,6 +419,7 @@ export declare interface TextBlockProps extends ContentBlockProps {
350
419
  export declare interface TextProps {
351
420
  block: TextBlock;
352
421
  className?: string;
422
+ nonInteractive?: boolean;
353
423
  }
354
424
 
355
425
  export declare interface Theme {
@@ -360,6 +430,7 @@ export declare interface Theme {
360
430
  ReplyBar: React_2.ComponentType<ReplyBarProps>;
361
431
  TimeAgo: React_2.ComponentType<TimeAgoProps>;
362
432
  MessageActionMenu: React_2.ComponentType<MessageActionMenuProps>;
433
+ CompactMessageContent: React_2.ComponentType<CompactMessageContentProps>;
363
434
  ChatHeader: React_2.ComponentType<ChatHeaderProps>;
364
435
  Message: React_2.ComponentType<MessageProps>;
365
436
  MessageField: React_2.ComponentType<MessageFieldProps>;
@@ -373,6 +444,7 @@ export declare interface Theme {
373
444
  AudioBlock: React_2.ComponentType<AudioBlockProps>;
374
445
  VoiceBlock: React_2.ComponentType<VoiceBlockProps>;
375
446
  VideoBlock: React_2.ComponentType<VideoBlockProps>;
447
+ ConversationListItem: React_2.ComponentType<ConversationListItemProps>;
376
448
  }
377
449
 
378
450
  export declare interface TimeAgo {
@@ -385,7 +457,8 @@ export declare interface TimeAgo {
385
457
  short: string;
386
458
  }
387
459
 
388
- export declare interface TimeAgoProps extends BaseChatboxProps {
460
+ export declare interface TimeAgoProps {
461
+ common: CommonChatboxProps;
389
462
  timestamp: number;
390
463
  }
391
464
 
@@ -479,6 +552,17 @@ export declare interface UserPermissions {
479
552
  canMarkConversationAsUnread: boolean;
480
553
  }
481
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
+
482
566
  export { UserSnapshot }
483
567
 
484
568
  /**
@@ -527,6 +611,7 @@ declare global {
527
611
  declare global {
528
612
  interface HTMLElementTagNameMap {
529
613
  "t-chatbox": ChatboxHTMLElement;
614
+ "t-conversation-list": ConversationListHTMLElement;
530
615
  }
531
616
  }
532
617
 
@@ -535,6 +620,7 @@ declare global {
535
620
  namespace JSX {
536
621
  interface IntrinsicElements {
537
622
  "t-chatbox": typeof UnthemedChatbox;
623
+ "t-conversation-list": typeof UnthemedConversationList;
538
624
  }
539
625
  }
540
626
  }