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/index.mjs CHANGED
@@ -35,7 +35,7 @@ import {
35
35
  sendMessageStream,
36
36
  useSendMessage,
37
37
  useSendMessageStream
38
- } from "./chunk-RGS6AZWV.mjs";
38
+ } from "./chunk-R73LRYVJ.mjs";
39
39
 
40
40
  // src/http/HttpClient.ts
41
41
  var HttpClient = class {
@@ -1,4 +1,4 @@
1
- export { an as FloatingChatBox, ao as FloatingChatBoxProps, aj as LayerSnapshot, ar as LayerStyle, am as ZenitFeatureFilterPanel, al as ZenitLayerManager, ah as ZenitMap, ak as ZenitMapProps, ai as ZenitMapRef, aw as ZoomOpacityOptions, ax as clampNumber, ay as clampOpacity, av as getAccentByLayerId, aC as getEffectiveLayerOpacity, at as getLayerColor, aB as getLayerZoomOpacityFactor, au as getStyleByLayerId, aA as getZoomOpacityFactor, az as isPolygonLayer, as as resolveLayerAccent, ap as useSendMessage, aq as useSendMessageStream } from '../index-C_2fk0Fk.mjs';
1
+ export { an as FloatingChatBox, ao as FloatingChatBoxProps, aj as LayerSnapshot, ar as LayerStyle, am as ZenitFeatureFilterPanel, al as ZenitLayerManager, ah as ZenitMap, ak as ZenitMapProps, ai as ZenitMapRef, aw as ZoomOpacityOptions, ax as clampNumber, ay as clampOpacity, av as getAccentByLayerId, aC as getEffectiveLayerOpacity, at as getLayerColor, aB as getLayerZoomOpacityFactor, au as getStyleByLayerId, aA as getZoomOpacityFactor, az as isPolygonLayer, as as resolveLayerAccent, ap as useSendMessage, aq as useSendMessageStream } from '../index-Da0hFqDL.mjs';
2
2
  export { ChevronLeft, ChevronRight, Eye, EyeOff, Layers, Upload, X, ZoomIn } from 'lucide-react';
3
3
  import 'react';
4
4
  import 'leaflet';
@@ -1,4 +1,4 @@
1
- export { an as FloatingChatBox, ao as FloatingChatBoxProps, aj as LayerSnapshot, ar as LayerStyle, am as ZenitFeatureFilterPanel, al as ZenitLayerManager, ah as ZenitMap, ak as ZenitMapProps, ai as ZenitMapRef, aw as ZoomOpacityOptions, ax as clampNumber, ay as clampOpacity, av as getAccentByLayerId, aC as getEffectiveLayerOpacity, at as getLayerColor, aB as getLayerZoomOpacityFactor, au as getStyleByLayerId, aA as getZoomOpacityFactor, az as isPolygonLayer, as as resolveLayerAccent, ap as useSendMessage, aq as useSendMessageStream } from '../index-C_2fk0Fk.js';
1
+ export { an as FloatingChatBox, ao as FloatingChatBoxProps, aj as LayerSnapshot, ar as LayerStyle, am as ZenitFeatureFilterPanel, al as ZenitLayerManager, ah as ZenitMap, ak as ZenitMapProps, ai as ZenitMapRef, aw as ZoomOpacityOptions, ax as clampNumber, ay as clampOpacity, av as getAccentByLayerId, aC as getEffectiveLayerOpacity, at as getLayerColor, aB as getLayerZoomOpacityFactor, au as getStyleByLayerId, aA as getZoomOpacityFactor, az as isPolygonLayer, as as resolveLayerAccent, ap as useSendMessage, aq as useSendMessageStream } from '../index-Da0hFqDL.js';
2
2
  export { ChevronLeft, ChevronRight, Eye, EyeOff, Layers, Upload, X, ZoomIn } from 'lucide-react';
3
3
  import 'react';
4
4
  import 'leaflet';
@@ -2330,6 +2330,11 @@ var styles = {
2330
2330
  height: 56,
2331
2331
  padding: 0
2332
2332
  },
2333
+ floatingButtonMobile: {
2334
+ width: 56,
2335
+ height: 56,
2336
+ padding: 0
2337
+ },
2333
2338
  // Panel (expandable)
2334
2339
  panel: {
2335
2340
  position: "fixed",
@@ -2579,7 +2584,9 @@ var FloatingChatBox = ({
2579
2584
  baseUrl,
2580
2585
  accessToken,
2581
2586
  getAccessToken,
2582
- onActionClick
2587
+ onActionClick,
2588
+ onOpenChange,
2589
+ hideButton
2583
2590
  }) => {
2584
2591
  const [open, setOpen] = (0, import_react4.useState)(false);
2585
2592
  const [expanded, setExpanded] = (0, import_react4.useState)(false);
@@ -2598,6 +2605,14 @@ var FloatingChatBox = ({
2598
2605
  }, [accessToken, baseUrl, getAccessToken]);
2599
2606
  const { sendMessage: sendMessage2, isStreaming, streamingText, completeResponse } = useSendMessageStream(chatConfig);
2600
2607
  const canSend = Boolean(mapId) && Boolean(baseUrl) && inputValue.trim().length > 0 && !isStreaming;
2608
+ (0, import_react4.useEffect)(() => {
2609
+ onOpenChange?.(open);
2610
+ }, [open, onOpenChange]);
2611
+ (0, import_react4.useEffect)(() => {
2612
+ if (open && isMobile) {
2613
+ setExpanded(true);
2614
+ }
2615
+ }, [open, isMobile]);
2601
2616
  const scrollToBottom = (0, import_react4.useCallback)(() => {
2602
2617
  if (messagesEndRef.current) {
2603
2618
  messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
@@ -2619,8 +2634,9 @@ var FloatingChatBox = ({
2619
2634
  }, [messages, streamingText, scrollToBottom]);
2620
2635
  (0, import_react4.useEffect)(() => {
2621
2636
  if (!open) return;
2637
+ if (isMobile && expanded) return;
2622
2638
  const handleClickOutside = (event) => {
2623
- if (open && chatBoxRef.current && !chatBoxRef.current.contains(event.target)) {
2639
+ if (chatBoxRef.current && !chatBoxRef.current.contains(event.target)) {
2624
2640
  setOpen(false);
2625
2641
  }
2626
2642
  };
@@ -2628,7 +2644,7 @@ var FloatingChatBox = ({
2628
2644
  return () => {
2629
2645
  document.removeEventListener("mousedown", handleClickOutside);
2630
2646
  };
2631
- }, [open]);
2647
+ }, [open, isMobile, expanded]);
2632
2648
  (0, import_react4.useEffect)(() => {
2633
2649
  if (typeof window === "undefined") return;
2634
2650
  const mediaQuery = window.matchMedia("(max-width: 768px)");
@@ -2648,31 +2664,13 @@ var FloatingChatBox = ({
2648
2664
  };
2649
2665
  }, []);
2650
2666
  (0, import_react4.useEffect)(() => {
2651
- if (typeof window === "undefined" || typeof document === "undefined") return;
2652
- const mediaQuery = window.matchMedia("(max-width: 768px)");
2653
- const originalOverflow = document.body.style.overflow;
2654
- const updateOverflow = () => {
2655
- if (open && expanded && mediaQuery.matches) {
2656
- document.body.style.overflow = "hidden";
2657
- } else {
2658
- document.body.style.overflow = originalOverflow;
2659
- }
2660
- };
2661
- updateOverflow();
2662
- if (mediaQuery.addEventListener) {
2663
- mediaQuery.addEventListener("change", updateOverflow);
2664
- } else {
2665
- mediaQuery.addListener(updateOverflow);
2666
- }
2667
+ if (typeof document === "undefined") return;
2668
+ if (!open || !isMobile) return;
2669
+ document.body.style.overflow = "hidden";
2667
2670
  return () => {
2668
- if (mediaQuery.removeEventListener) {
2669
- mediaQuery.removeEventListener("change", updateOverflow);
2670
- } else {
2671
- mediaQuery.removeListener(updateOverflow);
2672
- }
2673
- document.body.style.overflow = originalOverflow;
2671
+ document.body.style.overflow = "";
2674
2672
  };
2675
- }, [open, expanded]);
2673
+ }, [open, isMobile]);
2676
2674
  const addMessage = (0, import_react4.useCallback)((message) => {
2677
2675
  setMessages((prev) => [...prev, message]);
2678
2676
  }, []);
@@ -2881,13 +2879,18 @@ var FloatingChatBox = ({
2881
2879
  display: flex !important;
2882
2880
  flex-direction: column !important;
2883
2881
  overflow: hidden !important;
2884
- z-index: 3000 !important;
2882
+ z-index: 100000 !important;
2885
2883
  padding-top: env(safe-area-inset-top);
2886
- padding-bottom: env(safe-area-inset-bottom);
2887
2884
  }
2888
2885
  .zenit-chat-panel.zenit-chat-panel--fullscreen .zenit-ai-body {
2889
2886
  flex: 1;
2890
- overflow: auto;
2887
+ min-height: 0;
2888
+ overflow-y: auto;
2889
+ -webkit-overflow-scrolling: touch;
2890
+ }
2891
+ .zenit-chat-panel.zenit-chat-panel--fullscreen .zenit-ai-input-area {
2892
+ flex-shrink: 0;
2893
+ padding-bottom: max(14px, env(safe-area-inset-bottom));
2891
2894
  }
2892
2895
  .zenit-ai-button.zenit-ai-button--hidden-mobile {
2893
2896
  display: none !important;
@@ -2898,7 +2901,7 @@ var FloatingChatBox = ({
2898
2901
  "div",
2899
2902
  {
2900
2903
  ref: chatBoxRef,
2901
- className: `zenit-chat-panel${expanded ? " zenit-chat-panel--expanded" : ""}${expanded && isMobile ? " zenit-chat-panel--fullscreen" : ""}`,
2904
+ className: `zenit-chat-panel${expanded ? " zenit-chat-panel--expanded" : ""}${isMobile ? " zenit-chat-panel--fullscreen" : ""}`,
2902
2905
  style: {
2903
2906
  ...styles.panel,
2904
2907
  ...expanded ? styles.panelExpanded : styles.panelNormal
@@ -2998,7 +3001,7 @@ var FloatingChatBox = ({
2998
3001
  ),
2999
3002
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: messagesEndRef })
3000
3003
  ] }),
3001
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: styles.inputWrapper, children: [
3004
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "zenit-ai-input-area", style: styles.inputWrapper, children: [
3002
3005
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3003
3006
  "textarea",
3004
3007
  {
@@ -3035,20 +3038,20 @@ var FloatingChatBox = ({
3035
3038
  ]
3036
3039
  }
3037
3040
  ),
3038
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3041
+ !(hideButton && !open) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3039
3042
  "button",
3040
3043
  {
3041
3044
  type: "button",
3042
- className: `zenit-ai-button ${open ? "open" : ""}${open && expanded && isMobile ? " zenit-ai-button--hidden-mobile" : ""}`,
3045
+ className: `zenit-ai-button ${open ? "open" : ""}${open && isMobile ? " zenit-ai-button--hidden-mobile" : ""}`,
3043
3046
  style: {
3044
3047
  ...styles.floatingButton,
3045
- ...open ? styles.floatingButtonOpen : styles.floatingButtonClosed
3048
+ ...open ? styles.floatingButtonOpen : isMobile ? styles.floatingButtonMobile : styles.floatingButtonClosed
3046
3049
  },
3047
3050
  onClick: () => setOpen((prev) => !prev),
3048
3051
  "aria-label": open ? "Cerrar asistente" : "Abrir asistente Zenit AI",
3049
3052
  children: open ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CloseIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
3050
3053
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChatIcon, {}),
3051
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Asistente IA" })
3054
+ !isMobile && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Asistente IA" })
3052
3055
  ] })
3053
3056
  }
3054
3057
  )