chatbotlite 0.5.1 → 0.6.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/embed.global.js +74 -22
- package/dist/embed.global.js.map +1 -1
- package/dist/react/index.cjs +316 -194
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +15 -0
- package/dist/react/index.d.ts +15 -0
- package/dist/react/index.js +316 -194
- package/dist/react/index.js.map +1 -1
- package/package.json +11 -2
package/dist/react/index.cjs
CHANGED
|
@@ -5,6 +5,18 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
5
5
|
|
|
6
6
|
// src/react/ChatWidget.tsx
|
|
7
7
|
|
|
8
|
+
// src/react/color.ts
|
|
9
|
+
function luminance(hex) {
|
|
10
|
+
const m = hex.replace("#", "");
|
|
11
|
+
const norm = m.length === 3 ? m.split("").map((c) => c + c).join("") : m;
|
|
12
|
+
if (norm.length !== 6 || !/^[0-9a-fA-F]{6}$/.test(norm)) return 0;
|
|
13
|
+
const r = parseInt(norm.slice(0, 2), 16) / 255;
|
|
14
|
+
const g = parseInt(norm.slice(2, 4), 16) / 255;
|
|
15
|
+
const b = parseInt(norm.slice(4, 6), 16) / 255;
|
|
16
|
+
const toLinear = (c) => c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
17
|
+
return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);
|
|
18
|
+
}
|
|
19
|
+
|
|
8
20
|
// src/core/tools.ts
|
|
9
21
|
var MARKER_RE = /\[SKILL:(\w+)((?:\s+\w+=(?:"[^"]*"|[\w./@*+,:-]+))*)\s*\]/g;
|
|
10
22
|
var ARG_RE = /(\w+)=("([^"]*)"|([\w./@*+,:-]+))/g;
|
|
@@ -1011,26 +1023,82 @@ function RequestPayment(props) {
|
|
|
1011
1023
|
] })
|
|
1012
1024
|
] });
|
|
1013
1025
|
}
|
|
1014
|
-
var BOLT = "\u26A1";
|
|
1015
1026
|
var DEFAULT_PRIMARY = "#0f172a";
|
|
1016
1027
|
var DEFAULT_ON_PRIMARY = "#ffffff";
|
|
1017
|
-
var
|
|
1018
|
-
var
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
var
|
|
1023
|
-
var
|
|
1024
|
-
var
|
|
1025
|
-
var
|
|
1026
|
-
var
|
|
1028
|
+
var IconPaperclip = ({ size = 18 }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.75, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" }) });
|
|
1029
|
+
var IconMic = ({ size = 16 }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.75, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1030
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "3", width: "6", height: "12", rx: "3" }),
|
|
1031
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 11a7 7 0 0 0 14 0M12 19v3" })
|
|
1032
|
+
] });
|
|
1033
|
+
var IconBolt = ({ size = 11 }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", style: { verticalAlign: "-1px" }, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M13 2L4 14h7l-1 8 9-12h-7l1-8z" }) });
|
|
1034
|
+
var SURFACE = "var(--cbl-bg)";
|
|
1035
|
+
var CHAT_BG = "var(--cbl-bg-chat)";
|
|
1036
|
+
var BUBBLE_BOT = "var(--cbl-bg-elevated)";
|
|
1037
|
+
var INPUT_BG = "var(--cbl-bg-sunken)";
|
|
1038
|
+
var BORDER = "var(--cbl-border)";
|
|
1039
|
+
var BORDER_LIGHT = "var(--cbl-border-light)";
|
|
1040
|
+
var TEXT_BODY = "var(--cbl-text)";
|
|
1041
|
+
var TEXT_MUTED = "var(--cbl-text-muted)";
|
|
1042
|
+
var TEXT_FAINT = "var(--cbl-text-faint)";
|
|
1043
|
+
var FONT_STACK = "var(--cbl-font)";
|
|
1027
1044
|
var STYLE_TAG_ID = "chatbotlite-widget-styles";
|
|
1045
|
+
var TOKENS = `
|
|
1046
|
+
:where(.chatbotlite-root) {
|
|
1047
|
+
--cbl-bg: #FFFFFF;
|
|
1048
|
+
--cbl-bg-elevated: #FFFFFF;
|
|
1049
|
+
--cbl-bg-chat: #F7F8FA;
|
|
1050
|
+
--cbl-bg-sunken: #F1F3F5;
|
|
1051
|
+
--cbl-border: #E5E7EB;
|
|
1052
|
+
--cbl-border-strong: #D1D5DB;
|
|
1053
|
+
--cbl-border-light: rgba(15,23,42,0.06);
|
|
1054
|
+
--cbl-text: #0F172A;
|
|
1055
|
+
--cbl-text-muted: #64748B;
|
|
1056
|
+
--cbl-text-faint: #94A3B8;
|
|
1057
|
+
--cbl-success: #10B981;
|
|
1058
|
+
--cbl-danger: #EF4444;
|
|
1059
|
+
--cbl-font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", system-ui, sans-serif;
|
|
1060
|
+
--cbl-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
|
|
1061
|
+
--cbl-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
|
|
1062
|
+
--cbl-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
1063
|
+
--cbl-shadow-1: 0 1px 2px rgba(15,23,42,0.04);
|
|
1064
|
+
--cbl-shadow-2: 0 4px 12px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
|
|
1065
|
+
--cbl-shadow-3: 0 10px 32px rgba(15,23,42,0.10), 0 2px 6px rgba(15,23,42,0.04);
|
|
1066
|
+
--cbl-shadow-4: 0 20px 48px rgba(15,23,42,0.18), 0 4px 12px rgba(15,23,42,0.08);
|
|
1067
|
+
}
|
|
1068
|
+
@media (prefers-color-scheme: dark) {
|
|
1069
|
+
:where(.chatbotlite-root[data-color-scheme="auto"]),
|
|
1070
|
+
:where(.chatbotlite-root[data-color-scheme="dark"]) {
|
|
1071
|
+
--cbl-bg: #16181D;
|
|
1072
|
+
--cbl-bg-elevated: #1F2228;
|
|
1073
|
+
--cbl-bg-chat: #0B0D10;
|
|
1074
|
+
--cbl-bg-sunken: #1F2228;
|
|
1075
|
+
--cbl-border: #24272E;
|
|
1076
|
+
--cbl-border-strong: #2E323A;
|
|
1077
|
+
--cbl-border-light: rgba(255,255,255,0.06);
|
|
1078
|
+
--cbl-text: #ECEDEE;
|
|
1079
|
+
--cbl-text-muted: #9BA1A6;
|
|
1080
|
+
--cbl-text-faint: #6B7177;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
:where(.chatbotlite-root[data-color-scheme="light"]) {
|
|
1084
|
+
--cbl-bg: #FFFFFF;
|
|
1085
|
+
--cbl-bg-elevated: #FFFFFF;
|
|
1086
|
+
--cbl-bg-chat: #F7F8FA;
|
|
1087
|
+
--cbl-bg-sunken: #F1F3F5;
|
|
1088
|
+
--cbl-border: #E5E7EB;
|
|
1089
|
+
--cbl-border-strong: #D1D5DB;
|
|
1090
|
+
--cbl-border-light: rgba(15,23,42,0.06);
|
|
1091
|
+
--cbl-text: #0F172A;
|
|
1092
|
+
--cbl-text-muted: #64748B;
|
|
1093
|
+
--cbl-text-faint: #94A3B8;
|
|
1094
|
+
}
|
|
1095
|
+
`;
|
|
1028
1096
|
var KEYFRAMES = `
|
|
1029
1097
|
@keyframes chatbotlite-pop { 0% { opacity: 0; transform: scale(0.6); } 100% { opacity: 1; transform: scale(1); } }
|
|
1030
1098
|
@keyframes chatbotlite-slide { 0% { opacity: 0; transform: translateY(16px) scale(0.98); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
|
|
1031
1099
|
@keyframes chatbotlite-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
|
|
1032
1100
|
@keyframes chatbotlite-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }
|
|
1033
|
-
@keyframes chatbotlite-cursor { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }
|
|
1101
|
+
@keyframes chatbotlite-cursor { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0.2; } }
|
|
1034
1102
|
@keyframes chatbotlite-pulse { 0%, 100% { box-shadow: 0 12px 28px -8px rgba(15,23,42,0.32), 0 4px 8px -2px rgba(15,23,42,0.12); } 50% { box-shadow: 0 14px 32px -8px rgba(15,23,42,0.36), 0 6px 12px -2px rgba(15,23,42,0.16); } }
|
|
1035
1103
|
.chatbotlite-launcher { transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 180ms cubic-bezier(0.4, 0, 0.2, 1); animation: chatbotlite-pop 320ms cubic-bezier(0.34, 1.56, 0.64, 1), chatbotlite-pulse 3.6s ease-in-out 1.2s 2; }
|
|
1036
1104
|
.chatbotlite-launcher:hover { transform: translateY(-2px) scale(1.04); }
|
|
@@ -1040,10 +1108,12 @@ var KEYFRAMES = `
|
|
|
1040
1108
|
.chatbotlite-send { transition: transform 120ms ease, opacity 120ms ease, box-shadow 120ms ease; }
|
|
1041
1109
|
.chatbotlite-send:not(:disabled):hover { transform: translateY(-1px); }
|
|
1042
1110
|
.chatbotlite-send:not(:disabled):active { transform: translateY(0); }
|
|
1043
|
-
.chatbotlite-input:focus { box-shadow:
|
|
1111
|
+
.chatbotlite-input:focus { box-shadow: none; outline: none; }
|
|
1112
|
+
.chatbotlite-composer { transition: background 120ms ease, box-shadow 120ms ease; }
|
|
1113
|
+
.chatbotlite-composer:focus-within { background: ${SURFACE}; box-shadow: 0 0 0 1px ${BORDER}, 0 1px 2px rgba(15,23,42,0.04); }
|
|
1044
1114
|
.chatbotlite-msg { animation: chatbotlite-fade-in 220ms cubic-bezier(0.4, 0, 0.2, 1); }
|
|
1045
1115
|
.chatbotlite-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: ${TEXT_FAINT}; margin-right: 4px; animation: chatbotlite-dot 1.2s ease-in-out infinite; }
|
|
1046
|
-
.chatbotlite-cursor { display: inline-block; width:
|
|
1116
|
+
.chatbotlite-cursor { display: inline-block; width: 0.5ch; vertical-align: text-bottom; margin-left: 1px; font-size: inherit; line-height: inherit; animation: chatbotlite-cursor 1s ease-in-out infinite; }
|
|
1047
1117
|
.chatbotlite-icon-btn:hover:not(:disabled) { background: rgba(15,23,42,0.06) !important; opacity: 1 !important; }
|
|
1048
1118
|
.chatbotlite-icon-btn:active:not(:disabled) { transform: scale(0.92); }
|
|
1049
1119
|
.chatbotlite-dot:nth-child(2) { animation-delay: 0.15s; }
|
|
@@ -1055,7 +1125,7 @@ function ensureStyles() {
|
|
|
1055
1125
|
if (document.getElementById(STYLE_TAG_ID)) return;
|
|
1056
1126
|
const style = document.createElement("style");
|
|
1057
1127
|
style.id = STYLE_TAG_ID;
|
|
1058
|
-
style.textContent = KEYFRAMES;
|
|
1128
|
+
style.textContent = TOKENS + KEYFRAMES;
|
|
1059
1129
|
document.head.appendChild(style);
|
|
1060
1130
|
}
|
|
1061
1131
|
function ChatWidget(props) {
|
|
@@ -1071,7 +1141,8 @@ function ChatWidget(props) {
|
|
|
1071
1141
|
const resolvedTitle = title ?? "Chat";
|
|
1072
1142
|
const resolvedGreeting = greeting ?? "Hi! How can we help?";
|
|
1073
1143
|
const primary = themeOverrides?.primary ?? DEFAULT_PRIMARY;
|
|
1074
|
-
const
|
|
1144
|
+
const primaryIsLight = luminance(primary) > 0.65;
|
|
1145
|
+
const onPrimary = themeOverrides?.onPrimary ?? (primaryIsLight ? "#0f172a" : DEFAULT_ON_PRIMARY);
|
|
1075
1146
|
const attachCfg = props.attach;
|
|
1076
1147
|
const attachEnabled = attachCfg?.enabled === true;
|
|
1077
1148
|
const acceptAttr = attachCfg?.accept?.join(",");
|
|
@@ -1207,7 +1278,12 @@ function ChatWidget(props) {
|
|
|
1207
1278
|
body = JSON.stringify({ message: text, transcript: history, enabledTools });
|
|
1208
1279
|
}
|
|
1209
1280
|
const res = await fetch(props.endpoint, { method: "POST", headers, body });
|
|
1210
|
-
if (!res.ok)
|
|
1281
|
+
if (!res.ok) {
|
|
1282
|
+
const raw = await res.text().catch(() => "");
|
|
1283
|
+
const looksLikeHtml = /^\s*<(!doctype|html|head|body)/i.test(raw);
|
|
1284
|
+
const snippet = looksLikeHtml ? "" : raw.slice(0, 120).replace(/\s+/g, " ").trim();
|
|
1285
|
+
throw new Error(`Server returned ${res.status}${snippet ? ` \u2014 ${snippet}` : ""}`);
|
|
1286
|
+
}
|
|
1211
1287
|
const contentType = res.headers.get("Content-Type") ?? "";
|
|
1212
1288
|
if (contentType.includes("text/event-stream") && res.body) {
|
|
1213
1289
|
const reader = res.body.getReader();
|
|
@@ -1309,10 +1385,13 @@ function ChatWidget(props) {
|
|
|
1309
1385
|
!open && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1310
1386
|
"button",
|
|
1311
1387
|
{
|
|
1312
|
-
className: "chatbotlite-launcher",
|
|
1388
|
+
className: "chatbotlite-root chatbotlite-launcher",
|
|
1389
|
+
"data-color-scheme": "auto",
|
|
1313
1390
|
onClick: () => setOpen(true),
|
|
1314
1391
|
"aria-label": "Open chat",
|
|
1315
1392
|
style: {
|
|
1393
|
+
["--cbl-primary"]: primary,
|
|
1394
|
+
["--cbl-on-primary"]: onPrimary,
|
|
1316
1395
|
position: "fixed",
|
|
1317
1396
|
bottom: 20,
|
|
1318
1397
|
...launcherPos,
|
|
@@ -1332,15 +1411,24 @@ function ChatWidget(props) {
|
|
|
1332
1411
|
alignItems: "center",
|
|
1333
1412
|
justifyContent: "center"
|
|
1334
1413
|
},
|
|
1335
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { filter: "drop-shadow(0 1px 2px rgba(0,0,0,0.2))" }, children:
|
|
1414
|
+
children: props.launcherIcon ? props.launcherIcon.startsWith("http") || props.launcherIcon.startsWith("/") ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: props.launcherIcon, alt: "", style: { width: 28, height: 28, objectFit: "contain" } }) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: { filter: "drop-shadow(0 1px 2px rgba(0,0,0,0.2))" }, children: props.launcherIcon }) : /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "26", height: "26", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1415
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21 12a8 8 0 0 1-13.6 5.8L3 19l1.2-4.4A8 8 0 1 1 21 12z" }),
|
|
1416
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "9", cy: "12", r: "1", fill: "currentColor", stroke: "none" }),
|
|
1417
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "1", fill: "currentColor", stroke: "none" }),
|
|
1418
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "15", cy: "12", r: "1", fill: "currentColor", stroke: "none" })
|
|
1419
|
+
] })
|
|
1336
1420
|
}
|
|
1337
1421
|
),
|
|
1338
1422
|
open && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1339
1423
|
"div",
|
|
1340
1424
|
{
|
|
1425
|
+
className: "chatbotlite-root",
|
|
1426
|
+
"data-color-scheme": "auto",
|
|
1341
1427
|
role: "dialog",
|
|
1342
1428
|
"aria-label": "Chat",
|
|
1343
1429
|
style: {
|
|
1430
|
+
["--cbl-primary"]: primary,
|
|
1431
|
+
["--cbl-on-primary"]: onPrimary,
|
|
1344
1432
|
position: "fixed",
|
|
1345
1433
|
bottom: 20,
|
|
1346
1434
|
...panelPos,
|
|
@@ -1370,24 +1458,39 @@ function ChatWidget(props) {
|
|
|
1370
1458
|
gap: 12,
|
|
1371
1459
|
borderBottom: `1px solid ${BORDER_LIGHT}`
|
|
1372
1460
|
}, children: [
|
|
1373
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 10, minWidth: 0 }, children: [
|
|
1374
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1375
|
-
width:
|
|
1376
|
-
height:
|
|
1461
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: props.avatar ? 10 : 0, minWidth: 0 }, children: [
|
|
1462
|
+
props.avatar === true && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1463
|
+
width: 32,
|
|
1464
|
+
height: 32,
|
|
1377
1465
|
borderRadius: "50%",
|
|
1378
1466
|
background: primary,
|
|
1379
1467
|
color: onPrimary,
|
|
1380
1468
|
display: "flex",
|
|
1381
1469
|
alignItems: "center",
|
|
1382
1470
|
justifyContent: "center",
|
|
1383
|
-
fontSize:
|
|
1471
|
+
fontSize: 14,
|
|
1384
1472
|
fontWeight: 600,
|
|
1385
1473
|
flexShrink: 0,
|
|
1386
1474
|
letterSpacing: "-0.02em"
|
|
1387
1475
|
}, children: resolvedTitle.charAt(0).toUpperCase() }),
|
|
1476
|
+
typeof props.avatar === "string" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1477
|
+
"img",
|
|
1478
|
+
{
|
|
1479
|
+
src: props.avatar,
|
|
1480
|
+
alt: "",
|
|
1481
|
+
style: {
|
|
1482
|
+
width: 32,
|
|
1483
|
+
height: 32,
|
|
1484
|
+
borderRadius: "50%",
|
|
1485
|
+
objectFit: "cover",
|
|
1486
|
+
flexShrink: 0,
|
|
1487
|
+
border: `1px solid ${BORDER}`
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
),
|
|
1388
1491
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", lineHeight: 1.2, minWidth: 0 }, children: [
|
|
1389
1492
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 600, fontSize: 15, letterSpacing: "-0.01em", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", color: TEXT_BODY }, children: resolvedTitle }),
|
|
1390
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: TEXT_MUTED, marginTop: 2, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: subtitle ?? (sending ? "typing\u2026" : "
|
|
1493
|
+
(subtitle || sending) && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: TEXT_MUTED, marginTop: 2, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: subtitle ?? (sending ? "typing\u2026" : "") })
|
|
1391
1494
|
] })
|
|
1392
1495
|
] }),
|
|
1393
1496
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1436,22 +1539,30 @@ function ChatWidget(props) {
|
|
|
1436
1539
|
className: "chatbotlite-msg",
|
|
1437
1540
|
style: {
|
|
1438
1541
|
alignSelf: m.role === "user" ? "flex-end" : "flex-start",
|
|
1439
|
-
maxWidth: "
|
|
1440
|
-
padding: "
|
|
1441
|
-
borderRadius:
|
|
1542
|
+
maxWidth: "82%",
|
|
1543
|
+
padding: "9px 13px",
|
|
1544
|
+
borderRadius: m.role === "user" ? "18px 18px 4px 18px" : "18px 18px 18px 4px",
|
|
1442
1545
|
background: m.role === "user" ? primary : BUBBLE_BOT,
|
|
1443
1546
|
color: m.role === "user" ? onPrimary : TEXT_BODY,
|
|
1444
|
-
border: "none"
|
|
1445
|
-
fontSize: 14
|
|
1446
|
-
lineHeight: 1.
|
|
1547
|
+
border: m.role === "user" ? "none" : `1px solid ${BORDER}`,
|
|
1548
|
+
fontSize: 14,
|
|
1549
|
+
lineHeight: 1.5,
|
|
1447
1550
|
letterSpacing: "-0.005em",
|
|
1448
1551
|
whiteSpace: "pre-wrap",
|
|
1449
1552
|
wordBreak: "break-word",
|
|
1450
|
-
boxShadow: m.role === "user" ? "
|
|
1553
|
+
boxShadow: m.role === "user" ? "0 1px 2px rgba(15,23,42,0.12)" : "0 1px 2px rgba(15,23,42,0.04)"
|
|
1451
1554
|
},
|
|
1452
1555
|
children: [
|
|
1453
1556
|
m.content,
|
|
1454
|
-
sending && m.role === "assistant" && m === messages[messages.length - 1] && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1557
|
+
sending && m.role === "assistant" && m === messages[messages.length - 1] && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1558
|
+
"span",
|
|
1559
|
+
{
|
|
1560
|
+
className: "chatbotlite-cursor",
|
|
1561
|
+
style: { color: primary },
|
|
1562
|
+
"aria-hidden": "true",
|
|
1563
|
+
children: "\u258D"
|
|
1564
|
+
}
|
|
1565
|
+
)
|
|
1455
1566
|
]
|
|
1456
1567
|
}
|
|
1457
1568
|
),
|
|
@@ -1551,10 +1662,11 @@ function ChatWidget(props) {
|
|
|
1551
1662
|
className: "chatbotlite-msg",
|
|
1552
1663
|
style: {
|
|
1553
1664
|
alignSelf: "flex-start",
|
|
1554
|
-
padding: "
|
|
1555
|
-
borderRadius:
|
|
1665
|
+
padding: "12px 14px",
|
|
1666
|
+
borderRadius: "18px 18px 18px 4px",
|
|
1556
1667
|
background: BUBBLE_BOT,
|
|
1557
|
-
|
|
1668
|
+
border: `1px solid ${BORDER}`,
|
|
1669
|
+
boxShadow: "0 1px 2px rgba(15,23,42,0.04)"
|
|
1558
1670
|
},
|
|
1559
1671
|
children: [
|
|
1560
1672
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "chatbotlite-dot" }),
|
|
@@ -1587,9 +1699,9 @@ function ChatWidget(props) {
|
|
|
1587
1699
|
maxWidth: 200
|
|
1588
1700
|
},
|
|
1589
1701
|
children: [
|
|
1590
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
|
|
1591
|
-
|
|
1592
|
-
f.name
|
|
1702
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", color: TEXT_MUTED }, children: [
|
|
1703
|
+
/* @__PURE__ */ jsxRuntime.jsx(IconPaperclip, { size: 12 }),
|
|
1704
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", color: TEXT_BODY }, children: f.name })
|
|
1593
1705
|
] }),
|
|
1594
1706
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1595
1707
|
"button",
|
|
@@ -1607,159 +1719,169 @@ function ChatWidget(props) {
|
|
|
1607
1719
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1608
1720
|
padding: "10px 12px 12px",
|
|
1609
1721
|
background: SURFACE
|
|
1610
|
-
}, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1722
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1723
|
+
"div",
|
|
1724
|
+
{
|
|
1725
|
+
className: "chatbotlite-composer",
|
|
1726
|
+
style: {
|
|
1727
|
+
display: "flex",
|
|
1728
|
+
alignItems: "center",
|
|
1729
|
+
gap: 4,
|
|
1730
|
+
padding: "4px 4px 4px 8px",
|
|
1731
|
+
background: INPUT_BG,
|
|
1732
|
+
borderRadius: 999
|
|
1733
|
+
},
|
|
1734
|
+
children: [
|
|
1735
|
+
attachEnabled && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1736
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1737
|
+
"input",
|
|
1738
|
+
{
|
|
1739
|
+
ref: fileInputRef,
|
|
1740
|
+
type: "file",
|
|
1741
|
+
multiple: true,
|
|
1742
|
+
accept: acceptAttr,
|
|
1743
|
+
style: { display: "none" },
|
|
1744
|
+
onChange: (e) => {
|
|
1745
|
+
if (e.target.files) addFiles(e.target.files);
|
|
1746
|
+
e.target.value = "";
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
),
|
|
1750
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1751
|
+
"button",
|
|
1752
|
+
{
|
|
1753
|
+
className: "chatbotlite-icon-btn",
|
|
1754
|
+
onClick: () => fileInputRef.current?.click(),
|
|
1755
|
+
disabled: sending || files.length >= maxFiles,
|
|
1756
|
+
"aria-label": "Attach file",
|
|
1757
|
+
style: {
|
|
1758
|
+
width: 32,
|
|
1759
|
+
height: 32,
|
|
1760
|
+
borderRadius: "50%",
|
|
1761
|
+
background: "transparent",
|
|
1762
|
+
border: "none",
|
|
1763
|
+
cursor: sending || files.length >= maxFiles ? "default" : "pointer",
|
|
1764
|
+
opacity: sending || files.length >= maxFiles ? 0.35 : 0.75,
|
|
1765
|
+
color: TEXT_MUTED,
|
|
1766
|
+
lineHeight: 1,
|
|
1767
|
+
padding: 0,
|
|
1768
|
+
display: "flex",
|
|
1769
|
+
alignItems: "center",
|
|
1770
|
+
justifyContent: "center",
|
|
1771
|
+
flexShrink: 0,
|
|
1772
|
+
alignSelf: "center",
|
|
1773
|
+
transition: "opacity 120ms ease, background 120ms ease"
|
|
1774
|
+
},
|
|
1775
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(IconPaperclip, { size: 18 })
|
|
1776
|
+
}
|
|
1777
|
+
)
|
|
1778
|
+
] }),
|
|
1779
|
+
voiceEnabled && speechSupported && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1780
|
+
"button",
|
|
1781
|
+
{
|
|
1782
|
+
className: "chatbotlite-icon-btn",
|
|
1783
|
+
onClick: toggleVoice,
|
|
1784
|
+
disabled: sending,
|
|
1785
|
+
"aria-label": voiceListening ? "Stop recording" : "Start voice input",
|
|
1786
|
+
style: {
|
|
1787
|
+
width: 32,
|
|
1788
|
+
height: 32,
|
|
1789
|
+
borderRadius: "50%",
|
|
1790
|
+
background: voiceListening ? primary : "transparent",
|
|
1791
|
+
color: voiceListening ? onPrimary : "inherit",
|
|
1792
|
+
border: "none",
|
|
1793
|
+
cursor: sending ? "default" : "pointer",
|
|
1794
|
+
opacity: sending ? 0.35 : voiceListening ? 1 : 0.75,
|
|
1795
|
+
lineHeight: 1,
|
|
1796
|
+
padding: 0,
|
|
1797
|
+
display: "flex",
|
|
1798
|
+
alignItems: "center",
|
|
1799
|
+
justifyContent: "center",
|
|
1800
|
+
flexShrink: 0,
|
|
1801
|
+
alignSelf: "center",
|
|
1802
|
+
transition: "opacity 120ms ease, background 120ms ease, color 120ms ease"
|
|
1803
|
+
},
|
|
1804
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(IconMic, { size: 16 })
|
|
1631
1805
|
}
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
borderRadius: "50%",
|
|
1674
|
-
background: voiceListening ? primary : "transparent",
|
|
1675
|
-
color: voiceListening ? onPrimary : "inherit",
|
|
1676
|
-
border: "none",
|
|
1677
|
-
cursor: sending ? "default" : "pointer",
|
|
1678
|
-
opacity: sending ? 0.35 : voiceListening ? 1 : 0.7,
|
|
1679
|
-
fontSize: 16,
|
|
1680
|
-
lineHeight: 1,
|
|
1681
|
-
padding: 0,
|
|
1682
|
-
display: "flex",
|
|
1683
|
-
alignItems: "center",
|
|
1684
|
-
justifyContent: "center",
|
|
1685
|
-
flexShrink: 0,
|
|
1686
|
-
alignSelf: "center",
|
|
1687
|
-
transition: "opacity 120ms ease, background 120ms ease, color 120ms ease"
|
|
1688
|
-
},
|
|
1689
|
-
children: "\u{1F399}\uFE0F"
|
|
1690
|
-
}
|
|
1691
|
-
),
|
|
1692
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1693
|
-
"textarea",
|
|
1694
|
-
{
|
|
1695
|
-
ref: inputRef,
|
|
1696
|
-
className: "chatbotlite-input",
|
|
1697
|
-
rows: 1,
|
|
1698
|
-
value: input,
|
|
1699
|
-
onChange: (e) => {
|
|
1700
|
-
setInput(e.target.value);
|
|
1701
|
-
const el = e.currentTarget;
|
|
1702
|
-
el.style.height = "auto";
|
|
1703
|
-
el.style.height = Math.min(el.scrollHeight, 100) + "px";
|
|
1704
|
-
},
|
|
1705
|
-
onKeyDown: (e) => {
|
|
1706
|
-
if (e.key === "Enter" && !e.shiftKey) {
|
|
1707
|
-
e.preventDefault();
|
|
1708
|
-
void send();
|
|
1806
|
+
),
|
|
1807
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1808
|
+
"textarea",
|
|
1809
|
+
{
|
|
1810
|
+
ref: inputRef,
|
|
1811
|
+
className: "chatbotlite-input",
|
|
1812
|
+
rows: 1,
|
|
1813
|
+
value: input,
|
|
1814
|
+
onChange: (e) => {
|
|
1815
|
+
setInput(e.target.value);
|
|
1816
|
+
const el = e.currentTarget;
|
|
1817
|
+
el.style.height = "20px";
|
|
1818
|
+
if (el.scrollHeight > 28) {
|
|
1819
|
+
el.style.height = Math.min(el.scrollHeight, 100) + "px";
|
|
1820
|
+
}
|
|
1821
|
+
},
|
|
1822
|
+
onKeyDown: (e) => {
|
|
1823
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
1824
|
+
e.preventDefault();
|
|
1825
|
+
void send();
|
|
1826
|
+
}
|
|
1827
|
+
},
|
|
1828
|
+
placeholder: "Message",
|
|
1829
|
+
disabled: sending,
|
|
1830
|
+
style: {
|
|
1831
|
+
flex: 1,
|
|
1832
|
+
padding: "4px 6px",
|
|
1833
|
+
margin: 0,
|
|
1834
|
+
border: "none",
|
|
1835
|
+
background: "transparent",
|
|
1836
|
+
fontSize: 14,
|
|
1837
|
+
fontFamily: FONT_STACK,
|
|
1838
|
+
color: TEXT_BODY,
|
|
1839
|
+
outline: "none",
|
|
1840
|
+
resize: "none",
|
|
1841
|
+
lineHeight: 1.4,
|
|
1842
|
+
height: 20,
|
|
1843
|
+
maxHeight: 100,
|
|
1844
|
+
boxSizing: "content-box",
|
|
1845
|
+
overflow: "hidden"
|
|
1846
|
+
}
|
|
1709
1847
|
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
opacity: sending || !input.trim() && files.length === 0 ? 0.35 : 1,
|
|
1748
|
-
display: "flex",
|
|
1749
|
-
alignItems: "center",
|
|
1750
|
-
justifyContent: "center",
|
|
1751
|
-
flexShrink: 0,
|
|
1752
|
-
padding: 0,
|
|
1753
|
-
transition: "opacity 120ms ease, transform 80ms ease"
|
|
1754
|
-
},
|
|
1755
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1756
|
-
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "19", x2: "12", y2: "5" }),
|
|
1757
|
-
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "5 12 12 5 19 12" })
|
|
1758
|
-
] })
|
|
1759
|
-
}
|
|
1760
|
-
)
|
|
1761
|
-
] }) }),
|
|
1762
|
-
showBranding && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1848
|
+
),
|
|
1849
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1850
|
+
"button",
|
|
1851
|
+
{
|
|
1852
|
+
className: "chatbotlite-send",
|
|
1853
|
+
onClick: () => void send(),
|
|
1854
|
+
disabled: sending || !input.trim() && files.length === 0,
|
|
1855
|
+
"aria-label": "Send message",
|
|
1856
|
+
style: {
|
|
1857
|
+
width: 34,
|
|
1858
|
+
height: 34,
|
|
1859
|
+
borderRadius: "50%",
|
|
1860
|
+
background: primary,
|
|
1861
|
+
color: onPrimary,
|
|
1862
|
+
border: "none",
|
|
1863
|
+
fontSize: 14,
|
|
1864
|
+
fontWeight: 600,
|
|
1865
|
+
fontFamily: FONT_STACK,
|
|
1866
|
+
cursor: sending || !input.trim() && files.length === 0 ? "default" : "pointer",
|
|
1867
|
+
opacity: sending || !input.trim() && files.length === 0 ? 0.35 : 1,
|
|
1868
|
+
display: "flex",
|
|
1869
|
+
alignItems: "center",
|
|
1870
|
+
justifyContent: "center",
|
|
1871
|
+
flexShrink: 0,
|
|
1872
|
+
padding: 0,
|
|
1873
|
+
transition: "opacity 120ms ease, transform 80ms ease"
|
|
1874
|
+
},
|
|
1875
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1876
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "19", x2: "12", y2: "5" }),
|
|
1877
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "5 12 12 5 19 12" })
|
|
1878
|
+
] })
|
|
1879
|
+
}
|
|
1880
|
+
)
|
|
1881
|
+
]
|
|
1882
|
+
}
|
|
1883
|
+
) }),
|
|
1884
|
+
showBranding && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1763
1885
|
"a",
|
|
1764
1886
|
{
|
|
1765
1887
|
className: "chatbotlite-brand",
|
|
@@ -1778,10 +1900,10 @@ function ChatWidget(props) {
|
|
|
1778
1900
|
letterSpacing: "0.01em",
|
|
1779
1901
|
transition: "color 120ms ease"
|
|
1780
1902
|
},
|
|
1781
|
-
children: [
|
|
1782
|
-
|
|
1783
|
-
"
|
|
1784
|
-
]
|
|
1903
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: 5 }, children: [
|
|
1904
|
+
/* @__PURE__ */ jsxRuntime.jsx(IconBolt, { size: 11 }),
|
|
1905
|
+
"Powered by chatbotlite"
|
|
1906
|
+
] })
|
|
1785
1907
|
}
|
|
1786
1908
|
)
|
|
1787
1909
|
]
|