aptolix_chatbot 1.0.5 → 1.0.6

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.
@@ -370,6 +370,9 @@
370
370
  min-height: 180px;
371
371
  width: 100vw;
372
372
  max-width: 100vw;
373
+ left: 0;
374
+ right: 0;
375
+ margin: 0;
373
376
  }
374
377
  #aptolix-chat-header {
375
378
  font-size: 1rem;
@@ -381,6 +384,12 @@
381
384
  #aptolix-chat-input {
382
385
  padding: 6px 2px;
383
386
  }
387
+ #aptolix-chat-expand {
388
+ display: none !important;
389
+ }
390
+ #aptolix-chat-window.section-mode #aptolix-chat-close {
391
+ display: none !important;
392
+ }
384
393
  }
385
394
 
386
395
  .aptolix-retry-btn {
@@ -397,5 +406,34 @@
397
406
  background: #d8b4fe;
398
407
  }
399
408
 
409
+ .aptolix-hint-bubble {
410
+ position: fixed;
411
+ bottom: 110px; /* Adjust so it's above the bubble */
412
+ right: 40px; /* Adjust to align with bubble */
413
+ background: #fff;
414
+ color: #333;
415
+ padding: 10px 18px;
416
+ border-radius: 18px;
417
+ box-shadow: 0 2px 12px rgba(0,0,0,0.12);
418
+ font-size: 15px;
419
+ z-index: 9999;
420
+ transition: opacity 0.3s;
421
+ opacity: 1;
422
+ pointer-events: none;
423
+ max-width: 220px;
424
+ }
425
+
426
+ .aptolix-hint-bubble::after {
427
+ content: "";
428
+ position: absolute;
429
+ bottom: -12px; /* Position arrow below the bubble */
430
+ right: 28px; /* Align arrow with bubble */
431
+ width: 0;
432
+ height: 0;
433
+ border-left: 10px solid transparent;
434
+ border-right: 10px solid transparent;
435
+ border-top: 12px solid #fff; /* Same as bubble background */
436
+ }
437
+
400
438
 
401
439
 
package/src/index.js CHANGED
@@ -2,19 +2,48 @@
2
2
  import './chatbotstyle.css';
3
3
 
4
4
  const AptolixChatbot = {
5
- init: ({ apiHost, chatflowid, title, subtitle, greeting, mode = "bubble", target }) => {
5
+ init: ({ apiHost, chatflowid, title, subtitle, greeting, mode = "bubble", target, hintText = "I am here to help", hintDelay = 5000 // default 5 seconds
6
+ }) => {
6
7
 
7
8
  const modeClass = mode === "section" ? "section-mode" : "bubble-mode";
9
+ const chatWindow = document.createElement('div');
8
10
 
9
- let bubble;
11
+ let bubble, hintBubbleTimeout, hintBubble;
10
12
  if (mode === "bubble") {
11
13
  bubble = document.createElement('div');
12
14
  bubble.id = "aptolix-chat-bubble";
13
15
  bubble.innerText = "💬";
14
16
  document.body.appendChild(bubble);
17
+
18
+ // Create hint bubble but keep it hidden initially
19
+ hintBubble = document.createElement('div');
20
+ hintBubble.id = "aptolix-chat-hint-bubble";
21
+ hintBubble.className = "aptolix-hint-bubble";
22
+ hintBubble.innerText = hintText;
23
+ hintBubble.style.display = "none";
24
+ document.body.appendChild(hintBubble);
25
+
26
+ // Show hint bubble after delay
27
+ hintBubbleTimeout = setTimeout(() => {
28
+ if (chatWindow.style.display === "none") {
29
+ hintBubble.style.display = "block";
30
+ }
31
+ }, hintDelay);
32
+
33
+ // Hide hint bubble when main bubble is clicked
34
+ bubble.addEventListener("click", () => {
35
+ hintBubble.style.display = "none";
36
+ clearTimeout(hintBubbleTimeout);
37
+ });
38
+
39
+ // Hide hint bubble if chat is opened by other means
40
+ chatWindow.addEventListener("transitionstart", () => {
41
+ hintBubble.style.display = "none";
42
+ clearTimeout(hintBubbleTimeout);
43
+ });
15
44
  }
16
45
 
17
- const chatWindow = document.createElement('div');
46
+
18
47
  chatWindow.id = "aptolix-chat-window";
19
48
  chatWindow.classList.add(modeClass);
20
49
  chatWindow.style.display = mode === "section" ? "flex" : "none";
@@ -31,7 +60,7 @@ const AptolixChatbot = {
31
60
  <div id="aptolix-chat-header">
32
61
  <div class="aptolix-header-flex">
33
62
  <div class="aptolix-header-title">
34
- <strong>${title || "Assistant"}</strong>
63
+ <strong>${title || "AI Chatbot"}</strong>
35
64
  ${subtitle ? `<div class="aptolix-header-subtitle">${subtitle}</div>` : ""}
36
65
  </div>
37
66
  <div class="aptolix-header-actions">
@@ -39,6 +68,7 @@ const AptolixChatbot = {
39
68
  <button id="aptolix-chat-expand" title="Expand/Collapse" aria-label="Expand/Collapse">
40
69
  <span id="aptolix-chat-expand-icon">⤢</span>
41
70
  </button>
71
+ <button id="aptolix-chat-download" title="Download chat" aria-label="Download chat">⤓</button>
42
72
  <button id="aptolix-chat-close" title="Close chat" aria-label="Close chat">×</button>
43
73
  </div>
44
74
  </div>
@@ -60,6 +90,7 @@ const AptolixChatbot = {
60
90
  const input = chatWindow.querySelector("#aptolix-chat-inputbox");
61
91
  const sendButton = chatWindow.querySelector("button");
62
92
  const messagesDiv = chatWindow.querySelector("#aptolix-chat-messages");
93
+ const downloadBtn = chatWindow.querySelector("#aptolix-chat-download");
63
94
 
64
95
  if (mode === "bubble") {
65
96
  closeBtn.addEventListener("click", () => {
@@ -233,6 +264,29 @@ const AptolixChatbot = {
233
264
  this.style.overflowY = 'hidden';
234
265
  }
235
266
  });
267
+
268
+ downloadBtn.addEventListener("click", () => {
269
+ // Collect all messages
270
+ const messages = Array.from(messagesDiv.querySelectorAll('.message')).map(msg => {
271
+ const sender = msg.classList.contains('user') ? "You" : "Bot";
272
+ // Remove HTML tags for plain text
273
+ const text = msg.innerText || msg.textContent;
274
+ return `${sender}: ${text}`;
275
+ }).join('\n\n');
276
+
277
+ // Create a blob and trigger download
278
+ const blob = new Blob([messages], { type: "text/plain" });
279
+ const url = URL.createObjectURL(blob);
280
+ const a = document.createElement("a");
281
+ a.href = url;
282
+ a.download = "chat_history.txt";
283
+ document.body.appendChild(a);
284
+ a.click();
285
+ setTimeout(() => {
286
+ document.body.removeChild(a);
287
+ URL.revokeObjectURL(url);
288
+ }, 100);
289
+ });
236
290
  },
237
291
  initFull: function(options) {
238
292
  let el = document.querySelector('aptolix-chatbot');
@@ -270,7 +324,7 @@ class AptolixChatbotElement extends HTMLElement {
270
324
  const chatflowid = this.getAttribute('chatflowid');
271
325
  if (!apiHost || !chatflowid) return;
272
326
 
273
- const title = this.getAttribute('title') || "Aptolix Assistant";
327
+ const title = this.getAttribute('title') || "Aptolix AI Chatbot";
274
328
  const greeting = this.getAttribute('greeting');
275
329
  const subtitle = this.getAttribute('subtitle');
276
330
  const targetAttr = this.getAttribute('target');