@talkjs/react-components 0.0.12 → 0.0.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talkjs/react-components",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "bugs": {
5
5
  "url": "https://talkjs.com/?chat"
6
6
  },
@@ -24,9 +24,10 @@
24
24
  "dependencies": {
25
25
  "@floating-ui/dom": "^1.6.5",
26
26
  "@legendapp/state": "3.0.0-alpha.9",
27
- "@reach/menu-button": "^0.18.0",
27
+ "@radix-ui/react-dropdown-menu": "^2.1.15",
28
28
  "@talkjs/core": "~1.4.2",
29
29
  "autolinker": "^4.0.0",
30
+ "emoji-picker-element": "1.8.2",
30
31
  "htm": "^3.1.1",
31
32
  "lodash.merge": "^4.6.2",
32
33
  "onecolor": "^4.1.0",
package/theming.d.ts CHANGED
@@ -145,8 +145,6 @@ export declare interface Chatbox {
145
145
  custom?: Record<string, string>;
146
146
  }): Promise<void>;
147
147
  setReferencedMessage(messageId: string | null): void;
148
- openMessageActionMenu(messageId: string): void;
149
- closeMessageActionMenu(): void;
150
148
  getMessageFieldText: () => string;
151
149
  setMessageFieldText: (text: string) => void;
152
150
  }
@@ -158,6 +156,11 @@ export declare interface ChatHeaderProps {
158
156
  t: Translation;
159
157
  chatbox: Chatbox;
160
158
  themeCustom?: any;
159
+ isUserConnected: {
160
+ [userId: string]: boolean;
161
+ };
162
+ permissions: UserPermissions;
163
+ device: DeviceFeatures;
161
164
  }
162
165
 
163
166
  export declare interface ContentBlockProps {
@@ -180,12 +183,24 @@ export declare interface DeleteMessageEvent {
180
183
  conversation: ConversationSnapshot;
181
184
  }
182
185
 
186
+ export declare interface DeviceFeatures {
187
+ /**
188
+ * True if the browser supports IndexedDB, which the emoji picker depends on.
189
+ */
190
+ supportsEmojiPicker: boolean;
191
+ /**
192
+ * True if the user agents reports this device as mobile (incl tablets).
193
+ */
194
+ isMobile: boolean;
195
+ }
196
+
183
197
  export declare function Editor({ placeholder, disabled, className, characterLimit, spellcheck, }: EditorProps): JSX.Element;
184
198
 
185
199
  export declare interface EditorController extends EditorState {
186
200
  send(): void;
187
201
  shareLocation(): void;
188
202
  attachFile(): void;
203
+ toggleEmojiPicker(): void;
189
204
  }
190
205
 
191
206
  export declare interface EditorProps {
@@ -201,6 +216,13 @@ declare interface EditorState {
201
216
  atTextLimit: boolean;
202
217
  isEmpty: boolean;
203
218
  characterCount: number;
219
+ showEmojiPicker: boolean;
220
+ }
221
+
222
+ export declare function EmojiPicker(props: EmojiPickerProps): JSX.Element;
223
+
224
+ declare interface EmojiPickerProps {
225
+ colorScheme: "light" | "dark";
204
226
  }
205
227
 
206
228
  export { FileBlock }
@@ -233,7 +255,7 @@ export declare function html(strings: TemplateStringsArray, ...args: any[]): Rea
233
255
  export declare function i18n(code: string): Translation;
234
256
 
235
257
  export declare interface IconProps {
236
- type: "attach" | "chevronLeft" | "left" | "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";
258
+ 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";
237
259
  className?: string;
238
260
  themeCustom?: any;
239
261
  }
@@ -251,15 +273,43 @@ export declare interface LocationBlockProps extends ContentBlockProps {
251
273
  block: LocationBlock;
252
274
  }
253
275
 
254
- export declare interface MessageActionMenuProps {
255
- currentUser: UserSnapshot;
256
- permissions: MessagePermissions;
257
- conversation: ConversationSnapshot;
258
- message: MessageSnapshot;
259
- chatbox: Chatbox;
260
- t: Translation;
261
- themeCustom?: any;
262
- }
276
+ /**
277
+ * MenuButton component that renders a dropdown menu triggered by a button.
278
+ *
279
+ * Usage:
280
+ * <MenuButton
281
+ * menuComponent={YourMenuComponent}
282
+ * menuProps={{ prop1: value1, prop2: value2 }}
283
+ * aria-label="Message actions"
284
+ * >
285
+ * <Icon type="horizontalDots" />
286
+ * </MenuButton>
287
+ *
288
+ * All props except for menuComponent and menuProps are passed to the button element.
289
+ *
290
+ * The menuComponent should be a component that renders the dropdown content.
291
+ * The menuProps are passed to the menuComponent.
292
+ *
293
+ * The menu component shouod render the MenuItem component for each menu item it wants to include.
294
+ *
295
+ * This is meant as a reuseable and accessible dropdown menu. We're using Radix for this, because they fulli implement
296
+ * the ARIA Menu Button pattern, but without adding any styles, so we can completely customise the look and feel.
297
+ */
298
+ export declare function MenuButton<T extends object>(props: MenuButtonProps<T>): JSX.Element;
299
+
300
+ export declare type MenuButtonProps<T extends object> = {
301
+ menuComponent: React.ComponentType<T>;
302
+ menuProps: T;
303
+ children: React.ReactNode;
304
+ } & React.HTMLAttributes<HTMLButtonElement>;
305
+
306
+ export declare function MenuItem(props: MenuItemProps): JSX.Element;
307
+
308
+ export declare type MenuItemProps = React.HTMLAttributes<HTMLDivElement> & {
309
+ onSelect?: () => void;
310
+ disabled?: boolean;
311
+ textValue?: string;
312
+ };
263
313
 
264
314
  export declare function MessageContent(props: MessageContentProps): JSX.Element;
265
315
 
@@ -268,7 +318,7 @@ export declare interface MessageContentProps {
268
318
  message: MessageSnapshot;
269
319
  t: Translation;
270
320
  messageStatus: MessageStatus;
271
- themeCustom: any;
321
+ themeCustom?: any;
272
322
  className?: string;
273
323
  }
274
324
 
@@ -293,6 +343,7 @@ export declare interface MessageFieldProps {
293
343
  chatbox: Chatbox;
294
344
  editor?: EditorController;
295
345
  themeCustom?: any;
346
+ device: DeviceFeatures;
296
347
  }
297
348
 
298
349
  export declare interface MessageListFooterProps {
@@ -320,8 +371,8 @@ export declare interface MessageProps {
320
371
  permissions: MessagePermissions;
321
372
  t: Translation;
322
373
  chatbox: Chatbox;
323
- messageActionMenuAnchorRef: React_2.RefObject<HTMLElement | undefined>;
324
374
  themeCustom?: any;
375
+ device: DeviceFeatures;
325
376
  }
326
377
 
327
378
  export { MessageSnapshot }
@@ -387,7 +438,6 @@ export declare interface Theme {
387
438
  ChatHeader: React_2.ComponentType<ChatHeaderProps>;
388
439
  Message: React_2.ComponentType<MessageProps>;
389
440
  MessageField: React_2.ComponentType<MessageFieldProps>;
390
- MessageActionMenu: React_2.ComponentType<MessageActionMenuProps>;
391
441
  Icon: React_2.ComponentType<IconProps>;
392
442
  MessageDivider: React_2.ComponentType<MessageDividerProps>;
393
443
  MessageListFooter: React_2.ComponentType<MessageListFooterProps>;
@@ -529,6 +579,22 @@ export declare interface VoiceBlockProps extends ContentBlockProps {
529
579
  export { }
530
580
 
531
581
 
582
+ declare global {
583
+ namespace JSX {
584
+ interface IntrinsicElements {
585
+ "emoji-picker": {
586
+ class?: string;
587
+ ref: React.Ref<HTMLElement>;
588
+ };
589
+ }
590
+ }
591
+ interface HTMLElementEventMap {
592
+ "emoji-click": EmojiClickEvent;
593
+ "skin-tone-change": SkinToneChangeEvent;
594
+ }
595
+ }
596
+
597
+
532
598
  declare global {
533
599
  interface HTMLElementTagNameMap {
534
600
  "t-chatbox": ChatboxHTMLElement;