UNPKG

ayongui

Version:
166 lines (165 loc) 4.38 kB
import { j as s } from "../../../react/jsx-runtime.mjs"; import o, { useState as y, useEffect as g } from "react"; import C from "../button/index.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 X from "../icon/components/tick-solid/index.mjs"; import Y from "../icon/components/wrong-solid/index.mjs"; import Z from "../icon/components/lament-solid/index.mjs"; import A from "../icon/components/illustrate-solid/index.mjs"; import c from "../mount-dom/index.mjs"; import t from "./index.module.less.mjs"; let d = 0; const L = { info: o.createElement(A, { className: `${t.iconSize} ${t.info}` }), success: o.createElement(X, { className: `${t.iconSize} ${t.success}` }), warning: o.createElement(Z, { className: `${t.iconSize} ${t.warning}` }), error: o.createElement(Y, { className: `${t.iconSize} ${t.error}` }) }, i = ({ children: e, title: n, closeIcon: x, confirmLoading: r = !1, zIndex: S = 999, style: T = { width: "50%" }, headerClassName: b = "", bodyClassName: D = "", makeClassName: z = "", open: l = !1, placement: $ = "center", maskClosable: M = !0, type: W = "", content: _ = "", okText: v = "", cancelText: O = "", onClose: B = () => { }, onOk: F = () => { }, onCancel: I = () => { }, onAyongClose: f = () => { }, footerRender: j = null, mainRender: h = null, headerRender: k = null }) => { const [P, w] = y(l), [q, E] = y(l), [G, N] = y(r); let H = M; const J = { zIndex: S, ...T }, a = () => { B(), f(); }; g(() => { l && w(!0), l || (clearTimeout(d), d = setTimeout(() => { E(!1); }, 500)); }, [l]), g(() => { r ? N(!0) : d = setTimeout(() => { N(!1); }, 500); }, [r]); const K = (p) => { w(l); }, Q = (p) => { E(!0); }, R = () => { F(), f(); }, U = () => { I(), f(); }; return /* @__PURE__ */ s.jsx( "div", { onClick: () => { H && a(); }, onAnimationEnd: Q, className: `${P ? t.makeTram : t.warpclose} ${t.make} ${z} `, children: /* @__PURE__ */ s.jsx( "div", { onTransitionEnd: K, style: J, onClick: (p) => p.stopPropagation(), className: `${t.main} ${q ? `${t.openmian} ${t[$]}` : t[$]}`, children: typeof h == "function" ? h() : /* @__PURE__ */ s.jsxs(o.Fragment, { children: [ typeof k == "function" ? k(a) : /* @__PURE__ */ s.jsxs("header", { className: `${t.header} ${b}`, children: [ x ? o.createElement(x.type, { onClick: a }) : L[W] || /* @__PURE__ */ s.jsx(V, { onClick: a }), /* @__PURE__ */ s.jsx("h3", { children: n }) ] }), /* @__PURE__ */ s.jsx("main", { className: `${t.mainbody} ${D}`, children: _ || e }), typeof j == "function" ? j() : /* @__PURE__ */ s.jsxs("footer", { children: [ /* @__PURE__ */ s.jsx(C, { style: { marginRight: "15px" }, onClick: U, children: O || "取消" }), /* @__PURE__ */ s.jsx( C, { type: "primary", disabled: G || r, loading: r, onClick: R, children: v || "确定" } ) ] }) ] }) } ) } ); }, m = (e) => /* @__PURE__ */ s.jsx(i, { ...e }), u = { top: "100px", center: "30%" }; m.info = (e) => { c({ element: (n) => /* @__PURE__ */ s.jsx(i, { ...n }), open: !0, ...e, style: { top: u[e.placement], ...e.style }, type: "info" }); }; m.success = (e) => { c({ element: (n) => /* @__PURE__ */ s.jsx(i, { ...n }), ...e, open: !0, style: { width: "30%", top: u[e.placement], ...e.style }, type: "success" }); }; m.warning = (e) => { c({ element: (n) => /* @__PURE__ */ s.jsx(i, { ...n }), ...e, open: !0, style: { width: "30%", top: u[e.placement], ...e.style }, type: "warning" }); }; m.error = (e) => { c({ element: (n) => /* @__PURE__ */ s.jsx(i, { ...n }), ...e, open: !0, style: { width: "30%", top: u[e.placement], ...e.style }, type: "error" }); }; export { m as default };