@wisdomgarden/torque 0.2.2 → 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.
- package/dist/components/_inner/drawer/base-bottom-drawer.d.ts +1 -1
- package/dist/components/_inner/drawer/base-bottom-drawer.js +52 -44
- package/dist/components/_inner/menu/_web/menu.web.js +83 -72
- package/dist/components/_inner/portal/index.d.ts +1 -0
- package/dist/components/_inner/portal/index.js +5 -0
- package/dist/components/_inner/portal/portal.d.ts +14 -0
- package/dist/components/_inner/portal/portal.js +19 -0
- package/dist/components/button/styles/button-variables.module.css.js +1 -1
- package/dist/components/drawer/drawer.d.ts +1 -1
- package/dist/components/drawer/drawer.js +42 -34
- package/dist/components/modal/index.d.ts +1 -1
- package/dist/components/modal/modal.d.ts +7 -4
- package/dist/components/modal/modal.js +191 -44
- package/dist/components/modal/modal.module.css.js +20 -6
- package/dist/components/modal/modal.types.d.ts +96 -0
- package/dist/components/modal-deprecated/index.d.ts +2 -0
- package/dist/components/modal-deprecated/index.js +5 -0
- package/dist/components/modal-deprecated/modal-deprecated.d.ts +11 -0
- package/dist/components/modal-deprecated/modal-deprecated.js +70 -0
- package/dist/components/modal-deprecated/modal-deprecated.module.css.js +10 -0
- package/dist/components/notifications/index.d.ts +2 -0
- package/dist/components/notifications/index.js +4 -2
- package/dist/components/notifications/notifications-container.d.ts +9 -0
- package/dist/components/notifications/notifications-container.js +22 -0
- package/dist/components/overlay-layer/constants.d.ts +14 -0
- package/dist/components/overlay-layer/constants.js +8 -0
- package/dist/components/overlay-layer/index.d.ts +5 -0
- package/dist/components/overlay-layer/index.js +10 -0
- package/dist/components/overlay-layer/overlay-parent-context.d.ts +6 -0
- package/dist/components/overlay-layer/overlay-parent-context.js +18 -0
- package/dist/components/overlay-layer/overlay-stack-debug.d.ts +24 -0
- package/dist/components/overlay-layer/overlay-stack-debug.js +151 -0
- package/dist/components/overlay-layer/overlay-stack.d.ts +38 -0
- package/dist/components/overlay-layer/overlay-stack.js +137 -0
- package/dist/components/overlay-layer/overlay-tier-scope.d.ts +12 -0
- package/dist/components/overlay-layer/overlay-tier-scope.js +16 -0
- package/dist/components/overlay-layer/types.d.ts +63 -0
- package/dist/components/overlay-layer/use-mantine-overlay-layer.d.ts +21 -0
- package/dist/components/overlay-layer/use-mantine-overlay-layer.js +24 -0
- package/dist/components/overlay-layer/use-overlay-layer.d.ts +26 -0
- package/dist/components/overlay-layer/use-overlay-layer.js +77 -0
- package/dist/components/popover/hooks.d.ts +0 -1
- package/dist/components/popover/hooks.js +69 -83
- package/dist/components/popover/popover-context.d.ts +0 -1
- package/dist/components/popover/popover-context.js +3 -4
- package/dist/components/popover/popover-dropdown.js +110 -91
- package/dist/components/popover/popover.js +134 -150
- package/dist/components/popover/popover.types.d.ts +7 -3
- package/dist/components/tooltip/index.d.ts +10 -2
- package/dist/components/tooltip/index.js +100 -92
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +193 -182
- package/dist/provider/ui-context.d.ts +10 -0
- package/dist/provider/ui-context.js +8 -7
- package/dist/provider/ui-provider.d.ts +23 -1
- package/dist/provider/ui-provider.js +17 -10
- package/package.json +3 -3
- package/dist/components/popover/popover-stack.d.ts +0 -10
- 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 {
|
|
3
|
-
import { Drawer as
|
|
4
|
-
import {
|
|
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
|
|
8
|
-
import
|
|
9
|
-
import { IconButton as
|
|
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
|
|
14
|
+
const q = ({
|
|
12
15
|
withCloseButton: e = !0,
|
|
13
|
-
title:
|
|
16
|
+
title: t,
|
|
14
17
|
"aria-label": m,
|
|
15
|
-
children:
|
|
18
|
+
children: c,
|
|
16
19
|
bottomSection: n,
|
|
17
|
-
height:
|
|
20
|
+
height: f = "fit-content",
|
|
18
21
|
noMinHeight: h = !1,
|
|
19
22
|
contentClassName: w,
|
|
20
|
-
bodyClassName:
|
|
21
|
-
|
|
23
|
+
bodyClassName: u,
|
|
24
|
+
ref: y,
|
|
25
|
+
...s
|
|
22
26
|
}) => {
|
|
23
|
-
const B =
|
|
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__ */
|
|
27
|
-
|
|
30
|
+
/* @__PURE__ */ r(
|
|
31
|
+
x,
|
|
28
32
|
{
|
|
29
|
-
...
|
|
33
|
+
...s,
|
|
34
|
+
ref: B,
|
|
35
|
+
zIndex: i.zIndex,
|
|
36
|
+
closeOnEscape: !1,
|
|
37
|
+
closeOnClickOutside: !1,
|
|
30
38
|
position: "bottom",
|
|
31
|
-
title: m ?? (typeof
|
|
39
|
+
title: m ?? (typeof t == "string" ? t : void 0),
|
|
32
40
|
withCloseButton: !1,
|
|
33
41
|
styles: {
|
|
34
42
|
content: {
|
|
35
|
-
height:
|
|
43
|
+
height: f
|
|
36
44
|
}
|
|
37
45
|
},
|
|
38
46
|
classNames: {
|
|
39
|
-
content:
|
|
40
|
-
|
|
41
|
-
n &&
|
|
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:
|
|
47
|
-
body:
|
|
48
|
-
|
|
49
|
-
n &&
|
|
50
|
-
|
|
54
|
+
header: o.hiddenHeader,
|
|
55
|
+
body: d(
|
|
56
|
+
o.drawerBody,
|
|
57
|
+
n && o.drawerBodyWithBottomSection,
|
|
58
|
+
u
|
|
51
59
|
)
|
|
52
60
|
},
|
|
53
|
-
children: [
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
children: /* @__PURE__ */ l(H, { id: i.id, children: [
|
|
62
|
+
C && /* @__PURE__ */ r(
|
|
63
|
+
R,
|
|
56
64
|
{
|
|
57
|
-
title:
|
|
65
|
+
title: t,
|
|
58
66
|
withCloseButton: e,
|
|
59
|
-
onClose:
|
|
67
|
+
onClose: s.onClose
|
|
60
68
|
}
|
|
61
69
|
),
|
|
62
|
-
n ? /* @__PURE__ */
|
|
63
|
-
/* @__PURE__ */ r("div", { className:
|
|
64
|
-
/* @__PURE__ */ r("div", { className:
|
|
65
|
-
] }) :
|
|
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
|
-
},
|
|
71
|
-
const
|
|
72
|
-
return /* @__PURE__ */
|
|
73
|
-
e.withCloseButton && /* @__PURE__ */ r(
|
|
74
|
-
/* @__PURE__ */ r(
|
|
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
|
-
|
|
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":
|
|
92
|
+
"aria-label": t.close
|
|
85
93
|
}
|
|
86
94
|
)
|
|
87
95
|
] });
|
|
88
96
|
};
|
|
89
97
|
export {
|
|
90
|
-
|
|
98
|
+
q as BaseBottomDrawer
|
|
91
99
|
};
|
|
@@ -1,77 +1,88 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as n, Fragment as
|
|
3
|
-
import { Menu as
|
|
4
|
-
import { Icon as
|
|
5
|
-
import d, { useState as
|
|
6
|
-
import { IconButton as
|
|
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
|
|
9
|
-
const
|
|
9
|
+
import c from "./menu-web.module.css.js";
|
|
10
|
+
const q = ({
|
|
10
11
|
menuItems: e,
|
|
11
12
|
onClick: l,
|
|
12
|
-
children:
|
|
13
|
-
disabled:
|
|
13
|
+
children: a,
|
|
14
|
+
disabled: t,
|
|
14
15
|
triggerAriaLabel: h,
|
|
15
16
|
renderTarget: b,
|
|
16
|
-
trigger:
|
|
17
|
-
position:
|
|
18
|
-
"data-testid":
|
|
17
|
+
trigger: i = "click-hover",
|
|
18
|
+
position: w,
|
|
19
|
+
"data-testid": v
|
|
19
20
|
}) => {
|
|
20
|
-
const [
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
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(
|
|
33
|
+
return /* @__PURE__ */ n(O, { children: d.isValidElement(r) ? d.cloneElement(
|
|
26
34
|
r,
|
|
27
35
|
{
|
|
28
36
|
disabled: !0,
|
|
29
|
-
"data-testid":
|
|
37
|
+
"data-testid": v ?? o?.["data-testid"]
|
|
30
38
|
}
|
|
31
39
|
) : r });
|
|
32
40
|
}
|
|
33
|
-
const
|
|
41
|
+
const C = d.isValidElement(r) ? r.props : void 0;
|
|
34
42
|
return /* @__PURE__ */ u(
|
|
35
|
-
|
|
43
|
+
s,
|
|
36
44
|
{
|
|
37
|
-
trigger:
|
|
38
|
-
opened:
|
|
39
|
-
onChange:
|
|
40
|
-
position:
|
|
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(
|
|
53
|
+
/* @__PURE__ */ n(s.Target, { ref: f, children: d.isValidElement(r) ? d.cloneElement(
|
|
43
54
|
r,
|
|
44
55
|
{
|
|
45
|
-
"aria-label": h ??
|
|
46
|
-
"data-testid":
|
|
56
|
+
"aria-label": h ?? C?.["aria-label"],
|
|
57
|
+
"data-testid": v ?? C?.["data-testid"]
|
|
47
58
|
}
|
|
48
59
|
) : r }),
|
|
49
|
-
/* @__PURE__ */ n(
|
|
50
|
-
(o,
|
|
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:
|
|
67
|
+
onAction: g
|
|
57
68
|
},
|
|
58
|
-
o.value ?? o.label ??
|
|
69
|
+
o.value ?? o.label ?? N
|
|
59
70
|
) : /* @__PURE__ */ n(
|
|
60
|
-
|
|
71
|
+
x,
|
|
61
72
|
{
|
|
62
73
|
item: o,
|
|
63
74
|
onClick: l,
|
|
64
|
-
onAction:
|
|
75
|
+
onAction: g
|
|
65
76
|
},
|
|
66
|
-
o.value ?? o.label ??
|
|
77
|
+
o.value ?? o.label ?? N
|
|
67
78
|
)
|
|
68
79
|
) })
|
|
69
80
|
]
|
|
70
81
|
}
|
|
71
82
|
);
|
|
72
|
-
}, k = (e) => /* @__PURE__ */ u(
|
|
73
|
-
/* @__PURE__ */ n(
|
|
74
|
-
/* @__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 ??
|
|
93
|
+
l.value ?? l.label ?? a
|
|
83
94
|
) : /* @__PURE__ */ n(
|
|
84
|
-
|
|
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 ??
|
|
101
|
+
l.value ?? l.label ?? a
|
|
91
102
|
)) })
|
|
92
|
-
] }),
|
|
103
|
+
] }), x = ({
|
|
93
104
|
item: e,
|
|
94
105
|
onClick: l,
|
|
95
|
-
onAction:
|
|
106
|
+
onAction: a
|
|
96
107
|
}) => {
|
|
97
|
-
const
|
|
98
|
-
return
|
|
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
|
|
101
|
-
return /* @__PURE__ */ u(
|
|
102
|
-
e.description && /* @__PURE__ */ n(
|
|
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
|
-
|
|
120
|
+
B,
|
|
110
121
|
{
|
|
111
122
|
variant: "text",
|
|
112
123
|
color: "regular",
|
|
113
|
-
iconClassName:
|
|
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:
|
|
122
|
-
|
|
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:
|
|
138
|
+
className: c.submenuIcon
|
|
128
139
|
}
|
|
129
140
|
) })
|
|
130
141
|
] });
|
|
131
142
|
}
|
|
132
|
-
function
|
|
143
|
+
function V({
|
|
133
144
|
item: e,
|
|
134
145
|
onClick: l,
|
|
135
|
-
onAction:
|
|
146
|
+
onAction: a
|
|
136
147
|
}) {
|
|
137
|
-
const
|
|
138
|
-
return /* @__PURE__ */ u("div", { className:
|
|
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:
|
|
143
|
-
onClickCapture: (
|
|
153
|
+
className: c.disabledOverlay,
|
|
154
|
+
onClickCapture: (i) => i.stopPropagation()
|
|
144
155
|
}
|
|
145
156
|
) }),
|
|
146
157
|
/* @__PURE__ */ n(
|
|
147
|
-
|
|
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
|
-
|
|
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:
|
|
176
|
+
rightSection: y(e),
|
|
166
177
|
disabled: e.disabled,
|
|
167
|
-
onClick: (
|
|
168
|
-
|
|
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
|
|
186
|
+
function z({
|
|
176
187
|
target: e,
|
|
177
188
|
subItems: l,
|
|
178
|
-
ref:
|
|
179
|
-
...
|
|
189
|
+
ref: a,
|
|
190
|
+
...t
|
|
180
191
|
}) {
|
|
181
192
|
return /* @__PURE__ */ n(
|
|
182
|
-
|
|
193
|
+
s.Sub.Item,
|
|
183
194
|
{
|
|
184
|
-
ref:
|
|
195
|
+
ref: a,
|
|
185
196
|
component: "button",
|
|
186
197
|
type: "button",
|
|
187
198
|
"data-testid": e["data-testid"],
|
|
188
|
-
leftSection: e.leftIconName && /* @__PURE__ */ n(
|
|
199
|
+
leftSection: e.leftIconName && /* @__PURE__ */ n(I, { name: e.leftIconName, width: 16, height: 16 }),
|
|
189
200
|
disabled: e.disabled,
|
|
190
|
-
rightSection:
|
|
191
|
-
...
|
|
201
|
+
rightSection: y(e),
|
|
202
|
+
...t,
|
|
192
203
|
children: e.label
|
|
193
204
|
}
|
|
194
205
|
);
|
|
195
206
|
}
|
|
196
207
|
export {
|
|
197
|
-
|
|
208
|
+
q as MenuWeb
|
|
198
209
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Portal } from './portal';
|
|
@@ -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
|
+
};
|
|
@@ -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 {
|
|
3
|
-
import { Drawer as
|
|
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
|
|
8
|
-
import { IconButton as
|
|
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
|
|
13
|
+
const L = ({
|
|
11
14
|
children: r,
|
|
12
15
|
withCloseButton: i = !0,
|
|
13
|
-
withXPadding:
|
|
16
|
+
withXPadding: c = !0,
|
|
14
17
|
topPadding: l = !0,
|
|
15
18
|
headerAlign: h = "center",
|
|
16
|
-
title:
|
|
17
|
-
classNames:
|
|
19
|
+
title: n,
|
|
20
|
+
classNames: a,
|
|
18
21
|
"aria-label": g,
|
|
19
|
-
|
|
22
|
+
ref: u,
|
|
23
|
+
...d
|
|
20
24
|
}) => {
|
|
21
|
-
const
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
-
|
|
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
|
-
...
|
|
27
|
-
|
|
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
|
-
...
|
|
31
|
-
header: t(e.hiddenHeader,
|
|
32
|
-
body: t(e.drawerBody,
|
|
33
|
-
content: t(e.drawerContent,
|
|
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
|
-
|
|
37
|
-
|
|
43
|
+
children: /* @__PURE__ */ f(O, { id: s.id, children: [
|
|
44
|
+
m && /* @__PURE__ */ o(
|
|
45
|
+
b,
|
|
38
46
|
{
|
|
39
|
-
title:
|
|
47
|
+
title: n,
|
|
40
48
|
withCloseButton: i,
|
|
41
49
|
headerAlign: h,
|
|
42
|
-
onClose:
|
|
50
|
+
onClose: d.onClose
|
|
43
51
|
}
|
|
44
52
|
),
|
|
45
|
-
/* @__PURE__ */
|
|
53
|
+
/* @__PURE__ */ o(
|
|
46
54
|
"div",
|
|
47
55
|
{
|
|
48
56
|
className: t(e.main, {
|
|
49
|
-
[e.mainXPadding]:
|
|
50
|
-
[e.mainTopPadding]: !
|
|
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
|
-
},
|
|
59
|
-
const i =
|
|
60
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
69
|
-
r.withCloseButton && /* @__PURE__ */
|
|
70
|
-
|
|
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
|
-
|
|
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
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ModalProps } from './modal.types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 对话框(自建实现)。
|
|
5
|
+
*
|
|
6
|
+
* 层级、Escape、点遮罩都交给层级模块 `overlay-layer`:层级按打开顺序计算,
|
|
7
|
+
* Escape 只关最上层,写在 Popover 里面还是外面结果一样。
|
|
5
8
|
*/
|
|
6
|
-
export declare const Modal: ({ children, withCloseButton,
|
|
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;
|