@ifhover/leaf-ui 0.16.6 → 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/card/card.cjs +29 -14
- package/dist/cjs/browser/modules/card/card.cjs.map +1 -1
- 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 -174
- package/dist/cjs/browser/modules/tabs/tabs.cjs.map +1 -1
- package/dist/cjs/card/card.cjs +29 -14
- package/dist/cjs/card/card.cjs.map +1 -1
- package/dist/cjs/card/card.d.cts.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 +79 -22
- 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 -174
- 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/card/card.js +30 -15
- package/dist/esm/browser/modules/card/card.js.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 -173
- package/dist/esm/browser/modules/tabs/tabs.js.map +1 -1
- package/dist/esm/card/card.d.ts.map +1 -1
- package/dist/esm/card/card.js +30 -15
- package/dist/esm/card/card.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 +79 -22
- 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 -173
- package/dist/esm/tabs/tabs.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/modal/modal.cjs
CHANGED
|
@@ -29,218 +29,69 @@ var __webpack_require__ = {};
|
|
|
29
29
|
var __webpack_exports__ = {};
|
|
30
30
|
__webpack_require__.r(__webpack_exports__);
|
|
31
31
|
__webpack_require__.d(__webpack_exports__, {
|
|
32
|
-
Modal: ()=>Modal
|
|
33
|
-
ModalBase: ()=>ModalBase
|
|
32
|
+
Modal: ()=>Modal
|
|
34
33
|
});
|
|
35
34
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
36
|
-
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
37
35
|
const external_react_namespaceObject = require("react");
|
|
38
|
-
const button_cjs_namespaceObject = require("../button/button.cjs");
|
|
39
36
|
const component_defaults_cjs_namespaceObject = require("../config-provider/component-defaults.cjs");
|
|
40
|
-
const context_cjs_namespaceObject = require("../config-provider/context.cjs");
|
|
41
37
|
const scrollbar_cjs_namespaceObject = require("../scrollbar/scrollbar.cjs");
|
|
42
38
|
const classes_cjs_namespaceObject = require("../shared/classes.cjs");
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
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",
|
|
39
|
+
const tabs_cjs_namespaceObject = require("../tabs/tabs.cjs");
|
|
40
|
+
const external_base_cjs_namespaceObject = require("./base.cjs");
|
|
41
|
+
const useBrowserLayoutEffect = "u" < typeof window ? external_react_namespaceObject.useEffect : external_react_namespaceObject.useLayoutEffect;
|
|
42
|
+
function ModalTabsLayout({ open, tabs, title, titleId, hasHeading, closeButton, contentRef, snapHeight, ariaLabel, ariaLabelledBy, scrollbarLabel, scrollbarLabelledBy, error, children }) {
|
|
43
|
+
const tabExtra = hasHeading || null == closeButton ? tabs.extra : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
44
|
+
className: "leaf-dialog-tab-extra leaf-modal__tab-extra",
|
|
120
45
|
children: [
|
|
121
|
-
|
|
122
|
-
|
|
46
|
+
tabs.extra,
|
|
47
|
+
closeButton
|
|
123
48
|
]
|
|
124
|
-
})
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
49
|
+
});
|
|
50
|
+
const tabLabel = tabs['aria-label'] ?? ('string' == typeof title ? title : ariaLabel);
|
|
51
|
+
const tabLabelledBy = tabs['aria-labelledby'] ?? (null == tabs['aria-label'] && null != title ? titleId : null == tabs['aria-label'] ? ariaLabelledBy : void 0);
|
|
52
|
+
const parts = (0, tabs_cjs_namespaceObject.useTabsParts)({
|
|
53
|
+
...tabs,
|
|
54
|
+
type: 'line',
|
|
55
|
+
placement: 'top',
|
|
56
|
+
size: tabs.size ?? 'md',
|
|
57
|
+
'aria-label': tabLabel,
|
|
58
|
+
'aria-labelledby': tabLabelledBy,
|
|
59
|
+
extra: tabExtra,
|
|
60
|
+
className: (0, classes_cjs_namespaceObject.classes)('leaf-dialog-tabs', hasHeading && 'leaf-dialog-tabs--headed', 'leaf-modal__tabs', tabs.className),
|
|
61
|
+
panelsClassName: 'leaf-dialog-panels',
|
|
62
|
+
visibilityKey: open
|
|
63
|
+
});
|
|
64
|
+
const previousSelected = (0, external_react_namespaceObject.useRef)(parts?.selected);
|
|
65
|
+
useBrowserLayoutEffect(()=>{
|
|
66
|
+
if (previousSelected.current === parts?.selected) return;
|
|
67
|
+
previousSelected.current = parts?.selected;
|
|
68
|
+
snapHeight();
|
|
139
69
|
}, [
|
|
140
|
-
|
|
141
|
-
|
|
70
|
+
parts?.selected,
|
|
71
|
+
snapHeight
|
|
142
72
|
]);
|
|
143
|
-
(0,
|
|
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
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
151
|
-
hidden: !present,
|
|
152
|
-
className: "leaf-modal-mask",
|
|
153
|
-
"data-blur": maskBlur ? void 0 : 'off',
|
|
154
|
-
"data-state": open ? 'open' : 'closing',
|
|
155
|
-
"aria-hidden": !open || void 0,
|
|
156
|
-
...(0, inert_cjs_namespaceObject.inertProps)(!open),
|
|
73
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
157
74
|
children: [
|
|
158
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
className: "leaf-modal-backdrop",
|
|
162
|
-
tabIndex: -1,
|
|
163
|
-
"aria-label": messages.common.close,
|
|
164
|
-
onClick: ()=>{
|
|
165
|
-
if (maskClosable) close.current?.();
|
|
166
|
-
}
|
|
75
|
+
parts && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
76
|
+
...parts.rootProps,
|
|
77
|
+
children: parts.header
|
|
167
78
|
}),
|
|
168
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
"aria-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
null != description && descriptionId
|
|
178
|
-
].filter(Boolean).join(' ') || void 0,
|
|
179
|
-
tabIndex: -1,
|
|
180
|
-
className: (0, classes_cjs_namespaceObject.classes)('leaf-modal', divided && 'leaf-modal--divided', className),
|
|
181
|
-
style: {
|
|
182
|
-
width,
|
|
183
|
-
...style
|
|
184
|
-
},
|
|
185
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(overlay_owner_cjs_namespaceObject.OverlayOwner.Provider, {
|
|
186
|
-
value: modalId,
|
|
79
|
+
(parts?.hasPanels || null != children && false !== children || null != error) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(scrollbar_cjs_namespaceObject.ScrollbarControl, {
|
|
80
|
+
className: "leaf-modal__body",
|
|
81
|
+
viewportClassName: "leaf-modal__viewport",
|
|
82
|
+
orientation: "vertical",
|
|
83
|
+
"aria-labelledby": scrollbarLabelledBy,
|
|
84
|
+
"aria-label": scrollbarLabel,
|
|
85
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
86
|
+
ref: contentRef,
|
|
87
|
+
className: "leaf-modal__content",
|
|
187
88
|
children: [
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
children: icon
|
|
195
|
-
}),
|
|
196
|
-
(null != title || null != description) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
197
|
-
className: "leaf-modal__heading",
|
|
198
|
-
children: [
|
|
199
|
-
null != title && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("h2", {
|
|
200
|
-
id: titleId,
|
|
201
|
-
children: title
|
|
202
|
-
}),
|
|
203
|
-
null != description && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
204
|
-
id: descriptionId,
|
|
205
|
-
className: "leaf-modal__description",
|
|
206
|
-
children: description
|
|
207
|
-
})
|
|
208
|
-
]
|
|
209
|
-
}),
|
|
210
|
-
closable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
211
|
-
type: "button",
|
|
212
|
-
className: "leaf-modal__close",
|
|
213
|
-
"aria-label": messages.common.close,
|
|
214
|
-
onClick: ()=>close.current?.(),
|
|
215
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.X, {
|
|
216
|
-
size: 18,
|
|
217
|
-
"aria-hidden": "true"
|
|
218
|
-
})
|
|
219
|
-
})
|
|
220
|
-
]
|
|
221
|
-
}),
|
|
222
|
-
(null != children && false !== children || null != error) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(scrollbar_cjs_namespaceObject.ScrollbarControl, {
|
|
223
|
-
className: "leaf-modal__body",
|
|
224
|
-
viewportClassName: "leaf-modal__viewport",
|
|
225
|
-
orientation: "vertical",
|
|
226
|
-
"aria-labelledby": null != title ? titleId : void 0,
|
|
227
|
-
"aria-label": null == title ? props['aria-label'] ?? messages.common.confirm : void 0,
|
|
228
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
229
|
-
ref: content,
|
|
230
|
-
className: "leaf-modal__content",
|
|
231
|
-
children: [
|
|
232
|
-
children,
|
|
233
|
-
error && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
234
|
-
role: "alert",
|
|
235
|
-
className: "leaf-confirm-error",
|
|
236
|
-
children: error
|
|
237
|
-
})
|
|
238
|
-
]
|
|
239
|
-
})
|
|
240
|
-
}),
|
|
241
|
-
null != renderedFooter && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
242
|
-
className: "leaf-modal__footer",
|
|
243
|
-
children: renderedFooter
|
|
89
|
+
parts?.panels,
|
|
90
|
+
children,
|
|
91
|
+
error && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
92
|
+
role: "alert",
|
|
93
|
+
className: "leaf-confirm-error",
|
|
94
|
+
children: error
|
|
244
95
|
})
|
|
245
96
|
]
|
|
246
97
|
})
|
|
@@ -248,25 +99,29 @@ function ModalSurface({ open, title, description, icon, divided = true, footer,
|
|
|
248
99
|
]
|
|
249
100
|
});
|
|
250
101
|
}
|
|
251
|
-
function
|
|
252
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
102
|
+
function ModalControl({ divided = true, confirmLoading = false, width = 480, closable = true, maskClosable = true, keyboard = true, forceRender = false, destroyOnClose = false, ...props }) {
|
|
103
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_base_cjs_namespaceObject.ModalBase, {
|
|
104
|
+
...props,
|
|
105
|
+
divided: divided,
|
|
106
|
+
confirmLoading: confirmLoading,
|
|
107
|
+
width: width,
|
|
108
|
+
closable: closable,
|
|
109
|
+
maskClosable: maskClosable,
|
|
110
|
+
keyboard: keyboard,
|
|
111
|
+
forceRender: forceRender,
|
|
112
|
+
destroyOnClose: destroyOnClose,
|
|
113
|
+
renderTabsLayout: ModalTabsLayout
|
|
257
114
|
});
|
|
258
115
|
}
|
|
259
116
|
function Modal(rawProps) {
|
|
260
117
|
const props = (0, component_defaults_cjs_namespaceObject.useComponentProps)('Modal', rawProps);
|
|
261
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
118
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModalControl, {
|
|
262
119
|
...props
|
|
263
120
|
});
|
|
264
121
|
}
|
|
265
122
|
exports.Modal = __webpack_exports__.Modal;
|
|
266
|
-
exports.ModalBase = __webpack_exports__.ModalBase;
|
|
267
123
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
268
|
-
"Modal"
|
|
269
|
-
"ModalBase"
|
|
124
|
+
"Modal"
|
|
270
125
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
271
126
|
Object.defineProperty(exports, '__esModule', {
|
|
272
127
|
value: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal/modal.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../src/modal/modal.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 { type HTMLAttributes, type ReactNode, useEffect, useId, useRef, useState } from 'react';\nimport { ButtonControl, type ButtonProps } from '../button/button';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { useLeafConfig } from '../config-provider/context';\nimport { ScrollbarControl as Scrollbar } from '../scrollbar/scrollbar';\nimport { classes } from '../shared/classes';\nimport { type DialogFocusOptions, 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';\n\nexport interface ModalFooterActions {\n confirmButton: ReactNode;\n cancelButton: ReactNode;\n}\nexport interface ModalProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>,\n DialogFocusOptions {\n open: boolean;\n title?: ReactNode;\n /** Supporting text displayed below the title. */\n description?: ReactNode;\n /** Decorative header icon. */\n icon?: ReactNode;\n /** Separate the header and footer with subtle borders. */\n divided?: boolean;\n footer?: ReactNode | ((actions: ModalFooterActions) => ReactNode);\n confirmText?: ReactNode;\n cancelText?: ReactNode;\n confirmLoading?: boolean;\n confirmButtonProps?: ButtonProps;\n cancelButtonProps?: ButtonProps;\n onConfirm?: () => void | Promise<void>;\n onCancel?: () => void;\n width?: number | string;\n closable?: boolean;\n maskClosable?: boolean;\n keyboard?: boolean;\n onClose?: () => void;\n afterClose?: () => void;\n forceRender?: boolean;\n destroyOnClose?: boolean;\n preserve?: boolean;\n container?: Element | DocumentFragment | (() => Element | DocumentFragment);\n}\n\nfunction ModalSurface({\n open,\n title,\n description,\n icon,\n divided = true,\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 children,\n className,\n style,\n ...props\n}: ModalProps) {\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 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 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('leaf-modal', divided && 'leaf-modal--divided', className)}\n style={{ width, ...style }}\n >\n <OverlayOwner.Provider value={modalId}>\n {(title != null || description != null || icon != null || 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 title == null &&\n description == null &&\n icon == null &&\n '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 {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 )}\n </div>\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={title != null ? titleId : undefined}\n aria-label={\n title == null ? (props['aria-label'] ?? messages.common.confirm) : undefined\n }\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 {renderedFooter != null && <div className=\"leaf-modal__footer\">{renderedFooter}</div>}\n </OverlayOwner.Provider>\n </div>\n </div>\n );\n}\n// Other components reuse the dialog mechanics without inheriting public Modal defaults.\nexport function ModalBase(props: ModalProps) {\n return (\n <ScopedPortal container={props.container}>\n <ModalSurface {...props} />\n </ScopedPortal>\n );\n}\nexport function Modal(rawProps: ModalProps) {\n const props = useComponentProps('Modal', rawProps);\n return <ModalBase {...props} />;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","ModalSurface","open","title","description","icon","divided","footer","confirmText","cancelText","confirmLoading","confirmButtonProps","cancelButtonProps","onConfirm","onCancel","width","closable","maskClosable","keyboard","onClose","afterClose","forceRender","destroyOnClose","preserve","initialFocus","returnFocus","_container","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","useNaturalHeightTransition","titleId","useId","descriptionId","modalId","close","wasPresent","useDialog","visited","inertProps","Boolean","classes","OverlayOwner","X","Scrollbar","ModalBase","ScopedPortal","Modal","rawProps","useComponentProps"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS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A,AAAa,UAAbA,YAAuBU,AAAS,QAATA,KAAY,KACxD,AADwD,cACxD,qCAACsC,8BAAAA,gBAASA,EAAAA;4BACR,WAAU;4BACV,mBAAkB;4BAClB,aAAY;4BACZ,mBAAiBxE,AAAS,QAATA,QAAgB2D,UAAUlB;4BAC3C,cACEzC,AAAS,QAATA,QAAiB2B,KAAK,CAAC,aAAa,IAAIC,SAAS,MAAM,CAAC,OAAO,GAAIa;sCAGrE,oDAAC;gCAAI,KAAKa;gCAAS,WAAU;;oCAC1B9B;oCACAU,SACC,AADQ,WAATA,GACC,qCAAC;wCAAE,MAAK;wCAAQ,WAAU;kDACvBA;;;;;wBAMQ,QAAlBkB,kBAA0B,WAAR,GAAQ,qCAAC;4BAAI,WAAU;sCAAsBA;;;;;;;AAK1E;AAEO,SAASqB,UAAU9C,KAAiB;IACzC,OACE,AADK,WAAP,GACE,qCAAC+C,kCAAAA,YAAYA,EAAAA;QAAC,WAAW/C,MAAM,SAAS;kBACtC,mDAAC7B,cAAAA;YAAc,GAAG6B,KAAK;;;AAG7B;AACO,SAASgD,MAAMC,QAAoB;IACxC,MAAMjD,QAAQkD,AAAAA,IAAAA,uCAAAA,iBAAAA,AAAAA,EAAkB,SAASD;IACzC,OAAO,WAAP,GAAO,qCAACH,WAAAA;QAAW,GAAG9C,KAAK;;AAC7B"}
|
|
1
|
+
{"version":3,"file":"modal/modal.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../src/modal/modal.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 { type HTMLAttributes, type ReactNode, useEffect, useLayoutEffect, useRef } from 'react';\nimport type { ButtonProps } from '../button/button';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { ScrollbarControl as Scrollbar } from '../scrollbar/scrollbar';\nimport { classes } from '../shared/classes';\nimport type { DialogFocusOptions } from '../shared/dialog';\nimport { type TabsProps, useTabsParts } from '../tabs/tabs';\nimport { ModalBase, type ModalTabsRenderProps } from './base';\n\nconst useBrowserLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\nexport interface ModalFooterActions {\n confirmButton: ReactNode;\n cancelButton: ReactNode;\n}\n/** Tabs controls integrated with the modal; Modal fixes the line type and top placement. */\nexport interface ModalTabsProps extends Omit<TabsProps, 'type' | 'placement' | 'children'> {}\n\nexport interface ModalProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>,\n DialogFocusOptions {\n open: boolean;\n title?: ReactNode;\n /** Supporting text displayed below the title. */\n description?: ReactNode;\n /** Decorative header icon. */\n icon?: ReactNode;\n /** Separate the header and footer with subtle borders. */\n divided?: boolean;\n /** Embedded tabs placed below the heading, or replacing it when no title is supplied. */\n tabs?: ModalTabsProps;\n footer?: ReactNode | ((actions: ModalFooterActions) => ReactNode);\n confirmText?: ReactNode;\n cancelText?: ReactNode;\n confirmLoading?: boolean;\n confirmButtonProps?: ButtonProps;\n cancelButtonProps?: ButtonProps;\n onConfirm?: () => void | Promise<void>;\n onCancel?: () => void;\n width?: number | string;\n closable?: boolean;\n maskClosable?: boolean;\n keyboard?: boolean;\n onClose?: () => void;\n afterClose?: () => void;\n forceRender?: boolean;\n destroyOnClose?: boolean;\n preserve?: boolean;\n container?: Element | DocumentFragment | (() => Element | DocumentFragment);\n}\n\nfunction ModalTabsLayout({\n open,\n tabs,\n title,\n titleId,\n hasHeading,\n closeButton,\n contentRef,\n snapHeight,\n ariaLabel,\n ariaLabelledBy,\n scrollbarLabel,\n scrollbarLabelledBy,\n error,\n children,\n}: ModalTabsRenderProps) {\n const tabExtra =\n !hasHeading && closeButton != null ? (\n <div className=\"leaf-dialog-tab-extra leaf-modal__tab-extra\">\n {tabs.extra}\n {closeButton}\n </div>\n ) : (\n tabs.extra\n );\n const tabLabel = tabs['aria-label'] ?? (typeof title === 'string' ? title : ariaLabel);\n const tabLabelledBy =\n tabs['aria-labelledby'] ??\n (tabs['aria-label'] == null && title != null\n ? titleId\n : tabs['aria-label'] == null\n ? ariaLabelledBy\n : undefined);\n const parts = useTabsParts({\n ...tabs,\n type: 'line',\n placement: 'top',\n size: tabs.size ?? 'md',\n 'aria-label': tabLabel,\n 'aria-labelledby': tabLabelledBy,\n extra: tabExtra,\n className: classes(\n 'leaf-dialog-tabs',\n hasHeading && 'leaf-dialog-tabs--headed',\n 'leaf-modal__tabs',\n tabs.className,\n ),\n panelsClassName: 'leaf-dialog-panels',\n visibilityKey: open,\n });\n const previousSelected = useRef(parts?.selected);\n useBrowserLayoutEffect(() => {\n if (previousSelected.current === parts?.selected) return;\n previousSelected.current = parts?.selected;\n snapHeight();\n }, [parts?.selected, snapHeight]);\n\n return (\n <>\n {parts && <div {...parts.rootProps}>{parts.header}</div>}\n {(parts?.hasPanels || (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={contentRef} className=\"leaf-modal__content\">\n {parts?.panels}\n {children}\n {error && (\n <p role=\"alert\" className=\"leaf-confirm-error\">\n {error}\n </p>\n )}\n </div>\n </Scrollbar>\n )}\n </>\n );\n}\n\ntype ModalControlProps = ModalProps;\n\nfunction ModalControl({\n divided = true,\n confirmLoading = false,\n width = 480,\n closable = true,\n maskClosable = true,\n keyboard = true,\n forceRender = false,\n destroyOnClose = false,\n ...props\n}: ModalControlProps) {\n return (\n <ModalBase\n {...props}\n divided={divided}\n confirmLoading={confirmLoading}\n width={width}\n closable={closable}\n maskClosable={maskClosable}\n keyboard={keyboard}\n forceRender={forceRender}\n destroyOnClose={destroyOnClose}\n renderTabsLayout={ModalTabsLayout}\n />\n );\n}\n\nexport function Modal(rawProps: ModalProps) {\n const props = useComponentProps('Modal', rawProps);\n return <ModalControl {...props} />;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","useBrowserLayoutEffect","window","useEffect","useLayoutEffect","ModalTabsLayout","open","tabs","title","titleId","hasHeading","closeButton","contentRef","snapHeight","ariaLabel","ariaLabelledBy","scrollbarLabel","scrollbarLabelledBy","error","children","tabExtra","tabLabel","tabLabelledBy","undefined","parts","useTabsParts","classes","previousSelected","useRef","Scrollbar","ModalControl","divided","confirmLoading","width","closable","maskClosable","keyboard","forceRender","destroyOnClose","props","ModalBase","Modal","rawProps","useComponentProps"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA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MLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { ButtonProps } from '../button/button.cjs';
|
|
3
|
+
import type { DialogFocusOptions } from '../shared/dialog.cjs';
|
|
4
|
+
import { type TabsProps } from '../tabs/tabs.cjs';
|
|
4
5
|
export interface ModalFooterActions {
|
|
5
6
|
confirmButton: ReactNode;
|
|
6
7
|
cancelButton: ReactNode;
|
|
7
8
|
}
|
|
9
|
+
/** Tabs controls integrated with the modal; Modal fixes the line type and top placement. */
|
|
10
|
+
export interface ModalTabsProps extends Omit<TabsProps, 'type' | 'placement' | 'children'> {
|
|
11
|
+
}
|
|
8
12
|
export interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>, DialogFocusOptions {
|
|
9
13
|
open: boolean;
|
|
10
14
|
title?: ReactNode;
|
|
@@ -14,6 +18,8 @@ export interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'
|
|
|
14
18
|
icon?: ReactNode;
|
|
15
19
|
/** Separate the header and footer with subtle borders. */
|
|
16
20
|
divided?: boolean;
|
|
21
|
+
/** Embedded tabs placed below the heading, or replacing it when no title is supplied. */
|
|
22
|
+
tabs?: ModalTabsProps;
|
|
17
23
|
footer?: ReactNode | ((actions: ModalFooterActions) => ReactNode);
|
|
18
24
|
confirmText?: ReactNode;
|
|
19
25
|
cancelText?: ReactNode;
|
|
@@ -33,6 +39,5 @@ export interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'
|
|
|
33
39
|
preserve?: boolean;
|
|
34
40
|
container?: Element | DocumentFragment | (() => Element | DocumentFragment);
|
|
35
41
|
}
|
|
36
|
-
export declare function ModalBase(props: ModalProps): import("react").JSX.Element;
|
|
37
42
|
export declare function Modal(rawProps: ModalProps): import("react").JSX.Element;
|
|
38
43
|
//# sourceMappingURL=modal.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.cts","sourceRoot":"","sources":["../../../src/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,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,GAAG,gBAAgB,GAAG,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC,CAAC;CAC7E;AAkHD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,UAAU,+BAGzC"}
|
|
@@ -39,6 +39,7 @@ const useBrowserLayoutEffect = "u" < typeof window ? external_react_namespaceObj
|
|
|
39
39
|
function useNaturalHeightTransition(surfaceRef, contentRef, open) {
|
|
40
40
|
const enabled = (0, external_motion_cjs_namespaceObject.useMotionEnabled)();
|
|
41
41
|
const sync = (0, external_react_namespaceObject.useRef)(void 0);
|
|
42
|
+
const snap = (0, external_react_namespaceObject.useRef)(()=>{});
|
|
42
43
|
useBrowserLayoutEffect(()=>{
|
|
43
44
|
const surface = surfaceRef.current;
|
|
44
45
|
const content = contentRef.current;
|
|
@@ -87,6 +88,14 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
|
|
|
87
88
|
});
|
|
88
89
|
};
|
|
89
90
|
sync.current = update;
|
|
91
|
+
snap.current = ()=>{
|
|
92
|
+
animation?.cancel();
|
|
93
|
+
reveal?.cancel();
|
|
94
|
+
animation = void 0;
|
|
95
|
+
reveal = void 0;
|
|
96
|
+
lastHeight = surface.offsetHeight;
|
|
97
|
+
lastLayout = layout();
|
|
98
|
+
};
|
|
90
99
|
let observer;
|
|
91
100
|
if ("u" > typeof ResizeObserver) {
|
|
92
101
|
observer = new ResizeObserver(update);
|
|
@@ -94,12 +103,7 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
|
|
|
94
103
|
for (const part of parts())observer.observe(part);
|
|
95
104
|
}
|
|
96
105
|
const resize = ()=>{
|
|
97
|
-
|
|
98
|
-
reveal?.cancel();
|
|
99
|
-
animation = void 0;
|
|
100
|
-
reveal = void 0;
|
|
101
|
-
lastHeight = surface.offsetHeight;
|
|
102
|
-
lastLayout = layout();
|
|
106
|
+
snap.current();
|
|
103
107
|
};
|
|
104
108
|
window.addEventListener('resize', resize);
|
|
105
109
|
window.visualViewport?.addEventListener('resize', resize);
|
|
@@ -110,6 +114,7 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
|
|
|
110
114
|
animation?.cancel();
|
|
111
115
|
reveal?.cancel();
|
|
112
116
|
sync.current = void 0;
|
|
117
|
+
snap.current = ()=>{};
|
|
113
118
|
};
|
|
114
119
|
}, [
|
|
115
120
|
open,
|
|
@@ -120,6 +125,7 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
|
|
|
120
125
|
useBrowserLayoutEffect(()=>{
|
|
121
126
|
sync.current?.();
|
|
122
127
|
});
|
|
128
|
+
return (0, external_react_namespaceObject.useRef)(()=>snap.current()).current;
|
|
123
129
|
}
|
|
124
130
|
function useContentTransition(ref, view, direction = 0, layoutOnly = false) {
|
|
125
131
|
const enabled = (0, external_motion_cjs_namespaceObject.useMotionEnabled)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared/presence.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../src/shared/presence.ts"],"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 { type RefObject, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { animateMotion, useMotionEnabled } from './motion';\n\nconst useBrowserLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\n/** Interpolate natural dialog height, including state changes inside its children. */\nexport function useNaturalHeightTransition(\n surfaceRef: RefObject<HTMLElement | null>,\n contentRef: RefObject<HTMLElement | null>,\n open: boolean,\n) {\n const enabled = useMotionEnabled();\n const sync = useRef<(() => void) | undefined>(undefined);\n useBrowserLayoutEffect(() => {\n const surface = surfaceRef.current;\n const content = contentRef.current;\n if (!open || !enabled || !surface || !content) return;\n let animation: Animation | undefined;\n let reveal: Animation | undefined;\n let lastHeight = surface.offsetHeight;\n let lastLayout = '';\n const parts = () =>\n Array.from(surface.children).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.contains(content),\n );\n const layout = () =>\n [surface.offsetWidth, content.offsetHeight, ...parts().map((part) => part.offsetHeight)].join(\n ':',\n );\n lastLayout = layout();\n const update = () => {\n const nextLayout = layout();\n if (nextLayout === lastLayout || surface.closest('[data-state=\"closing\"]')) return;\n lastLayout = nextLayout;\n // CSS height is unaffected by the separate entrance scale on the surface.\n const before =\n animation?.playState === 'running'\n ? Number.parseFloat(getComputedStyle(surface).height) || lastHeight\n : lastHeight;\n const opacity = reveal?.playState === 'running' ? getComputedStyle(content).opacity : '0.72';\n animation?.cancel();\n reveal?.cancel();\n const height = surface.offsetHeight;\n lastHeight = height;\n if (!before || !height || Math.abs(before - height) < 1) return;\n animation = animateMotion(surface, [{ height: `${before}px` }, { height: `${height}px` }], {\n durationMultiplier: 1.6,\n });\n if (animation)\n reveal = animateMotion(content, [{ opacity }, { opacity: 1 }], {\n durationMultiplier: 1.25,\n });\n };\n sync.current = update;\n let observer: ResizeObserver | undefined;\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(update);\n observer.observe(content);\n for (const part of parts()) observer.observe(part);\n }\n // Viewport constraints change the visible height without changing content.\n // Resizing establishes a fresh baseline instead of animating stale geometry.\n const resize = () => {\n animation?.cancel();\n reveal?.cancel();\n animation = undefined;\n reveal = undefined;\n lastHeight = surface.offsetHeight;\n lastLayout = layout();\n };\n window.addEventListener('resize', resize);\n window.visualViewport?.addEventListener('resize', resize);\n return () => {\n window.removeEventListener('resize', resize);\n window.visualViewport?.removeEventListener('resize', resize);\n observer?.disconnect();\n animation?.cancel();\n reveal?.cancel();\n sync.current = undefined;\n };\n }, [open, enabled, surfaceRef, contentRef]);\n // React updates to the header/footer are measurable before the next paint.\n useBrowserLayoutEffect(() => {\n sync.current?.();\n });\n}\n\n/** Animate a panel's explicit view change without remounting its focused controls. */\nexport function useContentTransition(\n ref: RefObject<HTMLElement | null>,\n view: string | number,\n direction = 0,\n layoutOnly = false,\n) {\n const enabled = useMotionEnabled();\n const travel = useRef(direction);\n travel.current = direction;\n const previous = useRef<{ view: string | number; height: number } | undefined>(undefined);\n useBrowserLayoutEffect(() => {\n const node = ref.current;\n if (!node) {\n previous.current = undefined;\n return;\n }\n const height = Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n const last = previous.current;\n previous.current = { view, height };\n if (!enabled || !last || last.view === view || node.closest('[data-state=\"closing\"]')) return;\n const changesHeight = last.height > 0 && height > 0 && Math.abs(last.height - height) > 1;\n if (layoutOnly && !changesHeight) return;\n const animation = animateMotion(\n node,\n [\n {\n ...(layoutOnly ? {} : { opacity: 0.45, translate: `${travel.current * 12}px 4px` }),\n ...(changesHeight ? { height: `${last.height}px`, overflow: 'clip' } : {}),\n },\n {\n ...(layoutOnly ? {} : { opacity: 1, translate: '0 0' }),\n ...(changesHeight ? { height: `${height}px`, overflow: 'clip' } : {}),\n },\n ],\n { durationMultiplier: 1.25 },\n );\n return () => {\n if (animation && changesHeight && previous.current)\n previous.current.height =\n Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n animation?.cancel();\n };\n }, [enabled, ref, view, layoutOnly]);\n}\n\n/** Keep a closing overlay mounted until its CSS transition or animation finishes. */\nexport function usePresence(open: boolean, ref: RefObject<HTMLElement | null>) {\n const enabled = useMotionEnabled();\n const [present, setPresent] = useState(open);\n if (open && !present) setPresent(true);\n useEffect(() => {\n if (open || !present) return;\n const node = ref.current;\n if (!node || !enabled) {\n setPresent(false);\n return;\n }\n const computed = getComputedStyle(node);\n const durations = [computed.animationDuration, computed.transitionDuration];\n const delays = [computed.animationDelay, computed.transitionDelay];\n const milliseconds = (value: string) => {\n const numeric = Number.parseFloat(value) || 0;\n return value.trim().endsWith('ms') ? numeric : numeric * 1000;\n };\n const duration = Math.max(\n 0,\n ...durations.flatMap((list, index) => {\n const delay = (delays[index] || '0s').split(',').map(milliseconds);\n return (list || '0s')\n .split(',')\n .map((value, i) => milliseconds(value) + (delay[i % delay.length] ?? 0));\n }),\n );\n const finish = () => setPresent(false);\n const ended = (event: Event) => {\n if (event.target === node && (!('propertyName' in event) || event.propertyName === 'opacity'))\n finish();\n };\n const timer = setTimeout(finish, duration ? duration + 32 : 0);\n node.addEventListener('animationend', ended);\n node.addEventListener('transitionend', ended);\n return () => {\n clearTimeout(timer);\n node.removeEventListener('animationend', ended);\n node.removeEventListener('transitionend', ended);\n };\n }, [open, present, ref, enabled]);\n return present;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","useBrowserLayoutEffect","window","useEffect","useLayoutEffect","useNaturalHeightTransition","surfaceRef","contentRef","open","enabled","useMotionEnabled","sync","useRef","undefined","surface","content","animation","reveal","lastHeight","lastLayout","parts","Array","child","HTMLElement","layout","part","update","nextLayout","before","Number","getComputedStyle","opacity","height","Math","animateMotion","observer","ResizeObserver","resize","useContentTransition","ref","view","direction","layoutOnly","travel","previous","node","last","changesHeight","usePresence","present","setPresent","useState","computed","durations","delays","milliseconds","value","numeric","duration","list","index","delay","i","finish","ended","event","timer","setTimeout","clearTimeout"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;ACHA,MAAMI,yBAAyB,AAAkB,MAAlB,OAAOC,SAAyBC,+BAAAA,SAASA,GAAGC,+BAAAA,eAAeA;AAGnF,SAASC,2BACdC,UAAyC,EACzCC,UAAyC,EACzCC,IAAa;IAEb,MAAMC,UAAUC,AAAAA,IAAAA,oCAAAA,gBAAAA,AAAAA;IAChB,MAAMC,OAAOC,AAAAA,IAAAA,+BAAAA,MAAAA,AAAAA,EAA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,gBAAgBmB;YACzCnB,KAAK,mBAAmB,CAAC,iBAAiBmB;QAC5C;IACF,GAAG;QAACxD;QAAMyC;QAASV;QAAK9B;KAAQ;IAChC,OAAOwC;AACT"}
|
|
1
|
+
{"version":3,"file":"shared/presence.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../src/shared/presence.ts"],"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 { type RefObject, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { animateMotion, useMotionEnabled } from './motion';\n\nconst useBrowserLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\n/** Interpolate natural dialog height, including state changes inside its children. */\nexport function useNaturalHeightTransition(\n surfaceRef: RefObject<HTMLElement | null>,\n contentRef: RefObject<HTMLElement | null>,\n open: boolean,\n) {\n const enabled = useMotionEnabled();\n const sync = useRef<(() => void) | undefined>(undefined);\n const snap = useRef<() => void>(() => {});\n useBrowserLayoutEffect(() => {\n const surface = surfaceRef.current;\n const content = contentRef.current;\n if (!open || !enabled || !surface || !content) return;\n let animation: Animation | undefined;\n let reveal: Animation | undefined;\n let lastHeight = surface.offsetHeight;\n let lastLayout = '';\n const parts = () =>\n Array.from(surface.children).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.contains(content),\n );\n const layout = () =>\n [surface.offsetWidth, content.offsetHeight, ...parts().map((part) => part.offsetHeight)].join(\n ':',\n );\n lastLayout = layout();\n const update = () => {\n const nextLayout = layout();\n if (nextLayout === lastLayout || surface.closest('[data-state=\"closing\"]')) return;\n lastLayout = nextLayout;\n // CSS height is unaffected by the separate entrance scale on the surface.\n const before =\n animation?.playState === 'running'\n ? Number.parseFloat(getComputedStyle(surface).height) || lastHeight\n : lastHeight;\n const opacity = reveal?.playState === 'running' ? getComputedStyle(content).opacity : '0.72';\n animation?.cancel();\n reveal?.cancel();\n const height = surface.offsetHeight;\n lastHeight = height;\n if (!before || !height || Math.abs(before - height) < 1) return;\n animation = animateMotion(surface, [{ height: `${before}px` }, { height: `${height}px` }], {\n durationMultiplier: 1.6,\n });\n if (animation)\n reveal = animateMotion(content, [{ opacity }, { opacity: 1 }], {\n durationMultiplier: 1.25,\n });\n };\n sync.current = update;\n // 切换标签页时立即刷新高度基线,避免触发容器高度缓动。\n snap.current = () => {\n animation?.cancel();\n reveal?.cancel();\n animation = undefined;\n reveal = undefined;\n lastHeight = surface.offsetHeight;\n lastLayout = layout();\n };\n let observer: ResizeObserver | undefined;\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(update);\n observer.observe(content);\n for (const part of parts()) observer.observe(part);\n }\n // Viewport constraints change the visible height without changing content.\n // Resizing establishes a fresh baseline instead of animating stale geometry.\n const resize = () => {\n snap.current();\n };\n window.addEventListener('resize', resize);\n window.visualViewport?.addEventListener('resize', resize);\n return () => {\n window.removeEventListener('resize', resize);\n window.visualViewport?.removeEventListener('resize', resize);\n observer?.disconnect();\n animation?.cancel();\n reveal?.cancel();\n sync.current = undefined;\n snap.current = () => {};\n };\n }, [open, enabled, surfaceRef, contentRef]);\n // React updates to the header/footer are measurable before the next paint.\n useBrowserLayoutEffect(() => {\n sync.current?.();\n });\n return useRef(() => snap.current()).current;\n}\n\n/** Animate a panel's explicit view change without remounting its focused controls. */\nexport function useContentTransition(\n ref: RefObject<HTMLElement | null>,\n view: string | number,\n direction = 0,\n layoutOnly = false,\n) {\n const enabled = useMotionEnabled();\n const travel = useRef(direction);\n travel.current = direction;\n const previous = useRef<{ view: string | number; height: number } | undefined>(undefined);\n useBrowserLayoutEffect(() => {\n const node = ref.current;\n if (!node) {\n previous.current = undefined;\n return;\n }\n const height = Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n const last = previous.current;\n previous.current = { view, height };\n if (!enabled || !last || last.view === view || node.closest('[data-state=\"closing\"]')) return;\n const changesHeight = last.height > 0 && height > 0 && Math.abs(last.height - height) > 1;\n if (layoutOnly && !changesHeight) return;\n const animation = animateMotion(\n node,\n [\n {\n ...(layoutOnly ? {} : { opacity: 0.45, translate: `${travel.current * 12}px 4px` }),\n ...(changesHeight ? { height: `${last.height}px`, overflow: 'clip' } : {}),\n },\n {\n ...(layoutOnly ? {} : { opacity: 1, translate: '0 0' }),\n ...(changesHeight ? { height: `${height}px`, overflow: 'clip' } : {}),\n },\n ],\n { durationMultiplier: 1.25 },\n );\n return () => {\n if (animation && changesHeight && previous.current)\n previous.current.height =\n Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n animation?.cancel();\n };\n }, [enabled, ref, view, layoutOnly]);\n}\n\n/** Keep a closing overlay mounted until its CSS transition or animation finishes. */\nexport function usePresence(open: boolean, ref: RefObject<HTMLElement | null>) {\n const enabled = useMotionEnabled();\n const [present, setPresent] = useState(open);\n if (open && !present) setPresent(true);\n useEffect(() => {\n if (open || !present) return;\n const node = ref.current;\n if (!node || !enabled) {\n setPresent(false);\n return;\n }\n const computed = getComputedStyle(node);\n const durations = [computed.animationDuration, computed.transitionDuration];\n const delays = [computed.animationDelay, computed.transitionDelay];\n const milliseconds = (value: string) => {\n const numeric = Number.parseFloat(value) || 0;\n return value.trim().endsWith('ms') ? numeric : numeric * 1000;\n };\n const duration = Math.max(\n 0,\n ...durations.flatMap((list, index) => {\n const delay = (delays[index] || '0s').split(',').map(milliseconds);\n return (list || '0s')\n .split(',')\n .map((value, i) => milliseconds(value) + (delay[i % delay.length] ?? 0));\n }),\n );\n const finish = () => setPresent(false);\n const ended = (event: Event) => {\n if (event.target === node && (!('propertyName' in event) || event.propertyName === 'opacity'))\n finish();\n };\n const timer = setTimeout(finish, duration ? duration + 32 : 0);\n node.addEventListener('animationend', ended);\n node.addEventListener('transitionend', ended);\n return () => {\n clearTimeout(timer);\n node.removeEventListener('animationend', ended);\n node.removeEventListener('transitionend', ended);\n };\n }, [open, present, ref, enabled]);\n return present;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","useBrowserLayoutEffect","window","useEffect","useLayoutEffect","useNaturalHeightTransition","surfaceRef","contentRef","open","enabled","useMotionEnabled","sync","useRef","undefined","snap","surface","content","animation","reveal","lastHeight","lastLayout","parts","Array","child","HTMLElement","layout","part","update","nextLayout","before","Number","getComputedStyle","opacity","height","Math","animateMotion","observer","ResizeObserver","resize","useContentTransition","ref","view","direction","layoutOnly","travel","previous","node","last","changesHeight","usePresence","present","setPresent","useState","computed","durations","delays","milliseconds","value","numeric","duration","list","index","delay","i","finish","ended","event","timer","setTimeout","clearTimeout"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,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,OAAVA;QACjD;QACA,MAAMC,WAAWzB,KAAK,GAAG,CACvB,MACGoB,UAAU,OAAO,CAAC,CAACM,MAAMC;YAC1B,MAAMC,QAASP,AAAAA,CAAAA,MAAM,CAACM,MAAM,IAAI,IAAG,EAAG,KAAK,CAAC,KAAK,GAAG,CAACL;YACrD,OAAQI,AAAAA,CAAAA,QAAQ,IAAG,EAChB,KAAK,CAAC,KACN,GAAG,CAAC,CAACH,OAAOM,IAAMP,aAAaC,SAAUK,CAAAA,KAAK,CAACC,IAAID,MAAM,MAAM,CAAC,IAAI;QACzE;QAEF,MAAME,SAAS,IAAMb,WAAW;QAChC,MAAMc,QAAQ,CAACC;YACb,IAAIA,MAAM,MAAM,KAAKpB,QAAS,EAAE,mBAAkBoB,KAAI,KAAMA,AAAuB,cAAvBA,MAAM,YAAY,AAAa,GACzFF;QACJ;QACA,MAAMG,QAAQC,WAAWJ,QAAQL,WAAWA,WAAW,KAAK;QAC5Db,KAAK,gBAAgB,CAAC,gBAAgBmB;QACtCnB,KAAK,gBAAgB,CAAC,iBAAiBmB;QACvC,OAAO;YACLI,aAAaF;YACbrB,KAAK,mBAAmB,CAAC,gBAAgBmB;YACzCnB,KAAK,mBAAmB,CAAC,iBAAiBmB;QAC5C;IACF,GAAG;QAACzD;QAAM0C;QAASV;QAAK/B;KAAQ;IAChC,OAAOyC;AACT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RefObject } from 'react';
|
|
2
2
|
/** Interpolate natural dialog height, including state changes inside its children. */
|
|
3
|
-
export declare function useNaturalHeightTransition(surfaceRef: RefObject<HTMLElement | null>, contentRef: RefObject<HTMLElement | null>, open: boolean): void;
|
|
3
|
+
export declare function useNaturalHeightTransition(surfaceRef: RefObject<HTMLElement | null>, contentRef: RefObject<HTMLElement | null>, open: boolean): () => void;
|
|
4
4
|
/** Animate a panel's explicit view change without remounting its focused controls. */
|
|
5
5
|
export declare function useContentTransition(ref: RefObject<HTMLElement | null>, view: string | number, direction?: number, layoutOnly?: boolean): void;
|
|
6
6
|
/** Keep a closing overlay mounted until its CSS transition or animation finishes. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presence.d.cts","sourceRoot":"","sources":["../../../src/shared/presence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAgD,MAAM,OAAO,CAAC;AAKrF,sFAAsF;AACtF,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACzC,UAAU,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACzC,IAAI,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"presence.d.cts","sourceRoot":"","sources":["../../../src/shared/presence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAgD,MAAM,OAAO,CAAC;AAKrF,sFAAsF;AACtF,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACzC,UAAU,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACzC,IAAI,EAAE,OAAO,cAmFd;AAED,sFAAsF;AACtF,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAClC,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,SAAS,SAAI,EACb,UAAU,UAAQ,QAuCnB;AAED,qFAAqF;AACrF,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,WA0C5E"}
|