@weavy/uikit-react 12.1.0 → 14.0.0

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.
Files changed (280) hide show
  1. package/changelog.md +60 -0
  2. package/dist/cjs/index.js +28 -6
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/types/client/WeavyClient.d.ts +8 -1
  5. package/dist/cjs/types/components/Attachment.d.ts +2 -1
  6. package/dist/cjs/types/components/Chat.d.ts +1 -1
  7. package/dist/cjs/types/components/Messages.d.ts +3 -1
  8. package/dist/cjs/types/components/PdfViewer.d.ts +3 -1
  9. package/dist/cjs/types/components/Preview.d.ts +8 -10
  10. package/dist/cjs/types/contexts/PreviewContext.d.ts +2 -1
  11. package/dist/cjs/types/contexts/WeavyContext.d.ts +2 -3
  12. package/dist/cjs/types/hooks/useConversations.d.ts +1 -1
  13. package/dist/cjs/types/hooks/useMutateMessage.d.ts +1 -1
  14. package/dist/cjs/types/hooks/useMutateRead.d.ts +1 -0
  15. package/dist/cjs/types/types/Chat.d.ts +2 -1
  16. package/dist/cjs/types/types/Message.d.ts +2 -0
  17. package/dist/cjs/types/types/types.d.ts +63 -9
  18. package/dist/cjs/types/ui/Spinner.d.ts +10 -0
  19. package/dist/cjs/types/utils/fileUtilities.d.ts +1 -4
  20. package/dist/css/weavy-chat.css +1803 -1041
  21. package/dist/css/weavy-messenger.css +2141 -1360
  22. package/dist/css/weavy.css +1943 -1162
  23. package/dist/esm/index.js +28 -6
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/types/client/WeavyClient.d.ts +8 -1
  26. package/dist/esm/types/components/Attachment.d.ts +2 -1
  27. package/dist/esm/types/components/Chat.d.ts +1 -1
  28. package/dist/esm/types/components/Messages.d.ts +3 -1
  29. package/dist/esm/types/components/PdfViewer.d.ts +3 -1
  30. package/dist/esm/types/components/Preview.d.ts +8 -10
  31. package/dist/esm/types/contexts/PreviewContext.d.ts +2 -1
  32. package/dist/esm/types/contexts/WeavyContext.d.ts +2 -3
  33. package/dist/esm/types/hooks/useConversations.d.ts +1 -1
  34. package/dist/esm/types/hooks/useMutateMessage.d.ts +1 -1
  35. package/dist/esm/types/hooks/useMutateRead.d.ts +1 -0
  36. package/dist/esm/types/types/Chat.d.ts +2 -1
  37. package/dist/esm/types/types/Message.d.ts +2 -0
  38. package/dist/esm/types/types/types.d.ts +63 -9
  39. package/dist/esm/types/ui/Spinner.d.ts +10 -0
  40. package/dist/esm/types/utils/fileUtilities.d.ts +1 -4
  41. package/dist/index.d.ts +15 -7
  42. package/package.json +2 -2
  43. package/rollup.config.js +3 -1
  44. package/src/client/WeavyClient.ts +105 -29
  45. package/src/components/Attachment.tsx +8 -7
  46. package/src/components/Chat.tsx +8 -7
  47. package/src/components/Conversation.tsx +29 -23
  48. package/src/components/ConversationBadge.tsx +7 -5
  49. package/src/components/ConversationForm.tsx +1 -1
  50. package/src/components/ConversationList.tsx +59 -11
  51. package/src/components/ConversationListItem.tsx +71 -54
  52. package/src/components/FileBrowser.tsx +53 -50
  53. package/src/components/MeetingCard.tsx +35 -13
  54. package/src/components/Meetings.tsx +1 -1
  55. package/src/components/Message.tsx +41 -41
  56. package/src/components/Messages.tsx +62 -61
  57. package/src/components/Messenger.tsx +7 -2
  58. package/src/components/NewConversation.tsx +1 -1
  59. package/src/components/PdfViewer.tsx +93 -88
  60. package/src/components/Preview.tsx +115 -54
  61. package/src/components/Reactions.tsx +11 -5
  62. package/src/components/SearchUsers.tsx +21 -11
  63. package/src/components/SeenBy.tsx +13 -7
  64. package/src/components/Typing.tsx +11 -12
  65. package/src/contexts/PreviewContext.tsx +90 -16
  66. package/src/contexts/UserContext.tsx +1 -1
  67. package/src/contexts/WeavyContext.tsx +10 -7
  68. package/src/hooks/useBadge.ts +2 -6
  69. package/src/hooks/useChat.ts +3 -14
  70. package/src/hooks/useConversation.ts +1 -7
  71. package/src/hooks/useConversations.ts +15 -11
  72. package/src/hooks/useFileUploader.ts +6 -8
  73. package/src/hooks/useMembers.ts +1 -7
  74. package/src/hooks/useMessages.ts +1 -7
  75. package/src/hooks/useMutateChat.ts +6 -11
  76. package/src/hooks/useMutateConversation.ts +7 -10
  77. package/src/hooks/useMutateConversationName.ts +10 -12
  78. package/src/hooks/useMutateDeleteReaction.ts +3 -8
  79. package/src/hooks/useMutateExternalBlobs.ts +6 -11
  80. package/src/hooks/useMutateMeeting.ts +6 -11
  81. package/src/hooks/useMutateMembers.ts +8 -13
  82. package/src/hooks/useMutateMessage.ts +9 -18
  83. package/src/hooks/useMutatePinned.ts +3 -8
  84. package/src/hooks/useMutateReaction.ts +6 -12
  85. package/src/hooks/useMutateRead.ts +5 -12
  86. package/src/hooks/useMutateRemoveMembers.ts +7 -12
  87. package/src/hooks/useMutateTyping.ts +6 -11
  88. package/src/hooks/usePresence.ts +2 -3
  89. package/src/hooks/useReactions.ts +11 -12
  90. package/src/hooks/useSearchUsers.ts +1 -6
  91. package/src/hooks/useUser.ts +3 -14
  92. package/src/scss/theme/_alert.scss +61 -63
  93. package/src/scss/theme/_appbar.scss +105 -28
  94. package/src/scss/theme/_avatar.scss +23 -28
  95. package/src/scss/theme/_badge.scss +26 -18
  96. package/src/scss/theme/_buttons.scss +107 -52
  97. package/src/scss/theme/_card.scss +102 -4
  98. package/src/scss/theme/_checkbox.scss +16 -20
  99. package/src/scss/theme/_code-vscode-dark.scss +184 -0
  100. package/src/scss/theme/_code-vscode-light.scss +179 -0
  101. package/src/scss/theme/_code.scss +9 -114
  102. package/src/scss/theme/_comment-editor-cm.scss +97 -0
  103. package/src/scss/theme/_comment-editor.scss +129 -0
  104. package/src/scss/theme/_comments.scss +66 -0
  105. package/src/scss/theme/_content.scss +33 -5
  106. package/src/scss/theme/_conversations.scss +19 -78
  107. package/src/scss/theme/_dropdown.scss +102 -15
  108. package/src/scss/theme/_embed.scss +135 -0
  109. package/src/scss/theme/_facepile.scss +11 -0
  110. package/src/scss/theme/_filebrowser.scss +1 -1
  111. package/src/scss/theme/_files.scss +77 -48
  112. package/src/scss/theme/_grid.scss +8 -0
  113. package/src/scss/theme/_icons.scss +155 -19
  114. package/src/scss/theme/_image-grid.scss +7 -10
  115. package/src/scss/theme/_input.scss +160 -0
  116. package/src/scss/theme/_item.scss +169 -0
  117. package/src/scss/theme/_list.scss +57 -0
  118. package/src/scss/theme/_meeting.scss +11 -0
  119. package/src/scss/theme/_message-editor-cm.scss +95 -0
  120. package/src/scss/theme/_message-editor.scss +66 -20
  121. package/src/scss/theme/_messages.scss +51 -105
  122. package/src/scss/theme/_meta.scss +12 -0
  123. package/src/scss/theme/_overlays.scss +31 -76
  124. package/src/scss/theme/_pager.scss +5 -1
  125. package/src/scss/theme/_pane.scss +13 -2
  126. package/src/scss/theme/_panels.scss +34 -25
  127. package/src/scss/theme/_picker-list.scss +5 -3
  128. package/src/scss/theme/_placeholder.scss +19 -0
  129. package/src/scss/theme/_poll.scss +49 -0
  130. package/src/scss/theme/_post-editor-cm.scss +100 -0
  131. package/src/scss/theme/_post-editor.scss +127 -0
  132. package/src/scss/theme/_post.scss +83 -0
  133. package/src/scss/theme/_preview-code.scss +14 -0
  134. package/src/scss/theme/_preview-embed.scss +11 -5
  135. package/src/scss/theme/_preview-image.scss +8 -26
  136. package/src/scss/theme/_preview-media.scss +1 -0
  137. package/src/scss/theme/_preview-pdf.scss +10 -15
  138. package/src/scss/theme/_preview-text.scss +1 -1
  139. package/src/scss/theme/_preview.scss +59 -76
  140. package/src/scss/theme/_reactions.scss +48 -17
  141. package/src/scss/theme/_sheet.scss +59 -0
  142. package/src/scss/theme/_sidebar.scss +86 -0
  143. package/src/scss/theme/_spinner.scss +11 -7
  144. package/src/scss/theme/_tab.scss +72 -0
  145. package/src/scss/theme/_tables.scss +70 -23
  146. package/src/scss/theme/_toasts.scss +56 -26
  147. package/src/scss/theme/_type.scss +41 -0
  148. package/src/scss/theme/{mixins → base}/_backdrop.scss +0 -0
  149. package/src/scss/theme/{bootstrap/mixins → base}/_breakpoints.scss +9 -0
  150. package/src/scss/theme/base/_colors.scss +315 -0
  151. package/src/scss/theme/base/_md.scss +19 -0
  152. package/src/scss/theme/base/_palette.scss +130 -0
  153. package/src/scss/theme/{mixins → base}/_position.scss +5 -5
  154. package/src/scss/theme/base/_reboot.scss +51 -0
  155. package/src/scss/theme/base/_scroll.scss +180 -0
  156. package/src/scss/theme/base/_svg.scss +49 -0
  157. package/src/scss/theme/base/_text.scss +23 -0
  158. package/src/scss/theme/base/_vars.scss +203 -0
  159. package/src/scss/theme/{fonts → base/fonts}/_fontmapping-roboto.scss +0 -0
  160. package/src/scss/theme/{fonts → base/fonts}/_fontmapping-segoe-ui.scss +0 -0
  161. package/src/scss/theme/base/fonts/_index.scss +2 -0
  162. package/src/scss/weavy-chat.scss +11 -4
  163. package/src/scss/weavy-messenger.scss +38 -21
  164. package/src/types/Chat.ts +2 -1
  165. package/src/types/Message.ts +3 -1
  166. package/src/types/types.ts +72 -10
  167. package/src/ui/Icon.tsx +1 -1
  168. package/src/ui/Spinner.tsx +19 -0
  169. package/src/utils/fileUtilities.ts +11 -125
  170. package/src/utils/infiniteScroll.js +11 -2
  171. package/src/utils/postal-parent.js +398 -0
  172. package/src/utils/promise.js +187 -0
  173. package/src/utils/scrollbarDetection.js +68 -9
  174. package/src/utils/utils.js +547 -0
  175. package/src/scss/theme/_attachments.scss +0 -74
  176. package/src/scss/theme/_cm-editor.scss +0 -42
  177. package/src/scss/theme/_colors.scss +0 -520
  178. package/src/scss/theme/_config.scss +0 -6
  179. package/src/scss/theme/_inputs.scss +0 -28
  180. package/src/scss/theme/_nav.scss +0 -52
  181. package/src/scss/theme/_palette.scss +0 -165
  182. package/src/scss/theme/_preview-icon.scss +0 -41
  183. package/src/scss/theme/_reboot.scss +0 -41
  184. package/src/scss/theme/_root.scss +0 -2
  185. package/src/scss/theme/_scroll.scss +0 -55
  186. package/src/scss/theme/_search.scss +0 -68
  187. package/src/scss/theme/_turbo.scss +0 -17
  188. package/src/scss/theme/_variables.scss +0 -139
  189. package/src/scss/theme/bootstrap/_accordion.scss +0 -146
  190. package/src/scss/theme/bootstrap/_alert.scss +0 -71
  191. package/src/scss/theme/bootstrap/_badge.scss +0 -38
  192. package/src/scss/theme/bootstrap/_breadcrumb.scss +0 -40
  193. package/src/scss/theme/bootstrap/_button-group.scss +0 -142
  194. package/src/scss/theme/bootstrap/_buttons.scss +0 -186
  195. package/src/scss/theme/bootstrap/_card.scss +0 -234
  196. package/src/scss/theme/bootstrap/_carousel.scss +0 -229
  197. package/src/scss/theme/bootstrap/_close.scss +0 -40
  198. package/src/scss/theme/bootstrap/_containers.scss +0 -41
  199. package/src/scss/theme/bootstrap/_dropdown.scss +0 -248
  200. package/src/scss/theme/bootstrap/_forms.scss +0 -9
  201. package/src/scss/theme/bootstrap/_functions.scss +0 -302
  202. package/src/scss/theme/bootstrap/_grid.scss +0 -33
  203. package/src/scss/theme/bootstrap/_helpers.scss +0 -10
  204. package/src/scss/theme/bootstrap/_images.scss +0 -42
  205. package/src/scss/theme/bootstrap/_list-group.scss +0 -191
  206. package/src/scss/theme/bootstrap/_maps.scss +0 -54
  207. package/src/scss/theme/bootstrap/_mixins.scss +0 -43
  208. package/src/scss/theme/bootstrap/_modal.scss +0 -237
  209. package/src/scss/theme/bootstrap/_nav.scss +0 -172
  210. package/src/scss/theme/bootstrap/_navbar.scss +0 -276
  211. package/src/scss/theme/bootstrap/_offcanvas.scss +0 -143
  212. package/src/scss/theme/bootstrap/_pagination.scss +0 -109
  213. package/src/scss/theme/bootstrap/_placeholders.scss +0 -51
  214. package/src/scss/theme/bootstrap/_popover.scss +0 -196
  215. package/src/scss/theme/bootstrap/_progress.scss +0 -59
  216. package/src/scss/theme/bootstrap/_reboot.scss +0 -610
  217. package/src/scss/theme/bootstrap/_root.scss +0 -73
  218. package/src/scss/theme/bootstrap/_spinners.scss +0 -85
  219. package/src/scss/theme/bootstrap/_tables.scss +0 -164
  220. package/src/scss/theme/bootstrap/_toasts.scss +0 -70
  221. package/src/scss/theme/bootstrap/_tooltip.scss +0 -120
  222. package/src/scss/theme/bootstrap/_transitions.scss +0 -27
  223. package/src/scss/theme/bootstrap/_type.scss +0 -106
  224. package/src/scss/theme/bootstrap/_utilities.scss +0 -647
  225. package/src/scss/theme/bootstrap/_variables.scss +0 -1633
  226. package/src/scss/theme/bootstrap/forms/_floating-labels.scss +0 -74
  227. package/src/scss/theme/bootstrap/forms/_form-check.scss +0 -175
  228. package/src/scss/theme/bootstrap/forms/_form-control.scss +0 -194
  229. package/src/scss/theme/bootstrap/forms/_form-range.scss +0 -91
  230. package/src/scss/theme/bootstrap/forms/_form-select.scss +0 -71
  231. package/src/scss/theme/bootstrap/forms/_form-text.scss +0 -11
  232. package/src/scss/theme/bootstrap/forms/_input-group.scss +0 -129
  233. package/src/scss/theme/bootstrap/forms/_labels.scss +0 -36
  234. package/src/scss/theme/bootstrap/forms/_validation.scss +0 -12
  235. package/src/scss/theme/bootstrap/helpers/_clearfix.scss +0 -3
  236. package/src/scss/theme/bootstrap/helpers/_color-bg.scss +0 -10
  237. package/src/scss/theme/bootstrap/helpers/_colored-links.scss +0 -12
  238. package/src/scss/theme/bootstrap/helpers/_position.scss +0 -36
  239. package/src/scss/theme/bootstrap/helpers/_ratio.scss +0 -26
  240. package/src/scss/theme/bootstrap/helpers/_stacks.scss +0 -15
  241. package/src/scss/theme/bootstrap/helpers/_stretched-link.scss +0 -15
  242. package/src/scss/theme/bootstrap/helpers/_text-truncation.scss +0 -7
  243. package/src/scss/theme/bootstrap/helpers/_visually-hidden.scss +0 -8
  244. package/src/scss/theme/bootstrap/helpers/_vr.scss +0 -8
  245. package/src/scss/theme/bootstrap/mixins/_alert.scss +0 -15
  246. package/src/scss/theme/bootstrap/mixins/_backdrop.scss +0 -14
  247. package/src/scss/theme/bootstrap/mixins/_banner.scss +0 -9
  248. package/src/scss/theme/bootstrap/mixins/_border-radius.scss +0 -78
  249. package/src/scss/theme/bootstrap/mixins/_box-shadow.scss +0 -18
  250. package/src/scss/theme/bootstrap/mixins/_buttons.scss +0 -70
  251. package/src/scss/theme/bootstrap/mixins/_caret.scss +0 -64
  252. package/src/scss/theme/bootstrap/mixins/_clearfix.scss +0 -9
  253. package/src/scss/theme/bootstrap/mixins/_color-scheme.scss +0 -7
  254. package/src/scss/theme/bootstrap/mixins/_container.scss +0 -11
  255. package/src/scss/theme/bootstrap/mixins/_deprecate.scss +0 -10
  256. package/src/scss/theme/bootstrap/mixins/_forms.scss +0 -152
  257. package/src/scss/theme/bootstrap/mixins/_gradients.scss +0 -47
  258. package/src/scss/theme/bootstrap/mixins/_grid.scss +0 -151
  259. package/src/scss/theme/bootstrap/mixins/_image.scss +0 -16
  260. package/src/scss/theme/bootstrap/mixins/_list-group.scss +0 -24
  261. package/src/scss/theme/bootstrap/mixins/_lists.scss +0 -7
  262. package/src/scss/theme/bootstrap/mixins/_pagination.scss +0 -10
  263. package/src/scss/theme/bootstrap/mixins/_reset-text.scss +0 -17
  264. package/src/scss/theme/bootstrap/mixins/_resize.scss +0 -6
  265. package/src/scss/theme/bootstrap/mixins/_table-variants.scss +0 -24
  266. package/src/scss/theme/bootstrap/mixins/_text-truncate.scss +0 -8
  267. package/src/scss/theme/bootstrap/mixins/_transition.scss +0 -26
  268. package/src/scss/theme/bootstrap/mixins/_utilities.scss +0 -97
  269. package/src/scss/theme/bootstrap/mixins/_visually-hidden.scss +0 -29
  270. package/src/scss/theme/bootstrap/utilities/_api.scss +0 -47
  271. package/src/scss/theme/bootstrap/vendor/_rfs.scss +0 -354
  272. package/src/scss/theme/bs/_badge.scss +0 -20
  273. package/src/scss/theme/bs/_buttons.scss +0 -185
  274. package/src/scss/theme/bs/_dropdown.scss +0 -86
  275. package/src/scss/theme/bs/_forms.scss +0 -161
  276. package/src/scss/theme/bs/_list-group.scss +0 -73
  277. package/src/scss/theme/bs/_tables.scss +0 -46
  278. package/src/scss/theme/fonts/_index.scss +0 -2
  279. package/src/scss/theme/mixins/_palette.scss +0 -165
  280. package/src/scss/theme/mixins/_scrollbar.scss +0 -110
@@ -1,16 +1,23 @@
1
1
  export default class WeavyClient {
2
2
  url: string;
3
- tokenFactory: () => string | Promise<string>;
4
3
  connection: import("@microsoft/signalr").HubConnection;
4
+ tokenFactory: (refresh: boolean) => Promise<string>;
5
5
  groups: string[];
6
6
  connectionEvents: any[];
7
7
  isConnectionStarted: any;
8
+ token: string;
9
+ tokenPromise: Promise<string> | null;
8
10
  EVENT_NAMESPACE: string;
9
11
  EVENT_CLOSE: string;
10
12
  EVENT_RECONNECTING: string;
11
13
  EVENT_RECONNECTED: string;
12
14
  constructor(options: WeavyClientOptions);
15
+ get(url: string, retry?: boolean): Promise<Response>;
16
+ post(url: string, method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", body: string | FormData, contentType?: string, retry?: boolean): Promise<Response>;
17
+ getToken(refresh: boolean): Promise<string>;
18
+ tokenFactoryInternal(refresh?: boolean, fromSR?: boolean): Promise<string>;
13
19
  subscribe(group: string, event: string, callback: any): Promise<void>;
14
20
  unsubscribe(group: string, event: string, callback: any): Promise<void>;
21
+ destroy(): void;
15
22
  triggerHandler(name: string, ...data: any): void;
16
23
  }
@@ -8,6 +8,7 @@ declare type Props = {
8
8
  kind: string;
9
9
  size: number;
10
10
  provider: string;
11
+ onClick?: (e: any) => void;
11
12
  };
12
- declare const Attachment: ({ previewFormat, url, previewUrl, mediaType, name, kind, size, provider }: Props) => JSX.Element;
13
+ declare const Attachment: ({ previewFormat, url, previewUrl, mediaType, name, kind, size, provider, onClick }: Props) => JSX.Element;
13
14
  export default Attachment;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { ChatProps } from '../types/Chat';
3
- declare const Chat: ({ id }: ChatProps) => JSX.Element;
3
+ declare const Chat: ({ uid, className }: ChatProps) => JSX.Element;
4
4
  export default Chat;
@@ -4,6 +4,8 @@ declare type Props = {
4
4
  members: MembersResult | undefined;
5
5
  displayName?: string;
6
6
  avatarUrl?: string;
7
+ lastMessageId: number | null;
8
+ chatRoom: boolean;
7
9
  };
8
- declare const Messages: ({ id, members, displayName, avatarUrl }: Props) => JSX.Element;
10
+ declare const Messages: ({ id, members, displayName, avatarUrl, lastMessageId, chatRoom }: Props) => JSX.Element;
9
11
  export default Messages;
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  declare type Props = {
3
3
  src: string;
4
+ pdfCMapsUrl: string;
5
+ pdfWorkerUrl: string;
4
6
  };
5
- declare const PdfViewer: ({ src }: Props) => JSX.Element;
7
+ declare const PdfViewer: ({ src, pdfCMapsUrl, pdfWorkerUrl }: Props) => JSX.Element;
6
8
  export default PdfViewer;
@@ -7,20 +7,16 @@ declare type ImageProps = {
7
7
  export declare const PreviewImage: ({ src, width, height }: ImageProps) => JSX.Element;
8
8
  declare type DocumentProps = {
9
9
  src: string;
10
+ client: any;
10
11
  };
11
- export declare const PreviewDocument: ({ src }: DocumentProps) => JSX.Element;
12
- declare type VideoProps = {
12
+ export declare const PreviewDocument: ({ src, client }: DocumentProps) => JSX.Element;
13
+ declare type MediaProps = {
14
+ format: string;
13
15
  src: string;
14
16
  name: string;
15
17
  mediaType?: string;
16
18
  };
17
- export declare const PreviewVideo: ({ src, name, mediaType }: VideoProps) => JSX.Element;
18
- declare type AudioProps = {
19
- src: string;
20
- name: string;
21
- mediaType?: string;
22
- };
23
- export declare const PreviewAudio: ({ src, name, mediaType }: AudioProps) => JSX.Element;
19
+ export declare const PreviewMedia: ({ format, src, name, mediaType }: MediaProps) => JSX.Element;
24
20
  declare type TextProps = {
25
21
  src: string;
26
22
  html?: boolean;
@@ -45,7 +41,9 @@ declare type IconProps = {
45
41
  };
46
42
  export declare const PreviewIcon: ({ children, src, icon, name, provider, download, className }: IconProps) => JSX.Element;
47
43
  declare type PreviewProps = {
44
+ client: any;
48
45
  src: string;
46
+ link?: string;
49
47
  format: PreviewFormatType;
50
48
  name: string;
51
49
  icon: string;
@@ -54,5 +52,5 @@ declare type PreviewProps = {
54
52
  mediaType?: string;
55
53
  provider?: string;
56
54
  };
57
- export declare const Preview: ({ src, format, name, icon, width, height, mediaType, provider }: PreviewProps) => JSX.Element;
55
+ export declare const Preview: ({ client, src, link, format, name, icon, width, height, mediaType, provider }: PreviewProps) => JSX.Element;
58
56
  export default Preview;
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  export declare const PreviewContext: React.Context<PreviewContextProps>;
3
3
  declare type Props = {
4
+ client: any;
4
5
  children: React.ReactNode;
5
6
  };
6
- declare const PreviewProvider: ({ children }: Props) => JSX.Element;
7
+ declare const PreviewProvider: ({ client, children }: Props) => JSX.Element;
7
8
  export default PreviewProvider;
@@ -1,10 +1,9 @@
1
1
  import React from "react";
2
- import WeavyClient from "../client/WeavyClient";
3
2
  export declare const WeavyContext: React.Context<WeavyContextProps>;
4
- declare type Props = {
3
+ declare type WeavyProviderProperties = {
5
4
  children: React.ReactNode;
6
5
  client: WeavyClient;
7
6
  options?: WeavyContextOptions;
8
7
  };
9
- declare const WeavyProvider: ({ children, client, options }: Props) => JSX.Element;
8
+ declare const WeavyProvider: ({ children, client, options }: WeavyProviderProperties) => JSX.Element;
10
9
  export default WeavyProvider;
@@ -1 +1 @@
1
- export default function useConversations(): import("react-query").UseQueryResult<ConversationsResult, unknown>;
1
+ export default function useConversations(options: any): import("react-query").UseInfiniteQueryResult<ConversationsResult, unknown>;
@@ -1,4 +1,4 @@
1
- export default function useMutateMessage(): import("react-query").UseMutationResult<any, unknown, {
1
+ export default function useMutateMessage(): import("react-query").UseMutationResult<MessageType, unknown, {
2
2
  id: number | null;
3
3
  text: string;
4
4
  userId: number;
@@ -1,4 +1,5 @@
1
1
  export default function useMutateRead(): import("react-query").UseMutationResult<any, unknown, {
2
2
  id: number | null;
3
3
  read: boolean;
4
+ messageId: number | null;
4
5
  }, unknown>;
@@ -1,3 +1,4 @@
1
1
  export interface ChatProps {
2
- id: string;
2
+ uid: string;
3
+ className?: string;
3
4
  }
@@ -6,10 +6,12 @@ export interface MessageProps {
6
6
  avatar?: string;
7
7
  name: string;
8
8
  created_at: string;
9
+ created_by: string;
9
10
  attachments: AttachmentType[];
10
11
  meeting: MeetingCardType;
11
12
  parentId: number | null;
12
13
  reactions: ReactableType[];
13
14
  reactions_count?: number;
14
15
  seenBy: MemberType[];
16
+ chatRoom: boolean;
15
17
  }
@@ -1,13 +1,16 @@
1
1
  /// <reference types="react" />
2
2
  interface WeavyClient {
3
3
  url: string;
4
- tokenFactory: (() => string | Promise<string>);
4
+ tokenFactoryInternal: () => Promise<string>;
5
5
  subscribe: Function;
6
6
  unsubscribe: Function;
7
+ destroy: Function;
8
+ get: (url: string, retry?: boolean) => Promise<Response>;
9
+ post: (url: string, method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", body: string | FormData, contentType?: string, retry?: boolean) => Promise<Response>;
7
10
  }
8
11
  declare type WeavyClientOptions = {
9
12
  url: string;
10
- tokenFactory: (() => string | Promise<string>);
13
+ tokenFactory: (refresh: boolean) => Promise<string>;
11
14
  };
12
15
  declare type WeavyContextProps = {
13
16
  client: WeavyClient | null;
@@ -19,6 +22,8 @@ declare type WeavyContextOptions = {
19
22
  enableCloudFiles?: boolean;
20
23
  enableScrollbarDetection?: boolean;
21
24
  filebrowserUrl?: string;
25
+ pdfWorkerUrl?: string;
26
+ pdfCMapsUrl?: string;
22
27
  reactions?: string[];
23
28
  };
24
29
  declare type MessengerContextProps = {
@@ -73,9 +78,14 @@ declare type MemberType = {
73
78
  name: string;
74
79
  display_name: string;
75
80
  avatar_url: string;
76
- delivered_at: string;
77
- read_at: string;
81
+ delivered_at?: string;
82
+ read_at?: string;
78
83
  presence: string;
84
+ marked_id?: number;
85
+ marked_at?: string;
86
+ };
87
+ declare type MemberTypingType = MemberType & {
88
+ time: number;
79
89
  };
80
90
  declare type MessageType = {
81
91
  id: number;
@@ -85,6 +95,7 @@ declare type MessageType = {
85
95
  temp?: boolean;
86
96
  created_at: string;
87
97
  created_by: MemberType;
98
+ created_by_id: number;
88
99
  attachments: AttachmentType[];
89
100
  attachment_ids: number[];
90
101
  meeting: MeetingCardType;
@@ -93,10 +104,11 @@ declare type MessageType = {
93
104
  };
94
105
  declare type UserType = {
95
106
  id: number;
107
+ uid: string;
108
+ name: string;
96
109
  username: string;
97
110
  email: string;
98
- name: string;
99
- title: string;
111
+ display_name: string;
100
112
  avatar_url: string;
101
113
  presence: string;
102
114
  };
@@ -114,11 +126,17 @@ declare type AttachmentType = {
114
126
  size: number;
115
127
  provider: string;
116
128
  download_url: string;
117
- preview_url: string;
118
- thumbnail_url: string;
129
+ embed_url: string;
119
130
  external_url: string;
131
+ thumbnail_url: string;
132
+ preview_format: PreviewFormatType;
133
+ application_url: string;
134
+ preview_url: string;
135
+ created_at: string;
136
+ created_by?: UserType;
137
+ createdById?: number;
120
138
  };
121
- declare type PreviewFormatType = "text" | "code" | "markup" | "image" | "video" | "audio" | "document" | "embed" | "link" | "download" | "none";
139
+ declare type PreviewFormatType = "audio" | "code" | "embed" | "html" | "image" | "pdf" | "text" | "video" | "none";
122
140
  declare type ReactionType = {
123
141
  id: number;
124
142
  parent: MessageType;
@@ -153,3 +171,39 @@ declare type BadgeType = {
153
171
  rooms: number;
154
172
  chat: number;
155
173
  };
174
+ declare type EntityType = {
175
+ id: number;
176
+ type: string;
177
+ };
178
+ declare type RealtimeMessage = {
179
+ action: string;
180
+ id: number;
181
+ actor: UserType;
182
+ message: MessageType;
183
+ };
184
+ declare type RealtimeReaction = {
185
+ action: string;
186
+ id: number;
187
+ actor: UserType;
188
+ entity: EntityType;
189
+ reaction: string;
190
+ };
191
+ declare type RealtimeApp = {
192
+ action: string;
193
+ id: number;
194
+ actor: UserType;
195
+ app: ConversationType;
196
+ };
197
+ declare type RealtimeMember = {
198
+ action: string;
199
+ id: number;
200
+ actor: UserType;
201
+ app: ConversationType;
202
+ member: MemberType;
203
+ };
204
+ declare type RealtimeTyping = {
205
+ action: string;
206
+ id: number;
207
+ actor: MemberTypingType;
208
+ conversation: ConversationType;
209
+ };
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ declare type SpinnerProps = {
3
+ size?: number;
4
+ spin?: boolean;
5
+ overlay?: boolean;
6
+ };
7
+ declare const UISpinner: {
8
+ UI: ({ spin, size, overlay }: SpinnerProps) => JSX.Element;
9
+ };
10
+ export default UISpinner;
@@ -6,15 +6,12 @@ export declare function isWebImage(path: string): boolean;
6
6
  export declare function isBitmap(path: string): boolean;
7
7
  export declare function isMetaFile(path: string): boolean;
8
8
  export declare function isVideo(ext: string): boolean;
9
+ export declare function isMarkdown(ext: string): boolean;
9
10
  export declare function isMarkup(ext: string): boolean;
10
11
  export declare function isCode(ext: string): boolean;
11
12
  export declare function isText(ext: string): boolean;
12
13
  export declare function isOfficeDocument(path: string): boolean;
13
- export declare function canResize(path: string): boolean;
14
- export declare function canConvertToImage(filename: string): boolean;
15
- export declare function canConvertToPdf(filename: string): boolean;
16
14
  export declare function getIcon(name: string, mediaType?: string): {
17
15
  icon: string;
18
16
  color?: string;
19
17
  };
20
- export declare function getPreviewFormat(filename: string): PreviewFormatType;
package/dist/index.d.ts CHANGED
@@ -3,30 +3,37 @@ import * as _microsoft_signalr from '@microsoft/signalr';
3
3
  import React, { FC } from 'react';
4
4
  import { Styles } from 'react-modal';
5
5
 
6
- declare class WeavyClient {
6
+ declare class WeavyClient$1 {
7
7
  url: string;
8
- tokenFactory: () => string | Promise<string>;
9
8
  connection: _microsoft_signalr.HubConnection;
9
+ tokenFactory: (refresh: boolean) => Promise<string>;
10
10
  groups: string[];
11
11
  connectionEvents: any[];
12
12
  isConnectionStarted: any;
13
+ token: string;
14
+ tokenPromise: Promise<string> | null;
13
15
  EVENT_NAMESPACE: string;
14
16
  EVENT_CLOSE: string;
15
17
  EVENT_RECONNECTING: string;
16
18
  EVENT_RECONNECTED: string;
17
19
  constructor(options: WeavyClientOptions);
20
+ get(url: string, retry?: boolean): Promise<Response>;
21
+ post(url: string, method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", body: string | FormData, contentType?: string, retry?: boolean): Promise<Response>;
22
+ getToken(refresh: boolean): Promise<string>;
23
+ tokenFactoryInternal(refresh?: boolean, fromSR?: boolean): Promise<string>;
18
24
  subscribe(group: string, event: string, callback: any): Promise<void>;
19
25
  unsubscribe(group: string, event: string, callback: any): Promise<void>;
26
+ destroy(): void;
20
27
  triggerHandler(name: string, ...data: any): void;
21
28
  }
22
29
 
23
30
  declare const WeavyContext: React.Context<WeavyContextProps>;
24
- declare type Props$2 = {
31
+ declare type WeavyProviderProperties = {
25
32
  children: React.ReactNode;
26
33
  client: WeavyClient;
27
34
  options?: WeavyContextOptions;
28
35
  };
29
- declare const WeavyProvider: ({ children, client, options }: Props$2) => JSX.Element;
36
+ declare const WeavyProvider: ({ children, client, options }: WeavyProviderProperties) => JSX.Element;
30
37
 
31
38
  declare const MessengerContext: React.Context<MessengerContextProps>;
32
39
  declare type Props$1 = {
@@ -48,10 +55,11 @@ interface ConversationProps {
48
55
  declare const _default: React.MemoExoticComponent<({ id, showBackButton }: ConversationProps) => JSX.Element>;
49
56
 
50
57
  interface ChatProps {
51
- id: string;
58
+ uid: string;
59
+ className?: string;
52
60
  }
53
61
 
54
- declare const Chat: ({ id }: ChatProps) => JSX.Element;
62
+ declare const Chat: ({ uid, className }: ChatProps) => JSX.Element;
55
63
 
56
64
  declare const UIButton: {
57
65
  UI: any;
@@ -94,4 +102,4 @@ declare const UIOverlay: {
94
102
  UI: ({ children, className, isOpen, style }: OverlayProps) => JSX.Element;
95
103
  };
96
104
 
97
- export { UIButton as Button, Chat, _default as Conversation, ConversationBadge, ConversationList, UIDropdown as Dropdown, UIIcon as Icon, Messenger, MessengerContext, MessengerProvider, UIOverlay as Overlay, WeavyClient, WeavyContext, WeavyProvider };
105
+ export { UIButton as Button, Chat, _default as Conversation, ConversationBadge, ConversationList, UIDropdown as Dropdown, UIIcon as Icon, Messenger, MessengerContext, MessengerProvider, UIOverlay as Overlay, WeavyClient$1 as WeavyClient, WeavyContext, WeavyProvider };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weavy/uikit-react",
3
- "version": "12.1.0",
3
+ "version": "14.0.0",
4
4
  "author": "Weavy",
5
5
  "description": "React UI-kit for Weavy",
6
6
  "homepage": "https://github.com/weavy/weavy-uikit-react",
@@ -50,7 +50,7 @@
50
50
  "emoji-toolkit": "^6.6.0",
51
51
  "lodash.debounce": "^4.0.8",
52
52
  "lodash.throttle": "^4.1.1",
53
- "pdfjs-dist": "^2.14.305",
53
+ "pdfjs-dist": "^2.16.105",
54
54
  "react-modal": "^3.14.4",
55
55
  "react-query": "^3.34.16"
56
56
  }
package/rollup.config.js CHANGED
@@ -24,7 +24,9 @@ export default [
24
24
  ],
25
25
  plugins: [
26
26
  peerDepsExternal(),
27
- resolve(),
27
+ resolve({
28
+ browser: true
29
+ }),
28
30
  commonjs(),
29
31
  typescript({ tsconfig: "./tsconfig.json" }),
30
32
  terser(),
@@ -2,77 +2,153 @@ import { HubConnectionBuilder, LogLevel } from '@microsoft/signalr';
2
2
 
3
3
  export default class WeavyClient {
4
4
  url;
5
- tokenFactory;
6
5
  connection;
7
- groups: string[];
8
- connectionEvents: any[];
6
+ tokenFactory;
7
+ groups: string[] = [];
8
+ connectionEvents: any[] = [];
9
9
  isConnectionStarted: any;
10
-
10
+ token: string = "";
11
+ tokenPromise: Promise<string> | null;
11
12
  EVENT_NAMESPACE = ".connection";
12
13
  EVENT_CLOSE = "close";
13
14
  EVENT_RECONNECTING = "reconnecting";
14
15
  EVENT_RECONNECTED = "reconnected";
15
16
 
17
+
16
18
  constructor(options: WeavyClientOptions) {
17
19
  this.url = options.url;
18
- this.tokenFactory = options.tokenFactory
19
- this.groups = [];
20
- this.connectionEvents = [];
21
-
20
+ this.tokenFactory = options.tokenFactory;
21
+ this.tokenPromise = null;
22
22
  this.connection = new HubConnectionBuilder()
23
23
  .configureLogging(LogLevel.None)
24
24
  .withUrl(this.url + "/hubs/rtm", {
25
- accessTokenFactory: this.tokenFactory
25
+ accessTokenFactory: () => { return this.tokenFactoryInternal.call(this, true, true) }
26
26
  })
27
27
  .withAutomaticReconnect()
28
28
  .build();
29
-
30
- this.isConnectionStarted = this.connection.start();
29
+
30
+ this.isConnectionStarted = this.connection.start();
31
31
 
32
32
  this.connection.onclose(error => this.triggerHandler(this.EVENT_CLOSE, error));
33
33
  this.connection.onreconnecting(error => this.triggerHandler(this.EVENT_RECONNECTING, error));
34
34
  this.connection.onreconnected(connectionId => this.triggerHandler(this.EVENT_RECONNECTED, connectionId));
35
-
35
+
36
36
  }
37
37
 
38
+ async get(url: string, retry: boolean = true): Promise<Response> {
39
+ //const token = await this.tokenFactoryInternal();
40
+ //console.log("GET:", url, " - t:", token);
41
+ const response = await fetch(this.url + url, {
42
+ headers: {
43
+ "content-type": "application/json",
44
+ "Authorization": "Bearer " + await this.tokenFactoryInternal()
45
+ }
46
+ });
38
47
 
39
- async subscribe(group: string, event: string, callback: any) {
40
- await this.isConnectionStarted;
48
+ if (!response.ok) {
49
+ if ((response.status === 401 || response.status === 403) && retry) {
50
+ await this.tokenFactoryInternal(true);
51
+ return await this.get(url, false);
52
+ }
53
+
54
+ console.error(`Error calling endpoint ${url}`, response)
55
+ }
56
+
57
+ return response;
58
+ }
59
+
60
+ async post(url: string, method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", body: string | FormData, contentType: string = "application/json", retry: boolean = true): Promise<Response> {
61
+ let headers: HeadersInit = {
62
+ "Authorization": "Bearer " + await this.tokenFactoryInternal()
63
+ };
64
+
65
+ if(contentType !== ""){
66
+ headers["content-type"] = contentType
67
+ }
68
+ const response = await fetch(this.url + url, {
69
+ method: method,
70
+ body: body,
71
+ headers: headers
72
+ });
73
+
74
+ if (!response.ok) {
75
+ if ((response.status === 401 || response.status === 403) && retry) {
76
+ await this.tokenFactoryInternal(true);
77
+ return await this.post(url, method, body, contentType, false);
78
+ }
79
+
80
+ console.error(`Error calling endpoint ${url}`, response)
81
+ }
82
+
83
+ return response;
84
+ }
85
+
86
+ async getToken(refresh: boolean) {
87
+ if (!this.token || refresh) {
88
+ this.token = await this.tokenFactory(true);
89
+ }
90
+ return this.token;
91
+ }
92
+
93
+ async tokenFactoryInternal(refresh: boolean = false, fromSR: boolean = false): Promise<string> {
94
+
95
+ if(this.token && !refresh) return this.token;
96
+
97
+ if(!this.tokenPromise){
41
98
 
99
+ this.tokenPromise = this.tokenFactory(refresh);
100
+ let token = await this.tokenPromise;
101
+
102
+ this.tokenPromise = null;
103
+ this.token = token;
104
+ return this.token;
105
+ } else{
106
+ //console.log("Already a promise in action, wait for it to resolve...")
107
+ return this.tokenPromise;
108
+ }
109
+ }
110
+
111
+ async subscribe(group: string, event: string, callback: any) {
112
+ await this.isConnectionStarted;
113
+
42
114
  try {
43
115
  var name = group ? group + ":" + event : event;
44
- await this.connection.invoke("AddToGroup", name);
116
+ await this.connection.invoke("Subscribe", name);
45
117
  this.groups.push(name);
46
118
  this.connection.on(name, callback);
47
- } catch(err: any){
48
- console.warn("Error in AddToGroup:", err)
119
+ } catch (err: any) {
120
+ console.warn("Error in Subscribe:", err)
49
121
  }
50
-
122
+
51
123
  }
52
124
 
53
125
  async unsubscribe(group: string, event: string, callback: any) {
54
126
  await this.isConnectionStarted;
55
127
  var name = group ? group + ":" + event : event;
56
-
128
+
57
129
  // get first occurence of group name and remove it
58
130
  const index = this.groups.findIndex(e => e === name);
59
- if(index !== -1){
131
+ if (index !== -1) {
60
132
  this.groups = this.groups.splice(index, 1);
61
133
 
62
- try {
134
+ try {
63
135
  // if no more groups, remove from server
64
- if(!this.groups.find(e => e === name)){
65
- await this.connection.invoke("RemoveFromGroup", name);
136
+ if (!this.groups.find(e => e === name)) {
137
+ await this.connection.invoke("Unsubscribe", name);
66
138
  }
67
-
68
- } catch(err: any){
69
- console.warn("Error in RemoveFromGroup:", err)
139
+
140
+ } catch (err: any) {
141
+ console.warn("Error in Unsubscribe:", err)
70
142
  }
71
143
  }
72
-
144
+
73
145
  this.connection.off(name, callback);
74
146
  }
75
-
147
+
148
+ destroy(){
149
+ this.connection.stop();
150
+ }
151
+
76
152
  triggerHandler(name: string, ...data: any) {
77
153
  name = name.endsWith(this.EVENT_NAMESPACE) ? name : name + this.EVENT_NAMESPACE;
78
154
  let event = new CustomEvent(name, { cancelable: false });
@@ -88,7 +164,7 @@ export default class WeavyClient {
88
164
  if (name === this.EVENT_RECONNECTED + this.EVENT_NAMESPACE) {
89
165
  // re-add to signalr groups after reconnect
90
166
  for (var i = 0; i < this.groups.length; i++) {
91
- this.connection.invoke("AddToGroup", this.groups[i]);
167
+ this.connection.invoke("Subscribe", this.groups[i]);
92
168
  }
93
169
  }
94
170
  }
@@ -10,19 +10,20 @@ type Props = {
10
10
  name: string,
11
11
  kind: string,
12
12
  size: number,
13
- provider: string
13
+ provider: string,
14
+ onClick?: (e: any) => void
14
15
  }
15
16
 
16
- const Attachment = ({ previewFormat, url, previewUrl, mediaType, name, kind, size, provider }: Props) => {
17
+ const Attachment = ({ previewFormat, url, previewUrl, mediaType, name, kind, size, provider, onClick }: Props) => {
17
18
  let fileSize = size > 0 ? fileSizeAsString(size) : null;
18
19
  let { icon, color } = getIcon(name, mediaType)
19
20
  return (
20
- <a href={previewUrl || url} className={'wy-attachment'} target={"_blank"} title={name}>
21
- <div className={'wy-attachment-icon'} title={kind}><Icon.UI name={icon} color={color} size={2} /></div>
22
- <div className={'wy-attachment-content'}>
23
- <div className={'wy-attachment-title'}>{name}</div>
21
+ <a href={previewUrl || url} className="wy-item wy-item-hover wy-item-lg wy-attachment" target={"_blank"} title={name} onClick={onClick ? (e) => onClick(e) : undefined}>
22
+ <Icon.UI name={icon} color={color} size={2} />
23
+ <div className="wy-item-body wy-attachment-content">
24
+ <div className="wy-item-title wy-attachment-title">{name}</div>
24
25
  {fileSize &&
25
- <div className={'wy-attachment-meta'} title={fileSize}>{fileSize}</div>
26
+ <div className="wy-item-text wy-attachment-meta" title={fileSize}>{fileSize}</div>
26
27
  }
27
28
  </div>
28
29
  </a>