@satek-team-intern/chatbot-widget 0.10.8 → 0.11.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/README.md +82 -32
- package/dist/assets/background_chatlive_setting.webp +0 -0
- package/dist/chatbot-widget.es.js +5636 -3926
- package/dist/chatbot-widget.umd.js +5 -21
- package/dist/constants/scenario_guest_vi.json.d.ts +103 -0
- package/dist/index.d.ts +1 -0
- package/dist/locales/en.json.d.ts +75 -7
- package/dist/locales/vi.json.d.ts +76 -8
- package/dist/src/assets/Icons.d.ts +67 -48
- package/dist/src/assets/createIcon.d.ts +5 -1
- package/dist/src/components/ChatWindow.d.ts +2 -31
- package/dist/src/components/FloatingButton.d.ts +1 -17
- package/dist/src/components/account/MultiChatManager.d.ts +6 -0
- package/dist/src/components/account/index.d.ts +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/modals/AddGroup.d.ts +0 -1
- package/dist/src/components/modals/AddMember.d.ts +0 -1
- package/dist/src/components/modals/UpdateGroup.d.ts +0 -2
- package/dist/src/components/modals/UserProfileModal.d.ts +1 -10
- package/dist/src/components/shared/AvatarFallBack.d.ts +2 -2
- package/dist/src/components/shared/OnboardingFormBlock.d.ts +10 -0
- package/dist/src/components/shared/QuickReplyButton.d.ts +13 -0
- package/dist/src/components/shared/index.d.ts +2 -1
- package/dist/src/components/sidebar/AppSideBar.d.ts +1 -4
- package/dist/src/components/sidebar/ChatInfoPanel.d.ts +0 -1
- package/dist/src/components/sidebar/ChatList.d.ts +0 -1
- package/dist/src/components/sidebar/ChatSearchBar.d.ts +0 -1
- package/dist/src/components/sidebar/ChatSidebar.d.ts +9 -0
- package/dist/src/components/sidebar/index.d.ts +1 -0
- package/dist/src/components/view/ChatHeader.d.ts +0 -4
- package/dist/src/components/view/ChatListItem.d.ts +1 -3
- package/dist/src/components/view/ChatMainArea.d.ts +9 -0
- package/dist/src/components/view/ChatMainHeader.d.ts +6 -0
- package/dist/src/components/view/ChatliveSetting.d.ts +1 -0
- package/dist/src/components/view/ContactList.d.ts +1 -1
- package/dist/src/components/view/EmptyChatState.d.ts +1 -0
- package/dist/src/components/view/FileIconMap.d.ts +8 -0
- package/dist/src/components/view/GroupList.d.ts +1 -0
- package/dist/src/components/view/ImageFileItem.d.ts +1 -1
- package/dist/src/components/view/MessageFiles.d.ts +3 -0
- package/dist/src/components/view/MessageItem.d.ts +1 -2
- package/dist/src/components/view/SettingSection.d.ts +1 -0
- package/dist/src/components/view/ThemeSetting.d.ts +1 -3
- package/dist/src/components/view/WindowResizeHandles.d.ts +6 -0
- package/dist/src/components/view/index.d.ts +6 -0
- package/dist/src/constants/common.d.ts +3 -1
- package/dist/src/constants/index.d.ts +4 -0
- package/dist/src/constants/onboarding.d.ts +4 -0
- package/dist/src/constants/permissionRules.d.ts +25 -0
- package/dist/src/constants/permissions.d.ts +15 -0
- package/dist/src/hooks/index.d.ts +7 -1
- package/dist/src/hooks/useChat.d.ts +2 -2
- package/dist/src/hooks/useChatActions.d.ts +9 -0
- package/dist/src/hooks/useChatSearch.d.ts +27 -0
- package/dist/src/hooks/useChatWidget.d.ts +4 -0
- package/dist/src/hooks/usePermissions.d.ts +9 -0
- package/dist/src/hooks/useProcessOnboarding.d.ts +3 -0
- package/dist/src/hooks/useSetting.d.ts +4 -1
- package/dist/src/hooks/useVoiceRecorder.d.ts +1 -1
- package/dist/src/hooks/useWindowControls.d.ts +14 -0
- package/dist/src/services/chat.service.d.ts +8 -9
- package/dist/src/services/chatManager.service.d.ts +16 -0
- package/dist/src/services/index.d.ts +1 -0
- package/dist/src/store/selectors/chat.d.ts +5 -0
- package/dist/src/store/selectors/index.d.ts +1 -0
- package/dist/src/store/selectors/setting.d.ts +3 -34
- package/dist/src/store/slices/chatSlice.d.ts +108 -5
- package/dist/src/store/slices/index.d.ts +2 -0
- package/dist/src/store/slices/layoutSlice.d.ts +12 -0
- package/dist/src/store/slices/onboardingSlice.d.ts +15 -0
- package/dist/src/store/slices/settingSlice.d.ts +5 -2
- package/dist/src/store/store.d.ts +5 -1
- package/dist/src/types/chat.type.d.ts +79 -6
- package/dist/src/types/index.d.ts +2 -0
- package/dist/src/types/layout.type.d.ts +13 -0
- package/dist/src/types/onboarding.type.d.ts +45 -0
- package/dist/src/types/types.d.ts +23 -10
- package/dist/src/utils/chat.utils.d.ts +7 -12
- package/dist/src/utils/engine.utils.d.ts +5 -0
- package/dist/src/utils/file.utils.d.ts +4 -6
- package/dist/src/utils/format.utils.d.ts +1 -1
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/text.utils.d.ts +1 -0
- package/package.json +2 -1
- package/dist/src/components/modals/AddChat.d.ts +0 -16
- package/dist/src/components/modals/ThemeModal.d.ts +0 -8
- package/dist/src/components/shared/ChatAvatar.d.ts +0 -5
- package/dist/src/components/shared/MemberAvatarFallBack.d.ts +0 -5
- package/dist/src/components/sidebar/SideBarInfoChat.d.ts +0 -11
- package/dist/src/styles/index.d.ts +0 -1
- package/dist/src/utils/formatDateLabel.d.ts +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChatUser, ChatConversation, ChatMessage, PaginationInfo } from '../../../types';
|
|
2
|
-
export interface
|
|
1
|
+
import { ChatUser, ChatConversation, ChatMessage, PaginationInfo, UseChatOptions } from '../../../types';
|
|
2
|
+
export interface AccountChatState {
|
|
3
3
|
currentUser: ChatUser | null;
|
|
4
4
|
chats: ChatConversation[];
|
|
5
5
|
currentChat?: ChatConversation | null;
|
|
@@ -10,16 +10,119 @@ export interface ChatState {
|
|
|
10
10
|
totalMessagesUnread: number;
|
|
11
11
|
messagesPagination: PaginationInfo | null;
|
|
12
12
|
replyingMessage: ChatMessage | null;
|
|
13
|
+
disabledMembers: Record<string, boolean>;
|
|
13
14
|
memberSocketMap: Record<number, string[]>;
|
|
14
15
|
disconnectedSockets: Record<string, boolean>;
|
|
15
|
-
|
|
16
|
+
selectedUserProfile: ChatUser | null;
|
|
17
|
+
}
|
|
18
|
+
export interface ChatState {
|
|
19
|
+
accounts: Record<string, AccountChatState>;
|
|
20
|
+
activeAccountCode?: string;
|
|
21
|
+
defaultAccountCode?: string;
|
|
22
|
+
accountConfigs: UseChatOptions[];
|
|
16
23
|
}
|
|
17
|
-
export declare const
|
|
24
|
+
export declare const defaultAccountState: AccountChatState;
|
|
25
|
+
export declare const setDefaultAccount: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
26
|
+
accountCode: string;
|
|
27
|
+
}, "widget-chatslice/setDefaultAccount">, setActiveAccount: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
28
|
+
accountCode: string;
|
|
29
|
+
}, "widget-chatslice/setActiveAccount">, registerAccountConfig: import('@reduxjs/toolkit').ActionCreatorWithPayload<UseChatOptions, "widget-chatslice/registerAccountConfig">, removeAccountConfig: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
30
|
+
accountCode: string;
|
|
31
|
+
}, "widget-chatslice/removeAccountConfig">, initAccountState: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
32
|
+
accountCode: string;
|
|
33
|
+
}, "widget-chatslice/initAccountState">, clearAccount: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
34
|
+
accountCode: string;
|
|
35
|
+
}, "widget-chatslice/clearAccount">, removeAccountState: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
36
|
+
accountCode: string;
|
|
37
|
+
}, "widget-chatslice/removeAccountState">, setCurrentUser: import('@reduxjs/toolkit').ActionCreatorWithPayload<ChatUser | null, "widget-chatslice/setCurrentUser">, setChats: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
38
|
+
accountCode: string;
|
|
39
|
+
chats: ChatConversation[];
|
|
40
|
+
}, "widget-chatslice/setChats">, setCurrentChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
41
|
+
accountCode: string;
|
|
42
|
+
chat: ChatConversation | null;
|
|
43
|
+
}, "widget-chatslice/setCurrentChat">, setCurrentChatMessages: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
44
|
+
accountCode: string;
|
|
45
|
+
messages: ChatMessage[];
|
|
46
|
+
}, "widget-chatslice/setCurrentChatMessages">, setCurrentChatMembers: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
47
|
+
accountCode: string;
|
|
48
|
+
members: ChatUser[];
|
|
49
|
+
}, "widget-chatslice/setCurrentChatMembers">, setMembers: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
50
|
+
accountCode: string;
|
|
51
|
+
members: ChatUser[];
|
|
52
|
+
}, "widget-chatslice/setMembers">, setDisabledMembers: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
53
|
+
accountCode: string;
|
|
54
|
+
disabledMembers: string[];
|
|
55
|
+
}, "widget-chatslice/setDisabledMembers">, setMember: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
56
|
+
accountCode: string;
|
|
57
|
+
member: ChatUser;
|
|
58
|
+
timestamp: number;
|
|
59
|
+
socketId: string;
|
|
60
|
+
}, "widget-chatslice/setMember">, setMemberDisconnect: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
61
|
+
accountCode: string;
|
|
62
|
+
socketId: string;
|
|
63
|
+
}, "widget-chatslice/setMemberDisconnect">, setMessagesPagination: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
64
|
+
accountCode: string;
|
|
65
|
+
pagination?: PaginationInfo;
|
|
66
|
+
}, "widget-chatslice/setMessagesPagination">, prependMessages: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
67
|
+
accountCode: string;
|
|
68
|
+
messages: ChatMessage[];
|
|
69
|
+
}, "widget-chatslice/prependMessages">, addNewMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
70
|
+
accountCode: string;
|
|
71
|
+
chat: ChatConversation;
|
|
72
|
+
message: ChatMessage;
|
|
73
|
+
}, "widget-chatslice/addNewMessage">, addNewSystemMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
74
|
+
accountCode: string;
|
|
75
|
+
message: ChatMessage;
|
|
76
|
+
}, "widget-chatslice/addNewSystemMessage">, removeChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
77
|
+
accountCode: string;
|
|
78
|
+
chatId: number;
|
|
79
|
+
}, "widget-chatslice/removeChat">, addChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
80
|
+
accountCode: string;
|
|
81
|
+
chat: ChatConversation;
|
|
82
|
+
}, "widget-chatslice/addChat">, updateChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
83
|
+
accountCode: string;
|
|
84
|
+
chat: ChatConversation;
|
|
85
|
+
}, "widget-chatslice/updateChat">, updateChatAvatar: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
86
|
+
accountCode: string;
|
|
87
|
+
chatId: number;
|
|
88
|
+
avatar: string;
|
|
89
|
+
}, "widget-chatslice/updateChatAvatar">, removeMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
90
|
+
accountCode: string;
|
|
91
|
+
chat_id: number;
|
|
92
|
+
message_id: number;
|
|
93
|
+
type: "remove" | "revoke";
|
|
94
|
+
}, "widget-chatslice/removeMessage">, updateMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
95
|
+
accountCode: string;
|
|
96
|
+
chat_id: number;
|
|
97
|
+
message: ChatMessage;
|
|
98
|
+
}, "widget-chatslice/updateMessage">, setReplyingMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
99
|
+
accountCode: string;
|
|
100
|
+
message: ChatMessage | null;
|
|
101
|
+
}, "widget-chatslice/setReplyingMessage">, setTotalMessagesUnread: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
102
|
+
accountCode: string;
|
|
103
|
+
total: number;
|
|
104
|
+
}, "widget-chatslice/setTotalMessagesUnread">, updateMemberReadStatus: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
105
|
+
accountCode: string;
|
|
18
106
|
chatId: number;
|
|
19
107
|
memberId: number;
|
|
20
108
|
lastReadId: number;
|
|
21
109
|
}, "widget-chatslice/updateMemberReadStatus">, toggleChatSetting: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
110
|
+
accountCode: string;
|
|
22
111
|
chatId: number;
|
|
23
112
|
setting: "is_muted" | "is_pined";
|
|
24
|
-
}, "widget-chatslice/toggleChatSetting">, renewMemberActivity: import('@reduxjs/toolkit').ActionCreatorWithPayload<
|
|
113
|
+
}, "widget-chatslice/toggleChatSetting">, renewMemberActivity: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
114
|
+
accountCode: string;
|
|
115
|
+
userId: number;
|
|
116
|
+
}, "widget-chatslice/renewMemberActivity">, memberJoinChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
117
|
+
accountCode: string;
|
|
118
|
+
member: ChatUser;
|
|
119
|
+
chat: ChatConversation;
|
|
120
|
+
}, "widget-chatslice/memberJoinChat">, memberLeaveChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
121
|
+
accountCode: string;
|
|
122
|
+
member_id: number;
|
|
123
|
+
chat: ChatConversation;
|
|
124
|
+
}, "widget-chatslice/memberLeaveChat">, setSelectedUserProfile: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
125
|
+
accountCode: string;
|
|
126
|
+
userProfile: ChatUser | null;
|
|
127
|
+
}, "widget-chatslice/setSelectedUserProfile">;
|
|
25
128
|
export declare const chatReducer: import('redux').Reducer<ChatState>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PositionWidget, WidgetChatTab, WidgetMode, WidgetSize, WidgetSubChatTab } from '../../../types';
|
|
2
|
+
export interface LayoutState {
|
|
3
|
+
mode: WidgetMode;
|
|
4
|
+
isChatLoading: boolean;
|
|
5
|
+
activeChatTab: WidgetChatTab;
|
|
6
|
+
activeSubChatTab: WidgetSubChatTab;
|
|
7
|
+
dragPosition: PositionWidget;
|
|
8
|
+
fullpagePosition: PositionWidget;
|
|
9
|
+
fullpageSize: WidgetSize;
|
|
10
|
+
}
|
|
11
|
+
export declare const setIsChatLoading: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setIsChatLoading">, setActiveChatTab: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setActiveChatTab">, setWidgetMode: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setWidgetMode">, setDragPosition: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setDragPosition">, setFullpagePosition: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setFullpagePosition">, setFullpageSize: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setFullpageSize">, setActiveSubChatTab: import('@reduxjs/toolkit').ActionCreatorWithPayload<WidgetSubChatTab, "widget-layoutslice/setActiveSubChatTab">;
|
|
12
|
+
export declare const layoutReducer: import('redux').Reducer<LayoutState>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChatMessage, MetadataOptions, OnboardingConfigJSON, OnboardingData } from '../../../types';
|
|
2
|
+
export interface OnboardingState {
|
|
3
|
+
onboardingState: string;
|
|
4
|
+
data: OnboardingData;
|
|
5
|
+
messages: ChatMessage[];
|
|
6
|
+
currentGuestCode: string;
|
|
7
|
+
config: OnboardingConfigJSON | null;
|
|
8
|
+
}
|
|
9
|
+
export declare const resetOnboarding: import('@reduxjs/toolkit').ActionCreatorWithoutPayload<"widget-onboardingSlice/resetOnboarding">, setCurrentGuestCode: import('@reduxjs/toolkit').ActionCreatorWithPayload<string, "widget-onboardingSlice/setCurrentGuestCode">, updateOnboarding: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
10
|
+
botReply: string;
|
|
11
|
+
nextState: string;
|
|
12
|
+
updatedData: OnboardingData;
|
|
13
|
+
metadata?: MetadataOptions;
|
|
14
|
+
}, "widget-onboardingSlice/updateOnboarding">, addOnboardingMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<string, "widget-onboardingSlice/addOnboardingMessage">, updateOnboardingState: import('@reduxjs/toolkit').ActionCreatorWithPayload<string, "widget-onboardingSlice/updateOnboardingState">, finishOnboarding: import('@reduxjs/toolkit').ActionCreatorWithoutPayload<"widget-onboardingSlice/finishOnboarding">, markMessageAsAnswered: import('@reduxjs/toolkit').ActionCreatorWithPayload<number, "widget-onboardingSlice/markMessageAsAnswered">, setOnboardingConfig: import('@reduxjs/toolkit').ActionCreatorWithPayload<OnboardingConfigJSON, "widget-onboardingSlice/setOnboardingConfig">;
|
|
15
|
+
export declare const onboardingReducer: import('redux').Reducer<OnboardingState>;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { LanguageOption, WidgetFeature } from '../../../types';
|
|
1
|
+
import { LanguageOption, WidgetFeature, WidgetRole } from '../../../types';
|
|
2
2
|
export interface SettingState {
|
|
3
3
|
theme: 'light' | 'dark';
|
|
4
4
|
primaryColor: string;
|
|
5
5
|
features: WidgetFeature;
|
|
6
6
|
currentLanguage: LanguageOption;
|
|
7
7
|
hasMultipleLanguages: boolean;
|
|
8
|
+
draggable: boolean;
|
|
9
|
+
role: WidgetRole;
|
|
8
10
|
}
|
|
9
11
|
export declare const setConfig: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
10
12
|
features?: WidgetFeature;
|
|
11
13
|
language?: LanguageOption;
|
|
12
|
-
|
|
14
|
+
role?: WidgetRole;
|
|
15
|
+
}, "widget-settingslice/setConfig">, setTheme: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-settingslice/setTheme">, setFeatures: import('@reduxjs/toolkit').ActionCreatorWithPayload<WidgetFeature, "widget-settingslice/setFeatures">, setPrimaryColor: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-settingslice/setPrimaryColor">, setDraggable: import('@reduxjs/toolkit').ActionCreatorWithPayload<boolean, "widget-settingslice/setDraggable">, setLanguage: import('@reduxjs/toolkit').ActionCreatorWithPayload<LanguageOption, "widget-settingslice/setLanguage">;
|
|
13
16
|
export declare const settingReducer: import('redux').Reducer<SettingState>;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { Tuple, AnyAction, ThunkDispatch, UnknownAction, EnhancedStore, StoreEnhancer } from '@reduxjs/toolkit';
|
|
2
|
-
import { ChatState, SettingState } from '../../store/slices';
|
|
2
|
+
import { ChatState, SettingState, LayoutState, OnboardingState } from '../../store/slices';
|
|
3
3
|
export declare const store: EnhancedStore<{
|
|
4
4
|
chat: ChatState;
|
|
5
5
|
setting: SettingState;
|
|
6
|
+
layout: LayoutState;
|
|
7
|
+
onboarding: OnboardingState;
|
|
6
8
|
}, AnyAction, Tuple<[
|
|
7
9
|
StoreEnhancer<{
|
|
8
10
|
dispatch: ThunkDispatch<{
|
|
9
11
|
chat: ChatState;
|
|
10
12
|
setting: SettingState;
|
|
13
|
+
layout: LayoutState;
|
|
14
|
+
onboarding: OnboardingState;
|
|
11
15
|
}, undefined, UnknownAction>;
|
|
12
16
|
}>,
|
|
13
17
|
StoreEnhancer
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { AuthInfo } from '
|
|
1
|
+
import { AuthInfo, WidgetScope } from '../../types';
|
|
2
|
+
export interface UseChatOptions {
|
|
3
|
+
chatKey: string;
|
|
4
|
+
authInfo: AuthInfo;
|
|
5
|
+
scope?: WidgetScope;
|
|
6
|
+
workspace?: string;
|
|
7
|
+
disabledMembers?: string[];
|
|
8
|
+
isPrimary?: boolean;
|
|
9
|
+
}
|
|
2
10
|
export interface ChatUser {
|
|
3
11
|
id: number;
|
|
4
12
|
code: string;
|
|
@@ -17,12 +25,57 @@ export interface ChatResponse<T = unknown> {
|
|
|
17
25
|
statusText?: string;
|
|
18
26
|
[key: string]: unknown;
|
|
19
27
|
}
|
|
28
|
+
export type FormFieldType = 'text' | 'tel' | 'email' | 'radio' | 'select';
|
|
29
|
+
export interface FormFieldOption {
|
|
30
|
+
label: string;
|
|
31
|
+
value: string;
|
|
32
|
+
}
|
|
33
|
+
export interface FormFieldValidation {
|
|
34
|
+
rule: string;
|
|
35
|
+
value?: number | string;
|
|
36
|
+
error_message: string;
|
|
37
|
+
}
|
|
38
|
+
export interface FormField {
|
|
39
|
+
save_variable: string;
|
|
40
|
+
label: string;
|
|
41
|
+
type: FormFieldType;
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
required: boolean;
|
|
44
|
+
options?: FormFieldOption[];
|
|
45
|
+
validation?: FormFieldValidation;
|
|
46
|
+
}
|
|
47
|
+
interface BaseMetadata {
|
|
48
|
+
isAnswered: boolean;
|
|
49
|
+
}
|
|
50
|
+
interface ButtonMetadata extends BaseMetadata {
|
|
51
|
+
type: 'quick_reply' | 'interactive_input';
|
|
52
|
+
actions: MetadataActions[];
|
|
53
|
+
}
|
|
54
|
+
interface FormMetadata extends BaseMetadata {
|
|
55
|
+
type: 'form_input';
|
|
56
|
+
submit_button_label?: string;
|
|
57
|
+
fields: FormField[];
|
|
58
|
+
}
|
|
59
|
+
export type MetadataOptions = ButtonMetadata | FormMetadata;
|
|
60
|
+
export interface MetadataActions {
|
|
61
|
+
id: string;
|
|
62
|
+
label: string;
|
|
63
|
+
value: string;
|
|
64
|
+
}
|
|
65
|
+
export interface SystemMessageContent {
|
|
66
|
+
data: {
|
|
67
|
+
code: string;
|
|
68
|
+
};
|
|
69
|
+
name: string;
|
|
70
|
+
type: 'live';
|
|
71
|
+
}
|
|
72
|
+
export type MessageContentType = string | SystemMessageContent | null;
|
|
20
73
|
export interface ChatMessage {
|
|
21
74
|
id: number;
|
|
22
|
-
type: 'text';
|
|
75
|
+
type: 'text' | 'json' | 'html';
|
|
23
76
|
action: Record<string, number>;
|
|
24
77
|
member: ChatUser;
|
|
25
|
-
content:
|
|
78
|
+
content: MessageContentType;
|
|
26
79
|
files?: ChatFile[];
|
|
27
80
|
revoked: boolean;
|
|
28
81
|
removed: boolean;
|
|
@@ -31,6 +84,7 @@ export interface ChatMessage {
|
|
|
31
84
|
created_at: string;
|
|
32
85
|
updated_at: string;
|
|
33
86
|
[key: string]: unknown;
|
|
87
|
+
metadata?: MetadataOptions;
|
|
34
88
|
}
|
|
35
89
|
export interface ChatConversation {
|
|
36
90
|
id: number;
|
|
@@ -50,6 +104,7 @@ export interface ChatConversation {
|
|
|
50
104
|
[key: string]: unknown;
|
|
51
105
|
}
|
|
52
106
|
export interface ChatEvent {
|
|
107
|
+
system_message: 'system.messages';
|
|
53
108
|
chats_created: 'chats.created';
|
|
54
109
|
chats_updated: 'chats.updated';
|
|
55
110
|
chats_deleted: 'chats.deleted';
|
|
@@ -72,14 +127,19 @@ export interface ChatConfig {
|
|
|
72
127
|
maxRetries?: number;
|
|
73
128
|
[key: string]: unknown;
|
|
74
129
|
}
|
|
130
|
+
export type ChatDurationUnit = 'minutes' | 'hours' | 'days';
|
|
75
131
|
export interface ChatSetting {
|
|
76
132
|
allow_delete_chat: boolean;
|
|
77
133
|
allow_delete_message: boolean;
|
|
78
134
|
allow_revoke_message: boolean;
|
|
79
135
|
delete_duration: number;
|
|
80
|
-
delete_duration_unit:
|
|
136
|
+
delete_duration_unit: ChatDurationUnit;
|
|
81
137
|
revoke_duration: number;
|
|
82
|
-
revoke_duration_unit:
|
|
138
|
+
revoke_duration_unit: ChatDurationUnit;
|
|
139
|
+
project_id: number;
|
|
140
|
+
project_code: string;
|
|
141
|
+
project_name: string;
|
|
142
|
+
workspace: string;
|
|
83
143
|
}
|
|
84
144
|
export type MessageAction = 'like' | 'love' | 'revoke' | 'remove';
|
|
85
145
|
export interface PaginationInfo {
|
|
@@ -90,6 +150,10 @@ export interface PaginationInfo {
|
|
|
90
150
|
total_pages: number;
|
|
91
151
|
}
|
|
92
152
|
export interface ChatEventPayloads {
|
|
153
|
+
'system.messages': {
|
|
154
|
+
message: ChatMessage;
|
|
155
|
+
type: 'add';
|
|
156
|
+
};
|
|
93
157
|
'chats.created': {
|
|
94
158
|
chat: ChatConversation;
|
|
95
159
|
};
|
|
@@ -204,7 +268,7 @@ export interface ChatInstance {
|
|
|
204
268
|
* @param receiverId ID người nhận (Number)
|
|
205
269
|
* @returns Promise trả về object cuộc trò chuyện (ChatConversation) hoặc null
|
|
206
270
|
*/
|
|
207
|
-
findChatByReceiver(receiverId: number): Promise<
|
|
271
|
+
findChatByReceiver(receiverId: number | string): Promise<ChatConversation | undefined>;
|
|
208
272
|
/**
|
|
209
273
|
* Tạo cuộc trò chuyện 1-1 hoặc lấy cuộc trò chuyện cũ nếu đã tồn tại.
|
|
210
274
|
* @param receiverId ID người nhận (Number, bắt buộc)
|
|
@@ -274,6 +338,14 @@ export interface ChatInstance {
|
|
|
274
338
|
message_id: number;
|
|
275
339
|
member_id: number;
|
|
276
340
|
}>;
|
|
341
|
+
/**
|
|
342
|
+
* Lấy danh sách tin nhắn hệ thống (system messages)
|
|
343
|
+
* @param limit Số lượng tin nhắn (Number, tùy chọn, mặc định 20)
|
|
344
|
+
* @param page Trang (Number, tùy chọn, mặc định 1)
|
|
345
|
+
*/
|
|
346
|
+
getSystemMessages(limit?: number, page?: number): Promise<ChatResponse<ChatMessage[]> & {
|
|
347
|
+
pagination?: PaginationInfo;
|
|
348
|
+
}>;
|
|
277
349
|
EVENTS: ChatEvent;
|
|
278
350
|
/**
|
|
279
351
|
* Đăng ký lắng nghe sự kiện realtime
|
|
@@ -295,3 +367,4 @@ export interface ChatInstance {
|
|
|
295
367
|
runEvent<K extends keyof ChatEventPayloads>(name: K | string, data?: ChatEventPayloads[K]): void;
|
|
296
368
|
}
|
|
297
369
|
export type ChatConstructor = new (workspace?: string) => ChatInstance;
|
|
370
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type WidgetMode = 'closed' | 'popup' | 'fullpage';
|
|
2
|
+
export type WidgetChatTab = 'chats' | 'contacts' | 'supports' | 'settings';
|
|
3
|
+
export type WidgetContactTab = 'members' | 'groups';
|
|
4
|
+
export type WidgetSettingTab = 'theme' | 'account' | 'chatlive';
|
|
5
|
+
export type WidgetSubChatTab = '' | WidgetContactTab | WidgetSettingTab;
|
|
6
|
+
export interface PositionWidget {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
export interface WidgetSize {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FormField } from './chat.type';
|
|
2
|
+
export type OnboardingData = {
|
|
3
|
+
name: string;
|
|
4
|
+
} & Record<string, string | undefined>;
|
|
5
|
+
export type Primitive = string | number | boolean | null | undefined;
|
|
6
|
+
export interface DeepData {
|
|
7
|
+
[key: string]: Primitive | DeepData;
|
|
8
|
+
}
|
|
9
|
+
export interface OnboardingEdgeCase {
|
|
10
|
+
match_keywords: string[];
|
|
11
|
+
override_value: string;
|
|
12
|
+
override_message?: string;
|
|
13
|
+
next_step: string;
|
|
14
|
+
}
|
|
15
|
+
export interface OnboardingOption {
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
next_step: string;
|
|
19
|
+
}
|
|
20
|
+
export interface OnboardingValidation {
|
|
21
|
+
rule: string;
|
|
22
|
+
value: string | number | string[];
|
|
23
|
+
error_message: string;
|
|
24
|
+
}
|
|
25
|
+
export interface OnboardingStepConfig {
|
|
26
|
+
type: 'text_input' | 'quick_reply' | 'system_action' | 'interactive_input' | 'form_input';
|
|
27
|
+
save_variable?: keyof OnboardingData | null;
|
|
28
|
+
bot_message: string;
|
|
29
|
+
next_step: string;
|
|
30
|
+
validation?: OnboardingValidation;
|
|
31
|
+
edge_cases?: OnboardingEdgeCase[];
|
|
32
|
+
options?: OnboardingOption[];
|
|
33
|
+
action_name?: string;
|
|
34
|
+
fields?: FormField[];
|
|
35
|
+
submit_button_label?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface OnboardingConfigJSON {
|
|
38
|
+
meta: {
|
|
39
|
+
version: string;
|
|
40
|
+
bot_name: string;
|
|
41
|
+
start_step: string;
|
|
42
|
+
end_step: string;
|
|
43
|
+
};
|
|
44
|
+
steps: Record<string, OnboardingStepConfig>;
|
|
45
|
+
}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
export type WidgetMode = 'closed' | 'popup' | 'fullpage';
|
|
2
1
|
export interface AuthInfo {
|
|
3
|
-
code
|
|
2
|
+
code?: string;
|
|
4
3
|
name: string;
|
|
5
4
|
avatar?: string;
|
|
6
5
|
phone?: string;
|
|
7
|
-
email
|
|
6
|
+
email?: string;
|
|
8
7
|
}
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
/**
|
|
9
|
+
* Phạm vi hoạt động (Ngữ cảnh môi trường) của Chat Widget.
|
|
10
|
+
*
|
|
11
|
+
* - `external`: Widget được nhúng vào các website bên ngoài (phục vụ khách vãng lai và admin).
|
|
12
|
+
* - `internal`: Widget chạy nội bộ trong hệ thống/app SaOne (phục vụ cho thành viên - member).
|
|
13
|
+
*/
|
|
14
|
+
export type WidgetScope = 'external' | 'internal';
|
|
15
|
+
export type WidgetRole = 'guest' | 'admin' | 'member';
|
|
16
|
+
/**
|
|
17
|
+
* Vị trí tính theo tọa độ
|
|
18
|
+
*
|
|
19
|
+
* - right: Khoảng cách từ mép phải của cửa sổ trình duyệt đến điểm đặt widget.
|
|
20
|
+
* - bottom: Khoảng cách từ mép dưới của cửa sổ trình duyệt đến điểm đặt widget.
|
|
12
21
|
*/
|
|
13
22
|
export interface PositionType {
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
right: number;
|
|
24
|
+
bottom: number;
|
|
16
25
|
}
|
|
17
26
|
/** Các loại định dạng tập tin được phép đính kèm từ thiết bị */
|
|
18
27
|
export type AttachmentType = 'image' | 'video' | 'audio' | 'file' | 'multiple';
|
|
@@ -33,8 +42,10 @@ export type WidgetChatMode = 'single' | 'group';
|
|
|
33
42
|
* Các tùy chọn can thiệp và mở rộng giao diện Widget.
|
|
34
43
|
* - 'change-color': Người dùng cuối có thể tự chọn màu chủ đạo (Primary Color).
|
|
35
44
|
* - 'change-theme': Người dùng cuối có thể chuyển đổi giữa các chủ đề (ví dụ: Sáng/Tối).
|
|
45
|
+
* - 'drag-and-drop': Hiển thị cấu hình toggle kéo thả để thay đổi vị trí của widget trên màn hình.
|
|
46
|
+
* - 'resize-window': Cho phép người dùng thay đổi kích thước cửa sổ chat bằng cách kéo thả cạnh cửa sổ.
|
|
36
47
|
*/
|
|
37
|
-
export type WidgetCustomizationOptions = 'change-color' | 'change-theme';
|
|
48
|
+
export type WidgetCustomizationOptions = 'change-color' | 'change-theme' | 'drag-and-drop' | 'resize-window';
|
|
38
49
|
export interface WidgetFeature {
|
|
39
50
|
/** Danh sách các loại tập tin cho phép tải lên. Nếu có 'multiple', cho phép chọn nhiều file. */
|
|
40
51
|
attachments?: AttachmentType[];
|
|
@@ -49,8 +60,9 @@ export interface WidgetFeature {
|
|
|
49
60
|
customizations?: WidgetCustomizationOptions[];
|
|
50
61
|
}
|
|
51
62
|
export interface ChatWidgetProps {
|
|
63
|
+
scope?: WidgetScope;
|
|
52
64
|
title?: string;
|
|
53
|
-
workspace
|
|
65
|
+
workspace?: string;
|
|
54
66
|
logoUrl?: string;
|
|
55
67
|
primaryColor?: string;
|
|
56
68
|
auth: AuthInfo;
|
|
@@ -58,4 +70,5 @@ export interface ChatWidgetProps {
|
|
|
58
70
|
features?: WidgetFeature;
|
|
59
71
|
language?: LanguageOption;
|
|
60
72
|
initPosition?: PositionType;
|
|
73
|
+
disabledMembers?: string[];
|
|
61
74
|
}
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import { AttachmentType, ChatConversation, ChatUser, CommunicationFeature, WidgetChatMode, WidgetCustomizationOptions,
|
|
1
|
+
import { AttachmentType, AuthInfo, ChatConversation, ChatUser, CommunicationFeature, WidgetChatMode, WidgetCustomizationOptions, WidgetRole, WidgetScope } from '../../types';
|
|
2
2
|
export declare const getChatName: (chat?: ChatConversation | null, currentUserId?: number, fallback?: string) => string;
|
|
3
|
+
export declare const getRoleSystem: (scope?: WidgetScope, auth?: AuthInfo) => WidgetRole;
|
|
3
4
|
export interface FeatureSet {
|
|
4
5
|
attachments: Set<AttachmentType>;
|
|
5
6
|
communication: Set<CommunicationFeature>;
|
|
6
7
|
chatModes: Set<WidgetChatMode>;
|
|
7
8
|
customizations: Set<WidgetCustomizationOptions>;
|
|
8
9
|
}
|
|
9
|
-
export interface FeatureAnalysis {
|
|
10
|
-
featureSet: FeatureSet;
|
|
11
|
-
hasVoice: boolean;
|
|
12
|
-
hasAttachment: boolean;
|
|
13
|
-
hasMultipleAttachments: boolean;
|
|
14
|
-
hasGroupChat: boolean;
|
|
15
|
-
hasSingleChat: boolean;
|
|
16
|
-
hasChangeColor: boolean;
|
|
17
|
-
hasMultipleLanguages: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare const analyzeFeatures: (features: WidgetFeature, hasMultipleLanguages?: boolean) => FeatureAnalysis;
|
|
20
10
|
export declare const getAcceptFilter: (featureSet: FeatureSet) => string;
|
|
21
11
|
export declare const createFileTypeChecker: (featureSet: FeatureSet) => (file: File) => boolean;
|
|
22
12
|
export declare const isConnected: (socketAt: string | undefined) => boolean;
|
|
@@ -33,3 +23,8 @@ export declare const transformMember: (member: ChatUser, memberSocketMap: Record
|
|
|
33
23
|
email: string;
|
|
34
24
|
last_read_id?: number;
|
|
35
25
|
};
|
|
26
|
+
export declare const getContrastColor: (hex: string) => "#ffffff" | "#1e293b";
|
|
27
|
+
export declare const generateGuestCode: () => string;
|
|
28
|
+
export declare const getChatTimestamp: (chat: ChatConversation) => number;
|
|
29
|
+
export declare const sortChatsByRecency: (chats: ChatConversation[] | undefined) => ChatConversation[];
|
|
30
|
+
export declare const calculateTotalUnread: (chats: ChatConversation[], currentUserId: number) => number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DeepData } from '../../types';
|
|
2
|
+
export declare const interpolateString: <T extends DeepData>(template: string, data: T) => string;
|
|
3
|
+
export declare const PHONE_REGEX: RegExp;
|
|
4
|
+
export declare const EMAIL_REGEX: RegExp;
|
|
5
|
+
export declare const evaluateCondition: (rule: string, value: unknown, input: string) => boolean;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { CSSProperties
|
|
2
|
-
/**
|
|
3
|
-
* Lấy icon dựa trên tên file hoặc extension
|
|
4
|
-
* @param fileNameOrExt Có thể là "image.png" hoặc chỉ "png"
|
|
5
|
-
*/
|
|
6
|
-
export declare const getFileIcon: (fileNameOrExt: string) => JSX.Element;
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
7
2
|
export declare const getFileKey: (file: File) => string | undefined;
|
|
8
3
|
export declare const formatFileSize: (bytes: number) => string;
|
|
9
4
|
export declare const getFileType: (fileName: string) => "image" | "video" | "audio" | "pdf" | "other";
|
|
5
|
+
export declare const getFileExt: (fileName: string) => string;
|
|
10
6
|
export declare const getImagePreview: (file: File) => string;
|
|
11
7
|
export declare const isImageFile: (file: File) => boolean;
|
|
8
|
+
export declare const isAudioFile: (file: File) => boolean;
|
|
9
|
+
export declare const getAudioPreview: (file: File) => string;
|
|
12
10
|
export declare const sortFilesByType: (files: File[]) => File[];
|
|
13
11
|
export declare const sanitizeImage: (file: File) => Promise<File>;
|
|
14
12
|
export declare const getFilesValidationError: (files: File[], hasMultipleAttachments: boolean, isFileTypeAllowed: (file: File) => boolean) => Promise<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LanguageOption } from '../../types';
|
|
2
|
-
export declare const formatDateLabel: (dateStr: string | Date, currentLanguage: LanguageOption) => string;
|
|
3
2
|
export declare const formatDuration: (ms: number) => string;
|
|
4
3
|
export declare const removeVietnameseTones: (str: string) => string;
|
|
5
4
|
export declare const formatToDateTimeString: (dateInput: string | number | Date) => string;
|
|
6
5
|
export declare const getCleanTitle: (url: string) => string | null;
|
|
7
6
|
export declare const formatMessageTime: (dateInput: Date, language: LanguageOption) => string;
|
|
7
|
+
export declare const formatMessageDateShort: (dateInput: Date, language: LanguageOption) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const highlightText: (text: string, query: string) => string | import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@satek-team-intern/chatbot-widget",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "A widget chatbot can be integrated into any website, providing a seamless and interactive user experience. It is designed to be easily embedded and customizable, allowing businesses to engage with their customers effectively.",
|
|
5
5
|
"author": "Satek Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@eslint/js": "^10.0.1",
|
|
54
|
+
"@types/node": "^25.9.1",
|
|
54
55
|
"@types/react": "^19.2.14",
|
|
55
56
|
"@types/react-dom": "^19.2.3",
|
|
56
57
|
"@vitejs/plugin-react": "^6.0.1",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ChatUser } from '../../../types';
|
|
3
|
-
interface AddChatProps {
|
|
4
|
-
isOpen: boolean;
|
|
5
|
-
onClose: () => void;
|
|
6
|
-
members: ChatUser[];
|
|
7
|
-
selectedMembers: string[];
|
|
8
|
-
onToggleMember: (userId: string) => void;
|
|
9
|
-
newGroupName: string;
|
|
10
|
-
onNewGroupNameChange: (name: string) => void;
|
|
11
|
-
modalSearchQuery: string;
|
|
12
|
-
onModalSearchQueryChange: (query: string) => void;
|
|
13
|
-
onCreateChat: () => void;
|
|
14
|
-
}
|
|
15
|
-
export declare const AddChat: FC<AddChatProps>;
|
|
16
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ChatConversation, ChatUser } from '../../../types';
|
|
3
|
-
interface SideBarInfoChatProps {
|
|
4
|
-
currentUser: ChatUser | null;
|
|
5
|
-
onClose: () => void;
|
|
6
|
-
onAddMember: () => void;
|
|
7
|
-
onUpdateGroup?: (chat: ChatConversation) => void;
|
|
8
|
-
onRemoveMember?: (chatId: number, memberId: number) => void;
|
|
9
|
-
}
|
|
10
|
-
declare const SideBarInfoChat: FC<SideBarInfoChatProps>;
|
|
11
|
-
export { SideBarInfoChat };
|