@a.izzuddin/ai-chat 0.2.25 → 0.2.26

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/index.mjs CHANGED
@@ -5371,7 +5371,7 @@ MarkdownIt.prototype.renderInline = function(src, env) {
5371
5371
  var lib_default = MarkdownIt;
5372
5372
 
5373
5373
  // src/components/ai-chat.ts
5374
- console.log("Chatbot Ver = 0.2.24-beta.0");
5374
+ console.log("Chatbot Ver = 0.2.25-beta.5");
5375
5375
  var md = new lib_default({
5376
5376
  html: false,
5377
5377
  // Disable HTML tags in source for security
@@ -5789,7 +5789,8 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
5789
5789
  id: (Date.now() + 1).toString(),
5790
5790
  role: "assistant",
5791
5791
  content: responseText,
5792
- suggestedQuestions
5792
+ suggestedQuestions,
5793
+ language: this.language
5793
5794
  };
5794
5795
  this.messages = [...this.messages, assistantMessage];
5795
5796
  this.clearPendingRequest();
@@ -5938,7 +5939,8 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
5938
5939
  content: responseText,
5939
5940
  faqs,
5940
5941
  suggestedQuestions,
5941
- confidence
5942
+ confidence,
5943
+ language: this.language
5942
5944
  };
5943
5945
  this.messages = [...this.messages, assistantMessage];
5944
5946
  this.clearPendingRequest();
@@ -6025,7 +6027,8 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6025
6027
  id: (Date.now() + 1).toString(),
6026
6028
  role: "assistant",
6027
6029
  content: responseText,
6028
- suggestedQuestions
6030
+ suggestedQuestions,
6031
+ language: this.language
6029
6032
  };
6030
6033
  this.messages = [...this.messages, assistantMessage];
6031
6034
  this.clearPendingRequest();
@@ -6194,7 +6197,8 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6194
6197
  content: responseText,
6195
6198
  faqs,
6196
6199
  suggestedQuestions,
6197
- confidence
6200
+ confidence,
6201
+ language: this.language
6198
6202
  };
6199
6203
  this.messages = [...this.messages, assistantMessage];
6200
6204
  this.clearPendingRequest();
@@ -6226,6 +6230,13 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6226
6230
  <!-- Header -->
6227
6231
  <div class="header" style="--primary-color: ${this.primaryColor}; --primary-color-light: ${primaryColorLight}; --primary-color-hover: ${this.primaryColorHover};">
6228
6232
  <div class="header-content">
6233
+ ${this.mode === "widget" ? html`
6234
+ <button class="header-back-button" @click=${this.toggleWidget} aria-label="Back">
6235
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
6236
+ <polyline points="15 18 9 12 15 6"></polyline>
6237
+ </svg>
6238
+ </button>
6239
+ ` : ""}
6229
6240
  <div class="header-avatar">
6230
6241
  ${this.botAvatarUrl ? html`<img src="${this.botAvatarUrl}" alt="Bot" class="header-avatar-image" />` : html`<svg viewBox="0 0 24 24" fill="none" stroke="${this.primaryColor}" stroke-width="2" style="width: 1.5rem; height: 1.5rem;">
6231
6242
  <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
@@ -6276,7 +6287,7 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6276
6287
  ` : ""}
6277
6288
  ${msg.role === "assistant" && msg.suggestedQuestions && msg.suggestedQuestions.length > 0 ? html`
6278
6289
  <div class="faq-section">
6279
- <p class="faq-title">${this.language === "ms" || this.language === "my" ? "Cadangan Soalan:" : "Suggested Questions:"}</p>
6290
+ <p class="faq-title">${msg.language === "ms" || msg.language === "my" ? "Cadangan Soalan:" : "Suggested Questions:"}</p>
6280
6291
  <ul class="faq-list">
6281
6292
  ${msg.suggestedQuestions.map((question) => html`
6282
6293
  <li class="faq-item" @click=${(e) => this.handleFAQClick(question, e)}>
@@ -6368,14 +6379,18 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6368
6379
  <button
6369
6380
  class=${classMap({
6370
6381
  "widget-button": true,
6371
- "widget-button-no-bg": !!this.widgetIconUrl,
6372
- "widget-button-hidden": this.isOpen
6382
+ "widget-button-no-bg": !this.isOpen && !!this.widgetIconUrl,
6383
+ "widget-button-close": this.isOpen
6373
6384
  })}
6374
6385
  style="--primary-color: ${this.primaryColor}; --primary-color-light: ${primaryColorLight};"
6375
6386
  @click=${this.toggleWidget}
6376
6387
  aria-label=${this.isOpen ? "Close chat" : "Open chat"}
6377
6388
  >
6378
- ${this.widgetIconUrl ? html`
6389
+ ${this.isOpen ? html`
6390
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
6391
+ <polyline points="6 9 12 15 18 9"></polyline>
6392
+ </svg>
6393
+ ` : this.widgetIconUrl ? html`
6379
6394
  <img src="${this.widgetIconUrl}" alt="Chat" class="widget-button-icon" />
6380
6395
  ` : html`
6381
6396
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
@@ -6451,8 +6466,19 @@ AIChat.styles = css`
6451
6466
  transform: scale(1.1);
6452
6467
  }
6453
6468
 
6454
- .widget-button-hidden {
6455
- display: none;
6469
+ .widget-button-close {
6470
+ background: var(--primary-color, #3681D3);
6471
+ box-shadow: 0 4px 16px rgba(54, 129, 211, 0.3);
6472
+ }
6473
+
6474
+ .widget-button-close:hover {
6475
+ background: var(--primary-color, #3681D3);
6476
+ box-shadow: 0 6px 20px rgba(54, 129, 211, 0.4);
6477
+ transform: scale(1.05);
6478
+ }
6479
+
6480
+ .widget-button-close svg {
6481
+ color: #ffffff;
6456
6482
  }
6457
6483
 
6458
6484
  .widget-speech-bubble {
@@ -6503,7 +6529,7 @@ AIChat.styles = css`
6503
6529
 
6504
6530
  .widget-window {
6505
6531
  position: absolute;
6506
- bottom: 0;
6532
+ bottom: 90px;
6507
6533
  right: 0;
6508
6534
  width: var(--widget-width, 380px);
6509
6535
  height: var(--widget-height, 600px);
@@ -6549,10 +6575,14 @@ AIChat.styles = css`
6549
6575
  /* Mobile portrait */
6550
6576
  @media (max-width: 480px) and (orientation: portrait) {
6551
6577
  .widget-window {
6552
- width: calc(100vw - 40px);
6553
- height: 70vh;
6554
- bottom: 0;
6578
+ position: fixed;
6579
+ top: 0;
6580
+ left: 0;
6555
6581
  right: 0;
6582
+ bottom: 0;
6583
+ width: 100vw;
6584
+ height: 100vh;
6585
+ border-radius: 0;
6556
6586
  }
6557
6587
 
6558
6588
  .widget-button {
@@ -6569,10 +6599,14 @@ AIChat.styles = css`
6569
6599
  /* Mobile landscape */
6570
6600
  @media (max-width: 900px) and (orientation: landscape) {
6571
6601
  .widget-window {
6572
- width: var(--widget-width, 500px);
6573
- height: calc(100vh - 100px);
6574
- bottom: 0;
6602
+ position: fixed;
6603
+ top: 0;
6604
+ left: 0;
6575
6605
  right: 0;
6606
+ bottom: 0;
6607
+ width: 100vw;
6608
+ height: 100vh;
6609
+ border-radius: 0;
6576
6610
  }
6577
6611
 
6578
6612
  .widget-button {
@@ -6833,6 +6867,41 @@ AIChat.styles = css`
6833
6867
  height: 1.25rem;
6834
6868
  }
6835
6869
 
6870
+ .header-back-button {
6871
+ display: none;
6872
+ background: none;
6873
+ border: none;
6874
+ cursor: pointer;
6875
+ color: #fff;
6876
+ padding: 0.3rem;
6877
+ align-items: center;
6878
+ justify-content: center;
6879
+ border-radius: 50%;
6880
+ transition: background 0.2s;
6881
+ flex-shrink: 0;
6882
+ }
6883
+
6884
+ .header-back-button:hover {
6885
+ background: rgba(255, 255, 255, 0.2);
6886
+ }
6887
+
6888
+ .header-back-button svg {
6889
+ width: 1.25rem;
6890
+ height: 1.25rem;
6891
+ }
6892
+
6893
+ @media (max-width: 480px) {
6894
+ .header-back-button {
6895
+ display: flex;
6896
+ }
6897
+ }
6898
+
6899
+ @media (max-width: 900px) and (orientation: landscape) {
6900
+ .header-back-button {
6901
+ display: flex;
6902
+ }
6903
+ }
6904
+
6836
6905
  .messages-area {
6837
6906
  flex: 1;
6838
6907
  overflow-y: auto;