@yamada-ui/modal
Version:
Yamada UI modal component
113 lines (109 loc) • 3.82 kB
JavaScript
"use client"
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/dialog-overlay.tsx
var dialog_overlay_exports = {};
__export(dialog_overlay_exports, {
DialogOverlay: () => DialogOverlay
});
module.exports = __toCommonJS(dialog_overlay_exports);
var import_motion2 = require("@yamada-ui/motion");
var import_utils3 = require("@yamada-ui/utils");
// src/modal-context.ts
var import_utils = require("@yamada-ui/utils");
var [ModalProvider, useModal] = (0, import_utils.createContext)({
name: `ModalContext`,
errorMessage: `useModal returned is 'undefined'. Seems you forgot to wrap the components in "<Modal />" `
});
var [DialogProvider, useDialog] = (0, import_utils.createContext)({
name: `DialogContext`,
errorMessage: `useDialog returned is 'undefined'. Seems you forgot to wrap the components in "<Dialog />" `
});
var [DrawerProvider, useDrawer] = (0, import_utils.createContext)({
name: `DrawerContext`,
errorMessage: `useDrawer returned is 'undefined'. Seems you forgot to wrap the components in "<Drawer />" `
});
// src/modal-overlay.tsx
var import_motion = require("@yamada-ui/motion");
var import_transitions = require("@yamada-ui/transitions");
var import_utils2 = require("@yamada-ui/utils");
var import_jsx_runtime = require("react/jsx-runtime");
var ModalOverlay = (0, import_motion.motionForwardRef)(
({ className, onClick, __css, ...rest }, ref) => {
const {
animation,
closeOnOverlay,
duration,
styles,
onClose,
onOverlayClick
} = useModal();
const css = {
h: "100dvh",
left: 0,
position: "fixed",
top: 0,
w: "100vw",
...__css ? __css : styles.overlay
};
const props = animation !== "none" ? import_transitions.fadeProps : {};
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_motion.motion.div,
{
ref,
className: (0, import_utils2.cx)("ui-modal__overlay", className),
"aria-hidden": true,
custom: { duration },
onClick: (0, import_utils2.handlerAll)(onClick, onOverlayClick, (ev) => {
ev.stopPropagation();
if (closeOnOverlay) onClose == null ? void 0 : onClose();
}),
__css: css,
...props,
...rest
}
);
}
);
ModalOverlay.displayName = "ModalOverlay";
ModalOverlay.__ui__ = "ModalOverlay";
// src/dialog-overlay.tsx
var import_jsx_runtime2 = require("react/jsx-runtime");
var DialogOverlay = (0, import_motion2.motionForwardRef)(
({ className, ...rest }, ref) => {
const styles = useDialog();
const css = { ...styles.overlay };
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
ModalOverlay,
{
ref,
className: (0, import_utils3.cx)("ui-dialog__overlay", className),
__css: css,
...rest
}
);
}
);
DialogOverlay.displayName = "DialogOverlay";
DialogOverlay.__ui__ = "DialogOverlay";
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DialogOverlay
});
//# sourceMappingURL=dialog-overlay.js.map