@weavy/uikit-react 11.1.0 → 13.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 (256) hide show
  1. package/.github/workflows/publish.yml +1 -1
  2. package/README.md +3 -4
  3. package/changelog.md +57 -0
  4. package/dist/cjs/index.js +28 -6
  5. package/dist/cjs/index.js.map +1 -1
  6. package/dist/cjs/types/client/WeavyClient.d.ts +8 -1
  7. package/dist/cjs/types/components/Attachment.d.ts +2 -1
  8. package/dist/cjs/types/components/Chat.d.ts +1 -1
  9. package/dist/cjs/types/components/Image.d.ts +2 -0
  10. package/dist/cjs/types/components/PdfViewer.d.ts +8 -0
  11. package/dist/cjs/types/components/Preview.d.ts +56 -0
  12. package/dist/cjs/types/contexts/MessengerContext.d.ts +1 -2
  13. package/dist/cjs/types/contexts/PreviewContext.d.ts +2 -1
  14. package/dist/cjs/types/contexts/WeavyContext.d.ts +2 -3
  15. package/dist/cjs/types/types/Chat.d.ts +1 -1
  16. package/dist/cjs/types/types/Messenger.d.ts +0 -1
  17. package/dist/cjs/types/types/types.d.ts +18 -8
  18. package/dist/cjs/types/ui/Spinner.d.ts +9 -0
  19. package/dist/cjs/types/utils/fileUtilities.d.ts +13 -1
  20. package/dist/css/weavy-chat.css +2860 -0
  21. package/dist/css/weavy-messenger.css +3217 -0
  22. package/dist/css/weavy.css +3217 -0
  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/Image.d.ts +2 -0
  29. package/dist/esm/types/components/PdfViewer.d.ts +8 -0
  30. package/dist/esm/types/components/Preview.d.ts +56 -0
  31. package/dist/esm/types/contexts/MessengerContext.d.ts +1 -2
  32. package/dist/esm/types/contexts/PreviewContext.d.ts +2 -1
  33. package/dist/esm/types/contexts/WeavyContext.d.ts +2 -3
  34. package/dist/esm/types/types/Chat.d.ts +1 -1
  35. package/dist/esm/types/types/Messenger.d.ts +0 -1
  36. package/dist/esm/types/types/types.d.ts +18 -8
  37. package/dist/esm/types/ui/Spinner.d.ts +9 -0
  38. package/dist/esm/types/utils/fileUtilities.d.ts +13 -1
  39. package/dist/index.d.ts +15 -9
  40. package/package.json +14 -4
  41. package/rollup.config.js +3 -3
  42. package/src/client/WeavyClient.ts +105 -24
  43. package/src/components/Attachment.tsx +8 -8
  44. package/src/components/Avatar.tsx +2 -3
  45. package/src/components/Chat.tsx +13 -17
  46. package/src/components/Conversation.tsx +23 -32
  47. package/src/components/ConversationBadge.tsx +1 -2
  48. package/src/components/ConversationForm.tsx +11 -18
  49. package/src/components/ConversationList.tsx +4 -5
  50. package/src/components/ConversationListItem.tsx +11 -13
  51. package/src/components/FileBrowser.tsx +2 -3
  52. package/src/components/Image.tsx +39 -7
  53. package/src/components/MeetingCard.tsx +7 -8
  54. package/src/components/Message.tsx +13 -14
  55. package/src/components/Messages.tsx +7 -8
  56. package/src/components/Messenger.tsx +5 -6
  57. package/src/components/NewConversation.tsx +5 -7
  58. package/src/components/PdfViewer.tsx +276 -0
  59. package/src/components/Presence.tsx +2 -2
  60. package/src/components/Preview.tsx +355 -0
  61. package/src/components/Reactions.tsx +8 -8
  62. package/src/components/SearchUsers.tsx +19 -18
  63. package/src/components/SeenBy.tsx +1 -2
  64. package/src/contexts/MessengerContext.tsx +4 -12
  65. package/src/contexts/PreviewContext.tsx +89 -17
  66. package/src/contexts/WeavyContext.tsx +15 -5
  67. package/src/hooks/useBadge.ts +2 -6
  68. package/src/hooks/useChat.ts +3 -14
  69. package/src/hooks/useConversation.ts +1 -8
  70. package/src/hooks/useConversations.ts +1 -7
  71. package/src/hooks/useFileUploader.ts +6 -8
  72. package/src/hooks/useMembers.ts +1 -7
  73. package/src/hooks/useMessages.ts +1 -7
  74. package/src/hooks/useMutateChat.ts +6 -11
  75. package/src/hooks/useMutateConversation.ts +7 -10
  76. package/src/hooks/useMutateConversationName.ts +10 -12
  77. package/src/hooks/useMutateDeleteReaction.ts +3 -8
  78. package/src/hooks/useMutateExternalBlobs.ts +6 -11
  79. package/src/hooks/useMutateMeeting.ts +6 -11
  80. package/src/hooks/useMutateMembers.ts +8 -13
  81. package/src/hooks/useMutateMessage.ts +10 -15
  82. package/src/hooks/useMutatePinned.ts +3 -8
  83. package/src/hooks/useMutateReaction.ts +6 -12
  84. package/src/hooks/useMutateRead.ts +1 -10
  85. package/src/hooks/useMutateRemoveMembers.ts +7 -12
  86. package/src/hooks/useMutateTyping.ts +6 -11
  87. package/src/hooks/usePresence.ts +4 -5
  88. package/src/hooks/useReactions.ts +0 -1
  89. package/src/hooks/useSearchUsers.ts +1 -6
  90. package/src/hooks/useUser.ts +3 -14
  91. package/src/index.ts +2 -2
  92. package/src/scss/theme/_alert.scss +73 -0
  93. package/src/scss/theme/_appbar.scss +114 -0
  94. package/src/scss/theme/_attachments.scss +74 -0
  95. package/src/scss/theme/_avatar.scss +54 -0
  96. package/src/scss/theme/_badge.scss +47 -0
  97. package/src/scss/theme/_buttons.scss +96 -0
  98. package/src/scss/theme/_card.scss +7 -0
  99. package/src/scss/theme/_checkbox.scss +56 -0
  100. package/src/scss/theme/_cm-editor.scss +42 -0
  101. package/src/scss/theme/_code-vscode-dark.scss +184 -0
  102. package/src/scss/theme/_code-vscode-light.scss +179 -0
  103. package/src/scss/theme/_code.scss +12 -0
  104. package/src/scss/theme/_colors.scss +520 -0
  105. package/src/scss/theme/_config.scss +6 -0
  106. package/src/scss/theme/_content.scss +15 -0
  107. package/src/scss/theme/_conversations.scss +91 -0
  108. package/src/scss/theme/_dropdown.scss +86 -0
  109. package/src/scss/theme/_emoji.scss +5 -0
  110. package/src/scss/theme/_filebrowser.scss +26 -0
  111. package/src/scss/theme/_files.scss +140 -0
  112. package/src/scss/theme/_icons.scss +62 -0
  113. package/src/scss/theme/_image-grid.scss +63 -0
  114. package/src/scss/theme/_inputs.scss +28 -0
  115. package/src/scss/theme/_message-editor.scss +90 -0
  116. package/src/scss/theme/_messages.scss +238 -0
  117. package/src/scss/theme/_nav.scss +52 -0
  118. package/src/scss/theme/_overlays.scss +157 -0
  119. package/src/scss/theme/_pager.scss +19 -0
  120. package/src/scss/theme/_palette.scss +165 -0
  121. package/src/scss/theme/_pane.scss +16 -0
  122. package/src/scss/theme/_panels.scss +141 -0
  123. package/src/scss/theme/_picker-list.scss +37 -0
  124. package/src/scss/theme/_preview-code.scss +5 -0
  125. package/src/scss/theme/_preview-embed.scss +38 -0
  126. package/src/scss/theme/_preview-html.scss +7 -0
  127. package/src/scss/theme/_preview-icon.scss +41 -0
  128. package/src/scss/theme/_preview-image.scss +86 -0
  129. package/src/scss/theme/_preview-media.scss +28 -0
  130. package/src/scss/theme/_preview-pdf.scss +838 -0
  131. package/src/scss/theme/_preview-text.scss +5 -0
  132. package/src/scss/theme/_preview.scss +110 -0
  133. package/src/scss/theme/_reactions.scss +58 -0
  134. package/src/scss/theme/_reboot.scss +41 -0
  135. package/src/scss/theme/_root.scss +2 -0
  136. package/src/scss/theme/_scroll.scss +55 -0
  137. package/src/scss/theme/_search.scss +68 -0
  138. package/src/scss/theme/_spinner.scss +63 -0
  139. package/src/scss/theme/_tables.scss +53 -0
  140. package/src/scss/theme/_toasts.scss +47 -0
  141. package/src/scss/theme/_turbo.scss +17 -0
  142. package/src/scss/theme/_typing.scss +26 -0
  143. package/src/scss/theme/_variables.scss +139 -0
  144. package/src/scss/theme/bootstrap/_accordion.scss +146 -0
  145. package/src/scss/theme/bootstrap/_alert.scss +71 -0
  146. package/src/scss/theme/bootstrap/_badge.scss +38 -0
  147. package/src/scss/theme/bootstrap/_breadcrumb.scss +40 -0
  148. package/src/scss/theme/bootstrap/_button-group.scss +142 -0
  149. package/src/scss/theme/bootstrap/_buttons.scss +186 -0
  150. package/src/scss/theme/bootstrap/_card.scss +234 -0
  151. package/src/scss/theme/bootstrap/_carousel.scss +229 -0
  152. package/src/scss/theme/bootstrap/_close.scss +40 -0
  153. package/src/scss/theme/bootstrap/_containers.scss +41 -0
  154. package/src/scss/theme/bootstrap/_dropdown.scss +248 -0
  155. package/src/scss/theme/bootstrap/_forms.scss +9 -0
  156. package/src/scss/theme/bootstrap/_functions.scss +302 -0
  157. package/src/scss/theme/bootstrap/_grid.scss +33 -0
  158. package/src/scss/theme/bootstrap/_helpers.scss +10 -0
  159. package/src/scss/theme/bootstrap/_images.scss +42 -0
  160. package/src/scss/theme/bootstrap/_list-group.scss +191 -0
  161. package/src/scss/theme/bootstrap/_maps.scss +54 -0
  162. package/src/scss/theme/bootstrap/_mixins.scss +43 -0
  163. package/src/scss/theme/bootstrap/_modal.scss +237 -0
  164. package/src/scss/theme/bootstrap/_nav.scss +172 -0
  165. package/src/scss/theme/bootstrap/_navbar.scss +276 -0
  166. package/src/scss/theme/bootstrap/_offcanvas.scss +143 -0
  167. package/src/scss/theme/bootstrap/_pagination.scss +109 -0
  168. package/src/scss/theme/bootstrap/_placeholders.scss +51 -0
  169. package/src/scss/theme/bootstrap/_popover.scss +196 -0
  170. package/src/scss/theme/bootstrap/_progress.scss +59 -0
  171. package/src/scss/theme/bootstrap/_reboot.scss +610 -0
  172. package/src/scss/theme/bootstrap/_root.scss +73 -0
  173. package/src/scss/theme/bootstrap/_spinners.scss +85 -0
  174. package/src/scss/theme/bootstrap/_tables.scss +164 -0
  175. package/src/scss/theme/bootstrap/_toasts.scss +70 -0
  176. package/src/scss/theme/bootstrap/_tooltip.scss +120 -0
  177. package/src/scss/theme/bootstrap/_transitions.scss +27 -0
  178. package/src/scss/theme/bootstrap/_type.scss +106 -0
  179. package/src/scss/theme/bootstrap/_utilities.scss +647 -0
  180. package/src/scss/theme/bootstrap/_variables.scss +1633 -0
  181. package/src/scss/theme/bootstrap/forms/_floating-labels.scss +74 -0
  182. package/src/scss/theme/bootstrap/forms/_form-check.scss +175 -0
  183. package/src/scss/theme/bootstrap/forms/_form-control.scss +194 -0
  184. package/src/scss/theme/bootstrap/forms/_form-range.scss +91 -0
  185. package/src/scss/theme/bootstrap/forms/_form-select.scss +71 -0
  186. package/src/scss/theme/bootstrap/forms/_form-text.scss +11 -0
  187. package/src/scss/theme/bootstrap/forms/_input-group.scss +129 -0
  188. package/src/scss/theme/bootstrap/forms/_labels.scss +36 -0
  189. package/src/scss/theme/bootstrap/forms/_validation.scss +12 -0
  190. package/src/scss/theme/bootstrap/helpers/_clearfix.scss +3 -0
  191. package/src/scss/theme/bootstrap/helpers/_color-bg.scss +10 -0
  192. package/src/scss/theme/bootstrap/helpers/_colored-links.scss +12 -0
  193. package/src/scss/theme/bootstrap/helpers/_position.scss +36 -0
  194. package/src/scss/theme/bootstrap/helpers/_ratio.scss +26 -0
  195. package/src/scss/theme/bootstrap/helpers/_stacks.scss +15 -0
  196. package/src/scss/theme/bootstrap/helpers/_stretched-link.scss +15 -0
  197. package/src/scss/theme/bootstrap/helpers/_text-truncation.scss +7 -0
  198. package/src/scss/theme/bootstrap/helpers/_visually-hidden.scss +8 -0
  199. package/src/scss/theme/bootstrap/helpers/_vr.scss +8 -0
  200. package/src/scss/theme/bootstrap/mixins/_alert.scss +15 -0
  201. package/src/scss/theme/bootstrap/mixins/_backdrop.scss +14 -0
  202. package/src/scss/theme/bootstrap/mixins/_banner.scss +9 -0
  203. package/src/scss/theme/bootstrap/mixins/_border-radius.scss +78 -0
  204. package/src/scss/theme/bootstrap/mixins/_box-shadow.scss +18 -0
  205. package/src/scss/theme/bootstrap/mixins/_breakpoints.scss +127 -0
  206. package/src/scss/theme/bootstrap/mixins/_buttons.scss +70 -0
  207. package/src/scss/theme/bootstrap/mixins/_caret.scss +64 -0
  208. package/src/scss/theme/bootstrap/mixins/_clearfix.scss +9 -0
  209. package/src/scss/theme/bootstrap/mixins/_color-scheme.scss +7 -0
  210. package/src/scss/theme/bootstrap/mixins/_container.scss +11 -0
  211. package/src/scss/theme/bootstrap/mixins/_deprecate.scss +10 -0
  212. package/src/scss/theme/bootstrap/mixins/_forms.scss +152 -0
  213. package/src/scss/theme/bootstrap/mixins/_gradients.scss +47 -0
  214. package/src/scss/theme/bootstrap/mixins/_grid.scss +151 -0
  215. package/src/scss/theme/bootstrap/mixins/_image.scss +16 -0
  216. package/src/scss/theme/bootstrap/mixins/_list-group.scss +24 -0
  217. package/src/scss/theme/bootstrap/mixins/_lists.scss +7 -0
  218. package/src/scss/theme/bootstrap/mixins/_pagination.scss +10 -0
  219. package/src/scss/theme/bootstrap/mixins/_reset-text.scss +17 -0
  220. package/src/scss/theme/bootstrap/mixins/_resize.scss +6 -0
  221. package/src/scss/theme/bootstrap/mixins/_table-variants.scss +24 -0
  222. package/src/scss/theme/bootstrap/mixins/_text-truncate.scss +8 -0
  223. package/src/scss/theme/bootstrap/mixins/_transition.scss +26 -0
  224. package/src/scss/theme/bootstrap/mixins/_utilities.scss +97 -0
  225. package/src/scss/theme/bootstrap/mixins/_visually-hidden.scss +29 -0
  226. package/src/scss/theme/bootstrap/utilities/_api.scss +47 -0
  227. package/src/scss/theme/bootstrap/vendor/_rfs.scss +354 -0
  228. package/src/scss/theme/bs/_badge.scss +20 -0
  229. package/src/scss/theme/bs/_buttons.scss +185 -0
  230. package/src/scss/theme/bs/_dropdown.scss +86 -0
  231. package/src/scss/theme/bs/_forms.scss +161 -0
  232. package/src/scss/theme/bs/_list-group.scss +73 -0
  233. package/src/scss/theme/bs/_tables.scss +46 -0
  234. package/src/scss/theme/fonts/_fontmapping-roboto.scss +129 -0
  235. package/src/scss/theme/fonts/_fontmapping-segoe-ui.scss +127 -0
  236. package/src/scss/theme/fonts/_index.scss +2 -0
  237. package/src/scss/theme/mixins/_backdrop.scss +13 -0
  238. package/src/scss/theme/mixins/_palette.scss +165 -0
  239. package/src/scss/theme/mixins/_position.scss +33 -0
  240. package/src/scss/theme/mixins/_scrollbar.scss +110 -0
  241. package/src/scss/weavy-chat.scss +32 -0
  242. package/src/scss/weavy-messenger.scss +61 -0
  243. package/src/scss/weavy.scss +2 -0
  244. package/src/types/Chat.ts +1 -1
  245. package/src/types/Messenger.ts +1 -1
  246. package/src/types/types.ts +20 -11
  247. package/src/ui/Button.tsx +3 -4
  248. package/src/ui/Dropdown.tsx +4 -5
  249. package/src/ui/Icon.tsx +75 -39
  250. package/src/ui/Overlay.tsx +2 -3
  251. package/src/ui/Spinner.tsx +18 -0
  252. package/src/utils/fileUtilities.ts +166 -72
  253. package/src/utils/scrollbarDetection.js +48 -0
  254. package/dist/cjs/types/utils/styles.d.ts +0 -17
  255. package/dist/esm/types/utils/styles.d.ts +0 -17
  256. package/src/utils/styles.ts +0 -42
@@ -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 }: ChatProps) => JSX.Element;
4
4
  export default Chat;
@@ -7,6 +7,8 @@ declare type ImageProps = {
7
7
  more?: number;
8
8
  onClick: (e: any) => void;
9
9
  };
10
+ export declare function checkImageLoad(img: HTMLImageElement): void;
11
+ export declare function imageLoaded(event: any): void;
10
12
  export declare const Image: ({ src, previewSrc, width, height, more, onClick }: ImageProps) => JSX.Element;
11
13
  declare type ImageGridProps = {
12
14
  children: React.ReactNode;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ declare type Props = {
3
+ src: string;
4
+ pdfCMapsUrl: string;
5
+ pdfWorkerUrl: string;
6
+ };
7
+ declare const PdfViewer: ({ src, pdfCMapsUrl, pdfWorkerUrl }: Props) => JSX.Element;
8
+ export default PdfViewer;
@@ -0,0 +1,56 @@
1
+ import React from "react";
2
+ declare type ImageProps = {
3
+ src: string;
4
+ width?: number;
5
+ height?: number;
6
+ };
7
+ export declare const PreviewImage: ({ src, width, height }: ImageProps) => JSX.Element;
8
+ declare type DocumentProps = {
9
+ src: string;
10
+ client: any;
11
+ };
12
+ export declare const PreviewDocument: ({ src, client }: DocumentProps) => JSX.Element;
13
+ declare type MediaProps = {
14
+ format: string;
15
+ src: string;
16
+ name: string;
17
+ mediaType?: string;
18
+ };
19
+ export declare const PreviewMedia: ({ format, src, name, mediaType }: MediaProps) => JSX.Element;
20
+ declare type TextProps = {
21
+ src: string;
22
+ html?: boolean;
23
+ code?: boolean;
24
+ };
25
+ export declare const PreviewText: ({ src, html, code }: TextProps) => JSX.Element;
26
+ declare type EmbedProps = {
27
+ src: string;
28
+ name: string;
29
+ icon: string;
30
+ provider?: string;
31
+ };
32
+ export declare const PreviewEmbed: ({ src, name, icon, provider }: EmbedProps) => JSX.Element;
33
+ declare type IconProps = {
34
+ children?: React.ReactNode;
35
+ src: string;
36
+ icon: string;
37
+ name: string;
38
+ provider?: string;
39
+ download?: boolean;
40
+ className?: string;
41
+ };
42
+ export declare const PreviewIcon: ({ children, src, icon, name, provider, download, className }: IconProps) => JSX.Element;
43
+ declare type PreviewProps = {
44
+ client: any;
45
+ src: string;
46
+ link?: string;
47
+ format: PreviewFormatType;
48
+ name: string;
49
+ icon: string;
50
+ width?: number;
51
+ height?: number;
52
+ mediaType?: string;
53
+ provider?: string;
54
+ };
55
+ export declare const Preview: ({ client, src, link, format, name, icon, width, height, mediaType, provider }: PreviewProps) => JSX.Element;
56
+ export default Preview;
@@ -2,7 +2,6 @@ import React from "react";
2
2
  export declare const MessengerContext: React.Context<MessengerContextProps>;
3
3
  declare type Props = {
4
4
  children: React.ReactNode;
5
- options?: MessengerContextOptions;
6
5
  };
7
- declare const MessengerProvider: ({ children, options }: Props) => JSX.Element;
6
+ declare const MessengerProvider: ({ children }: Props) => JSX.Element;
8
7
  export default MessengerProvider;
@@ -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,3 +1,3 @@
1
1
  export interface ChatProps {
2
- id: string;
2
+ uid: string;
3
3
  }
@@ -1,3 +1,2 @@
1
1
  export interface Messenger {
2
- options?: MessengerContextOptions;
3
2
  }
@@ -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;
@@ -17,19 +20,19 @@ declare type WeavyContextOptions = {
17
20
  zoomAuthenticationUrl?: string;
18
21
  teamsAuthenticationUrl?: string;
19
22
  enableCloudFiles?: boolean;
23
+ enableScrollbarDetection?: boolean;
20
24
  filebrowserUrl?: string;
25
+ pdfWorkerUrl?: string;
26
+ pdfCMapsUrl?: string;
27
+ reactions?: string[];
21
28
  };
22
29
  declare type MessengerContextProps = {
23
- options?: MessengerContextOptions;
24
30
  selectedConversationId: null | number;
25
31
  setSelectedConversationId: Function;
26
32
  };
27
33
  declare type UserContextProps = {
28
34
  user: UserType;
29
35
  };
30
- declare type MessengerContextOptions = {
31
- reactions?: string[];
32
- };
33
36
  declare type PreviewContextProps = {
34
37
  openPreview: Function;
35
38
  closePreview: Function;
@@ -116,10 +119,17 @@ declare type AttachmentType = {
116
119
  size: number;
117
120
  provider: string;
118
121
  download_url: string;
119
- preview_url: string;
120
- thumbnail_url: string;
122
+ embed_url: string;
121
123
  external_url: string;
124
+ thumbnail_url: string;
125
+ preview_format: PreviewFormatType;
126
+ application_url: string;
127
+ preview_url: string;
128
+ created_at: string;
129
+ created_by?: UserType;
130
+ createdById?: number;
122
131
  };
132
+ declare type PreviewFormatType = "audio" | "code" | "embed" | "html" | "image" | "pdf" | "text" | "video" | "none";
123
133
  declare type ReactionType = {
124
134
  id: number;
125
135
  parent: MessageType;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ declare type SpinnerProps = {
3
+ size?: number;
4
+ spin?: boolean;
5
+ };
6
+ declare const UISpinner: {
7
+ UI: ({ spin, size }: SpinnerProps) => JSX.Element;
8
+ };
9
+ export default UISpinner;
@@ -1,5 +1,17 @@
1
1
  export declare const fileSizeAsString: (size: number) => string;
2
- export declare const getIcon: (name: string, mediaType?: string) => {
2
+ export declare function getExtension(name: string): string;
3
+ export declare function isAudio(ext: string): boolean;
4
+ export declare function isImage(ext: string): boolean;
5
+ export declare function isWebImage(path: string): boolean;
6
+ export declare function isBitmap(path: string): boolean;
7
+ export declare function isMetaFile(path: string): boolean;
8
+ export declare function isVideo(ext: string): boolean;
9
+ export declare function isMarkdown(ext: string): boolean;
10
+ export declare function isMarkup(ext: string): boolean;
11
+ export declare function isCode(ext: string): boolean;
12
+ export declare function isText(ext: string): boolean;
13
+ export declare function isOfficeDocument(path: string): boolean;
14
+ export declare function getIcon(name: string, mediaType?: string): {
3
15
  icon: string;
4
16
  color?: string;
5
17
  };
package/dist/index.d.ts CHANGED
@@ -3,37 +3,43 @@ 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 = {
33
40
  children: React.ReactNode;
34
- options?: MessengerContextOptions;
35
41
  };
36
- declare const MessengerProvider: ({ children, options }: Props$1) => JSX.Element;
42
+ declare const MessengerProvider: ({ children }: Props$1) => JSX.Element;
37
43
 
38
44
  declare const Messenger: FC<Messenger>;
39
45
 
@@ -49,10 +55,10 @@ interface ConversationProps {
49
55
  declare const _default: React.MemoExoticComponent<({ id, showBackButton }: ConversationProps) => JSX.Element>;
50
56
 
51
57
  interface ChatProps {
52
- id: string;
58
+ uid: string;
53
59
  }
54
60
 
55
- declare const Chat: ({ id }: ChatProps) => JSX.Element;
61
+ declare const Chat: ({ uid }: ChatProps) => JSX.Element;
56
62
 
57
63
  declare const UIButton: {
58
64
  UI: any;
@@ -95,4 +101,4 @@ declare const UIOverlay: {
95
101
  UI: ({ children, className, isOpen, style }: OverlayProps) => JSX.Element;
96
102
  };
97
103
 
98
- 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 };
104
+ 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": "11.1.0",
3
+ "version": "13.0.0",
4
4
  "author": "Weavy",
5
5
  "description": "React UI-kit for Weavy",
6
6
  "homepage": "https://github.com/weavy/weavy-uikit-react",
@@ -8,6 +8,7 @@
8
8
  "main": "dist/cjs/index.js",
9
9
  "module": "dist/esm/index.js",
10
10
  "types": "./dist/cjs/types/index.d.ts",
11
+ "style": "dist/css/weavy-react.css",
11
12
  "devDependencies": {
12
13
  "@rollup/plugin-commonjs": "^22.0.0",
13
14
  "@rollup/plugin-node-resolve": "^13.1.3",
@@ -17,11 +18,13 @@
17
18
  "@types/react": "^18.0.8",
18
19
  "@types/react-dom": "^18.0.3",
19
20
  "@types/react-modal": "^3.13.1",
21
+ "npm-run-all": "^4.1.5",
22
+ "rimraf": "^3.0.2",
20
23
  "rollup": "^2.72.0",
21
- "rollup-plugin-delete": "^2.0.0",
22
24
  "rollup-plugin-dts": "^4.2.1",
23
25
  "rollup-plugin-peer-deps-external": "^2.2.4",
24
26
  "rollup-plugin-terser": "^7.0.2",
27
+ "sass": "^1.53.0",
25
28
  "tslib": "^2.4.0",
26
29
  "typescript": "^4.6.4"
27
30
  },
@@ -30,10 +33,16 @@
30
33
  "react-dom": "^18.1.0"
31
34
  },
32
35
  "scripts": {
33
- "build": "rollup -c",
34
- "watch": "rollup -c --watch"
36
+ "clean": "rimraf dist/*",
37
+ "build": "npm-run-all clean --parallel css js",
38
+ "css": "sass src/scss:dist/css --no-source-map",
39
+ "js": "rollup -c",
40
+ "watch": "npm-run-all clean --parallel watch-css watch-js",
41
+ "watch-css": "sass src/scss:dist/css --watch",
42
+ "watch-js": "rollup -c --watch"
35
43
  },
36
44
  "dependencies": {
45
+ "@mdi/js": "^6.9.96",
37
46
  "@mdi/react": "^1.6.0",
38
47
  "@microsoft/signalr": "^6.0.3",
39
48
  "classnames": "^2.3.1",
@@ -41,6 +50,7 @@
41
50
  "emoji-toolkit": "^6.6.0",
42
51
  "lodash.debounce": "^4.0.8",
43
52
  "lodash.throttle": "^4.1.1",
53
+ "pdfjs-dist": "^2.15.349",
44
54
  "react-modal": "^3.14.4",
45
55
  "react-query": "^3.34.16"
46
56
  }
package/rollup.config.js CHANGED
@@ -4,7 +4,6 @@ import typescript from "@rollup/plugin-typescript";
4
4
  import dts from "rollup-plugin-dts";
5
5
  import { terser } from "rollup-plugin-terser";
6
6
  import peerDepsExternal from 'rollup-plugin-peer-deps-external';
7
- import del from 'rollup-plugin-delete';
8
7
 
9
8
  const packageJson = require("./package.json");
10
9
 
@@ -24,9 +23,10 @@ export default [
24
23
  },
25
24
  ],
26
25
  plugins: [
27
- del({ targets: 'dist/*' }),
28
26
  peerDepsExternal(),
29
- resolve(),
27
+ resolve({
28
+ browser: true
29
+ }),
30
30
  commonjs(),
31
31
  typescript({ tsconfig: "./tsconfig.json" }),
32
32
  terser(),
@@ -2,77 +2,158 @@ 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
+ }
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
+ });
47
+
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;
36
58
  }
37
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
+ }
38
79
 
39
- async subscribe(group: string, event: string, callback: any) {
80
+ console.error(`Error calling endpoint ${url}`, response)
81
+ }
82
+
83
+ return response;
84
+ }
85
+
86
+ async getToken(refresh: boolean) {
87
+ console.log("Refresh, ", refresh)
88
+ if (!this.token || refresh) {
89
+ console.log("Getting new token...")
90
+ this.token = await this.tokenFactory(true);
91
+ //return await this.tokenFactory(refresh);
92
+ }
93
+ //this.tokenPromise = null;
94
+ console.log("Resolve new token...")
95
+ return this.token;
96
+ }
97
+
98
+ async tokenFactoryInternal(refresh: boolean = false, fromSR: boolean = false): Promise<string> {
99
+ //console.log("Get token with refresh: ", refresh, fromSR)
100
+ if(this.token && !refresh) return this.token;
101
+
102
+ if(!this.tokenPromise){
103
+ //console.log("No ongoing promise, create new one. Refresh: ", refresh)
104
+ this.tokenPromise = this.tokenFactory(refresh);
105
+ let token = await this.tokenPromise;
106
+ //console.log("Got token: ", token)
107
+ this.tokenPromise = null;
108
+ this.token = token;
109
+ return this.token;
110
+ } else{
111
+ //console.log("Already a promise in action, wait for it to resolve...")
112
+ return this.tokenPromise;
113
+ }
114
+ }
115
+
116
+ async subscribe(group: string, event: string, callback: any) {
40
117
  await this.isConnectionStarted;
41
-
118
+
42
119
  try {
43
120
  var name = group ? group + ":" + event : event;
44
121
  await this.connection.invoke("AddToGroup", name);
45
122
  this.groups.push(name);
46
123
  this.connection.on(name, callback);
47
- } catch(err: any){
124
+ } catch (err: any) {
48
125
  console.warn("Error in AddToGroup:", err)
49
126
  }
50
-
127
+
51
128
  }
52
129
 
53
130
  async unsubscribe(group: string, event: string, callback: any) {
54
131
  await this.isConnectionStarted;
55
132
  var name = group ? group + ":" + event : event;
56
-
133
+
57
134
  // get first occurence of group name and remove it
58
135
  const index = this.groups.findIndex(e => e === name);
59
- if(index !== -1){
136
+ if (index !== -1) {
60
137
  this.groups = this.groups.splice(index, 1);
61
138
 
62
- try {
139
+ try {
63
140
  // if no more groups, remove from server
64
- if(!this.groups.find(e => e === name)){
141
+ if (!this.groups.find(e => e === name)) {
65
142
  await this.connection.invoke("RemoveFromGroup", name);
66
143
  }
67
-
68
- } catch(err: any){
144
+
145
+ } catch (err: any) {
69
146
  console.warn("Error in RemoveFromGroup:", err)
70
147
  }
71
148
  }
72
-
149
+
73
150
  this.connection.off(name, callback);
74
151
  }
75
-
152
+
153
+ destroy(){
154
+ this.connection.stop();
155
+ }
156
+
76
157
  triggerHandler(name: string, ...data: any) {
77
158
  name = name.endsWith(this.EVENT_NAMESPACE) ? name : name + this.EVENT_NAMESPACE;
78
159
  let event = new CustomEvent(name, { cancelable: false });
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import Icon from "../ui/Icon";
3
3
  import { fileSizeAsString, getIcon } from "../utils/fileUtilities";
4
- import { prefix as wy } from "../utils/styles";
5
4
 
6
5
  type Props = {
7
6
  previewFormat: string,
@@ -11,19 +10,20 @@ type Props = {
11
10
  name: string,
12
11
  kind: string,
13
12
  size: number,
14
- provider: string
13
+ provider: string,
14
+ onClick?: (e: any) => void
15
15
  }
16
16
 
17
- const Attachment = ({ previewFormat, url, previewUrl, mediaType, name, kind, size, provider }: Props) => {
17
+ const Attachment = ({ previewFormat, url, previewUrl, mediaType, name, kind, size, provider, onClick }: Props) => {
18
18
  let fileSize = size > 0 ? fileSizeAsString(size) : null;
19
19
  let { icon, color } = getIcon(name, mediaType)
20
20
  return (
21
- <a href={previewUrl || url} className={wy('attachment')} target={"_blank"} title={name}>
22
- <div className={wy('attachment-icon')} title={kind}><Icon.UI name={icon} color={color} size={2} /></div>
23
- <div className={wy('attachment-content')}>
24
- <div className={wy('attachment-title')}>{name}</div>
21
+ <a href={previewUrl || url} className="wy-attachment" target={"_blank"} title={name} onClick={onClick ? (e) => onClick(e) : undefined}>
22
+ <div className="wy-attachment-icon" title={kind}><Icon.UI name={icon} color={color} size={2} /></div>
23
+ <div className="wy-attachment-content">
24
+ <div className="wy-attachment-title">{name}</div>
25
25
  {fileSize &&
26
- <div className={wy('attachment-meta')} title={fileSize}>{fileSize}</div>
26
+ <div className="wy-attachment-meta" title={fileSize}>{fileSize}</div>
27
27
  }
28
28
  </div>
29
29
  </a>
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import classNames from 'classnames';
3
3
  import Presence from "./Presence";
4
- import { prefix as wy } from "../utils/styles";
5
4
 
6
5
  type Props = {
7
6
  id?: number,
@@ -14,8 +13,8 @@ type Props = {
14
13
 
15
14
  const Avatar = ({ id, src, name, presence, size = 48, className }: Props) => {
16
15
  return (
17
- <div className={classNames(wy('avatar-presence'), className)}>
18
- <img alt="" title={name} className={wy('avatar')} height={size} width={size} src={src} />
16
+ <div className={classNames('wy-avatar-presence', className)}>
17
+ <img alt="" title={name} className="wy-avatar" height={size} width={size} src={src} />
19
18
  {presence && id &&
20
19
  <Presence id={id} status={presence} />
21
20
  }