@fusioni/client-sdk 1.1.17 → 1.1.18
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/components/ChatWidget.d.ts.map +1 -1
- package/dist/fusioni-sdk.umd.js +49 -4
- package/dist/fusioni-sdk.umd.js.map +1 -1
- package/dist/index.esm.js +48 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +48 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../../src/components/ChatWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkF,MAAM,OAAO,CAAC;AACvG,OAAO,EACL,eAAe,EAEf,uBAAuB,EAGxB,MAAM,UAAU,CAAC;AAmBlB,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../../src/components/ChatWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkF,MAAM,OAAO,CAAC;AACvG,OAAO,EACL,eAAe,EAEf,uBAAuB,EAGxB,MAAM,UAAU,CAAC;AAmBlB,OAAO,qBAAqB,CAAC;AAkD7B,eAAO,MAAM,UAAU,iGAu5BrB,CAAC"}
|
package/dist/fusioni-sdk.umd.js
CHANGED
|
@@ -6694,6 +6694,7 @@ var Fusioni = (function () {
|
|
|
6694
6694
|
styleInject(css_248z);
|
|
6695
6695
|
|
|
6696
6696
|
const getStoredConversationIdKey = (agencyId) => `fusioni:selectedConversationId:${agencyId}`;
|
|
6697
|
+
const getStoredChatPanelOpenKey = (agencyId) => `fusioni:chatPanelOpen:${agencyId}`;
|
|
6697
6698
|
const readStoredConversationId = (agencyId) => {
|
|
6698
6699
|
if (typeof window === 'undefined')
|
|
6699
6700
|
return null;
|
|
@@ -6720,6 +6721,26 @@ var Fusioni = (function () {
|
|
|
6720
6721
|
// Storage can be unavailable in restricted browser contexts.
|
|
6721
6722
|
}
|
|
6722
6723
|
};
|
|
6724
|
+
const readStoredChatPanelOpen = (agencyId) => {
|
|
6725
|
+
if (typeof window === 'undefined')
|
|
6726
|
+
return false;
|
|
6727
|
+
try {
|
|
6728
|
+
return window.sessionStorage.getItem(getStoredChatPanelOpenKey(agencyId)) === 'true';
|
|
6729
|
+
}
|
|
6730
|
+
catch {
|
|
6731
|
+
return false;
|
|
6732
|
+
}
|
|
6733
|
+
};
|
|
6734
|
+
const writeStoredChatPanelOpen = (agencyId, isOpen) => {
|
|
6735
|
+
if (typeof window === 'undefined')
|
|
6736
|
+
return;
|
|
6737
|
+
try {
|
|
6738
|
+
window.sessionStorage.setItem(getStoredChatPanelOpenKey(agencyId), String(isOpen));
|
|
6739
|
+
}
|
|
6740
|
+
catch {
|
|
6741
|
+
// Storage can be unavailable in restricted browser contexts.
|
|
6742
|
+
}
|
|
6743
|
+
};
|
|
6723
6744
|
const ChatWidget = reactExports.forwardRef(function ChatWidget({ config, onMessageSent, onMessageReceived, onConversationCreated, onConversationDeleted, onError }, ref) {
|
|
6724
6745
|
const [languageOverride, setLanguageOverride] = reactExports.useState(null);
|
|
6725
6746
|
const [isOpen, setIsOpen] = reactExports.useState(false);
|
|
@@ -6742,6 +6763,15 @@ var Fusioni = (function () {
|
|
|
6742
6763
|
// Translation and language management - use merged config or fallback to user config
|
|
6743
6764
|
const { t, currentLanguage, changeLanguage } = useTranslation(translationDefault);
|
|
6744
6765
|
const activeAgencyId = mergedConfig?.agencyId || config.agencyId;
|
|
6766
|
+
const updateChatOpen = reactExports.useCallback((nextIsOpen) => {
|
|
6767
|
+
setIsOpen(nextIsOpen);
|
|
6768
|
+
if (activeAgencyId) {
|
|
6769
|
+
writeStoredChatPanelOpen(activeAgencyId, nextIsOpen);
|
|
6770
|
+
}
|
|
6771
|
+
if (!nextIsOpen) {
|
|
6772
|
+
setIsConversationListOpen(false);
|
|
6773
|
+
}
|
|
6774
|
+
}, [activeAgencyId]);
|
|
6745
6775
|
const { conversations, currentConversation, messages, streamMessages, setCurrentConversation, setStreamMessages, addMessage, updateMessage, removeMessage, removeOptimisticUserMessages, truncateMessagesAt, addConversation, updateConversation, removeConversation, loadConversations, loadMessages, clearMessages } = useChatState(activeAgencyId);
|
|
6746
6776
|
const { theme, toggleTheme, setTheme } = useTheme(mergedConfig?.theme || config.theme);
|
|
6747
6777
|
const isMobileLayout = useIsMobileLayout();
|
|
@@ -6823,6 +6853,12 @@ var Fusioni = (function () {
|
|
|
6823
6853
|
};
|
|
6824
6854
|
}
|
|
6825
6855
|
}, [activeAgencyId, loadConversations]);
|
|
6856
|
+
reactExports.useEffect(() => {
|
|
6857
|
+
if (!activeAgencyId) {
|
|
6858
|
+
return;
|
|
6859
|
+
}
|
|
6860
|
+
setIsOpen(readStoredChatPanelOpen(activeAgencyId));
|
|
6861
|
+
}, [activeAgencyId]);
|
|
6826
6862
|
// SSE connection for real-time updates - only when a chat panel is open
|
|
6827
6863
|
useSSE(activeAgencyId, (data) => {
|
|
6828
6864
|
// Same as fusioni-web chat.component: latest SSE line replaces stream (single loading row updates)
|
|
@@ -6837,8 +6873,17 @@ var Fusioni = (function () {
|
|
|
6837
6873
|
};
|
|
6838
6874
|
}, []);
|
|
6839
6875
|
const handleToggleChat = reactExports.useCallback(() => {
|
|
6840
|
-
setIsOpen(prev =>
|
|
6841
|
-
|
|
6876
|
+
setIsOpen(prev => {
|
|
6877
|
+
const nextIsOpen = !prev;
|
|
6878
|
+
if (activeAgencyId) {
|
|
6879
|
+
writeStoredChatPanelOpen(activeAgencyId, nextIsOpen);
|
|
6880
|
+
}
|
|
6881
|
+
if (!nextIsOpen) {
|
|
6882
|
+
setIsConversationListOpen(false);
|
|
6883
|
+
}
|
|
6884
|
+
return nextIsOpen;
|
|
6885
|
+
});
|
|
6886
|
+
}, [activeAgencyId]);
|
|
6842
6887
|
const handleToggleConversationList = reactExports.useCallback(() => {
|
|
6843
6888
|
setIsConversationListOpen(prev => !prev);
|
|
6844
6889
|
}, []);
|
|
@@ -7272,7 +7317,7 @@ var Fusioni = (function () {
|
|
|
7272
7317
|
if (error) {
|
|
7273
7318
|
return (jsxRuntimeExports.jsxs("div", { className: "fusioni-chat-error", children: [jsxRuntimeExports.jsxs("p", { children: [t('common.error'), ": ", error] }), jsxRuntimeExports.jsx("button", { onClick: () => setError(null), children: t('chat.errors.retry') })] }));
|
|
7274
7319
|
}
|
|
7275
|
-
return (jsxRuntimeExports.jsxs("div", { className: `fusioni-chat-widget ${theme}`, style: { '--primary-color': mergedConfig.primaryColor || '#6366f1' }, children: [jsxRuntimeExports.jsx(FloatingButton, { isOpen: isOpen, onClick: handleToggleChat, position: mergedConfig.position || 'bottom-right', primaryColor: mergedConfig.primaryColor, buttonRef: floatingButtonRef, variant: mergedConfig.buttonVariant || 'glass', shouldDisplay: !hasConfigError && (!isMobileLayout || !isOpen) }), isOpen && (jsxRuntimeExports.jsx(ChatPanel, { isOpen: isOpen, onClose: () =>
|
|
7320
|
+
return (jsxRuntimeExports.jsxs("div", { className: `fusioni-chat-widget ${theme}`, style: { '--primary-color': mergedConfig.primaryColor || '#6366f1' }, children: [jsxRuntimeExports.jsx(FloatingButton, { isOpen: isOpen, onClick: handleToggleChat, position: mergedConfig.position || 'bottom-right', primaryColor: mergedConfig.primaryColor, buttonRef: floatingButtonRef, variant: mergedConfig.buttonVariant || 'glass', shouldDisplay: !hasConfigError && (!isMobileLayout || !isOpen) }), isOpen && (jsxRuntimeExports.jsx(ChatPanel, { isOpen: isOpen, onClose: () => updateChatOpen(false), position: mergedConfig.position || 'bottom-right', isFullscreen: isFullscreen, floatingButtonRef: floatingButtonRef, children: jsxRuntimeExports.jsxs("div", { className: "fusioni-chat-container", children: [mergedConfig.showConversationList !== false && (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: `fusioni-conversation-backdrop ${isConversationListOpen ? 'open' : ''}`, onClick: () => setIsConversationListOpen(false) }), jsxRuntimeExports.jsx(ConversationList, { conversations: conversations, selectedConversationId: currentConversation?.id || undefined, onSelectConversation: handleSelectConversation, onDeleteConversation: handleDeleteConversation, onCreateConversation: handleCreateConversation, isOpen: isConversationListOpen, currentLanguage: currentLanguage })] })), jsxRuntimeExports.jsxs("div", { className: "fusioni-chat-main", children: [jsxRuntimeExports.jsxs("div", { className: "fusioni-chat-main-header", children: [mergedConfig.showConversationList !== false ? (jsxRuntimeExports.jsxs("button", { type: "button", onClick: handleToggleConversationList, className: `fusioni-conversation-toggle ${isConversationListOpen ? 'open' : ''}`, children: [jsxRuntimeExports.jsx("svg", { className: "fusioni-conversation-toggle-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntimeExports.jsx("path", { d: "M3 12h18M3 6h18M3 18h18" }) }), t('chat.conversations.title')] })) : (jsxRuntimeExports.jsx("span", { className: "fusioni-chat-main-header-title", children: t('chat.title') })), jsxRuntimeExports.jsxs("div", { className: "fusioni-header-actions", children: [jsxRuntimeExports.jsx("button", { type: "button", onClick: handleCreateConversation, disabled: isLoading, className: "fusioni-btn fusioni-btn-icon", title: t('chat.conversations.newConversation'), "aria-label": t('chat.conversations.newConversation'), children: jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: jsxRuntimeExports.jsx("path", { d: "M12 5V19M5 12H19", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), mergedConfig.showThemeToggle !== false && (jsxRuntimeExports.jsx("button", { type: "button", onClick: toggleTheme, className: "fusioni-btn fusioni-btn-icon", title: theme === 'dark' ? t('chat.theme.light') : t('chat.theme.dark'), children: theme === 'dark' ? (jsxRuntimeExports.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [jsxRuntimeExports.jsx("circle", { cx: "12", cy: "12", r: "5" }), jsxRuntimeExports.jsx("line", { x1: "12", y1: "1", x2: "12", y2: "3" }), jsxRuntimeExports.jsx("line", { x1: "12", y1: "21", x2: "12", y2: "23" }), jsxRuntimeExports.jsx("line", { x1: "4.22", y1: "4.22", x2: "5.64", y2: "5.64" }), jsxRuntimeExports.jsx("line", { x1: "18.36", y1: "18.36", x2: "19.78", y2: "19.78" }), jsxRuntimeExports.jsx("line", { x1: "1", y1: "12", x2: "3", y2: "12" }), jsxRuntimeExports.jsx("line", { x1: "21", y1: "12", x2: "23", y2: "12" }), jsxRuntimeExports.jsx("line", { x1: "4.22", y1: "19.78", x2: "5.64", y2: "18.36" }), jsxRuntimeExports.jsx("line", { x1: "18.36", y1: "5.64", x2: "19.78", y2: "4.22" })] })) : (jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntimeExports.jsx("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }) })) })), mergedConfig.showFullscreenToggle !== false && (jsxRuntimeExports.jsx("button", { type: "button", onClick: handleToggleFullscreen, className: "fusioni-btn fusioni-btn-icon", title: isFullscreen ? t('chat.fullscreen.exit') : t('chat.fullscreen.enter'), children: isFullscreen ? (jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntimeExports.jsx("path", { d: "M8 3V5M8 3H5M8 3L3 8M16 3V5M16 3H19M16 3L21 8M8 21V19M8 21H5M8 21L3 16M16 21V19M16 21H19M16 21L21 16" }) })) : (jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntimeExports.jsx("path", { d: "M8 3H5C4.46957 3 3.96086 3.21071 3.58579 3.58579C3.21071 3.96086 3 4.46957 3 5V8M21 8V5C21 4.46957 20.7893 3.96086 20.4142 3.58579C20.0391 3.21071 19.5304 3 19 3H16M16 21H19C19.5304 21 20.0391 20.7893 20.4142 20.4142C20.7893 20.0391 21 19.5304 21 19V16M3 16V19C3 19.5304 3.21071 20.0391 3.58579 20.4142C3.96086 20.7893 4.46957 21 5 21H8" }) })) })), mergedConfig.showLanguageSwitcher !== false && (jsxRuntimeExports.jsx(LanguageSwitcher, { currentLanguage: currentLanguage, onLanguageChange: handleLanguageChange })), jsxRuntimeExports.jsx("button", { type: "button", onClick: () => updateChatOpen(false), className: "fusioni-btn fusioni-btn-icon fusioni-chat-toolbar-close-mobile", title: t('common.close'), "aria-label": t('common.close'), children: jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": "true", children: jsxRuntimeExports.jsx("path", { d: "M18 6L6 18M6 6L18 18", strokeLinecap: "round", strokeLinejoin: "round" }) }) })] })] }), currentConversation ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(MessageList, { messages: messages, streamMessages: streamMessages, showThoughts: false, onDeleteMessage: handleDeleteMessage, onEditMessage: handleEditMessage, onConfirmation: handleConfirmation, enableButtons: !isLoading, apiBaseUrl: mergedConfig.apiBaseUrl, apiKey: mergedConfig.accessToken, agencyId: mergedConfig.agencyId, currentLanguage: currentLanguage, theme: theme, onSuggestionClick: (prompt) => handleSendMessage(prompt) }), jsxRuntimeExports.jsx(ChatInput, { onSendMessage: handleSendMessage, onFileUpload: handleFileUpload, disabled: isLoading, placeholder: t('chat.input.placeholder'), enableAudioRecording: mergedConfig.enableAudioRecording !== false, enableFileUpload: mergedConfig.enableFileUpload !== false, maxFileSize: mergedConfig.maxFileSize || 10, allowedFileTypes: mergedConfig.allowedFileTypes || ['image/*'], currentLanguage: currentLanguage })] })) : (jsxRuntimeExports.jsx("div", { className: "fusioni-chat-welcome", children: jsxRuntimeExports.jsxs("div", { className: "fusioni-chat-welcome-content", children: [jsxRuntimeExports.jsx("h3", { children: t('chat.welcome.title') }), jsxRuntimeExports.jsx("p", { children: t('chat.welcome.description') }), jsxRuntimeExports.jsx("button", { onClick: handleCreateConversation, disabled: isLoading, className: "fusioni-btn fusioni-btn-primary", children: isLoading ? t('chat.welcome.creating') : t('chat.welcome.startButton') })] }) }))] })] }) })), jsxRuntimeExports.jsx(ConfirmationDialog, { isOpen: isDeleteDialogOpen, title: t('chat.conversations.deleteConfirm.title'), message: t('chat.conversations.deleteConfirm.message'), confirmText: t('chat.conversations.deleteConfirm.confirm'), cancelText: t('chat.conversations.deleteConfirm.cancel'), onConfirm: confirmDeleteConversation, onCancel: cancelDeleteConversation, currentLanguage: currentLanguage, variant: "danger" }), jsxRuntimeExports.jsx(ConfirmationDialog, { isOpen: isDeleteMessageDialogOpen, title: t('chat.messages.deleteConfirm.title'), message: t('chat.messages.deleteConfirm.message'), confirmText: t('chat.messages.deleteConfirm.confirm'), cancelText: t('chat.messages.deleteConfirm.cancel'), onConfirm: confirmDeleteMessage, onCancel: cancelDeleteMessage, currentLanguage: currentLanguage, variant: "danger" })] }));
|
|
7276
7321
|
});
|
|
7277
7322
|
ChatWidget.displayName = 'ChatWidget';
|
|
7278
7323
|
|
|
@@ -7338,7 +7383,7 @@ var Fusioni = (function () {
|
|
|
7338
7383
|
const Fusioni = {
|
|
7339
7384
|
init,
|
|
7340
7385
|
mount,
|
|
7341
|
-
version: "1.1.
|
|
7386
|
+
version: "1.1.17",
|
|
7342
7387
|
};
|
|
7343
7388
|
if (typeof window !== 'undefined') {
|
|
7344
7389
|
window.Fusioni = Fusioni;
|