@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,9 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { ChatInputHandle } from '../../../components';
|
|
3
|
+
interface ChatMainAreaProps {
|
|
4
|
+
isInfoSidebarOpen: boolean;
|
|
5
|
+
setIsInfoSidebarOpen: (isOpen: boolean) => void;
|
|
6
|
+
chatInputRef: RefObject<ChatInputHandle | null>;
|
|
7
|
+
}
|
|
8
|
+
export declare const ChatMainArea: ({ isInfoSidebarOpen, setIsInfoSidebarOpen, chatInputRef, }: ChatMainAreaProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface ChatMainHeaderProps {
|
|
2
|
+
isInfoSidebarOpen: boolean;
|
|
3
|
+
setIsInfoSidebarOpen: (isOpen: boolean) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const ChatMainHeader: ({ isInfoSidebarOpen, setIsInfoSidebarOpen, }: ChatMainHeaderProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ChatLiveSetting: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EmptyChatState: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ChatConversation } from '../../../types';
|
|
3
|
+
interface GroupListProps {
|
|
4
|
+
groups: ChatConversation[];
|
|
5
|
+
onGroupClick: (group: ChatConversation) => void;
|
|
6
|
+
onCreateGroupModalOpen: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const GroupList: FC<GroupListProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ChatFile } from '../../../types';
|
|
2
|
+
interface ImageFileItemProps {
|
|
3
|
+
file: ChatFile;
|
|
4
|
+
displayedImages: ChatFile[];
|
|
5
|
+
hasMoreImages: boolean;
|
|
6
|
+
remainingImagesCount: number;
|
|
7
|
+
handleImageClick: (file: ChatFile) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const ImageFileItem: ({ file, displayedImages, hasMoreImages, remainingImagesCount, handleImageClick, }: ImageFileItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FC, ReactNode, MouseEvent, CSSProperties } from 'react';
|
|
2
|
+
import { ChatFile } from '../../../types';
|
|
3
|
+
interface MessageFilesProps {
|
|
4
|
+
files?: ChatFile[];
|
|
5
|
+
}
|
|
6
|
+
interface FileWrapperProps {
|
|
7
|
+
file: ChatFile;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
isLink?: boolean;
|
|
11
|
+
handleImageClick?: (file: ChatFile) => void;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
export declare const FileWrapper: ({ file, children, className, isLink, handleImageClick, style, }: FileWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const DefaultFileUI: ({ file, handleDownload, }: {
|
|
16
|
+
file: ChatFile;
|
|
17
|
+
handleDownload: (e: MouseEvent, file: ChatFile) => void;
|
|
18
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare const AudioFileItem: ({ file }: {
|
|
20
|
+
file: ChatFile;
|
|
21
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const MessageFiles: FC<MessageFilesProps>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SettingSection: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ThemeSetting: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
interface WindowResizeHandlesProps {
|
|
3
|
+
onResizeMouseDown: (e: MouseEvent<HTMLDivElement, globalThis.MouseEvent>, direction: 'nw' | 'ne' | 'sw' | 'se' | 'n' | 's' | 'e' | 'w') => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const WindowResizeHandles: ({ onResizeMouseDown, }: WindowResizeHandlesProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './ChatHeader';
|
|
2
|
+
export * from './ChatInput';
|
|
3
|
+
export * from './ContactList';
|
|
4
|
+
export * from './GroupList';
|
|
5
|
+
export * from './MessageFiles';
|
|
6
|
+
export * from './MessageItem';
|
|
7
|
+
export * from './MessageList';
|
|
8
|
+
export * from './ChatListItem';
|
|
9
|
+
export * from './ImageFileItem';
|
|
10
|
+
export * from './ThemeSetting';
|
|
11
|
+
export * from './WindowResizeHandles';
|
|
12
|
+
export * from './EmptyChatState';
|
|
13
|
+
export * from './ChatMainHeader';
|
|
14
|
+
export * from './ChatMainArea';
|
|
15
|
+
export * from './ChatliveSetting';
|
|
16
|
+
export * from './SettingSection';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChatUser, LanguageOption } from '../../types';
|
|
2
|
+
export declare const COMMON_EMOJIS: string[];
|
|
3
|
+
export declare const COLOR_PRESETS: {
|
|
4
|
+
name: string;
|
|
5
|
+
className: string;
|
|
6
|
+
value: string;
|
|
7
|
+
dotClass: string;
|
|
8
|
+
}[];
|
|
9
|
+
export declare const EXTRACT_URL_REGEX: RegExp;
|
|
10
|
+
export declare const LOCAL_OR_IP_REGEX: RegExp;
|
|
11
|
+
export declare const GENERAL_URL_REGEX: RegExp;
|
|
12
|
+
export declare const MESSAGE_LIMIT = 500;
|
|
13
|
+
export declare const DEFAULT_LANGUAGE: LanguageOption;
|
|
14
|
+
export declare const SYSTEM_CHAT_ID = -100;
|
|
15
|
+
export declare const SYSTEM_CHAT_ACCOUNT: ChatUser;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PERMISSIONS, PermissionType } from './permissions';
|
|
2
|
+
import { ChatSetting, WidgetRole } from '../../types';
|
|
3
|
+
import { FeatureSet } from '../../utils';
|
|
4
|
+
export interface PermissionContext {
|
|
5
|
+
role: WidgetRole;
|
|
6
|
+
featureSet: FeatureSet;
|
|
7
|
+
chatSetting: ChatSetting | undefined;
|
|
8
|
+
isAdmin: boolean;
|
|
9
|
+
isGuest: boolean;
|
|
10
|
+
hasMultipleLanguages?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface PermissionPayloadMap {
|
|
13
|
+
[PERMISSIONS.DELETE_MESSAGE]: {
|
|
14
|
+
messageCreatedTime: string;
|
|
15
|
+
};
|
|
16
|
+
[PERMISSIONS.REVOKE_MESSAGE]: {
|
|
17
|
+
messageCreatedTime: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export type GetPayload<T extends PermissionType> = T extends keyof PermissionPayloadMap ? PermissionPayloadMap[T] : undefined;
|
|
21
|
+
type PermissionRulesConfig = {
|
|
22
|
+
[K in PermissionType]: (ctx: PermissionContext, payload: GetPayload<K>) => boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare const PERMISSION_RULES: PermissionRulesConfig;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const PERMISSIONS: {
|
|
2
|
+
readonly DELETE_CHAT: "delete_chat";
|
|
3
|
+
readonly DELETE_MESSAGE: "delete_message";
|
|
4
|
+
readonly REVOKE_MESSAGE: "revoke_message";
|
|
5
|
+
readonly USE_VOICE: "use_voice";
|
|
6
|
+
readonly USE_IMAGE_ATTACHMENT: "use_image_attachment";
|
|
7
|
+
readonly USE_ATTACHMENT: "use_attachment";
|
|
8
|
+
readonly USE_MULTIPLE_ATTACHMENTS: "use_multiple_attachments";
|
|
9
|
+
readonly USE_GROUP_CHAT: "use_group_chat";
|
|
10
|
+
readonly CHANGE_COLOR: "change_color";
|
|
11
|
+
readonly USE_MULTIPLE_LANGUAGES: "use_multiple_languages";
|
|
12
|
+
readonly USE_DRAG_AND_DROP: "use_drag_and_drop";
|
|
13
|
+
readonly USE_RESIZE_WINDOW: "use_resize_window";
|
|
14
|
+
};
|
|
15
|
+
export type PermissionType = (typeof PERMISSIONS)[keyof typeof PERMISSIONS];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { ChatFile } from '../../types';
|
|
3
|
+
export interface FileViewerContextType {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
files: ChatFile[];
|
|
6
|
+
initialIndex: number;
|
|
7
|
+
openViewer: (files: ChatFile[], initialIndex?: number) => void;
|
|
8
|
+
closeViewer: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const FileViewerContext: import('react').Context<FileViewerContextType | undefined>;
|
|
11
|
+
export { FileViewerContext };
|
|
12
|
+
export declare const FileViewerProvider: FC<{
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type ToastType = 'success' | 'error' | 'info' | 'warning';
|
|
2
|
+
export interface Toast {
|
|
3
|
+
id: string;
|
|
4
|
+
message: string;
|
|
5
|
+
type: ToastType;
|
|
6
|
+
isConfirm?: boolean;
|
|
7
|
+
onConfirm?: () => void;
|
|
8
|
+
onCancel?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface ToastContextType {
|
|
11
|
+
showToast: (message: string, type?: ToastType) => void;
|
|
12
|
+
confirm: (message: string) => Promise<boolean>;
|
|
13
|
+
removeToast: (id: string) => void;
|
|
14
|
+
toasts: Toast[];
|
|
15
|
+
}
|
|
16
|
+
export declare const ToastContext: import('react').Context<ToastContextType | undefined>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './useChat';
|
|
2
|
+
export { useFileViewer } from './useFileViewer';
|
|
3
|
+
export { useDragDropFiles } from './useDragDropFiles';
|
|
4
|
+
export { useVoiceRecorder } from './useVoiceRecorder';
|
|
5
|
+
export { useTranslation } from './useTranslation';
|
|
6
|
+
export { useToast } from './useToast';
|
|
7
|
+
export { useSetting } from './useSetting';
|
|
8
|
+
export { useChatSearch } from './useChatSearch';
|
|
9
|
+
export { useWindowControls } from './useWindowControls';
|
|
10
|
+
export { useChatActions } from './useChatActions';
|
|
11
|
+
export { useChatWidget } from './useChatWidget';
|
|
12
|
+
export { useProcessOnboarding } from './useProcessOnboarding';
|
|
13
|
+
export { usePermissions } from './usePermissions';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ChatConversation } from '../../types';
|
|
2
|
+
export declare const useChatActions: ({ setIsModalOpen, setIsUpdateGroupOpen, setUpdatingGroup, }: {
|
|
3
|
+
setIsModalOpen: (isOpen: boolean) => void;
|
|
4
|
+
setIsUpdateGroupOpen: (isOpen: boolean) => void;
|
|
5
|
+
setUpdatingGroup: (chat: ChatConversation | null) => void;
|
|
6
|
+
}) => {
|
|
7
|
+
removeMember: (chatId: number, memberId: number) => Promise<void>;
|
|
8
|
+
handleCreateChat: (directMemberId: string) => Promise<void>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ChatConversation, ChatFile, ChatMessage, ChatUser } from '../../types';
|
|
2
|
+
interface SearchChatConversation extends ChatConversation {
|
|
3
|
+
matchedMemberNames?: string[];
|
|
4
|
+
}
|
|
5
|
+
type ChatSearchResultType = {
|
|
6
|
+
filteredChat: ChatConversation[];
|
|
7
|
+
matchedMembers: never[];
|
|
8
|
+
matchedMessages: never[];
|
|
9
|
+
matchedFiles: never[];
|
|
10
|
+
totalMatchedFiles: number;
|
|
11
|
+
} | {
|
|
12
|
+
filteredChat: SearchChatConversation[];
|
|
13
|
+
matchedMembers: ChatUser[];
|
|
14
|
+
matchedMessages: {
|
|
15
|
+
chat: ChatConversation;
|
|
16
|
+
message: ChatMessage | null;
|
|
17
|
+
}[];
|
|
18
|
+
matchedFiles: {
|
|
19
|
+
chat: ChatConversation;
|
|
20
|
+
files: ChatFile[];
|
|
21
|
+
}[];
|
|
22
|
+
totalMatchedFiles: number;
|
|
23
|
+
};
|
|
24
|
+
export declare const useChatSearch: (deferredChatQuery: string, chatFilter: string) => {
|
|
25
|
+
searchResult: ChatSearchResultType;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DragEvent } from 'react';
|
|
2
|
+
interface DragDropFilesProps {
|
|
3
|
+
onFilesAdded: (files: FileList) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const useDragDropFiles: ({ onFilesAdded }: DragDropFilesProps) => {
|
|
6
|
+
isDragOver: boolean;
|
|
7
|
+
handleDragEnter: (e: DragEvent<HTMLDivElement>) => void;
|
|
8
|
+
handleDragOver: (e: DragEvent<HTMLDivElement>) => void;
|
|
9
|
+
handleDragLeave: (e: DragEvent<HTMLDivElement>) => void;
|
|
10
|
+
handleDrop: (e: DragEvent<HTMLDivElement>) => void;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GetPayload, PermissionType } from '../../constants';
|
|
2
|
+
interface WidgetSettings {
|
|
3
|
+
hasPermission: <T extends PermissionType>(type: T, ...args: GetPayload<T> extends undefined ? [] : [payload: GetPayload<T>]) => boolean;
|
|
4
|
+
acceptFilter: string;
|
|
5
|
+
isFileTypeAllowed: (file: File) => boolean;
|
|
6
|
+
isGuest: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const usePermissions: () => WidgetSettings;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AuthInfo, LanguageOption, PositionType, WidgetFeature, WidgetScope } from '../../types';
|
|
2
|
+
export declare const useSetting: (config?: {
|
|
3
|
+
scope?: WidgetScope;
|
|
4
|
+
features?: WidgetFeature;
|
|
5
|
+
language?: LanguageOption;
|
|
6
|
+
auth?: AuthInfo;
|
|
7
|
+
initPosition?: PositionType;
|
|
8
|
+
}) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useToast: () => import('../../contexts').ToastContextType;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const useTranslation: () => {
|
|
2
|
+
t: (path: import('../../services').NestedKeys<import('../../services').TranslationSchema>, params?: Record<string, string>) => string;
|
|
3
|
+
currentLanguage: import('../types').LanguageOption;
|
|
4
|
+
toggleChangeLanguage: () => void;
|
|
5
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface VoiceRecorderState {
|
|
2
|
+
isRecording: boolean;
|
|
3
|
+
duration: number;
|
|
4
|
+
recordedFile: File | null;
|
|
5
|
+
error: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface VoiceRecorderHandle {
|
|
8
|
+
startRecording: () => Promise<void>;
|
|
9
|
+
stopRecording: () => Promise<File | null>;
|
|
10
|
+
cancelRecording: () => void;
|
|
11
|
+
playback: () => void;
|
|
12
|
+
clearRecording: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const useVoiceRecorder: () => [VoiceRecorderState, VoiceRecorderHandle];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MouseEvent, RefObject } from 'react';
|
|
2
|
+
interface UseWindowControlsProps {
|
|
3
|
+
chatWindowRef: RefObject<HTMLDivElement | null>;
|
|
4
|
+
}
|
|
5
|
+
export declare const useWindowControls: (props: UseWindowControlsProps) => {
|
|
6
|
+
handleMouseDown: (e: MouseEvent<HTMLDivElement>) => void;
|
|
7
|
+
handleResizeMouseDown: (e: MouseEvent<HTMLDivElement>, direction: 'nw' | 'ne' | 'sw' | 'se' | 'n' | 's' | 'e' | 'w') => void;
|
|
8
|
+
toggleFullScreen: () => void;
|
|
9
|
+
safePos: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
} | null;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AuthInfo, ChatEventPayloads, ChatResponse, ChatConversation, ChatMessage, ChatConfig, PaginationInfo, MessageAction, ChatUser, ChatSetting } from '../../types';
|
|
2
|
+
export declare class ChatService {
|
|
3
|
+
private chatSDK;
|
|
4
|
+
accountCode: string;
|
|
5
|
+
constructor(accountCode: string);
|
|
6
|
+
init(workspace?: string): void;
|
|
7
|
+
get setting(): ChatSetting;
|
|
8
|
+
setAuth(data: AuthInfo): Promise<ChatUser>;
|
|
9
|
+
getAuth(): ChatUser | null;
|
|
10
|
+
clearAuth(): void;
|
|
11
|
+
setReceiver(data: ChatUser): Promise<ChatResponse<ChatUser>>;
|
|
12
|
+
getReceiver(): ChatUser | null;
|
|
13
|
+
clearReceiver(): void;
|
|
14
|
+
getMembers(chatId?: number | null, limit?: number, page?: number, include?: string): Promise<ChatResponse<ChatUser[]>>;
|
|
15
|
+
addMember(chatId: number, memberId: number): Promise<ChatResponse>;
|
|
16
|
+
removeMember(chatId: number, memberId: number): Promise<ChatResponse>;
|
|
17
|
+
getChats(limit?: number, page?: number): Promise<ChatResponse<ChatConversation[]> & {
|
|
18
|
+
pagination?: PaginationInfo;
|
|
19
|
+
}>;
|
|
20
|
+
findChatByReceiver(receiverId: number | string): Promise<ChatConversation | undefined>;
|
|
21
|
+
addChat(receiverId: number, content?: string): Promise<ChatResponse<ChatConversation>>;
|
|
22
|
+
addGroup(memberIds: number[], name: string, avatar?: string | File, userId?: number): Promise<ChatResponse<ChatConversation>>;
|
|
23
|
+
updateGroup(chatId: number, name: string, avatar?: string | File): Promise<ChatResponse<ChatConversation>>;
|
|
24
|
+
removeChat(chatId: number): Promise<ChatResponse>;
|
|
25
|
+
readChat(chatId: number): Promise<ChatResponse>;
|
|
26
|
+
unreadChat(chatId: number): Promise<ChatResponse>;
|
|
27
|
+
getMessages(chatId: number, limit?: number, page?: number): Promise<ChatResponse<ChatMessage[]> & {
|
|
28
|
+
pagination?: PaginationInfo;
|
|
29
|
+
}>;
|
|
30
|
+
addMessage(chatId: number, content?: string | null, files?: FileList | File[] | null, replyId?: number | null): Promise<ChatResponse<ChatMessage>>;
|
|
31
|
+
actionMessage(chatId: number, messageId: number, action: MessageAction): Promise<{
|
|
32
|
+
message_id: number;
|
|
33
|
+
member_id: number;
|
|
34
|
+
}>;
|
|
35
|
+
getSystemMessages(limit?: number, page?: number): Promise<ChatResponse<ChatMessage[]> & {
|
|
36
|
+
pagination?: PaginationInfo;
|
|
37
|
+
}>;
|
|
38
|
+
addEventListener<K extends keyof ChatEventPayloads>(event: K, listener: (data: K extends keyof ChatEventPayloads ? ChatEventPayloads[K] : unknown) => void): void;
|
|
39
|
+
removeEventListener<K extends keyof ChatEventPayloads>(event: K, listener?: (data: ChatEventPayloads[K]) => void): void;
|
|
40
|
+
runEvent<K extends keyof ChatEventPayloads>(name: K | string, data?: ChatEventPayloads[K]): void;
|
|
41
|
+
setConfig(config: ChatConfig): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ChatService } from '../../services';
|
|
2
|
+
declare class ChatServiceManager {
|
|
3
|
+
private static instance;
|
|
4
|
+
private chatKeys;
|
|
5
|
+
private services;
|
|
6
|
+
private scriptLoadPromise;
|
|
7
|
+
private constructor();
|
|
8
|
+
static getInstance(): ChatServiceManager;
|
|
9
|
+
loadSDK(chatKey: string): Promise<void>;
|
|
10
|
+
getOrCreateAccount(accountCode: string, chatKey: string, workspace?: string): Promise<ChatService>;
|
|
11
|
+
getAccount(accountCode?: string): ChatService | undefined;
|
|
12
|
+
removeAccount(accountCode: string): void;
|
|
13
|
+
getChatKey(accountCode: string): string;
|
|
14
|
+
}
|
|
15
|
+
export declare const chatManager: ChatServiceManager;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { en } from '../../locales';
|
|
2
|
+
import { LanguageOption } from '../../types';
|
|
3
|
+
export type TranslationSchema = typeof en;
|
|
4
|
+
export type NestedKeys<T> = T extends object ? {
|
|
5
|
+
[K in keyof T]: `${Exclude<K, symbol>}${'' | `.${NestedKeys<T[K]>}`}`;
|
|
6
|
+
}[keyof T] : '';
|
|
7
|
+
declare class TranslationManager {
|
|
8
|
+
private static instance;
|
|
9
|
+
private translations;
|
|
10
|
+
private currentLocale;
|
|
11
|
+
private constructor();
|
|
12
|
+
static getInstance(): TranslationManager;
|
|
13
|
+
get locale(): LanguageOption;
|
|
14
|
+
set locale(lang: LanguageOption);
|
|
15
|
+
t(path: NestedKeys<TranslationSchema>, params?: Record<string, string>): string;
|
|
16
|
+
}
|
|
17
|
+
export declare const lang: TranslationManager;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RootState } from '../../../store';
|
|
2
|
+
export declare const selectActiveAccountCode: (state: RootState) => string;
|
|
3
|
+
export declare const selectDefaultAccountCode: (state: RootState) => string;
|
|
4
|
+
export declare const selectChatAccount: (state: RootState) => import('../../../store').AccountChatState;
|
|
5
|
+
export declare const selectChatAccountConfig: (state: RootState) => import('../../types').UseChatOptions | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RootState } from '../../../store';
|
|
2
|
+
import { ChatDurationUnit } from '../../../types';
|
|
3
|
+
export declare const selectChatSettingByAccount: (state: RootState) => import('../../../types').ChatSetting | undefined;
|
|
4
|
+
export declare const getDurationInMs: (duration: number, unit: ChatDurationUnit) => number;
|