@ifhover/leaf-ui 0.16.7 → 0.17.0
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/cjs/browser/modules/confirm/confirm.cjs +2 -2
- package/dist/cjs/browser/modules/confirm/confirm.cjs.map +1 -1
- package/dist/cjs/browser/modules/drawer/drawer.cjs +120 -61
- package/dist/cjs/browser/modules/drawer/drawer.cjs.map +1 -1
- package/dist/cjs/browser/modules/filelist/filelist.cjs +2 -2
- package/dist/cjs/browser/modules/filelist/filelist.cjs.map +1 -1
- package/dist/cjs/browser/modules/modal/base.cjs +287 -0
- package/dist/cjs/browser/modules/modal/base.cjs.map +1 -0
- package/dist/cjs/browser/modules/modal/modal.cjs +64 -209
- package/dist/cjs/browser/modules/modal/modal.cjs.map +1 -1
- package/dist/cjs/browser/modules/shared/presence.cjs +12 -6
- package/dist/cjs/browser/modules/shared/presence.cjs.map +1 -1
- package/dist/cjs/browser/modules/tabletanstack/tabletanstack.cjs +14 -2
- package/dist/cjs/browser/modules/tabletanstack/tabletanstack.cjs.map +1 -1
- package/dist/cjs/browser/modules/tabs/tabs.cjs +194 -175
- package/dist/cjs/browser/modules/tabs/tabs.cjs.map +1 -1
- package/dist/cjs/confirm/confirm.cjs +2 -2
- package/dist/cjs/confirm/confirm.cjs.map +1 -1
- package/dist/cjs/drawer/drawer.cjs +120 -61
- package/dist/cjs/drawer/drawer.cjs.map +1 -1
- package/dist/cjs/drawer/drawer.d.cts +6 -0
- package/dist/cjs/drawer/drawer.d.cts.map +1 -1
- package/dist/cjs/drawer/index.d.cts +1 -1
- package/dist/cjs/drawer/index.d.cts.map +1 -1
- package/dist/cjs/filelist/filelist.cjs +2 -2
- package/dist/cjs/filelist/filelist.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/index.d.cts.map +1 -1
- package/dist/cjs/modal/base.cjs +285 -0
- package/dist/cjs/modal/base.cjs.map +1 -0
- package/dist/cjs/modal/base.d.cts +23 -0
- package/dist/cjs/modal/base.d.cts.map +1 -0
- package/dist/cjs/modal/index.d.cts +1 -1
- package/dist/cjs/modal/index.d.cts.map +1 -1
- package/dist/cjs/modal/modal.cjs +64 -209
- package/dist/cjs/modal/modal.cjs.map +1 -1
- package/dist/cjs/modal/modal.d.cts +8 -3
- package/dist/cjs/modal/modal.d.cts.map +1 -1
- package/dist/cjs/shared/presence.cjs +12 -6
- package/dist/cjs/shared/presence.cjs.map +1 -1
- package/dist/cjs/shared/presence.d.cts +1 -1
- package/dist/cjs/shared/presence.d.cts.map +1 -1
- package/dist/cjs/styles/card.css +1 -1
- package/dist/cjs/styles/colorpicker.css +1 -1
- package/dist/cjs/styles/components/card.css +1 -1
- package/dist/cjs/styles/components/drawer.css +1 -1
- package/dist/cjs/styles/components/modal.css +1 -1
- package/dist/cjs/styles/components/tabletanstack.css +1 -1
- package/dist/cjs/styles/components/tabs.css +1 -1
- package/dist/cjs/styles/config-provider.css +1 -1
- package/dist/cjs/styles/confirm.css +1 -1
- package/dist/cjs/styles/daterangepicker.css +1 -1
- package/dist/cjs/styles/drawer.css +1 -1
- package/dist/cjs/styles/filelist.css +1 -1
- package/dist/cjs/styles/index.css +75 -14
- package/dist/cjs/styles/index.css.map +1 -1
- package/dist/cjs/styles/modal.css +1 -1
- package/dist/cjs/styles/tabletanstack.css +1 -1
- package/dist/cjs/styles/tabs.css +1 -1
- package/dist/cjs/styles/upload.css +1 -1
- package/dist/cjs/tabletanstack/tabletanstack.cjs +14 -2
- package/dist/cjs/tabletanstack/tabletanstack.cjs.map +1 -1
- package/dist/cjs/tabletanstack/tabletanstack.d.cts.map +1 -1
- package/dist/cjs/tabs/tabs.cjs +194 -175
- package/dist/cjs/tabs/tabs.cjs.map +1 -1
- package/dist/cjs/tabs/tabs.d.cts +14 -1
- package/dist/cjs/tabs/tabs.d.cts.map +1 -1
- package/dist/esm/browser/modules/confirm/confirm.js +1 -1
- package/dist/esm/browser/modules/confirm/confirm.js.map +1 -1
- package/dist/esm/browser/modules/drawer/drawer.js +121 -62
- package/dist/esm/browser/modules/drawer/drawer.js.map +1 -1
- package/dist/esm/browser/modules/filelist/filelist.js +1 -1
- package/dist/esm/browser/modules/filelist/filelist.js.map +1 -1
- package/dist/esm/browser/modules/modal/base.js +249 -0
- package/dist/esm/browser/modules/modal/base.js.map +1 -0
- package/dist/esm/browser/modules/modal/modal.js +65 -207
- package/dist/esm/browser/modules/modal/modal.js.map +1 -1
- package/dist/esm/browser/modules/shared/presence.js +12 -6
- package/dist/esm/browser/modules/shared/presence.js.map +1 -1
- package/dist/esm/browser/modules/tabletanstack/tabletanstack.js +14 -2
- package/dist/esm/browser/modules/tabletanstack/tabletanstack.js.map +1 -1
- package/dist/esm/browser/modules/tabs/tabs.js +190 -174
- package/dist/esm/browser/modules/tabs/tabs.js.map +1 -1
- package/dist/esm/confirm/confirm.js +1 -1
- package/dist/esm/confirm/confirm.js.map +1 -1
- package/dist/esm/drawer/drawer.d.ts +6 -0
- package/dist/esm/drawer/drawer.d.ts.map +1 -1
- package/dist/esm/drawer/drawer.js +121 -62
- package/dist/esm/drawer/drawer.js.map +1 -1
- package/dist/esm/drawer/index.d.ts +1 -1
- package/dist/esm/drawer/index.d.ts.map +1 -1
- package/dist/esm/filelist/filelist.js +1 -1
- package/dist/esm/filelist/filelist.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/modal/base.d.ts +23 -0
- package/dist/esm/modal/base.d.ts.map +1 -0
- package/dist/esm/modal/base.js +247 -0
- package/dist/esm/modal/base.js.map +1 -0
- package/dist/esm/modal/index.d.ts +1 -1
- package/dist/esm/modal/index.d.ts.map +1 -1
- package/dist/esm/modal/modal.d.ts +8 -3
- package/dist/esm/modal/modal.d.ts.map +1 -1
- package/dist/esm/modal/modal.js +65 -207
- package/dist/esm/modal/modal.js.map +1 -1
- package/dist/esm/shared/presence.d.ts +1 -1
- package/dist/esm/shared/presence.d.ts.map +1 -1
- package/dist/esm/shared/presence.js +12 -6
- package/dist/esm/shared/presence.js.map +1 -1
- package/dist/esm/styles/card.css +1 -1
- package/dist/esm/styles/colorpicker.css +1 -1
- package/dist/esm/styles/components/card.css +1 -1
- package/dist/esm/styles/components/drawer.css +1 -1
- package/dist/esm/styles/components/modal.css +1 -1
- package/dist/esm/styles/components/tabletanstack.css +1 -1
- package/dist/esm/styles/components/tabs.css +1 -1
- package/dist/esm/styles/config-provider.css +1 -1
- package/dist/esm/styles/confirm.css +1 -1
- package/dist/esm/styles/daterangepicker.css +1 -1
- package/dist/esm/styles/drawer.css +1 -1
- package/dist/esm/styles/filelist.css +1 -1
- package/dist/esm/styles/index.css +75 -14
- package/dist/esm/styles/index.css.map +1 -1
- package/dist/esm/styles/modal.css +1 -1
- package/dist/esm/styles/tabletanstack.css +1 -1
- package/dist/esm/styles/tabs.css +1 -1
- package/dist/esm/styles/upload.css +1 -1
- package/dist/esm/tabletanstack/tabletanstack.d.ts.map +1 -1
- package/dist/esm/tabletanstack/tabletanstack.js +14 -2
- package/dist/esm/tabletanstack/tabletanstack.js.map +1 -1
- package/dist/esm/tabs/tabs.d.ts +14 -1
- package/dist/esm/tabs/tabs.d.ts.map +1 -1
- package/dist/esm/tabs/tabs.js +190 -174
- package/dist/esm/tabs/tabs.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
require('../../../styles/foundation.css');
|
|
4
|
+
require('../../../styles/components/modal.css');
|
|
5
|
+
var __webpack_require__ = {};
|
|
6
|
+
(()=>{
|
|
7
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
8
|
+
var define = (defs, kind)=>{
|
|
9
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
[kind]: defs[key]
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
define(getters, "get");
|
|
15
|
+
define(values, "value");
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
20
|
+
})();
|
|
21
|
+
(()=>{
|
|
22
|
+
__webpack_require__.r = (exports1)=>{
|
|
23
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
24
|
+
value: 'Module'
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
27
|
+
value: true
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
31
|
+
var __webpack_exports__ = {};
|
|
32
|
+
__webpack_require__.r(__webpack_exports__);
|
|
33
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
34
|
+
ModalBase: ()=>ModalBase
|
|
35
|
+
});
|
|
36
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
37
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
38
|
+
const external_react_namespaceObject = require("react");
|
|
39
|
+
const button_cjs_namespaceObject = require("../button/button.cjs");
|
|
40
|
+
const context_cjs_namespaceObject = require("../config-provider/context.cjs");
|
|
41
|
+
const scrollbar_cjs_namespaceObject = require("../scrollbar/scrollbar.cjs");
|
|
42
|
+
const classes_cjs_namespaceObject = require("../shared/classes.cjs");
|
|
43
|
+
const dialog_cjs_namespaceObject = require("../shared/dialog.cjs");
|
|
44
|
+
const inert_cjs_namespaceObject = require("../shared/inert.cjs");
|
|
45
|
+
const overlay_owner_cjs_namespaceObject = require("../shared/overlay-owner.cjs");
|
|
46
|
+
const presence_cjs_namespaceObject = require("../shared/presence.cjs");
|
|
47
|
+
const scoped_portal_cjs_namespaceObject = require("../shared/scoped-portal.cjs");
|
|
48
|
+
function ModalSurface({ open, title, description, icon, divided = true, tabs, footer, confirmText, cancelText, confirmLoading = false, confirmButtonProps, cancelButtonProps, onConfirm, onCancel, width = 480, closable = true, maskClosable = true, keyboard = true, onClose, afterClose, forceRender = false, destroyOnClose = false, preserve, initialFocus, returnFocus, container: _container, renderTabsLayout: RenderTabsLayout, children, className, style, ...props }) {
|
|
49
|
+
const { messages, maskBlur } = (0, context_cjs_namespaceObject.useLeafConfig)();
|
|
50
|
+
const [pending, setPending] = (0, external_react_namespaceObject.useState)(false);
|
|
51
|
+
const [error, setError] = (0, external_react_namespaceObject.useState)();
|
|
52
|
+
const mounted = (0, external_react_namespaceObject.useRef)(true);
|
|
53
|
+
const accepting = (0, external_react_namespaceObject.useRef)(false);
|
|
54
|
+
const generation = (0, external_react_namespaceObject.useRef)(0);
|
|
55
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
56
|
+
mounted.current = true;
|
|
57
|
+
return ()=>{
|
|
58
|
+
mounted.current = false;
|
|
59
|
+
};
|
|
60
|
+
}, []);
|
|
61
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
62
|
+
generation.current++;
|
|
63
|
+
accepting.current = false;
|
|
64
|
+
setPending(false);
|
|
65
|
+
if (open) setError(void 0);
|
|
66
|
+
}, [
|
|
67
|
+
open
|
|
68
|
+
]);
|
|
69
|
+
const busy = pending || confirmLoading;
|
|
70
|
+
async function accept() {
|
|
71
|
+
if (accepting.current || busy) return;
|
|
72
|
+
if (!onConfirm) {
|
|
73
|
+
if (confirmButtonProps?.type !== 'submit') onClose?.();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
accepting.current = true;
|
|
77
|
+
const request = generation.current;
|
|
78
|
+
setPending(true);
|
|
79
|
+
setError(void 0);
|
|
80
|
+
try {
|
|
81
|
+
await onConfirm();
|
|
82
|
+
} catch (reason) {
|
|
83
|
+
if (mounted.current && generation.current === request) setError(reason instanceof Error ? reason.message : String(reason));
|
|
84
|
+
} finally{
|
|
85
|
+
if (generation.current === request) {
|
|
86
|
+
accepting.current = false;
|
|
87
|
+
if (mounted.current) setPending(false);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const cancel = ()=>{
|
|
92
|
+
if (!busy) (onCancel ?? onClose)?.();
|
|
93
|
+
};
|
|
94
|
+
const actions = {
|
|
95
|
+
cancelButton: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.ButtonControl, {
|
|
96
|
+
type: "button",
|
|
97
|
+
variant: "outline",
|
|
98
|
+
...cancelButtonProps,
|
|
99
|
+
disabled: busy || cancelButtonProps?.disabled,
|
|
100
|
+
onClick: (event)=>{
|
|
101
|
+
cancelButtonProps?.onClick?.(event);
|
|
102
|
+
if (!event.defaultPrevented) cancel();
|
|
103
|
+
},
|
|
104
|
+
children: cancelText ?? messages.common.cancel
|
|
105
|
+
}),
|
|
106
|
+
confirmButton: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.ButtonControl, {
|
|
107
|
+
type: "button",
|
|
108
|
+
variant: "solid",
|
|
109
|
+
...confirmButtonProps,
|
|
110
|
+
loading: busy || confirmButtonProps?.loading,
|
|
111
|
+
onClick: (event)=>{
|
|
112
|
+
confirmButtonProps?.onClick?.(event);
|
|
113
|
+
if (!event.defaultPrevented) accept();
|
|
114
|
+
},
|
|
115
|
+
children: confirmText ?? messages.common.confirm
|
|
116
|
+
})
|
|
117
|
+
};
|
|
118
|
+
const renderedFooter = 'function' == typeof footer ? footer(actions) : void 0 === footer ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
119
|
+
className: "leaf-modal__actions",
|
|
120
|
+
children: [
|
|
121
|
+
actions.cancelButton,
|
|
122
|
+
actions.confirmButton
|
|
123
|
+
]
|
|
124
|
+
}) : footer;
|
|
125
|
+
const panel = (0, external_react_namespaceObject.useRef)(null);
|
|
126
|
+
const content = (0, external_react_namespaceObject.useRef)(null);
|
|
127
|
+
const backdrop = (0, external_react_namespaceObject.useRef)(null);
|
|
128
|
+
const present = (0, presence_cjs_namespaceObject.usePresence)(open, backdrop);
|
|
129
|
+
const snapHeight = (0, presence_cjs_namespaceObject.useNaturalHeightTransition)(panel, content, open);
|
|
130
|
+
const titleId = `${(0, external_react_namespaceObject.useId)()}-title`;
|
|
131
|
+
const descriptionId = `${(0, external_react_namespaceObject.useId)()}-description`;
|
|
132
|
+
const modalId = `${(0, external_react_namespaceObject.useId)()}-dialog`;
|
|
133
|
+
const close = (0, external_react_namespaceObject.useRef)(cancel);
|
|
134
|
+
close.current = cancel;
|
|
135
|
+
const wasPresent = (0, external_react_namespaceObject.useRef)(false);
|
|
136
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
137
|
+
if (wasPresent.current && !present) afterClose?.();
|
|
138
|
+
wasPresent.current = present;
|
|
139
|
+
}, [
|
|
140
|
+
present,
|
|
141
|
+
afterClose
|
|
142
|
+
]);
|
|
143
|
+
(0, dialog_cjs_namespaceObject.useDialog)(open, panel, modalId, cancel, keyboard, {
|
|
144
|
+
initialFocus,
|
|
145
|
+
returnFocus
|
|
146
|
+
});
|
|
147
|
+
const visited = (0, external_react_namespaceObject.useRef)(false);
|
|
148
|
+
if (open) visited.current = true;
|
|
149
|
+
if (!present && !forceRender && ((void 0 === preserve ? destroyOnClose : !preserve) || !visited.current)) return null;
|
|
150
|
+
const hasTabs = Boolean(tabs?.items?.length);
|
|
151
|
+
const hasHeading = null != title || null != description || null != icon;
|
|
152
|
+
const closeButton = closable ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
153
|
+
type: "button",
|
|
154
|
+
className: "leaf-modal__close",
|
|
155
|
+
"aria-label": messages.common.close,
|
|
156
|
+
onClick: ()=>close.current?.(),
|
|
157
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.X, {
|
|
158
|
+
size: 18,
|
|
159
|
+
"aria-hidden": "true"
|
|
160
|
+
})
|
|
161
|
+
}) : null;
|
|
162
|
+
const scrollbarLabel = null == title ? props['aria-label'] ?? tabs?.['aria-label'] ?? messages.common.confirm : void 0;
|
|
163
|
+
const scrollbarLabelledBy = null != title ? titleId : void 0;
|
|
164
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
165
|
+
hidden: !present,
|
|
166
|
+
className: "leaf-modal-mask",
|
|
167
|
+
"data-blur": maskBlur ? void 0 : 'off',
|
|
168
|
+
"data-state": open ? 'open' : 'closing',
|
|
169
|
+
"aria-hidden": !open || void 0,
|
|
170
|
+
...(0, inert_cjs_namespaceObject.inertProps)(!open),
|
|
171
|
+
children: [
|
|
172
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
173
|
+
ref: backdrop,
|
|
174
|
+
type: "button",
|
|
175
|
+
className: "leaf-modal-backdrop",
|
|
176
|
+
tabIndex: -1,
|
|
177
|
+
"aria-label": messages.common.close,
|
|
178
|
+
onClick: ()=>{
|
|
179
|
+
if (maskClosable) close.current?.();
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
182
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
183
|
+
...props,
|
|
184
|
+
ref: panel,
|
|
185
|
+
id: props.id ?? modalId,
|
|
186
|
+
role: props.role ?? 'dialog',
|
|
187
|
+
"aria-modal": "true",
|
|
188
|
+
"aria-labelledby": null != title ? titleId : props['aria-labelledby'],
|
|
189
|
+
"aria-describedby": [
|
|
190
|
+
props['aria-describedby'],
|
|
191
|
+
null != description && descriptionId
|
|
192
|
+
].filter(Boolean).join(' ') || void 0,
|
|
193
|
+
tabIndex: -1,
|
|
194
|
+
className: (0, classes_cjs_namespaceObject.classes)('leaf-modal', divided && 'leaf-modal--divided', hasTabs && 'leaf-modal--tabbed', hasHeading && 'leaf-modal--headed', className),
|
|
195
|
+
style: {
|
|
196
|
+
width,
|
|
197
|
+
...style
|
|
198
|
+
},
|
|
199
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(overlay_owner_cjs_namespaceObject.OverlayOwner.Provider, {
|
|
200
|
+
value: modalId,
|
|
201
|
+
children: [
|
|
202
|
+
(hasHeading || !hasTabs && closable) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
203
|
+
className: (0, classes_cjs_namespaceObject.classes)('leaf-modal__header', null == description && 'leaf-modal__header--simple', null != icon && 'leaf-modal__header--icon', !hasHeading && 'leaf-modal__header--compact'),
|
|
204
|
+
children: [
|
|
205
|
+
null != icon && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
206
|
+
className: "leaf-modal__icon",
|
|
207
|
+
"aria-hidden": "true",
|
|
208
|
+
children: icon
|
|
209
|
+
}),
|
|
210
|
+
(null != title || null != description) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
211
|
+
className: "leaf-modal__heading",
|
|
212
|
+
children: [
|
|
213
|
+
null != title && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("h2", {
|
|
214
|
+
id: titleId,
|
|
215
|
+
children: title
|
|
216
|
+
}),
|
|
217
|
+
null != description && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
218
|
+
id: descriptionId,
|
|
219
|
+
className: "leaf-modal__description",
|
|
220
|
+
children: description
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
}),
|
|
224
|
+
closeButton
|
|
225
|
+
]
|
|
226
|
+
}),
|
|
227
|
+
hasTabs && tabs && RenderTabsLayout ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RenderTabsLayout, {
|
|
228
|
+
open: open,
|
|
229
|
+
tabs: tabs,
|
|
230
|
+
title: title,
|
|
231
|
+
titleId: titleId,
|
|
232
|
+
hasHeading: hasHeading,
|
|
233
|
+
closeButton: hasHeading ? null : closeButton,
|
|
234
|
+
contentRef: content,
|
|
235
|
+
snapHeight: snapHeight,
|
|
236
|
+
ariaLabel: props['aria-label'],
|
|
237
|
+
ariaLabelledBy: props['aria-labelledby'],
|
|
238
|
+
scrollbarLabel: scrollbarLabel,
|
|
239
|
+
scrollbarLabelledBy: scrollbarLabelledBy,
|
|
240
|
+
error: error,
|
|
241
|
+
children: children
|
|
242
|
+
}) : (null != children && false !== children || null != error) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(scrollbar_cjs_namespaceObject.ScrollbarControl, {
|
|
243
|
+
className: "leaf-modal__body",
|
|
244
|
+
viewportClassName: "leaf-modal__viewport",
|
|
245
|
+
orientation: "vertical",
|
|
246
|
+
"aria-labelledby": scrollbarLabelledBy,
|
|
247
|
+
"aria-label": scrollbarLabel,
|
|
248
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
249
|
+
ref: content,
|
|
250
|
+
className: "leaf-modal__content",
|
|
251
|
+
children: [
|
|
252
|
+
children,
|
|
253
|
+
error && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
254
|
+
role: "alert",
|
|
255
|
+
className: "leaf-confirm-error",
|
|
256
|
+
children: error
|
|
257
|
+
})
|
|
258
|
+
]
|
|
259
|
+
})
|
|
260
|
+
}),
|
|
261
|
+
null != renderedFooter && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
262
|
+
className: "leaf-modal__footer",
|
|
263
|
+
children: renderedFooter
|
|
264
|
+
})
|
|
265
|
+
]
|
|
266
|
+
})
|
|
267
|
+
})
|
|
268
|
+
]
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function ModalBase(props) {
|
|
272
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(scoped_portal_cjs_namespaceObject.ScopedPortal, {
|
|
273
|
+
container: props.container,
|
|
274
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModalSurface, {
|
|
275
|
+
...props
|
|
276
|
+
})
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
exports.ModalBase = __webpack_exports__.ModalBase;
|
|
280
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
281
|
+
"ModalBase"
|
|
282
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
283
|
+
Object.defineProperty(exports, '__esModule', {
|
|
284
|
+
value: true
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
//# sourceMappingURL=base.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal/base.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../../../src/modal/base.tsx"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { X } from 'lucide-react';\nimport {\n type ComponentType,\n type ReactNode,\n type Ref,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\nimport { ButtonControl } from '../button/button';\nimport { useLeafConfig } from '../config-provider/context';\nimport { ScrollbarControl as Scrollbar } from '../scrollbar/scrollbar';\nimport { classes } from '../shared/classes';\nimport { useDialog } from '../shared/dialog';\nimport { inertProps } from '../shared/inert';\nimport { OverlayOwner } from '../shared/overlay-owner';\nimport { useNaturalHeightTransition, usePresence } from '../shared/presence';\nimport { ScopedPortal } from '../shared/scoped-portal';\nimport type { ModalFooterActions, ModalProps, ModalTabsProps } from './modal';\n\nexport interface ModalTabsRenderProps {\n open: boolean;\n tabs: ModalTabsProps;\n title?: ReactNode;\n titleId: string;\n hasHeading: boolean;\n closeButton: ReactNode;\n contentRef: Ref<HTMLDivElement>;\n snapHeight: () => void;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n scrollbarLabel?: string;\n scrollbarLabelledBy?: string;\n error?: string;\n children?: ReactNode;\n}\n\nexport interface ModalBaseProps extends ModalProps {\n renderTabsLayout?: ComponentType<ModalTabsRenderProps>;\n}\n\nfunction ModalSurface({\n open,\n title,\n description,\n icon,\n divided = true,\n tabs,\n footer,\n confirmText,\n cancelText,\n confirmLoading = false,\n confirmButtonProps,\n cancelButtonProps,\n onConfirm,\n onCancel,\n width = 480,\n closable = true,\n maskClosable = true,\n keyboard = true,\n onClose,\n afterClose,\n forceRender = false,\n destroyOnClose = false,\n preserve,\n initialFocus,\n returnFocus,\n container: _container,\n renderTabsLayout: RenderTabsLayout,\n children,\n className,\n style,\n ...props\n}: ModalBaseProps) {\n const { messages, maskBlur } = useLeafConfig();\n const [pending, setPending] = useState(false);\n const [error, setError] = useState<string>();\n const mounted = useRef(true);\n const accepting = useRef(false);\n const generation = useRef(0);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n useEffect(() => {\n generation.current++;\n accepting.current = false;\n setPending(false);\n if (open) setError(undefined);\n }, [open]);\n const busy = pending || confirmLoading;\n async function accept() {\n if (accepting.current || busy) return;\n if (!onConfirm) {\n if (confirmButtonProps?.type !== 'submit') onClose?.();\n return;\n }\n accepting.current = true;\n const request = generation.current;\n setPending(true);\n setError(undefined);\n try {\n await onConfirm();\n } catch (reason) {\n if (mounted.current && generation.current === request)\n setError(reason instanceof Error ? reason.message : String(reason));\n } finally {\n if (generation.current === request) {\n accepting.current = false;\n if (mounted.current) setPending(false);\n }\n }\n }\n const cancel = () => {\n if (!busy) (onCancel ?? onClose)?.();\n };\n const actions: ModalFooterActions = {\n cancelButton: (\n <ButtonControl\n type=\"button\"\n variant=\"outline\"\n {...cancelButtonProps}\n disabled={busy || cancelButtonProps?.disabled}\n onClick={(event) => {\n cancelButtonProps?.onClick?.(event);\n if (!event.defaultPrevented) cancel();\n }}\n >\n {cancelText ?? messages.common.cancel}\n </ButtonControl>\n ),\n confirmButton: (\n <ButtonControl\n type=\"button\"\n variant=\"solid\"\n {...confirmButtonProps}\n loading={busy || confirmButtonProps?.loading}\n onClick={(event) => {\n confirmButtonProps?.onClick?.(event);\n if (!event.defaultPrevented) void accept();\n }}\n >\n {confirmText ?? messages.common.confirm}\n </ButtonControl>\n ),\n };\n const renderedFooter =\n typeof footer === 'function' ? (\n footer(actions)\n ) : footer === undefined ? (\n <div className=\"leaf-modal__actions\">\n {actions.cancelButton}\n {actions.confirmButton}\n </div>\n ) : (\n footer\n );\n const panel = useRef<HTMLDivElement>(null);\n const content = useRef<HTMLDivElement>(null);\n const backdrop = useRef<HTMLButtonElement>(null);\n const present = usePresence(open, backdrop);\n const snapHeight = useNaturalHeightTransition(panel, content, open);\n const titleId = `${useId()}-title`;\n const descriptionId = `${useId()}-description`;\n const modalId = `${useId()}-dialog`;\n const close = useRef(cancel);\n close.current = cancel;\n const wasPresent = useRef(false);\n useEffect(() => {\n if (wasPresent.current && !present) afterClose?.();\n wasPresent.current = present;\n }, [present, afterClose]);\n useDialog(open, panel, modalId, cancel, keyboard, { initialFocus, returnFocus });\n const visited = useRef(false);\n if (open) visited.current = true;\n if (\n !present &&\n !forceRender &&\n ((preserve === undefined ? destroyOnClose : !preserve) || !visited.current)\n )\n return null;\n\n const hasTabs = Boolean(tabs?.items?.length);\n const hasHeading = title != null || description != null || icon != null;\n const closeButton = closable ? (\n <button\n type=\"button\"\n className=\"leaf-modal__close\"\n aria-label={messages.common.close}\n onClick={() => close.current?.()}\n >\n <X size={18} aria-hidden=\"true\" />\n </button>\n ) : null;\n const scrollbarLabel =\n title == null\n ? (props['aria-label'] ?? tabs?.['aria-label'] ?? messages.common.confirm)\n : undefined;\n const scrollbarLabelledBy = title != null ? titleId : undefined;\n\n return (\n <div\n hidden={!present}\n className=\"leaf-modal-mask\"\n data-blur={maskBlur ? undefined : 'off'}\n data-state={open ? 'open' : 'closing'}\n aria-hidden={!open || undefined}\n {...inertProps(!open)}\n >\n <button\n ref={backdrop}\n type=\"button\"\n className=\"leaf-modal-backdrop\"\n tabIndex={-1}\n aria-label={messages.common.close}\n onClick={() => {\n if (maskClosable) close.current?.();\n }}\n />\n {/* biome-ignore lint/a11y/useAriaPropsSupportedByRole: dialog and alertdialog both support aria-modal. */}\n <div\n {...props}\n ref={panel}\n id={props.id ?? modalId}\n role={props.role ?? 'dialog'}\n aria-modal=\"true\"\n aria-labelledby={title != null ? titleId : props['aria-labelledby']}\n aria-describedby={\n [props['aria-describedby'], description != null && descriptionId]\n .filter(Boolean)\n .join(' ') || undefined\n }\n tabIndex={-1}\n className={classes(\n 'leaf-modal',\n divided && 'leaf-modal--divided',\n hasTabs && 'leaf-modal--tabbed',\n hasHeading && 'leaf-modal--headed',\n className,\n )}\n style={{ width, ...style }}\n >\n <OverlayOwner.Provider value={modalId}>\n {(hasHeading || (!hasTabs && closable)) && (\n <div\n className={classes(\n 'leaf-modal__header',\n description == null && 'leaf-modal__header--simple',\n icon != null && 'leaf-modal__header--icon',\n !hasHeading && 'leaf-modal__header--compact',\n )}\n >\n {icon != null && (\n <span className=\"leaf-modal__icon\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n {(title != null || description != null) && (\n <div className=\"leaf-modal__heading\">\n {title != null && <h2 id={titleId}>{title}</h2>}\n {description != null && (\n <div id={descriptionId} className=\"leaf-modal__description\">\n {description}\n </div>\n )}\n </div>\n )}\n {closeButton}\n </div>\n )}\n {hasTabs && tabs && RenderTabsLayout ? (\n <RenderTabsLayout\n open={open}\n tabs={tabs}\n title={title}\n titleId={titleId}\n hasHeading={hasHeading}\n closeButton={!hasHeading ? closeButton : null}\n contentRef={content}\n snapHeight={snapHeight}\n ariaLabel={props['aria-label']}\n ariaLabelledBy={props['aria-labelledby']}\n scrollbarLabel={scrollbarLabel}\n scrollbarLabelledBy={scrollbarLabelledBy}\n error={error}\n >\n {children}\n </RenderTabsLayout>\n ) : (\n ((children != null && children !== false) || error != null) && (\n <Scrollbar\n className=\"leaf-modal__body\"\n viewportClassName=\"leaf-modal__viewport\"\n orientation=\"vertical\"\n aria-labelledby={scrollbarLabelledBy}\n aria-label={scrollbarLabel}\n >\n <div ref={content} className=\"leaf-modal__content\">\n {children}\n {error && (\n <p role=\"alert\" className=\"leaf-confirm-error\">\n {error}\n </p>\n )}\n </div>\n </Scrollbar>\n )\n )}\n {renderedFooter != null && <div className=\"leaf-modal__footer\">{renderedFooter}</div>}\n </OverlayOwner.Provider>\n </div>\n </div>\n );\n}\n\n// 内部复用的对话框基础容器,避免 Confirm / FileList 继承公开 Modal 默认配置或引入 Tabs。\nexport function ModalBase(props: ModalBaseProps) {\n return (\n <ScopedPortal container={props.container}>\n <ModalSurface {...props} />\n </ScopedPortal>\n );\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","ModalSurface","open","title","description","icon","divided","tabs","footer","confirmText","cancelText","confirmLoading","confirmButtonProps","cancelButtonProps","onConfirm","onCancel","width","closable","maskClosable","keyboard","onClose","afterClose","forceRender","destroyOnClose","preserve","initialFocus","returnFocus","_container","RenderTabsLayout","children","className","style","props","messages","maskBlur","useLeafConfig","pending","setPending","useState","error","setError","mounted","useRef","accepting","generation","useEffect","undefined","busy","accept","request","reason","Error","String","cancel","actions","ButtonControl","event","renderedFooter","panel","content","backdrop","present","usePresence","snapHeight","useNaturalHeightTransition","titleId","useId","descriptionId","modalId","close","wasPresent","useDialog","visited","hasTabs","Boolean","hasHeading","closeButton","X","scrollbarLabel","scrollbarLabelledBy","inertProps","classes","OverlayOwner","Scrollbar","ModalBase","ScopedPortal"],"mappings":";;;;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C/B,cAAAA;YAAc,GAAG+B,KAAK;;;AAG7B"}
|
|
@@ -31,218 +31,69 @@ var __webpack_require__ = {};
|
|
|
31
31
|
var __webpack_exports__ = {};
|
|
32
32
|
__webpack_require__.r(__webpack_exports__);
|
|
33
33
|
__webpack_require__.d(__webpack_exports__, {
|
|
34
|
-
Modal: ()=>Modal
|
|
35
|
-
ModalBase: ()=>ModalBase
|
|
34
|
+
Modal: ()=>Modal
|
|
36
35
|
});
|
|
37
36
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
38
|
-
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
39
37
|
const external_react_namespaceObject = require("react");
|
|
40
|
-
const button_cjs_namespaceObject = require("../button/button.cjs");
|
|
41
38
|
const component_defaults_cjs_namespaceObject = require("../config-provider/component-defaults.cjs");
|
|
42
|
-
const context_cjs_namespaceObject = require("../config-provider/context.cjs");
|
|
43
39
|
const scrollbar_cjs_namespaceObject = require("../scrollbar/scrollbar.cjs");
|
|
44
40
|
const classes_cjs_namespaceObject = require("../shared/classes.cjs");
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const { messages, maskBlur } = (0, context_cjs_namespaceObject.useLeafConfig)();
|
|
52
|
-
const [pending, setPending] = (0, external_react_namespaceObject.useState)(false);
|
|
53
|
-
const [error, setError] = (0, external_react_namespaceObject.useState)();
|
|
54
|
-
const mounted = (0, external_react_namespaceObject.useRef)(true);
|
|
55
|
-
const accepting = (0, external_react_namespaceObject.useRef)(false);
|
|
56
|
-
const generation = (0, external_react_namespaceObject.useRef)(0);
|
|
57
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
58
|
-
mounted.current = true;
|
|
59
|
-
return ()=>{
|
|
60
|
-
mounted.current = false;
|
|
61
|
-
};
|
|
62
|
-
}, []);
|
|
63
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
64
|
-
generation.current++;
|
|
65
|
-
accepting.current = false;
|
|
66
|
-
setPending(false);
|
|
67
|
-
if (open) setError(void 0);
|
|
68
|
-
}, [
|
|
69
|
-
open
|
|
70
|
-
]);
|
|
71
|
-
const busy = pending || confirmLoading;
|
|
72
|
-
async function accept() {
|
|
73
|
-
if (accepting.current || busy) return;
|
|
74
|
-
if (!onConfirm) {
|
|
75
|
-
if (confirmButtonProps?.type !== 'submit') onClose?.();
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
accepting.current = true;
|
|
79
|
-
const request = generation.current;
|
|
80
|
-
setPending(true);
|
|
81
|
-
setError(void 0);
|
|
82
|
-
try {
|
|
83
|
-
await onConfirm();
|
|
84
|
-
} catch (reason) {
|
|
85
|
-
if (mounted.current && generation.current === request) setError(reason instanceof Error ? reason.message : String(reason));
|
|
86
|
-
} finally{
|
|
87
|
-
if (generation.current === request) {
|
|
88
|
-
accepting.current = false;
|
|
89
|
-
if (mounted.current) setPending(false);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const cancel = ()=>{
|
|
94
|
-
if (!busy) (onCancel ?? onClose)?.();
|
|
95
|
-
};
|
|
96
|
-
const actions = {
|
|
97
|
-
cancelButton: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.ButtonControl, {
|
|
98
|
-
type: "button",
|
|
99
|
-
variant: "outline",
|
|
100
|
-
...cancelButtonProps,
|
|
101
|
-
disabled: busy || cancelButtonProps?.disabled,
|
|
102
|
-
onClick: (event)=>{
|
|
103
|
-
cancelButtonProps?.onClick?.(event);
|
|
104
|
-
if (!event.defaultPrevented) cancel();
|
|
105
|
-
},
|
|
106
|
-
children: cancelText ?? messages.common.cancel
|
|
107
|
-
}),
|
|
108
|
-
confirmButton: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.ButtonControl, {
|
|
109
|
-
type: "button",
|
|
110
|
-
variant: "solid",
|
|
111
|
-
...confirmButtonProps,
|
|
112
|
-
loading: busy || confirmButtonProps?.loading,
|
|
113
|
-
onClick: (event)=>{
|
|
114
|
-
confirmButtonProps?.onClick?.(event);
|
|
115
|
-
if (!event.defaultPrevented) accept();
|
|
116
|
-
},
|
|
117
|
-
children: confirmText ?? messages.common.confirm
|
|
118
|
-
})
|
|
119
|
-
};
|
|
120
|
-
const renderedFooter = 'function' == typeof footer ? footer(actions) : void 0 === footer ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
121
|
-
className: "leaf-modal__actions",
|
|
41
|
+
const tabs_cjs_namespaceObject = require("../tabs/tabs.cjs");
|
|
42
|
+
const external_base_cjs_namespaceObject = require("./base.cjs");
|
|
43
|
+
const useBrowserLayoutEffect = "u" < typeof window ? external_react_namespaceObject.useEffect : external_react_namespaceObject.useLayoutEffect;
|
|
44
|
+
function ModalTabsLayout({ open, tabs, title, titleId, hasHeading, closeButton, contentRef, snapHeight, ariaLabel, ariaLabelledBy, scrollbarLabel, scrollbarLabelledBy, error, children }) {
|
|
45
|
+
const tabExtra = hasHeading || null == closeButton ? tabs.extra : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
46
|
+
className: "leaf-dialog-tab-extra leaf-modal__tab-extra",
|
|
122
47
|
children: [
|
|
123
|
-
|
|
124
|
-
|
|
48
|
+
tabs.extra,
|
|
49
|
+
closeButton
|
|
125
50
|
]
|
|
126
|
-
})
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
51
|
+
});
|
|
52
|
+
const tabLabel = tabs['aria-label'] ?? ('string' == typeof title ? title : ariaLabel);
|
|
53
|
+
const tabLabelledBy = tabs['aria-labelledby'] ?? (null == tabs['aria-label'] && null != title ? titleId : null == tabs['aria-label'] ? ariaLabelledBy : void 0);
|
|
54
|
+
const parts = (0, tabs_cjs_namespaceObject.useTabsParts)({
|
|
55
|
+
...tabs,
|
|
56
|
+
type: 'line',
|
|
57
|
+
placement: 'top',
|
|
58
|
+
size: tabs.size ?? 'md',
|
|
59
|
+
'aria-label': tabLabel,
|
|
60
|
+
'aria-labelledby': tabLabelledBy,
|
|
61
|
+
extra: tabExtra,
|
|
62
|
+
className: (0, classes_cjs_namespaceObject.classes)('leaf-dialog-tabs', hasHeading && 'leaf-dialog-tabs--headed', 'leaf-modal__tabs', tabs.className),
|
|
63
|
+
panelsClassName: 'leaf-dialog-panels',
|
|
64
|
+
visibilityKey: open
|
|
65
|
+
});
|
|
66
|
+
const previousSelected = (0, external_react_namespaceObject.useRef)(parts?.selected);
|
|
67
|
+
useBrowserLayoutEffect(()=>{
|
|
68
|
+
if (previousSelected.current === parts?.selected) return;
|
|
69
|
+
previousSelected.current = parts?.selected;
|
|
70
|
+
snapHeight();
|
|
141
71
|
}, [
|
|
142
|
-
|
|
143
|
-
|
|
72
|
+
parts?.selected,
|
|
73
|
+
snapHeight
|
|
144
74
|
]);
|
|
145
|
-
(0,
|
|
146
|
-
initialFocus,
|
|
147
|
-
returnFocus
|
|
148
|
-
});
|
|
149
|
-
const visited = (0, external_react_namespaceObject.useRef)(false);
|
|
150
|
-
if (open) visited.current = true;
|
|
151
|
-
if (!present && !forceRender && ((void 0 === preserve ? destroyOnClose : !preserve) || !visited.current)) return null;
|
|
152
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
153
|
-
hidden: !present,
|
|
154
|
-
className: "leaf-modal-mask",
|
|
155
|
-
"data-blur": maskBlur ? void 0 : 'off',
|
|
156
|
-
"data-state": open ? 'open' : 'closing',
|
|
157
|
-
"aria-hidden": !open || void 0,
|
|
158
|
-
...(0, inert_cjs_namespaceObject.inertProps)(!open),
|
|
75
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
159
76
|
children: [
|
|
160
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
className: "leaf-modal-backdrop",
|
|
164
|
-
tabIndex: -1,
|
|
165
|
-
"aria-label": messages.common.close,
|
|
166
|
-
onClick: ()=>{
|
|
167
|
-
if (maskClosable) close.current?.();
|
|
168
|
-
}
|
|
77
|
+
parts && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
78
|
+
...parts.rootProps,
|
|
79
|
+
children: parts.header
|
|
169
80
|
}),
|
|
170
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
"aria-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
null != description && descriptionId
|
|
180
|
-
].filter(Boolean).join(' ') || void 0,
|
|
181
|
-
tabIndex: -1,
|
|
182
|
-
className: (0, classes_cjs_namespaceObject.classes)('leaf-modal', divided && 'leaf-modal--divided', className),
|
|
183
|
-
style: {
|
|
184
|
-
width,
|
|
185
|
-
...style
|
|
186
|
-
},
|
|
187
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(overlay_owner_cjs_namespaceObject.OverlayOwner.Provider, {
|
|
188
|
-
value: modalId,
|
|
81
|
+
(parts?.hasPanels || null != children && false !== children || null != error) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(scrollbar_cjs_namespaceObject.ScrollbarControl, {
|
|
82
|
+
className: "leaf-modal__body",
|
|
83
|
+
viewportClassName: "leaf-modal__viewport",
|
|
84
|
+
orientation: "vertical",
|
|
85
|
+
"aria-labelledby": scrollbarLabelledBy,
|
|
86
|
+
"aria-label": scrollbarLabel,
|
|
87
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
88
|
+
ref: contentRef,
|
|
89
|
+
className: "leaf-modal__content",
|
|
189
90
|
children: [
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
children: icon
|
|
197
|
-
}),
|
|
198
|
-
(null != title || null != description) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
199
|
-
className: "leaf-modal__heading",
|
|
200
|
-
children: [
|
|
201
|
-
null != title && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("h2", {
|
|
202
|
-
id: titleId,
|
|
203
|
-
children: title
|
|
204
|
-
}),
|
|
205
|
-
null != description && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
206
|
-
id: descriptionId,
|
|
207
|
-
className: "leaf-modal__description",
|
|
208
|
-
children: description
|
|
209
|
-
})
|
|
210
|
-
]
|
|
211
|
-
}),
|
|
212
|
-
closable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
213
|
-
type: "button",
|
|
214
|
-
className: "leaf-modal__close",
|
|
215
|
-
"aria-label": messages.common.close,
|
|
216
|
-
onClick: ()=>close.current?.(),
|
|
217
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.X, {
|
|
218
|
-
size: 18,
|
|
219
|
-
"aria-hidden": "true"
|
|
220
|
-
})
|
|
221
|
-
})
|
|
222
|
-
]
|
|
223
|
-
}),
|
|
224
|
-
(null != children && false !== children || null != error) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(scrollbar_cjs_namespaceObject.ScrollbarControl, {
|
|
225
|
-
className: "leaf-modal__body",
|
|
226
|
-
viewportClassName: "leaf-modal__viewport",
|
|
227
|
-
orientation: "vertical",
|
|
228
|
-
"aria-labelledby": null != title ? titleId : void 0,
|
|
229
|
-
"aria-label": null == title ? props['aria-label'] ?? messages.common.confirm : void 0,
|
|
230
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
231
|
-
ref: content,
|
|
232
|
-
className: "leaf-modal__content",
|
|
233
|
-
children: [
|
|
234
|
-
children,
|
|
235
|
-
error && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
236
|
-
role: "alert",
|
|
237
|
-
className: "leaf-confirm-error",
|
|
238
|
-
children: error
|
|
239
|
-
})
|
|
240
|
-
]
|
|
241
|
-
})
|
|
242
|
-
}),
|
|
243
|
-
null != renderedFooter && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
244
|
-
className: "leaf-modal__footer",
|
|
245
|
-
children: renderedFooter
|
|
91
|
+
parts?.panels,
|
|
92
|
+
children,
|
|
93
|
+
error && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
94
|
+
role: "alert",
|
|
95
|
+
className: "leaf-confirm-error",
|
|
96
|
+
children: error
|
|
246
97
|
})
|
|
247
98
|
]
|
|
248
99
|
})
|
|
@@ -250,25 +101,29 @@ function ModalSurface({ open, title, description, icon, divided = true, footer,
|
|
|
250
101
|
]
|
|
251
102
|
});
|
|
252
103
|
}
|
|
253
|
-
function
|
|
254
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
104
|
+
function ModalControl({ divided = true, confirmLoading = false, width = 480, closable = true, maskClosable = true, keyboard = true, forceRender = false, destroyOnClose = false, ...props }) {
|
|
105
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_base_cjs_namespaceObject.ModalBase, {
|
|
106
|
+
...props,
|
|
107
|
+
divided: divided,
|
|
108
|
+
confirmLoading: confirmLoading,
|
|
109
|
+
width: width,
|
|
110
|
+
closable: closable,
|
|
111
|
+
maskClosable: maskClosable,
|
|
112
|
+
keyboard: keyboard,
|
|
113
|
+
forceRender: forceRender,
|
|
114
|
+
destroyOnClose: destroyOnClose,
|
|
115
|
+
renderTabsLayout: ModalTabsLayout
|
|
259
116
|
});
|
|
260
117
|
}
|
|
261
118
|
function Modal(rawProps) {
|
|
262
119
|
const props = (0, component_defaults_cjs_namespaceObject.useComponentProps)('Modal', rawProps);
|
|
263
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
120
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModalControl, {
|
|
264
121
|
...props
|
|
265
122
|
});
|
|
266
123
|
}
|
|
267
124
|
exports.Modal = __webpack_exports__.Modal;
|
|
268
|
-
exports.ModalBase = __webpack_exports__.ModalBase;
|
|
269
125
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
270
|
-
"Modal"
|
|
271
|
-
"ModalBase"
|
|
126
|
+
"Modal"
|
|
272
127
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
273
128
|
Object.defineProperty(exports, '__esModule', {
|
|
274
129
|
value: true
|