@baihuiru/cheetah-webcomponents
Version:
Cheetah Web Components library - React components as Web Components
965 lines (964 loc) • 32.7 kB
JavaScript
var Ee = (e, t, o) => new Promise((n, a) => {
var s = (c) => {
try {
f(o.next(c));
} catch (i) {
a(i);
}
}, d = (c) => {
try {
f(o.throw(c));
} catch (i) {
a(i);
}
}, f = (c) => c.done ? n(c.value) : Promise.resolve(c.value).then(s, d);
f((o = o.apply(e, t)).next());
});
import { r, A as Y, _ as D, a as q, b as _, c as Ie, d as z, e as pe, K as Ve, R as M, C as We, f as Fe, g as X, h as Ue, u as qe, i as Xe, m as Ye, j as Se, k as Je, l as Ze, n as Ce, o as Le, L as Qe, p as et, q as tt, s as nt, t as ot, v as be, B as at, w as rt } from "./button-868752f1.mjs";
var st = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z" } }] }, name: "check-circle", theme: "filled" };
const ct = st;
var lt = function(t, o) {
return /* @__PURE__ */ r.createElement(Y, D({}, t, {
ref: o,
icon: ct
}));
}, it = /* @__PURE__ */ r.forwardRef(lt);
const ut = it;
var dt = { icon: { tag: "svg", attrs: { "fill-rule": "evenodd", viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z" } }] }, name: "close-circle", theme: "filled" };
const ft = dt;
var mt = function(t, o) {
return /* @__PURE__ */ r.createElement(Y, D({}, t, {
ref: o,
icon: ft
}));
}, vt = /* @__PURE__ */ r.forwardRef(mt);
const gt = vt;
var pt = { icon: { tag: "svg", attrs: { "fill-rule": "evenodd", viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M799.86 166.31c.02 0 .04.02.08.06l57.69 57.7c.04.03.05.05.06.08a.12.12 0 010 .06c0 .03-.02.05-.06.09L569.93 512l287.7 287.7c.04.04.05.06.06.09a.12.12 0 010 .07c0 .02-.02.04-.06.08l-57.7 57.69c-.03.04-.05.05-.07.06a.12.12 0 01-.07 0c-.03 0-.05-.02-.09-.06L512 569.93l-287.7 287.7c-.04.04-.06.05-.09.06a.12.12 0 01-.07 0c-.02 0-.04-.02-.08-.06l-57.69-57.7c-.04-.03-.05-.05-.06-.07a.12.12 0 010-.07c0-.03.02-.05.06-.09L454.07 512l-287.7-287.7c-.04-.04-.05-.06-.06-.09a.12.12 0 010-.07c0-.02.02-.04.06-.08l57.7-57.69c.03-.04.05-.05.07-.06a.12.12 0 01.07 0c.03 0 .05.02.09.06L512 454.07l287.7-287.7c.04-.04.06-.05.09-.06a.12.12 0 01.07 0z" } }] }, name: "close", theme: "outlined" };
const Ct = pt;
var yt = function(t, o) {
return /* @__PURE__ */ r.createElement(Y, D({}, t, {
ref: o,
icon: Ct
}));
}, ht = /* @__PURE__ */ r.forwardRef(yt);
const xt = ht;
var Et = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z" } }] }, name: "copy", theme: "outlined" };
const St = Et;
var bt = function(t, o) {
return /* @__PURE__ */ r.createElement(Y, D({}, t, {
ref: o,
icon: St
}));
}, Nt = /* @__PURE__ */ r.forwardRef(bt);
const Ot = Nt;
var Pt = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z" } }] }, name: "exclamation-circle", theme: "filled" };
const wt = Pt;
var kt = function(t, o) {
return /* @__PURE__ */ r.createElement(Y, D({}, t, {
ref: o,
icon: wt
}));
}, Rt = /* @__PURE__ */ r.forwardRef(kt);
const $t = Rt;
var Mt = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 010-96 48.01 48.01 0 010 96z" } }] }, name: "info-circle", theme: "filled" };
const It = Mt;
var Ft = function(t, o) {
return /* @__PURE__ */ r.createElement(Y, D({}, t, {
ref: o,
icon: It
}));
}, Lt = /* @__PURE__ */ r.forwardRef(Ft);
const jt = Lt;
var At = `accept acceptCharset accessKey action allowFullScreen allowTransparency
alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge
charSet checked classID className colSpan cols content contentEditable contextMenu
controls coords crossOrigin data dateTime default defer dir disabled download draggable
encType form formAction formEncType formMethod formNoValidate formTarget frameBorder
headers height hidden high href hrefLang htmlFor httpEquiv icon id inputMode integrity
is keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media
mediaGroup method min minLength multiple muted name noValidate nonce open
optimum pattern placeholder poster preload radioGroup readOnly rel required
reversed role rowSpan rows sandbox scope scoped scrolling seamless selected
shape size sizes span spellCheck src srcDoc srcLang srcSet start step style
summary tabIndex target title type useMap value width wmode wrap`, Tt = `onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown
onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick
onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown
onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel
onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough
onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata
onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`, _t = "".concat(At, " ").concat(Tt).split(/[\s\n]+/), Dt = "aria-", Ht = "data-";
function Ne(e, t) {
return e.indexOf(t) === 0;
}
function zt(e) {
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, o;
t === !1 ? o = {
aria: !0,
data: !0,
attr: !0
} : t === !0 ? o = {
aria: !0
} : o = q({}, t);
var n = {};
return Object.keys(e).forEach(function(a) {
// Aria
(o.aria && (a === "role" || Ne(a, Dt)) || // Data
o.data && Ne(a, Ht) || // Attr
o.attr && _t.includes(a)) && (n[a] = e[a]);
}), n;
}
var je = /* @__PURE__ */ r.forwardRef(function(e, t) {
var o = e.prefixCls, n = e.style, a = e.className, s = e.duration, d = s === void 0 ? 4.5 : s, f = e.showProgress, c = e.pauseOnHover, i = c === void 0 ? !0 : c, x = e.eventKey, m = e.content, p = e.closable, C = e.closeIcon, b = C === void 0 ? "x" : C, v = e.props, y = e.onClick, I = e.onNoticeClose, k = e.times, O = e.hovering, P = r.useState(!1), N = _(P, 2), E = N[0], B = N[1], g = r.useState(0), l = _(g, 2), u = l[0], h = l[1], F = r.useState(0), j = _(F, 2), $ = j[0], J = j[1], w = O || E, A = d > 0 && f, G = function() {
I(x);
}, Z = function(S) {
(S.key === "Enter" || S.code === "Enter" || S.keyCode === Ve.ENTER) && G();
};
r.useEffect(function() {
if (!w && d > 0) {
var T = Date.now() - $, S = setTimeout(function() {
G();
}, d * 1e3 - $);
return function() {
i && clearTimeout(S), J(Date.now() - T);
};
}
}, [d, w, k]), r.useEffect(function() {
if (!w && A && (i || $ === 0)) {
var T = performance.now(), S, R = function le() {
cancelAnimationFrame(S), S = requestAnimationFrame(function(ie) {
var U = ie + $ - T, K = Math.min(U / (d * 1e3), 1);
h(K * 100), K < 1 && le();
});
};
return R(), function() {
i && cancelAnimationFrame(S);
};
}
}, [d, $, w, A, k]);
var oe = r.useMemo(function() {
return Ie(p) === "object" && p !== null ? p : p ? {
closeIcon: b
} : {};
}, [p, b]), ce = zt(oe, !0), Q = 100 - (!u || u < 0 ? 0 : u > 100 ? 100 : u), H = "".concat(o, "-notice");
return /* @__PURE__ */ r.createElement("div", D({}, v, {
ref: t,
className: z(H, a, pe({}, "".concat(H, "-closable"), p)),
style: n,
onMouseEnter: function(S) {
var R;
B(!0), v == null || (R = v.onMouseEnter) === null || R === void 0 || R.call(v, S);
},
onMouseLeave: function(S) {
var R;
B(!1), v == null || (R = v.onMouseLeave) === null || R === void 0 || R.call(v, S);
},
onClick: y
}), /* @__PURE__ */ r.createElement("div", {
className: "".concat(H, "-content")
}, m), p && /* @__PURE__ */ r.createElement("a", D({
tabIndex: 0,
className: "".concat(H, "-close"),
onKeyDown: Z,
"aria-label": "Close"
}, ce, {
onClick: function(S) {
S.preventDefault(), S.stopPropagation(), G();
}
}), oe.closeIcon), A && /* @__PURE__ */ r.createElement("progress", {
className: "".concat(H, "-progress"),
max: "100",
value: Q
}, Q + "%"));
}), Ae = /* @__PURE__ */ M.createContext({}), Bt = function(t) {
var o = t.children, n = t.classNames;
return /* @__PURE__ */ M.createElement(Ae.Provider, {
value: {
classNames: n
}
}, o);
}, Oe = 8, Pe = 3, we = 16, Gt = function(t) {
var o = {
offset: Oe,
threshold: Pe,
gap: we
};
if (t && Ie(t) === "object") {
var n, a, s;
o.offset = (n = t.offset) !== null && n !== void 0 ? n : Oe, o.threshold = (a = t.threshold) !== null && a !== void 0 ? a : Pe, o.gap = (s = t.gap) !== null && s !== void 0 ? s : we;
}
return [!!t, o];
}, Kt = ["className", "style", "classNames", "styles"], Vt = function(t) {
var o = t.configList, n = t.placement, a = t.prefixCls, s = t.className, d = t.style, f = t.motion, c = t.onAllNoticeRemoved, i = t.onNoticeClose, x = t.stack, m = r.useContext(Ae), p = m.classNames, C = r.useRef({}), b = r.useState(null), v = _(b, 2), y = v[0], I = v[1], k = r.useState([]), O = _(k, 2), P = O[0], N = O[1], E = o.map(function(w) {
return {
config: w,
key: String(w.key)
};
}), B = Gt(x), g = _(B, 2), l = g[0], u = g[1], h = u.offset, F = u.threshold, j = u.gap, $ = l && (P.length > 0 || E.length <= F), J = typeof f == "function" ? f(n) : f;
return r.useEffect(function() {
l && P.length > 1 && N(function(w) {
return w.filter(function(A) {
return E.some(function(G) {
var Z = G.key;
return A === Z;
});
});
});
}, [P, E, l]), r.useEffect(function() {
var w;
if (l && C.current[(w = E[E.length - 1]) === null || w === void 0 ? void 0 : w.key]) {
var A;
I(C.current[(A = E[E.length - 1]) === null || A === void 0 ? void 0 : A.key]);
}
}, [E, l]), /* @__PURE__ */ M.createElement(We, D({
key: n,
className: z(a, "".concat(a, "-").concat(n), p == null ? void 0 : p.list, s, pe(pe({}, "".concat(a, "-stack"), !!l), "".concat(a, "-stack-expanded"), $)),
style: d,
keys: E,
motionAppear: !0
}, J, {
onAllRemoved: function() {
c(n);
}
}), function(w, A) {
var G = w.config, Z = w.className, oe = w.style, ce = w.index, Q = G, H = Q.key, T = Q.times, S = String(H), R = G, le = R.className, ie = R.style, U = R.classNames, K = R.styles, ze = Fe(R, Kt), ue = E.findIndex(function(re) {
return re.key === S;
}), ae = {};
if (l) {
var ee = E.length - 1 - (ue > -1 ? ue : ce - 1), he = n === "top" || n === "bottom" ? "-50%" : "0";
if (ee > 0) {
var de, fe, me;
ae.height = $ ? (de = C.current[S]) === null || de === void 0 ? void 0 : de.offsetHeight : y == null ? void 0 : y.offsetHeight;
for (var xe = 0, ve = 0; ve < ee; ve++) {
var ge;
xe += ((ge = C.current[E[E.length - 1 - ve].key]) === null || ge === void 0 ? void 0 : ge.offsetHeight) + j;
}
var Be = ($ ? xe : ee * h) * (n.startsWith("top") ? 1 : -1), Ge = !$ && y !== null && y !== void 0 && y.offsetWidth && (fe = C.current[S]) !== null && fe !== void 0 && fe.offsetWidth ? ((y == null ? void 0 : y.offsetWidth) - h * 2 * (ee < 3 ? ee : 3)) / ((me = C.current[S]) === null || me === void 0 ? void 0 : me.offsetWidth) : 1;
ae.transform = "translate3d(".concat(he, ", ").concat(Be, "px, 0) scaleX(").concat(Ge, ")");
} else
ae.transform = "translate3d(".concat(he, ", 0, 0)");
}
return /* @__PURE__ */ M.createElement("div", {
ref: A,
className: z("".concat(a, "-notice-wrapper"), Z, U == null ? void 0 : U.wrapper),
style: q(q(q({}, oe), ae), K == null ? void 0 : K.wrapper),
onMouseEnter: function() {
return N(function(V) {
return V.includes(S) ? V : [].concat(X(V), [S]);
});
},
onMouseLeave: function() {
return N(function(V) {
return V.filter(function(Ke) {
return Ke !== S;
});
});
}
}, /* @__PURE__ */ M.createElement(je, D({}, ze, {
ref: function(V) {
ue > -1 ? C.current[S] = V : delete C.current[S];
},
prefixCls: a,
classNames: U,
styles: K,
className: z(le, p == null ? void 0 : p.notice),
style: ie,
times: T,
key: H,
eventKey: H,
onNoticeClose: i,
hovering: l && P.length > 0
})));
});
}, Wt = /* @__PURE__ */ r.forwardRef(function(e, t) {
var o = e.prefixCls, n = o === void 0 ? "rc-notification" : o, a = e.container, s = e.motion, d = e.maxCount, f = e.className, c = e.style, i = e.onAllRemoved, x = e.stack, m = e.renderNotifications, p = r.useState([]), C = _(p, 2), b = C[0], v = C[1], y = function(l) {
var u, h = b.find(function(F) {
return F.key === l;
});
h == null || (u = h.onClose) === null || u === void 0 || u.call(h), v(function(F) {
return F.filter(function(j) {
return j.key !== l;
});
});
};
r.useImperativeHandle(t, function() {
return {
open: function(l) {
v(function(u) {
var h = X(u), F = h.findIndex(function(J) {
return J.key === l.key;
}), j = q({}, l);
if (F >= 0) {
var $;
j.times = ((($ = u[F]) === null || $ === void 0 ? void 0 : $.times) || 0) + 1, h[F] = j;
} else
j.times = 0, h.push(j);
return d > 0 && h.length > d && (h = h.slice(-d)), h;
});
},
close: function(l) {
y(l);
},
destroy: function() {
v([]);
}
};
});
var I = r.useState({}), k = _(I, 2), O = k[0], P = k[1];
r.useEffect(function() {
var g = {};
b.forEach(function(l) {
var u = l.placement, h = u === void 0 ? "topRight" : u;
h && (g[h] = g[h] || [], g[h].push(l));
}), Object.keys(O).forEach(function(l) {
g[l] = g[l] || [];
}), P(g);
}, [b]);
var N = function(l) {
P(function(u) {
var h = q({}, u), F = h[l] || [];
return F.length || delete h[l], h;
});
}, E = r.useRef(!1);
if (r.useEffect(function() {
Object.keys(O).length > 0 ? E.current = !0 : E.current && (i == null || i(), E.current = !1);
}, [O]), !a)
return null;
var B = Object.keys(O);
return /* @__PURE__ */ Ue.createPortal(/* @__PURE__ */ r.createElement(r.Fragment, null, B.map(function(g) {
var l = O[g], u = /* @__PURE__ */ r.createElement(Vt, {
key: g,
configList: l,
placement: g,
prefixCls: n,
className: f == null ? void 0 : f(g),
style: c == null ? void 0 : c(g),
motion: s,
onNoticeClose: y,
onAllNoticeRemoved: N,
stack: x
});
return m ? m(u, {
prefixCls: n,
key: g
}) : u;
})), a);
}), Ut = ["getContainer", "motion", "prefixCls", "maxCount", "className", "style", "onAllRemoved", "stack", "renderNotifications"], qt = function() {
return document.body;
}, ke = 0;
function Xt() {
for (var e = {}, t = arguments.length, o = new Array(t), n = 0; n < t; n++)
o[n] = arguments[n];
return o.forEach(function(a) {
a && Object.keys(a).forEach(function(s) {
var d = a[s];
d !== void 0 && (e[s] = d);
});
}), e;
}
function Yt() {
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = e.getContainer, o = t === void 0 ? qt : t, n = e.motion, a = e.prefixCls, s = e.maxCount, d = e.className, f = e.style, c = e.onAllRemoved, i = e.stack, x = e.renderNotifications, m = Fe(e, Ut), p = r.useState(), C = _(p, 2), b = C[0], v = C[1], y = r.useRef(), I = /* @__PURE__ */ r.createElement(Wt, {
container: b,
ref: y,
prefixCls: a,
motion: n,
maxCount: s,
className: d,
style: f,
onAllRemoved: c,
stack: i,
renderNotifications: x
}), k = r.useState([]), O = _(k, 2), P = O[0], N = O[1], E = qe(function(g) {
var l = Xt(m, g);
(l.key === null || l.key === void 0) && (l.key = "rc-notification-".concat(ke), ke += 1), N(function(u) {
return [].concat(X(u), [{
type: "open",
config: l
}]);
});
}), B = r.useMemo(function() {
return {
open: E,
close: function(l) {
N(function(u) {
return [].concat(X(u), [{
type: "close",
key: l
}]);
});
},
destroy: function() {
N(function(l) {
return [].concat(X(l), [{
type: "destroy"
}]);
});
}
};
}, []);
return r.useEffect(function() {
v(o());
}), r.useEffect(function() {
if (y.current && P.length) {
P.forEach(function(u) {
switch (u.type) {
case "open":
y.current.open(u.config);
break;
case "close":
y.current.close(u.key);
break;
case "destroy":
y.current.destroy();
break;
}
});
var g, l;
N(function(u) {
return (g !== u || !l) && (g = u, l = u.filter(function(h) {
return !P.includes(h);
})), l;
});
}
}, [P]), [B, I];
}
const Jt = (e) => {
const {
componentCls: t,
iconCls: o,
boxShadow: n,
colorText: a,
colorSuccess: s,
colorError: d,
colorWarning: f,
colorInfo: c,
fontSizeLG: i,
motionEaseInOutCirc: x,
motionDurationSlow: m,
marginXS: p,
paddingXS: C,
borderRadiusLG: b,
zIndexPopup: v,
// Custom token
contentPadding: y,
contentBg: I
} = e, k = `${t}-notice`, O = new Se("MessageMoveIn", {
"0%": {
padding: 0,
transform: "translateY(-100%)",
opacity: 0
},
"100%": {
padding: C,
transform: "translateY(0)",
opacity: 1
}
}), P = new Se("MessageMoveOut", {
"0%": {
maxHeight: e.height,
padding: C,
opacity: 1
},
"100%": {
maxHeight: 0,
padding: 0,
opacity: 0
}
}), N = {
padding: C,
textAlign: "center",
[`${t}-custom-content`]: {
display: "flex",
alignItems: "center"
},
[`${t}-custom-content > ${o}`]: {
marginInlineEnd: p,
// affected by ltr or rtl
fontSize: i
},
[`${k}-content`]: {
display: "inline-block",
padding: y,
background: I,
borderRadius: b,
boxShadow: n,
pointerEvents: "all"
},
[`${t}-success > ${o}`]: {
color: s
},
[`${t}-error > ${o}`]: {
color: d
},
[`${t}-warning > ${o}`]: {
color: f
},
[`${t}-info > ${o},
${t}-loading > ${o}`]: {
color: c
}
};
return [
// ============================ Holder ============================
{
[t]: Object.assign(Object.assign({}, Je(e)), {
color: a,
position: "fixed",
top: p,
width: "100%",
pointerEvents: "none",
zIndex: v,
[`${t}-move-up`]: {
animationFillMode: "forwards"
},
[`
${t}-move-up-appear,
${t}-move-up-enter
`]: {
animationName: O,
animationDuration: m,
animationPlayState: "paused",
animationTimingFunction: x
},
[`
${t}-move-up-appear${t}-move-up-appear-active,
${t}-move-up-enter${t}-move-up-enter-active
`]: {
animationPlayState: "running"
},
[`${t}-move-up-leave`]: {
animationName: P,
animationDuration: m,
animationPlayState: "paused",
animationTimingFunction: x
},
[`${t}-move-up-leave${t}-move-up-leave-active`]: {
animationPlayState: "running"
},
"&-rtl": {
direction: "rtl",
span: {
direction: "rtl"
}
}
})
},
// ============================ Notice ============================
{
[t]: {
[`${k}-wrapper`]: Object.assign({}, N)
}
},
// ============================= Pure =============================
{
[`${t}-notice-pure-panel`]: Object.assign(Object.assign({}, N), {
padding: 0,
textAlign: "start"
})
}
];
}, Zt = (e) => ({
zIndexPopup: e.zIndexPopupBase + Ze + 10,
contentBg: e.colorBgElevated,
contentPadding: `${(e.controlHeightLG - e.fontSize * e.lineHeight) / 2}px ${e.paddingSM}px`
}), Te = Xe("Message", (e) => {
const t = Ye(e, {
height: 150
});
return [Jt(t)];
}, Zt);
var Qt = globalThis && globalThis.__rest || function(e, t) {
var o = {};
for (var n in e)
Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (o[n] = e[n]);
if (e != null && typeof Object.getOwnPropertySymbols == "function")
for (var a = 0, n = Object.getOwnPropertySymbols(e); a < n.length; a++)
t.indexOf(n[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[a]) && (o[n[a]] = e[n[a]]);
return o;
};
const en = {
info: /* @__PURE__ */ r.createElement(jt, null),
success: /* @__PURE__ */ r.createElement(ut, null),
error: /* @__PURE__ */ r.createElement(gt, null),
warning: /* @__PURE__ */ r.createElement($t, null),
loading: /* @__PURE__ */ r.createElement(Qe, null)
}, _e = ({
prefixCls: e,
type: t,
icon: o,
children: n
}) => /* @__PURE__ */ r.createElement("div", {
className: z(`${e}-custom-content`, `${e}-${t}`)
}, o || en[t], /* @__PURE__ */ r.createElement("span", null, n)), tn = (e) => {
const {
prefixCls: t,
className: o,
type: n,
icon: a,
content: s
} = e, d = Qt(e, ["prefixCls", "className", "type", "icon", "content"]), {
getPrefixCls: f
} = r.useContext(Ce), c = t || f("message"), i = Le(c), [x, m, p] = Te(c, i);
return x(/* @__PURE__ */ r.createElement(je, Object.assign({}, d, {
prefixCls: c,
className: z(o, m, `${c}-notice-pure-panel`, p, i),
eventKey: "pure",
duration: null,
content: /* @__PURE__ */ r.createElement(_e, {
prefixCls: c,
type: n,
icon: a
}, s)
})));
}, nn = tn;
function on(e, t) {
return {
motionName: t != null ? t : `${e}-move-up`
};
}
function ye(e) {
let t;
const o = new Promise((a) => {
t = e(() => {
a(!0);
});
}), n = () => {
t == null || t();
};
return n.then = (a, s) => o.then(a, s), n.promise = o, n;
}
var an = globalThis && globalThis.__rest || function(e, t) {
var o = {};
for (var n in e)
Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (o[n] = e[n]);
if (e != null && typeof Object.getOwnPropertySymbols == "function")
for (var a = 0, n = Object.getOwnPropertySymbols(e); a < n.length; a++)
t.indexOf(n[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[a]) && (o[n[a]] = e[n[a]]);
return o;
};
const rn = 8, sn = 3, cn = ({
children: e,
prefixCls: t
}) => {
const o = Le(t), [n, a, s] = Te(t, o);
return n(/* @__PURE__ */ r.createElement(Bt, {
classNames: {
list: z(a, s, o)
}
}, e));
}, ln = (e, {
prefixCls: t,
key: o
}) => /* @__PURE__ */ r.createElement(cn, {
prefixCls: t,
key: o
}, e), un = /* @__PURE__ */ r.forwardRef((e, t) => {
const {
top: o,
prefixCls: n,
getContainer: a,
maxCount: s,
duration: d = sn,
rtl: f,
transitionName: c,
onAllRemoved: i
} = e, {
getPrefixCls: x,
getPopupContainer: m,
message: p,
direction: C
} = r.useContext(Ce), b = n || x("message"), v = () => ({
left: "50%",
transform: "translateX(-50%)",
top: o != null ? o : rn
}), y = () => z({
[`${b}-rtl`]: f != null ? f : C === "rtl"
}), I = () => on(b, c), k = /* @__PURE__ */ r.createElement("span", {
className: `${b}-close-x`
}, /* @__PURE__ */ r.createElement(xt, {
className: `${b}-close-icon`
})), [O, P] = Yt({
prefixCls: b,
style: v,
className: y,
motion: I,
closable: !1,
closeIcon: k,
duration: d,
getContainer: () => (a == null ? void 0 : a()) || (m == null ? void 0 : m()) || document.body,
maxCount: s,
onAllRemoved: i,
renderNotifications: ln
});
return r.useImperativeHandle(t, () => Object.assign(Object.assign({}, O), {
prefixCls: b,
message: p
})), P;
});
let Re = 0;
function De(e) {
const t = r.useRef(null);
return et(), [r.useMemo(() => {
const n = (c) => {
var i;
(i = t.current) === null || i === void 0 || i.close(c);
}, a = (c) => {
if (!t.current) {
const E = () => {
};
return E.then = () => {
}, E;
}
const {
open: i,
prefixCls: x,
message: m
} = t.current, p = `${x}-notice`, {
content: C,
icon: b,
type: v,
key: y,
className: I,
style: k,
onClose: O
} = c, P = an(c, ["content", "icon", "type", "key", "className", "style", "onClose"]);
let N = y;
return N == null && (Re += 1, N = `antd-message-${Re}`), ye((E) => (i(Object.assign(Object.assign({}, P), {
key: N,
content: /* @__PURE__ */ r.createElement(_e, {
prefixCls: x,
type: v,
icon: b
}, C),
placement: "top",
className: z(v && `${p}-${v}`, I, m == null ? void 0 : m.className),
style: Object.assign(Object.assign({}, m == null ? void 0 : m.style), k),
onClose: () => {
O == null || O(), E();
}
})), () => {
n(N);
}));
}, d = {
open: a,
destroy: (c) => {
var i;
c !== void 0 ? n(c) : (i = t.current) === null || i === void 0 || i.destroy();
}
};
return ["info", "success", "warning", "error", "loading"].forEach((c) => {
const i = (x, m, p) => {
let C;
x && typeof x == "object" && "content" in x ? C = x : C = {
content: x
};
let b, v;
typeof m == "function" ? v = m : (b = m, v = p);
const y = Object.assign(Object.assign({
onClose: v,
duration: b
}, C), {
type: c
});
return a(y);
};
d[c] = i;
}), d;
}, []), /* @__PURE__ */ r.createElement(un, Object.assign({
key: "message-holder"
}, e, {
ref: t
}))];
}
function dn(e) {
return De(e);
}
const fn = /* @__PURE__ */ M.createContext({});
let L = null, W = (e) => e(), te = [], ne = {};
function $e() {
const {
getContainer: e,
duration: t,
rtl: o,
maxCount: n,
top: a
} = ne, s = (e == null ? void 0 : e()) || document.body;
return {
getContainer: () => s,
duration: t,
rtl: o,
maxCount: n,
top: a
};
}
const mn = /* @__PURE__ */ M.forwardRef((e, t) => {
const {
messageConfig: o,
sync: n
} = e, {
getPrefixCls: a
} = r.useContext(Ce), s = ne.prefixCls || a("message"), d = r.useContext(fn), [f, c] = De(Object.assign(Object.assign(Object.assign({}, o), {
prefixCls: s
}), d.message));
return M.useImperativeHandle(t, () => {
const i = Object.assign({}, f);
return Object.keys(i).forEach((x) => {
i[x] = (...m) => (n(), f[x].apply(f, m));
}), {
instance: i,
sync: n
};
}), c;
}), vn = /* @__PURE__ */ M.forwardRef((e, t) => {
const [o, n] = M.useState($e), a = () => {
n($e);
};
M.useEffect(a, []);
const s = ot(), d = s.getRootPrefixCls(), f = s.getIconPrefixCls(), c = s.getTheme(), i = /* @__PURE__ */ M.createElement(mn, {
ref: t,
sync: a,
messageConfig: o
});
return /* @__PURE__ */ M.createElement(nt, {
prefixCls: d,
iconPrefixCls: f,
theme: c
}, s.holderRender ? s.holderRender(i) : i);
});
function se() {
if (!L) {
const e = document.createDocumentFragment(), t = {
fragment: e
};
L = t, W(() => {
tt()(/* @__PURE__ */ M.createElement(vn, {
ref: (n) => {
const {
instance: a,
sync: s
} = n || {};
Promise.resolve().then(() => {
!t.instance && a && (t.instance = a, t.sync = s, se());
});
}
}), e);
});
return;
}
L.instance && (te.forEach((e) => {
const {
type: t,
skipped: o
} = e;
if (!o)
switch (t) {
case "open": {
W(() => {
const n = L.instance.open(Object.assign(Object.assign({}, ne), e.config));
n == null || n.then(e.resolve), e.setCloseFn(n);
});
break;
}
case "destroy":
W(() => {
L == null || L.instance.destroy(e.key);
});
break;
default:
W(() => {
var n;
const a = (n = L.instance)[t].apply(n, X(e.args));
a == null || a.then(e.resolve), e.setCloseFn(a);
});
}
}), te = []);
}
function gn(e) {
ne = Object.assign(Object.assign({}, ne), e), W(() => {
var t;
(t = L == null ? void 0 : L.sync) === null || t === void 0 || t.call(L);
});
}
function pn(e) {
const t = ye((o) => {
let n;
const a = {
type: "open",
config: e,
resolve: o,
setCloseFn: (s) => {
n = s;
}
};
return te.push(a), () => {
n ? W(() => {
n();
}) : a.skipped = !0;
};
});
return se(), t;
}
function Cn(e, t) {
const o = ye((n) => {
let a;
const s = {
type: e,
args: t,
resolve: n,
setCloseFn: (d) => {
a = d;
}
};
return te.push(s), () => {
a ? W(() => {
a();
}) : s.skipped = !0;
};
});
return se(), o;
}
const yn = (e) => {
te.push({
type: "destroy",
key: e
}), se();
}, hn = ["success", "info", "warning", "error", "loading"], xn = {
open: pn,
destroy: yn,
config: gn,
useMessage: dn,
_InternalPanelDoNotUseOrYouWillBeFired: nn
}, He = xn;
hn.forEach((e) => {
He[e] = (...t) => Cn(e, t);
});
const Me = He, En = ({ text: e, children: t }) => {
const o = () => Ee(void 0, null, function* () {
try {
yield navigator.clipboard.writeText(e), Me.success("复制成功!");
} catch (n) {
console.error("复制失败:", n), Me.error("复制失败,请手动复制");
}
});
return /* @__PURE__ */ be.jsx(
at,
{
icon: /* @__PURE__ */ be.jsx(Ot, {}),
onClick: o,
type: "primary",
style: { marginLeft: "8px" },
children: t || "复制"
}
);
}, Sn = rt(En, {
props: {
text: "string",
children: "string"
}
});
customElements.get("rwc-copy-button") || customElements.define("rwc-copy-button", Sn);
export {
En as CopyButton,
Sn as RwcCopyButton,
Sn as default
};
//# sourceMappingURL=copy-button.es.js.map