@a.izzuddin/ai-chat 0.2.23 → 0.2.25-beta.1

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
@@ -5397,7 +5397,7 @@ var AIChat = class extends LitElement {
5397
5397
  this.widgetHeight = "600px";
5398
5398
  this.primaryColor = "#3681D3";
5399
5399
  this.primaryColorHover = "#3457C7";
5400
- this.userMessageBg = "#D6E4FF";
5400
+ this.userMessageBg = "#1a4fbd";
5401
5401
  this.botMessageBg = "#F5F5F5";
5402
5402
  this.welcomeMessage = "How can I help you today?";
5403
5403
  this.welcomeSubtitle = "";
@@ -6232,6 +6232,14 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6232
6232
  </svg>`}
6233
6233
  </div>
6234
6234
  <h1 class="title">${this.chatTitle}</h1>
6235
+ ${this.mode === "widget" ? html`
6236
+ <button class="header-close-button" @click=${this.toggleWidget} aria-label="Close chat">
6237
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
6238
+ <line x1="18" y1="6" x2="6" y2="18"></line>
6239
+ <line x1="6" y1="6" x2="18" y2="18"></line>
6240
+ </svg>
6241
+ </button>
6242
+ ` : ""}
6235
6243
  </div>
6236
6244
  </div>
6237
6245
 
@@ -6268,7 +6276,7 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6268
6276
  ` : ""}
6269
6277
  ${msg.role === "assistant" && msg.suggestedQuestions && msg.suggestedQuestions.length > 0 ? html`
6270
6278
  <div class="faq-section">
6271
- <p class="faq-title">Cadangan Soalan:</p>
6279
+ <p class="faq-title">${this.language === "ms" || this.language === "my" ? "Cadangan Soalan:" : "Suggested Questions:"}</p>
6272
6280
  <ul class="faq-list">
6273
6281
  ${msg.suggestedQuestions.map((question) => html`
6274
6282
  <li class="faq-item" @click=${(e) => this.handleFAQClick(question, e)}>
@@ -6302,7 +6310,9 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6302
6310
  ${this.botAvatarUrl ? html`<img src="${this.botAvatarUrl}" alt="AI" class="avatar-image" />` : "AI"}
6303
6311
  </div>
6304
6312
  <div class="message-content">
6305
- <div class="spinner"></div>
6313
+ <div class="spinner">
6314
+ <span></span><span></span><span></span>
6315
+ </div>
6306
6316
  </div>
6307
6317
  </div>
6308
6318
  ` : ""}
@@ -6315,7 +6325,7 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6315
6325
  <input
6316
6326
  type="text"
6317
6327
  class="input-field"
6318
- placeholder="Taip mesej anda..."
6328
+ placeholder="${this.language === "ms" || this.language === "my" ? "Taip mesej anda..." : "Type your message..."}"
6319
6329
  .value=${this.input}
6320
6330
  @input=${this.handleInput}
6321
6331
  ?disabled=${this.isLoading}
@@ -6326,14 +6336,10 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6326
6336
  ?disabled=${this.isLoading || !this.input.trim()}
6327
6337
  aria-label="Send message"
6328
6338
  >
6329
- ${this.isLoading ? html`
6330
- <div class="spinner" style="border-color: #fff; border-top-color: transparent;"></div>
6331
- ` : html`
6332
- <svg class="send-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
6333
- <line x1="22" y1="2" x2="11" y2="13"></line>
6334
- <polygon points="22 2 15 22 11 13 2 9 22 2"></polygon>
6335
- </svg>
6336
- `}
6339
+ <svg class="send-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
6340
+ <line x1="22" y1="2" x2="11" y2="13"></line>
6341
+ <polygon points="22 2 15 22 11 13 2 9 22 2"></polygon>
6342
+ </svg>
6337
6343
  </button>
6338
6344
  </form>
6339
6345
  </div>
@@ -6353,22 +6359,23 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
6353
6359
  ${this.renderChatUI()}
6354
6360
  </div>
6355
6361
 
6362
+ <!-- Speech Bubble -->
6363
+ ${!this.isOpen ? html`
6364
+ <div class="widget-speech-bubble">${this.language === "ms" || this.language === "my" ? "Perlukan bantuan? Sembang dengan saya!" : "Need help? Chat with me!"}</div>
6365
+ ` : ""}
6366
+
6356
6367
  <!-- Toggle Button -->
6357
6368
  <button
6358
6369
  class=${classMap({
6359
6370
  "widget-button": true,
6360
- "widget-button-no-bg": !this.isOpen && !!this.widgetIconUrl
6371
+ "widget-button-no-bg": !!this.widgetIconUrl,
6372
+ "widget-button-hidden": this.isOpen
6361
6373
  })}
6362
6374
  style="--primary-color: ${this.primaryColor}; --primary-color-light: ${primaryColorLight};"
6363
6375
  @click=${this.toggleWidget}
6364
6376
  aria-label=${this.isOpen ? "Close chat" : "Open chat"}
6365
6377
  >
6366
- ${this.isOpen ? html`
6367
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
6368
- <line x1="18" y1="6" x2="6" y2="18"></line>
6369
- <line x1="6" y1="6" x2="18" y2="18"></line>
6370
- </svg>
6371
- ` : this.widgetIconUrl ? html`
6378
+ ${this.widgetIconUrl ? html`
6372
6379
  <img src="${this.widgetIconUrl}" alt="Chat" class="widget-button-icon" />
6373
6380
  ` : html`
6374
6381
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
@@ -6414,8 +6421,8 @@ AIChat.styles = css`
6414
6421
  }
6415
6422
 
6416
6423
  .widget-button {
6417
- width: 60px;
6418
- height: 60px;
6424
+ width: 80px;
6425
+ height: 80px;
6419
6426
  border-radius: 50%;
6420
6427
  background: #3681D3;
6421
6428
  border: none;
@@ -6444,6 +6451,43 @@ AIChat.styles = css`
6444
6451
  transform: scale(1.1);
6445
6452
  }
6446
6453
 
6454
+ .widget-button-hidden {
6455
+ display: none;
6456
+ }
6457
+
6458
+ .widget-speech-bubble {
6459
+ position: absolute;
6460
+ bottom: 22px;
6461
+ right: 90px;
6462
+ background: #fff;
6463
+ color: #333;
6464
+ font-size: 0.875rem;
6465
+ font-weight: 500;
6466
+ padding: 0.5rem 0.875rem;
6467
+ border-radius: 1rem 1rem 0.25rem 1rem;
6468
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
6469
+ white-space: nowrap;
6470
+ opacity: 0;
6471
+ transform: translateX(8px);
6472
+ transition: opacity 0.2s, transform 0.2s;
6473
+ pointer-events: none;
6474
+ }
6475
+
6476
+ .widget-speech-bubble::after {
6477
+ content: '';
6478
+ position: absolute;
6479
+ bottom: 6px;
6480
+ right: -8px;
6481
+ border-width: 6px 0 6px 8px;
6482
+ border-style: solid;
6483
+ border-color: transparent transparent transparent #fff;
6484
+ }
6485
+
6486
+ .widget-container:hover .widget-speech-bubble {
6487
+ opacity: 1;
6488
+ transform: translateX(0);
6489
+ }
6490
+
6447
6491
  .widget-button svg {
6448
6492
  width: 28px;
6449
6493
  height: 28px;
@@ -6451,15 +6495,15 @@ AIChat.styles = css`
6451
6495
  }
6452
6496
 
6453
6497
  .widget-button-icon {
6454
- width: 60px;
6455
- height: 60px;
6498
+ width: 80px;
6499
+ height: 80px;
6456
6500
  object-fit: contain;
6457
6501
  border-radius: 50%;
6458
6502
  }
6459
6503
 
6460
6504
  .widget-window {
6461
6505
  position: absolute;
6462
- bottom: 80px;
6506
+ bottom: 0;
6463
6507
  right: 0;
6464
6508
  width: var(--widget-width, 380px);
6465
6509
  height: var(--widget-height, 600px);
@@ -6507,18 +6551,18 @@ AIChat.styles = css`
6507
6551
  .widget-window {
6508
6552
  width: calc(100vw - 40px);
6509
6553
  height: 70vh;
6510
- bottom: 80px;
6554
+ bottom: 0;
6511
6555
  right: 0;
6512
6556
  }
6513
6557
 
6514
6558
  .widget-button {
6515
- width: 56px;
6516
- height: 56px;
6559
+ width: 68px;
6560
+ height: 68px;
6517
6561
  }
6518
6562
 
6519
6563
  .widget-button svg {
6520
- width: 24px;
6521
- height: 24px;
6564
+ width: 28px;
6565
+ height: 28px;
6522
6566
  }
6523
6567
  }
6524
6568
 
@@ -6527,18 +6571,18 @@ AIChat.styles = css`
6527
6571
  .widget-window {
6528
6572
  width: var(--widget-width, 500px);
6529
6573
  height: calc(100vh - 100px);
6530
- bottom: 80px;
6574
+ bottom: 0;
6531
6575
  right: 0;
6532
6576
  }
6533
6577
 
6534
6578
  .widget-button {
6535
- width: 56px;
6536
- height: 56px;
6579
+ width: 68px;
6580
+ height: 68px;
6537
6581
  }
6538
6582
 
6539
6583
  .widget-button svg {
6540
- width: 24px;
6541
- height: 24px;
6584
+ width: 28px;
6585
+ height: 28px;
6542
6586
  }
6543
6587
  }
6544
6588
 
@@ -6570,11 +6614,11 @@ AIChat.styles = css`
6570
6614
  }
6571
6615
 
6572
6616
  .message.user {
6573
- margin-left: 3.5rem;
6617
+ margin-left: 0;
6574
6618
  }
6575
6619
 
6576
6620
  .message.assistant {
6577
- margin-right: 2.75rem;
6621
+ margin-right: 0;
6578
6622
  }
6579
6623
 
6580
6624
  .avatar {
@@ -6590,7 +6634,7 @@ AIChat.styles = css`
6590
6634
  }
6591
6635
 
6592
6636
  .message.user .message-content {
6593
- max-width: 85%;
6637
+ max-width: 100%;
6594
6638
  }
6595
6639
 
6596
6640
  .empty-state {
@@ -6666,11 +6710,11 @@ AIChat.styles = css`
6666
6710
  }
6667
6711
 
6668
6712
  .message.user {
6669
- margin-left: 3rem;
6713
+ margin-left: 0;
6670
6714
  }
6671
6715
 
6672
6716
  .message.assistant {
6673
- margin-right: 2.25rem;
6717
+ margin-right: 0;
6674
6718
  }
6675
6719
 
6676
6720
  .avatar {
@@ -6686,7 +6730,7 @@ AIChat.styles = css`
6686
6730
  }
6687
6731
 
6688
6732
  .message.user .message-content {
6689
- max-width: 80%;
6733
+ max-width: 100%;
6690
6734
  }
6691
6735
 
6692
6736
  .empty-state {
@@ -6765,6 +6809,30 @@ AIChat.styles = css`
6765
6809
  color: #fff;
6766
6810
  }
6767
6811
 
6812
+ .header-close-button {
6813
+ background: none;
6814
+ border: none;
6815
+ cursor: pointer;
6816
+ color: #fff;
6817
+ padding: 0.3rem;
6818
+ display: flex;
6819
+ align-items: center;
6820
+ justify-content: center;
6821
+ margin-left: auto;
6822
+ border-radius: 50%;
6823
+ transition: background 0.2s;
6824
+ flex-shrink: 0;
6825
+ }
6826
+
6827
+ .header-close-button:hover {
6828
+ background: rgba(255, 255, 255, 0.2);
6829
+ }
6830
+
6831
+ .header-close-button svg {
6832
+ width: 1.25rem;
6833
+ height: 1.25rem;
6834
+ }
6835
+
6768
6836
  .messages-area {
6769
6837
  flex: 1;
6770
6838
  overflow-y: auto;
@@ -6883,11 +6951,11 @@ AIChat.styles = css`
6883
6951
  .message.user {
6884
6952
  flex-direction: row-reverse;
6885
6953
  justify-content: flex-end;
6886
- margin-left: 5rem;
6954
+ margin-left: 0;
6887
6955
  }
6888
6956
 
6889
6957
  .message.assistant {
6890
- margin-right: 3.5rem;
6958
+ margin-right: 0;
6891
6959
  }
6892
6960
 
6893
6961
  .avatar {
@@ -6917,37 +6985,46 @@ AIChat.styles = css`
6917
6985
  }
6918
6986
 
6919
6987
  .message-content {
6920
- max-width: 36rem;
6988
+ width: fit-content;
6989
+ max-width: 100%;
6921
6990
  border-radius: 1.25rem;
6922
- line-height: 1.6;
6991
+ line-height: 1.65;
6923
6992
  overflow-wrap: break-word;
6924
6993
  word-wrap: break-word;
6925
6994
  min-width: 0;
6926
6995
  font-size: 1.2rem;
6996
+ padding: 0.875rem 1.125rem;
6997
+ letter-spacing: 0.01em;
6927
6998
  }
6928
6999
 
6929
7000
  .message.user .message-content {
6930
- background: var(--user-message-bg, #D6E4FF);
6931
- color: #1a1a1a;
7001
+ background: var(--user-message-bg, #0D47A1);
7002
+ color: #ffffff;
6932
7003
  border-radius: 1.25rem 0.25rem 1.25rem 1.25rem;
6933
- max-width: 26rem;
7004
+ box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
7005
+ max-width: 100%;
6934
7006
  margin-left: auto;
6935
7007
  }
6936
7008
 
6937
7009
  .message.assistant .message-content {
6938
- background: var(--bot-message-bg, #F5F5F5);
6939
- color: #1a1a1a;
7010
+ flex: 1;
7011
+ background: var(--bot-message-bg, #f0f2f5);
7012
+ color: #1a1a2e;
6940
7013
  border-radius: 0.25rem 1.25rem 1.25rem 1.25rem;
7014
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
7015
+ border: 1px solid rgba(0, 0, 0, 0.06);
6941
7016
  }
6942
7017
 
6943
7018
  :host([theme="dark"]) .message.user .message-content {
6944
- background: #3D5A99;
7019
+ background: #1a4fbd;
6945
7020
  color: #fff;
7021
+ box-shadow: 0 2px 8px rgba(29, 78, 216, 0.4);
6946
7022
  }
6947
7023
 
6948
7024
  :host([theme="dark"]) .message.assistant .message-content {
6949
7025
  background: #27272a;
6950
- color: #fafafa;
7026
+ color: #e4e4e7;
7027
+ border-color: rgba(255, 255, 255, 0.06);
6951
7028
  }
6952
7029
 
6953
7030
  .message-text {
@@ -7203,17 +7280,29 @@ AIChat.styles = css`
7203
7280
  }
7204
7281
 
7205
7282
  .spinner {
7283
+ display: flex;
7284
+ align-items: center;
7285
+ gap: 0.35rem;
7286
+ padding: 0.25rem 0;
7287
+ }
7288
+
7289
+ .spinner span {
7206
7290
  display: inline-block;
7207
- width: 1.25rem;
7208
- height: 1.25rem;
7209
- border: 2px solid #e4e4e7;
7210
- border-top-color: #71717a;
7291
+ width: 0.55rem;
7292
+ height: 0.55rem;
7293
+ background-color: var(--primary-color, #3681D3);
7211
7294
  border-radius: 50%;
7212
- animation: spin 1s linear infinite;
7295
+ animation: dot-pulse 1.4s ease-in-out infinite;
7296
+ opacity: 0.3;
7213
7297
  }
7214
7298
 
7215
- @keyframes spin {
7216
- to { transform: rotate(360deg); }
7299
+ .spinner span:nth-child(1) { animation-delay: 0s; }
7300
+ .spinner span:nth-child(2) { animation-delay: 0.2s; }
7301
+ .spinner span:nth-child(3) { animation-delay: 0.4s; }
7302
+
7303
+ @keyframes dot-pulse {
7304
+ 0%, 100% { transform: scale(1); opacity: 0.3; }
7305
+ 50% { transform: scale(1.5); opacity: 1; }
7217
7306
  }
7218
7307
 
7219
7308
  .input-area {