UNPKG

ayongui

Version:
93 lines (92 loc) 2.67 kB
import { j as e } from "../../../react/jsx-runtime.mjs"; import f, { useState as g, useEffect as W } from "react"; import r from "./index.module.less.mjs"; import "../icon/index.module.less.mjs"; import v from "../icon/components/wrongs-frame/index.mjs"; import "../icon/components/loading-frame/loading.module.less.mjs"; import A from "react-dom"; const M = { top: (t) => ({ width: "100%", height: t }), bottom: (t) => ({ width: "100%", height: t }), right: (t) => ({ width: t, height: "100%" }), left: (t) => ({ width: t, height: "100%" }) }, x = ({ children: t, title: i, closeIcon: o, zIndex: s = 999, getContainer: n = !0, headerClassName: C = "", bodyClassName: j = "", makeClassName: k = "", open: a = !1, placement: m = "bottom", size: w = "380px", maskClosable: p = !0, onClose: b = () => { }, mainRender: h = null, headerRender: d = null } = {}) => { const [$, u] = g(a), [E, y] = g(a); let N = p; const D = { ...s ? { zIndex: s } : {}, ...n ? {} : { position: "absolute" } }, l = () => { b(); }; W(() => { a && u(!0), a || setTimeout(() => { y(!1); }, 500); }, [a]); const _ = (c) => { u(a); }, T = (c) => { y(!0); }; return /* @__PURE__ */ e.jsx( "div", { onClick: () => { N && l(); }, onAnimationEnd: T, style: D, className: `${$ ? r.makeTram : r.warpclose} ${r.make} ${k} `, children: /* @__PURE__ */ e.jsx( "div", { onTransitionEnd: _, style: M[m](w), onClick: (c) => c.stopPropagation(), className: `${r.main} ${E ? `${r.openmian} ${r[m]}` : r[m]}`, children: typeof h == "function" ? h() : /* @__PURE__ */ e.jsxs(f.Fragment, { children: [ typeof d == "function" ? d(l) : /* @__PURE__ */ e.jsxs("header", { className: C, children: [ o ? f.createElement(o.type, { onClick: l }) : /* @__PURE__ */ e.jsx(v, { onClick: l }), /* @__PURE__ */ e.jsx("h3", { children: i }) ] }), /* @__PURE__ */ e.jsx("main", { className: j, children: t }) ] }) } ) } ); }, O = (t) => { let i = t.maskClosable, o = t.getContainer; return f.Children.toArray(t.children).some((s) => { var n; ((n = s == null ? void 0 : s.type) == null ? void 0 : n.displayName) === "Drawer" && (i = !1, o = !1); }), o ? A.createPortal(/* @__PURE__ */ e.jsx( x, { ...t, children: t.children } ), document.body) : /* @__PURE__ */ e.jsx(x, { ...t, maskClosable: i, children: t.children }); }; O.displayName = "Drawer"; export { O as default };