@weavy/uikit-react 12.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 (86) hide show
  1. package/changelog.md +36 -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/PdfViewer.d.ts +3 -1
  8. package/dist/cjs/types/components/Preview.d.ts +8 -10
  9. package/dist/cjs/types/contexts/PreviewContext.d.ts +2 -1
  10. package/dist/cjs/types/contexts/WeavyContext.d.ts +2 -3
  11. package/dist/cjs/types/types/Chat.d.ts +1 -1
  12. package/dist/cjs/types/types/types.d.ts +16 -5
  13. package/dist/cjs/types/ui/Spinner.d.ts +9 -0
  14. package/dist/cjs/types/utils/fileUtilities.d.ts +1 -4
  15. package/dist/css/weavy-chat.css +270 -94
  16. package/dist/css/weavy-messenger.css +274 -96
  17. package/dist/css/weavy.css +274 -96
  18. package/dist/esm/index.js +28 -6
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/types/client/WeavyClient.d.ts +8 -1
  21. package/dist/esm/types/components/Attachment.d.ts +2 -1
  22. package/dist/esm/types/components/Chat.d.ts +1 -1
  23. package/dist/esm/types/components/PdfViewer.d.ts +3 -1
  24. package/dist/esm/types/components/Preview.d.ts +8 -10
  25. package/dist/esm/types/contexts/PreviewContext.d.ts +2 -1
  26. package/dist/esm/types/contexts/WeavyContext.d.ts +2 -3
  27. package/dist/esm/types/types/Chat.d.ts +1 -1
  28. package/dist/esm/types/types/types.d.ts +16 -5
  29. package/dist/esm/types/ui/Spinner.d.ts +9 -0
  30. package/dist/esm/types/utils/fileUtilities.d.ts +1 -4
  31. package/dist/index.d.ts +14 -7
  32. package/package.json +2 -2
  33. package/rollup.config.js +3 -1
  34. package/src/client/WeavyClient.ts +105 -24
  35. package/src/components/Attachment.tsx +8 -7
  36. package/src/components/Chat.tsx +3 -3
  37. package/src/components/Conversation.tsx +3 -3
  38. package/src/components/Message.tsx +1 -1
  39. package/src/components/Messages.tsx +1 -1
  40. package/src/components/PdfViewer.tsx +88 -83
  41. package/src/components/Preview.tsx +115 -54
  42. package/src/components/SearchUsers.tsx +2 -2
  43. package/src/contexts/PreviewContext.tsx +90 -16
  44. package/src/contexts/WeavyContext.tsx +7 -4
  45. package/src/hooks/useBadge.ts +2 -6
  46. package/src/hooks/useChat.ts +3 -14
  47. package/src/hooks/useConversation.ts +1 -7
  48. package/src/hooks/useConversations.ts +1 -7
  49. package/src/hooks/useFileUploader.ts +6 -8
  50. package/src/hooks/useMembers.ts +1 -7
  51. package/src/hooks/useMessages.ts +1 -7
  52. package/src/hooks/useMutateChat.ts +6 -11
  53. package/src/hooks/useMutateConversation.ts +7 -10
  54. package/src/hooks/useMutateConversationName.ts +10 -12
  55. package/src/hooks/useMutateDeleteReaction.ts +3 -8
  56. package/src/hooks/useMutateExternalBlobs.ts +6 -11
  57. package/src/hooks/useMutateMeeting.ts +6 -11
  58. package/src/hooks/useMutateMembers.ts +8 -13
  59. package/src/hooks/useMutateMessage.ts +10 -15
  60. package/src/hooks/useMutatePinned.ts +3 -8
  61. package/src/hooks/useMutateReaction.ts +6 -12
  62. package/src/hooks/useMutateRead.ts +1 -10
  63. package/src/hooks/useMutateRemoveMembers.ts +7 -12
  64. package/src/hooks/useMutateTyping.ts +6 -11
  65. package/src/hooks/useSearchUsers.ts +1 -6
  66. package/src/hooks/useUser.ts +3 -14
  67. package/src/scss/theme/_appbar.scss +4 -2
  68. package/src/scss/theme/_cm-editor.scss +1 -1
  69. package/src/scss/theme/_code-vscode-dark.scss +184 -0
  70. package/src/scss/theme/_code-vscode-light.scss +179 -0
  71. package/src/scss/theme/_code.scss +9 -112
  72. package/src/scss/theme/_files.scss +1 -1
  73. package/src/scss/theme/_message-editor.scss +1 -1
  74. package/src/scss/theme/_overlays.scss +2 -2
  75. package/src/scss/theme/_panels.scss +11 -7
  76. package/src/scss/theme/_preview-code.scss +5 -0
  77. package/src/scss/theme/_preview-embed.scss +3 -3
  78. package/src/scss/theme/_preview-image.scss +1 -1
  79. package/src/scss/theme/_preview-text.scss +1 -1
  80. package/src/scss/theme/_preview.scss +7 -2
  81. package/src/scss/weavy-chat.scss +1 -0
  82. package/src/scss/weavy-messenger.scss +1 -0
  83. package/src/types/Chat.ts +1 -1
  84. package/src/types/types.ts +16 -5
  85. package/src/ui/Spinner.tsx +18 -0
  86. package/src/utils/fileUtilities.ts +11 -125
@@ -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;
@@ -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,3 +1,3 @@
1
1
  export interface ChatProps {
2
- id: string;
2
+ uid: string;
3
3
  }
@@ -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 = {
@@ -114,11 +119,17 @@ declare type AttachmentType = {
114
119
  size: number;
115
120
  provider: string;
116
121
  download_url: string;
117
- preview_url: string;
118
- thumbnail_url: string;
122
+ embed_url: string;
119
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;
120
131
  };
121
- declare type PreviewFormatType = "text" | "code" | "markup" | "image" | "video" | "audio" | "document" | "embed" | "link" | "download" | "none";
132
+ declare type PreviewFormatType = "audio" | "code" | "embed" | "html" | "image" | "pdf" | "text" | "video" | "none";
122
133
  declare type ReactionType = {
123
134
  id: number;
124
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;
@@ -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;