@sytechui/modal 2.2.29
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/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/chunk-6UNMARUO.mjs +112 -0
- package/dist/chunk-IYHOL6KG.mjs +37 -0
- package/dist/chunk-MZ2TEFDD.mjs +37 -0
- package/dist/chunk-NQ34YL6U.mjs +31 -0
- package/dist/chunk-NQV4LXOC.mjs +25 -0
- package/dist/chunk-PN5RGUFB.mjs +133 -0
- package/dist/chunk-S6FNYUYS.mjs +41 -0
- package/dist/chunk-ULX4JIBE.mjs +13 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +433 -0
- package/dist/index.mjs +40 -0
- package/dist/modal-body.d.mts +8 -0
- package/dist/modal-body.d.ts +8 -0
- package/dist/modal-body.js +62 -0
- package/dist/modal-body.mjs +8 -0
- package/dist/modal-content.d.mts +15 -0
- package/dist/modal-content.d.ts +15 -0
- package/dist/modal-content.js +180 -0
- package/dist/modal-content.mjs +9 -0
- package/dist/modal-context.d.mts +310 -0
- package/dist/modal-context.d.ts +310 -0
- package/dist/modal-context.js +37 -0
- package/dist/modal-context.mjs +9 -0
- package/dist/modal-footer.d.mts +8 -0
- package/dist/modal-footer.d.ts +8 -0
- package/dist/modal-footer.js +56 -0
- package/dist/modal-footer.mjs +8 -0
- package/dist/modal-header.d.mts +13 -0
- package/dist/modal-header.d.ts +13 -0
- package/dist/modal-header.js +62 -0
- package/dist/modal-header.mjs +8 -0
- package/dist/modal-transition.d.mts +35 -0
- package/dist/modal-transition.d.ts +35 -0
- package/dist/modal-transition.js +64 -0
- package/dist/modal-transition.mjs +7 -0
- package/dist/modal.d.mts +19 -0
- package/dist/modal.d.ts +19 -0
- package/dist/modal.js +175 -0
- package/dist/modal.mjs +9 -0
- package/dist/use-modal.d.mts +227 -0
- package/dist/use-modal.d.ts +227 -0
- package/dist/use-modal.js +156 -0
- package/dist/use-modal.mjs +7 -0
- package/package.json +68 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var index_exports = {};
|
|
33
|
+
__export(index_exports, {
|
|
34
|
+
Modal: () => modal_default,
|
|
35
|
+
ModalBody: () => modal_body_default,
|
|
36
|
+
ModalContent: () => modal_content_default,
|
|
37
|
+
ModalFooter: () => modal_footer_default,
|
|
38
|
+
ModalHeader: () => modal_header_default,
|
|
39
|
+
ModalProvider: () => ModalProvider,
|
|
40
|
+
useDisclosure: () => import_use_disclosure.useDisclosure,
|
|
41
|
+
useDraggable: () => import_use_draggable.useDraggable,
|
|
42
|
+
useModal: () => useModal,
|
|
43
|
+
useModalContext: () => useModalContext
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(index_exports);
|
|
46
|
+
|
|
47
|
+
// src/modal.tsx
|
|
48
|
+
var import_framer_motion = require("framer-motion");
|
|
49
|
+
var import_overlays2 = require("@react-aria/overlays");
|
|
50
|
+
var import_system2 = require("@sytechui/system");
|
|
51
|
+
|
|
52
|
+
// src/use-modal.ts
|
|
53
|
+
var import_use_aria_modal_overlay = require("@sytechui/use-aria-modal-overlay");
|
|
54
|
+
var import_react = require("react");
|
|
55
|
+
var import_theme = require("@sytechui/theme");
|
|
56
|
+
var import_system = require("@sytechui/system");
|
|
57
|
+
var import_use_aria_button = require("@sytechui/use-aria-button");
|
|
58
|
+
var import_focus = require("@react-aria/focus");
|
|
59
|
+
var import_shared_utils = require("@sytechui/shared-utils");
|
|
60
|
+
var import_react_utils = require("@sytechui/react-utils");
|
|
61
|
+
var import_overlays = require("@react-stately/overlays");
|
|
62
|
+
function useModal(originalProps) {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
const globalContext = (0, import_system.useProviderContext)();
|
|
65
|
+
const [props, variantProps] = (0, import_system.mapPropsVariants)(originalProps, import_theme.modal.variantKeys);
|
|
66
|
+
const {
|
|
67
|
+
ref,
|
|
68
|
+
as,
|
|
69
|
+
className,
|
|
70
|
+
classNames,
|
|
71
|
+
isOpen,
|
|
72
|
+
defaultOpen,
|
|
73
|
+
onOpenChange,
|
|
74
|
+
motionProps,
|
|
75
|
+
closeButton,
|
|
76
|
+
isDismissable = true,
|
|
77
|
+
hideCloseButton = false,
|
|
78
|
+
shouldBlockScroll = true,
|
|
79
|
+
portalContainer,
|
|
80
|
+
isKeyboardDismissDisabled = false,
|
|
81
|
+
onClose,
|
|
82
|
+
...otherProps
|
|
83
|
+
} = props;
|
|
84
|
+
const Component = as || "section";
|
|
85
|
+
const domRef = (0, import_react_utils.useDOMRef)(ref);
|
|
86
|
+
const closeButtonRef = (0, import_react.useRef)(null);
|
|
87
|
+
const [headerMounted, setHeaderMounted] = (0, import_react.useState)(false);
|
|
88
|
+
const [bodyMounted, setBodyMounted] = (0, import_react.useState)(false);
|
|
89
|
+
const disableAnimation = (_b = (_a = originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
|
|
90
|
+
const dialogId = (0, import_react.useId)();
|
|
91
|
+
const headerId = (0, import_react.useId)();
|
|
92
|
+
const bodyId = (0, import_react.useId)();
|
|
93
|
+
const state = (0, import_overlays.useOverlayTriggerState)({
|
|
94
|
+
isOpen,
|
|
95
|
+
defaultOpen,
|
|
96
|
+
onOpenChange: (isOpen2) => {
|
|
97
|
+
onOpenChange == null ? void 0 : onOpenChange(isOpen2);
|
|
98
|
+
if (!isOpen2) {
|
|
99
|
+
onClose == null ? void 0 : onClose();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const { modalProps, underlayProps } = (0, import_use_aria_modal_overlay.useAriaModalOverlay)(
|
|
104
|
+
{
|
|
105
|
+
isDismissable,
|
|
106
|
+
shouldBlockScroll,
|
|
107
|
+
isKeyboardDismissDisabled
|
|
108
|
+
},
|
|
109
|
+
state,
|
|
110
|
+
domRef
|
|
111
|
+
);
|
|
112
|
+
const { buttonProps: closeButtonProps } = (0, import_use_aria_button.useAriaButton)({ onPress: state.close }, closeButtonRef);
|
|
113
|
+
const { isFocusVisible: isCloseButtonFocusVisible, focusProps: closeButtonFocusProps } = (0, import_focus.useFocusRing)();
|
|
114
|
+
const baseStyles = (0, import_theme.cn)(classNames == null ? void 0 : classNames.base, className);
|
|
115
|
+
const slots = (0, import_react.useMemo)(
|
|
116
|
+
() => (0, import_theme.modal)({
|
|
117
|
+
...variantProps,
|
|
118
|
+
disableAnimation
|
|
119
|
+
}),
|
|
120
|
+
[(0, import_shared_utils.objectToDeps)(variantProps), disableAnimation]
|
|
121
|
+
);
|
|
122
|
+
const getDialogProps = (props2 = {}, ref2 = null) => {
|
|
123
|
+
var _a2;
|
|
124
|
+
return {
|
|
125
|
+
ref: (0, import_shared_utils.mergeRefs)(ref2, domRef),
|
|
126
|
+
...(0, import_shared_utils.mergeProps)(modalProps, otherProps, props2),
|
|
127
|
+
className: slots.base({ class: (0, import_theme.cn)(baseStyles, props2.className) }),
|
|
128
|
+
id: dialogId,
|
|
129
|
+
"data-open": (0, import_shared_utils.dataAttr)(state.isOpen),
|
|
130
|
+
"data-dismissable": (0, import_shared_utils.dataAttr)(isDismissable),
|
|
131
|
+
"aria-modal": (0, import_shared_utils.dataAttr)(true),
|
|
132
|
+
"data-placement": (_a2 = originalProps == null ? void 0 : originalProps.placement) != null ? _a2 : "right",
|
|
133
|
+
"aria-labelledby": headerMounted ? headerId : void 0,
|
|
134
|
+
"aria-describedby": bodyMounted ? bodyId : void 0
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
const getBackdropProps = (0, import_react.useCallback)(
|
|
138
|
+
(props2 = {}) => ({
|
|
139
|
+
className: slots.backdrop({ class: classNames == null ? void 0 : classNames.backdrop }),
|
|
140
|
+
...underlayProps,
|
|
141
|
+
...props2
|
|
142
|
+
}),
|
|
143
|
+
[slots, classNames, underlayProps]
|
|
144
|
+
);
|
|
145
|
+
const getCloseButtonProps = () => {
|
|
146
|
+
return {
|
|
147
|
+
role: "button",
|
|
148
|
+
tabIndex: 0,
|
|
149
|
+
"aria-label": "Close",
|
|
150
|
+
"data-focus-visible": (0, import_shared_utils.dataAttr)(isCloseButtonFocusVisible),
|
|
151
|
+
className: slots.closeButton({ class: classNames == null ? void 0 : classNames.closeButton }),
|
|
152
|
+
...(0, import_shared_utils.mergeProps)(closeButtonProps, closeButtonFocusProps)
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
Component,
|
|
157
|
+
slots,
|
|
158
|
+
domRef,
|
|
159
|
+
headerId,
|
|
160
|
+
bodyId,
|
|
161
|
+
motionProps,
|
|
162
|
+
classNames,
|
|
163
|
+
isDismissable,
|
|
164
|
+
closeButton,
|
|
165
|
+
hideCloseButton,
|
|
166
|
+
portalContainer,
|
|
167
|
+
shouldBlockScroll,
|
|
168
|
+
backdrop: (_c = originalProps.backdrop) != null ? _c : "opaque",
|
|
169
|
+
isOpen: state.isOpen,
|
|
170
|
+
onClose: state.close,
|
|
171
|
+
disableAnimation,
|
|
172
|
+
setBodyMounted,
|
|
173
|
+
setHeaderMounted,
|
|
174
|
+
getDialogProps,
|
|
175
|
+
getBackdropProps,
|
|
176
|
+
getCloseButtonProps
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/modal-context.ts
|
|
181
|
+
var import_react_utils2 = require("@sytechui/react-utils");
|
|
182
|
+
var [ModalProvider, useModalContext] = (0, import_react_utils2.createContext)({
|
|
183
|
+
name: "ModalContext",
|
|
184
|
+
errorMessage: "useModalContext: `context` is undefined. Seems you forgot to wrap all popover components within `<Modal />`"
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// src/modal.tsx
|
|
188
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
189
|
+
var Modal = (0, import_system2.forwardRef)((props, ref) => {
|
|
190
|
+
const { children, ...otherProps } = props;
|
|
191
|
+
const context = useModal({ ...otherProps, ref });
|
|
192
|
+
const overlay = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_overlays2.Overlay, { portalContainer: context.portalContainer, children });
|
|
193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalProvider, { value: context, children: context.disableAnimation && context.isOpen ? overlay : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.AnimatePresence, { children: context.isOpen ? overlay : null }) });
|
|
194
|
+
});
|
|
195
|
+
Modal.displayName = "HeroUI.Modal";
|
|
196
|
+
var modal_default = Modal;
|
|
197
|
+
|
|
198
|
+
// src/modal-content.tsx
|
|
199
|
+
var import_react2 = require("react");
|
|
200
|
+
var import_overlays3 = require("@react-aria/overlays");
|
|
201
|
+
var import_framer_utils2 = require("@sytechui/framer-utils");
|
|
202
|
+
var import_shared_icons = require("@sytechui/shared-icons");
|
|
203
|
+
var import_framer_motion2 = require("framer-motion");
|
|
204
|
+
var import_dialog = require("@react-aria/dialog");
|
|
205
|
+
var import_shared_utils2 = require("@sytechui/shared-utils");
|
|
206
|
+
var import_use_viewport_size = require("@sytechui/use-viewport-size");
|
|
207
|
+
|
|
208
|
+
// src/modal-transition.ts
|
|
209
|
+
var import_framer_utils = require("@sytechui/framer-utils");
|
|
210
|
+
var scaleInOut = {
|
|
211
|
+
enter: {
|
|
212
|
+
scale: "var(--scale-enter)",
|
|
213
|
+
y: "var(--slide-enter)",
|
|
214
|
+
opacity: 1,
|
|
215
|
+
willChange: "auto",
|
|
216
|
+
transition: {
|
|
217
|
+
scale: {
|
|
218
|
+
duration: 0.4,
|
|
219
|
+
ease: import_framer_utils.TRANSITION_EASINGS.ease
|
|
220
|
+
},
|
|
221
|
+
opacity: {
|
|
222
|
+
duration: 0.4,
|
|
223
|
+
ease: import_framer_utils.TRANSITION_EASINGS.ease
|
|
224
|
+
},
|
|
225
|
+
y: {
|
|
226
|
+
type: "spring",
|
|
227
|
+
bounce: 0,
|
|
228
|
+
duration: 0.6
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
exit: {
|
|
233
|
+
scale: "var(--scale-exit)",
|
|
234
|
+
y: "var(--slide-exit)",
|
|
235
|
+
opacity: 0,
|
|
236
|
+
willChange: "transform",
|
|
237
|
+
transition: {
|
|
238
|
+
duration: 0.3,
|
|
239
|
+
ease: import_framer_utils.TRANSITION_EASINGS.ease
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// src/modal-content.tsx
|
|
245
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
246
|
+
var domAnimation = () => import("@sytechui/dom-animation").then((res) => res.default);
|
|
247
|
+
var ModalContent = (props) => {
|
|
248
|
+
const { as, children, role = "dialog", ...otherProps } = props;
|
|
249
|
+
const {
|
|
250
|
+
Component: DialogComponent,
|
|
251
|
+
domRef,
|
|
252
|
+
slots,
|
|
253
|
+
classNames,
|
|
254
|
+
motionProps,
|
|
255
|
+
backdrop,
|
|
256
|
+
closeButton,
|
|
257
|
+
hideCloseButton,
|
|
258
|
+
disableAnimation,
|
|
259
|
+
getDialogProps,
|
|
260
|
+
getBackdropProps,
|
|
261
|
+
getCloseButtonProps,
|
|
262
|
+
onClose
|
|
263
|
+
} = useModalContext();
|
|
264
|
+
const Component = as || DialogComponent || "div";
|
|
265
|
+
const viewport = (0, import_use_viewport_size.useViewportSize)();
|
|
266
|
+
const { dialogProps } = (0, import_dialog.useDialog)(
|
|
267
|
+
{
|
|
268
|
+
role
|
|
269
|
+
},
|
|
270
|
+
domRef
|
|
271
|
+
);
|
|
272
|
+
const closeButtonContent = (0, import_react2.isValidElement)(closeButton) ? (0, import_react2.cloneElement)(closeButton, getCloseButtonProps()) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { ...getCloseButtonProps(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_shared_icons.CloseIcon, {}) });
|
|
273
|
+
const onKeyDown = (0, import_react2.useCallback)((e) => {
|
|
274
|
+
if (e.key === "Tab" && e.nativeEvent.isComposing) {
|
|
275
|
+
e.stopPropagation();
|
|
276
|
+
e.preventDefault();
|
|
277
|
+
}
|
|
278
|
+
}, []);
|
|
279
|
+
const contentProps = getDialogProps((0, import_shared_utils2.mergeProps)(dialogProps, otherProps));
|
|
280
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Component, { ...contentProps, onKeyDown: (0, import_shared_utils2.chain)(contentProps.onKeyDown, onKeyDown), children: [
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_overlays3.DismissButton, { onDismiss: onClose }),
|
|
282
|
+
!hideCloseButton && closeButtonContent,
|
|
283
|
+
typeof children === "function" ? children(onClose) : children,
|
|
284
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_overlays3.DismissButton, { onDismiss: onClose })
|
|
285
|
+
] });
|
|
286
|
+
const backdropContent = (0, import_react2.useMemo)(() => {
|
|
287
|
+
if (backdrop === "transparent") {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
if (disableAnimation) {
|
|
291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ...getBackdropProps() });
|
|
292
|
+
}
|
|
293
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_framer_motion2.LazyMotion, { features: domAnimation, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
294
|
+
import_framer_motion2.m.div,
|
|
295
|
+
{
|
|
296
|
+
animate: "enter",
|
|
297
|
+
exit: "exit",
|
|
298
|
+
initial: "exit",
|
|
299
|
+
variants: import_framer_utils2.TRANSITION_VARIANTS.fade,
|
|
300
|
+
...getBackdropProps()
|
|
301
|
+
}
|
|
302
|
+
) });
|
|
303
|
+
}, [backdrop, disableAnimation, getBackdropProps]);
|
|
304
|
+
const viewportStyle = {
|
|
305
|
+
"--visual-viewport-height": viewport.height + "px"
|
|
306
|
+
};
|
|
307
|
+
const contents = disableAnimation ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
308
|
+
"div",
|
|
309
|
+
{
|
|
310
|
+
className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }),
|
|
311
|
+
"data-slot": "wrapper",
|
|
312
|
+
style: viewportStyle,
|
|
313
|
+
children: content
|
|
314
|
+
}
|
|
315
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_framer_motion2.LazyMotion, { features: domAnimation, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
316
|
+
import_framer_motion2.m.div,
|
|
317
|
+
{
|
|
318
|
+
animate: "enter",
|
|
319
|
+
className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }),
|
|
320
|
+
"data-slot": "wrapper",
|
|
321
|
+
exit: "exit",
|
|
322
|
+
initial: "exit",
|
|
323
|
+
variants: scaleInOut,
|
|
324
|
+
...motionProps,
|
|
325
|
+
style: viewportStyle,
|
|
326
|
+
children: content
|
|
327
|
+
}
|
|
328
|
+
) });
|
|
329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { tabIndex: -1, children: [
|
|
330
|
+
backdropContent,
|
|
331
|
+
contents
|
|
332
|
+
] });
|
|
333
|
+
};
|
|
334
|
+
ModalContent.displayName = "HeroUI.ModalContent";
|
|
335
|
+
var modal_content_default = ModalContent;
|
|
336
|
+
|
|
337
|
+
// src/modal-header.tsx
|
|
338
|
+
var import_react3 = require("react");
|
|
339
|
+
var import_system3 = require("@sytechui/system");
|
|
340
|
+
var import_react_utils3 = require("@sytechui/react-utils");
|
|
341
|
+
var import_theme2 = require("@sytechui/theme");
|
|
342
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
343
|
+
var ModalHeader = (0, import_system3.forwardRef)((props, ref) => {
|
|
344
|
+
const { as, children, className, ...otherProps } = props;
|
|
345
|
+
const { slots, classNames, headerId, setHeaderMounted } = useModalContext();
|
|
346
|
+
const domRef = (0, import_react_utils3.useDOMRef)(ref);
|
|
347
|
+
const Component = as || "header";
|
|
348
|
+
(0, import_react3.useEffect)(() => {
|
|
349
|
+
setHeaderMounted(true);
|
|
350
|
+
return () => setHeaderMounted(false);
|
|
351
|
+
}, [setHeaderMounted]);
|
|
352
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
353
|
+
Component,
|
|
354
|
+
{
|
|
355
|
+
ref: domRef,
|
|
356
|
+
className: slots.header({ class: (0, import_theme2.cn)(classNames == null ? void 0 : classNames.header, className) }),
|
|
357
|
+
id: headerId,
|
|
358
|
+
...otherProps,
|
|
359
|
+
children
|
|
360
|
+
}
|
|
361
|
+
);
|
|
362
|
+
});
|
|
363
|
+
ModalHeader.displayName = "HeroUI.ModalHeader";
|
|
364
|
+
var modal_header_default = ModalHeader;
|
|
365
|
+
|
|
366
|
+
// src/modal-body.tsx
|
|
367
|
+
var import_react4 = require("react");
|
|
368
|
+
var import_system4 = require("@sytechui/system");
|
|
369
|
+
var import_react_utils4 = require("@sytechui/react-utils");
|
|
370
|
+
var import_theme3 = require("@sytechui/theme");
|
|
371
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
372
|
+
var ModalBody = (0, import_system4.forwardRef)((props, ref) => {
|
|
373
|
+
const { as, children, className, ...otherProps } = props;
|
|
374
|
+
const { slots, classNames, bodyId, setBodyMounted } = useModalContext();
|
|
375
|
+
const domRef = (0, import_react_utils4.useDOMRef)(ref);
|
|
376
|
+
const Component = as || "div";
|
|
377
|
+
(0, import_react4.useEffect)(() => {
|
|
378
|
+
setBodyMounted(true);
|
|
379
|
+
return () => setBodyMounted(false);
|
|
380
|
+
}, [setBodyMounted]);
|
|
381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
382
|
+
Component,
|
|
383
|
+
{
|
|
384
|
+
ref: domRef,
|
|
385
|
+
className: slots.body({ class: (0, import_theme3.cn)(classNames == null ? void 0 : classNames.body, className) }),
|
|
386
|
+
id: bodyId,
|
|
387
|
+
...otherProps,
|
|
388
|
+
children
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
});
|
|
392
|
+
ModalBody.displayName = "HeroUI.ModalBody";
|
|
393
|
+
var modal_body_default = ModalBody;
|
|
394
|
+
|
|
395
|
+
// src/modal-footer.tsx
|
|
396
|
+
var import_system5 = require("@sytechui/system");
|
|
397
|
+
var import_react_utils5 = require("@sytechui/react-utils");
|
|
398
|
+
var import_theme4 = require("@sytechui/theme");
|
|
399
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
400
|
+
var ModalFooter = (0, import_system5.forwardRef)((props, ref) => {
|
|
401
|
+
const { as, children, className, ...otherProps } = props;
|
|
402
|
+
const { slots, classNames } = useModalContext();
|
|
403
|
+
const domRef = (0, import_react_utils5.useDOMRef)(ref);
|
|
404
|
+
const Component = as || "footer";
|
|
405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
406
|
+
Component,
|
|
407
|
+
{
|
|
408
|
+
ref: domRef,
|
|
409
|
+
className: slots.footer({ class: (0, import_theme4.cn)(classNames == null ? void 0 : classNames.footer, className) }),
|
|
410
|
+
...otherProps,
|
|
411
|
+
children
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
});
|
|
415
|
+
ModalFooter.displayName = "HeroUI.ModalFooter";
|
|
416
|
+
var modal_footer_default = ModalFooter;
|
|
417
|
+
|
|
418
|
+
// src/index.ts
|
|
419
|
+
var import_use_disclosure = require("@sytechui/use-disclosure");
|
|
420
|
+
var import_use_draggable = require("@sytechui/use-draggable");
|
|
421
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
422
|
+
0 && (module.exports = {
|
|
423
|
+
Modal,
|
|
424
|
+
ModalBody,
|
|
425
|
+
ModalContent,
|
|
426
|
+
ModalFooter,
|
|
427
|
+
ModalHeader,
|
|
428
|
+
ModalProvider,
|
|
429
|
+
useDisclosure,
|
|
430
|
+
useDraggable,
|
|
431
|
+
useModal,
|
|
432
|
+
useModalContext
|
|
433
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
modal_body_default
|
|
4
|
+
} from "./chunk-IYHOL6KG.mjs";
|
|
5
|
+
import {
|
|
6
|
+
modal_content_default
|
|
7
|
+
} from "./chunk-6UNMARUO.mjs";
|
|
8
|
+
import {
|
|
9
|
+
modal_footer_default
|
|
10
|
+
} from "./chunk-NQ34YL6U.mjs";
|
|
11
|
+
import {
|
|
12
|
+
modal_header_default
|
|
13
|
+
} from "./chunk-MZ2TEFDD.mjs";
|
|
14
|
+
import "./chunk-S6FNYUYS.mjs";
|
|
15
|
+
import {
|
|
16
|
+
modal_default
|
|
17
|
+
} from "./chunk-NQV4LXOC.mjs";
|
|
18
|
+
import {
|
|
19
|
+
useModal
|
|
20
|
+
} from "./chunk-PN5RGUFB.mjs";
|
|
21
|
+
import {
|
|
22
|
+
ModalProvider,
|
|
23
|
+
useModalContext
|
|
24
|
+
} from "./chunk-ULX4JIBE.mjs";
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
import { useDisclosure } from "@sytechui/use-disclosure";
|
|
28
|
+
import { useDraggable } from "@sytechui/use-draggable";
|
|
29
|
+
export {
|
|
30
|
+
modal_default as Modal,
|
|
31
|
+
modal_body_default as ModalBody,
|
|
32
|
+
modal_content_default as ModalContent,
|
|
33
|
+
modal_footer_default as ModalFooter,
|
|
34
|
+
modal_header_default as ModalHeader,
|
|
35
|
+
ModalProvider,
|
|
36
|
+
useDisclosure,
|
|
37
|
+
useDraggable,
|
|
38
|
+
useModal,
|
|
39
|
+
useModalContext
|
|
40
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as _sytechui_system from '@sytechui/system';
|
|
2
|
+
import { HTMLHeroUIProps } from '@sytechui/system';
|
|
3
|
+
|
|
4
|
+
interface ModalBodyProps extends HTMLHeroUIProps<"div"> {
|
|
5
|
+
}
|
|
6
|
+
declare const ModalBody: _sytechui_system.InternalForwardRefRenderFunction<"div", ModalBodyProps, never>;
|
|
7
|
+
|
|
8
|
+
export { type ModalBodyProps, ModalBody as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as _sytechui_system from '@sytechui/system';
|
|
2
|
+
import { HTMLHeroUIProps } from '@sytechui/system';
|
|
3
|
+
|
|
4
|
+
interface ModalBodyProps extends HTMLHeroUIProps<"div"> {
|
|
5
|
+
}
|
|
6
|
+
declare const ModalBody: _sytechui_system.InternalForwardRefRenderFunction<"div", ModalBodyProps, never>;
|
|
7
|
+
|
|
8
|
+
export { type ModalBodyProps, ModalBody as default };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/modal-body.tsx
|
|
22
|
+
var modal_body_exports = {};
|
|
23
|
+
__export(modal_body_exports, {
|
|
24
|
+
default: () => modal_body_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(modal_body_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_system = require("@sytechui/system");
|
|
29
|
+
var import_react_utils2 = require("@sytechui/react-utils");
|
|
30
|
+
var import_theme = require("@sytechui/theme");
|
|
31
|
+
|
|
32
|
+
// src/modal-context.ts
|
|
33
|
+
var import_react_utils = require("@sytechui/react-utils");
|
|
34
|
+
var [ModalProvider, useModalContext] = (0, import_react_utils.createContext)({
|
|
35
|
+
name: "ModalContext",
|
|
36
|
+
errorMessage: "useModalContext: `context` is undefined. Seems you forgot to wrap all popover components within `<Modal />`"
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// src/modal-body.tsx
|
|
40
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
+
var ModalBody = (0, import_system.forwardRef)((props, ref) => {
|
|
42
|
+
const { as, children, className, ...otherProps } = props;
|
|
43
|
+
const { slots, classNames, bodyId, setBodyMounted } = useModalContext();
|
|
44
|
+
const domRef = (0, import_react_utils2.useDOMRef)(ref);
|
|
45
|
+
const Component = as || "div";
|
|
46
|
+
(0, import_react.useEffect)(() => {
|
|
47
|
+
setBodyMounted(true);
|
|
48
|
+
return () => setBodyMounted(false);
|
|
49
|
+
}, [setBodyMounted]);
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
|
+
Component,
|
|
52
|
+
{
|
|
53
|
+
ref: domRef,
|
|
54
|
+
className: slots.body({ class: (0, import_theme.cn)(classNames == null ? void 0 : classNames.body, className) }),
|
|
55
|
+
id: bodyId,
|
|
56
|
+
...otherProps,
|
|
57
|
+
children
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
ModalBody.displayName = "HeroUI.ModalBody";
|
|
62
|
+
var modal_body_default = ModalBody;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { AriaDialogProps } from '@react-aria/dialog';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { HTMLHeroUIProps } from '@sytechui/system';
|
|
5
|
+
|
|
6
|
+
type KeysToOmit = "children" | "role";
|
|
7
|
+
interface ModalContentProps extends AriaDialogProps, HTMLHeroUIProps<"div", KeysToOmit> {
|
|
8
|
+
children: ReactNode | ((onClose: () => void) => ReactNode);
|
|
9
|
+
}
|
|
10
|
+
declare const ModalContent: {
|
|
11
|
+
(props: ModalContentProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { type ModalContentProps, ModalContent as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { AriaDialogProps } from '@react-aria/dialog';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { HTMLHeroUIProps } from '@sytechui/system';
|
|
5
|
+
|
|
6
|
+
type KeysToOmit = "children" | "role";
|
|
7
|
+
interface ModalContentProps extends AriaDialogProps, HTMLHeroUIProps<"div", KeysToOmit> {
|
|
8
|
+
children: ReactNode | ((onClose: () => void) => ReactNode);
|
|
9
|
+
}
|
|
10
|
+
declare const ModalContent: {
|
|
11
|
+
(props: ModalContentProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { type ModalContentProps, ModalContent as default };
|