@windrun-huaiin/third-ui 5.14.0 → 5.14.1

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