@locdo.tech/botiq-chat-sdk 0.2.0 → 0.3.0
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/sdk/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./npm-
|
|
1
|
+
import { t as e } from "./npm-6G46H82M.js";
|
|
2
2
|
export { e as init };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/core/config.ts
|
|
2
|
-
var e = "
|
|
2
|
+
var e = "https://bot-q-backend.vercel.app", t = {
|
|
3
3
|
name: "BotIQ",
|
|
4
4
|
design: {
|
|
5
5
|
colors: {
|
|
@@ -26,7 +26,12 @@ var e = "http://localhost:3001", t = {
|
|
|
26
26
|
}, n = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/, r = new Set(["bottom-right", "bottom-left"]), i = new Set(["circle", "square"]), a = new Set([
|
|
27
27
|
"inter",
|
|
28
28
|
"plus-jakarta",
|
|
29
|
-
"poppins"
|
|
29
|
+
"poppins",
|
|
30
|
+
"nunito",
|
|
31
|
+
"dm-sans",
|
|
32
|
+
"raleway",
|
|
33
|
+
"lato",
|
|
34
|
+
"playfair"
|
|
30
35
|
]);
|
|
31
36
|
function o(e) {
|
|
32
37
|
let t = e.colors;
|
|
@@ -149,6 +154,26 @@ var S = {
|
|
|
149
154
|
poppins: {
|
|
150
155
|
url: "https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap",
|
|
151
156
|
family: "'Poppins', system-ui, -apple-system, sans-serif"
|
|
157
|
+
},
|
|
158
|
+
nunito: {
|
|
159
|
+
url: "https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600&display=swap",
|
|
160
|
+
family: "'Nunito', system-ui, -apple-system, sans-serif"
|
|
161
|
+
},
|
|
162
|
+
"dm-sans": {
|
|
163
|
+
url: "https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap",
|
|
164
|
+
family: "'DM Sans', system-ui, -apple-system, sans-serif"
|
|
165
|
+
},
|
|
166
|
+
raleway: {
|
|
167
|
+
url: "https://fonts.googleapis.com/css2?family=Raleway:wght@400;500;600&display=swap",
|
|
168
|
+
family: "'Raleway', system-ui, -apple-system, sans-serif"
|
|
169
|
+
},
|
|
170
|
+
lato: {
|
|
171
|
+
url: "https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap",
|
|
172
|
+
family: "'Lato', system-ui, -apple-system, sans-serif"
|
|
173
|
+
},
|
|
174
|
+
playfair: {
|
|
175
|
+
url: "https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600&display=swap",
|
|
176
|
+
family: "'Playfair Display', Georgia, serif"
|
|
152
177
|
}
|
|
153
178
|
};
|
|
154
179
|
function C(e) {
|
|
@@ -250,6 +275,7 @@ function C(e) {
|
|
|
250
275
|
align-items: center;
|
|
251
276
|
justify-content: center;
|
|
252
277
|
flex-shrink: 0;
|
|
278
|
+
overflow: hidden;
|
|
253
279
|
}
|
|
254
280
|
|
|
255
281
|
.avatar svg { width: 20px; height: 20px; fill: #fff; }
|
|
@@ -471,9 +497,12 @@ function C(e) {
|
|
|
471
497
|
//#region src/core/ui.ts
|
|
472
498
|
var w = "https://bot-q-frontend.vercel.app/", T = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 2H4a2 2 0 00-2 2v18l4-4h14a2 2 0 002-2V4a2 2 0 00-2-2z\"/>\n</svg>", E = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"/>\n</svg>", D = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 2a2 2 0 012 2c0 .74-.4 1.38-1 1.72V7h3a3 3 0 013 3v8a3 3 0 01-3 3H8a3 3 0 01-3-3v-8a3 3 0 013-3h3V5.72A2 2 0 0110 4a2 2 0 012-2zm-2 9a1.5 1.5 0 100 3 1.5 1.5 0 000-3zm4 0a1.5 1.5 0 100 3 1.5 1.5 0 000-3z\"/>\n</svg>", O = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\"/>\n</svg>", k = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 2H4a2 2 0 00-2 2v18l4-4h14a2 2 0 002-2V4a2 2 0 00-2-2zm-2 10H6v-2h12v2zm0-3H6V7h12v2z\"/>\n</svg>";
|
|
473
499
|
function A(e) {
|
|
500
|
+
return !e || e.type === "icon" ? D : e.type === "emoji" ? `<span style="font-size:22px;line-height:1;display:flex;align-items:center;justify-content:center;width:100%;height:100%">${j(e.value)}</span>` : e.type === "initials" ? `<div style="width:100%;height:100%;border-radius:50%;background:${e.bgColor ?? "#F97316"};display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:700;color:#fff">${j(e.value.slice(0, 2).toUpperCase())}</div>` : e.type === "image" ? `<img src="${j(e.value)}" style="width:100%;height:100%;object-fit:cover;border-radius:50%" alt="" />` : D;
|
|
501
|
+
}
|
|
502
|
+
function j(e) {
|
|
474
503
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
475
504
|
}
|
|
476
|
-
function
|
|
505
|
+
function M(e, t, n, r) {
|
|
477
506
|
let { name: i, design: a } = t, o, s, c, l, u, d, { content: f } = a;
|
|
478
507
|
function p(e) {
|
|
479
508
|
e.setAttribute("data-position", a.layout.position), o = e.attachShadow({ mode: "open" });
|
|
@@ -483,9 +512,9 @@ function j(e, t, n, r) {
|
|
|
483
512
|
<span class="icon-close">${E}</span>
|
|
484
513
|
`, s.addEventListener("click", r), o.appendChild(s), c = document.createElement("div"), c.className = "chat-window", c.setAttribute("role", "dialog"), c.setAttribute("aria-label", `${i} chat`), c.innerHTML = `
|
|
485
514
|
<div class="chat-header">
|
|
486
|
-
<div class="avatar">${
|
|
515
|
+
<div class="avatar">${A(a.avatar)}</div>
|
|
487
516
|
<div class="header-text">
|
|
488
|
-
<span class="bot-name">${
|
|
517
|
+
<span class="bot-name">${j(i)}</span>
|
|
489
518
|
<span class="bot-status">Trực tuyến</span>
|
|
490
519
|
</div>
|
|
491
520
|
<button class="close-btn" aria-label="Close chat">×</button>
|
|
@@ -495,7 +524,7 @@ function j(e, t, n, r) {
|
|
|
495
524
|
<div class="input-row">
|
|
496
525
|
<textarea
|
|
497
526
|
class="input"
|
|
498
|
-
placeholder="${
|
|
527
|
+
placeholder="${j(f.placeholder)}"
|
|
499
528
|
rows="1"
|
|
500
529
|
maxlength="2000"
|
|
501
530
|
aria-label="Message input"
|
|
@@ -520,11 +549,11 @@ function j(e, t, n, r) {
|
|
|
520
549
|
}
|
|
521
550
|
function h(e) {
|
|
522
551
|
if (e.messages.length === 0 && !e.isLoading) {
|
|
523
|
-
let e = f.suggestionChips.length > 0 ? `<div class="chips">${f.suggestionChips.map((e) => `<button class="chip">${
|
|
552
|
+
let e = f.suggestionChips.length > 0 ? `<div class="chips">${f.suggestionChips.map((e) => `<button class="chip">${j(e)}</button>`).join("")}</div>` : "";
|
|
524
553
|
l.innerHTML = `
|
|
525
554
|
<div class="empty-state">
|
|
526
555
|
${k}
|
|
527
|
-
<span class="greeting">${
|
|
556
|
+
<span class="greeting">${j(f.greeting)}</span>
|
|
528
557
|
${e}
|
|
529
558
|
</div>
|
|
530
559
|
`, l.querySelectorAll(".chip").forEach((e) => {
|
|
@@ -534,7 +563,7 @@ function j(e, t, n, r) {
|
|
|
534
563
|
}
|
|
535
564
|
let t = e.messages.map((e) => `
|
|
536
565
|
<div class="message ${e.role}">
|
|
537
|
-
<div class="message-bubble">${
|
|
566
|
+
<div class="message-bubble">${j(e.content)}</div>
|
|
538
567
|
</div>
|
|
539
568
|
`).join(""), r = e.isLoading ? "<div class=\"typing\"><span></span><span></span><span></span></div>" : "";
|
|
540
569
|
l.innerHTML = t + r, l.scrollTop = l.scrollHeight;
|
|
@@ -549,7 +578,7 @@ function j(e, t, n, r) {
|
|
|
549
578
|
}
|
|
550
579
|
//#endregion
|
|
551
580
|
//#region src/builds/npm/index.ts
|
|
552
|
-
function
|
|
581
|
+
function N(e) {
|
|
553
582
|
if (!e.apiKey) return console.warn("[BotIQ] apiKey is required"), () => void 0;
|
|
554
583
|
let t = c(e), n = f();
|
|
555
584
|
b({ messages: p(n) });
|
|
@@ -558,7 +587,7 @@ function M(e) {
|
|
|
558
587
|
let i = () => void 0, a = !1;
|
|
559
588
|
s(t.apiKey, t.apiUrl).then((e) => {
|
|
560
589
|
if (a) return;
|
|
561
|
-
let n =
|
|
590
|
+
let n = M(t, e, o, l);
|
|
562
591
|
n.mount(r), i = x((e) => n.update(e)), n.update(y());
|
|
563
592
|
});
|
|
564
593
|
function o(e) {
|
|
@@ -592,4 +621,4 @@ function M(e) {
|
|
|
592
621
|
};
|
|
593
622
|
}
|
|
594
623
|
//#endregion
|
|
595
|
-
export {
|
|
624
|
+
export { N as t };
|
package/dist/sdk/react.js
CHANGED
package/dist/sdk/vue.js
CHANGED