@getwidgets/live-chat-widget 1.1.0 → 1.1.2
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/live-chat-widget.umd.js +61 -61
- package/package.json +1 -1
|
@@ -20359,7 +20359,8 @@
|
|
|
20359
20359
|
textAlign: "left",
|
|
20360
20360
|
minWidth: isMobile ? "90vw" : "280px",
|
|
20361
20361
|
maxWidth: isMobile ? "90vw" : "400px",
|
|
20362
|
-
margin: isMobile ? "0 auto" : "0"
|
|
20362
|
+
margin: isMobile ? "0 auto" : "0",
|
|
20363
|
+
fontFamily: headerConfig.font_family || "'Inter', sans-serif"
|
|
20363
20364
|
}
|
|
20364
20365
|
},
|
|
20365
20366
|
unreadCount > 0 && /* @__PURE__ */ React.createElement(
|
|
@@ -20414,7 +20415,7 @@
|
|
|
20414
20415
|
},
|
|
20415
20416
|
/* @__PURE__ */ React.createElement("path", { d: "M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM6 9h12v2H6V9zm8 5H6v-2h8v2zm4-6H6V6h12v2z" })
|
|
20416
20417
|
)
|
|
20417
|
-
), /* @__PURE__ */ React.createElement("div", { className: "flex-1" }, /* @__PURE__ */ React.createElement("h3", { className: "font-semibold text-sm" }, headerConfig.title || "Live Chat"), /* @__PURE__ */ React.createElement("p", { className: "text-xs opacity-70" }, "Just now"))), /* @__PURE__ */ React.createElement(
|
|
20418
|
+
), /* @__PURE__ */ React.createElement("div", { className: "flex-1" }, /* @__PURE__ */ React.createElement("h3", { className: "font-semibold text-sm", style: headerConfig.font_color ? { color: headerConfig.font_color } : { color: "black" } }, headerConfig.title || "Live Chat"), /* @__PURE__ */ React.createElement("p", { className: "text-xs opacity-70", style: headerConfig.font_color ? { color: headerConfig.font_color } : { color: "black" } }, "Just now"))), /* @__PURE__ */ React.createElement(
|
|
20418
20419
|
"button",
|
|
20419
20420
|
{
|
|
20420
20421
|
onClick: handleCloseNotification,
|
|
@@ -20423,7 +20424,7 @@
|
|
|
20423
20424
|
},
|
|
20424
20425
|
"×"
|
|
20425
20426
|
)),
|
|
20426
|
-
/* @__PURE__ */ React.createElement("p", { className: "text-sm leading-relaxed text-gray-200", style: { fontSize: isMobile ? "13px" : "14px" } }, (latestMessage == null ? void 0 : latestMessage.content) || (inputAreaConfig == null ? void 0 : inputAreaConfig.first_ai_message) || headerConfig.subtitle || "Connect with visitors")
|
|
20427
|
+
/* @__PURE__ */ React.createElement("p", { className: "text-sm leading-relaxed text-gray-200", style: { fontSize: isMobile ? "13px" : "14px", color: headerConfig.font_color ? headerConfig.font_color : "#000000" } }, (latestMessage == null ? void 0 : latestMessage.content) || (inputAreaConfig == null ? void 0 : inputAreaConfig.welcome_message) || (inputAreaConfig == null ? void 0 : inputAreaConfig.first_ai_message) || headerConfig.subtitle || "Connect with visitors")
|
|
20427
20428
|
), !isOpen && !showNotificationPreview && /* @__PURE__ */ React.createElement(
|
|
20428
20429
|
"button",
|
|
20429
20430
|
{
|
|
@@ -20445,8 +20446,8 @@
|
|
|
20445
20446
|
src: headerConfig.logo_url,
|
|
20446
20447
|
alt: "logo",
|
|
20447
20448
|
style: {
|
|
20448
|
-
width:
|
|
20449
|
-
height:
|
|
20449
|
+
width: "auto",
|
|
20450
|
+
height: `${headerConfig.logo_size || 32}px`
|
|
20450
20451
|
}
|
|
20451
20452
|
}
|
|
20452
20453
|
) : /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 24 24", fill: "currentColor", style: { width: isMobile ? 18 : 20, height: isMobile ? 18 : 20 } }, /* @__PURE__ */ React.createElement("path", { d: "M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM6 9h12v2H6V9zm8 5H6v-2h8v2zm4-6H6V6h12v2z" })),
|
|
@@ -20476,6 +20477,7 @@
|
|
|
20476
20477
|
maxHeight: responsiveDimensions.maxHeight,
|
|
20477
20478
|
backgroundColor: appearanceConfig.background_color || "#F9FAFB",
|
|
20478
20479
|
borderRadius: isMobile ? responsiveDimensions.borderRadius : appearanceConfig.border_radius || "16px",
|
|
20480
|
+
fontFamily: headerConfig.font_family || "'Inter', sans-serif",
|
|
20479
20481
|
...isMobile ? { borderBottomLeftRadius: 0, borderBottomRightRadius: 0 } : {}
|
|
20480
20482
|
}
|
|
20481
20483
|
},
|
|
@@ -20516,7 +20518,8 @@
|
|
|
20516
20518
|
{
|
|
20517
20519
|
src: headerConfig.logo_url,
|
|
20518
20520
|
alt: "logo",
|
|
20519
|
-
className: "w-auto
|
|
20521
|
+
className: "w-auto mx-auto mb-2",
|
|
20522
|
+
style: { height: `${headerConfig.logo_size || 32}px` }
|
|
20520
20523
|
}
|
|
20521
20524
|
), !headerConfig.hide_title && /* @__PURE__ */ React.createElement("h2", { className: "font-semibold leading-tight", style: { fontSize: isMobile ? "14px" : "16px", margin: "0" } }, headerConfig.title || "Live Chat"), /* @__PURE__ */ React.createElement("p", { className: "opacity-80 leading-tight", style: { fontSize: isMobile ? "11px" : "13px", margin: "2px 0 0 0" } }, headerConfig.subtitle || "Connect with visitors"))
|
|
20522
20525
|
),
|
|
@@ -20554,7 +20557,7 @@
|
|
|
20554
20557
|
wordBreak: "break-word"
|
|
20555
20558
|
}
|
|
20556
20559
|
},
|
|
20557
|
-
inputAreaConfig.first_ai_message || "Hello! How can I assist you today?"
|
|
20560
|
+
inputAreaConfig.welcome_message || inputAreaConfig.first_ai_message || "Hello! How can I assist you today?"
|
|
20558
20561
|
)) : combinedMessages.map((message) => {
|
|
20559
20562
|
const timeText = getMessageTime(message);
|
|
20560
20563
|
return /* @__PURE__ */ React.createElement("div", { key: message.id, className: `flex flex-col ${message.role === "user" ? "items-end" : "items-start"}` }, /* @__PURE__ */ React.createElement(
|
|
@@ -20797,74 +20800,71 @@
|
|
|
20797
20800
|
}
|
|
20798
20801
|
`));
|
|
20799
20802
|
};
|
|
20800
|
-
|
|
20803
|
+
let reactRoot = null;
|
|
20804
|
+
let userDetails = { name: null, email: null, unique_id: null };
|
|
20805
|
+
let currentWidgetId = null;
|
|
20806
|
+
function init({
|
|
20807
|
+
widgetId,
|
|
20808
|
+
mode = "inline",
|
|
20809
|
+
name: name2 = null,
|
|
20810
|
+
email = null,
|
|
20811
|
+
unique_id = null
|
|
20812
|
+
}) {
|
|
20801
20813
|
const container = document.getElementById("livechat-root");
|
|
20802
20814
|
if (!container) {
|
|
20803
|
-
console.error(
|
|
20815
|
+
console.error(
|
|
20816
|
+
"Live Chat Widget root element (#livechat-root) not found."
|
|
20817
|
+
);
|
|
20804
20818
|
return;
|
|
20805
20819
|
}
|
|
20806
|
-
|
|
20807
|
-
|
|
20808
|
-
|
|
20809
|
-
|
|
20810
|
-
|
|
20811
|
-
|
|
20812
|
-
|
|
20813
|
-
|
|
20814
|
-
|
|
20815
|
-
|
|
20816
|
-
|
|
20817
|
-
|
|
20818
|
-
|
|
20819
|
-
|
|
20820
|
+
currentWidgetId = widgetId;
|
|
20821
|
+
container.dataset.widgetId = widgetId;
|
|
20822
|
+
if (!container.__livechat_mounted) {
|
|
20823
|
+
container.innerHTML = "";
|
|
20824
|
+
const shadowRoot = container.attachShadow({ mode: "open" });
|
|
20825
|
+
const mountPoint = document.createElement("div");
|
|
20826
|
+
mountPoint.id = "live-chat-widget-mount";
|
|
20827
|
+
shadowRoot.appendChild(mountPoint);
|
|
20828
|
+
const styles = document.createElement("style");
|
|
20829
|
+
styles.textContent = `
|
|
20830
|
+
@import url("https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css");
|
|
20831
|
+
`;
|
|
20832
|
+
shadowRoot.appendChild(styles);
|
|
20833
|
+
reactRoot = client.createRoot(mountPoint);
|
|
20834
|
+
container.__livechat_mounted = true;
|
|
20835
|
+
}
|
|
20836
|
+
userDetails = { name: name2, email, unique_id };
|
|
20837
|
+
if (reactRoot) {
|
|
20838
|
+
reactRoot.render(
|
|
20820
20839
|
/* @__PURE__ */ React.createElement(React.StrictMode, null, /* @__PURE__ */ React.createElement(
|
|
20821
20840
|
LiveChatWidget,
|
|
20822
20841
|
{
|
|
20823
|
-
widgetId,
|
|
20824
|
-
name:
|
|
20825
|
-
email,
|
|
20826
|
-
unique_id
|
|
20842
|
+
widgetId: currentWidgetId,
|
|
20843
|
+
name: userDetails.name,
|
|
20844
|
+
email: userDetails.email,
|
|
20845
|
+
unique_id: userDetails.unique_id
|
|
20827
20846
|
}
|
|
20828
20847
|
))
|
|
20829
20848
|
);
|
|
20830
|
-
container.__livechat_mounted = true;
|
|
20831
|
-
} catch (err) {
|
|
20832
|
-
console.error("❌ LiveChatWidget render failed:", err);
|
|
20833
|
-
const errDiv = document.createElement("div");
|
|
20834
|
-
errDiv.style.cssText = "padding:20px; border:2px solid #f00; background:#fee; color:#c00; font-family:monospace; border-radius:8px; margin:20px;";
|
|
20835
|
-
errDiv.innerHTML = `
|
|
20836
|
-
<h3 style="margin:0 0 10px 0;">Live Chat Widget Error</h3>
|
|
20837
|
-
<pre style="white-space: pre-wrap; margin:0;">${(err == null ? void 0 : err.message) || String(err)}</pre>
|
|
20838
|
-
<p style="margin:10px 0 0 0;">Check console for details.</p>
|
|
20839
|
-
`;
|
|
20840
|
-
mountPoint.appendChild(errDiv);
|
|
20841
20849
|
}
|
|
20842
20850
|
}
|
|
20843
|
-
let userDetails = { name: null, email: null, unique_id: null };
|
|
20844
20851
|
function setUser({ name: name2, email, unique_id }) {
|
|
20845
|
-
if (userDetails.name
|
|
20846
|
-
|
|
20847
|
-
|
|
20848
|
-
|
|
20849
|
-
|
|
20850
|
-
|
|
20851
|
-
|
|
20852
|
-
|
|
20853
|
-
|
|
20854
|
-
|
|
20855
|
-
|
|
20856
|
-
|
|
20857
|
-
|
|
20858
|
-
widgetId: container.dataset.widgetId,
|
|
20859
|
-
name: name2,
|
|
20860
|
-
email,
|
|
20861
|
-
unique_id
|
|
20862
|
-
}
|
|
20863
|
-
))
|
|
20864
|
-
);
|
|
20852
|
+
if (userDetails.name === name2 && userDetails.email === email && userDetails.unique_id === unique_id) {
|
|
20853
|
+
return;
|
|
20854
|
+
}
|
|
20855
|
+
userDetails = { name: name2, email, unique_id };
|
|
20856
|
+
if (reactRoot) {
|
|
20857
|
+
reactRoot.render(
|
|
20858
|
+
/* @__PURE__ */ React.createElement(React.StrictMode, null, /* @__PURE__ */ React.createElement(
|
|
20859
|
+
LiveChatWidget,
|
|
20860
|
+
{
|
|
20861
|
+
widgetId: currentWidgetId,
|
|
20862
|
+
name: userDetails.name,
|
|
20863
|
+
email: userDetails.email,
|
|
20864
|
+
unique_id: userDetails.unique_id
|
|
20865
20865
|
}
|
|
20866
|
-
|
|
20867
|
-
|
|
20866
|
+
))
|
|
20867
|
+
);
|
|
20868
20868
|
}
|
|
20869
20869
|
}
|
|
20870
20870
|
window.LiveChatWidget = { init, setUser };
|