UNPKG

@yamada-ui/modal

Version:

Yamada UI modal component

102 lines (100 loc) 2.79 kB
"use client" import { DialogCloseButton } from "./chunk-3RGLB7UM.mjs"; import { ModalCloseButton } from "./chunk-PXV3LL5A.mjs"; import { useModal } from "./chunk-64A25YOZ.mjs"; // src/modal-content.tsx import { motion, motionForwardRef } from "@yamada-ui/motion"; import { scaleFadeProps, slideFadeProps } from "@yamada-ui/transitions"; import { cx, findChildren, getValidChildren } from "@yamada-ui/utils"; import { jsx, jsxs } from "react/jsx-runtime"; var getModalContentProps = (animation = "scale", duration) => { switch (animation) { case "scale": return { ...scaleFadeProps, custom: { duration, reverse: true, scale: 0.95 } }; case "top": return { ...slideFadeProps, custom: { duration, offsetY: -16, reverse: true } }; case "right": return { ...slideFadeProps, custom: { duration, offsetX: 16, reverse: true } }; case "left": return { ...slideFadeProps, custom: { duration, offsetX: -16, reverse: true } }; case "bottom": return { ...slideFadeProps, custom: { duration, offsetY: 16, reverse: true } }; } }; var ModalContent = motionForwardRef( ({ className, children, __css, ...rest }, ref) => { var _a, _b; const { animation, bodyRef, duration, headerRef, scrollBehavior, styles, withCloseButton, onClose } = useModal(); const validChildren = getValidChildren(children); const [customModalCloseButton, ...cloneChildren] = findChildren( validChildren, ModalCloseButton, DialogCloseButton ); const props = animation !== "none" ? getModalContentProps(animation, duration) : {}; const css = { display: "flex", flexDirection: "column", maxH: "100%", outline: 0, overflow: scrollBehavior === "inside" ? "hidden" : "auto", position: "relative", ...__css ? __css : styles.container }; return /* @__PURE__ */ jsxs( motion.section, { ref, className: cx("ui-modal", className), "aria-describedby": (_a = bodyRef.current) == null ? void 0 : _a.id, "aria-labelledby": (_b = headerRef.current) == null ? void 0 : _b.id, "aria-modal": "true", role: "dialog", tabIndex: -1, __css: css, ...props, ...rest, children: [ customModalCloseButton != null ? customModalCloseButton : withCloseButton && onClose ? /* @__PURE__ */ jsx(ModalCloseButton, {}) : null, cloneChildren ] } ); } ); ModalContent.displayName = "ModalContent"; ModalContent.__ui__ = "ModalContent"; export { ModalContent }; //# sourceMappingURL=chunk-FXMVCPK5.mjs.map