Files
NapCatQQ/.pnpm-store/v3/files/7b/96aba95dda1d0c86bb26b10bdfb290026655d30f8c9d1e110abe8e74855c2a29695d387fd064b2c208c571f26943909c883aa803eecfd04b1da835efe9b954
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

112 lines
3.5 KiB
Plaintext

"use client";
import {
scaleInOut
} from "./chunk-I7NTTF2N.mjs";
import {
useModalContext
} from "./chunk-UX6VCJJD.mjs";
// src/modal-content.tsx
import { cloneElement, isValidElement, useMemo, useCallback } from "react";
import { DismissButton } from "@react-aria/overlays";
import { TRANSITION_VARIANTS } from "@heroui/framer-utils";
import { CloseIcon } from "@heroui/shared-icons";
import { LazyMotion, m } from "framer-motion";
import { useDialog } from "@react-aria/dialog";
import { chain, mergeProps, useViewportSize } from "@react-aria/utils";
import { jsx, jsxs } from "react/jsx-runtime";
var domAnimation = () => import("@heroui/dom-animation").then((res) => res.default);
var ModalContent = (props) => {
const { as, children, role = "dialog", ...otherProps } = props;
const {
Component: DialogComponent,
domRef,
slots,
classNames,
motionProps,
backdrop,
closeButton,
hideCloseButton,
disableAnimation,
getDialogProps,
getBackdropProps,
getCloseButtonProps,
onClose
} = useModalContext();
const Component = as || DialogComponent || "div";
const viewport = useViewportSize();
const { dialogProps } = useDialog(
{
role
},
domRef
);
const closeButtonContent = isValidElement(closeButton) ? cloneElement(closeButton, getCloseButtonProps()) : /* @__PURE__ */ jsx("button", { ...getCloseButtonProps(), children: /* @__PURE__ */ jsx(CloseIcon, {}) });
const onKeyDown = useCallback((e) => {
if (e.key === "Tab" && e.nativeEvent.isComposing) {
e.stopPropagation();
e.preventDefault();
}
}, []);
const contentProps = getDialogProps(mergeProps(dialogProps, otherProps));
const content = /* @__PURE__ */ jsxs(Component, { ...contentProps, onKeyDown: chain(contentProps.onKeyDown, onKeyDown), children: [
/* @__PURE__ */ jsx(DismissButton, { onDismiss: onClose }),
!hideCloseButton && closeButtonContent,
typeof children === "function" ? children(onClose) : children,
/* @__PURE__ */ jsx(DismissButton, { onDismiss: onClose })
] });
const backdropContent = useMemo(() => {
if (backdrop === "transparent") {
return null;
}
if (disableAnimation) {
return /* @__PURE__ */ jsx("div", { ...getBackdropProps() });
}
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx(
m.div,
{
animate: "enter",
exit: "exit",
initial: "exit",
variants: TRANSITION_VARIANTS.fade,
...getBackdropProps()
}
) });
}, [backdrop, disableAnimation, getBackdropProps]);
const viewportStyle = {
"--visual-viewport-height": viewport.height + "px"
};
const contents = disableAnimation ? /* @__PURE__ */ jsx(
"div",
{
className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }),
"data-slot": "wrapper",
style: viewportStyle,
children: content
}
) : /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx(
m.div,
{
animate: "enter",
className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }),
"data-slot": "wrapper",
exit: "exit",
initial: "exit",
variants: scaleInOut,
...motionProps,
style: viewportStyle,
children: content
}
) });
return /* @__PURE__ */ jsxs("div", { tabIndex: -1, children: [
backdropContent,
contents
] });
};
ModalContent.displayName = "HeroUI.ModalContent";
var modal_content_default = ModalContent;
export {
modal_content_default
};