@windrun-huaiin/third-ui 5.14.0 → 5.14.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.
@@ -2787,19 +2787,22 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
2787
2787
  }, [chart, id, resolvedTheme, watermarkEnabled, watermarkText]);
2788
2788
  const clamp = (v, min, max) => Math.min(Math.max(v, min), max);
2789
2789
  const resetTransform = (0, import_react35.useCallback)(() => {
2790
- setScale(1);
2790
+ setScale(4);
2791
2791
  setTranslate({ x: 0, y: 0 });
2792
2792
  }, []);
2793
2793
  const zoomBy = (0, import_react35.useCallback)((delta) => {
2794
- setScale((prev) => clamp(prev + delta, 0.25, 6));
2794
+ setScale((prev) => clamp(prev + delta, 0.25, 10));
2795
2795
  }, []);
2796
2796
  const onWheel = (0, import_react35.useCallback)((e) => {
2797
2797
  if (e.metaKey || e.ctrlKey) {
2798
2798
  e.preventDefault();
2799
+ e.stopPropagation();
2799
2800
  const delta = e.deltaY > 0 ? -0.1 : 0.1;
2800
- setScale((prev) => clamp(prev + delta, 0.25, 6));
2801
+ setScale((prev) => clamp(prev + delta, 0.25, 10));
2801
2802
  } else {
2802
- setTranslate((prev) => ({ x: prev.x, y: prev.y - e.deltaY }));
2803
+ e.preventDefault();
2804
+ e.stopPropagation();
2805
+ setTranslate((prev) => ({ x: prev.x - e.deltaX, y: prev.y - e.deltaY }));
2803
2806
  }
2804
2807
  }, []);
2805
2808
  const onPointerDown = (0, import_react35.useCallback)((e) => {
@@ -2818,6 +2821,57 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
2818
2821
  isPanningRef.current = false;
2819
2822
  e.currentTarget.releasePointerCapture(e.pointerId);
2820
2823
  }, []);
2824
+ (0, import_react35.useEffect)(() => {
2825
+ if (!open) return;
2826
+ resetTransform();
2827
+ const onGlobalWheel = (ev) => {
2828
+ if (ev.ctrlKey || ev.metaKey) {
2829
+ ev.preventDefault();
2830
+ }
2831
+ };
2832
+ const onKeyDown = (ev) => {
2833
+ if (!(ev.ctrlKey || ev.metaKey)) return;
2834
+ const k = ev.key;
2835
+ if (k === "=" || k === "+") {
2836
+ ev.preventDefault();
2837
+ setScale((prev) => clamp(prev + 0.2, 0.25, 10));
2838
+ } else if (k === "-") {
2839
+ ev.preventDefault();
2840
+ setScale((prev) => clamp(prev - 0.2, 0.25, 10));
2841
+ } else if (k === "0") {
2842
+ ev.preventDefault();
2843
+ resetTransform();
2844
+ }
2845
+ };
2846
+ window.addEventListener("wheel", onGlobalWheel, { passive: false, capture: true });
2847
+ window.addEventListener("keydown", onKeyDown, { capture: true });
2848
+ return () => {
2849
+ window.removeEventListener("wheel", onGlobalWheel, true);
2850
+ window.removeEventListener("keydown", onKeyDown, true);
2851
+ };
2852
+ }, [open, resetTransform]);
2853
+ (0, import_react35.useEffect)(() => {
2854
+ if (!open) return;
2855
+ const previousPosition = document.body.style.position;
2856
+ const previousTop = document.body.style.top;
2857
+ const previousLeft = document.body.style.left;
2858
+ const previousRight = document.body.style.right;
2859
+ const previousWidth = document.body.style.width;
2860
+ const scrollY = window.scrollY;
2861
+ document.body.style.position = "fixed";
2862
+ document.body.style.top = `-${scrollY}px`;
2863
+ document.body.style.left = "0";
2864
+ document.body.style.right = "0";
2865
+ document.body.style.width = "100%";
2866
+ return () => {
2867
+ document.body.style.position = previousPosition;
2868
+ document.body.style.top = previousTop;
2869
+ document.body.style.left = previousLeft;
2870
+ document.body.style.right = previousRight;
2871
+ document.body.style.width = previousWidth;
2872
+ window.scrollTo(0, scrollY);
2873
+ };
2874
+ }, [open]);
2821
2875
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { children: [
2822
2876
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
2823
2877
  "div",
@@ -2848,10 +2902,24 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
2848
2902
  "aria-label": typeof title === "string" ? title : "Mermaid Preview",
2849
2903
  className: "fixed inset-0 z-[9999] flex items-center justify-center",
2850
2904
  children: [
2851
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "absolute inset-0 bg-black/60", onClick: () => {
2852
- setOpen(false);
2853
- resetTransform();
2854
- } }),
2905
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2906
+ "div",
2907
+ {
2908
+ className: "absolute inset-0 bg-black/60",
2909
+ onClick: () => {
2910
+ setOpen(false);
2911
+ resetTransform();
2912
+ },
2913
+ onWheel: (e) => {
2914
+ e.preventDefault();
2915
+ e.stopPropagation();
2916
+ },
2917
+ onTouchMove: (e) => {
2918
+ e.preventDefault();
2919
+ e.stopPropagation();
2920
+ }
2921
+ }
2922
+ ),
2855
2923
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "relative z-[1] max-w-[95vw] w-[95vw] h-[88vh] p-0 bg-white dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-700 rounded-md shadow-2xl overflow-hidden", children: [
2856
2924
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex items-center justify-between px-3 py-2 border-b border-neutral-200 dark:border-neutral-700", children: [
2857
2925
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex items-center gap-2 text-sm text-neutral-600 dark:text-neutral-300", children: [
@@ -2864,7 +2932,7 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
2864
2932
  {
2865
2933
  "aria-label": "Zoom out",
2866
2934
  className: "flex h-6 w-6 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-[13px]",
2867
- onClick: () => zoomBy(-0.2),
2935
+ onClick: () => zoomBy(-0.5),
2868
2936
  children: "\uFF0D"
2869
2937
  }
2870
2938
  ),
@@ -2877,10 +2945,47 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
2877
2945
  {
2878
2946
  "aria-label": "Zoom in",
2879
2947
  className: "flex h-6 w-6 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-[13px]",
2880
- onClick: () => zoomBy(0.2),
2948
+ onClick: () => zoomBy(0.5),
2881
2949
  children: "\uFF0B"
2882
2950
  }
2883
2951
  ),
2952
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "mx-1 h-4 w-px bg-neutral-300 dark:bg-neutral-700" }),
2953
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2954
+ "button",
2955
+ {
2956
+ "aria-label": "Zoom 100%",
2957
+ className: "inline-flex h-6 min-w-8 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 px-1.5 text-[12px]",
2958
+ onClick: () => setScale(1),
2959
+ children: "X1"
2960
+ }
2961
+ ),
2962
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2963
+ "button",
2964
+ {
2965
+ "aria-label": "Zoom 200%",
2966
+ className: "ml-1 inline-flex h-6 min-w-8 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 px-1.5 text-[12px]",
2967
+ onClick: () => setScale(2),
2968
+ children: "X2"
2969
+ }
2970
+ ),
2971
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2972
+ "button",
2973
+ {
2974
+ "aria-label": "Zoom 300%",
2975
+ className: "ml-1 inline-flex h-6 min-w-8 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 px-1.5 text-[12px]",
2976
+ onClick: () => setScale(3),
2977
+ children: "X3"
2978
+ }
2979
+ ),
2980
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2981
+ "button",
2982
+ {
2983
+ "aria-label": "Zoom 1000%",
2984
+ className: "ml-1 inline-flex h-6 min-w-10 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 px-1.5 text-[12px]",
2985
+ onClick: () => setScale(10),
2986
+ children: "X10"
2987
+ }
2988
+ ),
2884
2989
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2885
2990
  "button",
2886
2991
  {
@@ -2907,7 +3012,7 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
2907
3012
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
2908
3013
  "div",
2909
3014
  {
2910
- className: "relative h-[calc(88vh-40px)] w-full overflow-hidden bg-white dark:bg-neutral-900",
3015
+ className: "relative h-[calc(88vh-40px)] w-full overflow-hidden bg-white dark:bg-neutral-900 touch-none overscroll-contain",
2911
3016
  onWheel,
2912
3017
  onPointerDown,
2913
3018
  onPointerMove,