quickblox-react-ui-kit 0.1.7 → 0.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/dist/Presentation/Views/Base/BaseViewModel.d.ts +8 -0
- package/dist/Presentation/Views/Dialogs/Dialogs.d.ts +3 -1
- package/dist/Presentation/components/UI/Dialogs/DialogInformation/DialogInformation.d.ts +3 -1
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidget.d.ts +8 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/ErrorMessageIcon.d.ts +11 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.d.ts +9 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultTextInputWidget.d.ts +2 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/useDefaultVoiceInputWidget.d.ts +2 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/ContextMenu.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/MessagesView.d.ts +7 -1
- package/dist/Presentation/components/UI/svgs/Icons/Media/AIWidget/index.d.ts +4 -0
- package/dist/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.d.ts +9 -0
- package/dist/Presentation/components/layouts/TestStage/CompanyLogo/CompanyLogo.d.ts +3 -0
- package/dist/Presentation/components/providers/QuickBloxUIKitProvider/useQbInitializedDataContext.d.ts +3 -0
- package/dist/Presentation/components/providers/QuickBloxUIKitProvider/useQbUIKitDataContext.d.ts +3 -0
- package/dist/QBconfig.d.ts +12 -0
- package/dist/index-ui.d.ts +3 -2
- package/dist/index-ui.js +72 -17
- package/dist/utils/utils.d.ts +3 -0
- package/package.json +1 -1
- package/src/App.tsx +21 -19
- package/src/Presentation/Views/Base/BaseViewModel.ts +17 -1
- package/src/Presentation/Views/Dialogs/Dialogs.tsx +14 -9
- package/src/Presentation/Views/Dialogs/useDialogsViewModel.ts +1 -1
- package/src/Presentation/components/UI/Dialogs/DialogInformation/DialogInformation.tsx +17 -8
- package/src/Presentation/components/UI/Dialogs/DialogInformation/UsersList/useUsersListViewModel.ts +2 -2
- package/src/Presentation/components/UI/Dialogs/EditDialog/EditDialog.tsx +2 -2
- package/src/Presentation/components/UI/Dialogs/InviteMembers/useInviteMembersViewModel.ts +2 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidget.ts +13 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/ErrorMessageIcon.tsx +98 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.tsx +136 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultTextInputWidget.tsx +60 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/useDefaultVoiceInputWidget.tsx +86 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/ContextMenu.tsx +96 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +275 -51
- package/src/Presentation/components/UI/Dialogs/MessagesView/useMessagesViewModel.ts +2 -2
- package/src/Presentation/components/UI/svgs/Icons/Media/AIWidget/Send.svg +3 -0
- package/src/Presentation/components/UI/svgs/Icons/Media/AIWidget/index.tsx +39 -0
- package/src/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +83 -8
- package/src/Presentation/components/layouts/TestStage/CompanyLogo/CompanyLogo.tsx +27 -0
- package/src/Presentation/components/layouts/TestStage/LoginView/Login.tsx +2 -2
- package/src/Presentation/components/providers/QuickBloxUIKitProvider/useEventMessagesRepository.ts +2 -2
- package/src/Presentation/components/providers/QuickBloxUIKitProvider/{useQbDataContext.ts → useQbInitializedDataContext.ts} +2 -2
- package/src/Presentation/components/providers/QuickBloxUIKitProvider/useQbUIKitDataContext.ts +11 -0
- package/src/QBconfig.ts +12 -0
- package/src/index-ui.ts +4 -2
- package/src/utils/utils.ts +39 -0
- package/dist/Presentation/components/providers/QuickBloxUIKitProvider/useQbDataContext.d.ts +0 -3
package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultTextInputWidget.tsx
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { AIWidget } from './AIWidget';
|
|
3
|
+
|
|
4
|
+
export default function useDefaultTextInputWidget(): AIWidget {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function
|
|
6
|
+
const fileToWidget = (file: File): void => {};
|
|
7
|
+
|
|
8
|
+
const renderWidget = (): JSX.Element => {
|
|
9
|
+
// return <SendIcon width="21" height="18" applyZoom color="red" />;
|
|
10
|
+
return (
|
|
11
|
+
<div
|
|
12
|
+
style={{
|
|
13
|
+
width: '21',
|
|
14
|
+
height: '18',
|
|
15
|
+
color: 'red',
|
|
16
|
+
fontSize: '9px',
|
|
17
|
+
fontStyle: 'bold',
|
|
18
|
+
fontWeight: '900',
|
|
19
|
+
border: '2px solid red',
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
T2V
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
async function getData(textToSend: string): Promise<string> {
|
|
28
|
+
const response = await fetch(
|
|
29
|
+
`https://func270519800.azurewebsites.net/api/TranslateTextToEng?text=${textToSend}`,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
console.log('getData: response: ', response);
|
|
33
|
+
const data = await response.text();
|
|
34
|
+
|
|
35
|
+
console.log(
|
|
36
|
+
'getData have response: ',
|
|
37
|
+
JSON.stringify(data.replaceAll('\n\n', '')),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return data.replaceAll('\n\n', '');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const [textFromWidgetToInput, setTextFromWidgetToInput] = useState('');
|
|
44
|
+
const textToWidget = (value: string): void => {
|
|
45
|
+
if (value && value.length > 0) {
|
|
46
|
+
// eslint-disable-next-line promise/catch-or-return,promise/always-return
|
|
47
|
+
getData(value).then((data) => {
|
|
48
|
+
setTextFromWidgetToInput(data);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
fileToContent: undefined,
|
|
55
|
+
textToContent: textFromWidgetToInput,
|
|
56
|
+
fileToWidget,
|
|
57
|
+
renderWidget,
|
|
58
|
+
textToWidget,
|
|
59
|
+
};
|
|
60
|
+
}
|
package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/useDefaultVoiceInputWidget.tsx
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { AIWidget } from './AIWidget';
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import VoiceIcon from '../../../svgs/Icons/Actions/Voice';
|
|
5
|
+
|
|
6
|
+
export default function useDefaultVoiceInputWidget(): AIWidget {
|
|
7
|
+
const renderWidget = (): JSX.Element => {
|
|
8
|
+
// return <VoiceIcon width="21" height="18" applyZoom color="red" />;
|
|
9
|
+
return (
|
|
10
|
+
<div
|
|
11
|
+
style={{
|
|
12
|
+
width: '21',
|
|
13
|
+
height: '18',
|
|
14
|
+
color: 'red',
|
|
15
|
+
fontSize: '9px',
|
|
16
|
+
fontStyle: 'bold',
|
|
17
|
+
fontWeight: '900',
|
|
18
|
+
border: '2px solid red',
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
v2t
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const [textFromWidgetToInput, setTextFromWidgetToInput] = useState('');
|
|
27
|
+
const textToWidget = (value: string): void => {
|
|
28
|
+
if (value && value.length > 0) {
|
|
29
|
+
setTextFromWidgetToInput(value.toUpperCase());
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const [audioFromWidgetToInput, setAudioFromWidgetToInput] = useState<File>();
|
|
34
|
+
|
|
35
|
+
async function sendFile(file: File): Promise<any> {
|
|
36
|
+
if (file) {
|
|
37
|
+
// Создание объекта FormData и добавление файла
|
|
38
|
+
const formData = new FormData();
|
|
39
|
+
|
|
40
|
+
formData.append('file', file, file.name);
|
|
41
|
+
|
|
42
|
+
// Отправка запроса POST с телом formData
|
|
43
|
+
const response = await fetch(
|
|
44
|
+
'https://func270519800.azurewebsites.net/api/VoiceToText',
|
|
45
|
+
{
|
|
46
|
+
method: 'POST',
|
|
47
|
+
body: formData,
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// Возвращение данных из ответа
|
|
52
|
+
console.log('sendFile: response: ', response);
|
|
53
|
+
const data = await response.text();
|
|
54
|
+
|
|
55
|
+
console.log(
|
|
56
|
+
'sendFile have response: ',
|
|
57
|
+
JSON.stringify(data.replaceAll('\n\n', '')),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return data.replaceAll('\n\n', '');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const fileToWidget = (file: File): void => {
|
|
65
|
+
setAudioFromWidgetToInput(file);
|
|
66
|
+
const fileInfo = `${file.name}, ${file.type}, ${file.size} Mb`;
|
|
67
|
+
|
|
68
|
+
console.log(fileInfo);
|
|
69
|
+
if (file) {
|
|
70
|
+
// Отправка файла и получение результата
|
|
71
|
+
sendFile(file).then((result) => {
|
|
72
|
+
// Обработка результата
|
|
73
|
+
console.log(result);
|
|
74
|
+
setTextFromWidgetToInput(result);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
fileToContent: audioFromWidgetToInput,
|
|
81
|
+
textToContent: textFromWidgetToInput,
|
|
82
|
+
fileToWidget,
|
|
83
|
+
renderWidget,
|
|
84
|
+
textToWidget,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { useState, CSSProperties, useRef, useEffect } from 'react';
|
|
2
|
+
import EditDots from '../../svgs/Icons/Actions/EditDots';
|
|
3
|
+
|
|
4
|
+
type MenuItem = {
|
|
5
|
+
title: string;
|
|
6
|
+
action: () => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type ContextMenuProps = {
|
|
10
|
+
items?: MenuItem[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const ContextMenuStyles: { [key: string]: CSSProperties } = {
|
|
14
|
+
contextMenuIcon: {
|
|
15
|
+
display: 'inline-block',
|
|
16
|
+
position: 'relative',
|
|
17
|
+
width: '42px',
|
|
18
|
+
height: '42px',
|
|
19
|
+
cursor: 'pointer',
|
|
20
|
+
},
|
|
21
|
+
contextMenuContent: {
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
top: '0',
|
|
24
|
+
left: '50%',
|
|
25
|
+
transform: 'translateX(-50%)',
|
|
26
|
+
backgroundColor: 'white',
|
|
27
|
+
border: '1px solid gray',
|
|
28
|
+
borderRadius: '8px',
|
|
29
|
+
padding: '4px',
|
|
30
|
+
zIndex: 1,
|
|
31
|
+
width: 'max-content',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function ContextMenu({ items }: ContextMenuProps) {
|
|
36
|
+
const [menuVisible, setMenuVisible] = useState(false);
|
|
37
|
+
const contextMenuRef = useRef<HTMLDivElement | null>(null);
|
|
38
|
+
|
|
39
|
+
const handleClick = () => {
|
|
40
|
+
setMenuVisible(!menuVisible);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const handleMenuItemClick = (action: () => void) => {
|
|
44
|
+
action();
|
|
45
|
+
setMenuVisible(false); // Закрыть контекстное меню после клика на пункт меню
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
function handleClickOutside(event: MouseEvent) {
|
|
50
|
+
if (
|
|
51
|
+
contextMenuRef.current &&
|
|
52
|
+
!contextMenuRef.current.contains(event.target as Node)
|
|
53
|
+
) {
|
|
54
|
+
setMenuVisible(false);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
59
|
+
|
|
60
|
+
return () => {
|
|
61
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
62
|
+
};
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
style={{
|
|
68
|
+
...ContextMenuStyles.contextMenuIcon,
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<div onClick={handleClick}>
|
|
72
|
+
<EditDots />
|
|
73
|
+
</div>
|
|
74
|
+
{menuVisible && (
|
|
75
|
+
<div ref={contextMenuRef} style={ContextMenuStyles.contextMenuContent}>
|
|
76
|
+
{items?.map((item, index) => (
|
|
77
|
+
<div
|
|
78
|
+
key={index}
|
|
79
|
+
style={{
|
|
80
|
+
padding: '4px',
|
|
81
|
+
cursor: 'pointer',
|
|
82
|
+
}}
|
|
83
|
+
onClick={() => {
|
|
84
|
+
handleMenuItemClick(item.action); // Используем новую функцию обработчика
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
{item.title}
|
|
88
|
+
</div>
|
|
89
|
+
))}
|
|
90
|
+
</div>
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default ContextMenu;
|