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.
@@ -2287,6 +2287,11 @@ var styles = {
2287
2287
  height: 56,
2288
2288
  padding: 0
2289
2289
  },
2290
+ floatingButtonMobile: {
2291
+ width: 56,
2292
+ height: 56,
2293
+ padding: 0
2294
+ },
2290
2295
  // Panel (expandable)
2291
2296
  panel: {
2292
2297
  position: "fixed",
@@ -2536,7 +2541,9 @@ var FloatingChatBox = ({
2536
2541
  baseUrl,
2537
2542
  accessToken,
2538
2543
  getAccessToken,
2539
- onActionClick
2544
+ onActionClick,
2545
+ onOpenChange,
2546
+ hideButton
2540
2547
  }) => {
2541
2548
  const [open, setOpen] = useState4(false);
2542
2549
  const [expanded, setExpanded] = useState4(false);
@@ -2555,6 +2562,14 @@ var FloatingChatBox = ({
2555
2562
  }, [accessToken, baseUrl, getAccessToken]);
2556
2563
  const { sendMessage: sendMessage2, isStreaming, streamingText, completeResponse } = useSendMessageStream(chatConfig);
2557
2564
  const canSend = Boolean(mapId) && Boolean(baseUrl) && inputValue.trim().length > 0 && !isStreaming;
2565
+ useEffect3(() => {
2566
+ onOpenChange?.(open);
2567
+ }, [open, onOpenChange]);
2568
+ useEffect3(() => {
2569
+ if (open && isMobile) {
2570
+ setExpanded(true);
2571
+ }
2572
+ }, [open, isMobile]);
2558
2573
  const scrollToBottom = useCallback3(() => {
2559
2574
  if (messagesEndRef.current) {
2560
2575
  messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
@@ -2576,8 +2591,9 @@ var FloatingChatBox = ({
2576
2591
  }, [messages, streamingText, scrollToBottom]);
2577
2592
  useEffect3(() => {
2578
2593
  if (!open) return;
2594
+ if (isMobile && expanded) return;
2579
2595
  const handleClickOutside = (event) => {
2580
- if (open && chatBoxRef.current && !chatBoxRef.current.contains(event.target)) {
2596
+ if (chatBoxRef.current && !chatBoxRef.current.contains(event.target)) {
2581
2597
  setOpen(false);
2582
2598
  }
2583
2599
  };
@@ -2585,7 +2601,7 @@ var FloatingChatBox = ({
2585
2601
  return () => {
2586
2602
  document.removeEventListener("mousedown", handleClickOutside);
2587
2603
  };
2588
- }, [open]);
2604
+ }, [open, isMobile, expanded]);
2589
2605
  useEffect3(() => {
2590
2606
  if (typeof window === "undefined") return;
2591
2607
  const mediaQuery = window.matchMedia("(max-width: 768px)");
@@ -2605,31 +2621,13 @@ var FloatingChatBox = ({
2605
2621
  };
2606
2622
  }, []);
2607
2623
  useEffect3(() => {
2608
- if (typeof window === "undefined" || typeof document === "undefined") return;
2609
- const mediaQuery = window.matchMedia("(max-width: 768px)");
2610
- const originalOverflow = document.body.style.overflow;
2611
- const updateOverflow = () => {
2612
- if (open && expanded && mediaQuery.matches) {
2613
- document.body.style.overflow = "hidden";
2614
- } else {
2615
- document.body.style.overflow = originalOverflow;
2616
- }
2617
- };
2618
- updateOverflow();
2619
- if (mediaQuery.addEventListener) {
2620
- mediaQuery.addEventListener("change", updateOverflow);
2621
- } else {
2622
- mediaQuery.addListener(updateOverflow);
2623
- }
2624
+ if (typeof document === "undefined") return;
2625
+ if (!open || !isMobile) return;
2626
+ document.body.style.overflow = "hidden";
2624
2627
  return () => {
2625
- if (mediaQuery.removeEventListener) {
2626
- mediaQuery.removeEventListener("change", updateOverflow);
2627
- } else {
2628
- mediaQuery.removeListener(updateOverflow);
2629
- }
2630
- document.body.style.overflow = originalOverflow;
2628
+ document.body.style.overflow = "";
2631
2629
  };
2632
- }, [open, expanded]);
2630
+ }, [open, isMobile]);
2633
2631
  const addMessage = useCallback3((message) => {
2634
2632
  setMessages((prev) => [...prev, message]);
2635
2633
  }, []);
@@ -2838,13 +2836,18 @@ var FloatingChatBox = ({
2838
2836
  display: flex !important;
2839
2837
  flex-direction: column !important;
2840
2838
  overflow: hidden !important;
2841
- z-index: 3000 !important;
2839
+ z-index: 100000 !important;
2842
2840
  padding-top: env(safe-area-inset-top);
2843
- padding-bottom: env(safe-area-inset-bottom);
2844
2841
  }
2845
2842
  .zenit-chat-panel.zenit-chat-panel--fullscreen .zenit-ai-body {
2846
2843
  flex: 1;
2847
- overflow: auto;
2844
+ min-height: 0;
2845
+ overflow-y: auto;
2846
+ -webkit-overflow-scrolling: touch;
2847
+ }
2848
+ .zenit-chat-panel.zenit-chat-panel--fullscreen .zenit-ai-input-area {
2849
+ flex-shrink: 0;
2850
+ padding-bottom: max(14px, env(safe-area-inset-bottom));
2848
2851
  }
2849
2852
  .zenit-ai-button.zenit-ai-button--hidden-mobile {
2850
2853
  display: none !important;
@@ -2855,7 +2858,7 @@ var FloatingChatBox = ({
2855
2858
  "div",
2856
2859
  {
2857
2860
  ref: chatBoxRef,
2858
- className: `zenit-chat-panel${expanded ? " zenit-chat-panel--expanded" : ""}${expanded && isMobile ? " zenit-chat-panel--fullscreen" : ""}`,
2861
+ className: `zenit-chat-panel${expanded ? " zenit-chat-panel--expanded" : ""}${isMobile ? " zenit-chat-panel--fullscreen" : ""}`,
2859
2862
  style: {
2860
2863
  ...styles.panel,
2861
2864
  ...expanded ? styles.panelExpanded : styles.panelNormal
@@ -2955,7 +2958,7 @@ var FloatingChatBox = ({
2955
2958
  ),
2956
2959
  /* @__PURE__ */ jsx5("div", { ref: messagesEndRef })
2957
2960
  ] }),
2958
- /* @__PURE__ */ jsxs4("div", { style: styles.inputWrapper, children: [
2961
+ /* @__PURE__ */ jsxs4("div", { className: "zenit-ai-input-area", style: styles.inputWrapper, children: [
2959
2962
  /* @__PURE__ */ jsx5(
2960
2963
  "textarea",
2961
2964
  {
@@ -2992,20 +2995,20 @@ var FloatingChatBox = ({
2992
2995
  ]
2993
2996
  }
2994
2997
  ),
2995
- /* @__PURE__ */ jsx5(
2998
+ !(hideButton && !open) && /* @__PURE__ */ jsx5(
2996
2999
  "button",
2997
3000
  {
2998
3001
  type: "button",
2999
- className: `zenit-ai-button ${open ? "open" : ""}${open && expanded && isMobile ? " zenit-ai-button--hidden-mobile" : ""}`,
3002
+ className: `zenit-ai-button ${open ? "open" : ""}${open && isMobile ? " zenit-ai-button--hidden-mobile" : ""}`,
3000
3003
  style: {
3001
3004
  ...styles.floatingButton,
3002
- ...open ? styles.floatingButtonOpen : styles.floatingButtonClosed
3005
+ ...open ? styles.floatingButtonOpen : isMobile ? styles.floatingButtonMobile : styles.floatingButtonClosed
3003
3006
  },
3004
3007
  onClick: () => setOpen((prev) => !prev),
3005
3008
  "aria-label": open ? "Cerrar asistente" : "Abrir asistente Zenit AI",
3006
3009
  children: open ? /* @__PURE__ */ jsx5(CloseIcon, {}) : /* @__PURE__ */ jsxs4(Fragment, { children: [
3007
3010
  /* @__PURE__ */ jsx5(ChatIcon, {}),
3008
- /* @__PURE__ */ jsx5("span", { children: "Asistente IA" })
3011
+ !isMobile && /* @__PURE__ */ jsx5("span", { children: "Asistente IA" })
3009
3012
  ] })
3010
3013
  }
3011
3014
  )
@@ -3054,4 +3057,4 @@ export {
3054
3057
  useSendMessageStream,
3055
3058
  FloatingChatBox
3056
3059
  };
3057
- //# sourceMappingURL=chunk-RGS6AZWV.mjs.map
3060
+ //# sourceMappingURL=chunk-R73LRYVJ.mjs.map