@a.izzuddin/ai-chat 0.2.24 → 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 -74
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -74
- package/dist/index.mjs.map +1 -1
- package/global.d.ts +24 -24
- package/package.json +88 -88
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 = "#
|
|
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"
|
|
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"
|
|
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
|
-
|
|
6330
|
-
<
|
|
6331
|
-
|
|
6332
|
-
|
|
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":
|
|
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.
|
|
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:
|
|
6418
|
-
height:
|
|
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:
|
|
6455
|
-
height:
|
|
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:
|
|
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:
|
|
6554
|
+
bottom: 0;
|
|
6511
6555
|
right: 0;
|
|
6512
6556
|
}
|
|
6513
6557
|
|
|
6514
6558
|
.widget-button {
|
|
6515
|
-
width:
|
|
6516
|
-
height:
|
|
6559
|
+
width: 68px;
|
|
6560
|
+
height: 68px;
|
|
6517
6561
|
}
|
|
6518
6562
|
|
|
6519
6563
|
.widget-button svg {
|
|
6520
|
-
width:
|
|
6521
|
-
height:
|
|
6564
|
+
width: 28px;
|
|
6565
|
+
height: 28px;
|
|
6522
6566
|
}
|
|
6523
6567
|
}
|
|
6524
6568
|
|
|
@@ -6527,33 +6571,18 @@ AIChat.styles = css`
|
|
|
6527
6571
|
.widget-window {
|
|
6528
6572
|
width: var(--widget-width, 500px);
|
|
6529
6573
|
height: calc(100vh - 100px);
|
|
6530
|
-
bottom:
|
|
6574
|
+
bottom: 0;
|
|
6531
6575
|
right: 0;
|
|
6532
6576
|
}
|
|
6533
6577
|
|
|
6534
6578
|
.widget-button {
|
|
6535
|
-
width:
|
|
6536
|
-
height:
|
|
6579
|
+
width: 68px;
|
|
6580
|
+
height: 68px;
|
|
6537
6581
|
}
|
|
6538
6582
|
|
|
6539
6583
|
.widget-button svg {
|
|
6540
|
-
width:
|
|
6541
|
-
height:
|
|
6542
|
-
}
|
|
6543
|
-
}
|
|
6544
|
-
|
|
6545
|
-
/* Desktop responsive styles - reduce excessive margins on large screens */
|
|
6546
|
-
@media (min-width: 1025px) {
|
|
6547
|
-
.message.user {
|
|
6548
|
-
margin-left: 2rem;
|
|
6549
|
-
}
|
|
6550
|
-
|
|
6551
|
-
.message.assistant {
|
|
6552
|
-
margin-right: 1.5rem;
|
|
6553
|
-
}
|
|
6554
|
-
|
|
6555
|
-
.contact-support-wrapper {
|
|
6556
|
-
margin-left: 1.5rem;
|
|
6584
|
+
width: 28px;
|
|
6585
|
+
height: 28px;
|
|
6557
6586
|
}
|
|
6558
6587
|
}
|
|
6559
6588
|
|
|
@@ -6585,11 +6614,11 @@ AIChat.styles = css`
|
|
|
6585
6614
|
}
|
|
6586
6615
|
|
|
6587
6616
|
.message.user {
|
|
6588
|
-
margin-left:
|
|
6617
|
+
margin-left: 0;
|
|
6589
6618
|
}
|
|
6590
6619
|
|
|
6591
6620
|
.message.assistant {
|
|
6592
|
-
margin-right:
|
|
6621
|
+
margin-right: 0;
|
|
6593
6622
|
}
|
|
6594
6623
|
|
|
6595
6624
|
.avatar {
|
|
@@ -6605,7 +6634,7 @@ AIChat.styles = css`
|
|
|
6605
6634
|
}
|
|
6606
6635
|
|
|
6607
6636
|
.message.user .message-content {
|
|
6608
|
-
max-width:
|
|
6637
|
+
max-width: 100%;
|
|
6609
6638
|
}
|
|
6610
6639
|
|
|
6611
6640
|
.empty-state {
|
|
@@ -6681,11 +6710,11 @@ AIChat.styles = css`
|
|
|
6681
6710
|
}
|
|
6682
6711
|
|
|
6683
6712
|
.message.user {
|
|
6684
|
-
margin-left:
|
|
6713
|
+
margin-left: 0;
|
|
6685
6714
|
}
|
|
6686
6715
|
|
|
6687
6716
|
.message.assistant {
|
|
6688
|
-
margin-right:
|
|
6717
|
+
margin-right: 0;
|
|
6689
6718
|
}
|
|
6690
6719
|
|
|
6691
6720
|
.avatar {
|
|
@@ -6701,7 +6730,7 @@ AIChat.styles = css`
|
|
|
6701
6730
|
}
|
|
6702
6731
|
|
|
6703
6732
|
.message.user .message-content {
|
|
6704
|
-
max-width:
|
|
6733
|
+
max-width: 100%;
|
|
6705
6734
|
}
|
|
6706
6735
|
|
|
6707
6736
|
.empty-state {
|
|
@@ -6780,6 +6809,30 @@ AIChat.styles = css`
|
|
|
6780
6809
|
color: #fff;
|
|
6781
6810
|
}
|
|
6782
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
|
+
|
|
6783
6836
|
.messages-area {
|
|
6784
6837
|
flex: 1;
|
|
6785
6838
|
overflow-y: auto;
|
|
@@ -6898,11 +6951,11 @@ AIChat.styles = css`
|
|
|
6898
6951
|
.message.user {
|
|
6899
6952
|
flex-direction: row-reverse;
|
|
6900
6953
|
justify-content: flex-end;
|
|
6901
|
-
margin-left:
|
|
6954
|
+
margin-left: 0;
|
|
6902
6955
|
}
|
|
6903
6956
|
|
|
6904
6957
|
.message.assistant {
|
|
6905
|
-
margin-right:
|
|
6958
|
+
margin-right: 0;
|
|
6906
6959
|
}
|
|
6907
6960
|
|
|
6908
6961
|
.avatar {
|
|
@@ -6932,38 +6985,46 @@ AIChat.styles = css`
|
|
|
6932
6985
|
}
|
|
6933
6986
|
|
|
6934
6987
|
.message-content {
|
|
6935
|
-
|
|
6988
|
+
width: fit-content;
|
|
6989
|
+
max-width: 100%;
|
|
6936
6990
|
border-radius: 1.25rem;
|
|
6937
|
-
line-height: 1.
|
|
6991
|
+
line-height: 1.65;
|
|
6938
6992
|
overflow-wrap: break-word;
|
|
6939
6993
|
word-wrap: break-word;
|
|
6940
6994
|
min-width: 0;
|
|
6941
6995
|
font-size: 1.2rem;
|
|
6942
|
-
padding:
|
|
6996
|
+
padding: 0.875rem 1.125rem;
|
|
6997
|
+
letter-spacing: 0.01em;
|
|
6943
6998
|
}
|
|
6944
6999
|
|
|
6945
7000
|
.message.user .message-content {
|
|
6946
|
-
background: var(--user-message-bg, #
|
|
6947
|
-
color: #
|
|
7001
|
+
background: var(--user-message-bg, #0D47A1);
|
|
7002
|
+
color: #ffffff;
|
|
6948
7003
|
border-radius: 1.25rem 0.25rem 1.25rem 1.25rem;
|
|
6949
|
-
|
|
7004
|
+
box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
|
|
7005
|
+
max-width: 100%;
|
|
6950
7006
|
margin-left: auto;
|
|
6951
7007
|
}
|
|
6952
7008
|
|
|
6953
7009
|
.message.assistant .message-content {
|
|
6954
|
-
|
|
6955
|
-
|
|
7010
|
+
flex: 1;
|
|
7011
|
+
background: var(--bot-message-bg, #f0f2f5);
|
|
7012
|
+
color: #1a1a2e;
|
|
6956
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);
|
|
6957
7016
|
}
|
|
6958
7017
|
|
|
6959
7018
|
:host([theme="dark"]) .message.user .message-content {
|
|
6960
|
-
background: #
|
|
7019
|
+
background: #1a4fbd;
|
|
6961
7020
|
color: #fff;
|
|
7021
|
+
box-shadow: 0 2px 8px rgba(29, 78, 216, 0.4);
|
|
6962
7022
|
}
|
|
6963
7023
|
|
|
6964
7024
|
:host([theme="dark"]) .message.assistant .message-content {
|
|
6965
7025
|
background: #27272a;
|
|
6966
|
-
color: #
|
|
7026
|
+
color: #e4e4e7;
|
|
7027
|
+
border-color: rgba(255, 255, 255, 0.06);
|
|
6967
7028
|
}
|
|
6968
7029
|
|
|
6969
7030
|
.message-text {
|
|
@@ -7219,17 +7280,29 @@ AIChat.styles = css`
|
|
|
7219
7280
|
}
|
|
7220
7281
|
|
|
7221
7282
|
.spinner {
|
|
7283
|
+
display: flex;
|
|
7284
|
+
align-items: center;
|
|
7285
|
+
gap: 0.35rem;
|
|
7286
|
+
padding: 0.25rem 0;
|
|
7287
|
+
}
|
|
7288
|
+
|
|
7289
|
+
.spinner span {
|
|
7222
7290
|
display: inline-block;
|
|
7223
|
-
width:
|
|
7224
|
-
height:
|
|
7225
|
-
|
|
7226
|
-
border-top-color: #71717a;
|
|
7291
|
+
width: 0.55rem;
|
|
7292
|
+
height: 0.55rem;
|
|
7293
|
+
background-color: var(--primary-color, #3681D3);
|
|
7227
7294
|
border-radius: 50%;
|
|
7228
|
-
animation:
|
|
7295
|
+
animation: dot-pulse 1.4s ease-in-out infinite;
|
|
7296
|
+
opacity: 0.3;
|
|
7229
7297
|
}
|
|
7230
7298
|
|
|
7231
|
-
|
|
7232
|
-
|
|
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; }
|
|
7233
7306
|
}
|
|
7234
7307
|
|
|
7235
7308
|
.input-area {
|