Skip to content

Commit

Permalink
Option for TextChat minimization was added
Browse files Browse the repository at this point in the history
  • Loading branch information
annmirosh committed Dec 20, 2024
1 parent c60629e commit 8d4c615
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 11 deletions.
65 changes: 56 additions & 9 deletions dist/alan_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -89614,11 +89614,17 @@
<path d="M2.375 12.875C2.375 15.1141 2.375 16.2337 3.07062 16.9294C3.76624 17.625 4.88583 17.625 7.125 17.625H11.875C14.1142 17.625 15.2337 17.625 15.9294 16.9294C16.625 16.2337 16.625 15.1141 16.625 12.875" stroke="#1C274C" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M9.50001 3.375V13.6667M9.50001 13.6667L12.6667 10.2031M9.50001 13.6667L6.33334 10.2031" stroke="#1C274C" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`
`,
minimize: `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3 17.25L18 17.25" stroke="none" stroke-width="1.5" stroke-linecap="round"/>
</svg>`
};
function getCloseChatIcon(textChatOptions) {
return textChatOptions?.popup?.icons?.close?.svg || chatIcons.closeChat;
}
function getMinimizeChatIcon(textChatOptions) {
return textChatOptions?.popup?.icons?.minimize?.svg || chatIcons.minimize;
}
function getExpandChatIcon(textChatOptions) {
return textChatOptions?.popup?.icons?.fullScreen?.svgExpand || chatIcons.expandChat;
}
Expand Down Expand Up @@ -91095,6 +91101,21 @@
fill: ${textChatOptions?.popup?.icons?.close?.hover?.fill || `#97989c`};
}`;
}
keyFrames += getStyleSheetMarker() + `.alan-btn__minimize-chat-btn {
height: 100%;
display: ${textChatOptions?.popup?.minimizeMode?.enabled ? "flex" : `none`};
align-items: center;
cursor: pointer;
pointer-events: all;
}`;
keyFrames += getStyleSheetMarker() + `.alan-btn__minimize-chat-btn svg path {
stroke: ${textChatOptions?.popup?.icons?.minimize?.default?.fill || `#969EB0`};
}`;
if (!isMobile()) {
keyFrames += getStyleSheetMarker() + `.alan-btn__minimize-chat-btn:hover svg path {
stroke: ${textChatOptions?.popup?.icons?.minimize?.hover?.fill || `#0046ff`};
}`;
}
keyFrames += getStyleSheetMarker() + `.alan-btn__save-chat-state-btn {
height: 100%;
display: ${textChatOptions?.popup?.saveChatState?.enabled ? "flex" : `none`};
Expand Down Expand Up @@ -92418,7 +92439,6 @@
const tagRegex = new RegExp(tag.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g");
result = result.replace(tagRegex, replacement);
}
console.info("result", result);
return result;
}
function sanitize(str) {
Expand Down Expand Up @@ -92634,10 +92654,6 @@
}`,
`* + pre {
margin-top: 8px!important;
}`,
`pre + * {
margin-top: 16px!important;
font-size: ${responseBubbleFontSize}px!important;
}`,
`* + ul {
margin-top: 8px!important;
Expand Down Expand Up @@ -93969,7 +93985,7 @@ code.hljs {

// alan_btn/alan_btn.ts
(function(ns) {
uiState.lib.version = "alan-version.1.8.73".replace("alan-version.", "");
uiState.lib.version = "alan-version.1.8.74".replace("alan-version.", "");
if (window.alanBtn) {
console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
}
Expand All @@ -93995,6 +94011,7 @@ code.hljs {
var dragAndDropEnabled = true;
var curDialogId = null;
var textChatIsHidden = true;
var textChatWasClosedManually = false;
var voiceEnabledInTextChat = true;
var textChatMessages = [];
var canceledRequests = [];
Expand Down Expand Up @@ -95506,7 +95523,9 @@ code.hljs {
}
initTextChat();
if (isInlinedMode() || data.web.chatOptions?.textChat?.popup?.openByDefualt === true || isTextChatSavedStateOpened()) {
showTextChat(true);
if (!textChatWasClosedManually) {
showTextChat(true);
}
}
} else {
uiState.textChat.available = false;
Expand Down Expand Up @@ -96444,6 +96463,9 @@ ${LEARN_MORE_LABEL}
}
}
function onClearTextChatBtnClick() {
if (options.onEvent) {
options.onEvent({ name: "textChatCleared" });
}
clearDialogId();
if (window.tutorProject) {
window.tutorProject.close();
Expand All @@ -96463,7 +96485,6 @@ ${LEARN_MORE_LABEL}
manageSaveChatHistoryBtn();
}
function onNewDialogAutoReconnect() {
console.info("onNewDialogAutoReconnect");
if (textChatMessages?.length === 0)
return;
if (textChatMessages?.at(-1)?.type === "connection-separator")
Expand Down Expand Up @@ -96894,6 +96915,7 @@ ${LEARN_MORE_LABEL}
var rightHeaderIconsHolder = document.getElementById("chat-header-right-icons");
var leftHeaderIconsHolder = document.getElementById("chat-header-left-icons");
var closeChatBtnImg = document.getElementById("alan-btn-chat-close-btn");
var minimizeChatBtnImg = document.getElementById("alan-btn-chat-minimize-btn");
var expandCollapseChatBtnImg = document.getElementById("alan-btn-expand-collapse-chat-btn");
var saveChatStateBtnImg = document.getElementById("alan-btn-save-chat-state-btn");
const title = uiState.textChat.options?.header?.label || "Alan AI Assistant";
Expand Down Expand Up @@ -96965,6 +96987,11 @@ ${LEARN_MORE_LABEL}
addNeedClassesToExpandCollapseBtn(expandCollapseChatBtnImg);
}
if (!isInlinedMode()) {
if (uiState.textChat.options?.popup?.minimizeMode?.enabled === true) {
minimizeChatBtnImg = createDivWithSvg(getMinimizeChatIcon(uiState.textChat.options), { class: "alan-btn__minimize-chat-btn", id: "alan-btn-chat-minimize-btn" });
rightHeaderIconsHolder.appendChild(minimizeChatBtnImg);
minimizeChatBtnImg.addEventListener("click", minimizeTextChat);
}
closeChatBtnImg = createDivWithSvg(getCloseChatIcon(uiState.textChat.options), { class: "alan-btn__close-chat-btn", id: "alan-btn-chat-close-btn" });
rightHeaderIconsHolder.appendChild(closeChatBtnImg);
closeChatBtnImg.addEventListener("click", closeTextChat);
Expand Down Expand Up @@ -97012,6 +97039,9 @@ ${LEARN_MORE_LABEL}
const icon = uiState.textChat.options?.header?.icon?.svg;
headerTille.innerHTML = `${icon ? `<span class="alan-btn__chat-header-title-icon">${icon}</span>` : ""}<span class="alan-btn__chat-header-title-label" title="${title}">${title}</span>`;
}
if (minimizeChatBtnImg) {
minimizeChatBtnImg.innerHTML = getMinimizeChatIcon(uiState.textChat.options);
}
if (closeChatBtnImg) {
closeChatBtnImg.innerHTML = getCloseChatIcon(uiState.textChat.options);
}
Expand Down Expand Up @@ -97098,6 +97128,10 @@ ${LEARN_MORE_LABEL}
}
}
function showTextChat(noAnimation) {
textChatWasClosedManually = false;
if (options.onEvent) {
options.onEvent({ name: "textChatOpened" });
}
fixPopupScrollOnMobileForTextChat(true);
hideChatNotifications();
hidePopup();
Expand Down Expand Up @@ -97143,6 +97177,19 @@ ${LEARN_MORE_LABEL}
return false;
}
function closeTextChat() {
textChatWasClosedManually = true;
if (options.onEvent) {
options.onEvent({ name: "textChatClosed" });
}
hideTextChat();
if (uiState.textChat.options?.popup?.clearChatOnClose === true) {
onClearTextChatBtnClick();
}
}
function minimizeTextChat() {
if (options.onEvent) {
options.onEvent({ name: "textChatMinimized" });
}
hideTextChat();
}
function expandCollapseChatSidePanel() {
Expand Down
2 changes: 1 addition & 1 deletion dist/alan_lib.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alan-ai/alan-sdk-web",
"version": "1.8.73",
"version": "1.8.74",
"description": "Alan Web SDK: a lightweight JavaScript library for adding a voice experience to your website or web application",
"keywords": [
"alan sdk web",
Expand Down

0 comments on commit 8d4c615

Please sign in to comment.