@a.izzuddin/ai-chat 0.2.24 → 0.2.25-beta.3

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.js CHANGED
@@ -5399,7 +5399,7 @@ exports.AIChat = class AIChat extends lit.LitElement {
5399
5399
  this.widgetHeight = "600px";
5400
5400
  this.primaryColor = "#3681D3";
5401
5401
  this.primaryColorHover = "#3457C7";
5402
- this.userMessageBg = "#D6E4FF";
5402
+ this.userMessageBg = "#1a4fbd";
5403
5403
  this.botMessageBg = "#F5F5F5";
5404
5404
  this.welcomeMessage = "How can I help you today?";
5405
5405
  this.welcomeSubtitle = "";
@@ -6234,6 +6234,14 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6234
6234
  </svg>`}
6235
6235
  </div>
6236
6236
  <h1 class="title">${this.chatTitle}</h1>
6237
+ ${this.mode === "widget" ? lit.html`
6238
+ <button class="header-close-button" @click=${this.toggleWidget} aria-label="Close chat">
6239
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
6240
+ <line x1="18" y1="6" x2="6" y2="18"></line>
6241
+ <line x1="6" y1="6" x2="18" y2="18"></line>
6242
+ </svg>
6243
+ </button>
6244
+ ` : ""}
6237
6245
  </div>
6238
6246
  </div>
6239
6247
 
@@ -6270,7 +6278,7 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6270
6278
  ` : ""}
6271
6279
  ${msg.role === "assistant" && msg.suggestedQuestions && msg.suggestedQuestions.length > 0 ? lit.html`
6272
6280
  <div class="faq-section">
6273
- <p class="faq-title">Cadangan Soalan:</p>
6281
+ <p class="faq-title">${this.language === "ms" || this.language === "my" ? "Cadangan Soalan:" : "Suggested Questions:"}</p>
6274
6282
  <ul class="faq-list">
6275
6283
  ${msg.suggestedQuestions.map((question) => lit.html`
6276
6284
  <li class="faq-item" @click=${(e) => this.handleFAQClick(question, e)}>
@@ -6304,7 +6312,9 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6304
6312
  ${this.botAvatarUrl ? lit.html`<img src="${this.botAvatarUrl}" alt="AI" class="avatar-image" />` : "AI"}
6305
6313
  </div>
6306
6314
  <div class="message-content">
6307
- <div class="spinner"></div>
6315
+ <div class="spinner">
6316
+ <span></span><span></span><span></span>
6317
+ </div>
6308
6318
  </div>
6309
6319
  </div>
6310
6320
  ` : ""}
@@ -6317,7 +6327,7 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6317
6327
  <input
6318
6328
  type="text"
6319
6329
  class="input-field"
6320
- placeholder="Taip mesej anda..."
6330
+ placeholder="${this.language === "ms" || this.language === "my" ? "Taip mesej anda..." : "Type your message..."}"
6321
6331
  .value=${this.input}
6322
6332
  @input=${this.handleInput}
6323
6333
  ?disabled=${this.isLoading}
@@ -6328,14 +6338,10 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6328
6338
  ?disabled=${this.isLoading || !this.input.trim()}
6329
6339
  aria-label="Send message"
6330
6340
  >
6331
- ${this.isLoading ? lit.html`
6332
- <div class="spinner" style="border-color: #fff; border-top-color: transparent;"></div>
6333
- ` : lit.html`
6334
- <svg class="send-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
6335
- <line x1="22" y1="2" x2="11" y2="13"></line>
6336
- <polygon points="22 2 15 22 11 13 2 9 22 2"></polygon>
6337
- </svg>
6338
- `}
6341
+ <svg class="send-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
6342
+ <line x1="22" y1="2" x2="11" y2="13"></line>
6343
+ <polygon points="22 2 15 22 11 13 2 9 22 2"></polygon>
6344
+ </svg>
6339
6345
  </button>
6340
6346
  </form>
6341
6347
  </div>
@@ -6355,22 +6361,23 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6355
6361
  ${this.renderChatUI()}
6356
6362
  </div>
6357
6363
 
6364
+ <!-- Speech Bubble -->
6365
+ ${!this.isOpen ? lit.html`
6366
+ <div class="widget-speech-bubble">${this.language === "ms" || this.language === "my" ? "Perlukan bantuan? Sembang dengan saya!" : "Need help? Chat with me!"}</div>
6367
+ ` : ""}
6368
+
6358
6369
  <!-- Toggle Button -->
6359
6370
  <button
6360
6371
  class=${classMap_js.classMap({
6361
6372
  "widget-button": true,
6362
- "widget-button-no-bg": !this.isOpen && !!this.widgetIconUrl
6373
+ "widget-button-no-bg": !!this.widgetIconUrl,
6374
+ "widget-button-hidden": this.isOpen
6363
6375
  })}
6364
6376
  style="--primary-color: ${this.primaryColor}; --primary-color-light: ${primaryColorLight};"
6365
6377
  @click=${this.toggleWidget}
6366
6378
  aria-label=${this.isOpen ? "Close chat" : "Open chat"}
6367
6379
  >
6368
- ${this.isOpen ? lit.html`
6369
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
6370
- <line x1="18" y1="6" x2="6" y2="18"></line>
6371
- <line x1="6" y1="6" x2="18" y2="18"></line>
6372
- </svg>
6373
- ` : this.widgetIconUrl ? lit.html`
6380
+ ${this.widgetIconUrl ? lit.html`
6374
6381
  <img src="${this.widgetIconUrl}" alt="Chat" class="widget-button-icon" />
6375
6382
  ` : lit.html`
6376
6383
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
@@ -6416,8 +6423,8 @@ exports.AIChat.styles = lit.css`
6416
6423
  }
6417
6424
 
6418
6425
  .widget-button {
6419
- width: 60px;
6420
- height: 60px;
6426
+ width: 80px;
6427
+ height: 80px;
6421
6428
  border-radius: 50%;
6422
6429
  background: #3681D3;
6423
6430
  border: none;
@@ -6446,6 +6453,43 @@ exports.AIChat.styles = lit.css`
6446
6453
  transform: scale(1.1);
6447
6454
  }
6448
6455
 
6456
+ .widget-button-hidden {
6457
+ display: none;
6458
+ }
6459
+
6460
+ .widget-speech-bubble {
6461
+ position: absolute;
6462
+ bottom: 22px;
6463
+ right: 90px;
6464
+ background: #fff;
6465
+ color: #333;
6466
+ font-size: 0.875rem;
6467
+ font-weight: 500;
6468
+ padding: 0.5rem 0.875rem;
6469
+ border-radius: 1rem 1rem 0.25rem 1rem;
6470
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
6471
+ white-space: nowrap;
6472
+ opacity: 0;
6473
+ transform: translateX(8px);
6474
+ transition: opacity 0.2s, transform 0.2s;
6475
+ pointer-events: none;
6476
+ }
6477
+
6478
+ .widget-speech-bubble::after {
6479
+ content: '';
6480
+ position: absolute;
6481
+ bottom: 6px;
6482
+ right: -8px;
6483
+ border-width: 6px 0 6px 8px;
6484
+ border-style: solid;
6485
+ border-color: transparent transparent transparent #fff;
6486
+ }
6487
+
6488
+ .widget-container:hover .widget-speech-bubble {
6489
+ opacity: 1;
6490
+ transform: translateX(0);
6491
+ }
6492
+
6449
6493
  .widget-button svg {
6450
6494
  width: 28px;
6451
6495
  height: 28px;
@@ -6453,15 +6497,15 @@ exports.AIChat.styles = lit.css`
6453
6497
  }
6454
6498
 
6455
6499
  .widget-button-icon {
6456
- width: 60px;
6457
- height: 60px;
6500
+ width: 80px;
6501
+ height: 80px;
6458
6502
  object-fit: contain;
6459
6503
  border-radius: 50%;
6460
6504
  }
6461
6505
 
6462
6506
  .widget-window {
6463
6507
  position: absolute;
6464
- bottom: 80px;
6508
+ bottom: 0;
6465
6509
  right: 0;
6466
6510
  width: var(--widget-width, 380px);
6467
6511
  height: var(--widget-height, 600px);
@@ -6509,18 +6553,18 @@ exports.AIChat.styles = lit.css`
6509
6553
  .widget-window {
6510
6554
  width: calc(100vw - 40px);
6511
6555
  height: 70vh;
6512
- bottom: 80px;
6556
+ bottom: 0;
6513
6557
  right: 0;
6514
6558
  }
6515
6559
 
6516
6560
  .widget-button {
6517
- width: 56px;
6518
- height: 56px;
6561
+ width: 68px;
6562
+ height: 68px;
6519
6563
  }
6520
6564
 
6521
6565
  .widget-button svg {
6522
- width: 24px;
6523
- height: 24px;
6566
+ width: 28px;
6567
+ height: 28px;
6524
6568
  }
6525
6569
  }
6526
6570
 
@@ -6529,33 +6573,18 @@ exports.AIChat.styles = lit.css`
6529
6573
  .widget-window {
6530
6574
  width: var(--widget-width, 500px);
6531
6575
  height: calc(100vh - 100px);
6532
- bottom: 80px;
6576
+ bottom: 0;
6533
6577
  right: 0;
6534
6578
  }
6535
6579
 
6536
6580
  .widget-button {
6537
- width: 56px;
6538
- height: 56px;
6581
+ width: 68px;
6582
+ height: 68px;
6539
6583
  }
6540
6584
 
6541
6585
  .widget-button svg {
6542
- width: 24px;
6543
- height: 24px;
6544
- }
6545
- }
6546
-
6547
- /* Desktop responsive styles - reduce excessive margins on large screens */
6548
- @media (min-width: 1025px) {
6549
- .message.user {
6550
- margin-left: 2rem;
6551
- }
6552
-
6553
- .message.assistant {
6554
- margin-right: 1.5rem;
6555
- }
6556
-
6557
- .contact-support-wrapper {
6558
- margin-left: 1.5rem;
6586
+ width: 28px;
6587
+ height: 28px;
6559
6588
  }
6560
6589
  }
6561
6590
 
@@ -6587,11 +6616,11 @@ exports.AIChat.styles = lit.css`
6587
6616
  }
6588
6617
 
6589
6618
  .message.user {
6590
- margin-left: 3.5rem;
6619
+ margin-left: 0;
6591
6620
  }
6592
6621
 
6593
6622
  .message.assistant {
6594
- margin-right: 2.75rem;
6623
+ margin-right: 0;
6595
6624
  }
6596
6625
 
6597
6626
  .avatar {
@@ -6607,7 +6636,7 @@ exports.AIChat.styles = lit.css`
6607
6636
  }
6608
6637
 
6609
6638
  .message.user .message-content {
6610
- max-width: 85%;
6639
+ max-width: 100%;
6611
6640
  }
6612
6641
 
6613
6642
  .empty-state {
@@ -6683,11 +6712,11 @@ exports.AIChat.styles = lit.css`
6683
6712
  }
6684
6713
 
6685
6714
  .message.user {
6686
- margin-left: 3rem;
6715
+ margin-left: 0;
6687
6716
  }
6688
6717
 
6689
6718
  .message.assistant {
6690
- margin-right: 2.25rem;
6719
+ margin-right: 0;
6691
6720
  }
6692
6721
 
6693
6722
  .avatar {
@@ -6703,7 +6732,7 @@ exports.AIChat.styles = lit.css`
6703
6732
  }
6704
6733
 
6705
6734
  .message.user .message-content {
6706
- max-width: 80%;
6735
+ max-width: 100%;
6707
6736
  }
6708
6737
 
6709
6738
  .empty-state {
@@ -6782,6 +6811,30 @@ exports.AIChat.styles = lit.css`
6782
6811
  color: #fff;
6783
6812
  }
6784
6813
 
6814
+ .header-close-button {
6815
+ background: none;
6816
+ border: none;
6817
+ cursor: pointer;
6818
+ color: #fff;
6819
+ padding: 0.3rem;
6820
+ display: flex;
6821
+ align-items: center;
6822
+ justify-content: center;
6823
+ margin-left: auto;
6824
+ border-radius: 50%;
6825
+ transition: background 0.2s;
6826
+ flex-shrink: 0;
6827
+ }
6828
+
6829
+ .header-close-button:hover {
6830
+ background: rgba(255, 255, 255, 0.2);
6831
+ }
6832
+
6833
+ .header-close-button svg {
6834
+ width: 1.25rem;
6835
+ height: 1.25rem;
6836
+ }
6837
+
6785
6838
  .messages-area {
6786
6839
  flex: 1;
6787
6840
  overflow-y: auto;
@@ -6900,11 +6953,11 @@ exports.AIChat.styles = lit.css`
6900
6953
  .message.user {
6901
6954
  flex-direction: row-reverse;
6902
6955
  justify-content: flex-end;
6903
- margin-left: 5rem;
6956
+ margin-left: 0;
6904
6957
  }
6905
6958
 
6906
6959
  .message.assistant {
6907
- margin-right: 3.5rem;
6960
+ margin-right: 0;
6908
6961
  }
6909
6962
 
6910
6963
  .avatar {
@@ -6934,38 +6987,46 @@ exports.AIChat.styles = lit.css`
6934
6987
  }
6935
6988
 
6936
6989
  .message-content {
6937
- max-width: 36rem;
6990
+ width: fit-content;
6991
+ max-width: 100%;
6938
6992
  border-radius: 1.25rem;
6939
- line-height: 1.6;
6993
+ line-height: 1.65;
6940
6994
  overflow-wrap: break-word;
6941
6995
  word-wrap: break-word;
6942
6996
  min-width: 0;
6943
6997
  font-size: 1.2rem;
6944
- padding: 1rem 1.5rem;
6998
+ padding: 0.875rem 1.125rem;
6999
+ letter-spacing: 0.01em;
6945
7000
  }
6946
7001
 
6947
7002
  .message.user .message-content {
6948
- background: var(--user-message-bg, #D6E4FF);
6949
- color: #1a1a1a;
7003
+ background: var(--user-message-bg, #0D47A1);
7004
+ color: #ffffff;
6950
7005
  border-radius: 1.25rem 0.25rem 1.25rem 1.25rem;
6951
- max-width: 26rem;
7006
+ box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
7007
+ max-width: 100%;
6952
7008
  margin-left: auto;
6953
7009
  }
6954
7010
 
6955
7011
  .message.assistant .message-content {
6956
- background: var(--bot-message-bg, #F5F5F5);
6957
- color: #1a1a1a;
7012
+ flex: 1;
7013
+ background: var(--bot-message-bg, #f0f2f5);
7014
+ color: #1a1a2e;
6958
7015
  border-radius: 0.25rem 1.25rem 1.25rem 1.25rem;
7016
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
7017
+ border: 1px solid rgba(0, 0, 0, 0.06);
6959
7018
  }
6960
7019
 
6961
7020
  :host([theme="dark"]) .message.user .message-content {
6962
- background: #3D5A99;
7021
+ background: #1a4fbd;
6963
7022
  color: #fff;
7023
+ box-shadow: 0 2px 8px rgba(29, 78, 216, 0.4);
6964
7024
  }
6965
7025
 
6966
7026
  :host([theme="dark"]) .message.assistant .message-content {
6967
7027
  background: #27272a;
6968
- color: #fafafa;
7028
+ color: #e4e4e7;
7029
+ border-color: rgba(255, 255, 255, 0.06);
6969
7030
  }
6970
7031
 
6971
7032
  .message-text {
@@ -7221,17 +7282,29 @@ exports.AIChat.styles = lit.css`
7221
7282
  }
7222
7283
 
7223
7284
  .spinner {
7285
+ display: flex;
7286
+ align-items: center;
7287
+ gap: 0.35rem;
7288
+ padding: 0.25rem 0;
7289
+ }
7290
+
7291
+ .spinner span {
7224
7292
  display: inline-block;
7225
- width: 1.25rem;
7226
- height: 1.25rem;
7227
- border: 2px solid #e4e4e7;
7228
- border-top-color: #71717a;
7293
+ width: 0.55rem;
7294
+ height: 0.55rem;
7295
+ background-color: var(--primary-color, #3681D3);
7229
7296
  border-radius: 50%;
7230
- animation: spin 1s linear infinite;
7297
+ animation: dot-pulse 1.4s ease-in-out infinite;
7298
+ opacity: 0.3;
7231
7299
  }
7232
7300
 
7233
- @keyframes spin {
7234
- to { transform: rotate(360deg); }
7301
+ .spinner span:nth-child(1) { animation-delay: 0s; }
7302
+ .spinner span:nth-child(2) { animation-delay: 0.2s; }
7303
+ .spinner span:nth-child(3) { animation-delay: 0.4s; }
7304
+
7305
+ @keyframes dot-pulse {
7306
+ 0%, 100% { transform: scale(1); opacity: 0.3; }
7307
+ 50% { transform: scale(1.5); opacity: 1; }
7235
7308
  }
7236
7309
 
7237
7310
  .input-area {