@kayro-ia/widget 1.0.1 → 1.0.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/index.js +19 -8
- package/dist/index.mjs +20 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -684,16 +684,27 @@ function ChatWindow({ config }) {
|
|
|
684
684
|
// src/AIWidget.tsx
|
|
685
685
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
686
686
|
function AIWidget(props) {
|
|
687
|
-
var _a, _b, _c;
|
|
687
|
+
var _a, _b, _c, _d, _e, _f;
|
|
688
688
|
const { isOpen, setOpen } = useChatStore();
|
|
689
|
-
const
|
|
690
|
-
const
|
|
691
|
-
const zIndex = (_c = props.zIndex) != null ? _c : 9999;
|
|
689
|
+
const [serverConfig, setServerConfig] = (0, import_react4.useState)(null);
|
|
690
|
+
const baseUrl = ((_a = props.orchestratorUrl) != null ? _a : "https://app.kayro.com.ar").replace(/\/$/, "");
|
|
692
691
|
(0, import_react4.useEffect)(() => {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
}
|
|
692
|
+
fetch(`${baseUrl}/api/widget-config?apiKey=${encodeURIComponent(props.apiKey)}`).then((r) => r.ok ? r.json() : null).then((data) => {
|
|
693
|
+
if (data) setServerConfig(data);
|
|
694
|
+
}).catch(() => {
|
|
695
|
+
});
|
|
696
|
+
}, [props.apiKey, baseUrl]);
|
|
697
|
+
(0, import_react4.useEffect)(() => {
|
|
698
|
+
if (props.initialOpen) setOpen(true);
|
|
696
699
|
}, []);
|
|
700
|
+
const primaryColor = (_c = (_b = props.primaryColor) != null ? _b : serverConfig == null ? void 0 : serverConfig.primaryColor) != null ? _c : "#6366f1";
|
|
701
|
+
const position = (_d = props.position) != null ? _d : "bottom-right";
|
|
702
|
+
const zIndex = (_e = props.zIndex) != null ? _e : 9999;
|
|
703
|
+
const mergedConfig = {
|
|
704
|
+
...props,
|
|
705
|
+
primaryColor,
|
|
706
|
+
title: (_f = props.title) != null ? _f : serverConfig == null ? void 0 : serverConfig.assistantName
|
|
707
|
+
};
|
|
697
708
|
function handleBubbleClick() {
|
|
698
709
|
setOpen(!isOpen);
|
|
699
710
|
}
|
|
@@ -708,7 +719,7 @@ function AIWidget(props) {
|
|
|
708
719
|
zIndex
|
|
709
720
|
}
|
|
710
721
|
),
|
|
711
|
-
isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChatWindow, { config:
|
|
722
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChatWindow, { config: mergedConfig })
|
|
712
723
|
] });
|
|
713
724
|
}
|
|
714
725
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/AIWidget.tsx
|
|
2
|
-
import { useEffect as useEffect3 } from "react";
|
|
2
|
+
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/store/chatStore.ts
|
|
5
5
|
import { create } from "zustand";
|
|
@@ -658,16 +658,27 @@ function ChatWindow({ config }) {
|
|
|
658
658
|
// src/AIWidget.tsx
|
|
659
659
|
import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
660
660
|
function AIWidget(props) {
|
|
661
|
-
var _a, _b, _c;
|
|
661
|
+
var _a, _b, _c, _d, _e, _f;
|
|
662
662
|
const { isOpen, setOpen } = useChatStore();
|
|
663
|
-
const
|
|
664
|
-
const
|
|
665
|
-
const zIndex = (_c = props.zIndex) != null ? _c : 9999;
|
|
663
|
+
const [serverConfig, setServerConfig] = useState3(null);
|
|
664
|
+
const baseUrl = ((_a = props.orchestratorUrl) != null ? _a : "https://app.kayro.com.ar").replace(/\/$/, "");
|
|
666
665
|
useEffect3(() => {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
}
|
|
666
|
+
fetch(`${baseUrl}/api/widget-config?apiKey=${encodeURIComponent(props.apiKey)}`).then((r) => r.ok ? r.json() : null).then((data) => {
|
|
667
|
+
if (data) setServerConfig(data);
|
|
668
|
+
}).catch(() => {
|
|
669
|
+
});
|
|
670
|
+
}, [props.apiKey, baseUrl]);
|
|
671
|
+
useEffect3(() => {
|
|
672
|
+
if (props.initialOpen) setOpen(true);
|
|
670
673
|
}, []);
|
|
674
|
+
const primaryColor = (_c = (_b = props.primaryColor) != null ? _b : serverConfig == null ? void 0 : serverConfig.primaryColor) != null ? _c : "#6366f1";
|
|
675
|
+
const position = (_d = props.position) != null ? _d : "bottom-right";
|
|
676
|
+
const zIndex = (_e = props.zIndex) != null ? _e : 9999;
|
|
677
|
+
const mergedConfig = {
|
|
678
|
+
...props,
|
|
679
|
+
primaryColor,
|
|
680
|
+
title: (_f = props.title) != null ? _f : serverConfig == null ? void 0 : serverConfig.assistantName
|
|
681
|
+
};
|
|
671
682
|
function handleBubbleClick() {
|
|
672
683
|
setOpen(!isOpen);
|
|
673
684
|
}
|
|
@@ -682,7 +693,7 @@ function AIWidget(props) {
|
|
|
682
693
|
zIndex
|
|
683
694
|
}
|
|
684
695
|
),
|
|
685
|
-
isOpen && /* @__PURE__ */ jsx7(ChatWindow, { config:
|
|
696
|
+
isOpen && /* @__PURE__ */ jsx7(ChatWindow, { config: mergedConfig })
|
|
686
697
|
] });
|
|
687
698
|
}
|
|
688
699
|
export {
|