@modelnex/sdk 0.5.30 → 0.5.31
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 +35 -3
- package/dist/index.mjs +35 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8878,9 +8878,40 @@ var TOUR_THEME = {
|
|
|
8878
8878
|
cardBorder: "var(--modelnex-tour-card-border, rgba(79, 70, 229, 0.12))",
|
|
8879
8879
|
actionBg: "var(--modelnex-tour-action-bg, #1e1b4b)"
|
|
8880
8880
|
};
|
|
8881
|
+
var DOCKED_DESKTOP_PANEL_HEIGHT_RATIO = 0.7;
|
|
8882
|
+
var UNDOCKED_DESKTOP_PANEL_HEIGHT_RATIO = 0.4;
|
|
8881
8883
|
function shouldIgnoreTourGestureStart(target) {
|
|
8882
8884
|
return target instanceof HTMLElement && Boolean(target.closest('[data-modelnex-review-toggle="true"]'));
|
|
8883
8885
|
}
|
|
8886
|
+
function getViewportHeight() {
|
|
8887
|
+
if (typeof window === "undefined") return 0;
|
|
8888
|
+
const layoutViewportHeight = window.innerHeight || document.documentElement?.clientHeight || 0;
|
|
8889
|
+
const visualViewportHeight = window.visualViewport?.height;
|
|
8890
|
+
if (typeof visualViewportHeight === "number" && Number.isFinite(visualViewportHeight) && visualViewportHeight > 0) {
|
|
8891
|
+
return Math.round(Math.min(layoutViewportHeight || visualViewportHeight, visualViewportHeight));
|
|
8892
|
+
}
|
|
8893
|
+
return layoutViewportHeight;
|
|
8894
|
+
}
|
|
8895
|
+
function useViewportHeight() {
|
|
8896
|
+
const [viewportHeight, setViewportHeight] = (0, import_react18.useState)(() => getViewportHeight());
|
|
8897
|
+
(0, import_react18.useEffect)(() => {
|
|
8898
|
+
if (typeof window === "undefined") return;
|
|
8899
|
+
const updateViewportHeight = () => {
|
|
8900
|
+
setViewportHeight(getViewportHeight());
|
|
8901
|
+
};
|
|
8902
|
+
updateViewportHeight();
|
|
8903
|
+
const visualViewport = window.visualViewport;
|
|
8904
|
+
window.addEventListener("resize", updateViewportHeight, { passive: true });
|
|
8905
|
+
visualViewport?.addEventListener("resize", updateViewportHeight);
|
|
8906
|
+
visualViewport?.addEventListener("scroll", updateViewportHeight);
|
|
8907
|
+
return () => {
|
|
8908
|
+
window.removeEventListener("resize", updateViewportHeight);
|
|
8909
|
+
visualViewport?.removeEventListener("resize", updateViewportHeight);
|
|
8910
|
+
visualViewport?.removeEventListener("scroll", updateViewportHeight);
|
|
8911
|
+
};
|
|
8912
|
+
}, []);
|
|
8913
|
+
return viewportHeight;
|
|
8914
|
+
}
|
|
8884
8915
|
function useMediaQuery(query) {
|
|
8885
8916
|
const [matches, setMatches] = (0, import_react18.useState)(false);
|
|
8886
8917
|
(0, import_react18.useEffect)(() => {
|
|
@@ -9776,6 +9807,7 @@ function ModelNexChatBubble({
|
|
|
9776
9807
|
e.stopPropagation();
|
|
9777
9808
|
};
|
|
9778
9809
|
const isMobile = useMediaQuery("(max-width: 640px)");
|
|
9810
|
+
const viewportHeight = useViewportHeight();
|
|
9779
9811
|
const themeStyles = (0, import_react18.useMemo)(() => {
|
|
9780
9812
|
if (!theme) return null;
|
|
9781
9813
|
const styles = {};
|
|
@@ -9805,13 +9837,13 @@ function ModelNexChatBubble({
|
|
|
9805
9837
|
fontFamily: "var(--modelnex-font)",
|
|
9806
9838
|
...themeStyles
|
|
9807
9839
|
};
|
|
9808
|
-
const
|
|
9809
|
-
const
|
|
9840
|
+
const desktopPanelHeightRatio = docked ? DOCKED_DESKTOP_PANEL_HEIGHT_RATIO : UNDOCKED_DESKTOP_PANEL_HEIGHT_RATIO;
|
|
9841
|
+
const desktopPanelHeight = viewportHeight > 0 ? `${Math.round(viewportHeight * desktopPanelHeightRatio)}px` : docked ? "70vh" : "40vh";
|
|
9810
9842
|
const panelStyle = {
|
|
9811
9843
|
width: isMobile ? "100%" : "var(--modelnex-panel-width, 380px)",
|
|
9812
9844
|
maxWidth: "calc(100vw - 32px)",
|
|
9813
9845
|
height: isMobile ? "100%" : desktopPanelHeight,
|
|
9814
|
-
maxHeight: isMobile ? "100%" :
|
|
9846
|
+
maxHeight: isMobile ? "100%" : desktopPanelHeight,
|
|
9815
9847
|
borderRadius: isMobile ? "0" : "var(--modelnex-radius-panel, 20px)",
|
|
9816
9848
|
border: isMobile ? "none" : "1px solid var(--modelnex-border, #e4e4e7)",
|
|
9817
9849
|
background: "var(--modelnex-bg, #ffffff)",
|
package/dist/index.mjs
CHANGED
|
@@ -8668,9 +8668,40 @@ var TOUR_THEME = {
|
|
|
8668
8668
|
cardBorder: "var(--modelnex-tour-card-border, rgba(79, 70, 229, 0.12))",
|
|
8669
8669
|
actionBg: "var(--modelnex-tour-action-bg, #1e1b4b)"
|
|
8670
8670
|
};
|
|
8671
|
+
var DOCKED_DESKTOP_PANEL_HEIGHT_RATIO = 0.7;
|
|
8672
|
+
var UNDOCKED_DESKTOP_PANEL_HEIGHT_RATIO = 0.4;
|
|
8671
8673
|
function shouldIgnoreTourGestureStart(target) {
|
|
8672
8674
|
return target instanceof HTMLElement && Boolean(target.closest('[data-modelnex-review-toggle="true"]'));
|
|
8673
8675
|
}
|
|
8676
|
+
function getViewportHeight() {
|
|
8677
|
+
if (typeof window === "undefined") return 0;
|
|
8678
|
+
const layoutViewportHeight = window.innerHeight || document.documentElement?.clientHeight || 0;
|
|
8679
|
+
const visualViewportHeight = window.visualViewport?.height;
|
|
8680
|
+
if (typeof visualViewportHeight === "number" && Number.isFinite(visualViewportHeight) && visualViewportHeight > 0) {
|
|
8681
|
+
return Math.round(Math.min(layoutViewportHeight || visualViewportHeight, visualViewportHeight));
|
|
8682
|
+
}
|
|
8683
|
+
return layoutViewportHeight;
|
|
8684
|
+
}
|
|
8685
|
+
function useViewportHeight() {
|
|
8686
|
+
const [viewportHeight, setViewportHeight] = useState13(() => getViewportHeight());
|
|
8687
|
+
useEffect17(() => {
|
|
8688
|
+
if (typeof window === "undefined") return;
|
|
8689
|
+
const updateViewportHeight = () => {
|
|
8690
|
+
setViewportHeight(getViewportHeight());
|
|
8691
|
+
};
|
|
8692
|
+
updateViewportHeight();
|
|
8693
|
+
const visualViewport = window.visualViewport;
|
|
8694
|
+
window.addEventListener("resize", updateViewportHeight, { passive: true });
|
|
8695
|
+
visualViewport?.addEventListener("resize", updateViewportHeight);
|
|
8696
|
+
visualViewport?.addEventListener("scroll", updateViewportHeight);
|
|
8697
|
+
return () => {
|
|
8698
|
+
window.removeEventListener("resize", updateViewportHeight);
|
|
8699
|
+
visualViewport?.removeEventListener("resize", updateViewportHeight);
|
|
8700
|
+
visualViewport?.removeEventListener("scroll", updateViewportHeight);
|
|
8701
|
+
};
|
|
8702
|
+
}, []);
|
|
8703
|
+
return viewportHeight;
|
|
8704
|
+
}
|
|
8674
8705
|
function useMediaQuery(query) {
|
|
8675
8706
|
const [matches, setMatches] = useState13(false);
|
|
8676
8707
|
useEffect17(() => {
|
|
@@ -9566,6 +9597,7 @@ function ModelNexChatBubble({
|
|
|
9566
9597
|
e.stopPropagation();
|
|
9567
9598
|
};
|
|
9568
9599
|
const isMobile = useMediaQuery("(max-width: 640px)");
|
|
9600
|
+
const viewportHeight = useViewportHeight();
|
|
9569
9601
|
const themeStyles = useMemo3(() => {
|
|
9570
9602
|
if (!theme) return null;
|
|
9571
9603
|
const styles = {};
|
|
@@ -9595,13 +9627,13 @@ function ModelNexChatBubble({
|
|
|
9595
9627
|
fontFamily: "var(--modelnex-font)",
|
|
9596
9628
|
...themeStyles
|
|
9597
9629
|
};
|
|
9598
|
-
const
|
|
9599
|
-
const
|
|
9630
|
+
const desktopPanelHeightRatio = docked ? DOCKED_DESKTOP_PANEL_HEIGHT_RATIO : UNDOCKED_DESKTOP_PANEL_HEIGHT_RATIO;
|
|
9631
|
+
const desktopPanelHeight = viewportHeight > 0 ? `${Math.round(viewportHeight * desktopPanelHeightRatio)}px` : docked ? "70vh" : "40vh";
|
|
9600
9632
|
const panelStyle = {
|
|
9601
9633
|
width: isMobile ? "100%" : "var(--modelnex-panel-width, 380px)",
|
|
9602
9634
|
maxWidth: "calc(100vw - 32px)",
|
|
9603
9635
|
height: isMobile ? "100%" : desktopPanelHeight,
|
|
9604
|
-
maxHeight: isMobile ? "100%" :
|
|
9636
|
+
maxHeight: isMobile ? "100%" : desktopPanelHeight,
|
|
9605
9637
|
borderRadius: isMobile ? "0" : "var(--modelnex-radius-panel, 20px)",
|
|
9606
9638
|
border: isMobile ? "none" : "1px solid var(--modelnex-border, #e4e4e7)",
|
|
9607
9639
|
background: "var(--modelnex-bg, #ffffff)",
|