@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/README.md +346 -346
- package/README.npm.md +293 -293
- package/custom-elements.json +13 -13
- package/dist/index.js +147 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -58
- package/dist/index.mjs.map +1 -1
- package/global.d.ts +24 -24
- package/package.json +88 -88
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 = "#
|
|
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"
|
|
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"
|
|
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
|
-
|
|
6332
|
-
<
|
|
6333
|
-
|
|
6334
|
-
|
|
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":
|
|
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.
|
|
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:
|
|
6420
|
-
height:
|
|
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:
|
|
6457
|
-
height:
|
|
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:
|
|
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:
|
|
6556
|
+
bottom: 0;
|
|
6513
6557
|
right: 0;
|
|
6514
6558
|
}
|
|
6515
6559
|
|
|
6516
6560
|
.widget-button {
|
|
6517
|
-
width:
|
|
6518
|
-
height:
|
|
6561
|
+
width: 68px;
|
|
6562
|
+
height: 68px;
|
|
6519
6563
|
}
|
|
6520
6564
|
|
|
6521
6565
|
.widget-button svg {
|
|
6522
|
-
width:
|
|
6523
|
-
height:
|
|
6566
|
+
width: 28px;
|
|
6567
|
+
height: 28px;
|
|
6524
6568
|
}
|
|
6525
6569
|
}
|
|
6526
6570
|
|
|
@@ -6529,18 +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:
|
|
6576
|
+
bottom: 0;
|
|
6533
6577
|
right: 0;
|
|
6534
6578
|
}
|
|
6535
6579
|
|
|
6536
6580
|
.widget-button {
|
|
6537
|
-
width:
|
|
6538
|
-
height:
|
|
6581
|
+
width: 68px;
|
|
6582
|
+
height: 68px;
|
|
6539
6583
|
}
|
|
6540
6584
|
|
|
6541
6585
|
.widget-button svg {
|
|
6542
|
-
width:
|
|
6543
|
-
height:
|
|
6586
|
+
width: 28px;
|
|
6587
|
+
height: 28px;
|
|
6544
6588
|
}
|
|
6545
6589
|
}
|
|
6546
6590
|
|
|
@@ -6572,11 +6616,11 @@ exports.AIChat.styles = lit.css`
|
|
|
6572
6616
|
}
|
|
6573
6617
|
|
|
6574
6618
|
.message.user {
|
|
6575
|
-
margin-left:
|
|
6619
|
+
margin-left: 0;
|
|
6576
6620
|
}
|
|
6577
6621
|
|
|
6578
6622
|
.message.assistant {
|
|
6579
|
-
margin-right:
|
|
6623
|
+
margin-right: 0;
|
|
6580
6624
|
}
|
|
6581
6625
|
|
|
6582
6626
|
.avatar {
|
|
@@ -6592,7 +6636,7 @@ exports.AIChat.styles = lit.css`
|
|
|
6592
6636
|
}
|
|
6593
6637
|
|
|
6594
6638
|
.message.user .message-content {
|
|
6595
|
-
max-width:
|
|
6639
|
+
max-width: 100%;
|
|
6596
6640
|
}
|
|
6597
6641
|
|
|
6598
6642
|
.empty-state {
|
|
@@ -6668,11 +6712,11 @@ exports.AIChat.styles = lit.css`
|
|
|
6668
6712
|
}
|
|
6669
6713
|
|
|
6670
6714
|
.message.user {
|
|
6671
|
-
margin-left:
|
|
6715
|
+
margin-left: 0;
|
|
6672
6716
|
}
|
|
6673
6717
|
|
|
6674
6718
|
.message.assistant {
|
|
6675
|
-
margin-right:
|
|
6719
|
+
margin-right: 0;
|
|
6676
6720
|
}
|
|
6677
6721
|
|
|
6678
6722
|
.avatar {
|
|
@@ -6688,7 +6732,7 @@ exports.AIChat.styles = lit.css`
|
|
|
6688
6732
|
}
|
|
6689
6733
|
|
|
6690
6734
|
.message.user .message-content {
|
|
6691
|
-
max-width:
|
|
6735
|
+
max-width: 100%;
|
|
6692
6736
|
}
|
|
6693
6737
|
|
|
6694
6738
|
.empty-state {
|
|
@@ -6767,6 +6811,30 @@ exports.AIChat.styles = lit.css`
|
|
|
6767
6811
|
color: #fff;
|
|
6768
6812
|
}
|
|
6769
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
|
+
|
|
6770
6838
|
.messages-area {
|
|
6771
6839
|
flex: 1;
|
|
6772
6840
|
overflow-y: auto;
|
|
@@ -6885,11 +6953,11 @@ exports.AIChat.styles = lit.css`
|
|
|
6885
6953
|
.message.user {
|
|
6886
6954
|
flex-direction: row-reverse;
|
|
6887
6955
|
justify-content: flex-end;
|
|
6888
|
-
margin-left:
|
|
6956
|
+
margin-left: 0;
|
|
6889
6957
|
}
|
|
6890
6958
|
|
|
6891
6959
|
.message.assistant {
|
|
6892
|
-
margin-right:
|
|
6960
|
+
margin-right: 0;
|
|
6893
6961
|
}
|
|
6894
6962
|
|
|
6895
6963
|
.avatar {
|
|
@@ -6919,37 +6987,46 @@ exports.AIChat.styles = lit.css`
|
|
|
6919
6987
|
}
|
|
6920
6988
|
|
|
6921
6989
|
.message-content {
|
|
6922
|
-
|
|
6990
|
+
width: fit-content;
|
|
6991
|
+
max-width: 100%;
|
|
6923
6992
|
border-radius: 1.25rem;
|
|
6924
|
-
line-height: 1.
|
|
6993
|
+
line-height: 1.65;
|
|
6925
6994
|
overflow-wrap: break-word;
|
|
6926
6995
|
word-wrap: break-word;
|
|
6927
6996
|
min-width: 0;
|
|
6928
6997
|
font-size: 1.2rem;
|
|
6998
|
+
padding: 0.875rem 1.125rem;
|
|
6999
|
+
letter-spacing: 0.01em;
|
|
6929
7000
|
}
|
|
6930
7001
|
|
|
6931
7002
|
.message.user .message-content {
|
|
6932
|
-
background: var(--user-message-bg, #
|
|
6933
|
-
color: #
|
|
7003
|
+
background: var(--user-message-bg, #0D47A1);
|
|
7004
|
+
color: #ffffff;
|
|
6934
7005
|
border-radius: 1.25rem 0.25rem 1.25rem 1.25rem;
|
|
6935
|
-
|
|
7006
|
+
box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
|
|
7007
|
+
max-width: 100%;
|
|
6936
7008
|
margin-left: auto;
|
|
6937
7009
|
}
|
|
6938
7010
|
|
|
6939
7011
|
.message.assistant .message-content {
|
|
6940
|
-
|
|
6941
|
-
|
|
7012
|
+
flex: 1;
|
|
7013
|
+
background: var(--bot-message-bg, #f0f2f5);
|
|
7014
|
+
color: #1a1a2e;
|
|
6942
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);
|
|
6943
7018
|
}
|
|
6944
7019
|
|
|
6945
7020
|
:host([theme="dark"]) .message.user .message-content {
|
|
6946
|
-
background: #
|
|
7021
|
+
background: #1a4fbd;
|
|
6947
7022
|
color: #fff;
|
|
7023
|
+
box-shadow: 0 2px 8px rgba(29, 78, 216, 0.4);
|
|
6948
7024
|
}
|
|
6949
7025
|
|
|
6950
7026
|
:host([theme="dark"]) .message.assistant .message-content {
|
|
6951
7027
|
background: #27272a;
|
|
6952
|
-
color: #
|
|
7028
|
+
color: #e4e4e7;
|
|
7029
|
+
border-color: rgba(255, 255, 255, 0.06);
|
|
6953
7030
|
}
|
|
6954
7031
|
|
|
6955
7032
|
.message-text {
|
|
@@ -7205,17 +7282,29 @@ exports.AIChat.styles = lit.css`
|
|
|
7205
7282
|
}
|
|
7206
7283
|
|
|
7207
7284
|
.spinner {
|
|
7285
|
+
display: flex;
|
|
7286
|
+
align-items: center;
|
|
7287
|
+
gap: 0.35rem;
|
|
7288
|
+
padding: 0.25rem 0;
|
|
7289
|
+
}
|
|
7290
|
+
|
|
7291
|
+
.spinner span {
|
|
7208
7292
|
display: inline-block;
|
|
7209
|
-
width:
|
|
7210
|
-
height:
|
|
7211
|
-
|
|
7212
|
-
border-top-color: #71717a;
|
|
7293
|
+
width: 0.55rem;
|
|
7294
|
+
height: 0.55rem;
|
|
7295
|
+
background-color: var(--primary-color, #3681D3);
|
|
7213
7296
|
border-radius: 50%;
|
|
7214
|
-
animation:
|
|
7297
|
+
animation: dot-pulse 1.4s ease-in-out infinite;
|
|
7298
|
+
opacity: 0.3;
|
|
7215
7299
|
}
|
|
7216
7300
|
|
|
7217
|
-
|
|
7218
|
-
|
|
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; }
|
|
7219
7308
|
}
|
|
7220
7309
|
|
|
7221
7310
|
.input-area {
|