UNPKG

ayongui

Version:
126 lines (125 loc) 3.15 kB
import { j as n } from "../../../react/jsx-runtime.mjs"; import s, { useState as A, useEffect as C, isValidElement as P } from "react"; import "../icon/index.module.less.mjs"; import z from "../icon/components/wrongs-frame/index.mjs"; import "../icon/components/loading-frame/loading.module.less.mjs"; import R from "../icon/components/tick-solid/index.mjs"; import b from "../icon/components/wrong-solid/index.mjs"; import L from "../icon/components/lament-solid/index.mjs"; import M from "../icon/components/illustrate-solid/index.mjs"; import e from "./index.module.less.mjs"; import a from "../mount-dom/index.mjs"; const T = { info: s.createElement(M, { className: `${e.iconSize} ${e.info}` }), success: s.createElement(R, { className: `${e.iconSize} ${e.success}` }), warning: s.createElement(L, { className: `${e.iconSize} ${e.warning}` }), error: s.createElement(b, { className: `${e.iconSize} ${e.error}` }) }, c = ({ open: t, messages: o, title: x, zIndex: d, closeIcon: p, className: g, style: y, type: $, placement: h = "topRight", duration: j = 1600, btn: r = null, onClose: Y = () => { }, onAyongClose: E = () => { } }) => { const [N, u] = A(!1), S = { zIndex: d, ...y }; C(() => { typeof r == "function" && P(r()) || setTimeout(() => { i(); }, j); }, []); const i = () => { u(!1); }, k = (m) => { Array.from(m.target.classList).includes(e.openMain) || E(); }, w = (m) => { u(!0); }; return /* @__PURE__ */ n.jsxs( "div", { onAnimationEnd: w, onTransitionEnd: k, style: S, onClick: (m) => m.stopPropagation(), className: ` ${t ? e.makeTram : ""} ${e.main} ${e[h]} ${N ? e.openMain : ""}`, children: [ /* @__PURE__ */ n.jsxs("header", { children: [ p ? s.createElement(p.type, { onClick: i, className: e.iconSize }) : T[$], /* @__PURE__ */ n.jsx("h3", { onClick: i, children: x }), /* @__PURE__ */ n.jsx(z, { onClick: i }) ] }), /* @__PURE__ */ n.jsx("main", { className: g, children: o }), typeof r == "function" ? r(i) : "" ] } ); }, l = { open: !0, baseHieght: 100, style: { width: "20%" } }, f = { topRight: "top", topLeft: "top", bottomRight: "bottom", bottomLeft: "bottom", bottom: "bottom", undefined: "top" }, J = { info: (t) => { a({ element: (o) => /* @__PURE__ */ n.jsx(c, { ...o }), ...l, ...t, YAxisPlacement: f[t.placement], type: "info" }); }, success: (t) => { a({ element: (o) => /* @__PURE__ */ n.jsx(c, { ...o }), ...l, ...t, type: "success", YAxisPlacement: f[t.placement] }); }, warning: (t) => { a({ element: (o) => /* @__PURE__ */ n.jsx(c, { ...o }), ...l, ...t, type: "warning", YAxisPlacement: f[t.placement] }); }, error: (t) => { a({ element: (o) => /* @__PURE__ */ n.jsx(c, { ...o }), ...l, ...t, type: "error", YAxisPlacement: f[t.placement] }); } }; export { J as default };