@camlin/react-confirm-modal
Version:
A customizable confirmation modal component built with React and Ant Design, allowing multiple buttons and callback actions.
31 lines (28 loc) • 14.1 kB
JavaScript
(function(g,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("react"),require("antd")):typeof define=="function"&&define.amd?define(["exports","react","antd"],P):(g=typeof globalThis<"u"?globalThis:g||self,P(g.ReactConfirmModal={},g.React,g.Antd))})(this,function(g,P,ee){"use strict";var B={exports:{}},F={};/**
* @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 re;function je(){if(re)return F;re=1;var I=P,b=Symbol.for("react.element"),W=Symbol.for("react.fragment"),E=Object.prototype.hasOwnProperty,w=I.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,_={key:!0,ref:!0,__self:!0,__source:!0};function m(T,l,j){var p,h={},O=null,$=null;j!==void 0&&(O=""+j),l.key!==void 0&&(O=""+l.key),l.ref!==void 0&&($=l.ref);for(p in l)E.call(l,p)&&!_.hasOwnProperty(p)&&(h[p]=l[p]);if(T&&T.defaultProps)for(p in l=T.defaultProps,l)h[p]===void 0&&(h[p]=l[p]);return{$$typeof:b,type:T,key:O,ref:$,props:h,_owner:w.current}}return F.Fragment=W,F.jsx=m,F.jsxs=m,F}var A={};/**
* @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 te;function xe(){return te||(te=1,process.env.NODE_ENV!=="production"&&function(){var I=P,b=Symbol.for("react.element"),W=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),T=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),$=Symbol.for("react.offscreen"),ne=Symbol.iterator,De="@@iterator";function Fe(e){if(e===null||typeof e!="object")return null;var r=ne&&e[ne]||e[De];return typeof r=="function"?r:null}var x=I.__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];Ae("error",e,t)}}function Ae(e,r,t){{var n=x.ReactDebugCurrentFrame,o=n.getStackAddendum();o!==""&&(r+="%s",t=t.concat([o]));var u=t.map(function(i){return String(i)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var Ie=!1,We=!1,Ye=!1,Me=!1,$e=!1,ae;ae=Symbol.for("react.module.reference");function Le(e){return!!(typeof e=="string"||typeof e=="function"||e===E||e===_||$e||e===w||e===j||e===p||Me||e===$||Ie||We||Ye||typeof e=="object"&&e!==null&&(e.$$typeof===O||e.$$typeof===h||e.$$typeof===m||e.$$typeof===T||e.$$typeof===l||e.$$typeof===ae||e.getModuleId!==void 0))}function Ve(e,r,t){var n=e.displayName;if(n)return n;var o=r.displayName||r.name||"";return o!==""?t+"("+o+")":t}function ie(e){return e.displayName||"Context"}function R(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 E:return"Fragment";case W:return"Portal";case _:return"Profiler";case w:return"StrictMode";case j:return"Suspense";case p:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case T:var r=e;return ie(r)+".Consumer";case m:var t=e;return ie(t._context)+".Provider";case l:return Ve(e,e.render,"ForwardRef");case h:var n=e.displayName||null;return n!==null?n:R(e.type)||"Memo";case O:{var o=e,u=o._payload,i=o._init;try{return R(i(u))}catch{return null}}}return null}var C=Object.assign,Y=0,oe,ue,se,fe,le,ce,de;function ve(){}ve.__reactDisabledLog=!0;function Ue(){{if(Y===0){oe=console.log,ue=console.info,se=console.warn,fe=console.error,le=console.group,ce=console.groupCollapsed,de=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Y++}}function Ne(){{if(Y--,Y===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:C({},e,{value:oe}),info:C({},e,{value:ue}),warn:C({},e,{value:se}),error:C({},e,{value:fe}),group:C({},e,{value:le}),groupCollapsed:C({},e,{value:ce}),groupEnd:C({},e,{value:de})})}Y<0&&c("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var q=x.ReactCurrentDispatcher,K;function L(e,r,t){{if(K===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);K=n&&n[1]||""}return`
`+K+e}}var G=!1,V;{var Be=typeof WeakMap=="function"?WeakMap:Map;V=new Be}function pe(e,r){if(!e||G)return"";{var t=V.get(e);if(t!==void 0)return t}var n;G=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=q.current,q.current=null,Ue();try{if(r){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(v){n=v}Reflect.construct(e,[],i)}else{try{i.call()}catch(v){n=v}e.call(i.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,f=d.length-1;s>=1&&f>=0&&a[s]!==d[f];)f--;for(;s>=1&&f>=0;s--,f--)if(a[s]!==d[f]){if(s!==1||f!==1)do if(s--,f--,f<0||a[s]!==d[f]){var y=`
`+a[s].replace(" at new "," at ");return e.displayName&&y.includes("<anonymous>")&&(y=y.replace("<anonymous>",e.displayName)),typeof e=="function"&&V.set(e,y),y}while(s>=1&&f>=0);break}}}finally{G=!1,q.current=u,Ne(),Error.prepareStackTrace=o}var D=e?e.displayName||e.name:"",S=D?L(D):"";return typeof e=="function"&&V.set(e,S),S}function Je(e,r,t){return pe(e,!1)}function qe(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function U(e,r,t){if(e==null)return"";if(typeof e=="function")return pe(e,qe(e));if(typeof e=="string")return L(e);switch(e){case j:return L("Suspense");case p:return L("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case l:return Je(e.render);case h:return U(e.type,r,t);case O:{var n=e,o=n._payload,u=n._init;try{return U(u(o),r,t)}catch{}}}return""}var M=Object.prototype.hasOwnProperty,ye={},he=x.ReactDebugCurrentFrame;function N(e){if(e){var r=e._owner,t=U(e.type,e._source,r?r.type:null);he.setExtraStackFrame(t)}else he.setExtraStackFrame(null)}function Ke(e,r,t,n,o){{var u=Function.call.bind(M);for(var i in e)if(u(e,i)){var a=void 0;try{if(typeof e[i]!="function"){var d=Error((n||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw d.name="Invariant Violation",d}a=e[i](r,i,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(s){a=s}a&&!(a instanceof Error)&&(N(o),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,i,typeof a),N(null)),a instanceof Error&&!(a.message in ye)&&(ye[a.message]=!0,N(o),c("Failed %s type: %s",t,a.message),N(null))}}}var Ge=Array.isArray;function z(e){return Ge(e)}function ze(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Xe(e){try{return ge(e),!1}catch{return!0}}function ge(e){return""+e}function Ee(e){if(Xe(e))return c("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ze(e)),ge(e)}var _e=x.ReactCurrentOwner,He={key:!0,ref:!0,__self:!0,__source:!0},Re,be;function Ze(e){if(M.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Qe(e){if(M.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function er(e,r){typeof e.ref=="string"&&_e.current}function rr(e,r){{var t=function(){Re||(Re=!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 tr(e,r){{var t=function(){be||(be=!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 nr=function(e,r,t,n,o,u,i){var a={$$typeof:b,type:e,key:r,ref:t,props:i,_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:o}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function ar(e,r,t,n,o){{var u,i={},a=null,d=null;t!==void 0&&(Ee(t),a=""+t),Qe(r)&&(Ee(r.key),a=""+r.key),Ze(r)&&(d=r.ref,er(r,o));for(u in r)M.call(r,u)&&!He.hasOwnProperty(u)&&(i[u]=r[u]);if(e&&e.defaultProps){var s=e.defaultProps;for(u in s)i[u]===void 0&&(i[u]=s[u])}if(a||d){var f=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&rr(i,f),d&&tr(i,f)}return nr(e,a,d,o,n,_e.current,i)}}var X=x.ReactCurrentOwner,me=x.ReactDebugCurrentFrame;function k(e){if(e){var r=e._owner,t=U(e.type,e._source,r?r.type:null);me.setExtraStackFrame(t)}else me.setExtraStackFrame(null)}var H;H=!1;function Z(e){return typeof e=="object"&&e!==null&&e.$$typeof===b}function Te(){{if(X.current){var e=R(X.current.type);if(e)return`
Check the render method of \``+e+"`."}return""}}function ir(e){return""}var Oe={};function or(e){{var r=Te();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 Ce(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=or(r);if(Oe[t])return;Oe[t]=!0;var n="";e&&e._owner&&e._owner!==X.current&&(n=" It was passed a child from "+R(e._owner.type)+"."),k(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),k(null)}}function Se(e,r){{if(typeof e!="object")return;if(z(e))for(var t=0;t<e.length;t++){var n=e[t];Z(n)&&Ce(n,r)}else if(Z(e))e._store&&(e._store.validated=!0);else if(e){var o=Fe(e);if(typeof o=="function"&&o!==e.entries)for(var u=o.call(e),i;!(i=u.next()).done;)Z(i.value)&&Ce(i.value,r)}}}function ur(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===l||r.$$typeof===h))t=r.propTypes;else return;if(t){var n=R(r);Ke(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!H){H=!0;var o=R(r);c("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",o||"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 sr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){k(e),c("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),k(null);break}}e.ref!==null&&(k(e),c("Invalid attribute `ref` supplied to `React.Fragment`."),k(null))}}var Pe={};function we(e,r,t,n,o,u){{var i=Le(e);if(!i){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=ir();d?a+=d:a+=Te();var s;e===null?s="null":z(e)?s="array":e!==void 0&&e.$$typeof===b?(s="<"+(R(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 f=ar(e,r,t,o,u);if(f==null)return f;if(i){var y=r.children;if(y!==void 0)if(n)if(z(y)){for(var D=0;D<y.length;D++)Se(y[D],e);Object.freeze&&Object.freeze(y)}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 Se(y,e)}if(M.call(r,"key")){var S=R(e),v=Object.keys(r).filter(function(pr){return pr!=="key"}),Q=v.length>0?"{key: someKey, "+v.join(": ..., ")+": ...}":"{key: someKey}";if(!Pe[S+Q]){var vr=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} />`,Q,S,vr,S),Pe[S+Q]=!0}}return e===E?sr(f):ur(f),f}}function fr(e,r,t){return we(e,r,t,!0)}function lr(e,r,t){return we(e,r,t,!1)}var cr=lr,dr=fr;A.Fragment=E,A.jsx=cr,A.jsxs=dr}()),A}process.env.NODE_ENV==="production"?B.exports=je():B.exports=xe();var J=B.exports;const ke=({open:I,title:b,content:W,footerButtons:E=[],onConfirm:w})=>J.jsx(ee.Modal,{open:I,title:b,footer:E.map((_,m)=>J.jsx(ee.Button,{type:_.type,onClick:_.onClick,children:_.text},m)),onOk:w,transitionName:"",maskTransitionName:"",children:J.jsx("p",{children:W})});g.ConfirmModal=ke,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});