@fangxinyan/lumina 0.1.5 → 0.1.6
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/Drawer-IPGB4CXH.css +101 -0
- package/dist/Drawer.cjs +13 -0
- package/dist/Drawer.cjs.map +1 -0
- package/dist/Drawer.d.cts +45 -0
- package/dist/Drawer.d.ts +45 -0
- package/dist/Drawer.js +4 -0
- package/dist/Drawer.js.map +1 -0
- package/dist/Modal-N4YVLEWW.css +72 -0
- package/dist/Modal.cjs +2 -6
- package/dist/Modal.d.cts +37 -8
- package/dist/Modal.d.ts +37 -8
- package/dist/Modal.js +1 -1
- package/dist/chunk-AEJJGUEN.cjs +127 -0
- package/dist/chunk-AEJJGUEN.cjs.map +1 -0
- package/dist/chunk-IWVKITPN.js +102 -0
- package/dist/chunk-IWVKITPN.js.map +1 -0
- package/dist/chunk-OOBSH7EL.js +125 -0
- package/dist/chunk-OOBSH7EL.js.map +1 -0
- package/dist/chunk-QQXIWOI3.cjs +150 -0
- package/dist/chunk-QQXIWOI3.cjs.map +1 -0
- package/dist/index.cjs +22 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/styles.css +111 -20
- package/package.json +1 -1
- package/dist/Modal-AYKNIWWQ.css +0 -79
- package/dist/chunk-KF4MCHZL.cjs +0 -105
- package/dist/chunk-KF4MCHZL.cjs.map +0 -1
- package/dist/chunk-Q33V7MSK.js +0 -79
- package/dist/chunk-Q33V7MSK.js.map +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* ============ Drawer ============ */
|
|
2
|
+
.drawer-overlay {
|
|
3
|
+
position: fixed;
|
|
4
|
+
inset: 0;
|
|
5
|
+
background: color-mix(in oklch, var(--bg-sunken) 50%, transparent);
|
|
6
|
+
backdrop-filter: blur(4px);
|
|
7
|
+
z-index: 150;
|
|
8
|
+
animation: fadeIn var(--dur) var(--ease);
|
|
9
|
+
}
|
|
10
|
+
.drawer-overlay.hidden {
|
|
11
|
+
display: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.drawer {
|
|
15
|
+
position: fixed;
|
|
16
|
+
background: var(--bg);
|
|
17
|
+
padding: var(--gap-5);
|
|
18
|
+
z-index: 151;
|
|
19
|
+
overflow-y: auto;
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
}
|
|
23
|
+
.drawer.hidden {
|
|
24
|
+
display: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.drawer.right {
|
|
28
|
+
top: 0; right: 0; bottom: 0;
|
|
29
|
+
width: min(420px, 92vw);
|
|
30
|
+
animation: drawerInRight var(--dur-slow) var(--ease);
|
|
31
|
+
box-shadow: -24px 0 60px -20px rgba(40, 55, 80, 0.25);
|
|
32
|
+
}
|
|
33
|
+
.drawer.left {
|
|
34
|
+
top: 0; left: 0; bottom: 0;
|
|
35
|
+
width: min(420px, 92vw);
|
|
36
|
+
animation: drawerInLeft var(--dur-slow) var(--ease);
|
|
37
|
+
box-shadow: 24px 0 60px -20px rgba(40, 55, 80, 0.25);
|
|
38
|
+
}
|
|
39
|
+
.drawer.top {
|
|
40
|
+
top: 0; left: 0; right: 0;
|
|
41
|
+
height: min(320px, 80vh);
|
|
42
|
+
animation: drawerInTop var(--dur-slow) var(--ease);
|
|
43
|
+
box-shadow: 0 24px 60px -20px rgba(40, 55, 80, 0.25);
|
|
44
|
+
}
|
|
45
|
+
.drawer.bottom {
|
|
46
|
+
bottom: 0; left: 0; right: 0;
|
|
47
|
+
height: min(320px, 80vh);
|
|
48
|
+
animation: drawerInBottom var(--dur-slow) var(--ease);
|
|
49
|
+
box-shadow: 0 -24px 60px -20px rgba(40, 55, 80, 0.25);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@keyframes drawerInRight { from { transform: translateX( 20px); opacity: 0; } }
|
|
53
|
+
@keyframes drawerInLeft { from { transform: translateX(-20px); opacity: 0; } }
|
|
54
|
+
@keyframes drawerInTop { from { transform: translateY(-20px); opacity: 0; } }
|
|
55
|
+
@keyframes drawerInBottom { from { transform: translateY( 20px); opacity: 0; } }
|
|
56
|
+
|
|
57
|
+
.drawer-head {
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: space-between;
|
|
61
|
+
gap: var(--gap-3);
|
|
62
|
+
margin-bottom: var(--gap-4);
|
|
63
|
+
padding-bottom: var(--gap-4);
|
|
64
|
+
border-bottom: 1px solid var(--divider);
|
|
65
|
+
}
|
|
66
|
+
.drawer-head-right {
|
|
67
|
+
display: inline-flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: var(--gap-3);
|
|
70
|
+
}
|
|
71
|
+
.drawer-title {
|
|
72
|
+
font-size: 16px;
|
|
73
|
+
font-weight: 600;
|
|
74
|
+
}
|
|
75
|
+
.drawer-close {
|
|
76
|
+
width: 28px; height: 28px;
|
|
77
|
+
border: none;
|
|
78
|
+
background: transparent;
|
|
79
|
+
border-radius: var(--r-sm);
|
|
80
|
+
display: grid;
|
|
81
|
+
place-items: center;
|
|
82
|
+
color: var(--fg-subtle);
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
transition: all var(--dur-fast) var(--ease);
|
|
85
|
+
}
|
|
86
|
+
.drawer-close:hover {
|
|
87
|
+
color: var(--fg);
|
|
88
|
+
background: var(--bg);
|
|
89
|
+
box-shadow: var(--neu-flat);
|
|
90
|
+
}
|
|
91
|
+
.drawer-body {
|
|
92
|
+
flex: 1;
|
|
93
|
+
}
|
|
94
|
+
.drawer-foot {
|
|
95
|
+
display: flex;
|
|
96
|
+
gap: 10px;
|
|
97
|
+
justify-content: flex-end;
|
|
98
|
+
margin-top: var(--gap-4);
|
|
99
|
+
padding-top: var(--gap-4);
|
|
100
|
+
border-top: 1px solid var(--divider);
|
|
101
|
+
}
|
package/dist/Drawer.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkAEJJGUEN_cjs = require('./chunk-AEJJGUEN.cjs');
|
|
4
|
+
require('./chunk-YVO7XO4W.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "Drawer", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkAEJJGUEN_cjs.Drawer; }
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=Drawer.cjs.map
|
|
13
|
+
//# sourceMappingURL=Drawer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"Drawer.cjs"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface DrawerProps {
|
|
4
|
+
/** Whether the drawer is visible. */
|
|
5
|
+
open: boolean;
|
|
6
|
+
/** Close callback (triggered by mask click / close button / Esc). */
|
|
7
|
+
onClose?: () => void;
|
|
8
|
+
/** Which edge the drawer slides from. */
|
|
9
|
+
placement?: "left" | "right" | "top" | "bottom";
|
|
10
|
+
/** Width (for left/right) or height (for top/bottom). Number → px. */
|
|
11
|
+
size?: number | string;
|
|
12
|
+
/** Header title. */
|
|
13
|
+
title?: React.ReactNode;
|
|
14
|
+
/** Extra content rendered to the right of the title (e.g. action buttons). */
|
|
15
|
+
extra?: React.ReactNode;
|
|
16
|
+
/** Footer content. */
|
|
17
|
+
footer?: React.ReactNode;
|
|
18
|
+
/** Drawer body. */
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
/** Render the mask overlay. Default true. Set `false` for a non-blocking drawer. */
|
|
21
|
+
mask?: boolean;
|
|
22
|
+
/** Close when clicking the mask. Default true. Ignored when `mask` is false. */
|
|
23
|
+
maskClosable?: boolean;
|
|
24
|
+
/** Close on Escape key. Default true. */
|
|
25
|
+
keyboard?: boolean;
|
|
26
|
+
/** Show the close (×) button in the header. Default true. */
|
|
27
|
+
closable?: boolean;
|
|
28
|
+
/** Override the close icon node. */
|
|
29
|
+
closeIcon?: React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* When true the drawer's children are unmounted every time it closes.
|
|
32
|
+
* Default `false` — children stay mounted across open/close cycles so
|
|
33
|
+
* internal state (form fields, scroll position) is preserved.
|
|
34
|
+
*/
|
|
35
|
+
destroyOnClose?: boolean;
|
|
36
|
+
/** Fires after the open/close animation finishes. */
|
|
37
|
+
afterOpenChange?: (open: boolean) => void;
|
|
38
|
+
/** Stack index for nested drawers. */
|
|
39
|
+
zIndex?: number;
|
|
40
|
+
className?: string;
|
|
41
|
+
}
|
|
42
|
+
/** `Drawer` — slide-in panel from an edge. */
|
|
43
|
+
declare const Drawer: React.FC<DrawerProps>;
|
|
44
|
+
|
|
45
|
+
export { Drawer, type DrawerProps };
|
package/dist/Drawer.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface DrawerProps {
|
|
4
|
+
/** Whether the drawer is visible. */
|
|
5
|
+
open: boolean;
|
|
6
|
+
/** Close callback (triggered by mask click / close button / Esc). */
|
|
7
|
+
onClose?: () => void;
|
|
8
|
+
/** Which edge the drawer slides from. */
|
|
9
|
+
placement?: "left" | "right" | "top" | "bottom";
|
|
10
|
+
/** Width (for left/right) or height (for top/bottom). Number → px. */
|
|
11
|
+
size?: number | string;
|
|
12
|
+
/** Header title. */
|
|
13
|
+
title?: React.ReactNode;
|
|
14
|
+
/** Extra content rendered to the right of the title (e.g. action buttons). */
|
|
15
|
+
extra?: React.ReactNode;
|
|
16
|
+
/** Footer content. */
|
|
17
|
+
footer?: React.ReactNode;
|
|
18
|
+
/** Drawer body. */
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
/** Render the mask overlay. Default true. Set `false` for a non-blocking drawer. */
|
|
21
|
+
mask?: boolean;
|
|
22
|
+
/** Close when clicking the mask. Default true. Ignored when `mask` is false. */
|
|
23
|
+
maskClosable?: boolean;
|
|
24
|
+
/** Close on Escape key. Default true. */
|
|
25
|
+
keyboard?: boolean;
|
|
26
|
+
/** Show the close (×) button in the header. Default true. */
|
|
27
|
+
closable?: boolean;
|
|
28
|
+
/** Override the close icon node. */
|
|
29
|
+
closeIcon?: React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* When true the drawer's children are unmounted every time it closes.
|
|
32
|
+
* Default `false` — children stay mounted across open/close cycles so
|
|
33
|
+
* internal state (form fields, scroll position) is preserved.
|
|
34
|
+
*/
|
|
35
|
+
destroyOnClose?: boolean;
|
|
36
|
+
/** Fires after the open/close animation finishes. */
|
|
37
|
+
afterOpenChange?: (open: boolean) => void;
|
|
38
|
+
/** Stack index for nested drawers. */
|
|
39
|
+
zIndex?: number;
|
|
40
|
+
className?: string;
|
|
41
|
+
}
|
|
42
|
+
/** `Drawer` — slide-in panel from an edge. */
|
|
43
|
+
declare const Drawer: React.FC<DrawerProps>;
|
|
44
|
+
|
|
45
|
+
export { Drawer, type DrawerProps };
|
package/dist/Drawer.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"Drawer.js"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* ============ Modal ============ */
|
|
2
|
+
.modal-overlay {
|
|
3
|
+
position: fixed;
|
|
4
|
+
inset: 0;
|
|
5
|
+
background: color-mix(in oklch, var(--bg-sunken) 60%, transparent);
|
|
6
|
+
backdrop-filter: blur(8px);
|
|
7
|
+
display: grid;
|
|
8
|
+
place-items: center;
|
|
9
|
+
z-index: 200;
|
|
10
|
+
animation: fadeIn var(--dur) var(--ease);
|
|
11
|
+
}
|
|
12
|
+
.modal-overlay.hidden {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
.modal {
|
|
16
|
+
background: var(--bg);
|
|
17
|
+
border-radius: var(--r-xl);
|
|
18
|
+
box-shadow: var(--neu-out-lg), 0 24px 60px -20px rgba(40, 55, 80, 0.3);
|
|
19
|
+
padding: var(--gap-6);
|
|
20
|
+
width: min(480px, 92vw);
|
|
21
|
+
animation: modalIn var(--dur-slow) var(--ease);
|
|
22
|
+
max-height: 86vh;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
}
|
|
26
|
+
@keyframes modalIn {
|
|
27
|
+
from { opacity: 0; transform: translateY(8px) scale(0.97); }
|
|
28
|
+
}
|
|
29
|
+
.modal-head {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: flex-start;
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
gap: var(--gap-3);
|
|
34
|
+
margin-bottom: var(--gap-3);
|
|
35
|
+
}
|
|
36
|
+
.modal-titles {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
gap: 4px;
|
|
40
|
+
}
|
|
41
|
+
.modal-title { font-size: 17px; font-weight: 600; }
|
|
42
|
+
.modal-desc { font-size: 13px; color: var(--fg-muted); }
|
|
43
|
+
.modal-body {
|
|
44
|
+
padding: var(--gap-3) 0;
|
|
45
|
+
color: var(--fg-muted);
|
|
46
|
+
font-size: 13px;
|
|
47
|
+
line-height: 1.6;
|
|
48
|
+
flex: 1;
|
|
49
|
+
overflow-y: auto;
|
|
50
|
+
}
|
|
51
|
+
.modal-foot {
|
|
52
|
+
display: flex;
|
|
53
|
+
gap: 10px;
|
|
54
|
+
justify-content: flex-end;
|
|
55
|
+
margin-top: var(--gap-4);
|
|
56
|
+
}
|
|
57
|
+
.modal-close {
|
|
58
|
+
width: 28px; height: 28px;
|
|
59
|
+
border: none;
|
|
60
|
+
background: transparent;
|
|
61
|
+
border-radius: var(--r-sm);
|
|
62
|
+
display: grid;
|
|
63
|
+
place-items: center;
|
|
64
|
+
color: var(--fg-subtle);
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
transition: all var(--dur-fast) var(--ease);
|
|
67
|
+
}
|
|
68
|
+
.modal-close:hover {
|
|
69
|
+
color: var(--fg);
|
|
70
|
+
background: var(--bg);
|
|
71
|
+
box-shadow: var(--neu-flat);
|
|
72
|
+
}
|
package/dist/Modal.cjs
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkQQXIWOI3_cjs = require('./chunk-QQXIWOI3.cjs');
|
|
4
4
|
require('./chunk-AAMYURWQ.cjs');
|
|
5
5
|
require('./chunk-YVO7XO4W.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
Object.defineProperty(exports, "Drawer", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () { return chunkKF4MCHZL_cjs.Drawer; }
|
|
12
|
-
});
|
|
13
9
|
Object.defineProperty(exports, "Modal", {
|
|
14
10
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkQQXIWOI3_cjs.Modal; }
|
|
16
12
|
});
|
|
17
13
|
//# sourceMappingURL=Modal.cjs.map
|
|
18
14
|
//# sourceMappingURL=Modal.cjs.map
|
package/dist/Modal.d.cts
CHANGED
|
@@ -1,27 +1,56 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { ButtonProps } from './Button.cjs';
|
|
3
|
+
import './Icon.cjs';
|
|
2
4
|
|
|
3
5
|
interface ModalProps {
|
|
6
|
+
/** Whether the modal is visible. */
|
|
4
7
|
open: boolean;
|
|
8
|
+
/** Fired by mask click / close button / Esc. Also the fallback for cancel. */
|
|
5
9
|
onClose?: () => void;
|
|
10
|
+
/** Dedicated Cancel callback. Falls back to `onClose` when omitted. */
|
|
11
|
+
onCancel?: () => void;
|
|
12
|
+
/** Fired when the default OK button is clicked. */
|
|
13
|
+
onOk?: () => void;
|
|
6
14
|
title?: React.ReactNode;
|
|
7
15
|
description?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Footer content. Pass `null` to hide the footer, or a custom node to
|
|
18
|
+
* replace the default OK / Cancel buttons.
|
|
19
|
+
*/
|
|
8
20
|
footer?: React.ReactNode;
|
|
9
21
|
children?: React.ReactNode;
|
|
10
22
|
width?: number | string;
|
|
23
|
+
/** Show the close (×) button. Default true. */
|
|
24
|
+
closable?: boolean;
|
|
25
|
+
/** Override the close icon node. */
|
|
26
|
+
closeIcon?: React.ReactNode;
|
|
11
27
|
/** Close when clicking the mask. Default true. */
|
|
12
28
|
maskClosable?: boolean;
|
|
13
29
|
/** Close on Escape key. Default true. */
|
|
14
30
|
escClosable?: boolean;
|
|
31
|
+
/** Label for the default OK button. */
|
|
32
|
+
okText?: React.ReactNode;
|
|
33
|
+
/** Label for the default Cancel button. */
|
|
34
|
+
cancelText?: React.ReactNode;
|
|
35
|
+
/** Extra props forwarded to the default OK button. */
|
|
36
|
+
okButtonProps?: Partial<ButtonProps>;
|
|
37
|
+
/** Extra props forwarded to the default Cancel button. */
|
|
38
|
+
cancelButtonProps?: Partial<ButtonProps>;
|
|
39
|
+
/** Show a spinner on the OK button (e.g. while an async submit is running). */
|
|
40
|
+
confirmLoading?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* When true the modal's children are unmounted every time it closes.
|
|
43
|
+
* Default `false` — children stay mounted so internal state survives
|
|
44
|
+
* reopens, matching antd's default.
|
|
45
|
+
*/
|
|
46
|
+
destroyOnClose?: boolean;
|
|
47
|
+
/** Fires after the open/close animation finishes. */
|
|
48
|
+
afterOpenChange?: (open: boolean) => void;
|
|
49
|
+
/** Override the z-index of the overlay. */
|
|
50
|
+
zIndex?: number;
|
|
15
51
|
className?: string;
|
|
16
52
|
}
|
|
17
53
|
/** `Modal` — centered dialog with mask. Renders into `document.body`. */
|
|
18
54
|
declare const Modal: React.FC<ModalProps>;
|
|
19
|
-
interface DrawerProps extends Omit<ModalProps, "width"> {
|
|
20
|
-
/** Edge the drawer slides from. */
|
|
21
|
-
placement?: "left" | "right" | "top" | "bottom";
|
|
22
|
-
size?: number | string;
|
|
23
|
-
}
|
|
24
|
-
/** `Drawer` — slide-in panel from an edge. */
|
|
25
|
-
declare const Drawer: React.FC<DrawerProps>;
|
|
26
55
|
|
|
27
|
-
export {
|
|
56
|
+
export { Modal, type ModalProps };
|
package/dist/Modal.d.ts
CHANGED
|
@@ -1,27 +1,56 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { ButtonProps } from './Button.js';
|
|
3
|
+
import './Icon.js';
|
|
2
4
|
|
|
3
5
|
interface ModalProps {
|
|
6
|
+
/** Whether the modal is visible. */
|
|
4
7
|
open: boolean;
|
|
8
|
+
/** Fired by mask click / close button / Esc. Also the fallback for cancel. */
|
|
5
9
|
onClose?: () => void;
|
|
10
|
+
/** Dedicated Cancel callback. Falls back to `onClose` when omitted. */
|
|
11
|
+
onCancel?: () => void;
|
|
12
|
+
/** Fired when the default OK button is clicked. */
|
|
13
|
+
onOk?: () => void;
|
|
6
14
|
title?: React.ReactNode;
|
|
7
15
|
description?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Footer content. Pass `null` to hide the footer, or a custom node to
|
|
18
|
+
* replace the default OK / Cancel buttons.
|
|
19
|
+
*/
|
|
8
20
|
footer?: React.ReactNode;
|
|
9
21
|
children?: React.ReactNode;
|
|
10
22
|
width?: number | string;
|
|
23
|
+
/** Show the close (×) button. Default true. */
|
|
24
|
+
closable?: boolean;
|
|
25
|
+
/** Override the close icon node. */
|
|
26
|
+
closeIcon?: React.ReactNode;
|
|
11
27
|
/** Close when clicking the mask. Default true. */
|
|
12
28
|
maskClosable?: boolean;
|
|
13
29
|
/** Close on Escape key. Default true. */
|
|
14
30
|
escClosable?: boolean;
|
|
31
|
+
/** Label for the default OK button. */
|
|
32
|
+
okText?: React.ReactNode;
|
|
33
|
+
/** Label for the default Cancel button. */
|
|
34
|
+
cancelText?: React.ReactNode;
|
|
35
|
+
/** Extra props forwarded to the default OK button. */
|
|
36
|
+
okButtonProps?: Partial<ButtonProps>;
|
|
37
|
+
/** Extra props forwarded to the default Cancel button. */
|
|
38
|
+
cancelButtonProps?: Partial<ButtonProps>;
|
|
39
|
+
/** Show a spinner on the OK button (e.g. while an async submit is running). */
|
|
40
|
+
confirmLoading?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* When true the modal's children are unmounted every time it closes.
|
|
43
|
+
* Default `false` — children stay mounted so internal state survives
|
|
44
|
+
* reopens, matching antd's default.
|
|
45
|
+
*/
|
|
46
|
+
destroyOnClose?: boolean;
|
|
47
|
+
/** Fires after the open/close animation finishes. */
|
|
48
|
+
afterOpenChange?: (open: boolean) => void;
|
|
49
|
+
/** Override the z-index of the overlay. */
|
|
50
|
+
zIndex?: number;
|
|
15
51
|
className?: string;
|
|
16
52
|
}
|
|
17
53
|
/** `Modal` — centered dialog with mask. Renders into `document.body`. */
|
|
18
54
|
declare const Modal: React.FC<ModalProps>;
|
|
19
|
-
interface DrawerProps extends Omit<ModalProps, "width"> {
|
|
20
|
-
/** Edge the drawer slides from. */
|
|
21
|
-
placement?: "left" | "right" | "top" | "bottom";
|
|
22
|
-
size?: number | string;
|
|
23
|
-
}
|
|
24
|
-
/** `Drawer` — slide-in panel from an edge. */
|
|
25
|
-
declare const Drawer: React.FC<DrawerProps>;
|
|
26
55
|
|
|
27
|
-
export {
|
|
56
|
+
export { Modal, type ModalProps };
|
package/dist/Modal.js
CHANGED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkYVO7XO4W_cjs = require('./chunk-YVO7XO4W.cjs');
|
|
4
|
+
require('./tokens-HWQ7KWPG.css');
|
|
5
|
+
require('./shared-NJHRNLRH.css');
|
|
6
|
+
require('./Drawer-IPGB4CXH.css');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var ReactDOM = require('react-dom');
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
+
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
function _interopNamespace(e) {
|
|
14
|
+
if (e && e.__esModule) return e;
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
Object.keys(e).forEach(function (k) {
|
|
18
|
+
if (k !== 'default') {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return e[k]; }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
32
|
+
var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
33
|
+
|
|
34
|
+
var ANIM_MS = 280;
|
|
35
|
+
var Drawer = ({
|
|
36
|
+
open,
|
|
37
|
+
onClose,
|
|
38
|
+
placement = "right",
|
|
39
|
+
size = 380,
|
|
40
|
+
title,
|
|
41
|
+
extra,
|
|
42
|
+
footer,
|
|
43
|
+
children,
|
|
44
|
+
mask = true,
|
|
45
|
+
maskClosable = true,
|
|
46
|
+
keyboard = true,
|
|
47
|
+
closable = true,
|
|
48
|
+
closeIcon,
|
|
49
|
+
destroyOnClose = false,
|
|
50
|
+
afterOpenChange,
|
|
51
|
+
zIndex,
|
|
52
|
+
className = ""
|
|
53
|
+
}) => {
|
|
54
|
+
const [hasOpenedOnce, setHasOpenedOnce] = React__namespace.useState(open);
|
|
55
|
+
React__namespace.useEffect(() => {
|
|
56
|
+
if (open) setHasOpenedOnce(true);
|
|
57
|
+
}, [open]);
|
|
58
|
+
React__namespace.useEffect(() => {
|
|
59
|
+
if (!open || !keyboard) return;
|
|
60
|
+
const h = (e) => e.key === "Escape" && onClose?.();
|
|
61
|
+
window.addEventListener("keydown", h);
|
|
62
|
+
return () => window.removeEventListener("keydown", h);
|
|
63
|
+
}, [open, keyboard, onClose]);
|
|
64
|
+
const prevOpen = React__namespace.useRef(open);
|
|
65
|
+
React__namespace.useEffect(() => {
|
|
66
|
+
if (prevOpen.current !== open) {
|
|
67
|
+
prevOpen.current = open;
|
|
68
|
+
if (afterOpenChange) {
|
|
69
|
+
const id = window.setTimeout(() => afterOpenChange(open), ANIM_MS);
|
|
70
|
+
return () => window.clearTimeout(id);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, [open, afterOpenChange]);
|
|
74
|
+
if (typeof document === "undefined") return null;
|
|
75
|
+
if (!hasOpenedOnce) return null;
|
|
76
|
+
if (!open && destroyOnClose) return null;
|
|
77
|
+
const isV = placement === "left" || placement === "right";
|
|
78
|
+
const style = isV ? { width: size } : { height: size };
|
|
79
|
+
if (zIndex != null) style.zIndex = zIndex;
|
|
80
|
+
return ReactDOM__default.default.createPortal(
|
|
81
|
+
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
82
|
+
mask && /* @__PURE__ */ jsxRuntime.jsx(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
className: `drawer-overlay ${open ? "" : "hidden"}`,
|
|
86
|
+
style: zIndex != null ? { zIndex: zIndex - 1 } : void 0,
|
|
87
|
+
onClick: () => maskClosable && onClose?.()
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
91
|
+
"div",
|
|
92
|
+
{
|
|
93
|
+
className: `drawer ${placement} ${open ? "" : "hidden"} ${className}`,
|
|
94
|
+
style,
|
|
95
|
+
onClick: (e) => e.stopPropagation(),
|
|
96
|
+
role: "dialog",
|
|
97
|
+
"aria-hidden": !open,
|
|
98
|
+
children: [
|
|
99
|
+
(title || extra || closable) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "drawer-head", children: [
|
|
100
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "drawer-title", children: title }),
|
|
101
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "drawer-head-right", children: [
|
|
102
|
+
extra,
|
|
103
|
+
closable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
104
|
+
"button",
|
|
105
|
+
{
|
|
106
|
+
type: "button",
|
|
107
|
+
className: "drawer-close",
|
|
108
|
+
onClick: onClose,
|
|
109
|
+
"aria-label": "Close",
|
|
110
|
+
children: closeIcon ?? /* @__PURE__ */ jsxRuntime.jsx(chunkYVO7XO4W_cjs.Icon, { name: "x", size: 16 })
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
] })
|
|
114
|
+
] }),
|
|
115
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "drawer-body", children }),
|
|
116
|
+
footer && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "drawer-foot", children: footer })
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
] }),
|
|
121
|
+
document.body
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
exports.Drawer = Drawer;
|
|
126
|
+
//# sourceMappingURL=chunk-AEJJGUEN.cjs.map
|
|
127
|
+
//# sourceMappingURL=chunk-AEJJGUEN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Drawer/Drawer.tsx"],"names":["React","ReactDOM","jsxs","Fragment","jsx","Icon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,IAAM,OAAA,GAAU,GAAA;AAGT,IAAM,SAAgC,CAAC;AAAA,EAC5C,IAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA,GAAY,OAAA;AAAA,EACZ,IAAA,GAAO,GAAA;AAAA,EACP,KAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA,GAAO,IAAA;AAAA,EACP,YAAA,GAAe,IAAA;AAAA,EACf,QAAA,GAAW,IAA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A,EAAgB,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,8BACrCF,eAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,mBAAA,EACZ,QAAA,EAAA;AAAA,gBAAA,KAAA;AAAA,gBACA,QAAA,oBACCE,cAAA;AAAA,kBAAC,QAAA;AAAA,kBAAA;AAAA,oBACC,IAAA,EAAK,QAAA;AAAA,oBACL,SAAA,EAAU,cAAA;AAAA,oBACV,OAAA,EAAS,OAAA;AAAA,oBACT,YAAA,EAAW,OAAA;AAAA,oBAEV,uCAAaA,cAAA,CAACC,sBAAA,EAAA,EAAK,IAAA,EAAK,GAAA,EAAI,MAAM,EAAA,EAAI;AAAA;AAAA;AACzC,eAAA,EAEJ;AAAA,aAAA,EACF,CAAA;AAAA,4BAEFD,cAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,aAAA,EAAe,QAAA,EAAS,CAAA;AAAA,YACtC,MAAA,oBAAUA,cAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,eAAe,QAAA,EAAA,MAAA,EAAO;AAAA;AAAA;AAAA;AAClD,KAAA,EACF,CAAA;AAAA,IACA,QAAA,CAAS;AAAA,GACX;AACF","file":"chunk-AEJJGUEN.cjs","sourcesContent":["import \"../../styles/tokens.css\";\nimport \"../../styles/shared.css\";\nimport \"./Drawer.css\";\nimport * as React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { Icon } from \"../Icon\";\n\nexport interface DrawerProps {\n /** Whether the drawer is visible. */\n open: boolean;\n /** Close callback (triggered by mask click / close button / Esc). */\n onClose?: () => void;\n /** Which edge the drawer slides from. */\n placement?: \"left\" | \"right\" | \"top\" | \"bottom\";\n /** Width (for left/right) or height (for top/bottom). Number → px. */\n size?: number | string;\n /** Header title. */\n title?: React.ReactNode;\n /** Extra content rendered to the right of the title (e.g. action buttons). */\n extra?: React.ReactNode;\n /** Footer content. */\n footer?: React.ReactNode;\n /** Drawer body. */\n children?: React.ReactNode;\n /** Render the mask overlay. Default true. Set `false` for a non-blocking drawer. */\n mask?: boolean;\n /** Close when clicking the mask. Default true. Ignored when `mask` is false. */\n maskClosable?: boolean;\n /** Close on Escape key. Default true. */\n keyboard?: boolean;\n /** Show the close (×) button in the header. Default true. */\n closable?: boolean;\n /** Override the close icon node. */\n closeIcon?: React.ReactNode;\n /**\n * When true the drawer's children are unmounted every time it closes.\n * Default `false` — children stay mounted across open/close cycles so\n * internal state (form fields, scroll position) is preserved.\n */\n destroyOnClose?: boolean;\n /** Fires after the open/close animation finishes. */\n afterOpenChange?: (open: boolean) => void;\n /** Stack index for nested drawers. */\n zIndex?: number;\n className?: string;\n}\n\nconst ANIM_MS = 280;\n\n/** `Drawer` — slide-in panel from an edge. */\nexport const Drawer: React.FC<DrawerProps> = ({\n open,\n onClose,\n placement = \"right\",\n size = 380,\n title,\n extra,\n footer,\n children,\n mask = true,\n maskClosable = true,\n keyboard = true,\n closable = true,\n closeIcon,\n destroyOnClose = false,\n afterOpenChange,\n zIndex,\n className = \"\",\n}) => {\n const [hasOpenedOnce, setHasOpenedOnce] = React.useState(open);\n React.useEffect(() => {\n if (open) setHasOpenedOnce(true);\n }, [open]);\n\n React.useEffect(() => {\n if (!open || !keyboard) return;\n const h = (e: KeyboardEvent) => e.key === \"Escape\" && onClose?.();\n window.addEventListener(\"keydown\", h);\n return () => window.removeEventListener(\"keydown\", h);\n }, [open, keyboard, onClose]);\n\n const prevOpen = React.useRef(open);\n React.useEffect(() => {\n if (prevOpen.current !== open) {\n prevOpen.current = open;\n if (afterOpenChange) {\n const id = window.setTimeout(() => afterOpenChange(open), ANIM_MS);\n return () => window.clearTimeout(id);\n }\n }\n }, [open, afterOpenChange]);\n\n if (typeof document === \"undefined\") return null;\n if (!hasOpenedOnce) return null;\n if (!open && destroyOnClose) return null;\n\n const isV = placement === \"left\" || placement === \"right\";\n const style: React.CSSProperties = isV ? { width: size } : { height: size };\n if (zIndex != null) style.zIndex = zIndex;\n\n return ReactDOM.createPortal(\n <>\n {mask && (\n <div\n className={`drawer-overlay ${open ? \"\" : \"hidden\"}`}\n style={zIndex != null ? { zIndex: zIndex - 1 } : undefined}\n onClick={() => maskClosable && onClose?.()}\n />\n )}\n <div\n className={`drawer ${placement} ${open ? \"\" : \"hidden\"} ${className}`}\n style={style}\n onClick={(e) => e.stopPropagation()}\n role=\"dialog\"\n aria-hidden={!open}\n >\n {(title || extra || closable) && (\n <div className=\"drawer-head\">\n <div className=\"drawer-title\">{title}</div>\n <div className=\"drawer-head-right\">\n {extra}\n {closable && (\n <button\n type=\"button\"\n className=\"drawer-close\"\n onClick={onClose}\n aria-label=\"Close\"\n >\n {closeIcon ?? <Icon name=\"x\" size={16} />}\n </button>\n )}\n </div>\n </div>\n )}\n <div className=\"drawer-body\">{children}</div>\n {footer && <div className=\"drawer-foot\">{footer}</div>}\n </div>\n </>,\n document.body\n );\n};\n"]}
|