@weavy/uikit-react 11.1.0 → 11.2.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/README.md +3 -4
- package/changelog.md +6 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/contexts/MessengerContext.d.ts +1 -2
- package/dist/cjs/types/types/Messenger.d.ts +0 -1
- package/dist/cjs/types/types/types.d.ts +2 -4
- package/dist/cjs/types/utils/styles.d.ts +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/contexts/MessengerContext.d.ts +1 -2
- package/dist/esm/types/types/Messenger.d.ts +0 -1
- package/dist/esm/types/types/types.d.ts +2 -4
- package/dist/esm/types/utils/styles.d.ts +2 -2
- package/dist/index.d.ts +1 -2
- package/package.json +1 -1
- package/src/components/Chat.tsx +8 -11
- package/src/components/Conversation.tsx +1 -1
- package/src/components/FileBrowser.tsx +1 -1
- package/src/components/Messenger.tsx +4 -4
- package/src/components/Reactions.tsx +2 -1
- package/src/contexts/MessengerContext.tsx +4 -12
- package/src/contexts/WeavyContext.tsx +8 -1
- package/src/index.ts +2 -2
- package/src/types/Messenger.ts +1 -1
- package/src/types/types.ts +3 -7
- package/src/utils/scrollbarDetection.js +50 -0
- package/src/utils/styles.ts +21 -6
|
@@ -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
|
|
6
|
+
declare const MessengerProvider: ({ children }: Props) => JSX.Element;
|
|
8
7
|
export default MessengerProvider;
|
|
@@ -17,19 +17,17 @@ declare type WeavyContextOptions = {
|
|
|
17
17
|
zoomAuthenticationUrl?: string;
|
|
18
18
|
teamsAuthenticationUrl?: string;
|
|
19
19
|
enableCloudFiles?: boolean;
|
|
20
|
+
enableScrollbarDetection?: boolean;
|
|
20
21
|
filebrowserUrl?: string;
|
|
22
|
+
reactions?: string[];
|
|
21
23
|
};
|
|
22
24
|
declare type MessengerContextProps = {
|
|
23
|
-
options?: MessengerContextOptions;
|
|
24
25
|
selectedConversationId: null | number;
|
|
25
26
|
setSelectedConversationId: Function;
|
|
26
27
|
};
|
|
27
28
|
declare type UserContextProps = {
|
|
28
29
|
user: UserType;
|
|
29
30
|
};
|
|
30
|
-
declare type MessengerContextOptions = {
|
|
31
|
-
reactions?: string[];
|
|
32
|
-
};
|
|
33
31
|
declare type PreviewContextProps = {
|
|
34
32
|
openPreview: Function;
|
|
35
33
|
closePreview: Function;
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare function setPrefix(prefix: string): void;
|
|
6
6
|
/**
|
|
7
|
-
* Prefixes one or more classnames (with or without dot) using the themePrefix
|
|
7
|
+
* Prefixes one or more classnames (with or without dot or double dash) using the themePrefix
|
|
8
8
|
* @param {...string} strs
|
|
9
9
|
* @returns string[]
|
|
10
10
|
*/
|
|
11
11
|
export declare function prefixes(...strs: string[]): string[];
|
|
12
12
|
/**
|
|
13
|
-
* Prefixes
|
|
13
|
+
* Prefixes a classname string (containing one or multiple space-separated classnames, with or without dot or double dash) using the themePrefix
|
|
14
14
|
* @param {string} str
|
|
15
15
|
* @returns string
|
|
16
16
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -31,9 +31,8 @@ declare const WeavyProvider: ({ children, client, options }: Props$2) => JSX.Ele
|
|
|
31
31
|
declare const MessengerContext: React.Context<MessengerContextProps>;
|
|
32
32
|
declare type Props$1 = {
|
|
33
33
|
children: React.ReactNode;
|
|
34
|
-
options?: MessengerContextOptions;
|
|
35
34
|
};
|
|
36
|
-
declare const MessengerProvider: ({ children
|
|
35
|
+
declare const MessengerProvider: ({ children }: Props$1) => JSX.Element;
|
|
37
36
|
|
|
38
37
|
declare const Messenger: FC<Messenger>;
|
|
39
38
|
|
package/package.json
CHANGED
package/src/components/Chat.tsx
CHANGED
|
@@ -37,19 +37,16 @@ const Chat = ({ id }: ChatProps) => {
|
|
|
37
37
|
}, [dataChat]);
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
|
-
|
|
40
|
+
<div className={wy('messenger-conversation scroll-y')}>
|
|
41
41
|
<header className={wy('appbars')}>
|
|
42
42
|
<nav className={wy('appbar')}>
|
|
43
|
-
|
|
43
|
+
<div></div>
|
|
44
44
|
{selectedId && dataConversation &&
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
</Typing>
|
|
51
|
-
</div>
|
|
52
|
-
</>
|
|
45
|
+
<div className="wy-appbar-text">
|
|
46
|
+
<Typing id={selectedId} context="conversation">
|
|
47
|
+
{dataConversation.display_name}
|
|
48
|
+
</Typing>
|
|
49
|
+
</div>
|
|
53
50
|
}
|
|
54
51
|
</nav>
|
|
55
52
|
</header>
|
|
@@ -61,7 +58,7 @@ const Chat = ({ id }: ChatProps) => {
|
|
|
61
58
|
{selectedId && dataMembers &&
|
|
62
59
|
<Messages id={selectedId} members={dataMembers} />
|
|
63
60
|
}
|
|
64
|
-
|
|
61
|
+
</div>
|
|
65
62
|
)
|
|
66
63
|
}
|
|
67
64
|
|
|
@@ -131,7 +131,7 @@ const Conversation = ({ id, showBackButton }: ConversationProps) => {
|
|
|
131
131
|
{selectedConversationId && dataConversation &&
|
|
132
132
|
|
|
133
133
|
<>
|
|
134
|
-
<div>
|
|
134
|
+
<div className='wy-appbar-text'>
|
|
135
135
|
<Typing id={selectedConversationId} context="conversation">
|
|
136
136
|
{dataConversation.display_name}
|
|
137
137
|
</Typing>
|
|
@@ -61,7 +61,7 @@ const FileBrowser = ({ onFileAdded }: Props) => {
|
|
|
61
61
|
$filebrowserFrame.name = "weavy-filebrowser";
|
|
62
62
|
$filebrowserFrame.src = filebrowserSrc;
|
|
63
63
|
$filebrowserFrame.className = wy('filebrowser-frame');
|
|
64
|
-
$filebrowserFrame.style.cssText = "position:
|
|
64
|
+
$filebrowserFrame.style.cssText = "position: fixed; top: 0; left: 0; height: 100%; width: 100%; background: rgba(1,1,1,.4); z-index: 10000; display:none"
|
|
65
65
|
|
|
66
66
|
window.top?.document.body.appendChild($filebrowserFrame);
|
|
67
67
|
|
|
@@ -6,7 +6,7 @@ import { Messenger } from '../types/Messenger';
|
|
|
6
6
|
import { WeavyContext } from '../contexts/WeavyContext';
|
|
7
7
|
import { prefix as wy } from "../utils/styles";
|
|
8
8
|
|
|
9
|
-
const Messenger: FC<Messenger> = (
|
|
9
|
+
const Messenger: FC<Messenger> = () => {
|
|
10
10
|
|
|
11
11
|
const { client } = useContext(WeavyContext);
|
|
12
12
|
|
|
@@ -15,14 +15,14 @@ const Messenger: FC<Messenger> = ({ options }) => {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
|
-
<MessengerProvider
|
|
18
|
+
<MessengerProvider>
|
|
19
19
|
<div className={wy('messenger-provider')}>
|
|
20
20
|
|
|
21
|
-
<div className={wy('messenger-sidebar')}>
|
|
21
|
+
<div className={wy('messenger-sidebar scroll-y')}>
|
|
22
22
|
<ConversationList />
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
|
-
<div
|
|
25
|
+
<div className={wy('messenger-conversation scroll-y')}>
|
|
26
26
|
<Conversation id={null} />
|
|
27
27
|
</div>
|
|
28
28
|
</div>
|
|
@@ -8,6 +8,7 @@ import classNames from "classnames";
|
|
|
8
8
|
import { prefix as wy } from "../utils/styles";
|
|
9
9
|
import useReactions from "../hooks/useReactions";
|
|
10
10
|
import useMutateDeleteReaction from "../hooks/useMutateDeleteReaction";
|
|
11
|
+
import { WeavyContext } from "../contexts/WeavyContext";
|
|
11
12
|
|
|
12
13
|
type ReactionMenuProps = {
|
|
13
14
|
id: number,
|
|
@@ -25,7 +26,7 @@ export const ReactionsMenu = ({ id, reactions }: ReactionMenuProps) => {
|
|
|
25
26
|
const reactionMutation = useMutateReaction();
|
|
26
27
|
const reactionDeleteMutation = useMutateDeleteReaction();
|
|
27
28
|
const [visible, setVisible] = useState<boolean>(false);
|
|
28
|
-
const { options } = useContext(
|
|
29
|
+
const { options } = useContext(WeavyContext);
|
|
29
30
|
const [reactedEmoji, setReactedEmoji] = useState<string>('');
|
|
30
31
|
|
|
31
32
|
const emojis = options?.reactions;
|
|
@@ -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
|
|
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={{
|
|
26
|
+
<MessengerContext.Provider value={{ selectedConversationId, setSelectedConversationId }}>
|
|
35
27
|
{children}
|
|
36
28
|
</MessengerContext.Provider>
|
|
37
29
|
</>
|
|
@@ -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
|
-
|
|
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 &&
|
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
|
|
3
|
+
import { WeavyContext } from './contexts/WeavyContext';
|
|
4
4
|
import MessengerProvider from './contexts/MessengerContext';
|
|
5
|
-
import
|
|
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';
|
package/src/types/Messenger.ts
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -19,11 +19,12 @@ type WeavyContextOptions = {
|
|
|
19
19
|
zoomAuthenticationUrl?: string,
|
|
20
20
|
teamsAuthenticationUrl?: string,
|
|
21
21
|
enableCloudFiles?: boolean,
|
|
22
|
-
|
|
22
|
+
enableScrollbarDetection?: boolean,
|
|
23
|
+
filebrowserUrl?: string,
|
|
24
|
+
reactions?: string[]
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
type MessengerContextProps = {
|
|
26
|
-
options?: MessengerContextOptions,
|
|
27
28
|
selectedConversationId: null | number,
|
|
28
29
|
setSelectedConversationId: Function
|
|
29
30
|
};
|
|
@@ -32,11 +33,6 @@ type UserContextProps = {
|
|
|
32
33
|
user: UserType
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
type MessengerContextOptions = {
|
|
37
|
-
reactions?: string[]
|
|
38
|
-
}
|
|
39
|
-
|
|
40
36
|
type PreviewContextProps = {
|
|
41
37
|
openPreview: Function,
|
|
42
38
|
closePreview: Function
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { prefix } from "./styles";
|
|
2
|
+
|
|
3
|
+
// SCROLLBAR DETECTION
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The target which the scrollbar classname will be applied to.
|
|
7
|
+
* @type Element
|
|
8
|
+
*/
|
|
9
|
+
export var scrollbarClassnameTarget = document.documentElement;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The callback function for the scrollbar observer.
|
|
13
|
+
* @param {ResizeObserverTarget[]} entries
|
|
14
|
+
*/
|
|
15
|
+
export function checkScrollbar(entries) {
|
|
16
|
+
var element, overflowWidth;
|
|
17
|
+
for (var entry in entries) {
|
|
18
|
+
element = entries[entry].target;
|
|
19
|
+
try {
|
|
20
|
+
overflowWidth = element === document.documentElement ? window.innerWidth : element.clientWidth;
|
|
21
|
+
if (overflowWidth !== element.offsetWidth) {
|
|
22
|
+
// we have visible scrollbars, add .scrollbar to html element
|
|
23
|
+
scrollbarClassnameTarget.classList.add(prefix("scrollbars"));
|
|
24
|
+
} else {
|
|
25
|
+
scrollbarClassnameTarget.classList.remove(prefix("scrollbars"));
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.warn("scrollbar detection failed", e);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates a scrollbar detection element and starts observing it.
|
|
35
|
+
*/
|
|
36
|
+
export default function observeScrollbars() {
|
|
37
|
+
// insert scrollbar detection element
|
|
38
|
+
var scrollCheck = document.getElementById(prefix("scrollbar-detection"));
|
|
39
|
+
|
|
40
|
+
if (!scrollCheck) {
|
|
41
|
+
scrollCheck = document.createElement("aside");
|
|
42
|
+
scrollCheck.id = prefix("scrollbar-detection");
|
|
43
|
+
scrollCheck.className = prefix("scrollbar-detection");
|
|
44
|
+
document.documentElement.insertBefore(scrollCheck, document.body);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var scrollObserver = new ResizeObserver(checkScrollbar);
|
|
48
|
+
scrollObserver.observe(scrollCheck);
|
|
49
|
+
}
|
|
50
|
+
|
package/src/utils/styles.ts
CHANGED
|
@@ -13,7 +13,7 @@ var themePrefix = "wy";
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Prefixes one or more classnames (with or without dot) using the themePrefix
|
|
16
|
+
* Prefixes one or more classnames (with or without dot or double dash) using the themePrefix
|
|
17
17
|
* @param {...string} strs
|
|
18
18
|
* @returns string[]
|
|
19
19
|
*/
|
|
@@ -22,18 +22,33 @@ var themePrefix = "wy";
|
|
|
22
22
|
if (_prefix) {
|
|
23
23
|
strs = strs.map((str) => {
|
|
24
24
|
str ??= '';
|
|
25
|
-
if (str[0] === '.') {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
if (str[0] === '.') { // .example-class
|
|
26
|
+
// Skip if already set
|
|
27
|
+
if (str.substring(1).indexOf(_prefix + "-") !== 0) {
|
|
28
|
+
return `.${_prefix}-${str.substring(1)}`;
|
|
29
|
+
}
|
|
30
|
+
} else if (str.indexOf("--") === 0) { // --example-var
|
|
31
|
+
// Skip if already set
|
|
32
|
+
if (str.substring(2).indexOf(_prefix + "-") !== 0) {
|
|
33
|
+
return `--${_prefix}-${str.substring(2)}`;
|
|
34
|
+
}
|
|
35
|
+
} else { // example-class
|
|
36
|
+
// Skip if already set
|
|
37
|
+
if (str.indexOf(_prefix + "-") !== 0) {
|
|
38
|
+
return `${_prefix}-${str}`;
|
|
39
|
+
}
|
|
29
40
|
}
|
|
41
|
+
|
|
42
|
+
// return untouched str
|
|
43
|
+
return str;
|
|
44
|
+
|
|
30
45
|
})
|
|
31
46
|
}
|
|
32
47
|
return strs;
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
/**
|
|
36
|
-
* Prefixes
|
|
51
|
+
* Prefixes a classname string (containing one or multiple space-separated classnames, with or without dot or double dash) using the themePrefix
|
|
37
52
|
* @param {string} str
|
|
38
53
|
* @returns string
|
|
39
54
|
*/
|