quickblox-react-ui-kit 0.1.8 → 0.2.1
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/Data/DefaultConfigurations.d.ts +11 -0
- package/dist/Data/Stubs.d.ts +1 -1
- package/dist/Data/source/AISource.d.ts +13 -0
- package/dist/Domain/entity/MessageEntity.d.ts +1 -1
- package/dist/Presentation/Views/Base/BaseViewModel.d.ts +10 -5
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.d.ts +16 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.d.ts +14 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/ErrorMessageIcon.d.ts +11 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/SliderMenu.d.ts +23 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.d.ts +15 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/useDefaultVoiceInputWidget.d.ts +2 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/ContextMenu.d.ts +11 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/DropDownMenu.d.ts +26 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/ItemDropDownMenu/ItemDropDownMenu.d.ts +11 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.d.ts +3 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.d.ts +15 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/MessagesView.d.ts +5 -1
- package/dist/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.d.ts +9 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/BookIcon/BookIcon.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/HammerIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/HandshakeIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/MuscleIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/NecktieIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/NeutralFaceIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/PalmsUpTogetherIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/PerformingArtsIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/PointUpIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/SmileyIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/SmirkIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/WhiteCheckMarkIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/Actions/AssistAnswer/index.d.ts +4 -0
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Summarize/index.d.ts +4 -0
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Tone/index.d.ts +4 -0
- package/dist/Presentation/components/UI/svgs/Icons/Media/Translate/index.d.ts +4 -0
- package/dist/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.d.ts +9 -0
- package/dist/QBconfig.d.ts +22 -0
- package/dist/index-ui.d.ts +5 -1
- package/dist/index-ui.js +388 -25
- package/dist/utils/utils.d.ts +3 -0
- package/package.json +1 -1
- package/src/App.tsx +12 -18
- package/src/Data/DefaultConfigurations.ts +128 -0
- package/src/Data/Stubs.ts +15 -15
- package/src/Data/mapper/MessageLocalDTOMapper.ts +3 -2
- package/src/Data/mapper/MessageRemoteDTOMapper.ts +3 -2
- package/src/Data/source/AISource.ts +133 -0
- package/src/Data/source/remote/Mapper/MessageDTOMapper.ts +1 -1
- package/src/Domain/entity/MessageEntity.ts +1 -1
- package/src/Presentation/Views/Base/BaseViewModel.ts +20 -7
- package/src/Presentation/Views/Dialogs/Dialogs.tsx +37 -22
- package/src/Presentation/components/UI/Dialogs/HeaderDialogs/HeaderDialogs.scss +2 -2
- package/src/Presentation/components/UI/Dialogs/HeaderDialogs/HeaderDialogs.tsx +5 -5
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.ts +24 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.scss +55 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.tsx +116 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/ErrorMessageIcon.tsx +98 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/SliderMenu.tsx +172 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.ts +21 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.tsx +99 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.tsx +105 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.tsx +106 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/{InputWidget → AIWidgets}/useDefaultVoiceInputWidget.tsx +8 -7
- package/src/Presentation/components/UI/Dialogs/MessagesView/ContextMenu.tsx +95 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/DropDownMenu.scss +84 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/DropDownMenu.tsx +105 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/ItemDropDownMenu/ItemDropDownMenu.scss +50 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/ItemDropDownMenu/ItemDropDownMenu.tsx +43 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/HeaderMessages/HeaderMessages.tsx +14 -11
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.scss +39 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.tsx +26 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss +394 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx +747 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.scss +88 -4
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +625 -227
- package/src/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.scss +7 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.tsx +99 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/useMessagesViewModel.ts +2 -2
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BookIcon/BookIcon.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/HammerIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/HandshakeIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/MuscleIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/NecktieIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/NeutralFaceIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/PalmsUpTogetherIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/PerformingArtsIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/PointUpIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/SmileyIcon/index.tsx +20 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/SmirkIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/WhiteCheckMarkIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/AssistAnswer/AssistAnswer.svg +3 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/AssistAnswer/index.tsx +93 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Summarize/Summarize.svg +6 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Summarize/index.tsx +58 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Tone/Tone.svg +3 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Tone/index.tsx +34 -0
- package/src/Presentation/components/UI/svgs/Icons/Media/Translate/Translate.svg +3 -0
- package/src/Presentation/components/UI/svgs/Icons/Media/Translate/index.tsx +35 -0
- package/src/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +150 -37
- package/src/QBconfig.ts +31 -3
- package/src/index-ui.ts +9 -0
- package/src/utils/utils.ts +39 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InputWidget/InputWidget.d.ts +0 -8
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InputWidget/UseDefaultTextInputWidget.d.ts +0 -2
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InputWidget/useDefaultVoiceInputWidget.d.ts +0 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/InputWidget/InputWidget.ts +0 -15
- package/src/Presentation/components/UI/Dialogs/MessagesView/InputWidget/UseDefaultTextInputWidget.tsx +0 -60
- /package/dist/Presentation/components/UI/svgs/Icons/{Media → AIWidgets}/AIWidget/index.d.ts +0 -0
- /package/src/Presentation/components/UI/svgs/Icons/{Media → AIWidgets}/AIWidget/Send.svg +0 -0
- /package/src/Presentation/components/UI/svgs/Icons/{Media → AIWidgets}/AIWidget/index.tsx +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FunctionTypeFileWithContextToToVoid,
|
|
3
|
+
FunctionTypeJSXElement,
|
|
4
|
+
FunctionTypeStringWithContextToString,
|
|
5
|
+
} from '../../../../../Views/Base/BaseViewModel';
|
|
6
|
+
|
|
7
|
+
export interface AIWidget {
|
|
8
|
+
renderWidget: FunctionTypeJSXElement;
|
|
9
|
+
}
|
|
10
|
+
export interface AITextWidget extends AIWidget {
|
|
11
|
+
textToContent: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AIFileWidget extends AIWidget {
|
|
15
|
+
fileToContent: File | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface AIMessageWidget extends AITextWidget {
|
|
19
|
+
textToWidget: FunctionTypeStringWithContextToString;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface AIAttachmentWidget extends AIFileWidget {
|
|
23
|
+
fileToWidget: FunctionTypeFileWithContextToToVoid;
|
|
24
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
.dropdown-context-menu-tone * {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
}
|
|
5
|
+
.dropdown-context-menu-tone {
|
|
6
|
+
position: absolute;
|
|
7
|
+
bottom: -15px;
|
|
8
|
+
right: 0;
|
|
9
|
+
zIndex: 1;
|
|
10
|
+
width: max-content;
|
|
11
|
+
height: max-content;
|
|
12
|
+
|
|
13
|
+
background: var(--primary-primary-a-100, #ffffff);
|
|
14
|
+
border-radius: 4px;
|
|
15
|
+
padding: 8px 0px 8px 0px;
|
|
16
|
+
|
|
17
|
+
box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.04),
|
|
18
|
+
0px 3px 14px 0px rgba(0, 0, 0, 0.08), 0px 8px 10px 0px rgba(0, 0, 0, 0.12);
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.dropdown-context-menu-tone-menu-item {
|
|
23
|
+
padding: 4px 8px 4px 16px;
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: row;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: flex-start;
|
|
28
|
+
align-self: stretch;
|
|
29
|
+
flex-shrink: 0;
|
|
30
|
+
position: relative;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.dropdown-context-menu-tone-menu-item-title {
|
|
34
|
+
color: var(--secondary-secondary-900, #0b121b);
|
|
35
|
+
text-align: left;
|
|
36
|
+
font: var(--body-body-medium, 400 14px/20px "Roboto", sans-serif);
|
|
37
|
+
position: relative;
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: flex-start;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.dropdown-context-menu-tone-menu-item-icon {
|
|
44
|
+
border-radius: 4px;
|
|
45
|
+
padding: 4px;
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: row;
|
|
48
|
+
gap: 0px;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
flex-shrink: 0;
|
|
52
|
+
width: 24px;
|
|
53
|
+
height: 24px;
|
|
54
|
+
position: relative;
|
|
55
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, { useState, CSSProperties, useRef, useEffect } from 'react';
|
|
2
|
+
import './AIWidgetActions.scss';
|
|
3
|
+
import EditDots from '../../../../svgs/Icons/Actions/EditDots';
|
|
4
|
+
|
|
5
|
+
type MenuItem = {
|
|
6
|
+
title: string;
|
|
7
|
+
icon?: JSX.Element; // Добавлено поле для иконки пункта меню
|
|
8
|
+
action: () => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type ContextMenuProps = {
|
|
12
|
+
widgetToRender?: JSX.Element;
|
|
13
|
+
items?: MenuItem[];
|
|
14
|
+
title?: string | null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const ContextMenuStyles: { [key: string]: CSSProperties } = {
|
|
18
|
+
contextMenuIcon: {
|
|
19
|
+
display: 'inline-block',
|
|
20
|
+
position: 'relative',
|
|
21
|
+
maxWidth: '42px',
|
|
22
|
+
maxHeight: '42px',
|
|
23
|
+
cursor: 'pointer',
|
|
24
|
+
},
|
|
25
|
+
contextMenuContent: {
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
bottom: '10px',
|
|
28
|
+
right: '0',
|
|
29
|
+
backgroundColor: 'white',
|
|
30
|
+
border: '1px solid gray',
|
|
31
|
+
borderRadius: '8px',
|
|
32
|
+
padding: '4px',
|
|
33
|
+
zIndex: 1,
|
|
34
|
+
width: 'max-content',
|
|
35
|
+
},
|
|
36
|
+
menuItemContainer: {
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
padding: '4px',
|
|
40
|
+
cursor: 'pointer',
|
|
41
|
+
fontWeight: 'normal',
|
|
42
|
+
},
|
|
43
|
+
menuTitle: {
|
|
44
|
+
padding: '4px',
|
|
45
|
+
fontWeight: 'bold',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function AIWidgetActions({
|
|
50
|
+
items,
|
|
51
|
+
widgetToRender,
|
|
52
|
+
title = null,
|
|
53
|
+
}: ContextMenuProps) {
|
|
54
|
+
const [menuVisible, setMenuVisible] = useState(false);
|
|
55
|
+
const contextMenuRef = useRef<HTMLDivElement | null>(null);
|
|
56
|
+
|
|
57
|
+
const handleClick = () => {
|
|
58
|
+
setMenuVisible(!menuVisible);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleMenuItemClick = (action: () => void) => {
|
|
62
|
+
action();
|
|
63
|
+
setMenuVisible(false);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
function handleClickOutside(event: MouseEvent) {
|
|
68
|
+
if (
|
|
69
|
+
contextMenuRef.current &&
|
|
70
|
+
!contextMenuRef.current.contains(event.target as Node)
|
|
71
|
+
) {
|
|
72
|
+
setMenuVisible(false);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
80
|
+
};
|
|
81
|
+
}, []);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div style={ContextMenuStyles.contextMenuIcon}>
|
|
85
|
+
<div onClick={handleClick}>{widgetToRender || <EditDots />}</div>
|
|
86
|
+
{menuVisible && (
|
|
87
|
+
// <div ref={contextMenuRef} style={ContextMenuStyles.contextMenuContent}>
|
|
88
|
+
<div ref={contextMenuRef} className="dropdown-context-menu-tone">
|
|
89
|
+
{title && <div style={ContextMenuStyles.menuTitle}>{title}</div>}
|
|
90
|
+
{items?.map((item, index) => (
|
|
91
|
+
<div
|
|
92
|
+
key={index}
|
|
93
|
+
// style={ContextMenuStyles.menuItemContainer}
|
|
94
|
+
className="dropdown-context-menu-tone-menu-item"
|
|
95
|
+
onClick={() => {
|
|
96
|
+
handleMenuItemClick(item.action);
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
{item.icon && (
|
|
100
|
+
<div className="dropdown-context-menu-tone-menu-item-icon">
|
|
101
|
+
{item.icon}
|
|
102
|
+
</div>
|
|
103
|
+
)}
|
|
104
|
+
<div className="dropdown-context-menu-tone-menu-item-title">
|
|
105
|
+
{item.title}
|
|
106
|
+
</div>
|
|
107
|
+
<div className="dropdown-context-menu-tone-menu-item-icon" />
|
|
108
|
+
</div>
|
|
109
|
+
))}
|
|
110
|
+
</div>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default AIWidgetActions;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React, { useState, CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
type ErrorDescription = {
|
|
4
|
+
title: string;
|
|
5
|
+
action: () => void;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
type ErrorMessageIconProps = {
|
|
9
|
+
errorMessageText: string;
|
|
10
|
+
errorsDescriptions?: ErrorDescription[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const errorMessageIconStyles: { [key: string]: CSSProperties } = {
|
|
14
|
+
errorIcon: {
|
|
15
|
+
display: 'inline-block',
|
|
16
|
+
position: 'relative',
|
|
17
|
+
width: '21px', // Уменьшен размер круга
|
|
18
|
+
height: '21px', // Уменьшен размер круга
|
|
19
|
+
cursor: 'pointer',
|
|
20
|
+
},
|
|
21
|
+
circle: {
|
|
22
|
+
width: '21px', // Уменьшен размер круга
|
|
23
|
+
height: '21px', // Уменьшен размер круга
|
|
24
|
+
backgroundColor: 'red',
|
|
25
|
+
borderRadius: '50%',
|
|
26
|
+
display: 'flex',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
},
|
|
30
|
+
exclamationMark: {
|
|
31
|
+
color: 'white',
|
|
32
|
+
fontSize: '12px', // Уменьшен размер восклицательного знака
|
|
33
|
+
},
|
|
34
|
+
errorMessage: {
|
|
35
|
+
position: 'absolute',
|
|
36
|
+
bottom: '100%', // Изменено выравнивание, чтобы текст был выше
|
|
37
|
+
left: '50%',
|
|
38
|
+
transform: 'translateX(-50%)',
|
|
39
|
+
backgroundColor: 'lightgray',
|
|
40
|
+
border: '1px solid gray',
|
|
41
|
+
padding: '6px',
|
|
42
|
+
borderRadius: '8px',
|
|
43
|
+
whiteSpace: 'nowrap',
|
|
44
|
+
display: 'inline-block',
|
|
45
|
+
zIndex: 1, // Установлен zIndex, чтобы текст был выше других элементов
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function ErrorMessageIcon({
|
|
50
|
+
errorMessageText,
|
|
51
|
+
errorsDescriptions,
|
|
52
|
+
}: ErrorMessageIconProps) {
|
|
53
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
54
|
+
|
|
55
|
+
const handleMouseEnter = () => {
|
|
56
|
+
setIsHovered(true);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const handleMouseLeave = () => {
|
|
60
|
+
setIsHovered(false);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div
|
|
65
|
+
style={{
|
|
66
|
+
...errorMessageIconStyles.errorIcon,
|
|
67
|
+
...(isHovered ? { backgroundColor: 'yellow' } : {}),
|
|
68
|
+
}}
|
|
69
|
+
onMouseEnter={handleMouseEnter}
|
|
70
|
+
onMouseLeave={handleMouseLeave}
|
|
71
|
+
>
|
|
72
|
+
<div style={errorMessageIconStyles.circle}>
|
|
73
|
+
<span style={errorMessageIconStyles.exclamationMark}>!</span>
|
|
74
|
+
</div>
|
|
75
|
+
{isHovered && (
|
|
76
|
+
<div style={errorMessageIconStyles.errorMessage}>
|
|
77
|
+
{errorMessageText}
|
|
78
|
+
{errorsDescriptions?.map((item, index) => (
|
|
79
|
+
<div
|
|
80
|
+
key={index}
|
|
81
|
+
style={{
|
|
82
|
+
padding: '4px',
|
|
83
|
+
cursor: 'pointer',
|
|
84
|
+
}}
|
|
85
|
+
onClick={() => {
|
|
86
|
+
item.action();
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
{item.title}
|
|
90
|
+
</div>
|
|
91
|
+
))}
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default ErrorMessageIcon;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
type MenuItem = {
|
|
4
|
+
title: string;
|
|
5
|
+
icon?: JSX.Element;
|
|
6
|
+
action: () => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type SliderMenuProps = {
|
|
10
|
+
items: MenuItem[];
|
|
11
|
+
width: number;
|
|
12
|
+
arrowColor?: string;
|
|
13
|
+
activeArrowColor?: string;
|
|
14
|
+
borderColor?: string;
|
|
15
|
+
backgroundColor?: string;
|
|
16
|
+
itemBackgroundColor?: string;
|
|
17
|
+
itemWidth?: number;
|
|
18
|
+
itemHeight?: number;
|
|
19
|
+
itemBorder?: string;
|
|
20
|
+
fontSize?: number;
|
|
21
|
+
activeItemBorderColor?: string;
|
|
22
|
+
activeItemBoxShadow?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line react/function-component-definition
|
|
26
|
+
const SliderMenu: React.FC<SliderMenuProps> = ({
|
|
27
|
+
items,
|
|
28
|
+
width,
|
|
29
|
+
arrowColor = 'black',
|
|
30
|
+
activeArrowColor = 'red',
|
|
31
|
+
borderColor = 'gray',
|
|
32
|
+
backgroundColor = 'white',
|
|
33
|
+
itemBackgroundColor = 'lightgray',
|
|
34
|
+
itemWidth = 100,
|
|
35
|
+
itemHeight = 20,
|
|
36
|
+
itemBorder = '1px solid gray',
|
|
37
|
+
fontSize = 14,
|
|
38
|
+
activeItemBorderColor = 'blue',
|
|
39
|
+
activeItemBoxShadow = '2px 2px 4px rgba(0, 0, 0, 0.2)',
|
|
40
|
+
}) => {
|
|
41
|
+
const [currentIndex, setCurrentIndex] = useState(-1);
|
|
42
|
+
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
|
|
43
|
+
|
|
44
|
+
const handlePrev = () => {
|
|
45
|
+
setCurrentIndex((currentIndex - 1 + items.length) % items.length);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const handleNext = () => {
|
|
49
|
+
setCurrentIndex((currentIndex + 1) % items.length);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleItemClick = (index: number, action: () => void) => {
|
|
53
|
+
setCurrentIndex(index);
|
|
54
|
+
action();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div
|
|
59
|
+
style={{
|
|
60
|
+
border: `1px solid ${borderColor}`,
|
|
61
|
+
borderRadius: '10px',
|
|
62
|
+
padding: '4px',
|
|
63
|
+
display: 'flex',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
height: '24px',
|
|
66
|
+
backgroundColor,
|
|
67
|
+
position: 'relative',
|
|
68
|
+
overflow: 'hidden',
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<div
|
|
72
|
+
style={{
|
|
73
|
+
cursor: 'pointer',
|
|
74
|
+
marginRight: '4px',
|
|
75
|
+
width: '12px',
|
|
76
|
+
height: '12px',
|
|
77
|
+
borderTop: '4px solid transparent',
|
|
78
|
+
borderBottom: '4px solid transparent',
|
|
79
|
+
borderRight: `6px solid ${
|
|
80
|
+
hoveredIndex === null || currentIndex === 0
|
|
81
|
+
? arrowColor
|
|
82
|
+
: activeArrowColor
|
|
83
|
+
}`,
|
|
84
|
+
borderRadius: '5px',
|
|
85
|
+
transition: 'transform 0.3s ease-in-out',
|
|
86
|
+
transform:
|
|
87
|
+
hoveredIndex === null || currentIndex === 0
|
|
88
|
+
? 'scale(1)'
|
|
89
|
+
: 'scale(1.2)',
|
|
90
|
+
}}
|
|
91
|
+
onClick={handlePrev}
|
|
92
|
+
/>
|
|
93
|
+
<div
|
|
94
|
+
style={{
|
|
95
|
+
display: 'flex',
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
width: `${width}px`,
|
|
98
|
+
overflow: 'hidden',
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
<div
|
|
102
|
+
style={{
|
|
103
|
+
display: 'flex',
|
|
104
|
+
transform: `translateX(-${currentIndex * itemWidth}px)`,
|
|
105
|
+
transition: 'transform 0.3s ease-in-out',
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
{items.map((item, index) => (
|
|
109
|
+
<div
|
|
110
|
+
key={index}
|
|
111
|
+
style={{
|
|
112
|
+
width: `${itemWidth}px`,
|
|
113
|
+
height: `${itemHeight}px`,
|
|
114
|
+
display: 'flex',
|
|
115
|
+
alignItems: 'center',
|
|
116
|
+
paddingLeft: '4px',
|
|
117
|
+
backgroundColor: itemBackgroundColor,
|
|
118
|
+
borderRadius: '8px',
|
|
119
|
+
margin: '0 2px',
|
|
120
|
+
border:
|
|
121
|
+
index === currentIndex || index === hoveredIndex
|
|
122
|
+
? `2px solid ${activeItemBorderColor}`
|
|
123
|
+
: itemBorder,
|
|
124
|
+
fontSize: `${fontSize}px`,
|
|
125
|
+
flexDirection: 'row',
|
|
126
|
+
justifyContent: 'flex-start',
|
|
127
|
+
cursor: 'pointer',
|
|
128
|
+
boxShadow:
|
|
129
|
+
(index === currentIndex || index === hoveredIndex) &&
|
|
130
|
+
currentIndex !== -1
|
|
131
|
+
? activeItemBoxShadow
|
|
132
|
+
: 'none',
|
|
133
|
+
}}
|
|
134
|
+
onClick={() => handleItemClick(index, item.action)}
|
|
135
|
+
onMouseEnter={() => setHoveredIndex(index)}
|
|
136
|
+
onMouseLeave={() => setHoveredIndex(null)}
|
|
137
|
+
>
|
|
138
|
+
{item.icon && (
|
|
139
|
+
<div style={{ marginRight: '4px' }}>{item.icon}</div>
|
|
140
|
+
)}
|
|
141
|
+
{item.title}
|
|
142
|
+
</div>
|
|
143
|
+
))}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
<div
|
|
147
|
+
style={{
|
|
148
|
+
cursor: 'pointer',
|
|
149
|
+
marginLeft: '4px',
|
|
150
|
+
width: '12px',
|
|
151
|
+
height: '12px',
|
|
152
|
+
borderTop: '4px solid transparent',
|
|
153
|
+
borderBottom: '4px solid transparent',
|
|
154
|
+
borderLeft: `6px solid ${
|
|
155
|
+
hoveredIndex === null || currentIndex === items.length - 1
|
|
156
|
+
? arrowColor
|
|
157
|
+
: activeArrowColor
|
|
158
|
+
}`,
|
|
159
|
+
borderRadius: '5px',
|
|
160
|
+
transition: 'transform 0.3s ease-in-out',
|
|
161
|
+
transform:
|
|
162
|
+
hoveredIndex === null || currentIndex === items.length - 1
|
|
163
|
+
? 'scale(1)'
|
|
164
|
+
: 'scale(1.2)',
|
|
165
|
+
}}
|
|
166
|
+
onClick={handleNext}
|
|
167
|
+
/>
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export default SliderMenu;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export enum Tone {
|
|
2
|
+
Professional = 'Professional Tone',
|
|
3
|
+
Friendly = 'Friendly Tone',
|
|
4
|
+
Encouraging = 'Encouraging Tone',
|
|
5
|
+
Empathetic = 'Empathetic Tone',
|
|
6
|
+
Neutral = 'Neutral Tone',
|
|
7
|
+
Assertive = 'Assertive Tone',
|
|
8
|
+
Instructive = 'Instructive Tone',
|
|
9
|
+
Persuasive = 'Persuasive Tone',
|
|
10
|
+
Sarcastic = 'Sarcastic/Ironic Tone',
|
|
11
|
+
Poetic = 'Poetic Tone',
|
|
12
|
+
Unchanged = 'Unchanged',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const toneToString = (tone: Tone): string => {
|
|
16
|
+
return tone;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const stringToTone = (toneStr: string): Tone | undefined => {
|
|
20
|
+
return Tone[toneStr as keyof typeof Tone];
|
|
21
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { AIMessageWidget } from './AIMessageWidget';
|
|
3
|
+
import AIWidgetIcon from '../../../svgs/Icons/AIWidgets/AIWidget';
|
|
4
|
+
import ErrorMessageIcon from './ErrorMessageIcon';
|
|
5
|
+
import { AISource, IChatMessage } from '../../../../../../Data/source/AISource';
|
|
6
|
+
|
|
7
|
+
interface MessageWidgetProps {
|
|
8
|
+
// https://api.openai.com/v1/chat/completions'
|
|
9
|
+
// api: 'v1/chat/completions',
|
|
10
|
+
// servername: 'https://myproxy.com',
|
|
11
|
+
// https://func270519800.azurewebsites.net/api/TranslateTextToEng
|
|
12
|
+
servername: string;
|
|
13
|
+
api: string;
|
|
14
|
+
port: string;
|
|
15
|
+
sessionToken: string;
|
|
16
|
+
apiKey: string;
|
|
17
|
+
}
|
|
18
|
+
export default function UseDefaultAIAssistAnswerWidget({
|
|
19
|
+
servername,
|
|
20
|
+
api,
|
|
21
|
+
port,
|
|
22
|
+
sessionToken,
|
|
23
|
+
apiKey,
|
|
24
|
+
}: MessageWidgetProps): AIMessageWidget {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
+
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
27
|
+
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function
|
|
29
|
+
const fileToWidget = (file: File, context: IChatMessage[]): void => {};
|
|
30
|
+
|
|
31
|
+
const renderWidget = (): JSX.Element => {
|
|
32
|
+
if (errorMessage && errorMessage.length > 0) {
|
|
33
|
+
const errorsDescriptions:
|
|
34
|
+
| { title: string; action: () => void }[]
|
|
35
|
+
| undefined = [];
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<ErrorMessageIcon
|
|
39
|
+
errorMessageText={errorMessage}
|
|
40
|
+
errorsDescriptions={errorsDescriptions}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return <AIWidgetIcon applyZoom color="green" />;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const [textFromWidgetToContent, setTextFromWidgetToContent] = useState('');
|
|
49
|
+
const textToWidget = async (
|
|
50
|
+
textToSend: string,
|
|
51
|
+
context: IChatMessage[],
|
|
52
|
+
): Promise<string> => {
|
|
53
|
+
if (textToSend && textToSend.length > 0) {
|
|
54
|
+
const prompt = `You are a customer support chat operator. Your goal is to provide helpful and informative responses to customer inquiries. Give a response to the next user's query, considering the entire conversation context, and use grammar and vocabulary at the A2-B2 level. Answer in the format of simple sentences. Do not include question in answer. Please, provide answer for this issue:"${textToSend}"`;
|
|
55
|
+
|
|
56
|
+
if (apiKey.length > 0) {
|
|
57
|
+
// eslint-disable-next-line no-return-await
|
|
58
|
+
return await AISource.getData(
|
|
59
|
+
prompt,
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
61
|
+
context,
|
|
62
|
+
servername,
|
|
63
|
+
api,
|
|
64
|
+
port,
|
|
65
|
+
sessionToken,
|
|
66
|
+
).then((data) => {
|
|
67
|
+
setTextFromWidgetToContent(data);
|
|
68
|
+
|
|
69
|
+
return data;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line no-return-await
|
|
74
|
+
return await AISource.getDataWithProxyServer(
|
|
75
|
+
prompt,
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
77
|
+
context,
|
|
78
|
+
servername,
|
|
79
|
+
api,
|
|
80
|
+
port,
|
|
81
|
+
sessionToken,
|
|
82
|
+
).then((data) => {
|
|
83
|
+
setTextFromWidgetToContent(data);
|
|
84
|
+
|
|
85
|
+
return data;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// eslint-disable-next-line no-return-await
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return '';
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
textToContent: textFromWidgetToContent,
|
|
96
|
+
renderWidget,
|
|
97
|
+
textToWidget,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { AIMessageWidget } from './AIMessageWidget';
|
|
3
|
+
import ErrorMessageIcon from './ErrorMessageIcon';
|
|
4
|
+
import AIWidgetIcon from '../../../svgs/Icons/AIWidgets/AIWidget';
|
|
5
|
+
import { Tone, toneToString } from './Tone';
|
|
6
|
+
import { AISource, IChatMessage } from '../../../../../../Data/source/AISource';
|
|
7
|
+
|
|
8
|
+
interface MessageWidgetProps {
|
|
9
|
+
servername: string;
|
|
10
|
+
api: string;
|
|
11
|
+
port: string;
|
|
12
|
+
sessionToken: string;
|
|
13
|
+
apiKey: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default function UseDefaultAIRephraseMessageWidget({
|
|
17
|
+
servername,
|
|
18
|
+
api,
|
|
19
|
+
port,
|
|
20
|
+
sessionToken,
|
|
21
|
+
apiKey,
|
|
22
|
+
}: MessageWidgetProps): AIMessageWidget {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
+
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function
|
|
27
|
+
const fileToWidget = (file: File, context: IChatMessage[]): void => {};
|
|
28
|
+
|
|
29
|
+
const renderWidget = (): JSX.Element => {
|
|
30
|
+
if (errorMessage && errorMessage.length > 0) {
|
|
31
|
+
const errorsDescriptions:
|
|
32
|
+
| { title: string; action: () => void }[]
|
|
33
|
+
| undefined = [];
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ErrorMessageIcon
|
|
37
|
+
errorMessageText={errorMessage}
|
|
38
|
+
errorsDescriptions={errorsDescriptions}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return <AIWidgetIcon applyZoom color="green" />;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const [textFromWidgetToContent, setTextFromWidgetToContent] = useState('');
|
|
47
|
+
|
|
48
|
+
const textToWidget = async (
|
|
49
|
+
textToSend: string,
|
|
50
|
+
context: IChatMessage[],
|
|
51
|
+
additionalSettings?: { [key: string]: any },
|
|
52
|
+
): Promise<string> => {
|
|
53
|
+
if (textToSend && textToSend.length > 0) {
|
|
54
|
+
let prompt = `Analyze the entire context of our conversation – all the messages – and create a brief summary of our discussion. Based on this analysis, rephrase the following text in a style and tone that is typical for most of the dialogue messages. Provide only the rephrased text in as the message text to rephrase and nothing more.Give me only rephrase text in brackets and nothing more. Here is the message text to rephrase:"${textToSend}"`;
|
|
55
|
+
const { tone } = additionalSettings || {};
|
|
56
|
+
|
|
57
|
+
if (tone) {
|
|
58
|
+
prompt = `Analyze the entire context of our conversation – all the messages – and create a brief summary of our discussion. Based on this analysis, rephrase the following text in a ${toneToString(
|
|
59
|
+
tone as Tone,
|
|
60
|
+
)} style. Provide only the rephrased text in the same language as the message text to rephrase and nothing more.Give me only rephrase text in brackets and nothing more. Here is the message text to rephrase:"${textToSend}"`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (apiKey.length > 0) {
|
|
64
|
+
// eslint-disable-next-line no-return-await
|
|
65
|
+
return await AISource.getData(
|
|
66
|
+
prompt,
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
68
|
+
context,
|
|
69
|
+
servername,
|
|
70
|
+
api,
|
|
71
|
+
port,
|
|
72
|
+
sessionToken,
|
|
73
|
+
).then((data) => {
|
|
74
|
+
setTextFromWidgetToContent(data);
|
|
75
|
+
|
|
76
|
+
return data;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// eslint-disable-next-line no-return-await
|
|
81
|
+
return await AISource.getDataWithProxyServer(
|
|
82
|
+
prompt,
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
84
|
+
context,
|
|
85
|
+
servername,
|
|
86
|
+
api,
|
|
87
|
+
port,
|
|
88
|
+
sessionToken,
|
|
89
|
+
).then((data) => {
|
|
90
|
+
setTextFromWidgetToContent(data);
|
|
91
|
+
|
|
92
|
+
return data;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//
|
|
97
|
+
return '';
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
textToContent: textFromWidgetToContent,
|
|
102
|
+
renderWidget,
|
|
103
|
+
textToWidget,
|
|
104
|
+
};
|
|
105
|
+
}
|