@sevenfold/setto-client 0.22.1 → 0.22.3
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/setto-client.js +13 -8
- package/dist/setto-client.js.map +1 -1
- package/package.json +1 -1
package/dist/setto-client.js
CHANGED
|
@@ -22089,15 +22089,16 @@ function SettoChat() {
|
|
|
22089
22089
|
}, [apiUrl, config.siteId]);
|
|
22090
22090
|
useEffect(() => {
|
|
22091
22091
|
if (!open || messages.length > 0 || !settings) return;
|
|
22092
|
-
setMessages([{ role: "assistant", content: intro(i18n.language, settings.displayName) }]);
|
|
22092
|
+
setMessages([{ role: "assistant", content: intro(i18n.language, settings.displayName ?? void 0) }]);
|
|
22093
22093
|
}, [open, messages.length, settings, i18n.language]);
|
|
22094
22094
|
useEffect(() => {
|
|
22095
22095
|
if (open) logRef.current?.scrollTo({ top: logRef.current.scrollHeight });
|
|
22096
22096
|
}, [messages, open]);
|
|
22097
22097
|
if (!settings || window.location.pathname.startsWith("/setto")) return null;
|
|
22098
22098
|
const locale = i18n.language || "no";
|
|
22099
|
+
const siteName = settings.displayName?.trim() || null;
|
|
22099
22100
|
const labels = norwegian(locale) ? {
|
|
22100
|
-
open: `Snakk med ${
|
|
22101
|
+
open: siteName ? `Snakk med ${siteName}` : "Snakk med oss",
|
|
22101
22102
|
close: "Lukk chatten",
|
|
22102
22103
|
title: "Spør Barista",
|
|
22103
22104
|
disclosure: "AI-assistent · svarer fra nettstedets godkjente informasjon",
|
|
@@ -22119,7 +22120,7 @@ function SettoChat() {
|
|
|
22119
22120
|
leadConversation: "Still et spørsmål først, så kan vi knytte oppfølgingen til samtalen.",
|
|
22120
22121
|
failed: "Jeg får ikke svart akkurat nå. Kontakt gjerne teamet direkte."
|
|
22121
22122
|
} : {
|
|
22122
|
-
open: `Chat with ${
|
|
22123
|
+
open: siteName ? `Chat with ${siteName}` : "Chat with us",
|
|
22123
22124
|
close: "Close chat",
|
|
22124
22125
|
title: "Ask Barista",
|
|
22125
22126
|
disclosure: "AI assistant · answers from this website’s approved information",
|
|
@@ -22220,8 +22221,8 @@ function SettoChat() {
|
|
|
22220
22221
|
setLeadStatus("failed");
|
|
22221
22222
|
}
|
|
22222
22223
|
};
|
|
22223
|
-
return /* @__PURE__ */ jsxs("aside", { className: "setto-chat"
|
|
22224
|
-
open ? /* @__PURE__ */ jsxs("section", { className: "setto-chat__panel", role: "dialog", "aria-modal": "
|
|
22224
|
+
return /* @__PURE__ */ jsxs("aside", { className: `setto-chat${open ? " setto-chat--open" : ""}`, "aria-label": labels.title, "data-setto-ui": true, children: [
|
|
22225
|
+
open ? /* @__PURE__ */ jsxs("section", { className: "setto-chat__panel", role: "dialog", "aria-modal": "true", "aria-labelledby": `${formId}-title`, children: [
|
|
22225
22226
|
/* @__PURE__ */ jsxs("header", { className: "setto-chat__header", children: [
|
|
22226
22227
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
22227
22228
|
/* @__PURE__ */ jsx("p", { className: "setto-chat__eyebrow", children: "BARISTA" }),
|
|
@@ -22294,10 +22295,10 @@ function SettoChat() {
|
|
|
22294
22295
|
/* @__PURE__ */ jsx("button", { type: "submit", disabled: !draft.trim() || sending, children: sending ? labels.sending : labels.send })
|
|
22295
22296
|
] })
|
|
22296
22297
|
] }) : null,
|
|
22297
|
-
/* @__PURE__ */ jsxs("button", { className: "setto-chat__launcher", type: "button", onClick: () => setOpen(true), "aria-expanded":
|
|
22298
|
+
!open ? /* @__PURE__ */ jsxs("button", { className: "setto-chat__launcher", type: "button", onClick: () => setOpen(true), "aria-expanded": "false", children: [
|
|
22298
22299
|
/* @__PURE__ */ jsx("span", { className: "setto-chat__launcher-mark", "aria-hidden": "true", children: "✦" }),
|
|
22299
22300
|
/* @__PURE__ */ jsx("span", { children: labels.open })
|
|
22300
|
-
] })
|
|
22301
|
+
] }) : null
|
|
22301
22302
|
] });
|
|
22302
22303
|
}
|
|
22303
22304
|
function replaceLastAssistant(messages, content) {
|
|
@@ -22317,11 +22318,14 @@ function useChatStyles() {
|
|
|
22317
22318
|
style.textContent = `
|
|
22318
22319
|
.setto-chat { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 2147483000; color: #231d17; font-family: Archivo, ui-sans-serif, sans-serif; }
|
|
22319
22320
|
.setto-chat *, .setto-chat *::before, .setto-chat *::after { box-sizing: border-box; }
|
|
22321
|
+
.setto-chat--open { inset: 0; right: 0; bottom: 0; width: 100vw; height: 100dvh; display: block; background: #fffaf1; }
|
|
22320
22322
|
.setto-chat__launcher { border: 0; min-height: 54px; max-width: min(290px, calc(100vw - 32px)); border-radius: 999px; padding: 8px 18px 8px 9px; display: flex; align-items: center; gap: 10px; background: #251d16; color: #fff9ef; box-shadow: 0 14px 40px rgba(35,29,23,.28); font: 600 14px/1 Archivo, ui-sans-serif, sans-serif; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease; }
|
|
22321
22323
|
.setto-chat__launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 46px rgba(35,29,23,.36); }
|
|
22322
22324
|
.setto-chat__launcher-mark { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #df6540; color: #fff8eb; font-size: 18px; }
|
|
22323
22325
|
.setto-chat__panel { width: min(390px, calc(100vw - 32px)); height: min(590px, calc(100dvh - 104px)); margin-bottom: 12px; overflow: hidden; display: grid; grid-template-rows: auto 1fr auto auto auto; border: 1px solid rgba(37,29,22,.15); border-radius: 20px; background: #fffaf1; box-shadow: 0 22px 70px rgba(35,29,23,.3); }
|
|
22326
|
+
.setto-chat--open .setto-chat__panel { width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
|
|
22324
22327
|
.setto-chat__header { padding: 20px 20px 16px; display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid #eadfce; background: radial-gradient(circle at 0 0, #f4d4a9, transparent 52%), #fffaf1; }
|
|
22328
|
+
.setto-chat--open .setto-chat__header { padding-top: max(20px, env(safe-area-inset-top)); padding-right: max(20px, env(safe-area-inset-right)); padding-left: max(20px, env(safe-area-inset-left)); }
|
|
22325
22329
|
.setto-chat__eyebrow { margin: 0 0 4px; color: #b54628; font-size: 10px; font-weight: 700; letter-spacing: .14em; }
|
|
22326
22330
|
.setto-chat__header h2 { margin: 0; color: #211a14; font-family: "Instrument Serif", Georgia, serif; font-size: 29px; font-weight: 400; line-height: 1; }
|
|
22327
22331
|
.setto-chat__header p:not(.setto-chat__eyebrow) { margin: 7px 0 0; max-width: 280px; color: #70665a; font-size: 12px; line-height: 1.35; }
|
|
@@ -22345,12 +22349,13 @@ function useChatStyles() {
|
|
|
22345
22349
|
.setto-chat__lead-success { color: #30683d !important; font-weight: 600; }
|
|
22346
22350
|
.setto-chat__lead-error { color: #9b2f1e !important; font-weight: 600; }
|
|
22347
22351
|
.setto-chat__composer { padding: 12px; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; border-top: 1px solid #eadfce; background: #fffdf8; }
|
|
22352
|
+
.setto-chat--open .setto-chat__composer { padding-right: max(12px, env(safe-area-inset-right)); padding-bottom: max(12px, env(safe-area-inset-bottom)); padding-left: max(12px, env(safe-area-inset-left)); }
|
|
22348
22353
|
.setto-chat__composer textarea { width: 100%; max-height: 100px; resize: none; border: 1px solid #d8ccba; border-radius: 10px; background: #fffaf1; color: #231d17; padding: 10px; font: 14px/1.35 Archivo, ui-sans-serif, sans-serif; outline: none; }
|
|
22349
22354
|
.setto-chat__composer textarea:focus { border-color: #b54628; box-shadow: 0 0 0 3px rgba(181,70,40,.12); }
|
|
22350
22355
|
.setto-chat__composer button { min-height: 40px; border: 0; border-radius: 9px; padding: 0 13px; background: #b54628; color: #fffaf1; font: 600 13px Archivo, ui-sans-serif, sans-serif; cursor: pointer; }
|
|
22351
22356
|
.setto-chat__composer button:disabled { opacity: .5; cursor: default; }
|
|
22352
22357
|
.setto-chat__sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
|
|
22353
|
-
@media (max-width: 480px) { .setto-chat { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); } .setto-chat__panel { width: calc(100vw - 24px); height: min(610px, calc(100dvh - 88px)); } .setto-chat__launcher { min-height: 50px; } .setto-chat__lead-grid { grid-template-columns: 1fr; } }
|
|
22358
|
+
@media (max-width: 480px) { .setto-chat:not(.setto-chat--open) { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); } .setto-chat:not(.setto-chat--open) .setto-chat__panel { width: calc(100vw - 24px); height: min(610px, calc(100dvh - 88px)); } .setto-chat__launcher { min-height: 50px; } .setto-chat__lead-grid { grid-template-columns: 1fr; } }
|
|
22354
22359
|
@media (prefers-reduced-motion: reduce) { .setto-chat *, .setto-chat *::before, .setto-chat *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
|
|
22355
22360
|
`;
|
|
22356
22361
|
document.head.appendChild(style);
|