@askly/widget 2.8.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -3
- package/dist/core/events.d.ts +96 -0
- package/dist/core/format.d.ts +2 -0
- package/dist/core/greeting.d.ts +10 -0
- package/dist/core/session.d.ts +59 -0
- package/dist/core/storage.d.ts +4 -0
- package/dist/core/types.d.ts +65 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/realtime.d.ts +32 -0
- package/dist/ui/ChatTerms.d.ts +3 -0
- package/dist/ui/Composer.d.ts +28 -0
- package/dist/ui/ConversationList.d.ts +9 -0
- package/dist/ui/ExploreTab.d.ts +21 -0
- package/dist/ui/GreetingBubble.d.ts +16 -0
- package/dist/ui/HelpTab.d.ts +25 -0
- package/dist/ui/Launcher.d.ts +16 -0
- package/dist/ui/MessageList.d.ts +14 -0
- package/dist/ui/NavTabs.d.ts +9 -0
- package/dist/ui/PanelHeader.d.ts +18 -0
- package/dist/widget.d.ts +1 -38
- package/dist/widget.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live event stream from the server (server-sent events), read with fetch().
|
|
3
|
+
*
|
|
4
|
+
* Why not EventSource: it cannot send an Authorization header, and the stream is authorised
|
|
5
|
+
* by the widget's session token. fetch() with a streamed body does the same job.
|
|
6
|
+
*
|
|
7
|
+
* The stream is a notification channel, not the record. Whoever uses it is expected to read
|
|
8
|
+
* the conversation again when it comes up (`onLive`), so nothing here replays missed events.
|
|
9
|
+
* When the stream cannot be had at all (an older server, no session) it reports "unsupported"
|
|
10
|
+
* and stops; when it merely fails it reports "down" and keeps retrying with backoff, so the
|
|
11
|
+
* caller can poll in the meantime and stop polling when it returns.
|
|
12
|
+
*/
|
|
13
|
+
export interface StreamEvent {
|
|
14
|
+
type: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
data: any;
|
|
17
|
+
}
|
|
18
|
+
export interface EventStreamOptions {
|
|
19
|
+
/** Open the request. Resolves to null when there is no session to authorise it with. */
|
|
20
|
+
connect: (signal: AbortSignal) => Promise<Response | null>;
|
|
21
|
+
onEvent: (event: StreamEvent) => void;
|
|
22
|
+
/** The server confirmed the stream is up. */
|
|
23
|
+
onLive: () => void;
|
|
24
|
+
/** The stream is not delivering: "unsupported" is final, "down" will be retried. */
|
|
25
|
+
onDown: (reason: "unsupported" | "down") => void;
|
|
26
|
+
}
|
|
27
|
+
export interface EventStreamHandle {
|
|
28
|
+
close: () => void;
|
|
29
|
+
/** Drop the current connection and reconnect now (the network just changed). */
|
|
30
|
+
kick: () => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function openEventStream(options: EventStreamOptions): EventStreamHandle;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ComposerProps {
|
|
3
|
+
enableVoiceChat: boolean;
|
|
4
|
+
fileInputRef: React.RefObject<HTMLInputElement>;
|
|
5
|
+
handleEmojiClick: (emoji: string) => void;
|
|
6
|
+
handleFileChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
7
|
+
handleFileUploadClick: () => void;
|
|
8
|
+
input: string;
|
|
9
|
+
inputRef: React.RefObject<HTMLTextAreaElement>;
|
|
10
|
+
isListening: boolean;
|
|
11
|
+
isTyping: boolean;
|
|
12
|
+
leadRequired: boolean;
|
|
13
|
+
placeholderText: string;
|
|
14
|
+
readAloud: boolean;
|
|
15
|
+
sendMessage: (text?: string) => void | Promise<void>;
|
|
16
|
+
setInput: React.Dispatch<React.SetStateAction<string>>;
|
|
17
|
+
setShowEmojiPicker: (show: boolean) => void;
|
|
18
|
+
setTtsMuted: (muted: boolean) => void;
|
|
19
|
+
showEmojiPicker: boolean;
|
|
20
|
+
stopSpeaking: () => void;
|
|
21
|
+
toggleVoiceInput: () => void;
|
|
22
|
+
ttsMuted: boolean;
|
|
23
|
+
ttsMutedRef: React.MutableRefObject<boolean>;
|
|
24
|
+
turnstileBlocked: boolean;
|
|
25
|
+
uploadingFile: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** The message box and its actions: attach, emoji, voice input, read-aloud and send. */
|
|
28
|
+
export declare function Composer(props: ComposerProps): React.JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { SavedConversation } from "../core/types";
|
|
3
|
+
export interface ConversationListProps {
|
|
4
|
+
conversations: SavedConversation[];
|
|
5
|
+
setActiveChatId: (chatId: string | null) => void;
|
|
6
|
+
startNewChat: () => string;
|
|
7
|
+
}
|
|
8
|
+
/** The visitor's chats, newest first, with a button to start another. */
|
|
9
|
+
export declare function ConversationList(props: ConversationListProps): React.JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { WidgetTab, Faq, Article } from "../core/types";
|
|
3
|
+
export interface ExploreTabProps {
|
|
4
|
+
allArticles: Article[];
|
|
5
|
+
articlesLoading: boolean;
|
|
6
|
+
expandedFaqIndex: number | null;
|
|
7
|
+
faqs: Faq[];
|
|
8
|
+
handleSearchChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
9
|
+
handleSelectArticle: (article: Article) => void;
|
|
10
|
+
organizationLogo: string | undefined;
|
|
11
|
+
organizationName: string;
|
|
12
|
+
searchError: string | null;
|
|
13
|
+
searchLoading: boolean;
|
|
14
|
+
searchQuery: string;
|
|
15
|
+
searchResults: Article[];
|
|
16
|
+
setActiveTab: (tab: WidgetTab) => void;
|
|
17
|
+
setExpandedFaqIndex: (index: number | null) => void;
|
|
18
|
+
setInput: React.Dispatch<React.SetStateAction<string>>;
|
|
19
|
+
}
|
|
20
|
+
/** The home screen: search, shortcuts, popular questions and recommended articles. */
|
|
21
|
+
export declare function ExploreTab(props: ExploreTabProps): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Faq } from "../core/types";
|
|
3
|
+
export interface GreetingBubbleProps {
|
|
4
|
+
accentVars: React.CSSProperties;
|
|
5
|
+
aiAnswering: boolean;
|
|
6
|
+
aiAvatarUrl: string | null;
|
|
7
|
+
dismissGreeting: () => void;
|
|
8
|
+
faqs: Faq[];
|
|
9
|
+
greetingText: string;
|
|
10
|
+
openFromGreeting: (question?: string) => void;
|
|
11
|
+
organizationLogo: string | undefined;
|
|
12
|
+
position: "left" | "right";
|
|
13
|
+
resolvedTheme: string;
|
|
14
|
+
}
|
|
15
|
+
/** The hello shown beside the closed launcher. A status region, so it is announced without taking focus. */
|
|
16
|
+
export declare function GreetingBubble(props: GreetingBubbleProps): React.JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { WidgetTab, Article } from "../core/types";
|
|
3
|
+
export interface HelpTabProps {
|
|
4
|
+
allArticles: Article[];
|
|
5
|
+
articleFeedback: Record<string, "yes" | "no" | "somewhat">;
|
|
6
|
+
articlesLoading: boolean;
|
|
7
|
+
handleSearchChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
handleSelectArticle: (article: Article) => void;
|
|
9
|
+
organizationLogo: string | undefined;
|
|
10
|
+
organizationName: string;
|
|
11
|
+
searchError: string | null;
|
|
12
|
+
searchLoading: boolean;
|
|
13
|
+
searchQuery: string;
|
|
14
|
+
searchResults: Article[];
|
|
15
|
+
selectedArticle: Article | null;
|
|
16
|
+
selectedCollection: string | null;
|
|
17
|
+
setActiveTab: (tab: WidgetTab) => void;
|
|
18
|
+
setArticleFeedback: React.Dispatch<React.SetStateAction<Record<string, "yes" | "no" | "somewhat">>>;
|
|
19
|
+
setInput: React.Dispatch<React.SetStateAction<string>>;
|
|
20
|
+
setSelectedArticle: (article: Article | null) => void;
|
|
21
|
+
setSelectedCollection: (collection: string | null) => void;
|
|
22
|
+
themeColor: string;
|
|
23
|
+
}
|
|
24
|
+
/** The help center: collections, article list and the article reader. */
|
|
25
|
+
export declare function HelpTab(props: HelpTabProps): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { WidgetTab } from "../core/types";
|
|
3
|
+
export interface LauncherProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
setOpen: (open: boolean) => void;
|
|
6
|
+
buttonIcon: string;
|
|
7
|
+
buttonShape: "round" | "square";
|
|
8
|
+
buttonStyle: React.CSSProperties;
|
|
9
|
+
launcherUnread: number;
|
|
10
|
+
resolvedTheme: string;
|
|
11
|
+
setActiveChatId: (chatId: string | null) => void;
|
|
12
|
+
setActiveTab: (tab: WidgetTab) => void;
|
|
13
|
+
unreadChatId: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
/** The floating button that opens and closes the panel, with the unread badge. */
|
|
16
|
+
export declare function Launcher(props: LauncherProps): React.JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Message } from "../core/types";
|
|
3
|
+
export interface MessageListProps {
|
|
4
|
+
copiedMsgIndex: number | null;
|
|
5
|
+
messages: Message[];
|
|
6
|
+
msgReactions: Record<number, "up" | "down">;
|
|
7
|
+
setCopiedMsgIndex: React.Dispatch<React.SetStateAction<number | null>>;
|
|
8
|
+
setMsgReactions: React.Dispatch<React.SetStateAction<Record<number, "up" | "down">>>;
|
|
9
|
+
showTimestamp: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** The messages of the chat on screen. */
|
|
12
|
+
declare function MessageListView(props: MessageListProps): React.JSX.Element;
|
|
13
|
+
export declare const MessageList: React.MemoExoticComponent<typeof MessageListView>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { WidgetTab, Article } from "../core/types";
|
|
3
|
+
export interface NavTabsProps {
|
|
4
|
+
activeTab: WidgetTab;
|
|
5
|
+
setActiveTab: (tab: WidgetTab) => void;
|
|
6
|
+
setSelectedArticle: (article: Article | null) => void;
|
|
7
|
+
}
|
|
8
|
+
/** The bottom navigation between Explore, Messages and Help. */
|
|
9
|
+
export declare function NavTabs(props: NavTabsProps): React.JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { WidgetTab } from "../core/types";
|
|
3
|
+
export interface PanelHeaderProps {
|
|
4
|
+
activeChatId: string | null;
|
|
5
|
+
activeTab: WidgetTab;
|
|
6
|
+
aiAnswering: boolean;
|
|
7
|
+
aiAvatarUrl: string | null;
|
|
8
|
+
aiName: string | null;
|
|
9
|
+
headerStyle: React.CSSProperties;
|
|
10
|
+
isExpanded: boolean;
|
|
11
|
+
organizationLogo: string | undefined;
|
|
12
|
+
organizationName: string;
|
|
13
|
+
setActiveChatId: (chatId: string | null) => void;
|
|
14
|
+
setIsExpanded: (expanded: boolean) => void;
|
|
15
|
+
setOpen: (open: boolean) => void;
|
|
16
|
+
}
|
|
17
|
+
/** The panel's top bar, which changes with the section on screen. */
|
|
18
|
+
export declare function PanelHeader(props: PanelHeaderProps): React.JSX.Element;
|
package/dist/widget.d.ts
CHANGED
|
@@ -1,41 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import type { ChatWidgetProps } from "./core/types";
|
|
2
3
|
import "./styles.css";
|
|
3
|
-
interface ChatWidgetProps {
|
|
4
|
-
orgId?: string;
|
|
5
|
-
organizationName?: string;
|
|
6
|
-
themeColor?: string;
|
|
7
|
-
theme?: "light" | "dark" | "auto";
|
|
8
|
-
position?: "left" | "right";
|
|
9
|
-
orgServerRoute: string;
|
|
10
|
-
enableVoiceChat?: boolean;
|
|
11
|
-
readAloud?: boolean;
|
|
12
|
-
welcomeMessage?: string;
|
|
13
|
-
placeholderText?: string;
|
|
14
|
-
organizationLogo?: string;
|
|
15
|
-
buttonIcon?: string;
|
|
16
|
-
buttonShape?: "round" | "square";
|
|
17
|
-
autoOpen?: boolean;
|
|
18
|
-
greeting?: boolean | {
|
|
19
|
-
message?: string;
|
|
20
|
-
delayMs?: number;
|
|
21
|
-
};
|
|
22
|
-
showTimestamp?: boolean;
|
|
23
|
-
soundEnabled?: boolean;
|
|
24
|
-
soundVolume?: number;
|
|
25
|
-
poweredBy?: string;
|
|
26
|
-
userId?: string;
|
|
27
|
-
timestamp?: number;
|
|
28
|
-
signature?: string;
|
|
29
|
-
turnstileSiteKey?: string;
|
|
30
|
-
excludePaths?: string[];
|
|
31
|
-
includePaths?: string[];
|
|
32
|
-
configOverride?: Record<string, any>;
|
|
33
|
-
resetGeneration?: number;
|
|
34
|
-
onMessageSent?: (message: string) => void;
|
|
35
|
-
onMessageReceived?: (reply: string) => void;
|
|
36
|
-
onChatOpened?: () => void;
|
|
37
|
-
onChatClosed?: () => void;
|
|
38
|
-
onEscalation?: (data: any) => void;
|
|
39
|
-
}
|
|
40
4
|
export declare const ChatWidget: ({ orgId, organizationName: initialOrganizationName, themeColor: initialThemeColor, theme: initialTheme, position, orgServerRoute, enableVoiceChat: initialEnableVoiceChat, readAloud: initialReadAloud, welcomeMessage: initialWelcomeMessage, placeholderText, organizationLogo: initialOrganizationLogo, buttonIcon, buttonShape: initialButtonShape, autoOpen, greeting, showTimestamp, soundEnabled, soundVolume, poweredBy, userId, timestamp, signature, turnstileSiteKey, excludePaths, includePaths, configOverride, resetGeneration: initResetGeneration, onMessageSent, onMessageReceived, onChatOpened, onChatClosed, onEscalation, }: ChatWidgetProps) => React.JSX.Element | null;
|
|
41
|
-
export {};
|