@camlin/react-confirm-modal
Version:
A customizable confirmation modal component built with React and Ant Design, allowing multiple buttons and callback actions.
650 lines (647 loc) • 21.4 kB
JavaScript
import Se from "react";
import { Modal as fr, Button as cr } from "antd";
var H = { exports: {} }, I = {};
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Oe;
function dr() {
if (Oe) return I;
Oe = 1;
var k = Se, b = Symbol.for("react.element"), D = Symbol.for("react.fragment"), h = Object.prototype.hasOwnProperty, S = k.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, E = { key: !0, ref: !0, __self: !0, __source: !0 };
function R(m, f, P) {
var p, y = {}, T = null, W = null;
P !== void 0 && (T = "" + P), f.key !== void 0 && (T = "" + f.key), f.ref !== void 0 && (W = f.ref);
for (p in f) h.call(f, p) && !E.hasOwnProperty(p) && (y[p] = f[p]);
if (m && m.defaultProps) for (p in f = m.defaultProps, f) y[p] === void 0 && (y[p] = f[p]);
return { $$typeof: b, type: m, key: T, ref: W, props: y, _owner: S.current };
}
return I.Fragment = D, I.jsx = R, I.jsxs = R, I;
}
var $ = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Ce;
function vr() {
return Ce || (Ce = 1, process.env.NODE_ENV !== "production" && function() {
var k = Se, b = Symbol.for("react.element"), D = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), S = Symbol.for("react.strict_mode"), E = Symbol.for("react.profiler"), R = Symbol.for("react.provider"), m = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), p = Symbol.for("react.suspense_list"), y = Symbol.for("react.memo"), T = Symbol.for("react.lazy"), W = Symbol.for("react.offscreen"), Z = Symbol.iterator, Pe = "@@iterator";
function we(e) {
if (e === null || typeof e != "object")
return null;
var r = Z && e[Z] || e[Pe];
return typeof r == "function" ? r : null;
}
var w = k.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function c(e) {
{
for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
t[n - 1] = arguments[n];
je("error", e, t);
}
}
function je(e, r, t) {
{
var n = w.ReactDebugCurrentFrame, i = n.getStackAddendum();
i !== "" && (r += "%s", t = t.concat([i]));
var u = t.map(function(o) {
return String(o);
});
u.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, u);
}
}
var xe = !1, ke = !1, De = !1, Fe = !1, Ae = !1, Q;
Q = Symbol.for("react.module.reference");
function Ie(e) {
return !!(typeof e == "string" || typeof e == "function" || e === h || e === E || Ae || e === S || e === P || e === p || Fe || e === W || xe || ke || De || typeof e == "object" && e !== null && (e.$$typeof === T || e.$$typeof === y || e.$$typeof === R || e.$$typeof === m || e.$$typeof === f || // This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
// we don't know which Flight build this will end up being used
// with.
e.$$typeof === Q || e.getModuleId !== void 0));
}
function $e(e, r, t) {
var n = e.displayName;
if (n)
return n;
var i = r.displayName || r.name || "";
return i !== "" ? t + "(" + i + ")" : t;
}
function ee(e) {
return e.displayName || "Context";
}
function _(e) {
if (e == null)
return null;
if (typeof e.tag == "number" && c("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
return e.displayName || e.name || null;
if (typeof e == "string")
return e;
switch (e) {
case h:
return "Fragment";
case D:
return "Portal";
case E:
return "Profiler";
case S:
return "StrictMode";
case P:
return "Suspense";
case p:
return "SuspenseList";
}
if (typeof e == "object")
switch (e.$$typeof) {
case m:
var r = e;
return ee(r) + ".Consumer";
case R:
var t = e;
return ee(t._context) + ".Provider";
case f:
return $e(e, e.render, "ForwardRef");
case y:
var n = e.displayName || null;
return n !== null ? n : _(e.type) || "Memo";
case T: {
var i = e, u = i._payload, o = i._init;
try {
return _(o(u));
} catch {
return null;
}
}
}
return null;
}
var O = Object.assign, F = 0, re, te, ne, ae, oe, ie, ue;
function se() {
}
se.__reactDisabledLog = !0;
function We() {
{
if (F === 0) {
re = console.log, te = console.info, ne = console.warn, ae = console.error, oe = console.group, ie = console.groupCollapsed, ue = console.groupEnd;
var e = {
configurable: !0,
enumerable: !0,
value: se,
writable: !0
};
Object.defineProperties(console, {
info: e,
log: e,
warn: e,
error: e,
group: e,
groupCollapsed: e,
groupEnd: e
});
}
F++;
}
}
function Ye() {
{
if (F--, F === 0) {
var e = {
configurable: !0,
enumerable: !0,
writable: !0
};
Object.defineProperties(console, {
log: O({}, e, {
value: re
}),
info: O({}, e, {
value: te
}),
warn: O({}, e, {
value: ne
}),
error: O({}, e, {
value: ae
}),
group: O({}, e, {
value: oe
}),
groupCollapsed: O({}, e, {
value: ie
}),
groupEnd: O({}, e, {
value: ue
})
});
}
F < 0 && c("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
var U = w.ReactCurrentDispatcher, N;
function Y(e, r, t) {
{
if (N === void 0)
try {
throw Error();
} catch (i) {
var n = i.stack.trim().match(/\n( *(at )?)/);
N = n && n[1] || "";
}
return `
` + N + e;
}
}
var B = !1, M;
{
var Me = typeof WeakMap == "function" ? WeakMap : Map;
M = new Me();
}
function le(e, r) {
if (!e || B)
return "";
{
var t = M.get(e);
if (t !== void 0)
return t;
}
var n;
B = !0;
var i = Error.prepareStackTrace;
Error.prepareStackTrace = void 0;
var u;
u = U.current, U.current = null, We();
try {
if (r) {
var o = function() {
throw Error();
};
if (Object.defineProperty(o.prototype, "props", {
set: function() {
throw Error();
}
}), typeof Reflect == "object" && Reflect.construct) {
try {
Reflect.construct(o, []);
} catch (v) {
n = v;
}
Reflect.construct(e, [], o);
} else {
try {
o.call();
} catch (v) {
n = v;
}
e.call(o.prototype);
}
} else {
try {
throw Error();
} catch (v) {
n = v;
}
e();
}
} catch (v) {
if (v && n && typeof v.stack == "string") {
for (var a = v.stack.split(`
`), d = n.stack.split(`
`), s = a.length - 1, l = d.length - 1; s >= 1 && l >= 0 && a[s] !== d[l]; )
l--;
for (; s >= 1 && l >= 0; s--, l--)
if (a[s] !== d[l]) {
if (s !== 1 || l !== 1)
do
if (s--, l--, l < 0 || a[s] !== d[l]) {
var g = `
` + a[s].replace(" at new ", " at ");
return e.displayName && g.includes("<anonymous>") && (g = g.replace("<anonymous>", e.displayName)), typeof e == "function" && M.set(e, g), g;
}
while (s >= 1 && l >= 0);
break;
}
}
} finally {
B = !1, U.current = u, Ye(), Error.prepareStackTrace = i;
}
var x = e ? e.displayName || e.name : "", C = x ? Y(x) : "";
return typeof e == "function" && M.set(e, C), C;
}
function Le(e, r, t) {
return le(e, !1);
}
function Ve(e) {
var r = e.prototype;
return !!(r && r.isReactComponent);
}
function L(e, r, t) {
if (e == null)
return "";
if (typeof e == "function")
return le(e, Ve(e));
if (typeof e == "string")
return Y(e);
switch (e) {
case P:
return Y("Suspense");
case p:
return Y("SuspenseList");
}
if (typeof e == "object")
switch (e.$$typeof) {
case f:
return Le(e.render);
case y:
return L(e.type, r, t);
case T: {
var n = e, i = n._payload, u = n._init;
try {
return L(u(i), r, t);
} catch {
}
}
}
return "";
}
var A = Object.prototype.hasOwnProperty, fe = {}, ce = w.ReactDebugCurrentFrame;
function V(e) {
if (e) {
var r = e._owner, t = L(e.type, e._source, r ? r.type : null);
ce.setExtraStackFrame(t);
} else
ce.setExtraStackFrame(null);
}
function Ue(e, r, t, n, i) {
{
var u = Function.call.bind(A);
for (var o in e)
if (u(e, o)) {
var a = void 0;
try {
if (typeof e[o] != "function") {
var d = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
throw d.name = "Invariant Violation", d;
}
a = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (s) {
a = s;
}
a && !(a instanceof Error) && (V(i), c("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), V(null)), a instanceof Error && !(a.message in fe) && (fe[a.message] = !0, V(i), c("Failed %s type: %s", t, a.message), V(null));
}
}
}
var Ne = Array.isArray;
function J(e) {
return Ne(e);
}
function Be(e) {
{
var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
return t;
}
}
function Je(e) {
try {
return de(e), !1;
} catch {
return !0;
}
}
function de(e) {
return "" + e;
}
function ve(e) {
if (Je(e))
return c("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Be(e)), de(e);
}
var pe = w.ReactCurrentOwner, qe = {
key: !0,
ref: !0,
__self: !0,
__source: !0
}, ge, ye;
function Ke(e) {
if (A.call(e, "ref")) {
var r = Object.getOwnPropertyDescriptor(e, "ref").get;
if (r && r.isReactWarning)
return !1;
}
return e.ref !== void 0;
}
function Ge(e) {
if (A.call(e, "key")) {
var r = Object.getOwnPropertyDescriptor(e, "key").get;
if (r && r.isReactWarning)
return !1;
}
return e.key !== void 0;
}
function ze(e, r) {
typeof e.ref == "string" && pe.current;
}
function Xe(e, r) {
{
var t = function() {
ge || (ge = !0, c("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
};
t.isReactWarning = !0, Object.defineProperty(e, "key", {
get: t,
configurable: !0
});
}
}
function He(e, r) {
{
var t = function() {
ye || (ye = !0, c("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
};
t.isReactWarning = !0, Object.defineProperty(e, "ref", {
get: t,
configurable: !0
});
}
}
var Ze = function(e, r, t, n, i, u, o) {
var a = {
// This tag allows us to uniquely identify this as a React Element
$$typeof: b,
// Built-in properties that belong on the element
type: e,
key: r,
ref: t,
props: o,
// Record the component responsible for creating this element.
_owner: u
};
return a._store = {}, Object.defineProperty(a._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: !1
}), Object.defineProperty(a, "_self", {
configurable: !1,
enumerable: !1,
writable: !1,
value: n
}), Object.defineProperty(a, "_source", {
configurable: !1,
enumerable: !1,
writable: !1,
value: i
}), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
};
function Qe(e, r, t, n, i) {
{
var u, o = {}, a = null, d = null;
t !== void 0 && (ve(t), a = "" + t), Ge(r) && (ve(r.key), a = "" + r.key), Ke(r) && (d = r.ref, ze(r, i));
for (u in r)
A.call(r, u) && !qe.hasOwnProperty(u) && (o[u] = r[u]);
if (e && e.defaultProps) {
var s = e.defaultProps;
for (u in s)
o[u] === void 0 && (o[u] = s[u]);
}
if (a || d) {
var l = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
a && Xe(o, l), d && He(o, l);
}
return Ze(e, a, d, i, n, pe.current, o);
}
}
var q = w.ReactCurrentOwner, he = w.ReactDebugCurrentFrame;
function j(e) {
if (e) {
var r = e._owner, t = L(e.type, e._source, r ? r.type : null);
he.setExtraStackFrame(t);
} else
he.setExtraStackFrame(null);
}
var K;
K = !1;
function G(e) {
return typeof e == "object" && e !== null && e.$$typeof === b;
}
function Ee() {
{
if (q.current) {
var e = _(q.current.type);
if (e)
return `
Check the render method of \`` + e + "`.";
}
return "";
}
}
function er(e) {
return "";
}
var _e = {};
function rr(e) {
{
var r = Ee();
if (!r) {
var t = typeof e == "string" ? e : e.displayName || e.name;
t && (r = `
Check the top-level render call using <` + t + ">.");
}
return r;
}
}
function be(e, r) {
{
if (!e._store || e._store.validated || e.key != null)
return;
e._store.validated = !0;
var t = rr(r);
if (_e[t])
return;
_e[t] = !0;
var n = "";
e && e._owner && e._owner !== q.current && (n = " It was passed a child from " + _(e._owner.type) + "."), j(e), c('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), j(null);
}
}
function Re(e, r) {
{
if (typeof e != "object")
return;
if (J(e))
for (var t = 0; t < e.length; t++) {
var n = e[t];
G(n) && be(n, r);
}
else if (G(e))
e._store && (e._store.validated = !0);
else if (e) {
var i = we(e);
if (typeof i == "function" && i !== e.entries)
for (var u = i.call(e), o; !(o = u.next()).done; )
G(o.value) && be(o.value, r);
}
}
}
function tr(e) {
{
var r = e.type;
if (r == null || typeof r == "string")
return;
var t;
if (typeof r == "function")
t = r.propTypes;
else if (typeof r == "object" && (r.$$typeof === f || // Note: Memo only checks outer props here.
// Inner props are checked in the reconciler.
r.$$typeof === y))
t = r.propTypes;
else
return;
if (t) {
var n = _(r);
Ue(t, e.props, "prop", n, e);
} else if (r.PropTypes !== void 0 && !K) {
K = !0;
var i = _(r);
c("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i || "Unknown");
}
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && c("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
}
}
function nr(e) {
{
for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
var n = r[t];
if (n !== "children" && n !== "key") {
j(e), c("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), j(null);
break;
}
}
e.ref !== null && (j(e), c("Invalid attribute `ref` supplied to `React.Fragment`."), j(null));
}
}
var me = {};
function Te(e, r, t, n, i, u) {
{
var o = Ie(e);
if (!o) {
var a = "";
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
var d = er();
d ? a += d : a += Ee();
var s;
e === null ? s = "null" : J(e) ? s = "array" : e !== void 0 && e.$$typeof === b ? (s = "<" + (_(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : s = typeof e, c("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", s, a);
}
var l = Qe(e, r, t, i, u);
if (l == null)
return l;
if (o) {
var g = r.children;
if (g !== void 0)
if (n)
if (J(g)) {
for (var x = 0; x < g.length; x++)
Re(g[x], e);
Object.freeze && Object.freeze(g);
} else
c("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
else
Re(g, e);
}
if (A.call(r, "key")) {
var C = _(e), v = Object.keys(r).filter(function(lr) {
return lr !== "key";
}), z = v.length > 0 ? "{key: someKey, " + v.join(": ..., ") + ": ...}" : "{key: someKey}";
if (!me[C + z]) {
var sr = v.length > 0 ? "{" + v.join(": ..., ") + ": ...}" : "{}";
c(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`, z, C, sr, C), me[C + z] = !0;
}
}
return e === h ? nr(l) : tr(l), l;
}
}
function ar(e, r, t) {
return Te(e, r, t, !0);
}
function or(e, r, t) {
return Te(e, r, t, !1);
}
var ir = or, ur = ar;
$.Fragment = h, $.jsx = ir, $.jsxs = ur;
}()), $;
}
process.env.NODE_ENV === "production" ? H.exports = dr() : H.exports = vr();
var X = H.exports;
const yr = ({
open: k,
title: b,
content: D,
footerButtons: h = [],
onConfirm: S
}) => /* @__PURE__ */ X.jsx(
fr,
{
open: k,
title: b,
footer: h.map((E, R) => /* @__PURE__ */ X.jsx(cr, { type: E.type, onClick: E.onClick, children: E.text }, R)),
onOk: S,
transitionName: "",
maskTransitionName: "",
children: /* @__PURE__ */ X.jsx("p", { children: D })
}
);
export {
yr as ConfirmModal
};