@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.
- package/changelog.md +36 -0
- package/dist/cjs/index.js +28 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/client/WeavyClient.d.ts +8 -1
- package/dist/cjs/types/components/Attachment.d.ts +2 -1
- package/dist/cjs/types/components/Chat.d.ts +1 -1
- package/dist/cjs/types/components/PdfViewer.d.ts +3 -1
- package/dist/cjs/types/components/Preview.d.ts +8 -10
- package/dist/cjs/types/contexts/PreviewContext.d.ts +2 -1
- package/dist/cjs/types/contexts/WeavyContext.d.ts +2 -3
- package/dist/cjs/types/types/Chat.d.ts +1 -1
- package/dist/cjs/types/types/types.d.ts +16 -5
- package/dist/cjs/types/ui/Spinner.d.ts +9 -0
- package/dist/cjs/types/utils/fileUtilities.d.ts +1 -4
- package/dist/css/weavy-chat.css +270 -94
- package/dist/css/weavy-messenger.css +274 -96
- package/dist/css/weavy.css +274 -96
- package/dist/esm/index.js +28 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/client/WeavyClient.d.ts +8 -1
- package/dist/esm/types/components/Attachment.d.ts +2 -1
- package/dist/esm/types/components/Chat.d.ts +1 -1
- package/dist/esm/types/components/PdfViewer.d.ts +3 -1
- package/dist/esm/types/components/Preview.d.ts +8 -10
- package/dist/esm/types/contexts/PreviewContext.d.ts +2 -1
- package/dist/esm/types/contexts/WeavyContext.d.ts +2 -3
- package/dist/esm/types/types/Chat.d.ts +1 -1
- package/dist/esm/types/types/types.d.ts +16 -5
- package/dist/esm/types/ui/Spinner.d.ts +9 -0
- package/dist/esm/types/utils/fileUtilities.d.ts +1 -4
- package/dist/index.d.ts +14 -7
- package/package.json +2 -2
- package/rollup.config.js +3 -1
- package/src/client/WeavyClient.ts +105 -24
- package/src/components/Attachment.tsx +8 -7
- package/src/components/Chat.tsx +3 -3
- package/src/components/Conversation.tsx +3 -3
- package/src/components/Message.tsx +1 -1
- package/src/components/Messages.tsx +1 -1
- package/src/components/PdfViewer.tsx +88 -83
- package/src/components/Preview.tsx +115 -54
- package/src/components/SearchUsers.tsx +2 -2
- package/src/contexts/PreviewContext.tsx +90 -16
- package/src/contexts/WeavyContext.tsx +7 -4
- package/src/hooks/useBadge.ts +2 -6
- package/src/hooks/useChat.ts +3 -14
- package/src/hooks/useConversation.ts +1 -7
- package/src/hooks/useConversations.ts +1 -7
- package/src/hooks/useFileUploader.ts +6 -8
- package/src/hooks/useMembers.ts +1 -7
- package/src/hooks/useMessages.ts +1 -7
- package/src/hooks/useMutateChat.ts +6 -11
- package/src/hooks/useMutateConversation.ts +7 -10
- package/src/hooks/useMutateConversationName.ts +10 -12
- package/src/hooks/useMutateDeleteReaction.ts +3 -8
- package/src/hooks/useMutateExternalBlobs.ts +6 -11
- package/src/hooks/useMutateMeeting.ts +6 -11
- package/src/hooks/useMutateMembers.ts +8 -13
- package/src/hooks/useMutateMessage.ts +10 -15
- package/src/hooks/useMutatePinned.ts +3 -8
- package/src/hooks/useMutateReaction.ts +6 -12
- package/src/hooks/useMutateRead.ts +1 -10
- package/src/hooks/useMutateRemoveMembers.ts +7 -12
- package/src/hooks/useMutateTyping.ts +6 -11
- package/src/hooks/useSearchUsers.ts +1 -6
- package/src/hooks/useUser.ts +3 -14
- package/src/scss/theme/_appbar.scss +4 -2
- package/src/scss/theme/_cm-editor.scss +1 -1
- package/src/scss/theme/_code-vscode-dark.scss +184 -0
- package/src/scss/theme/_code-vscode-light.scss +179 -0
- package/src/scss/theme/_code.scss +9 -112
- package/src/scss/theme/_files.scss +1 -1
- package/src/scss/theme/_message-editor.scss +1 -1
- package/src/scss/theme/_overlays.scss +2 -2
- package/src/scss/theme/_panels.scss +11 -7
- package/src/scss/theme/_preview-code.scss +5 -0
- package/src/scss/theme/_preview-embed.scss +3 -3
- package/src/scss/theme/_preview-image.scss +1 -1
- package/src/scss/theme/_preview-text.scss +1 -1
- package/src/scss/theme/_preview.scss +7 -2
- package/src/scss/weavy-chat.scss +1 -0
- package/src/scss/weavy-messenger.scss +1 -0
- package/src/types/Chat.ts +1 -1
- package/src/types/types.ts +16 -5
- package/src/ui/Spinner.tsx +18 -0
- 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
|
-
|
|
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: .
|
|
29
|
-
left: .
|
|
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:
|
|
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-
|
|
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
|
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
// Embedded iframes
|
|
4
4
|
|
|
5
|
-
.wy-content-iframe
|
|
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
|
-
|
|
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)
|
|
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
|
|
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 & {
|
|
@@ -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:
|
|
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
|
|
90
|
+
.wy-dark & {
|
|
86
91
|
background-color: rgba($dark, $opacity-backdrop);
|
|
87
92
|
color: $navbar-dark-color;
|
|
88
93
|
|
package/src/scss/weavy-chat.scss
CHANGED
package/src/types/Chat.ts
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
interface WeavyClient {
|
|
2
2
|
url: string,
|
|
3
|
-
|
|
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: (
|
|
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
|
-
|
|
140
|
+
embed_url: string,
|
|
141
|
+
external_url: string,
|
|
136
142
|
thumbnail_url: string,
|
|
137
|
-
|
|
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 = "
|
|
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
|
}
|