@weavy/uikit-react 11.0.1 → 12.1.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 (242) hide show
  1. package/.github/workflows/publish.yml +1 -1
  2. package/README.md +3 -4
  3. package/changelog.md +30 -0
  4. package/dist/cjs/index.js +6 -6
  5. package/dist/cjs/index.js.map +1 -1
  6. package/dist/cjs/types/client/WeavyClient.d.ts +1 -1
  7. package/dist/cjs/types/components/Image.d.ts +2 -0
  8. package/dist/cjs/types/components/PdfViewer.d.ts +6 -0
  9. package/dist/cjs/types/components/Preview.d.ts +58 -0
  10. package/dist/cjs/types/contexts/MessengerContext.d.ts +1 -2
  11. package/dist/cjs/types/hooks/useUser.d.ts +2 -1
  12. package/dist/cjs/types/types/Messenger.d.ts +0 -1
  13. package/dist/cjs/types/types/types.d.ts +11 -6
  14. package/dist/cjs/types/utils/fileUtilities.d.ts +16 -1
  15. package/dist/css/weavy-chat.css +2684 -0
  16. package/dist/css/weavy-messenger.css +3039 -0
  17. package/dist/css/weavy.css +3039 -0
  18. package/dist/esm/index.js +6 -6
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/types/client/WeavyClient.d.ts +1 -1
  21. package/dist/esm/types/components/Image.d.ts +2 -0
  22. package/dist/esm/types/components/PdfViewer.d.ts +6 -0
  23. package/dist/esm/types/components/Preview.d.ts +58 -0
  24. package/dist/esm/types/contexts/MessengerContext.d.ts +1 -2
  25. package/dist/esm/types/hooks/useUser.d.ts +2 -1
  26. package/dist/esm/types/types/Messenger.d.ts +0 -1
  27. package/dist/esm/types/types/types.d.ts +11 -6
  28. package/dist/esm/types/utils/fileUtilities.d.ts +16 -1
  29. package/dist/index.d.ts +2 -3
  30. package/package.json +14 -4
  31. package/rollup.config.js +0 -2
  32. package/src/client/WeavyClient.ts +3 -3
  33. package/src/components/Attachment.tsx +5 -6
  34. package/src/components/Avatar.tsx +2 -3
  35. package/src/components/Chat.tsx +10 -14
  36. package/src/components/Conversation.tsx +21 -30
  37. package/src/components/ConversationBadge.tsx +1 -2
  38. package/src/components/ConversationForm.tsx +11 -18
  39. package/src/components/ConversationList.tsx +4 -5
  40. package/src/components/ConversationListItem.tsx +13 -15
  41. package/src/components/FileBrowser.tsx +2 -3
  42. package/src/components/Image.tsx +39 -7
  43. package/src/components/MeetingCard.tsx +7 -8
  44. package/src/components/Message.tsx +12 -13
  45. package/src/components/Messages.tsx +19 -19
  46. package/src/components/Messenger.tsx +5 -6
  47. package/src/components/NewConversation.tsx +5 -7
  48. package/src/components/PdfViewer.tsx +271 -0
  49. package/src/components/Presence.tsx +2 -2
  50. package/src/components/Preview.tsx +294 -0
  51. package/src/components/Reactions.tsx +8 -8
  52. package/src/components/SearchUsers.tsx +18 -17
  53. package/src/components/SeenBy.tsx +1 -2
  54. package/src/components/Typing.tsx +4 -4
  55. package/src/contexts/MessengerContext.tsx +4 -12
  56. package/src/contexts/PreviewContext.tsx +4 -6
  57. package/src/contexts/WeavyContext.tsx +8 -1
  58. package/src/hooks/useBadge.ts +1 -1
  59. package/src/hooks/useChat.ts +1 -1
  60. package/src/hooks/useConversation.ts +1 -2
  61. package/src/hooks/useConversations.ts +1 -1
  62. package/src/hooks/useFileUploader.ts +5 -1
  63. package/src/hooks/useMembers.ts +1 -1
  64. package/src/hooks/useMessages.ts +1 -1
  65. package/src/hooks/useMutateChat.ts +1 -1
  66. package/src/hooks/useMutateConversation.ts +1 -1
  67. package/src/hooks/useMutateConversationName.ts +1 -1
  68. package/src/hooks/useMutateDeleteReaction.ts +1 -1
  69. package/src/hooks/useMutateExternalBlobs.ts +1 -1
  70. package/src/hooks/useMutateMeeting.ts +1 -1
  71. package/src/hooks/useMutateMembers.ts +1 -1
  72. package/src/hooks/useMutateMessage.ts +2 -1
  73. package/src/hooks/useMutatePinned.ts +1 -1
  74. package/src/hooks/useMutateReaction.ts +1 -1
  75. package/src/hooks/useMutateRead.ts +1 -1
  76. package/src/hooks/useMutateRemoveMembers.ts +1 -1
  77. package/src/hooks/useMutateTyping.ts +1 -1
  78. package/src/hooks/usePresence.ts +8 -5
  79. package/src/hooks/useReactions.ts +0 -1
  80. package/src/hooks/useSearchUsers.ts +1 -1
  81. package/src/hooks/useUser.ts +4 -3
  82. package/src/index.ts +2 -2
  83. package/src/scss/theme/_alert.scss +73 -0
  84. package/src/scss/theme/_appbar.scss +112 -0
  85. package/src/scss/theme/_attachments.scss +74 -0
  86. package/src/scss/theme/_avatar.scss +54 -0
  87. package/src/scss/theme/_badge.scss +47 -0
  88. package/src/scss/theme/_buttons.scss +96 -0
  89. package/src/scss/theme/_card.scss +7 -0
  90. package/src/scss/theme/_checkbox.scss +56 -0
  91. package/src/scss/theme/_cm-editor.scss +42 -0
  92. package/src/scss/theme/_code.scss +115 -0
  93. package/src/scss/theme/_colors.scss +520 -0
  94. package/src/scss/theme/_config.scss +6 -0
  95. package/src/scss/theme/_content.scss +15 -0
  96. package/src/scss/theme/_conversations.scss +91 -0
  97. package/src/scss/theme/_dropdown.scss +86 -0
  98. package/src/scss/theme/_emoji.scss +5 -0
  99. package/src/scss/theme/_filebrowser.scss +26 -0
  100. package/src/scss/theme/_files.scss +140 -0
  101. package/src/scss/theme/_icons.scss +62 -0
  102. package/src/scss/theme/_image-grid.scss +63 -0
  103. package/src/scss/theme/_inputs.scss +28 -0
  104. package/src/scss/theme/_message-editor.scss +90 -0
  105. package/src/scss/theme/_messages.scss +238 -0
  106. package/src/scss/theme/_nav.scss +52 -0
  107. package/src/scss/theme/_overlays.scss +157 -0
  108. package/src/scss/theme/_pager.scss +19 -0
  109. package/src/scss/theme/_palette.scss +165 -0
  110. package/src/scss/theme/_pane.scss +16 -0
  111. package/src/scss/theme/_panels.scss +137 -0
  112. package/src/scss/theme/_picker-list.scss +37 -0
  113. package/src/scss/theme/_preview-embed.scss +38 -0
  114. package/src/scss/theme/_preview-html.scss +7 -0
  115. package/src/scss/theme/_preview-icon.scss +41 -0
  116. package/src/scss/theme/_preview-image.scss +86 -0
  117. package/src/scss/theme/_preview-media.scss +28 -0
  118. package/src/scss/theme/_preview-pdf.scss +838 -0
  119. package/src/scss/theme/_preview-text.scss +5 -0
  120. package/src/scss/theme/_preview.scss +105 -0
  121. package/src/scss/theme/_reactions.scss +58 -0
  122. package/src/scss/theme/_reboot.scss +41 -0
  123. package/src/scss/theme/_root.scss +2 -0
  124. package/src/scss/theme/_scroll.scss +55 -0
  125. package/src/scss/theme/_search.scss +68 -0
  126. package/src/scss/theme/_spinner.scss +63 -0
  127. package/src/scss/theme/_tables.scss +53 -0
  128. package/src/scss/theme/_toasts.scss +47 -0
  129. package/src/scss/theme/_turbo.scss +17 -0
  130. package/src/scss/theme/_typing.scss +26 -0
  131. package/src/scss/theme/_variables.scss +139 -0
  132. package/src/scss/theme/bootstrap/_accordion.scss +146 -0
  133. package/src/scss/theme/bootstrap/_alert.scss +71 -0
  134. package/src/scss/theme/bootstrap/_badge.scss +38 -0
  135. package/src/scss/theme/bootstrap/_breadcrumb.scss +40 -0
  136. package/src/scss/theme/bootstrap/_button-group.scss +142 -0
  137. package/src/scss/theme/bootstrap/_buttons.scss +186 -0
  138. package/src/scss/theme/bootstrap/_card.scss +234 -0
  139. package/src/scss/theme/bootstrap/_carousel.scss +229 -0
  140. package/src/scss/theme/bootstrap/_close.scss +40 -0
  141. package/src/scss/theme/bootstrap/_containers.scss +41 -0
  142. package/src/scss/theme/bootstrap/_dropdown.scss +248 -0
  143. package/src/scss/theme/bootstrap/_forms.scss +9 -0
  144. package/src/scss/theme/bootstrap/_functions.scss +302 -0
  145. package/src/scss/theme/bootstrap/_grid.scss +33 -0
  146. package/src/scss/theme/bootstrap/_helpers.scss +10 -0
  147. package/src/scss/theme/bootstrap/_images.scss +42 -0
  148. package/src/scss/theme/bootstrap/_list-group.scss +191 -0
  149. package/src/scss/theme/bootstrap/_maps.scss +54 -0
  150. package/src/scss/theme/bootstrap/_mixins.scss +43 -0
  151. package/src/scss/theme/bootstrap/_modal.scss +237 -0
  152. package/src/scss/theme/bootstrap/_nav.scss +172 -0
  153. package/src/scss/theme/bootstrap/_navbar.scss +276 -0
  154. package/src/scss/theme/bootstrap/_offcanvas.scss +143 -0
  155. package/src/scss/theme/bootstrap/_pagination.scss +109 -0
  156. package/src/scss/theme/bootstrap/_placeholders.scss +51 -0
  157. package/src/scss/theme/bootstrap/_popover.scss +196 -0
  158. package/src/scss/theme/bootstrap/_progress.scss +59 -0
  159. package/src/scss/theme/bootstrap/_reboot.scss +610 -0
  160. package/src/scss/theme/bootstrap/_root.scss +73 -0
  161. package/src/scss/theme/bootstrap/_spinners.scss +85 -0
  162. package/src/scss/theme/bootstrap/_tables.scss +164 -0
  163. package/src/scss/theme/bootstrap/_toasts.scss +70 -0
  164. package/src/scss/theme/bootstrap/_tooltip.scss +120 -0
  165. package/src/scss/theme/bootstrap/_transitions.scss +27 -0
  166. package/src/scss/theme/bootstrap/_type.scss +106 -0
  167. package/src/scss/theme/bootstrap/_utilities.scss +647 -0
  168. package/src/scss/theme/bootstrap/_variables.scss +1633 -0
  169. package/src/scss/theme/bootstrap/forms/_floating-labels.scss +74 -0
  170. package/src/scss/theme/bootstrap/forms/_form-check.scss +175 -0
  171. package/src/scss/theme/bootstrap/forms/_form-control.scss +194 -0
  172. package/src/scss/theme/bootstrap/forms/_form-range.scss +91 -0
  173. package/src/scss/theme/bootstrap/forms/_form-select.scss +71 -0
  174. package/src/scss/theme/bootstrap/forms/_form-text.scss +11 -0
  175. package/src/scss/theme/bootstrap/forms/_input-group.scss +129 -0
  176. package/src/scss/theme/bootstrap/forms/_labels.scss +36 -0
  177. package/src/scss/theme/bootstrap/forms/_validation.scss +12 -0
  178. package/src/scss/theme/bootstrap/helpers/_clearfix.scss +3 -0
  179. package/src/scss/theme/bootstrap/helpers/_color-bg.scss +10 -0
  180. package/src/scss/theme/bootstrap/helpers/_colored-links.scss +12 -0
  181. package/src/scss/theme/bootstrap/helpers/_position.scss +36 -0
  182. package/src/scss/theme/bootstrap/helpers/_ratio.scss +26 -0
  183. package/src/scss/theme/bootstrap/helpers/_stacks.scss +15 -0
  184. package/src/scss/theme/bootstrap/helpers/_stretched-link.scss +15 -0
  185. package/src/scss/theme/bootstrap/helpers/_text-truncation.scss +7 -0
  186. package/src/scss/theme/bootstrap/helpers/_visually-hidden.scss +8 -0
  187. package/src/scss/theme/bootstrap/helpers/_vr.scss +8 -0
  188. package/src/scss/theme/bootstrap/mixins/_alert.scss +15 -0
  189. package/src/scss/theme/bootstrap/mixins/_backdrop.scss +14 -0
  190. package/src/scss/theme/bootstrap/mixins/_banner.scss +9 -0
  191. package/src/scss/theme/bootstrap/mixins/_border-radius.scss +78 -0
  192. package/src/scss/theme/bootstrap/mixins/_box-shadow.scss +18 -0
  193. package/src/scss/theme/bootstrap/mixins/_breakpoints.scss +127 -0
  194. package/src/scss/theme/bootstrap/mixins/_buttons.scss +70 -0
  195. package/src/scss/theme/bootstrap/mixins/_caret.scss +64 -0
  196. package/src/scss/theme/bootstrap/mixins/_clearfix.scss +9 -0
  197. package/src/scss/theme/bootstrap/mixins/_color-scheme.scss +7 -0
  198. package/src/scss/theme/bootstrap/mixins/_container.scss +11 -0
  199. package/src/scss/theme/bootstrap/mixins/_deprecate.scss +10 -0
  200. package/src/scss/theme/bootstrap/mixins/_forms.scss +152 -0
  201. package/src/scss/theme/bootstrap/mixins/_gradients.scss +47 -0
  202. package/src/scss/theme/bootstrap/mixins/_grid.scss +151 -0
  203. package/src/scss/theme/bootstrap/mixins/_image.scss +16 -0
  204. package/src/scss/theme/bootstrap/mixins/_list-group.scss +24 -0
  205. package/src/scss/theme/bootstrap/mixins/_lists.scss +7 -0
  206. package/src/scss/theme/bootstrap/mixins/_pagination.scss +10 -0
  207. package/src/scss/theme/bootstrap/mixins/_reset-text.scss +17 -0
  208. package/src/scss/theme/bootstrap/mixins/_resize.scss +6 -0
  209. package/src/scss/theme/bootstrap/mixins/_table-variants.scss +24 -0
  210. package/src/scss/theme/bootstrap/mixins/_text-truncate.scss +8 -0
  211. package/src/scss/theme/bootstrap/mixins/_transition.scss +26 -0
  212. package/src/scss/theme/bootstrap/mixins/_utilities.scss +97 -0
  213. package/src/scss/theme/bootstrap/mixins/_visually-hidden.scss +29 -0
  214. package/src/scss/theme/bootstrap/utilities/_api.scss +47 -0
  215. package/src/scss/theme/bootstrap/vendor/_rfs.scss +354 -0
  216. package/src/scss/theme/bs/_badge.scss +20 -0
  217. package/src/scss/theme/bs/_buttons.scss +185 -0
  218. package/src/scss/theme/bs/_dropdown.scss +86 -0
  219. package/src/scss/theme/bs/_forms.scss +161 -0
  220. package/src/scss/theme/bs/_list-group.scss +73 -0
  221. package/src/scss/theme/bs/_tables.scss +46 -0
  222. package/src/scss/theme/fonts/_fontmapping-roboto.scss +129 -0
  223. package/src/scss/theme/fonts/_fontmapping-segoe-ui.scss +127 -0
  224. package/src/scss/theme/fonts/_index.scss +2 -0
  225. package/src/scss/theme/mixins/_backdrop.scss +13 -0
  226. package/src/scss/theme/mixins/_palette.scss +165 -0
  227. package/src/scss/theme/mixins/_position.scss +33 -0
  228. package/src/scss/theme/mixins/_scrollbar.scss +110 -0
  229. package/src/scss/weavy-chat.scss +31 -0
  230. package/src/scss/weavy-messenger.scss +60 -0
  231. package/src/scss/weavy.scss +2 -0
  232. package/src/types/Messenger.ts +1 -1
  233. package/src/types/types.ts +14 -9
  234. package/src/ui/Button.tsx +3 -4
  235. package/src/ui/Dropdown.tsx +4 -5
  236. package/src/ui/Icon.tsx +75 -39
  237. package/src/ui/Overlay.tsx +2 -3
  238. package/src/utils/fileUtilities.ts +280 -72
  239. package/src/utils/scrollbarDetection.js +48 -0
  240. package/dist/cjs/types/utils/styles.d.ts +0 -17
  241. package/dist/esm/types/utils/styles.d.ts +0 -17
  242. package/src/utils/styles.ts +0 -42
@@ -4,7 +4,6 @@ import useSearchUsers from "../hooks/useSearchUsers";
4
4
  import Avatar from './Avatar';
5
5
  import Button from '../ui/Button';
6
6
  import Icon from '../ui/Icon';
7
- import { prefix as wy } from "../utils/styles";
8
7
 
9
8
  type SearchUsersProps = {
10
9
  handleSubmit: any,
@@ -42,33 +41,33 @@ const SearchUsers = ({handleSubmit, buttonTitle}: SearchUsersProps) => {
42
41
  }
43
42
 
44
43
  return (
45
- <div className={wy('search scroll-y')}>
46
- <div className={wy('search-form pane-group')}>
44
+ <div className="wy-search wy-scroll-y">
45
+ <div className="wy-search-form wy-pane-group">
47
46
  <Button.UI><Icon.UI name="magnify" /></Button.UI>
48
- <input className={wy('search-input')} value={text} onChange={(e) => setText(e.target.value)} name="text" placeholder='Search...' />
47
+ <input className="wy-search-input" value={text} onChange={(e) => setText(e.target.value)} name="text" placeholder='Search...' />
49
48
  </div>
50
49
 
51
- <div className={wy('pane-group')}>
50
+ <div className="wy-pane-group">
52
51
  {data && data.data.length === 0 &&
53
- <div className={wy('search-no-result')}>Your search did not match any people.</div>
52
+ <div className="wy-search-no-result">Your search did not match any people.</div>
54
53
  }
55
- <table className={wy('search-result-table')}>
54
+ <table className="wy-search-result-table">
56
55
  <tbody>
57
56
  {data && data.data.length > 0 && data.data.map((user: MemberType) => {
58
57
  return (
59
- <tr key={user.id} className={wy('search-result-table-checkbox')}>
60
- <td className={wy('search-result-table-icon')}>
58
+ <tr key={user.id} className="wy-search-result-table-checkbox">
59
+ <td className="wy-search-result-table-icon">
61
60
  <Avatar src={user.avatar_url} size={24} id={user.id} presence={user.presence} name={user.display_name} />
62
61
  </td>
63
- <td>{user.display_name}</td>
64
- <td className={wy('search-result-table-icon')}><input type="checkbox" checked={isChecked(user.id)} onChange={(e) => handleSelected(e, user)} /></td>
62
+ <td><label htmlFor={'chk' + user.id}>{user.display_name}</label></td>
63
+ <td className="wy-search-result-table-icon"><input type="checkbox" id={'chk' + user.id} checked={isChecked(user.id)} onChange={(e) => handleSelected(e, user)} /></td>
65
64
  </tr>
66
65
  )
67
66
  })}
68
- </tbody>
67
+ </tbody>
69
68
  </table>
70
69
  </div>
71
- {/*<div className={wy('search-group')}>
70
+ {/*<div className="wy-search-group">
72
71
  <h2>Selected people</h2>
73
72
  <ul>
74
73
  {selected && selected.length > 0 && selected.map((user: UserType) => {
@@ -76,10 +75,12 @@ const SearchUsers = ({handleSubmit, buttonTitle}: SearchUsersProps) => {
76
75
  })}
77
76
  </ul>
78
77
  </div>*/}
79
- <div className={wy('footerbars')}>
80
- <div className={wy('footerbar')}>
81
- <div className={wy('pane-group')}>
82
- <button className={wy('button-primary')} type="button" onClick={() => {handleSubmit(selected); clear();}} disabled={selected.length === 0}>{buttonTitle}</button>
78
+ <div className="wy-footerbars">
79
+ <div className="wy-footerbar">
80
+ <div className="wy-pane-group">
81
+ <div className="wy-buttons">
82
+ <button className="wy-button wy-button-primary" type="button" onClick={() => {handleSubmit(selected); clear();}} disabled={selected.length === 0}>{buttonTitle}</button>
83
+ </div>
83
84
  </div>
84
85
  </div>
85
86
  </div>
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import Avatar from "./Avatar";
3
3
  import dayjs from 'dayjs';
4
- import { prefix as wy } from "../utils/styles";
5
4
 
6
5
  type Props = {
7
6
  id: number,
@@ -13,7 +12,7 @@ type Props = {
13
12
  const SeenBy = ({ seenBy }: Props) => {
14
13
 
15
14
  return (
16
- <div className={wy('readby-status')}>
15
+ <div className="wy-readby-status">
17
16
  {seenBy && seenBy.length > 0 && seenBy.map((member: MemberType) => {
18
17
  const date = dayjs.utc(member.read_at).tz(dayjs.tz.guess());
19
18
  return (<Avatar name={`Seen by ${member.name} at ${date.format('LLLL')}`} src={member.avatar_url} size={16} key={member.id}/>)})
@@ -26,12 +26,12 @@ const Typing = ({ children, id, context }: Props) => {
26
26
  useEffect(() => {
27
27
  setActiveTypers([]);
28
28
 
29
- client.subscribe(`a${id}`, "typing", handleTyping);
30
- client.subscribe(`a${id}`, "message-inserted", handleStopTyping);
29
+ client?.subscribe(`a${id}`, "typing", handleTyping);
30
+ client?.subscribe(`a${id}`, "message-inserted", handleStopTyping);
31
31
 
32
32
  return () => {
33
- client.unsubscribe(`a${id}`, "typing", handleTyping);
34
- client.unsubscribe(`a${id}`, "message-inserted", handleStopTyping);
33
+ client?.unsubscribe(`a${id}`, "typing", handleTyping);
34
+ client?.unsubscribe(`a${id}`, "message-inserted", handleStopTyping);
35
35
  }
36
36
  }, [id])
37
37
 
@@ -3,22 +3,14 @@ import usePresence from "../hooks/usePresence";
3
3
 
4
4
  export const MessengerContext = createContext<MessengerContextProps>({
5
5
  selectedConversationId: null,
6
- setSelectedConversationId: (id: any) => { },
7
- options: {}
6
+ setSelectedConversationId: (id: any) => { }
8
7
  });
9
8
 
10
9
  type Props = {
11
- children: React.ReactNode,
12
- options?: MessengerContextOptions
10
+ children: React.ReactNode
13
11
  }
14
12
 
15
- const MessengerProvider = ({ children, options }: Props) => {
16
-
17
- let defaultOptions: MessengerContextOptions = {
18
- reactions: ['😍', '😎', '😉', '😜', '👍']
19
- };
20
-
21
- let opts = { ...defaultOptions, ...options };
13
+ const MessengerProvider = ({ children }: Props) => {
22
14
 
23
15
  const [selectedConversationId, setSelectedConversation] = useState(null);
24
16
 
@@ -31,7 +23,7 @@ const MessengerProvider = ({ children, options }: Props) => {
31
23
 
32
24
  return (
33
25
  <>
34
- <MessengerContext.Provider value={{ options: opts, selectedConversationId, setSelectedConversationId }}>
26
+ <MessengerContext.Provider value={{ selectedConversationId, setSelectedConversationId }}>
35
27
  {children}
36
28
  </MessengerContext.Provider>
37
29
  </>
@@ -2,7 +2,6 @@ import React, { createContext, useEffect, useState } from "react";
2
2
  import Overlay from '../ui/Overlay';
3
3
  import Button from '../ui/Button';
4
4
  import Icon from '../ui/Icon';
5
- import { prefix as wy } from "../utils/styles";
6
5
 
7
6
  export const PreviewContext = createContext<PreviewContextProps>({
8
7
  openPreview: Function,
@@ -64,11 +63,11 @@ const PreviewProvider = ({ children }: Props) => {
64
63
  {children}
65
64
  </PreviewContext.Provider>
66
65
 
67
- <Overlay.UI isOpen={modalPreviewOpen} className={wy('dark')}>
68
- <header className={wy('appbars')}>
69
- <nav className={wy('appbar')}>
66
+ <Overlay.UI isOpen={modalPreviewOpen} className={'wy-dark'}>
67
+ <header className={'wy-appbars'}>
68
+ <nav className={'wy-appbar'}>
70
69
  <Button.UI onClick={closePreview}><Icon.UI name='close' /></Button.UI>
71
- <div className={wy('appbar-text')}>
70
+ <div className={'wy-appbar-text'}>
72
71
  {activeAttachment &&
73
72
  <span>{activeAttachment.name}</span>
74
73
  }
@@ -102,4 +101,3 @@ const PreviewProvider = ({ children }: Props) => {
102
101
  };
103
102
 
104
103
  export default PreviewProvider;
105
-
@@ -8,6 +8,7 @@ import timezone from 'dayjs/plugin/timezone';
8
8
  import localizedFormat from 'dayjs/plugin/localizedFormat';
9
9
  import PreviewProvider from "./PreviewContext";
10
10
  import WeavyClient from "../client/WeavyClient";
11
+ import detectScrollbars from '../utils/scrollbarDetection';
11
12
 
12
13
  dayjs.extend(relativeTime);
13
14
  dayjs.extend(utc);
@@ -40,11 +41,17 @@ const WeavyProvider = ({ children, client, options }: Props) => {
40
41
  zoomAuthenticationUrl: undefined,
41
42
  teamsAuthenticationUrl: undefined,
42
43
  enableCloudFiles: true,
43
- filebrowserUrl: "https://filebrowser.weavycloud.com/index10.html"
44
+ enableScrollbarDetection: true,
45
+ filebrowserUrl: "https://filebrowser.weavycloud.com/index10.html",
46
+ reactions: ['😍', '😎', '😉', '😜', '👍']
44
47
  };
45
48
 
46
49
  let opts = { ...defaultOptions, ...options }
47
50
 
51
+ if (opts.enableScrollbarDetection) {
52
+ detectScrollbars();
53
+ }
54
+
48
55
  return (
49
56
  <>
50
57
  {client &&
@@ -12,7 +12,7 @@ export default function useBadge() {
12
12
 
13
13
  const getBadge = async () => {
14
14
 
15
- const response = await fetch(client.uri + "/api/conversations/badge", {
15
+ const response = await fetch(client.url + "/api/conversations/badge", {
16
16
  headers: {
17
17
  "content-type": "application/json",
18
18
  "Authorization": "Bearer " + await client.tokenFactory()
@@ -12,7 +12,7 @@ export default function useChat(id: string, options: any) {
12
12
 
13
13
  const getConversation = async () => {
14
14
 
15
- const response = await fetch(client.uri + "/api/apps/idf/" + id, {
15
+ const response = await fetch(client.url + "/api/apps/idf/" + id, {
16
16
  headers: {
17
17
  "content-type": "application/json",
18
18
  "Authorization": "Bearer " + await client.tokenFactory()
@@ -1,5 +1,4 @@
1
1
  import { useContext } from "react";
2
-
3
2
  import { useQuery } from "react-query";
4
3
  import { WeavyContext } from "../contexts/WeavyContext";
5
4
 
@@ -13,7 +12,7 @@ export default function useConversation(id: number | null, options: any) {
13
12
 
14
13
  const getConversation = async () => {
15
14
 
16
- const response = await fetch(client.uri + "/api/conversations/" + id, {
15
+ const response = await fetch(client.url + "/api/conversations/" + id, {
17
16
  headers: {
18
17
  "content-type": "application/json",
19
18
  "Authorization": "Bearer " + await client.tokenFactory()
@@ -12,7 +12,7 @@ export default function useConversations() {
12
12
 
13
13
  const getConversations = async () => {
14
14
 
15
- const response = await fetch(client.uri + "/api/conversations?contextual=false", {
15
+ const response = await fetch(client.url + "/api/conversations?contextual=false", {
16
16
  headers: {
17
17
  "content-type": "application/json",
18
18
  "Authorization": "Bearer " + await client.tokenFactory()
@@ -7,13 +7,17 @@ export default function useFileUploader(callback: Function) {
7
7
 
8
8
  const { client } = useContext(WeavyContext);
9
9
 
10
+ if (!client) {
11
+ throw new Error('useFileUploader must be used within an WeavyProvider');
12
+ }
13
+
10
14
  return useMutation(
11
15
  async ({ request }: any) => {
12
16
 
13
17
  const formData = new FormData();
14
18
  formData.append('blob', request.file);
15
19
 
16
- var response = await fetch(client.uri + "/api/blobs", {
20
+ var response = await fetch(client.url + "/api/blobs", {
17
21
  method: 'POST',
18
22
  body: formData,
19
23
  headers: {
@@ -12,7 +12,7 @@ export default function useMembers(id: number | null, options: any) {
12
12
 
13
13
  const getConversationMembers = async () => {
14
14
 
15
- const response = await fetch(client.uri + "/api/apps/" + id + "/members", {
15
+ const response = await fetch(client.url + "/api/apps/" + id + "/members", {
16
16
  headers: {
17
17
  "content-type": "application/json",
18
18
  "Authorization": "Bearer " + await client.tokenFactory()
@@ -14,7 +14,7 @@ export default function useMessages(id: number | null, options: any) {
14
14
  const getMessages = async (opt: any) => {
15
15
  let skip = opt.pageParam || 0;
16
16
 
17
- const response = await fetch(client.uri + "/api/apps/" + id + "/messages?orderby=createdat+desc&skip=" + skip + "&top=" + PAGE_SIZE, {
17
+ const response = await fetch(client.url + "/api/apps/" + id + "/messages?orderby=createdat+desc&skip=" + skip + "&top=" + PAGE_SIZE, {
18
18
  headers: {
19
19
  "content-type": "application/json",
20
20
  "Authorization": "Bearer " + await client.tokenFactory()
@@ -21,7 +21,7 @@ export default function useMutateChat() {
21
21
  // create new conversation
22
22
  const mutateChat = async ({ identifier, members }: MutateProps) => {
23
23
 
24
- const response = await fetch(client.uri + "/api/apps/", {
24
+ const response = await fetch(client.url + "/api/apps/", {
25
25
  method: "POST",
26
26
  body: JSON.stringify({
27
27
  identifier: identifier,
@@ -20,7 +20,7 @@ export default function useMutateConversation() {
20
20
  // create new conversation
21
21
  const mutateConversation = async ({ members }: MutateProps) => {
22
22
 
23
- const response = await fetch(client.uri + "/api/conversations/", {
23
+ const response = await fetch(client.url + "/api/conversations/", {
24
24
  method: "POST",
25
25
  body: JSON.stringify({ members: members }),
26
26
  headers: {
@@ -20,7 +20,7 @@ export default function useMutateConversationName() {
20
20
 
21
21
  const mutateConversationName = async ({ id, name }: MutateProps) => {
22
22
 
23
- const response = await fetch(client.uri + "/api/apps/" + id, {
23
+ const response = await fetch(client.url + "/api/apps/" + id, {
24
24
  method: "PATCH",
25
25
  body: JSON.stringify({ name: name }),
26
26
  headers: {
@@ -22,7 +22,7 @@ export default function useMutateDeleteReaction() {
22
22
  const mutateDeleteReaction = async ({ id, reaction }: MutateProps) => {
23
23
 
24
24
  // remove the existing reaction
25
- const response = await fetch(client.uri + "/api/messages/" + id + "/reactions/", {
25
+ const response = await fetch(client.url + "/api/messages/" + id + "/reactions/", {
26
26
  method: "DELETE",
27
27
  headers: {
28
28
  "content-type": "application/json",
@@ -19,7 +19,7 @@ export default function useMutateExternalBlobs() {
19
19
 
20
20
  const mutateExternalBlobs = async ({ blobs }: MutateProps) => {
21
21
 
22
- const response = await fetch(client.uri + "/api/blobs/external", {
22
+ const response = await fetch(client.url + "/api/blobs/external", {
23
23
  method: "POST",
24
24
  body: JSON.stringify(blobs),
25
25
  headers: {
@@ -19,7 +19,7 @@ export default function useMutateMeeting() {
19
19
 
20
20
  const mutateMeeting = async ({ provider }: MutateProps) => {
21
21
 
22
- const response = await fetch(client.uri + "/api/meetings", {
22
+ const response = await fetch(client.url + "/api/meetings", {
23
23
  method: "POST",
24
24
  body: JSON.stringify({provider: provider}),
25
25
  headers: {
@@ -21,7 +21,7 @@ export default function useMutateMembers() {
21
21
  // add members to conversation
22
22
  const mutateMembers = async ({ id, members }: MutateProps) => {
23
23
 
24
- const response = await fetch(client.uri + "/api/apps/" + id + "/members/", {
24
+ const response = await fetch(client.url + "/api/apps/" + id + "/members/", {
25
25
  method: "POST",
26
26
  body: JSON.stringify(members),
27
27
  headers: {
@@ -22,7 +22,7 @@ export default function useMutateMessage() {
22
22
  }
23
23
 
24
24
  const mutateMessage = async ({ id, text, userId, attachments, meetings }: MutateProps) => {
25
- const response = await fetch(client.uri + "/api/apps/" + id + "/messages", {
25
+ const response = await fetch(client.url + "/api/apps/" + id + "/messages", {
26
26
  method: "POST",
27
27
  body: JSON.stringify({
28
28
  text: text,
@@ -86,6 +86,7 @@ export default function useMutateMessage() {
86
86
  let pageMessages = [...data, {
87
87
  id: tempId,
88
88
  text: variables.text,
89
+ html: variables.text,
89
90
  display_name: "",
90
91
  temp: true,
91
92
  parent_id: null,
@@ -20,7 +20,7 @@ export default function useMutatePinned() {
20
20
 
21
21
  const mutatePinned = async ({ id, pin }: MutateProps) => {
22
22
 
23
- const response = await fetch(client.uri + "/api/conversations/" + id + "/pin", {
23
+ const response = await fetch(client.url + "/api/conversations/" + id + "/pin", {
24
24
  method: + !pin ? "DELETE": "PUT",
25
25
  body: "",
26
26
  headers: {
@@ -22,7 +22,7 @@ export default function useMutateReaction() {
22
22
  const mutateReaction = async ({id, reaction }: MutateProps) => {
23
23
 
24
24
 
25
- const response = await fetch(client.uri + "/api/messages/" + id + "/reactions/", {
25
+ const response = await fetch(client.url + "/api/messages/" + id + "/reactions/", {
26
26
  method: "POST",
27
27
  body: JSON.stringify({ content: reaction}),
28
28
  headers: {
@@ -20,7 +20,7 @@ export default function useMutateRead() {
20
20
 
21
21
  const mutateRead = async ({ id, read }: MutateProps) => {
22
22
 
23
- const response = await fetch(client.uri + "/api/conversations/" + id + "/read", {
23
+ const response = await fetch(client.url + "/api/conversations/" + id + "/read", {
24
24
  method: !read ? "DELETE": "PUT",
25
25
  body: "",
26
26
  headers: {
@@ -22,7 +22,7 @@ export default function useMutateRemoveMembers() {
22
22
 
23
23
  const mutateRemove = async ({ id, members }: MutateProps) => {
24
24
 
25
- const response = await fetch(client.uri + "/api/apps/" + id + "/members/" + members.join(","), {
25
+ const response = await fetch(client.url + "/api/apps/" + id + "/members/" + members.join(","), {
26
26
  method: "DELETE",
27
27
  body: JSON.stringify(members),
28
28
  headers: {
@@ -18,7 +18,7 @@ export default function useMutateTyping() {
18
18
 
19
19
  const mutateTyping = async ({ id }: MutateProps) => {
20
20
 
21
- const response = await fetch(client.uri + "/api/conversations/" + id + "/typing", {
21
+ const response = await fetch(client.url + "/api/conversations/" + id + "/typing", {
22
22
  method: "PUT",
23
23
  body: JSON.stringify({}),
24
24
  headers: {
@@ -1,11 +1,14 @@
1
1
  import { useContext, useEffect } from "react";
2
2
  import { WeavyContext } from "../contexts/WeavyContext";
3
- import { prefix as wy } from "../utils/styles";
4
3
 
5
4
  export default function usePresence() {
6
5
 
7
6
  const {client} = useContext(WeavyContext);
8
7
 
8
+ if (!client) {
9
+ throw new Error('usePresence must be used within an WeavyProvider');
10
+ }
11
+
9
12
  useEffect(() => {
10
13
  client.subscribe("online", "online", handlePresenceChange)
11
14
  }, []);
@@ -13,18 +16,18 @@ export default function usePresence() {
13
16
  const handlePresenceChange = (data: any) => {
14
17
 
15
18
  if (Array.isArray(data)) {
16
- document.querySelectorAll(wy(".presence")).forEach(function (item) {
17
- item.classList.remove(wy("presence-active"));
19
+ document.querySelectorAll(".wy-presence").forEach(function (item) {
20
+ item.classList.remove("wy-presence-active");
18
21
  });
19
22
 
20
23
  data.forEach(function (id) {
21
24
  document.querySelectorAll("[data-presence-id='" + id + "']").forEach(function (item) {
22
- item.classList.add(wy("presence-active"));
25
+ item.classList.add("wy-presence-active");
23
26
  });
24
27
  });
25
28
  } else {
26
29
  document.querySelectorAll("[data-presence-id='" + data + "']").forEach(function (item) {
27
- item.classList.add(wy("presence-active"));
30
+ item.classList.add("wy-presence-active");
28
31
  });
29
32
  }
30
33
  }
@@ -2,7 +2,6 @@ import { useCallback, useContext, useEffect, useLayoutEffect, useState } from "r
2
2
  import { UserContext } from "../contexts/UserContext";
3
3
  import useEvents from "./useEvents";
4
4
 
5
-
6
5
  export default function useReactions(id: number, reactions: ReactableType[]) {
7
6
  const { on, off } = useEvents();
8
7
  const { user } = useContext(UserContext);
@@ -12,7 +12,7 @@ export default function useSearchUsers(text: string, options: any) {
12
12
  }
13
13
 
14
14
  const getUsers = async () => {
15
- const response = await fetch(client.uri + "/api/users?q=" + text + "&skip=0&top=" + PAGE_SIZE, {
15
+ const response = await fetch(client.url + "/api/users?q=" + text + "&skip=0&top=" + PAGE_SIZE, {
16
16
  headers: {
17
17
  "content-type": "application/json",
18
18
  "Authorization": "Bearer " + await client.tokenFactory()
@@ -1,9 +1,10 @@
1
1
  //import { useContext } from "react";
2
2
  import { useQuery } from "react-query";
3
+ import WeavyClient from "../client/WeavyClient";
3
4
  //import { WeavyContext } from "../contexts/WeavyContext";
4
5
 
5
6
  /// GET current user
6
- export default function useUser(client: any) {
7
+ export default function useUser(client: WeavyClient) {
7
8
  //const { client } = useContext(WeavyContext);
8
9
 
9
10
  if (!client) {
@@ -13,7 +14,7 @@ export default function useUser(client: any) {
13
14
  const getUser = async () => {
14
15
 
15
16
  try {
16
- const response = await fetch(client.uri + "/api/user", {
17
+ const response = await fetch(client.url + "/api/user", {
17
18
  headers: {
18
19
  "content-type": "application/json",
19
20
  "Authorization": "Bearer " + await client.tokenFactory()
@@ -27,7 +28,7 @@ export default function useUser(client: any) {
27
28
  console.error("Could not load Weavy user data...")
28
29
  return null;
29
30
  } catch(err: any){
30
- console.error(`Could not connect to the Weavy backend. Please make sure ${client.uri} is up and running!`)
31
+ console.error(`Could not connect to the Weavy backend. Please make sure ${client.url} is up and running!`)
31
32
  }
32
33
 
33
34
 
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import WeavyClient from './client/WeavyClient';
2
2
  import WeavyProvider from './contexts/WeavyContext';
3
- import { WeavyContext } from './contexts/WeavyContext';
3
+ import { WeavyContext } from './contexts/WeavyContext';
4
4
  import MessengerProvider from './contexts/MessengerContext';
5
- import { MessengerContext } from './contexts/MessengerContext';
5
+ import { MessengerContext } from './contexts/MessengerContext';
6
6
  import Messenger from './components/Messenger';
7
7
  import ConversationBadge from './components/ConversationBadge';
8
8
  import ConversationList from './components/ConversationList';
@@ -0,0 +1,73 @@
1
+ @use "config" as *;
2
+
3
+ // Global alerts
4
+
5
+ .wy-alert-message {
6
+ padding: .25rem .5rem;
7
+ background-color: $client-alert-background;
8
+ text-align: center;
9
+ width: $client-panel-width;
10
+ color: $client-alert-color;
11
+ border-radius: .1875rem;
12
+ margin: 0 auto;
13
+ margin-top: 1rem;
14
+ font-family: $font-family-base;
15
+ position: relative;
16
+ z-index: 10;
17
+ box-shadow: $md-shadow-8dp;
18
+ max-width: calc(100% - 3rem);
19
+ pointer-events: none;
20
+ user-select: none;
21
+
22
+ a {
23
+ color: darken($client-alert-color, 10%);
24
+ text-decoration: $link-decoration;
25
+ font-weight: $alert-link-font-weight;
26
+ pointer-events: auto;
27
+ }
28
+
29
+ &.wy-fade {
30
+ transition: all $md-animation-duration $md-animation-curve-default;
31
+ opacity: 0;
32
+ height: 0;
33
+ padding-top: 0;
34
+ padding-bottom: 0;
35
+ margin-top: 0;
36
+
37
+ &.wy-in {
38
+ transition: opacity $md-animation-duration $md-animation-curve-default;
39
+ opacity: 1;
40
+ height: auto;
41
+ padding-top: .5rem;
42
+ padding-bottom: .5rem;
43
+ margin-top: 1rem;
44
+ }
45
+ }
46
+
47
+ .wy-button {
48
+ cursor: pointer;
49
+ display: inline-flex;
50
+ flex-shrink: 0;
51
+ flex-grow: 0;
52
+
53
+ > * {
54
+ display: inline-flex;
55
+ }
56
+
57
+ font-weight: 400;
58
+ text-align: center;
59
+ white-space: nowrap;
60
+ vertical-align: middle;
61
+ user-select: none;
62
+ border: 1px solid transparent;
63
+ padding: .3125rem .75rem;
64
+ font-size: 1rem;
65
+ line-height: 1.5;
66
+ border-radius: .1875rem;
67
+ color: $white;
68
+ background-color: $primary;
69
+ border-color: $primary;
70
+ box-shadow: $btn-box-shadow;
71
+ margin-top: .5rem;
72
+ }
73
+ }