@xbrain-swe/nova-chat-widget 0.1.7 → 0.1.8
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.cjs +38 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -14
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1505,6 +1505,28 @@ function XbNovaChat({
|
|
|
1505
1505
|
nudgeNodeId: activeNudgeNodeId,
|
|
1506
1506
|
onDismissSheet: () => setOpen(false)
|
|
1507
1507
|
});
|
|
1508
|
+
const effectiveBotId = activeBotId ?? botId;
|
|
1509
|
+
const [cachedBranding, setCachedBranding] = useState4(null);
|
|
1510
|
+
useEffect8(() => {
|
|
1511
|
+
try {
|
|
1512
|
+
const raw = window.localStorage.getItem(`xbnova_branding:${effectiveBotId}`);
|
|
1513
|
+
setCachedBranding(raw ? JSON.parse(raw) : null);
|
|
1514
|
+
} catch {
|
|
1515
|
+
setCachedBranding(null);
|
|
1516
|
+
}
|
|
1517
|
+
}, [effectiveBotId]);
|
|
1518
|
+
useEffect8(() => {
|
|
1519
|
+
if (!onboarding?.branding) return;
|
|
1520
|
+
try {
|
|
1521
|
+
window.localStorage.setItem(
|
|
1522
|
+
`xbnova_branding:${effectiveBotId}`,
|
|
1523
|
+
JSON.stringify({ logo_url: onboarding.branding.logo_url, avatar_text: onboarding.branding.avatar_text })
|
|
1524
|
+
);
|
|
1525
|
+
} catch {
|
|
1526
|
+
}
|
|
1527
|
+
}, [onboarding?.branding, effectiveBotId]);
|
|
1528
|
+
const branding = onboarding?.branding ?? cachedBranding ?? void 0;
|
|
1529
|
+
const brandingReady = Boolean(onboarding) || cachedBranding !== null || Boolean(error);
|
|
1508
1530
|
useEffect8(() => {
|
|
1509
1531
|
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
1510
1532
|
}, [messages]);
|
|
@@ -1632,7 +1654,8 @@ function XbNovaChat({
|
|
|
1632
1654
|
children: /* @__PURE__ */ jsx7(
|
|
1633
1655
|
Avatar,
|
|
1634
1656
|
{
|
|
1635
|
-
branding
|
|
1657
|
+
branding,
|
|
1658
|
+
ready: brandingReady,
|
|
1636
1659
|
size: avatarSize,
|
|
1637
1660
|
className: "shadow-md",
|
|
1638
1661
|
gradient: avatarGradientStyle
|
|
@@ -1681,7 +1704,8 @@ function XbNovaChat({
|
|
|
1681
1704
|
/* @__PURE__ */ jsx7(
|
|
1682
1705
|
Avatar,
|
|
1683
1706
|
{
|
|
1684
|
-
branding
|
|
1707
|
+
branding,
|
|
1708
|
+
ready: brandingReady,
|
|
1685
1709
|
size: headerAvatarSize,
|
|
1686
1710
|
className: "shrink-0",
|
|
1687
1711
|
gradient: avatarGradientStyle
|
|
@@ -1801,6 +1825,7 @@ function XbNovaChat({
|
|
|
1801
1825
|
}
|
|
1802
1826
|
function Avatar({
|
|
1803
1827
|
branding,
|
|
1828
|
+
ready,
|
|
1804
1829
|
size,
|
|
1805
1830
|
className = "",
|
|
1806
1831
|
gradient
|
|
@@ -1808,27 +1833,26 @@ function Avatar({
|
|
|
1808
1833
|
const box = { width: size, height: size };
|
|
1809
1834
|
const logoUrl = branding?.logo_url?.trim() ?? "";
|
|
1810
1835
|
const [failedUrl, setFailedUrl] = useState4("");
|
|
1836
|
+
const [loadedUrl, setLoadedUrl] = useState4("");
|
|
1837
|
+
const base = `${className} relative flex flex-none items-center justify-center overflow-hidden rounded-full font-bold text-white`;
|
|
1838
|
+
if (!ready) {
|
|
1839
|
+
return /* @__PURE__ */ jsx7("span", { className: base, style: { ...gradient, ...box }, "aria-hidden": true });
|
|
1840
|
+
}
|
|
1811
1841
|
if (logoUrl && failedUrl !== logoUrl) {
|
|
1812
|
-
return /* @__PURE__ */ jsx7(
|
|
1842
|
+
return /* @__PURE__ */ jsx7("span", { className: base, style: { ...gradient, ...box }, children: /* @__PURE__ */ jsx7(
|
|
1813
1843
|
"img",
|
|
1814
1844
|
{
|
|
1815
1845
|
src: logoUrl,
|
|
1816
1846
|
alt: "",
|
|
1847
|
+
onLoad: () => setLoadedUrl(logoUrl),
|
|
1817
1848
|
onError: () => setFailedUrl(logoUrl),
|
|
1818
|
-
|
|
1819
|
-
|
|
1849
|
+
className: "absolute inset-0 h-full w-full rounded-full bg-white object-cover transition-opacity duration-200",
|
|
1850
|
+
style: { opacity: loadedUrl === logoUrl ? 1 : 0 }
|
|
1820
1851
|
}
|
|
1821
|
-
);
|
|
1852
|
+
) });
|
|
1822
1853
|
}
|
|
1823
1854
|
const text = branding?.avatar_text?.trim() || "AI";
|
|
1824
|
-
return /* @__PURE__ */ jsx7(
|
|
1825
|
-
"span",
|
|
1826
|
-
{
|
|
1827
|
-
className: `${className} flex flex-none items-center justify-center rounded-full font-bold text-white`,
|
|
1828
|
-
style: { ...gradient, ...box, fontSize: Math.max(10, Math.round(size * 0.4)) },
|
|
1829
|
-
children: text
|
|
1830
|
-
}
|
|
1831
|
-
);
|
|
1855
|
+
return /* @__PURE__ */ jsx7("span", { className: base, style: { ...gradient, ...box, fontSize: Math.max(10, Math.round(size * 0.4)) }, children: text });
|
|
1832
1856
|
}
|
|
1833
1857
|
function Bubble({ role, children }) {
|
|
1834
1858
|
const mine = role === "user";
|