@wisdomgarden/torque 0.2.2 → 0.2.4

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 (60) hide show
  1. package/dist/components/_inner/drawer/base-bottom-drawer.d.ts +1 -1
  2. package/dist/components/_inner/drawer/base-bottom-drawer.js +52 -44
  3. package/dist/components/_inner/menu/_web/menu.web.js +83 -72
  4. package/dist/components/_inner/portal/index.d.ts +1 -0
  5. package/dist/components/_inner/portal/index.js +5 -0
  6. package/dist/components/_inner/portal/portal.d.ts +14 -0
  7. package/dist/components/_inner/portal/portal.js +19 -0
  8. package/dist/components/button/styles/button-variables.module.css.js +1 -1
  9. package/dist/components/drawer/drawer.d.ts +1 -1
  10. package/dist/components/drawer/drawer.js +42 -34
  11. package/dist/components/modal/index.d.ts +1 -1
  12. package/dist/components/modal/modal.d.ts +7 -4
  13. package/dist/components/modal/modal.js +191 -44
  14. package/dist/components/modal/modal.module.css.js +20 -6
  15. package/dist/components/modal/modal.types.d.ts +96 -0
  16. package/dist/components/modal-deprecated/index.d.ts +2 -0
  17. package/dist/components/modal-deprecated/index.js +5 -0
  18. package/dist/components/modal-deprecated/modal-deprecated.d.ts +11 -0
  19. package/dist/components/modal-deprecated/modal-deprecated.js +70 -0
  20. package/dist/components/modal-deprecated/modal-deprecated.module.css.js +10 -0
  21. package/dist/components/notifications/index.d.ts +2 -0
  22. package/dist/components/notifications/index.js +4 -2
  23. package/dist/components/notifications/notifications-container.d.ts +9 -0
  24. package/dist/components/notifications/notifications-container.js +22 -0
  25. package/dist/components/overlay-layer/constants.d.ts +15 -0
  26. package/dist/components/overlay-layer/constants.js +8 -0
  27. package/dist/components/overlay-layer/index.d.ts +5 -0
  28. package/dist/components/overlay-layer/index.js +11 -0
  29. package/dist/components/overlay-layer/overlay-parent-context.d.ts +6 -0
  30. package/dist/components/overlay-layer/overlay-parent-context.js +18 -0
  31. package/dist/components/overlay-layer/overlay-stack-debug.d.ts +24 -0
  32. package/dist/components/overlay-layer/overlay-stack-debug.js +151 -0
  33. package/dist/components/overlay-layer/overlay-stack.d.ts +38 -0
  34. package/dist/components/overlay-layer/overlay-stack.js +137 -0
  35. package/dist/components/overlay-layer/overlay-tier-scope.d.ts +12 -0
  36. package/dist/components/overlay-layer/overlay-tier-scope.js +16 -0
  37. package/dist/components/overlay-layer/types.d.ts +63 -0
  38. package/dist/components/overlay-layer/use-mantine-overlay-layer.d.ts +21 -0
  39. package/dist/components/overlay-layer/use-mantine-overlay-layer.js +24 -0
  40. package/dist/components/overlay-layer/use-overlay-layer.d.ts +26 -0
  41. package/dist/components/overlay-layer/use-overlay-layer.js +77 -0
  42. package/dist/components/popover/hooks.d.ts +0 -1
  43. package/dist/components/popover/hooks.js +69 -83
  44. package/dist/components/popover/popover-context.d.ts +0 -1
  45. package/dist/components/popover/popover-context.js +3 -4
  46. package/dist/components/popover/popover-dropdown.js +110 -91
  47. package/dist/components/popover/popover.js +134 -150
  48. package/dist/components/popover/popover.types.d.ts +7 -3
  49. package/dist/components/tooltip/index.d.ts +10 -2
  50. package/dist/components/tooltip/index.js +100 -92
  51. package/dist/index.css +1 -1
  52. package/dist/index.d.ts +2 -0
  53. package/dist/index.js +197 -185
  54. package/dist/provider/ui-context.d.ts +10 -0
  55. package/dist/provider/ui-context.js +8 -7
  56. package/dist/provider/ui-provider.d.ts +23 -1
  57. package/dist/provider/ui-provider.js +17 -10
  58. package/package.json +3 -3
  59. package/dist/components/popover/popover-stack.d.ts +0 -10
  60. package/dist/components/popover/popover-stack.js +0 -24
@@ -29,4 +29,4 @@ export type BaseBottomDrawerProps = DistributiveOmit<DrawerProps, 'withXPadding'
29
29
  /**
30
30
  * 移动端使用的底部弹出的抽屉组件
31
31
  */
32
- export declare const BaseBottomDrawer: ({ withCloseButton, title, "aria-label": ariaLabel, children, bottomSection, height, noMinHeight, contentClassName, bodyClassName, ...props }: BaseBottomDrawerProps) => import("react").JSX.Element;
32
+ export declare const BaseBottomDrawer: ({ withCloseButton, title, "aria-label": ariaLabel, children, bottomSection, height, noMinHeight, contentClassName, bodyClassName, ref, ...props }: BaseBottomDrawerProps) => import("react").JSX.Element;
@@ -1,79 +1,87 @@
1
1
  "use client";
2
- import { jsxs as s, jsx as r, Fragment as u } from "react/jsx-runtime";
3
- import { Drawer as C, Space as y, Text as N } from "@mantine/core";
4
- import { clsx as c } from "clsx";
2
+ import { jsx as r, jsxs as l, Fragment as v } from "react/jsx-runtime";
3
+ import { Drawer as x, Space as g, Text as p } from "@mantine/core";
4
+ import { useMergedRef as N } from "@mantine/hooks";
5
+ import { clsx as d } from "clsx";
5
6
  import "../../../provider/ui-context.js";
6
7
  import "react";
7
- import { useLocale as x } from "../../../provider/hooks.js";
8
- import t from "../../drawer/drawer.module.css.js";
9
- import { IconButton as g } from "../../icon-button/icon-button.js";
8
+ import { useLocale as O } from "../../../provider/hooks.js";
9
+ import o from "../../drawer/drawer.module.css.js";
10
+ import { IconButton as D } from "../../icon-button/icon-button.js";
11
+ import { OverlayParentProvider as H } from "../../overlay-layer/overlay-parent-context.js";
12
+ import { useMantineOverlayLayer as M } from "../../overlay-layer/use-mantine-overlay-layer.js";
10
13
  import a from "./base-bottom-drawer.module.css.js";
11
- const k = ({
14
+ const q = ({
12
15
  withCloseButton: e = !0,
13
- title: o,
16
+ title: t,
14
17
  "aria-label": m,
15
- children: i,
18
+ children: c,
16
19
  bottomSection: n,
17
- height: d = "fit-content",
20
+ height: f = "fit-content",
18
21
  noMinHeight: h = !1,
19
22
  contentClassName: w,
20
- bodyClassName: f,
21
- ...l
23
+ bodyClassName: u,
24
+ ref: y,
25
+ ...s
22
26
  }) => {
23
- const B = o || e;
27
+ const i = M("Drawer", s, "bottom-drawer"), B = N(i.rootRef, y), C = t || e;
24
28
  return (
25
29
  // todo 无障碍aria-describedby没有正确关联的问题待解决
26
- /* @__PURE__ */ s(
27
- C,
30
+ /* @__PURE__ */ r(
31
+ x,
28
32
  {
29
- ...l,
33
+ ...s,
34
+ ref: B,
35
+ zIndex: i.zIndex,
36
+ closeOnEscape: !1,
37
+ closeOnClickOutside: !1,
30
38
  position: "bottom",
31
- title: m ?? (typeof o == "string" ? o : void 0),
39
+ title: m ?? (typeof t == "string" ? t : void 0),
32
40
  withCloseButton: !1,
33
41
  styles: {
34
42
  content: {
35
- height: d
43
+ height: f
36
44
  }
37
45
  },
38
46
  classNames: {
39
- content: c(
40
- t.drawerContent,
41
- n && t.drawerContentWithBottomSection,
47
+ content: d(
48
+ o.drawerContent,
49
+ n && o.drawerContentWithBottomSection,
42
50
  w,
43
51
  a.content,
44
52
  !h && a.contentMinHeight
45
53
  ),
46
- header: t.hiddenHeader,
47
- body: c(
48
- t.drawerBody,
49
- n && t.drawerBodyWithBottomSection,
50
- f
54
+ header: o.hiddenHeader,
55
+ body: d(
56
+ o.drawerBody,
57
+ n && o.drawerBodyWithBottomSection,
58
+ u
51
59
  )
52
60
  },
53
- children: [
54
- B && /* @__PURE__ */ r(
55
- p,
61
+ children: /* @__PURE__ */ l(H, { id: i.id, children: [
62
+ C && /* @__PURE__ */ r(
63
+ R,
56
64
  {
57
- title: o,
65
+ title: t,
58
66
  withCloseButton: e,
59
- onClose: l.onClose
67
+ onClose: s.onClose
60
68
  }
61
69
  ),
62
- n ? /* @__PURE__ */ s(u, { children: [
63
- /* @__PURE__ */ r("div", { className: t.drawerMain, children: i }),
64
- /* @__PURE__ */ r("div", { className: t.drawerBottomSection, children: n })
65
- ] }) : i
66
- ]
70
+ n ? /* @__PURE__ */ l(v, { children: [
71
+ /* @__PURE__ */ r("div", { className: o.drawerMain, children: c }),
72
+ /* @__PURE__ */ r("div", { className: o.drawerBottomSection, children: n })
73
+ ] }) : c
74
+ ] })
67
75
  }
68
76
  )
69
77
  );
70
- }, p = (e) => {
71
- const o = x();
72
- return /* @__PURE__ */ s("div", { className: a.header, children: [
73
- e.withCloseButton && /* @__PURE__ */ r(y, { w: 40 }),
74
- /* @__PURE__ */ r(N, { className: a.headerTitle, children: e.title }),
78
+ }, R = (e) => {
79
+ const t = O();
80
+ return /* @__PURE__ */ l("div", { className: a.header, children: [
81
+ e.withCloseButton && /* @__PURE__ */ r(g, { w: 40 }),
82
+ /* @__PURE__ */ r(p, { className: a.headerTitle, children: e.title }),
75
83
  e.withCloseButton && /* @__PURE__ */ r(
76
- g,
84
+ D,
77
85
  {
78
86
  iconName: "close",
79
87
  variant: "text",
@@ -81,11 +89,11 @@ const k = ({
81
89
  size: "lg",
82
90
  className: a.headerClose,
83
91
  onClick: () => e.onClose?.(),
84
- "aria-label": o.close
92
+ "aria-label": t.close
85
93
  }
86
94
  )
87
95
  ] });
88
96
  };
89
97
  export {
90
- k as BaseBottomDrawer
98
+ q as BaseBottomDrawer
91
99
  };
@@ -1,77 +1,88 @@
1
1
  "use client";
2
- import { jsx as n, Fragment as m, jsxs as u } from "react/jsx-runtime";
3
- import { Menu as c, Text as E, Box as S } from "@mantine/core";
4
- import { Icon as p } from "@wisdomgarden/torque-icons";
5
- import d, { useState as M, useRef as P } from "react";
6
- import { IconButton as x } from "../../../icon-button/icon-button.js";
2
+ import { jsx as n, Fragment as O, jsxs as u } from "react/jsx-runtime";
3
+ import { Menu as s, Text as M, Box as S } from "@mantine/core";
4
+ import { Icon as I } from "@wisdomgarden/torque-icons";
5
+ import d, { useState as P, useRef as R } from "react";
6
+ import { IconButton as B } from "../../../icon-button/icon-button.js";
7
+ import { useOverlayLayerInternal as D } from "../../../overlay-layer/use-overlay-layer.js";
7
8
  import { Tooltip as T } from "../../../tooltip/index.js";
8
- import i from "./menu-web.module.css.js";
9
- const H = ({
9
+ import c from "./menu-web.module.css.js";
10
+ const q = ({
10
11
  menuItems: e,
11
12
  onClick: l,
12
- children: t,
13
- disabled: a,
13
+ children: a,
14
+ disabled: t,
14
15
  triggerAriaLabel: h,
15
16
  renderTarget: b,
16
- trigger: s = "click-hover",
17
- position: y,
18
- "data-testid": g
17
+ trigger: i = "click-hover",
18
+ position: w,
19
+ "data-testid": v
19
20
  }) => {
20
- const [f, A] = M(!1), I = P(null), r = b?.({ opened: f }) ?? t, v = () => {
21
- I.current?.focus({ preventScroll: !0 });
22
- };
23
- if (a) {
21
+ const [p, m] = P(!1), f = R(null), r = b?.({ opened: p }) ?? a, g = () => {
22
+ f.current?.focus({ preventScroll: !0 });
23
+ }, { zIndex: E, ref: A } = D({
24
+ opened: p && !t,
25
+ insideRefs: [f],
26
+ close: (o) => {
27
+ m(!1), o === "escape" && g();
28
+ },
29
+ name: "menu"
30
+ });
31
+ if (t) {
24
32
  const o = d.isValidElement(r) ? r.props : void 0;
25
- return /* @__PURE__ */ n(m, { children: d.isValidElement(r) ? d.cloneElement(
33
+ return /* @__PURE__ */ n(O, { children: d.isValidElement(r) ? d.cloneElement(
26
34
  r,
27
35
  {
28
36
  disabled: !0,
29
- "data-testid": g ?? o?.["data-testid"]
37
+ "data-testid": v ?? o?.["data-testid"]
30
38
  }
31
39
  ) : r });
32
40
  }
33
- const N = d.isValidElement(r) ? r.props : void 0;
41
+ const C = d.isValidElement(r) ? r.props : void 0;
34
42
  return /* @__PURE__ */ u(
35
- c,
43
+ s,
36
44
  {
37
- trigger: s,
38
- opened: f,
39
- onChange: A,
40
- position: y,
45
+ trigger: i,
46
+ opened: p,
47
+ onChange: m,
48
+ position: w,
49
+ zIndex: E,
50
+ closeOnEscape: !1,
51
+ closeOnClickOutside: !1,
41
52
  children: [
42
- /* @__PURE__ */ n(c.Target, { ref: I, children: d.isValidElement(r) ? d.cloneElement(
53
+ /* @__PURE__ */ n(s.Target, { ref: f, children: d.isValidElement(r) ? d.cloneElement(
43
54
  r,
44
55
  {
45
- "aria-label": h ?? N?.["aria-label"],
46
- "data-testid": g ?? N?.["data-testid"]
56
+ "aria-label": h ?? C?.["aria-label"],
57
+ "data-testid": v ?? C?.["data-testid"]
47
58
  }
48
59
  ) : r }),
49
- /* @__PURE__ */ n(c.Dropdown, { children: e.map(
50
- (o, C) => o.children && o.children.length > 0 ? /* @__PURE__ */ n(
60
+ /* @__PURE__ */ n(s.Dropdown, { ref: A, children: e.map(
61
+ (o, N) => o.children && o.children.length > 0 ? /* @__PURE__ */ n(
51
62
  k,
52
63
  {
53
64
  target: o,
54
65
  subItems: o.children,
55
66
  onClick: l,
56
- onAction: v
67
+ onAction: g
57
68
  },
58
- o.value ?? o.label ?? C
69
+ o.value ?? o.label ?? N
59
70
  ) : /* @__PURE__ */ n(
60
- O,
71
+ x,
61
72
  {
62
73
  item: o,
63
74
  onClick: l,
64
- onAction: v
75
+ onAction: g
65
76
  },
66
- o.value ?? o.label ?? C
77
+ o.value ?? o.label ?? N
67
78
  )
68
79
  ) })
69
80
  ]
70
81
  }
71
82
  );
72
- }, k = (e) => /* @__PURE__ */ u(c.Sub, { children: [
73
- /* @__PURE__ */ n(c.Sub.Target, { children: /* @__PURE__ */ n(R, { ...e }) }),
74
- /* @__PURE__ */ n(c.Sub.Dropdown, { children: e.subItems.map((l, t) => l.children && l.children.length > 0 ? /* @__PURE__ */ n(
83
+ }, k = (e) => /* @__PURE__ */ u(s.Sub, { children: [
84
+ /* @__PURE__ */ n(s.Sub.Target, { children: /* @__PURE__ */ n(z, { ...e }) }),
85
+ /* @__PURE__ */ n(s.Sub.Dropdown, { children: e.subItems.map((l, a) => l.children && l.children.length > 0 ? /* @__PURE__ */ n(
75
86
  k,
76
87
  {
77
88
  target: l,
@@ -79,38 +90,38 @@ const H = ({
79
90
  onClick: e.onClick,
80
91
  onAction: e.onAction
81
92
  },
82
- l.value ?? l.label ?? t
93
+ l.value ?? l.label ?? a
83
94
  ) : /* @__PURE__ */ n(
84
- O,
95
+ x,
85
96
  {
86
97
  item: l,
87
98
  onClick: e.onClick,
88
99
  onAction: e.onAction
89
100
  },
90
- l.value ?? l.label ?? t
101
+ l.value ?? l.label ?? a
91
102
  )) })
92
- ] }), O = ({
103
+ ] }), x = ({
93
104
  item: e,
94
105
  onClick: l,
95
- onAction: t
106
+ onAction: a
96
107
  }) => {
97
- const a = e.type ?? "option";
98
- return a === "divider" || a === "thick-divider" ? /* @__PURE__ */ n(c.Divider, {}) : a === "label" ? /* @__PURE__ */ n(c.Label, { children: e.label }) : /* @__PURE__ */ n(B, { item: e, onClick: l, onAction: t });
108
+ const t = e.type ?? "option";
109
+ return t === "divider" || t === "thick-divider" ? /* @__PURE__ */ n(s.Divider, {}) : t === "label" ? /* @__PURE__ */ n(s.Label, { children: e.label }) : /* @__PURE__ */ n(V, { item: e, onClick: l, onAction: a });
99
110
  };
100
- function w(e) {
101
- return /* @__PURE__ */ u(m, { children: [
102
- e.description && /* @__PURE__ */ n(E, { className: i.labelHeader, fz: 12, lh: "20px", children: e.description }),
111
+ function y(e) {
112
+ return /* @__PURE__ */ u(O, { children: [
113
+ e.description && /* @__PURE__ */ n(M, { className: c.labelHeader, fz: 12, lh: "20px", children: e.description }),
103
114
  e.rightIconButtonProps && /* @__PURE__ */ n(
104
115
  T,
105
116
  {
106
117
  label: e.rightIconTooltip ?? "",
107
118
  disabled: !e.rightIconTooltip || e.disabled,
108
119
  children: /* @__PURE__ */ n(
109
- x,
120
+ B,
110
121
  {
111
122
  variant: "text",
112
123
  color: "regular",
113
- iconClassName: i.submenuIcon,
124
+ iconClassName: c.submenuIcon,
114
125
  ...e.rightIconButtonProps,
115
126
  "aria-label": e.rightIconButtonProps["aria-label"] || e.rightIconTooltip,
116
127
  renderRoot: (l) => /* @__PURE__ */ n(S, { role: "button", ...l })
@@ -118,33 +129,33 @@ function w(e) {
118
129
  )
119
130
  }
120
131
  ),
121
- e.children && e.children.length > 0 && /* @__PURE__ */ n(S, { w: 22, h: 22, className: i.submenuIconWrap, children: /* @__PURE__ */ n(
122
- p,
132
+ e.children && e.children.length > 0 && /* @__PURE__ */ n(S, { w: 22, h: 22, className: c.submenuIconWrap, children: /* @__PURE__ */ n(
133
+ I,
123
134
  {
124
135
  name: "right",
125
136
  width: 16,
126
137
  height: 16,
127
- className: i.submenuIcon
138
+ className: c.submenuIcon
128
139
  }
129
140
  ) })
130
141
  ] });
131
142
  }
132
- function B({
143
+ function V({
133
144
  item: e,
134
145
  onClick: l,
135
- onAction: t
146
+ onAction: a
136
147
  }) {
137
- const a = e.dangerous && !e.disabled, h = e.labelClassName ?? (a ? i.dangerous : void 0), b = e.leftIconClassName ?? (a ? i.dangerous : void 0);
138
- return /* @__PURE__ */ u("div", { className: i.relative, children: [
148
+ const t = e.dangerous && !e.disabled, h = e.labelClassName ?? (t ? c.dangerous : void 0), b = e.leftIconClassName ?? (t ? c.dangerous : void 0);
149
+ return /* @__PURE__ */ u("div", { className: c.relative, children: [
139
150
  e.disabled && e.disabledTooltip && /* @__PURE__ */ n(T, { label: e.disabledTooltip, children: /* @__PURE__ */ n(
140
151
  "div",
141
152
  {
142
- className: i.disabledOverlay,
143
- onClickCapture: (s) => s.stopPropagation()
153
+ className: c.disabledOverlay,
154
+ onClickCapture: (i) => i.stopPropagation()
144
155
  }
145
156
  ) }),
146
157
  /* @__PURE__ */ n(
147
- c.Item,
158
+ s.Item,
148
159
  {
149
160
  component: "button",
150
161
  type: "button",
@@ -153,7 +164,7 @@ function B({
153
164
  itemLabel: h
154
165
  },
155
166
  leftSection: e.leftIconName && /* @__PURE__ */ n(
156
- p,
167
+ I,
157
168
  {
158
169
  name: e.leftIconName,
159
170
  width: 16,
@@ -162,37 +173,37 @@ function B({
162
173
  useOriginalColor: e.leftUseOriginalColor
163
174
  }
164
175
  ),
165
- rightSection: w(e),
176
+ rightSection: y(e),
166
177
  disabled: e.disabled,
167
- onClick: (s) => {
168
- t(), e.onClick && e.onClick(s, e), l && l(s, e);
178
+ onClick: (i) => {
179
+ a(), e.onClick && e.onClick(i, e), l && l(i, e);
169
180
  },
170
181
  children: e.label
171
182
  }
172
183
  )
173
184
  ] });
174
185
  }
175
- function R({
186
+ function z({
176
187
  target: e,
177
188
  subItems: l,
178
- ref: t,
179
- ...a
189
+ ref: a,
190
+ ...t
180
191
  }) {
181
192
  return /* @__PURE__ */ n(
182
- c.Sub.Item,
193
+ s.Sub.Item,
183
194
  {
184
- ref: t,
195
+ ref: a,
185
196
  component: "button",
186
197
  type: "button",
187
198
  "data-testid": e["data-testid"],
188
- leftSection: e.leftIconName && /* @__PURE__ */ n(p, { name: e.leftIconName, width: 16, height: 16 }),
199
+ leftSection: e.leftIconName && /* @__PURE__ */ n(I, { name: e.leftIconName, width: 16, height: 16 }),
189
200
  disabled: e.disabled,
190
- rightSection: w(e),
191
- ...a,
201
+ rightSection: y(e),
202
+ ...t,
192
203
  children: e.label
193
204
  }
194
205
  );
195
206
  }
196
207
  export {
197
- H as MenuWeb
208
+ q as MenuWeb
198
209
  };
@@ -0,0 +1 @@
1
+ export { Portal } from './portal';
@@ -0,0 +1,5 @@
1
+ "use client";
2
+ import { Portal as r } from "./portal.js";
3
+ export {
4
+ r as Portal
5
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ /**
3
+ * 把内容挂到浮层的挂载点上。
4
+ *
5
+ * 挂载点来自 `UiProvider` 的 `portalRoot`:传了就挂到那里,没传就挂 `document.body`。
6
+ * 它是宿主传进来的普通值,render 期就能求值,所以不需要「先渲染 null、等 effect
7
+ * 解析挂载点再渲染」那两段 —— 挂载点在首帧就是最终值。
8
+ *
9
+ * 服务端和水合阶段什么都不渲染,避免对不上;之后的客户端渲染直接挂,没有多出来的一帧。
10
+ * `document.body` 只在客户端那次求值,服务端走不到这里。
11
+ */
12
+ export declare function Portal({ children }: Readonly<{
13
+ children?: React.ReactNode;
14
+ }>): React.ReactPortal | null;
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { useSyncExternalStore as e } from "react";
3
+ import { createPortal as r } from "react-dom";
4
+ import "../../../provider/ui-context.js";
5
+ import "react/jsx-runtime";
6
+ import { useUiContext as n } from "../../../provider/hooks.js";
7
+ const i = () => () => {
8
+ }, s = () => !0, c = () => !1;
9
+ function S({ children: t }) {
10
+ const { portalRoot: o } = n();
11
+ return e(
12
+ i,
13
+ s,
14
+ c
15
+ ) ? r(t, o ?? document.body) : null;
16
+ }
17
+ export {
18
+ S as Portal
19
+ };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- const t = "_buttonVar_xuom7_2", a = {
2
+ const t = "_buttonVar_1oymn_2", a = {
3
3
  buttonVar: t
4
4
  };
5
5
  export {
@@ -29,5 +29,5 @@ export type DrawerProps = Omit<MantineDrawerProps, 'closeButtonProps' | 'title'
29
29
  /**
30
30
  * Pc端抽屉组件
31
31
  */
32
- export declare const Drawer: ({ children, withCloseButton, withXPadding, topPadding, headerAlign, title, classNames, "aria-label": ariaLabel, ...props }: DrawerProps) => import("react").JSX.Element;
32
+ export declare const Drawer: ({ children, withCloseButton, withXPadding, topPadding, headerAlign, title, classNames, "aria-label": ariaLabel, ref, ...props }: DrawerProps) => import("react").JSX.Element;
33
33
  export {};
@@ -1,63 +1,71 @@
1
1
  "use client";
2
- import { jsxs as m, jsx as a } from "react/jsx-runtime";
3
- import { Drawer as u, Text as f } from "@mantine/core";
2
+ import { jsx as o, jsxs as f } from "react/jsx-runtime";
3
+ import { Drawer as w, Text as C } from "@mantine/core";
4
+ import { useMergedRef as v } from "@mantine/hooks";
4
5
  import { clsx as t } from "clsx";
5
6
  import "../../provider/ui-context.js";
6
7
  import "react";
7
- import { useLocale as C } from "../../provider/hooks.js";
8
- import { IconButton as w } from "../icon-button/icon-button.js";
8
+ import { useLocale as x } from "../../provider/hooks.js";
9
+ import { IconButton as D } from "../icon-button/icon-button.js";
10
+ import { OverlayParentProvider as O } from "../overlay-layer/overlay-parent-context.js";
11
+ import { useMantineOverlayLayer as T } from "../overlay-layer/use-mantine-overlay-layer.js";
9
12
  import e from "./drawer.module.css.js";
10
- const S = ({
13
+ const L = ({
11
14
  children: r,
12
15
  withCloseButton: i = !0,
13
- withXPadding: d = !0,
16
+ withXPadding: c = !0,
14
17
  topPadding: l = !0,
15
18
  headerAlign: h = "center",
16
- title: o,
17
- classNames: n,
19
+ title: n,
20
+ classNames: a,
18
21
  "aria-label": g,
19
- ...s
22
+ ref: u,
23
+ ...d
20
24
  }) => {
21
- const c = o || i;
22
- return /* @__PURE__ */ m(
23
- u,
25
+ const s = T("Drawer", d, "drawer"), y = v(s.rootRef, u), m = n || i;
26
+ return /* @__PURE__ */ o(
27
+ w,
24
28
  {
25
29
  position: "right",
26
- ...s,
27
- title: g ?? (typeof o == "string" ? o : void 0),
30
+ ...d,
31
+ ref: y,
32
+ zIndex: s.zIndex,
33
+ closeOnEscape: !1,
34
+ closeOnClickOutside: !1,
35
+ title: g ?? (typeof n == "string" ? n : void 0),
28
36
  withCloseButton: !1,
29
37
  classNames: {
30
- ...n,
31
- header: t(e.hiddenHeader, n?.header),
32
- body: t(e.drawerBody, n?.body),
33
- content: t(e.drawerContent, n?.content)
38
+ ...a,
39
+ header: t(e.hiddenHeader, a?.header),
40
+ body: t(e.drawerBody, a?.body),
41
+ content: t(e.drawerContent, a?.content)
34
42
  },
35
- children: [
36
- c && /* @__PURE__ */ a(
37
- x,
43
+ children: /* @__PURE__ */ f(O, { id: s.id, children: [
44
+ m && /* @__PURE__ */ o(
45
+ b,
38
46
  {
39
- title: o,
47
+ title: n,
40
48
  withCloseButton: i,
41
49
  headerAlign: h,
42
- onClose: s.onClose
50
+ onClose: d.onClose
43
51
  }
44
52
  ),
45
- /* @__PURE__ */ a(
53
+ /* @__PURE__ */ o(
46
54
  "div",
47
55
  {
48
56
  className: t(e.main, {
49
- [e.mainXPadding]: d,
50
- [e.mainTopPadding]: !c && l
57
+ [e.mainXPadding]: c,
58
+ [e.mainTopPadding]: !m && l
51
59
  }),
52
60
  children: r
53
61
  }
54
62
  )
55
- ]
63
+ ] })
56
64
  }
57
65
  );
58
- }, x = (r) => {
59
- const i = C(), l = typeof r.title == "string" ? f : "div";
60
- return /* @__PURE__ */ m(
66
+ }, b = (r) => {
67
+ const i = x(), l = typeof r.title == "string" ? C : "div";
68
+ return /* @__PURE__ */ f(
61
69
  "div",
62
70
  {
63
71
  className: t(e.header, {
@@ -65,9 +73,9 @@ const S = ({
65
73
  [e.headerAlignStart]: r.headerAlign === "start"
66
74
  }),
67
75
  children: [
68
- /* @__PURE__ */ a(l, { className: e.headerTitle, children: r.title }),
69
- r.withCloseButton && /* @__PURE__ */ a(
70
- w,
76
+ /* @__PURE__ */ o(l, { className: e.headerTitle, children: r.title }),
77
+ r.withCloseButton && /* @__PURE__ */ o(
78
+ D,
71
79
  {
72
80
  variant: "text",
73
81
  color: "regular",
@@ -82,5 +90,5 @@ const S = ({
82
90
  );
83
91
  };
84
92
  export {
85
- S as Drawer
93
+ L as Drawer
86
94
  };
@@ -1,2 +1,2 @@
1
1
  export { Modal } from './modal';
2
- export type { ModalProps } from './modal';
2
+ export type { ModalClassNames, ModalCloseButtonProps, ModalOverlayProps, ModalProps, ModalSizePreset, ModalSpacingPreset, } from './modal.types';
@@ -1,6 +1,9 @@
1
- import { Modal as MModal } from '@mantine/core';
2
- export type ModalProps = Omit<Parameters<typeof MModal>[0], 'closeButtonProps'>;
1
+ import React from 'react';
2
+ import type { ModalProps } from './modal.types';
3
3
  /**
4
- * Pc端弹窗组件
4
+ * 对话框(自建实现)。
5
+ *
6
+ * 层级、Escape、点遮罩都交给层级模块 `overlay-layer`:层级按打开顺序计算,
7
+ * Escape 只关最上层,写在 Popover 里面还是外面结果一样。
5
8
  */
6
- export declare const Modal: ({ children, withCloseButton, title, ...props }: ModalProps) => import("react").JSX.Element;
9
+ export declare const Modal: ({ opened, onClose, title, children, centered, size, classNames, className, zIndex, padding, radius, withCloseButton, closeOnClickOutside, closeOnEscape, closeButtonProps, onExitTransitionEnd, transitionProps, overlayProps, onClick, keepMounted, yOffset, xOffset, "aria-label": ariaLabel, }: ModalProps) => React.JSX.Element | null;