@wisdomgarden/torque 0.2.1 → 0.2.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.
Files changed (63) hide show
  1. package/dist/common/is-dev.d.ts +1 -0
  2. package/dist/common/is-dev.js +5 -0
  3. package/dist/components/_inner/drawer/base-bottom-drawer.d.ts +1 -1
  4. package/dist/components/_inner/drawer/base-bottom-drawer.js +52 -44
  5. package/dist/components/_inner/menu/_web/menu.web.js +83 -72
  6. package/dist/components/_inner/portal/index.d.ts +1 -0
  7. package/dist/components/_inner/portal/index.js +5 -0
  8. package/dist/components/_inner/portal/portal.d.ts +14 -0
  9. package/dist/components/_inner/portal/portal.js +19 -0
  10. package/dist/components/button/styles/button-variables.module.css.js +1 -1
  11. package/dist/components/drawer/drawer.d.ts +1 -1
  12. package/dist/components/drawer/drawer.js +42 -34
  13. package/dist/components/modal/index.d.ts +1 -1
  14. package/dist/components/modal/modal.d.ts +7 -4
  15. package/dist/components/modal/modal.js +191 -44
  16. package/dist/components/modal/modal.module.css.js +20 -6
  17. package/dist/components/modal/modal.types.d.ts +96 -0
  18. package/dist/components/modal-deprecated/index.d.ts +2 -0
  19. package/dist/components/modal-deprecated/index.js +5 -0
  20. package/dist/components/modal-deprecated/modal-deprecated.d.ts +11 -0
  21. package/dist/components/modal-deprecated/modal-deprecated.js +70 -0
  22. package/dist/components/modal-deprecated/modal-deprecated.module.css.js +10 -0
  23. package/dist/components/notifications/index.d.ts +2 -0
  24. package/dist/components/notifications/index.js +4 -2
  25. package/dist/components/notifications/notifications-container.d.ts +9 -0
  26. package/dist/components/notifications/notifications-container.js +22 -0
  27. package/dist/components/overlay-layer/constants.d.ts +14 -0
  28. package/dist/components/overlay-layer/constants.js +8 -0
  29. package/dist/components/overlay-layer/index.d.ts +5 -0
  30. package/dist/components/overlay-layer/index.js +10 -0
  31. package/dist/components/overlay-layer/overlay-parent-context.d.ts +6 -0
  32. package/dist/components/overlay-layer/overlay-parent-context.js +18 -0
  33. package/dist/components/overlay-layer/overlay-stack-debug.d.ts +24 -0
  34. package/dist/components/overlay-layer/overlay-stack-debug.js +151 -0
  35. package/dist/components/overlay-layer/overlay-stack.d.ts +38 -0
  36. package/dist/components/overlay-layer/overlay-stack.js +137 -0
  37. package/dist/components/overlay-layer/overlay-tier-scope.d.ts +12 -0
  38. package/dist/components/overlay-layer/overlay-tier-scope.js +16 -0
  39. package/dist/components/overlay-layer/types.d.ts +63 -0
  40. package/dist/components/overlay-layer/use-mantine-overlay-layer.d.ts +21 -0
  41. package/dist/components/overlay-layer/use-mantine-overlay-layer.js +24 -0
  42. package/dist/components/overlay-layer/use-overlay-layer.d.ts +26 -0
  43. package/dist/components/overlay-layer/use-overlay-layer.js +77 -0
  44. package/dist/components/popover/hooks.d.ts +0 -1
  45. package/dist/components/popover/hooks.js +69 -83
  46. package/dist/components/popover/popover-context.d.ts +0 -1
  47. package/dist/components/popover/popover-context.js +3 -4
  48. package/dist/components/popover/popover-dropdown.js +110 -91
  49. package/dist/components/popover/popover.js +120 -129
  50. package/dist/components/popover/popover.types.d.ts +18 -5
  51. package/dist/components/tooltip/index.d.ts +10 -2
  52. package/dist/components/tooltip/index.js +100 -92
  53. package/dist/index.css +1 -1
  54. package/dist/index.d.ts +2 -0
  55. package/dist/index.js +193 -182
  56. package/dist/provider/hooks.js +12 -11
  57. package/dist/provider/ui-context.d.ts +10 -0
  58. package/dist/provider/ui-context.js +8 -7
  59. package/dist/provider/ui-provider.d.ts +23 -1
  60. package/dist/provider/ui-provider.js +17 -10
  61. package/package.json +3 -3
  62. package/dist/components/popover/popover-stack.d.ts +0 -10
  63. package/dist/components/popover/popover-stack.js +0 -24
@@ -1,194 +1,185 @@
1
1
  "use client";
2
- import { jsx as ie } from "react/jsx-runtime";
3
- import { offset as le, flip as ae, size as de, shift as ue, limitShift as fe, arrow as me, hide as pe, useFloating as ge, autoUpdate as ve } from "@floating-ui/react-dom";
4
- import { useDirection as he, getFloatingPosition as Ee } from "@mantine/core";
5
- import B, { useRef as l, useId as xe, useCallback as r, useEffect as J, useMemo as K } from "react";
6
- import { useEscapeClose as Re } from "./hooks.js";
7
- import { PopoverContext as Q } from "./popover-context.js";
8
- const v = 8, Te = ({
9
- children: W,
10
- position: X = "bottom",
11
- offset: C = 8,
12
- opened: N,
13
- defaultOpened: Y = !1,
14
- onOpenChange: T,
15
- disabled: b = !1,
2
+ import { jsx as re } from "react/jsx-runtime";
3
+ import { offset as se, flip as ie, size as le, shift as ae, limitShift as ce, arrow as de, hide as ue, useFloating as fe, autoUpdate as pe } from "@floating-ui/react-dom";
4
+ import { useDirection as me, getFloatingPosition as ge } from "@mantine/core";
5
+ import J, { useRef as r, useId as he, useCallback as s, useEffect as K, useMemo as L } from "react";
6
+ import { isDev as ve } from "../../common/is-dev.js";
7
+ import { PopoverContext as O } from "./popover-context.js";
8
+ const g = 8, be = ({
9
+ children: Q,
10
+ position: W = "bottom",
11
+ offset: P = 8,
12
+ opened: w,
13
+ defaultOpened: X = !1,
14
+ onOpenChange: d,
15
+ disabled: y = !1,
16
16
  withArrow: i = !1,
17
- arrowSize: a = 8,
18
- trigger: I = "click",
19
- openDelay: L = 0,
20
- closeDelay: M = 100,
21
- closeOnClickOutside: S = !0,
22
- closeOnEscape: Z = !0,
23
- restoreFocus: z,
17
+ arrowSize: u = 8,
18
+ trigger: l = "click",
19
+ openDelay: F = 0,
20
+ closeDelay: E = 100,
21
+ closeOnClickOutside: b = !0,
22
+ closeOnEscape: C = !0,
23
+ restoreFocus: D,
24
24
  strategy: h = "absolute",
25
- initialFocusRef: $,
26
- trapFocus: D = !1,
27
- preventAutoFocus: G = !1,
28
- "aria-labelledby": H
25
+ initialFocusRef: N,
26
+ trapFocus: T = !1,
27
+ preventAutoFocus: I = !1,
28
+ "aria-labelledby": M
29
29
  }) => {
30
- const E = B.useContext(Q), j = E?.registerNestedFloatingElement, x = E ? E.depth + 1 : 0, R = N !== void 0, [ee, te] = B.useState(Y), o = R ? N : ee, d = l(null), u = l(null), f = l(null), F = l(/* @__PURE__ */ new Set()), P = l(void 0), y = xe(), { dir: ne } = he(), n = r(
30
+ const $ = J.useContext(O)?.registerNestedFloatingElement, a = w !== void 0, [Y, Z] = J.useState(X), c = a ? w : Y, f = r(null), S = r(null), p = r(null), v = r(/* @__PURE__ */ new Set()), x = r(void 0), G = he(), { dir: z } = me(), n = s(
31
31
  (e) => {
32
- R || te(e), T?.(e);
32
+ a || Z(e), d?.(e);
33
33
  },
34
- [R, T]
35
- ), w = r(() => n(!1), [n]), k = r(() => n(!o), [o, n]), s = r(() => {
36
- window.clearTimeout(P.current), P.current = void 0;
37
- }, []), O = r(
34
+ [a, d]
35
+ ), H = s(() => n(!c), [c, n]), o = s(() => {
36
+ window.clearTimeout(x.current), x.current = void 0;
37
+ }, []), j = s(
38
38
  (e) => {
39
- s();
40
- const t = e ? L : M;
39
+ o();
40
+ const t = e ? F : E;
41
41
  if (t <= 0) {
42
42
  n(e);
43
43
  return;
44
44
  }
45
- P.current = window.setTimeout(() => n(e), t);
45
+ x.current = window.setTimeout(() => n(e), t);
46
46
  },
47
- [s, L, M, n]
47
+ [o, F, E, n]
48
48
  );
49
- J(() => s, [s]);
50
- const U = r(
49
+ K(() => o, [o]);
50
+ const k = r(!1);
51
+ K(() => {
52
+ !ve() || k.current || !a || l === "none" || d || (k.current = !0, console.warn(
53
+ `[@wisdomgarden/torque] <Popover trigger="${l}"> is controlled through \`opened\` but got no \`onOpenChange\`, so every built-in trigger resolves to a no-op — including the \`openDelay\` / \`closeDelay\` timers, which still run and then have nowhere to report. Pass \`onOpenChange\`, or use trigger="none" if the host owns the open state.`
54
+ ));
55
+ }, [a, l, d]);
56
+ const q = s(
51
57
  (e) => {
52
- F.current.add(e);
53
- const t = j?.(e);
58
+ v.current.add(e);
59
+ const t = $?.(e);
54
60
  return () => {
55
- F.current.delete(e), t?.();
61
+ v.current.delete(e), t?.();
56
62
  };
57
63
  },
58
- [j]
59
- ), m = r(() => {
60
- const e = f.current ? [f.current] : [];
61
- return F.current.forEach((t) => {
64
+ [$]
65
+ ), U = s(() => {
66
+ const e = p.current ? [p.current] : [];
67
+ return v.current.forEach((t) => {
62
68
  t.isConnected && e.push(t);
63
69
  }), Array.from(new Set(e));
64
- }, []);
65
- J(() => {
66
- if (!S || !o) return;
67
- const e = (t) => {
68
- const g = t.composedPath(), c = u.current;
69
- c && g.includes(c) || m().some((ce) => g.includes(ce)) || w();
70
- };
71
- return document.addEventListener("mousedown", e, !0), document.addEventListener("touchstart", e, !0), () => {
72
- document.removeEventListener("mousedown", e, !0), document.removeEventListener("touchstart", e, !0);
73
- };
74
- }, [S, o, w, m]), Re(
75
- Z,
76
- o,
77
- w,
78
- u,
79
- y,
80
- x,
81
- z
82
- );
83
- const oe = K(
70
+ }, []), ee = L(
84
71
  () => [
85
- le(C + (i ? a / 2 : 0)),
86
- ae({ padding: v }),
72
+ se(P + (i ? u / 2 : 0)),
73
+ ie({ padding: g }),
87
74
  // 必须在 shift 之前:否则 availableHeight 是 shift 推动后的位置算出的(≈整屏),高度约束失效
88
- de({
89
- padding: v,
90
- apply({ availableWidth: e, availableHeight: t, rects: g, elements: c }) {
91
- c.floating.style.setProperty(
75
+ le({
76
+ padding: g,
77
+ apply({ availableWidth: e, availableHeight: t, rects: oe, elements: R }) {
78
+ R.floating.style.setProperty(
92
79
  "--t-popover-available-width",
93
80
  `${Math.max(0, e)}px`
94
- ), c.floating.style.setProperty(
81
+ ), R.floating.style.setProperty(
95
82
  "--t-popover-available-height",
96
83
  `${Math.max(0, t)}px`
97
- ), c.floating.style.setProperty(
84
+ ), R.floating.style.setProperty(
98
85
  "--t-popover-reference-width",
99
- `${g.reference.width}px`
86
+ `${oe.reference.width}px`
100
87
  );
101
88
  }
102
89
  }),
103
- ue({
104
- padding: v,
90
+ ae({
91
+ padding: g,
105
92
  crossAxis: !0,
106
93
  mainAxis: !0,
107
- limiter: fe()
94
+ limiter: ce()
108
95
  }),
109
96
  ...i ? (
110
97
  // floating-ui 的 arrow 中间件按设计就是收一个 ref 对象(它在定位阶段自己读
111
98
  // .current),不是我们在渲染期读 ref 的值。没有保留该 API 的改写方式。
112
99
  // eslint-disable-next-line react-hooks/refs
113
- [me({ element: d, padding: v })]
100
+ [de({ element: f, padding: g })]
114
101
  ) : [],
115
- pe()
102
+ ue()
116
103
  ],
117
- [C, i, a, d]
104
+ [P, i, u, f]
118
105
  ), {
119
106
  x: V,
120
107
  y: _,
121
- refs: p,
122
- placement: re,
123
- middlewareData: q
124
- } = ge({
125
- open: o,
108
+ refs: m,
109
+ placement: te,
110
+ middlewareData: A
111
+ } = fe({
112
+ open: c,
126
113
  strategy: h,
127
- placement: Ee(ne, X),
128
- middleware: oe,
129
- whileElementsMounted: ve
130
- }), A = re.split("-")[0], se = K(
114
+ placement: ge(z, W),
115
+ middleware: ee,
116
+ whileElementsMounted: pe
117
+ }), B = te.split("-")[0], ne = L(
131
118
  () => ({
132
- opened: o,
119
+ opened: c,
133
120
  setOpen: n,
134
- toggle: k,
135
- trigger: I,
136
- disabled: b,
137
- id: y,
121
+ toggle: H,
122
+ trigger: l,
123
+ disabled: y,
124
+ id: G,
138
125
  withArrow: i,
139
- arrowSize: a,
126
+ arrowSize: u,
140
127
  x: V,
141
128
  y: _,
142
129
  strategy: h,
143
- resolvedSide: A,
144
- middlewareData: q,
145
- scheduleHover: O,
146
- cancelHoverTimer: s,
147
- referenceRef: u,
148
- floatingRef: f,
149
- arrowRef: d,
150
- setReference: p.setReference,
151
- setFloating: p.setFloating,
152
- depth: x,
153
- registerNestedFloatingElement: U,
154
- getFloatingScopeElements: m,
155
- initialFocusRef: $,
156
- trapFocus: D,
157
- preventAutoFocus: G,
158
- ariaLabelledby: H
130
+ resolvedSide: B,
131
+ middlewareData: A,
132
+ scheduleHover: j,
133
+ cancelHoverTimer: o,
134
+ referenceRef: S,
135
+ floatingRef: p,
136
+ arrowRef: f,
137
+ setReference: m.setReference,
138
+ setFloating: m.setFloating,
139
+ registerNestedFloatingElement: q,
140
+ getFloatingScopeElements: U,
141
+ initialFocusRef: N,
142
+ trapFocus: T,
143
+ preventAutoFocus: I,
144
+ ariaLabelledby: M,
145
+ restoreFocus: D,
146
+ closeOnEscape: C,
147
+ closeOnClickOutside: b
159
148
  }),
160
149
  [
161
- o,
150
+ c,
162
151
  n,
163
- k,
164
- I,
165
- b,
152
+ H,
153
+ l,
166
154
  y,
155
+ G,
167
156
  i,
168
- a,
157
+ u,
169
158
  V,
170
159
  _,
171
160
  h,
161
+ B,
172
162
  A,
173
- q,
174
- O,
175
- s,
176
- u,
163
+ j,
164
+ o,
165
+ S,
166
+ p,
177
167
  f,
178
- d,
179
- p.setReference,
180
- p.setFloating,
181
- x,
168
+ m.setReference,
169
+ m.setFloating,
170
+ q,
182
171
  U,
183
- m,
184
- $,
172
+ N,
173
+ T,
174
+ I,
175
+ M,
185
176
  D,
186
- G,
187
- H
177
+ C,
178
+ b
188
179
  ]
189
180
  );
190
- return /* @__PURE__ */ ie(Q.Provider, { value: se, children: W });
181
+ return /* @__PURE__ */ re(O.Provider, { value: ne, children: Q });
191
182
  };
192
183
  export {
193
- Te as Popover
184
+ be as Popover
194
185
  };
@@ -22,7 +22,11 @@ export interface PopoverProps {
22
22
  */
23
23
  offset?: number;
24
24
  /**
25
- * 受控模式:是否展开
25
+ * 受控模式:是否展开。
26
+ *
27
+ * 受控之后内部不再持有开关状态,所有内部触发都只转发给 `onOpenChange`,
28
+ * 所以除 `trigger="none"` 外**必须同时提供 `onOpenChange`** ——
29
+ * 漏传会让 click / hover 以及 `openDelay` / `closeDelay` 全部静默失效。
26
30
  */
27
31
  opened?: boolean;
28
32
  /**
@@ -31,7 +35,8 @@ export interface PopoverProps {
31
35
  */
32
36
  defaultOpened?: boolean;
33
37
  /**
34
- * 展开状态变更回调
38
+ * 展开状态变更回调。受控与非受控都会调用;受控下它是内部触发唯一的出口,
39
+ * 必须无条件回写,业务上的启用与否交给 `disabled`。
35
40
  */
36
41
  onOpenChange?: (opened: boolean) => void;
37
42
  /**
@@ -64,6 +69,10 @@ export interface PopoverProps {
64
69
  /**
65
70
  * hover 关闭延迟(ms),留出鼠标从触发元素移动到浮层的时间。
66
71
  * 仅 `trigger="hover"` 生效。
72
+ *
73
+ * 设为 `0` 即取消这段缓冲:鼠标离开触发元素就同步关闭,够不到浮层,键盘也 Tab 不进去。
74
+ * 想要「只给看、不给进一步操作」的富文本 tooltip 就该设 `0`,但浮层内容必须纯展示;
75
+ * 浮层内有可交互内容时不要设 `0`。
67
76
  * @default 100
68
77
  */
69
78
  closeDelay?: number;
@@ -209,11 +218,9 @@ export interface PopoverContextValue {
209
218
  arrowRef: React.RefObject<HTMLDivElement | null>;
210
219
  setReference: (node: HTMLElement | null) => void;
211
220
  setFloating: (node: HTMLDivElement | null) => void;
212
- /** 当前 Popover 的逻辑嵌套深度,用于浮层层级和 Escape 栈排序 */
213
- depth: number;
214
221
  /** 将后代 Portal 浮层登记到当前 Popover 的交互与焦点范围中 */
215
222
  registerNestedFloatingElement: (element: HTMLElement) => () => void;
216
- /** 返回当前浮层及所有已登记后代浮层,用于外部点击与焦点判断 */
223
+ /** 返回当前浮层及所有已登记后代浮层,用于焦点范围判断 */
217
224
  getFloatingScopeElements: () => HTMLElement[];
218
225
  /** 外部传入的初始焦点目标;`usePopoverFocus` 有值时优先聚焦该元素 */
219
226
  initialFocusRef?: React.RefObject<HTMLElement | null>;
@@ -223,4 +230,10 @@ export interface PopoverContextValue {
223
230
  preventAutoFocus: boolean;
224
231
  /** dialog 的 `aria-labelledby` id;由 `PopoverDropdown` 写到 role="dialog" 元素上 */
225
232
  ariaLabelledby?: string;
233
+ /** Escape 关闭后恢复焦点的方法;未传时聚焦 Target */
234
+ restoreFocus?: () => void;
235
+ /** 交给层级模块:本层为栈顶时 Escape 是否关闭 */
236
+ closeOnEscape: boolean;
237
+ /** 交给层级模块:点在外面时是否关闭 */
238
+ closeOnClickOutside: boolean;
226
239
  }
@@ -27,6 +27,14 @@ export type TooltipProps = React.HTMLAttributes<HTMLDivElement> & WrapperDisplay
27
27
  readonly strategy?: FloatingStrategy;
28
28
  /** 是否禁用 Tooltip 的显示 */
29
29
  readonly disabled?: boolean;
30
+ /**
31
+ * 鼠标移入浮层时是否保持显示,默认 `true`。
32
+ *
33
+ * - `true`:浮层可 hover,用户能选中并复制其中的文字,适合 info 等解释说明场景;
34
+ * - `false`:浮层不响应鼠标(`pointer-events: none`),鼠标移向浮层即消失,
35
+ * 适合列表选择等仅需查看完整文本、无复制需求的场景。
36
+ */
37
+ readonly interactive?: boolean;
30
38
  /** 触发 Tooltip 的目标元素 */
31
39
  readonly children: React.ReactNode;
32
40
  /** Tooltip 内显示的提示内容 */
@@ -41,7 +49,7 @@ export type TooltipProps = React.HTMLAttributes<HTMLDivElement> & WrapperDisplay
41
49
  readonly truncateMaxLines?: number;
42
50
  /** 透传给浮层根节点的 ref */
43
51
  readonly ref?: React.Ref<HTMLDivElement>;
44
- /** 浮层的 z-index 层级,默认 300 */
52
+ /** 浮层的 z-index 层级。不传时由层级模块按打开顺序计算(普通层从 200 起) */
45
53
  readonly zIndex?: number;
46
54
  };
47
55
  /**
@@ -50,5 +58,5 @@ export type TooltipProps = React.HTMLAttributes<HTMLDivElement> & WrapperDisplay
50
58
  * 基于 `@floating-ui/react-dom` 封装的工具提示组件,支持智能定位、自动翻转、箭头指示,
51
59
  * 以及独有的「仅文本截断时才显示 (showOnlyWhenTruncated)」功能。
52
60
  */
53
- export declare const Tooltip: ({ position, strategy, arrowProps, offset: offsetProp, label, children, disabled, showOnlyWhenTruncated, truncateMaxWidth, truncateMaxLines, ref: externalRef, inline, block, zIndex, ...others }: TooltipProps) => import("react").JSX.Element;
61
+ export declare const Tooltip: ({ position, strategy, arrowProps, offset: offsetProp, label, children, disabled, interactive, showOnlyWhenTruncated, truncateMaxWidth, truncateMaxLines, ref: externalRef, inline, block, zIndex: zIndexProp, ...others }: TooltipProps) => import("react").JSX.Element;
54
62
  export type * from './types';
@@ -1,150 +1,158 @@
1
1
  "use client";
2
- import { jsxs as b, Fragment as oe, jsx as m } from "react/jsx-runtime";
3
- import { offset as ne, flip as se, shift as ie, arrow as ae, hide as le, useFloating as ce, autoUpdate as de } from "@floating-ui/react-dom";
4
- import { useDirection as ue, getFloatingPosition as fe, Portal as me, Transition as pe } from "@mantine/core";
5
- import { useMergedRef as H } from "@mantine/hooks";
6
- import { useRef as i, useState as ge, isValidElement as we, useMemo as p, useCallback as r } from "react";
7
- import { FloatingArrow as ve } from "./floating-arrow.js";
8
- import h from "./styles.module.css.js";
9
- import { useMergedEvents as Te } from "./use-merged-events.js";
10
- import { useTooltipTrigger as Ee } from "./use-tooltip-trigger.js";
11
- import { getTruncationTarget as Re, isTruncated as Fe } from "./utils.js";
12
- const g = 8, Le = ({
13
- position: D = "top",
14
- strategy: N = "absolute",
15
- arrowProps: P,
16
- offset: w = 5,
17
- label: y,
2
+ import { jsxs as H, Fragment as ie, jsx as g } from "react/jsx-runtime";
3
+ import { offset as ae, flip as le, shift as ce, arrow as de, hide as fe, useFloating as me, autoUpdate as ue } from "@floating-ui/react-dom";
4
+ import { useDirection as pe, getFloatingPosition as ge, Transition as we } from "@mantine/core";
5
+ import { useMergedRef as I } from "@mantine/hooks";
6
+ import { useRef as i, useState as Te, isValidElement as ve, useMemo as w, useCallback as r } from "react";
7
+ import { Portal as xe } from "../_inner/portal/portal.js";
8
+ import { useOverlayLayer as Ee } from "../overlay-layer/use-overlay-layer.js";
9
+ import { FloatingArrow as Re } from "./floating-arrow.js";
10
+ import L from "./styles.module.css.js";
11
+ import { useMergedEvents as Fe } from "./use-merged-events.js";
12
+ import { useTooltipTrigger as Me } from "./use-tooltip-trigger.js";
13
+ import { getTruncationTarget as ye, isTruncated as he } from "./utils.js";
14
+ const T = 8, Be = ({
15
+ position: b = "top",
16
+ strategy: z = "absolute",
17
+ arrowProps: D,
18
+ offset: v = 5,
19
+ label: N,
18
20
  children: a,
19
- disabled: A,
20
- showOnlyWhenTruncated: l = !1,
21
- truncateMaxWidth: L,
22
- truncateMaxLines: k = 1,
23
- ref: I,
24
- inline: c,
25
- block: v = !0,
26
- zIndex: S = 300,
21
+ disabled: x,
22
+ interactive: l = !0,
23
+ showOnlyWhenTruncated: c = !1,
24
+ truncateMaxWidth: P,
25
+ truncateMaxLines: A = 1,
26
+ ref: k,
27
+ inline: d,
28
+ block: E = !0,
29
+ zIndex: S,
27
30
  ...j
28
31
  }) => {
29
- const T = i(null), d = i(null), E = i(null), [R, o] = ge(!1), z = we(a), B = p(
30
- () => c !== void 0 ? !c : v ?? !0,
31
- [v, c]
32
+ const R = i(null), f = i(null), F = i(null), [m, o] = Te(!1), B = ve(a), C = w(
33
+ () => d !== void 0 ? !d : E ?? !0,
34
+ [E, d]
32
35
  ), {
33
- size: C = 6,
34
- offset: G = 5,
35
- radius: V = 0
36
- } = P ?? {}, { dir: F } = ue(), U = p(() => [
37
- ne(w),
38
- se({ padding: g }),
39
- ie({ padding: g }),
36
+ size: G = 6,
37
+ offset: V = 5,
38
+ radius: O = 0
39
+ } = D ?? {}, { dir: M } = pe(), U = w(() => [
40
+ ae(v),
41
+ le({ padding: T }),
42
+ ce({ padding: T }),
40
43
  // 同 popover.tsx:floating-ui 的 arrow 中间件收的就是 ref 对象本身。
41
44
  // eslint-disable-next-line react-hooks/refs
42
- ae({ element: E, padding: g }),
43
- le()
44
- ], [w]), {
45
+ de({ element: F, padding: T }),
46
+ fe()
47
+ ], [v]), {
45
48
  x: X,
46
49
  y: Y,
47
- refs: M,
50
+ refs: y,
48
51
  floatingStyles: _,
49
52
  placement: q,
50
53
  middlewareData: { arrow: { x: J, y: K } = {} },
51
- middlewareData: x
52
- } = ce({
53
- open: R,
54
- strategy: N,
55
- placement: fe(F, D),
54
+ middlewareData: h
55
+ } = me({
56
+ open: m,
57
+ strategy: z,
58
+ placement: ge(M, b),
56
59
  middleware: U,
57
- whileElementsMounted: de
58
- }), O = H(
59
- T,
60
- I,
61
- M.setFloating
60
+ whileElementsMounted: ue
61
+ }), { zIndex: Q, ref: Z } = Ee({
62
+ opened: !x && m,
63
+ zIndex: S,
64
+ name: "tooltip"
65
+ }), $ = I(
66
+ R,
67
+ k,
68
+ y.setFloating,
69
+ Z
62
70
  ), t = i(0), n = r(() => {
63
71
  t.current && (clearTimeout(t.current), t.current = 0);
64
- }, []), Q = H(d, M.setReference), s = r(() => {
65
- if (n(), l) {
66
- const e = Re(d.current);
67
- if (!Fe(e)) return;
72
+ }, []), W = I(f, y.setReference), s = r(() => {
73
+ if (n(), c) {
74
+ const e = ye(f.current);
75
+ if (!he(e)) return;
68
76
  }
69
77
  o(!0);
70
- }, [n, l]), u = r((e) => {
71
- const f = e.relatedTarget instanceof Node ? e.relatedTarget : null;
72
- f && (d.current?.contains(f) || T.current?.contains(f)) || (t.current = window.setTimeout(() => {
78
+ }, [n, c]), u = r((e) => {
79
+ const p = e.relatedTarget instanceof Node ? e.relatedTarget : null;
80
+ p && (f.current?.contains(p) || R.current?.contains(p)) || (t.current = window.setTimeout(() => {
73
81
  o(!1);
74
82
  }, 100));
75
- }, []), Z = r(() => {
83
+ }, []), ee = r(() => {
76
84
  t.current = window.setTimeout(() => {
77
85
  o(!1);
78
86
  }, 100);
79
- }, []), $ = r(() => {
87
+ }, []), te = r(() => {
80
88
  n(), o(!1);
81
- }, [n]), W = Te({
82
- userProps: z ? a.props : {},
89
+ }, [n]), re = Fe({
90
+ userProps: B ? a.props : {},
83
91
  internalProps: {
84
92
  onMouseEnter: s,
85
93
  onMouseLeave: u,
86
94
  onFocus: s,
87
- onBlur: Z,
88
- onClick: $
95
+ onBlur: ee,
96
+ onClick: te
89
97
  }
90
- }), ee = p(
91
- () => ({
98
+ }), oe = w(
99
+ () => l ? {
92
100
  onMouseEnter: s,
93
101
  onMouseLeave: u
94
- }),
95
- [s, u]
96
- ), { trigger: te, id: re } = Ee({
102
+ } : {},
103
+ [l, s, u]
104
+ ), { trigger: ne, id: se } = Me({
97
105
  children: a,
98
- showOnlyWhenTruncated: l,
99
- truncateMaxWidth: L,
100
- truncateMaxLines: k,
101
- isBlock: B,
102
- mergedReferenceRef: Q,
103
- mergedEvents: W
106
+ showOnlyWhenTruncated: c,
107
+ truncateMaxWidth: P,
108
+ truncateMaxLines: A,
109
+ isBlock: C,
110
+ mergedReferenceRef: W,
111
+ mergedEvents: re
104
112
  });
105
- return /* @__PURE__ */ b(oe, { children: [
106
- /* @__PURE__ */ m(me, { children: /* @__PURE__ */ m(pe, { mounted: !A && R, children: (e) => /* @__PURE__ */ b(
113
+ return /* @__PURE__ */ H(ie, { children: [
114
+ /* @__PURE__ */ g(xe, { children: /* @__PURE__ */ g(we, { mounted: !x && m, children: (e) => /* @__PURE__ */ H(
107
115
  "div",
108
116
  {
109
- id: re,
117
+ id: se,
110
118
  tabIndex: -1,
111
119
  role: "tooltip",
112
- ref: O,
113
- className: h.wgTooltip,
120
+ ref: $,
121
+ className: L.wgTooltip,
114
122
  ...j,
115
123
  style: {
116
124
  left: X,
117
125
  top: Y,
118
126
  ...e,
119
127
  ..._,
120
- zIndex: S,
121
- visibility: x.hide?.referenceHidden ? "hidden" : void 0,
122
- pointerEvents: x.hide?.referenceHidden ? "none" : void 0
128
+ zIndex: Q,
129
+ visibility: h.hide?.referenceHidden ? "hidden" : void 0,
130
+ pointerEvents: !l || h.hide?.referenceHidden ? "none" : void 0
123
131
  },
124
- ...ee,
132
+ ...oe,
125
133
  children: [
126
- y,
127
- /* @__PURE__ */ m(
128
- ve,
134
+ N,
135
+ /* @__PURE__ */ g(
136
+ Re,
129
137
  {
130
138
  "aria-hidden": "true",
131
- ref: E,
132
- className: h.wgTooltipArrow,
139
+ ref: F,
140
+ className: L.wgTooltipArrow,
133
141
  arrowX: J,
134
142
  arrowY: K,
135
- arrowSize: C,
136
- arrowOffset: G,
137
- arrowRadius: V,
138
- dir: F,
143
+ arrowSize: G,
144
+ arrowOffset: V,
145
+ arrowRadius: O,
146
+ dir: M,
139
147
  placement: q
140
148
  }
141
149
  )
142
150
  ]
143
151
  }
144
152
  ) }) }),
145
- te
153
+ ne
146
154
  ] });
147
155
  };
148
156
  export {
149
- Le as Tooltip
157
+ Be as Tooltip
150
158
  };