zenit-sdk 0.0.1 → 0.0.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/{chunk-RGS6AZWV.mjs → chunk-R73LRYVJ.mjs} +39 -36
- package/dist/chunk-R73LRYVJ.mjs.map +1 -0
- package/dist/{index-C_2fk0Fk.d.mts → index-Da0hFqDL.d.mts} +4 -0
- package/dist/{index-C_2fk0Fk.d.ts → index-Da0hFqDL.d.ts} +4 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +38 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react/index.d.mts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +38 -35
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +1 -1
- package/package.json +27 -7
- package/dist/chunk-RGS6AZWV.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -3374,6 +3374,11 @@ var styles = {
|
|
|
3374
3374
|
height: 56,
|
|
3375
3375
|
padding: 0
|
|
3376
3376
|
},
|
|
3377
|
+
floatingButtonMobile: {
|
|
3378
|
+
width: 56,
|
|
3379
|
+
height: 56,
|
|
3380
|
+
padding: 0
|
|
3381
|
+
},
|
|
3377
3382
|
// Panel (expandable)
|
|
3378
3383
|
panel: {
|
|
3379
3384
|
position: "fixed",
|
|
@@ -3623,7 +3628,9 @@ var FloatingChatBox = ({
|
|
|
3623
3628
|
baseUrl,
|
|
3624
3629
|
accessToken,
|
|
3625
3630
|
getAccessToken,
|
|
3626
|
-
onActionClick
|
|
3631
|
+
onActionClick,
|
|
3632
|
+
onOpenChange,
|
|
3633
|
+
hideButton
|
|
3627
3634
|
}) => {
|
|
3628
3635
|
const [open, setOpen] = (0, import_react4.useState)(false);
|
|
3629
3636
|
const [expanded, setExpanded] = (0, import_react4.useState)(false);
|
|
@@ -3642,6 +3649,14 @@ var FloatingChatBox = ({
|
|
|
3642
3649
|
}, [accessToken, baseUrl, getAccessToken]);
|
|
3643
3650
|
const { sendMessage: sendMessage2, isStreaming, streamingText, completeResponse } = useSendMessageStream(chatConfig);
|
|
3644
3651
|
const canSend = Boolean(mapId) && Boolean(baseUrl) && inputValue.trim().length > 0 && !isStreaming;
|
|
3652
|
+
(0, import_react4.useEffect)(() => {
|
|
3653
|
+
onOpenChange?.(open);
|
|
3654
|
+
}, [open, onOpenChange]);
|
|
3655
|
+
(0, import_react4.useEffect)(() => {
|
|
3656
|
+
if (open && isMobile) {
|
|
3657
|
+
setExpanded(true);
|
|
3658
|
+
}
|
|
3659
|
+
}, [open, isMobile]);
|
|
3645
3660
|
const scrollToBottom = (0, import_react4.useCallback)(() => {
|
|
3646
3661
|
if (messagesEndRef.current) {
|
|
3647
3662
|
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
|
|
@@ -3663,8 +3678,9 @@ var FloatingChatBox = ({
|
|
|
3663
3678
|
}, [messages, streamingText, scrollToBottom]);
|
|
3664
3679
|
(0, import_react4.useEffect)(() => {
|
|
3665
3680
|
if (!open) return;
|
|
3681
|
+
if (isMobile && expanded) return;
|
|
3666
3682
|
const handleClickOutside = (event) => {
|
|
3667
|
-
if (
|
|
3683
|
+
if (chatBoxRef.current && !chatBoxRef.current.contains(event.target)) {
|
|
3668
3684
|
setOpen(false);
|
|
3669
3685
|
}
|
|
3670
3686
|
};
|
|
@@ -3672,7 +3688,7 @@ var FloatingChatBox = ({
|
|
|
3672
3688
|
return () => {
|
|
3673
3689
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
3674
3690
|
};
|
|
3675
|
-
}, [open]);
|
|
3691
|
+
}, [open, isMobile, expanded]);
|
|
3676
3692
|
(0, import_react4.useEffect)(() => {
|
|
3677
3693
|
if (typeof window === "undefined") return;
|
|
3678
3694
|
const mediaQuery = window.matchMedia("(max-width: 768px)");
|
|
@@ -3692,31 +3708,13 @@ var FloatingChatBox = ({
|
|
|
3692
3708
|
};
|
|
3693
3709
|
}, []);
|
|
3694
3710
|
(0, import_react4.useEffect)(() => {
|
|
3695
|
-
if (typeof
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
const updateOverflow = () => {
|
|
3699
|
-
if (open && expanded && mediaQuery.matches) {
|
|
3700
|
-
document.body.style.overflow = "hidden";
|
|
3701
|
-
} else {
|
|
3702
|
-
document.body.style.overflow = originalOverflow;
|
|
3703
|
-
}
|
|
3704
|
-
};
|
|
3705
|
-
updateOverflow();
|
|
3706
|
-
if (mediaQuery.addEventListener) {
|
|
3707
|
-
mediaQuery.addEventListener("change", updateOverflow);
|
|
3708
|
-
} else {
|
|
3709
|
-
mediaQuery.addListener(updateOverflow);
|
|
3710
|
-
}
|
|
3711
|
+
if (typeof document === "undefined") return;
|
|
3712
|
+
if (!open || !isMobile) return;
|
|
3713
|
+
document.body.style.overflow = "hidden";
|
|
3711
3714
|
return () => {
|
|
3712
|
-
|
|
3713
|
-
mediaQuery.removeEventListener("change", updateOverflow);
|
|
3714
|
-
} else {
|
|
3715
|
-
mediaQuery.removeListener(updateOverflow);
|
|
3716
|
-
}
|
|
3717
|
-
document.body.style.overflow = originalOverflow;
|
|
3715
|
+
document.body.style.overflow = "";
|
|
3718
3716
|
};
|
|
3719
|
-
}, [open,
|
|
3717
|
+
}, [open, isMobile]);
|
|
3720
3718
|
const addMessage = (0, import_react4.useCallback)((message) => {
|
|
3721
3719
|
setMessages((prev) => [...prev, message]);
|
|
3722
3720
|
}, []);
|
|
@@ -3925,13 +3923,18 @@ var FloatingChatBox = ({
|
|
|
3925
3923
|
display: flex !important;
|
|
3926
3924
|
flex-direction: column !important;
|
|
3927
3925
|
overflow: hidden !important;
|
|
3928
|
-
z-index:
|
|
3926
|
+
z-index: 100000 !important;
|
|
3929
3927
|
padding-top: env(safe-area-inset-top);
|
|
3930
|
-
padding-bottom: env(safe-area-inset-bottom);
|
|
3931
3928
|
}
|
|
3932
3929
|
.zenit-chat-panel.zenit-chat-panel--fullscreen .zenit-ai-body {
|
|
3933
3930
|
flex: 1;
|
|
3934
|
-
|
|
3931
|
+
min-height: 0;
|
|
3932
|
+
overflow-y: auto;
|
|
3933
|
+
-webkit-overflow-scrolling: touch;
|
|
3934
|
+
}
|
|
3935
|
+
.zenit-chat-panel.zenit-chat-panel--fullscreen .zenit-ai-input-area {
|
|
3936
|
+
flex-shrink: 0;
|
|
3937
|
+
padding-bottom: max(14px, env(safe-area-inset-bottom));
|
|
3935
3938
|
}
|
|
3936
3939
|
.zenit-ai-button.zenit-ai-button--hidden-mobile {
|
|
3937
3940
|
display: none !important;
|
|
@@ -3942,7 +3945,7 @@ var FloatingChatBox = ({
|
|
|
3942
3945
|
"div",
|
|
3943
3946
|
{
|
|
3944
3947
|
ref: chatBoxRef,
|
|
3945
|
-
className: `zenit-chat-panel${expanded ? " zenit-chat-panel--expanded" : ""}${
|
|
3948
|
+
className: `zenit-chat-panel${expanded ? " zenit-chat-panel--expanded" : ""}${isMobile ? " zenit-chat-panel--fullscreen" : ""}`,
|
|
3946
3949
|
style: {
|
|
3947
3950
|
...styles.panel,
|
|
3948
3951
|
...expanded ? styles.panelExpanded : styles.panelNormal
|
|
@@ -4042,7 +4045,7 @@ var FloatingChatBox = ({
|
|
|
4042
4045
|
),
|
|
4043
4046
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: messagesEndRef })
|
|
4044
4047
|
] }),
|
|
4045
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: styles.inputWrapper, children: [
|
|
4048
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "zenit-ai-input-area", style: styles.inputWrapper, children: [
|
|
4046
4049
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4047
4050
|
"textarea",
|
|
4048
4051
|
{
|
|
@@ -4079,20 +4082,20 @@ var FloatingChatBox = ({
|
|
|
4079
4082
|
]
|
|
4080
4083
|
}
|
|
4081
4084
|
),
|
|
4082
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4085
|
+
!(hideButton && !open) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4083
4086
|
"button",
|
|
4084
4087
|
{
|
|
4085
4088
|
type: "button",
|
|
4086
|
-
className: `zenit-ai-button ${open ? "open" : ""}${open &&
|
|
4089
|
+
className: `zenit-ai-button ${open ? "open" : ""}${open && isMobile ? " zenit-ai-button--hidden-mobile" : ""}`,
|
|
4087
4090
|
style: {
|
|
4088
4091
|
...styles.floatingButton,
|
|
4089
|
-
...open ? styles.floatingButtonOpen : styles.floatingButtonClosed
|
|
4092
|
+
...open ? styles.floatingButtonOpen : isMobile ? styles.floatingButtonMobile : styles.floatingButtonClosed
|
|
4090
4093
|
},
|
|
4091
4094
|
onClick: () => setOpen((prev) => !prev),
|
|
4092
4095
|
"aria-label": open ? "Cerrar asistente" : "Abrir asistente Zenit AI",
|
|
4093
4096
|
children: open ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CloseIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
4094
4097
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChatIcon, {}),
|
|
4095
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Asistente IA" })
|
|
4098
|
+
!isMobile && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Asistente IA" })
|
|
4096
4099
|
] })
|
|
4097
4100
|
}
|
|
4098
4101
|
)
|