@satek-team-intern/chatbot-widget 0.11.0 → 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/dist/chatbot-widget.umd.js +9 -1
- package/dist/constants/scenario_guest_vi.json.d.ts +103 -0
- package/dist/locales/en.json.d.ts +331 -0
- package/dist/locales/vi.json.d.ts +332 -0
- package/dist/src/assets/Icons.d.ts +67 -0
- package/dist/src/assets/createIcon.d.ts +24 -0
- package/dist/src/assets/index.d.ts +2 -0
- package/dist/src/components/ChatWidget.d.ts +3 -0
- package/dist/src/components/ChatWindow.d.ts +3 -0
- package/dist/src/components/FloatingButton.d.ts +1 -0
- 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 +8 -0
- package/dist/src/components/modals/AddGroup.d.ts +6 -0
- package/dist/src/components/modals/AddMember.d.ts +6 -0
- package/dist/src/components/modals/FileViewer.d.ts +10 -0
- package/dist/src/components/modals/UpdateGroup.d.ts +8 -0
- package/dist/src/components/modals/UserProfileModal.d.ts +1 -0
- package/dist/src/components/modals/index.d.ts +5 -0
- package/dist/src/components/shared/AvatarFallBack.d.ts +5 -0
- 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/ToastContainer.d.ts +2 -0
- package/dist/src/components/shared/index.d.ts +4 -0
- package/dist/src/components/sidebar/AppSideBar.d.ts +1 -0
- package/dist/src/components/sidebar/ChatInfoPanel.d.ts +10 -0
- package/dist/src/components/sidebar/ChatList.d.ts +7 -0
- package/dist/src/components/sidebar/ChatSearchBar.d.ts +9 -0
- package/dist/src/components/sidebar/ChatSidebar.d.ts +9 -0
- package/dist/src/components/sidebar/index.d.ts +5 -0
- package/dist/src/components/view/ChatHeader.d.ts +10 -0
- package/dist/src/components/view/ChatInput.d.ts +4 -0
- package/dist/src/components/view/ChatListItem.d.ts +7 -0
- 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 +6 -0
- 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 +9 -0
- package/dist/src/components/view/ImageFileItem.d.ts +10 -0
- package/dist/src/components/view/MessageFiles.d.ts +23 -0
- package/dist/src/components/view/MessageItem.d.ts +7 -0
- package/dist/src/components/view/MessageList.d.ts +2 -0
- package/dist/src/components/view/SettingSection.d.ts +1 -0
- package/dist/src/components/view/ThemeSetting.d.ts +1 -0
- package/dist/src/components/view/WindowResizeHandles.d.ts +6 -0
- package/dist/src/components/view/index.d.ts +16 -0
- package/dist/src/config/configEnv.d.ts +11 -0
- package/dist/src/constants/common.d.ts +15 -0
- package/dist/src/constants/file.d.ts +3 -0
- package/dist/src/constants/index.d.ts +6 -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/contexts/FileViewerContext.d.ts +14 -0
- package/dist/src/contexts/ToastContext.d.ts +4 -0
- package/dist/src/contexts/index.d.ts +3 -0
- package/dist/src/contexts/toast-context.d.ts +16 -0
- package/dist/src/hooks/index.d.ts +13 -0
- package/dist/src/hooks/useChat.d.ts +2 -0
- 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/useDragDropFiles.d.ts +12 -0
- package/dist/src/hooks/useFileViewer.d.ts +2 -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 +8 -0
- package/dist/src/hooks/useToast.d.ts +1 -0
- package/dist/src/hooks/useTranslation.d.ts +5 -0
- package/dist/src/hooks/useVoiceRecorder.d.ts +14 -0
- package/dist/src/hooks/useWindowControls.d.ts +14 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/locales/index.d.ts +3 -0
- package/dist/src/services/chat.service.d.ts +42 -0
- package/dist/src/services/chatManager.service.d.ts +16 -0
- package/dist/src/services/index.d.ts +3 -0
- package/dist/src/services/language.service.d.ts +18 -0
- package/dist/src/store/index.d.ts +3 -0
- package/dist/src/store/selectors/chat.d.ts +5 -0
- package/dist/src/store/selectors/index.d.ts +2 -0
- package/dist/src/store/selectors/setting.d.ts +4 -0
- package/dist/src/store/slices/chatSlice.d.ts +128 -0
- package/dist/src/store/slices/index.d.ts +4 -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 +16 -0
- package/dist/src/store/store.d.ts +20 -0
- package/dist/src/types/chat.type.d.ts +370 -0
- package/dist/src/types/index.d.ts +4 -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 +74 -0
- package/dist/src/utils/chat.utils.d.ts +30 -0
- package/dist/src/utils/engine.utils.d.ts +5 -0
- package/dist/src/utils/file.utils.d.ts +18 -0
- package/dist/src/utils/format.utils.d.ts +7 -0
- package/dist/src/utils/index.d.ts +7 -0
- package/dist/src/utils/text.utils.d.ts +1 -0
- package/dist/src/utils/validate.utils.d.ts +1 -0
- package/dist/src/utils/voice.utils.d.ts +1 -0
- package/package.json +7 -5
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export interface AuthInfo {
|
|
2
|
+
code?: string;
|
|
3
|
+
name: string;
|
|
4
|
+
avatar?: string;
|
|
5
|
+
phone?: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
}
|
|
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.
|
|
21
|
+
*/
|
|
22
|
+
export interface PositionType {
|
|
23
|
+
right: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
}
|
|
26
|
+
/** Các loại định dạng tập tin được phép đính kèm từ thiết bị */
|
|
27
|
+
export type AttachmentType = 'image' | 'video' | 'audio' | 'file' | 'multiple';
|
|
28
|
+
/** Các tùy chọn ngôn ngữ hiển thị trên giao diện */
|
|
29
|
+
export type LanguageOption = 'english' | 'vietnamese';
|
|
30
|
+
/**
|
|
31
|
+
* Các phương thức truyền thông và ghi hình.
|
|
32
|
+
* - 'voice': Ghi âm và gửi tin nhắn thoại.
|
|
33
|
+
*/
|
|
34
|
+
export type CommunicationFeature = 'voice';
|
|
35
|
+
/**
|
|
36
|
+
* Chế độ vận hành của cửa sổ chat.
|
|
37
|
+
* - 'single': Chat 1-1.
|
|
38
|
+
* - 'group': Chế độ chat nhóm nhiều người tham gia.
|
|
39
|
+
*/
|
|
40
|
+
export type WidgetChatMode = 'single' | 'group';
|
|
41
|
+
/**
|
|
42
|
+
* Các tùy chọn can thiệp và mở rộng giao diện Widget.
|
|
43
|
+
* - 'change-color': Người dùng cuối có thể tự chọn màu chủ đạo (Primary Color).
|
|
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ổ.
|
|
47
|
+
*/
|
|
48
|
+
export type WidgetCustomizationOptions = 'change-color' | 'change-theme' | 'drag-and-drop' | 'resize-window';
|
|
49
|
+
export interface WidgetFeature {
|
|
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. */
|
|
51
|
+
attachments?: AttachmentType[];
|
|
52
|
+
/** Các tính năng tương tác trực tiếp bằng âm thanh và hình ảnh. */
|
|
53
|
+
communication?: CommunicationFeature[];
|
|
54
|
+
/**
|
|
55
|
+
* Xác định các hình thức hội thoại mà widget hỗ trợ.
|
|
56
|
+
* Nếu không truyền, mặc định là ['single']
|
|
57
|
+
*/
|
|
58
|
+
chatModes?: WidgetChatMode[];
|
|
59
|
+
/** Các quyền tùy biến giao diện cho phép người dùng thực hiện. */
|
|
60
|
+
customizations?: WidgetCustomizationOptions[];
|
|
61
|
+
}
|
|
62
|
+
export interface ChatWidgetProps {
|
|
63
|
+
scope?: WidgetScope;
|
|
64
|
+
title?: string;
|
|
65
|
+
workspace?: string;
|
|
66
|
+
logoUrl?: string;
|
|
67
|
+
primaryColor?: string;
|
|
68
|
+
auth: AuthInfo;
|
|
69
|
+
chatKey: string;
|
|
70
|
+
features?: WidgetFeature;
|
|
71
|
+
language?: LanguageOption;
|
|
72
|
+
initPosition?: PositionType;
|
|
73
|
+
disabledMembers?: string[];
|
|
74
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AttachmentType, AuthInfo, ChatConversation, ChatUser, CommunicationFeature, WidgetChatMode, WidgetCustomizationOptions, WidgetRole, WidgetScope } from '../../types';
|
|
2
|
+
export declare const getChatName: (chat?: ChatConversation | null, currentUserId?: number, fallback?: string) => string;
|
|
3
|
+
export declare const getRoleSystem: (scope?: WidgetScope, auth?: AuthInfo) => WidgetRole;
|
|
4
|
+
export interface FeatureSet {
|
|
5
|
+
attachments: Set<AttachmentType>;
|
|
6
|
+
communication: Set<CommunicationFeature>;
|
|
7
|
+
chatModes: Set<WidgetChatMode>;
|
|
8
|
+
customizations: Set<WidgetCustomizationOptions>;
|
|
9
|
+
}
|
|
10
|
+
export declare const getAcceptFilter: (featureSet: FeatureSet) => string;
|
|
11
|
+
export declare const createFileTypeChecker: (featureSet: FeatureSet) => (file: File) => boolean;
|
|
12
|
+
export declare const isConnected: (socketAt: string | undefined) => boolean;
|
|
13
|
+
export declare const addSocketToMap: (memberSocketMap: Record<string, string[]>, memberId: string | number, // Chấp nhận cả string và number cho key
|
|
14
|
+
socketId: string | undefined) => void;
|
|
15
|
+
export declare const transformMember: (member: ChatUser, memberSocketMap: Record<string, string[]>, disconnectedSockets: Record<string, boolean>) => {
|
|
16
|
+
socket_id: string | undefined;
|
|
17
|
+
socket_at: string | undefined;
|
|
18
|
+
id: number;
|
|
19
|
+
code: string;
|
|
20
|
+
name: string;
|
|
21
|
+
avatar?: string;
|
|
22
|
+
phone?: string;
|
|
23
|
+
email: string;
|
|
24
|
+
last_read_id?: number;
|
|
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;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export declare const getFileKey: (file: File) => string | undefined;
|
|
3
|
+
export declare const formatFileSize: (bytes: number) => string;
|
|
4
|
+
export declare const getFileType: (fileName: string) => "image" | "video" | "audio" | "pdf" | "other";
|
|
5
|
+
export declare const getFileExt: (fileName: string) => string;
|
|
6
|
+
export declare const getImagePreview: (file: File) => string;
|
|
7
|
+
export declare const isImageFile: (file: File) => boolean;
|
|
8
|
+
export declare const isAudioFile: (file: File) => boolean;
|
|
9
|
+
export declare const getAudioPreview: (file: File) => string;
|
|
10
|
+
export declare const sortFilesByType: (files: File[]) => File[];
|
|
11
|
+
export declare const sanitizeImage: (file: File) => Promise<File>;
|
|
12
|
+
export declare const getFilesValidationError: (files: File[], hasMultipleAttachments: boolean, isFileTypeAllowed: (file: File) => boolean) => Promise<{
|
|
13
|
+
message: string;
|
|
14
|
+
type: "warning" | "error";
|
|
15
|
+
} | null>;
|
|
16
|
+
export declare const validateFileContent: (file: File) => Promise<boolean>;
|
|
17
|
+
export declare const validateFileUrlContent: (url: string, type: string) => Promise<boolean>;
|
|
18
|
+
export declare function getImageRatioStyleFromLink(imgUrl: string): Promise<CSSProperties>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LanguageOption } from '../../types';
|
|
2
|
+
export declare const formatDuration: (ms: number) => string;
|
|
3
|
+
export declare const removeVietnameseTones: (str: string) => string;
|
|
4
|
+
export declare const formatToDateTimeString: (dateInput: string | number | Date) => string;
|
|
5
|
+
export declare const getCleanTitle: (url: string) => string | null;
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isStandardUrl: (urlString: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const convertToMp3: (blob: Blob) => Promise<Blob>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@satek-team-intern/chatbot-widget",
|
|
3
|
-
"version": "0.11.
|
|
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",
|
|
@@ -18,17 +18,19 @@
|
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
21
|
+
"types": "./dist/src/index.d.ts",
|
|
22
22
|
"scripts": {
|
|
23
23
|
"dev": "vite",
|
|
24
|
-
"build": "
|
|
24
|
+
"build": "npm run build:es && npm run build:umd",
|
|
25
|
+
"build:es": "cross-env VITE_TARGET_FORMAT=es vite build",
|
|
26
|
+
"build:umd": "cross-env VITE_TARGET_FORMAT=umd vite build",
|
|
25
27
|
"lint": "eslint --fix",
|
|
26
28
|
"prepare": "husky",
|
|
27
|
-
"prepublishOnly": "npm run lint && npm run build"
|
|
29
|
+
"prepublishOnly": "npm run lint && npx tsc --noEmit && npm run build"
|
|
28
30
|
},
|
|
29
31
|
"exports": {
|
|
30
32
|
".": {
|
|
31
|
-
"types": "./dist/index.d.ts",
|
|
33
|
+
"types": "./dist/src/index.d.ts",
|
|
32
34
|
"import": "./dist/chatbot-widget.es.js",
|
|
33
35
|
"require": "./dist/chatbot-widget.umd.js"
|
|
34
36
|
}
|