@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
@@ -104,9 +104,9 @@
104
104
  }
105
105
 
106
106
  &.wy-open[data-title]::before {
107
- background: rgba($dark, $opacity-backdrop);
107
+ background-color: rgba($dark, $opacity-backdrop);
108
108
  color: $navbar-dark-color;
109
- border-bottom: $border-width #000 solid;
109
+ box-shadow: rgba($gray-800, $opacity-backdrop) 0px -1px 0px 0px inset
110
110
  }
111
111
  }
112
112
 
@@ -25,8 +25,8 @@
25
25
  flex-direction: column;
26
26
 
27
27
  .wy-controls {
28
- top: .5rem;
29
- left: .5rem;
28
+ top: .75rem;
29
+ left: .75rem;
30
30
  min-width: 2rem;
31
31
  width: auto;
32
32
  display: flex;
@@ -65,20 +65,24 @@
65
65
  top: 0;
66
66
  left: 0;
67
67
  right: 0;
68
- height: ($appbar-height - .0625rem);
68
+ height: $appbar-height;
69
+ padding: $navbar-padding-y $navbar-padding-x;
69
70
  opacity: 0;
70
71
  pointer-events: none;
71
72
  display: flex;
72
73
  align-items: center;
73
74
  justify-content: center;
74
- background-color: rgba($gray-50, $opacity-backdrop);
75
- color: $navbar-light-color;
76
- border-bottom: $border-width solid $border-color;
77
75
  transition: opacity .1s .2s step-end;
78
- font-family: $font-family-base;
76
+ font-family: var(--#{$prefix}font-sans-serif, #{$font-family-sans-serif});
79
77
  line-height: $line-height-base;
80
78
  font-weight: $font-weight-base;
81
79
 
80
+ background-color: rgba($gray-50, $opacity-backdrop);
81
+ color: $navbar-light-color;
82
+ //border-bottom: $border-width solid rgba($gray-200, $opacity-backdrop);
83
+ box-shadow: rgba($gray-200, $opacity-backdrop) 0px -1px 0px 0px inset;
84
+
85
+
82
86
  @include backdrop.filter;
83
87
  }
84
88
 
@@ -0,0 +1,5 @@
1
+ .wy-content-code {
2
+ align-self: flex-start;
3
+ width: 100%;
4
+ padding: 1rem 3rem;
5
+ }
@@ -2,14 +2,14 @@
2
2
 
3
3
  // Embedded iframes
4
4
 
5
- .wy-content-iframe, [data-controller~="embed"] {
5
+ .wy-content-iframe {
6
6
  border: 0;
7
7
  display: block;
8
8
  width: 100%;
9
9
  height: 100%;
10
10
  flex: 1 1 100%;
11
11
 
12
- &:not(.wy-loading):not([data-controller~="embed"]), &[data-controller~="embed"].wy-loaded {
12
+ &.wy-loaded {
13
13
  background: $white;
14
14
 
15
15
  ~ .wy-content-iframe-fallback, ~ .wy-spinner {
@@ -17,7 +17,7 @@
17
17
  }
18
18
  }
19
19
 
20
- &.wy-loading:not(.wy-loaded), &[data-controller~="embed"]:not(.wy-loaded) {
20
+ &.wy-loading:not(.wy-loaded) {
21
21
  position: absolute;
22
22
  visibility: hidden;
23
23
  z-index: -1;
@@ -18,7 +18,7 @@
18
18
  height: 100%;
19
19
  width: 100%;
20
20
  // Similar to object-fit: contain; but works for divs. Must subtract margins.
21
- --max-width: #{'min(calc((100vh - 3rem - 1px) * (var(--width) / var(--height))), calc(var(--width) * 1px), 100%)'};
21
+ --max-width: #{'min(calc((100vh - 3rem) * (var(--width) / var(--height))), calc(var(--width) * 1px), 100%)'};
22
22
  --max-height: #{'min(calc(100vw * (var(--height) / var(--width))), calc(var(--height) * 1px), 100%)'};
23
23
  /* // With sidebar
24
24
  body.controller-content & {
@@ -2,4 +2,4 @@
2
2
  .wy-content-text {
3
3
  word-break: break-word;
4
4
  white-space: pre-wrap;
5
- }
5
+ }
@@ -8,6 +8,11 @@
8
8
  justify-content: center;
9
9
  height: calc(100% - $appbar-height - $border-width);
10
10
  position: relative;
11
+ background-color: $body-bg;
12
+
13
+ .wy-dark &, &.wy-dark {
14
+ background-color: $dark;
15
+ }
11
16
  }
12
17
 
13
18
  .wy-nav-prev, .wy-nav-next {
@@ -43,7 +48,7 @@
43
48
  @include media-breakpoint-up(md) {
44
49
  padding: 3rem 4rem;
45
50
  margin: 2rem 3.5rem;
46
- border-radius: $border-radius-sm;
51
+ border-radius: .125rem;
47
52
  box-shadow: $box-shadow-sm;
48
53
  width: 120ch;
49
54
  min-height: 170ch;
@@ -82,7 +87,7 @@
82
87
  @include backdrop.filter;
83
88
 
84
89
  // dark theme
85
- .wy-dark &, &.wy-dark {
90
+ .wy-dark & {
86
91
  background-color: rgba($dark, $opacity-backdrop);
87
92
  color: $navbar-dark-color;
88
93
 
@@ -18,6 +18,7 @@
18
18
  @use "theme/panels";
19
19
  @use "theme/picker-list";
20
20
  @use "theme/preview";
21
+ @use "theme/preview-code";
21
22
  @use "theme/preview-embed";
22
23
  @use "theme/preview-html";
23
24
  @use "theme/preview-icon";
@@ -24,6 +24,7 @@
24
24
  @use "theme/panels";
25
25
  @use "theme/picker-list";
26
26
  @use "theme/preview";
27
+ @use "theme/preview-code";
27
28
  @use "theme/preview-embed";
28
29
  @use "theme/preview-html";
29
30
  @use "theme/preview-icon";
package/src/types/Chat.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export interface ChatProps {
2
- id: string
2
+ uid: string
3
3
  }
@@ -1,13 +1,16 @@
1
1
  interface WeavyClient {
2
2
  url: string,
3
- tokenFactory: (() => string | Promise<string>),
3
+ tokenFactoryInternal: () => Promise<string>,
4
4
  subscribe: Function,
5
5
  unsubscribe: Function,
6
+ destroy: Function,
7
+ get: (url: string, retry?: boolean) => Promise<Response>,
8
+ post: (url: string, method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", body: string | FormData, contentType?: string, retry?: boolean) => Promise<Response>
6
9
  }
7
10
 
8
11
  type WeavyClientOptions = {
9
12
  url: string,
10
- tokenFactory: (() => string | Promise<string>)
13
+ tokenFactory: (refresh: boolean) => Promise<string>
11
14
  }
12
15
 
13
16
  type WeavyContextProps = {
@@ -21,6 +24,8 @@ type WeavyContextOptions = {
21
24
  enableCloudFiles?: boolean,
22
25
  enableScrollbarDetection?: boolean,
23
26
  filebrowserUrl?: string,
27
+ pdfWorkerUrl?: string,
28
+ pdfCMapsUrl?: string,
24
29
  reactions?: string[]
25
30
  }
26
31
 
@@ -132,12 +137,18 @@ type AttachmentType = {
132
137
  size: number,
133
138
  provider: string,
134
139
  download_url: string,
135
- preview_url: string,
140
+ embed_url: string,
141
+ external_url: string,
136
142
  thumbnail_url: string,
137
- external_url: string
143
+ preview_format: PreviewFormatType,
144
+ application_url: string,
145
+ preview_url: string,
146
+ created_at: string,
147
+ created_by?: UserType,
148
+ createdById?: number
138
149
  }
139
150
 
140
- type PreviewFormatType = "text"|"code"|"markup"|"image"|"video"|"audio"|"document"|"embed"|"link"|"download"|"none";
151
+ type PreviewFormatType = "audio"|"code"|"embed"|"html"|"image"|"pdf"|"text"|"video"|"none";
141
152
 
142
153
  type ReactionType = {
143
154
  id: number,
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+
4
+ type SpinnerProps = {
5
+ size?: number,
6
+ spin?: boolean,
7
+ }
8
+
9
+ const SpinnerImpl = ({ spin = true, size = 24 }: SpinnerProps) => {
10
+
11
+ return (
12
+ <svg className={classNames("wy-spinner", {"wy-spin" : spin })} width={size} height={size} viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle fill="none" cx="12" cy="12" r="11" stroke-linecap="butt" stroke-width="2" /></svg>
13
+ )
14
+ }
15
+
16
+ // Export as replacable UI component
17
+ const UISpinner = { UI: SpinnerImpl };
18
+ export default UISpinner;
@@ -144,6 +144,16 @@ export function isVideo (ext: string) {
144
144
  }
145
145
  }
146
146
 
147
+ export function isMarkdown (ext: string) {
148
+ switch (ext) {
149
+ case ".markdown":
150
+ case ".md":
151
+ return true;
152
+ default:
153
+ return false;
154
+ }
155
+ }
156
+
147
157
  export function isMarkup (ext: string) {
148
158
  switch (ext) {
149
159
  case ".htm":
@@ -192,10 +202,6 @@ export function isCode (ext: string) {
192
202
  case ".lst":
193
203
  case ".m":
194
204
  case ".make":
195
- case ".markdown":
196
- case ".md":
197
- case ".mdown":
198
- case ".mkdn":
199
205
  case ".ml":
200
206
  case ".mm":
201
207
  case ".out":
@@ -228,7 +234,7 @@ export function isCode (ext: string) {
228
234
  }
229
235
 
230
236
  export function isText (ext: string) {
231
- if (isCode(ext)) {
237
+ if (isCode(ext) || isMarkdown(ext)) {
232
238
  return true;
233
239
  }
234
240
  switch (ext) {
@@ -261,99 +267,6 @@ export function isOfficeDocument(path: string) {
261
267
  }
262
268
  }
263
269
 
264
- export function canResize(path:string) {
265
- return isBitmap(path) || isMetaFile(path);
266
- }
267
-
268
- export function canConvertToImage (filename: string) {
269
- var ext = getExtension(filename);
270
- if (canResize(ext) || isText(ext)) {
271
- return true;
272
- }
273
- switch (ext) {
274
- case ".ai":
275
- case ".csv":
276
- case ".doc":
277
- case ".docm":
278
- case ".docx":
279
- case ".dot":
280
- case ".dotm":
281
- case ".dotx":
282
- case ".eml":
283
- case ".eps":
284
- case ".msg":
285
- case ".odp":
286
- case ".ods":
287
- case ".odt":
288
- case ".ott":
289
- case ".pdf":
290
- case ".potm":
291
- case ".potx":
292
- case ".ppt":
293
- case ".pptx":
294
- case ".pps":
295
- case ".ppsx":
296
- case ".pptm":
297
- case ".ppsm":
298
- case ".psd":
299
- case ".rtf":
300
- case ".svg":
301
- case ".xls":
302
- case ".xlsb":
303
- case ".xlsm":
304
- case ".xlsx":
305
- case ".xltm":
306
- case ".xltx":
307
- case ".webp":
308
- return true;
309
- default:
310
- return false;
311
- }
312
- }
313
-
314
- export function canConvertToPdf (filename: string) {
315
- var ext = getExtension(filename);
316
- switch (ext) {
317
- case ".ai":
318
- case ".doc":
319
- case ".docm":
320
- case ".docx":
321
- case ".dot":
322
- case ".dotm":
323
- case ".dotx":
324
- case ".eml":
325
- case ".html":
326
- case ".mhtml":
327
- case ".msg":
328
- case ".odt":
329
- case ".ott":
330
- case ".pdf":
331
- case ".rtf":
332
- case ".txt":
333
- case ".xml":
334
- case ".xls":
335
- case ".xlsb":
336
- case ".xlsm":
337
- case ".xlsx":
338
- case ".xltm":
339
- case ".xltx":
340
- case ".ods":
341
- case ".csv":
342
- case ".ppt":
343
- case ".pptx":
344
- case ".pps":
345
- case ".ppsx":
346
- case ".pptm":
347
- case ".ppsm":
348
- case ".potx":
349
- case ".potm":
350
- case ".odp":
351
- return true;
352
- default:
353
- return false;
354
- }
355
- }
356
-
357
270
  export function getIcon (name: string, mediaType?: string): { icon: string, color?: string } {
358
271
  var ext = getExtension(name);
359
272
 
@@ -408,31 +321,4 @@ export function getIcon (name: string, mediaType?: string): { icon: string, colo
408
321
 
409
322
  // fallback
410
323
  return { icon: "file" };
411
- }
412
-
413
- export function getPreviewFormat(filename:string): PreviewFormatType {
414
- var ext = getExtension(filename);
415
- if (isCode(ext)) {
416
- //return "code";
417
- }
418
- if (isText(ext)) {
419
- return "text";
420
- }
421
- if (isWebImage(ext)) {
422
- return "image";
423
- }
424
- if (isVideo(ext)) {
425
- return "video";
426
- }
427
- if (isAudio(ext)) {
428
- return "audio";
429
- }
430
- if (canConvertToPdf(ext)) {
431
- return "document";
432
- }
433
- if (canConvertToImage(ext)) {
434
- return "image";
435
- }
436
-
437
- return "none";
438
324
  }