@yamada-ui/modal
Version:
Yamada UI modal component
128 lines (126 loc) • 3.1 kB
JavaScript
"use client"
import {
Modal
} from "./chunk-SA5RYCAR.mjs";
import {
DrawerContent
} from "./chunk-XYURL3FF.mjs";
import {
DrawerOverlay
} from "./chunk-ZMEZYJLF.mjs";
import {
DrawerProvider
} from "./chunk-64A25YOZ.mjs";
// src/drawer.tsx
import { omitThemeProps, useComponentMultiStyle } from "@yamada-ui/core";
import { motionForwardRef } from "@yamada-ui/motion";
import { findChildren, getValidChildren } from "@yamada-ui/utils";
import { jsx, jsxs } from "react/jsx-runtime";
var Drawer = motionForwardRef(
({
size,
closeOnDrag = false,
isFullHeight,
fullHeight = isFullHeight,
placement = "right",
...props
}, ref) => {
const [styles, mergedProps] = useComponentMultiStyle("Drawer", {
size,
closeOnDrag,
fullHeight,
placement,
...props
});
const {
allowPinchZoom,
autoFocus,
blockScrollOnMount,
children,
closeOnEsc,
closeOnOverlay,
dragConstraints = 0,
dragElastic = 0.1,
dragOffset = 80,
dragVelocity = 100,
duration = { enter: 0.4, exit: 0.3 },
finalFocusRef,
initialFocusRef,
isOpen,
lockFocusAcrossFrames,
open = isOpen,
restoreFocus,
withCloseButton = !closeOnDrag,
withDragBar = true,
withOverlay = true,
blankForDragProps,
containerProps,
portalProps,
onClose,
onCloseComplete,
onEsc,
onOverlayClick,
...rest
} = omitThemeProps(mergedProps, ["fullHeight"]);
const validChildren = getValidChildren(children);
const [customDrawerOverlay, ...cloneChildren] = findChildren(
validChildren,
DrawerOverlay
);
return /* @__PURE__ */ jsx(DrawerProvider, { value: styles, children: /* @__PURE__ */ jsxs(
Modal,
{
ref,
...{
allowPinchZoom,
autoFocus,
blockScrollOnMount,
closeOnEsc,
closeOnOverlay,
duration,
finalFocusRef,
initialFocusRef,
isOpen,
lockFocusAcrossFrames,
open,
restoreFocus,
withCloseButton: false,
withOverlay: false,
containerProps,
portalProps,
onClose,
onCloseComplete,
onEsc,
onOverlayClick
},
children: [
customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ jsx(DrawerOverlay, {}) : null,
/* @__PURE__ */ jsx(
DrawerContent,
{
...{
dragConstraints,
dragElastic,
dragOffset,
dragVelocity,
withCloseButton,
withDragBar,
blankForDragProps,
...rest,
closeOnDrag,
placement
},
children: cloneChildren
}
)
]
}
) });
}
);
Drawer.displayName = "Drawer";
Drawer.__ui__ = "Drawer";
export {
Drawer
};
//# sourceMappingURL=chunk-YIOFBA6M.mjs.map